kritzel-stencil 0.1.78 → 0.1.80

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 (163) hide show
  1. package/dist/cjs/{index-BRZ6e6oa.js → index-CFnj_FXt.js} +36 -9
  2. package/dist/cjs/index.cjs.js +1 -1
  3. package/dist/cjs/kritzel-active-users_42.cjs.entry.js +333 -177
  4. package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/stencil.cjs.js +3 -3
  7. package/dist/cjs/{workspace.migrations-sUPrO23c.js → workspace.migrations-DUXtSb7C.js} +244 -197
  8. package/dist/collection/classes/core/core.class.js +39 -31
  9. package/dist/collection/classes/core/store.class.js +57 -16
  10. package/dist/collection/classes/core/viewport.class.js +12 -12
  11. package/dist/collection/classes/handlers/context-menu.handler.js +1 -1
  12. package/dist/collection/classes/handlers/line-handle.handler.js +7 -4
  13. package/dist/collection/classes/handlers/move.handler.js +11 -8
  14. package/dist/collection/classes/handlers/resize.handler.js +12 -3
  15. package/dist/collection/classes/handlers/rotation.handler.js +12 -3
  16. package/dist/collection/classes/handlers/selection.handler.js +20 -15
  17. package/dist/collection/classes/managers/anchor.manager.js +4 -4
  18. package/dist/collection/classes/objects/base-object.class.js +6 -6
  19. package/dist/collection/classes/objects/custom-element.class.js +2 -2
  20. package/dist/collection/classes/objects/group.class.js +10 -10
  21. package/dist/collection/classes/objects/image.class.js +2 -2
  22. package/dist/collection/classes/objects/line.class.js +7 -7
  23. package/dist/collection/classes/objects/path.class.js +5 -5
  24. package/dist/collection/classes/objects/selection-box.class.js +1 -1
  25. package/dist/collection/classes/objects/selection-group.class.js +16 -16
  26. package/dist/collection/classes/objects/shape.class.js +37 -31
  27. package/dist/collection/classes/objects/text.class.js +40 -32
  28. package/dist/collection/classes/structures/app-state-map.structure.js +18 -16
  29. package/dist/collection/classes/structures/object-map.structure.js +30 -27
  30. package/dist/collection/classes/tools/brush-tool.class.js +14 -14
  31. package/dist/collection/classes/tools/image-tool.class.js +1 -1
  32. package/dist/collection/classes/tools/line-tool.class.js +14 -14
  33. package/dist/collection/classes/tools/selection-tool.class.js +2 -2
  34. package/dist/collection/classes/tools/shape-tool.class.js +6 -6
  35. package/dist/collection/classes/tools/text-tool.class.js +2 -2
  36. package/dist/collection/collection-manifest.json +1 -1
  37. package/dist/collection/components/core/kritzel-awareness-cursors/kritzel-awareness-cursors.js +6 -6
  38. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +2 -2
  39. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +70 -11
  40. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +21 -1
  41. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +159 -60
  42. package/dist/collection/configs/default-engine-config.js +2 -2
  43. package/dist/collection/constants/version.js +1 -1
  44. package/dist/collection/helpers/keyboard.helper.js +15 -11
  45. package/dist/components/index.js +1 -1
  46. package/dist/components/kritzel-active-users.js +1 -1
  47. package/dist/components/kritzel-avatar.js +1 -1
  48. package/dist/components/kritzel-awareness-cursors.js +1 -1
  49. package/dist/components/kritzel-back-to-content.js +1 -1
  50. package/dist/components/kritzel-brush-style.js +1 -1
  51. package/dist/components/kritzel-button.js +1 -1
  52. package/dist/components/kritzel-color-palette.js +1 -1
  53. package/dist/components/kritzel-color.js +1 -1
  54. package/dist/components/kritzel-context-menu.js +1 -1
  55. package/dist/components/kritzel-controls.js +1 -1
  56. package/dist/components/kritzel-current-user-dialog.js +1 -1
  57. package/dist/components/kritzel-current-user.js +1 -1
  58. package/dist/components/kritzel-cursor-trail.js +1 -1
  59. package/dist/components/kritzel-dialog.js +1 -1
  60. package/dist/components/kritzel-dropdown.js +1 -1
  61. package/dist/components/kritzel-editor.js +1 -1
  62. package/dist/components/kritzel-engine.js +1 -1
  63. package/dist/components/kritzel-export.js +1 -1
  64. package/dist/components/kritzel-font-family.js +1 -1
  65. package/dist/components/kritzel-font-size.js +1 -1
  66. package/dist/components/kritzel-font.js +1 -1
  67. package/dist/components/kritzel-icon.js +1 -1
  68. package/dist/components/kritzel-input.js +1 -1
  69. package/dist/components/kritzel-line-endings.js +1 -1
  70. package/dist/components/kritzel-login-dialog.js +1 -1
  71. package/dist/components/kritzel-master-detail.js +1 -1
  72. package/dist/components/kritzel-menu-item.js +1 -1
  73. package/dist/components/kritzel-menu.js +1 -1
  74. package/dist/components/kritzel-more-menu.js +1 -1
  75. package/dist/components/kritzel-numeric-input.js +1 -1
  76. package/dist/components/kritzel-opacity-slider.js +1 -1
  77. package/dist/components/kritzel-pill-tabs.js +1 -1
  78. package/dist/components/kritzel-portal.js +1 -1
  79. package/dist/components/kritzel-settings.js +1 -1
  80. package/dist/components/kritzel-shape-fill.js +1 -1
  81. package/dist/components/kritzel-share-dialog.js +1 -1
  82. package/dist/components/kritzel-slide-toggle.js +1 -1
  83. package/dist/components/kritzel-split-button.js +1 -1
  84. package/dist/components/kritzel-stroke-size.js +1 -1
  85. package/dist/components/kritzel-tool-config.js +1 -1
  86. package/dist/components/kritzel-tooltip.js +1 -1
  87. package/dist/components/kritzel-utility-panel.js +1 -1
  88. package/dist/components/kritzel-workspace-manager.js +1 -1
  89. package/dist/components/{p-Md9Y-b3d.js → p-1ppb4M65.js} +1 -1
  90. package/dist/components/{p-KJ4dHzrS.js → p-7yR-sKH8.js} +1 -1
  91. package/dist/components/{p-CN8IxBlU.js → p-B-Gej_Ak.js} +1 -1
  92. package/dist/components/{p-76W5pG2O.js → p-B4F19Aqj.js} +1 -1
  93. package/dist/components/{p-BuI6Gkzg.js → p-B5WII1Lk.js} +1 -1
  94. package/dist/components/p-BWj1eE2b.js +1 -0
  95. package/dist/components/{p-ZC5YELQJ.js → p-BZ8bK8qT.js} +1 -1
  96. package/dist/components/{p-DkWWzVg8.js → p-BaaFG0p-.js} +1 -1
  97. package/dist/components/{p-6NFl6EB2.js → p-Bat829Bg.js} +1 -1
  98. package/dist/components/p-BcwZ36sO.js +1 -0
  99. package/dist/components/{p-53di1Zko.js → p-BjPmEs5A.js} +1 -1
  100. package/dist/components/{p-D5IhryUR.js → p-Brwz_Dpb.js} +1 -1
  101. package/dist/components/p-BzQmBVwr.js +9 -0
  102. package/dist/components/{p-C2l9mZ1P.js → p-C-MtTi6x.js} +1 -1
  103. package/dist/components/p-C8WnYSHi.js +1 -0
  104. package/dist/components/{p-BLsH_Oi0.js → p-C9zsWWH2.js} +1 -1
  105. package/dist/components/{p-ZQ2bKafG.js → p-CJKsuQun.js} +1 -1
  106. package/dist/components/{p-m1nVDC3G.js → p-CJzg_ejc.js} +1 -1
  107. package/dist/components/{p-Dte67BWd.js → p-CM7rYf9A.js} +1 -1
  108. package/dist/components/{p-Dr3-pKVg.js → p-CMGHx71q.js} +1 -1
  109. package/dist/components/{p-CI9Nbh-x.js → p-CNMpVlot.js} +1 -1
  110. package/dist/components/{p-DDKjsXCe.js → p-CS7r-zhx.js} +1 -1
  111. package/dist/components/{p-DaGZEV0R.js → p-C_fSm7T4.js} +1 -1
  112. package/dist/components/{p-Ck1dhpUQ.js → p-CfEGaTaV.js} +1 -1
  113. package/dist/components/{p-CWMFGEe0.js → p-CvyE2Wg-.js} +1 -1
  114. package/dist/components/{p-D3pNw-SV.js → p-D5BXoK9m.js} +1 -1
  115. package/dist/components/{p-DV7Z_qfa.js → p-D7pwbRUy.js} +1 -1
  116. package/dist/components/{p-CBslLN3-.js → p-DCH4Rlqx.js} +1 -1
  117. package/dist/components/{p-CYh7yV-K.js → p-DEOUiiyI.js} +1 -1
  118. package/dist/components/{p-pCC6t6BH.js → p-DKeBfe_l.js} +1 -1
  119. package/dist/components/{p-DWsCbu01.js → p-DUQmBcTy.js} +1 -1
  120. package/dist/components/{p-D14QNK3X.js → p-DUnKjQN7.js} +1 -1
  121. package/dist/components/{p-BrZ_gL8Q.js → p-DYcsC2zO.js} +1 -1
  122. package/dist/components/{p-D7yzmu1l.js → p-DkT0KZCm.js} +1 -1
  123. package/dist/components/{p-Cns7qSKS.js → p-DrsORMoT.js} +1 -1
  124. package/dist/components/{p-BueaqfA2.js → p-Dw0Obsn5.js} +1 -1
  125. package/dist/components/{p-DxzDda_J.js → p-Gm5hSQ-e.js} +1 -1
  126. package/dist/components/{p-C4fKLlrd.js → p-HK-6khHo.js} +1 -1
  127. package/dist/components/{p-_QEHfsIk.js → p-V3VW2JKl.js} +1 -1
  128. package/dist/components/{p-Lhyh6KeB.js → p-VxgCvVox.js} +1 -1
  129. package/dist/components/{p-l_YGO7RB.js → p-cjeDomsc.js} +1 -1
  130. package/dist/components/{p-gtQlsorg.js → p-rNu5JVNH.js} +1 -1
  131. package/dist/components/p-xYCbKFih.js +1 -0
  132. package/dist/esm/{index-BbOHefEf.js → index-D9HaikfQ.js} +36 -9
  133. package/dist/esm/index.js +1 -1
  134. package/dist/esm/kritzel-active-users_42.entry.js +333 -177
  135. package/dist/esm/kritzel-brush-style.entry.js +1 -1
  136. package/dist/esm/loader.js +3 -3
  137. package/dist/esm/stencil.js +4 -4
  138. package/dist/esm/{workspace.migrations-NhRgr2_H.js → workspace.migrations-OzSSw5kt.js} +244 -197
  139. package/dist/stencil/index.esm.js +1 -1
  140. package/dist/stencil/p-D9HaikfQ.js +2 -0
  141. package/dist/stencil/p-OzSSw5kt.js +1 -0
  142. package/dist/stencil/{p-98238bf9.entry.js → p-b0be4da1.entry.js} +1 -1
  143. package/dist/stencil/p-f7be06a8.entry.js +9 -0
  144. package/dist/stencil/stencil.esm.js +1 -1
  145. package/dist/types/classes/core/store.class.d.ts +23 -0
  146. package/dist/types/classes/objects/shape.class.d.ts +1 -0
  147. package/dist/types/classes/objects/text.class.d.ts +1 -0
  148. package/dist/types/classes/providers/hocuspocus-sync-provider.class.d.ts +1 -1
  149. package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +7 -5
  150. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +10 -4
  151. package/dist/types/components.d.ts +35 -13
  152. package/dist/types/constants/version.d.ts +1 -1
  153. package/dist/types/helpers/tool-config.helper.d.ts +1 -1
  154. package/dist/types/interfaces/engine-state.interface.d.ts +10 -10
  155. package/package.json +1 -1
  156. package/dist/components/p-Ban3OlgZ.js +0 -9
  157. package/dist/components/p-CGGiwvWZ.js +0 -1
  158. package/dist/components/p-CHY71o5B.js +0 -1
  159. package/dist/components/p-DXpYcAnT.js +0 -1
  160. package/dist/components/p-pGzF7PUB.js +0 -1
  161. package/dist/stencil/p-4a4b38e4.entry.js +0 -9
  162. package/dist/stencil/p-BbOHefEf.js +0 -2
  163. package/dist/stencil/p-NhRgr2_H.js +0 -1
