previewSymbol2D-OWVXJGGW.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. import {
  2. o
  3. } from "./chunk-5IVP3KUS.js";
  4. import {
  5. h as h2
  6. } from "./chunk-DX5KJRJR.js";
  7. import {
  8. d,
  9. e as e2,
  10. t
  11. } from "./chunk-K3NLQPKD.js";
  12. import {
  13. f,
  14. h,
  15. y
  16. } from "./chunk-I26BWYY3.js";
  17. import "./chunk-NDUYF7XW.js";
  18. import "./chunk-JEA4MMTV.js";
  19. import "./chunk-RG3AHHRL.js";
  20. import "./chunk-XHRNCFJT.js";
  21. import "./chunk-OKUFE7TO.js";
  22. import "./chunk-GZBNC76D.js";
  23. import "./chunk-3Z755LKF.js";
  24. import "./chunk-LTZ5XXDV.js";
  25. import "./chunk-DLMAGHHC.js";
  26. import "./chunk-JOYXMSKE.js";
  27. import "./chunk-ECY35CJI.js";
  28. import "./chunk-PT62335L.js";
  29. import "./chunk-MCWCB5IY.js";
  30. import "./chunk-4ONPMX2F.js";
  31. import "./chunk-CRGY2SDS.js";
  32. import "./chunk-4T5ZGMEN.js";
  33. import "./chunk-3OSQ6GXO.js";
  34. import "./chunk-3WQOA5CB.js";
  35. import "./chunk-FZQZIM7U.js";
  36. import "./chunk-CZBRZ6SU.js";
  37. import "./chunk-VGWC3IKZ.js";
  38. import "./chunk-2H5MD622.js";
  39. import {
  40. e,
  41. u
  42. } from "./chunk-UVVU4UUO.js";
  43. import {
  44. l
  45. } from "./chunk-X4SA4ELJ.js";
  46. import "./chunk-5N7JLUJJ.js";
  47. import "./chunk-ZAY3CMAZ.js";
  48. import "./chunk-P3XKUGLS.js";
  49. import "./chunk-2ZSOO377.js";
  50. import "./chunk-LU5IJZB4.js";
  51. import "./chunk-7IBV2TRE.js";
  52. import "./chunk-ZLNEXZAN.js";
  53. import "./chunk-5UVJ64RB.js";
  54. import "./chunk-SFEFRQCL.js";
  55. import "./chunk-ZYRIJWLX.js";
  56. import "./chunk-RYY6632W.js";
  57. import "./chunk-DW42UVIT.js";
  58. import "./chunk-YAEIHDJH.js";
  59. import "./chunk-TJNOJH33.js";
  60. import "./chunk-OSHI574D.js";
  61. import "./chunk-ETGAZ7LF.js";
  62. import "./chunk-75U5LM2V.js";
  63. import "./chunk-RMDDCMKS.js";
  64. import "./chunk-VCH45Q2I.js";
  65. import "./chunk-LBW34VZ2.js";
  66. import "./chunk-GSSTTHIT.js";
  67. import "./chunk-YFSLJIO4.js";
  68. import "./chunk-IM3LVQXV.js";
  69. import "./chunk-55RWC67C.js";
  70. import "./chunk-HZRKBTHJ.js";
  71. import "./chunk-DVUG3KID.js";
  72. import "./chunk-FWSQEIAR.js";
  73. import "./chunk-VEGAOVMY.js";
  74. import "./chunk-6T6G6LCQ.js";
  75. import "./chunk-YEJL5NEF.js";
  76. import "./chunk-PQFTYGF5.js";
  77. import "./chunk-2Z2TG5CU.js";
  78. import "./chunk-6KZ2LTDA.js";
  79. import "./chunk-U2XHEJM7.js";
  80. import "./chunk-SQOPWYIT.js";
  81. import "./chunk-V6P2MAQQ.js";
  82. import {
  83. s3 as s
  84. } from "./chunk-E5O6P5I2.js";
  85. import "./chunk-SPWQ3AWG.js";
  86. import "./chunk-2TIUKVZN.js";
  87. import "./chunk-YXWMMD76.js";
  88. import "./chunk-S5KM4IGW.js";
  89. // node_modules/@arcgis/core/views/support/colorUtils.js
  90. function e3(r2) {
  91. let { r: n, g: a, b: o2, a: e4 } = r2;
  92. return e4 < 1 && (n = Math.round(e4 * n + 255 * (1 - e4)), a = Math.round(e4 * a + 255 * (1 - e4)), o2 = Math.round(e4 * o2 + 255 * (1 - e4))), new l({ r: n, g: a, b: o2 });
  93. }
  94. function u2(t2) {
  95. const { r: r2, g: n, b: a } = e3(t2);
  96. return 0.2126 * r2 + 0.7152 * n + 0.0722 * a;
  97. }
  98. // node_modules/@arcgis/core/symbols/support/previewSymbol2D.js
  99. var p = "picture-fill";
  100. var d2 = "picture-marker";
  101. var f2 = "simple-fill";
  102. var y2 = "simple-line";
  103. var w = "simple-marker";
  104. var g = "text";
  105. var v = "Aa";
  106. var b = t.size;
  107. var x = t.maxSize;
  108. var k = t.maxOutlineSize;
  109. var M = t.lineWidth;
  110. var z = 225;
  111. var L = document.createElement("canvas");
  112. function j(e4, t2) {
  113. const a = L.getContext("2d"), n = [];
  114. 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;
  115. }
  116. var C = 7.2 / 2.54;
  117. var S = 72 / 2.54;
  118. function F(e4) {
  119. if (0 === e4.length)
  120. return 0;
  121. if (e4.length > 2) {
  122. const t2 = e(1), a = parseFloat(e4);
  123. switch (e4.slice(-2)) {
  124. case "px":
  125. return a;
  126. case "pt":
  127. return a * t2;
  128. case "in":
  129. return 72 * a * t2;
  130. case "pc":
  131. return 12 * a * t2;
  132. case "mm":
  133. return a * C * t2;
  134. case "cm":
  135. return a * S * t2;
  136. }
  137. }
  138. return parseFloat(e4);
  139. }
  140. function E(e4) {
  141. const t2 = e4 == null ? void 0 : e4.size;
  142. return { width: null != t2 && "object" == typeof t2 && "width" in t2 ? u(t2.width) : null, height: null != t2 && "object" == typeof t2 && "height" in t2 ? u(t2.height) : null };
  143. }
  144. async function U(e4, t2) {
  145. const a = t2.fill, n = e4.color;
  146. if ("pattern" === (a == null ? void 0 : a.type) && n && e4.type !== p) {
  147. const e5 = await h(a.src, n.toCss(true));
  148. a.src = e5, t2.fill = a;
  149. }
  150. }
  151. async function Z(e4, t2, n, l2) {
  152. if (!("font" in e4) || !e4.font || "text" !== t2.shape.type)
  153. return;
  154. try {
  155. await o(e4.font);
  156. } catch {
  157. }
  158. const { width: i } = E(l2), s2 = /[\uE600-\uE6FF]/.test(t2.shape.text);
  159. null != i || s2 || (n[0] = j(t2.shape.text, { weight: t2.font.weight, size: t2.font.size, family: t2.font.family }));
  160. }
  161. function q(e4, t2) {
  162. return e4 > t2 ? "dark" : "light";
  163. }
  164. function D(e4, t2) {
  165. var _a;
  166. const a = "number" == typeof (t2 == null ? void 0 : t2.size) ? t2 == null ? void 0 : t2.size : null, l2 = null != a ? u(a) : null, o2 = null != (t2 == null ? void 0 : t2.maxSize) ? u(t2.maxSize) : null, r2 = null != (t2 == null ? void 0 : t2.rotation) ? t2.rotation : "angle" in e4 ? e4.angle : null, m = f(e4);
  167. let u3 = y(e4);
  168. "dark" !== T(e4, 245) || (t2 == null ? void 0 : t2.ignoreWhiteSymbols) || (u3 = { width: 0.75, ...u3, color: "#bdc3c7" });
  169. const h3 = { shape: null, fill: m, stroke: u3, offset: [0, 0] };
  170. (u3 == null ? void 0 : u3.width) && (u3.width = Math.min(u3.width, k));
  171. const z2 = (u3 == null ? void 0 : u3.width) || 0;
  172. let L2 = null != (t2 == null ? void 0 : t2.size) && (null == (t2 == null ? void 0 : t2.scale) || (t2 == null ? void 0 : t2.scale)), C2 = 0, S2 = 0, U2 = false;
  173. switch (e4.type) {
  174. case w: {
  175. const a2 = e4.style, { width: i, height: s2 } = E(t2), c = i === s2 && null != i ? i : null != l2 ? l2 : Math.min(u(e4.size), o2 || x);
  176. switch (C2 = c, S2 = c, a2) {
  177. case "circle":
  178. h3.shape = { type: "circle", cx: 0, cy: 0, r: 0.5 * c }, L2 || (C2 += z2, S2 += z2);
  179. break;
  180. case "cross":
  181. h3.shape = { type: "path", path: [{ command: "M", values: [0, 0.5 * S2] }, { command: "L", values: [C2, 0.5 * S2] }, { command: "M", values: [0.5 * C2, 0] }, { command: "L", values: [0.5 * C2, S2] }] };
  182. break;
  183. case "diamond":
  184. h3.shape = { type: "path", path: [{ command: "M", values: [0, 0.5 * S2] }, { command: "L", values: [0.5 * C2, 0] }, { command: "L", values: [C2, 0.5 * S2] }, { command: "L", values: [0.5 * C2, S2] }, { command: "Z", values: [] }] }, L2 || (C2 += z2, S2 += z2);
  185. break;
  186. case "square":
  187. h3.shape = { type: "path", path: [{ command: "M", values: [0, 0] }, { command: "L", values: [C2, 0] }, { command: "L", values: [C2, S2] }, { command: "L", values: [0, S2] }, { command: "Z", values: [] }] }, L2 || (C2 += z2, S2 += z2), r2 && (U2 = true);
  188. break;
  189. case "triangle":
  190. h3.shape = { type: "path", path: [{ command: "M", values: [0.5 * C2, 0] }, { command: "L", values: [C2, S2] }, { command: "L", values: [0, S2] }, { command: "Z", values: [] }] }, L2 || (C2 += z2, S2 += z2), r2 && (U2 = true);
  191. break;
  192. case "x":
  193. h3.shape = { type: "path", path: [{ command: "M", values: [0, 0] }, { command: "L", values: [C2, S2] }, { command: "M", values: [C2, 0] }, { command: "L", values: [0, S2] }] }, r2 && (U2 = true);
  194. break;
  195. case "path":
  196. h3.shape = { type: "path", path: e4.path || "" }, L2 || (C2 += z2, S2 += z2), r2 && (U2 = true), L2 = true;
  197. }
  198. break;
  199. }
  200. case y2: {
  201. const { width: e5, height: a2 } = E(t2), n = null != a2 ? a2 : null != l2 ? l2 : z2, i = null != e5 ? e5 : M;
  202. u3 && (u3.width = n), C2 = i, S2 = n;
  203. const s2 = ((_a = h3 == null ? void 0 : h3.stroke) == null ? void 0 : _a.cap) || "butt", o3 = "round" === s2;
  204. L2 = true, h3.stroke && (h3.stroke.cap = "butt" === s2 ? "square" : s2), h3.shape = { type: "path", path: [{ command: "M", values: [o3 ? n / 2 : 0, S2 / 2] }, { command: "L", values: [o3 ? C2 - n / 2 : C2, S2 / 2] }] };
  205. break;
  206. }
  207. case p:
  208. case f2: {
  209. const e5 = "object" == typeof (t2 == null ? void 0 : t2.symbolConfig) && (t2 == null ? void 0 : t2.symbolConfig.isSquareFill), { width: a2, height: n } = E(t2);
  210. C2 = !e5 && a2 !== n || null == a2 ? null != l2 ? l2 : b : a2, S2 = !e5 && a2 !== n || null == n ? C2 : n, L2 || (C2 += z2, S2 += z2), L2 = true, h3.shape = e5 ? { type: "path", path: [{ command: "M", values: [0, 0] }, { command: "L", values: [C2, 0] }, { command: "L", values: [C2, S2] }, { command: "L", values: [0, S2] }, { command: "L", values: [0, 0] }, { command: "Z", values: [] }] } : e2.fill[0];
  211. break;
  212. }
  213. case d2: {
  214. const a2 = Math.min(u(e4.width), o2 || x), i = Math.min(u(e4.height), o2 || x), { width: s2, height: c } = E(t2), m2 = s2 === c && null != s2 ? s2 : null != l2 ? l2 : Math.max(a2, i), u4 = a2 / i;
  215. C2 = u4 <= 1 ? Math.ceil(m2 * u4) : m2, S2 = u4 <= 1 ? m2 : Math.ceil(m2 / u4), h3.shape = { type: "image", x: -Math.round(C2 / 2), y: -Math.round(S2 / 2), width: C2, height: S2, src: e4.url || "" }, r2 && (U2 = true);
  216. break;
  217. }
  218. case g: {
  219. const a2 = e4, i = (t2 == null ? void 0 : t2.overrideText) || a2.text || v, s2 = a2.font, { width: r3, height: c } = E(t2), m2 = null != c ? c : null != l2 ? l2 : Math.min(u(s2.size), o2 || x), u4 = j(i, { weight: s2.weight, size: m2, family: s2.family }), p2 = /[\uE600-\uE6FF]/.test(i);
  220. C2 = r3 != null ? r3 : p2 ? m2 : u4, S2 = m2;
  221. let d3 = 0.25 * F((s2 ? m2 : 0).toString());
  222. p2 && (d3 += 5), h3.shape = { type: "text", text: i, x: a2.xoffset || 0, y: a2.yoffset || d3, align: "middle", alignBaseline: a2.verticalAlignment, decoration: s2 && s2.decoration, rotated: a2.rotated, kerning: a2.kerning }, h3.font = s2 && { size: m2, style: s2.style, decoration: s2.decoration, weight: s2.weight, family: s2.family };
  223. break;
  224. }
  225. }
  226. return { shapeDescriptor: h3, size: [C2, S2], renderOptions: { node: t2 == null ? void 0 : t2.node, scale: L2, opacity: t2 == null ? void 0 : t2.opacity, rotation: r2, useRotationSize: U2, effectView: t2 == null ? void 0 : t2.effectView } };
  227. }
  228. async function O(e4, a) {
  229. const { shapeDescriptor: n, size: l2, renderOptions: i } = D(e4, a);
  230. if (!n.shape)
  231. throw new s("symbolPreview: renderPreviewHTML2D", "symbol not supported.");
  232. await U(e4, n), await Z(e4, n, l2, a);
  233. const s2 = [[n]];
  234. if ("object" == typeof (a == null ? void 0 : a.symbolConfig) && (a == null ? void 0 : a.symbolConfig.applyColorModulation)) {
  235. const e5 = 0.6 * l2[0];
  236. s2.unshift([{ ...n, offset: [-e5, 0], fill: d(n.fill, -0.3) }]), s2.push([{ ...n, offset: [e5, 0], fill: d(n.fill, 0.3) }]), l2[0] += 2 * e5, i.scale = false;
  237. }
  238. return h2(s2, l2, i);
  239. }
  240. function T(t2, a = z) {
  241. const n = f(t2), l2 = y(t2), o2 = !n || "type" in n ? null : new l(n), r2 = (l2 == null ? void 0 : l2.color) ? new l(l2 == null ? void 0 : l2.color) : null, c = o2 ? q(u2(o2), a) : null, m = r2 ? q(u2(r2), a) : null;
  242. return m ? c ? c === m ? c : a >= z ? "light" : "dark" : m : c;
  243. }
  244. export {
  245. T as getContrastingBackgroundTheme,
  246. D as getRenderSymbolParameters,
  247. O as previewSymbol2D
  248. };
  249. //# sourceMappingURL=previewSymbol2D-OWVXJGGW.js.map