import { m as m2 } from "./chunk-XWA3NEEY.js"; import { Y, se } from "./chunk-54X4RLMR.js"; import { s, s2 } from "./chunk-MWIFVNKP.js"; import "./chunk-LSDW2622.js"; import "./chunk-IQNZZCQJ.js"; import "./chunk-TODU7HVH.js"; import "./chunk-PZKZIMMP.js"; import "./chunk-YLVXZ2PS.js"; import "./chunk-WFSV2B2I.js"; import "./chunk-Q34L5KZA.js"; import { l as l2 } from "./chunk-AEFA3FTZ.js"; import { t } from "./chunk-Z6GWVH7Z.js"; import "./chunk-MFFE4I2S.js"; import "./chunk-XBH7TGC2.js"; import "./chunk-K3NA3LQS.js"; import { c as c3, i, m } from "./chunk-7SW2GQFP.js"; import { e as e2, n, r } from "./chunk-TRK7CKWP.js"; import "./chunk-EGVIPYN2.js"; import "./chunk-7IKYLNB5.js"; import "./chunk-6P6NA7JB.js"; import "./chunk-7256PFPA.js"; import { p } from "./chunk-EN7YGJWG.js"; import "./chunk-VBNMTM7L.js"; import "./chunk-3D3QEPRE.js"; import "./chunk-JFNNSBWL.js"; import "./chunk-522WBHUO.js"; import "./chunk-WNCU6BFU.js"; import "./chunk-C43UE3Z5.js"; import { l } from "./chunk-7XXXCK2A.js"; import "./chunk-7ZIDBK7B.js"; import "./chunk-65BYCSII.js"; import "./chunk-WZQZRKNH.js"; import "./chunk-LRDX4TO7.js"; import "./chunk-6A4U74YA.js"; import "./chunk-GJXW4HL5.js"; import "./chunk-WJW5DUN6.js"; import "./chunk-PJ7ZQ4VD.js"; import "./chunk-WDLTDV2L.js"; import "./chunk-TERAW6FT.js"; import "./chunk-N2663GRX.js"; import { e, u } from "./chunk-WEMIK25H.js"; import "./chunk-JXW4QTJA.js"; import "./chunk-UXF37FQ4.js"; import "./chunk-ZOEK6QHJ.js"; import "./chunk-XNLG7T2T.js"; import "./chunk-IR4PV7VK.js"; import { c as c2, v, y } from "./chunk-2Z6LERTI.js"; import "./chunk-OWVBLVP3.js"; import "./chunk-AFZ7XSEW.js"; import "./chunk-4NKD334K.js"; import "./chunk-65K7LC56.js"; import "./chunk-ATPLLI5W.js"; import "./chunk-WJ3OEUD3.js"; import "./chunk-MXB2XLKV.js"; import "./chunk-XH7RUGVZ.js"; import "./chunk-TBBTRX4O.js"; import "./chunk-YBSUITLL.js"; import "./chunk-ALDCDSPV.js"; import "./chunk-DT6EAZQ5.js"; import "./chunk-HNOZUNJ4.js"; import { U } from "./chunk-VNFRAYHO.js"; import "./chunk-R5IG2D6H.js"; import "./chunk-VBRY5KJM.js"; import "./chunk-PDKDCAAD.js"; import "./chunk-ECW2QABR.js"; import "./chunk-GCDJLKH4.js"; import "./chunk-MRJEICT6.js"; import "./chunk-Y3WMVFTW.js"; import "./chunk-SAS7RONY.js"; import "./chunk-WSRBH7BF.js"; import "./chunk-IHXECKQQ.js"; import { f } from "./chunk-ULGDPLM2.js"; import "./chunk-EMJ4ZSM2.js"; import { c } from "./chunk-IKP3YN53.js"; import "./chunk-GZT4BVFP.js"; import "./chunk-A5ICIBVI.js"; // node_modules/@arcgis/core/symbols/cim/CIMSymbolRasterizer.js var M; !function(e3) { e3.Legend = "legend", e3.Preview = "preview"; }(M || (M = {})); var C = (e3, t2, r3) => { if (e3 && e3.targetSize) { let i2; if (r3) { const t3 = Math.max(r3.frame.xmax - r3.frame.xmin, r3.frame.ymax - r3.frame.ymin); i2 = e3.targetSize / u(t3); } else i2 = e3.targetSize / t2.referenceSize; return i2; } return e3 && e3.scaleFactor ? e3.scaleFactor : 1; }; var I = { fill: { legend: { frame: { xmax: 15, xmin: 0, ymax: 15, ymin: 0 }, geometry: { rings: [[[0, 15], [15, 7.5], [15, 0], [0, 0], [0, 15]]] }, canvasPaths: { rings: [[[0, 15], [0, 0], [15, 7.5], [15, 15], [0, 15]]] } }, preview: { frame: { xmax: 100, xmin: 0, ymax: 100, ymin: 0 }, geometry: { rings: [[[0, 100], [100, 100], [100, 0], [0, 0], [0, 100]]] }, canvasPaths: { rings: [[[0, 100], [0, 0], [100, 0], [100, 100], [0, 100]]] } } }, stroke: { legend: { frame: { xmax: 24, xmin: 0, ymax: 2, ymin: -2 }, geometry: { paths: [[[0, 0], [12, 0], [24, 0]]] }, canvasPaths: { paths: [[[0, 2], [12, 2], [24, 2]]] } }, preview: { frame: { xmax: 100, xmin: 0, ymax: 2, ymin: -2 }, geometry: { paths: [[[0, 0], [50, 0], [100, 0]]] }, canvasPaths: { paths: [[[0, 2], [50, 2], [100, 2]]] } } } }; var z = class { constructor(e3, t2) { this._spatialReference = e3, this._avoidSDF = t2, this._resourceCache = new Map(), this._pictureMarkerCache = new Map(), this._textRasterizer = new s2(), this._cimResourceManager = new s(), this._rasterizer = new m2(this._cimResourceManager); } async rasterizeCIMSymbolAsync(e3, t2, r3, a, i2, o, n3, c4) { a = a || (t2 ? t2.centroid != null ? "esriGeometryPolygon" : v(t2.geometry) : null) || x(e3); const l3 = await this.analyzeCIMSymbol(e3, t2 ? P(t2.attributes) : null, r3, a, c4); return this.rasterizeCIMSymbol(l3, t2, a, i2, o, n3); } async analyzeCIMSymbol(e3, t2, a, i2, s4) { const o = [], n3 = t2 ? { geometryType: i2, spatialReference: this._spatialReference, fields: t2 } : null; let l3; await Y(e3.data, n3, this._cimResourceManager, o, this._avoidSDF), f(s4); for (const r3 of o) r3.cim.type !== "CIMPictureMarker" && r3.cim.type !== "CIMPictureFill" && r3.cim.type !== "CIMPictureStroke" || (l3 || (l3 = []), l3.push(this._fetchPictureMarkerResource(r3, s4))), a && r3.type === "text" && typeof r3.text == "string" && r3.text.includes("[") && (r3.text = n(a, r3.text, r3.cim.textCase)); return l3 && await Promise.all(l3), o; } async _fetchPictureMarkerResource(e3, r3) { const a = e3.materialHash; if (!this._pictureMarkerCache.get(a)) { const i2 = (await U(e3.cim.url, { responseType: "image", signal: r3 && r3.signal })).data; this._pictureMarkerCache.set(a, i2); } } rasterizeCIMSymbol(e3, t2, r3, a, i2, s4) { const o = []; for (const n3 of e3) { a && typeof a.scaleFactor == "function" && (a.scaleFactor = a.scaleFactor(t2, i2, s4)); const e4 = this._getRasterizedResource(n3, t2, r3, a, i2, s4); if (!e4) continue; let c4 = 0, l3 = e4.anchorX || 0, m3 = e4.anchorY || 0, h = false, f2 = 0, g = 0; if (r3 === "esriGeometryPoint") { const e5 = C(a, n3, null); if (f2 = e2(n3.offsetX, t2, i2, s4) * e5 || 0, g = e2(n3.offsetY, t2, i2, s4) * e5 || 0, n3.type === "marker") c4 = e2(n3.rotation, t2, i2, s4) || 0, h = !!n3.rotateClockwise && n3.rotateClockwise; else if (n3.type === "text") { if (c4 = e2(n3.angle, t2, i2, s4) || 0, n3.horizontalAlignment !== void 0) switch (n3.horizontalAlignment) { case "left": l3 = -0.5; break; case "right": l3 = 0.5; break; default: l3 = 0; } if (n3.verticalAlignment !== void 0) switch (n3.verticalAlignment) { case "top": m3 = 0.5; break; case "bottom": m3 = -0.5; break; case "baseline": m3 = -0.25; break; default: m3 = 0; } } } e4 != null && o.push({ angle: c4, rotateClockWise: h, anchorX: l3, anchorY: m3, offsetX: f2, offsetY: g, rasterizedResource: e4 }); } return this.getSymbolImage(o); } getSymbolImage(e3) { const t2 = document.createElement("canvas"), r3 = t2.getContext("2d"); let i2 = 0, s4 = 0, o = 0, n3 = 0; const c4 = []; for (let f2 = 0; f2 < e3.length; f2++) { const t3 = e3[f2], l4 = t3.rasterizedResource; if (!l4) continue; const m4 = l4.size, h2 = t3.offsetX, g = t3.offsetY, u2 = t3.anchorX, y2 = t3.anchorY, p2 = t3.rotateClockWise || false; let d = t3.angle, M2 = u(h2) - m4[0] * (0.5 + u2), C2 = u(g) - m4[1] * (0.5 + y2), I2 = M2 + m4[0], z2 = C2 + m4[1]; if (d) { p2 && (d = -d); const e4 = Math.sin(d * Math.PI / 180), t4 = Math.cos(d * Math.PI / 180), r4 = M2 * t4 - C2 * e4, a = M2 * e4 + C2 * t4, i3 = M2 * t4 - z2 * e4, s5 = M2 * e4 + z2 * t4, o2 = I2 * t4 - z2 * e4, n4 = I2 * e4 + z2 * t4, c5 = I2 * t4 - C2 * e4, l5 = I2 * e4 + C2 * t4; M2 = Math.min(r4, i3, o2, c5), C2 = Math.min(a, s5, n4, l5), I2 = Math.max(r4, i3, o2, c5), z2 = Math.max(a, s5, n4, l5); } i2 = M2 < i2 ? M2 : i2, s4 = C2 < s4 ? C2 : s4, o = I2 > o ? I2 : o, n3 = z2 > n3 ? z2 : n3; const P2 = r3.createImageData(l4.size[0], l4.size[1]); P2.data.set(new Uint8ClampedArray(l4.image.buffer)); const x2 = { offsetX: h2, offsetY: g, rotateClockwise: p2, angle: d, rasterizedImage: P2, anchorX: u2, anchorY: y2 }; c4.push(x2); } t2.width = o - i2, t2.height = n3 - s4; const l3 = -i2, m3 = n3; for (let f2 = 0; f2 < c4.length; f2++) { const e4 = c4[f2], t3 = this._imageDataToCanvas(e4.rasterizedImage), i3 = e4.rasterizedImage.width, s5 = e4.rasterizedImage.height, o2 = l3 - i3 * (0.5 + e4.anchorX), n4 = m3 - s5 * (0.5 - e4.anchorY); if (e4.angle) { const i4 = (360 - e4.angle) * Math.PI / 180; r3.save(), r3.translate(u(e4.offsetX), -u(e4.offsetY)), r3.translate(l3, m3), r3.rotate(i4), r3.translate(-l3, -m3), r3.drawImage(t3, o2, n4), r3.restore(); } else r3.drawImage(t3, o2 + u(e4.offsetX), n4 - u(e4.offsetY)); } const h = new p({ x: l3 / t2.width - 0.5, y: m3 / t2.height - 0.5 }); return { imageData: t2.width !== 0 && t2.height !== 0 ? r3.getImageData(0, 0, t2.width, t2.height) : r3.createImageData(1, 1), anchorPosition: h }; } _imageDataToCanvas(e3) { this._imageDataCanvas || (this._imageDataCanvas = document.createElement("canvas")); const t2 = this._imageDataCanvas, r3 = t2.getContext("2d"); return t2.width = e3.width, t2.height = e3.height, r3.putImageData(e3, 0, 0), t2; } _imageTo32Array(t2, r3, a, i2) { this._imageDataCanvas || (this._imageDataCanvas = document.createElement("canvas")); const s4 = this._imageDataCanvas, o = s4.getContext("2d"); if (s4.width = r3, s4.height = a, o.drawImage(t2, 0, 0, r3, a), i2) { o.save(); const s5 = new l(i2); o.fillStyle = s5.toHex(), o.globalCompositeOperation = "multiply", o.fillRect(0, 0, r3, a), o.globalCompositeOperation = "destination-atop", o.drawImage(t2, 0, 0, r3, a), o.restore(); } return new Uint32Array(o.getImageData(0, 0, r3, a).data.buffer); } _getRasterizedResource(e3, t2, r3, a, s4, o) { let n3, c4, l3, m3, h = null, f2 = null; if (r3 === "esriGeometryPolyline" || r3 === "esriGeometryPolygon") { const m4 = a && a.style ? a.style : M.Legend, g2 = r3 === "esriGeometryPolyline" ? I.stroke[m4] : I.fill[m4]; if (e3.type === "line") { if (e3.cim.type !== "CIMSolidStroke") { if (e3.cim.type === "CIMPictureStroke") { const r4 = e2(e3.width, t2, s4, o), a2 = e2(e3.color, t2, s4, o), { image: i2, width: n4, height: c5 } = this._getPictureResource(e3, r4, a2); return this._rasterizePictureResource(e3, i2, n4, c5, g2, r4); } return null; } ({ analyzedCIM: n3, hash: l3 } = w(e3, t2, s4, o)), c4 = this._embedCIMLayerInVectorMarker(n3, g2); } else if (e3.type === "marker") { if (e3.cim.type === "CIMPictureMarker") { const r4 = e2(e3.size, t2, s4, o), a2 = e2(e3.color, t2, s4, o), { image: i2, width: n4, height: c5 } = this._getPictureResource(e3, r4, a2); return this._rasterizePictureResource(e3, i2, n4, c5, g2, r4); } if (e3.cim.type !== "CIMVectorMarker") return null; e3.cim.offsetX = e2(e3.offsetX, t2, s4, o), e3.cim.offsetY = e2(e3.offsetY, t2, s4, o), e3.cim.rotation = e2(e3.rotation, t2, s4, o), e3.cim.markerPlacement = e3.markerPlacement, { analyzedCIM: n3 } = w(e3, t2, s4, o), l3 = c(JSON.stringify(n3)).toString(), c4 = this._embedCIMLayerInVectorMarker(n3, g2), h = e2(e3.size, t2, s4, o), f2 = e3.path; } else { if (e3.type === "text") return null; if (e3.type === "fill") { if (e3.cim.type === "CIMHatchFill" || e3.cim.type === "CIMVectorMarker" || e3.cim.type === "CIMPictureMarker" || e3.cim.type === "CIMPictureFill") { const r4 = e3.cim.size || e3.cim.height; let a2, i2, c5; if (e3.cim.type === "CIMPictureMarker" || e3.cim.type === "CIMPictureFill") ({ image: a2, width: i2, height: c5 } = this._getPictureResource(e3, r4, e2(e3.color, t2, s4, o))); else { ({ analyzedCIM: n3, hash: l3 } = w(e3, t2, s4, o)); const m5 = this._rasterizer.rasterizeJSONResource({ cim: n3, type: e3.type, url: e3.url, mosaicHash: l3, size: r4, path: f2 }, 1, this._avoidSDF); a2 = m5.image, i2 = m5.size[0], c5 = m5.size[1]; } return this._rasterizePictureResource(e3, a2, i2, c5, g2, null); } if (e3.cim.type !== "CIMSolidFill") return null; ({ analyzedCIM: n3, hash: l3 } = w(e3, t2, s4, o)), c4 = this._embedCIMLayerInVectorMarker(n3, g2); } } } else { if (e3.type === "text") return m3 = this._rasterizeTextResource(e3, t2, a, s4, o), m3; ({ analyzedCIM: n3, hash: l3 } = w(e3, t2, s4, o)); const r4 = C(a, e3, null); if (e3.cim.type === "CIMPictureMarker") { const a2 = e2(e3.size, t2, s4, o) * r4, { image: i2, width: n4, height: c5 } = this._getPictureResource(e3, a2, e2(e3.color, t2, s4, o)); return m3 = { image: i2, size: [n4, c5], sdf: false, simplePattern: false, anchorX: e3.anchorPoint ? e3.anchorPoint.x : 0, anchorY: e3.anchorPoint ? e3.anchorPoint.y : 0 }, m3; } m(n3, r4, { preserveOutlineWidth: false }), c4 = n3; } l3 += r3, a && (l3 += JSON.stringify(a)); const g = this._resourceCache; return g.has(l3) ? g.get(l3) : (m3 = this._rasterizer.rasterizeJSONResource({ cim: c4, type: e3.type, url: e3.url, mosaicHash: l3, size: h, path: f2 }, window.devicePixelRatio || 1, this._avoidSDF), g.set(l3, m3), m3); } _rasterizeTextResource(e3, t2, r3, a, i2) { const s4 = C(r3, e3, null), o = e2(e3.text, t2, a, i2); if (!o || o.length === 0) return null; const n3 = e2(e3.fontName, t2, a, i2), c4 = e2(e3.style, t2, a, i2), l3 = e2(e3.weight, t2, a, i2), m3 = e2(e3.decoration, t2, a, i2), h = e2(e3.size, t2, a, i2) * s4, f2 = e2(e3.horizontalAlignment, t2, a, i2), g = e2(e3.verticalAlignment, t2, a, i2), p2 = r(e2(e3.color, t2, a, i2)), d = r(e2(e3.outlineColor, t2, a, i2)), M2 = { color: p2, size: h, horizontalAlignment: f2, verticalAlignment: g, font: { family: n3, style: c4, weight: l3, decoration: m3 }, halo: { size: e2(e3.outlineSize, t2, a, i2) || 0, color: d, style: c4 }, pixelRatio: 1, premultiplyColors: !this._avoidSDF }; return this._textRasterizer.rasterizeText(o, M2); } _rasterizePictureResource(e3, t2, r3, i2, s4, c4) { const l3 = document.createElement("canvas"), m3 = l3.getContext("2d"); l3.height = u(Math.max(s4.frame.ymax - s4.frame.ymin, c4)), l3.width = u(s4.frame.xmax - s4.frame.xmin); const h = m3.createImageData(r3, i2); h.data.set(new Uint8ClampedArray(t2.buffer)); const f2 = this._imageDataToCanvas(h), g = m3.createPattern(f2, "repeat"), u2 = Math.cos((-e3.cim.rotation || 0) * Math.PI / 180), y2 = Math.sin((-e3.cim.rotation || 0) * Math.PI / 180); g.setTransform({ m11: u2, m12: y2, m21: -y2, m22: u2, m41: u(e3.cim.offsetX) || 0, m42: u(e3.cim.offsetY) || 0 }); const p2 = s4.canvasPaths; let d, M2, C2; c2(p2) ? (d = p2.rings, m3.fillStyle = g, M2 = m3.fill, C2 = ["evenodd"]) : y(p2) && (d = p2.paths, m3.strokeStyle = g, m3.lineWidth = c4, M2 = m3.stroke, d[0][0][1] = l3.height / 2, d[0][1][1] = l3.height / 2), m3.beginPath(); for (const o of d) { const e4 = o ? o.length : 0; if (e4 > 1) { let t3 = o[0]; m3.moveTo(u(t3[0]), u(t3[1])); for (let r4 = 1; r4 < e4; ++r4) t3 = o[r4], m3.lineTo(u(t3[0]), u(t3[1])); m3.closePath(); } } M2.apply(m3, C2); const I2 = m3.getImageData(0, 0, l3.width, l3.height), z2 = new Uint8Array(I2.data); return { size: [l3.width, l3.height], image: new Uint32Array(z2.buffer), sdf: false, simplePattern: false, anchorX: 0, anchorY: 0 }; } _getPictureResource(e3, t2, r3) { const i2 = this._pictureMarkerCache.get(e3.materialHash); if (!i2) return null; const s4 = i2.height / i2.width, o = t2 ? s4 > 1 ? u(t2) : u(t2) / s4 : i2.width, n3 = t2 ? s4 > 1 ? u(t2) * s4 : u(t2) : i2.height; return { image: this._imageTo32Array(i2, o, n3, r3), width: o, height: n3 }; } _embedCIMLayerInVectorMarker(e3, t2) { const r3 = c2(t2.geometry) ? "CIMPolygonSymbol" : "CIMLineSymbol", a = t2.frame; return { type: "CIMVectorMarker", frame: a, size: a.ymax - a.ymin, markerGraphics: [{ type: "CIMMarkerGraphic", geometry: t2.geometry, symbol: { type: r3, symbolLayers: [e3] } }] }; } }; function P(e3) { return (e3 ? Object.keys(e3) : []).map((t2) => ({ name: t2, alias: t2, type: typeof e3[t2] == "string" ? "esriFieldTypeString" : "esriFieldTypeDouble" })); } function x(e3) { if (!(e3 && e3.data && e3.data.symbol)) return null; switch (e3.data.symbol.type) { case "CIMPointSymbol": case "CIMTextSymbol": return "esriGeometryPoint"; case "CIMLineSymbol": return "esriGeometryPolyline"; case "CIMPolygonSymbol": return "esriGeometryPolygon"; default: return null; } } function w(e3, t2, r3, a) { let i2, s4; if (typeof e3.materialHash == "function") { i2 = (0, e3.materialHash)(t2, r3, a), s4 = se(e3.cim, e3.materialOverrides); } else i2 = e3.materialHash, s4 = e3.cim; return { analyzedCIM: s4, hash: i2 }; } // node_modules/@arcgis/core/symbols/support/previewCIMSymbol.js var s3 = new z(null, true); var n2 = t.maxSize; async function r2(t2, a = {}) { const { size: r3, maxSize: c4, node: m3, opacity: f2 } = a, p2 = a.cimOptions || a, { feature: y2, fieldMap: h, geometryType: u2, style: d } = p2, g = i(t2), w2 = typeof r3 == "number" ? r3 : null, b = Math.min(w2 != null ? w2 : g, c4 != null ? c4 : e(n2)); b !== g && (t2 = t2.clone(), c3(t2, b, { preserveOutlineWidth: true })); let M2 = 3; t2 && t2.data && t2.data.symbol && t2.data.symbol.type !== "CIMPointSymbol" && (M2 = 1); const S = await s3.rasterizeCIMSymbolAsync(t2, y2, h, u2, { scaleFactor: M2, style: d }), j = document.createElement("canvas"); j.width = S.imageData.width, j.height = S.imageData.height; j.getContext("2d").putImageData(S.imageData, 0, 0); let x2 = j.width / M2, z2 = j.height / M2; if (r3 != null && (a?.scale == null || a?.scale)) { const e3 = x2 / z2; x2 = e3 <= 1 ? Math.ceil(b * e3) : b, z2 = e3 <= 1 ? b : Math.ceil(b / e3); } const C2 = new Image(x2, z2); C2.src = j.toDataURL(), f2 != null && (C2.style.opacity = `${f2}`); let D = C2; if (a.effectView != null) { const e3 = { shape: { type: "image", x: 0, y: 0, width: x2, height: z2, src: C2.src }, fill: null, stroke: null, offset: [0, 0] }; D = l2([[e3]], [x2, z2], { effectView: a.effectView }); } return m3 && m3.appendChild(D), D; } export { r2 as previewCIMSymbol }; //# sourceMappingURL=previewCIMSymbol-BW3KYEB2.js.map