@thibezer/ui-components-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +624 -0
  3. package/dist/botao.cjs +1 -0
  4. package/dist/botao.d.ts +8 -0
  5. package/dist/botao.js +6 -0
  6. package/dist/camadas.cjs +296 -0
  7. package/dist/camadas.d.ts +14 -0
  8. package/dist/camadas.js +1857 -0
  9. package/dist/campo-texto.cjs +1 -0
  10. package/dist/campo-texto.d.ts +8 -0
  11. package/dist/campo-texto.js +11 -0
  12. package/dist/canvas.cjs +254 -0
  13. package/dist/canvas.d.ts +8 -0
  14. package/dist/canvas.js +3082 -0
  15. package/dist/card.cjs +1 -0
  16. package/dist/card.d.ts +7 -0
  17. package/dist/card.js +5 -0
  18. package/dist/components/ui-alerta/index.d.ts +2 -0
  19. package/dist/components/ui-alerta/ui-alerta-base.d.ts +23 -0
  20. package/dist/components/ui-alerta/ui-alerta.d.ts +2 -0
  21. package/dist/components/ui-alerta/ui-toast.d.ts +34 -0
  22. package/dist/components/ui-avatar/index.d.ts +1 -0
  23. package/dist/components/ui-avatar/ui-avatar.d.ts +12 -0
  24. package/dist/components/ui-badge/index.d.ts +1 -0
  25. package/dist/components/ui-badge/ui-badge.d.ts +20 -0
  26. package/dist/components/ui-barra-ferramentas/ferramentas-comum.d.ts +22 -0
  27. package/dist/components/ui-barra-ferramentas/ferramentas-icones.d.ts +24 -0
  28. package/dist/components/ui-barra-ferramentas/index.d.ts +4 -0
  29. package/dist/components/ui-barra-ferramentas/tipos.d.ts +55 -0
  30. package/dist/components/ui-barra-ferramentas/ui-paleta-ferramentas.d.ts +54 -0
  31. package/dist/components/ui-barra-ferramentas/ui-ribbon.d.ts +52 -0
  32. package/dist/components/ui-botao/index.d.ts +1 -0
  33. package/dist/components/ui-botao/ui-botao.d.ts +26 -0
  34. package/dist/components/ui-camadas/camadas-arvore-renderer.d.ts +18 -0
  35. package/dist/components/ui-camadas/camadas-drag-drop.d.ts +18 -0
  36. package/dist/components/ui-camadas/camadas-eventos-arvore.d.ts +2 -0
  37. package/dist/components/ui-camadas/camadas-eventos-camadas.d.ts +2 -0
  38. package/dist/components/ui-camadas/camadas-eventos-rodape.d.ts +2 -0
  39. package/dist/components/ui-camadas/camadas-host.d.ts +23 -0
  40. package/dist/components/ui-camadas/camadas-icones.d.ts +23 -0
  41. package/dist/components/ui-camadas/camadas-mapas-base.d.ts +3 -0
  42. package/dist/components/ui-camadas/camadas-metricas.d.ts +17 -0
  43. package/dist/components/ui-camadas/camadas-persistencia.d.ts +65 -0
  44. package/dist/components/ui-camadas/camadas-resizer.d.ts +16 -0
  45. package/dist/components/ui-camadas/camadas-rodape.d.ts +2 -0
  46. package/dist/components/ui-camadas/camadas-selecao.d.ts +24 -0
  47. package/dist/components/ui-camadas/camadas-sincronizacao-dom.d.ts +3 -0
  48. package/dist/components/ui-camadas/camadas-teclado.d.ts +3 -0
  49. package/dist/components/ui-camadas/camadas-utils.d.ts +26 -0
  50. package/dist/components/ui-camadas/index.d.ts +11 -0
  51. package/dist/components/ui-camadas/tipos.d.ts +116 -0
  52. package/dist/components/ui-camadas/ui-camadas.d.ts +112 -0
  53. package/dist/components/ui-campo-texto/campo-texto-estados.d.ts +12 -0
  54. package/dist/components/ui-campo-texto/campo-texto-template.d.ts +2 -0
  55. package/dist/components/ui-campo-texto/index.d.ts +1 -0
  56. package/dist/components/ui-campo-texto/ui-campo-texto.d.ts +57 -0
  57. package/dist/components/ui-canvas-cad/cad-atributos-sync.d.ts +13 -0
  58. package/dist/components/ui-canvas-cad/cad-broadcast.d.ts +19 -0
  59. package/dist/components/ui-canvas-cad/cad-colecoes-dados.d.ts +46 -0
  60. package/dist/components/ui-canvas-cad/cad-eventos-canvas.d.ts +26 -0
  61. package/dist/components/ui-canvas-cad/cad-inicializador.d.ts +19 -0
  62. package/dist/components/ui-canvas-cad/cad-painel-camadas.d.ts +9 -0
  63. package/dist/components/ui-canvas-cad/cad-tamanho-observer.d.ts +7 -0
  64. package/dist/components/ui-canvas-cad/cad-template.d.ts +1 -0
  65. package/dist/components/ui-canvas-cad/cad-toolbar-painel.d.ts +29 -0
  66. package/dist/components/ui-canvas-cad/index.d.ts +8 -0
  67. package/dist/components/ui-canvas-cad/ui-canvas-cad.d.ts +91 -0
  68. package/dist/components/ui-card/index.d.ts +1 -0
  69. package/dist/components/ui-card/ui-card.d.ts +18 -0
  70. package/dist/components/ui-checkbox/index.d.ts +1 -0
  71. package/dist/components/ui-checkbox/ui-checkbox.d.ts +36 -0
  72. package/dist/components/ui-drawer/drawer-acessibilidade.d.ts +16 -0
  73. package/dist/components/ui-drawer/index.d.ts +1 -0
  74. package/dist/components/ui-drawer/ui-drawer.d.ts +37 -0
  75. package/dist/components/ui-icone/index.d.ts +1 -0
  76. package/dist/components/ui-icone/ui-icone.d.ts +15 -0
  77. package/dist/components/ui-lista-flutuante/index.d.ts +1 -0
  78. package/dist/components/ui-lista-flutuante/lista-flutuante-posicionamento.d.ts +15 -0
  79. package/dist/components/ui-lista-flutuante/lista-flutuante-render.d.ts +9 -0
  80. package/dist/components/ui-lista-flutuante/lista-flutuante-teclado.d.ts +13 -0
  81. package/dist/components/ui-lista-flutuante/lista-flutuante-template.d.ts +2 -0
  82. package/dist/components/ui-lista-flutuante/tipos.d.ts +4 -0
  83. package/dist/components/ui-lista-flutuante/ui-lista-flutuante.d.ts +63 -0
  84. package/dist/components/ui-mapa/index.d.ts +3 -0
  85. package/dist/components/ui-mapa/ui-mapa-linha.d.ts +12 -0
  86. package/dist/components/ui-mapa/ui-mapa-marcador.d.ts +15 -0
  87. package/dist/components/ui-mapa/ui-mapa.d.ts +16 -0
  88. package/dist/components/ui-modal/index.d.ts +2 -0
  89. package/dist/components/ui-modal/modal-acessibilidade.d.ts +12 -0
  90. package/dist/components/ui-modal/ui-modal.d.ts +30 -0
  91. package/dist/components/ui-radio/index.d.ts +1 -0
  92. package/dist/components/ui-radio/radio-grupo-registry.d.ts +10 -0
  93. package/dist/components/ui-radio/ui-radio.d.ts +29 -0
  94. package/dist/components/ui-segmented/index.d.ts +1 -0
  95. package/dist/components/ui-segmented/segmented-indicador.d.ts +13 -0
  96. package/dist/components/ui-segmented/segmented-teclado.d.ts +4 -0
  97. package/dist/components/ui-segmented/segmented-template.d.ts +4 -0
  98. package/dist/components/ui-segmented/ui-segmented.d.ts +48 -0
  99. package/dist/components/ui-seletor-mapa-base/index.d.ts +2 -0
  100. package/dist/components/ui-seletor-mapa-base/tipos.d.ts +22 -0
  101. package/dist/components/ui-seletor-mapa-base/ui-seletor-mapa-base.d.ts +43 -0
  102. package/dist/components/ui-skeleton/index.d.ts +1 -0
  103. package/dist/components/ui-skeleton/ui-skeleton.d.ts +19 -0
  104. package/dist/components/ui-stat/index.d.ts +1 -0
  105. package/dist/components/ui-stat/ui-stat.d.ts +30 -0
  106. package/dist/components/ui-switch/index.d.ts +1 -0
  107. package/dist/components/ui-switch/ui-switch.d.ts +36 -0
  108. package/dist/components/ui-tabela/index.d.ts +7 -0
  109. package/dist/components/ui-tabela/tabela-atributos-sync.d.ts +14 -0
  110. package/dist/components/ui-tabela/tabela-corpo.d.ts +18 -0
  111. package/dist/components/ui-tabela/tabela-dom.d.ts +15 -0
  112. package/dist/components/ui-tabela/tabela-header.d.ts +18 -0
  113. package/dist/components/ui-tabela/tabela-interacao.d.ts +9 -0
  114. package/dist/components/ui-tabela/tabela-localizador.d.ts +4 -0
  115. package/dist/components/ui-tabela/tabela-ordenacao.d.ts +12 -0
  116. package/dist/components/ui-tabela/tabela-orquestrador-dados.d.ts +18 -0
  117. package/dist/components/ui-tabela/tabela-redimensionamento.d.ts +28 -0
  118. package/dist/components/ui-tabela/tabela-remota.d.ts +15 -0
  119. package/dist/components/ui-tabela/tabela-renderizador.d.ts +29 -0
  120. package/dist/components/ui-tabela/tabela-selecao.d.ts +24 -0
  121. package/dist/components/ui-tabela/tipos.d.ts +27 -0
  122. package/dist/components/ui-tabela/ui-tabela.d.ts +83 -0
  123. package/dist/components/ui-tabela-propriedades/avaliador-expressao.d.ts +6 -0
  124. package/dist/components/ui-tabela-propriedades/editores-basicos.d.ts +7 -0
  125. package/dist/components/ui-tabela-propriedades/editores-cad.d.ts +17 -0
  126. package/dist/components/ui-tabela-propriedades/index.d.ts +6 -0
  127. package/dist/components/ui-tabela-propriedades/propriedades-densidade.d.ts +5 -0
  128. package/dist/components/ui-tabela-propriedades/propriedades-dom-utils.d.ts +6 -0
  129. package/dist/components/ui-tabela-propriedades/propriedades-editores.d.ts +5 -0
  130. package/dist/components/ui-tabela-propriedades/propriedades-flutuante.d.ts +7 -0
  131. package/dist/components/ui-tabela-propriedades/propriedades-gerenciador-valores.d.ts +26 -0
  132. package/dist/components/ui-tabela-propriedades/propriedades-painel-controles.d.ts +15 -0
  133. package/dist/components/ui-tabela-propriedades/propriedades-render-arvore.d.ts +24 -0
  134. package/dist/components/ui-tabela-propriedades/propriedades-seletor-tipo.d.ts +13 -0
  135. package/dist/components/ui-tabela-propriedades/propriedades-splitter.d.ts +13 -0
  136. package/dist/components/ui-tabela-propriedades/propriedades-template.d.ts +1 -0
  137. package/dist/components/ui-tabela-propriedades/tipos.d.ts +48 -0
  138. package/dist/components/ui-tabela-propriedades/ui-tabela-propriedades.d.ts +66 -0
  139. package/dist/components/ui-texto/index.d.ts +1 -0
  140. package/dist/components/ui-texto/ui-texto.d.ts +15 -0
  141. package/dist/components/ui-tooltip/index.d.ts +1 -0
  142. package/dist/components/ui-tooltip/ui-tooltip.d.ts +25 -0
  143. package/dist/core/acessibilidade.d.ts +21 -0
  144. package/dist/core/form-associated-element.d.ts +33 -0
  145. package/dist/core/form-validacao.d.ts +34 -0
  146. package/dist/core/index.d.ts +7 -0
  147. package/dist/core/leaflet-loader.d.ts +7 -0
  148. package/dist/core/leaflet-style.d.ts +7 -0
  149. package/dist/core/listener-bag.d.ts +21 -0
  150. package/dist/core/ssr-safe.d.ts +20 -0
  151. package/dist/core/ui-bus.d.ts +85 -0
  152. package/dist/core/zero-js-triggers.d.ts +1 -0
  153. package/dist/core.cjs +1 -0
  154. package/dist/core.js +22 -0
  155. package/dist/data.cjs +1 -0
  156. package/dist/data.d.ts +22 -0
  157. package/dist/data.js +63 -0
  158. package/dist/feedback.cjs +1 -0
  159. package/dist/feedback.d.ts +26 -0
  160. package/dist/feedback.js +25 -0
  161. package/dist/form-validacao-BIOXxt-1.js +140 -0
  162. package/dist/form-validacao-ytRYSF3E.cjs +1 -0
  163. package/dist/forms.cjs +1 -0
  164. package/dist/forms.d.ts +22 -0
  165. package/dist/forms.js +25 -0
  166. package/dist/gerencigeo-canvas/canvas_destaque.d.ts +13 -0
  167. package/dist/gerencigeo-canvas/canvas_destaque_marcadores.d.ts +8 -0
  168. package/dist/gerencigeo-canvas/canvas_interacao.d.ts +56 -0
  169. package/dist/gerencigeo-canvas/canvas_selecao_box.d.ts +23 -0
  170. package/dist/gerencigeo-canvas/controller_dados_ops.d.ts +15 -0
  171. package/dist/gerencigeo-canvas/index.d.ts +17 -0
  172. package/dist/gerencigeo-canvas/layer_defaults.d.ts +3 -0
  173. package/dist/gerencigeo-canvas/layer_instance_ops.d.ts +6 -0
  174. package/dist/gerencigeo-canvas/layer_manager.d.ts +37 -0
  175. package/dist/gerencigeo-canvas/layer_pane_ops.d.ts +8 -0
  176. package/dist/gerencigeo-canvas/layer_renderer_factory.d.ts +14 -0
  177. package/dist/gerencigeo-canvas/layer_state_ops.d.ts +6 -0
  178. package/dist/gerencigeo-canvas/mapa_config.d.ts +11 -0
  179. package/dist/gerencigeo-canvas/mapa_controller.d.ts +53 -0
  180. package/dist/gerencigeo-canvas/mapa_core.d.ts +30 -0
  181. package/dist/gerencigeo-canvas/mapa_linhas.d.ts +14 -0
  182. package/dist/gerencigeo-canvas/mapa_marcadores.d.ts +18 -0
  183. package/dist/gerencigeo-canvas/mapa_pontos_shapes.d.ts +8 -0
  184. package/dist/gerencigeo-canvas/renderers/grid_renderer.d.ts +9 -0
  185. package/dist/gerencigeo-canvas/renderers/tile_renderer.d.ts +8 -0
  186. package/dist/gerencigeo-canvas/renderers/vector_lines_builder.d.ts +4 -0
  187. package/dist/gerencigeo-canvas/renderers/vector_lines_renderer.d.ts +9 -0
  188. package/dist/gerencigeo-canvas/renderers/vector_points_renderer.d.ts +11 -0
  189. package/dist/gerencigeo-canvas/renderers/vector_polygons_renderer.d.ts +9 -0
  190. package/dist/gerencigeo-canvas/renderers/wms_renderer.d.ts +8 -0
  191. package/dist/gerencigeo-canvas/sigef_consultor.d.ts +9 -0
  192. package/dist/gerencigeo-canvas/tile_preloader.d.ts +2 -0
  193. package/dist/gerencigeo-canvas/types.d.ts +169 -0
  194. package/dist/gerencigeo-canvas/utils.d.ts +46 -0
  195. package/dist/index.cjs +1 -0
  196. package/dist/index.d.ts +116 -0
  197. package/dist/index.js +186 -0
  198. package/dist/leaflet-Cw6tqYFh.cjs +1 -0
  199. package/dist/leaflet-DkaFZYc5.js +69 -0
  200. package/dist/leaflet-loader-94z5VsdY.cjs +2 -0
  201. package/dist/leaflet-loader-Cjcdgj5R.js +21 -0
  202. package/dist/listener-bag-D5omxZ9h.cjs +1 -0
  203. package/dist/listener-bag-DQgv7OON.js +34 -0
  204. package/dist/mapa.cjs +19 -0
  205. package/dist/mapa.d.ts +11 -0
  206. package/dist/mapa.js +264 -0
  207. package/dist/modal.cjs +1 -0
  208. package/dist/modal.d.ts +8 -0
  209. package/dist/modal.js +8 -0
  210. package/dist/register.cjs +1 -0
  211. package/dist/register.d.ts +7 -0
  212. package/dist/register.js +21 -0
  213. package/dist/seletor-mapa-base.cjs +53 -0
  214. package/dist/seletor-mapa-base.d.ts +8 -0
  215. package/dist/seletor-mapa-base.js +275 -0
  216. package/dist/ssr-safe-5cWfJP-s.js +10 -0
  217. package/dist/ssr-safe-CiHD1adl.cjs +1 -0
  218. package/dist/tabela.cjs +1 -0
  219. package/dist/tabela.d.ts +12 -0
  220. package/dist/tabela.js +56 -0
  221. package/dist/tools.cjs +1 -0
  222. package/dist/tools.d.ts +8 -0
  223. package/dist/tools.js +30 -0
  224. package/dist/ui-badge-92yelKls.js +183 -0
  225. package/dist/ui-badge-B95jSECC.cjs +28 -0
  226. package/dist/ui-botao-BShEouvi.js +124 -0
  227. package/dist/ui-botao-DF1yuUUD.cjs +12 -0
  228. package/dist/ui-campo-texto-BCh5HyCM.cjs +16 -0
  229. package/dist/ui-campo-texto-B_JF6POq.js +361 -0
  230. package/dist/ui-card-BJ8SmvVf.js +111 -0
  231. package/dist/ui-card-Bhm6k91e.cjs +20 -0
  232. package/dist/ui-kit.css +1 -0
  233. package/dist/ui-modal-Bi4isGYh.cjs +18 -0
  234. package/dist/ui-modal-DV-pw2x1.js +194 -0
  235. package/dist/ui-paleta-ferramentas-B6dJ0O6K.cjs +18 -0
  236. package/dist/ui-paleta-ferramentas-Bpp4XBVg.js +633 -0
  237. package/dist/ui-segmented-C8wuycjJ.js +411 -0
  238. package/dist/ui-segmented-NC5cBXLh.cjs +19 -0
  239. package/dist/ui-skeleton-B3xQyn0Z.js +396 -0
  240. package/dist/ui-skeleton-D42oQufF.cjs +33 -0
  241. package/dist/ui-switch-C6o4yZUF.cjs +53 -0
  242. package/dist/ui-switch-CO9MoS8x.js +826 -0
  243. package/dist/ui-tabela-propriedades-7yJ9g7ti.cjs +145 -0
  244. package/dist/ui-tabela-propriedades-D-XKNVwK.js +2078 -0
  245. package/dist/ui-toast-CQBqvUm3.cjs +20 -0
  246. package/dist/ui-toast-CwUmiqyG.js +156 -0
  247. package/dist/zero-js-triggers-DdESy0tk.js +205 -0
  248. package/dist/zero-js-triggers-QGD7FOTv.cjs +1 -0
  249. package/package.json +149 -0
