@thibezer/ui-components-kit 2.24.1 → 2.25.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 (154) hide show
  1. package/CHANGELOG.md +83 -1
  2. package/dist/botao.cjs +12 -1
  3. package/dist/botao.js +162 -3
  4. package/dist/camadas.cjs +311 -1
  5. package/dist/camadas.js +3244 -148
  6. package/dist/campo-texto.cjs +16 -1
  7. package/dist/campo-texto.js +308 -7
  8. package/dist/canvas.cjs +22 -22
  9. package/dist/canvas.js +230 -233
  10. package/dist/card.cjs +20 -1
  11. package/dist/card.js +145 -2
  12. package/dist/components/ui-canvas-prancha/index.d.ts +1 -1
  13. package/dist/components/ui-canvas-prancha/prancha-teclado.d.ts +26 -0
  14. package/dist/components/ui-canvas-prancha/ui-canvas-prancha-base.d.ts +9 -0
  15. package/dist/components/ui-canvas-prancha/ui-canvas-prancha.d.ts +2 -2
  16. package/dist/components/ui-editor-prancha/editor-barra.d.ts +19 -0
  17. package/dist/components/ui-editor-prancha/editor-modos.d.ts +35 -0
  18. package/dist/components/ui-editor-prancha/editor-tipos.d.ts +4 -0
  19. package/dist/components/ui-editor-prancha/index.d.ts +1 -0
  20. package/dist/components/ui-editor-prancha/ui-editor-prancha.d.ts +63 -7
  21. package/dist/core/alvo-digitavel.d.ts +3 -0
  22. package/dist/core.cjs +1 -1
  23. package/dist/core.js +43 -54
  24. package/dist/{cores-utils-BrdynxRd.js → cores-utils-DMyqWvZh.js} +2 -2
  25. package/dist/cores.cjs +32 -1
  26. package/dist/cores.js +300 -13
  27. package/dist/custom-elements.json +11945 -11071
  28. package/dist/data.cjs +28 -1
  29. package/dist/data.js +286 -99
  30. package/dist/{feature_caixa-2Sxv3tGa.js → feature_caixa-BVc5LenS.js} +42 -42
  31. package/dist/{feature_desenho-BVHivWIB.js → feature_desenho-CC8Mp5Gp.js} +2 -2
  32. package/dist/feedback.cjs +52 -1
  33. package/dist/feedback.js +655 -25
  34. package/dist/forms.cjs +66 -1
  35. package/dist/forms.js +1216 -39
  36. package/dist/{geometria-px-DUs5FgLE.js → geometria-px-DHMPUsxC.js} +47 -47
  37. package/dist/index.cjs +67 -1
  38. package/dist/index.js +1476 -274
  39. package/dist/kit-base-BmkPi5Rz.cjs +2 -0
  40. package/dist/kit-base-CBXA66aM.js +1084 -0
  41. package/dist/mapa.cjs +5 -5
  42. package/dist/mapa.js +16 -17
  43. package/dist/modal.cjs +18 -1
  44. package/dist/modal.js +235 -29
  45. package/dist/motor.js +49 -49
  46. package/dist/prancha-nucleo.cjs +3 -1
  47. package/dist/prancha-nucleo.js +3120 -277
  48. package/dist/prancha.cjs +38 -1
  49. package/dist/prancha.js +3470 -228
  50. package/dist/register.cjs +1 -1
  51. package/dist/register.js +3 -20
  52. package/dist/seletor-mapa-base.cjs +13 -13
  53. package/dist/seletor-mapa-base.js +3 -5
  54. package/dist/tabela.cjs +142 -1
  55. package/dist/tabela.js +3773 -92
  56. package/dist/tipos-elementos.d.ts +7 -3
  57. package/dist/tipos-vue.d.ts +6 -3
  58. package/dist/tools.cjs +16 -1
  59. package/dist/tools.js +1564 -26
  60. package/dist/{ui-seletor-cor-Cd8jkzXG.js → ui-seletor-cor-CPjA9vhZ.js} +8 -9
  61. package/dist/ui-seletor-cor-D_ifitEN.cjs +83 -0
  62. package/dist/utils-ClVgqVyJ.cjs +1 -0
  63. package/dist/utils-DrHoxxmf.js +83 -0
  64. package/package.json +43 -2
  65. package/dist/acessibilidade-CSzX-DkG.cjs +0 -1
  66. package/dist/acessibilidade-CUlSXc2X.js +0 -38
  67. package/dist/altura-controle-ukMRPckR.cjs +0 -1
  68. package/dist/altura-controle-vxQiXG4q.js +0 -62
  69. package/dist/alvo-digitavel-CzCvNVQ3.js +0 -23
  70. package/dist/alvo-digitavel-DbH0hYFf.cjs +0 -1
  71. package/dist/degrade-CIxvOTUv.cjs +0 -1
  72. package/dist/degrade-gDa5sW__.js +0 -119
  73. package/dist/feature_caixa-CnYPKVFS.cjs +0 -1
  74. package/dist/feature_caixa-DCs9ZeSk.js +0 -1038
  75. package/dist/feature_historico-BAIYk1Me.cjs +0 -3
  76. package/dist/feature_historico-C4h9y5fu.js +0 -3039
  77. package/dist/form-atalhos-7JTYvumA.cjs +0 -1
  78. package/dist/form-atalhos-DDTlpgaB.js +0 -203
  79. package/dist/form-erros-CwPz7Jr4.cjs +0 -1
  80. package/dist/form-erros-DT5HklfD.js +0 -184
  81. package/dist/form-submissao-C-SPRKgT.js +0 -61
  82. package/dist/form-submissao-DxKO5MHI.cjs +0 -1
  83. package/dist/form-validacao-BlQFxUVj.js +0 -104
  84. package/dist/form-validacao-DIeyQVH5.cjs +0 -1
  85. package/dist/geometria-px-DKrWq_XY.js +0 -639
  86. package/dist/leaflet-CEPcxGWV.cjs +0 -1
  87. package/dist/leaflet-DOq10gfg.js +0 -84
  88. package/dist/leaflet-loader-94z5VsdY.cjs +0 -2
  89. package/dist/leaflet-loader-Cjcdgj5R.js +0 -21
  90. package/dist/listener-bag-D5omxZ9h.cjs +0 -1
  91. package/dist/listener-bag-DQgv7OON.js +0 -34
  92. package/dist/motor-By2te6PZ.js +0 -1400
  93. package/dist/motor-CkMxd378.cjs +0 -1
  94. package/dist/opcoes-CupvWVIm.js +0 -24
  95. package/dist/opcoes-vdAUY5OI.cjs +0 -1
  96. package/dist/parts-CaoQiCfI.js +0 -7
  97. package/dist/parts-vQa2873h.cjs +0 -1
  98. package/dist/prancha-paleta-BZ-9QDgh.js +0 -5276
  99. package/dist/prancha-paleta-Bb24vP71.cjs +0 -17
  100. package/dist/ssr-safe-5cWfJP-s.js +0 -10
  101. package/dist/ssr-safe-CiHD1adl.cjs +0 -1
  102. package/dist/svg-seguro-ChVJ2L2z.js +0 -74
  103. package/dist/svg-seguro-J2RM1Ssf.cjs +0 -1
  104. package/dist/ui-badge-DE58YSBY.cjs +0 -28
  105. package/dist/ui-badge-KgmI3jOD.js +0 -201
  106. package/dist/ui-botao-Dz8YvmiA.cjs +0 -12
  107. package/dist/ui-botao-zLkcMMyP.js +0 -168
  108. package/dist/ui-bus-CUd99VJi.js +0 -177
  109. package/dist/ui-bus-XqBLlTYQ.cjs +0 -1
  110. package/dist/ui-camadas-DoHPnbQm.js +0 -3133
  111. package/dist/ui-camadas-Vx7wYD4D.cjs +0 -311
  112. package/dist/ui-campo-texto-Dliyt9qr.cjs +0 -16
  113. package/dist/ui-campo-texto-btevggO3.js +0 -379
  114. package/dist/ui-card-7IEYbCN0.js +0 -150
  115. package/dist/ui-card-Bx8EyzYY.cjs +0 -20
  116. package/dist/ui-card-C-EJoKnm.js +0 -150
  117. package/dist/ui-card-DFnRp9bl.js +0 -146
  118. package/dist/ui-card-DrWVJQKw.cjs +0 -20
  119. package/dist/ui-card-DsIjHMmG.cjs +0 -20
  120. package/dist/ui-controle-cores-B1w_Yl69.cjs +0 -32
  121. package/dist/ui-controle-cores-BRjMvmMn.js +0 -291
  122. package/dist/ui-controle-cores-BcH9k2Fa.js +0 -292
  123. package/dist/ui-controle-cores-CvSTP6gJ.cjs +0 -32
  124. package/dist/ui-editor-prancha-CIngI6yI.js +0 -2886
  125. package/dist/ui-editor-prancha-DorSe6sC.cjs +0 -31
  126. package/dist/ui-linha-2kY7TNUJ.cjs +0 -38
  127. package/dist/ui-linha-B4mBRm1x.cjs +0 -61
  128. package/dist/ui-linha-DTEIIww4.js +0 -1167
  129. package/dist/ui-linha-KFF86FW5.js +0 -752
  130. package/dist/ui-modal-BrXzVZ65.js +0 -216
  131. package/dist/ui-modal-lARKzEVZ.cjs +0 -18
  132. package/dist/ui-paleta-ferramentas-Bu6JaT0s.js +0 -1245
  133. package/dist/ui-paleta-ferramentas-D3Jhwt26.cjs +0 -21
  134. package/dist/ui-paleta-ferramentas-DebHYiwd.js +0 -1615
  135. package/dist/ui-paleta-ferramentas-Dgejtluh.js +0 -1423
  136. package/dist/ui-paleta-ferramentas-hzyo8wBt.cjs +0 -22
  137. package/dist/ui-paleta-ferramentas-jWuICjW8.cjs +0 -22
  138. package/dist/ui-seletor-cor-0RLjcME6.cjs +0 -83
  139. package/dist/ui-seletor-cor-CMuuW-Ym.cjs +0 -83
  140. package/dist/ui-seletor-cor-DFIQ1sin.js +0 -405
  141. package/dist/ui-skeleton-BLEV6h3k.js +0 -653
  142. package/dist/ui-skeleton-B_XTaGrX.cjs +0 -52
  143. package/dist/ui-switch-BXIDwC-Y.cjs +0 -66
  144. package/dist/ui-switch-Ctxk-jKS.js +0 -1212
  145. package/dist/ui-tabela-CXxqbwXv.cjs +0 -7
  146. package/dist/ui-tabela-Cd0vOwnT.js +0 -1459
  147. package/dist/ui-tabela-propriedades-C5cIF5ES.js +0 -3779
  148. package/dist/ui-tabela-propriedades-CJyo568n.js +0 -3517
  149. package/dist/ui-tabela-propriedades-D96Djx-q.cjs +0 -136
  150. package/dist/ui-tabela-propriedades-Wa34hfIr.cjs +0 -142
  151. package/dist/ui-tabela-propriedades-ahQhQauu.js +0 -2329
  152. package/dist/ui-tabela-propriedades-w9JWhjHy.cjs +0 -142
  153. package/dist/zero-js-triggers-CJT988bR.js +0 -83
  154. package/dist/zero-js-triggers-CgM9IIQB.cjs +0 -1
package/dist/prancha.js CHANGED
@@ -1,231 +1,3473 @@
1
+ var Qe = Object.defineProperty;
2
+ var Ye = (t, e, a) => e in t ? Qe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
3
+ var m = (t, e, a) => Ye(t, typeof e != "symbol" ? e + "" : e, a);
1
4
  /* empty css */