@@ -1 +0,0 @@
1
- function t(t,e,n){const l="undefined"!=typeof HTMLElement?HTMLElement.prototype:null;for(;t&&t!==l;){const l=Object.getOwnPropertyDescriptor(t,e);if(l&&(!n||l.get))return l;t=Object.getPrototypeOf(t)}}var e,n=(e,n)=>{var l;Object.entries(null!=(l=n.l.t)?l:{}).map((([l,[o]])=>{if(31&o||32&o){const o=e[l],s=t(Object.getPrototypeOf(e),l,!0)||Object.getOwnPropertyDescriptor(e,l);s&&Object.defineProperty(e,l,{get(){return s.get.call(this)},set(t){s.set.call(this,t)},configurable:!0,enumerable:!0}),n.o.has(l)?e[l]=n.o.get(l):void 0!==o&&(e[l]=o)}}))},l=t=>{if(t.__stencil__getHostRef)return t.__stencil__getHostRef()},o=(t,e)=>e in t,s=(t,e)=>(0,console.error)(t,e),i=new Map,r="undefined"!=typeof window?window:{},c=r.HTMLElement||class{},u={i:0,u:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,l)=>t.addEventListener(e,n,l),rel:(t,e,n,l)=>t.removeEventListener(e,n,l),ce:(t,e)=>new CustomEvent(t,e)},f=(()=>{var t;let e=!1;try{null==(t=r.document)||t.addEventListener("e",null,Object.defineProperty({},"passive",{get(){e=!0}}))}catch(t){}return e})(),a=(()=>{try{return!!r.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(t){}return!1})(),d=!!a&&(()=>!!r.document&&Object.getOwnPropertyDescriptor(r.document.adoptedStyleSheets,"length").writable)(),p=!1,h=[],m=[],b=(t,e)=>n=>{t.push(n),p||(p=!0,e&&4&u.i?$(y):u.raf(y))},v=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){s(t)}t.length=0},y=()=>{v(h),v(m),(p=h.length>0)&&u.raf(y)},$=t=>Promise.resolve(undefined).then(t),w=b(m,!0),g=t=>{const e=new URL(t,u.u);return e.origin!==r.location.origin?e.href:e.pathname},j=t=>u.u=t;function O(){const t=this.attachShadow({mode:"open"});void 0===e&&(e=null),e&&(d?t.adoptedStyleSheets.push(e):t.adoptedStyleSheets=[...t.adoptedStyleSheets,e])}var S,M=new WeakMap,k=t=>"sc-"+t.p,E=t=>"object"==(t=typeof t)||"function"===t,A=(t,e,...n)=>{let l=null,o=null,s=!1,i=!1;const r=[],c=e=>{for(let n=0;n<e.length;n++)l=e[n],Array.isArray(l)?c(l):null!=l&&"boolean"!=typeof l&&((s="function"!=typeof t&&!E(l))&&(l=String(l)),s&&i?r[r.length-1].h+=l:r.push(s?C(null,l):l),i=s)};if(c(n),e){e.key&&(o=e.key);{const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter((e=>t[e])).join(" "))}}const u=C(t,null);return u.m=e,r.length>0&&(u.v=r),u.$=o,u},C=(t,e)=>({i:0,j:t,h:null!=e?e:null,O:null,v:null,m:null,$:null}),x={},L=(t,e)=>null==t||E(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?"string"==typeof t?parseFloat(t):"number"==typeof t?t:NaN:1&e?String(t):t,N=(t,e)=>{const n=t;return{emit:t=>_(n,e,{bubbles:!0,composed:!0,cancelable:!0,detail:t})}},_=(t,e,n)=>{const l=u.ce(e,n);return t.dispatchEvent(l),l},D=(t,e,n,s,i,c)=>{if(n===s)return;let f=o(t,e),a=e.toLowerCase();if("class"===e){const e=t.classList,l=P(n);let o=P(s);e.remove(...l.filter((t=>t&&!o.includes(t)))),e.add(...o.filter((t=>t&&!l.includes(t))))}else if("style"===e){for(const e in n)s&&null!=s[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in s)n&&s[e]===n[e]||(e.includes("-")?t.style.setProperty(e,s[e]):t.style[e]=s[e])}else if("key"===e);else if("ref"===e)s&&K(s,t);else if(t.__lookupSetter__(e)||"o"!==e[0]||"n"!==e[1]){if("a"===e[0]&&e.startsWith("attr:")){const n=e.slice(5);let o;{const e=l(t);if(e&&e.l&&e.l.t){const t=e.l.t[n];t&&t[1]&&(o=t[1])}}return o||(o=n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),void(null==s||!1===s?!1===s&&""!==t.getAttribute(o)||t.removeAttribute(o):t.setAttribute(o,!0===s?"":s))}if("p"===e[0]&&e.startsWith("prop:")){const n=e.slice(5);try{t[n]=s}catch(t){}return}{const l=E(s);if((f||l&&null!==s)&&!i)try{if(t.tagName.includes("-"))t[e]!==s&&(t[e]=s);else{const l=null==s?"":s;"list"===e?f=!1:null!=n&&t[e]===l||("function"==typeof t.__lookupSetter__(e)?t[e]=l:t.setAttribute(e,l))}}catch(t){}null==s||!1===s?!1===s&&""!==t.getAttribute(e)||t.removeAttribute(e):(!f||4&c||i)&&!l&&1===t.nodeType&&t.setAttribute(e,s=!0===s?"":s)}}else if(e="-"===e[2]?e.slice(3):o(r,a)?a.slice(2):a[2]+e.slice(3),n||s){const l=e.endsWith(R);e=e.replace(U,""),n&&u.rel(t,e,n,l),s&&u.ael(t,e,s,l)}},H=/\s/,P=t=>("object"==typeof t&&t&&"baseVal"in t&&(t=t.baseVal),t&&"string"==typeof t?t.split(H):[]),R="Capture",U=new RegExp(R+"$"),W=(t,e,n)=>{const l=11===e.O.nodeType&&e.O.host?e.O.host:e.O,o=t&&t.m||{},s=e.m||{};for(const t of F(Object.keys(o)))t in s||D(l,t,o[t],void 0,n,e.i);for(const t of F(Object.keys(s)))D(l,t,o[t],s[t],n,e.i)};function F(t){return t.includes("ref")?[...t.filter((t=>"ref"!==t)),"ref"]:t}var V=!1,q=!1,z=[],T=[],Y=(t,e,n)=>{const l=e.v[n];let o,s,i=0;if(null!=l.h)o=l.O=r.document.createTextNode(l.h);else{if(q||(q="svg"===l.j),!r.document)throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(o=l.O=r.document.createElementNS(q?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",l.j),q&&"foreignObject"===l.j&&(q=!1),W(null,l,q),l.v){const e="template"===l.j?o.content:o;for(i=0;i<l.v.length;++i)s=Y(t,l,i),s&&e.appendChild(s)}"svg"===l.j?q=!1:"foreignObject"===o.tagName&&(q=!0)}return o["s-hn"]=S,o},Z=(t,e,n,l,o,s)=>{let i,r=t;for(r.shadowRoot&&r.tagName===S&&(r=r.shadowRoot),"template"===n.j&&(r=r.content);o<=s;++o)l[o]&&(i=Y(null,n,o),i&&(l[o].O=i,Q(r,i,e)))},B=(t,e,n)=>{for(let l=e;l<=n;++l){const e=t[l];if(e){const t=e.O;J(e),t&&t.remove()}}},G=(t,e,n=!1)=>t.j===e.j&&(n?(n&&!t.$&&e.$&&(t.$=e.$),!0):t.$===e.$),I=(t,e,n=!1)=>{const l=e.O=t.O,o=t.v,s=e.v,i=e.j,r=e.h;null==r?(q="svg"===i||"foreignObject"!==i&&q,"slot"!==i||V||t.S!==e.S&&(e.O["s-sn"]=e.S||"",(t=>{u.i|=1;const e=t.closest(S.toLowerCase());if(null!=e){const n=Array.from(e.__childNodes||e.childNodes).find((t=>t["s-cr"])),l=Array.from(t.__childNodes||t.childNodes);for(const t of n?l.reverse():l)null!=t["s-sh"]&&(Q(e,t,null!=n?n:null),t["s-sh"]=void 0)}u.i&=-2})(e.O.parentElement)),W(t,e,q),null!==o&&null!==s?((t,e,n,l,o=!1)=>{let s,i,r=0,c=0,u=0,f=0,a=e.length-1,d=e[0],p=e[a],h=l.length-1,m=l[0],b=l[h];const v="template"===n.j?t.content:t;for(;r<=a&&c<=h;)if(null==d)d=e[++r];else if(null==p)p=e[--a];else if(null==m)m=l[++c];else if(null==b)b=l[--h];else if(G(d,m,o))I(d,m,o),d=e[++r],m=l[++c];else if(G(p,b,o))I(p,b,o),p=e[--a],b=l[--h];else if(G(d,b,o))I(d,b,o),Q(v,d.O,p.O.nextSibling),d=e[++r],b=l[--h];else if(G(p,m,o))I(p,m,o),Q(v,p.O,d.O),p=e[--a],m=l[++c];else{for(u=-1,f=r;f<=a;++f)if(e[f]&&null!==e[f].$&&e[f].$===m.$){u=f;break}u>=0?(i=e[u],i.j!==m.j?s=Y(e&&e[c],n,u):(I(i,m,o),e[u]=void 0,s=i.O),m=l[++c]):(s=Y(e&&e[c],n,c),m=l[++c]),s&&Q(d.O.parentNode,s,d.O)}r>a?Z(t,null==l[h+1]?null:l[h+1].O,n,l,c,h):c>h&&B(e,r,a)})(l,o,e,s,n):null!==s?(null!==t.h&&(l.textContent=""),Z(l,null,e,s,0,s.length-1)):!n&&null!==o&&B(o,0,o.length-1),q&&"svg"===i&&(q=!1)):t.h!==r&&(l.data=r)},J=t=>{t.m&&t.m.ref&&z.push((()=>t.m.ref(null))),t.v&&t.v.map(J)},K=(t,e)=>{T.push((()=>t(e)))},Q=(t,e,n)=>t.__insertBefore?t.__insertBefore(e,n):null==t?void 0:t.insertBefore(e,n),X=(t,e,n=!1)=>{const l=t.$hostElement$,o=t.l,s=t.M||C(null,null);var i;const r=(i=e)&&i.j===x?e:A(null,null,e);if(S=l.tagName,o.k&&(r.m=r.m||{},o.k.forEach((([t,e])=>{r.m[e]=l[t]}))),n&&r.m)for(const t of Object.keys(r.m))l.hasAttribute(t)&&!["key","ref","style","class"].includes(t)&&(r.m[t]=l[t]);r.j=null,r.i|=4,t.M=r,r.O=s.O=l.shadowRoot||l,V=!(!(1&o.i)||128&o.i),I(s,r,n),z.forEach((t=>t())),z.length=0,T.forEach((t=>t())),T.length=0},tt=(t,e)=>{if(e&&!t.A&&e["s-p"]){const n=e["s-p"].push(new Promise((l=>t.A=()=>{e["s-p"].splice(n-1,1),l()})))}},et=(t,e)=>{if(t.i|=16,4&t.i)return void(t.i|=512);tt(t,t.C);const n=()=>nt(t,e);if(!e)return w(n);queueMicrotask((()=>{n()}))},nt=(t,e)=>{const n=t.$hostElement$,l=n;if(!l)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let o;return o=ut(l,e?"componentWillLoad":"componentWillUpdate",void 0,n),o=lt(o,(()=>ut(l,"componentWillRender",void 0,n))),lt(o,(()=>st(t,l,e)))},lt=(t,e)=>ot(t)?t.then(e).catch((t=>{console.error(t),e()})):e(),ot=t=>t instanceof Promise||t&&t.then&&"function"==typeof t.then,st=async(t,e,n)=>{var l;const o=t.$hostElement$,s=o["s-rc"];n&&(t=>{const e=t.l,n=t.$hostElement$,l=e.i,o=((t,e)=>{var n,l,o;const s=k(e),c=i.get(s);if(!r.document)return s;if(t=11===t.nodeType?t:r.document,c)if("string"==typeof c){let o,i=M.get(t=t.head||t);if(i||M.set(t,i=new Set),!i.has(s)){o=r.document.createElement("style"),o.textContent=c;const f=null!=(n=u.L)?n:function(){var t,e,n;return null!=(n=null==(e=null==(t=r.document.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:e.getAttribute("content"))?n:void 0}();if(null!=f&&o.setAttribute("nonce",f),!(1&e.i))if("HEAD"===t.nodeName){const e=t.querySelectorAll("link[rel=preconnect]"),n=e.length>0?e[e.length-1].nextSibling:t.querySelector("style");t.insertBefore(o,(null==n?void 0:n.parentNode)===t?n:null)}else if("host"in t)if(a){const e=new(null!=(l=t.defaultView)?l:t.ownerDocument.defaultView).CSSStyleSheet;e.replaceSync(c),d?t.adoptedStyleSheets.unshift(e):t.adoptedStyleSheets=[e,...t.adoptedStyleSheets]}else{const e=t.querySelector("style");e?e.textContent=c+e.textContent:t.prepend(o)}else t.append(o);1&e.i&&t.insertBefore(o,null),4&e.i&&(o.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),i&&i.add(s)}}else{let e=M.get(t);if(e||M.set(t,e=new Set),!e.has(s)){const n=null!=(o=t.defaultView)?o:t.ownerDocument.defaultView;let l;if(c.constructor===n.CSSStyleSheet)l=c;else{l=new n.CSSStyleSheet;for(let t=0;t<c.cssRules.length;t++)l.insertRule(c.cssRules[t].cssText,t)}d?t.adoptedStyleSheets.push(l):t.adoptedStyleSheets=[...t.adoptedStyleSheets,l],e.add(s)}}return s})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(t);it(t,e,o,n),s&&(s.map((t=>t())),o["s-rc"]=void 0);{const e=null!=(l=o["s-p"])?l:[],n=()=>rt(t);0===e.length?n():(Promise.all(e).then(n).catch(n),t.i|=4,e.length=0)}},it=(t,e,n,l)=>{try{e=e.render(),t.i&=-17,t.i|=2,X(t,e,l)}catch(e){s(e,t.$hostElement$)}return null},rt=t=>{const e=t.$hostElement$,n=e,l=t.C;ut(n,"componentDidRender",void 0,e),64&t.i?ut(n,"componentDidUpdate",void 0,e):(t.i|=64,ft(e),ut(n,"componentDidLoad",void 0,e),t.N(e),l||ct()),t.A&&(t.A(),t.A=void 0),512&t.i&&$((()=>et(t,!1))),t.i&=-517},ct=()=>{$((()=>_(r,"appload",{detail:{namespace:"stencil"}})))},ut=(t,e,n,l)=>{if(t&&t[e])try{return t[e](n)}catch(t){s(t,l)}},ft=t=>t.classList.add("hydrated"),at=(t,e,n,o)=>{const i=l(t);if(!i)return;const r=t,c=i.o.get(e),u=i.i,f=r;n=L(n,o.t[e][0]);const a=Number.isNaN(c)&&Number.isNaN(n);if(n!==c&&!a){if(i.o.set(e,n),o._){const t=o._[e];t&&t.map((t=>{try{const[[l,o]]=Object.entries(t);(128&u||1&o)&&(f?f[l](n,c,e):i.D.push((()=>{i.H[l](n,c,e)})))}catch(t){s(t,r)}}))}if(2&u){if(f.componentShouldUpdate&&!1===f.componentShouldUpdate(n,c,e)&&!(16&u))return;16&u||et(i,!1)}}},dt=(e,n)=>{var o,s;const i=e.prototype;{e.watchers&&!n._&&(n._=e.watchers),e.deserializers&&!n.P&&(n.P=e.deserializers),e.serializers&&!n.R&&(n.R=e.serializers);const r=Object.entries(null!=(o=n.t)?o:{});r.map((([e,[o]])=>{if(31&o||32&o){const{get:s,set:r}=t(i,e)||{};s&&(n.t[e][0]|=2048),r&&(n.t[e][0]|=4096),Object.defineProperty(i,e,{get(){return s?s.apply(this):(t=e,l(this).o.get(t));var t},configurable:!0,enumerable:!0}),Object.defineProperty(i,e,{set(t){const s=l(this);if(s){if(r)return void 0===(32&o?this[e]:s.$hostElement$[e])&&s.o.get(e)&&(t=s.o.get(e)),r.apply(this,[L(t,o)]),void at(this,e,t=32&o?this[e]:s.$hostElement$[e],n);at(this,e,t,n)}}})}}));{const t=new Map;i.attributeChangedCallback=function(e,o,s){u.jmp((()=>{var c;const u=t.get(e),f=l(this);if(this.hasOwnProperty(u),i.hasOwnProperty(u)&&"number"==typeof this[u]&&this[u]==s)return;if(null==u){const t=null==f?void 0:f.i;if(f&&t&&!(8&t)&&s!==o){const l=this,i=null==(c=n._)?void 0:c[e];null==i||i.forEach((n=>{const[[i,r]]=Object.entries(n);null!=l[i]&&(128&t||1&r)&&l[i].call(l,s,o,e)}))}return}const a=r.find((([t])=>t===u));a&&4&a[1][0]&&(s=null!==s&&"false"!==s);const d=Object.getOwnPropertyDescriptor(i,u);s==this[u]||d.get&&!d.set||(this[u]=s)}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(s=n._)?s:{}),...r.filter((([t,e])=>31&e[0])).map((([e,l])=>{var o;const s=l[1]||e;return t.set(s,e),512&l[0]&&(null==(o=n.k)||o.push([e,s])),s}))]))}}return e},pt=(t,e)=>{const o={i:e[0],p:e[1]};try{o.t=e[2],o.U=e[3],o._=t._,o.P=t.P,o.R=t.R,o.k=[];const r=t.prototype.connectedCallback,c=t.prototype.disconnectedCallback;return Object.assign(t.prototype,{__hasHostListenerAttached:!1,__registerHost(){((t,e)=>{const l={i:0,$hostElement$:t,l:e,o:new Map,W:new Map};l.F=new Promise((t=>l.N=t)),t["s-p"]=[],t["s-rc"]=[];const o=l;t.__stencil__getHostRef=()=>o,512&e.i&&n(t,l)})(this,o)},connectedCallback(){if(!this.__hasHostListenerAttached){const t=l(this);if(!t)return;ht(this,t,o.U),this.__hasHostListenerAttached=!0}(t=>{if(!(1&u.i)){const e=l(t);if(!e)return;const n=e.l,o=()=>{};if(1&e.i)ht(t,e,n.U),(null==e?void 0:e.H)||(null==e?void 0:e.F)&&e.F.then((()=>{}));else{e.i|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){tt(e,e.C=n);break}}n.t&&Object.entries(n.t).map((([e,[n]])=>{if(31&n&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];delete t[e],t[e]=n}})),(async(t,e,n)=>{let l;try{if(!(32&e.i)&&(e.i|=32,l=t.constructor,customElements.whenDefined(t.localName).then((()=>e.i|=128)),l&&l.style)){let t;"string"==typeof l.style&&(t=l.style);const e=k(n);if(!i.has(e)){const l=()=>{};((t,e,n)=>{let l=i.get(t);a&&n?(l=l||new CSSStyleSheet,"string"==typeof l?l=e:l.replaceSync(e)):l=e,i.set(t,l)})(e,t,!!(1&n.i)),l()}}const o=e.C,s=()=>et(e,!0);o&&o["s-rc"]?o["s-rc"].push(s):s()}catch(n){s(n,t),e.A&&(e.A(),e.A=void 0),e.N&&e.N(t)}})(t,e,n)}o()}})(this),r&&r.call(this)},disconnectedCallback(){(async t=>{if(!(1&u.i)){const e=l(t);(null==e?void 0:e.V)&&(e.V.map((t=>t())),e.V=void 0)}M.has(t)&&M.delete(t),t.shadowRoot&&M.has(t.shadowRoot)&&M.delete(t.shadowRoot)})(this),c&&c.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw new Error(`Unable to re-use existing shadow root for ${o.p}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else O.call(this,o)}}),Object.defineProperty(t,"is",{value:o.p,configurable:!0}),dt(t,o)}catch(e){return s(e),t}},ht=(t,e,n)=>{n&&r.document&&n.map((([n,l,o])=>{const s=bt(r.document,t,n),i=mt(e,o),c=vt(n);u.ael(s,l,i,c),(e.V=e.V||[]).push((()=>u.rel(s,l,i,c)))}))},mt=(t,e)=>n=>{try{t.$hostElement$[e](n)}catch(e){s(e,t.$hostElement$)}},bt=(t,e,n)=>4&n?t:8&n?r:e,vt=t=>f?{passive:!!(1&t),capture:!!(2&t)}:!!(2&t),yt=t=>u.L=t,$t=t=>Object.assign(u,t);function wt(t,e){X({l:{i:0,p:e.tagName},$hostElement$:e},t)}function gt(t){return t}export{c as H,yt as a,$t as b,N as c,x as d,g,A as h,pt as p,wt as r,j as s,gt as t}
@@ -1 +0,0 @@
1
- import{p as t,H as e,h as s,d as r,t as o}from"./p-CGGiwvWZ.js";import{K as n,a as i}from"./p-DXpYcAnT.js";const a=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow()}core;showEdgeIndicators=!0;edgeIndicatorPadding=8;remoteCursors=new Map;objectVersion=0;cleanupIntervalId;objectChangeRafId=null;componentDidLoad(){this.core.store.state.objects?.onAwarenessChange((t=>{this.handleAwarenessChange(t)})),this.core.store.state.objects?.onObjectsChange((()=>{this.handleRemoteObjectChange()})),this.cleanupIntervalId=setInterval((()=>{this.cleanupStaleCursors()}),3e3)}disconnectedCallback(){this.cleanupIntervalId&&clearInterval(this.cleanupIntervalId),null!==this.objectChangeRafId&&cancelAnimationFrame(this.objectChangeRafId)}handleAwarenessChange(t){const e=this.core.store.state.objects?.localClientId,s=Date.now(),r=new Map(this.remoteCursors),o=new Set;t.forEach(((t,n)=>{if(n===e)return;if(!t.user)return;o.add(n);const i=t.user,a=t.cursor,l=t.activeObjectId||null,c=t.selectionBox||null,d=r.get(n);r.set(n,{clientId:n,user:i,cursor:a,activeObjectId:l,selectionBox:c,lastUpdated:s,lastCursorMove:!d||!d.cursor!=!a||a&&d.cursor&&(a.x!==d.cursor.x||a.y!==d.cursor.y)?s:d?.lastCursorMove??s})}));for(const t of r.keys())o.has(t)||r.delete(t);this.remoteCursors=r}cleanupStaleCursors(){const t=Date.now();let e=!1;const s=new Map(this.remoteCursors);for(const[r,o]of s)t-o.lastUpdated>3e4?(s.delete(r),e=!0):!e&&t-o.lastCursorMove>1e4&&(e=!0);e&&(this.remoteCursors=s)}isStale(t){return Date.now()-t.lastCursorMove>1e4}hasActiveDrawingCursors(){for(const t of this.remoteCursors.values())if(t.activeObjectId)return!0;return!1}handleRemoteObjectChange(){this.hasActiveDrawingCursors()&&null===this.objectChangeRafId&&(this.objectChangeRafId=requestAnimationFrame((()=>{this.objectChangeRafId=null,this.objectVersion++})))}getActiveObjectTip(t){const e=this.core.store.state.objects?.findById(t);if(!e)return null;if(e instanceof n&&!e.isCompleted){const t=e.points[e.points.length-1];return t?{x:(t[0]-e.x)/e.scale+e.translateX,y:(t[1]-e.y)/e.scale+e.translateY}:null}return e instanceof i&&!e.isCompleted?{x:(e.endX-e.x)/e.scale+e.translateX,y:(e.endY-e.y)/e.scale+e.translateY}:null}worldToScreen(t,e){const{scale:s,translateX:r,translateY:o}=this.core.store.state;return{x:t*s+r,y:e*s+o}}isInViewport(t,e){const{viewportWidth:s,viewportHeight:r}=this.core.store.state;return t>=0&&t<=s&&e>=0&&e<=r}clampToEdge(t,e){const{viewportWidth:s,viewportHeight:r}=this.core.store.state,o=this.edgeIndicatorPadding,n=Math.max(o,Math.min(s-o,t)),i=Math.max(o,Math.min(r-o,e)),a=n-o,l=s-o-n,c=i-o;let d="top";const h=Math.min(a,l,c,r-o-i);return d=h===a?"left":h===l?"right":h===c?"top":"bottom",{x:n,y:i,angle:Math.atan2(e-i,t-n),edge:d}}getUserDisplayName(t){return t.displayName?t.displayName:t.firstName||t.lastName?[t.firstName,t.lastName].filter(Boolean).join(" "):"Unknown"}render(){const t=Array.from(this.remoteCursors.values());return s(r,{key:"5a28def6e024249c4309c087502cde9f219f5421"},t.map((t=>{if(!t.cursor)return null;let e,s=!1;if(t.activeObjectId){const r=this.getActiveObjectTip(t.activeObjectId);r?(s=!0,e=this.worldToScreen(r.x,r.y)):e=this.worldToScreen(t.cursor.x,t.cursor.y)}else e=this.worldToScreen(t.cursor.x,t.cursor.y);const r=this.isInViewport(e.x,e.y),o=this.isStale(t),n=t.user.color||"#6B7280";return r?this.renderCursor(t,e.x,e.y,n,o,s):this.showEdgeIndicators?this.renderEdgeIndicator(t,e.x,e.y,n,o,s):null})),t.map((t=>{if(!t.selectionBox)return null;const e=t.user.color||"#6B7280",r=t.selectionBox,o=this.worldToScreen(r.x,r.y),{scale:n}=this.core.store.state;return s("div",{key:`selection-box-${t.clientId}`,class:"remote-selection-box",style:{transform:`translate(${o.x}px, ${o.y}px)`,width:r.width*n+"px",height:r.height*n+"px",backgroundColor:`color-mix(in srgb, ${e} 20%, transparent)`,borderColor:`color-mix(in srgb, ${e} 50%, transparent)`}})})))}renderCursor(t,e,r,o,n,i){return s("div",{key:`cursor-${t.clientId}`,class:{"awareness-cursor":!0,stale:n,"tracking-object":i},style:{transform:`translate(${e}px, ${r}px)`}},s("svg",{class:"cursor-arrow",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s("path",{d:"M5 3L19 12L12 13L9 20L5 3Z",fill:o,stroke:"#ffffff","stroke-width":"1.5","stroke-linejoin":"round"})),s("span",{class:"cursor-label",style:{backgroundColor:o}},this.getUserDisplayName(t.user)))}renderEdgeIndicator(t,e,r,o,n,i){const a=this.clampToEdge(e,r),l=180*a.angle/Math.PI+90;let c=0,d=0;"left"===a.edge?c=20:"right"===a.edge?c=-20:"top"===a.edge?d=20:"bottom"===a.edge&&(d=-20);const h=this.getUserDisplayName(t.user);return s("div",{key:`edge-${t.clientId}`,class:{"edge-indicator":!0,stale:n,"tracking-object":i},style:{transform:`translate(${a.x}px, ${a.y}px)`}},s("svg",{class:{"edge-arrow":!0,stale:n},width:"16",height:"16",viewBox:"0 0 16 16",style:{transform:`rotate(${l}deg)`}},s("path",{d:"M8 1L14 13H2L8 1Z",fill:o,stroke:"#ffffff","stroke-width":"1.5","stroke-linejoin":"round"})),s("span",{class:"edge-label",style:{backgroundColor:o,transform:`translate(${c}px, ${d}px)`}},h))}static get style(){return":host{display:block;position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:1}.awareness-cursor{position:absolute;top:0;left:0;transition:transform var(--kritzel-awareness-cursor-transition-duration, 100ms) ease-out, opacity 300ms ease;will-change:transform}.awareness-cursor.stale{opacity:0}.awareness-cursor.tracking-object{transition-duration:0ms}.cursor-arrow{filter:drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3))}.cursor-label{position:absolute;left:16px;top:16px;white-space:nowrap;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;font-size:var(--kritzel-awareness-cursor-label-font-size, 12px);color:var(--kritzel-awareness-cursor-label-text-color, #ffffff);padding:2px 8px;border-radius:4px;line-height:1.4;font-weight:500;pointer-events:none;user-select:none}.edge-indicator{position:absolute;top:-12px;left:-12px;width:24px;height:24px;display:flex;align-items:center;justify-content:center;transition:transform var(--kritzel-awareness-cursor-transition-duration, 100ms) ease-out, opacity 300ms ease;will-change:transform;pointer-events:auto;user-select:none;cursor:pointer}.edge-indicator.stale{opacity:0}.edge-indicator.tracking-object{transition-duration:0ms}.edge-arrow{position:absolute;filter:drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));transition:opacity 300ms ease}.edge-arrow.stale{opacity:0}.edge-label{position:absolute;white-space:nowrap;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;font-size:var(--kritzel-awareness-cursor-label-font-size, 12px);color:var(--kritzel-awareness-cursor-label-text-color, #ffffff);padding:2px 8px;border-radius:4px;line-height:1.4;font-weight:500;pointer-events:none;opacity:0;transform-origin:center;transition:opacity 150ms ease}.edge-indicator:hover .edge-label{opacity:1}.remote-selection-box{position:absolute;top:0;left:0;border-width:2px;border-style:solid;pointer-events:none;will-change:transform, width, height;transition:transform var(--kritzel-awareness-cursor-transition-duration, 100ms) ease-out, width var(--kritzel-awareness-cursor-transition-duration, 100ms) ease-out, height var(--kritzel-awareness-cursor-transition-duration, 100ms) ease-out}"}},[513,"kritzel-awareness-cursors",{core:[16],showEdgeIndicators:[4,"show-edge-indicators"],edgeIndicatorPadding:[2,"edge-indicator-padding"],remoteCursors:[32],objectVersion:[32]}]);function l(){"undefined"!=typeof customElements&&["kritzel-awareness-cursors"].forEach((t=>{"kritzel-awareness-cursors"===t&&(customElements.get(o(t))||customElements.define(o(t),a))}))}export{a as K,l as d}
@@ -1 +0,0 @@
1
- import{O as t}from"./p-BAN5dnHX.js";import{a as i}from"./p-CjazGGq3.js";class s{static doPolygonsIntersect(t,i){const s=[t.bottomLeft,t.bottomRight,t.topRight,t.topLeft],h=[i.bottomLeft,i.bottomRight,i.topRight,i.topLeft];for(const t of s)if(this.isPointInPolygon(t,h))return!0;for(const t of h)if(this.isPointInPolygon(t,s))return!0;for(let t=0;t<s.length;t++){const i=s[t],n=s[(t+1)%s.length];for(let t=0;t<h.length;t++)if(this.intersectLines(i,n,h[t],h[(t+1)%h.length]))return!0}return!1}static isPointInPolygon(t,i){let s=!1;for(let h=0,n=i.length-1;h<i.length;n=h++){const e=i[h].x,r=i[h].y,o=i[n].y;r>t.y!=o>t.y&&t.x<(i[n].x-e)*(t.y-r)/(o-r)+e&&(s=!s)}return s}static intersectLines(t,i,s,h){const n=(i.x-t.x)*(h.y-s.y)-(i.y-t.y)*(h.x-s.x);if(0===n)return!1;const e=((s.x-t.x)*(h.y-s.y)-(s.y-t.y)*(h.x-s.x))/n,r=-((t.x-s.x)*(i.y-t.y)-(t.y-s.y)*(i.x-t.x))/n;return e>=0&&e<=1&&r>=0&&r<=1}static getLineIntersectionPoint(t,i,s,h){const n=(i.x-t.x)*(h.y-s.y)-(i.y-t.y)*(h.x-s.x);if(0===n)return null;const e=((s.x-t.x)*(h.y-s.y)-(s.y-t.y)*(h.x-s.x))/n,r=-((t.x-s.x)*(i.y-t.y)-(t.y-s.y)*(i.x-t.x))/n;return e>=0&&e<=1&&r>=0&&r<=1?{x:t.x+e*(i.x-t.x),y:t.y+e*(i.y-t.y)}:null}static getLinePolygonIntersection(t,i,s){const h=[s.topLeft,s.topRight,s.bottomRight,s.bottomLeft];let n=null,e=1/0;for(let s=0;s<h.length;s++){const r=this.getLineIntersectionPoint(t,i,h[s],h[(s+1)%h.length]);if(r){const i=Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));i<e&&(e=i,n=r)}}return n}static getEllipsePolygonApproximation(t,i,s,h,n=32,e=0){const r=[],o=Math.cos(e),a=Math.sin(e);for(let e=0;e<n;e++){const u=2*Math.PI*e/n,c=s*Math.cos(u),l=h*Math.sin(u);r.push({x:t+c*o-l*a,y:i+c*a+l*o})}return r}static getLinePointsArrayIntersection(t,i,s){let h=null,n=1/0;for(let e=0;e<s.length;e++){const r=this.getLineIntersectionPoint(t,i,s[e],s[(e+1)%s.length]);if(r){const i=Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));i<n&&(n=i,h=r)}}return h}static isPointInPolygonPoints(t,i){return this.isPointInPolygon(t,i)}}class h{__class__="KritzelBaseObject";_core;_elementRef;id;workspaceId;x;y;translateX;translateY;height;width;backgroundColor;borderColor;borderWidth=0;opacity=1;padding=0;scale;resizing=!1;rotation=0;markedForRemoval=!1;zIndex=0;userId;isVisible=!0;isSelected=!1;isHovered=!1;isMounted=!1;isEditable=!1;isInteractive=!1;isDebugInfoVisible=!1;get totalWidth(){return this.width+2*this.padding}get totalHeight(){return this.height+2*this.padding}set elementRef(t){this._elementRef=t}get elementRef(){return this._elementRef}get boundingBox(){return{x:this.translateX,y:this.translateY,z:this.scale,width:this.totalWidth/this.scale,height:this.totalHeight/this.scale}}get rotatedBoundingBox(){const t=this.rotatedPolygon,i=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],s=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],h=Math.min(...i),n=Math.max(...i),e=Math.min(...s),r=Math.max(...s);return{x:h,y:e,z:this.scale,width:n-h,height:r-e}}get rotatedPolygon(){const t=this.translateX+this.totalWidth/2/this.scale,i=this.translateY+this.totalHeight/2/this.scale,s=this.rotation,h=Math.cos(s),n=Math.sin(s),e=this.translateX,r=this.translateY,o=e+this.totalWidth/this.scale,a=r+this.totalHeight/this.scale,u=(s,e)=>({x:h*(s-t)-n*(e-i)+t,y:n*(s-t)+h*(e-i)+i});return{topLeft:u(e,r),topRight:u(o,r),bottomRight:u(o,a),bottomLeft:u(e,a)}}get minXRotated(){return Math.min(this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x)}get minYRotated(){return Math.min(this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y)}get maxXRotated(){return Math.max(this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x)}get maxYRotated(){return Math.max(this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y)}get transformationMatrix(){const t=1/this.scale;return`matrix(${t}, 0, 0, ${t}, ${this.translateX}, ${this.translateY})`}get rotationDegrees(){return this.rotation*(180/Math.PI)}get centerX(){return this.translateX+this.totalWidth/2/this.scale}get centerY(){return this.translateY+this.totalHeight/2/this.scale}constructor(){this.id=this.generateId()}static create(t){const i=new h;return i._core=t,i.zIndex=t.store.currentZIndex,i.workspaceId=t.store.state.activeWorkspace.id,i.userId=t.user?.id,i}mount(t){this.isMounted||(this.elementRef=t,this.isMounted=!0)}generateId(){return t.generateUUID()}isInViewport(){const t=this._core.store.state.scale;if(this.boundingBox.width*t*(this.boundingBox.height*t)<.5)return!1;const i=-this._core.store.state.translateX/this._core.store.state.scale,s=-this._core.store.state.translateY/this._core.store.state.scale;return this.rotatedBoundingBox.x<i+this._core.store.state.viewportWidth/this._core.store.state.scale&&this.rotatedBoundingBox.x+this.rotatedBoundingBox.width>i&&this.rotatedBoundingBox.y<s+this._core.store.state.viewportHeight/this._core.store.state.scale&&this.rotatedBoundingBox.y+this.rotatedBoundingBox.height>s}centerInViewport(){const{viewportWidth:t,viewportHeight:i,translateX:s,translateY:h,scale:n}=this._core.store.state,{x:e,y:r,width:o,height:a}=this.rotatedBoundingBox;this.updatePosition(this.translateX+((t/2-s)/n-(e+o/2)),this.translateY+((i/2-h)/n-(r+a/2)))}update(){this._core.store.state.objects.update(this)}move(t,i,s,h){const n=(i-h)/this._core.store.state.scale;this.translateX+=(t-s)/this._core.store.state.scale,this.translateY+=n,this._core.store.state.objects.update(this)}resize(t,i,s,h){s<=1||h<=1||(this.width=s,this.height=h,this.translateX=t,this.translateY=i,this._core.store.state.objects.update(this),this._core.anchorManager.updateAnchorsForObject(this.id))}rotate(t){this.rotation=t,this._core.store.state.objects.update(this)}clone(){const t=Object.create(Object.getPrototypeOf(this));return Object.assign(t,this),t.id=this.id,t}copy(){const t=Object.create(Object.getPrototypeOf(this));return Object.assign(t,this),t.id=this.generateId(),t.isMounted=!1,t}serialize(){const{_core:t,_elementRef:i,element:s,totalWidth:h,totalHeight:n,...e}=this,r=structuredClone(e);return s&&"object"==typeof s&&"nodeType"in s&&1===s.nodeType&&(r.element=s.cloneNode(!0)),r}deserialize(t){return Object.assign(this,t),this}isClass(t){return this.__class__===t}edit(t){}onAfterUpdate(t){}hitTest(t,i){return!0}hitTestPolygon(t){return s.doPolygonsIntersect(this.rotatedPolygon,t)}updatePosition(t,i){this.translateX=t,this.translateY=i,this._core.store.state.objects.update(this)}}var n,e={},r=(n||(n=1,function(t){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const{PI:i}=Math,s=i+1e-4,h=[1,1];function n(t,i,s,h=t=>t){return t*h(.5-i*(.5-s))}const{min:e}=Math;function r(t,i,s){let h=e(1,i/s);return e(1,t+(e(1,1-h)-t)*(.275*h))}function o(t,i){return[t[0]+i[0],t[1]+i[1]]}function a(t,i,s){return t[0]=i[0]+s[0],t[1]=i[1]+s[1],t}function u(t,i){return[t[0]-i[0],t[1]-i[1]]}function c(t,i,s){return t[0]=i[0]-s[0],t[1]=i[1]-s[1],t}function l(t,i){return[t[0]*i,t[1]*i]}function f(t,i,s){return t[0]=i[0]*s,t[1]=i[1]*s,t}function d(t){return[t[1],-t[0]]}function M(t,i){let s=i[0];return t[0]=i[1],t[1]=-s,t}function g(t,i){return t[0]*i[0]+t[1]*i[1]}function m(t,i){return t[0]===i[0]&&t[1]===i[1]}function p(t,i){let s=t[0]-i[0],h=t[1]-i[1];return s*s+h*h}function x(t){return function(t,i){return[t[0]/i,t[1]/i]}(t,function(t){return Math.hypot(t[0],t[1])}(t))}function y(t,i){return Math.hypot(t[1]-i[1],t[0]-i[0])}function v(t,i,s){let h=Math.sin(s),n=Math.cos(s),e=t[0]-i[0],r=t[1]-i[1];return[e*n-r*h+i[0],e*h+r*n+i[1]]}function P(t,i,s,h){let n=Math.sin(h),e=Math.cos(h),r=i[0]-s[0],o=i[1]-s[1],a=r*n+o*e;return t[0]=r*e-o*n+s[0],t[1]=a+s[1],t}function $(t,i,s){return o(t,l(u(i,t),s))}function b(t,i,s,h){let n=s[1]-i[1];return t[0]=i[0]+(s[0]-i[0])*h,t[1]=i[1]+n*h,t}function w(t,i,s){return o(t,l(i,s))}const L=[0,0],I=[0,0],X=[0,0];function _(t,i){let h=w(t,x(d(u(t,o(t,[1,1])))),-i),n=[],e=1/13;for(let i=e;i<=1;i+=e)n.push(v(h,t,2*s*i));return n}function z(t,i,h){let n=[],e=1/h;for(let h=e;h<=1;h+=e)n.push(v(i,t,s*h));return n}function Y(t,i,s){let h=u(i,s),n=l(h,.5),e=l(h,.51);return[u(t,n),u(t,e),o(t,e),o(t,n)]}function j(t,i,h,n){let e=[],r=w(t,i,h),o=1/n;for(let i=o;i<1;i+=o)e.push(v(r,t,3*s*i));return e}function k(t,i,s){return[o(t,l(i,s)),o(t,l(i,.99*s)),u(t,l(i,.99*s)),u(t,l(i,s))]}function A(t,i,s){return!1===t||void 0===t?0:!0===t?Math.max(i,s):t}function B(t,i={}){let{size:h=16,smoothing:e=.5,thinning:l=.5,simulatePressure:m=!0,easing:x=t=>t,start:y={},end:v={},last:$=!1}=i,{cap:w=!0,easing:B=t=>t*(2-t)}=y,{cap:R=!0,easing:C=t=>--t*t*t+1}=v;if(0===t.length||h<=0)return[];let S,T=t[t.length-1].runningLength,O=A(y.taper,h,T),D=A(v.taper,h,T),V=(h*e)**2,W=[],H=[],E=function(t,i,s){return t.slice(0,10).reduce(((t,h)=>{let n=h.pressure;return i&&(n=r(t,h.distance,s)),(t+n)/2}),t[0].pressure)}(t,m,h),F=n(h,l,t[t.length-1].pressure,x),K=t[0].vector,G=t[0].point,Q=G,U=G,q=Q,N=!1;for(let i=0;i<t.length;i++){let{pressure:e}=t[i],{point:d,vector:y,distance:v,runningLength:$}=t[i],w=i===t.length-1;if(!w&&T-$<3)continue;l?(m&&(e=r(E,v,h)),F=n(h,l,e,x)):F=h/2,void 0===S&&(S=F);let _=$<O?B($/O):1,z=T-$<D?C((T-$)/D):1;F=Math.max(.01,F*Math.min(_,z));let Y=(w?t[i]:t[i+1]).vector,j=w?1:g(y,Y),k=null!==j&&j<0;if(g(y,K)<0&&!N||k){M(L,K),f(L,L,F);for(let t=0;t<=1;t+=.07692307692307693)c(I,d,L),P(I,I,d,s*t),U=[I[0],I[1]],W.push(U),a(X,d,L),P(X,X,d,s*-t),q=[X[0],X[1]],H.push(q);G=U,Q=q,k&&(N=!0)}else N=!1,w?(M(L,y),f(L,L,F),W.push(u(d,L)),H.push(o(d,L))):(b(L,Y,y,j),M(L,L),f(L,L,F),c(I,d,L),U=[I[0],I[1]],(i<=1||p(G,U)>V)&&(W.push(U),G=U),a(X,d,L),q=[X[0],X[1]],(i<=1||p(Q,q)>V)&&(H.push(q),Q=q),E=e,K=y)}let Z=[t[0].point[0],t[0].point[1]],J=t.length>1?[t[t.length-1].point[0],t[t.length-1].point[1]]:o(t[0].point,[1,1]),tt=[],it=[];if(1===t.length){if(!O&&!D||$)return _(Z,S||F)}else{O||D&&1===t.length||(w?tt.push(...z(Z,H[0],13)):tt.push(...Y(Z,W[0],H[0])));let i=d(function(t){return[-t[0],-t[1]]}(t[t.length-1].vector));D||O&&1===t.length?it.push(J):R?it.push(...j(J,i,F,29)):it.push(...k(J,i,F))}return W.concat(it,H.reverse(),tt)}const R=[0,0];function C(t){return null!=t&&t>=0}function S(t,i={}){let{streamline:s=.5,size:n=16,last:e=!1}=i;if(0===t.length)return[];let r=.15+.85*(1-s),a=Array.isArray(t[0])?t:t.map((({x:t,y:i,pressure:s=.5})=>[t,i,s]));if(2===a.length){let t=a[1];a=a.slice(0,-1);for(let i=1;i<5;i++)a.push($(a[0],t,i/4))}1===a.length&&(a=[...a,[...o(a[0],h),...a[0].slice(2)]]);let u=[{point:[a[0][0],a[0][1]],pressure:C(a[0][2])?a[0][2]:.25,vector:[...h],distance:0,runningLength:0}],l=!1,f=0,d=u[0],M=a.length-1;for(let t=1;t<a.length;t++){let i=e&&t===M?[a[t][0],a[t][1]]:$(d.point,a[t],r);if(m(d.point,i))continue;let s=y(i,d.point);if(f+=s,t<M&&!l){if(f<n)continue;l=!0}c(R,d.point,i),d={point:i,pressure:C(a[t][2])?a[t][2]:.5,vector:x(R),distance:s,runningLength:f},u.push(d)}return u[0].vector=u[1]?.vector||[0,0],u}function T(t,i={}){return B(S(t,i),i)}t.default=T,t.getStroke=T,t.getStrokeOutlinePoints=B,t.getStrokePoints=S}(e)),e);class o{static average(t,i){return(t+i)/2}}class a extends h{__class__="KritzelPath";points;d;stroke={light:"none",dark:"none"};strokeWidth;lineSlack=.5;fill;x=0;y=0;height=0;width=0;scale=1;options;isVisible=!0;isDebugInfoVisible=!0;isCompleted=!1;_adjustedPoints=null;get viewBox(){return`${this.x} ${this.y} ${this.width} ${this.height}`}constructor(t){super(),this.options=t,this.points=t?.points??[],this.translateX=t?.translateX??0,this.translateY=t?.translateY??0,this.scale=t?.scale??1,this.strokeWidth=t?.strokeWidth??8,this.fill=t?.fill??{light:"#000000",dark:"#ffffff"},this.d=this.generateSvgPath(),this.updateDimensions()}static create(t,i){const s=new a;return s._core=t,s.id=s.generateId(),s.workspaceId=t.store.state.activeWorkspace.id,s.userId=t.user?.id,s.options=i,s.points=i?.points??[],s.translateX=i?.translateX??0,s.translateY=i?.translateY??0,s.scale=i?.scale??1,s.strokeWidth=i?.strokeWidth??8,s.fill=i?.fill??{light:"#000000",dark:"#ffffff"},s.opacity=i?.opacity??1,s.zIndex=t.store.currentZIndex,s.d=s.generateSvgPath(),s.updateDimensions(),s}copy(){const t=super.copy();return this.points&&(t.points=this.points.map((t=>[...t]))),t}resize(t,i,s,h){if(s<=1||h<=1)return;const n=s/this.width,e=h/this.height;if(this.width=s,this.height=h,1===this.points.length){const t=this.points[0],i=Math.max(0,s-this.strokeWidth)/n,r=Math.max(0,h-this.strokeWidth)/e;this.points.push([t[0]+i,t[1]+r])}this.points=this.points.map((([t,i])=>[t*n,i*e])),this.d=this.generateSvgPath(),this.width=Math.max(...this.points.map((t=>t[0])))-Math.min(...this.points.map((t=>t[0])))+this.strokeWidth,this.height=Math.max(...this.points.map((t=>t[1])))-Math.min(...this.points.map((t=>t[1])))+this.strokeWidth,this.x=Math.min(...this.points.map((t=>t[0])))-this.strokeWidth/2,this.y=Math.min(...this.points.map((t=>t[1])))-this.strokeWidth/2,this.translateX=t,this.translateY=i,this._adjustedPoints=null,this._core.store.state.objects.update(this)}rotate(t){this.rotation=t,this._adjustedPoints=null,this._core.store.state.objects.update(this)}move(t,i,s,h){const n=(i-h)/this._core.store.state.scale;this.translateX+=(t-s)/this._core.store.state.scale,this.translateY+=n,this._adjustedPoints=null,this._core.store.state.objects.update(this)}hitTest(t,i){const s=this.strokeWidth/this.scale/2;if(null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints()),1===this._adjustedPoints.length){const h=this._adjustedPoints[0];return this.pointToLineSegmentDistance(t,i,h[0],h[1],h[0],h[1])<=s}for(let h=0;h<this._adjustedPoints.length-1;h++){const n=this._adjustedPoints[h],e=this._adjustedPoints[h+1];if(this.pointToLineSegmentDistance(t,i,n[0],n[1],e[0],e[1])<=s)return!0}return!1}hitTestPolygon(t){const i=this.strokeWidth/this.scale/2;null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints());const h=[{x:t.bottomLeft.x,y:t.bottomLeft.y},{x:t.bottomRight.x,y:t.bottomRight.y},{x:t.topRight.x,y:t.topRight.y},{x:t.topLeft.x,y:t.topLeft.y}];for(const[t,i]of this._adjustedPoints)if(s.isPointInPolygon({x:t,y:i},h))return!0;for(const t of h)if(this.hitTest(t.x,t.y))return!0;for(let t=0;t<this._adjustedPoints.length-1;t++){const i={x:this._adjustedPoints[t][0],y:this._adjustedPoints[t][1]},n={x:this._adjustedPoints[t+1][0],y:this._adjustedPoints[t+1][1]};for(let t=0;t<h.length;t++)if(s.intersectLines(i,n,h[t],h[(t+1)%h.length]))return!0}for(let t=0;t<this._adjustedPoints.length-1;t++){const s=this._adjustedPoints[t],n=this._adjustedPoints[t+1];for(let t=0;t<h.length;t++){const e=h[t],r=h[(t+1)%h.length],o=this.pointToLineSegmentDistance(e.x,e.y,s[0],s[1],n[0],n[1]),a=this.pointToLineSegmentDistance(r.x,r.y,s[0],s[1],n[0],n[1]),u=this.pointToLineSegmentDistance(s[0],s[1],e.x,e.y,r.x,r.y),c=this.pointToLineSegmentDistance(n[0],n[1],e.x,e.y,r.x,r.y);if(Math.min(o,a,u,c)<=i)return!0}}return!1}updatePosition(t,i){this.translateX=t,this.translateY=i,this._adjustedPoints=null,this._core.store.state.objects.update(this)}onAfterUpdate(t){t.includes("strokeWidth")&&(this.d=this.generateSvgPath(),this.updateBoundingBox(),this._adjustedPoints=null)}computeAdjustedPoints(){if(!this.points?.length)return[];const t=this.rotation,i=Math.cos(t),s=Math.sin(t),h=this.points.map((t=>t[0])),n=this.points.map((t=>t[1])),e={x:(Math.min(...h)+Math.max(...h))/2,y:(Math.min(...n)+Math.max(...n))/2},{x:r,y:o}=e;return this.points.map((([t,h])=>{const n=t-r,e=h-o;return[r+n*i-e*s,o+n*s+e*i]})).map((([t,i])=>[Math.abs(t-this.x)/this.scale+this.translateX,Math.abs(i-this.y)/this.scale+this.translateY]))}pointToLineSegmentDistance(t,i,s,h,n,e){const r=n-s,o=e-h,a=r*r+o*o;let u,c,l=-1;0!==a&&(l=((t-s)*r+(i-h)*o)/a),l<0?(u=s,c=h):l>1?(u=n,c=e):(u=s+l*r,c=h+l*o);const f=t-u,d=i-c;return Math.sqrt(f*f+d*d)}updateDimensions(){const t=this.points.map((([t,i])=>[t*Math.cos(this.rotation)-i*Math.sin(this.rotation),t*Math.sin(this.rotation)+i*Math.cos(this.rotation)])),i=Math.min(...t.map((t=>t[0]-this.strokeWidth/2))),s=Math.min(...t.map((t=>t[1]-this.strokeWidth/2))),h=Math.max(...t.map((t=>t[0]+this.strokeWidth/2))),n=Math.max(...t.map((t=>t[1]+this.strokeWidth/2)));this.width=h-i+this.lineSlack,this.height=n-s+this.lineSlack,this.x=i,this.y=s,this.translateX=(this.x+this.translateX)/this.scale,this.translateY=(this.y+this.translateY)/this.scale}updateBoundingBox(){const t=Math.min(...this.points.map((t=>t[0])))-this.strokeWidth/2,i=Math.min(...this.points.map((t=>t[1])))-this.strokeWidth/2,s=Math.max(...this.points.map((t=>t[0])))+this.strokeWidth/2,h=Math.max(...this.points.map((t=>t[1])))+this.strokeWidth/2;this.width=s-t+this.lineSlack,this.height=h-i+this.lineSlack,this.x=t,this.y=i}generateSvgPath(){const t=this.getStrokeFromPoints(this.points,this.strokeWidth);return this.getSvgPathFromStroke(t)}getStrokeFromPoints(t,i){return r.getStroke(t,{size:i,thinning:.5,smoothing:.5,streamline:.5,easing:t=>t,simulatePressure:!0,last:!0,start:{cap:!0,taper:0,easing:t=>t},end:{cap:!0,taper:0,easing:t=>t}})}getSvgPathFromStroke(t,i=!0){const s=t.length;if(s<4)return"";let h=t[0],n=t[1];const e=t[2];let r=`M${h[0].toFixed(2)},${h[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${o.average(n[0],e[0]).toFixed(2)},${o.average(n[1],e[1]).toFixed(2)} T`;for(let i=2,e=s-1;i<e;i++)h=t[i],n=t[i+1],r+=`${o.average(h[0],n[0]).toFixed(2)},${o.average(h[1],n[1]).toFixed(2)} `;return i&&(r+="Z"),r}isLowRes(){if(!this._core)return!1;const t=this._core.store.state.scale;return this.boundingBox.width*t*(this.boundingBox.height*t)<500}getClipPoint(t){const i=this.centerX,s=this.centerY,h=this.strokeWidth/this.scale/2;if(null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints()),this._adjustedPoints.length<1)return null;let n=!0;for(let e=1;e<=32;e++){const r=e/32,o=t.x+(i-t.x)*r,a=t.y+(s-t.y)*r;let u=1/0;if(1===this._adjustedPoints.length){const t=this._adjustedPoints[0],i=o-t[0],s=a-t[1];u=Math.sqrt(i*i+s*s)}else for(let t=0;t<this._adjustedPoints.length-1;t++){const i=this._adjustedPoints[t],s=this._adjustedPoints[t+1],h=this.pointToLineSegmentDistance(o,a,i[0],i[1],s[0],s[1]);h<u&&(u=h)}const c=u<=h;if(n&&c){let n=(e-1)/32,o=r;for(let e=0;e<8;e++){const e=(n+o)/2,r=t.x+(i-t.x)*e,a=t.y+(s-t.y)*e;let u=1/0;if(1===this._adjustedPoints.length){const t=this._adjustedPoints[0],i=r-t[0],s=a-t[1];u=Math.sqrt(i*i+s*s)}else for(let t=0;t<this._adjustedPoints.length-1;t++){const i=this._adjustedPoints[t],s=this._adjustedPoints[t+1],h=this.pointToLineSegmentDistance(r,a,i[0],i[1],s[0],s[1]);h<u&&(u=h)}u<=h?o=e:n=e}const a=(n+o)/2;return{x:t.x+(i-t.x)*a,y:t.y+(s-t.y)*a}}n=!c}return null}}class u extends h{__class__="KritzelLine";startX;startY;endX;endY;controlX;controlY;stroke;strokeWidth;scale=1;options;startAnchor;endAnchor;arrows;isVisible=!0;isDebugInfoVisible=!0;isCompleted=!1;_adjustedPoints=null;_clipInfo=null;get d(){return void 0!==this.controlX&&void 0!==this.controlY?`M ${this.startX} ${this.startY} Q ${this.controlX} ${this.controlY} ${this.endX} ${this.endY}`:`M ${this.startX} ${this.startY} L ${this.endX} ${this.endY}`}get viewBox(){return`${this.x} ${this.y} ${this.width} ${this.height}`}constructor(t){super(),this.options=t,this.startX=t?.startX??0,this.startY=t?.startY??0,this.endX=t?.endX??0,this.endY=t?.endY??0,this.controlX=t?.controlX,this.controlY=t?.controlY,this.translateX=t?.translateX??0,this.translateY=t?.translateY??0,this.scale=t?.scale??1,this.strokeWidth=t?.strokeWidth??4,this.stroke=t?.stroke??{light:"#000000",dark:"#ffffff"},this.startAnchor=t?.startAnchor,this.endAnchor=t?.endAnchor,this.arrows=t?.arrows,this.updateDimensions()}static create(t,i){const s=new u;return s._core=t,s.id=s.generateId(),s.workspaceId=t.store.state.activeWorkspace.id,s.userId=t.user?.id,s.options=i,s.startX=i?.startX??0,s.startY=i?.startY??0,s.endX=i?.endX??0,s.endY=i?.endY??0,s.controlX=i?.controlX,s.controlY=i?.controlY,s.translateX=i?.translateX??0,s.translateY=i?.translateY??0,s.scale=i?.scale??1,s.strokeWidth=i?.strokeWidth??4,s.stroke=i?.stroke??{light:"#000000",dark:"#ffffff"},s.opacity=i?.opacity??1,s.startAnchor=i?.startAnchor,s.endAnchor=i?.endAnchor,s.arrows=i?.arrows,s.zIndex=t.store.currentZIndex,s.updateDimensions(),s}resize(t,i,s,h){if(s<=1||h<=1)return;const n=s/this.width,e=h/this.height;this.startX=this.startX*n,this.startY=this.startY*e,this.endX=this.endX*n,this.endY=this.endY*e,void 0!==this.controlX&&void 0!==this.controlY&&(this.controlX=this.controlX*n,this.controlY=this.controlY*e);const{minX:r,minY:o,maxX:a,maxY:u}=this.calculateBoundingBox();this.width=a-r,this.height=u-o,this.x=r,this.y=o,this.translateX=t,this.translateY=i,this._adjustedPoints=null,this._clipInfo=null,this._core.store.state.objects.update(this),this._core.anchorManager.updateAnchorsForObject(this.id),this.startAnchor&&this._core.anchorManager.updateAnchorsForObject(this.startAnchor.objectId),this.endAnchor&&this._core.anchorManager.updateAnchorsForObject(this.endAnchor.objectId)}rotate(t){this.rotation=t,this._adjustedPoints=null,this._clipInfo=null,this._core.store.state.objects.update(this)}move(t,i,s,h){const n=(i-h)/this._core.store.state.scale;this.translateX+=(t-s)/this._core.store.state.scale,this.translateY+=n,this.startAnchor&&this._core.anchorManager.updateAnchorsForObject(this.startAnchor.objectId),this.endAnchor&&this._core.anchorManager.updateAnchorsForObject(this.endAnchor.objectId),this._adjustedPoints=null,this._clipInfo=null,this._core.store.state.objects.update(this)}hitTest(t,i){const s=Math.max(this.strokeWidth,20)/this.scale/2;if(null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints()),void 0!==this.controlX&&void 0!==this.controlY){const h=this.getClipInfo();return this.pointToBezierDistance(t,i,h.start?.t??0,h.end?.t??1)<=s}const h=this.getClipInfo(),n=h.start?[h.start.x,h.start.y]:this._adjustedPoints[0],e=h.end?[h.end.x,h.end.y]:this._adjustedPoints[1];return this.pointToLineSegmentDistance(t,i,n[0],n[1],e[0],e[1])<=s}hitTestPolygon(t){const i=this.strokeWidth/this.scale/2;null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints());const h=this.getClipInfo(),n=[{x:t.bottomLeft.x,y:t.bottomLeft.y},{x:t.bottomRight.x,y:t.bottomRight.y},{x:t.topRight.x,y:t.topRight.y},{x:t.topLeft.x,y:t.topLeft.y}],e=h.start?[h.start.x,h.start.y]:this._adjustedPoints[0],r=h.end?[h.end.x,h.end.y]:this._adjustedPoints[1],o=[e,r];for(const[t,i]of o)if(s.isPointInPolygon({x:t,y:i},n))return!0;for(const t of n)if(this.hitTest(t.x,t.y))return!0;if(void 0!==this.controlX&&void 0!==this.controlY){const t=this._adjustedPoints[0],e=this._adjustedPoints[1],r=this.computeAdjustedControlPoint(),o=h.start?.t??0,a=h.end?.t??1,u=20;for(let h=0;h<=u;h++){const c=o+h/u*(a-o),l=1-c,f=l*l*t[0]+2*l*c*r[0]+c*c*e[0],d=l*l*t[1]+2*l*c*r[1]+c*c*e[1];if(s.isPointInPolygon({x:f,y:d},n))return!0;for(let t=0;t<n.length;t++){const s=n[t],h=n[(t+1)%n.length];if(this.pointToLineSegmentDistance(f,d,s.x,s.y,h.x,h.y)<=i)return!0}}return!1}const a={x:e[0],y:e[1]},u={x:r[0],y:r[1]};for(let t=0;t<n.length;t++){const h=n[t],e=n[(t+1)%n.length];if(s.intersectLines(a,u,h,e))return!0;const r=this.pointToLineSegmentDistance(h.x,h.y,a.x,a.y,u.x,u.y),o=this.pointToLineSegmentDistance(e.x,e.y,a.x,a.y,u.x,u.y),c=this.pointToLineSegmentDistance(a.x,a.y,h.x,h.y,e.x,e.y),l=this.pointToLineSegmentDistance(u.x,u.y,h.x,h.y,e.x,e.y);if(Math.min(r,o,c,l)<=i)return!0}return!1}updatePosition(t,i){this.translateX=t,this.translateY=i,this._adjustedPoints=null,this._clipInfo=null,this._core.store.state.objects.update(this)}updateEndpoint(t,i,s){"start"===t?(this.startX=i,this.startY=s):(this.endX=i,this.endY=s);const h=this.width,n=this.height,{minX:e,minY:r,maxX:o,maxY:a}=this.calculateBoundingBox(),u=e-this.x,c=r-this.y,l=o-e,f=a-r,d=(l-h)/2,M=(f-n)/2;this.x=e,this.y=r,this.width=l,this.height=f;const g=Math.cos(this.rotation),m=Math.sin(this.rotation),p=u+d,x=c+M,y=p*m+x*g-M;this.translateX+=(p*g-x*m-d)/this.scale,this.translateY+=y/this.scale,this._adjustedPoints=null,this._clipInfo=null,this._core.store.state.objects.update(this)}updateControlPoint(t,i){this.controlX=t,this.controlY=i;const s=this.width,h=this.height,{minX:n,minY:e,maxX:r,maxY:o}=this.calculateBoundingBox(),a=n-this.x,u=e-this.y,c=r-n,l=o-e,f=(c-s)/2,d=(l-h)/2;this.x=n,this.y=e,this.width=c,this.height=l;const M=Math.cos(this.rotation),g=Math.sin(this.rotation),m=a+f,p=u+d,x=m*g+p*M-d;this.translateX+=(m*M-p*g-f)/this.scale,this.translateY+=x/this.scale,this._adjustedPoints=null,this._clipInfo=null,this._core.store.state.objects.update(this)}computeAdjustedPoints(){const t=[[this.startX,this.startY],[this.endX,this.endY]],i=this.rotation,s=Math.cos(i),h=Math.sin(i),n=t.map((t=>t[0])),e=t.map((t=>t[1])),r={x:(Math.min(...n)+Math.max(...n))/2,y:(Math.min(...e)+Math.max(...e))/2},{x:o,y:a}=r;return t.map((([t,i])=>{const n=t-o,e=i-a;return[o+n*s-e*h,a+n*h+e*s]})).map((([t,i])=>[(t-this.x)/this.scale+this.translateX,(i-this.y)/this.scale+this.translateY]))}pointToLineSegmentDistance(t,i,s,h,n,e){const r=n-s,o=e-h,a=r*r+o*o;let u,c,l=-1;0!==a&&(l=((t-s)*r+(i-h)*o)/a),l<0?(u=s,c=h):l>1?(u=n,c=e):(u=s+l*r,c=h+l*o);const f=t-u,d=i-c;return Math.sqrt(f*f+d*d)}pointToBezierDistance(t,i,s=0,h=1){null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints());const n=this._adjustedPoints[0],e=this._adjustedPoints[1],r=this.computeAdjustedControlPoint();let o=1/0;for(let a=0;a<=20;a++){const u=s+a/20*(h-s),c=1-u,l=t-(c*c*n[0]+2*c*u*r[0]+u*u*e[0]),f=i-(c*c*n[1]+2*c*u*r[1]+u*u*e[1]),d=Math.sqrt(l*l+f*f);d<o&&(o=d)}return o}getClipInfo(){if(this._clipInfo)return this._clipInfo;const t=this.endAnchor,i={};if(this.startAnchor){const t=this._core.anchorManager.findAnchorTarget(this,"start");if(t){const s=this._core.anchorManager.computeAnchorClipInfo(this,"start",t);s&&(i.start={x:s.worldX,y:s.worldY,t:s.t})}}if(t){const t=this._core.anchorManager.findAnchorTarget(this,"end");if(t){const s=this._core.anchorManager.computeAnchorClipInfo(this,"end",t);s&&(i.end={x:s.worldX,y:s.worldY,t:s.t})}}return this._clipInfo=i,i}computeAdjustedControlPoint(){if(void 0===this.controlX||void 0===this.controlY)return[(this.startX+this.endX)/2,(this.startY+this.endY)/2];const t=this.rotation,i=Math.cos(t),s=Math.sin(t),h=[this.startX,this.endX],n=[this.startY,this.endY],e={x:(Math.min(...h)+Math.max(...h))/2,y:(Math.min(...n)+Math.max(...n))/2},{x:r,y:o}=e,a=this.controlX-r,u=this.controlY-o;return[(r+a*i-u*s-this.x)/this.scale+this.translateX,(o+a*s+u*i-this.y)/this.scale+this.translateY]}get rotatedPolygon(){const t=this.padding,{minX:i,minY:s,maxX:h,maxY:n}=u.calculateBoundingBox(this.startX,this.startY,this.endX,this.endY,this.controlX,this.controlY,this.strokeWidth),e=i-this.x+t,r=s-this.y+t,o=h-this.x+t,a=n-this.y+t,c={x:e,y:r},l={x:o,y:r},f={x:o,y:a},d={x:e,y:a},M=this.totalWidth/2,g=this.totalHeight/2,m=this.rotation,p=Math.cos(m),x=Math.sin(m),y=t=>({x:((t.x-M)*p-(t.y-g)*x+M)/this.scale+this.translateX,y:((t.x-M)*x+(t.y-g)*p+g)/this.scale+this.translateY});return{topLeft:y(c),topRight:y(l),bottomRight:y(f),bottomLeft:y(d)}}static calculateBoundingBox(t,i,s,h,n,e,r){let o=Math.min(t,s),a=Math.min(i,h),u=Math.max(t,s),c=Math.max(i,h);if(void 0!==n&&void 0!==e){const r=t-2*n+s;if(0!==r){const i=(t-n)/r;if(i>0&&i<1){const h=(1-i)*(1-i)*t+2*(1-i)*i*n+i*i*s;o=Math.min(o,h),u=Math.max(u,h)}}const l=i-2*e+h;if(0!==l){const t=(i-e)/l;if(t>0&&t<1){const s=(1-t)*(1-t)*i+2*(1-t)*t*e+t*t*h;a=Math.min(a,s),c=Math.max(c,s)}}}const l=r/2;return{minX:o-l,minY:a-l,maxX:u+l,maxY:c+l}}calculateBoundingBox(){return u.calculateBoundingBox(this.startX,this.startY,this.endX,this.endY,this.controlX,this.controlY,this.strokeWidth)}updateDimensions(){const{minX:t,minY:i,maxX:s,maxY:h}=this.calculateBoundingBox();this.width=s-t,this.height=h-i,this.x=t,this.y=i,this.translateX=(this.x+this.translateX)/this.scale,this.translateY=(this.y+this.translateY)/this.scale}get startMarkerId(){return`arrow-start-${this.id}`}get endMarkerId(){return`arrow-end-${this.id}`}getArrowSize(t){const i="start"===t?this.arrows?.start:this.arrows?.end;return i?.size??3*this.strokeWidth}getArrowFill(t){const s="start"===t?this.arrows?.start:this.arrows?.end;return i.resolveThemeColor(s?.fill??this.stroke)}getArrowPath(t="triangle"){switch(t){case"triangle":default:return"M 0 0 L 10 5 L 0 10 z";case"open":return"M 0 0 L 10 5 L 0 10";case"diamond":return"M 0 5 L 5 0 L 10 5 L 5 10 z";case"circle":return"M 5,0 A 5,5 0 1,1 5,10 A 5,5 0 1,1 5,0"}}get hasStartArrow(){return!0===this.arrows?.start?.enabled}get hasEndArrow(){return!0===this.arrows?.end?.enabled}}export{a as K,u as a,s as b,h as c}