package/dist/canvas.js ADDED
@@ -0,0 +1,3082 @@
1
+ var ft = Object.defineProperty;
2
+ var ut = (n, t, e) => t in n ? ft(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var u = (n, t, e) => ut(n, typeof t != "symbol" ? t + "" : t, e);
4
+ /* empty css */
5
+ import v from "leaflet";
6
+ import { e as P, p as O, r as W, b as Y, a as K, o as J, c as ot, l as gt } from "./leaflet-DkaFZYc5.js";
7
+ import { f as ke } from "./leaflet-DkaFZYc5.js";
8
+ import { L as dt } from "./listener-bag-DQgv7OON.js";
9
+ import { d as mt, S as vt } from "./ssr-safe-5cWfJP-s.js";
10
+ const it = {
11
+ perimetroWeight: 1,
12
+ fechamentoWeight: 1,
13
+ vizinhoWeight: 1,
14
+ bancoWeight: 1,
15
+ markerSizeBase: 10,
16
+ markerStyleM: "circle-dot",
17
+ markerSizeM: 14,
18
+ markerStyleP: "circle",
19
+ markerSizeP: 10,
20
+ markerStyleV: "cross",
21
+ markerSizeV: 8,
22
+ enableAnimations: !1,
23
+ preferCanvas: !0,
24
+ crosshair: !1,
25
+ satOpacity: 1,
26
+ magnetSnap: !1
27
+ }, F = class F {
28
+ constructor() {
29
+ u(this, "config");
30
+ this.config = this.loadConfig();
31
+ }
32
+ static getInstance() {
33
+ return F.instance || (F.instance = new F()), F.instance;
34
+ }
35
+ loadConfig() {
36
+ try {
37
+ const t = typeof localStorage < "u" ? localStorage.getItem("gerencigeo_mapa_config") : null;
38
+ if (t)
39
+ return { ...it, ...JSON.parse(t) };
40
+ } catch (t) {
41
+ console.error("Erro ao carregar configurações do mapa", t);
42
+ }
43
+ return { ...it };
44
+ }
45
+ saveConfig(t) {
46
+ this.config = { ...this.config, ...t }, typeof localStorage < "u" && localStorage.setItem("gerencigeo_mapa_config", JSON.stringify(this.config));
47
+ }
48
+ getConfig() {
49
+ return this.config = this.loadConfig(), { ...this.config };
50
+ }
51
+ };
52
+ u(F, "instance");
53
+ let Q = F;
54
+ async function yt(n, t, e, o) {
55
+ const i = n.getSize(), s = n.getBounds(), a = s.getSouthWest(), c = s.getNorthEast(), r = `${a.lng},${a.lat},${c.lng},${c.lat}`;
56
+ let l = 0, p = 0;
57
+ try {
58
+ if (t.containerPoint)
59
+ l = Math.round(t.containerPoint.x), p = Math.round(t.containerPoint.y);
60
+ else if (t.layerPoint) {
61
+ const b = n.layerPointToContainerPoint(t.layerPoint);
62
+ l = Math.round(b.x), p = Math.round(b.y);
63
+ }
64
+ } catch {
65
+ l = 0, p = 0;
66
+ }
67
+ const d = `https://acervofundiario.incra.gov.br/i3geo/ogc.php?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&FORMAT=image/png&TRANSPARENT=true&QUERY_LAYERS=certificada_sigef_particular_pr&LAYERS=certificada_sigef_particular_pr&INFO_FORMAT=application/json&X=${l}&Y=${p}&WIDTH=${i.x}&HEIGHT=${i.y}&SRS=EPSG:4326&BBOX=${r}`, f = n.getContainer();
68
+ f.style.cursor = "wait";
69
+ const h = v.popup({
70
+ className: "compact-sigef-popup",
71
+ maxWidth: 250
72
+ }).setLatLng(t.latlng).setContent(`
73
+ <div style="font-family:sans-serif; display:flex; align-items:center; gap:8px; color:rgba(255,255,255,0.9); font-size:12px;">
74
+ <svg style="animation:spin 1s linear infinite; width:14px; height:14px; flex-shrink:0;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
75
+ <circle cx="12" cy="12" r="10" stroke="rgba(255,255,255,0.2)" stroke-width="4" fill="none"></circle>
76
+ <path fill="#00f5a0" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
77
+ </svg>
78
+ Consultando...
79
+ </div>
80
+ `).openOn(n);
81
+ o.currentAbortController && o.currentAbortController.abort(), o.currentAbortController = new AbortController();
82
+ const y = o.currentAbortController.signal, S = setTimeout(() => {
83
+ o.currentAbortController && o.currentAbortController.abort();
84
+ }, 8e3);
85
+ try {
86
+ const M = typeof window < "u" && (window.location.origin.includes("localhost") || window.location.origin.includes("127.0.0.1") || window.location.origin.includes("[::1]")) ? `${e}/proxy/sigef?url=${encodeURIComponent(d)}` : `${window.location.origin}/api.php?action=proxy_sigef&url=${encodeURIComponent(d)}`, I = await fetch(M, { signal: y });
87
+ clearTimeout(S);
88
+ let z = null;
89
+ if (I.ok) {
90
+ const E = await I.text();
91
+ try {
92
+ z = JSON.parse(E);
93
+ } catch {
94
+ z = null;
95
+ }
96
+ }
97
+ if (z && z.features && z.features.length > 0) {
98
+ const E = z.features[0], w = E.properties || {}, g = String(E.id || w.parcela_codigo || w.co_parcela || w.id_parcela || ""), m = String(w.nome_area || w.nome_imovel || "Imóvel Sem Nome");
99
+ if (g) {
100
+ const x = encodeURIComponent(g), L = `https://sigef.incra.gov.br/geo/exportar/parcela/shp/${x}/`, _ = `https://sigef.incra.gov.br/geo/parcela/detalhe/${x}/`, k = document.createElement("div");
101
+ k.style.cssText = "font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.4; min-width:180px;", k.innerHTML = `
102
+ <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:6px; padding-bottom:5px; border-bottom:1px solid rgba(255, 255, 255, 0.1);">
103
+ <span style="font-weight:700; font-size:11px; color:#10b981; text-transform:uppercase; letter-spacing:0.5px;">SIGEF</span>
104
+ <span style="font-size:10px; color:rgba(255, 255, 255, 0.5);">${P(w.situacao_informada || w.status || "Certificada")}</span>
105
+ </div>
106
+ <div style="font-weight:700; font-size:12px; margin-bottom:4px; color:#ffffff; word-break:break-word;">${P(m)}</div>
107
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.7); margin-bottom:2px;">Cód: <span style="font-family:monospace;">${P(w.codigo_imovel || "N/A")}</span></div>
108
+ <div style="display:flex; gap:12px; font-size:11px; color:rgba(255, 255, 255, 0.7); margin-bottom:6px;">
109
+ <span>Mat: <strong style="color:#ffffff;">${P(w.registro_matricula || w.matricula || "N/A")}</strong></span>
110
+ <span>${P(w.data_submissao || "")}</span>
111
+ </div>
112
+ <div style="display:flex; flex-direction:column; gap:5px; padding-top:6px; border-top:1px solid rgba(255, 255, 255, 0.1);">
113
+ <a href="${L}" target="_blank" rel="noopener noreferrer" style="display:flex; align-items:center; justify-content:center; gap:5px; padding:5px 8px; background:rgba(16, 185, 129, 0.15); border:1px solid rgba(16, 185, 129, 0.3); color:#34d399; font-size:11px; font-weight:700; border-radius:5px; text-decoration:none; cursor:pointer;">
114
+ <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
115
+ Baixar Shapefile
116
+ </a>
117
+ <button class="btn-importar-confrontante-sigef" style="display:flex; align-items:center; justify-content:center; gap:5px; padding:5px 8px; background:rgba(14, 165, 233, 0.15); border:1px solid rgba(14, 165, 233, 0.3); color:#38bdf8; font-size:11px; font-weight:700; border-radius:5px; cursor:pointer; width:100%; text-align:center;">
118
+ <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
119
+ Importar Confrontante (CSV)
120
+ </button>
121
+ <a href="${_}" target="_blank" rel="noopener noreferrer" style="display:flex; align-items:center; justify-content:center; gap:4px; padding:4px 6px; background:rgba(255, 255, 255, 0.05); border:1px solid rgba(255, 255, 255, 0.1); color:rgba(255, 255, 255, 0.7); font-size:10px; font-weight:600; border-radius:5px; text-decoration:none; cursor:pointer;">
122
+ <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
123
+ Abrir no SIGEF
124
+ </a>
125
+ </div>
126
+ `;
127
+ const N = k.querySelector(".btn-importar-confrontante-sigef");
128
+ N && N.addEventListener("click", () => {
129
+ window.dispatchEvent(
130
+ new CustomEvent("gerencigeo:importar_vizinho_sigef", {
131
+ detail: { uuid: g, nome: m }
132
+ })
133
+ );
134
+ }), h.setContent(k);
135
+ } else
136
+ h.setContent(`
137
+ <div style="font-family:sans-serif; font-size:12px; color:#b45309; padding:2px 0;">
138
+ Lote identificado, mas código da parcela indisponível.
139
+ </div>
140
+ `);
141
+ } else
142
+ h.setContent(`
143
+ <div style="font-family:sans-serif; font-size:12px; color:rgba(255, 255, 255, 0.7); padding:2px 0;">
144
+ Nenhum imóvel SIGEF certificado neste ponto.
145
+ </div>
146
+ `);
147
+ } catch (b) {
148
+ b.name === "AbortError" ? h.setContent(`
149
+ <div style="font-family:sans-serif; font-size:12px; color:#f59e0b; padding:2px 0;">
150
+ Consulta cancelada ou tempo limite de resposta esgotado.
151
+ </div>
152
+ `) : (console.warn("Erro ao consultar SIGEF:", b), h.setContent(`
153
+ <div style="font-family:sans-serif; font-size:12px; color:#f59e0b; padding:2px 0;">
154
+ Serviço de consulta SIGEF indisponível nesta área.
155
+ </div>
156
+ `));
157
+ } finally {
158
+ f.style.cursor = "";
159
+ }
160
+ }
161
+ function bt(n, t) {
162
+ if (!n) return;
163
+ const e = Math.floor(n.getZoom()), o = Math.max(e, 12), i = Math.min(e + 1, 19), s = t.pad(0.2), a = ["mt0", "mt1", "mt2", "mt3"];
164
+ let c = 0;
165
+ const r = 32;
166
+ for (let l = o; l <= i && c < r; l++) {
167
+ const p = s.getNorthWest(), d = s.getSouthEast(), f = nt(p.lng, l), h = nt(d.lng, l), y = st(p.lat, l), S = st(d.lat, l);
168
+ for (let b = f; b <= h && c < r; b++)
169
+ for (let M = y; M <= S && c < r; M++) {
170
+ const z = `https://${a[(b + M) % a.length]}.google.com/vt/lyrs=s,h&x=${b}&y=${M}&z=${l}`, E = new Image();
171
+ E.src = z, c++;
172
+ }
173
+ }
174
+ }
175
+ function nt(n, t) {
176
+ return Math.floor((n + 180) / 360 * Math.pow(2, t));
177
+ }
178
+ function st(n, t) {
179
+ const e = n * Math.PI / 180;
180
+ return Math.floor(
181
+ (1 - Math.log(Math.tan(e) + 1 / Math.cos(e)) / Math.PI) / 2 * Math.pow(2, t)
182
+ );
183
+ }
184
+ class xt {
185
+ constructor(t) {
186
+ u(this, "map", null);
187
+ u(this, "configManager", Q.getInstance());
188
+ u(this, "config", this.configManager.getConfig());
189
+ u(this, "apiBaseUrl", "/api");
190
+ u(this, "bancoPontosGroup", v.layerGroup());
191
+ u(this, "pontosVizinhosGroup", v.layerGroup());
192
+ u(this, "controller");
193
+ u(this, "containerElement", null);
194
+ u(this, "bc");
195
+ u(this, "sigefState", {});
196
+ this.controller = t;
197
+ }
198
+ init(t) {
199
+ if (this.map)
200
+ try {
201
+ this.map.off(), this.map.remove();
202
+ } catch {
203
+ } finally {
204
+ this.map = null;
205
+ }
206
+ const e = typeof t == "string" ? document.getElementById(t) : t;
207
+ if (!e) return null;
208
+ if (this.containerElement = e, e._leaflet_id)
209
+ try {
210
+ delete e._leaflet_id;
211
+ } catch {
212
+ e._leaflet_id = void 0;
213
+ }
214
+ if (this.map = v.map(e, {
215
+ maxZoom: 24,
216
+ scrollWheelZoom: !0,
217
+ preferCanvas: this.config.preferCanvas !== void 0 ? this.config.preferCanvas : !0,
218
+ zoomControl: !1
219
+ }).setView([-23.7661, -53.3204], 14), this.listenConfigBroadcast(), this.applyMapStyles(), !this.map.getPane("sigefPane")) {
220
+ const o = this.map.createPane("sigefPane");
221
+ o.style.zIndex = "390";
222
+ }
223
+ if (!this.map.getPane("perimetroPane")) {
224
+ const o = this.map.createPane("perimetroPane");
225
+ o.style.zIndex = "450";
226
+ }
227
+ if (!this.map.getPane("verticesPane")) {
228
+ const o = this.map.createPane("verticesPane");
229
+ o.style.zIndex = "650";
230
+ }
231
+ return v.control.scale({
232
+ metric: !0,
233
+ imperial: !1,
234
+ position: "bottomleft"
235
+ }).addTo(this.map), this.map.on("click", (o) => {
236
+ if (this.controller.modoCliqueSequencialAtivo || this.controller.canvasInteracao && this.controller.canvasInteracao.selectionHappened) return;
237
+ (this.controller.layerManager ? this.controller.layerManager.isLayerActiveAndSelectable("sigef") : !1) && this.consultarSigef(o);
238
+ }), setTimeout(() => {
239
+ this.invalidateSize();
240
+ }, 250), this.map;
241
+ }
242
+ invalidateSize(t = !1) {
243
+ var e, o;
244
+ if (this.map)
245
+ try {
246
+ const i = (o = (e = this.map).getContainer) == null ? void 0 : o.call(e);
247
+ if (!i || !i.parentNode) return;
248
+ this.map.invalidateSize({ animate: t, pan: !1 });
249
+ } catch {
250
+ }
251
+ }
252
+ applyMapStyles() {
253
+ const t = this.containerElement || document.getElementById("mapa-triagem");
254
+ t && (t.style.cursor = this.config.crosshair ? "crosshair" : "");
255
+ }
256
+ listenConfigBroadcast() {
257
+ if (!(typeof BroadcastChannel > "u"))
258
+ try {
259
+ this.bc = new BroadcastChannel("gerencigeo_map_config"), this.bc.onmessage = (t) => {
260
+ t.data === "RELOAD_REQUIRED" && (this.config = this.configManager.getConfig(), this.applyMapStyles(), window.dispatchEvent(new CustomEvent("gerencigeo:map_config_changed", { detail: this.config })));
261
+ };
262
+ } catch {
263
+ }
264
+ }
265
+ destroy() {
266
+ if (this.sigefState.currentAbortController && (this.sigefState.currentAbortController.abort(), this.sigefState.currentAbortController = void 0), this.bc) {
267
+ try {
268
+ this.bc.close();
269
+ } catch {
270
+ }
271
+ this.bc = void 0;
272
+ }
273
+ if (this.map)
274
+ try {
275
+ this.map.off(), this.map.remove();
276
+ } catch {
277
+ } finally {
278
+ this.map = null;
279
+ }
280
+ if (this.containerElement && this.containerElement._leaflet_id)
281
+ try {
282
+ delete this.containerElement._leaflet_id;
283
+ } catch {
284
+ this.containerElement._leaflet_id = void 0;
285
+ }
286
+ }
287
+ preCarregarTilesRegiao(t) {
288
+ bt(this.map, t);
289
+ }
290
+ async consultarSigef(t) {
291
+ this.map && await yt(this.map, t, this.apiBaseUrl, this.sigefState);
292
+ }
293
+ }
294
+ const Pt = [
295
+ "verticesPane",
296
+ "perimetroPane",
297
+ "overlayPane",
298
+ "markerPane",
299
+ "pane-vertices",
300
+ "pane-perimetro",
301
+ "pane-vizinhos",
302
+ "pane-homologados",
303
+ "pane-homologados-pontos"
304
+ ];
305
+ class wt {
306
+ constructor(t, e, o) {
307
+ u(this, "map");
308
+ u(this, "mapContainer");
309
+ u(this, "ctx");
310
+ u(this, "selectionDiv", null);
311
+ u(this, "isSelecting", !1);
312
+ u(this, "selectStartPos", { x: 0, y: 0 });
313
+ u(this, "selectStartPoint", null);
314
+ this.map = t, this.mapContainer = e, this.ctx = o, this.criarDivSelecao();
315
+ }
316
+ criarDivSelecao() {
317
+ this.selectionDiv || (this.selectionDiv = document.createElement("div"), this.selectionDiv.className = "cad-selection-box", this.selectionDiv.style.position = "absolute", this.selectionDiv.style.zIndex = "9999", this.selectionDiv.style.pointerEvents = "none", this.selectionDiv.style.display = "none", this.selectionDiv.style.borderRadius = "2px", this.mapContainer.style.position = "relative", this.mapContainer.appendChild(this.selectionDiv));
318
+ }
319
+ setPanesPointerEvents(t) {
320
+ Pt.forEach((e) => {
321
+ const o = this.map.getPane(e);
322
+ o && (o.style.pointerEvents = t);
323
+ });
324
+ }
325
+ iniciarSelecao(t) {
326
+ const e = this.mapContainer.getBoundingClientRect(), o = t.clientX - e.left, i = t.clientY - e.top;
327
+ this.isSelecting = !0, this.selectStartPos = { x: o, y: i }, this.selectStartPoint = this.map.mouseEventToContainerPoint(t), this.selectionDiv && (this.selectionDiv.style.left = `${o}px`, this.selectionDiv.style.top = `${i}px`, this.selectionDiv.style.width = "0px", this.selectionDiv.style.height = "0px", this.selectionDiv.style.display = "block"), this.setPanesPointerEvents("none");
328
+ }
329
+ atualizarSelecao(t) {
330
+ if (!this.isSelecting || !this.selectionDiv) return;
331
+ const e = this.mapContainer.getBoundingClientRect(), o = t.clientX - e.left, i = t.clientY - e.top, s = Math.abs(o - this.selectStartPos.x), a = Math.abs(i - this.selectStartPos.y), c = Math.min(o, this.selectStartPos.x), r = Math.min(i, this.selectStartPos.y);
332
+ this.selectionDiv.style.left = `${Math.round(c)}px`, this.selectionDiv.style.top = `${Math.round(r)}px`, this.selectionDiv.style.width = `${Math.round(s)}px`, this.selectionDiv.style.height = `${Math.round(a)}px`, o >= this.selectStartPos.x ? (this.selectionDiv.style.background = "rgba(14, 116, 144, 0.22)", this.selectionDiv.style.border = "1px solid #06b6d4") : (this.selectionDiv.style.background = "rgba(16, 185, 129, 0.22)", this.selectionDiv.style.border = "1px dashed #10b981");
333
+ }
334
+ finalizarSelecao(t, e, o) {
335
+ var M, I, z, E, w, g;
336
+ if (!this.isSelecting) return !1;
337
+ this.isSelecting = !1, this.selectionDiv && (this.selectionDiv.style.display = "none"), this.map.closePopup(), setTimeout(() => {
338
+ try {
339
+ this.setPanesPointerEvents("auto"), this.ctx.layerManager && this.ctx.layerManager.ensurePanes();
340
+ } catch {
341
+ }
342
+ }, 80);
343
+ const i = this.mapContainer.getBoundingClientRect(), s = t.clientX - i.left, a = t.clientY - i.top, c = this.map.mouseEventToContainerPoint(t), r = Math.abs(s - this.selectStartPos.x), l = Math.abs(a - this.selectStartPos.y);
344
+ if (r < 4 && l < 4) {
345
+ const m = t.target;
346
+ return m && ((M = m.classList) != null && M.contains("leaflet-container") || m.id === "mapa-triagem" || (I = m.closest) != null && I.call(m, ".leaflet-pane")) && ((z = m.closest) != null && z.call(m, ".custom-leaflet-marker") || (E = m.closest) != null && E.call(m, ".custom-div-icon") || o()), !1;
347
+ }
348
+ if (!this.selectStartPoint) return !1;
349
+ const p = {
350
+ x1: Math.min(this.selectStartPoint.x, c.x),
351
+ y1: Math.min(this.selectStartPoint.y, c.y),
352
+ x2: Math.max(this.selectStartPoint.x, c.x),
353
+ y2: Math.max(this.selectStartPoint.y, c.y)
354
+ }, d = ((w = this.ctx.mapaController) == null ? void 0 : w.getMarkers()) || [], f = ((g = this.ctx.mapaController) == null ? void 0 : g.getVizinhosMarkers()) || [], h = [], y = [], S = !this.ctx.layerManager || this.ctx.layerManager.isLayerActiveAndSelectable("vertices"), b = !this.ctx.layerManager || this.ctx.layerManager.isLayerActiveAndSelectable("vizinhos");
355
+ return S && d.forEach((m) => {
356
+ const x = m.pontoId;
357
+ if (!x) return;
358
+ const L = this.map.latLngToContainerPoint(m.getLatLng());
359
+ L.x >= p.x1 && L.x <= p.x2 && L.y >= p.y1 && L.y <= p.y2 && h.push(x);
360
+ }), b && f.forEach((m) => {
361
+ const x = m.pontoId;
362
+ if (!x) return;
363
+ const L = this.map.latLngToContainerPoint(m.getLatLng());
364
+ L.x >= p.x1 && L.x <= p.x2 && L.y >= p.y1 && L.y <= p.y2 && y.push(x);
365
+ }), t.ctrlKey || t.metaKey ? (h.forEach((m) => {
366
+ this.ctx.selectedPontoIds.includes(m) ? this.ctx.selectedPontoIds = this.ctx.selectedPontoIds.filter((x) => x !== m) : this.ctx.selectedPontoIds.push(m);
367
+ }), y.forEach((m) => {
368
+ this.ctx.selectedVizinhoPontoIds.includes(m) ? this.ctx.selectedVizinhoPontoIds = this.ctx.selectedVizinhoPontoIds.filter((x) => x !== m) : this.ctx.selectedVizinhoPontoIds.push(m);
369
+ })) : (this.ctx.selectedPontoIds = h, this.ctx.selectedVizinhoPontoIds = y), this.ctx.selectedPontoIds.length > 0 && (this.ctx.lastSelectedPontoId = this.ctx.selectedPontoIds[this.ctx.selectedPontoIds.length - 1]), e(), !0;
370
+ }
371
+ cancelarSelecao() {
372
+ this.isSelecting && (this.isSelecting = !1, this.selectionDiv && (this.selectionDiv.style.display = "none"), this.setPanesPointerEvents("auto"), this.ctx.layerManager && this.ctx.layerManager.ensurePanes());
373
+ }
374
+ destruir() {
375
+ this.selectionDiv && this.selectionDiv.parentNode && (this.selectionDiv.parentNode.removeChild(this.selectionDiv), this.selectionDiv = null), this.setPanesPointerEvents("auto");
376
+ }
377
+ }
378
+ class Ct {
379
+ constructor(t) {
380
+ u(this, "ctx");
381
+ u(this, "map", null);
382
+ u(this, "mapContainer", null);
383
+ u(this, "selecaoBox", null);
384
+ // Estados de Pan (Rodinha)
385
+ u(this, "isPanning", !1);
386
+ u(this, "lastMousePos", { x: 0, y: 0 });
387
+ u(this, "lastMiddleClickTime", 0);
388
+ // Estados de Toque (Mobile/Tablet)
389
+ u(this, "touchStartPos", { x: 0, y: 0 });
390
+ u(this, "touchStartDist", 0);
391
+ u(this, "isTouchPanning", !1);
392
+ u(this, "selectionHappened", !1);
393
+ u(this, "panHappened", !1);
394
+ u(this, "handleTouchStart", (t) => {
395
+ if (!(!this.map || !this.mapContainer)) {
396
+ if (t.touches.length === 1)
397
+ this.isTouchPanning = !0, this.touchStartPos = { x: t.touches[0].clientX, y: t.touches[0].clientY };
398
+ else if (t.touches.length === 2) {
399
+ this.isTouchPanning = !1;
400
+ const e = t.touches[0].clientX - t.touches[1].clientX, o = t.touches[0].clientY - t.touches[1].clientY;
401
+ this.touchStartDist = Math.hypot(e, o);
402
+ }
403
+ }
404
+ });
405
+ u(this, "handleTouchMove", (t) => {
406
+ if (!(!this.map || !this.mapContainer)) {
407
+ if (t.touches.length === 1 && this.isTouchPanning) {
408
+ t.preventDefault(), this.panHappened = !0;
409
+ const e = this.touchStartPos.x - t.touches[0].clientX, o = this.touchStartPos.y - t.touches[0].clientY;
410
+ this.map.panBy([e, o], { animate: !1 }), this.touchStartPos = { x: t.touches[0].clientX, y: t.touches[0].clientY };
411
+ } else if (t.touches.length === 2 && this.touchStartDist > 0) {
412
+ t.preventDefault(), this.panHappened = !0;
413
+ const e = t.touches[0].clientX - t.touches[1].clientX, o = t.touches[0].clientY - t.touches[1].clientY, i = Math.hypot(e, o);
414
+ Math.abs(i - this.touchStartDist) > 25 && (i > this.touchStartDist ? this.map.zoomIn(1) : this.map.zoomOut(1), this.touchStartDist = i);
415
+ }
416
+ }
417
+ });
418
+ u(this, "handleTouchEnd", () => {
419
+ this.isTouchPanning = !1, this.touchStartDist = 0, setTimeout(() => {
420
+ this.panHappened = !1;
421
+ }, 120);
422
+ });
423
+ u(this, "handleContextMenu", (t) => {
424
+ t.preventDefault();
425
+ });
426
+ u(this, "handleMouseDown", (t) => {
427
+ var e;
428
+ if (!(!this.map || !this.mapContainer)) {
429
+ if (t.button === 1) {
430
+ t.preventDefault();
431
+ const o = Date.now();
432
+ if (o - this.lastMiddleClickTime < 300) {
433
+ this.zoomExtents();
434
+ return;
435
+ }
436
+ this.lastMiddleClickTime = o, this.isPanning = !0, this.panHappened = !1, this.lastMousePos = { x: t.clientX, y: t.clientY }, this.mapContainer.style.cursor = "grabbing";
437
+ return;
438
+ }
439
+ if (t.button === 0) {
440
+ if (this.selectionHappened = !1, this.ctx.mapaController && this.ctx.mapaController.modoCliqueSequencialAtivo)
441
+ return;
442
+ (e = this.selecaoBox) == null || e.iniciarSelecao(t);
443
+ }
444
+ }
445
+ });
446
+ u(this, "handleMouseMove", (t) => {
447
+ var e;
448
+ if (!(!this.map || !this.mapContainer)) {
449
+ if (this.isPanning) {
450
+ const o = this.lastMousePos.x - t.clientX, i = this.lastMousePos.y - t.clientY;
451
+ (Math.abs(o) > 1 || Math.abs(i) > 1) && (this.panHappened = !0), this.map.panBy([o, i], { animate: !1 }), this.lastMousePos = { x: t.clientX, y: t.clientY };
452
+ return;
453
+ }
454
+ (e = this.selecaoBox) == null || e.atualizarSelecao(t);
455
+ }
456
+ });
457
+ u(this, "handleMouseUp", (t) => {
458
+ this.isPanning && (this.isPanning = !1, this.mapContainer && (this.mapContainer.style.cursor = "grab"), setTimeout(() => {
459
+ this.panHappened = !1;
460
+ }, 120)), this.selecaoBox && this.selecaoBox.isSelecting && this.selecaoBox.finalizarSelecao(
461
+ t,
462
+ () => this.notificarSelecao(),
463
+ () => this.limparSelecao()
464
+ ) && (this.selectionHappened = !0, setTimeout(() => {
465
+ this.selectionHappened = !1;
466
+ }, 120));
467
+ });
468
+ u(this, "handleKeyDown", (t) => {
469
+ var e;
470
+ if (t.key === "Escape") {
471
+ const o = document.activeElement;
472
+ if (o && (o.tagName === "INPUT" || o.tagName === "TEXTAREA" || o.tagName === "SELECT" || o.isContentEditable))
473
+ return;
474
+ (e = this.selecaoBox) == null || e.cancelarSelecao(), this.limparSelecao();
475
+ }
476
+ });
477
+ this.ctx = {
478
+ selectedPontoIds: [],
479
+ selectedVizinhoPontoIds: [],
480
+ lastSelectedPontoId: null,
481
+ pontosList: [],
482
+ ...t
483
+ };
484
+ }
485
+ ativar(t, e) {
486
+ this.ctx.mapaController = t, e && (this.ctx.containerHost = e), this.map = t.getMap(), this.map && (this.mapContainer = this.map.getContainer(), this.mapContainer && (this.map.dragging.disable(), this.map.doubleClickZoom.disable(), this.selecaoBox = new wt(this.map, this.mapContainer, this.ctx), this.mapContainer.addEventListener("mousedown", this.handleMouseDown), this.mapContainer.addEventListener("mousemove", this.handleMouseMove), window.addEventListener("mouseup", this.handleMouseUp), this.mapContainer.addEventListener("contextmenu", this.handleContextMenu), window.addEventListener("keydown", this.handleKeyDown), this.mapContainer.addEventListener("touchstart", this.handleTouchStart, { passive: !1 }), this.mapContainer.addEventListener("touchmove", this.handleTouchMove, { passive: !1 }), this.mapContainer.addEventListener("touchend", this.handleTouchEnd), this.mapContainer.addEventListener("touchcancel", this.handleTouchEnd)));
487
+ }
488
+ desativar() {
489
+ this.mapContainer && (this.mapContainer.removeEventListener("mousedown", this.handleMouseDown), this.mapContainer.removeEventListener("mousemove", this.handleMouseMove), this.mapContainer.removeEventListener("contextmenu", this.handleContextMenu), this.mapContainer.removeEventListener("touchstart", this.handleTouchStart), this.mapContainer.removeEventListener("touchmove", this.handleTouchMove), this.mapContainer.removeEventListener("touchend", this.handleTouchEnd), this.mapContainer.removeEventListener("touchcancel", this.handleTouchEnd)), window.removeEventListener("mouseup", this.handleMouseUp), window.removeEventListener("keydown", this.handleKeyDown), this.selecaoBox && (this.selecaoBox.destruir(), this.selecaoBox = null), this.map && (this.map.dragging.enable(), this.map.doubleClickZoom.enable());
490
+ }
491
+ limparSelecao() {
492
+ var t, e;
493
+ (this.ctx.selectedPontoIds.length > 0 || this.ctx.selectedVizinhoPontoIds.length > 0) && (this.ctx.selectedPontoIds = [], this.ctx.selectedVizinhoPontoIds = [], this.ctx.lastSelectedPontoId = null, this.ctx.mapaController && (this.ctx.mapaController.context.selectedPontoIds = [], (e = (t = this.ctx.mapaController).atualizarDestaqueMarcadores) == null || e.call(t)), this.notificarSelecao());
494
+ }
495
+ notificarSelecao() {
496
+ var t, e;
497
+ this.ctx.mapaController && (this.ctx.mapaController.context.selectedPontoIds = [...this.ctx.selectedPontoIds], (e = (t = this.ctx.mapaController).atualizarDestaqueMarcadores) == null || e.call(t)), this.ctx.atualizarDestaqueLinhasTabela && this.ctx.atualizarDestaqueLinhasTabela(), this.ctx.onSelectionChange && this.ctx.onSelectionChange(this.ctx.selectedPontoIds, this.ctx.selectedVizinhoPontoIds), window.dispatchEvent(new CustomEvent("gerencigeo:ponto-selecionado", {
498
+ detail: {
499
+ selectedPontoIds: this.ctx.selectedPontoIds,
500
+ selectedVizinhoPontoIds: this.ctx.selectedVizinhoPontoIds,
501
+ lastSelectedPontoId: this.ctx.lastSelectedPontoId
502
+ }
503
+ }));
504
+ }
505
+ zoomExtents() {
506
+ if (!this.ctx.pontosList || this.ctx.pontosList.length === 0) return;
507
+ const t = this.ctx.pontosList.filter((e) => e.tipo_ponto !== "B" && e.tipo !== "B");
508
+ t.length > 0 && this.ctx.mapaController && this.ctx.mapaController.fitBounds(t);
509
+ }
510
+ destroy() {
511
+ this.desativar();
512
+ }
513
+ }
514
+ class j {
515
+ static register(t, e) {
516
+ this.renderers.set(t.toLowerCase(), e);
517
+ }
518
+ static get(t) {
519
+ return this.renderers.get(t.toLowerCase());
520
+ }
521
+ static has(t) {
522
+ return this.renderers.has(t.toLowerCase());
523
+ }
524
+ static getRegisteredTypes() {
525
+ return Array.from(this.renderers.keys());
526
+ }
527
+ }
528
+ u(j, "renderers", /* @__PURE__ */ new Map());
529
+ class St {
530
+ render(t, e, o) {
531
+ var r, l, p;
532
+ const i = ((r = t.dados) == null ? void 0 : r.url) || "https://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}", s = ((l = t.dados) == null ? void 0 : l.subdomains) || ["mt0", "mt1", "mt2", "mt3"], a = ((p = t.dados) == null ? void 0 : p.attribution) || "Google Satélite";
533
+ return v.tileLayer(i, {
534
+ maxZoom: 24,
535
+ maxNativeZoom: 20,
536
+ subdomains: s,
537
+ attribution: a,
538
+ keepBuffer: 16,
539
+ updateWhenZooming: !1,
540
+ updateWhenIdle: !0,
541
+ className: "smooth-zoom-layer",
542
+ opacity: t.opacidade !== void 0 ? t.opacidade : 1,
543
+ pane: `pane-${t.id}`
544
+ });
545
+ }
546
+ update(t, e, o) {
547
+ e instanceof v.TileLayer && o.opacidade !== void 0 && e.setOpacity(o.opacidade);
548
+ }
549
+ destroy(t, e) {
550
+ e.hasLayer(t) && e.removeLayer(t);
551
+ }
552
+ }
553
+ class Mt {
554
+ render(t, e, o) {
555
+ var l, p, d, f;
556
+ const i = ((l = t.dados) == null ? void 0 : l.url) || "https://acervofundiario.incra.gov.br/i3geo/ogc.php", s = ((p = t.dados) == null ? void 0 : p.layers) || "certificada_sigef_particular_pr", a = ((d = t.dados) == null ? void 0 : d.format) || "image/png", c = ((f = t.dados) == null ? void 0 : f.attribution) || "INCRA/SIGEF";
557
+ return v.tileLayer.wms(i, {
558
+ layers: s,
559
+ format: a,
560
+ transparent: !0,
561
+ version: "1.1.1",
562
+ pane: `pane-${t.id}`,
563
+ attribution: c,
564
+ className: "sigef-wms-layer",
565
+ keepBuffer: 8,
566
+ updateWhenZooming: !1,
567
+ updateWhenIdle: !0,
568
+ opacity: t.opacidade !== void 0 ? t.opacidade : 0.85
569
+ });
570
+ }
571
+ update(t, e, o) {
572
+ e instanceof v.TileLayer.WMS && o.opacidade !== void 0 && e.setOpacity(o.opacidade);
573
+ }
574
+ destroy(t, e) {
575
+ e.hasLayer(t) && e.removeLayer(t);
576
+ }
577
+ }
578
+ function pt(n, t, e) {
579
+ const o = n.estilo.espessuraLinha || e.config.perimetroWeight || 2, i = e.graphicScale.lineScaleMultiplier || 1;
580
+ if (n.estilo.scaleMode === "world") {
581
+ const s = n.estilo.dimensaoMetros || 0.3, a = t.getCenter(), c = t.getZoom(), r = 40075016686e-3 * Math.abs(Math.cos(a.lat * Math.PI / 180)) / Math.pow(2, c + 8), l = s / (r > 0 ? r : 1);
582
+ return Math.max(1, Math.round(l * i));
583
+ }
584
+ return Math.max(1, Math.round(o * i));
585
+ }
586
+ function at(n, t, e, o, i) {
587
+ var y, S, b, M, I, z, E, w;
588
+ const s = n.id === "homologados", a = ((y = n.dados) == null ? void 0 : y.conexoes) ?? (Array.isArray(n.dados) && n.dados.length > 0 && "origemId" in n.dados[0] ? n.dados : null), c = ((S = n.dados) == null ? void 0 : S.segmentos) || o.segmentos || [], r = ((b = n.dados) == null ? void 0 : b.pontos) || (s ? o.bancoPontos || [] : o.pontos) || [], l = pt(n, e, o), p = n.opacidade !== void 0 ? n.opacidade : 1, d = n.interativo && !n.bloqueada, f = [];
589
+ r.forEach((g) => {
590
+ const m = O(g.lat ?? g.latitude ?? g.y, g.lon ?? g.lng ?? g.longitude ?? g.x);
591
+ m && f.push({ ...g, lat: m.lat, lon: m.lon });
592
+ });
593
+ const h = (g) => {
594
+ const m = f.find((x) => String(x.id) === String(g));
595
+ if (m) return m;
596
+ if (o.pontos) {
597
+ const x = o.pontos.find((L) => String(L.id) === String(g));
598
+ if (x) {
599
+ const L = O(x.lat, x.lon);
600
+ if (L) return { ...x, lat: L.lat, lon: L.lon };
601
+ }
602
+ }
603
+ return null;
604
+ };
605
+ if (a && Array.isArray(a)) {
606
+ a.forEach((g) => {
607
+ var L, _, k, N, q, V, C;
608
+ const m = h(g.origemId), x = h(g.destinoId);
609
+ if (m && x && m.lat && m.lon && x.lat && x.lon) {
610
+ const $ = g.tipoLinha === "tracejada" || ((L = g.estilo) == null ? void 0 : L.tipoLinha) === "tracejada", T = ((_ = g.estilo) == null ? void 0 : _.cor) || ((k = g.estilo) == null ? void 0 : k.color) || n.estilo.corPrimaria || "#00f5a0", B = ((N = g.estilo) == null ? void 0 : N.espessura) || ((q = g.estilo) == null ? void 0 : q.weight) || l, A = v.polyline([[m.lat, m.lon], [x.lat, x.lon]], {
611
+ color: T,
612
+ weight: B,
613
+ opacity: ((V = g.estilo) == null ? void 0 : V.opacidade) ?? p,
614
+ dashArray: $ ? "6, 6" : n.estilo.dashArray,
615
+ pane: i,
616
+ interactive: d
617
+ });
618
+ if (d) {
619
+ const G = g.acoes || n.acoes || ((C = n.dados) == null ? void 0 : C.acoes) || [], H = `${g.origemId}-${g.destinoId}`, D = W(G, H);
620
+ A.bindPopup(`
621
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.3;">
622
+ <div style="font-weight:700; font-size:12px; margin-bottom:3px; color:#ffffff;">Conexão ${P(String(g.origemId))} ↔ ${P(String(g.destinoId))}</div>
623
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.65);">Tipo: ${P(g.tipoLinha || "contínua")}</div>
624
+ ${D}
625
+ </div>
626
+ `, { className: "compact-popup", maxWidth: 220 }), A.on("popupopen", (R) => {
627
+ if (o.modoSequencial) {
628
+ A.closePopup();
629
+ return;
630
+ }
631
+ Y(R.popup, g, o, A);
632
+ });
633
+ }
634
+ A.addTo(t);
635
+ }
636
+ });
637
+ return;
638
+ }
639
+ if ((M = n.dados) != null && M.polilinhaSequencial || ((I = n.dados) == null ? void 0 : I.fechar) !== void 0 && f.length >= 2) {
640
+ const g = ((z = n.dados) == null ? void 0 : z.chaveGrupo) || o.chaveGrupo, m = K(f, g), x = ((E = n.dados) == null ? void 0 : E.fechar) !== !1, L = n.estilo.corPrimaria || "#00f5a0";
641
+ Object.entries(m).forEach(([_, k]) => {
642
+ const N = J(k);
643
+ if (N.length < 2) return;
644
+ const q = N.map((C) => [C.lat, C.lon]), V = v.polyline(q, {
645
+ color: L,
646
+ weight: l,
647
+ opacity: p,
648
+ dashArray: n.estilo.dashArray,
649
+ pane: i,
650
+ interactive: d
651
+ });
652
+ if (d && V.bindPopup(`
653
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.3;">
654
+ <div style="font-weight:700; font-size:12px; margin-bottom:3px; color:#ffffff;">Polilinha: Grupo ${P(_)}</div>
655
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.65);">Vértices: ${N.length}</div>
656
+ </div>
657
+ `, { className: "compact-popup", maxWidth: 220 }), V.addTo(t), x && q.length >= 3) {
658
+ const C = q[q.length - 1], $ = q[0];
659
+ v.polyline([C, $], {
660
+ color: L,
661
+ weight: l,
662
+ opacity: p,
663
+ dashArray: "4, 4",
664
+ pane: i,
665
+ interactive: d
666
+ }).addTo(t);
667
+ }
668
+ });
669
+ return;
670
+ }
671
+ if (!s && c && c.length > 0)
672
+ c.forEach((g) => {
673
+ var L;
674
+ const m = f.find((_) => String(_.id) === String(g.ponto_inicio_id)), x = f.find((_) => String(_.id) === String(g.ponto_fim_id));
675
+ if (m && x && m.lat && m.lon && x.lat && x.lon) {
676
+ const _ = g.tipo_limite_sigef || g.tipo_limite || "", k = g.metodo_posicionamento_sigef || g.metodo_posicionamento || "", N = _ === "LA1" ? "#10b981" : _ === "LN1" ? "#3b82f6" : "#00f5a0", q = n.estilo.corPrimaria || N, V = v.polyline([[m.lat, m.lon], [x.lat, x.lon]], {
677
+ color: q,
678
+ weight: l,
679
+ opacity: p,
680
+ dashArray: _ === "LN1" ? "6, 6" : n.estilo.dashArray,
681
+ pane: i,
682
+ interactive: d
683
+ });
684
+ if (d) {
685
+ const C = g.acoes || n.acoes || ((L = n.dados) == null ? void 0 : L.acoes) || [], $ = `${g.ponto_inicio_id}-${g.ponto_fim_id}`, T = W(C, $);
686
+ V.bindPopup(`
687
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.3;">
688
+ <div style="font-weight:700; font-size:12px; margin-bottom:3px; color:#ffffff;">${P(m.nome_vertice)} ↔ ${P(x.nome_vertice)}</div>
689
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.65);">Limite: ${P(_ || "N/A")} · ${P(k || "N/A")}</div>
690
+ ${T}
691
+ </div>
692
+ `, { className: "compact-popup", maxWidth: 220 }), V.on("popupopen", (B) => {
693
+ if (o.modoSequencial) {
694
+ V.closePopup();
695
+ return;
696
+ }
697
+ Y(B.popup, g, o, V);
698
+ });
699
+ }
700
+ V.addTo(t);
701
+ }
702
+ });
703
+ else if (f && f.length >= 2) {
704
+ const g = f.filter(
705
+ (k) => k.lat && k.lon && k.tipo_ponto !== "B" && k.tipo !== "B" && k.ignorar_poligono !== 1
706
+ ), m = ((w = n.dados) == null ? void 0 : w.chaveGrupo) || o.chaveGrupo, x = K(g, m), L = n.estilo.corPrimaria || (s ? "#f59e0b" : "#10b981"), _ = n.estilo.dashArray || (s ? "6, 8" : void 0);
707
+ Object.values(x).forEach((k) => {
708
+ const N = J(k);
709
+ if (N.length < 2) return;
710
+ const q = N.map((C) => [C.lat, C.lon]);
711
+ if (v.polyline(q, {
712
+ color: L,
713
+ weight: l,
714
+ opacity: p,
715
+ dashArray: _,
716
+ pane: i,
717
+ interactive: d
718
+ }).addTo(t), q.length >= 3) {
719
+ const C = q[q.length - 1], $ = q[0];
720
+ v.polyline([C, $], {
721
+ color: L,
722
+ weight: l,
723
+ opacity: p,
724
+ dashArray: s ? "6, 8" : "4, 4",
725
+ pane: i,
726
+ interactive: d
727
+ }).addTo(t);
728
+ }
729
+ });
730
+ }
731
+ }
732
+ class kt {
733
+ constructor() {
734
+ u(this, "zoomListenerMap", /* @__PURE__ */ new WeakMap());
735
+ }
736
+ render(t, e, o) {
737
+ const i = v.layerGroup(), s = `pane-${t.id}`;
738
+ at(t, i, e, o, s);
739
+ const a = () => {
740
+ if (t.estilo.scaleMode === "world") {
741
+ const c = pt(t, e, o);
742
+ i.eachLayer((r) => {
743
+ r.setStyle && r.setStyle({ weight: c });
744
+ });
745
+ }
746
+ };
747
+ return e.on("zoomend", a), this.zoomListenerMap.set(i, a), i;
748
+ }
749
+ update(t, e, o, i, s) {
750
+ (o.opacidade !== void 0 || o.estilo !== void 0 || o.dados !== void 0 || o.interativo !== void 0 || o.bloqueada !== void 0) && (e.clearLayers(), at(t, e, s, i, `pane-${t.id}`));
751
+ }
752
+ destroy(t, e) {
753
+ const o = this.zoomListenerMap.get(t);
754
+ o && (e.off("zoomend", o), this.zoomListenerMap.delete(t)), t.clearLayers(), e.hasLayer(t) && e.removeLayer(t);
755
+ }
756
+ }
757
+ function Lt(n) {
758
+ if (!n) return "#00f5a0";
759
+ const t = n.trim();
760
+ if (t.startsWith("#") || t.startsWith("rgb") || t.startsWith("hsl") || t.startsWith("var("))
761
+ return t;
762
+ if (t.includes("bg-[#") && t.includes("]")) {
763
+ const o = t.match(/bg-\[(#[a-fA-F0-9]+)\]/);
764
+ if (o) return o[1];
765
+ }
766
+ const e = {
767
+ "bg-mint-vibrant": "#00f5a0",
768
+ "bg-indigo-500": "#6366f1",
769
+ "bg-rose-500": "#f43f5e",
770
+ "bg-amber-500": "#f59e0b",
771
+ "bg-forest-deep": "#06130b",
772
+ "bg-purple-500": "#a855f7",
773
+ "bg-blue-500": "#3b82f6",
774
+ "bg-emerald-500": "#10b981"
775
+ };
776
+ for (const [o, i] of Object.entries(e))
777
+ if (t.includes(o)) return i;
778
+ return "#00f5a0";
779
+ }
780
+ function Z(n, t, e, o = "", i = "", s = !1) {
781
+ const a = s || o.includes("ponto-selecionado") || o.includes("cad-marker-selected"), c = Lt(e), r = t + 6, l = t, p = a ? `box-shadow: 0 0 0 2px #ffffff, 0 0 0 4.5px ${c}, 0 0 16px ${c}; filter: drop-shadow(0 0 4px ${c});` : "box-shadow: 0 1px 4px rgba(0, 0, 0, 0.65), 0 0 1px rgba(0, 0, 0, 0.9);", f = `display:flex; align-items:center; justify-content:center; width:${r}px; height:${r}px; position:relative; pointer-events:auto; ${a ? "transform: scale(1.35); transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);" : "transition: transform 0.15s ease, filter 0.15s ease;"}`, h = `${e} ${o} ${a ? "ponto-selecionado" : ""}`.trim();
782
+ switch (n) {
783
+ case "square":
784
+ return `
785
+ <div id="${i}" class="${h}" style="${f}">
786
+ <div style="width:${l}px; height:${l}px; background-color:${c}; border-radius:2px; border:1px solid rgba(0,0,0,0.4); box-sizing:border-box; ${p}"></div>
787
+ </div>
788
+ `;
789
+ case "circle-dot": {
790
+ const y = Math.max(3, Math.floor(l / 3));
791
+ return `
792
+ <div id="${i}" class="${h}" style="${f}">
793
+ <div style="width:${l}px; height:${l}px; background-color:${c}; border-radius:50%; display:flex; align-items:center; justify-content:center; border:1px solid rgba(0,0,0,0.3); box-sizing:border-box; ${p}">
794
+ <div style="width:${y}px; height:${y}px; background-color:#ffffff; border-radius:50%; box-shadow:0 0 2px rgba(0,0,0,0.8);"></div>
795
+ </div>
796
+ </div>
797
+ `;
798
+ }
799
+ case "diamond":
800
+ return `
801
+ <div id="${i}" class="${h}" style="${f}">
802
+ <svg width="${l + 2}" height="${l + 2}" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" style="overflow:visible; ${a ? `filter: drop-shadow(0 0 3px #ffffff) drop-shadow(0 0 6px ${c});` : "filter: drop-shadow(0 1px 2px rgba(0,0,0,0.7));"}">
803
+ <polygon points="6,1 11,6 6,11 1,6" fill="${c}" stroke="#000000" stroke-width="1.2" stroke-linejoin="round" />
804
+ ${a ? '<polygon points="6,2.5 9.5,6 6,9.5 2.5,6" fill="none" stroke="#ffffff" stroke-width="1" />' : ""}
805
+ </svg>
806
+ </div>
807
+ `;
808
+ case "cross":
809
+ return `
810
+ <div id="${i}" class="${h}" style="${f}">
811
+ <svg width="${l + 4}" height="${l + 4}" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" style="overflow:visible; ${a ? `filter: drop-shadow(0 0 3px #ffffff) drop-shadow(0 0 6px ${c});` : "filter: drop-shadow(0 1px 2px rgba(0,0,0,0.7));"}">
812
+ ${a ? '<circle cx="6" cy="6" r="5.5" stroke="#ffffff" stroke-width="1.2" stroke-dasharray="2 2" fill="none" />' : ""}
813
+ <!-- Halo escuro de contraste para satélite -->
814
+ <line x1="6" y1="1" x2="6" y2="11" stroke="#000000" stroke-width="3" stroke-linecap="round" />
815
+ <line x1="1" y1="6" x2="11" y2="6" stroke="#000000" stroke-width="3" stroke-linecap="round" />
816
+ <!-- Traço colorido do marcador -->
817
+ <line x1="6" y1="1" x2="6" y2="11" stroke="${c}" stroke-width="${a ? "2.2" : "1.6"}" stroke-linecap="round" />
818
+ <line x1="1" y1="6" x2="11" y2="6" stroke="${c}" stroke-width="${a ? "2.2" : "1.6"}" stroke-linecap="round" />
819
+ </svg>
820
+ </div>
821
+ `;
822
+ case "x":
823
+ return `
824
+ <div id="${i}" class="${h}" style="${f}">
825
+ <svg width="${l + 4}" height="${l + 4}" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" style="overflow:visible; ${a ? `filter: drop-shadow(0 0 3px #ffffff) drop-shadow(0 0 6px ${c});` : "filter: drop-shadow(0 1px 2px rgba(0,0,0,0.7));"}">
826
+ ${a ? '<circle cx="6" cy="6" r="5.5" stroke="#ffffff" stroke-width="1.2" stroke-dasharray="2 2" fill="none" />' : ""}
827
+ <!-- Halo escuro de contraste para satélite -->
828
+ <line x1="2" y1="2" x2="10" y2="10" stroke="#000000" stroke-width="3" stroke-linecap="round" />
829
+ <line x1="10" y1="2" x2="2" y2="10" stroke="#000000" stroke-width="3" stroke-linecap="round" />
830
+ <!-- Traço colorido do marcador -->
831
+ <line x1="2" y1="2" x2="10" y2="10" stroke="${c}" stroke-width="${a ? "2.2" : "1.6"}" stroke-linecap="round" />
832
+ <line x1="10" y1="2" x2="2" y2="10" stroke="${c}" stroke-width="${a ? "2.2" : "1.6"}" stroke-linecap="round" />
833
+ </svg>
834
+ </div>
835
+ `;
836
+ case "triangle":
837
+ return `
838
+ <div id="${i}" class="${h}" style="${f}">
839
+ <svg width="${l + 2}" height="${l + 2}" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" style="overflow:visible; ${a ? `filter: drop-shadow(0 0 3px #ffffff) drop-shadow(0 0 6px ${c});` : "filter: drop-shadow(0 1px 2px rgba(0,0,0,0.7));"}">
840
+ <polygon points="6,1.5 11,10.5 1,10.5" fill="${c}" stroke="#000000" stroke-width="1.2" stroke-linejoin="round" />
841
+ ${a ? '<polygon points="6,3.5 9.5,9.5 2.5,9.5" fill="none" stroke="#ffffff" stroke-width="1" />' : ""}
842
+ </svg>
843
+ </div>
844
+ `;
845
+ case "circle":
846
+ default:
847
+ return `
848
+ <div id="${i}" class="${h}" style="${f}">
849
+ <div style="width:${l}px; height:${l}px; background-color:${c}; border-radius:50%; border:1px solid rgba(0,0,0,0.35); box-sizing:border-box; ${p}"></div>
850
+ </div>
851
+ `;
852
+ }
853
+ }
854
+ class zt {
855
+ constructor() {
856
+ u(this, "zoomListenerMap", /* @__PURE__ */ new WeakMap());
857
+ }
858
+ render(t, e, o) {
859
+ const i = v.layerGroup(), s = `pane-${t.id}`;
860
+ this.rebuildPoints(t, i, e, o, s);
861
+ const a = () => {
862
+ t.estilo.scaleMode === "world" && i.eachLayer((c) => {
863
+ if (c.setIcon && c.baseSize && c.shapeStyle && c.markerBg && c.pontoId !== void 0) {
864
+ const r = this.calculateSize(t, e, o, c.baseSize), l = o.config.enableAnimations ? "transition-all duration-150" : "", p = Z(
865
+ c.shapeStyle,
866
+ r,
867
+ c.markerBg,
868
+ l,
869
+ `map-marker-${t.id}-${c.pontoId}`,
870
+ !!c.isSelected
871
+ ), d = v.divIcon({
872
+ html: p,
873
+ className: "custom-leaflet-marker flex items-center justify-center",
874
+ iconSize: [r + 6, r + 6]
875
+ });
876
+ c.setIcon(d);
877
+ }
878
+ });
879
+ };
880
+ return e.on("zoomend", a), this.zoomListenerMap.set(i, a), i;
881
+ }
882
+ calculateSize(t, e, o, i) {
883
+ const s = o.graphicScale.markerScaleMultiplier || 1;
884
+ if (t.estilo.scaleMode === "world") {
885
+ const a = t.estilo.dimensaoMetros || 0.25, c = e.getCenter(), r = e.getZoom(), l = 40075016686e-3 * Math.abs(Math.cos(c.lat * Math.PI / 180)) / Math.pow(2, r + 8), p = a / (l > 0 ? l : 1);
886
+ return Math.max(3, Math.round(p * s));
887
+ }
888
+ return Math.max(4, Math.round(i * s));
889
+ }
890
+ rebuildPoints(t, e, o, i, s) {
891
+ var f;
892
+ const c = t.id === "homologados-pontos" ? i.bancoPontos || [] : ((f = t.dados) == null ? void 0 : f.pontos) || i.pontos || [], r = t.interativo && !t.bloqueada, l = t.id === "vizinhos", p = t.id === "homologados" || t.id === "homologados-pontos", d = i.selectedPontoIds || [];
893
+ c.forEach((h) => {
894
+ var b;
895
+ const y = h.lat ?? h.latitude, S = h.lon ?? h.lng ?? h.longitude;
896
+ if (y !== void 0 && S !== void 0 && y !== 0 && S !== 0 && !isNaN(Number(y)) && !isNaN(Number(S))) {
897
+ const M = h.tipo_ponto === "B" || h.tipo === "B", I = h.tipo_ponto === "M" || h.tipo === "M";
898
+ let z = t.estilo.estiloMarcador || "x", E = t.estilo.corPrimaria || "bg-mint-vibrant", w = t.estilo.tamanhoMarcador || 7;
899
+ p ? (z = "circle", E = t.estilo.corPrimaria || "#f59e0b", w = 8) : l ? (z = I ? "circle-dot" : t.estilo.estiloMarcador || "cross", E = t.estilo.corPrimaria || "#a855f7", w = I ? 10 : 8) : I ? (E = "#6366f1", z = "circle-dot", w = 10) : M && (E = "#f43f5e", z = "square", w = 9);
900
+ const g = !!(h.selecionado || d.length > 0 && (d.includes(h.id) || d.includes(String(h.id)) || d.includes(Number(h.id)))), m = this.calculateSize(t, o, i, w), x = i.config.enableAnimations ? "transition-all duration-150" : "", L = Z(
901
+ z,
902
+ m,
903
+ E,
904
+ x,
905
+ `map-marker-${t.id}-${h.id}`,
906
+ g
907
+ ), _ = v.divIcon({
908
+ html: L,
909
+ className: `custom-leaflet-marker flex items-center justify-center ${g ? "cad-marker-selected" : ""}`,
910
+ iconSize: [m + 6, m + 6]
911
+ }), k = v.marker([Number(y), Number(S)], {
912
+ icon: _,
913
+ pane: s,
914
+ interactive: r
915
+ });
916
+ if (g && k.setZIndexOffset(2e3), k.pontoId = h.id, k.layerId = t.id, k.isVizinho = l, k.baseSize = w, k.shapeStyle = z, k.markerBg = E, k.isSelected = g, r) {
917
+ const N = p ? "Vértice Homologado SIGEF" : l ? "Confrontante (Importado)" : I ? "Base Homologada PPP" : M ? "Base de Campo (Translação)" : "Vértice de Perímetro", q = h.acoes || t.acoes || ((b = t.dados) == null ? void 0 : b.acoes) || [], V = W(q, h.id);
918
+ k.bindPopup(`
919
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.3;">
920
+ <div style="font-weight:700; font-size:13px; margin-bottom:4px; color:#ffffff;">${P(h.nome_vertice || String(h.id))}</div>
921
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.65);">${P(N)} · ${P(h.tipo_ponto || h.tipo || "Vértice")}</div>
922
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.45); font-family:monospace; margin-top:4px;">Lat ${Number(y).toFixed(6)} &nbsp; Lon ${Number(S).toFixed(6)}</div>
923
+ ${V}
924
+ </div>
925
+ `, {
926
+ className: "compact-popup",
927
+ maxWidth: 240
928
+ }), q && q.length > 0 && k.on("popupopen", (C) => {
929
+ Y(C.popup, h, i, k);
930
+ }), k.on("click", () => {
931
+ i.onMarkerClick && i.onMarkerClick(h.id, l, h, { lat: Number(y), lon: Number(S) });
932
+ });
933
+ }
934
+ k.addTo(e);
935
+ }
936
+ });
937
+ }
938
+ update(t, e, o, i, s) {
939
+ (o.opacidade !== void 0 || o.estilo !== void 0 || o.dados !== void 0 || o.interativo !== void 0 || o.bloqueada !== void 0) && (e.clearLayers(), this.rebuildPoints(t, e, s, i, `pane-${t.id}`));
940
+ }
941
+ destroy(t, e) {
942
+ const o = this.zoomListenerMap.get(t);
943
+ o && (e.off("zoomend", o), this.zoomListenerMap.delete(t)), t.clearLayers(), e.hasLayer(t) && e.removeLayer(t);
944
+ }
945
+ }
946
+ class It {
947
+ render(t, e, o) {
948
+ const i = v.layerGroup(), s = `pane-${t.id}`;
949
+ return this.rebuildPolygons(t, i, o, s), i;
950
+ }
951
+ rebuildPolygons(t, e, o, i) {
952
+ var d, f;
953
+ const a = (((d = t.dados) == null ? void 0 : d.poligonos) ?? (Array.isArray(t.dados) ? t.dados : null)) || ((f = t.dados) == null ? void 0 : f.confrontantes) || o.confrontantes || [], c = t.interativo && !t.bloqueada, r = t.estilo.corPrimaria || "#a855f7", l = t.estilo.espessuraLinha || 1.5, p = t.opacidade !== void 0 ? t.opacidade : 0.8;
954
+ a.forEach((h) => {
955
+ var w, g, m, x, L, _, k, N, q, V;
956
+ if (!h) return;
957
+ const y = ((w = h.estilo) == null ? void 0 : w.cor) || ((g = h.estilo) == null ? void 0 : g.color) || r, S = ((m = h.estilo) == null ? void 0 : m.espessura) || ((x = h.estilo) == null ? void 0 : x.weight) || l, b = ((L = h.estilo) == null ? void 0 : L.opacidade) ?? p, M = ((_ = h.estilo) == null ? void 0 : _.fillColor) || y, I = ((k = h.estilo) == null ? void 0 : k.fillOpacity) ?? Math.min(0.2, b * 0.15), z = ((N = h.estilo) == null ? void 0 : N.dashArray) || t.estilo.dashArray || "4, 6";
958
+ if (h.coordenadas && Array.isArray(h.coordenadas) && h.coordenadas.length >= 3) {
959
+ const C = Array.isArray(h.coordenadas[0]) && Array.isArray(h.coordenadas[0][0]);
960
+ let $;
961
+ if (C ? $ = h.coordenadas.map(
962
+ (T) => T.map((B) => {
963
+ const A = O(B[0], B[1]);
964
+ return A ? [A.lat, A.lon] : null;
965
+ }).filter(Boolean)
966
+ ) : $ = h.coordenadas.map((T) => {
967
+ const B = O(T[0], T[1]);
968
+ return B ? [B.lat, B.lon] : null;
969
+ }).filter(Boolean), $ && (C ? ((q = $[0]) == null ? void 0 : q.length) >= 3 : $.length >= 3)) {
970
+ const T = v.polygon($, {
971
+ color: y,
972
+ weight: S,
973
+ opacity: b,
974
+ dashArray: z,
975
+ fillColor: M,
976
+ fillOpacity: I,
977
+ pane: i,
978
+ interactive: c
979
+ });
980
+ if (T.poligonoId = h.id, T.layerId = t.id, c) {
981
+ let B = "";
982
+ h.metadados && Object.keys(h.metadados).length > 0 && (B = Object.entries(h.metadados).map(([A, G]) => `<div style="font-size:11px;"><strong>${P(A)}:</strong> ${P(String(G))}</div>`).join("")), T.bindPopup(`
983
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.3; min-width:180px;">
984
+ <div style="font-weight:700; font-size:12px; color:#c084fc; margin-bottom:3px; border-bottom:1px solid rgba(255,255,255,0.1); padding-bottom:3px;">Polígono ${P(String(h.id ?? ""))}</div>
985
+ ${B || `<div style="font-size:11px;">Área vetorial definida por ${h.coordenadas.length} vértices</div>`}
986
+ </div>
987
+ `, { className: "compact-popup", maxWidth: 220 }), T.on("popupopen", () => {
988
+ o.modoSequencial && T.closePopup();
989
+ });
990
+ }
991
+ T.addTo(e);
992
+ return;
993
+ }
994
+ }
995
+ const E = h.wkt || h.poligono_wkt;
996
+ if (E) {
997
+ const C = [...E.matchAll(/\(([^()]+)\)/g)];
998
+ if (C.length > 0) {
999
+ const $ = P(h.nome_propriedade || `Polígono ${String(h.id || "")}`), T = P(h.nome || "Proprietário"), B = [];
1000
+ if (C.forEach((A) => {
1001
+ const G = A[1].split(",").map((H) => {
1002
+ const D = H.trim().split(/\s+/);
1003
+ if (D.length < 2) return null;
1004
+ const R = O(D[1], D[0]);
1005
+ return R ? [R.lat, R.lon] : null;
1006
+ }).filter((H) => H !== null);
1007
+ G.length >= 3 && B.push(G);
1008
+ }), B.length > 0) {
1009
+ const A = B.length === 1 ? B[0] : B, G = v.polygon(A, {
1010
+ color: y,
1011
+ weight: S,
1012
+ opacity: b,
1013
+ dashArray: z,
1014
+ fillColor: M,
1015
+ fillOpacity: I,
1016
+ pane: i,
1017
+ interactive: c
1018
+ });
1019
+ if (G.poligonoId = h.id, G.layerId = t.id, c) {
1020
+ const H = h.acoes || t.acoes || ((V = t.dados) == null ? void 0 : V.acoes) || [], D = W(H, h.id);
1021
+ G.bindPopup(`
1022
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.3; min-width:180px;">
1023
+ <div style="font-weight:700; font-size:12px; color:#c084fc; margin-bottom:3px; border-bottom:1px solid rgba(255,255,255,0.1); padding-bottom:3px;">${$}</div>
1024
+ <div style="font-size:11px; margin-bottom:2px;"><strong>Identificador:</strong> ${P(String(h.id ?? ""))}</div>
1025
+ ${h.nome ? `<div style="font-size:11px;"><strong>Proprietário:</strong> ${T}</div>` : ""}
1026
+ ${D}
1027
+ </div>
1028
+ `, { className: "compact-popup", maxWidth: 220 }), G.on("popupopen", (R) => {
1029
+ if (o.modoSequencial) {
1030
+ G.closePopup();
1031
+ return;
1032
+ }
1033
+ Y(R.popup, h, o, G);
1034
+ });
1035
+ }
1036
+ G.addTo(e);
1037
+ }
1038
+ }
1039
+ }
1040
+ h.pontos && h.pontos.length > 0 && h.pontos.forEach((C) => {
1041
+ var T;
1042
+ const $ = O(C.lat ?? C.latitude ?? C.y, C.lon ?? C.lng ?? C.longitude ?? C.x);
1043
+ if ($) {
1044
+ const B = v.divIcon({
1045
+ html: '<div style="width:8px; height:8px; background:#a855f7; border-radius:50%; border:1px solid #ffffff; box-shadow:0 0 4px rgba(168,85,247,0.8);"></div>',
1046
+ className: "custom-leaflet-marker flex items-center justify-center",
1047
+ iconSize: [12, 12]
1048
+ }), A = v.marker([$.lat, $.lon], {
1049
+ icon: B,
1050
+ pane: i,
1051
+ interactive: c
1052
+ });
1053
+ if (A.pontoId = C.id, A.isVizinho = !0, A.layerId = t.id, c) {
1054
+ const G = C.acoes || h.acoes || t.acoes || ((T = t.dados) == null ? void 0 : T.acoes) || [], H = W(G, C.id);
1055
+ A.bindPopup(`
1056
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.3; min-width:170px;">
1057
+ <div style="font-weight:700; font-size:12px; color:#c084fc; margin-bottom:3px;">${P(C.nome_vertice || String(C.id))}</div>
1058
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.65);">Confrontante: ${P(h.nome || "Desconhecido")}</div>
1059
+ <div style="font-size:10px; color:rgba(255, 255, 255, 0.45); font-family:monospace; margin-top:3px;">Lat ${$.lat.toFixed(6)} &nbsp; Lon ${$.lon.toFixed(6)}</div>
1060
+ ${H}
1061
+ </div>
1062
+ `, { className: "compact-popup", maxWidth: 220 }), A.on("click", () => {
1063
+ o.modoSequencial && A.closePopup(), o.onMarkerClick && o.onMarkerClick(C.id, !0, C, { lat: $.lat, lon: $.lon });
1064
+ }), A.on("popupopen", (D) => {
1065
+ if (o.modoSequencial) {
1066
+ A.closePopup();
1067
+ return;
1068
+ }
1069
+ Y(D.popup, C, o, A);
1070
+ });
1071
+ }
1072
+ A.addTo(e);
1073
+ }
1074
+ });
1075
+ });
1076
+ }
1077
+ update(t, e, o, i) {
1078
+ o.opacidade !== void 0 && o.estilo === void 0 && o.dados === void 0 && o.interativo === void 0 && o.bloqueada === void 0 || (o.opacidade !== void 0 || o.estilo !== void 0 || o.dados !== void 0 || o.interativo !== void 0 || o.bloqueada !== void 0) && (e.clearLayers(), this.rebuildPolygons(t, e, i, `pane-${t.id}`));
1079
+ }
1080
+ destroy(t, e) {
1081
+ t.clearLayers(), e.hasLayer(t) && e.removeLayer(t);
1082
+ }
1083
+ }
1084
+ class Et {
1085
+ constructor() {
1086
+ u(this, "moveListenerMap", /* @__PURE__ */ new WeakMap());
1087
+ }
1088
+ render(t, e, o) {
1089
+ const i = v.layerGroup(), s = `pane-${t.id}`, a = () => {
1090
+ if (i.clearLayers(), !t.visivel) return;
1091
+ if (e.getZoom() > 20) {
1092
+ const r = e.getBounds(), l = r.getSouth(), p = r.getNorth(), d = r.getWest(), f = r.getEast(), h = e.getCenter(), y = 8999e-9, S = Math.cos(h.lat * Math.PI / 180), b = y / (S > 0.1 ? S : 1), M = Math.floor((p - l) / y), I = Math.floor((f - d) / b);
1093
+ if (M < 200 && I < 200) {
1094
+ const z = Math.ceil(l / y) * y;
1095
+ for (let w = z; w <= p; w += y)
1096
+ v.polyline([[w, d], [w, f]], {
1097
+ color: t.estilo.corPrimaria || "rgba(0, 245, 160, 0.18)",
1098
+ weight: t.estilo.espessuraLinha || 0.6,
1099
+ interactive: !1,
1100
+ pane: s
1101
+ }).addTo(i);
1102
+ const E = Math.ceil(d / b) * b;
1103
+ for (let w = E; w <= f; w += b)
1104
+ v.polyline([[l, w], [p, w]], {
1105
+ color: t.estilo.corPrimaria || "rgba(0, 245, 160, 0.18)",
1106
+ weight: t.estilo.espessuraLinha || 0.6,
1107
+ interactive: !1,
1108
+ pane: s
1109
+ }).addTo(i);
1110
+ }
1111
+ }
1112
+ };
1113
+ return a(), e.on("zoomend moveend", a), this.moveListenerMap.set(i, a), i;
1114
+ }
1115
+ update(t, e) {
1116
+ t.visivel || e.clearLayers();
1117
+ }
1118
+ destroy(t, e) {
1119
+ const o = this.moveListenerMap.get(t);
1120
+ o && (e.off("zoomend moveend", o), this.moveListenerMap.delete(t)), t.clearLayers(), e.hasLayer(t) && e.removeLayer(t);
1121
+ }
1122
+ }
1123
+ function At() {
1124
+ j.register("tile", new St()), j.register("wms", new Mt()), j.register("vetorial-linhas", new kt()), j.register("vetorial-pontos", new zt()), j.register("vetorial-poligonos", new It()), j.register("grid", new Et());
1125
+ }
1126
+ At();
1127
+ const _t = [
1128
+ {
1129
+ id: "satelite",
1130
+ nome: "Satélite Google Híbrido",
1131
+ categoria: "base",
1132
+ tipo: "tile",
1133
+ visivel: !0,
1134
+ opacidade: 1,
1135
+ zIndex: 200,
1136
+ interativo: !1,
1137
+ bloqueada: !1,
1138
+ estilo: { scaleMode: "screen" }
1139
+ },
1140
+ {
1141
+ id: "sigef",
1142
+ nome: "Acervo Fundiário SIGEF (INCRA)",
1143
+ categoria: "wms",
1144
+ tipo: "wms",
1145
+ visivel: !0,
1146
+ opacidade: 0.85,
1147
+ zIndex: 390,
1148
+ interativo: !0,
1149
+ bloqueada: !1,
1150
+ estilo: { scaleMode: "screen" }
1151
+ },
1152
+ {
1153
+ id: "homologados",
1154
+ nome: "Poligonal Homologada (Banco)",
1155
+ categoria: "referencia",
1156
+ tipo: "vetorial-linhas",
1157
+ visivel: !0,
1158
+ opacidade: 0.9,
1159
+ zIndex: 420,
1160
+ interativo: !0,
1161
+ bloqueada: !1,
1162
+ estilo: {
1163
+ corPrimaria: "#f59e0b",
1164
+ espessuraLinha: 2,
1165
+ dashArray: "6, 8",
1166
+ scaleMode: "screen"
1167
+ }
1168
+ },
1169
+ {
1170
+ id: "homologados-pontos",
1171
+ nome: "Marcos Homologados (Banco)",
1172
+ categoria: "referencia",
1173
+ tipo: "vetorial-pontos",
1174
+ visivel: !0,
1175
+ opacidade: 1,
1176
+ zIndex: 430,
1177
+ interativo: !0,
1178
+ bloqueada: !1,
1179
+ estilo: {
1180
+ tamanhoMarcador: 8,
1181
+ estiloMarcador: "circle",
1182
+ scaleMode: "screen"
1183
+ }
1184
+ },
1185
+ {
1186
+ id: "perimetro",
1187
+ nome: "Divisas e Poligonal do Imóvel",
1188
+ categoria: "levantamento",
1189
+ tipo: "vetorial-linhas",
1190
+ visivel: !0,
1191
+ opacidade: 1,
1192
+ zIndex: 450,
1193
+ interativo: !0,
1194
+ bloqueada: !1,
1195
+ estilo: {
1196
+ corPrimaria: "#00f5a0",
1197
+ espessuraLinha: 2,
1198
+ scaleMode: "screen",
1199
+ dimensaoMetros: 0.3
1200
+ }
1201
+ },
1202
+ {
1203
+ id: "vizinhos",
1204
+ nome: "Imóveis Confrontantes (WKT/CSV)",
1205
+ categoria: "referencia",
1206
+ tipo: "vetorial-poligonos",
1207
+ visivel: !0,
1208
+ opacidade: 0.8,
1209
+ zIndex: 500,
1210
+ interativo: !0,
1211
+ bloqueada: !1,
1212
+ estilo: {
1213
+ corPrimaria: "#a855f7",
1214
+ espessuraLinha: 1.5,
1215
+ dashArray: "4, 6",
1216
+ scaleMode: "screen"
1217
+ }
1218
+ },
1219
+ {
1220
+ id: "vertices",
1221
+ nome: "Vértices e Marcos do Levantamento",
1222
+ categoria: "levantamento",
1223
+ tipo: "vetorial-pontos",
1224
+ visivel: !0,
1225
+ opacidade: 1,
1226
+ zIndex: 650,
1227
+ interativo: !0,
1228
+ bloqueada: !1,
1229
+ estilo: {
1230
+ tamanhoMarcador: 8,
1231
+ scaleMode: "screen",
1232
+ dimensaoMetros: 0.25
1233
+ }
1234
+ },
1235
+ {
1236
+ id: "grade",
1237
+ nome: "Grade de Coordenadas UTM",
1238
+ categoria: "referencia",
1239
+ tipo: "grid",
1240
+ visivel: !0,
1241
+ opacidade: 0.5,
1242
+ zIndex: 700,
1243
+ interativo: !1,
1244
+ bloqueada: !1,
1245
+ estilo: {
1246
+ corPrimaria: "rgba(0, 245, 160, 0.18)",
1247
+ espessuraLinha: 0.6,
1248
+ scaleMode: "screen"
1249
+ }
1250
+ }
1251
+ ];
1252
+ function $t(n) {
1253
+ return n.map((t) => ({
1254
+ id: t.id,
1255
+ visivel: t.visivel,
1256
+ opacidade: t.opacidade,
1257
+ zIndex: t.zIndex,
1258
+ bloqueada: t.bloqueada,
1259
+ estilo: { ...t.estilo }
1260
+ }));
1261
+ }
1262
+ function qt(n, t) {
1263
+ !t || !Array.isArray(t) || t.forEach((e) => {
1264
+ const o = n.find((i) => i.id === e.id);
1265
+ o && (e.visivel !== void 0 && (o.visivel = e.visivel), e.opacidade !== void 0 && (o.opacidade = e.opacidade), e.zIndex !== void 0 && (o.zIndex = e.zIndex), e.bloqueada !== void 0 && (o.bloqueada = e.bloqueada), e.estilo && (o.estilo = { ...o.estilo, ...e.estilo }));
1266
+ });
1267
+ }
1268
+ function Tt(n, t, e, o, i) {
1269
+ n.dados = t;
1270
+ const s = i.get(n.id);
1271
+ if (s && e && o) {
1272
+ const a = j.get(n.tipo);
1273
+ a && a.update(n, s, { dados: t }, o, e);
1274
+ } else if (e && o && n.visivel) {
1275
+ const a = j.get(n.tipo);
1276
+ if (a) {
1277
+ const c = a.render(n, e, o);
1278
+ c && (c.addTo(e), i.set(n.id, c));
1279
+ }
1280
+ }
1281
+ }
1282
+ function U(n) {
1283
+ return `pane-${n}`;
1284
+ }
1285
+ function et(n) {
1286
+ return n.visivel && n.interativo && !n.bloqueada ? "auto" : "none";
1287
+ }
1288
+ function Bt(n, t) {
1289
+ t.forEach((e) => {
1290
+ const o = U(e.id), i = n.getPane(o) ?? n.createPane(o);
1291
+ i && (i.style.zIndex = String(e.zIndex), i.style.pointerEvents = et(e));
1292
+ });
1293
+ }
1294
+ function Nt(n, t) {
1295
+ const e = n.getPane(U(t.id));
1296
+ e && (e.style.display = t.visivel ? "" : "none", e.style.pointerEvents = et(t));
1297
+ }
1298
+ function Vt(n, t) {
1299
+ const e = n.getPane(U(t.id));
1300
+ e && (e.style.opacity = String(t.opacidade));
1301
+ }
1302
+ function Gt(n, t) {
1303
+ const e = n.getPane(U(t.id));
1304
+ e && (e.style.zIndex = String(t.zIndex));
1305
+ }
1306
+ function Ot(n, t) {
1307
+ const e = n.getPane(U(t.id));
1308
+ e && (e.style.pointerEvents = et(t));
1309
+ }
1310
+ function rt(n, t, e, o) {
1311
+ const i = j.get(n.tipo);
1312
+ if (!i) return;
1313
+ const s = i.render(n, t, e);
1314
+ s && (s.addTo(t), o.set(n.id, s));
1315
+ }
1316
+ function X(n, t, e) {
1317
+ const o = e.get(n.id);
1318
+ if (!o) return;
1319
+ const i = j.get(n.tipo);
1320
+ i && i.destroy(o, t), e.delete(n.id);
1321
+ }
1322
+ function lt(n, t, e, o, i) {
1323
+ const s = i.get(n.id);
1324
+ if (!s) return;
1325
+ const a = j.get(n.tipo);
1326
+ a && a.update(n, s, t, o, e);
1327
+ }
1328
+ class jt {
1329
+ constructor(t) {
1330
+ u(this, "layers", []);
1331
+ u(this, "layerInstances", /* @__PURE__ */ new Map());
1332
+ u(this, "map", null);
1333
+ u(this, "context", null);
1334
+ u(this, "listeners", []);
1335
+ this.layers = (t || _t).map((e) => ({ ...e, estilo: { ...e.estilo } }));
1336
+ }
1337
+ attachMap(t, e) {
1338
+ this.map = t, this.context = e, this.ensurePanes(), this.renderAllLayers();
1339
+ }
1340
+ ensurePanes() {
1341
+ this.map && Bt(this.map, this.layers);
1342
+ }
1343
+ renderAllLayers() {
1344
+ !this.map || !this.context || (this.layers.forEach((t) => {
1345
+ X(t, this.map, this.layerInstances), t.visivel && rt(t, this.map, this.context, this.layerInstances);
1346
+ }), this.notifyChange());
1347
+ }
1348
+ setLayerVisibility(t, e) {
1349
+ const o = this.layers.find((i) => i.id === t);
1350
+ !o || o.visivel === e || (o.visivel = e, !(!this.map || !this.context) && (Nt(this.map, o), e ? this.layerInstances.has(t) || rt(o, this.map, this.context, this.layerInstances) : X(o, this.map, this.layerInstances), this.notifyChange()));
1351
+ }
1352
+ setLayerOpacity(t, e) {
1353
+ const o = this.layers.find((i) => i.id === t);
1354
+ o && (o.opacidade = Math.max(0, Math.min(1, e)), this.map && (Vt(this.map, o), this.context && lt(o, { opacidade: o.opacidade }, this.map, this.context, this.layerInstances)), this.notifyChange());
1355
+ }
1356
+ setLayerZIndex(t, e) {
1357
+ const o = this.layers.find((i) => i.id === t);
1358
+ o && (o.zIndex = e, this.map && Gt(this.map, o), this.notifyChange());
1359
+ }
1360
+ setLayerBlocked(t, e) {
1361
+ const o = this.layers.find((i) => i.id === t);
1362
+ o && (o.bloqueada = e, this.map && Ot(this.map, o), this.notifyChange());
1363
+ }
1364
+ setLayerScaleMode(t, e) {
1365
+ const o = this.layers.find((i) => i.id === t);
1366
+ o && (o.estilo.scaleMode = e, this.map && this.context && lt(o, { estilo: o.estilo }, this.map, this.context, this.layerInstances), this.notifyChange());
1367
+ }
1368
+ setGraphicScale(t) {
1369
+ this.context && (this.context.graphicScale = { ...this.context.graphicScale, ...t }, this.renderAllLayers());
1370
+ }
1371
+ updateContext(t) {
1372
+ this.context && (this.context = { ...this.context, ...t }, this.renderAllLayers());
1373
+ }
1374
+ getLayers() {
1375
+ return [...this.layers];
1376
+ }
1377
+ getActiveSelectableLayers() {
1378
+ return this.layers.filter((t) => t.visivel && t.interativo && !t.bloqueada);
1379
+ }
1380
+ isLayerActiveAndSelectable(t) {
1381
+ const e = this.layers.find((o) => o.id === t);
1382
+ return !!(e && e.visivel && e.interativo && !e.bloqueada);
1383
+ }
1384
+ exportState() {
1385
+ return $t(this.layers);
1386
+ }
1387
+ importState(t) {
1388
+ !t || !Array.isArray(t) || (qt(this.layers, t), this.ensurePanes(), this.renderAllLayers());
1389
+ }
1390
+ onChange(t) {
1391
+ return this.listeners.push(t), () => {
1392
+ this.listeners = this.listeners.filter((e) => e !== t);
1393
+ };
1394
+ }
1395
+ notifyChange() {
1396
+ const t = this.getLayers();
1397
+ this.listeners.forEach((e) => {
1398
+ try {
1399
+ e(t);
1400
+ } catch (o) {
1401
+ console.error("Erro no listener de camadas:", o);
1402
+ }
1403
+ });
1404
+ }
1405
+ getAllLayerInstances() {
1406
+ return Array.from(this.layerInstances.values());
1407
+ }
1408
+ getLayerInstance(t) {
1409
+ return this.layerInstances.get(t);
1410
+ }
1411
+ getLayer(t) {
1412
+ return this.layers.find((e) => e.id === t);
1413
+ }
1414
+ getLayerDef(t) {
1415
+ return this.layers.find((e) => e.id === t);
1416
+ }
1417
+ getOrCreateLayer(t, e, o) {
1418
+ let i = this.layers.find((s) => s.id === t);
1419
+ return i || (i = {
1420
+ id: t,
1421
+ nome: o,
1422
+ categoria: "custom",
1423
+ tipo: e,
1424
+ visivel: !0,
1425
+ opacidade: 1,
1426
+ zIndex: 600,
1427
+ interativo: !0,
1428
+ bloqueada: !1,
1429
+ estilo: { scaleMode: "screen" }
1430
+ }, this.layers.push(i), this.ensurePanes()), i;
1431
+ }
1432
+ setLayerData(t, e) {
1433
+ const o = this.layers.find((i) => i.id === t);
1434
+ o && (Tt(o, e, this.map, this.context, this.layerInstances), this.notifyChange());
1435
+ }
1436
+ clearLayers(t) {
1437
+ (t && t.length > 0 ? t : Array.from(this.layerInstances.keys())).forEach((o) => {
1438
+ const i = this.layers.find((s) => s.id === o);
1439
+ i ? X(i, this.map, this.layerInstances) : this.layerInstances.delete(o);
1440
+ }), this.notifyChange();
1441
+ }
1442
+ destroy() {
1443
+ this.map && (this.layers.forEach((t) => X(t, this.map, this.layerInstances)), this.layerInstances.clear()), this.listeners = [];
1444
+ }
1445
+ }
1446
+ function ht(n, t) {
1447
+ var a, c;
1448
+ if (t == null) return null;
1449
+ const e = String(t).trim(), o = (r) => r ? (r.lon = r.lng, r) : null, s = n.getMarkers().find((r) => {
1450
+ var h, y, S, b;
1451
+ const l = r.pontoId, p = r.elementoId ?? r.id ?? ((h = r.options) == null ? void 0 : h.pontoId) ?? ((y = r.options) == null ? void 0 : y.id), d = (S = r.elemento) == null ? void 0 : S.nome_vertice, f = (b = r.elemento) == null ? void 0 : b.codigo_completo;
1452
+ return String(l) === e || String(p) === e || d && String(d).toLowerCase() === e.toLowerCase() || f && String(f).toLowerCase() === e.toLowerCase();
1453
+ });
1454
+ if (s && typeof s.getLatLng == "function")
1455
+ return o(s.getLatLng());
1456
+ if (n.layerManager)
1457
+ for (const r of n.layerManager.getAllLayerInstances()) {
1458
+ let l = null;
1459
+ const p = (d) => {
1460
+ var y, S, b, M, I;
1461
+ if (l) return;
1462
+ const f = d.pontoId ?? d.elementoId ?? d.id ?? ((y = d.options) == null ? void 0 : y.id) ?? ((S = d.options) == null ? void 0 : S.pontoId), h = ((b = d.elemento) == null ? void 0 : b.nome) ?? ((M = d.elemento) == null ? void 0 : M.nome_vertice) ?? ((I = d.options) == null ? void 0 : I.nome);
1463
+ (String(f) === e || h && String(h).toLowerCase() === e.toLowerCase()) && (typeof d.getLatLng == "function" ? l = d.getLatLng() : typeof d.getBounds == "function" && (l = d.getBounds().getCenter()));
1464
+ };
1465
+ if (p(r), typeof r.eachLayer == "function" && r.eachLayer(p), l) return o(l);
1466
+ }
1467
+ if (n.context.pontos && n.context.pontos.length > 0) {
1468
+ const r = n.context.pontos.find(
1469
+ (l) => String(l.id) === e || l.nome_vertice && String(l.nome_vertice).toLowerCase() === e.toLowerCase()
1470
+ );
1471
+ if (r) {
1472
+ const l = r.lat ?? r.latitude ?? r.y, p = r.lon ?? r.lng ?? r.longitude ?? r.x, d = O(l, p);
1473
+ if (d) return o(v.latLng(d.lat, d.lon));
1474
+ }
1475
+ }
1476
+ if (n.context.bancoPontos && n.context.bancoPontos.length > 0) {
1477
+ const r = n.context.bancoPontos.find(
1478
+ (l) => String(l.id) === e || l.codigo_completo && String(l.codigo_completo).toLowerCase() === e.toLowerCase() || l.nome_vertice && String(l.nome_vertice).toLowerCase() === e.toLowerCase()
1479
+ );
1480
+ if (r) {
1481
+ const l = r.lat ?? r.latitude ?? r.y, p = r.lon ?? r.lng ?? r.longitude ?? r.x, d = O(l, p);
1482
+ if (d) return o(v.latLng(d.lat, d.lon));
1483
+ }
1484
+ }
1485
+ if (n.context.confrontantes && n.context.confrontantes.length > 0) {
1486
+ const r = n.context.confrontantes.find(
1487
+ (l) => String(l.id) === e || l.nome && String(l.nome).toLowerCase() === e.toLowerCase() || l.nome_propriedade && String(l.nome_propriedade).toLowerCase() === e.toLowerCase()
1488
+ );
1489
+ if (r) {
1490
+ if (r.pontos && r.pontos.length > 0) {
1491
+ let l = 0, p = 0, d = 0;
1492
+ for (const f of r.pontos) {
1493
+ const h = f.lat ?? f.latitude ?? f.y, y = f.lon ?? f.lng ?? f.longitude ?? f.x, S = O(h, y);
1494
+ S && (l += S.lat, p += S.lon, d++);
1495
+ }
1496
+ if (d > 0)
1497
+ return o(v.latLng(l / d, p / d));
1498
+ }
1499
+ if (r.poligono_wkt) {
1500
+ const l = ot(r.poligono_wkt);
1501
+ if (l) return o(v.latLng(l.lat, l.lon));
1502
+ }
1503
+ }
1504
+ }
1505
+ if (n.context.segmentos && n.context.segmentos.length > 0) {
1506
+ const r = n.context.segmentos.find(
1507
+ (l) => String(l.id) === e || `${l.ponto_inicio_id}-${l.ponto_fim_id}` === e
1508
+ );
1509
+ if (r) {
1510
+ const l = (a = n.context.pontos) == null ? void 0 : a.find((d) => String(d.id) === String(r.ponto_inicio_id)), p = (c = n.context.pontos) == null ? void 0 : c.find((d) => String(d.id) === String(r.ponto_fim_id));
1511
+ if (l && p) {
1512
+ const d = O(l.lat ?? l.latitude, l.lon ?? l.longitude), f = O(p.lat ?? p.latitude, p.lon ?? p.longitude);
1513
+ if (d && f)
1514
+ return o(v.latLng((d.lat + f.lat) / 2, (d.lon + f.lon) / 2));
1515
+ }
1516
+ }
1517
+ }
1518
+ if (n.layerManager) {
1519
+ for (const r of n.layerManager.getLayers())
1520
+ if (r.dados) {
1521
+ if (Array.isArray(r.dados.pontos)) {
1522
+ const l = r.dados.pontos.find((p) => String(p.id) === e || p.nome_vertice && String(p.nome_vertice) === e);
1523
+ if (l) {
1524
+ const p = O(l.lat, l.lon);
1525
+ if (p) return o(v.latLng(p.lat, p.lon));
1526
+ }
1527
+ }
1528
+ if (Array.isArray(r.dados.poligonos)) {
1529
+ const l = r.dados.poligonos.find((p) => String(p.id) === e);
1530
+ if (l) {
1531
+ if (l.wkt) {
1532
+ const p = ot(l.wkt);
1533
+ if (p) return o(v.latLng(p.lat, p.lon));
1534
+ }
1535
+ if (Array.isArray(l.coordenadas) && l.coordenadas.length > 0) {
1536
+ let p = 0, d = 0, f = 0;
1537
+ for (const h of l.coordenadas) {
1538
+ const y = O(h[0], h[1]) || O(h[1], h[0]);
1539
+ y && (p += y.lat, d += y.lon, f++);
1540
+ }
1541
+ if (f > 0) return o(v.latLng(p / f, d / f));
1542
+ }
1543
+ }
1544
+ }
1545
+ }
1546
+ }
1547
+ return null;
1548
+ }
1549
+ function Ht(n, t, e, o) {
1550
+ var h, y;
1551
+ tt(t, n.getMap());
1552
+ const i = n.getMap();
1553
+ if (!i) return;
1554
+ const s = ht(n, e);
1555
+ if (!s) {
1556
+ console.warn(`[ui-canvas-cad] Elemento com identificador "${e}" não encontrado para destaque.`);
1557
+ return;
1558
+ }
1559
+ const a = (o == null ? void 0 : o.pan) === !0, c = o == null ? void 0 : o.zoom;
1560
+ a ? c !== void 0 ? typeof i.flyTo == "function" ? i.flyTo(s, c, { animate: !0 }) : i.setView(s, c, { animate: !0 }) : typeof i.panTo == "function" ? i.panTo(s, { animate: !0 }) : i.setView(s, i.getZoom(), { animate: !0 }) : c !== void 0 && i.setZoom(c, { animate: !0 });
1561
+ const r = (o == null ? void 0 : o.cor) || "#00f5a0", l = "pane-destaque";
1562
+ let p = i.getPane(l);
1563
+ p || (p = i.createPane(l)), p && (p.style.zIndex = "850", p.style.pointerEvents = "none");
1564
+ const d = v.divIcon({
1565
+ className: "cad-destaque-marker-container",
1566
+ html: `
1567
+ <div class="cad-pulse-highlight" style="--cad-pulse-cor: ${P(r)};">
1568
+ <div class="cad-pulse-core"></div>
1569
+ <div class="cad-pulse-ring ring-1"></div>
1570
+ <div class="cad-pulse-ring ring-2"></div>
1571
+ </div>
1572
+ `,
1573
+ iconSize: [52, 52],
1574
+ iconAnchor: [26, 26]
1575
+ });
1576
+ t.destaqueMarker = v.marker(s, {
1577
+ icon: d,
1578
+ pane: l,
1579
+ interactive: !1,
1580
+ keyboard: !1
1581
+ }), t.destaqueMarker.addTo(i);
1582
+ const f = (y = (h = t.destaqueMarker).getElement) == null ? void 0 : y.call(h);
1583
+ f && (f.style.pointerEvents = "none"), o != null && o.duracaoMs && o.duracaoMs > 0 && (t.destaqueTimeoutId = window.setTimeout(() => {
1584
+ tt(t, i);
1585
+ }, o.duracaoMs));
1586
+ }
1587
+ function tt(n, t) {
1588
+ n.destaqueTimeoutId !== null && (window.clearTimeout(n.destaqueTimeoutId), n.destaqueTimeoutId = null), n.destaqueMarker && (t && t.hasLayer(n.destaqueMarker) ? t.removeLayer(n.destaqueMarker) : typeof n.destaqueMarker.remove == "function" && n.destaqueMarker.remove(), n.destaqueMarker = null);
1589
+ }
1590
+ function Dt(n, t) {
1591
+ const e = /* @__PURE__ */ new Map();
1592
+ n.forEach((i) => {
1593
+ const s = i.lat ?? i.latitude ?? i.y, a = i.lon ?? i.lng ?? i.longitude ?? i.x, c = O(s, a);
1594
+ c && (i.lat = c.lat, i.lon = c.lon);
1595
+ const r = i.confrontante_id ?? i.id_confrontante ?? 0;
1596
+ e.has(r) || e.set(r, []), e.get(r).push(i);
1597
+ });
1598
+ const o = /* @__PURE__ */ new Map();
1599
+ return t.forEach((i) => {
1600
+ const s = i.id !== void 0 && i.id !== null ? i.id : 0;
1601
+ o.set(s, { ...i, pontos: [] });
1602
+ }), e.forEach((i, s) => {
1603
+ var a, c;
1604
+ if (o.has(s)) {
1605
+ const r = o.get(s);
1606
+ r.pontos = i;
1607
+ } else
1608
+ o.set(s, {
1609
+ id: s,
1610
+ nome: ((a = i[0]) == null ? void 0 : a.nome_confrontante) || "Confrontante",
1611
+ nome_propriedade: ((c = i[0]) == null ? void 0 : c.nome_propriedade) || "",
1612
+ pontos: i
1613
+ });
1614
+ }), Array.from(o.values()).filter((i) => i.pontos && i.pontos.length > 0 || !!i.poligono_wkt);
1615
+ }
1616
+ function Rt(n, t) {
1617
+ const e = /* @__PURE__ */ new Map();
1618
+ return t.forEach((o) => {
1619
+ o.id !== void 0 && o.id !== null && o.pontos && o.pontos.length > 0 && e.set(o.id, o.pontos);
1620
+ }), n.map((o) => {
1621
+ const i = o.id !== void 0 && o.id !== null ? o.id : void 0;
1622
+ return i !== void 0 && (!o.pontos || o.pontos.length === 0) && e.has(i) ? { ...o, pontos: e.get(i) } : { ...o };
1623
+ });
1624
+ }
1625
+ function Ft(n, t, e = !1) {
1626
+ let o = [...n];
1627
+ e && t && t.forEach((s) => {
1628
+ s.pontos && o.push(...s.pontos);
1629
+ });
1630
+ const i = o.map((s) => {
1631
+ const a = s.lat ?? s.latitude ?? s.y, c = s.lon ?? s.lng ?? s.longitude ?? s.x, r = O(a, c);
1632
+ return r ? v.latLng(r.lat, r.lon) : null;
1633
+ }).filter((s) => s !== null);
1634
+ return i.length === 1 ? { single: i[0] } : i.length > 1 ? { bounds: v.latLngBounds(i) } : null;
1635
+ }
1636
+ function Wt(n, t) {
1637
+ const e = [], o = /* @__PURE__ */ new Set(), i = (s) => {
1638
+ s instanceof v.Marker && s.pontoId !== void 0 && !o.has(s) && (o.add(s), e.push(s));
1639
+ };
1640
+ return n && n.eachLayer((s) => {
1641
+ i(s), typeof s.eachLayer == "function" && s.eachLayer(i);
1642
+ }), t && t.getAllLayerInstances().forEach((s) => {
1643
+ i(s), typeof s.eachLayer == "function" && s.eachLayer(i);
1644
+ }), e;
1645
+ }
1646
+ function Yt(n, t, e = "vertices", o) {
1647
+ const i = t || [];
1648
+ n.layerManager.getOrCreateLayer(e, "vetorial-pontos", "Pontos / Vértices"), e === "vertices" && (n.context.pontos = i, n.canvasInteracao.ctx.pontosList = i, o && (n.customMarkerClickCallback = (s) => {
1649
+ const a = i.find((c) => String(c.id) === String(s)) || { id: s, lat: 0, lon: 0 };
1650
+ o(a);
1651
+ })), n.layerManager.setLayerData(e, { pontos: i, onClique: o }), n.layerManager.setLayerVisibility(e, !0);
1652
+ }
1653
+ function Zt(n, t, e = "linhas") {
1654
+ const o = t || [];
1655
+ n.layerManager.getOrCreateLayer(e, "vetorial-linhas", "Conexões / Linhas"), (e === "linhas" || e === "perimetro") && (n.context.segmentos = o.map((i) => ({
1656
+ ponto_inicio_id: Number(i.origemId) || 0,
1657
+ ponto_fim_id: Number(i.destinoId) || 0,
1658
+ tipo_limite_sigef: i.tipoLinha === "tracejada" ? "LN1" : "LA1"
1659
+ }))), n.layerManager.setLayerData(e, { conexoes: o }), n.layerManager.setLayerVisibility(e, !0);
1660
+ }
1661
+ function Ut(n, t, e = !0, o = "polilinha", i) {
1662
+ const s = t || [];
1663
+ n.layerManager.getOrCreateLayer(o, "vetorial-linhas", "Polilinhas"), (o === "polilinha" || o === "perimetro") && (n.context.pontos = s, n.context.segmentos = [], n.canvasInteracao.ctx.pontosList = s);
1664
+ const a = i || n.chaveGrupo || n.context.chaveGrupo;
1665
+ n.layerManager.setLayerData(o, {
1666
+ pontos: s,
1667
+ fechar: e !== !1,
1668
+ polilinhaSequencial: !0,
1669
+ chaveGrupo: a
1670
+ }), n.layerManager.setLayerVisibility(o, !0);
1671
+ }
1672
+ function Xt(n, t, e = "poligonos") {
1673
+ const o = t || [];
1674
+ n.layerManager.getOrCreateLayer(e, "vetorial-poligonos", "Polígonos"), n.layerManager.setLayerData(e, { poligonos: o }), n.layerManager.setLayerVisibility(e, !0);
1675
+ }
1676
+ function Kt(n, t, e) {
1677
+ const o = t || [];
1678
+ if (e != null) {
1679
+ const i = e || [];
1680
+ n.context.pontos = i, n.canvasInteracao.ctx.pontosList = i;
1681
+ }
1682
+ n.context.segmentos = o, n.layerManager.updateContext({
1683
+ segmentos: o,
1684
+ ...e != null ? { pontos: n.context.pontos } : {}
1685
+ });
1686
+ }
1687
+ function Jt(n, t = !1) {
1688
+ n.context.pontos = [], n.context.segmentos = [], n.context.confrontantes = [], n.canvasInteracao.ctx.pontosList = [], n.canvasInteracao.limparSelecao();
1689
+ const e = {
1690
+ pontos: [],
1691
+ segmentos: [],
1692
+ confrontantes: []
1693
+ };
1694
+ t || (n.context.bancoPontos = [], e.bancoPontos = []), n.layerManager.updateContext(e);
1695
+ }
1696
+ function ct(n) {
1697
+ return n != null && !isNaN(Number(n)) && String(n).trim() !== "" ? Number(n) : n;
1698
+ }
1699
+ function Qt(n, t) {
1700
+ var a, c;
1701
+ const e = n.core.map, o = n.layerManager.getLayerDef(t.layerId), i = t.baseSize || 8, s = ((a = n.context.graphicScale) == null ? void 0 : a.markerScaleMultiplier) || 1;
1702
+ if (e && ((c = o == null ? void 0 : o.estilo) == null ? void 0 : c.scaleMode) === "world") {
1703
+ const r = o.estilo.dimensaoMetros || 0.25, l = e.getCenter(), p = e.getZoom(), d = 40075016686e-3 * Math.abs(Math.cos(l.lat * Math.PI / 180)) / Math.pow(2, p + 8), f = r / (d > 0 ? d : 1);
1704
+ return Math.max(3, Math.round(f * s));
1705
+ }
1706
+ return Math.max(4, Math.round(i * s));
1707
+ }
1708
+ function te(n, t, e, o, i) {
1709
+ const s = Qt(n, e), a = n.context.config.enableAnimations ? "transition-all duration-150" : "", c = Z(
1710
+ e.shapeStyle,
1711
+ s,
1712
+ e.markerBg,
1713
+ a,
1714
+ `map-marker-${e.layerId || "pts"}-${o}`,
1715
+ i
1716
+ );
1717
+ t.setIcon(v.divIcon({
1718
+ html: c,
1719
+ className: `custom-leaflet-marker flex items-center justify-center ${i ? "cad-marker-selected ponto-selecionado" : ""}`,
1720
+ iconSize: [s + 6, s + 6]
1721
+ }));
1722
+ }
1723
+ function ee(n) {
1724
+ const t = n.context.selectedPontoIds || [], e = n.canvasInteracao.ctx.selectedVizinhoPontoIds || [], o = /* @__PURE__ */ new Set([
1725
+ ...t.map(String),
1726
+ ...e.map(String)
1727
+ ]);
1728
+ for (const i of n.getMarkers()) {
1729
+ const s = i, a = s.pontoId;
1730
+ if (a == null) continue;
1731
+ const c = o.has(String(a));
1732
+ if (s.isSelected === c) continue;
1733
+ s.isSelected = c, i.setZIndexOffset(c ? 2e3 : 0), s.shapeStyle && s.baseSize && s.markerBg && te(n, i, s, a, c);
1734
+ const r = i.getElement();
1735
+ r && (c ? r.classList.add("cad-marker-selected", "ponto-selecionado") : r.classList.remove("cad-marker-selected", "ponto-selecionado"));
1736
+ }
1737
+ }
1738
+ class oe {
1739
+ constructor(t) {
1740
+ u(this, "core");
1741
+ u(this, "layerManager");
1742
+ u(this, "canvasInteracao");
1743
+ u(this, "context");
1744
+ u(this, "modoCliqueSequencialAtivo", !1);
1745
+ u(this, "chaveGrupo");
1746
+ u(this, "zonaProjecao", 22);
1747
+ u(this, "levantamentoId", null);
1748
+ u(this, "customMarkerClickCallback");
1749
+ u(this, "customPopupActionCallback");
1750
+ u(this, "destaqueState", {
1751
+ destaqueMarker: null,
1752
+ destaqueTimeoutId: null
1753
+ });
1754
+ this.core = new xt(this), this.layerManager = new jt(t), this.canvasInteracao = new Ct({
1755
+ mapaController: this,
1756
+ layerManager: this.layerManager
1757
+ }), this.context = {
1758
+ pontos: [],
1759
+ segmentos: [],
1760
+ bancoPontos: [],
1761
+ confrontantes: [],
1762
+ zonaProjecao: 22,
1763
+ config: this.core.config,
1764
+ graphicScale: {
1765
+ markerScaleMultiplier: 1,
1766
+ lineScaleMultiplier: 1,
1767
+ scaleModeGlobal: "screen"
1768
+ },
1769
+ onMarkerClick: (e, o) => {
1770
+ if (this.modoCliqueSequencialAtivo || this.context.modoSequencial) return;
1771
+ const i = ct(e);
1772
+ if (this.customMarkerClickCallback)
1773
+ try {
1774
+ this.customMarkerClickCallback(i, o);
1775
+ } catch (s) {
1776
+ console.error("Erro no customMarkerClickCallback:", s);
1777
+ }
1778
+ o ? this.canvasInteracao.ctx.selectedVizinhoPontoIds = [i] : (this.canvasInteracao.ctx.selectedPontoIds = [i], this.canvasInteracao.ctx.lastSelectedPontoId = i), this.context.selectedPontoIds = [...this.canvasInteracao.ctx.selectedPontoIds], this.atualizarDestaqueMarcadores(), window.dispatchEvent(new CustomEvent("gerencigeo:ponto-selecionado", {
1779
+ detail: { selectedPontoIds: [i], lastSelectedPontoId: i, isVizinho: o }
1780
+ }));
1781
+ },
1782
+ onPopupAcao: (e, o, i) => {
1783
+ if (this.customPopupActionCallback)
1784
+ try {
1785
+ this.customPopupActionCallback(e, o, i);
1786
+ } catch (s) {
1787
+ console.error("Erro no customPopupActionCallback:", s);
1788
+ }
1789
+ }
1790
+ };
1791
+ }
1792
+ init(t, e) {
1793
+ const o = this.core.init(t);
1794
+ return o && (this.layerManager.attachMap(o, this.context), this.canvasInteracao.ativar(this, e)), o;
1795
+ }
1796
+ invalidateSize() {
1797
+ try {
1798
+ this.core && (typeof this.core.invalidateSize == "function" ? this.core.invalidateSize() : this.core.map && typeof this.core.map.invalidateSize == "function" && this.core.map.invalidateSize());
1799
+ } catch {
1800
+ }
1801
+ }
1802
+ setPontos(t) {
1803
+ const e = t || [];
1804
+ this.context.pontos = e, this.canvasInteracao.ctx.pontosList = e, this.layerManager.updateContext({ pontos: e });
1805
+ }
1806
+ setSegmentos(t) {
1807
+ const e = t || [];
1808
+ this.context.segmentos = e, this.layerManager.updateContext({ segmentos: e });
1809
+ }
1810
+ setBancoPontos(t) {
1811
+ const e = t || [];
1812
+ this.context.bancoPontos = e, this.layerManager.updateContext({ bancoPontos: e });
1813
+ }
1814
+ setConfrontantes(t) {
1815
+ const e = t || [];
1816
+ this.context.confrontantes = e, this.layerManager.updateContext({ confrontantes: e });
1817
+ }
1818
+ plotarPontos(t, e = "vertices", o) {
1819
+ Yt(this, t, e, o);
1820
+ }
1821
+ plotarConexoes(t, e = "linhas") {
1822
+ Zt(this, t, e);
1823
+ }
1824
+ plotarPolilinhaSequencial(t, e = !0, o = "polilinha", i) {
1825
+ Ut(this, t, e, o, i);
1826
+ }
1827
+ plotarPoligonos(t, e = "poligonos") {
1828
+ Xt(this, t, e);
1829
+ }
1830
+ limparCamadas(t) {
1831
+ this.layerManager.clearLayers(t), (!t || t.length === 0) && this.canvasInteracao.limparSelecao();
1832
+ }
1833
+ obterMarcadores(t) {
1834
+ if (t) {
1835
+ const e = [], o = this.layerManager.getLayerInstance(t);
1836
+ if (o) {
1837
+ const i = (s) => {
1838
+ s instanceof v.Marker && e.push(s);
1839
+ };
1840
+ i(o), typeof o.eachLayer == "function" && o.eachLayer(i);
1841
+ }
1842
+ return e;
1843
+ }
1844
+ return this.getMarkers();
1845
+ }
1846
+ plotPontos(t, e) {
1847
+ e && (this.customMarkerClickCallback = e), this.setPontos(t || []);
1848
+ }
1849
+ plotSegmentos(t, e) {
1850
+ Kt(this, t, e);
1851
+ }
1852
+ plotPolilinhaTemporaria(t) {
1853
+ const e = t || [];
1854
+ this.context.pontos = e, this.context.segmentos = [], this.canvasInteracao.ctx.pontosList = e, this.layerManager.updateContext({ pontos: e, segmentos: [] });
1855
+ }
1856
+ plotPoligonalHomologada(t) {
1857
+ const e = t || [];
1858
+ this.setBancoPontos(e), this.layerManager.setLayerVisibility("homologados", !0), this.layerManager.setLayerVisibility("homologados-pontos", !0);
1859
+ }
1860
+ plotPontosVizinhos(t) {
1861
+ const e = Dt(t || [], this.context.confrontantes || []);
1862
+ this.setConfrontantes(e), this.layerManager.setLayerVisibility("vizinhos", !0);
1863
+ }
1864
+ plotPoligonosVizinhos(t) {
1865
+ const e = Rt(t || [], this.context.confrontantes || []);
1866
+ this.setConfrontantes(e), this.layerManager.setLayerVisibility("vizinhos", !0);
1867
+ }
1868
+ clearOverlays(t = !1) {
1869
+ Jt(this, t);
1870
+ }
1871
+ setGraphicScale(t) {
1872
+ this.layerManager.setGraphicScale(t);
1873
+ }
1874
+ exportState() {
1875
+ return this.layerManager.exportState();
1876
+ }
1877
+ importState(t) {
1878
+ this.layerManager.importState(t);
1879
+ }
1880
+ selectPonto(t, e) {
1881
+ if (!this.core.map) return;
1882
+ const o = String(t), i = this.getMarkers().find((a) => String(a.pontoId) === o);
1883
+ if (i) {
1884
+ const a = e !== void 0 ? e : this.core.map.getZoom();
1885
+ this.core.map.setView(i.getLatLng(), a), i.openPopup();
1886
+ }
1887
+ const s = ct(t);
1888
+ this.canvasInteracao.ctx.selectedPontoIds = [s], this.canvasInteracao.ctx.lastSelectedPontoId = s, this.context.selectedPontoIds = [s], this.atualizarDestaqueMarcadores();
1889
+ }
1890
+ atualizarDestaqueMarcadores() {
1891
+ ee(this);
1892
+ }
1893
+ fitBounds(t, e = [40, 40], o = !1) {
1894
+ if (!this.core.map) return;
1895
+ const i = Ft(t || this.context.pontos || [], this.context.confrontantes, o);
1896
+ if (i) {
1897
+ i.single ? this.core.map.setView(i.single, 18) : i.bounds && (this.core.map.fitBounds(i.bounds, { padding: e }), this.core.map.once("moveend", () => {
1898
+ this.core.preCarregarTilesRegiao(i.bounds);
1899
+ }));
1900
+ try {
1901
+ this.core.map.invalidateSize();
1902
+ } catch {
1903
+ }
1904
+ }
1905
+ }
1906
+ getMarkers() {
1907
+ return Wt(this.core.map, this.layerManager);
1908
+ }
1909
+ getVizinhosMarkers() {
1910
+ return this.getMarkers().filter((t) => !!t.isVizinho);
1911
+ }
1912
+ get destaqueAtivo() {
1913
+ return this.destaqueState.destaqueMarker !== null;
1914
+ }
1915
+ localizarCoordenadasElemento(t) {
1916
+ return ht(this, t);
1917
+ }
1918
+ destacarElemento(t, e) {
1919
+ Ht(this, this.destaqueState, t, e);
1920
+ }
1921
+ limparDestaque() {
1922
+ tt(this.destaqueState, this.getMap());
1923
+ }
1924
+ destroy() {
1925
+ if (this.limparDestaque(), this.canvasInteracao.desativar(), this.layerManager.destroy(), this.core.destroy(), this.core.map)
1926
+ try {
1927
+ this.core.map.off(), this.core.map.remove();
1928
+ } catch {
1929
+ } finally {
1930
+ this.core.map = null;
1931
+ }
1932
+ }
1933
+ getMap() {
1934
+ return this.core.map;
1935
+ }
1936
+ }
1937
+ function ie(n, t, e, o) {
1938
+ if (!n) return;
1939
+ if (n.querySelectorAll(".layer-item").length === t.length) {
1940
+ t.forEach((s) => {
1941
+ var c, r;
1942
+ const a = n.querySelector(`.layer-item[data-layer-id="${s.id}"]`);
1943
+ if (a) {
1944
+ const l = a.querySelector(".layer-chk-visibility");
1945
+ l && l.checked !== s.visivel && (l.checked = s.visivel);
1946
+ const p = a.querySelector(".layer-opacity-slider"), d = a.querySelector(".opacity-percent-label"), f = Math.round(s.opacidade * 100);
1947
+ p && parseInt(p.value, 10) !== f && (p.value = String(f)), d && (d.textContent = `${f}%`);
1948
+ const h = a.querySelector(".btn-lock-layer");
1949
+ h && (h.classList.toggle("active", !!s.bloqueada), h.title = s.bloqueada ? "Desbloquear Camada" : "Bloquear Camada");
1950
+ const y = a.querySelector(".btn-toggle-scale-mode");
1951
+ y && ((c = s.estilo) != null && c.scaleMode) && (y.textContent = ((r = s.estilo) == null ? void 0 : r.scaleMode) === "world" ? "Métrico" : "Tela");
1952
+ }
1953
+ });
1954
+ return;
1955
+ }
1956
+ n.innerHTML = `
1957
+ ${t.map((s) => {
1958
+ var a, c;
1959
+ return `
1960
+ <div class="layer-item" data-layer-id="${s.id}">
1961
+ <div class="layer-item-row">
1962
+ <label class="layer-item-label">
1963
+ <input type="checkbox" class="layer-chk-visibility" data-layer-id="${s.id}" ${s.visivel ? "checked" : ""} />
1964
+ <span>${s.nome}</span>
1965
+ </label>
1966
+ <div class="layer-item-actions">
1967
+ <button class="btn-layer-action btn-lock-layer ${s.bloqueada ? "active" : ""}" data-layer-id="${s.id}" type="button" title="${s.bloqueada ? "Desbloquear Camada" : "Bloquear Camada"}">
1968
+ ${s.bloqueada ? '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>' : '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>'}
1969
+ </button>
1970
+ ${(a = s.estilo) != null && a.scaleMode ? `
1971
+ <span class="scale-mode-pill btn-toggle-scale-mode" data-layer-id="${s.id}" title="Alternar modo de escala">
1972
+ ${((c = s.estilo) == null ? void 0 : c.scaleMode) === "world" ? "Métrico" : "Tela"}
1973
+ </span>
1974
+ ` : ""}
1975
+ </div>
1976
+ </div>
1977
+ <div class="layer-controls-row">
1978
+ <span>Opacidade</span>
1979
+ <input type="range" min="0" max="100" value="${Math.round(s.opacidade * 100)}" class="layer-opacity-slider" data-layer-id="${s.id}" />
1980
+ <span class="opacity-percent-label" style="font-family:monospace; font-size:9px; width:28px; text-align:right;">${Math.round(s.opacidade * 100)}%</span>
1981
+ </div>
1982
+ </div>
1983
+ `;
1984
+ }).join("")}
1985
+ `, e.cleanup(), n.querySelectorAll(".layer-chk-visibility").forEach((s) => {
1986
+ e.add(s, "change", (a) => {
1987
+ const c = a.target.getAttribute("data-layer-id"), r = a.target.checked;
1988
+ c && o.setLayerVisibility(c, r);
1989
+ });
1990
+ }), n.querySelectorAll(".layer-opacity-slider").forEach((s) => {
1991
+ e.add(s, "input", (a) => {
1992
+ const c = a.target.getAttribute("data-layer-id"), r = parseInt(a.target.value, 10), l = r / 100, p = a.target.closest(".layer-item"), d = p == null ? void 0 : p.querySelector(".opacity-percent-label");
1993
+ d && (d.textContent = `${r}%`), c && o.setLayerOpacity(c, l);
1994
+ });
1995
+ }), n.querySelectorAll(".btn-lock-layer").forEach((s) => {
1996
+ e.add(s, "click", (a) => {
1997
+ const c = a.currentTarget.getAttribute("data-layer-id");
1998
+ if (c) {
1999
+ const r = t.find((l) => l.id === c);
2000
+ r && o.setLayerBlocked(c, !r.bloqueada);
2001
+ }
2002
+ });
2003
+ }), n.querySelectorAll(".btn-toggle-scale-mode").forEach((s) => {
2004
+ e.add(s, "click", (a) => {
2005
+ var r;
2006
+ const c = a.currentTarget.getAttribute("data-layer-id");
2007
+ if (c) {
2008
+ const l = t.find((p) => p.id === c);
2009
+ if (l) {
2010
+ const p = ((r = l.estilo) == null ? void 0 : r.scaleMode) === "world" ? "screen" : "world";
2011
+ o.setLayerScaleMode(c, p);
2012
+ }
2013
+ }
2014
+ });
2015
+ });
2016
+ }
2017
+ function ne(n, t, e, o) {
2018
+ var b, M, I, z, E, w;
2019
+ if (n.modoSequencial || n.controller.canvasInteracao.selectionHappened || n.controller.canvasInteracao.panHappened || n.mouseMovedSinceDown) return !1;
2020
+ const i = (t == null ? void 0 : t.originalEvent) || t, s = typeof (i == null ? void 0 : i.composedPath) == "function" ? i.composedPath() : [], a = s.length > 0 ? s[0] : (i == null ? void 0 : i.target) || (t == null ? void 0 : t.target);
2021
+ if (a) {
2022
+ const g = '.custom-leaflet-marker, .leaflet-marker-icon, .leaflet-interactive, .compact-popup, .leaflet-popup, .ui-popup-btn, .cad-btn-tool, .qgis-layer-panel, [class*="leaflet-marker"], [class*="leaflet-popup"]';
2023
+ if (((b = a.matches) == null ? void 0 : b.call(a, g)) || ((M = a.closest) == null ? void 0 : M.call(a, g))) return !1;
2024
+ }
2025
+ const c = n.controller.getMap();
2026
+ if (!c || !n.mapContainer) return !1;
2027
+ let r, l;
2028
+ if (o)
2029
+ r = Math.round(o.x), l = Math.round(o.y);
2030
+ else if (t != null && t.containerPoint || t != null && t.layerPoint)
2031
+ r = Math.round(((I = t.containerPoint) == null ? void 0 : I.x) ?? ((z = t.layerPoint) == null ? void 0 : z.x) ?? 0), l = Math.round(((E = t.containerPoint) == null ? void 0 : E.y) ?? ((w = t.layerPoint) == null ? void 0 : w.y) ?? 0);
2032
+ else {
2033
+ const g = n.mapContainer.getBoundingClientRect(), m = (i == null ? void 0 : i.clientX) ?? 0, x = (i == null ? void 0 : i.clientY) ?? 0;
2034
+ r = Math.round(m - g.left), l = Math.round(x - g.top);
2035
+ }
2036
+ const p = { x: r, y: l };
2037
+ let d, f;
2038
+ const h = e || (t == null ? void 0 : t.latlng);
2039
+ if (h && typeof h.lat == "number")
2040
+ d = h.lat, f = h.lng ?? h.lon ?? 0;
2041
+ else {
2042
+ const g = c.containerPointToLatLng(v.point(p.x, p.y));
2043
+ d = g.lat, f = g.lng;
2044
+ }
2045
+ const y = n.controller.layerManager ? n.controller.layerManager.getLayers().filter((g) => g.visivel).map((g) => g.id) : [], S = i;
2046
+ return n.host.dispatchEvent(new CustomEvent("ui-canvas-clique", {
2047
+ detail: {
2048
+ coordenadas: {
2049
+ lat: d,
2050
+ lng: f
2051
+ },
2052
+ pontoPixel: p,
2053
+ eventoOriginal: S,
2054
+ lat: d,
2055
+ lon: f,
2056
+ lng: f,
2057
+ camadasAtivas: y
2058
+ },
2059
+ bubbles: !0,
2060
+ composed: !0
2061
+ })), !0;
2062
+ }
2063
+ function se(n, t, e, o) {
2064
+ const i = o || n.obterElementoPorId(e);
2065
+ n.host.dispatchEvent(new CustomEvent("ui-acao-popup", {
2066
+ detail: {
2067
+ acaoId: t,
2068
+ elementoId: e,
2069
+ elemento: i ?? { id: e }
2070
+ },
2071
+ bubbles: !0,
2072
+ composed: !0
2073
+ })), n.fecharPopup();
2074
+ }
2075
+ function ae(n, t, e, o, i, s, a) {
2076
+ let c = o || n.obterElementoPorId(t), r = i;
2077
+ if (!r && c) {
2078
+ const l = c.lat ?? c.latitude ?? 0, p = c.lon ?? c.lng ?? c.longitude ?? 0;
2079
+ r = { lat: Number(l), lon: Number(p) };
2080
+ }
2081
+ if (r || (r = { lat: 0, lon: 0 }), n.modoSequencial) {
2082
+ n.fecharPopup(), n.host.dispatchEvent(new CustomEvent("ui-clique-sequencial", {
2083
+ detail: {
2084
+ id: t,
2085
+ elemento: c ?? { id: t, lat: r.lat, lon: r.lon },
2086
+ coordenadas: r
2087
+ },
2088
+ bubbles: !0,
2089
+ composed: !0
2090
+ }));
2091
+ return;
2092
+ }
2093
+ if (a)
2094
+ try {
2095
+ const l = t != null && !isNaN(Number(t)) && String(t).trim() !== "" ? Number(t) : t;
2096
+ a(l, e);
2097
+ } catch (l) {
2098
+ console.error("Erro no callback de clique de marcador:", l);
2099
+ }
2100
+ if (s)
2101
+ try {
2102
+ s(t, e, c, r);
2103
+ } catch (l) {
2104
+ console.error("Erro no handler anterior de marker click:", l);
2105
+ }
2106
+ n.host.dispatchEvent(new CustomEvent("ui-ponto-selecionado", {
2107
+ detail: { selectedIds: [t], lastSelectedId: t, isVizinho: e },
2108
+ bubbles: !0,
2109
+ composed: !0
2110
+ })), n.host.dispatchEvent(new CustomEvent("ui-elemento-selecionado", {
2111
+ detail: { id: t, elemento: c, tipo: e ? "vizinho" : "vertice", coordenadas: r },
2112
+ bubbles: !0,
2113
+ composed: !0
2114
+ }));
2115
+ }
2116
+ function re(n, t) {
2117
+ let e = null, o = null, i = 0, s = 0;
2118
+ function a() {
2119
+ var p;
2120
+ try {
2121
+ if (!n.isConnected) return;
2122
+ const d = t.getMap();
2123
+ if (!d) return;
2124
+ const f = (p = d.getContainer) == null ? void 0 : p.call(d);
2125
+ if (!f || !f.parentNode) return;
2126
+ t.invalidateSize();
2127
+ } catch {
2128
+ }
2129
+ }
2130
+ function c(p = 25) {
2131
+ o !== null && (window.clearTimeout(o), o = null), o = window.setTimeout(() => {
2132
+ o = null, a();
2133
+ }, p);
2134
+ }
2135
+ function r() {
2136
+ l(), !(typeof ResizeObserver > "u") && (e = new ResizeObserver((p) => {
2137
+ for (const d of p) {
2138
+ let f = 0, h = 0;
2139
+ d.contentRect ? (f = d.contentRect.width, h = d.contentRect.height) : d.borderBoxSize && d.borderBoxSize.length > 0 ? (f = d.borderBoxSize[0].inlineSize, h = d.borderBoxSize[0].blockSize) : (f = n.clientWidth || n.offsetWidth, h = n.clientHeight || n.offsetHeight), f > 0 && h > 0 && (Math.abs(f - i) >= 0.5 || Math.abs(h - s) >= 0.5) && (i = f, s = h, c(25));
2140
+ }
2141
+ }), e.observe(n));
2142
+ }
2143
+ function l() {
2144
+ e && (e.disconnect(), e = null), o !== null && (window.clearTimeout(o), o = null);
2145
+ }
2146
+ return {
2147
+ observe: r,
2148
+ disconnect: l,
2149
+ invalidateSizeSafely: a
2150
+ };
2151
+ }
2152
+ class le {
2153
+ constructor(t) {
2154
+ u(this, "canal", null);
2155
+ u(this, "contexto");
2156
+ this.contexto = t;
2157
+ }
2158
+ conectar(t) {
2159
+ this.desconectar();
2160
+ const e = t !== void 0 ? t : this.contexto.host.getAttribute("canal-configuracao");
2161
+ if (!(!e || typeof BroadcastChannel > "u"))
2162
+ try {
2163
+ this.canal = new BroadcastChannel(e), this.canal.onmessage = (o) => {
2164
+ this.processarMensagem(o.data);
2165
+ };
2166
+ } catch (o) {
2167
+ console.warn(`[ui-canvas-cad] Erro ao conectar ao BroadcastChannel "${e}":`, o);
2168
+ }
2169
+ }
2170
+ processarMensagem(t) {
2171
+ if (!t || typeof t != "object") return;
2172
+ const e = t.tipo || "ESTILOS_ALTERADOS", o = t.configuracoes || t;
2173
+ if (o.crosshair !== void 0) {
2174
+ const i = !!o.crosshair;
2175
+ this.contexto.mapContainer && (this.contexto.mapContainer.style.cursor = i ? "crosshair" : "");
2176
+ const s = this.contexto.controller.getMap();
2177
+ if (s) {
2178
+ const a = s.getContainer();
2179
+ a && (a.style.cursor = i ? "crosshair" : "");
2180
+ }
2181
+ this.contexto.controller.core.config.crosshair = i;
2182
+ }
2183
+ if (o.opacidadeBase !== void 0) {
2184
+ const i = parseFloat(o.opacidadeBase);
2185
+ isNaN(i) || this.contexto.setLayerOpacity("satelite", i);
2186
+ }
2187
+ if (o.satOpacity !== void 0) {
2188
+ const i = parseFloat(o.satOpacity);
2189
+ isNaN(i) || this.contexto.setLayerOpacity("satelite", i);
2190
+ }
2191
+ o.opacidades && typeof o.opacidades == "object" && Object.entries(o.opacidades).forEach(([i, s]) => {
2192
+ const a = parseFloat(s);
2193
+ isNaN(a) || this.contexto.setLayerOpacity(i, a);
2194
+ }), this.contexto.host.dispatchEvent(new CustomEvent("ui-config-aplicada", {
2195
+ detail: {
2196
+ tipo: e,
2197
+ configuracoes: o
2198
+ },
2199
+ bubbles: !0,
2200
+ composed: !0
2201
+ }));
2202
+ }
2203
+ desconectar() {
2204
+ if (this.canal) {
2205
+ try {
2206
+ this.canal.close();
2207
+ } catch {
2208
+ }
2209
+ this.canal = null;
2210
+ }
2211
+ }
2212
+ }
2213
+ class ce {
2214
+ constructor(t) {
2215
+ u(this, "contexto");
2216
+ u(this, "uiListeners", new dt());
2217
+ u(this, "isLayersPanelOpen", !1);
2218
+ u(this, "mouseMovedSinceDown", !1);
2219
+ u(this, "mouseDownPos", { x: 0, y: 0 });
2220
+ this.contexto = t;
2221
+ }
2222
+ get estaPainelAberto() {
2223
+ return this.isLayersPanelOpen;
2224
+ }
2225
+ get houveMovimentoMouse() {
2226
+ return this.mouseMovedSinceDown;
2227
+ }
2228
+ toggleLayersPanel() {
2229
+ this.isLayersPanelOpen = !this.isLayersPanelOpen, this.contexto.layersPanel && (this.isLayersPanelOpen ? this.contexto.layersPanel.classList.remove("collapsed") : this.contexto.layersPanel.classList.add("collapsed"));
2230
+ const t = this.contexto.shadow.getElementById("btn-toggle-layers");
2231
+ t == null || t.classList.toggle("active", this.isLayersPanelOpen);
2232
+ }
2233
+ closeLayersPanel() {
2234
+ var e;
2235
+ this.isLayersPanelOpen = !1, (e = this.contexto.layersPanel) == null || e.classList.add("collapsed");
2236
+ const t = this.contexto.shadow.getElementById("btn-toggle-layers");
2237
+ t == null || t.classList.remove("active");
2238
+ }
2239
+ vincularEventos() {
2240
+ this.uiListeners.cleanup();
2241
+ const t = this.contexto.shadow.getElementById("btn-toggle-layers"), e = this.contexto.shadow.getElementById("btn-close-layers"), o = this.contexto.shadow.getElementById("btn-zoom-extents"), i = this.contexto.shadow.getElementById("btn-clear-selection");
2242
+ this.uiListeners.add(t, "click", () => {
2243
+ this.contexto.onToggleCamadas ? this.contexto.onToggleCamadas() : this.toggleLayersPanel();
2244
+ }), this.uiListeners.add(e, "click", () => {
2245
+ this.contexto.onCloseCamadas ? this.contexto.onCloseCamadas() : this.closeLayersPanel();
2246
+ }), this.uiListeners.add(o, "click", () => {
2247
+ var s, a;
2248
+ (a = (s = this.contexto).onZoomExtents) == null || a.call(s);
2249
+ }), this.uiListeners.add(i, "click", () => {
2250
+ var s, a;
2251
+ (a = (s = this.contexto).onLimparSelecao) == null || a.call(s);
2252
+ }), this.contexto.mapContainer && (this.uiListeners.add(this.contexto.mapContainer, "mousedown", (s) => {
2253
+ s.button === 0 && (this.mouseDownPos = { x: s.clientX, y: s.clientY }, this.mouseMovedSinceDown = !1);
2254
+ }), this.uiListeners.add(this.contexto.mapContainer, "mousemove", (s) => {
2255
+ Math.hypot(s.clientX - this.mouseDownPos.x, s.clientY - this.mouseDownPos.y) >= 4 && (this.mouseMovedSinceDown = !0);
2256
+ }), this.uiListeners.add(this.contexto.mapContainer, "click", (s) => {
2257
+ var a, c;
2258
+ s.button === 0 && (this.mouseMovedSinceDown || (c = (a = this.contexto).onTratarCliqueCanvas) == null || c.call(a, s));
2259
+ })), this.uiListeners.add(this.contexto.shadow, "click", (s) => {
2260
+ var r, l, p;
2261
+ const a = s.composedPath ? s.composedPath()[0] : s.target, c = (r = a == null ? void 0 : a.closest) == null ? void 0 : r.call(a, ".ui-popup-btn");
2262
+ if (c) {
2263
+ s.preventDefault(), s.stopPropagation();
2264
+ const d = c.getAttribute("data-acao-id"), f = c.getAttribute("data-elemento-id");
2265
+ d && f !== null && ((p = (l = this.contexto).onDispararAcaoPopup) == null || p.call(l, d, f));
2266
+ }
2267
+ });
2268
+ }
2269
+ limpar() {
2270
+ this.uiListeners.cleanup();
2271
+ }
2272
+ }
2273
+ class de {
2274
+ constructor(t) {
2275
+ u(this, "contexto");
2276
+ u(this, "_pontos", []);
2277
+ u(this, "_segmentos", []);
2278
+ u(this, "_bancoPontos", []);
2279
+ u(this, "_confrontantes", []);
2280
+ u(this, "customMarkerClickHandler");
2281
+ this.contexto = t;
2282
+ }
2283
+ get pontos() {
2284
+ return this._pontos;
2285
+ }
2286
+ set pontos(t) {
2287
+ this._pontos = t || [], this.contexto.obterController().setPontos(this._pontos);
2288
+ }
2289
+ get segmentos() {
2290
+ return this._segmentos;
2291
+ }
2292
+ set segmentos(t) {
2293
+ this._segmentos = t || [], this.contexto.obterController().setSegmentos(this._segmentos);
2294
+ }
2295
+ get bancoPontos() {
2296
+ return this._bancoPontos;
2297
+ }
2298
+ set bancoPontos(t) {
2299
+ this._bancoPontos = t || [], this.contexto.obterController().setBancoPontos(this._bancoPontos);
2300
+ }
2301
+ get confrontantes() {
2302
+ return this._confrontantes;
2303
+ }
2304
+ set confrontantes(t) {
2305
+ this._confrontantes = t || [], this.contexto.obterController().setConfrontantes(this._confrontantes);
2306
+ }
2307
+ sincronizarInicial() {
2308
+ const t = this.contexto.obterController();
2309
+ this._pontos.length > 0 && t.setPontos(this._pontos), this._segmentos.length > 0 && t.setSegmentos(this._segmentos), this._bancoPontos.length > 0 && t.setBancoPontos(this._bancoPontos), this._confrontantes.length > 0 && t.setConfrontantes(this._confrontantes);
2310
+ }
2311
+ obterElementoPorId(t) {
2312
+ return this._pontos.find((e) => String(e.id) === String(t)) || this._bancoPontos.find((e) => String(e.id) === String(t)) || this._confrontantes.find((e) => String(e.id) === String(t));
2313
+ }
2314
+ plotarPontos(t, e = "vertices", o) {
2315
+ const i = t || [];
2316
+ e === "vertices" && (this._pontos = i), this.contexto.obterController().plotarPontos(i, e, o);
2317
+ }
2318
+ plotarConexoes(t, e = "linhas") {
2319
+ const o = t || [];
2320
+ this.contexto.obterController().plotarConexoes(o, e);
2321
+ }
2322
+ plotarPolilinhaSequencial(t, e = !0, o = "polilinha", i) {
2323
+ const s = t || [];
2324
+ (o === "polilinha" || o === "perimetro") && (this._pontos = s, this._segmentos = []);
2325
+ const a = i ?? this.contexto.obterChaveGrupo();
2326
+ this.contexto.obterController().plotarPolilinhaSequencial(s, e, o, a);
2327
+ }
2328
+ plotarPoligonos(t, e = "poligonos") {
2329
+ const o = t || [];
2330
+ this.contexto.obterController().plotarPoligonos(o, e);
2331
+ }
2332
+ limparCamadas(t) {
2333
+ !t || t.length === 0 ? (this._pontos = [], this._segmentos = [], this._confrontantes = []) : (t.includes("vertices") && (this._pontos = []), (t.includes("linhas") || t.includes("perimetro") || t.includes("polilinha")) && (this._segmentos = []), (t.includes("poligonos") || t.includes("vizinhos")) && (this._confrontantes = [])), this.contexto.obterController().limparCamadas(t);
2334
+ }
2335
+ obterMarcadores(t) {
2336
+ return this.contexto.obterController().obterMarcadores(t);
2337
+ }
2338
+ plotPontos(t, e) {
2339
+ e && (this.customMarkerClickHandler = e);
2340
+ const o = t || [];
2341
+ this._pontos = o, this.contexto.obterController().plotPontos(o, e);
2342
+ }
2343
+ plotSegmentos(t, e) {
2344
+ const o = t || [];
2345
+ e != null && (this._pontos = e || []), this._segmentos = o, this.contexto.obterController().plotSegmentos(o, e);
2346
+ }
2347
+ plotPolilinhaTemporaria(t) {
2348
+ const e = t || [];
2349
+ this._pontos = e, this._segmentos = [], this.contexto.obterController().plotPolilinhaTemporaria(e);
2350
+ }
2351
+ plotPoligonalHomologada(t) {
2352
+ const e = t || [];
2353
+ this._bancoPontos = e, this.contexto.obterController().plotPoligonalHomologada(e), this.contexto.setLayerVisibility("homologados", !0), this.contexto.setLayerVisibility("homologados-pontos", !0);
2354
+ }
2355
+ plotPontosVizinhos(t) {
2356
+ const e = t || [], o = this.contexto.obterController();
2357
+ o.plotPontosVizinhos(e), this._confrontantes = o.context.confrontantes || [];
2358
+ }
2359
+ plotPoligonosVizinhos(t) {
2360
+ const e = t || [], o = this.contexto.obterController();
2361
+ o.plotPoligonosVizinhos(e), this._confrontantes = o.context.confrontantes || [];
2362
+ }
2363
+ clearOverlays(t = !1) {
2364
+ this._pontos = [], this._segmentos = [], this._confrontantes = [], t || (this._bancoPontos = []), this.contexto.obterController().clearOverlays(t);
2365
+ }
2366
+ getMarkers() {
2367
+ return this.contexto.obterController().getMarkers();
2368
+ }
2369
+ getVizinhosMarkers() {
2370
+ return this.contexto.obterController().getVizinhosMarkers();
2371
+ }
2372
+ }
2373
+ const pe = ':host{display:block;width:100%;height:520px;position:relative;border-radius:var(--ui-radius-lg, 10px);overflow:hidden;box-shadow:0 10px 30px -5px #0009;border:1px solid rgba(255,255,255,.1);background:#080d0a;color:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Inter,sans-serif;user-select:none;-webkit-user-select:none}*,*:before,*:after{box-sizing:border-box}.cad-root{position:relative;width:100%;height:100%;display:flex;overflow:hidden}.cad-map-container{width:100%;height:100%;background:#080d0a;z-index:1}.qgis-layer-panel{position:absolute;top:12px;left:12px;z-index:var(--ui-z-workspace-hud, 500);width:290px;max-height:calc(100% - 24px);background:#0a120eeb;backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border:1px solid rgba(255,255,255,.15);border-radius:8px;box-shadow:0 20px 40px #000000b3;display:flex;flex-direction:column;transition:transform .25s cubic-bezier(.16,1,.3,1),opacity .25s ease;overflow:hidden}.qgis-layer-panel.collapsed{transform:translate(-310px);opacity:0;pointer-events:none}.layer-panel-header{padding:10px 14px;background:#ffffff08;border-bottom:1px solid rgba(255,255,255,.08);display:flex;align-items:center;justify-content:space-between}.layer-panel-title{font-size:12px;font-weight:700;letter-spacing:.5px;color:#00f5a0;display:flex;align-items:center;gap:6px;text-transform:uppercase}.layer-panel-close{background:transparent;border:none;color:#ffffff80;cursor:pointer;padding:2px;border-radius:4px;display:flex;align-items:center;justify-content:center;transition:all .15s}.layer-panel-close:hover{color:#fff;background:#ffffff1a}.layer-panel-body{padding:8px 10px;overflow-y:auto;display:flex;flex-direction:column;gap:2px;max-height:400px}.layer-panel-body::-webkit-scrollbar{width:5px}.layer-panel-body::-webkit-scrollbar-track{background:transparent}.layer-panel-body::-webkit-scrollbar-thumb{background:#fff3;border-radius:4px}.layer-panel-body::-webkit-scrollbar-thumb:hover{background:#00f5a066}.layer-item{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.08);border-radius:0;padding:4px;display:flex;flex-direction:column;gap:3px;transition:background .15s ease}.layer-item:last-child{border-bottom:none}.layer-item:hover{background:#ffffff08;border-radius:4px}.layer-item-row{display:flex;align-items:center;justify-content:space-between;min-height:18px}.layer-item-label{display:flex;align-items:center;gap:7px;font-size:11px;font-weight:600;line-height:1.2;color:#ffffffe6;cursor:pointer;-webkit-user-select:none;user-select:none}.layer-chk-visibility{-moz-appearance:none;appearance:none;-webkit-appearance:none;width:14px;height:14px;border:1px solid rgba(255,255,255,.4);border-radius:3px;background:#0006;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;position:relative;transition:all .15s ease;flex-shrink:0;margin:0}.layer-chk-visibility:hover{border-color:#00f5a0}.layer-chk-visibility:checked{background:#00f5a0;border-color:#00f5a0}.layer-chk-visibility:checked:after{content:"";width:3.5px;height:7px;border:solid #04150c;border-width:0 1.5px 1.5px 0;transform:rotate(45deg) translateY(-.5px);display:block}.layer-item-actions{display:flex;align-items:center;gap:4px}.btn-layer-action{background:transparent;border:none;color:#fff6;cursor:pointer;padding:2px;border-radius:3px;display:flex;align-items:center;justify-content:center;transition:all .15s}.btn-layer-action:hover{color:#00f5a0;background:#ffffff14}.btn-layer-action.active{color:#f43f5e;background:#f43f5e26}.layer-controls-row{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:9.5px;line-height:1;color:#ffffff80;padding-left:21px}.layer-opacity-slider{flex:1;height:3px;margin:0;border-radius:2px;background:#ffffff26;accent-color:#00f5a0;cursor:pointer}.scale-mode-pill{font-size:8.5px;font-weight:600;padding:1px 6px;border-radius:6px;background:#ffffff0f;color:#ffffffb3;cursor:pointer;border:1px solid rgba(255,255,255,.1);transition:all .15s;line-height:1.2}.scale-mode-pill:hover{border-color:#00f5a0;color:#00f5a0;background:#00f5a01a}.cad-quick-toolbar{position:absolute;top:12px;right:12px;z-index:var(--ui-z-workspace-hud, 500);display:flex;flex-direction:column;gap:6px;background:#0c1510eb;backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);border:1px solid rgba(255,255,255,.15);border-radius:8px;padding:5px;box-shadow:0 10px 25px -5px #0009}.cad-btn-tool{background:transparent;border:none;color:#fff9;cursor:pointer;padding:7px;border-radius:5px;display:flex;align-items:center;justify-content:center;transition:all .15s}.cad-btn-tool:hover{background:#ffffff1a;color:#fff}.cad-btn-tool.active{background:#00f5a026;color:#00f5a0;border:1px solid rgba(0,245,160,.3)}.cad-selection-box{pointer-events:none;box-sizing:border-box}.custom-leaflet-marker{cursor:pointer}.custom-leaflet-marker:hover{filter:brightness(1.25);transform:scale(1.15);transition:transform .15s ease}.leaflet-popup-content-wrapper{background:#0f1712!important;color:#f8fafc!important;border:1px solid rgba(255,255,255,.15)!important;border-radius:8px!important;box-shadow:0 10px 25px #0009!important;padding:0!important;backdrop-filter:blur(16px)!important;-webkit-backdrop-filter:blur(16px)!important}.leaflet-popup-tip{background:#0f1712!important;border:1px solid rgba(255,255,255,.15)!important;box-shadow:none!important}.leaflet-popup-close-button{color:#fff9!important;padding:6px!important;transition:color .15s ease}.leaflet-popup-close-button:hover{color:#fff!important}.leaflet-popup-content{margin:12px 14px!important;line-height:1.4;font-family:inherit;color:#f8fafc}.compact-popup .leaflet-popup-content{margin:10px 12px!important}.ui-popup-actions-footer{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid rgba(255,255,255,.1);justify-content:flex-end;align-items:center;flex-wrap:wrap}.ui-popup-btn{display:inline-flex;align-items:center;justify-content:center;font-family:inherit;font-size:11px;font-weight:500;padding:4px 9px;border-radius:var(--ui-raio-borda, var(--ui-radius-sm, 6px));cursor:pointer;transition:all .15s ease;border:1px solid transparent;outline:none;line-height:1.25;-webkit-user-select:none;user-select:none}.ui-popup-btn-primary{background:var(--ui-cor-primaria, #00f5a0);color:#080d0a;font-weight:600;border-color:var(--ui-cor-primaria, #00f5a0)}.ui-popup-btn-primary:hover{filter:brightness(1.1);box-shadow:0 0 10px #00f5a059}.ui-popup-btn-secondary{background:#ffffff14;color:#fff;border-color:#ffffff2e}.ui-popup-btn-secondary:hover{background:#ffffff29;border-color:#ffffff4d}.ui-popup-btn-destrutivo{background:#ef444426;color:#f87171;border-color:#ef444459}.ui-popup-btn-destrutivo:hover{background:#ef444440;border-color:#ef444499;color:#fff}@media (max-width: 520px){.qgis-layer-panel{top:8px;left:8px;right:8px;width:auto;max-height:calc(100% - 16px)}.qgis-layer-panel.collapsed{transform:translateY(-115%)}.layer-panel-close{min-width:36px;min-height:36px;font-size:16px}.layer-action-btn{min-width:32px;min-height:32px}}.cad-destaque-marker-container{pointer-events:none!important;background:transparent!important;border:none!important;overflow:visible!important}.cad-destaque-marker-container *{pointer-events:none!important}.cad-pulse-highlight{position:relative;width:52px;height:52px;display:flex;align-items:center;justify-content:center;pointer-events:none!important;user-select:none;-webkit-user-select:none}.cad-pulse-core{position:absolute;width:14px;height:14px;border-radius:50%;background-color:var(--cad-pulse-cor, #00f5a0);box-shadow:0 0 10px var(--cad-pulse-cor, #00f5a0),0 0 20px var(--cad-pulse-cor, #00f5a0);pointer-events:none!important;animation:cad-pulse-glow 1.4s ease-in-out infinite alternate}.cad-pulse-ring{position:absolute;width:100%;height:100%;border-radius:50%;border:2.5px solid var(--cad-pulse-cor, #00f5a0);box-shadow:0 0 10px var(--cad-pulse-cor, #00f5a0);pointer-events:none!important;opacity:0;animation:cad-pulse-ping 1.8s cubic-bezier(0,0,.2,1) infinite}.cad-pulse-ring.ring-2{animation-delay:.6s}@keyframes cad-pulse-ping{0%{transform:scale(.35);opacity:.95}60%{opacity:.5}to{transform:scale(2.5);opacity:0}}@keyframes cad-pulse-glow{0%{transform:scale(.85);opacity:.8}to{transform:scale(1.15);opacity:1;box-shadow:0 0 14px var(--cad-pulse-cor, #00f5a0),0 0 26px var(--cad-pulse-cor, #00f5a0)}}.cad-marker-selected,.ponto-selecionado{z-index:2000!important}.cad-marker-selected>div,.ponto-selecionado>div{animation:cad-ponto-pulse 1.8s ease-in-out infinite alternate!important}@keyframes cad-ponto-pulse{0%{filter:drop-shadow(0 0 3px #ffffff) drop-shadow(0 0 6px #00f5a0)}to{filter:drop-shadow(0 0 6px #ffffff) drop-shadow(0 0 16px #00f5a0)}}.ui-popup-actions-footer{margin-top:8px;padding-top:6px;border-top:1px solid rgba(255,255,255,.12);display:flex;gap:6px;flex-wrap:wrap}.ui-popup-btn{display:inline-flex;align-items:center;justify-content:center;padding:4px 8px;font-size:11px;font-weight:600;border-radius:4px;border:1px solid rgba(255,255,255,.15);background:#ffffff14;color:#fff;cursor:pointer;line-height:1.2;transition:all .15s ease;-webkit-user-select:none;user-select:none}.ui-popup-btn:hover{background:#ffffff2e;border-color:#ffffff4d}.ui-popup-btn-primary{background:#00f5a0;color:#06130b;border-color:#00f5a0}.ui-popup-btn-primary:hover{background:#10ffad;box-shadow:0 0 8px #00f5a066}.ui-popup-btn-danger{background:#f43f5e33;color:#f43f5e;border-color:#f43f5e66}.ui-popup-btn-danger:hover{background:#f43f5e59;color:#fff}';
2374
+ function he() {
2375
+ return `
2376
+ <style>
2377
+ ${gt}
2378
+ ${pe}
2379
+ </style>
2380
+ <div class="cad-root" id="cad-root">
2381
+ <div class="cad-map-container" id="cad-map-container"></div>
2382
+ <div class="qgis-layer-panel collapsed" id="qgis-layer-panel">
2383
+ <div class="layer-panel-header">
2384
+ <div class="layer-panel-title">
2385
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polygon points="12 2 2 7 12 12 22 7 12 2"/><polyline points="2 17 12 22 22 17"/><polyline points="2 12 12 17 22 12"/></svg>
2386
+ Camadas
2387
+ </div>
2388
+ <button class="layer-panel-close" id="btn-close-layers" type="button" title="Fechar">
2389
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
2390
+ </button>
2391
+ </div>
2392
+ <div class="layer-panel-body" id="layers-list-container"></div>
2393
+ </div>
2394
+ <div class="cad-quick-toolbar">
2395
+ <button class="cad-btn-tool" id="btn-toggle-layers" type="button" title="Camadas">
2396
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 2 7 12 12 22 7 12 2"/><polyline points="2 17 12 22 22 17"/><polyline points="2 12 12 17 22 12"/></svg>
2397
+ </button>
2398
+ <button class="cad-btn-tool" id="btn-zoom-extents" type="button" title="Enquadrar">
2399
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="22" y1="12" x2="18" y2="12"/><line x1="6" y1="12" x2="2" y2="12"/><line x1="12" y1="6" x2="12" y2="2"/><line x1="12" y1="22" x2="12" y2="18"/></svg>
2400
+ </button>
2401
+ <button class="cad-btn-tool" id="btn-clear-selection" type="button" title="Limpar seleção">
2402
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" stroke-dasharray="3 3"/><line x1="9" y1="9" x2="15" y2="15"/><line x1="15" y1="9" x2="9" y2="15"/></svg>
2403
+ </button>
2404
+ </div>
2405
+ </div>
2406
+ `;
2407
+ }
2408
+ function fe(n, t, e, o) {
2409
+ if (e !== o) {
2410
+ if (t === "sat-opacity") {
2411
+ const i = parseFloat(o);
2412
+ isNaN(i) || n.setLayerOpacity("satelite", i);
2413
+ } else if (t === "scale-mode")
2414
+ (o === "world" || o === "screen") && (n.setLayerScaleMode("perimetro", o), n.setLayerScaleMode("vertices", o));
2415
+ else if (t === "modo-sequencial")
2416
+ n.host.modoSequencial = o !== null && o !== "false";
2417
+ else if (t === "chave-grupo")
2418
+ n.host.chaveGrupo = o || void 0;
2419
+ else if (t === "zona-projecao" || t === "fuso") {
2420
+ const i = parseInt(o, 10);
2421
+ !isNaN(i) && i > 0 && (n.atualizarZonaProjecao(i), t === "fuso" && n.host.getAttribute("zona-projecao") !== o ? n.host.setAttribute("zona-projecao", o) : t === "zona-projecao" && n.host.hasAttribute("fuso") && n.host.getAttribute("fuso") !== o && n.host.setAttribute("fuso", o), n.controller.zonaProjecao = i, n.controller.context.zonaProjecao = i);
2422
+ } else if (t === "canal-configuracao")
2423
+ n.broadcastConfig.conectar(o);
2424
+ else if (t === "crosshair") {
2425
+ const i = o !== null && o !== "false";
2426
+ n.mapContainer && (n.mapContainer.style.cursor = i ? "crosshair" : "");
2427
+ const s = n.controller.getMap();
2428
+ if (s) {
2429
+ const a = s.getContainer();
2430
+ a && (a.style.cursor = i ? "crosshair" : "");
2431
+ }
2432
+ n.controller.core.config.crosshair = i;
2433
+ }
2434
+ }
2435
+ }
2436
+ function ue(n) {
2437
+ if (!n.mapContainer) return;
2438
+ if (n.mapContainer._leaflet_id && !n.controller.getMap())
2439
+ try {
2440
+ delete n.mapContainer._leaflet_id;
2441
+ } catch {
2442
+ n.mapContainer._leaflet_id = void 0;
2443
+ }
2444
+ if (n.controller.init(n.mapContainer, n.shadow), n.toolbarPainel.vincularEventos(), n.renderLayersUI(), n.host.hasAttribute("modo-sequencial") && (n.controller.modoCliqueSequencialAtivo = !0, n.controller.context.modoSequencial = !0), n.host.hasAttribute("chave-grupo")) {
2445
+ const o = n.host.getAttribute("chave-grupo");
2446
+ o && (n.host.chaveGrupo = o);
2447
+ }
2448
+ if (n.host.hasAttribute("zona-projecao") || n.host.hasAttribute("fuso")) {
2449
+ const o = n.host.zonaProjecao;
2450
+ n.controller.zonaProjecao = o, n.controller.context.zonaProjecao = o;
2451
+ }
2452
+ if (n.host.hasAttribute("crosshair")) {
2453
+ const o = n.host.getAttribute("crosshair") !== "false";
2454
+ n.mapContainer && (n.mapContainer.style.cursor = o ? "crosshair" : ""), n.controller.core.config.crosshair = o;
2455
+ }
2456
+ n.colecoesDados.sincronizarInicial(), n.controller.layerManager.onChange((o) => {
2457
+ n.renderLayersUI(), n.host.dispatchEvent(new CustomEvent("ui-camadas-alteradas", {
2458
+ detail: { layers: o },
2459
+ bubbles: !0,
2460
+ composed: !0
2461
+ }));
2462
+ });
2463
+ const t = n.controller.context.onMarkerClick;
2464
+ n.controller.context.onMarkerClick = (o, i, s, a) => {
2465
+ ae(
2466
+ n.obterContextoEventos(),
2467
+ o,
2468
+ i,
2469
+ s,
2470
+ a,
2471
+ t,
2472
+ n.colecoesDados.customMarkerClickHandler
2473
+ );
2474
+ }, n.controller.context.onPopupAcao = (o, i, s) => {
2475
+ n.dispararAcaoPopup(o, i, s);
2476
+ };
2477
+ const e = n.controller.getMap();
2478
+ e && e.on("click", (o) => {
2479
+ n.toolbarPainel.houveMovimentoMouse || n.tratarCliqueLivreCanvas(o, o.latlng, o.containerPoint);
2480
+ }), setTimeout(() => {
2481
+ n.invalidateSizeSafely();
2482
+ }, 150);
2483
+ }
2484
+ class ge extends vt {
2485
+ constructor() {
2486
+ super();
2487
+ u(this, "shadow");
2488
+ u(this, "mapContainer", null);
2489
+ u(this, "layersPanel", null);
2490
+ u(this, "controller");
2491
+ u(this, "controladorTamanho");
2492
+ u(this, "toolbarPainel");
2493
+ u(this, "broadcastConfig");
2494
+ u(this, "colecoesDados");
2495
+ u(this, "layerItemListeners", new dt());
2496
+ u(this, "initTimeout");
2497
+ u(this, "lastPopupActionEmit");
2498
+ u(this, "lastCanvasClickTime", 0);
2499
+ u(this, "_chaveGrupo");
2500
+ u(this, "_zonaProjecao", 22);
2501
+ this.shadow = this.attachShadow({ mode: "open" }), this.controller = new oe(), this.controladorTamanho = re(this, this.controller), this.shadow.innerHTML = he(), this.mapContainer = this.shadow.getElementById("cad-map-container"), this.layersPanel = this.shadow.getElementById("qgis-layer-panel"), this.toolbarPainel = new ce({
2502
+ shadow: this.shadow,
2503
+ mapContainer: this.mapContainer,
2504
+ layersPanel: this.layersPanel,
2505
+ onToggleCamadas: () => this.toggleLayersPanel(),
2506
+ onCloseCamadas: () => this.closeLayersPanel(),
2507
+ onZoomExtents: () => this.zoomExtents(),
2508
+ onLimparSelecao: () => this.limparSelecao(),
2509
+ onTratarCliqueCanvas: (e) => this.tratarCliqueLivreCanvas(e),
2510
+ onDispararAcaoPopup: (e, o) => this.dispararAcaoPopup(e, o)
2511
+ }), this.broadcastConfig = new le({
2512
+ host: this,
2513
+ controller: this.controller,
2514
+ mapContainer: this.mapContainer,
2515
+ setLayerOpacity: (e, o) => this.setLayerOpacity(e, o)
2516
+ }), this.colecoesDados = new de({
2517
+ obterController: () => this.controller,
2518
+ obterChaveGrupo: () => this.chaveGrupo,
2519
+ setLayerVisibility: (e, o) => this.setLayerVisibility(e, o)
2520
+ });
2521
+ }
2522
+ static get observedAttributes() {
2523
+ return ["sat-opacity", "scale-mode", "crosshair", "modo-sequencial", "chave-grupo", "zona-projecao", "fuso", "canal-configuracao"];
2524
+ }
2525
+ connectedCallback() {
2526
+ const e = this.getAttribute("zona-projecao") || this.getAttribute("fuso");
2527
+ if (e) {
2528
+ const o = parseInt(e, 10);
2529
+ !isNaN(o) && o > 0 && (this._zonaProjecao = o, this.controller.zonaProjecao = o, this.controller.context.zonaProjecao = o);
2530
+ }
2531
+ this.controladorTamanho.observe(), this.broadcastConfig.conectar(), this.initTimeout = window.setTimeout(() => this.initCAD(), 0);
2532
+ }
2533
+ destroy() {
2534
+ if (this.initTimeout && (window.clearTimeout(this.initTimeout), this.initTimeout = void 0), this.controladorTamanho.disconnect(), this.broadcastConfig.desconectar(), this.limparDestaque(), this.toolbarPainel.limpar(), this.layerItemListeners.cleanup(), this.controller.destroy(), this.mapContainer && this.mapContainer._leaflet_id)
2535
+ try {
2536
+ delete this.mapContainer._leaflet_id;
2537
+ } catch {
2538
+ this.mapContainer._leaflet_id = void 0;
2539
+ }
2540
+ }
2541
+ disconnectedCallback() {
2542
+ this.destroy();
2543
+ }
2544
+ invalidateSizeSafely() {
2545
+ this.controladorTamanho.invalidateSizeSafely();
2546
+ }
2547
+ attributeChangedCallback(e, o, i) {
2548
+ fe(
2549
+ {
2550
+ host: this,
2551
+ controller: this.controller,
2552
+ mapContainer: this.mapContainer,
2553
+ broadcastConfig: this.broadcastConfig,
2554
+ setLayerOpacity: (s, a) => this.setLayerOpacity(s, a),
2555
+ setLayerScaleMode: (s, a) => this.setLayerScaleMode(s, a),
2556
+ atualizarZonaProjecao: (s) => {
2557
+ this._zonaProjecao = s;
2558
+ }
2559
+ },
2560
+ e,
2561
+ o,
2562
+ i
2563
+ );
2564
+ }
2565
+ initCAD() {
2566
+ ue({
2567
+ host: this,
2568
+ shadow: this.shadow,
2569
+ mapContainer: this.mapContainer,
2570
+ controller: this.controller,
2571
+ toolbarPainel: this.toolbarPainel,
2572
+ colecoesDados: this.colecoesDados,
2573
+ obterContextoEventos: () => this.obterContextoEventos(),
2574
+ renderLayersUI: () => this.renderLayersUI(),
2575
+ invalidateSizeSafely: () => this.invalidateSizeSafely(),
2576
+ tratarCliqueLivreCanvas: (e, o, i) => this.tratarCliqueLivreCanvas(e, o, i),
2577
+ dispararAcaoPopup: (e, o, i) => this.dispararAcaoPopup(e, o, i)
2578
+ });
2579
+ }
2580
+ obterContextoEventos() {
2581
+ return {
2582
+ host: this,
2583
+ controller: this.controller,
2584
+ mapContainer: this.mapContainer,
2585
+ modoSequencial: this.modoSequencial,
2586
+ mouseMovedSinceDown: this.toolbarPainel.houveMovimentoMouse,
2587
+ obterElementoPorId: (e) => this.colecoesDados.obterElementoPorId(e),
2588
+ fecharPopup: () => {
2589
+ var e;
2590
+ (e = this.controller.getMap()) == null || e.closePopup();
2591
+ }
2592
+ };
2593
+ }
2594
+ tratarCliqueLivreCanvas(e, o, i) {
2595
+ const s = Date.now();
2596
+ s - this.lastCanvasClickTime < 50 || (this.lastCanvasClickTime = s, ne(this.obterContextoEventos(), e, o, i));
2597
+ }
2598
+ dispararAcaoPopup(e, o, i) {
2599
+ const s = Date.now();
2600
+ this.lastPopupActionEmit && this.lastPopupActionEmit.acaoId === e && this.lastPopupActionEmit.elementoId === o && s - this.lastPopupActionEmit.time < 50 || (this.lastPopupActionEmit = { acaoId: e, elementoId: o, time: s }, se(this.obterContextoEventos(), e, o, i));
2601
+ }
2602
+ toggleLayersPanel() {
2603
+ this.toolbarPainel.toggleLayersPanel();
2604
+ }
2605
+ closeLayersPanel() {
2606
+ this.toolbarPainel.closeLayersPanel();
2607
+ }
2608
+ renderLayersUI() {
2609
+ const e = this.shadow.getElementById("layers-list-container");
2610
+ ie(e, this.controller.layerManager.getLayers(), this.layerItemListeners, {
2611
+ setLayerVisibility: (o, i) => this.setLayerVisibility(o, i),
2612
+ setLayerOpacity: (o, i) => this.setLayerOpacity(o, i),
2613
+ setLayerBlocked: (o, i) => this.controller.layerManager.setLayerBlocked(o, i),
2614
+ setLayerScaleMode: (o, i) => this.setLayerScaleMode(o, i)
2615
+ });
2616
+ }
2617
+ get pontos() {
2618
+ return this.colecoesDados.pontos;
2619
+ }
2620
+ set pontos(e) {
2621
+ this.colecoesDados.pontos = e;
2622
+ }
2623
+ get segmentos() {
2624
+ return this.colecoesDados.segmentos;
2625
+ }
2626
+ set segmentos(e) {
2627
+ this.colecoesDados.segmentos = e;
2628
+ }
2629
+ get bancoPontos() {
2630
+ return this.colecoesDados.bancoPontos;
2631
+ }
2632
+ set bancoPontos(e) {
2633
+ this.colecoesDados.bancoPontos = e;
2634
+ }
2635
+ get pontosHomologados() {
2636
+ return this.bancoPontos;
2637
+ }
2638
+ set pontosHomologados(e) {
2639
+ this.bancoPontos = e;
2640
+ }
2641
+ get confrontantes() {
2642
+ return this.colecoesDados.confrontantes;
2643
+ }
2644
+ set confrontantes(e) {
2645
+ this.colecoesDados.confrontantes = e;
2646
+ }
2647
+ get vizinhos() {
2648
+ return this.confrontantes;
2649
+ }
2650
+ set vizinhos(e) {
2651
+ this.confrontantes = e;
2652
+ }
2653
+ get modoSequencial() {
2654
+ return this.hasAttribute("modo-sequencial");
2655
+ }
2656
+ set modoSequencial(e) {
2657
+ var i;
2658
+ const o = !!e;
2659
+ o ? this.hasAttribute("modo-sequencial") || this.setAttribute("modo-sequencial", "") : this.hasAttribute("modo-sequencial") && this.removeAttribute("modo-sequencial"), this.controller.modoCliqueSequencialAtivo = o, this.controller.context.modoSequencial = o, o && ((i = this.controller.getMap()) == null || i.closePopup());
2660
+ }
2661
+ get chaveGrupo() {
2662
+ return this.getAttribute("chave-grupo") || this._chaveGrupo;
2663
+ }
2664
+ set chaveGrupo(e) {
2665
+ this._chaveGrupo = e, e ? this.getAttribute("chave-grupo") !== e && this.setAttribute("chave-grupo", e) : this.hasAttribute("chave-grupo") && this.removeAttribute("chave-grupo"), this.controller.chaveGrupo = e, this.controller.context.chaveGrupo = e, this.controller.layerManager.updateContext({ chaveGrupo: e });
2666
+ }
2667
+ get zonaProjecao() {
2668
+ return this._zonaProjecao ?? 22;
2669
+ }
2670
+ set zonaProjecao(e) {
2671
+ const o = typeof e == "number" ? Math.floor(e) : parseInt(String(e), 10);
2672
+ if (!isNaN(o) && o > 0) {
2673
+ this._zonaProjecao = o;
2674
+ const i = String(o);
2675
+ this.getAttribute("zona-projecao") !== i && this.setAttribute("zona-projecao", i), this.hasAttribute("fuso") && this.getAttribute("fuso") !== i && this.setAttribute("fuso", i), this.controller.zonaProjecao = o, this.controller.context.zonaProjecao = o;
2676
+ }
2677
+ }
2678
+ get canalConfiguracao() {
2679
+ return this.getAttribute("canal-configuracao");
2680
+ }
2681
+ set canalConfiguracao(e) {
2682
+ e ? this.setAttribute("canal-configuracao", e) : this.removeAttribute("canal-configuracao");
2683
+ }
2684
+ fitBounds(e, o = [40, 40], i = !1) {
2685
+ this.controller.fitBounds(e, o, i);
2686
+ }
2687
+ zoomExtents() {
2688
+ this.controller.canvasInteracao.zoomExtents();
2689
+ }
2690
+ selectPonto(e, o) {
2691
+ this.controller.selectPonto(e, o);
2692
+ }
2693
+ selecionarPonto(e, o) {
2694
+ this.controller.selectPonto(e, o);
2695
+ }
2696
+ get pontosSelecionados() {
2697
+ return this.controller.context.selectedPontoIds || this.controller.canvasInteracao.ctx.selectedPontoIds || [];
2698
+ }
2699
+ set pontosSelecionados(e) {
2700
+ const o = Array.isArray(e) ? e : [];
2701
+ this.controller.canvasInteracao.ctx.selectedPontoIds = o, this.controller.context.selectedPontoIds = [...o], this.controller.atualizarDestaqueMarcadores();
2702
+ }
2703
+ atualizarDestaqueMarcadores() {
2704
+ this.controller.atualizarDestaqueMarcadores();
2705
+ }
2706
+ limparSelecao() {
2707
+ this.controller.canvasInteracao.limparSelecao();
2708
+ }
2709
+ setLayerVisibility(e, o) {
2710
+ this.controller.layerManager.setLayerVisibility(e, o);
2711
+ }
2712
+ setLayerOpacity(e, o) {
2713
+ this.controller.layerManager.setLayerOpacity(e, o);
2714
+ }
2715
+ setLayerScaleMode(e, o) {
2716
+ this.controller.layerManager.setLayerScaleMode(e, o);
2717
+ }
2718
+ setGraphicScale(e) {
2719
+ this.controller.setGraphicScale(e);
2720
+ }
2721
+ exportState() {
2722
+ return this.controller.exportState();
2723
+ }
2724
+ importState(e) {
2725
+ this.controller.importState(e);
2726
+ }
2727
+ invalidateSize() {
2728
+ this.invalidateSizeSafely();
2729
+ }
2730
+ get destaqueAtivo() {
2731
+ return this.controller.destaqueAtivo;
2732
+ }
2733
+ destacarElemento(e, o) {
2734
+ !this.controller.getMap() && this.mapContainer && this.initCAD(), this.controller.destacarElemento(e, o);
2735
+ }
2736
+ limparDestaque() {
2737
+ this.controller.limparDestaque();
2738
+ }
2739
+ plotarPontos(e, o = "vertices", i) {
2740
+ this.colecoesDados.plotarPontos(e, o, i);
2741
+ }
2742
+ plotarConexoes(e, o = "linhas") {
2743
+ this.colecoesDados.plotarConexoes(e, o);
2744
+ }
2745
+ plotarPolilinhaSequencial(e, o = !0, i = "polilinha", s) {
2746
+ this.colecoesDados.plotarPolilinhaSequencial(e, o, i, s);
2747
+ }
2748
+ plotarPoligonos(e, o = "poligonos") {
2749
+ this.colecoesDados.plotarPoligonos(e, o);
2750
+ }
2751
+ limparCamadas(e) {
2752
+ this.colecoesDados.limparCamadas(e);
2753
+ }
2754
+ obterMarcadores(e) {
2755
+ return this.colecoesDados.obterMarcadores(e);
2756
+ }
2757
+ plotPontos(e, o) {
2758
+ this.colecoesDados.plotPontos(e, o);
2759
+ }
2760
+ plotSegmentos(e, o) {
2761
+ this.colecoesDados.plotSegmentos(e, o);
2762
+ }
2763
+ plotPolilinhaTemporaria(e) {
2764
+ this.colecoesDados.plotPolilinhaTemporaria(e);
2765
+ }
2766
+ plotPoligonalHomologada(e) {
2767
+ this.colecoesDados.plotPoligonalHomologada(e);
2768
+ }
2769
+ plotPontosVizinhos(e) {
2770
+ this.colecoesDados.plotPontosVizinhos(e);
2771
+ }
2772
+ plotPoligonosVizinhos(e) {
2773
+ this.colecoesDados.plotPoligonosVizinhos(e);
2774
+ }
2775
+ clearOverlays(e = !1) {
2776
+ this.colecoesDados.clearOverlays(e);
2777
+ }
2778
+ getMarkers() {
2779
+ return this.colecoesDados.getMarkers();
2780
+ }
2781
+ getVizinhosMarkers() {
2782
+ return this.colecoesDados.getVizinhosMarkers();
2783
+ }
2784
+ getMap() {
2785
+ return this.controller.getMap();
2786
+ }
2787
+ getController() {
2788
+ return this.controller;
2789
+ }
2790
+ getLayerManager() {
2791
+ return this.controller.layerManager;
2792
+ }
2793
+ }
2794
+ mt("ui-canvas-cad", ge);
2795
+ class we {
2796
+ constructor(t, e) {
2797
+ u(this, "polylines", []);
2798
+ u(this, "bancoPontosAtivo", !1);
2799
+ u(this, "core");
2800
+ this.core = t;
2801
+ }
2802
+ setBancoPontosAtivo(t) {
2803
+ this.bancoPontosAtivo = t;
2804
+ }
2805
+ plotSegmentos(t, e) {
2806
+ this.core.map && t.forEach((o) => {
2807
+ const i = e.find((a) => String(a.id) === String(o.ponto_inicio_id)), s = e.find((a) => String(a.id) === String(o.ponto_fim_id));
2808
+ if (i && s && i.lat && i.lon && s.lat && s.lon) {
2809
+ const a = o.tipo_limite_sigef || o.tipo_limite || "", c = o.metodo_posicionamento_sigef || o.metodo_posicionamento || "", r = this.bancoPontosAtivo ? "#94a3b8" : a === "LA1" ? "#10b981" : "#3b82f6", l = this.core.config.perimetroWeight, p = this.bancoPontosAtivo ? 0.4 : 1, d = v.polyline([[i.lat, i.lon], [s.lat, s.lon]], {
2810
+ color: r,
2811
+ weight: l,
2812
+ opacity: p,
2813
+ dashArray: a === "LN1" ? "6, 6" : void 0,
2814
+ pane: "perimetroPane"
2815
+ }).bindPopup(`
2816
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.3;">
2817
+ <div style="font-weight:700; font-size:12px; margin-bottom:3px; color:#ffffff;">${P(i.nome_vertice)} ↔ ${P(s.nome_vertice)}</div>
2818
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.65);">Limite: ${P(a)} · ${P(c)}</div>
2819
+ </div>
2820
+ `, {
2821
+ className: "compact-popup",
2822
+ maxWidth: 220
2823
+ }).addTo(this.core.map);
2824
+ this.polylines.push(d);
2825
+ }
2826
+ });
2827
+ }
2828
+ plotPolilinhaTemporaria(t) {
2829
+ var r, l, p;
2830
+ if (!this.core.map) return;
2831
+ const e = t.filter(
2832
+ (d) => d.lat && d.lon && d.lat !== 0 && d.lon !== 0 && d.tipo_ponto !== "B" && d.tipo !== "B" && d.ignorar_poligono !== 1
2833
+ );
2834
+ if (e.length < 2) return;
2835
+ const o = ((r = this.core.controller) == null ? void 0 : r.chaveGrupo) || ((p = (l = this.core.controller) == null ? void 0 : l.context) == null ? void 0 : p.chaveGrupo), i = K(e, o), s = this.bancoPontosAtivo ? "#94a3b8" : "#10b981", a = this.core.config.fechamentoWeight || 2, c = this.bancoPontosAtivo ? 0.4 : 1;
2836
+ Object.values(i).forEach((d) => {
2837
+ const f = J(d);
2838
+ if (f.length < 2) return;
2839
+ for (let b = 0; b < f.length - 1; b++) {
2840
+ const M = f[b], I = f[b + 1], z = v.polyline([[M.lat, M.lon], [I.lat, I.lon]], {
2841
+ color: s,
2842
+ weight: a,
2843
+ opacity: c,
2844
+ pane: "perimetroPane"
2845
+ }).addTo(this.core.map);
2846
+ this.polylines.push(z);
2847
+ }
2848
+ const h = f[f.length - 1], y = f[0], S = v.polyline([[h.lat, h.lon], [y.lat, y.lon]], {
2849
+ color: s,
2850
+ weight: a,
2851
+ opacity: c,
2852
+ dashArray: "4, 4",
2853
+ pane: "perimetroPane"
2854
+ }).addTo(this.core.map);
2855
+ this.polylines.push(S);
2856
+ });
2857
+ }
2858
+ plotPoligonalHomologada(t) {
2859
+ var s, a, c;
2860
+ if (!this.core.map || !this.core.bancoPontosGroup) return;
2861
+ this.core.bancoPontosGroup.clearLayers();
2862
+ const e = t.filter((r) => r.lat && r.lon && r.lat !== 0 && r.lon !== 0);
2863
+ if (e.length === 0) return;
2864
+ this.bancoPontosAtivo = !0, e.forEach((r) => {
2865
+ const l = `
2866
+ <div class="w-4.5 h-4.5 bg-amber-500 text-slate-950 border-2 border-slate-900 rounded-full flex items-center justify-center text-[7px] font-black font-mono shadow-md hover:scale-125 transition-transform" id="banco-marker-${r.id}">
2867
+ H
2868
+ </div>
2869
+ `, p = v.divIcon({
2870
+ html: l,
2871
+ className: "banco-leaflet-marker",
2872
+ iconSize: [18, 18]
2873
+ }), d = `
2874
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.35; min-width:180px;">
2875
+ <div style="font-weight:800; font-size:11px; color:#fbbf24; text-transform:uppercase; letter-spacing:0.5px; border-bottom:1px solid rgba(255, 255, 255, 0.1); padding-bottom:3px; margin-bottom:5px;">Vértice Homologado SIGEF</div>
2876
+ <div style="font-weight:700; font-size:13px; margin-bottom:3px; color:#ffffff;">${P(r.codigo_completo || r.nome_vertice)}</div>
2877
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.7); font-family:monospace;">Este (E): ${r.este ? r.este.toFixed(2) : "N/A"} m</div>
2878
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.7); font-family:monospace; margin-bottom:3px;">Norte (N): ${r.norte ? r.norte.toFixed(2) : "N/A"} m</div>
2879
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.7); margin-bottom:2px;">Alt (h): <strong>${r.altitude ? r.altitude.toFixed(2) : "N/A"} m</strong></div>
2880
+ <div style="font-size:10px; color:rgba(255, 255, 255, 0.45);">Método: ${P(r.metodo_posicionamento) || "N/A"} · Limite: ${P(r.tipo_limite) || "N/A"}</div>
2881
+ ${r.confrontante_descritivo ? `<div style="font-size:10px; color:rgba(255, 255, 255, 0.65); border-top:1px solid rgba(255, 255, 255, 0.1); padding-top:4px; margin-top:4px; word-break:break-word;"><strong>Conf:</strong> ${P(r.confrontante_descritivo)}</div>` : ""}
2882
+ </div>
2883
+ `;
2884
+ v.marker([r.lat, r.lon], {
2885
+ icon: p,
2886
+ pane: "verticesPane"
2887
+ }).bindPopup(d, { className: "compact-popup", maxWidth: 220 }).addTo(this.core.bancoPontosGroup);
2888
+ });
2889
+ const o = ((s = this.core.controller) == null ? void 0 : s.chaveGrupo) || ((c = (a = this.core.controller) == null ? void 0 : a.context) == null ? void 0 : c.chaveGrupo), i = K(e, o);
2890
+ for (const r in i) {
2891
+ const l = J(i[r]);
2892
+ if (l.length >= 2) {
2893
+ const p = l.map((d) => v.latLng(d.lat, d.lon));
2894
+ p.push(v.latLng(l[0].lat, l[0].lon)), v.polyline(p, {
2895
+ color: "#f59e0b",
2896
+ // Cor âmbar contrastante premium
2897
+ weight: this.core.config.bancoWeight,
2898
+ dashArray: "6, 8",
2899
+ pane: "perimetroPane"
2900
+ }).addTo(this.core.bancoPontosGroup);
2901
+ }
2902
+ }
2903
+ }
2904
+ clearLinhas() {
2905
+ this.core.map && this.polylines.forEach((t) => this.core.map.removeLayer(t)), this.core.bancoPontosGroup && this.core.bancoPontosGroup.clearLayers(), this.polylines = [];
2906
+ }
2907
+ }
2908
+ class Ce {
2909
+ constructor(t, e) {
2910
+ u(this, "markers", []);
2911
+ u(this, "vizinhosMarkers", []);
2912
+ u(this, "vizinhosPoligonos", []);
2913
+ u(this, "core");
2914
+ u(this, "controller");
2915
+ this.core = t, this.controller = e;
2916
+ }
2917
+ plotPontos(t, e) {
2918
+ this.core.map && t.forEach((o) => {
2919
+ var i, s, a;
2920
+ if (o.lat && o.lon && o.lat !== 0 && o.lon !== 0) {
2921
+ const c = o.tipo_ponto === "B" || o.tipo === "B", r = o.tipo_ponto === "M" || o.tipo === "M";
2922
+ let l = "bg-mint-vibrant", p = "x", d = 7;
2923
+ r ? (l = "bg-indigo-500", d = 9) : c && (l = "bg-rose-500", d = 9);
2924
+ const f = this.core.config.enableAnimations ? "transition-all duration-150" : "", h = (s = (i = this.controller) == null ? void 0 : i.linhas) != null && s.bancoPontosAtivo ? "opacity-40 hover:opacity-100" : "", y = Z(p, d, l, `${f} ${h}`, `map-marker-${o.id}`), S = v.divIcon({
2925
+ html: y,
2926
+ className: "custom-leaflet-marker flex items-center justify-center",
2927
+ iconSize: [d + 6, d + 6]
2928
+ }), b = r ? "Base Homologada PPP" : c ? "Base de Campo (Translação)" : "Vértice de Perímetro", M = v.marker([o.lat, o.lon], {
2929
+ icon: S,
2930
+ pane: "verticesPane"
2931
+ });
2932
+ M.pontoId = o.id, (a = this.controller) != null && a.modoCliqueSequencialAtivo || M.bindPopup(`
2933
+ <div style="font-family:sans-serif; color:rgba(255, 255, 255, 0.9); line-height:1.3;">
2934
+ <div style="font-weight:700; font-size:13px; margin-bottom:4px; color:#ffffff;">${P(o.nome_vertice)}</div>
2935
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.65);">${P(b)} · ${P(o.tipo_ponto || o.tipo)}</div>
2936
+ <div style="font-size:11px; color:rgba(255, 255, 255, 0.45); font-family:monospace; margin-top:4px;">Lat ${o.lat.toFixed(6)} &nbsp; Lon ${o.lon.toFixed(6)}</div>
2937
+ </div>
2938
+ `, {
2939
+ className: "compact-popup",
2940
+ maxWidth: 220
2941
+ }), M.addTo(this.core.map), M.setZIndexOffset(1e3), M.on("click", () => {
2942
+ e(o.id);
2943
+ }), this.markers.push(M);
2944
+ }
2945
+ });
2946
+ }
2947
+ plotPontosVizinhos(t) {
2948
+ if (!this.core.map || !this.core.pontosVizinhosGroup) return;
2949
+ this.core.map.hasLayer(this.core.pontosVizinhosGroup) || this.core.pontosVizinhosGroup.addTo(this.core.map), this.vizinhosMarkers && this.vizinhosMarkers.length > 0 && (this.vizinhosMarkers.forEach((o) => {
2950
+ o.off(), o.unbindPopup();
2951
+ }), this.vizinhosMarkers = []), this.core.pontosVizinhosGroup.clearLayers();
2952
+ const e = /* @__PURE__ */ new Map();
2953
+ (t || []).forEach((o) => {
2954
+ const i = o.lat ?? o.latitude ?? o.y, s = o.lon ?? o.lng ?? o.longitude ?? o.x, a = typeof i == "string" ? parseFloat(i.replace(",", ".")) : Number(i), c = typeof s == "string" ? parseFloat(s.replace(",", ".")) : Number(s);
2955
+ if (a !== void 0 && c !== void 0 && !isNaN(a) && !isNaN(c) && a !== 0 && c !== 0) {
2956
+ o.lat = a, o.lon = c;
2957
+ const r = o.confrontante_id !== void 0 && o.confrontante_id !== null ? String(o.confrontante_id) : "0";
2958
+ e.has(r) || e.set(r, []), e.get(r).push(o);
2959
+ }
2960
+ }), e.forEach((o) => {
2961
+ if (o.length >= 2) {
2962
+ o.sort((s, a) => Number(s.id) - Number(a.id));
2963
+ const i = o.map((s) => v.latLng(s.lat, s.lon));
2964
+ o.length > 2 && i.push(v.latLng(o[0].lat, o[0].lon)), v.polyline(i, {
2965
+ color: "#a855f7",
2966
+ weight: this.core.config.vizinhoWeight,
2967
+ dashArray: "4, 6",
2968
+ pane: "overlayPane"
2969
+ }).addTo(this.core.pontosVizinhosGroup);
2970
+ }
2971
+ o.forEach((i) => {
2972
+ var f, h;
2973
+ const s = document.createElement("div");
2974
+ s.className = "p-2 font-sans text-xs bg-[#0c1510] text-white min-w-[200px] rounded", s.innerHTML = `
2975
+ <div class="font-bold text-purple-400 mb-1 border-b border-white/10 pb-1">Confrontante (Importado)</div>
2976
+ <div class="mb-1"><strong>Vértice:</strong> <span class="font-mono">${P(i.nome_vertice || "")}</span></div>
2977
+ <div class="mb-1"><strong>Proprietário:</strong> ${P(i.nome_confrontante || "") || "Desconhecido"}</div>
2978
+ <div class="mb-1"><strong>Propriedade:</strong> ${P(i.nome_propriedade || "") || "Desconhecida"}</div>
2979
+ <div class="mb-1"><strong>Coordenadas:</strong> ${i.lat.toFixed(7)}, ${i.lon.toFixed(7)}</div>
2980
+ <div class="text-[10px] text-white/50 border-t border-white/5 pt-1 mt-1 font-mono uppercase tracking-wider mb-2">Pontos Imutáveis do Vizinho</div>
2981
+ <div style="display:flex; gap:6px; border-top:1px solid rgba(255,255,255,0.1); padding-top:6px;">
2982
+ <button class="btn-integrar" style="padding:3px 8px; font-size:10px; font-weight:700; border-radius:4px; background:#00f5a0; color:#04150c; border:none; cursor:pointer;" type="button">
2983
+ Integrar
2984
+ </button>
2985
+ <button class="btn-ocultar" style="padding:3px 8px; font-size:10px; font-weight:700; border-radius:4px; background:rgba(255,255,255,0.1); color:rgba(255,255,255,0.8); border:1px solid rgba(255,255,255,0.15); cursor:pointer;" type="button">
2986
+ Ocultar
2987
+ </button>
2988
+ </div>
2989
+ `, (f = s.querySelector(".btn-integrar")) == null || f.addEventListener("click", () => {
2990
+ window.dispatchEvent(new CustomEvent("gerencigeo:integrar_vizinho", { detail: { pontoId: i.id } }));
2991
+ }), (h = s.querySelector(".btn-ocultar")) == null || h.addEventListener("click", () => {
2992
+ window.dispatchEvent(new CustomEvent("gerencigeo:ocultar_vizinho", { detail: { pontoId: i.id } }));
2993
+ });
2994
+ let a = this.core.config.markerStyleV || "cross", c = this.core.config.markerSizeV || 8;
2995
+ i.tipo_ponto === "M" || i.tipo === "M" || i.tipo === "B" ? (a = this.core.config.markerStyleM || "circle-dot", c = this.core.config.markerSizeM || 14) : (i.tipo_ponto === "P" || i.tipo === "P" || i.tipo === "O") && (a = this.core.config.markerStyleP || "circle", c = this.core.config.markerSizeP || 10);
2996
+ const r = this.core.config.enableAnimations ? "transition-all duration-150" : "", l = Z(a, c, "bg-[#a855f7]", r, `map-marker-vizinho-${i.id}`), p = v.divIcon({
2997
+ html: l,
2998
+ className: "custom-leaflet-marker flex items-center justify-center",
2999
+ iconSize: [c + 4, c + 4]
3000
+ }), d = v.marker([i.lat, i.lon], {
3001
+ icon: p,
3002
+ pane: "overlayPane"
3003
+ }).bindPopup(s, { className: "custom-leaflet-popup" });
3004
+ d.pontoId = i.id, d.isVizinho = !0, d.addTo(this.core.pontosVizinhosGroup), this.vizinhosMarkers.push(d);
3005
+ });
3006
+ });
3007
+ }
3008
+ /**
3009
+ * Desenha o perímetro (limites) dos imóveis vizinhos importados via WKT POLYGON
3010
+ */
3011
+ plotPoligonosVizinhos(t) {
3012
+ !this.core.map || !this.core.pontosVizinhosGroup || (this.core.map.hasLayer(this.core.pontosVizinhosGroup) || this.core.pontosVizinhosGroup.addTo(this.core.map), this.vizinhosPoligonos.length > 0 && (this.vizinhosPoligonos.forEach((e) => e.off()), this.vizinhosPoligonos = []), (t || []).forEach((e) => {
3013
+ if (!e || !e.poligono_wkt) return;
3014
+ const o = /POLYGON\s*\(\s*\(\s*(.*?)\s*\)\s*\)/i.exec(e.poligono_wkt);
3015
+ if (!o) return;
3016
+ const i = o[1].split(",").map((r) => {
3017
+ const l = r.trim().split(/\s+/), p = parseFloat(l[0]), d = parseFloat(l[1]);
3018
+ return !isNaN(d) && !isNaN(p) ? [d, p] : null;
3019
+ }).filter((r) => r !== null);
3020
+ if (i.length < 3) return;
3021
+ const s = P(e.nome_propriedade || "Propriedade Vizinha"), a = P(e.nome || "Desconhecido"), c = v.polygon(i, {
3022
+ color: "#a855f7",
3023
+ weight: this.core.config.vizinhoWeight,
3024
+ dashArray: "4, 6",
3025
+ fillColor: "#a855f7",
3026
+ fillOpacity: 0.05,
3027
+ pane: "overlayPane"
3028
+ }).bindPopup(`
3029
+ <div class="p-2 font-sans text-xs bg-[#0c1510] text-white min-w-[200px] rounded">
3030
+ <div class="font-bold text-purple-400 mb-1 border-b border-white/10 pb-1">Limite do Vizinho (Importado)</div>
3031
+ <div class="mb-1"><strong>Propriedade:</strong> ${s}</div>
3032
+ <div class="mb-1"><strong>Proprietário:</strong> ${a}</div>
3033
+ </div>
3034
+ `, { className: "custom-leaflet-popup" });
3035
+ c.addTo(this.core.pontosVizinhosGroup), this.vizinhosPoligonos.push(c);
3036
+ }));
3037
+ }
3038
+ clearMarkers() {
3039
+ this.markers && (this.markers.forEach((t) => {
3040
+ t.off(), t.unbindPopup(), this.core.map && this.core.map.removeLayer(t);
3041
+ }), this.markers = []), this.vizinhosMarkers && (this.vizinhosMarkers.forEach((t) => {
3042
+ t.off(), t.unbindPopup();
3043
+ }), this.vizinhosMarkers = []), this.vizinhosPoligonos && (this.vizinhosPoligonos.forEach((t) => t.off()), this.vizinhosPoligonos = []), this.core.pontosVizinhosGroup && this.core.pontosVizinhosGroup.clearLayers();
3044
+ }
3045
+ }
3046
+ export {
3047
+ oe as CADMapaController,
3048
+ Pt as CAD_INTERACTIVE_PANES,
3049
+ oe as CanvasCADController,
3050
+ Ct as CanvasInteracao,
3051
+ jt as CanvasLayerManager,
3052
+ it as DEFAULT_CONFIG,
3053
+ _t as DEFAULT_LAYERS,
3054
+ oe as GerenciGeoMapaController,
3055
+ Et as GridLayerRenderer,
3056
+ j as LayerRendererFactory,
3057
+ Q as MapaConfigManager,
3058
+ xt as MapaCore,
3059
+ we as MapaLinhas,
3060
+ Ce as MapaMarcadores,
3061
+ St as TileLayerRenderer,
3062
+ ge as UICanvasCAD,
3063
+ kt as VectorLinesLayerRenderer,
3064
+ zt as VectorPointsLayerRenderer,
3065
+ It as VectorPolygonsLayerRenderer,
3066
+ Mt as WmsLayerRenderer,
3067
+ K as agruparPontosPorChave,
3068
+ Y as bindPopupAcoesEvents,
3069
+ re as criarControladorTamanho,
3070
+ P as escapeHtml,
3071
+ ot as extrairCentroDeWkt,
3072
+ Lt as extrairCorPonto,
3073
+ ke as formatUTM,
3074
+ Z as getPointShapeHtml,
3075
+ J as ordenarPontosPorSequencia,
3076
+ O as parseCoordenada,
3077
+ se as processarAcaoPopup,
3078
+ ne as processarCliqueLivreCanvas,
3079
+ W as renderPopupAcoesHtml,
3080
+ ie as renderizarPainelCamadas,
3081
+ ae as tratarCliqueMarcador
3082
+ };