2
- import "./ui-paleta-ferramentas-DebHYiwd.js";
3
- import "./ui-camadas-DoHPnbQm.js";
4
- import "./ui-tabela-propriedades-ahQhQauu.js";
5
- import { A as i, C as c, a as t, b as m, F as A, c as l, P, U as E, d, e as b, f as D, g as p, h as C, i as O, j as S, k as _, l as h, m as R, n as N, o as M, p as I, r as T } from "./ui-editor-prancha-CIngI6yI.js";
6
- import { E as g } from "./feature_caixa-2Sxv3tGa.js";
7
- import { A as x, C as v, D as f, E as F, a as H, b as z, c as U, d as G, e as j, F as B, f as X, g as V, h as Q, H as k, I as K, i as q, j as w, k as y, K as J, L as W, M as Y, l as Z, m as $, n as aa, o as sa, O as oa, P as ra, p as ea, R as na, S as ia, T as ca, q as ta, r as ma, s as Aa, t as la, u as Pa, v as Ea, w as da, x as ba, y as Da, z as pa, B as Ca, G as Oa, J as Sa, N as _a, Q as ha, U as Ra, V as Na, W as Ma, X as Ia, Y as Ta, Z as ua, _ as ga, $ as La, a0 as xa, a1 as va, a2 as fa, a3 as Fa, a4 as Ha, a5 as za, a6 as Ua, a7 as Ga, a8 as ja, a9 as Ba, aa as Xa, ab as Va, ac as Qa, ad as ka, ae as Ka, af as qa, ag as wa, ah as ya, ai as Ja, aj as Wa, ak as Ya, al as Za, am as $a, an as as, ao as ss, ap as os, aq as rs, ar as es, as as ns, at as is, au as cs, av as ts, aw as ms, ax as As, ay as ls, az as Ps, aA as Es, aB as ds, aC as bs, aD as Ds, aE as ps, aF as Cs, aG as Os, aH as Ss, aI as _s, aJ as hs, aK as Rs, aL as Ns, aM as Ms, aN as Is, aO as Ts, aP as us, aQ as gs, aR as Ls, aS as xs, aT as vs, aU as fs, aV as Fs, aW as Hs, aX as zs, aY as Us, aZ as Gs, a_ as js, a$ as Bs, b0 as Xs, b1 as Vs, b2 as Qs, b3 as ks, b4 as Ks, b5 as qs, b6 as ws, b7 as ys, b8 as Js, b9 as Ws, ba as Ys, bb as Zs, bc as $s, bd as ao, be as so, bf as oo, bg as ro, bh as eo, bi as no, bj as io, bk as co, bl as to, bm as mo, bn as Ao, bo as lo, bp as Po, bq as Eo, br as bo, bs as Do, bt as po, bu as Co, bv as Oo, bw as So, bx as _o, by as ho, bz as Ro, bA as No, bB as Mo, bC as Io, bD as To, bE as uo, bF as go, bG as Lo, bH as xo, bI as vo, bJ as fo, bK as Fo, bL as Ho, bM as zo, bN as Uo, bO as Go, bP as jo, bQ as Bo, bR as Xo, bS as Vo, bT as Qo, bU as ko, bV as Ko, bW as qo, bX as wo, bY as yo, bZ as Jo, b_ as Wo, b$ as Yo, c0 as Zo, c1 as $o, c2 as ar, c3 as sr, c4 as or, c5 as rr, c6 as er, c7 as nr, c8 as ir, c9 as cr } from "./feature_historico-C4h9y5fu.js";
8
- import { ESTILO_DO_TIPO_LINHA as mr, ajustarAparenciaEmLote as Ar, ajustarElementosACaixa as lr, mapearPontoNaCaixa as Pr, normalizarParaOrigem as Er, resumirAparencia as dr } from "./prancha-nucleo.js";
5
+ import { IndicePrancha as at, Historico as et, normalizarElementos as tt, analisarElemento as rt, compor as Fa, translacao as k, escala as H, mapaDeCamadas as it, normalizarCamadas as ot, expandirGrupos as st, buscarSnapPrancha as se, ESPESSURA_TRACO_PADRAO_MM as nt, COR_PADRAO_PRANCHA as lt, rotacao as za, espelharElementos as ct, ehMatrizFinita as ne, transformarElementos as I, definirRaiosDoRetangulo as ut, normalizarElemento as dt, moverAncoras as le, excluirAncora as ce, centroDaSelecao as ht, criarRetangulo as mt, criarElipse as ft, criarPoligonoRegular as pt, criarEstrela as gt, transformarElemento as ue, criarLinha as vt, ESPACO_PLANO as bt, criarCaminho as _a, paraMm as yt, criarTexto as At, caixaDeCantos as St, reordenar as Pt, agrupar as Mt, desagrupar as zt, alinhar as xt, distribuir as Et, ordenarPorEmpilhamento as U, aplicarAparencia as de, criarMascara as Ct, liberarMascara as Tt, unirCaminhos as wt, dividirComLinha as Dt, deslocarCaminho as It, duplicarElementos as he, simplificarCaminho as Ft, contornoDoTraco as _t, converterEmCaminho as Nt, desenharElementos as $, caixaOrientada as Ot, ancorasDoElemento as xa, alcasDoElemento as me, caixaDaSelecao as Ea, posicoesDasAlcas as fe, contornoNaFolha as Ca, aplicar as Rt, posicaoLocalDaAlca as Lt, ALCAS_ESCALA as kt, raiosEfetivos as pe, profundidadeNoCanto as ge, limitesNaFolha as Y, comRaioDeCanto as qt, moverAlcaDaAncora as Bt, moverAncora as jt, rotacaoPorArrasto as Gt, matrizDeCisalhamentoPorAlca as Ht, matrizDeEscalaPorAlca as $t, guiasInteligentes as Vt, marcasDosCantos as Kt, envelopeNaFolha as Wt, elementoNoTopo as na, trechoMaisProximo as Ut, adicionarAncora as Xt, ancoraMaisProxima as Zt, converterAncora as Jt, elementosNaCaixa as Qt, deMm as Yt, caixaDoQuadro as ve, OPERACOES_BOOLEANAS as ar, aplicarPathfinder as er, ehUnidadePrancha as tr, temMedidorTexto as rr, definirMedidorTexto as ir, saneada as or, ehPredefinicao as sr, gerarPredefinicao as nr, envelopeVisual as Na, exportarSvg as lr, ehPropriedadePrancha as cr, ehPropriedadeDeGeometria as ur, comPropriedade as dr, rotacaoEmGraus as hr, MODOS_MESCLAGEM as mr, valorDaPropriedade as fr, resolverAparencia as pr, ITENS_PREDEFINICOES as Oa } from "./prancha-nucleo.js";
6
+ import { DIMENSOES_FOLHA as So, EPSILON_DETERMINANTE as Po, ESCALA_MINIMA as Mo, ESPESSURA_PADRAO_MM as zo, ESTILOS_TRACO as xo, ESTILO_DO_TIPO_LINHA as Eo, FAIXAS_MAXIMO as Co, FAIXAS_PADRAO as To, FONTE_PADRAO as wo, FORMATOS_ABNT as Do, IDENTIDADE as Io, IDS_PROPRIEDADES_PRANCHA as Fo, KAPPA as _o, LIMITE_PONTA_PADRAO as No, MAX_LINHAS_HACHURA as Oo, MESCLAGEM_CSS as Ro, MM_POR_PX as Lo, MM_POR_UNIDADE as ko, PREDEFINICOES as qo, PRIORIDADE_SNAP_PRANCHA as Bo, ROTULOS_PREDEFINICOES as jo, SOMBRA_PADRAO as Go, TIPO_LINHA_DO_ESTILO as Ho, adaptarContextoRelativo as $o, ajustarAparenciaEmLote as Vo, ajustarElementosACaixa as Ko, aparenciaDe as Wo, aplicarTodos as Uo, aplicarVetor as Xo, areaComSinal as Zo, areaDosPoligonos as Jo, avisarUmaVez as Qo, caixaDoQuadroAbnt as Yo, caixaDoTexto as as, caixaNormalizada as es, caminhoDoContorno as ts, caminhoFinito as rs, caminhoParaSvg as is, cisalhamento as os, comoCaminhoNaFolha as ss, comprimentoDaPonta as ns, contornoElipse as ls, contornoEstrela as cs, contornoLocal as us, contornoLocalEmCache as ds, contornoPoligonoRegular as hs, contornoRetangulo as ms, corComOpacidade as fs, corNaPosicao as ps, decompor as gs, desenharPlano as vs, determinante as bs, diagnosticarContexto as ys, direcaoNaPonta as As, ehFechado as Ss, ehIdentidade as Ps, ehSingular as Ms, elementosNoLaco as zs, elementosNoPonto as xs, emTornoDe as Es, espelhamento as Cs, faixasDoGradienteLinear as Ts, feicaoDoElemento as ws, fonteSegura as Ds, geometriaDaPonta as Is, girarElementos as Fs, iguais as _s, inverter as Ns, limitesLocais as Os, linhasDeHachura as Rs, mapearPontoNaCaixa as Ls, margensAbnt as ks, matriz as qs, matrizDoElemento as Bs, meiaEspessura as js, modoDeTransformacao as Gs, moverElemento as Hs, multiplicar as $s, normalizarAparencia as Vs, normalizarGeometriaElemento as Ks, normalizarGradiente as Ws, normalizarHachura as Us, normalizarParaOrigem as Xs, operacaoBooleana as Zs, padraoTipoLinhaMm as Js, pivoNaFolha as Qs, planejar as Ys, planejarElemento as an, planejarElementos as en, planoDe as tn, pontoNoAnel as rn, raiosCabiveis as on, recompor as sn, redefinirAvisoContexto as nn, regiaoDoElemento as ln, resolverSombra as cn, resumirAparencia as un, temPreenchimento as dn, testarElemento as hn, transformarContorno as mn, varreduraDoArco as fn } from "./prancha-nucleo.js";
7
+ import { n as gr, T as vr } from "./geometria-px-DHMPUsxC.js";
8
+ import { K as be, M as Ra, N as br, O as yr, U as ye, S as Ae, L as Ta, d as Se } from "./kit-base-CBXA66aM.js";
9
+ import { E as gn } from "./feature_caixa-BVc5LenS.js";
10
+ import { S as Ar } from "./feature_desenho-CC8Mp5Gp.js";
11
+ const Sr = ":host{--ui-prancha-mesa: var(--ui-cor-fundo);--ui-prancha-papel: var(--ui-cor-papel);--ui-prancha-borda-papel: var(--ui-cor-borda);--ui-prancha-grade: var(--ui-cor-grade-papel);--ui-prancha-selecao: var(--ui-cor-primaria);--ui-prancha-alca: var(--ui-cor-superficie);--ui-prancha-guia: var(--ui-cor-guia);--ui-prancha-guia-inteligente: var(--ui-cor-guia-inteligente);--ui-prancha-snap: var(--ui-cor-destaque);--ui-prancha-regua: var(--ui-cor-fundo-elevado);--ui-prancha-texto-regua: var(--ui-cor-texto-secundario);--ui-prancha-tamanho-regua: 20px;display:block;position:relative;min-height:240px;min-width:240px;height:100%;background:var(--ui-cor-fundo);color:var(--ui-cor-texto);font-family:var(--ui-fonte-base);outline:none;contain:layout paint}:host([hidden]){display:none}.raiz{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;grid-template-columns:var(--ui-prancha-tamanho-regua) 1fr;grid-template-rows:var(--ui-prancha-tamanho-regua) 1fr}:host([sem-reguas]) .raiz{grid-template-columns:0 1fr;grid-template-rows:0 1fr}:host([sem-reguas]) .regua,:host([sem-reguas]) .canto{display:none}.canto{background:var(--ui-prancha-regua);border-right:1px solid var(--ui-cor-borda);border-bottom:1px solid var(--ui-cor-borda)}.regua{display:block;width:100%;height:100%;background:var(--ui-prancha-regua);cursor:default;touch-action:none}.regua-h{border-bottom:1px solid var(--ui-cor-borda);cursor:s-resize}.regua-v{border-right:1px solid var(--ui-cor-borda);cursor:e-resize}.viewport{position:relative;overflow:hidden;background:var(--ui-prancha-mesa);touch-action:none;cursor:default}.viewport:focus-visible{outline:2px solid var(--ui-cor-primaria);outline-offset:-2px}.viewport[data-cursor=mao]{cursor:grab}.viewport[data-cursor=arrastando]{cursor:grabbing}.viewport[data-cursor=mira]{cursor:crosshair}.viewport[data-cursor=mover]{cursor:move}.viewport[data-cursor=girar]{cursor:alias}.viewport[data-cursor=ancora]{cursor:pointer}.camada{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;display:block;pointer-events:none}.status{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}@media (pointer: coarse){:host{--ui-prancha-tamanho-regua: 24px}}";
12
+ function Pr() {
13
+ return `
14
+ <style>${Sr}</style>
15
+ <div class="raiz" part="base">
16
+ <div class="canto" part="canto-reguas" aria-hidden="true"></div>
17
+ <canvas class="regua regua-h" id="regua-h" part="regua regua-horizontal" aria-hidden="true"></canvas>
18
+ <canvas class="regua regua-v" id="regua-v" part="regua regua-vertical" aria-hidden="true"></canvas>
19
+ <div class="viewport" id="viewport" part="viewport" tabindex="0" role="application"
20
+ aria-roledescription="prancha de desenho" aria-label="Prancha" aria-describedby="ajuda">
21
+ <canvas class="camada" id="camada-base" part="canvas"></canvas>
22
+ <canvas class="camada" id="camada-sobreposicao" part="sobreposicao"></canvas>
23
+ </div>
24
+ <div class="status" id="ajuda">Atalhos: V seleção, A seleção direta, H mão, M retângulo, L elipse, P caneta, barra invertida linha, T texto. Setas movem, Shift multiplica por 10. Delete exclui. Ctrl+Z desfaz. Ctrl+0 ajusta a folha.</div>
25
+ <div class="status" id="status" part="status" role="status" aria-live="polite"></div>
26
+ </div>
27
+ `;
28
+ }
29
+ function La(t, e) {
30
+ const a = new Map(t.map((o) => [o.id, o])), r = new Map(e.map((o) => [o.id, o])), i = { adicionados: [], atualizados: [], removidos: [] };
31
+ for (const [o, s] of r) {
32
+ const n = a.get(o);
33
+ n ? n !== s && i.atualizados.push(s) : i.adicionados.push(s);
34
+ }
35
+ for (const [o, s] of a) r.has(o) || i.removidos.push(s);
36
+ return i;
37
+ }
38
+ const Aa = (t) => t.adicionados.length + t.atualizados.length + t.removidos.length === 0;
39
+ class Mr {
40
+ constructor() {
41
+ m(this, "lista", []);
42
+ m(this, "porId", /* @__PURE__ */ new Map());
43
+ m(this, "posicoes", /* @__PURE__ */ new Map());
44
+ m(this, "_selecao", []);
45
+ m(this, "indice", new at());
46
+ m(this, "historico", new et({ limite: 100, janelaRajadaMs: 1e3 }));
47
+ /** Contador de mudanças do documento (carga, edição, desfazer/refazer, renomear): base do `modificado` do componente. */
48
+ m(this, "revisao", 0);
49
+ m(this, "ouvinteMudanca", null);
50
+ }
51
+ /** Registra quem é avisado depois de cada mudança do documento (o componente avalia o `modificado`). */
52
+ ouvirMudancas(e) {
53
+ this.ouvinteMudanca = e;
54
+ }
55
+ mudou() {
56
+ var e;
57
+ this.revisao++;
58
+ try {
59
+ (e = this.ouvinteMudanca) == null || e.call(this);
60
+ } catch {
61
+ }
62
+ }
63
+ get elementos() {
64
+ return this.lista;
65
+ }
66
+ obter(e) {
67
+ return this.porId.get(e);
68
+ }
69
+ get selecao() {
70
+ return this._selecao;
71
+ }
72
+ elementosSelecionados() {
73
+ return this._selecao.map((e) => this.porId.get(e)).filter((e) => !!e);
74
+ }
75
+ /** Troca tudo (carga de documento): normaliza, recomeça o histórico e limpa a seleção. */
76
+ definir(e) {
77
+ const a = tt(e);
78
+ return this.aplicar(a.elementos), this.indice.definir(a.elementos), this.historico.limpar(), this._selecao = [], this.mudou(), a;
79
+ }
80
+ aplicar(e) {
81
+ this.lista = e, this.porId = new Map(e.map((a) => [a.id, a])), this.posicoes = new Map(e.map((a, r) => [a.id, r]));
82
+ }
83
+ /** Os elementos na ordem da lista do documento (o índice espacial devolve em outra ordem). */
84
+ naOrdemDoDocumento(e) {
85
+ return [...e].sort((a, r) => (this.posicoes.get(a.id) ?? 0) - (this.posicoes.get(r.id) ?? 0));
86
+ }
87
+ /** Mudança central: grava o passo no histórico, atualiza índice e seleção e devolve a diferença. */
88
+ substituir(e, a = {}) {
89
+ const r = this.lista, i = La(r, e);
90
+ return Aa(i) && r.length === e.length && r.every((o, s) => o === e[s]) || (a.registrar !== !1 && this.historico.registrar(r, { chave: a.chave, agora: a.agora }), this.aplicar(e), this.sincronizarIndice(i), this._selecao = this._selecao.filter((o) => this.porId.has(o)), this.mudou()), i;
91
+ }
92
+ sincronizarIndice(e) {
93
+ for (const r of e.removidos) this.indice.remover(r.id);
94
+ const a = [...e.adicionados, ...e.atualizados];
95
+ a.length > 0 && this.indice.atualizarVarios(a);
96
+ }
97
+ /** Aplica o lote do app (normalizado; ids repetidos e inválidos recusados). */
98
+ aplicarLote(e, a = !0) {
99
+ const r = { adicionados: [], atualizados: [], removidos: [], recusados: [] }, i = new Map(this.lista.map((d) => [d.id, d])), o = this.lista.map((d) => d.id), s = new Set((Array.isArray(e == null ? void 0 : e.remover) ? e.remover : []).filter((d) => typeof d == "string"));
100
+ for (const d of s)
101
+ i.delete(d) && r.removidos.push(d);
102
+ const n = (d, h) => {
103
+ Array.isArray(d) && d.forEach((u, f) => {
104
+ const p = rt(u);
105
+ if (typeof p == "string") {
106
+ r.recusados.push({ indice: f, motivo: p });
107
+ return;
108
+ }
109
+ const v = i.has(p.id);
110
+ if (h === "adicionar" && v) {
111
+ r.recusados.push({ indice: f, id: p.id, motivo: "id-duplicado" });
112
+ return;
113
+ }
114
+ if (h === "atualizar" && !v) {
115
+ r.recusados.push({ indice: f, id: p.id, motivo: "id-invalido" });
116
+ return;
117
+ }
118
+ h === "adicionar" && o.push(p.id), i.set(p.id, p), (h === "adicionar" ? r.adicionados : r.atualizados).push(p.id);
119
+ });
120
+ };
121
+ n(e == null ? void 0 : e.adicionar, "adicionar"), n(e == null ? void 0 : e.atualizar, "atualizar");
122
+ const l = /* @__PURE__ */ new Set(), c = [];
123
+ for (const d of o) {
124
+ const h = i.get(d);
125
+ h && !l.has(d) && (l.add(d), c.push(h));
126
+ }
127
+ return { resultado: r, diferenca: this.substituir(c, { registrar: a }) };
128
+ }
129
+ desfazer() {
130
+ const e = this.historico.desfazer(this.lista);
131
+ return e ? this.restaurar(e) : null;
132
+ }
133
+ refazer() {
134
+ const e = this.historico.refazer(this.lista);
135
+ return e ? this.restaurar(e) : null;
136
+ }
137
+ restaurar(e) {
138
+ const a = La(this.lista, e);
139
+ return this.aplicar(e), this.sincronizarIndice(a), this._selecao = this._selecao.filter((r) => this.porId.has(r)), this.mudou(), a;
140
+ }
141
+ /** Troca o id de um elemento em tudo (lista, índice, seleção e histórico). `false` se não existe ou o novo já existe. */
142
+ renomear(e, a) {
143
+ if (typeof a != "string" || !a.trim() || !this.porId.has(e) || this.porId.has(a)) return !1;
144
+ const r = (o) => o.map((s) => s.id === e ? { ...s, id: a } : s), i = r(this.lista);
145
+ return this.indice.remover(e), this.aplicar(i), this.indice.atualizar(this.porId.get(a)), this.historico.transformar(r), this._selecao = this._selecao.map((o) => o === e ? a : o), this.mudou(), !0;
146
+ }
147
+ /** Muda a seleção; devolve se mudou. Só ids existentes, não bloqueados nem ocultos, sem repetição, na ordem dada. */
148
+ selecionar(e, a = "substituir") {
149
+ const r = e.filter((n, l) => {
150
+ const c = this.porId.get(n);
151
+ return !!c && !c.bloqueado && !c.oculto && e.indexOf(n) === l;
152
+ }), i = this._selecao;
153
+ let o;
154
+ a === "substituir" ? o = r : a === "adicionar" ? o = [...i, ...r.filter((n) => !i.includes(n))] : a === "remover" ? o = i.filter((n) => !r.includes(n)) : o = [...i.filter((n) => !r.includes(n)), ...r.filter((n) => !i.includes(n))];
155
+ const s = o.length !== i.length || o.some((n, l) => n !== i[l]);
156
+ return s && (this._selecao = o), s;
157
+ }
158
+ }
159
+ const W = 96 / 25.4, pa = W * 0.02, ga = W * 64, E = (t) => typeof t == "number" && Number.isFinite(t);
160
+ class zr {
161
+ constructor() {
162
+ m(this, "zoom", W);
163
+ m(this, "pan", [0, 0]);
164
+ m(this, "largura", 0);
165
+ m(this, "altura", 0);
166
+ m(this, "dpr", 1);
167
+ }
168
+ get zoomPercentual() {
169
+ return this.zoom / W * 100;
170
+ }
171
+ /** Folha (mm) → px CSS da área de desenho. */
172
+ matrizTela() {
173
+ return Fa(H(this.zoom), k(this.pan[0], this.pan[1]));
174
+ }
175
+ /** Folha (mm) → px do dispositivo (com o dpr): a matriz do pintor. */
176
+ matrizDispositivo() {
177
+ return Fa(H(this.zoom), k(this.pan[0], this.pan[1]), H(this.dpr));
178
+ }
179
+ paraFolha(e, a) {
180
+ return [(e - this.pan[0]) / this.zoom, (a - this.pan[1]) / this.zoom];
181
+ }
182
+ paraTela(e) {
183
+ return [e[0] * this.zoom + this.pan[0], e[1] * this.zoom + this.pan[1]];
184
+ }
185
+ /** Muda o tamanho da área de desenho (px CSS) e o dpr; valores inválidos são ignorados. */
186
+ redimensionar(e, a, r = 1) {
187
+ E(e) && e >= 0 && (this.largura = e), E(a) && a >= 0 && (this.altura = a), E(r) && r > 0 && (this.dpr = Math.min(r, 4));
188
+ }
189
+ /** Zoom absoluto mantendo parado o ponto de tela `foco` (padrão: o centro). Devolve se mudou. */
190
+ definirZoom(e, a) {
191
+ if (!E(e) || e <= 0) return !1;
192
+ const r = Math.min(ga, Math.max(pa, e));
193
+ if (r === this.zoom) return !1;
194
+ const i = a && E(a[0]) && E(a[1]) ? a : [this.largura / 2, this.altura / 2], o = this.paraFolha(i[0], i[1]);
195
+ return this.zoom = r, this.pan = [i[0] - o[0] * r, i[1] - o[1] * r], !0;
196
+ }
197
+ zoomRelativo(e, a) {
198
+ return E(e) && e > 0 ? this.definirZoom(this.zoom * e, a) : !1;
199
+ }
200
+ deslocar(e, a) {
201
+ return !E(e) || !E(a) || e === 0 && a === 0 ? !1 : (this.pan = [this.pan[0] + e, this.pan[1] + a], !0);
202
+ }
203
+ /** Zoom absoluto mantendo o CENTRO da caixa (mm) no centro da área de desenho (usado no teto de zoom do enquadramento). */
204
+ definirZoomCentrado(e, a) {
205
+ return !E(e) || e <= 0 || !a || ![a.x, a.y, a.largura, a.altura].every(E) ? !1 : (this.zoom = Math.min(ga, Math.max(pa, e)), this.pan = [this.largura / 2 - (a.x + a.largura / 2) * this.zoom, this.altura / 2 - (a.y + a.altura / 2) * this.zoom], !0);
206
+ }
207
+ /** Enquadra a caixa (mm) com `margem` px em volta. Sem tamanho de área de desenho, não faz nada. */
208
+ enquadrar(e, a = 24) {
209
+ if (!e || ![e.x, e.y, e.largura, e.altura].every(E) || this.largura <= 0 || this.altura <= 0) return !1;
210
+ const r = Math.max(e.largura, 1e-6), i = Math.max(e.altura, 1e-6), o = Math.max(1, this.largura - 2 * a), s = Math.max(1, this.altura - 2 * a);
211
+ return this.zoom = Math.min(ga, Math.max(pa, Math.min(o / r, s / i))), this.pan = [this.largura / 2 - (e.x + r / 2) * this.zoom, this.altura / 2 - (e.y + i / 2) * this.zoom], !0;
212
+ }
213
+ }
214
+ function xr() {
215
+ return {
216
+ hoverId: null,
217
+ caixaSelecao: null,
218
+ substitutos: /* @__PURE__ */ new Map(),
219
+ previa: null,
220
+ pontosPrevia: [],
221
+ snap: null,
222
+ linhasInteligentes: [],
223
+ guiaArrastada: null,
224
+ pivo: null,
225
+ edicao: null,
226
+ rotulo: null,
227
+ ponteiro: null,
228
+ copiasEmGesto: []
229
+ };
230
+ }
231
+ function V(t) {
232
+ t.caixaSelecao = null, t.substitutos = /* @__PURE__ */ new Map(), t.previa = null, t.pontosPrevia = [], t.snap = null, t.linhasInteligentes = [], t.guiaArrastada = null, t.rotulo = null, t.copiasEmGesto = [];
233
+ }
234
+ const ka = Object.freeze({
235
+ mesa: "--ui-prancha-mesa",
236
+ papel: "--ui-prancha-papel",
237
+ bordaPapel: "--ui-prancha-borda-papel",
238
+ grade: "--ui-prancha-grade",
239
+ selecao: "--ui-prancha-selecao",
240
+ alca: "--ui-prancha-alca",
241
+ guia: "--ui-prancha-guia",
242
+ guiaInteligente: "--ui-prancha-guia-inteligente",
243
+ snap: "--ui-prancha-snap",
244
+ regua: "--ui-prancha-regua",
245
+ textoRegua: "--ui-prancha-texto-regua"
246
+ }), Sa = Object.freeze({
247
+ mesa: "#0b0b0d",
248
+ papel: "#ffffff",
249
+ bordaPapel: "rgba(255, 255, 255, 0.08)",
250
+ grade: "rgba(59, 155, 255, 0.22)",
251
+ selecao: "#00E08A",
252
+ alca: "#141417",
253
+ guia: "#3b9bff",
254
+ guiaInteligente: "#ff4fd8",
255
+ snap: "#00E08A",
256
+ regua: "#1a1a1e",
257
+ textoRegua: "#9696a6"
258
+ });
259
+ function Er(t) {
260
+ var r;
261
+ const e = { ...Sa };
262
+ if (!t || typeof getComputedStyle != "function") return e;
263
+ let a = null;
264
+ try {
265
+ a = getComputedStyle(t);
266
+ } catch {
267
+ return e;
268
+ }
269
+ for (const i of Object.keys(ka)) {
270
+ const o = (r = a.getPropertyValue(ka[i])) == null ? void 0 : r.trim();
271
+ o && (e[i] = gr(o, Sa[i]));
272
+ }
273
+ return e;
274
+ }
275
+ const Cr = {
276
+ selecao: "Seleção",
277
+ "selecao-direta": "Seleção direta",
278
+ mao: "Mão",
279
+ retangulo: "Retângulo",
280
+ elipse: "Elipse",
281
+ "poligono-regular": "Polígono regular",
282
+ estrela: "Estrela",
283
+ linha: "Linha",
284
+ seta: "Seta",
285
+ polilinha: "Polilinha",
286
+ poligono: "Polígono",
287
+ caneta: "Caneta",
288
+ texto: "Texto"
289
+ };
290
+ function Tr(t) {
291
+ return t <= 0 ? "Nenhum elemento selecionado" : t === 1 ? "1 elemento selecionado" : `${t} elementos selecionados`;
292
+ }
293
+ function wr(t) {
294
+ return `Ferramenta ${Cr[t] ?? t}`;
295
+ }
296
+ function la(t) {
297
+ return `Zoom ${Math.round(t)}%`;
298
+ }
299
+ function Dr(t, e) {
300
+ t && t.textContent !== e && (t.textContent = e);
301
+ }
302
+ class Ir {
303
+ constructor(e) {
304
+ m(this, "doc", new Mr());
305
+ m(this, "vista", new zr());
306
+ m(this, "ui", xr());
307
+ m(this, "cores", { ...Sa });
308
+ m(this, "guias", []);
309
+ m(this, "ferramenta", "selecao");
310
+ m(this, "opcoesFerramentas", {});
311
+ m(this, "folha", { largura: 210, altura: 297 });
312
+ m(this, "grade", 10);
313
+ m(this, "mostrarGrade", !1);
314
+ m(this, "snapLigado", !0);
315
+ m(this, "guiasInteligentes", !0);
316
+ m(this, "unidade", "mm");
317
+ m(this, "passoTeclado", 1);
318
+ m(this, "somenteLeitura", !1);
319
+ /** Margens da folha em mm (guias automáticas e quadro das pré-definições de moldura); `null` = sem margens. */
320
+ m(this, "margens", null);
321
+ /** Gera o id provisório de um elemento novo; o app pode trocar (`gerarId` do host) ou renomear depois. */
322
+ m(this, "gerarId");
323
+ m(this, "sequencia", 0);
324
+ /** Camadas da prancha (ordem = empilhamento), a camada dos elementos novos e o grupo isolado (duplo clique). */
325
+ m(this, "camadas", []);
326
+ m(this, "camadaAtiva", null);
327
+ m(this, "isolado", null);
328
+ /** Última transformação aplicada à seleção, para o Ctrl+D ("transformar de novo"). */
329
+ m(this, "ultimaTransformacao", null);
330
+ m(this, "cacheMapa", null);
331
+ /** Elementos para a base: os do documento com os substitutos do gesto em andamento no lugar. */
332
+ m(this, "cacheBase", null);
333
+ this.dep = e, this.gerarId = (a) => `${a}-${Date.now().toString(36)}-${(++this.sequencia).toString(36)}`;
334
+ }
335
+ emitir(e, a, r = !1) {
336
+ return this.dep.emitir(e, a, r);
337
+ }
338
+ agendar() {
339
+ this.dep.agendar();
340
+ }
341
+ anunciar(e) {
342
+ this.dep.anunciar(e);
343
+ }
344
+ recusar(e, a, r) {
345
+ this.emitir("prancha-recusa", r === void 0 ? { acao: e, motivo: a } : { acao: e, motivo: a, id: r });
346
+ }
347
+ /** Regras das camadas atuais (em cache pela lista). */
348
+ mapa() {
349
+ return (!this.cacheMapa || this.cacheMapa.camadas !== this.camadas) && (this.cacheMapa = { camadas: this.camadas, mapa: it(this.camadas) }), this.cacheMapa.mapa;
350
+ }
351
+ /** Pode ser selecionado agora: visível, destravado (ele e a camada), não é máscara e está no grupo isolado, se houver. */
352
+ podeSelecionar(e) {
353
+ const a = this.mapa();
354
+ return !!e && !e.mascara && a.visivel(e) && !a.travado(e) && (this.isolado === null || e.grupoId === this.isolado);
355
+ }
356
+ /** Elementos perto do ponto (pelo índice), visíveis, na ordem do documento (para o desempate do empilhamento). */
357
+ candidatosEm(e, a) {
358
+ const r = this.mapa();
359
+ return this.doc.naOrdemDoDocumento(this.doc.indice.consultarPonto(e, a).filter((i) => r.visivel(i)));
360
+ }
361
+ definirCamadas(e) {
362
+ this.camadas = ot(e), this.camadaAtiva && !this.camadas.some((a) => a.id === this.camadaAtiva) && (this.camadaAtiva = null), this.emitir("prancha-camadas", { camadas: this.camadas.map((a) => ({ ...a })) }), this.podarSelecao(), this.agendar();
363
+ }
364
+ /** Isola um grupo (só os membros se selecionam; o resto fica esmaecido) ou sai do isolamento (`null`). */
365
+ isolar(e) {
366
+ const a = typeof e == "string" && this.doc.elementos.some((r) => r.grupoId === e) ? e : null;
367
+ a !== this.isolado && (this.isolado = a, this.emitir("prancha-isolamento", { grupoId: a }), this.anunciar(a ? "Grupo isolado" : "Saiu do grupo"), this.podarSelecao(), this.agendar());
368
+ }
369
+ /** Tira da seleção o que deixou de ser selecionável (camada oculta ou bloqueada, fora do grupo isolado). */
370
+ podarSelecao() {
371
+ const e = this.doc.selecao.filter((a) => this.podeSelecionar(this.doc.obter(a)));
372
+ e.length !== this.doc.selecao.length && this.selecionar(e, "substituir", !1);
373
+ }
374
+ /**
375
+ * Elementos da BASE: os do documento, sem os que estão num gesto (arrasto, alça, âncora). A lista fica a mesma durante o
376
+ * gesto inteiro, então a base não é repintada a cada quadro; os elementos em gesto vão na sobreposição
377
+ * (`elementosEmGesto`), por cima, como a prévia de arrasto dos editores vetoriais.
378
+ */
379
+ elementosVisiveis() {
380
+ const e = this.ui.substitutos;
381
+ if (e.size === 0) return this.doc.elementos;
382
+ const a = [...e.keys()].join("\0"), r = this.cacheBase;
383
+ if (r && r.elementos === this.doc.elementos && r.ids === a) return r.base;
384
+ const i = this.doc.elementos.filter((o) => !e.has(o.id));
385
+ return this.cacheBase = { elementos: this.doc.elementos, ids: a, base: i }, i;
386
+ }
387
+ /** Elementos transformados pelo gesto em andamento, na ordem de empilhamento. */
388
+ elementosEmGesto() {
389
+ const e = this.ui.substitutos, a = e.size === 0 ? [] : this.doc.elementos.filter((r) => e.has(r.id)).map((r) => e.get(r.id));
390
+ return this.ui.copiasEmGesto.length > 0 ? [...a, ...this.ui.copiasEmGesto] : a;
391
+ }
392
+ /** Emite os eventos da diferença (criados, atualizados, removidos) com o motivo. */
393
+ emitirDiferenca(e, a) {
394
+ e.adicionados.length > 0 && this.emitir("prancha-elemento-criado", { elementos: e.adicionados, motivo: a }), e.atualizados.length > 0 && this.emitir("prancha-elemento-atualizado", { elementos: e.atualizados, motivo: a }), e.removidos.length > 0 && this.emitir("prancha-elemento-removido", { ids: e.removidos.map((r) => r.id), elementos: e.removidos, motivo: a });
395
+ }
396
+ emitirHistorico() {
397
+ this.emitir("prancha-historico", { podeDesfazer: this.doc.historico.podeDesfazer, podeRefazer: this.doc.historico.podeRefazer });
398
+ }
399
+ /** Mudança do usuário: histórico + eventos + repintura. `chave` junta rajadas (setas, scrubber) num passo. */
400
+ aplicar(e, a, r) {
401
+ const i = this.doc.selecao.join("\0"), o = this.doc.elementos.map((l) => l.id).join("\0"), s = this.doc.substituir(e, { chave: r });
402
+ return this.doc.elementos.map((l) => l.id).join("\0") !== o && s.adicionados.length === 0 && s.removidos.length === 0 && (this.emitir("prancha-ordem", { ids: this.doc.elementos.map((l) => l.id), motivo: a }), Aa(s) && this.emitirHistorico()), Aa(s) || (this.emitirDiferenca(s, a), this.emitirHistorico(), this.ui.edicao && !this.doc.obter(this.ui.edicao.id) && (this.ui.edicao = null), this.doc.selecao.join("\0") !== i && this.emitirSelecao()), this.agendar(), s;
403
+ }
404
+ /** Substitui elementos pelo id (os demais ficam como estão). */
405
+ aplicarSubstituicoes(e, a, r) {
406
+ const i = new Map(e.map((o) => [o.id, o]));
407
+ return this.aplicar(this.doc.elementos.map((o) => i.get(o.id) ?? o), a, r);
408
+ }
409
+ emitirSelecao() {
410
+ const e = this.doc.elementosSelecionados();
411
+ this.emitir("prancha-selecao", { ids: e.map((a) => a.id), elementos: e }), this.anunciar(Tr(e.length));
412
+ }
413
+ /**
414
+ * Muda a seleção. Fora do isolamento, um membro de grupo seleciona o grupo inteiro (`expandir`). Só entra o que pode ser
415
+ * selecionado (camadas, máscara, isolamento).
416
+ */
417
+ selecionar(e, a = "substituir", r = !0) {
418
+ const i = Array.isArray(e) ? e.filter((n) => typeof n == "string") : [], o = (r && this.isolado === null ? st(this.doc.elementos, i) : i).filter((n) => a === "remover" || this.podeSelecionar(this.doc.obter(n)));
419
+ return this.doc.selecionar(o, a) ? (this.ui.pivo = null, this.ui.edicao && !this.doc.selecao.includes(this.ui.edicao.id) && this.encerrarEdicao(), this.emitirSelecao(), this.agendar(), !0) : !1;
420
+ }
421
+ definirFerramenta(e) {
422
+ e !== this.ferramenta && (V(this.ui), e !== "selecao-direta" && this.ui.edicao && this.encerrarEdicao(), this.ferramenta = e, this.emitir("prancha-ferramenta", { ferramenta: e }), this.anunciar(wr(e)), this.agendar());
423
+ }
424
+ iniciarEdicao(e) {
425
+ var r;
426
+ const a = this.doc.obter(e);
427
+ return a ? a.bloqueado ? (this.recusar("editar-ancoras", "bloqueado", e), !1) : a.geometria.tipo === "texto" ? (this.recusar("editar-ancoras", "texto-sem-ancoras", e), !1) : (((r = this.ui.edicao) == null ? void 0 : r.id) === e || (this.ui.edicao && this.encerrarEdicao(), this.ui.edicao = { id: e, ancoras: [] }, this.doc.selecionar([e]), this.emitirSelecao(), this.emitir("prancha-edicao-iniciada", { elemento: a }), this.agendar()), !0) : !1;
428
+ }
429
+ encerrarEdicao() {
430
+ const e = this.ui.edicao;
431
+ if (!e) return;
432
+ this.ui.edicao = null;
433
+ const a = this.doc.obter(e.id);
434
+ a && this.emitir("prancha-edicao-concluida", { elemento: a }), this.agendar();
435
+ }
436
+ desfazer() {
437
+ const e = this.doc.desfazer();
438
+ return e ? (this.posHistorico(e, "desfazer"), !0) : (this.recusar("desfazer", "nada-a-desfazer"), !1);
439
+ }
440
+ refazer() {
441
+ const e = this.doc.refazer();
442
+ return e ? (this.posHistorico(e, "refazer"), !0) : (this.recusar("refazer", "nada-a-refazer"), !1);
443
+ }
444
+ posHistorico(e, a) {
445
+ V(this.ui), this.ui.edicao && !this.doc.obter(this.ui.edicao.id) && (this.ui.edicao = null), this.emitirDiferenca(e, a), this.emitirHistorico(), this.anunciar(a === "desfazer" ? "Desfeito" : "Refeito"), this.agendar();
446
+ }
447
+ /** Tolerância de snap em px (toque precisa de mais). */
448
+ toleranciaPx(e = !1) {
449
+ return e ? 16 : 8;
450
+ }
451
+ /**
452
+ * Snap do ponto (mm) aos elementos perto (pelo índice), às guias e (opcional) à grade. Grava o resultado no estado
453
+ * (para a sobreposição marcar). Snap desligado ou Alt: devolve o próprio ponto.
454
+ */
455
+ snapPonto(e, a = {}) {
456
+ if (!this.snapLigado || a.desligado)
457
+ return this.ui.snap = null, { ponto: e, resultado: null };
458
+ const r = this.toleranciaPx(a.toque), i = r / this.vista.zoom + 1, o = this.candidatosEm(e, i).filter((n) => !n.mascara), s = se(e, o, this.vista.zoom, {
459
+ toleranciaPx: r,
460
+ guias: this.guias,
461
+ grade: a.grade !== !1 && this.mostrarGrade ? { espacamento: this.grade } : null
462
+ }, a.excluir ?? []);
463
+ return this.ui.snap = s, { ponto: s ? s.coordenada : e, resultado: s };
464
+ }
465
+ /** Emite a vista (zoom/pan) e repinta. */
466
+ emitirVista() {
467
+ const e = this.vista;
468
+ this.emitir("prancha-vista", { zoom: e.zoom, zoomPercentual: e.zoomPercentual, pan: [e.pan[0], e.pan[1]] }), this.agendar();
469
+ }
470
+ emitirGuias() {
471
+ this.emitir("prancha-guias", { guias: this.guias.map((e) => ({ ...e })) }), this.agendar();
472
+ }
473
+ /** Aparência dos elementos novos (cópia; padrão traço preto 0,25 mm sem preenchimento). */
474
+ aparenciaNova() {
475
+ const e = this.opcoesFerramentas.aparencia;
476
+ return e ? JSON.parse(JSON.stringify(e)) : { traco: { cor: lt, espessura: nt }, preenchimento: null };
477
+ }
478
+ }
479
+ const Q = (t) => typeof t == "number" && Number.isFinite(t);
480
+ function ha(t, e) {
481
+ if (t.somenteLeitura)
482
+ return t.recusar(e, "somente-leitura"), null;
483
+ const a = t.doc.elementosSelecionados().filter((r) => !r.bloqueado);
484
+ return a.length === 0 ? (t.recusar(e, "sem-selecao"), null) : a;
485
+ }
486
+ function aa(t, e, a = "comando", r) {
487
+ if (!ne(e)) return !1;
488
+ const i = ha(t, "transformar");
489
+ return i ? (t.aplicarSubstituicoes(I(i, e), a, r), !0) : !1;
490
+ }
491
+ const Pe = (t, e, a, r = "comando", i) => Q(e) && Q(a) && aa(t, k(e, a), r, i);
492
+ function ma(t) {
493
+ return t.ui.pivo ?? ht(t.doc.elementosSelecionados());
494
+ }
495
+ function Me(t, e, a, r = "comando") {
496
+ const i = a ?? ma(t);
497
+ return Q(e) && !!i && aa(t, za(e * Math.PI / 180, i), r);
498
+ }
499
+ function Pa(t, e, a = e, r, i = "comando") {
500
+ const o = r ?? ma(t);
501
+ return !Q(e) || !Q(a) || e === 0 || a === 0 || !o ? !1 : aa(t, H(e, a, o), i);
502
+ }
503
+ function Fr(t, e, a = "comando") {
504
+ if (e !== "horizontal" && e !== "vertical") return !1;
505
+ const r = ha(t, "espelhar");
506
+ return r ? (t.aplicarSubstituicoes(ct(r, e, ma(t) ?? void 0), a), !0) : !1;
507
+ }
508
+ function ze(t, e = "remover") {
509
+ const a = ha(t, "remover");
510
+ if (!a) return !1;
511
+ const r = new Set(a.map((i) => i.id));
512
+ return t.aplicar(t.doc.elementos.filter((i) => !r.has(i.id)), e), !0;
513
+ }
514
+ function xe(t) {
515
+ return t.selecionar(t.doc.elementos.filter((e) => !e.bloqueado && !e.oculto).map((e) => e.id));
516
+ }
517
+ function _r(t, e) {
518
+ const a = t.doc.elementos.filter((s) => !s.bloqueado && !s.oculto);
519
+ if (a.length === 0) return !1;
520
+ const r = t.doc.selecao[t.doc.selecao.length - 1], i = a.findIndex((s) => s.id === r), o = a[i < 0 ? e > 0 ? 0 : a.length - 1 : (i + e + a.length) % a.length];
521
+ return t.selecionar([o.id]);
522
+ }
523
+ function F(t, e, a) {
524
+ var i;
525
+ if (t.somenteLeitura)
526
+ return t.recusar("criar", "somente-leitura"), [];
527
+ const r = [];
528
+ for (const o of e) {
529
+ const s = ((i = o == null ? void 0 : o.geometria) == null ? void 0 : i.tipo) ?? "elemento", n = o != null && o.id && !t.doc.obter(o.id) && !r.some((d) => d.id === o.id) ? o.id : t.gerarId(s), l = !(o != null && o.camadaId) && t.camadaAtiva ? { camadaId: t.camadaAtiva } : {}, c = dt({ ...o, id: n, ...l });
530
+ c ? r.push(c) : t.recusar("criar", "geometria-invalida");
531
+ }
532
+ return r.length === 0 ? [] : (t.aplicar([...t.doc.elementos, ...r], a), t.selecionar(r.map((o) => o.id)), t.anunciar(r.length === 1 ? "Elemento criado" : `${r.length} elementos criados`), r);
533
+ }
534
+ function Nr(t, e, a, r) {
535
+ const i = t.ui.edicao, o = i ? t.doc.obter(i.id) : void 0;
536
+ if (!i || !o || i.ancoras.length === 0) return !1;
537
+ const s = le(o, i.ancoras, e, a);
538
+ return s ? (t.aplicarSubstituicoes([s], "editar-ancoras", r), !0) : (t.recusar("editar-ancoras", "matriz-singular", o.id), !1);
539
+ }
540
+ function Or(t) {
541
+ const e = t.ui.edicao;
542
+ let a = e ? t.doc.obter(e.id) : void 0;
543
+ if (!e || !a || e.ancoras.length === 0) return !1;
544
+ let r = !1;
545
+ for (const i of [...e.ancoras].sort((o, s) => s - o)) {
546
+ const o = ce(a, i);
547
+ if (!o) {
548
+ t.recusar("excluir-ancora", "minimo-de-ancoras", a.id);
549
+ break;
550
+ }
551
+ a = o, r = !0;
552
+ }
553
+ return r ? (e.ancoras = [], t.aplicarSubstituicoes([a], "editar-ancoras"), !0) : !1;
554
+ }
555
+ function Ee(t, e) {
556
+ const a = ha(t, "definir-raios");
557
+ if (!a) return !1;
558
+ const r = a.map((i) => ut(i, e)).filter((i) => !!i);
559
+ return r.length === 0 ? (t.recusar("definir-raios", "tipo-nao-suportado"), !1) : (t.aplicarSubstituicoes(r, "cantos"), !0);
560
+ }
561
+ const oa = ["retangulo", "elipse", "poligono-regular", "estrela", "linha", "seta"], Ce = { polilinha: "linha", poligono: "poligono", caneta: "caneta" }, Rr = "__previa__", Lr = 3, kr = 8, qr = 400, Br = 4, ca = (t) => oa.includes(t) || t in Ce || t === "texto";
562
+ function qa(t, e, a, r) {
563
+ let i = e[0] - t[0], o = e[1] - t[1];
564
+ if (a) {
565
+ const s = Math.max(Math.abs(i), Math.abs(o));
566
+ i = (i < 0 ? -1 : 1) * s, o = (o < 0 ? -1 : 1) * s;
567
+ }
568
+ return r ? { x: t[0] - Math.abs(i), y: t[1] - Math.abs(o), largura: 2 * Math.abs(i), altura: 2 * Math.abs(o) } : St(t, [t[0] + i, t[1] + o]);
569
+ }
570
+ function jr(t, e) {
571
+ const a = e[0] - t[0], r = e[1] - t[1], i = Math.hypot(a, r), o = Math.round(Math.atan2(r, a) / (Math.PI / 4)) * (Math.PI / 4);
572
+ return [t[0] + i * Math.cos(o), t[1] + i * Math.sin(o)];
573
+ }
574
+ class Gr {
575
+ constructor(e) {
576
+ m(this, "arrasto", null);
577
+ m(this, "sessao", null);
578
+ m(this, "puxandoAlca", !1);
579
+ m(this, "ultimoClique", null);
580
+ this.c = e;
581
+ }
582
+ get emAndamento() {
583
+ return !!this.arrasto || !!this.sessao && this.sessao.nos > 0;
584
+ }
585
+ base(e = {}) {
586
+ return { id: Rr, aparencia: this.c.aparenciaNova(), ...e };
587
+ }
588
+ /** Elemento da forma de arrasto entre `inicio` e `atual` (null se degenerado). */
589
+ construir(e, a, r, i) {
590
+ const o = this.c.opcoesFerramentas;
591
+ if (e === "retangulo" || e === "elipse") {
592
+ const s = qa(a, r, i.shift, i.alt);
593
+ return e === "retangulo" ? mt(this.base(), s, o.raioCantos) : ft(this.base(), s);
594
+ }
595
+ if (e === "poligono-regular" || e === "estrela") {
596
+ const s = Math.hypot(r[0] - a[0], r[1] - a[1]), n = e === "poligono-regular" ? pt(this.base(), a, s, o.lados ?? 6) : gt(this.base(), a, s, s * (o.proporcaoInterna ?? 0.45), o.pontas ?? 5);
597
+ if (!n || i.shift) return n;
598
+ const l = Math.atan2(r[1] - a[1], r[0] - a[0]) + Math.PI / 2;
599
+ return ue(n, za(l, a));
600
+ }
601
+ if (e === "linha" || e === "seta") {
602
+ const s = i.shift ? jr(a, r) : r, n = this.c.aparenciaNova();
603
+ return e === "seta" && (n.traco = { ...n.traco ?? {}, pontaFim: o.ponta ?? { estilo: "triangulo" } }), vt(this.base({ aparencia: n }), a, s);
604
+ }
605
+ return null;
606
+ }
607
+ pressionar(e, a, r) {
608
+ const i = this.c.ferramenta, { ponto: o } = this.c.snapPonto(e, { toque: r.toque, desligado: r.alt && !oa.includes(i) });
609
+ if (oa.includes(i)) {
610
+ this.arrasto = { inicio: o, atual: o, inicioPx: a };
611
+ return;
612
+ }
613
+ if (i === "texto") {
614
+ this.solicitarTexto(o);
615
+ return;
616
+ }
617
+ const s = Ce[i];
618
+ if (!s) return;
619
+ this.sessao || (this.sessao = new Ar(s, !1, { espaco: bt }));
620
+ const n = this.sessao, l = Date.now(), c = !!this.ultimoClique && l - this.ultimoClique.t <= qr && Math.hypot(a[0] - this.ultimoClique.x, a[1] - this.ultimoClique.y) <= Br;
621
+ this.ultimoClique = { t: l, x: a[0], y: a[1] };
622
+ const d = n.primeiro;
623
+ if (d && n.fechaNoPrimeiro) {
624
+ const h = this.c.vista.paraTela(d);
625
+ if (Math.hypot(h[0] - a[0], h[1] - a[1]) <= kr) {
626
+ this.finalizar(n.concluirFechando());
627
+ return;
628
+ }
629
+ }
630
+ if (c && s !== "caneta") {
631
+ this.concluir();
632
+ return;
633
+ }
634
+ n.clicar(o), s === "caneta" && (this.puxandoAlca = !0), this.atualizarPrevia();
635
+ }
636
+ mover(e, a, r) {
637
+ const i = this.c.ferramenta;
638
+ if (this.arrasto) {
639
+ const { ponto: o } = this.c.snapPonto(e, { toque: r.toque });
640
+ this.arrasto.atual = o, this.c.ui.previa = this.construir(i, this.arrasto.inicio, o, r);
641
+ const s = qa(this.arrasto.inicio, o, r.shift, r.alt), n = (l) => Math.round(l * 10) / 10;
642
+ this.c.ui.rotulo = { texto: `${n(s.largura)} × ${n(s.altura)} mm`, em: o }, this.c.agendar();
643
+ return;
644
+ }
645
+ if (this.sessao) {
646
+ const { ponto: o } = this.c.snapPonto(e, { toque: r.toque, desligado: r.alt });
647
+ this.puxandoAlca ? this.sessao.definirAlca(o) : this.sessao.mover(o), this.atualizarPrevia();
648
+ } else ca(i) && (this.c.snapPonto(e, { toque: r.toque, desligado: r.alt }), this.c.agendar());
649
+ }
650
+ soltar(e, a, r) {
651
+ this.puxandoAlca = !1;
652
+ const i = this.arrasto;
653
+ if (!i) return;
654
+ this.arrasto = null;
655
+ const o = this.c.ui.previa;
656
+ if (V(this.c.ui), !o || Math.hypot(a[0] - i.inicioPx[0], a[1] - i.inicioPx[1]) < Lr) {
657
+ this.c.recusar("desenhar", "forma-pequena"), this.c.agendar();
658
+ return;
659
+ }
660
+ F(this.c, [{ ...o, id: "" }], "ferramenta");
661
+ }
662
+ atualizarPrevia() {
663
+ const e = this.sessao;
664
+ if (!e) return;
665
+ const a = e.previa();
666
+ this.c.ui.previa = a && (a.tipo === "LineString" || a.tipo === "Polygon") ? _a(this.base(), a) : null, this.c.ui.pontosPrevia = e.ferramenta === "caneta" ? e.ancoras.map((r) => r.ponto) : [...e.pontos], this.c.agendar();
667
+ }
668
+ finalizar(e) {
669
+ if (this.sessao = null, this.ultimoClique = null, V(this.c.ui), e && (e.tipo === "LineString" || e.tipo === "Polygon")) {
670
+ const a = _a({ id: "", aparencia: this.c.aparenciaNova() }, e);
671
+ a && F(this.c, [a], "ferramenta");
672
+ } else
673
+ this.c.recusar("desenhar", "geometria-invalida");
674
+ this.c.agendar();
675
+ }
676
+ concluir() {
677
+ const e = this.sessao;
678
+ return !e || !e.podeConcluir ? !1 : (this.finalizar(e.concluir()), !0);
679
+ }
680
+ cancelar() {
681
+ this.arrasto = null, this.sessao = null, this.puxandoAlca = !1, this.ultimoClique = null, V(this.c.ui), this.c.agendar();
682
+ }
683
+ /** Enter, Esc e Backspace durante o desenho; devolve se tratou. */
684
+ tecla(e) {
685
+ return e === "Enter" && this.sessao ? this.concluir() || !0 : e === "Escape" && this.emAndamento ? (this.cancelar(), !0) : e === "Backspace" && this.sessao && this.sessao.nos > 0 ? (this.sessao.desfazer(), this.sessao.nos === 0 ? this.cancelar() : this.atualizarPrevia(), !0) : !1;
686
+ }
687
+ /** Teclado: Enter com a ferramenta ativa e nada em andamento cria a forma padrão (40 × 30 mm) no centro da vista. */
688
+ criarNoCentro() {
689
+ const e = this.c.ferramenta, a = this.c.vista, r = a.largura > 0 ? a.paraFolha(a.largura / 2, a.altura / 2) : [this.c.folha.largura / 2, this.c.folha.altura / 2];
690
+ if (e === "texto")
691
+ return this.solicitarTexto(r), !0;
692
+ if (!oa.includes(e)) return !1;
693
+ const i = this.construir(e, [r[0] - 20, r[1] - 15], [r[0] + 20, r[1] + 15], { shift: !1, alt: !1 });
694
+ return !!i && F(this.c, [{ ...i, id: "" }], "ferramenta").length > 0;
695
+ }
696
+ solicitarTexto(e) {
697
+ const a = this.c.opcoesFerramentas, r = a.tamanhoTexto && a.tamanhoTexto > 0 ? a.tamanhoTexto : yt(12, "pt"), i = (n) => {
698
+ var c;
699
+ const l = At({ id: "", aparencia: { preenchimento: { cor: ((c = this.c.aparenciaNova().traco) == null ? void 0 : c.cor) ?? void 0 } } }, e, n, r);
700
+ return l ? F(this.c, [l], "texto")[0] ?? null : null;
701
+ }, o = { posicao: e, concluir: (n) => i(typeof n == "string" ? n : String(n ?? "")) };
702
+ this.c.emitir("prancha-texto-solicitado", o, !0) || i(a.textoPadrao ?? "Texto");
703
+ }
704
+ }
705
+ const Z = 5, R = { elementos: [], colagens: 0 }, Ma = (t) => typeof t == "number" && Number.isFinite(t);
706
+ function y(t, e, a = 1) {
707
+ if (t.somenteLeitura)
708
+ return t.recusar(e, "somente-leitura"), null;
709
+ const r = t.doc.elementosSelecionados().filter((i) => !t.mapa().travado(i));
710
+ return r.length < a ? (t.recusar(e, "sem-selecao"), null) : r;
711
+ }
712
+ function ea(t, e, a) {
713
+ return "ok" in a ? a.ok : (t.recusar(e, a.motivo === "texto" ? "texto-sem-ancoras" : a.motivo === "tipos-incompativeis" || a.motivo === "sem-forma-fechada" ? "tipo-nao-suportado" : "geometria-invalida"), null);
714
+ }
715
+ function O(t, e) {
716
+ const a = y(t, "ordem");
717
+ return !a || !["frente", "tras", "avancar", "recuar"].includes(e) ? !1 : (t.aplicar(Pt(t.doc.elementos, a.map((r) => r.id), e, t.camadas), "ordem"), !0);
718
+ }
719
+ function Te(t) {
720
+ const e = y(t, "agrupar", 2);
721
+ return e ? (t.aplicar(Mt(t.doc.elementos, e.map((a) => a.id), t.gerarId("grupo"), t.camadas), "agrupar"), !0) : !1;
722
+ }
723
+ function we(t) {
724
+ const e = y(t, "desagrupar");
725
+ if (!e) return !1;
726
+ const a = e.map((r) => r.id);
727
+ return t.isolado && e.some((r) => r.grupoId === t.isolado) && t.isolar(null), t.aplicar(zt(t.doc.elementos, a), "desagrupar"), !0;
728
+ }
729
+ function ua(t, e) {
730
+ const a = y(t, e === "bloqueado" ? "bloquear" : "ocultar");
731
+ if (!a) return !1;
732
+ const r = new Set(a.map((i) => i.id));
733
+ return t.selecionar([]), t.aplicar(t.doc.elementos.map((i) => r.has(i.id) ? { ...i, [e]: !0 } : i), e === "bloqueado" ? "bloquear" : "ocultar"), !0;
734
+ }
735
+ function da(t, e) {
736
+ if (t.somenteLeitura)
737
+ return t.recusar("liberar", "somente-leitura"), !1;
738
+ const a = [], r = t.doc.elementos.map((i) => {
739
+ if (!i[e]) return i;
740
+ a.push(i.id);
741
+ const o = { ...i };
742
+ return delete o[e], o;
743
+ });
744
+ return a.length === 0 ? !1 : (t.aplicar(r, e === "bloqueado" ? "bloquear" : "ocultar"), t.selecionar(a), !0);
745
+ }
746
+ function Hr(t, e, a = "selecao") {
747
+ const r = y(t, "alinhar");
748
+ if (!r) return !1;
749
+ let i = { tipo: "selecao" };
750
+ a === "folha" ? i = { tipo: "caixa", caixa: { x: 0, y: 0, largura: t.folha.largura, altura: t.folha.altura } } : a === "chave" ? i = { tipo: "chave", id: t.doc.selecao[0] } : a && typeof a == "object" && (i = { tipo: "caixa", caixa: a });
751
+ const o = xt(r, e, i);
752
+ return o.length === 0 ? !1 : (t.aplicarSubstituicoes(o, "alinhar"), !0);
753
+ }
754
+ function $r(t, e, a = "espacos", r) {
755
+ const i = y(t, "distribuir", 2);
756
+ if (!i) return !1;
757
+ const o = Et(i, e === "vertical" ? "vertical" : "horizontal", a === "centros" ? "centros" : "espacos", Ma(r) ? r : void 0);
758
+ return o.length === 0 ? !1 : (t.aplicarSubstituicoes(o, "distribuir"), !0);
759
+ }
760
+ function wa(t, e, a, r) {
761
+ const i = he(U(e, t.camadas), t.gerarId, a);
762
+ return F(t, i, r);
763
+ }
764
+ function Vr(t, e = [Z, Z]) {
765
+ const a = y(t, "duplicar");
766
+ if (!a) return !1;
767
+ const r = Ma(e == null ? void 0 : e[0]) && Ma(e == null ? void 0 : e[1]) ? e : [Z, Z], i = wa(t, a, r, "duplicar");
768
+ return t.ultimaTransformacao = { matriz: k(r[0], r[1]), duplicar: !0 }, i.length > 0;
769
+ }
770
+ function Ba(t, e, a = !1) {
771
+ ne(e) && (t.ultimaTransformacao = { matriz: e, duplicar: a });
772
+ }
773
+ function De(t) {
774
+ const e = t.ultimaTransformacao;
775
+ if (!e)
776
+ return t.recusar("transformar-de-novo", "nada-a-refazer"), !1;
777
+ const a = y(t, "transformar-de-novo");
778
+ if (!a) return !1;
779
+ if (e.duplicar) {
780
+ const i = wa(t, a, [0, 0], "duplicar");
781
+ return i.length === 0 ? !1 : (t.aplicarSubstituicoes(I(i, e.matriz), "transformar"), t.ultimaTransformacao = e, !0);
782
+ }
783
+ const r = aa(t, e.matriz, "transformar");
784
+ return t.ultimaTransformacao = e, r;
785
+ }
786
+ function Da(t) {
787
+ var a, r, i, o;
788
+ const e = t.doc.elementosSelecionados();
789
+ if (e.length === 0)
790
+ return t.recusar("copiar", "sem-selecao"), !1;
791
+ R.elementos = JSON.parse(JSON.stringify(U(e, t.camadas))), R.colagens = 0;
792
+ try {
793
+ const s = typeof navigator < "u" ? navigator : void 0;
794
+ (o = (i = (r = (a = s == null ? void 0 : s.clipboard) == null ? void 0 : a.writeText) == null ? void 0 : r.call(a, JSON.stringify({ tipo: "ui-canvas-prancha", elementos: R.elementos }))) == null ? void 0 : i.catch) == null || o.call(i, () => {
795
+ });
796
+ } catch {
797
+ }
798
+ return t.anunciar(e.length === 1 ? "Elemento copiado" : `${e.length} elementos copiados`), !0;
799
+ }
800
+ function Ie(t) {
801
+ const e = y(t, "recortar");
802
+ if (!e || !Da(t)) return !1;
803
+ const a = new Set(e.map((r) => r.id));
804
+ return t.aplicar(t.doc.elementos.filter((r) => !a.has(r.id)), "recortar"), !0;
805
+ }
806
+ function Fe(t, e = !1) {
807
+ if (R.elementos.length === 0)
808
+ return t.recusar("colar", "sem-selecao"), !1;
809
+ if (t.somenteLeitura)
810
+ return t.recusar("colar", "somente-leitura"), !1;
811
+ R.colagens++;
812
+ const a = e ? 0 : Z * R.colagens;
813
+ return wa(t, R.elementos, [a, a], "colar").length > 0;
814
+ }
815
+ function Kr(t, e) {
816
+ const a = e.aparencia ? JSON.parse(JSON.stringify(e.aparencia)) : void 0;
817
+ t.emitir("prancha-conta-gotas", { elemento: e, aparencia: a });
818
+ const r = t.doc.elementosSelecionados().filter((i) => i.id !== e.id && !t.mapa().travado(i));
819
+ return r.length === 0 ? (t.opcoesFerramentas = { ...t.opcoesFerramentas, aparencia: a }, t.anunciar("Aparência guardada para as formas novas"), !0) : t.somenteLeitura ? (t.recusar("conta-gotas", "somente-leitura"), !1) : (t.aplicarSubstituicoes(de(r, a), "conta-gotas"), !0);
820
+ }
821
+ function Wr(t, e) {
822
+ const a = y(t, "aparencia");
823
+ return a ? (t.aplicarSubstituicoes(de(a, e ?? void 0), "aparencia"), !0) : !1;
824
+ }
825
+ function Ur(t, e) {
826
+ const a = y(t, "mover-camada");
827
+ return !a || typeof e != "string" || !t.camadas.some((r) => r.id === e) ? (a && t.recusar("mover-camada", "id-invalido", typeof e == "string" ? e : void 0), !1) : (t.aplicarSubstituicoes(a.map((r) => ({ ...r, camadaId: e })), "camada"), !0);
828
+ }
829
+ function _e(t) {
830
+ const e = y(t, "mascara", 2);
831
+ if (!e) return !1;
832
+ const a = ea(t, "mascara", Ct(t.doc.elementos, e.map((r) => r.id), t.gerarId("grupo"), t.camadas));
833
+ return a ? (t.aplicar(a, "mascara"), !0) : !1;
834
+ }
835
+ function Ne(t) {
836
+ const e = y(t, "liberar-mascara");
837
+ if (!e) return !1;
838
+ const a = Tt(t.doc.elementos, e.map((r) => r.id));
839
+ return a.every((r, i) => r === t.doc.elementos[i]) ? (t.recusar("liberar-mascara", "tipo-nao-suportado"), !1) : (t.aplicar(a, "mascara"), !0);
840
+ }
841
+ function Oe(t, e = 0.01) {
842
+ const a = y(t, "unir", 2);
843
+ if (!a) return !1;
844
+ const r = U(a, t.camadas), i = ea(t, "unir", wt(r, e));
845
+ if (!i) return !1;
846
+ const o = new Set(r.slice(1).map((s) => s.id));
847
+ return t.aplicar(t.doc.elementos.filter((s) => !o.has(s.id)).map((s) => s.id === i.id ? i : s), "unir"), !0;
848
+ }
849
+ function Xr(t) {
850
+ const e = y(t, "dividir", 2);
851
+ if (!e) return !1;
852
+ const a = U(e, t.camadas), r = [...a].reverse().find((n) => n.geometria.tipo === "linha" || n.geometria.tipo === "caminho" && n.geometria.geometria.tipo === "LineString"), i = a.find((n) => n !== r);
853
+ if (!r || !i)
854
+ return t.recusar("dividir", "tipo-nao-suportado"), !1;
855
+ const o = ea(t, "dividir", Dt(i, r, t.gerarId));
856
+ if (!o) return !1;
857
+ const s = [];
858
+ for (const n of t.doc.elementos)
859
+ n.id !== r.id && (n.id === i.id ? s.push(...o) : s.push(n));
860
+ return t.aplicar(s, "dividir"), t.selecionar(o.map((n) => n.id)), !0;
861
+ }
862
+ function Zr(t, e) {
863
+ const a = y(t, "deslocar-caminho");
864
+ if (!a) return !1;
865
+ const r = a.map((i) => ea(t, "deslocar-caminho", It(i, e, t.gerarId("caminho")))).filter((i) => !!i);
866
+ return r.length > 0 && F(t, r, "deslocar-caminho").length > 0;
867
+ }
868
+ function Ia(t, e, a, r) {
869
+ const i = y(t, e);
870
+ if (!i) return !1;
871
+ const o = [];
872
+ for (const s of i) {
873
+ const n = r(s), l = n && typeof n == "object" && ("ok" in n || "motivo" in n) ? ea(t, e, n) : n;
874
+ l && o.push(l);
875
+ }
876
+ return o.length === 0 ? !1 : (t.aplicarSubstituicoes(o, a), !0);
877
+ }
878
+ const Jr = (t, e = 0.2) => Ia(t, "simplificar", "simplificar", (a) => Ft(a, e)), Qr = (t) => Ia(t, "contorno-traco", "contorno-traco", (e) => _t(e)), Yr = (t) => Ia(t, "converter-caminho", "converter-caminho", (e) => e.geometria.tipo === "caminho" ? null : Nt(e)), ai = 7, Re = 22, ja = 6, K = (t, e) => t.setTransform(e, 0, 0, e, 0, 0);
879
+ function z(t, e, a = !0) {
880
+ if (e.length !== 0) {
881
+ t.moveTo(e[0][0], e[0][1]);
882
+ for (let r = 1; r < e.length; r++) t.lineTo(e[r][0], e[r][1]);
883
+ a && t.closePath();
884
+ }
885
+ }
886
+ function va(t, e, a, r, i) {
887
+ const o = a / 2;
888
+ t.beginPath(), z(t, [[e[0] - o, e[1] - o], [e[0] + o, e[1] - o], [e[0] + o, e[1] + o], [e[0] - o, e[1] + o]]), t.fillStyle = r, t.fill(), t.strokeStyle = i, t.stroke();
889
+ }
890
+ function ta(t, e, a) {
891
+ const r = [];
892
+ for (let i = 0; i < 16; i++) r.push([e[0] + a * Math.cos(i * Math.PI / 8), e[1] + a * Math.sin(i * Math.PI / 8)]);
893
+ z(t, r);
894
+ }
895
+ function ei(t, e) {
896
+ const a = e.grade;
897
+ if (!a || !(a > 0)) return;
898
+ const { vista: r, folha: i } = e;
899
+ let o = a;
900
+ for (; o * r.zoom < 8; ) o *= 2;
901
+ const [s, n] = r.paraTela([0, 0]), [l, c] = r.paraTela([i.largura, i.altura]);
902
+ t.beginPath();
903
+ for (let d = 0; d <= i.largura + 1e-9; d += o) {
904
+ const h = Math.round(r.paraTela([d, 0])[0]) + 0.5;
905
+ t.moveTo(h, n), t.lineTo(h, c);
906
+ }
907
+ for (let d = 0; d <= i.altura + 1e-9; d += o) {
908
+ const h = Math.round(r.paraTela([0, d])[1]) + 0.5;
909
+ t.moveTo(s, h), t.lineTo(l, h);
910
+ }
911
+ t.strokeStyle = e.cores.grade, t.lineWidth = 1, t.setLineDash([]), t.globalAlpha = 1, t.stroke();
912
+ }
913
+ function ti(t, e, a, r) {
914
+ const i = e.matrizDispositivo();
915
+ t.setTransform(i.a, i.b, i.c, i.d, i.e, i.f), t.globalAlpha = 0.6, t.fillStyle = r, t.fillRect(0, 0, a.largura, a.altura);
916
+ }
917
+ function ri(t, e) {
918
+ const { vista: a, folha: r, cores: i } = e;
919
+ t.save(), K(t, a.dpr), t.globalAlpha = 1, t.fillStyle = i.mesa, t.fillRect(0, 0, a.largura, a.altura), t.restore();
920
+ const o = a.matrizDispositivo();
921
+ $(t, [], { matriz: o, fundo: { cor: i.papel, largura: r.largura, altura: r.altura } }), t.save(), K(t, a.dpr), ei(t, e), t.restore(), $(t, e.elementos, { matriz: o, camadas: e.camadas }), e.isolados && e.isolados.length > 0 && (t.save(), ti(t, a, r, i.papel), t.restore(), $(t, e.isolados, { matriz: o, camadas: e.camadas })), t.save(), K(t, a.dpr);
922
+ const [s, n] = a.paraTela([0, 0]), [l, c] = a.paraTela([r.largura, r.altura]);
923
+ t.beginPath(), z(t, [[s, n], [l, n], [l, c], [s, c]]), t.strokeStyle = i.bordaPapel, t.lineWidth = 1, t.stroke();
924
+ const d = e.margens;
925
+ if (d && d.largura > 0 && d.altura > 0) {
926
+ const [h, u] = a.paraTela([d.x, d.y]), [f, p] = a.paraTela([d.x + d.largura, d.y + d.altura]);
927
+ t.beginPath(), z(t, [[h, u], [f, u], [f, p], [h, p]]), t.strokeStyle = i.guiaInteligente, t.globalAlpha = 0.6, t.setLineDash([6, 4]), t.stroke(), t.setLineDash([]), t.globalAlpha = 1;
928
+ }
929
+ t.restore();
930
+ }
931
+ function Ga(t, e, a) {
932
+ const r = Ca(e);
933
+ if (!r) return;
934
+ const i = r.tipo === "Polygon" ? r.aneis : r.partes && r.partes.length > 1 ? r.partes : [r.coordenadas];
935
+ for (const o of i) z(t, o.map((s) => a.paraTela(s)), r.tipo === "Polygon");
936
+ }
937
+ function Ha(t, e) {
938
+ return ["no", "ne", "se", "so"].map((a) => e.paraTela(Rt(t.quadro, Lt(t, a))));
939
+ }
940
+ function $a(t, e, a) {
941
+ if (e.orientacao === "horizontal") {
942
+ const r = Math.round(a.paraTela([0, e.posicao])[1]) + 0.5;
943
+ t.moveTo(0, r), t.lineTo(a.largura, r);
944
+ } else {
945
+ const r = Math.round(a.paraTela([e.posicao, 0])[0]) + 0.5;
946
+ t.moveTo(r, 0), t.lineTo(r, a.altura);
947
+ }
948
+ }
949
+ function ba(t, e, a, r) {
950
+ typeof t.fillText == "function" && (t.font = "11px sans-serif", t.fillStyle = r, t.fillText(e, a[0], a[1]));
951
+ }
952
+ function ii(t, e) {
953
+ const { vista: a, cores: r, ui: i } = e;
954
+ t.save(), K(t, a.dpr), typeof t.clearRect == "function" && t.clearRect(0, 0, a.largura, a.altura), t.globalAlpha = 1, t.lineWidth = 1, t.setLineDash([]), t.beginPath();
955
+ for (const s of e.guias) $a(t, s, a);
956
+ t.strokeStyle = r.guia, t.stroke(), i.guiaArrastada && (t.beginPath(), $a(t, i.guiaArrastada.guia, a), t.setLineDash([4, 3]), t.stroke(), t.setLineDash([])), e.hover && !e.selecionados.includes(e.hover) && (t.beginPath(), Ga(t, e.hover, a), t.strokeStyle = r.selecao, t.stroke()), e.emGesto.length > 0 && ($(t, e.emGesto, { matriz: a.matrizDispositivo() }), K(t, a.dpr), t.globalAlpha = 1, t.lineWidth = 1, t.setLineDash([])), i.previa && ($(t, [i.previa], { matriz: a.matrizDispositivo() }), K(t, a.dpr), t.globalAlpha = 1, t.lineWidth = 1, t.setLineDash([]));
957
+ for (const s of i.pontosPrevia) va(t, a.paraTela(s), ja, r.alca, r.selecao);
958
+ const o = i.edicao ? e.selecionados.find((s) => s.id === i.edicao.id) ?? null : null;
959
+ for (const s of e.selecionados) {
960
+ const n = Ot(s);
961
+ !n || s === o || (t.beginPath(), z(t, Ha(n, a)), t.strokeStyle = r.selecao, t.stroke());
962
+ }
963
+ if (o && i.edicao) {
964
+ t.beginPath(), Ga(t, o, a), t.strokeStyle = r.selecao, t.stroke();
965
+ const s = xa(o), n = me(o);
966
+ t.beginPath(), i.edicao.ancoras.forEach((l) => {
967
+ const c = s[l], d = n[l];
968
+ if (!(!c || !d))
969
+ for (const h of [d.entrada, d.saida]) h && z(t, [a.paraTela(c), a.paraTela(h)], !1);
970
+ }), t.stroke(), i.edicao.ancoras.forEach((l) => {
971
+ const c = n[l];
972
+ if (c)
973
+ for (const d of [c.entrada, c.saida])
974
+ d && (t.beginPath(), ta(t, a.paraTela(d), 3), t.fillStyle = r.selecao, t.fill());
975
+ }), s.forEach((l, c) => va(t, a.paraTela(l), ja, i.edicao.ancoras.includes(c) ? r.selecao : r.alca, r.selecao));
976
+ } else if (e.caixaTransformacao && e.selecionados.length > 0) {
977
+ const s = Ea(e.selecionados);
978
+ if (s) {
979
+ const n = fe(s, Re / a.zoom);
980
+ t.beginPath(), z(t, Ha(s, a)), z(t, [a.paraTela(n.alcas.n), a.paraTela(n.rotacao)], !1), t.strokeStyle = r.selecao, t.stroke();
981
+ for (const c of Object.values(n.alcas)) va(t, a.paraTela(c), ai, r.alca, r.selecao);
982
+ t.beginPath(), ta(t, a.paraTela(n.rotacao), 4), t.fillStyle = r.alca, t.fill(), t.stroke();
983
+ for (const c of e.marcasCantos ?? [])
984
+ t.beginPath(), ta(t, a.paraTela(c), 3.5), t.fillStyle = r.alca, t.fill(), t.strokeStyle = r.selecao, t.stroke();
985
+ const l = a.paraTela(i.pivo ?? n.centro);
986
+ t.beginPath(), ta(t, l, 4), z(t, [[l[0] - 7, l[1]], [l[0] + 7, l[1]]], !1), z(t, [[l[0], l[1] - 7], [l[0], l[1] + 7]], !1), t.stroke();
987
+ }
988
+ }
989
+ if (i.linhasInteligentes.length > 0) {
990
+ t.beginPath();
991
+ for (const s of i.linhasInteligentes) {
992
+ const n = a.paraTela(s.orientacao === "vertical" ? [s.posicao, s.de] : [s.de, s.posicao]), l = a.paraTela(s.orientacao === "vertical" ? [s.posicao, s.ate] : [s.ate, s.posicao]);
993
+ z(t, [n, l], !1);
994
+ }
995
+ t.strokeStyle = r.guiaInteligente, t.stroke();
996
+ for (const s of i.linhasInteligentes) {
997
+ if (s.distancia === void 0) continue;
998
+ const n = a.paraTela(s.orientacao === "vertical" ? [s.posicao, (s.de + s.ate) / 2] : [(s.de + s.ate) / 2, s.posicao]);
999
+ ba(t, `${Math.round(s.distancia * 100) / 100} mm`, [n[0] + 4, n[1] - 4], r.guiaInteligente);
1000
+ }
1001
+ }
1002
+ if (i.caixaSelecao) {
1003
+ const s = a.paraTela(i.caixaSelecao.de), n = a.paraTela(i.caixaSelecao.ate);
1004
+ t.beginPath(), z(t, [s, [n[0], s[1]], n, [s[0], n[1]]]), t.setLineDash(i.caixaSelecao.crossing ? [5, 3] : []), t.strokeStyle = r.selecao, t.stroke(), t.setLineDash([]);
1005
+ }
1006
+ if (i.snap) {
1007
+ const s = a.paraTela(i.snap.coordenada);
1008
+ t.beginPath(), z(t, [[s[0] - 5, s[1] - 5], [s[0] + 5, s[1] - 5], [s[0] + 5, s[1] + 5], [s[0] - 5, s[1] + 5]]), t.strokeStyle = r.snap, t.stroke(), ba(t, i.snap.tipo, [s[0] + 8, s[1] - 8], r.snap);
1009
+ }
1010
+ if (i.rotulo) {
1011
+ const s = a.paraTela(i.rotulo.em);
1012
+ ba(t, i.rotulo.texto, [s[0] + 12, s[1] + 18], r.selecao);
1013
+ }
1014
+ t.restore();
1015
+ }
1016
+ const oi = 14;
1017
+ function Le(t) {
1018
+ const e = t.doc.elementosSelecionados();
1019
+ return e.length !== 1 || t.ferramenta !== "selecao" || t.somenteLeitura ? null : Kt(t.ui.substitutos.get(e[0].id) ?? e[0], oi / t.vista.zoom);
1020
+ }
1021
+ const L = (t, e) => Math.hypot(t[0] - e[0], t[1] - e[1]);
1022
+ function Va(t, e, a) {
1023
+ const r = t.doc.elementosSelecionados(), i = r.length > 0 ? Ea(r) : null;
1024
+ if (!i) return null;
1025
+ const o = a ? 19 : 6, s = t.vista, n = fe(i, Re / s.zoom), l = Le(t);
1026
+ if (l) {
1027
+ const c = l.findIndex((d) => L(s.paraTela(d), e) <= o);
1028
+ if (c >= 0) return { tipo: "canto", canto: c };
1029
+ }
1030
+ if (L(s.paraTela(t.ui.pivo ?? n.centro), e) <= o) return { tipo: "pivo" };
1031
+ if (L(s.paraTela(n.rotacao), e) <= o) return { tipo: "rotacao" };
1032
+ for (const c of kt) if (L(s.paraTela(n.alcas[c]), e) <= o) return { tipo: "escala", alca: c };
1033
+ return null;
1034
+ }
1035
+ function si(t, e, a, r) {
1036
+ const i = t.doc.elementosSelecionados().filter((n) => !n.bloqueado), o = Ea(i);
1037
+ if (!o || i.length === 0) return null;
1038
+ if (e.tipo === "pivo") return { tipo: "pivo" };
1039
+ if (e.tipo === "canto") {
1040
+ const n = i[0], l = pe(n), c = ge(n, e.canto ?? 0, a);
1041
+ return i.length !== 1 || !l || c === null ? null : { tipo: "canto", original: n, indice: e.canto ?? 0, raio0: l[e.canto ?? 0], profundidade0: c };
1042
+ }
1043
+ if (e.tipo === "rotacao") return { tipo: "rotacao", pivo: ma(t) ?? a, inicio: a, originais: i };
1044
+ const s = e.alca;
1045
+ return r.ctrl && (s === "n" || s === "s" || s === "e" || s === "o") ? { tipo: "cisalhamento", caixa: o, alca: s, originais: i } : { tipo: "escala", caixa: o, alca: s, originais: i };
1046
+ }
1047
+ function ni(t, e, a) {
1048
+ const r = 50 / t.vista.zoom, i = t.doc.indice.consultarCaixa(e, r).filter((s) => !a.has(s.id) && !s.oculto), o = [{ x: 0, y: 0, largura: t.folha.largura, altura: t.folha.altura }];
1049
+ for (const s of i.slice(0, 200)) {
1050
+ const n = Y(s);
1051
+ n && o.push(n);
1052
+ }
1053
+ return o;
1054
+ }
1055
+ function li(t) {
1056
+ let e = 1 / 0, a = 1 / 0, r = -1 / 0, i = -1 / 0;
1057
+ for (const o of t) {
1058
+ const s = Wt(o);
1059
+ s && (e = Math.min(e, s.x), a = Math.min(a, s.y), r = Math.max(r, s.x + s.largura), i = Math.max(i, s.y + s.altura));
1060
+ }
1061
+ return e <= r ? { x: e, y: a, largura: r - e, altura: i - a } : null;
1062
+ }
1063
+ function ci(t, e, a = !1, r = !1) {
1064
+ const i = t.doc.elementosSelecionados().filter((n) => !n.bloqueado);
1065
+ if (i.length === 0) return null;
1066
+ const o = i.length <= 200 ? i.length === 1 ? Y(i[0]) : li(i) : null, s = t.snapLigado && i.length <= 200 ? se(e, i, t.vista.zoom, { toleranciaPx: t.toleranciaPx(a), meio: !1, aresta: !1 }) : null;
1067
+ return { tipo: "mover", inicio: s ? s.coordenada : e, originais: i, caixa: o, duplicar: r };
1068
+ }
1069
+ function ui(t, e, a, r) {
1070
+ var s, n, l;
1071
+ const i = t.ui;
1072
+ i.linhasInteligentes = [], i.snap = null;
1073
+ let o = [];
1074
+ switch (e.tipo) {
1075
+ case "pivo":
1076
+ i.pivo = t.snapPonto(a, { toque: r.toque, desligado: r.alt }).ponto;
1077
+ break;
1078
+ case "mover": {
1079
+ let c = a[0] - e.inicio[0], d = a[1] - e.inicio[1];
1080
+ r.shift && (Math.abs(c) >= Math.abs(d) ? d = 0 : c = 0);
1081
+ const h = new Set(e.originais.map((f) => f.id));
1082
+ if ((!r.alt || e.duplicar) && t.snapLigado) {
1083
+ const f = t.snapPonto([e.inicio[0] + c, e.inicio[1] + d], { excluir: h, grade: !1, toque: r.toque });
1084
+ if (f.resultado)
1085
+ c = f.ponto[0] - e.inicio[0], d = f.ponto[1] - e.inicio[1];
1086
+ else if (e.caixa && t.guiasInteligentes) {
1087
+ const p = { ...e.caixa, x: e.caixa.x + c, y: e.caixa.y + d }, v = Vt(p, ni(t, p, h), 6 / t.vista.zoom);
1088
+ if (c += v.correcao[0], d += v.correcao[1], i.linhasInteligentes = v.linhas, v.linhas.length === 0) {
1089
+ const b = t.snapPonto([e.inicio[0] + c, e.inicio[1] + d], { excluir: h, toque: r.toque });
1090
+ ((s = b.resultado) == null ? void 0 : s.tipo) === "grade" && (c = b.ponto[0] - e.inicio[0], d = b.ponto[1] - e.inicio[1]);
1091
+ }
1092
+ }
1093
+ }
1094
+ e.matriz = k(c, d), o = I(e.originais, e.matriz), e.duplicar && (i.copiasEmGesto = o, o = []);
1095
+ const u = (f) => Math.round(f * 100) / 100;
1096
+ i.rotulo = { texto: `Δ ${u(c)}, ${u(d)} mm`, em: a };
1097
+ break;
1098
+ }
1099
+ case "escala": {
1100
+ const c = t.snapPonto(a, { excluir: e.originais.map((h) => h.id), toque: r.toque }).ponto, d = $t(e.caixa, e.alca, c, { proporcional: r.shift, doCentro: r.alt });
1101
+ d && (e.matriz = d, o = I(e.originais, d));
1102
+ break;
1103
+ }
1104
+ case "cisalhamento": {
1105
+ const c = Ht(e.caixa, e.alca, a);
1106
+ c && (e.matriz = c, o = I(e.originais, c));
1107
+ break;
1108
+ }
1109
+ case "rotacao": {
1110
+ const c = Gt(e.pivo, e.inicio, a, r.shift ? Math.PI / 4 : void 0);
1111
+ e.matriz = c.matriz, o = I(e.originais, c.matriz), i.rotulo = { texto: `${Math.round(c.angulo * 180 / Math.PI * 10) / 10}°`, em: a };
1112
+ break;
1113
+ }
1114
+ case "ancora": {
1115
+ const c = ((n = i.edicao) == null ? void 0 : n.ancoras) ?? [];
1116
+ if (c.length > 1 && c.includes(e.indice)) {
1117
+ const d = le(e.original, c, a[0] - e.inicio[0], a[1] - e.inicio[1]);
1118
+ d && (o = [d]);
1119
+ } else {
1120
+ const d = t.snapPonto(a, { excluir: [e.original.id], toque: r.toque, desligado: r.alt }).ponto, h = jt(e.original, e.indice, d);
1121
+ h && (o = [h]);
1122
+ }
1123
+ break;
1124
+ }
1125
+ case "alca-bezier": {
1126
+ const c = Bt(e.original, e.indice, e.qual, a, !r.alt);
1127
+ c && (o = [c]);
1128
+ break;
1129
+ }
1130
+ case "canto": {
1131
+ const c = ge(e.original, e.indice, a);
1132
+ if (c === null) break;
1133
+ const d = qt(e.original, r.alt ? e.indice : null, e.raio0 + c - e.profundidade0);
1134
+ if (d) {
1135
+ o = [d];
1136
+ const h = ((l = pe(d)) == null ? void 0 : l[e.indice]) ?? 0;
1137
+ i.rotulo = { texto: `R ${Math.round(h * 100) / 100} mm`, em: a };
1138
+ }
1139
+ break;
1140
+ }
1141
+ }
1142
+ i.substitutos = new Map(o.map((c) => [c.id, c])), t.agendar();
1143
+ }
1144
+ function di(t, e) {
1145
+ const a = [...t.ui.substitutos.values()];
1146
+ if (t.ui.substitutos = /* @__PURE__ */ new Map(), t.ui.copiasEmGesto = [], t.ui.linhasInteligentes = [], t.ui.snap = null, t.ui.rotulo = null, e.tipo === "mover" && e.duplicar) {
1147
+ if (e.matriz) {
1148
+ const i = I(he(e.originais, t.gerarId), e.matriz);
1149
+ F(t, i, "duplicar"), Ba(t, e.matriz, !0);
1150
+ }
1151
+ t.agendar();
1152
+ return;
1153
+ }
1154
+ if ((e.tipo === "mover" || e.tipo === "escala" || e.tipo === "rotacao" || e.tipo === "cisalhamento") && e.matriz && a.length > 0 && Ba(t, e.matriz, !1), e.tipo === "pivo" || a.length === 0) {
1155
+ t.agendar();
1156
+ return;
1157
+ }
1158
+ const r = e.tipo === "mover" ? "mover" : e.tipo === "ancora" || e.tipo === "alca-bezier" ? "editar-ancoras" : e.tipo === "canto" ? "cantos" : "transformar";
1159
+ (e.tipo === "rotacao" || e.tipo === "escala" || e.tipo === "cisalhamento") && t.ui.pivo && e.tipo !== "rotacao" && (t.ui.pivo = null), t.aplicarSubstituicoes(a, r);
1160
+ }
1161
+ function Ka(t, e, a) {
1162
+ const r = t.ui.edicao, i = r ? t.doc.obter(r.id) : void 0;
1163
+ if (!r || !i) return null;
1164
+ const o = a ? 19 : 6, s = t.vista, n = me(i);
1165
+ for (const d of r.ancoras) {
1166
+ const h = n[d];
1167
+ if (h != null && h.saida && L(s.paraTela(h.saida), e) <= o) return { tipo: "alca", indice: d, qual: "saida" };
1168
+ if (h != null && h.entrada && L(s.paraTela(h.entrada), e) <= o) return { tipo: "alca", indice: d, qual: "entrada" };
1169
+ }
1170
+ const l = xa(i);
1171
+ let c = null;
1172
+ return l.forEach((d, h) => {
1173
+ const u = L(s.paraTela(d), e);
1174
+ u <= o && (!c || u < c.d) && (c = { indice: h, d: u });
1175
+ }), c ? { tipo: "ancora", indice: c.indice } : null;
1176
+ }
1177
+ function hi(t, e, a) {
1178
+ const r = t.ui.edicao, i = r ? t.doc.obter(r.id) : void 0;
1179
+ if (!i) return [];
1180
+ const o = Math.min(e[0], a[0]), s = Math.max(e[0], a[0]), n = Math.min(e[1], a[1]), l = Math.max(e[1], a[1]);
1181
+ return xa(i).map((c, d) => c[0] >= o && c[0] <= s && c[1] >= n && c[1] <= l ? d : -1).filter((c) => c >= 0);
1182
+ }
1183
+ const mi = ["conta-gotas", "adicionar-ancora", "excluir-ancora", "converter-ancora"], fi = (t) => mi.includes(t), ke = (t, e) => (e ? 19 : 8) / t.vista.zoom;
1184
+ function pi(t, e, a) {
1185
+ const r = ke(t, a), i = t.doc.elementosSelecionados(), o = na(e, t.candidatosEm(e, r + 2), { tolerancia: r, camadas: t.camadas });
1186
+ return o && !i.includes(o) ? [...i, o] : i;
1187
+ }
1188
+ function gi(t, e, a) {
1189
+ const r = t.ferramenta, i = ke(t, a);
1190
+ if (r === "conta-gotas") {
1191
+ const o = na(e, t.candidatosEm(e, i + 2), { tolerancia: i, camadas: t.camadas, incluirBloqueados: !0 });
1192
+ return o ? Kr(t, o) : !1;
1193
+ }
1194
+ if (t.somenteLeitura)
1195
+ return t.recusar("editar-ancoras", "somente-leitura"), !1;
1196
+ for (const o of pi(t, e, a)) {
1197
+ if (!t.podeSelecionar(o)) continue;
1198
+ let s = null;
1199
+ if (r === "adicionar-ancora") {
1200
+ const n = Ut(o, e, i);
1201
+ if (n === null) continue;
1202
+ s = Xt(o, n, e);
1203
+ } else {
1204
+ const n = Zt(o, e, i);
1205
+ if (n === null) continue;
1206
+ if (s = r === "excluir-ancora" ? ce(o, n) : Jt(o, n), !s)
1207
+ return t.recusar(r, r === "excluir-ancora" ? "minimo-de-ancoras" : "tipo-nao-suportado", o.id), !1;
1208
+ }
1209
+ return s ? (t.aplicarSubstituicoes([s], "editar-ancoras"), t.doc.selecao.includes(s.id) || t.selecionar([s.id], "substituir", !1), !0) : (t.recusar(r, o.geometria.tipo === "texto" ? "texto-sem-ancoras" : "tipo-nao-suportado", o.id), !1);
1210
+ }
1211
+ return !1;
1212
+ }
1213
+ const vi = 4, Wa = 3;
1214
+ class bi {
1215
+ constructor(e, a, r) {
1216
+ m(this, "gesto", { tipo: "nenhum" });
1217
+ /** Espaço segurado (pan temporário). */
1218
+ m(this, "espaco", !1);
1219
+ m(this, "ultimoClique", null);
1220
+ this.c = e, this.viewport = a, this.ferramentas = r;
1221
+ }
1222
+ conectar(e, a, r) {
1223
+ e.add(this.viewport, "pointerdown", (i) => this.pressionar(i)), e.add(this.viewport, "pointermove", (i) => this.mover(i)), e.add(this.viewport, "pointerup", (i) => this.soltar(i)), e.add(this.viewport, "pointercancel", () => this.cancelar()), e.add(this.viewport, "pointerleave", () => this.sair()), e.add(this.viewport, "wheel", (i) => this.roda(i), { passive: !1 }), e.add(this.viewport, "contextmenu", (i) => {
1224
+ this.ferramentas.emAndamento && i.preventDefault();
1225
+ }), e.add(a, "pointerdown", (i) => this.puxarGuia(i, "horizontal")), e.add(r, "pointerdown", (i) => this.puxarGuia(i, "vertical"));
1226
+ }
1227
+ get ocupado() {
1228
+ return this.gesto.tipo !== "nenhum" || this.ferramentas.emAndamento;
1229
+ }
1230
+ local(e) {
1231
+ var r, i;
1232
+ const a = (i = (r = this.viewport).getBoundingClientRect) == null ? void 0 : i.call(r);
1233
+ return [e.clientX - ((a == null ? void 0 : a.left) ?? 0), e.clientY - ((a == null ? void 0 : a.top) ?? 0)];
1234
+ }
1235
+ mod(e) {
1236
+ return { shift: e.shiftKey, alt: e.altKey, ctrl: e.ctrlKey || e.metaKey, toque: e.pointerType === "touch" };
1237
+ }
1238
+ capturar(e) {
1239
+ var a, r;
1240
+ try {
1241
+ (r = (a = this.viewport).setPointerCapture) == null || r.call(a, e.pointerId);
1242
+ } catch {
1243
+ }
1244
+ }
1245
+ cursor(e) {
1246
+ this.viewport.dataset.cursor !== e && (this.viewport.dataset.cursor = e);
1247
+ }
1248
+ guiaSob(e) {
1249
+ const a = this.c.vista;
1250
+ for (let r = this.c.guias.length - 1; r >= 0; r--) {
1251
+ const i = this.c.guias[r];
1252
+ if ((i.orientacao === "horizontal" ? Math.abs(a.paraTela([0, i.posicao])[1] - e[1]) : Math.abs(a.paraTela([i.posicao, 0])[0] - e[0])) <= vi) return r;
1253
+ }
1254
+ return null;
1255
+ }
1256
+ pressionar(e) {
1257
+ if (e.button === 2) return;
1258
+ try {
1259
+ this.viewport.focus({ preventScroll: !0 });
1260
+ } catch {
1261
+ }
1262
+ const a = this.local(e), r = this.c.vista.paraFolha(a[0], a[1]), i = this.mod(e), o = this.c.ferramenta;
1263
+ if (this.capturar(e), e.button === 1 || this.espaco || o === "mao") {
1264
+ this.gesto = { tipo: "pan", inicioPx: a, panInicial: [...this.c.vista.pan] }, this.cursor("arrastando");
1265
+ return;
1266
+ }
1267
+ if (fi(o)) {
1268
+ gi(this.c, r, i.toque);
1269
+ return;
1270
+ }
1271
+ if (ca(o)) {
1272
+ if (this.c.somenteLeitura) {
1273
+ this.c.recusar("desenhar", "somente-leitura");
1274
+ return;
1275
+ }
1276
+ this.gesto = { tipo: "desenho" }, this.ferramentas.pressionar(r, a, i);
1277
+ return;
1278
+ }
1279
+ const s = Date.now(), n = !i.shift && !!this.ultimoClique && s - this.ultimoClique.t <= 400 && Math.hypot(a[0] - this.ultimoClique.x, a[1] - this.ultimoClique.y) <= 4;
1280
+ if (this.ultimoClique = n ? null : { t: s, x: a[0], y: a[1] }, o === "selecao-direta" && this.c.ui.edicao) {
1281
+ const u = Ka(this.c, a, i.toque), f = this.c.doc.obter(this.c.ui.edicao.id);
1282
+ if (u && f && !this.c.somenteLeitura) {
1283
+ const p = this.c.ui.edicao;
1284
+ u.tipo === "alca" ? this.gesto = { tipo: "selecao", gesto: { tipo: "alca-bezier", original: f, indice: u.indice, qual: u.qual }, inicioPx: a, moveu: !1 } : (i.shift ? p.ancoras = p.ancoras.includes(u.indice) ? p.ancoras.filter((v) => v !== u.indice) : [...p.ancoras, u.indice] : p.ancoras.includes(u.indice) || (p.ancoras = [u.indice]), this.gesto = { tipo: "selecao", gesto: { tipo: "ancora", original: f, indice: u.indice, inicio: r }, inicioPx: a, moveu: !1 }), this.c.agendar();
1285
+ return;
1286
+ }
1287
+ }
1288
+ if (o === "selecao" && !this.c.somenteLeitura) {
1289
+ const u = Va(this.c, a, i.toque);
1290
+ if (u) {
1291
+ const f = si(this.c, u, r, i);
1292
+ if (f) {
1293
+ this.gesto = { tipo: "selecao", gesto: f, inicioPx: a, moveu: !1 };
1294
+ return;
1295
+ }
1296
+ }
1297
+ }
1298
+ const l = (i.toque ? 12 : 4) / this.c.vista.zoom, c = this.c.candidatosEm(r, l + 2).filter((u) => this.c.podeSelecionar(u)), d = na(r, c, { tolerancia: l, camadas: this.c.camadas });
1299
+ if (d) {
1300
+ if (n && o === "selecao") {
1301
+ if (d.grupoId && this.c.isolado !== d.grupoId) {
1302
+ this.c.isolar(d.grupoId), this.c.selecionar([d.id], "substituir", !1);
1303
+ return;
1304
+ }
1305
+ this.c.definirFerramenta("selecao-direta"), this.c.iniciarEdicao(d.id);
1306
+ return;
1307
+ }
1308
+ if (o === "selecao-direta" ? this.c.iniciarEdicao(d.id) : i.shift ? this.c.selecionar([d.id], "alternar") : this.c.doc.selecao.includes(d.id) || this.c.selecionar([d.id]), this.c.somenteLeitura || !this.c.doc.selecao.includes(d.id)) return;
1309
+ const u = ci(this.c, r, i.toque, i.alt && o === "selecao");
1310
+ u && (this.gesto = { tipo: "selecao", gesto: u, inicioPx: a, moveu: !1 });
1311
+ return;
1312
+ }
1313
+ if (n && this.c.isolado) {
1314
+ this.c.isolar(null);
1315
+ return;
1316
+ }
1317
+ const h = o === "selecao" && !this.c.somenteLeitura ? this.guiaSob(a) : null;
1318
+ if (h !== null) {
1319
+ this.gesto = { tipo: "guia", indice: h }, this.c.ui.guiaArrastada = { guia: { ...this.c.guias[h] }, indice: h };
1320
+ return;
1321
+ }
1322
+ this.gesto = { tipo: "caixa", de: r, dePx: a, aditivo: i.shift, moveu: !1 };
1323
+ }
1324
+ mover(e) {
1325
+ const a = this.local(e), r = this.c.vista.paraFolha(a[0], a[1]), i = this.mod(e);
1326
+ this.c.ui.ponteiro = r, this.c.emitir("prancha-ponteiro", { coordenada: r });
1327
+ const o = this.gesto;
1328
+ switch (o.tipo) {
1329
+ case "pan":
1330
+ this.c.vista.pan = [o.panInicial[0] + a[0] - o.inicioPx[0], o.panInicial[1] + a[1] - o.inicioPx[1]], this.c.emitirVista();
1331
+ return;
1332
+ case "desenho":
1333
+ this.ferramentas.mover(r, a, i);
1334
+ return;
1335
+ case "selecao":
1336
+ if (!o.moveu && Math.hypot(a[0] - o.inicioPx[0], a[1] - o.inicioPx[1]) < Wa) return;
1337
+ o.moveu = !0, ui(this.c, o.gesto, r, i);
1338
+ return;
1339
+ case "guia": {
1340
+ const s = this.c.ui.guiaArrastada;
1341
+ s && (s.guia = { ...s.guia, posicao: s.guia.orientacao === "horizontal" ? r[1] : r[0] }), this.c.agendar();
1342
+ return;
1343
+ }
1344
+ case "caixa":
1345
+ if (!o.moveu && Math.hypot(a[0] - o.dePx[0], a[1] - o.dePx[1]) < Wa) return;
1346
+ o.moveu = !0, this.c.ui.caixaSelecao = { de: o.de, ate: r, crossing: r[0] < o.de[0] }, this.c.agendar();
1347
+ return;
1348
+ }
1349
+ if (ca(this.c.ferramenta)) {
1350
+ this.ferramentas.mover(r, a, i), this.cursor("mira");
1351
+ return;
1352
+ }
1353
+ this.atualizarHover(r, a, i.toque);
1354
+ }
1355
+ atualizarHover(e, a, r) {
1356
+ const i = this.c.ferramenta;
1357
+ if (i === "mao" || this.espaco) {
1358
+ this.cursor("mao");
1359
+ return;
1360
+ }
1361
+ const o = i === "selecao" ? Va(this.c, a, r) : null, s = 4 / this.c.vista.zoom, n = na(e, this.c.candidatosEm(e, s + 2).filter((c) => this.c.podeSelecionar(c)), { tolerancia: s, camadas: this.c.camadas }), l = (n == null ? void 0 : n.id) ?? null;
1362
+ this.cursor(o ? o.tipo === "rotacao" ? "girar" : "mover" : i === "selecao-direta" && Ka(this.c, a, r) ? "ancora" : n ? "mover" : "padrao"), l !== this.c.ui.hoverId ? (this.c.ui.hoverId = l, this.c.agendar()) : this.c.ui.ponteiro && this.c.agendar();
1363
+ }
1364
+ soltar(e) {
1365
+ var o, s;
1366
+ const a = this.local(e), r = this.c.vista.paraFolha(a[0], a[1]), i = this.gesto;
1367
+ this.gesto = { tipo: "nenhum" };
1368
+ try {
1369
+ (s = (o = this.viewport).releasePointerCapture) == null || s.call(o, e.pointerId);
1370
+ } catch {
1371
+ }
1372
+ switch (i.tipo) {
1373
+ case "pan":
1374
+ this.cursor(this.espaco || this.c.ferramenta === "mao" ? "mao" : "padrao");
1375
+ return;
1376
+ case "desenho":
1377
+ this.ferramentas.soltar(r, a, this.mod(e));
1378
+ return;
1379
+ case "selecao":
1380
+ i.moveu ? di(this.c, i.gesto) : this.c.agendar();
1381
+ return;
1382
+ case "guia":
1383
+ this.soltarGuia(i.indice, a);
1384
+ return;
1385
+ case "caixa":
1386
+ this.soltarCaixa(i, r);
1387
+ return;
1388
+ default:
1389
+ return;
1390
+ }
1391
+ }
1392
+ soltarCaixa(e, a) {
1393
+ if (this.c.ui.caixaSelecao = null, !e.moveu) {
1394
+ this.c.ui.edicao && this.c.ferramenta === "selecao-direta" && this.c.encerrarEdicao(), e.aditivo || this.c.selecionar([]), this.c.agendar();
1395
+ return;
1396
+ }
1397
+ if (this.c.ferramenta === "selecao-direta" && this.c.ui.edicao) {
1398
+ this.c.ui.edicao.ancoras = hi(this.c, e.de, a), this.c.agendar();
1399
+ return;
1400
+ }
1401
+ const r = { x: Math.min(e.de[0], a[0]), y: Math.min(e.de[1], a[1]), largura: Math.abs(a[0] - e.de[0]), altura: Math.abs(a[1] - e.de[1]) }, i = a[0] < e.de[0] ? "crossing" : "window", o = this.c.doc.indice.consultarCaixa(r).filter((n) => this.c.podeSelecionar(n)), s = Qt(r, o, i, { camadas: this.c.camadas }).map((n) => n.id);
1402
+ this.c.selecionar(s, e.aditivo ? "adicionar" : "substituir") || this.c.agendar();
1403
+ }
1404
+ puxarGuia(e, a) {
1405
+ if (e.button !== 0 || this.c.somenteLeitura) return;
1406
+ const r = this.local(e), i = this.c.vista.paraFolha(r[0], r[1]);
1407
+ this.capturar(e), this.gesto = { tipo: "guia", indice: null }, this.c.ui.guiaArrastada = { guia: { orientacao: a, posicao: a === "horizontal" ? i[1] : i[0] }, indice: null }, this.c.agendar();
1408
+ }
1409
+ soltarGuia(e, a) {
1410
+ const r = this.c.ui.guiaArrastada;
1411
+ if (this.c.ui.guiaArrastada = null, !r) return;
1412
+ const i = r.guia.orientacao === "horizontal" ? a[1] < 0 : a[0] < 0;
1413
+ e === null ? i || (this.c.guias = [...this.c.guias, r.guia]) : i ? this.c.guias = this.c.guias.filter((o, s) => s !== e) : this.c.guias = this.c.guias.map((o, s) => s === e ? r.guia : o), this.c.emitirGuias();
1414
+ }
1415
+ roda(e) {
1416
+ e.preventDefault();
1417
+ const a = this.local(e), r = e.deltaMode === 1 ? e.deltaY * 16 : e.deltaY;
1418
+ if (e.shiftKey && !e.ctrlKey) {
1419
+ this.c.vista.deslocar(-r, 0), this.c.emitirVista();
1420
+ return;
1421
+ }
1422
+ this.c.vista.zoomRelativo(Math.exp(-r * 15e-4), a) && (this.c.emitirVista(), this.c.anunciar(la(this.c.vista.zoomPercentual)));
1423
+ }
1424
+ sair() {
1425
+ this.gesto.tipo === "nenhum" && (this.c.ui.ponteiro = null, this.c.ui.hoverId = null, this.c.ui.snap = null, this.c.emitir("prancha-ponteiro", { coordenada: null }), this.c.agendar());
1426
+ }
1427
+ /** Cancela qualquer gesto (Esc, perda de ponteiro): nada muda no documento. */
1428
+ cancelar() {
1429
+ this.gesto = { tipo: "nenhum" }, this.ferramentas.cancelar(), V(this.c.ui), this.c.agendar();
1430
+ }
1431
+ }
1432
+ function yi(t, e = 50) {
1433
+ if (!(t > 0) || !Number.isFinite(t)) return 1;
1434
+ const a = e / t, r = 10 ** Math.floor(Math.log10(a));
1435
+ for (const i of [1, 2, 5, 10]) if (i * r >= a) return i * r;
1436
+ return 10 * r;
1437
+ }
1438
+ function Ai(t, e) {
1439
+ const { vista: a, cores: r, comprimento: i, espessura: o } = e, s = e.orientacao === "horizontal";
1440
+ t.save(), t.setTransform(a.dpr, 0, 0, a.dpr, 0, 0), t.globalAlpha = 1, t.fillStyle = r.regua, t.fillRect(0, 0, s ? i : o, s ? o : i);
1441
+ const n = 1 / Yt(1, e.unidade), l = a.zoom * n, c = yi(l), d = c / (c * l >= 100 ? 10 : 5), h = (s ? a.pan[0] : a.pan[1]) + e.deslocamento, u = Math.floor(-h / l / d) * d, f = (i - h) / l;
1442
+ t.beginPath();
1443
+ const p = [];
1444
+ for (let v = u, b = 0; v <= f && b < 5e3; v += d, b++) {
1445
+ const M = Math.round(h + v * l) + 0.5, C = Math.abs(v / c - Math.round(v / c)) < 1e-6, T = C ? o : o * 0.3;
1446
+ s ? (t.moveTo(M, o), t.lineTo(M, o - T)) : (t.moveTo(o, M), t.lineTo(o - T, M)), C && p.push([String(Math.round(v * 1e3) / 1e3), M]);
1447
+ }
1448
+ if (t.strokeStyle = r.textoRegua, t.lineWidth = 1, t.setLineDash([]), t.stroke(), typeof t.fillText == "function") {
1449
+ t.font = "9px sans-serif", t.fillStyle = r.textoRegua;
1450
+ for (const [v, b] of p)
1451
+ s ? t.fillText(v, b + 2, 9) : t.fillText(v, 1, b + 10);
1452
+ }
1453
+ if (e.ponteiro) {
1454
+ const v = a.paraTela(e.ponteiro), b = Math.round((s ? v[0] : v[1]) + e.deslocamento) + 0.5;
1455
+ t.beginPath(), s ? (t.moveTo(b, 0), t.lineTo(b, o)) : (t.moveTo(0, b), t.lineTo(o, b)), t.strokeStyle = r.selecao, t.stroke();
1456
+ }
1457
+ t.restore();
1458
+ }
1459
+ const Ua = (t) => {
1460
+ var e;
1461
+ try {
1462
+ return ((e = t.getContext) == null ? void 0 : e.call(t, "2d")) ?? null;
1463
+ } catch {
1464
+ return null;
1465
+ }
1466
+ };
1467
+ class Si {
1468
+ constructor(e, a, r) {
1469
+ m(this, "pedido", null);
1470
+ m(this, "contextos", /* @__PURE__ */ new Map());
1471
+ m(this, "ultimaBase", { elementos: null, texto: "" });
1472
+ m(this, "quadros", 0);
1473
+ m(this, "pinturasBase", 0);
1474
+ this.c = e, this.cv = a, this.fabrica = r;
1475
+ }
1476
+ /** Esquece os contextos (a fábrica mudou) e força a próxima pintura da base. */
1477
+ reiniciar() {
1478
+ this.contextos.clear(), this.ultimaBase = { elementos: null, texto: "" };
1479
+ }
1480
+ ctx(e, a) {
1481
+ return this.contextos.has(e) || this.contextos.set(e, this.fabrica()(a, e)), this.contextos.get(e) ?? null;
1482
+ }
1483
+ agendar() {
1484
+ this.pedido || (typeof requestAnimationFrame == "function" ? this.pedido = { tipo: "raf", id: requestAnimationFrame(() => {
1485
+ this.pedido = null, this.pintar();
1486
+ }) } : typeof setTimeout == "function" && (this.pedido = { tipo: "timeout", id: setTimeout(() => {
1487
+ this.pedido = null, this.pintar();
1488
+ }, 16) }));
1489
+ }
1490
+ cancelar() {
1491
+ this.pedido && (this.pedido.tipo === "raf" && typeof cancelAnimationFrame == "function" ? cancelAnimationFrame(this.pedido.id) : clearTimeout(this.pedido.id), this.pedido = null);
1492
+ }
1493
+ ajustar(e, a, r, i) {
1494
+ const o = Math.max(0, Math.round(a * i)), s = Math.max(0, Math.round(r * i));
1495
+ return e.width === o && e.height === s ? !1 : (e.width = o, e.height = s, !0);
1496
+ }
1497
+ /** Mede a área de desenho; devolve se o tamanho mudou. */
1498
+ medir() {
1499
+ const e = this.c.vista, a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, r = `${e.largura}x${e.altura}@${e.dpr}`;
1500
+ e.redimensionar(this.cv.viewport.clientWidth || 0, this.cv.viewport.clientHeight || 0, a);
1501
+ const i = r !== `${e.largura}x${e.altura}@${e.dpr}`;
1502
+ return i && (this.ultimaBase = { elementos: null, texto: "" }), i;
1503
+ }
1504
+ /** Pinta agora (o que estiver agendado é descartado). */
1505
+ pintar() {
1506
+ this.cancelar(), this.quadros++;
1507
+ const e = this.c, a = e.vista;
1508
+ if (a.largura <= 0 || a.altura <= 0) return;
1509
+ const r = this.ajustar(this.cv.base, a.largura, a.altura, a.dpr);
1510
+ this.ajustar(this.cv.sobreposicao, a.largura, a.altura, a.dpr);
1511
+ const i = e.elementosVisiveis(), o = [
1512
+ a.zoom,
1513
+ a.pan[0],
1514
+ a.pan[1],
1515
+ a.largura,
1516
+ a.altura,
1517
+ a.dpr,
1518
+ e.folha.largura,
1519
+ e.folha.altura,
1520
+ e.mostrarGrade ? e.grade : 0,
1521
+ Object.values(e.cores).join(),
1522
+ JSON.stringify(e.camadas),
1523
+ e.isolado ?? "",
1524
+ JSON.stringify(e.margens)
1525
+ ].join("|"), s = this.ctx("base", this.cv.base);
1526
+ if (s && (r || i !== this.ultimaBase.elementos || o !== this.ultimaBase.texto)) {
1527
+ try {
1528
+ const l = e.isolado ? i.filter((c) => c.grupoId === e.isolado) : null;
1529
+ ri(s, { vista: a, folha: e.folha, cores: e.cores, elementos: i, grade: e.mostrarGrade ? e.grade : null, camadas: e.camadas, isolados: l, margens: e.margens ? ve(e.folha.largura, e.folha.altura, e.margens) : null }), this.pinturasBase++;
1530
+ } catch {
1531
+ }
1532
+ this.ultimaBase = { elementos: i, texto: o };
1533
+ }
1534
+ const n = this.ctx("sobreposicao", this.cv.sobreposicao);
1535
+ if (n)
1536
+ try {
1537
+ const l = e.ui.hoverId ? e.doc.obter(e.ui.hoverId) ?? null : null, c = e.doc.elementosSelecionados().map((d) => e.ui.substitutos.get(d.id) ?? d);
1538
+ ii(n, { vista: a, cores: e.cores, ui: e.ui, selecionados: c, emGesto: e.elementosEmGesto(), hover: l, guias: e.guias, caixaTransformacao: e.ferramenta === "selecao", marcasCantos: Le(e) });
1539
+ } catch {
1540
+ }
1541
+ this.pintarReguas();
1542
+ }
1543
+ pintarReguas() {
1544
+ const e = this.c;
1545
+ for (const [a, r, i] of [["regua-horizontal", this.cv.reguaH, "horizontal"], ["regua-vertical", this.cv.reguaV, "vertical"]]) {
1546
+ const o = i === "horizontal" ? r.clientWidth : r.clientHeight, s = i === "horizontal" ? r.clientHeight : r.clientWidth;
1547
+ if (!(o > 0 && s > 0)) continue;
1548
+ this.ajustar(r, i === "horizontal" ? o : s, i === "horizontal" ? s : o, e.vista.dpr);
1549
+ const n = this.ctx(a, r);
1550
+ if (n)
1551
+ try {
1552
+ Ai(n, { orientacao: i, vista: e.vista, unidade: e.unidade, comprimento: o, espessura: s, cores: e.cores, ponteiro: e.ui.ponteiro, deslocamento: 0 });
1553
+ } catch {
1554
+ }
1555
+ }
1556
+ }
1557
+ }
1558
+ function q(t, e) {
1559
+ if (!ar.includes(e))
1560
+ return t.recusar("pathfinder", "comando-desconhecido"), !1;
1561
+ const a = y(t, "pathfinder", 2);
1562
+ if (!a) return !1;
1563
+ const r = er(U(a, t.camadas), e);
1564
+ if (!("ok" in r)) {
1565
+ const n = r.motivo === "sem-intersecao" || r.motivo === "resultado-vazio";
1566
+ return t.recusar("pathfinder", n ? "resultado-vazio" : "tipo-nao-suportado"), !1;
1567
+ }
1568
+ const { resultado: i, usados: o } = r.ok, s = new Set(o.filter((n) => n !== i.id));
1569
+ return t.aplicar(t.doc.elementos.filter((n) => !s.has(n.id)).map((n) => n.id === i.id ? i : n), "pathfinder"), t.selecionar([i.id]), !0;
1570
+ }
1571
+ const qe = /* @__PURE__ */ new WeakSet(), Xa = /* @__PURE__ */ new WeakSet(), bo = (t) => !!t && qe.has(t);
1572
+ function Pi(t) {
1573
+ qe.add(t);
1574
+ }
1575
+ const j = (t) => t === "exclusivo" || t === "isolado" || t === "modal" ? t : "local";
1576
+ function Be(t) {
1577
+ if (!t || typeof t != "object") return !1;
1578
+ const e = typeof t.key == "string" ? t.key : "";
1579
+ if (e === "F5" || e === "F11" || e === "F12" || e === "Tab") return !0;
1580
+ if (!(t.ctrlKey || t.metaKey) || t.altKey) return !1;
1581
+ const r = e.length === 1 ? e.toLowerCase() : e;
1582
+ return !!(t.shiftKey && (r === "i" || r === "j") || r === "r" || r === "l" || r === "w" || r === "t" || (r === "+" || r === "=" || r === "-" || r === "0") && !t.defaultPrevented);
1583
+ }
1584
+ const je = ["keydown", "keyup", "keypress"];
1585
+ function Mi(t, e) {
1586
+ const a = typeof t.composedPath == "function" ? t.composedPath() : [];
1587
+ return a.includes(e) ? !0 : a.length === 0 && typeof Node < "u" && e instanceof Node && t.target instanceof Node && e.contains(t.target);
1588
+ }
1589
+ function zi(t, e) {
1590
+ if (typeof Node > "u" || !(t instanceof Node)) return !1;
1591
+ let a = e;
1592
+ for (; a; ) {
1593
+ if (a === t) return !0;
1594
+ a = a.parentNode ?? (typeof ShadowRoot < "u" && a instanceof ShadowRoot ? a.host : null);
1595
+ }
1596
+ return !1;
1597
+ }
1598
+ function xi(t, e) {
1599
+ if (be(t)) return !0;
1600
+ const a = br();
1601
+ return !!a && yr(a) && !zi(e, a);
1602
+ }
1603
+ function Ge(t, e, a) {
1604
+ if (!(!t || !e || typeof a != "function"))
1605
+ for (const r of je)
1606
+ t.add(e, r, (i) => {
1607
+ a() && !Be(i) && i.stopPropagation();
1608
+ });
1609
+ }
1610
+ function He(t, e, a) {
1611
+ if (!(typeof window > "u" || !t || !e || typeof a != "function"))
1612
+ for (const r of je)
1613
+ t.add(window, r, (i) => {
1614
+ var o;
1615
+ !i || !a() || Mi(i, e) || Be(i) || xi(i, e) || (o = i.stopPropagation) == null || o.call(i);
1616
+ }, { capture: !0 });
1617
+ }
1618
+ const Za = { Digit1: "uniao", Digit2: "subtracao", Digit3: "intersecao", Digit4: "exclusao" }, Ja = {
1619
+ v: "selecao",
1620
+ a: "selecao-direta",
1621
+ h: "mao",
1622
+ m: "retangulo",
1623
+ l: "elipse",
1624
+ p: "caneta",
1625
+ "\\": "linha",
1626
+ t: "texto"
1627
+ };
1628
+ function Ei(t, e, a, r) {
1629
+ if (r.defaultPrevented || be(r)) return !1;
1630
+ const i = r.key, o = r.ctrlKey || r.metaKey, s = i.length === 1 ? i.toLowerCase() : i;
1631
+ if (i === " " && !o)
1632
+ return Ra(r) ? !1 : (e.espaco || (e.espaco = !0, t.agendar()), !0);
1633
+ if (e.ferramentas.tecla(i)) return !0;
1634
+ if (o) {
1635
+ if (r.shiftKey && !r.altKey && (s === "i" || s === "j")) return !1;
1636
+ const l = r.code ?? "";
1637
+ return r.altKey && r.shiftKey && l in Za ? q(t, Za[l]) || !0 : l === "BracketRight" || i === "]" || i === "}" ? O(t, r.shiftKey ? "frente" : "avancar") || !0 : l === "BracketLeft" || i === "[" || i === "{" ? O(t, r.shiftKey ? "tras" : "recuar") || !0 : s === "g" ? (r.shiftKey ? we(t) : Te(t)) || !0 : l === "Digit2" || i === "2" ? (r.altKey ? da(t, "bloqueado") : ua(t, "bloqueado")) || !0 : l === "Digit3" || i === "3" ? (r.altKey ? da(t, "oculto") : ua(t, "oculto")) || !0 : l === "Digit7" || i === "7" ? (r.altKey ? Ne(t) : _e(t)) || !0 : s === "c" && !r.shiftKey ? Da(t) || !0 : s === "x" ? Ie(t) || !0 : s === "v" ? Fe(t, r.shiftKey) || !0 : s === "d" ? De(t) || !0 : s === "j" ? Oe(t) || !0 : s === "z" && !r.shiftKey ? (t.desfazer(), !0) : s === "z" && r.shiftKey || s === "y" ? (t.refazer(), !0) : s === "a" ? (xe(t), !0) : i === "0" ? (a.ajustarFolha(), !0) : i === "1" ? (a.definirZoomPercentual(100), !0) : i === "=" || i === "+" ? (t.vista.zoomRelativo(1.25), t.emitirVista(), t.anunciar(la(t.vista.zoomPercentual)), !0) : i === "-" ? (t.vista.zoomRelativo(0.8), t.emitirVista(), t.anunciar(la(t.vista.zoomPercentual)), !0) : !1;
1638
+ }
1639
+ if (r.altKey && (i === "=" || i === "+")) return Pa(t, 1.1, 1.1, void 0, "teclado") || !0;
1640
+ if (r.altKey && i === "-") return Pa(t, 0.9, 0.9, void 0, "teclado") || !0;
1641
+ if (i.startsWith("Arrow")) {
1642
+ if (e.ocupado) return !0;
1643
+ const l = t.passoTeclado * (r.shiftKey ? 10 : 1), c = i === "ArrowLeft" ? -l : i === "ArrowRight" ? l : 0, d = i === "ArrowUp" ? -l : i === "ArrowDown" ? l : 0;
1644
+ if (t.ui.edicao && t.ui.edicao.ancoras.length > 0) Nr(t, c, d, "teclado-ancoras");
1645
+ else if (t.doc.selecao.length > 0) Pe(t, c, d, "teclado", "teclado-mover");
1646
+ else return !1;
1647
+ return !0;
1648
+ }
1649
+ if (i === "Delete" || i === "Backspace") {
1650
+ if (t.ui.edicao && t.ui.edicao.ancoras.length > 0) Or(t);
1651
+ else if (t.doc.selecao.length > 0) ze(t);
1652
+ else return !1;
1653
+ return !0;
1654
+ }
1655
+ if (i === "Escape")
1656
+ return e.ocupado ? (e.cancelar(), !0) : t.ui.edicao ? (t.encerrarEdicao(), !0) : t.isolado ? (t.isolar(null), !0) : t.doc.selecao.length > 0 ? (t.selecionar([]), !0) : (Xa.has(r) || (Xa.add(r), t.emitir("prancha-esc-sem-efeito", {})), !1);
1657
+ if (i === "Enter")
1658
+ return Ra(r) ? !1 : ca(t.ferramenta) ? e.ferramentas.criarNoCentro() || !0 : t.doc.selecao.length === 1 && !t.ui.edicao ? (t.definirFerramenta("selecao-direta"), t.iniciarEdicao(t.doc.selecao[0]) || !0) : !1;
1659
+ if (i === "PageDown" || i === "PageUp") return _r(t, i === "PageDown" ? 1 : -1) || !0;
1660
+ if (s === "r" && !r.altKey) return Me(t, r.shiftKey ? -15 : 15, void 0, "teclado") || !0;
1661
+ const n = r.altKey ? null : s === "i" && !r.shiftKey ? "conta-gotas" : i === "+" || i === "=" ? "adicionar-ancora" : i === "-" ? "excluir-ancora" : s === "c" && r.shiftKey ? "converter-ancora" : null;
1662
+ return n ? (e.ocupado && e.cancelar(), t.definirFerramenta(n), !0) : !r.altKey && !r.shiftKey && Ja[s] ? (e.ocupado && e.cancelar(), t.definirFerramenta(Ja[s]), !0) : !1;
1663
+ }
1664
+ function Ci(t, e, a) {
1665
+ a.key === " " && e.espaco && (e.espaco = !1, t.agendar());
1666
+ }
1667
+ const $e = [
1668
+ "selecao",
1669
+ "selecao-direta",
1670
+ "mao",
1671
+ "retangulo",
1672
+ "elipse",
1673
+ "poligono-regular",
1674
+ "estrela",
1675
+ "linha",
1676
+ "seta",
1677
+ "polilinha",
1678
+ "poligono",
1679
+ "caneta",
1680
+ "texto",
1681
+ // Fase 4
1682
+ "conta-gotas",
1683
+ "adicionar-ancora",
1684
+ "excluir-ancora",
1685
+ "converter-ancora"
1686
+ ];
1687
+ function Ve(t) {
1688
+ return typeof t == "string" && $e.includes(t);
1689
+ }
1690
+ const Ti = "prancha:comando", wi = [
1691
+ "definirFerramenta",
1692
+ "selecionarElementos",
1693
+ "alternarSelecaoElemento",
1694
+ "limparSelecao",
1695
+ "selecionarTudo",
1696
+ "desfazer",
1697
+ "refazer",
1698
+ "moverSelecao",
1699
+ "girarSelecao",
1700
+ "escalarSelecao",
1701
+ "espelharSelecao",
1702
+ "transformarSelecao",
1703
+ "removerSelecao",
1704
+ "definirRaiosCantos",
1705
+ "inserirPredefinicao",
1706
+ "ajustarFolha",
1707
+ "ajustarSelecao",
1708
+ "definirZoom",
1709
+ "aproximar",
1710
+ "afastar",
1711
+ "deslocarVista",
1712
+ "definirGuias",
1713
+ "adicionarGuia",
1714
+ "removerGuia",
1715
+ "definirSnap",
1716
+ "editarAncoras",
1717
+ "concluirEdicao",
1718
+ "definirOpcoesFerramentas",
1719
+ // Fase 4
1720
+ "definirCamadas",
1721
+ "definirCamadaAtiva",
1722
+ "moverSelecaoParaCamada",
1723
+ "isolarGrupo",
1724
+ "ordenarSelecao",
1725
+ "trazerParaFrente",
1726
+ "enviarParaTras",
1727
+ "avancar",
1728
+ "recuar",
1729
+ "agruparSelecao",
1730
+ "desagruparSelecao",
1731
+ "bloquearSelecao",
1732
+ "ocultarSelecao",
1733
+ "desbloquearTudo",
1734
+ "mostrarTudo",
1735
+ "alinharSelecao",
1736
+ "distribuirSelecao",
1737
+ "duplicarSelecao",
1738
+ "transformarDeNovo",
1739
+ "copiar",
1740
+ "recortar",
1741
+ "colar",
1742
+ "aplicarAparencia",
1743
+ "criarMascara",
1744
+ "liberarMascara",
1745
+ "unirSelecao",
1746
+ "dividirSelecao",
1747
+ "deslocarCaminho",
1748
+ "simplificarSelecao",
1749
+ "contornarTraco",
1750
+ "converterEmCaminho",
1751
+ // Fase 5
1752
+ "pathfinder",
1753
+ "unirFormas",
1754
+ "subtrairFrente",
1755
+ "intersectarFormas",
1756
+ "excluirSobreposicao",
1757
+ // Fase 6
1758
+ "aplicarPropriedade",
1759
+ "alterarElementos"
1760
+ ];
1761
+ function Di(t) {
1762
+ return typeof t == "string" && wi.includes(t);
1763
+ }
1764
+ function Ii(t, e) {
1765
+ return ye.on(Ti, (a) => {
1766
+ !a || typeof a != "object" || a.alvo !== void 0 && a.alvo !== t.id || e(a.comando, Array.isArray(a.args) ? a.args : []);
1767
+ });
1768
+ }
1769
+ const Ke = [
1770
+ "largura",
1771
+ "altura",
1772
+ "unidade",
1773
+ "grade",
1774
+ "mostrar-grade",
1775
+ "sem-reguas",
1776
+ "sem-snap",
1777
+ "sem-guias-inteligentes",
1778
+ "ferramenta",
1779
+ "rotulo",
1780
+ "somente-leitura",
1781
+ "passo-teclado",
1782
+ "margens",
1783
+ "teclado",
1784
+ "ajustar-ao-abrir"
1785
+ ];
1786
+ function We(t) {
1787
+ if (!t) return null;
1788
+ const e = t.trim().split(/[\s,;]+/).map((a) => parseFloat(a.replace(",", ".")));
1789
+ return e.length !== 1 && e.length !== 4 || !e.every((a) => Number.isFinite(a) && a >= 0 && a <= 1e5) ? null : e.length === 1 ? { esquerda: e[0], direita: e[0], superior: e[0], inferior: e[0] } : { esquerda: e[0], direita: e[1], superior: e[2], inferior: e[3] };
1790
+ }
1791
+ const Qa = (t) => t === "conteudo" || t === "nenhum" ? t : "folha", ra = (t, e, a, r) => {
1792
+ const i = t === null ? NaN : parseFloat(t.replace(",", "."));
1793
+ return Number.isFinite(i) && i >= a && i <= r ? i : e;
1794
+ };
1795
+ function Fi(t, e, a) {
1796
+ switch (e) {
1797
+ case "largura": {
1798
+ const r = ra(a, 210, 1, 1e5), i = r !== t.folha.largura;
1799
+ return t.folha = { ...t.folha, largura: r }, i;
1800
+ }
1801
+ case "altura": {
1802
+ const r = ra(a, 297, 1, 1e5), i = r !== t.folha.altura;
1803
+ return t.folha = { ...t.folha, altura: r }, i;
1804
+ }
1805
+ case "unidade":
1806
+ t.unidade = a && tr(a) ? a : "mm";
1807
+ break;
1808
+ case "grade":
1809
+ t.grade = ra(a, 10, 0.1, 1e4);
1810
+ break;
1811
+ case "mostrar-grade":
1812
+ t.mostrarGrade = a !== null && a !== "false";
1813
+ break;
1814
+ case "sem-snap":
1815
+ t.snapLigado = a === null || a === "false";
1816
+ break;
1817
+ case "sem-guias-inteligentes":
1818
+ t.guiasInteligentes = a === null || a === "false";
1819
+ break;
1820
+ case "ferramenta":
1821
+ t.definirFerramenta(a && Ve(a) ? a : "selecao");
1822
+ break;
1823
+ case "somente-leitura":
1824
+ t.somenteLeitura = a !== null && a !== "false";
1825
+ break;
1826
+ case "passo-teclado":
1827
+ t.passoTeclado = ra(a, 1, 1e-3, 1e3);
1828
+ break;
1829
+ case "margens":
1830
+ t.margens = We(a);
1831
+ break;
1832
+ }
1833
+ return t.agendar(), !1;
1834
+ }
1835
+ const Ya = 100, _i = 4e3;
1836
+ function Ni(t) {
1837
+ let e;
1838
+ const a = /* @__PURE__ */ new Map();
1839
+ return (r, i, o) => {
1840
+ var l;
1841
+ if (e === void 0)
1842
+ try {
1843
+ const c = (l = t()) == null ? void 0 : l.getContext("2d");
1844
+ e = c && typeof c.measureText == "function" ? c : null;
1845
+ } catch {
1846
+ e = null;
1847
+ }
1848
+ if (!e) return null;
1849
+ const s = `${i}\0${r}`;
1850
+ let n = a.get(s);
1851
+ if (n === void 0) {
1852
+ try {
1853
+ e.font = `${Ya}px ${i}`;
1854
+ const c = e.measureText(r).width;
1855
+ n = Number.isFinite(c) && c >= 0 ? c / Ya : null;
1856
+ } catch {
1857
+ n = null;
1858
+ }
1859
+ a.size >= _i && a.clear(), a.set(s, n);
1860
+ }
1861
+ return n === null ? null : n * o;
1862
+ };
1863
+ }
1864
+ function Oi() {
1865
+ if (rr() || typeof document > "u") return !1;
1866
+ const t = Ni(() => document.createElement("canvas"));
1867
+ return t("M", "sans-serif", 1) === null ? !1 : (ir(t), !0);
1868
+ }
1869
+ class Ri extends Ae {
1870
+ constructor() {
1871
+ super();
1872
+ m(this, "shadow");
1873
+ m(this, "bag", new Ta());
1874
+ m(this, "c");
1875
+ m(this, "interacao");
1876
+ m(this, "render");
1877
+ m(this, "viewport");
1878
+ m(this, "status");
1879
+ m(this, "observador", null);
1880
+ m(this, "desligarBus", []);
1881
+ m(this, "ponteiroSobre", !1);
1882
+ m(this, "focoDentro", !1);
1883
+ m(this, "enquadrou", !1);
1884
+ m(this, "_fabrica", Ua);
1885
+ m(this, "revisaoSalva", 0);
1886
+ m(this, "_modificado", !1);
1887
+ m(this, "conteudoEnquadrado", !1);
1888
+ m(this, "_pronto");
1889
+ m(this, "resolverPronto", null);
1890
+ m(this, "fimPronto", 0);
1891
+ m(this, "carregando", !1);
1892
+ this.shadow = this.attachShadow({ mode: "open" }), this.shadow.innerHTML = Pr();
1893
+ const a = (r) => this.shadow.getElementById(r);
1894
+ this.viewport = a("viewport"), this.status = a("status"), this.c = new Ir({
1895
+ emitir: (r, i, o) => {
1896
+ const s = new CustomEvent(r, { detail: i, bubbles: !0, composed: !0, cancelable: !!o });
1897
+ return this.dispatchEvent(s), s.defaultPrevented;
1898
+ },
1899
+ agendar: () => {
1900
+ var r;
1901
+ return (r = this.render) == null ? void 0 : r.agendar();
1902
+ },
1903
+ anunciar: (r) => Dr(this.status, r)
1904
+ }), this._pronto = new Promise((r) => {
1905
+ this.resolverPronto = r;
1906
+ }), this.c.doc.ouvirMudancas(() => this.avaliarModificado()), this.interacao = new bi(this.c, this.viewport, new Gr(this.c)), this.render = new Si(this.c, {
1907
+ viewport: this.viewport,
1908
+ base: a("camada-base"),
1909
+ sobreposicao: a("camada-sobreposicao"),
1910
+ reguaH: a("regua-h"),
1911
+ reguaV: a("regua-v")
1912
+ }, () => this._fabrica);
1913
+ }
1914
+ static get observedAttributes() {
1915
+ return Ke;
1916
+ }
1917
+ connectedCallback() {
1918
+ var a;
1919
+ this.bag.cleanup(), this.interacao.conectar(this.bag, this.shadow.getElementById("regua-h"), this.shadow.getElementById("regua-v")), Ge(this.bag, this, () => {
1920
+ const r = this.modoTeclado();
1921
+ return r === "isolado" || r === "modal";
1922
+ }), He(this.bag, this, () => this.modoTeclado() === "modal" && !this.hospedadaNoEditor()), this.bag.add(this, "pointerenter", () => {
1923
+ this.ponteiroSobre = !0;
1924
+ }), this.bag.add(this, "pointerleave", () => {
1925
+ this.ponteiroSobre = !1;
1926
+ }), this.bag.add(this, "focusin", () => {
1927
+ this.focoDentro = !0;
1928
+ }), this.bag.add(this, "focusout", () => {
1929
+ this.focoDentro = !1;
1930
+ }), this.bag.add(this.viewport, "keydown", (r) => this.tecla(r, !0)), typeof window < "u" && (this.bag.add(window, "keydown", (r) => {
1931
+ const i = this.modoTeclado();
1932
+ i === "exclusivo" ? this.tecla(r, !0, !0) : (i === "isolado" || i === "modal") && this.noEscopoDoTeclado(r) && this.tecla(r, !1, !0);
1933
+ }, { capture: !0 }), this.bag.add(window, "keydown", (r) => this.tecla(r)), this.bag.add(window, "keyup", (r) => Ci(this.c, this.interacao, r), { capture: !0 }), this.bag.add(window, "blur", () => {
1934
+ this.interacao.espaco = !1;
1935
+ })), typeof ResizeObserver == "function" && ((a = this.observador) == null || a.disconnect(), this.observador = new ResizeObserver(() => this.redimensionar()), this.observador.observe(this.viewport)), this.desligarBus.forEach((r) => r()), this.desligarBus = [
1936
+ Ii(this, (r, i) => this.executarComando(r, i)),
1937
+ ye.on("tema:alterado", () => this.atualizarCores())
1938
+ ], Oi() && this.c.doc.indice.definir(this.c.doc.elementos), this.atualizarCores(), this.atualizarRotulo(), this.c.margens = We(this.getAttribute("margens")), this.redimensionar(), this.prepararPronto();
1939
+ }
1940
+ disconnectedCallback() {
1941
+ var a;
1942
+ this.fimPronto && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(this.fimPronto), this.fimPronto = 0, this.bag.cleanup(), (a = this.observador) == null || a.disconnect(), this.observador = null, this.desligarBus.forEach((r) => r()), this.desligarBus = [], this.interacao.cancelar(), this.render.cancelar();
1943
+ }
1944
+ attributeChangedCallback(a, r, i) {
1945
+ if (a === "rotulo") {
1946
+ this.atualizarRotulo();
1947
+ return;
1948
+ }
1949
+ if (a === "teclado") return;
1950
+ Fi(this.c, a, i) && !this.enquadrou && this.ajustarFolha();
1951
+ }
1952
+ /** Resolve `pronto` quando a área de desenho foi medida; sem layout (teste, aba oculta), dois quadros depois. */
1953
+ prepararPronto() {
1954
+ if (this.resolverPronto) {
1955
+ if (this.c.vista.largura > 0) {
1956
+ this.concluirPronto();
1957
+ return;
1958
+ }
1959
+ typeof requestAnimationFrame == "function" && !this.fimPronto ? this.fimPronto = requestAnimationFrame(() => {
1960
+ this.fimPronto = requestAnimationFrame(() => {
1961
+ this.fimPronto = 0, this.concluirPronto();
1962
+ });
1963
+ }) : typeof requestAnimationFrame != "function" && this.concluirPronto();
1964
+ }
1965
+ }
1966
+ concluirPronto() {
1967
+ const a = this.resolverPronto;
1968
+ a && (this.resolverPronto = null, a(), this.dispatchEvent(new CustomEvent("prancha-pronta", { bubbles: !0, composed: !0, detail: {} })));
1969
+ }
1970
+ atualizarRotulo() {
1971
+ this.viewport.setAttribute("aria-label", this.getAttribute("rotulo") || "Prancha");
1972
+ }
1973
+ atualizarCores() {
1974
+ this.c.cores = Er(this), this.render.reiniciar(), this.c.agendar();
1975
+ }
1976
+ redimensionar() {
1977
+ if (this.render.medir(), !this.enquadrou && this.c.vista.largura > 0) {
1978
+ const a = Qa(this.getAttribute("ajustar-ao-abrir"));
1979
+ a === "conteudo" && this.c.doc.elementos.length > 0 ? (this.ajustarElementos(), this.conteudoEnquadrado = !0) : a !== "nenhum" && this.c.vista.enquadrar({ x: 0, y: 0, largura: this.c.folha.largura, altura: this.c.folha.altura }), this.enquadrou = !0;
1980
+ }
1981
+ this.render.pintar(), this.prepararPronto();
1982
+ }
1983
+ /** Modo do atributo `teclado`: `local` (padrão), `exclusivo`, `isolado` ou `modal`. */
1984
+ modoTeclado() {
1985
+ return j(this.getAttribute("teclado"));
1986
+ }
1987
+ hospedadaNoEditor() {
1988
+ const a = this.getRootNode(), r = a == null ? void 0 : a.host;
1989
+ return !!r && r.localName === "ui-editor-prancha";
1990
+ }
1991
+ tecladoExclusivo() {
1992
+ return this.modoTeclado() === "exclusivo";
1993
+ }
1994
+ /** O evento veio de dentro desta prancha ou do editor (outro componente) que a contém? */
1995
+ noEscopoDoTeclado(a) {
1996
+ const r = this.getRootNode().host, i = typeof a.composedPath == "function" ? a.composedPath() : [];
1997
+ return i.includes(this) || !!r && i.includes(r);
1998
+ }
1999
+ tecla(a, r = !1, i = !1) {
2000
+ !r && !this.focoDentro && !this.ponteiroSobre || !i && a.defaultPrevented && this.tecladoExclusivo() || Ei(this.c, this.interacao, { ajustarFolha: () => this.ajustarFolha(), definirZoomPercentual: (o) => this.definirZoom(o) }, a) && (a.preventDefault(), a.stopPropagation(), i && a.stopImmediatePropagation(), Pi(a));
2001
+ }
2002
+ // ---------- modificado, revisão e ciclo de vida ----------
2003
+ /** O documento mudou desde a carga (`definirElementos`) ou desde `marcarComoSalvo()`. */
2004
+ get modificado() {
2005
+ return this._modificado;
2006
+ }
2007
+ /** Contador de mudanças do documento (carga, edição, desfazer/refazer, renomear). */
2008
+ get revisao() {
2009
+ return this.c.doc.revisao;
2010
+ }
2011
+ /** Registra o estado atual como o salvo: `modificado` volta a `false` (e `prancha-modificado` só emite na transição). */
2012
+ marcarComoSalvo() {
2013
+ this.revisaoSalva = this.c.doc.revisao, this.avaliarModificado();
2014
+ }
2015
+ avaliarModificado() {
2016
+ if (this.carregando) return;
2017
+ const a = this.c.doc.revisao !== this.revisaoSalva;
2018
+ a !== this._modificado && (this._modificado = a, this.c.emitir("prancha-modificado", { modificado: a, revisao: this.c.doc.revisao }));
2019
+ }
2020
+ /**
2021
+ * Resolve quando a área de desenho foi medida e a prancha consegue enquadrar (ou, sem layout, dois quadros depois da
2022
+ * conexão). Também emite `prancha-pronta` uma vez.
2023
+ */
2024
+ get pronto() {
2025
+ return this._pronto;
2026
+ }
2027
+ /** Dá o foco à área de desenho (o `focus()` do host entrega o foco ao viewport, onde o teclado da prancha escuta). */
2028
+ focus(a) {
2029
+ this.viewport.focus(a);
2030
+ }
2031
+ // ---------- propriedades ----------
2032
+ /** Modo do teclado: `local` (padrão), `exclusivo`, `isolado` ou `modal`. */
2033
+ get teclado() {
2034
+ return this.modoTeclado();
2035
+ }
2036
+ set teclado(a) {
2037
+ this.setAttribute("teclado", j(a));
2038
+ }
2039
+ /** Ferramenta ativa. */
2040
+ get ferramenta() {
2041
+ return this.c.ferramenta;
2042
+ }
2043
+ set ferramenta(a) {
2044
+ this.definirFerramenta(a);
2045
+ }
2046
+ /** Elementos do documento (na ordem de empilhamento). */
2047
+ get elementos() {
2048
+ return [...this.c.doc.elementos];
2049
+ }
2050
+ /** Ids selecionados. */
2051
+ get selecao() {
2052
+ return [...this.c.doc.selecao];
2053
+ }
2054
+ get podeDesfazer() {
2055
+ return this.c.doc.historico.podeDesfazer;
2056
+ }
2057
+ get podeRefazer() {
2058
+ return this.c.doc.historico.podeRefazer;
2059
+ }
2060
+ /** Id provisório dos elementos criados pelo usuário (o app pode trocar por um gerador próprio). */
2061
+ get gerarId() {
2062
+ return this.c.gerarId;
2063
+ }
2064
+ set gerarId(a) {
2065
+ typeof a == "function" && (this.c.gerarId = a);
2066
+ }
2067
+ /** Fábrica do contexto 2D de cada canvas (padrão `getContext('2d')`); serve para pintar com um contexto próprio ou de teste. */
2068
+ get fabricaContexto() {
2069
+ return this._fabrica;
2070
+ }
2071
+ set fabricaContexto(a) {
2072
+ this._fabrica = typeof a == "function" ? a : Ua, this.render.reiniciar(), this.c.agendar();
2073
+ }
2074
+ // ---------- dados (sincronização do app: não emite prancha-elemento-*) ----------
2075
+ /** Carrega o documento (normaliza; recomeça o histórico e a seleção). Devolve os recusados. */
2076
+ definirElementos(a) {
2077
+ this.carregando = !0;
2078
+ const r = (() => {
2079
+ try {
2080
+ return this.c.doc.definir(a);
2081
+ } finally {
2082
+ this.carregando = !1;
2083
+ }
2084
+ })();
2085
+ return this.c.ui.edicao = null, this.c.emitirHistorico(), this.marcarComoSalvo(), !this.conteudoEnquadrado && this.enquadrou && Qa(this.getAttribute("ajustar-ao-abrir")) === "conteudo" && r.elementos.length > 0 && (this.conteudoEnquadrado = !0, this.ajustarElementos()), this.c.agendar(), { aceitos: r.elementos.length, recusados: r.recusados };
2086
+ }
2087
+ /** Lote de mudanças do app (adicionar, atualizar, remover) de uma vez. */
2088
+ aplicarLote(a, r = {}) {
2089
+ const { resultado: i } = this.c.doc.aplicarLote(a, r.historico !== !1);
2090
+ return this.c.emitirHistorico(), this.c.agendar(), i;
2091
+ }
2092
+ adicionarElemento(a, r) {
2093
+ return this.aplicarLote({ adicionar: [a] }, r).adicionados.length === 1;
2094
+ }
2095
+ atualizarElemento(a, r) {
2096
+ return this.aplicarLote({ atualizar: [a] }, r).atualizados.length === 1;
2097
+ }
2098
+ removerElemento(a, r) {
2099
+ return this.aplicarLote({ remover: [a] }, r).removidos.length === 1;
2100
+ }
2101
+ obterElementos() {
2102
+ return this.elementos;
2103
+ }
2104
+ obterElemento(a) {
2105
+ return this.c.doc.obter(a) ?? null;
2106
+ }
2107
+ /** Troca o id provisório pelo definitivo em tudo (documento, seleção e histórico). */
2108
+ renomearElemento(a, r) {
2109
+ var o;
2110
+ const i = this.c.doc.renomear(a, r);
2111
+ return i && ((o = this.c.ui.edicao) == null ? void 0 : o.id) === a && (this.c.ui.edicao.id = r), i;
2112
+ }
2113
+ // ---------- seleção e ferramentas ----------
2114
+ selecionarElementos(a) {
2115
+ return this.c.selecionar(Array.isArray(a) ? a : []);
2116
+ }
2117
+ alternarSelecaoElemento(a) {
2118
+ return this.c.selecionar([a], "alternar");
2119
+ }
2120
+ limparSelecao() {
2121
+ return this.c.selecionar([]);
2122
+ }
2123
+ selecionarTudo() {
2124
+ return xe(this.c);
2125
+ }
2126
+ obterSelecao() {
2127
+ return this.c.doc.elementosSelecionados();
2128
+ }
2129
+ definirFerramenta(a) {
2130
+ this.interacao.cancelar(), this.c.definirFerramenta(Ve(a) ? a : "selecao");
2131
+ }
2132
+ definirOpcoesFerramentas(a) {
2133
+ this.c.opcoesFerramentas = a && typeof a == "object" ? { ...a } : {};
2134
+ }
2135
+ obterOpcoesFerramentas() {
2136
+ return { ...this.c.opcoesFerramentas };
2137
+ }
2138
+ /** Entra na seleção direta (âncoras) do elemento. */
2139
+ editarAncoras(a) {
2140
+ const r = typeof a == "string" ? this.c.doc.obter(a) : void 0;
2141
+ return r ? r.bloqueado || r.geometria.tipo === "texto" ? this.c.iniciarEdicao(a) : (this.c.definirFerramenta("selecao-direta"), this.c.iniciarEdicao(a)) : (this.c.recusar("editar-ancoras", "id-invalido", typeof a == "string" ? a : void 0), !1);
2142
+ }
2143
+ concluirEdicao() {
2144
+ this.c.encerrarEdicao();
2145
+ }
2146
+ // ---------- histórico e comandos sobre a seleção (emitem prancha-elemento-*) ----------
2147
+ desfazer() {
2148
+ return this.c.desfazer();
2149
+ }
2150
+ refazer() {
2151
+ return this.c.refazer();
2152
+ }
2153
+ moverSelecao(a, r) {
2154
+ return Pe(this.c, a, r);
2155
+ }
2156
+ girarSelecao(a, r) {
2157
+ return Me(this.c, a, r);
2158
+ }
2159
+ escalarSelecao(a, r, i) {
2160
+ return Pa(this.c, a, r ?? a, i);
2161
+ }
2162
+ espelharSelecao(a) {
2163
+ return Fr(this.c, a);
2164
+ }
2165
+ transformarSelecao(a) {
2166
+ return aa(this.c, or(a));
2167
+ }
2168
+ removerSelecao() {
2169
+ return ze(this.c);
2170
+ }
2171
+ /** Raios dos cantos dos retângulos selecionados, em mm (número = os quatro; ou [sup. esq., sup. dir., inf. dir., inf. esq.]). */
2172
+ definirRaiosCantos(a) {
2173
+ return Ee(this.c, a);
2174
+ }
2175
+ /**
2176
+ * Insere uma pré-definição (moldura, seta...) e a deixa selecionada. Sem `caixa`: com `opcoes.quadro: 'margens'` (e o
2177
+ * atributo `margens`), o quadro das margens; senão, uma caixa no CENTRO DA ÁREA VISÍVEL, de tamanho proporcional ao zoom
2178
+ * (cerca de 35% da largura e 25% da altura visíveis, limitada à folha), para a forma nascer à vista.
2179
+ */
2180
+ inserirPredefinicao(a, r, i = {}) {
2181
+ if (!sr(a))
2182
+ return this.c.recusar("inserir-predefinicao", "geometria-invalida"), [];
2183
+ const { quadro: o, ...s } = i ?? {}, n = r ?? (o === "margens" && this.c.margens ? ve(this.c.folha.largura, this.c.folha.altura, this.c.margens) : null) ?? this.caixaNaVista(), l = nr(a, n, { ...s, id: s.id ?? this.c.gerarId(a) });
2184
+ return F(this.c, l, "predefinicao");
2185
+ }
2186
+ /** Caixa (mm) no centro da área visível, proporcional ao zoom e dentro da folha; sem vista medida, 60 × 40 mm no centro da folha. */
2187
+ caixaNaVista() {
2188
+ const a = this.c.folha, r = this.c.vista;
2189
+ let i = 0, o = 0, s = a.largura, n = a.altura;
2190
+ if (r.largura > 0 && r.altura > 0) {
2191
+ const v = r.paraFolha(0, 0), b = r.paraFolha(r.largura, r.altura), M = Math.max(0, v[0]), C = Math.max(0, v[1]), T = Math.min(a.largura, b[0]), P = Math.min(a.altura, b[1]);
2192
+ T > M && P > C && (i = M, o = C, s = T, n = P);
2193
+ }
2194
+ const l = (s - i) * (r.largura > 0 ? 0.35 : 0.3), c = (n - o) * (r.largura > 0 ? 0.25 : 0.15), d = Math.max(1, Math.min(l, a.largura)), h = Math.max(1, Math.min(c, a.altura)), u = r.largura > 0 && r.altura > 0 ? r.paraFolha(r.largura / 2, r.altura / 2) : [(i + s) / 2, (o + n) / 2], f = Math.min(a.largura, Math.max(0, u[0])), p = Math.min(a.altura, Math.max(0, u[1]));
2195
+ return { x: f - d / 2, y: p - h / 2, largura: d, altura: h };
2196
+ }
2197
+ // ---------- vista ----------
2198
+ ajustarFolha() {
2199
+ this.render.medir(), this.c.vista.enquadrar({ x: 0, y: 0, largura: this.c.folha.largura, altura: this.c.folha.altura }) && (this.enquadrou = !0), this.c.emitirVista();
2200
+ }
2201
+ ajustarSelecao() {
2202
+ const a = this.c.doc.elementosSelecionados();
2203
+ if (a.length === 0) {
2204
+ this.c.recusar("ajustar-selecao", "sem-selecao");
2205
+ return;
2206
+ }
2207
+ const r = Na(a);
2208
+ r && this.c.vista.enquadrar(r, 48) && this.c.emitirVista();
2209
+ }
2210
+ /**
2211
+ * Enquadra os elementos (os `ids`, ou todos) SEM mexer na seleção, com teto de zoom (`zoomMaximo`, em %: um elemento
2212
+ * pequeno não é ampliado absurdamente). Devolve se enquadrou.
2213
+ */
2214
+ ajustarElementos(a, r = {}) {
2215
+ const i = Array.isArray(a) ? a.map((c) => this.c.doc.obter(c)).filter((c) => !!c) : [...this.c.doc.elementos], o = Na(i);
2216
+ if (!o) return !1;
2217
+ const s = Number.isFinite(r == null ? void 0 : r.margem) && r.margem >= 0 ? r.margem : 48, n = Number.isFinite(r == null ? void 0 : r.zoomMaximo) && r.zoomMaximo > 0 ? r.zoomMaximo : 800;
2218
+ if (!this.c.vista.enquadrar(o, s)) return !1;
2219
+ const l = n / 100 * W;
2220
+ return this.c.vista.zoom > l && this.c.vista.definirZoomCentrado(l, o), this.c.emitirVista(), !0;
2221
+ }
2222
+ /** Zoom em % (100% = tamanho real a 96 dpi), no centro da vista. */
2223
+ definirZoom(a) {
2224
+ this.c.vista.definirZoom(a / 100 * W) && (this.c.emitirVista(), this.c.anunciar(la(this.c.vista.zoomPercentual)));
2225
+ }
2226
+ aproximar() {
2227
+ this.definirZoom(this.c.vista.zoomPercentual * 1.25);
2228
+ }
2229
+ afastar() {
2230
+ this.definirZoom(this.c.vista.zoomPercentual * 0.8);
2231
+ }
2232
+ deslocarVista(a, r) {
2233
+ this.c.vista.deslocar(a, r) && this.c.emitirVista();
2234
+ }
2235
+ obterVista() {
2236
+ const a = this.c.vista;
2237
+ return { zoom: a.zoom, zoomPercentual: a.zoomPercentual, pan: [a.pan[0], a.pan[1]] };
2238
+ }
2239
+ /** Ponto da área de desenho (px CSS) → folha (mm), e o inverso. */
2240
+ paraFolha(a, r) {
2241
+ return this.c.vista.paraFolha(a, r);
2242
+ }
2243
+ paraTela(a) {
2244
+ return this.c.vista.paraTela(a);
2245
+ }
2246
+ // ---------- guias e snap ----------
2247
+ definirGuias(a) {
2248
+ this.c.guias = (Array.isArray(a) ? a : []).filter((r) => r && (r.orientacao === "horizontal" || r.orientacao === "vertical") && Number.isFinite(r.posicao)).map((r) => ({ ...r })), this.c.emitirGuias();
2249
+ }
2250
+ adicionarGuia(a) {
2251
+ this.definirGuias([...this.c.guias, a]);
2252
+ }
2253
+ removerGuia(a) {
2254
+ this.definirGuias(this.c.guias.filter((r, i) => i !== a));
2255
+ }
2256
+ obterGuias() {
2257
+ return this.c.guias.map((a) => ({ ...a }));
2258
+ }
2259
+ definirSnap(a) {
2260
+ this.toggleAttribute("sem-snap", !a);
2261
+ }
2262
+ // ---------- exportação ----------
2263
+ /** SVG da folha com os elementos (o mesmo plano de pintura da tela). */
2264
+ exportarSvg(a = {}) {
2265
+ return lr(this.c.doc.elementos, { largura: this.c.folha.largura, altura: this.c.folha.altura, fundo: "#ffffff", ...a });
2266
+ }
2267
+ /** Pinta os elementos num contexto próprio (ex.: o PDF vetorial do app) com o mesmo código da tela. */
2268
+ desenharEm(a, r = {}) {
2269
+ return $(a, this.c.doc.elementos, r);
2270
+ }
2271
+ /** Mede e pinta agora (sem esperar o próximo quadro). */
2272
+ renderizarAgora() {
2273
+ this.render.medir(), this.render.pintar();
2274
+ }
2275
+ /** Executa um comando público pelo nome (o mesmo que o `ui-bus` usa). Comando desconhecido emite `prancha-recusa`. */
2276
+ executarComando(a, r = []) {
2277
+ if (!Di(a)) {
2278
+ this.c.recusar("executar-comando", "comando-desconhecido");
2279
+ return;
2280
+ }
2281
+ const i = this[a];
2282
+ try {
2283
+ return i.apply(this, Array.isArray(r) ? r : []);
2284
+ } catch {
2285
+ this.c.recusar(a, "geometria-invalida");
2286
+ return;
2287
+ }
2288
+ }
2289
+ }
2290
+ const ae = (t) => {
2291
+ const e = typeof t == "string" && t.trim() !== "" ? Number(t.replace(",", ".")) : t;
2292
+ return typeof e == "number" && Number.isFinite(e) ? e : null;
2293
+ };
2294
+ function Li(t) {
2295
+ let e = 1 / 0, a = 1 / 0, r = -1 / 0, i = -1 / 0;
2296
+ for (const o of t) {
2297
+ const s = Y(o);
2298
+ s && (e = Math.min(e, s.x), a = Math.min(a, s.y), r = Math.max(r, s.x + s.largura), i = Math.max(i, s.y + s.altura));
2299
+ }
2300
+ return Number.isFinite(e) ? { x: e, y: a, largura: r - e, altura: i - a } : null;
2301
+ }
2302
+ function ki(t, e, a) {
2303
+ const r = Li(t);
2304
+ if (!r) return null;
2305
+ let i = null;
2306
+ if (e === "geometria.x") i = k(a - r.x, 0);
2307
+ else if (e === "geometria.y") i = k(0, a - r.y);
2308
+ else if (e === "geometria.largura" && a > 0 && r.largura > 0) i = H(a / r.largura, 1, [r.x, r.y]);
2309
+ else if (e === "geometria.altura" && a > 0 && r.altura > 0) i = H(1, a / r.altura, [r.x, r.y]);
2310
+ else if (e === "geometria.rotacao")
2311
+ return t.map((o) => {
2312
+ const s = Y(o);
2313
+ if (!s) return o;
2314
+ const n = (a - hr(o)) * Math.PI / 180;
2315
+ return ue(o, za(n, [s.x + s.largura / 2, s.y + s.altura / 2]));
2316
+ });
2317
+ return i ? I(t, i) : null;
2318
+ }
2319
+ function qi(t, e, a) {
2320
+ if (t.somenteLeitura)
2321
+ return t.recusar("propriedade", "somente-leitura"), !1;
2322
+ if (!cr(e))
2323
+ return t.recusar("propriedade", "comando-desconhecido"), !1;
2324
+ const r = t.doc.elementosSelecionados();
2325
+ if (r.length === 0)
2326
+ return t.recusar("propriedade", "sem-selecao"), !1;
2327
+ const i = e === "elemento.bloqueado" || e === "elemento.oculto" ? r : r.filter((s) => !t.mapa().travado(s));
2328
+ if (i.length === 0)
2329
+ return t.recusar("propriedade", "bloqueado"), !1;
2330
+ if (e === "geometria.raio") {
2331
+ const s = ae(a);
2332
+ return s === null || s < 0 ? (t.recusar("propriedade", "geometria-invalida"), !1) : Ee(t, s);
2333
+ }
2334
+ let o;
2335
+ if (ur(e)) {
2336
+ const s = ae(a);
2337
+ o = s === null ? null : ki(i, e, s);
2338
+ } else {
2339
+ const s = i.map((n) => dr(n, e, a));
2340
+ o = s.every((n) => n !== null) ? s : null;
2341
+ }
2342
+ return o ? (t.aplicarSubstituicoes(o, "propriedades", `propriedade:${e}`), !0) : (t.recusar("propriedade", "geometria-invalida"), !1);
2343
+ }
2344
+ function Bi(t, e, a) {
2345
+ if (t.somenteLeitura)
2346
+ return t.recusar("alterar", "somente-leitura"), !1;
2347
+ if (!a || typeof a != "object" || !Array.isArray(e))
2348
+ return t.recusar("alterar", "geometria-invalida"), !1;
2349
+ const r = e.map((o) => typeof o == "string" ? t.doc.obter(o) : void 0).filter((o) => !!o);
2350
+ if (r.length === 0 || a.camadaId !== void 0 && a.camadaId !== null && !t.camadas.some((o) => o.id === a.camadaId))
2351
+ return t.recusar("alterar", "id-invalido"), !1;
2352
+ const i = r.map((o) => {
2353
+ const s = { ...o };
2354
+ a.nome !== void 0 && (typeof a.nome == "string" && a.nome.trim() !== "" ? s.nome = a.nome : delete s.nome);
2355
+ for (const n of ["oculto", "bloqueado"])
2356
+ typeof a[n] == "boolean" && (a[n] ? s[n] = !0 : delete s[n]);
2357
+ return a.camadaId !== void 0 && (a.camadaId ? s.camadaId = a.camadaId : delete s.camadaId), s;
2358
+ });
2359
+ return t.aplicarSubstituicoes(i, "propriedades"), !0;
2360
+ }
2361
+ const ji = {
2362
+ retangulo: "Retângulo",
2363
+ elipse: "Elipse",
2364
+ "poligono-regular": "Polígono",
2365
+ estrela: "Estrela",
2366
+ linha: "Linha",
2367
+ caminho: "Caminho",
2368
+ texto: "Texto"
2369
+ }, Ue = (t) => {
2370
+ var e;
2371
+ return ji[(e = t == null ? void 0 : t.geometria) == null ? void 0 : e.tipo] ?? "Elemento";
2372
+ }, Gi = {
2373
+ normal: "Normal",
2374
+ multiplicar: "Multiplicar",
2375
+ tela: "Tela",
2376
+ sobrepor: "Sobrepor",
2377
+ escurecer: "Escurecer",
2378
+ clarear: "Clarear",
2379
+ "subexposicao-cor": "Subexposição de cores",
2380
+ "superexposicao-cor": "Superexposição de cores",
2381
+ "luz-dura": "Luz direta",
2382
+ "luz-suave": "Luz indireta",
2383
+ diferenca: "Diferença",
2384
+ exclusao: "Exclusão",
2385
+ matiz: "Matiz",
2386
+ saturacao: "Saturação",
2387
+ cor: "Cor",
2388
+ luminosidade: "Luminosidade"
2389
+ }, Hi = {
2390
+ continua: "Contínua",
2391
+ tracejada: "Tracejada",
2392
+ "tracejada-curta": "Tracejada curta",
2393
+ "tracejada-longa": "Tracejada longa",
2394
+ pontilhada: "Pontilhada",
2395
+ "traco-ponto": "Traço-ponto"
2396
+ }, J = (t) => t.map(([e, a]) => ({ id: e, rotulo: a })), ee = J([["nenhuma", "Nenhuma"], ["triangulo", "Triângulo"], ["triangulo-aberto", "Triângulo vazado"], ["aberta", "Aberta"], ["circulo", "Círculo"], ["quadrado", "Quadrado"], ["losango", "Losango"], ["barra", "Barra"]]);
2397
+ function g(t, e, a, r, i = {}) {
2398
+ const o = t.map((l) => fr(l, e)).filter((l) => l !== void 0);
2399
+ if (o.length === 0) return null;
2400
+ const s = (l) => JSON.stringify(l);
2401
+ return o.every((l) => s(l) === s(o[0])) && o[0] !== null ? { id: e, rotulo: a, tipo: r, valor: o[0], ...i } : { id: e, rotulo: a, tipo: r, valor: null, misto: !0, ...i };
2402
+ }
2403
+ const w = { unidade: "mm", casasDecimais: 2, passo: 0.5 }, ia = { unidade: "%", casasDecimais: 0, passo: 5, min: 0, max: 100 }, B = (t) => t.filter((e) => e !== null);
2404
+ function $i(t) {
2405
+ let e = 1 / 0, a = 1 / 0, r = -1 / 0, i = -1 / 0;
2406
+ for (const n of t) {
2407
+ const l = Y(n);
2408
+ l && (e = Math.min(e, l.x), a = Math.min(a, l.y), r = Math.max(r, l.x + l.largura), i = Math.max(i, l.y + l.altura));
2409
+ }
2410
+ const o = (n) => Math.round(n * 1e6) / 1e6, s = Number.isFinite(e) ? [
2411
+ { id: "geometria.x", rotulo: "X", tipo: "numero", valor: o(e), ...w },
2412
+ { id: "geometria.y", rotulo: "Y", tipo: "numero", valor: o(a), ...w },
2413
+ { id: "geometria.largura", rotulo: "Largura", tipo: "numero", valor: o(r - e), ...w, min: 0 },
2414
+ { id: "geometria.altura", rotulo: "Altura", tipo: "numero", valor: o(i - a), ...w, min: 0 }
2415
+ ] : [];
2416
+ return s.push(g(t, "geometria.rotacao", "Rotação", "numero", { unidade: "°", casasDecimais: 2, passo: 15 })), t.every((n) => n.geometria.tipo === "retangulo") && s.push(g(t, "geometria.raio", "Raio dos cantos", "numero", { ...w, min: 0 })), B(s);
2417
+ }
2418
+ const N = (t) => String(Math.round(t * 100) / 100).replace(".", ",");
2419
+ function Vi(t) {
2420
+ const e = t && Number.isFinite(t.largura) && Number.isFinite(t.altura) ? t : null, a = [{ id: "dica", rotulo: "Seleção", tipo: "readonly", valor: "Nada selecionado", dica: "Selecione um elemento para editar: clique nele ou arraste um retângulo de seleção." }];
2421
+ if (e) {
2422
+ a.push({ id: "folha.tamanho", rotulo: "Folha", tipo: "readonly", valor: `${N(e.largura)} × ${N(e.altura)} mm` }), e.unidade && a.push({ id: "folha.unidade", rotulo: "Unidade", tipo: "readonly", valor: e.unidade }), Number.isFinite(e.grade) && a.push({ id: "folha.grade", rotulo: "Grade", tipo: "readonly", valor: `${N(e.grade)} mm` });
2423
+ const r = e.margens;
2424
+ r && a.push({ id: "folha.margens", rotulo: "Margens", tipo: "readonly", valor: `${N(r.esquerda)} / ${N(r.direita)} / ${N(r.superior)} / ${N(r.inferior)} mm`, dica: "esquerda / direita / superior / inferior" });
2425
+ }
2426
+ return [{ id: "folha", titulo: "Folha", aberto: !0, propriedades: a }];
2427
+ }
2428
+ function Ki(t) {
2429
+ const e = Array.isArray(t) ? t.filter((l) => l && typeof l == "object" && l.geometria) : [];
2430
+ if (e.length === 0) return [];
2431
+ const a = e.filter((l) => l.geometria.tipo === "texto"), r = e.filter((l) => {
2432
+ var c;
2433
+ return l.geometria.tipo !== "texto" && ((c = Ca(l)) == null ? void 0 : c.tipo) === "Polygon";
2434
+ }), i = e.length > a.length, o = e.length === 1 ? Ue(e[0]) : `${e.length} elementos`, s = [
2435
+ {
2436
+ id: "elemento",
2437
+ titulo: "Elemento",
2438
+ aberto: !0,
2439
+ propriedades: B([
2440
+ { id: "elemento.tipo", rotulo: "Tipo", tipo: "readonly", valor: o },
2441
+ g(e, "elemento.nome", "Nome", "texto"),
2442
+ g(e, "elemento.bloqueado", "Bloqueado", "booleano"),
2443
+ g(e, "elemento.oculto", "Oculto", "booleano")
2444
+ ])
2445
+ },
2446
+ { id: "geometria", titulo: "Posição e tamanho", aberto: !0, propriedades: $i(e) }
2447
+ ];
2448
+ if (i) {
2449
+ const l = e.filter((c) => c.geometria.tipo !== "texto");
2450
+ s.push({
2451
+ id: "traco",
2452
+ titulo: "Traço",
2453
+ aberto: !0,
2454
+ propriedades: B([
2455
+ g(l, "traco.ativo", "Com traço", "booleano"),
2456
+ g(l, "traco.cor", "Cor", "cor"),
2457
+ g(l, "traco.espessura", "Espessura", "numero", { ...w, passo: 0.05, min: 0 }),
2458
+ g(l, "traco.opacidade", "Opacidade", "numero", ia),
2459
+ g(l, "traco.tipoLinha", "Tipo de linha", "linha", { opcoes: vr.map((c) => ({ id: c, rotulo: Hi[c] ?? c })) }),
2460
+ g(l, "traco.escalaTipoLinha", "Escala da linha", "numero", { casasDecimais: 2, passo: 0.1, min: 0 }),
2461
+ g(l, "traco.terminacao", "Terminação", "selecao", { opcoes: J([["reta", "Reta"], ["arredondada", "Arredondada"], ["quadrada", "Quadrada"]]) }),
2462
+ g(l, "traco.juncao", "Junção", "selecao", { opcoes: J([["angular", "Angular"], ["arredondada", "Arredondada"], ["chanfrada", "Chanfrada"]]) }),
2463
+ r.length === l.length ? g(l, "traco.alinhamento", "Alinhamento", "selecao", { opcoes: J([["centro", "Centro"], ["dentro", "Dentro"], ["fora", "Fora"]]) }) : null,
2464
+ r.length === 0 ? g(l, "traco.pontaInicio", "Ponta inicial", "selecao", { opcoes: ee }) : null,
2465
+ r.length === 0 ? g(l, "traco.pontaFim", "Ponta final", "selecao", { opcoes: ee }) : null
2466
+ ])
2467
+ });
2468
+ }
2469
+ return [...r, ...a].length === e.length && s.push({
2470
+ id: "preenchimento",
2471
+ titulo: "Preenchimento",
2472
+ aberto: !0,
2473
+ propriedades: B([
2474
+ g(e, "preenchimento.ativo", "Com preenchimento", "booleano"),
2475
+ g(e, "preenchimento.cor", "Cor", "cor"),
2476
+ g(e, "preenchimento.opacidade", "Opacidade", "numero", ia),
2477
+ a.length === 0 ? g(e, "preenchimento.regra", "Regra", "selecao", { opcoes: J([["nonzero", "Diferente de zero"], ["evenodd", "Par-ímpar"]]) }) : null
2478
+ ])
2479
+ }), r.length === e.length && s.push({
2480
+ id: "hachura",
2481
+ titulo: "Hachura",
2482
+ aberto: !1,
2483
+ propriedades: B([
2484
+ g(e, "hachura.ativa", "Com hachura", "booleano"),
2485
+ g(e, "hachura.angulo", "Ângulo", "numero", { unidade: "°", casasDecimais: 1, passo: 15 }),
2486
+ g(e, "hachura.espacamento", "Espaçamento", "numero", { ...w, min: 0.1 }),
2487
+ g(e, "hachura.cor", "Cor", "cor"),
2488
+ g(e, "hachura.cruzada", "Cruzada", "booleano")
2489
+ ])
2490
+ }), s.push({
2491
+ id: "efeitos",
2492
+ titulo: "Efeitos",
2493
+ aberto: !1,
2494
+ propriedades: B([
2495
+ g(e, "efeitos.opacidade", "Opacidade", "numero", ia),
2496
+ g(e, "efeitos.mesclagem", "Mesclagem", "selecao", { opcoes: mr.map((l) => ({ id: l, rotulo: Gi[l] })) }),
2497
+ g(e, "sombra.ativa", "Sombra", "booleano"),
2498
+ g(e, "sombra.dx", "Sombra X", "numero", w),
2499
+ g(e, "sombra.dy", "Sombra Y", "numero", w),
2500
+ g(e, "sombra.desfoque", "Desfoque", "numero", { ...w, min: 0 }),
2501
+ g(e, "sombra.cor", "Cor da sombra", "cor"),
2502
+ g(e, "sombra.opacidade", "Opacidade da sombra", "numero", ia)
2503
+ ])
2504
+ }), s.filter((l) => l.propriedades.length > 0);
2505
+ }
2506
+ const G = "prancha:sem-camada", te = (t) => typeof t == "string" && t !== G ? t : null;
2507
+ function Wi(t, e = [], a = {}) {
2508
+ const r = Array.isArray(t) ? t.filter((u) => u && typeof u == "object" && u.geometria) : [], i = Array.isArray(e) ? e.filter((u) => u && typeof u.id == "string") : [], o = new Set(i.map((u) => u.id)), s = i.length === 0 && ((a == null ? void 0 : a.ocultarSemCamada) === !0 || (a == null ? void 0 : a.modo) === "simples"), n = (u) => u.camadaId && o.has(u.camadaId) ? u.camadaId : s ? "" : G, l = /* @__PURE__ */ new Map();
2509
+ for (const u of r) l.set(n(u), (l.get(n(u)) ?? 0) + 1);
2510
+ const c = [];
2511
+ !s && (l.has(G) || i.length === 0) && c.push({ id: G, name: "Sem camada", visible: !0, locked: !1, opacity: 1, order: 0, count: l.get(G) ?? 0 });
2512
+ for (const u of [...i].reverse())
2513
+ c.push({
2514
+ id: u.id,
2515
+ name: u.nome ?? u.id,
2516
+ visible: u.visivel !== !1,
2517
+ locked: u.bloqueada === !0,
2518
+ opacity: typeof u.opacidade == "number" && Number.isFinite(u.opacidade) ? Math.min(1, Math.max(0, u.opacidade)) : 1,
2519
+ order: c.length,
2520
+ count: l.get(u.id) ?? 0
2521
+ });
2522
+ const d = /* @__PURE__ */ new Map(), h = [...U(r, i)].reverse().map((u) => {
2523
+ var C, T, P;
2524
+ const f = Ue(u);
2525
+ let p = u.nome;
2526
+ if (!p) {
2527
+ const _ = (d.get(f) ?? 0) + 1;
2528
+ d.set(f, _), p = `${f} ${_}`;
2529
+ }
2530
+ const b = u.geometria.tipo === "texto" ? "Text" : ((C = Ca(u)) == null ? void 0 : C.tipo) === "Polygon" ? "Polygon" : "LineString";
2531
+ let M;
2532
+ try {
2533
+ const _ = pr(u);
2534
+ M = ((T = _.preenchimento) == null ? void 0 : T.cor) ?? ((P = _.traco) == null ? void 0 : P.cor);
2535
+ } catch {
2536
+ M = void 0;
2537
+ }
2538
+ return { id: u.id, name: p, layerId: n(u), type: b, geometryType: b, visible: u.oculto !== !0, locked: u.bloqueado === !0, color: M };
2539
+ });
2540
+ return { camadas: c, feicoes: h };
2541
+ }
2542
+ function Ui(t, e, a) {
2543
+ const r = Array.isArray(t) ? t : [];
2544
+ return !a || typeof a != "object" ? [...r] : r.map((i) => {
2545
+ if (i.id !== e) return i;
2546
+ const o = { ...i };
2547
+ return typeof a.visivel == "boolean" && (o.visivel = a.visivel), typeof a.bloqueada == "boolean" && (o.bloqueada = a.bloqueada), typeof a.opacidade == "number" && Number.isFinite(a.opacidade) && (o.opacidade = Math.min(1, Math.max(0, a.opacidade))), typeof a.nome == "string" && a.nome.trim() !== "" && (o.nome = a.nome), o;
2548
+ });
2549
+ }
2550
+ function Xi(t, e) {
2551
+ const a = Array.isArray(t) ? t : [], r = new Map(a.map((n) => [n.id, n])), i = /* @__PURE__ */ new Set(), o = [];
2552
+ for (const n of Array.isArray(e) ? e : []) {
2553
+ const l = typeof n == "string" ? r.get(n) : void 0;
2554
+ l && !i.has(l.id) && (i.add(l.id), o.push(l));
2555
+ }
2556
+ return [...a.filter((n) => !i.has(n.id)), ...o.reverse()];
2557
+ }
2558
+ class Zi extends Ri {
2559
+ static get observedAttributes() {
2560
+ return Ke;
2561
+ }
2562
+ // ---------- camadas e isolamento ----------
2563
+ /** Camadas da prancha (a primeira fica atrás). Elementos sem camada ficam por cima. */
2564
+ definirCamadas(e) {
2565
+ this.c.definirCamadas(e);
2566
+ }
2567
+ obterCamadas() {
2568
+ return this.c.camadas.map((e) => ({ ...e }));
2569
+ }
2570
+ /** Camada que recebe os elementos novos (desenhados, colados, pré-definições); `null` = sem camada. */
2571
+ definirCamadaAtiva(e) {
2572
+ this.c.camadaAtiva = typeof e == "string" && this.c.camadas.some((a) => a.id === e) ? e : null;
2573
+ }
2574
+ moverSelecaoParaCamada(e) {
2575
+ return Ur(this.c, e);
2576
+ }
2577
+ /** Isola um grupo (só os membros se selecionam) ou sai do isolamento com `null`. */
2578
+ isolarGrupo(e) {
2579
+ this.c.isolar(e);
2580
+ }
2581
+ // ---------- ordem, grupos, bloquear e ocultar ----------
2582
+ ordenarSelecao(e) {
2583
+ return O(this.c, e);
2584
+ }
2585
+ trazerParaFrente() {
2586
+ return O(this.c, "frente");
2587
+ }
2588
+ enviarParaTras() {
2589
+ return O(this.c, "tras");
2590
+ }
2591
+ avancar() {
2592
+ return O(this.c, "avancar");
2593
+ }
2594
+ recuar() {
2595
+ return O(this.c, "recuar");
2596
+ }
2597
+ agruparSelecao() {
2598
+ return Te(this.c);
2599
+ }
2600
+ desagruparSelecao() {
2601
+ return we(this.c);
2602
+ }
2603
+ bloquearSelecao() {
2604
+ return ua(this.c, "bloqueado");
2605
+ }
2606
+ ocultarSelecao() {
2607
+ return ua(this.c, "oculto");
2608
+ }
2609
+ desbloquearTudo() {
2610
+ return da(this.c, "bloqueado");
2611
+ }
2612
+ mostrarTudo() {
2613
+ return da(this.c, "oculto");
2614
+ }
2615
+ // ---------- alinhar, distribuir, duplicar ----------
2616
+ /** Alinha à seleção, à folha, ao primeiro selecionado (`'chave'`) ou a uma caixa em mm (as margens, o quadro). */
2617
+ alinharSelecao(e, a = "selecao") {
2618
+ return Hr(this.c, e, a);
2619
+ }
2620
+ /** Distribui centros ou espaços (iguais, ou `espacamento` fixo em mm). */
2621
+ distribuirSelecao(e, a = "espacos", r) {
2622
+ return $r(this.c, e, a, r);
2623
+ }
2624
+ duplicarSelecao(e) {
2625
+ return Vr(this.c, e);
2626
+ }
2627
+ /** Ctrl+D: repete a última transformação (duplicando, se ela foi uma cópia). */
2628
+ transformarDeNovo() {
2629
+ return De(this.c);
2630
+ }
2631
+ // ---------- área de transferência e aparência ----------
2632
+ copiar() {
2633
+ return Da(this.c);
2634
+ }
2635
+ recortar() {
2636
+ return Ie(this.c);
2637
+ }
2638
+ /** Cola deslocado a cada colagem, ou no mesmo lugar (`noLugar`). */
2639
+ colar(e = !1) {
2640
+ return Fe(this.c, e);
2641
+ }
2642
+ aplicarAparencia(e) {
2643
+ return Wr(this.c, e);
2644
+ }
2645
+ // ---------- máscara e operações de caminho ----------
2646
+ criarMascara() {
2647
+ return _e(this.c);
2648
+ }
2649
+ liberarMascara() {
2650
+ return Ne(this.c);
2651
+ }
2652
+ unirSelecao(e) {
2653
+ return Oe(this.c, e);
2654
+ }
2655
+ dividirSelecao() {
2656
+ return Xr(this.c);
2657
+ }
2658
+ /** Deslocar caminho (offset): cria um contorno novo a `distancia` mm (negativo = para dentro). */
2659
+ deslocarCaminho(e) {
2660
+ return Zr(this.c, e);
2661
+ }
2662
+ simplificarSelecao(e) {
2663
+ return Jr(this.c, e);
2664
+ }
2665
+ contornarTraco() {
2666
+ return Qr(this.c);
2667
+ }
2668
+ converterEmCaminho() {
2669
+ return Yr(this.c);
2670
+ }
2671
+ // ---------- Pathfinder (Fase 5) ----------
2672
+ /**
2673
+ * Operação booleana sobre a seleção: `'uniao'`, `'subtracao'` (o mais atrás menos os outros), `'intersecao'` ou
2674
+ * `'exclusao'`. O resultado é um caminho composto com o id e a aparência do mais à frente (na subtração, do mais atrás).
2675
+ */
2676
+ pathfinder(e) {
2677
+ return q(this.c, e);
2678
+ }
2679
+ /** Ctrl+Alt+Shift+1. */
2680
+ unirFormas() {
2681
+ return q(this.c, "uniao");
2682
+ }
2683
+ /** Ctrl+Alt+Shift+2 ("menos frente"). */
2684
+ subtrairFrente() {
2685
+ return q(this.c, "subtracao");
2686
+ }
2687
+ /** Ctrl+Alt+Shift+3. */
2688
+ intersectarFormas() {
2689
+ return q(this.c, "intersecao");
2690
+ }
2691
+ /** Ctrl+Alt+Shift+4. */
2692
+ excluirSobreposicao() {
2693
+ return q(this.c, "exclusao");
2694
+ }
2695
+ // ---------- painéis (Fase 6) ----------
2696
+ /**
2697
+ * Categorias para o `<ui-tabela-propriedades>` com a seleção atual. Sem seleção: a categoria "Folha" (tamanho, unidade,
2698
+ * grade, margens, somente leitura) com a dica "Selecione um elemento para editar", em vez de um painel vazio.
2699
+ */
2700
+ categoriasDePropriedades() {
2701
+ const e = this.c.doc.elementosSelecionados();
2702
+ return e.length > 0 ? Ki(e) : Vi({ largura: this.c.folha.largura, altura: this.c.folha.altura, unidade: this.c.unidade, grade: this.c.grade, margens: this.c.margens });
2703
+ }
2704
+ /**
2705
+ * Aplica um campo do painel de propriedades à seleção (o `id` e o `valor` do `ui-propriedade-alterada`). Ação do usuário:
2706
+ * histórico (rajada no mesmo campo = um passo) e `prancha-elemento-atualizado` com motivo `propriedades`.
2707
+ */
2708
+ aplicarPropriedade(e, a) {
2709
+ return qi(this.c, e, a);
2710
+ }
2711
+ /** Dados para o `<ui-camadas>` (`painel.definirCamadas(d.camadas, d.feicoes)`), da frente para trás. */
2712
+ dadosParaPainelDeCamadas(e) {
2713
+ return Wi(this.c.doc.elementos, this.c.camadas, e);
2714
+ }
2715
+ /** Oculta, trava, renomeia ou muda de camada elementos pelo id (o painel de camadas), inclusive travados. */
2716
+ alterarElementos(e, a) {
2717
+ return Bi(this.c, e, a);
2718
+ }
2719
+ }
2720
+ Se("ui-canvas-prancha", Zi);
2721
+ const A = (t) => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`, sa = {
2722
+ selecao: A('<path d="M5 3l14 8-6 2-3 6z" fill="currentColor"/>'),
2723
+ "selecao-direta": A('<path d="M5 3l14 8-6 2-3 6z"/>'),
2724
+ mao: A('<path d="M18 11V6a2 2 0 0 0-4 0M14 10V4a2 2 0 0 0-4 0v2M10 10.5V6a2 2 0 0 0-4 0v8M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.9-5.9-2.4L3.4 16a2 2 0 0 1 3.2-2.4L8 15"/>'),
2725
+ retangulo: A('<rect x="3" y="5" width="18" height="14" rx="1"/>'),
2726
+ elipse: A('<ellipse cx="12" cy="12" rx="9" ry="7"/>'),
2727
+ "poligono-regular": A('<path d="M12 3l8 5v8l-8 5-8-5V8z"/>'),
2728
+ estrela: A('<path d="M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6L12 16.6 6.6 19.5l1.2-6L3.3 9.3l6.1-.7z"/>'),
2729
+ linha: A('<line x1="5" y1="19" x2="19" y2="5"/>'),
2730
+ seta: A('<line x1="5" y1="19" x2="19" y2="5"/><path d="M11 5h8v8"/>'),
2731
+ polilinha: A('<polyline points="3 17 9 11 13 15 21 7"/>'),
2732
+ poligono: A('<path d="M4 18l3-12 10 2 3 9z"/>'),
2733
+ caneta: A('<path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="M2 2l7.6 7.6"/>'),
2734
+ texto: A('<path d="M4 7V4h16v3M9 20h6M12 4v16"/>'),
2735
+ "conta-gotas": A('<path d="M14 4l6 6M17 7l-9 9-4 1 1-4 9-9"/>'),
2736
+ "adicionar-ancora": A('<path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5"/><path d="M4 20h6M7 17v6"/>'),
2737
+ "excluir-ancora": A('<path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5"/><path d="M4 20h6"/>'),
2738
+ "converter-ancora": A('<path d="M4 20L12 4l8 16"/><path d="M8 12h8"/>')
2739
+ }, S = (t, e, a) => ({ id: t, rotulo: e, icone: sa[t], tipo: "ferramenta", ...a ? { atalho: a } : {} }), Ji = Object.freeze([
2740
+ S("selecao", "Seleção", "V"),
2741
+ S("selecao-direta", "Seleção direta", "A"),
2742
+ { id: "grupo-caneta", rotulo: "Caneta", icone: sa.caneta, tipo: "ferramenta", filhos: [
2743
+ S("caneta", "Caneta", "P"),
2744
+ S("adicionar-ancora", "Adicionar âncora", "+"),
2745
+ S("excluir-ancora", "Excluir âncora", "-"),
2746
+ S("converter-ancora", "Converter âncora", "Shift+C")
2747
+ ] },
2748
+ S("texto", "Texto", "T"),
2749
+ { id: "grupo-linhas", rotulo: "Linhas", icone: sa.linha, tipo: "ferramenta", filhos: [
2750
+ S("linha", "Linha", "\\"),
2751
+ S("seta", "Seta"),
2752
+ S("polilinha", "Polilinha"),
2753
+ S("poligono", "Polígono")
2754
+ ] },
2755
+ { id: "grupo-formas", rotulo: "Formas", icone: sa.retangulo, tipo: "ferramenta", filhos: [
2756
+ S("retangulo", "Retângulo", "M"),
2757
+ S("elipse", "Elipse", "L"),
2758
+ S("poligono-regular", "Polígono regular"),
2759
+ S("estrela", "Estrela")
2760
+ ] },
2761
+ S("conta-gotas", "Conta-gotas", "I"),
2762
+ S("mao", "Mão", "H")
2763
+ ]);
2764
+ function Qi(t) {
2765
+ return typeof t == "string" && $e.includes(t) ? t : null;
2766
+ }
2767
+ const Yi = ["prancha-elemento-criado", "prancha-elemento-atualizado", "prancha-elemento-removido", "prancha-ordem", "prancha-camadas"], ao = (t) => t.detail ?? {};
2768
+ function eo(t) {
2769
+ const { prancha: e, paleta: a, camadas: r, propriedades: i } = t ?? {};
2770
+ if (!e) return () => {
2771
+ };
2772
+ const o = new Ta(), s = (h, u, f) => o.add(h, u, (p) => {
2773
+ try {
2774
+ f(ao(p));
2775
+ } catch {
2776
+ }
2777
+ });
2778
+ a && (a.ferramentas = Ji, a.valor = e.ferramenta, s(a, "ui-change", (h) => {
2779
+ const u = Qi(h.valor);
2780
+ u && e.definirFerramenta(u);
2781
+ }), s(e, "prancha-ferramenta", (h) => {
2782
+ a.valor = h.ferramenta;
2783
+ }));
2784
+ const n = () => {
2785
+ i && (i.categorias = e.categoriasDePropriedades());
2786
+ };
2787
+ i && s(i, "ui-propriedade-alterada", (h) => {
2788
+ e.aplicarPropriedade(h.id, h.valor);
2789
+ });
2790
+ const l = () => {
2791
+ var u;
2792
+ if (!r) return;
2793
+ const h = e.dadosParaPainelDeCamadas({ ocultarSemCamada: t.listaPlana !== !1 });
2794
+ r.definirCamadas(h.camadas, h.feicoes), (u = r.selecionarFeicoes) == null || u.call(r, e.selecao);
2795
+ }, c = (h, u) => {
2796
+ h !== G && e.definirCamadas(Ui(e.obterCamadas(), h, u));
2797
+ };
2798
+ if (r) {
2799
+ const h = r;
2800
+ s(h, "ui-camada-visibilidade", (u) => c(u.camadaId, { visivel: u.visivel })), s(h, "ui-camada-bloqueio", (u) => c(u.camadaId, { bloqueada: u.bloqueado })), s(h, "ui-camada-opacidade", (u) => c(u.camadaId, { opacidade: u.opacidade })), s(h, "ui-camada-renomeada", (u) => c(u.camadaId, { nome: u.novoNome })), s(h, "ui-camada-selecionada", (u) => e.definirCamadaAtiva(te(u.camadaId))), s(h, "ui-camadas-reordenadas", (u) => {
2801
+ e.definirCamadas(Xi(e.obterCamadas(), (u.camadas ?? []).map((f) => f.id)));
2802
+ }), s(h, "ui-camada-adicionar", () => {
2803
+ const u = e.obterCamadas();
2804
+ let f = u.length + 1;
2805
+ for (; u.some((p) => p.id === `camada-${f}`); ) f++;
2806
+ e.definirCamadas([...u, { id: `camada-${f}`, nome: `Camada ${f}` }]);
2807
+ }), s(h, "ui-feicao-selecionada", (u) => e.selecionarElementos([u.feicaoId])), s(h, "ui-feicoes-selecionadas", (u) => e.selecionarElementos(u.feicoesIds ?? [])), s(h, "ui-feicao-visibilidade", (u) => e.alterarElementos([u.feicaoId], { oculto: !u.visivel })), s(h, "ui-feicao-bloqueio", (u) => e.alterarElementos([u.feicaoId], { bloqueado: u.bloqueado })), s(h, "ui-feicao-renomeada", (u) => e.alterarElementos([u.feicaoId], { nome: u.novoNome })), s(h, "ui-feicao-movida", (u) => e.alterarElementos([u.feicaoId], { camadaId: te(u.camadaDestinoId) }));
2808
+ }
2809
+ for (const h of Yi) o.add(e, h, () => {
2810
+ l(), n();
2811
+ });
2812
+ o.add(e, "prancha-selecao", () => {
2813
+ var h;
2814
+ (h = r == null ? void 0 : r.selecionarFeicoes) == null || h.call(r, e.selecao), n();
2815
+ }), l(), n();
2816
+ let d = !0;
2817
+ return () => {
2818
+ d && (d = !1, o.cleanup());
2819
+ };
2820
+ }
2821
+ const to = 720, ro = 24, io = 0.5, ya = (t) => t === "botoes" || t === "menu" ? t : "auto", X = (t) => t === "fixa" || t === "gaveta" ? t : "auto";
2822
+ function oo(t) {
2823
+ if (!t || typeof t != "object") return !1;
2824
+ const e = !!t.colapsadaAtual, a = t.transbordouNoDom === !0, r = t.larguraNecessaria, i = t.larguraDisponivel, o = typeof t.histerese == "number" && Number.isFinite(t.histerese) && t.histerese >= 0 ? t.histerese : ro, s = typeof i == "number" && Number.isFinite(i) && i > 0, n = typeof r == "number" && Number.isFinite(r) && r > 0;
2825
+ return !s || !n ? a ? !0 : e : e ? a ? !0 : i < r + o : a || r > i + io;
2826
+ }
2827
+ const so = "display:flex !important;flex-wrap:nowrap !important;width:max-content !important;max-width:none !important;position:absolute !important;visibility:hidden !important;pointer-events:none !important;left:0 !important;top:0 !important;", x = (t) => typeof t == "number" && Number.isFinite(t) && t > 0 ? t : 0, D = (t, e) => {
2828
+ if (typeof t != "string" || !t) return e;
2829
+ const a = parseFloat(t);
2830
+ return Number.isFinite(a) && a >= 0 ? a : e;
2831
+ }, Xe = (t) => {
2832
+ try {
2833
+ return typeof getComputedStyle == "function" ? getComputedStyle(t) : null;
2834
+ } catch {
2835
+ return null;
2836
+ }
2837
+ }, Ze = (t, e = !1) => {
2838
+ var o;
2839
+ let a = 0;
2840
+ try {
2841
+ a = ((o = t.getBoundingClientRect) == null ? void 0 : o.call(t).width) ?? 0;
2842
+ } catch {
2843
+ a = 0;
2844
+ }
2845
+ const r = x(t.offsetWidth), i = e ? x(t.scrollWidth) : 0;
2846
+ return Math.max(x(a), r, i, 0);
2847
+ };
2848
+ function re(t, e) {
2849
+ const a = Xe(t), r = D(a == null ? void 0 : a.columnGap, 4), i = D(a == null ? void 0 : a.paddingLeft, 0) + D(a == null ? void 0 : a.paddingRight, 0) + D(a == null ? void 0 : a.borderLeftWidth, 0) + D(a == null ? void 0 : a.borderRightWidth, 0);
2850
+ let o = 0, s = !1;
2851
+ for (const n of e) {
2852
+ const l = Ze(n, !0);
2853
+ l > 0 && (s = !0), o += l;
2854
+ }
2855
+ return {
2856
+ largura: s ? o + Math.max(0, e.length - 1) * r + i : 0,
2857
+ medido: s
2858
+ };
2859
+ }
2860
+ function no(t, e) {
2861
+ var o;
2862
+ const a = e[0];
2863
+ if (a) {
2864
+ const s = x(a.offsetHeight);
2865
+ if (s > 0) {
2866
+ const n = a.offsetTop, l = Math.max(4, s * 0.5);
2867
+ if (e.some((c) => c.offsetTop > n + l)) return !0;
2868
+ }
2869
+ try {
2870
+ const n = (o = a.getBoundingClientRect) == null ? void 0 : o.call(a);
2871
+ if (n && n.height > 0) {
2872
+ const l = Math.max(4, n.height * 0.5);
2873
+ if (e.some((c) => {
2874
+ var d, h;
2875
+ return (((h = (d = c.getBoundingClientRect) == null ? void 0 : d.call(c)) == null ? void 0 : h.top) ?? n.top) > n.top + l;
2876
+ })) return !0;
2877
+ }
2878
+ } catch {
2879
+ }
2880
+ }
2881
+ const r = x(t.clientWidth), i = x(t.scrollWidth);
2882
+ return r > 0 && i > r + 1;
2883
+ }
2884
+ function lo(t) {
2885
+ var C, T;
2886
+ const { barra: e, botoesFormas: a, botaoLateral: r, lateralVisivel: i, colapsadaAtual: o, larguraObservada: s } = t, n = Xe(e), l = D(n == null ? void 0 : n.paddingLeft, 0) + D(n == null ? void 0 : n.paddingRight, 0), c = D(n == null ? void 0 : n.columnGap, 4);
2887
+ let d = x(e.clientWidth);
2888
+ if (!(d > 0)) {
2889
+ let P = 0;
2890
+ try {
2891
+ P = x((C = e.getBoundingClientRect) == null ? void 0 : C.call(e).width);
2892
+ } catch {
2893
+ P = 0;
2894
+ }
2895
+ d = P > 0 ? P : x(s);
2896
+ }
2897
+ let h = Math.max(0, d - l);
2898
+ if (h > 0 && i) {
2899
+ const P = Ze(r, !1);
2900
+ P > 0 && (h = Math.max(0, h - P - c));
2901
+ }
2902
+ !(h > 0) && !o && (h = x(a.clientWidth));
2903
+ const u = Array.from(a.querySelectorAll("button[data-predefinicao]"));
2904
+ if (u.length === 0)
2905
+ return { larguraDisponivel: h, larguraNecessaria: 0, transbordouNoDom: !1 };
2906
+ if (o) {
2907
+ const P = a.getAttribute("style");
2908
+ try {
2909
+ a.style.cssText = so;
2910
+ const _ = re(a, u);
2911
+ let fa = 0;
2912
+ try {
2913
+ fa = x((T = a.getBoundingClientRect) == null ? void 0 : T.call(a).width);
2914
+ } catch {
2915
+ fa = 0;
2916
+ }
2917
+ const Je = x(a.scrollWidth);
2918
+ return {
2919
+ larguraDisponivel: h,
2920
+ larguraNecessaria: Math.max(_.largura, fa, Je),
2921
+ transbordouNoDom: !1
2922
+ };
2923
+ } finally {
2924
+ P === null ? a.removeAttribute("style") : a.setAttribute("style", P);
2925
+ }
2926
+ }
2927
+ const f = no(a, u), p = re(a, u), v = x(a.clientWidth), b = x(a.scrollWidth), M = p.medido ? v > 0 && b > v + 1 ? Math.max(p.largura, b) : p.largura : b;
2928
+ return { larguraDisponivel: h, larguraNecessaria: M, transbordouNoDom: f };
2929
+ }
2930
+ const co = ":host{--ui-editor-prancha-lateral: 300px;display:block;min-height:360px;min-width:240px;height:100%;color:var(--ui-cor-texto);font-family:var(--ui-fonte-base);box-sizing:border-box}:host([hidden]){display:none}.raiz{container-type:inline-size;container-name:editor;position:relative;display:grid;grid-template-rows:auto minmax(0,1fr) auto;height:100%;min-height:inherit;gap:var(--ui-espaco-sm);box-sizing:border-box}.barra{display:flex;flex-wrap:nowrap;gap:var(--ui-espaco-xs, 4px);align-items:center;min-width:0}.botoes-formas{display:flex;flex-wrap:wrap;gap:var(--ui-espaco-xs, 4px);min-width:0;flex:1 1 auto}.formas-menu{position:relative;display:none;flex:0 0 auto}.btn-lateral{display:none;margin-inline-start:auto;flex:0 0 auto}.acoes{display:flex;flex-wrap:nowrap;gap:var(--ui-espaco-xs);align-items:center;justify-content:flex-end;flex:0 0 auto}.area{position:relative;display:flex;gap:var(--ui-espaco-sm);align-items:stretch;min-height:0;min-width:0}.area>ui-paleta-ferramentas{flex:0 0 auto}.area>ui-canvas-prancha{flex:1 1 auto;min-width:0;height:auto}.lateral{flex:0 0 var(--ui-editor-prancha-lateral);display:flex;flex-direction:column;gap:var(--ui-espaco-sm);min-width:0}.lateral>ui-tabela-propriedades{flex:1 1 auto;min-height:200px}button{font:inherit;font-size:var(--ui-tamanho-corpo-sm);color:var(--ui-cor-texto);background:var(--ui-cor-superficie);border:1px solid var(--ui-cor-borda);border-radius:var(--ui-raio-sm);padding:var(--ui-espaco-xs) var(--ui-espaco-md);min-height:var(--ui-touch-target-min);cursor:pointer;white-space:nowrap}button:hover{border-color:var(--ui-cor-primaria)}button:focus-visible{outline:2px solid var(--ui-cor-primaria);outline-offset:2px}button.primario{background:var(--ui-cor-primaria);color:var(--ui-cor-texto-sobre-primaria, #000);border-color:var(--ui-cor-primaria)}.menu-formas{position:absolute;inset-block-start:100%;inset-inline-start:0;z-index:20;min-width:200px;max-height:70vh;overflow:auto;margin-block-start:var(--ui-espaco-xs);padding:var(--ui-espaco-xs);background:var(--ui-cor-superficie);border:1px solid var(--ui-cor-borda);border-radius:var(--ui-raio-sm);box-shadow:var(--ui-sombra-md, 0 8px 24px rgba(0, 0, 0, .35))}.menu-formas[hidden]{display:none}.menu-formas button{display:block;width:100%;text-align:start;border-color:transparent;background:transparent}.menu-formas button:hover,.menu-formas button:focus-visible{background:var(--ui-cor-fundo-elevado)}.menu-grupo{padding:var(--ui-espaco-xs) var(--ui-espaco-sm);font-size:var(--ui-tamanho-caption);color:var(--ui-cor-texto-secundario);text-transform:uppercase}.raiz[data-barra=menu] .botoes-formas,.raiz[data-barra=auto][data-barra-modo=menu] .botoes-formas{display:none}.raiz[data-barra=menu] .formas-menu,.raiz[data-barra=auto][data-barra-modo=menu] .formas-menu{display:block}.raiz[data-lateral=gaveta] .btn-lateral{display:inline-block}.raiz[data-lateral=gaveta] .lateral{position:absolute;inset-block:0;inset-inline-end:0;z-index:10;width:min(var(--ui-editor-prancha-lateral),92%);padding:var(--ui-espaco-sm);box-sizing:border-box;background:var(--ui-cor-fundo);border:1px solid var(--ui-cor-borda);box-shadow:var(--ui-sombra-md, 0 8px 24px rgba(0, 0, 0, .35))}.raiz[data-lateral=gaveta][data-lateral-aberta=false] .lateral{display:none}@container editor (max-width: 719.98px){.raiz[data-lateral=auto] .btn-lateral{display:inline-block}.raiz[data-lateral=auto] .lateral{position:absolute;inset-block:0;inset-inline-end:0;z-index:10;width:min(var(--ui-editor-prancha-lateral),92%);padding:var(--ui-espaco-sm);box-sizing:border-box;background:var(--ui-cor-fundo);border:1px solid var(--ui-cor-borda);box-shadow:var(--ui-sombra-md, 0 8px 24px rgba(0, 0, 0, .35))}.raiz[data-lateral=auto][data-lateral-aberta=false] .lateral{display:none}}@container editor (max-width: 420px){.area{flex-direction:column}.area>ui-paleta-ferramentas{align-self:flex-start}}", ie = ["largura", "altura", "unidade", "grade", "mostrar-grade", "margens", "ajustar-ao-abrir", "somente-leitura", "sem-snap", "sem-reguas", "rotulo"], oe = { molduras: "Molduras", formas: "Formas", linhas: "Linhas", setas: "Setas" };
2931
+ class uo extends Ae {
2932
+ constructor() {
2933
+ super();
2934
+ m(this, "shadow");
2935
+ m(this, "bag", new Ta());
2936
+ m(this, "desligarPaineis", null);
2937
+ m(this, "observador", null);
2938
+ m(this, "rafBarra", null);
2939
+ m(this, "_prancha");
2940
+ m(this, "paleta");
2941
+ m(this, "painelCamadas");
2942
+ m(this, "painelPropriedades");
2943
+ m(this, "raiz");
2944
+ m(this, "barra");
2945
+ m(this, "botoesFormas");
2946
+ m(this, "botaoLateral");
2947
+ m(this, "botaoFormas");
2948
+ m(this, "menuFormas");
2949
+ m(this, "_lateralAberta", !1);
2950
+ m(this, "estreito", !1);
2951
+ m(this, "barraColapsada", !1);
2952
+ m(this, "ultimaLarguraObservada", 0);
2953
+ this.shadow = this.attachShadow({ mode: "open" }), this.shadow.innerHTML = `
2954
+ <style>${co}</style>
2955
+ <div class="raiz" id="raiz" part="base" data-barra="auto" data-barra-modo="botoes" data-lateral="auto" data-lateral-aberta="false">
2956
+ <div class="barra" part="barra" id="barra" role="toolbar" aria-label="Formas e painéis">
2957
+ <div class="botoes-formas" id="botoes-formas" role="group" aria-label="Pré-definições"></div>
2958
+ <div class="formas-menu">
2959
+ <button type="button" id="btn-formas" class="btn-formas" aria-haspopup="menu" aria-expanded="false" aria-controls="menu-formas">Formas ▾</button>
2960
+ <div id="menu-formas" class="menu-formas" part="menu-formas" role="menu" aria-label="Formas" hidden></div>
2961
+ </div>
2962
+ <button type="button" id="btn-lateral" class="btn-lateral" aria-expanded="false" aria-controls="lateral" aria-keyshortcuts="Alt+P" title="Propriedades e camadas (Alt+P)">Propriedades</button>
2963
+ </div>
2964
+ <div class="area">
2965
+ <ui-paleta-ferramentas id="paleta" orientacao="vertical" atalhos></ui-paleta-ferramentas>
2966
+ <ui-canvas-prancha id="prancha" part="prancha" teclado="isolado" ajustar-ao-abrir="folha"></ui-canvas-prancha>
2967
+ <div class="lateral" id="lateral" part="lateral" role="region" aria-label="Camadas e propriedades">
2968
+ <ui-camadas id="camadas" densidade="compacto" mostrar-mapas-base="false" mostrar-rodape="false" persistir="false" altura="260"></ui-camadas>
2969
+ <ui-tabela-propriedades id="propriedades" titulo="Aparência" modo-aplicar="imediato"></ui-tabela-propriedades>
2970
+ </div>
2971
+ </div>
2972
+ <div class="acoes" part="acoes">
2973
+ <button type="button" id="cancelar">Cancelar</button>
2974
+ <button type="button" id="concluir" class="primario">Concluir</button>
2975
+ </div>
2976
+ </div>`;
2977
+ const a = (o) => this.shadow.getElementById(o);
2978
+ this._prancha = a("prancha"), this.paleta = a("paleta"), this.painelCamadas = a("camadas"), this.painelPropriedades = a("propriedades"), this.raiz = a("raiz"), this.barra = a("barra"), this.botoesFormas = a("botoes-formas"), this.botaoLateral = a("btn-lateral"), this.botaoFormas = a("btn-formas"), this.menuFormas = a("menu-formas");
2979
+ let r = null, i = null;
2980
+ for (const o of Oa) {
2981
+ const s = document.createElement("button");
2982
+ if (s.type = "button", s.dataset.predefinicao = o.valor, s.textContent = o.rotulo, this.botoesFormas.appendChild(s), o.grupo !== r) {
2983
+ r = o.grupo, i = document.createElement("div"), i.setAttribute("role", "group"), i.setAttribute("aria-label", oe[o.grupo]);
2984
+ const l = document.createElement("div");
2985
+ l.className = "menu-grupo", l.setAttribute("aria-hidden", "true"), l.textContent = oe[o.grupo], i.appendChild(l), this.menuFormas.appendChild(i);
2986
+ }
2987
+ const n = document.createElement("button");
2988
+ n.type = "button", n.setAttribute("role", "menuitem"), n.tabIndex = -1, n.dataset.predefinicao = o.valor, n.textContent = o.rotulo, i == null || i.appendChild(n);
2989
+ }
2990
+ }
2991
+ static get observedAttributes() {
2992
+ return [...ie, "teclado", "barra-formas", "lateral"];
2993
+ }
2994
+ connectedCallback() {
2995
+ var r;
2996
+ this.bag.cleanup(), this.pararObservador(), (r = this.desligarPaineis) == null || r.call(this), this.sincronizarAtributos(), this.desligarPaineis = eo({
2997
+ prancha: this._prancha,
2998
+ paleta: this.paleta,
2999
+ camadas: this.painelCamadas,
3000
+ propriedades: this.painelPropriedades
3001
+ });
3002
+ const a = () => j(this.getAttribute("teclado") ?? "isolado");
3003
+ Ge(this.bag, this, () => {
3004
+ const i = a();
3005
+ return i === "isolado" || i === "modal";
3006
+ }), He(this.bag, this, () => a() === "modal"), this.bag.add(this.shadow.getElementById("concluir"), "click", () => this.concluir()), this.bag.add(this.shadow.getElementById("cancelar"), "click", () => this.cancelar()), this.bag.add(this.botoesFormas, "click", (i) => {
3007
+ var s, n;
3008
+ const o = (n = (s = i.target) == null ? void 0 : s.closest) == null ? void 0 : n.call(s, "button[data-predefinicao]");
3009
+ o && this.inserir(o.dataset.predefinicao);
3010
+ }), this.bag.add(this.botaoFormas, "click", () => this.alternarMenuFormas()), this.bag.add(this.botaoFormas, "keydown", (i) => {
3011
+ i.key === "ArrowDown" && (i.preventDefault(), this.abrirMenuFormas());
3012
+ }), this.bag.add(this.menuFormas, "click", (i) => {
3013
+ var s, n;
3014
+ const o = (n = (s = i.target) == null ? void 0 : s.closest) == null ? void 0 : n.call(s, "button[data-predefinicao]");
3015
+ o && (this.fecharMenuFormas(!1), this.inserir(o.dataset.predefinicao));
3016
+ }), this.bag.add(this.menuFormas, "keydown", (i) => this.tecladoDoMenu(i)), typeof document < "u" && this.bag.add(document, "pointerdown", (i) => {
3017
+ if (this.menuFormas.hidden) return;
3018
+ const o = typeof i.composedPath == "function" ? i.composedPath() : [];
3019
+ !o.includes(this.menuFormas) && !o.includes(this.botaoFormas) && this.fecharMenuFormas(!1);
3020
+ }), this.bag.add(this.botaoLateral, "click", () => {
3021
+ this.lateralAberta = !this.lateralAberta;
3022
+ }), this.bag.add(this.shadow.getElementById("lateral"), "keydown", (i) => {
3023
+ i.key === "Escape" && this.emGaveta() && this._lateralAberta && (i.preventDefault(), i.stopPropagation(), this.lateralAberta = !1, this.botaoLateral.focus());
3024
+ }), this.bag.add(this, "keydown", (i) => {
3025
+ i.altKey && !i.ctrlKey && !i.metaKey && typeof i.key == "string" && i.key.toLowerCase() === "p" && (i.preventDefault(), this.lateralAberta = !this.lateralAberta, this._lateralAberta && this.emGaveta() && this.painelPropriedades.focus());
3026
+ }, { capture: !0 }), this.bag.add(this._prancha, "prancha-esc-sem-efeito", () => this.cancelar()), this.iniciarObservador(), this.atualizarLateral();
3027
+ }
3028
+ disconnectedCallback() {
3029
+ var a;
3030
+ this.bag.cleanup(), this.pararObservador(), this.ultimaLarguraObservada = 0, (a = this.desligarPaineis) == null || a.call(this), this.desligarPaineis = null, this.fecharMenuFormas(!1);
3031
+ }
3032
+ attributeChangedCallback(a, r, i) {
3033
+ if (a === "barra-formas") {
3034
+ const o = ya(i);
3035
+ o !== "auto" && (this.barraColapsada = !1), this.sincronizarModoBarra(), o === "auto" && this.isConnected && this.reajustarBarra();
3036
+ return;
3037
+ }
3038
+ if (a === "lateral") {
3039
+ this.raiz.dataset.lateral = X(i), this.atualizarLateral();
3040
+ return;
3041
+ }
3042
+ this.repassar(a, i);
3043
+ }
3044
+ repassar(a, r) {
3045
+ if (a === "teclado") {
3046
+ const i = j(r ?? "isolado");
3047
+ i === "local" ? this._prancha.removeAttribute("teclado") : this._prancha.setAttribute("teclado", i);
3048
+ return;
3049
+ }
3050
+ r === null ? this._prancha.removeAttribute(a) : this._prancha.setAttribute(a, r);
3051
+ }
3052
+ sincronizarAtributos() {
3053
+ for (const a of ie) this.repassar(a, this.getAttribute(a));
3054
+ this.repassar("teclado", this.getAttribute("teclado")), this.barraFormas !== "auto" && (this.barraColapsada = !1), this.sincronizarModoBarra(), this.raiz.dataset.lateral = X(this.getAttribute("lateral"));
3055
+ }
3056
+ inserir(a) {
3057
+ const r = Oa.find((i) => i.valor === a);
3058
+ r && this._prancha.inserirPredefinicao(r.valor, void 0, r.usaQuadro ? { quadro: "margens" } : {});
3059
+ }
3060
+ // ---------- menu "Formas" ----------
3061
+ itensDoMenu() {
3062
+ return Array.from(this.menuFormas.querySelectorAll('button[role="menuitem"]'));
3063
+ }
3064
+ abrirMenuFormas() {
3065
+ var a;
3066
+ this.menuFormas.hidden = !1, this.botaoFormas.setAttribute("aria-expanded", "true"), (a = this.itensDoMenu()[0]) == null || a.focus();
3067
+ }
3068
+ fecharMenuFormas(a) {
3069
+ this.menuFormas.hidden || (this.menuFormas.hidden = !0, this.botaoFormas.setAttribute("aria-expanded", "false"), a && this.botaoFormas.focus());
3070
+ }
3071
+ alternarMenuFormas() {
3072
+ this.menuFormas.hidden ? this.abrirMenuFormas() : this.fecharMenuFormas(!0);
3073
+ }
3074
+ tecladoDoMenu(a) {
3075
+ const r = this.itensDoMenu(), i = r.indexOf(this.shadow.activeElement);
3076
+ if (a.key === "Escape") {
3077
+ a.preventDefault(), a.stopPropagation(), this.fecharMenuFormas(!0);
3078
+ return;
3079
+ }
3080
+ if (a.key === "Tab") {
3081
+ this.fecharMenuFormas(!1);
3082
+ return;
3083
+ }
3084
+ const o = (s) => {
3085
+ var n;
3086
+ a.preventDefault(), (n = r[(s + r.length) % r.length]) == null || n.focus();
3087
+ };
3088
+ a.key === "ArrowDown" ? o(i + 1) : a.key === "ArrowUp" ? o(i - 1) : a.key === "Home" ? o(0) : a.key === "End" && o(r.length - 1);
3089
+ }
3090
+ // ---------- barra de formas e observador ----------
3091
+ iniciarObservador() {
3092
+ this.pararObservador(), typeof ResizeObserver == "function" && (this.observador = new ResizeObserver((a) => this.aoRedimensionar(a)), this.observador.observe(this.raiz), this.observador.observe(this.barra));
3093
+ }
3094
+ pararObservador() {
3095
+ var a;
3096
+ (a = this.observador) == null || a.disconnect(), this.observador = null, this.rafBarra !== null && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(this.rafBarra), this.rafBarra = null;
3097
+ }
3098
+ aoRedimensionar(a) {
3099
+ var o;
3100
+ if (!Array.isArray(a)) return;
3101
+ let r = null, i = null;
3102
+ for (const s of a) {
3103
+ const n = (o = s == null ? void 0 : s.contentRect) == null ? void 0 : o.width;
3104
+ typeof n != "number" || !Number.isFinite(n) || n < 0 || (!s.target || s.target === this.raiz ? r = n : s.target === this.barra && (i = n));
3105
+ }
3106
+ r !== null ? (this.ultimaLarguraObservada = r, r > 0 && this.definirLargura(r)) : i !== null && (this.ultimaLarguraObservada = i), this.barraFormas === "auto" && this.agendarAjusteBarra();
3107
+ }
3108
+ /** Agrupa rajadas de redimensionamento em um único reajuste por quadro (evita loops de ResizeObserver e pisca-pisca). */
3109
+ agendarAjusteBarra() {
3110
+ if (!(!this.isConnected || this.barraFormas !== "auto")) {
3111
+ if (typeof requestAnimationFrame != "function") {
3112
+ this.reajustarBarra();
3113
+ return;
3114
+ }
3115
+ this.rafBarra === null && (this.rafBarra = requestAnimationFrame(() => {
3116
+ this.rafBarra = null, this.isConnected && this.reajustarBarra();
3117
+ }));
3118
+ }
3119
+ }
3120
+ /**
3121
+ * Reavalia se a barra de formas no modo `auto` cabe em uma linha ou deve colapsar para `"Formas ▾"`.
3122
+ * Executado no máximo uma vez por quadro via `ResizeObserver`; pode ser chamado após alterações manuais de rótulos/layout.
3123
+ */
3124
+ reajustarBarra() {
3125
+ if (!this.isConnected) return;
3126
+ if (this.barraFormas !== "auto") {
3127
+ this.definirBarraColapsada(!1);
3128
+ return;
3129
+ }
3130
+ const a = lo({
3131
+ barra: this.barra,
3132
+ botoesFormas: this.botoesFormas,
3133
+ botaoLateral: this.botaoLateral,
3134
+ lateralVisivel: this.emGaveta(),
3135
+ colapsadaAtual: this.barraColapsada,
3136
+ larguraObservada: this.ultimaLarguraObservada
3137
+ }), r = oo({
3138
+ colapsadaAtual: this.barraColapsada,
3139
+ larguraNecessaria: a.larguraNecessaria,
3140
+ larguraDisponivel: a.larguraDisponivel,
3141
+ transbordouNoDom: a.transbordouNoDom
3142
+ });
3143
+ this.definirBarraColapsada(r);
3144
+ }
3145
+ definirBarraColapsada(a) {
3146
+ if (a === this.barraColapsada && this.raiz.dataset.barraModo) {
3147
+ this.sincronizarModoBarra();
3148
+ return;
3149
+ }
3150
+ this.barraColapsada = a, this.sincronizarModoBarra();
3151
+ }
3152
+ sincronizarModoBarra() {
3153
+ var o;
3154
+ const a = this.barraFormas;
3155
+ this.raiz.dataset.barra = a;
3156
+ const r = a === "menu" || a === "auto" && this.barraColapsada ? "menu" : "botoes", i = this.raiz.dataset.barraModo;
3157
+ if (this.raiz.dataset.barraModo = r, i === "menu" && r === "botoes") {
3158
+ const s = this.shadow.activeElement === this.botaoFormas || this.menuFormas.contains(this.shadow.activeElement);
3159
+ this.fecharMenuFormas(!1), s && ((o = this.botoesFormas.querySelector("button[data-predefinicao]")) == null || o.focus());
3160
+ }
3161
+ }
3162
+ // ---------- lateral ----------
3163
+ emGaveta() {
3164
+ const a = X(this.getAttribute("lateral"));
3165
+ return a === "gaveta" || a === "auto" && this.estreito;
3166
+ }
3167
+ definirLargura(a) {
3168
+ const r = a < to;
3169
+ r !== this.estreito && (this.estreito = r, this.atualizarLateral());
3170
+ }
3171
+ atualizarLateral() {
3172
+ const a = this.emGaveta();
3173
+ a || (this._lateralAberta = !1), this.raiz.dataset.lateralAberta = String(this._lateralAberta), this.botaoLateral.setAttribute("aria-expanded", String(!a || this._lateralAberta)), this.botaoLateral.toggleAttribute("data-gaveta", a), this.isConnected && this.barraFormas === "auto" && this.agendarAjusteBarra();
3174
+ }
3175
+ /** A lateral (camadas e propriedades) está visível? Em modo fixo é sempre `true`; em gaveta, é o estado aberto/fechado. */
3176
+ get lateralAberta() {
3177
+ return !this.emGaveta() || this._lateralAberta;
3178
+ }
3179
+ set lateralAberta(a) {
3180
+ this.emGaveta() && (this._lateralAberta = !!a, this.atualizarLateral(), this._lateralAberta && this.painelPropriedades.focus());
3181
+ }
3182
+ /** `auto`, `fixa` ou `gaveta`. */
3183
+ get lateral() {
3184
+ return X(this.getAttribute("lateral"));
3185
+ }
3186
+ set lateral(a) {
3187
+ this.setAttribute("lateral", X(a));
3188
+ }
3189
+ /** `auto`, `botoes` ou `menu`. */
3190
+ get barraFormas() {
3191
+ return ya(this.getAttribute("barra-formas"));
3192
+ }
3193
+ set barraFormas(a) {
3194
+ this.setAttribute("barra-formas", ya(a));
3195
+ }
3196
+ /** `isolado` (padrão), `exclusivo`, `local` ou `modal`. */
3197
+ get teclado() {
3198
+ return j(this.getAttribute("teclado") ?? "isolado");
3199
+ }
3200
+ set teclado(a) {
3201
+ this.setAttribute("teclado", j(a));
3202
+ }
3203
+ // ---------- API ----------
3204
+ /** A prancha interna (para usar a API completa: ferramentas, vista, exportação). */
3205
+ get prancha() {
3206
+ return this._prancha;
3207
+ }
3208
+ /** Elementos do desenho. Ao atribuir, carrega (normaliza) e marca como salvo. */
3209
+ get elementos() {
3210
+ return this._prancha.obterElementos();
3211
+ }
3212
+ set elementos(a) {
3213
+ this._prancha.definirElementos(Array.isArray(a) ? a : []);
3214
+ }
3215
+ get camadas() {
3216
+ return this._prancha.obterCamadas();
3217
+ }
3218
+ set camadas(a) {
3219
+ this._prancha.definirCamadas(Array.isArray(a) ? a : []);
3220
+ }
3221
+ get modificado() {
3222
+ return this._prancha.modificado;
3223
+ }
3224
+ marcarComoSalvo() {
3225
+ this._prancha.marcarComoSalvo();
3226
+ }
3227
+ /** Resolve quando a prancha mediu o layout e consegue enquadrar. */
3228
+ get pronto() {
3229
+ return this._prancha.pronto;
3230
+ }
3231
+ /** Confirma: emite `editor-concluir` com os dados atuais. */
3232
+ concluir() {
3233
+ const a = { elementos: this._prancha.obterElementos(), camadas: this._prancha.obterCamadas(), modificado: this._prancha.modificado };
3234
+ this.dispatchEvent(new CustomEvent("editor-concluir", { detail: a, bubbles: !0, composed: !0 }));
3235
+ }
3236
+ /** Cancela: emite `editor-cancelar`. */
3237
+ cancelar() {
3238
+ const a = { modificado: this._prancha.modificado };
3239
+ this.dispatchEvent(new CustomEvent("editor-cancelar", { detail: a, bubbles: !0, composed: !0 }));
3240
+ }
3241
+ focus(a) {
3242
+ this._prancha.focus(a);
3243
+ }
3244
+ }
3245
+ Se("ui-editor-prancha", uo);
9
3246
  export {
10
- x as ALCAS_ESCALA,
11
- i as ATRIBUTOS_PRANCHA,
12
- c as CAMADA_SEM_CAMADA,
13
- t as CANAL_COMANDOS_PRANCHA,
14
- m as COMANDOS_PRANCHA,
15
- v as COR_PADRAO_PRANCHA,
16
- f as DIMENSOES_FOLHA,
17
- F as EPSILON_DETERMINANTE,
18
- H as ESCALA_MINIMA,
19
- g as ESPACO_GEOGRAFICO,
20
- z as ESPACO_PLANO,
21
- U as ESPESSURA_PADRAO_MM,
22
- G as ESPESSURA_TRACO_PADRAO_MM,
23
- j as ESTILOS_TRACO,
24
- mr as ESTILO_DO_TIPO_LINHA,
25
- B as FAIXAS_MAXIMO,
26
- X as FAIXAS_PADRAO,
27
- A as FERRAMENTAS_PALETA_PRANCHA,
28
- l as FERRAMENTAS_PRANCHA,
29
- V as FONTE_PADRAO,
30
- Q as FORMATOS_ABNT,
31
- k as Historico,
32
- K as IDENTIDADE,
33
- q as IDS_PROPRIEDADES_PRANCHA,
34
- w as ITENS_PREDEFINICOES,
35
- y as IndicePrancha,
36
- J as KAPPA,
37
- W as LIMITE_PONTA_PADRAO,
38
- Y as MAX_LINHAS_HACHURA,
39
- Z as MESCLAGEM_CSS,
40
- $ as MM_POR_PX,
41
- aa as MM_POR_UNIDADE,
42
- sa as MODOS_MESCLAGEM,
43
- oa as OPERACOES_BOOLEANAS,
44
- ra as PREDEFINICOES,
45
- ea as PRIORIDADE_SNAP_PRANCHA,
46
- P as PX_POR_MM_100,
47
- na as ROTULOS_PREDEFINICOES,
48
- ia as SOMBRA_PADRAO,
49
- ca as TIPO_LINHA_DO_ESTILO,
50
- E as UICanvasPrancha,
51
- d as UICanvasPranchaBase,
52
- b as UIEditorPrancha,
53
- ta as adaptarContextoRelativo,
54
- ma as adicionarAncora,
55
- Aa as agrupar,
56
- Ar as ajustarAparenciaEmLote,
57
- lr as ajustarElementosACaixa,
58
- la as alcasDoElemento,
59
- Pa as alinhar,
60
- Ea as analisarElemento,
61
- da as ancoraMaisProxima,
62
- ba as ancorasDoElemento,
63
- Da as aparenciaDe,
64
- pa as aplicar,
65
- Ca as aplicarAparencia,
66
- Oa as aplicarPathfinder,
67
- Sa as aplicarTodos,
68
- _a as aplicarVetor,
69
- ha as areaComSinal,
70
- Ra as areaDosPoligonos,
71
- Na as avisarUmaVez,
72
- Ma as buscarSnapPrancha,
73
- Ia as caixaDaSelecao,
74
- Ta as caixaDeCantos,
75
- ua as caixaDoQuadro,
76
- ga as caixaDoQuadroAbnt,
77
- La as caixaDoTexto,
78
- xa as caixaNormalizada,
79
- va as caixaOrientada,
80
- D as camadaDoPainel,
81
- p as camadasComMudanca,
82
- C as camadasNaOrdemDoPainel,
83
- fa as caminhoDoContorno,
84
- Fa as caminhoFinito,
85
- Ha as caminhoParaSvg,
86
- O as categoriasDePropriedades,
87
- S as categoriasSemSelecao,
88
- za as centroDaSelecao,
89
- Ua as cisalhamento,
90
- Ga as comPropriedade,
91
- ja as comRaioDeCanto,
92
- Ba as comoCaminhoNaFolha,
93
- Xa as compor,
94
- Va as comprimentoDaPonta,
95
- Qa as contornoDoTraco,
96
- ka as contornoElipse,
97
- Ka as contornoEstrela,
98
- qa as contornoLocal,
99
- wa as contornoLocalEmCache,
100
- ya as contornoNaFolha,
101
- Ja as contornoPoligonoRegular,
102
- Wa as contornoRetangulo,
103
- Ya as converterAncora,
104
- Za as converterEmCaminho,
105
- $a as corComOpacidade,
106
- as as corNaPosicao,
107
- ss as criarCaminho,
108
- os as criarElipse,
109
- rs as criarEstrela,
110
- es as criarLinha,
111
- ns as criarMascara,
112
- is as criarPoligonoRegular,
113
- cs as criarRetangulo,
114
- ts as criarTexto,
115
- _ as dadosParaPainelDeCamadas,
116
- ms as deMm,
117
- As as decompor,
118
- ls as definirMedidorTexto,
119
- Ps as definirRaiosDoRetangulo,
120
- Es as desagrupar,
121
- ds as desenharElementos,
122
- bs as desenharPlano,
123
- Ds as deslocarCaminho,
124
- ps as determinante,
125
- Cs as diagnosticarContexto,
126
- Os as direcaoNaPonta,
127
- Ss as distribuir,
128
- _s as dividirComLinha,
129
- hs as duplicarElementos,
130
- Rs as ehFechado,
131
- h as ehFerramentaPrancha,
132
- Ns as ehIdentidade,
133
- Ms as ehMatrizFinita,
134
- Is as ehPredefinicao,
135
- Ts as ehPropriedadeDeGeometria,
136
- us as ehPropriedadePrancha,
137
- gs as ehSingular,
138
- Ls as ehUnidadePrancha,
139
- xs as elementoNoTopo,
140
- vs as elementosNaCaixa,
141
- fs as elementosNoLaco,
142
- Fs as elementosNoPonto,
143
- Hs as emTornoDe,
144
- zs as envelopeNaFolha,
145
- Us as envelopeVisual,
146
- Gs as escala,
147
- js as espelhamento,
148
- Bs as espelharElementos,
149
- R as eventoTratadoPelaPrancha,
150
- Xs as excluirAncora,
151
- Vs as expandirGrupos,
152
- Qs as exportarSvg,
153
- ks as faixasDoGradienteLinear,
154
- Ks as feicaoDoElemento,
155
- N as ferramentaDaPaleta,
156
- qs as fonteSegura,
157
- ws as geometriaDaPonta,
158
- ys as gerarPredefinicao,
159
- Js as girarElementos,
160
- Ws as guiasInteligentes,
161
- Ys as iguais,
162
- Zs as inverter,
163
- M as lerMargens,
164
- $s as liberarMascara,
165
- I as ligarPaineisPrancha,
166
- ao as limitesLocais,
167
- so as limitesNaFolha,
168
- oo as linhasDeHachura,
169
- ro as mapaDeCamadas,
170
- Pr as mapearPontoNaCaixa,
171
- eo as marcasDosCantos,
172
- no as margensAbnt,
173
- io as matriz,
174
- co as matrizDeCisalhamentoPorAlca,
175
- to as matrizDeEscalaPorAlca,
176
- mo as matrizDoElemento,
177
- Ao as meiaEspessura,
178
- lo as modoDeTransformacao,
179
- Po as moverAlcaDaAncora,
180
- Eo as moverAncora,
181
- bo as moverAncoras,
182
- Do as moverElemento,
183
- po as multiplicar,
184
- Co as normalizarAparencia,
185
- Oo as normalizarCamadas,
186
- So as normalizarElemento,
187
- _o as normalizarElementos,
188
- ho as normalizarGeometriaElemento,
189
- Ro as normalizarGradiente,
190
- No as normalizarHachura,
191
- Er as normalizarParaOrigem,
192
- Mo as operacaoBooleana,
193
- Io as ordenarPorEmpilhamento,
194
- To as padraoTipoLinhaMm,
195
- uo as paraMm,
196
- go as pivoNaFolha,
197
- Lo as planejar,
198
- xo as planejarElemento,
199
- vo as planejarElementos,
200
- fo as planoDe,
201
- Fo as pontoNoAnel,
202
- Ho as posicaoLocalDaAlca,
203
- zo as posicoesDasAlcas,
204
- Uo as profundidadeNoCanto,
205
- Go as raiosCabiveis,
206
- jo as raiosEfetivos,
207
- Bo as recompor,
208
- Xo as redefinirAvisoContexto,
209
- Vo as regiaoDoElemento,
210
- Qo as reordenar,
211
- ko as resolverAparencia,
212
- Ko as resolverSombra,
213
- dr as resumirAparencia,
214
- qo as rotacao,
215
- wo as rotacaoEmGraus,
216
- yo as rotacaoPorArrasto,
217
- T as rotuloDoTipo,
218
- Jo as saneada,
219
- Wo as simplificarCaminho,
220
- Yo as temMedidorTexto,
221
- Zo as temPreenchimento,
222
- $o as testarElemento,
223
- ar as transformarContorno,
224
- sr as transformarElemento,
225
- or as transformarElementos,
226
- rr as translacao,
227
- er as trechoMaisProximo,
228
- nr as unirCaminhos,
229
- ir as valorDaPropriedade,
230
- cr as varreduraDoArco
3247
+ kt as ALCAS_ESCALA,
3248
+ Ke as ATRIBUTOS_PRANCHA,
3249
+ G as CAMADA_SEM_CAMADA,
3250
+ Ti as CANAL_COMANDOS_PRANCHA,
3251
+ wi as COMANDOS_PRANCHA,
3252
+ lt as COR_PADRAO_PRANCHA,
3253
+ So as DIMENSOES_FOLHA,
3254
+ Po as EPSILON_DETERMINANTE,
3255
+ Mo as ESCALA_MINIMA,
3256
+ gn as ESPACO_GEOGRAFICO,
3257
+ bt as ESPACO_PLANO,
3258
+ zo as ESPESSURA_PADRAO_MM,
3259
+ nt as ESPESSURA_TRACO_PADRAO_MM,
3260
+ xo as ESTILOS_TRACO,
3261
+ Eo as ESTILO_DO_TIPO_LINHA,
3262
+ Co as FAIXAS_MAXIMO,
3263
+ To as FAIXAS_PADRAO,
3264
+ Ji as FERRAMENTAS_PALETA_PRANCHA,
3265
+ $e as FERRAMENTAS_PRANCHA,
3266
+ wo as FONTE_PADRAO,
3267
+ Do as FORMATOS_ABNT,
3268
+ et as Historico,
3269
+ Io as IDENTIDADE,
3270
+ Fo as IDS_PROPRIEDADES_PRANCHA,
3271
+ Oa as ITENS_PREDEFINICOES,
3272
+ at as IndicePrancha,
3273
+ _o as KAPPA,
3274
+ to as LARGURA_ESTREITA_PX,
3275
+ No as LIMITE_PONTA_PADRAO,
3276
+ Oo as MAX_LINHAS_HACHURA,
3277
+ Ro as MESCLAGEM_CSS,
3278
+ Lo as MM_POR_PX,
3279
+ ko as MM_POR_UNIDADE,
3280
+ mr as MODOS_MESCLAGEM,
3281
+ ar as OPERACOES_BOOLEANAS,
3282
+ qo as PREDEFINICOES,
3283
+ Bo as PRIORIDADE_SNAP_PRANCHA,
3284
+ W as PX_POR_MM_100,
3285
+ jo as ROTULOS_PREDEFINICOES,
3286
+ Go as SOMBRA_PADRAO,
3287
+ Ho as TIPO_LINHA_DO_ESTILO,
3288
+ Zi as UICanvasPrancha,
3289
+ Ri as UICanvasPranchaBase,
3290
+ uo as UIEditorPrancha,
3291
+ $o as adaptarContextoRelativo,
3292
+ Xt as adicionarAncora,
3293
+ Mt as agrupar,
3294
+ Vo as ajustarAparenciaEmLote,
3295
+ Ko as ajustarElementosACaixa,
3296
+ me as alcasDoElemento,
3297
+ xt as alinhar,
3298
+ rt as analisarElemento,
3299
+ Zt as ancoraMaisProxima,
3300
+ xa as ancorasDoElemento,
3301
+ Wo as aparenciaDe,
3302
+ Rt as aplicar,
3303
+ de as aplicarAparencia,
3304
+ er as aplicarPathfinder,
3305
+ Uo as aplicarTodos,
3306
+ Xo as aplicarVetor,
3307
+ Zo as areaComSinal,
3308
+ Jo as areaDosPoligonos,
3309
+ Qo as avisarUmaVez,
3310
+ se as buscarSnapPrancha,
3311
+ Ea as caixaDaSelecao,
3312
+ St as caixaDeCantos,
3313
+ ve as caixaDoQuadro,
3314
+ Yo as caixaDoQuadroAbnt,
3315
+ as as caixaDoTexto,
3316
+ es as caixaNormalizada,
3317
+ Ot as caixaOrientada,
3318
+ te as camadaDoPainel,
3319
+ Ui as camadasComMudanca,
3320
+ Xi as camadasNaOrdemDoPainel,
3321
+ ts as caminhoDoContorno,
3322
+ rs as caminhoFinito,
3323
+ is as caminhoParaSvg,
3324
+ Ki as categoriasDePropriedades,
3325
+ Vi as categoriasSemSelecao,
3326
+ ht as centroDaSelecao,
3327
+ os as cisalhamento,
3328
+ dr as comPropriedade,
3329
+ qt as comRaioDeCanto,
3330
+ ss as comoCaminhoNaFolha,
3331
+ Fa as compor,
3332
+ ns as comprimentoDaPonta,
3333
+ _t as contornoDoTraco,
3334
+ ls as contornoElipse,
3335
+ cs as contornoEstrela,
3336
+ us as contornoLocal,
3337
+ ds as contornoLocalEmCache,
3338
+ Ca as contornoNaFolha,
3339
+ hs as contornoPoligonoRegular,
3340
+ ms as contornoRetangulo,
3341
+ Jt as converterAncora,
3342
+ Nt as converterEmCaminho,
3343
+ fs as corComOpacidade,
3344
+ ps as corNaPosicao,
3345
+ _a as criarCaminho,
3346
+ ft as criarElipse,
3347
+ gt as criarEstrela,
3348
+ vt as criarLinha,
3349
+ Ct as criarMascara,
3350
+ pt as criarPoligonoRegular,
3351
+ mt as criarRetangulo,
3352
+ At as criarTexto,
3353
+ Wi as dadosParaPainelDeCamadas,
3354
+ Yt as deMm,
3355
+ gs as decompor,
3356
+ ir as definirMedidorTexto,
3357
+ ut as definirRaiosDoRetangulo,
3358
+ zt as desagrupar,
3359
+ $ as desenharElementos,
3360
+ vs as desenharPlano,
3361
+ It as deslocarCaminho,
3362
+ bs as determinante,
3363
+ ys as diagnosticarContexto,
3364
+ As as direcaoNaPonta,
3365
+ Et as distribuir,
3366
+ Dt as dividirComLinha,
3367
+ he as duplicarElementos,
3368
+ Ss as ehFechado,
3369
+ Ve as ehFerramentaPrancha,
3370
+ Ps as ehIdentidade,
3371
+ ne as ehMatrizFinita,
3372
+ sr as ehPredefinicao,
3373
+ ur as ehPropriedadeDeGeometria,
3374
+ cr as ehPropriedadePrancha,
3375
+ Ms as ehSingular,
3376
+ tr as ehUnidadePrancha,
3377
+ na as elementoNoTopo,
3378
+ Qt as elementosNaCaixa,
3379
+ zs as elementosNoLaco,
3380
+ xs as elementosNoPonto,
3381
+ Es as emTornoDe,
3382
+ Wt as envelopeNaFolha,
3383
+ Na as envelopeVisual,
3384
+ H as escala,
3385
+ Cs as espelhamento,
3386
+ ct as espelharElementos,
3387
+ bo as eventoTratadoPelaPrancha,
3388
+ ce as excluirAncora,
3389
+ st as expandirGrupos,
3390
+ lr as exportarSvg,
3391
+ Ts as faixasDoGradienteLinear,
3392
+ ws as feicaoDoElemento,
3393
+ Qi as ferramentaDaPaleta,
3394
+ Ds as fonteSegura,
3395
+ Is as geometriaDaPonta,
3396
+ nr as gerarPredefinicao,
3397
+ Fs as girarElementos,
3398
+ Vt as guiasInteligentes,
3399
+ _s as iguais,
3400
+ Ge as instalarIsolamentoDeTeclas,
3401
+ He as instalarTecladoModal,
3402
+ Ns as inverter,
3403
+ We as lerMargens,
3404
+ j as lerModoTeclado,
3405
+ Tt as liberarMascara,
3406
+ eo as ligarPaineisPrancha,
3407
+ Os as limitesLocais,
3408
+ Y as limitesNaFolha,
3409
+ Rs as linhasDeHachura,
3410
+ it as mapaDeCamadas,
3411
+ Ls as mapearPontoNaCaixa,
3412
+ Kt as marcasDosCantos,
3413
+ ks as margensAbnt,
3414
+ qs as matriz,
3415
+ Ht as matrizDeCisalhamentoPorAlca,
3416
+ $t as matrizDeEscalaPorAlca,
3417
+ Bs as matrizDoElemento,
3418
+ js as meiaEspessura,
3419
+ Gs as modoDeTransformacao,
3420
+ Bt as moverAlcaDaAncora,
3421
+ jt as moverAncora,
3422
+ le as moverAncoras,
3423
+ Hs as moverElemento,
3424
+ $s as multiplicar,
3425
+ Vs as normalizarAparencia,
3426
+ ot as normalizarCamadas,
3427
+ dt as normalizarElemento,
3428
+ tt as normalizarElementos,
3429
+ Ks as normalizarGeometriaElemento,
3430
+ Ws as normalizarGradiente,
3431
+ Us as normalizarHachura,
3432
+ Xs as normalizarParaOrigem,
3433
+ Zs as operacaoBooleana,
3434
+ U as ordenarPorEmpilhamento,
3435
+ Js as padraoTipoLinhaMm,
3436
+ yt as paraMm,
3437
+ Qs as pivoNaFolha,
3438
+ Ys as planejar,
3439
+ an as planejarElemento,
3440
+ en as planejarElementos,
3441
+ tn as planoDe,
3442
+ rn as pontoNoAnel,
3443
+ Lt as posicaoLocalDaAlca,
3444
+ fe as posicoesDasAlcas,
3445
+ ge as profundidadeNoCanto,
3446
+ on as raiosCabiveis,
3447
+ pe as raiosEfetivos,
3448
+ sn as recompor,
3449
+ nn as redefinirAvisoContexto,
3450
+ ln as regiaoDoElemento,
3451
+ Pt as reordenar,
3452
+ pr as resolverAparencia,
3453
+ cn as resolverSombra,
3454
+ un as resumirAparencia,
3455
+ za as rotacao,
3456
+ hr as rotacaoEmGraus,
3457
+ Gt as rotacaoPorArrasto,
3458
+ Ue as rotuloDoTipo,
3459
+ or as saneada,
3460
+ Ft as simplificarCaminho,
3461
+ Be as teclaReservadaDoNavegador,
3462
+ rr as temMedidorTexto,
3463
+ dn as temPreenchimento,
3464
+ hn as testarElemento,
3465
+ mn as transformarContorno,
3466
+ ue as transformarElemento,
3467
+ I as transformarElementos,
3468
+ k as translacao,
3469
+ Ut as trechoMaisProximo,
3470
+ wt as unirCaminhos,
3471
+ fr as valorDaPropriedade,
3472
+ fn as varreduraDoArco
231
3473
  };