previewSymbol2D-P5PKM6M4.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import {
  2. l as l2
  3. } from "./chunk-AEFA3FTZ.js";
  4. import {
  5. d,
  6. e as e2,
  7. t
  8. } from "./chunk-Z6GWVH7Z.js";
  9. import "./chunk-XBH7TGC2.js";
  10. import "./chunk-K3NA3LQS.js";
  11. import {
  12. b,
  13. j,
  14. w
  15. } from "./chunk-7SW2GQFP.js";
  16. import "./chunk-TRK7CKWP.js";
  17. import "./chunk-EGVIPYN2.js";
  18. import "./chunk-7IKYLNB5.js";
  19. import "./chunk-7256PFPA.js";
  20. import "./chunk-EN7YGJWG.js";
  21. import "./chunk-VBNMTM7L.js";
  22. import "./chunk-3D3QEPRE.js";
  23. import "./chunk-JFNNSBWL.js";
  24. import "./chunk-522WBHUO.js";
  25. import "./chunk-WNCU6BFU.js";
  26. import "./chunk-C43UE3Z5.js";
  27. import {
  28. l
  29. } from "./chunk-7XXXCK2A.js";
  30. import "./chunk-7ZIDBK7B.js";
  31. import "./chunk-65BYCSII.js";
  32. import "./chunk-WZQZRKNH.js";
  33. import "./chunk-LRDX4TO7.js";
  34. import "./chunk-6A4U74YA.js";
  35. import "./chunk-GJXW4HL5.js";
  36. import "./chunk-WJW5DUN6.js";
  37. import "./chunk-PJ7ZQ4VD.js";
  38. import "./chunk-WDLTDV2L.js";
  39. import "./chunk-TERAW6FT.js";
  40. import "./chunk-N2663GRX.js";
  41. import {
  42. e,
  43. u
  44. } from "./chunk-WEMIK25H.js";
  45. import "./chunk-JXW4QTJA.js";
  46. import "./chunk-UXF37FQ4.js";
  47. import "./chunk-ZOEK6QHJ.js";
  48. import "./chunk-XNLG7T2T.js";
  49. import "./chunk-IR4PV7VK.js";
  50. import "./chunk-2Z6LERTI.js";
  51. import "./chunk-OWVBLVP3.js";
  52. import "./chunk-AFZ7XSEW.js";
  53. import "./chunk-4NKD334K.js";
  54. import "./chunk-65K7LC56.js";
  55. import "./chunk-ATPLLI5W.js";
  56. import "./chunk-WJ3OEUD3.js";
  57. import "./chunk-MXB2XLKV.js";
  58. import "./chunk-XH7RUGVZ.js";
  59. import "./chunk-TBBTRX4O.js";
  60. import "./chunk-YBSUITLL.js";
  61. import "./chunk-ALDCDSPV.js";
  62. import "./chunk-DT6EAZQ5.js";
  63. import "./chunk-HNOZUNJ4.js";
  64. import "./chunk-VNFRAYHO.js";
  65. import "./chunk-R5IG2D6H.js";
  66. import "./chunk-VBRY5KJM.js";
  67. import "./chunk-PDKDCAAD.js";
  68. import "./chunk-ECW2QABR.js";
  69. import "./chunk-GCDJLKH4.js";
  70. import "./chunk-MRJEICT6.js";
  71. import "./chunk-Y3WMVFTW.js";
  72. import "./chunk-SAS7RONY.js";
  73. import "./chunk-WSRBH7BF.js";
  74. import "./chunk-IHXECKQQ.js";
  75. import "./chunk-ULGDPLM2.js";
  76. import {
  77. s3 as s
  78. } from "./chunk-EMJ4ZSM2.js";
  79. import "./chunk-IKP3YN53.js";
  80. import "./chunk-GZT4BVFP.js";
  81. import "./chunk-A5ICIBVI.js";
  82. // node_modules/@arcgis/core/views/support/colorUtils.js
  83. function e3(r2) {
  84. let { r: n, g: a, b: o, a: e4 } = r2;
  85. return e4 < 1 && (n = Math.round(e4 * n + 255 * (1 - e4)), a = Math.round(e4 * a + 255 * (1 - e4)), o = Math.round(e4 * o + 255 * (1 - e4))), new l({ r: n, g: a, b: o });
  86. }
  87. function u2(t2) {
  88. const { r: r2, g: n, b: a } = e3(t2);
  89. return 0.2126 * r2 + 0.7152 * n + 0.0722 * a;
  90. }
  91. // node_modules/@arcgis/core/symbols/support/previewSymbol2D.js
  92. var h = "picture-fill";
  93. var p = "picture-marker";
  94. var d2 = "simple-fill";
  95. var f = "simple-line";
  96. var y = "simple-marker";
  97. var v = "text";
  98. var w2 = "Aa";
  99. var g = t.size;
  100. var b2 = t.maxSize;
  101. var M = t.maxOutlineSize;
  102. var k = t.lineWidth;
  103. var x = 225;
  104. var z = document.createElement("canvas");
  105. function L(e4, t2) {
  106. const a = z.getContext("2d"), n = [];
  107. return t2 && (t2.weight && n.push(t2.weight), t2.size && n.push(t2.size + "px"), t2.family && n.push(t2.family)), a.font = n.join(" "), a.measureText(e4).width;
  108. }
  109. var j2 = 7.2 / 2.54;
  110. var C = 72 / 2.54;
  111. function S(e4) {
  112. if (e4.length === 0)
  113. return 0;
  114. if (e4.length > 2) {
  115. const t2 = e(1), a = parseFloat(e4);
  116. switch (e4.slice(-2)) {
  117. case "px":
  118. return a;
  119. case "pt":
  120. return a * t2;
  121. case "in":
  122. return 72 * a * t2;
  123. case "pc":
  124. return 12 * a * t2;
  125. case "mm":
  126. return a * j2 * t2;
  127. case "cm":
  128. return a * C * t2;
  129. }
  130. }
  131. return parseFloat(e4);
  132. }
  133. function F(e4) {
  134. const t2 = e4?.size;
  135. return { width: t2 != null && typeof t2 == "object" && "width" in t2 ? u(t2.width) : null, height: t2 != null && typeof t2 == "object" && "height" in t2 ? u(t2.height) : null };
  136. }
  137. async function U(e4, t2) {
  138. const a = t2.fill, n = e4.color;
  139. if (a?.type === "pattern" && n && e4.type !== h) {
  140. const e5 = await w(a.src, n.toCss(true));
  141. a.src = e5, t2.fill = a;
  142. }
  143. }
  144. function E(e4, t2) {
  145. return e4 > t2 ? "dark" : "light";
  146. }
  147. function Z(e4, t2) {
  148. const n = typeof t2?.size == "number" ? t2?.size : null, o = n != null ? u(n) : null, i = t2?.maxSize != null ? u(t2.maxSize) : null, r2 = t2?.rotation != null ? t2.rotation : "angle" in e4 ? e4.angle : null, m = b(e4);
  149. let u3 = j(e4);
  150. D(e4, 245) !== "dark" || t2?.ignoreWhiteSymbols || (u3 = { width: 0.75, ...u3, color: "#bdc3c7" });
  151. const x2 = { shape: null, fill: m, stroke: u3, offset: [0, 0] };
  152. u3?.width && (u3.width = Math.min(u3.width, M));
  153. const z2 = u3?.width || 0;
  154. let j3 = t2?.size != null && (t2?.scale == null || t2?.scale), C2 = 0, U2 = 0, E2 = false;
  155. switch (e4.type) {
  156. case y: {
  157. const t3 = e4.style, n2 = Math.min(o != null ? o : u(e4.size), i || b2);
  158. switch (C2 = n2, U2 = n2, t3) {
  159. case "circle":
  160. x2.shape = { type: "circle", cx: 0, cy: 0, r: 0.5 * n2 }, j3 || (C2 += z2, U2 += z2);
  161. break;
  162. case "cross":
  163. x2.shape = { type: "path", path: [{ command: "M", values: [0, 0.5 * U2] }, { command: "L", values: [C2, 0.5 * U2] }, { command: "M", values: [0.5 * C2, 0] }, { command: "L", values: [0.5 * C2, U2] }] };
  164. break;
  165. case "diamond":
  166. x2.shape = { type: "path", path: [{ command: "M", values: [0, 0.5 * U2] }, { command: "L", values: [0.5 * C2, 0] }, { command: "L", values: [C2, 0.5 * U2] }, { command: "L", values: [0.5 * C2, U2] }, { command: "Z", values: [] }] }, j3 || (C2 += z2, U2 += z2);
  167. break;
  168. case "square":
  169. x2.shape = { type: "path", path: [{ command: "M", values: [0, 0] }, { command: "L", values: [C2, 0] }, { command: "L", values: [C2, U2] }, { command: "L", values: [0, U2] }, { command: "Z", values: [] }] }, j3 || (C2 += z2, U2 += z2), r2 && (E2 = true);
  170. break;
  171. case "triangle":
  172. x2.shape = { type: "path", path: [{ command: "M", values: [0.5 * C2, 0] }, { command: "L", values: [C2, U2] }, { command: "L", values: [0, U2] }, { command: "Z", values: [] }] }, j3 || (C2 += z2, U2 += z2), r2 && (E2 = true);
  173. break;
  174. case "x":
  175. x2.shape = { type: "path", path: [{ command: "M", values: [0, 0] }, { command: "L", values: [C2, U2] }, { command: "M", values: [C2, 0] }, { command: "L", values: [0, U2] }] }, r2 && (E2 = true);
  176. break;
  177. case "path":
  178. x2.shape = { type: "path", path: e4.path || "" }, j3 || (C2 += z2, U2 += z2), r2 && (E2 = true), j3 = true;
  179. }
  180. break;
  181. }
  182. case f: {
  183. const { width: e5, height: a } = F(t2), n2 = a != null ? a : Math.min(o != null ? o : z2, i || M), l3 = e5 != null ? e5 : k;
  184. u3.width = n2, C2 = l3, U2 = n2;
  185. const s2 = x2?.stroke?.cap || "butt", c = s2 === "round";
  186. j3 = true, x2.stroke.cap = s2 === "butt" ? "square" : s2, x2.shape = { type: "path", path: [{ command: "M", values: [c ? n2 / 2 : 0, U2 / 2] }, { command: "L", values: [c ? C2 - n2 / 2 : C2, U2 / 2] }] };
  187. break;
  188. }
  189. case h:
  190. case d2: {
  191. const e5 = typeof t2?.symbolConfig == "object" && t2?.symbolConfig.isSquareFill, { width: a, height: n2 } = F(t2);
  192. C2 = e5 && a != null ? a : o != null ? o : g, U2 = e5 && n2 != null ? n2 : C2, j3 || (C2 += z2, U2 += z2), j3 = true, x2.shape = e5 ? { type: "path", path: [{ command: "M", values: [0, 0] }, { command: "L", values: [C2, 0] }, { command: "L", values: [C2, U2] }, { command: "L", values: [0, U2] }, { command: "L", values: [0, 0] }, { command: "Z", values: [] }] } : e2.fill[0];
  193. break;
  194. }
  195. case p: {
  196. let t3 = u(e4.width), n2 = u(e4.height);
  197. const l3 = o != null ? o : Math.max(t3, n2), s2 = t3 / n2;
  198. t3 = s2 <= 1 ? Math.ceil(l3 * s2) : l3, n2 = s2 <= 1 ? l3 : Math.ceil(l3 / s2), C2 = Math.min(t3, i || b2), U2 = Math.min(n2, i || b2), x2.shape = { type: "image", x: -Math.round(C2 / 2), y: -Math.round(U2 / 2), width: C2, height: U2, src: e4.url || "" }, r2 && (E2 = true);
  199. break;
  200. }
  201. case v: {
  202. const t3 = e4, n2 = t3.text || w2, l3 = t3.font, s2 = Math.min(o != null ? o : u(l3.size), i || b2), c = L(n2, { weight: l3.weight, size: s2, family: l3.family }), r3 = /[\uE600-\uE6FF]/.test(n2);
  203. C2 = r3 ? s2 : c, U2 = s2;
  204. let m2 = 0.25 * S((l3 ? s2 : 0).toString());
  205. r3 && (m2 += 5), x2.shape = { type: "text", text: n2, x: t3.xoffset || 0, y: t3.yoffset || m2, align: "middle", alignBaseline: t3.verticalAlignment, decoration: l3 && l3.decoration, rotated: t3.rotated, kerning: t3.kerning }, x2.font = l3 && { size: s2, style: l3.style, decoration: l3.decoration, weight: l3.weight, family: l3.family };
  206. break;
  207. }
  208. }
  209. return { shapeDescriptor: x2, size: [C2, U2], renderOptions: { node: t2?.node, scale: j3, opacity: t2?.opacity, rotation: r2, useRotationSize: E2, effectView: t2?.effectView } };
  210. }
  211. async function q(e4, a) {
  212. const { shapeDescriptor: n, size: l3, renderOptions: s2 } = Z(e4, a);
  213. if (!n.shape)
  214. throw new s("symbolPreview: renderPreviewHTML2D", "symbol not supported.");
  215. await U(e4, n);
  216. const o = [[n]];
  217. if (typeof a?.symbolConfig == "object" && a?.symbolConfig.applyColorModulation) {
  218. const e5 = 0.6 * l3[0];
  219. o.unshift([{ ...n, offset: [-e5, 0], fill: d(n.fill, -0.3) }]), o.push([{ ...n, offset: [e5, 0], fill: d(n.fill, 0.3) }]), l3[0] += 2 * e5, s2.scale = false;
  220. }
  221. return l2(o, l3, s2);
  222. }
  223. function D(t2, a = x) {
  224. const n = b(t2), o = j(t2), i = !n || "type" in n ? null : new l(n), c = o?.color ? new l(o?.color) : null, r2 = i ? E(u2(i), a) : null, m = c ? E(u2(c), a) : null;
  225. return m ? r2 ? r2 === m ? r2 : a >= x ? "light" : "dark" : m : r2;
  226. }
  227. export {
  228. D as getContrastingBackgroundTheme,
  229. Z as getRenderSymbolParameters,
  230. q as previewSymbol2D
  231. };
  232. //# sourceMappingURL=previewSymbol2D-P5PKM6M4.js.map