@myoc/element 0.19.502-ff5a131b0 → 0.19.503

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 (104) hide show
  1. package/dist/dev/index.js +7817 -2494
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +43 -18
  4. package/dist/types/common/debug.d.ts +21 -0
  5. package/dist/types/common/src/appEventBus.d.ts +27 -0
  6. package/dist/types/common/src/colors.d.ts +1 -1
  7. package/dist/types/common/src/constants.d.ts +3 -0
  8. package/dist/types/common/src/index.d.ts +3 -0
  9. package/dist/types/common/src/utils.d.ts +4 -7
  10. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  11. package/dist/types/element/src/Scene.d.ts +2 -0
  12. package/dist/types/element/src/arrowheads.d.ts +3 -0
  13. package/dist/types/element/src/arrows/focus.d.ts +27 -0
  14. package/dist/types/element/src/arrows/helpers.d.ts +5 -0
  15. package/dist/types/element/src/binding.d.ts +13 -8
  16. package/dist/types/element/src/bounds.d.ts +1 -1
  17. package/dist/types/element/src/collision.d.ts +4 -3
  18. package/dist/types/element/src/distribute.d.ts +2 -1
  19. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  20. package/dist/types/element/src/index.d.ts +4 -0
  21. package/dist/types/element/src/linearElementEditor.d.ts +5 -0
  22. package/dist/types/element/src/mutateElement.d.ts +2 -0
  23. package/dist/types/element/src/selection.d.ts +5 -1
  24. package/dist/types/element/src/shapes.d.ts +2 -22
  25. package/dist/types/element/src/textElement.d.ts +1 -1
  26. package/dist/types/element/src/textWrapping.d.ts +26 -0
  27. package/dist/types/element/src/types.d.ts +5 -2
  28. package/dist/types/element/src/utils.d.ts +5 -3
  29. package/dist/types/element/src/zindex.d.ts +1 -1
  30. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +38 -35
  31. package/dist/types/excalidraw/actions/actionBoundText.d.ts +27 -25
  32. package/dist/types/excalidraw/actions/actionCanvas.d.ts +143 -132
  33. package/dist/types/excalidraw/actions/actionClipboard.d.ts +26 -24
  34. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -12
  35. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +41 -36
  36. package/dist/types/excalidraw/actions/actionElementLink.d.ts +9 -12
  37. package/dist/types/excalidraw/actions/actionElementLock.d.ts +26 -24
  38. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -12
  39. package/dist/types/excalidraw/actions/actionExport.d.ts +75 -368
  40. package/dist/types/excalidraw/actions/actionFrame.d.ts +52 -48
  41. package/dist/types/excalidraw/actions/actionGroup.d.ts +27 -25
  42. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +15 -12
  43. package/dist/types/excalidraw/actions/actionLink.d.ts +13 -12
  44. package/dist/types/excalidraw/actions/actionMenu.d.ts +9 -12
  45. package/dist/types/excalidraw/actions/actionProperties.d.ts +28 -26
  46. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +13 -12
  47. package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -11
  48. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
  49. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +181 -0
  50. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +13 -12
  51. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +181 -0
  52. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -12
  53. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +9 -12
  54. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -12
  55. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +13 -12
  56. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -12
  57. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  58. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  59. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  60. package/dist/types/excalidraw/appState.d.ts +9 -7
  61. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  62. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  63. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  64. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  65. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  66. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  67. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  68. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  69. package/dist/types/excalidraw/clipboard.d.ts +6 -7
  70. package/dist/types/excalidraw/components/App.d.ts +55 -13
  71. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  72. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +1 -1
  73. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  74. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  75. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -1
  76. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  77. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  78. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
  79. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +30 -17
  80. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +3 -2
  81. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +11 -13
  82. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
  83. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
  84. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
  85. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
  86. package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +1 -1
  87. package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
  88. package/dist/types/excalidraw/components/icons.d.ts +23 -9
  89. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +17 -0
  90. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +23 -13
  91. package/dist/types/excalidraw/data/blob.d.ts +45 -44
  92. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  93. package/dist/types/excalidraw/data/index.d.ts +2 -3
  94. package/dist/types/excalidraw/data/json.d.ts +37 -28
  95. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  96. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  97. package/dist/types/excalidraw/index.d.ts +25 -3
  98. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  99. package/dist/types/excalidraw/types.d.ts +93 -16
  100. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
  101. package/dist/types/math/src/point.d.ts +7 -2
  102. package/dist/types/math/src/types.d.ts +25 -1
  103. package/package.json +3 -3
  104. package/dist/types/excalidraw/charts.d.ts +0 -27
@@ -1,27 +1,52 @@
1
- var Hc=Object.create;var Ks=Object.defineProperty;var _c=Object.getOwnPropertyDescriptor;var Uc=Object.getOwnPropertyNames;var Yc=Object.getPrototypeOf,Wc=Object.prototype.hasOwnProperty;var Xc=(e,t)=>()=>(e&&(t=e(e=0)),t);var jc=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Vc=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Uc(t))!Wc.call(e,o)&&o!==n&&Ks(e,o,{get:()=>t[o],enumerable:!(i=_c(t,o))||i.enumerable});return e};var $c=(e,t,n)=>(n=e!=null?Hc(Yc(e)):{},Vc(t||!e||!e.__esModule?Ks(n,"default",{value:e,enumerable:!0}):n,e));var v,P=Xc(()=>{v={PROD:!0}});var Xd=jc((BP,Wd)=>{P();var Yd="Expected a function",_d=NaN,Eh="[object Symbol]",gh=/^\s+|\s+$/g,xh=/^[-+]0x[0-9a-f]+$/i,wh=/^0b[01]+$/i,yh=/^0o[0-7]+$/i,bh=parseInt,Ph=typeof global=="object"&&global&&global.Object===Object&&global,Ih=typeof self=="object"&&self&&self.Object===Object&&self,Sh=Ph||Ih||Function("return this")(),Mh=Object.prototype,Ah=Mh.toString,Th=Math.max,vh=Math.min,Ls=function(){return Sh.Date.now()};function Dh(e,t,n){var i,o,r,s,a,l,d=0,c=!1,u=!1,m=!0;if(typeof e!="function")throw new TypeError(Yd);t=Ud(t)||0,$o(n)&&(c=!!n.leading,u="maxWait"in n,r=u?Th(Ud(n.maxWait)||0,t):r,m="trailing"in n?!!n.trailing:m);function p(I){var S=i,A=o;return i=o=void 0,d=I,s=e.apply(A,S),s}function f(I){return d=I,a=setTimeout(g,t),c?p(I):s}function h(I){var S=I-l,A=I-d,M=t-S;return u?vh(M,r-A):M}function E(I){var S=I-l,A=I-d;return l===void 0||S>=t||S<0||u&&A>=r}function g(){var I=Ls();if(E(I))return x(I);a=setTimeout(g,h(I))}function x(I){return a=void 0,m&&i?p(I):(i=o=void 0,s)}function w(){a!==void 0&&clearTimeout(a),d=0,i=l=o=a=void 0}function b(){return a===void 0?s:x(Ls())}function y(){var I=Ls(),S=E(I);if(i=arguments,o=this,l=I,S){if(a===void 0)return f(l);if(u)return a=setTimeout(g,t),p(l)}return a===void 0&&(a=setTimeout(g,t)),s}return y.cancel=w,y.flush=b,y}function Lh(e,t,n){var i=!0,o=!0;if(typeof e!="function")throw new TypeError(Yd);return $o(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),Dh(e,t,{leading:i,maxWait:t,trailing:o})}function $o(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Bh(e){return!!e&&typeof e=="object"}function Ch(e){return typeof e=="symbol"||Bh(e)&&Ah.call(e)==Eh}function Ud(e){if(typeof e=="number")return e;if(Ch(e))return _d;if($o(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=$o(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(gh,"");var n=wh.test(e);return n||yh.test(e)?bh(e.slice(2),n?2:8):xh.test(e)?_d:+e}Wd.exports=Lh});P();import{toIterable as rg}from"@excalidraw/common";P();import{SHIFT_LOCKING_ANGLE as Nt,viewportCoordsToSceneCoords as Yo}from"@excalidraw/common";import{normalizeRadians as bd,radiansBetweenAngles as Xf,radiansDifference as jf}from"@excalidraw/math";import{pointsEqual as Vf}from"@excalidraw/math";P();P();P();P();P();P();P();P();P();function dr(e,t,n){if(e&&e.length){let[i,o]=t,r=Math.PI/180*n,s=Math.cos(r),a=Math.sin(r);for(let l of e){let[d,c]=l;l[0]=(d-i)*s-(c-o)*a+i,l[1]=(d-i)*a+(c-o)*s+o}}}function qc(e,t,n){let i=[];e.forEach(o=>i.push(...o)),dr(i,t,n)}function Kc(e,t){return e[0]===t[0]&&e[1]===t[1]}function Qs(e,t,n,i=1){let o=n,r=Math.max(t,.1),s=e[0]&&e[0][0]&&typeof e[0][0]=="number"?[e]:e,a=[0,0];if(o)for(let d of s)dr(d,a,o);let l=Qc(s,r,i);if(o){for(let d of s)dr(d,a,-o);qc(l,a,-o)}return l}function Qc(e,t,n){let i=[];for(let d of e){let c=[...d];Kc(c[0],c[c.length-1])||c.push([c[0][0],c[0][1]]),c.length>2&&i.push(c)}let o=[];t=Math.max(t,.1);let r=[];for(let d of i)for(let c=0;c<d.length-1;c++){let u=d[c],m=d[c+1];if(u[1]!==m[1]){let p=Math.min(u[1],m[1]);r.push({ymin:p,ymax:Math.max(u[1],m[1]),x:p===u[1]?u[0]:m[0],islope:(m[0]-u[0])/(m[1]-u[1])})}}if(r.sort((d,c)=>d.ymin<c.ymin?-1:d.ymin>c.ymin?1:d.x<c.x?-1:d.x>c.x?1:d.ymax===c.ymax?0:(d.ymax-c.ymax)/Math.abs(d.ymax-c.ymax)),!r.length)return o;let s=[],a=r[0].ymin,l=0;for(;s.length||r.length;){if(r.length){let d=-1;for(let u=0;u<r.length&&!(r[u].ymin>a);u++)d=u;r.splice(0,d+1).forEach(u=>{s.push({s:a,edge:u})})}if(s=s.filter(d=>!(d.edge.ymax<=a)),s.sort((d,c)=>d.edge.x===c.edge.x?0:(d.edge.x-c.edge.x)/Math.abs(d.edge.x-c.edge.x)),(n!==1||l%t===0)&&s.length>1)for(let d=0;d<s.length;d=d+2){let c=d+1;if(c>=s.length)break;let u=s[d].edge,m=s[c].edge;o.push([[Math.round(u.x),a],[Math.round(m.x),a]])}a+=n,s.forEach(d=>{d.edge.x=d.edge.x+n*d.edge.islope}),l++}return o}function dt(e,t){var n;let i=t.hachureAngle+90,o=t.hachureGap;o<0&&(o=t.strokeWidth*4),o=Math.max(o,.1);let r=1;return t.roughness>=1&&(((n=t.randomizer)===null||n===void 0?void 0:n.next())||Math.random())>.7&&(r=o),Qs(e,o,i,r||1)}var Ut=class{constructor(t){this.helper=t}fillPolygons(t,n){return this._fillPolygons(t,n)}_fillPolygons(t,n){let i=dt(t,n);return{type:"fillSketch",ops:this.renderLines(i,n)}}renderLines(t,n){let i=[];for(let o of t)i.push(...this.helper.doubleLineOps(o[0][0],o[0][1],o[1][0],o[1][1],n));return i}};P();P();function Yt(e){let t=e[0],n=e[1];return Math.sqrt(Math.pow(t[0]-n[0],2)+Math.pow(t[1]-n[1],2))}var zi=class extends Ut{fillPolygons(t,n){let i=n.hachureGap;i<0&&(i=n.strokeWidth*4),i=Math.max(i,.1);let o=Object.assign({},n,{hachureGap:i}),r=dt(t,o),s=Math.PI/180*n.hachureAngle,a=[],l=i*.5*Math.cos(s),d=i*.5*Math.sin(s);for(let[u,m]of r)Yt([u,m])&&a.push([[u[0]-l,u[1]+d],[...m]],[[u[0]+l,u[1]-d],[...m]]);return{type:"fillSketch",ops:this.renderLines(a,n)}}};P();var Hi=class extends Ut{fillPolygons(t,n){let i=this._fillPolygons(t,n),o=Object.assign({},n,{hachureAngle:n.hachureAngle+90}),r=this._fillPolygons(t,o);return i.ops=i.ops.concat(r.ops),i}};P();var _i=class{constructor(t){this.helper=t}fillPolygons(t,n){n=Object.assign({},n,{hachureAngle:0});let i=dt(t,n);return this.dotsOnLines(i,n)}dotsOnLines(t,n){let i=[],o=n.hachureGap;o<0&&(o=n.strokeWidth*4),o=Math.max(o,.1);let r=n.fillWeight;r<0&&(r=n.strokeWidth/2);let s=o/4;for(let a of t){let l=Yt(a),d=l/o,c=Math.ceil(d)-1,u=l-c*o,m=(a[0][0]+a[1][0])/2-o/4,p=Math.min(a[0][1],a[1][1]);for(let f=0;f<c;f++){let h=p+u+f*o,E=m-s+Math.random()*2*s,g=h-s+Math.random()*2*s,x=this.helper.ellipse(E,g,r,r,n);i.push(...x.ops)}}return{type:"fillSketch",ops:i}}};P();var Ui=class{constructor(t){this.helper=t}fillPolygons(t,n){let i=dt(t,n);return{type:"fillSketch",ops:this.dashedLine(i,n)}}dashedLine(t,n){let i=n.dashOffset<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashOffset,o=n.dashGap<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashGap,r=[];return t.forEach(s=>{let a=Yt(s),l=Math.floor(a/(i+o)),d=(a+o-l*(i+o))/2,c=s[0],u=s[1];c[0]>u[0]&&(c=s[1],u=s[0]);let m=Math.atan((u[1]-c[1])/(u[0]-c[0]));for(let p=0;p<l;p++){let f=p*(i+o),h=f+i,E=[c[0]+f*Math.cos(m)+d*Math.cos(m),c[1]+f*Math.sin(m)+d*Math.sin(m)],g=[c[0]+h*Math.cos(m)+d*Math.cos(m),c[1]+h*Math.sin(m)+d*Math.sin(m)];r.push(...this.helper.doubleLineOps(E[0],E[1],g[0],g[1],n))}}),r}};P();var Yi=class{constructor(t){this.helper=t}fillPolygons(t,n){let i=n.hachureGap<0?n.strokeWidth*4:n.hachureGap,o=n.zigzagOffset<0?i:n.zigzagOffset;n=Object.assign({},n,{hachureGap:i+o});let r=dt(t,n);return{type:"fillSketch",ops:this.zigzagLines(r,o,n)}}zigzagLines(t,n,i){let o=[];return t.forEach(r=>{let s=Yt(r),a=Math.round(s/(2*n)),l=r[0],d=r[1];l[0]>d[0]&&(l=r[1],d=r[0]);let c=Math.atan((d[1]-l[1])/(d[0]-l[0]));for(let u=0;u<a;u++){let m=u*2*n,p=(u+1)*2*n,f=Math.sqrt(2*Math.pow(n,2)),h=[l[0]+m*Math.cos(c),l[1]+m*Math.sin(c)],E=[l[0]+p*Math.cos(c),l[1]+p*Math.sin(c)],g=[h[0]+f*Math.cos(c+Math.PI/4),h[1]+f*Math.sin(c+Math.PI/4)];o.push(...this.helper.doubleLineOps(h[0],h[1],g[0],g[1],i),...this.helper.doubleLineOps(g[0],g[1],E[0],E[1],i))}}),o}};var Be={};function Js(e,t){let n=e.fillStyle||"hachure";if(!Be[n])switch(n){case"zigzag":Be[n]||(Be[n]=new zi(t));break;case"cross-hatch":Be[n]||(Be[n]=new Hi(t));break;case"dots":Be[n]||(Be[n]=new _i(t));break;case"dashed":Be[n]||(Be[n]=new Ui(t));break;case"zigzag-line":Be[n]||(Be[n]=new Yi(t));break;case"hachure":default:n="hachure",Be[n]||(Be[n]=new Ut(t));break}return Be[n]}P();function ea(){return Math.floor(Math.random()*2**31)}var Wi=class{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}};P();P();var Xi={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function Jc(e){let t=new Array;for(;e!=="";)if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([aAcChHlLmMqQsStTvVzZ])/))t[t.length]={type:0,text:RegExp.$1},e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))t[t.length]={type:1,text:`${parseFloat(RegExp.$1)}`},e=e.substr(RegExp.$1.length);else return[];return t[t.length]={type:2,text:""},t}function cr(e,t){return e.type===t}function Cn(e){let t=[],n=Jc(e),i="BOD",o=0,r=n[o];for(;!cr(r,2);){let s=0,a=[];if(i==="BOD")if(r.text==="M"||r.text==="m")o++,s=Xi[r.text],i=r.text;else return Cn("M0,0"+e);else cr(r,1)?s=Xi[i]:(o++,s=Xi[r.text],i=r.text);if(o+s<n.length){for(let l=o;l<o+s;l++){let d=n[l];if(cr(d,1))a[a.length]=+d.text;else throw new Error("Param not a number: "+i+","+d.text)}if(typeof Xi[i]=="number"){let l={key:i,data:a};t.push(l),o+=s,r=n[o],i==="M"&&(i="L"),i==="m"&&(i="l")}else throw new Error("Bad segment: "+i)}else throw new Error("Path data ended short")}return t}P();function Kn(e){let t=0,n=0,i=0,o=0,r=[];for(let{key:s,data:a}of e)switch(s){case"M":r.push({key:"M",data:[...a]}),[t,n]=a,[i,o]=a;break;case"m":t+=a[0],n+=a[1],r.push({key:"M",data:[t,n]}),i=t,o=n;break;case"L":r.push({key:"L",data:[...a]}),[t,n]=a;break;case"l":t+=a[0],n+=a[1],r.push({key:"L",data:[t,n]});break;case"C":r.push({key:"C",data:[...a]}),t=a[4],n=a[5];break;case"c":{let l=a.map((d,c)=>c%2?d+n:d+t);r.push({key:"C",data:l}),t=l[4],n=l[5];break}case"Q":r.push({key:"Q",data:[...a]}),t=a[2],n=a[3];break;case"q":{let l=a.map((d,c)=>c%2?d+n:d+t);r.push({key:"Q",data:l}),t=l[2],n=l[3];break}case"A":r.push({key:"A",data:[...a]}),t=a[5],n=a[6];break;case"a":t+=a[5],n+=a[6],r.push({key:"A",data:[a[0],a[1],a[2],a[3],a[4],t,n]});break;case"H":r.push({key:"H",data:[...a]}),t=a[0];break;case"h":t+=a[0],r.push({key:"H",data:[t]});break;case"V":r.push({key:"V",data:[...a]}),n=a[0];break;case"v":n+=a[0],r.push({key:"V",data:[n]});break;case"S":r.push({key:"S",data:[...a]}),t=a[2],n=a[3];break;case"s":{let l=a.map((d,c)=>c%2?d+n:d+t);r.push({key:"S",data:l}),t=l[2],n=l[3];break}case"T":r.push({key:"T",data:[...a]}),t=a[0],n=a[1];break;case"t":t+=a[0],n+=a[1],r.push({key:"T",data:[t,n]});break;case"Z":case"z":r.push({key:"Z",data:[]}),t=i,n=o;break}return r}P();function Jn(e){let t=[],n="",i=0,o=0,r=0,s=0,a=0,l=0;for(let{key:d,data:c}of e){switch(d){case"M":t.push({key:"M",data:[...c]}),[i,o]=c,[r,s]=c;break;case"C":t.push({key:"C",data:[...c]}),i=c[4],o=c[5],a=c[2],l=c[3];break;case"L":t.push({key:"L",data:[...c]}),[i,o]=c;break;case"H":i=c[0],t.push({key:"L",data:[i,o]});break;case"V":o=c[0],t.push({key:"L",data:[i,o]});break;case"S":{let u=0,m=0;n==="C"||n==="S"?(u=i+(i-a),m=o+(o-l)):(u=i,m=o),t.push({key:"C",data:[u,m,...c]}),a=c[0],l=c[1],i=c[2],o=c[3];break}case"T":{let[u,m]=c,p=0,f=0;n==="Q"||n==="T"?(p=i+(i-a),f=o+(o-l)):(p=i,f=o);let h=i+2*(p-i)/3,E=o+2*(f-o)/3,g=u+2*(p-u)/3,x=m+2*(f-m)/3;t.push({key:"C",data:[h,E,g,x,u,m]}),a=p,l=f,i=u,o=m;break}case"Q":{let[u,m,p,f]=c,h=i+2*(u-i)/3,E=o+2*(m-o)/3,g=p+2*(u-p)/3,x=f+2*(m-f)/3;t.push({key:"C",data:[h,E,g,x,p,f]}),a=u,l=m,i=p,o=f;break}case"A":{let u=Math.abs(c[0]),m=Math.abs(c[1]),p=c[2],f=c[3],h=c[4],E=c[5],g=c[6];u===0||m===0?(t.push({key:"C",data:[i,o,E,g,E,g]}),i=E,o=g):(i!==E||o!==g)&&(ta(i,o,E,g,u,m,p,f,h).forEach(function(w){t.push({key:"C",data:w})}),i=E,o=g);break}case"Z":t.push({key:"Z",data:[]}),i=r,o=s;break}n=d}return t}function eu(e){return Math.PI*e/180}function Qn(e,t,n){let i=e*Math.cos(n)-t*Math.sin(n),o=e*Math.sin(n)+t*Math.cos(n);return[i,o]}function ta(e,t,n,i,o,r,s,a,l,d){let c=eu(s),u=[],m=0,p=0,f=0,h=0;if(d)[m,p,f,h]=d;else{[e,t]=Qn(e,t,-c),[n,i]=Qn(n,i,-c);let G=(e-n)/2,B=(t-i)/2,U=G*G/(o*o)+B*B/(r*r);U>1&&(U=Math.sqrt(U),o=U*o,r=U*r);let N=a===l?-1:1,Y=o*o,F=r*r,T=Y*F-Y*B*B-F*G*G,$=Y*B*B+F*G*G,Z=N*Math.sqrt(Math.abs(T/$));f=Z*o*B/r+(e+n)/2,h=Z*-r*G/o+(t+i)/2,m=Math.asin(parseFloat(((t-h)/r).toFixed(9))),p=Math.asin(parseFloat(((i-h)/r).toFixed(9))),e<f&&(m=Math.PI-m),n<f&&(p=Math.PI-p),m<0&&(m=Math.PI*2+m),p<0&&(p=Math.PI*2+p),l&&m>p&&(m=m-Math.PI*2),!l&&p>m&&(p=p-Math.PI*2)}let E=p-m;if(Math.abs(E)>Math.PI*120/180){let G=p,B=n,U=i;l&&p>m?p=m+Math.PI*120/180*1:p=m+Math.PI*120/180*-1,n=f+o*Math.cos(p),i=h+r*Math.sin(p),u=ta(n,i,B,U,o,r,s,0,l,[p,G,f,h])}E=p-m;let g=Math.cos(m),x=Math.sin(m),w=Math.cos(p),b=Math.sin(p),y=Math.tan(E/4),I=4/3*o*y,S=4/3*r*y,A=[e,t],M=[e+I*x,t-S*g],k=[n+I*b,i-S*w],L=[n,i];if(M[0]=2*A[0]-M[0],M[1]=2*A[1]-M[1],d)return[M,k,L].concat(u);{u=[M,k,L].concat(u);let G=[];for(let B=0;B<u.length;B+=3){let U=Qn(u[B][0],u[B][1],c),N=Qn(u[B+1][0],u[B+1][1],c),Y=Qn(u[B+2][0],u[B+2][1],c);G.push([U[0],U[1],N[0],N[1],Y[0],Y[1]])}return G}}var tu={randOffset:ou,randOffsetWithRange:ru,ellipse:iu,doubleLineOps:su};function ur(e,t,n,i,o){return{type:"path",ops:wt(e,t,n,i,o)}}function ei(e,t,n){let i=(e||[]).length;if(i>2){let o=[];for(let r=0;r<i-1;r++)o.push(...wt(e[r][0],e[r][1],e[r+1][0],e[r+1][1],n));return t&&o.push(...wt(e[i-1][0],e[i-1][1],e[0][0],e[0][1],n)),{type:"path",ops:o}}else if(i===2)return ur(e[0][0],e[0][1],e[1][0],e[1][1],n);return{type:"path",ops:[]}}function nu(e,t){return ei(e,!0,t)}function sa(e,t,n,i,o){let r=[[e,t],[e+n,t],[e+n,t+i],[e,t+i]];return nu(r,o)}function mr(e,t){let n=ia(e,1*(1+t.roughness*.2),t);if(!t.disableMultiStroke){let i=ia(e,1.5*(1+t.roughness*.22),au(t));n=n.concat(i)}return{type:"path",ops:n}}function iu(e,t,n,i,o){let r=pr(n,i,o);return $i(e,t,o,r).opset}function pr(e,t,n){let i=Math.sqrt(Math.PI*2*Math.sqrt((Math.pow(e/2,2)+Math.pow(t/2,2))/2)),o=Math.ceil(Math.max(n.curveStepCount,n.curveStepCount/Math.sqrt(200)*i)),r=Math.PI*2/o,s=Math.abs(e/2),a=Math.abs(t/2),l=1-n.curveFitting;return s+=R(s*l,n),a+=R(a*l,n),{increment:r,rx:s,ry:a}}function $i(e,t,n,i){let[o,r]=oa(i.increment,e,t,i.rx,i.ry,1,i.increment*ji(.1,ji(.4,1,n),n),n),s=Vi(o,null,n);if(!n.disableMultiStroke&&n.roughness!==0){let[a]=oa(i.increment,e,t,i.rx,i.ry,1.5,0,n),l=Vi(a,null,n);s=s.concat(l)}return{estimatedPoints:r,opset:{type:"path",ops:s}}}function fr(e,t,n,i,o,r,s,a,l){let d=e,c=t,u=Math.abs(n/2),m=Math.abs(i/2);u+=R(u*.01,l),m+=R(m*.01,l);let p=o,f=r;for(;p<0;)p+=Math.PI*2,f+=Math.PI*2;f-p>Math.PI*2&&(p=0,f=Math.PI*2);let h=Math.PI*2/l.curveStepCount,E=Math.min(h/2,(f-p)/2),g=ra(E,d,c,u,m,p,f,1,l);if(!l.disableMultiStroke){let x=ra(E,d,c,u,m,p,f,1.5,l);g.push(...x)}return s&&(a?g.push(...wt(d,c,d+u*Math.cos(p),c+m*Math.sin(p),l),...wt(d,c,d+u*Math.cos(f),c+m*Math.sin(f),l)):g.push({op:"lineTo",data:[d,c]},{op:"lineTo",data:[d+u*Math.cos(p),c+m*Math.sin(p)]})),{type:"path",ops:g}}function hr(e,t){let n=Jn(Kn(Cn(e))),i=[],o=[0,0],r=[0,0];for(let{key:s,data:a}of n)switch(s){case"M":{r=[a[0],a[1]],o=[a[0],a[1]];break}case"L":i.push(...wt(r[0],r[1],a[0],a[1],t)),r=[a[0],a[1]];break;case"C":{let[l,d,c,u,m,p]=a;i.push(...lu(l,d,c,u,m,p,r,t)),r=[m,p];break}case"Z":i.push(...wt(r[0],r[1],o[0],o[1],t)),r=[o[0],o[1]];break}return{type:"path",ops:i}}function Zi(e,t){let n=[];for(let i of e)if(i.length){let o=t.maxRandomnessOffset||0,r=i.length;if(r>2){n.push({op:"move",data:[i[0][0]+R(o,t),i[0][1]+R(o,t)]});for(let s=1;s<r;s++)n.push({op:"lineTo",data:[i[s][0]+R(o,t),i[s][1]+R(o,t)]})}}return{type:"fillPath",ops:n}}function gn(e,t){return Js(t,tu).fillPolygons(e,t)}function aa(e,t,n,i,o,r,s){let a=e,l=t,d=Math.abs(n/2),c=Math.abs(i/2);d+=R(d*.01,s),c+=R(c*.01,s);let u=o,m=r;for(;u<0;)u+=Math.PI*2,m+=Math.PI*2;m-u>Math.PI*2&&(u=0,m=Math.PI*2);let p=(m-u)/s.curveStepCount,f=[];for(let h=u;h<=m;h=h+p)f.push([a+d*Math.cos(h),l+c*Math.sin(h)]);return f.push([a+d*Math.cos(m),l+c*Math.sin(m)]),f.push([a,l]),gn([f],s)}function ou(e,t){return R(e,t)}function ru(e,t,n){return ji(e,t,n)}function su(e,t,n,i,o){return wt(e,t,n,i,o,!0)}function au(e){let t=Object.assign({},e);return t.randomizer=void 0,e.seed&&(t.seed=e.seed+1),t}function la(e){return e.randomizer||(e.randomizer=new Wi(e.seed||0)),e.randomizer.next()}function ji(e,t,n,i=1){return n.roughness*i*(la(n)*(t-e)+e)}function R(e,t,n=1){return ji(-e,e,t,n)}function wt(e,t,n,i,o,r=!1){let s=r?o.disableMultiStrokeFill:o.disableMultiStroke,a=na(e,t,n,i,o,!0,!1);if(s)return a;let l=na(e,t,n,i,o,!0,!0);return a.concat(l)}function na(e,t,n,i,o,r,s){let a=Math.pow(e-n,2)+Math.pow(t-i,2),l=Math.sqrt(a),d=1;l<200?d=1:l>500?d=.4:d=-.0016668*l+1.233334;let c=o.maxRandomnessOffset||0;c*c*100>a&&(c=l/10);let u=c/2,m=.2+la(o)*.2,p=o.bowing*o.maxRandomnessOffset*(i-t)/200,f=o.bowing*o.maxRandomnessOffset*(e-n)/200;p=R(p,o,d),f=R(f,o,d);let h=[],E=()=>R(u,o,d),g=()=>R(c,o,d),x=o.preserveVertices;return r&&(s?h.push({op:"move",data:[e+(x?0:E()),t+(x?0:E())]}):h.push({op:"move",data:[e+(x?0:R(c,o,d)),t+(x?0:R(c,o,d))]})),s?h.push({op:"bcurveTo",data:[p+e+(n-e)*m+E(),f+t+(i-t)*m+E(),p+e+2*(n-e)*m+E(),f+t+2*(i-t)*m+E(),n+(x?0:E()),i+(x?0:E())]}):h.push({op:"bcurveTo",data:[p+e+(n-e)*m+g(),f+t+(i-t)*m+g(),p+e+2*(n-e)*m+g(),f+t+2*(i-t)*m+g(),n+(x?0:g()),i+(x?0:g())]}),h}function ia(e,t,n){let i=[];i.push([e[0][0]+R(t,n),e[0][1]+R(t,n)]),i.push([e[0][0]+R(t,n),e[0][1]+R(t,n)]);for(let o=1;o<e.length;o++)i.push([e[o][0]+R(t,n),e[o][1]+R(t,n)]),o===e.length-1&&i.push([e[o][0]+R(t,n),e[o][1]+R(t,n)]);return Vi(i,null,n)}function Vi(e,t,n){let i=e.length,o=[];if(i>3){let r=[],s=1-n.curveTightness;o.push({op:"move",data:[e[1][0],e[1][1]]});for(let a=1;a+2<i;a++){let l=e[a];r[0]=[l[0],l[1]],r[1]=[l[0]+(s*e[a+1][0]-s*e[a-1][0])/6,l[1]+(s*e[a+1][1]-s*e[a-1][1])/6],r[2]=[e[a+1][0]+(s*e[a][0]-s*e[a+2][0])/6,e[a+1][1]+(s*e[a][1]-s*e[a+2][1])/6],r[3]=[e[a+1][0],e[a+1][1]],o.push({op:"bcurveTo",data:[r[1][0],r[1][1],r[2][0],r[2][1],r[3][0],r[3][1]]})}if(t&&t.length===2){let a=n.maxRandomnessOffset;o.push({op:"lineTo",data:[t[0]+R(a,n),t[1]+R(a,n)]})}}else i===3?(o.push({op:"move",data:[e[1][0],e[1][1]]}),o.push({op:"bcurveTo",data:[e[1][0],e[1][1],e[2][0],e[2][1],e[2][0],e[2][1]]})):i===2&&o.push(...wt(e[0][0],e[0][1],e[1][0],e[1][1],n));return o}function oa(e,t,n,i,o,r,s,a){let l=a.roughness===0,d=[],c=[];if(l){e=e/4,c.push([t+i*Math.cos(-e),n+o*Math.sin(-e)]);for(let u=0;u<=Math.PI*2;u=u+e){let m=[t+i*Math.cos(u),n+o*Math.sin(u)];d.push(m),c.push(m)}c.push([t+i*Math.cos(0),n+o*Math.sin(0)]),c.push([t+i*Math.cos(e),n+o*Math.sin(e)])}else{let u=R(.5,a)-Math.PI/2;c.push([R(r,a)+t+.9*i*Math.cos(u-e),R(r,a)+n+.9*o*Math.sin(u-e)]);let m=Math.PI*2+u-.01;for(let p=u;p<m;p=p+e){let f=[R(r,a)+t+i*Math.cos(p),R(r,a)+n+o*Math.sin(p)];d.push(f),c.push(f)}c.push([R(r,a)+t+i*Math.cos(u+Math.PI*2+s*.5),R(r,a)+n+o*Math.sin(u+Math.PI*2+s*.5)]),c.push([R(r,a)+t+.98*i*Math.cos(u+s),R(r,a)+n+.98*o*Math.sin(u+s)]),c.push([R(r,a)+t+.9*i*Math.cos(u+s*.5),R(r,a)+n+.9*o*Math.sin(u+s*.5)])}return[c,d]}function ra(e,t,n,i,o,r,s,a,l){let d=r+R(.1,l),c=[];c.push([R(a,l)+t+.9*i*Math.cos(d-e),R(a,l)+n+.9*o*Math.sin(d-e)]);for(let u=d;u<=s;u=u+e)c.push([R(a,l)+t+i*Math.cos(u),R(a,l)+n+o*Math.sin(u)]);return c.push([t+i*Math.cos(s),n+o*Math.sin(s)]),c.push([t+i*Math.cos(s),n+o*Math.sin(s)]),Vi(c,null,l)}function lu(e,t,n,i,o,r,s,a){let l=[],d=[a.maxRandomnessOffset||1,(a.maxRandomnessOffset||1)+.3],c=[0,0],u=a.disableMultiStroke?1:2,m=a.preserveVertices;for(let p=0;p<u;p++)p===0?l.push({op:"move",data:[s[0],s[1]]}):l.push({op:"move",data:[s[0]+(m?0:R(d[0],a)),s[1]+(m?0:R(d[0],a))]}),c=m?[o,r]:[o+R(d[p],a),r+R(d[p],a)],l.push({op:"bcurveTo",data:[e+R(d[p],a),t+R(d[p],a),n+R(d[p],a),i+R(d[p],a),c[0],c[1]]});return l}P();function ti(e){return[...e]}function da(e,t=0){let n=e.length;if(n<3)throw new Error("A curve must have at least three points.");let i=[];if(n===3)i.push(ti(e[0]),ti(e[1]),ti(e[2]),ti(e[2]));else{let o=[];o.push(e[0],e[0]);for(let a=1;a<e.length;a++)o.push(e[a]),a===e.length-1&&o.push(e[a]);let r=[],s=1-t;i.push(ti(o[0]));for(let a=1;a+2<o.length;a++){let l=o[a];r[0]=[l[0],l[1]],r[1]=[l[0]+(s*o[a+1][0]-s*o[a-1][0])/6,l[1]+(s*o[a+1][1]-s*o[a-1][1])/6],r[2]=[o[a+1][0]+(s*o[a][0]-s*o[a+2][0])/6,o[a+1][1]+(s*o[a][1]-s*o[a+2][1])/6],r[3]=[o[a+1][0],o[a+1][1]],i.push(r[1],r[2],r[3])}}return i}P();function du(e,t){return Math.sqrt(qi(e,t))}function qi(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function cu(e,t,n){let i=qi(t,n);if(i===0)return qi(e,t);let o=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/i;return o=Math.max(0,Math.min(1,o)),qi(e,xn(t,n,o))}function xn(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function uu(e,t){let n=e[t+0],i=e[t+1],o=e[t+2],r=e[t+3],s=3*i[0]-2*n[0]-r[0];s*=s;let a=3*i[1]-2*n[1]-r[1];a*=a;let l=3*o[0]-2*r[0]-n[0];l*=l;let d=3*o[1]-2*r[1]-n[1];return d*=d,s<l&&(s=l),a<d&&(a=d),s+a}function Er(e,t,n,i){let o=i||[];if(uu(e,t)<n){let r=e[t+0];o.length?du(o[o.length-1],r)>1&&o.push(r):o.push(r),o.push(e[t+3])}else{let s=e[t+0],a=e[t+1],l=e[t+2],d=e[t+3],c=xn(s,a,.5),u=xn(a,l,.5),m=xn(l,d,.5),p=xn(c,u,.5),f=xn(u,m,.5),h=xn(p,f,.5);Er([s,c,p,h],0,n,o),Er([h,f,m,d],0,n,o)}return o}function ni(e,t){return Ki(e,0,e.length,t)}function Ki(e,t,n,i,o){let r=o||[],s=e[t],a=e[n-1],l=0,d=1;for(let c=t+1;c<n-1;++c){let u=cu(e[c],s,a);u>l&&(l=u,d=c)}return Math.sqrt(l)>i?(Ki(e,t,d+1,i,r),Ki(e,d,n,i,r)):(r.length||r.push(s),r.push(a)),r}function yt(e,t=.15,n){let i=[],o=(e.length-1)/3;for(let r=0;r<o;r++){let s=r*3;Er(e,s,t,i)}return n&&n>0?Ki(i,0,i.length,n):i}P();function ca(e,t,n){let i=Cn(e),o=Jn(Kn(i)),r=[],s=[],a=[0,0],l=[],d=()=>{l.length>=4&&s.push(...yt(l,t)),l=[]},c=()=>{d(),s.length&&(r.push(s),s=[])};for(let{key:m,data:p}of o)switch(m){case"M":c(),a=[p[0],p[1]],s.push(a);break;case"L":d(),s.push([p[0],p[1]]);break;case"C":if(!l.length){let f=s.length?s[s.length-1]:a;l.push([f[0],f[1]])}l.push([p[0],p[1]]),l.push([p[2],p[3]]),l.push([p[4],p[5]]);break;case"Z":d(),s.push([a[0],a[1]]);break}if(c(),!n)return r;let u=[];for(let m of r){let p=ni(m,n);p.length&&u.push(p)}return u}var _e="none",$e=class{constructor(t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return ea()}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,n,i){return{shape:t,sets:n||[],options:i||this.defaultOptions}}line(t,n,i,o,r){let s=this._o(r);return this._d("line",[ur(t,n,i,o,s)],s)}rectangle(t,n,i,o,r){let s=this._o(r),a=[],l=sa(t,n,i,o,s);if(s.fill){let d=[[t,n],[t+i,n],[t+i,n+o],[t,n+o]];s.fillStyle==="solid"?a.push(Zi([d],s)):a.push(gn([d],s))}return s.stroke!==_e&&a.push(l),this._d("rectangle",a,s)}ellipse(t,n,i,o,r){let s=this._o(r),a=[],l=pr(i,o,s),d=$i(t,n,s,l);if(s.fill)if(s.fillStyle==="solid"){let c=$i(t,n,s,l).opset;c.type="fillPath",a.push(c)}else a.push(gn([d.estimatedPoints],s));return s.stroke!==_e&&a.push(d.opset),this._d("ellipse",a,s)}circle(t,n,i,o){let r=this.ellipse(t,n,i,i,o);return r.shape="circle",r}linearPath(t,n){let i=this._o(n);return this._d("linearPath",[ei(t,!1,i)],i)}arc(t,n,i,o,r,s,a=!1,l){let d=this._o(l),c=[],u=fr(t,n,i,o,r,s,a,!0,d);if(a&&d.fill)if(d.fillStyle==="solid"){let m=Object.assign({},d);m.disableMultiStroke=!0;let p=fr(t,n,i,o,r,s,!0,!1,m);p.type="fillPath",c.push(p)}else c.push(aa(t,n,i,o,r,s,d));return d.stroke!==_e&&c.push(u),this._d("arc",c,d)}curve(t,n){let i=this._o(n),o=[],r=mr(t,i);if(i.fill&&i.fill!==_e&&t.length>=3)if(i.fillStyle==="solid"){let s=mr(t,Object.assign(Object.assign({},i),{disableMultiStroke:!0,roughness:i.roughness?i.roughness+i.fillShapeRoughnessGain:0}));o.push({type:"fillPath",ops:this._mergedShape(s.ops)})}else{let s=da(t),a=yt(s,10,(1+i.roughness)/2);o.push(gn([a],i))}return i.stroke!==_e&&o.push(r),this._d("curve",o,i)}polygon(t,n){let i=this._o(n),o=[],r=ei(t,!0,i);return i.fill&&(i.fillStyle==="solid"?o.push(Zi([t],i)):o.push(gn([t],i))),i.stroke!==_e&&o.push(r),this._d("polygon",o,i)}path(t,n){let i=this._o(n),o=[];if(!t)return this._d("path",o,i);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let r=i.fill&&i.fill!=="transparent"&&i.fill!==_e,s=i.stroke!==_e,a=!!(i.simplification&&i.simplification<1),l=a?4-4*(i.simplification||1):(1+i.roughness)/2,d=ca(t,1,l),c=hr(t,i);if(r)if(i.fillStyle==="solid")if(d.length===1){let u=hr(t,Object.assign(Object.assign({},i),{disableMultiStroke:!0,roughness:i.roughness?i.roughness+i.fillShapeRoughnessGain:0}));o.push({type:"fillPath",ops:this._mergedShape(u.ops)})}else o.push(Zi(d,i));else o.push(gn(d,i));return s&&(a?d.forEach(u=>{o.push(ei(u,!1,i))}):o.push(c)),this._d("path",o,i)}opsToPath(t,n){let i="";for(let o of t.ops){let r=typeof n=="number"&&n>=0?o.data.map(s=>+s.toFixed(n)):o.data;switch(o.op){case"move":i+=`M${r[0]} ${r[1]} `;break;case"bcurveTo":i+=`C${r[0]} ${r[1]}, ${r[2]} ${r[3]}, ${r[4]} ${r[5]} `;break;case"lineTo":i+=`L${r[0]} ${r[1]} `;break}}return i.trim()}toPaths(t){let n=t.sets||[],i=t.options||this.defaultOptions,o=[];for(let r of n){let s=null;switch(r.type){case"path":s={d:this.opsToPath(r),stroke:i.stroke,strokeWidth:i.strokeWidth,fill:_e};break;case"fillPath":s={d:this.opsToPath(r),stroke:_e,strokeWidth:0,fill:i.fill||_e};break;case"fillSketch":s=this.fillSketch(r,i);break}s&&o.push(s)}return o}fillSketch(t,n){let i=n.fillWeight;return i<0&&(i=n.strokeWidth/2),{d:this.opsToPath(t),stroke:n.fill||_e,strokeWidth:i,fill:_e}}_mergedShape(t){return t.filter((n,i)=>i===0?!0:n.op!=="move")}};var Qi=class{constructor(t,n){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new $e(n)}draw(t){let n=t.sets||[],i=t.options||this.getDefaultOptions(),o=this.ctx,r=t.options.fixedDecimalPlaceDigits;for(let s of n)switch(s.type){case"path":o.save(),o.strokeStyle=i.stroke==="none"?"transparent":i.stroke,o.lineWidth=i.strokeWidth,i.strokeLineDash&&o.setLineDash(i.strokeLineDash),i.strokeLineDashOffset&&(o.lineDashOffset=i.strokeLineDashOffset),this._drawToContext(o,s,r),o.restore();break;case"fillPath":{o.save(),o.fillStyle=i.fill||"";let a=t.shape==="curve"||t.shape==="polygon"||t.shape==="path"?"evenodd":"nonzero";this._drawToContext(o,s,r,a),o.restore();break}case"fillSketch":this.fillSketch(o,s,i);break}}fillSketch(t,n,i){let o=i.fillWeight;o<0&&(o=i.strokeWidth/2),t.save(),i.fillLineDash&&t.setLineDash(i.fillLineDash),i.fillLineDashOffset&&(t.lineDashOffset=i.fillLineDashOffset),t.strokeStyle=i.fill||"",t.lineWidth=o,this._drawToContext(t,n,i.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,n,i,o="nonzero"){t.beginPath();for(let r of n.ops){let s=typeof i=="number"&&i>=0?r.data.map(a=>+a.toFixed(i)):r.data;switch(r.op){case"move":t.moveTo(s[0],s[1]);break;case"bcurveTo":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"lineTo":t.lineTo(s[0],s[1]);break}}n.type==="fillPath"?t.fill(o):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,n,i,o,r){let s=this.gen.line(t,n,i,o,r);return this.draw(s),s}rectangle(t,n,i,o,r){let s=this.gen.rectangle(t,n,i,o,r);return this.draw(s),s}ellipse(t,n,i,o,r){let s=this.gen.ellipse(t,n,i,o,r);return this.draw(s),s}circle(t,n,i,o){let r=this.gen.circle(t,n,i,o);return this.draw(r),r}linearPath(t,n){let i=this.gen.linearPath(t,n);return this.draw(i),i}polygon(t,n){let i=this.gen.polygon(t,n);return this.draw(i),i}arc(t,n,i,o,r,s,a=!1,l){let d=this.gen.arc(t,n,i,o,r,s,a,l);return this.draw(d),d}curve(t,n){let i=this.gen.curve(t,n);return this.draw(i),i}path(t,n){let i=this.gen.path(t,n);return this.draw(i),i}};P();P();var ii="http://www.w3.org/2000/svg";var Ji=class{constructor(t,n){this.svg=t,this.gen=new $e(n)}draw(t){let n=t.sets||[],i=t.options||this.getDefaultOptions(),o=this.svg.ownerDocument||window.document,r=o.createElementNS(ii,"g"),s=t.options.fixedDecimalPlaceDigits;for(let a of n){let l=null;switch(a.type){case"path":{l=o.createElementNS(ii,"path"),l.setAttribute("d",this.opsToPath(a,s)),l.setAttribute("stroke",i.stroke),l.setAttribute("stroke-width",i.strokeWidth+""),l.setAttribute("fill","none"),i.strokeLineDash&&l.setAttribute("stroke-dasharray",i.strokeLineDash.join(" ").trim()),i.strokeLineDashOffset&&l.setAttribute("stroke-dashoffset",`${i.strokeLineDashOffset}`);break}case"fillPath":{l=o.createElementNS(ii,"path"),l.setAttribute("d",this.opsToPath(a,s)),l.setAttribute("stroke","none"),l.setAttribute("stroke-width","0"),l.setAttribute("fill",i.fill||""),(t.shape==="curve"||t.shape==="polygon")&&l.setAttribute("fill-rule","evenodd");break}case"fillSketch":{l=this.fillSketch(o,a,i);break}}l&&r.appendChild(l)}return r}fillSketch(t,n,i){let o=i.fillWeight;o<0&&(o=i.strokeWidth/2);let r=t.createElementNS(ii,"path");return r.setAttribute("d",this.opsToPath(n,i.fixedDecimalPlaceDigits)),r.setAttribute("stroke",i.fill||""),r.setAttribute("stroke-width",o+""),r.setAttribute("fill","none"),i.fillLineDash&&r.setAttribute("stroke-dasharray",i.fillLineDash.join(" ").trim()),i.fillLineDashOffset&&r.setAttribute("stroke-dashoffset",`${i.fillLineDashOffset}`),r}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,n){return this.gen.opsToPath(t,n)}line(t,n,i,o,r){let s=this.gen.line(t,n,i,o,r);return this.draw(s)}rectangle(t,n,i,o,r){let s=this.gen.rectangle(t,n,i,o,r);return this.draw(s)}ellipse(t,n,i,o,r){let s=this.gen.ellipse(t,n,i,o,r);return this.draw(s)}circle(t,n,i,o){let r=this.gen.circle(t,n,i,o);return this.draw(r)}linearPath(t,n){let i=this.gen.linearPath(t,n);return this.draw(i)}polygon(t,n){let i=this.gen.polygon(t,n);return this.draw(i)}arc(t,n,i,o,r,s,a=!1,l){let d=this.gen.arc(t,n,i,o,r,s,a,l);return this.draw(d)}curve(t,n){let i=this.gen.curve(t,n);return this.draw(i)}path(t,n){let i=this.gen.path(t,n);return this.draw(i)}};var wn={canvas(e,t){return new Qi(e,t)},svg(e,t){return new Ji(e,t)},generator(e){return new $e(e)},newSeed(){return $e.newSeed()}};import{arrayToMap as wd,invariant as Es,rescalePoints as fd,sizeOf as Rf}from"@excalidraw/common";import{degreesToRadians as hs,lineSegment as Ee,pointDistance as Ff,pointFrom as D,pointFromArray as yd,pointRotateRads as oe}from"@excalidraw/math";P();import{invariant as mu}from"@excalidraw/common";import{curve as pu,lineSegment as fu,pointFrom as se,pointDistance as Yx,pointFromArray as hu,pointFromVector as Eu,pointRotateRads as et,polygon as ua,polygonFromPoints as gr,PRECISION as Wx,segmentsIntersectAt as Xx,vector as gu,vectorAdd as xu,vectorFromPoint as wu,vectorScale as jx}from"@excalidraw/math";import{getElementAbsoluteCoords as $x}from"@excalidraw/element";var ma=e=>{let{angle:t,width:n,height:i,x:o,y:r}=e,s=o+n/2,a=r+i/2,l=se(s,a),d;return e.type==="diamond"?d=ua(et(se(s,r),l,t),et(se(o+n,a),l,t),et(se(s,r+i),l,t),et(se(o,a),l,t)):d=ua(et(se(o,r),l,t),et(se(o+n,r),l,t),et(se(o+n,r+i),l,t),et(se(o,r+i),l,t)),{type:"polygon",data:d}};var pa=e=>{let{width:t,height:n,angle:i,x:o,y:r}=e;return{type:"ellipse",data:{center:se(o+t/2,r+n/2),angle:i,halfWidth:t/2,halfHeight:n/2}}},bt=e=>{if(!e)return[];for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},fa=(e,t=se(0,0),n,i)=>{let o=l=>et(se(l[0]+t[0],l[1]+t[1]),i,n),r=bt(e),s=[],a=se(0,0);for(let l of r){if(l.op==="move"){let d=hu(l.data);mu(d!=null,"Ops data is not a point"),a=o(d)}if(l.op==="bcurveTo"){let d=o(se(l.data[0],l.data[1])),c=o(se(l.data[2],l.data[3])),u=o(se(l.data[4],l.data[5]));s.push(pu(a,d,c,u)),a=u}}return{type:"polycurve",data:s}},yu=e=>{let t=e[0],n=[];for(let i=1;i<e.length;i++){let o=e[i];n.push(fu(t,o)),t=o}return n},ha=(e,t,n=!1)=>{let i=r=>et(Eu(xu(wu(r),gu(e.x,e.y))),t,e.angle),o=yu(e.points.map(r=>i(r)));return n?{type:"polygon",data:gr(o.flat())}:{type:"polyline",data:o}},Ea=(e,t,n=se(0,0),i,o)=>{let r=c=>et(se(c[0]+n[0],c[1]+n[1]),o,i);if(e.roundness===null)return{type:"polygon",data:gr(e.points.map(c=>r(c)))};let s=bt(t),a=[],l=!1;for(let c of s)c.op==="move"?(l=!l,l&&a.push(se(c.data[0],c.data[1]))):c.op==="bcurveTo"?l&&(a.push(se(c.data[0],c.data[1])),a.push(se(c.data[2],c.data[3])),a.push(se(c.data[4],c.data[5]))):c.op==="lineTo"&&l&&a.push(se(c.data[0],c.data[1]));let d=yt(a,10,5).map(c=>r(c));return{type:"polygon",data:gr(d)}};P();P();function ga(e,t,n,i=o=>o){return e*i(.5-t*(.5-n))}function bu(e){return[-e[0],-e[1]]}function nt(e,t){return[e[0]+t[0],e[1]+t[1]]}function Ze(e,t){return[e[0]-t[0],e[1]-t[1]]}function tt(e,t){return[e[0]*t,e[1]*t]}function Pu(e,t){return[e[0]/t,e[1]/t]}function oi(e){return[e[1],-e[0]]}function xa(e,t){return e[0]*t[0]+e[1]*t[1]}function Iu(e,t){return e[0]===t[0]&&e[1]===t[1]}function Su(e){return Math.hypot(e[0],e[1])}function Mu(e){return e[0]*e[0]+e[1]*e[1]}function wa(e,t){return Mu(Ze(e,t))}function Pa(e){return Pu(e,Su(e))}function Au(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function ri(e,t,n){let i=Math.sin(n),o=Math.cos(n),r=e[0]-t[0],s=e[1]-t[1],a=r*o-s*i,l=r*i+s*o;return[a+t[0],l+t[1]]}function xr(e,t,n){return nt(e,tt(Ze(t,e),n))}function ya(e,t,n){return nt(e,tt(t,n))}var{min:Gn,PI:Tu}=Math,ba=.275,si=Tu+1e-4;function vu(e,t={}){let{size:n=16,smoothing:i=.5,thinning:o=.5,simulatePressure:r=!0,easing:s=F=>F,start:a={},end:l={},last:d=!1}=t,{cap:c=!0,easing:u=F=>F*(2-F)}=a,{cap:m=!0,easing:p=F=>--F*F*F+1}=l;if(e.length===0||n<=0)return[];let f=e[e.length-1].runningLength,h=a.taper===!1?0:a.taper===!0?Math.max(n,f):a.taper,E=l.taper===!1?0:l.taper===!0?Math.max(n,f):l.taper,g=Math.pow(n*i,2),x=[],w=[],b=e.slice(0,10).reduce((F,T)=>{let $=T.pressure;if(r){let Z=Gn(1,T.distance/n),gt=Gn(1,1-Z);$=Gn(1,F+(gt-F)*(Z*ba))}return(F+$)/2},e[0].pressure),y=ga(n,o,e[e.length-1].pressure,s),I,S=e[0].vector,A=e[0].point,M=A,k=A,L=M,G=!1;for(let F=0;F<e.length;F++){let{pressure:T}=e[F],{point:$,vector:Z,distance:gt,runningLength:lt}=e[F];if(F<e.length-1&&f-lt<3)continue;if(o){if(r){let He=Gn(1,gt/n),Ve=Gn(1,1-He);T=Gn(1,b+(Ve-b)*(He*ba))}y=ga(n,o,T,s)}else y=n/2;I===void 0&&(I=y);let ki=lt<h?u(lt/h):1,ar=f-lt<E?p((f-lt)/E):1;y=Math.max(.01,y*Math.min(ki,ar));let Ri=(F<e.length-1?e[F+1]:e[F]).vector,qn=F<e.length-1?xa(Z,Ri):1,lr=xa(Z,S)<0&&!G,Fi=qn!==null&&qn<0;if(lr||Fi){let He=tt(oi(S),y);for(let Ve=1/13,_t=0;_t<=1;_t+=Ve)k=ri(Ze($,He),$,si*_t),x.push(k),L=ri(nt($,He),$,si*-_t),w.push(L);A=k,M=L,Fi&&(G=!0);continue}if(G=!1,F===e.length-1){let He=tt(oi(Z),y);x.push(Ze($,He)),w.push(nt($,He));continue}let Ni=tt(oi(xr(Ri,Z,qn)),y);k=Ze($,Ni),(F<=1||wa(A,k)>g)&&(x.push(k),A=k),L=nt($,Ni),(F<=1||wa(M,L)>g)&&(w.push(L),M=L),b=T,S=Z}let B=e[0].point.slice(0,2),U=e.length>1?e[e.length-1].point.slice(0,2):nt(e[0].point,[1,1]),N=[],Y=[];if(e.length===1){if(!(h||E)||d){let F=ya(B,Pa(oi(Ze(B,U))),-(I||y)),T=[];for(let $=1/13,Z=$;Z<=1;Z+=$)T.push(ri(F,B,si*2*Z));return T}}else{if(!(h||E&&e.length===1))if(c)for(let T=1/13,$=T;$<=1;$+=T){let Z=ri(w[0],B,si*$);N.push(Z)}else{let T=Ze(x[0],w[0]),$=tt(T,.5),Z=tt(T,.51);N.push(Ze(B,$),Ze(B,Z),nt(B,Z),nt(B,$))}let F=oi(bu(e[e.length-1].vector));if(E||h&&e.length===1)Y.push(U);else if(m){let T=ya(U,F,y);for(let $=1/29,Z=$;Z<1;Z+=$)Y.push(ri(T,U,si*3*Z))}else Y.push(nt(U,tt(F,y)),nt(U,tt(F,y*.99)),Ze(U,tt(F,y*.99)),Ze(U,tt(F,y)))}return x.concat(Y,w.reverse(),N)}function Du(e,t={}){var n;let{streamline:i=.5,size:o=16,last:r=!1}=t;if(e.length===0)return[];let s=.15+(1-i)*.85,a=Array.isArray(e[0])?e:e.map(({x:p,y:f,pressure:h=.5})=>[p,f,h]);if(a.length===2){let p=a[1];a=a.slice(0,-1);for(let f=1;f<5;f++)a.push(xr(a[0],p,f/4))}a.length===1&&(a=[...a,[...nt(a[0],[1,1]),...a[0].slice(2)]]);let l=[{point:[a[0][0],a[0][1]],pressure:a[0][2]>=0?a[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],d=!1,c=0,u=l[0],m=a.length-1;for(let p=1;p<a.length;p++){let f=r&&p===m?a[p].slice(0,2):xr(u.point,a[p],s);if(Iu(u.point,f))continue;let h=Au(f,u.point);if(c+=h,p<m&&!d){if(c<o)continue;d=!0}u={point:f,pressure:a[p][2]>=0?a[p][2]:.5,vector:Pa(Ze(u.point,f)),distance:h,runningLength:c},l.push(u)}return l[0].vector=((n=l[1])==null?void 0:n.vector)||[0,0],l}function Ia(e,t={}){return vu(Du(e,t),t)}import{pointFrom as le,pointDistance as ad,pointRotateRads as Ft}from"@excalidraw/math";import{ROUGHNESS as Mf,THEME as ps,isTransparent as Li,assertNever as Af,COLOR_PALETTE as Tf,LINE_POLYGON_POINT_MERGE_DISTANCE as vf,applyDarkModeFilter as Uo}from"@excalidraw/common";P();import{isRightAngleRads as pf,lineSegment as td,pointFrom as Fo,pointRotateRads as cs}from"@excalidraw/math";import{BOUND_TEXT_PADDING as No,DEFAULT_REDUCED_GLOBAL_ALPHA as ff,ELEMENT_READY_TO_ERASE_OPACITY as hf,FRAME_STYLE as Ti,DARK_THEME_FILTER as Ef,MIME_TYPES as ms,THEME as vi,distance as dn,getFontString as gf,isRTL as xf,getVerticalOffset as wf,invariant as yf,applyDarkModeFilter as Ho}from"@excalidraw/common";P();import{pointFrom as Pt,pointCenter as Lu,pointRotateRads as Wt,vectorFromPoint as wr,vectorNormalize as Sa,vectorSubtract as Ma,vectorAdd as eo,vectorScale as to,pointFromVector as Aa,clamp as be,isCloseTo as Ta}from"@excalidraw/math";var Pe=10,tw=(e,t,n,i,o,r,s,a)=>{let{width:l,height:d}=yr(e),c=i/l,u=o/d,m=(e.crop?.x??0)/c,p=(e.crop?.y??0)/u,f=Wt(Pt(r,s),de(e,t),-e.angle);r=f[0],s=f[1];let h=e.width,E=e.height,g=e.crop??{x:0,y:0,width:i,height:o,naturalWidth:i,naturalHeight:o},x=g.height,w=g.width,b=e.scale[0]===-1,y=e.scale[1]===-1,I=s-e.y,S=r-e.x;n.includes("n")&&(E=be(e.height-I,Pe,y?d-p:e.height+p)),n.includes("s")&&(I=s-e.y-e.height,E=be(e.height+I,Pe,y?e.height+p:d-p)),n.includes("e")&&(S=r-e.x-e.width,h=be(e.width+S,Pe,b?e.width+m:l-m)),n.includes("w")&&(h=be(e.width-S,Pe,b?l-m:e.width+m));let A=L=>{L.height=E*u,L.width=h*c};A(g);let M=(L,G)=>{A(G),L.includes("n")&&(y||(G.y+=x-G.height)),L.includes("s")&&y&&(G.y+=x-G.height),L.includes("e")&&b&&(G.x+=w-G.width),L.includes("w")&&(b||(G.x+=w-G.width))};switch(n){case"n":{if(a){let L=m+e.width/2,G=l-m-e.width/2,B=Math.min(L,G)*2;h=be(E*a,Pe,B),E=h/a}M(n,g),a&&(g.x+=(w-g.width)/2);break}case"s":{if(a){let L=m+e.width/2,G=l-m-e.width/2,B=Math.min(L,G)*2;h=be(E*a,Pe,B),E=h/a}M(n,g),a&&(g.x+=(w-g.width)/2);break}case"w":{if(a){let L=p+e.height/2,G=d-p-e.height/2,B=Math.min(L,G)*2;E=be(h/a,Pe,B),h=E*a}M(n,g),a&&(g.y+=(x-g.height)/2);break}case"e":{if(a){let L=p+e.height/2,G=d-p-e.height/2,B=Math.min(L,G)*2;E=be(h/a,Pe,B),h=E*a}M(n,g),a&&(g.y+=(x-g.height)/2);break}case"ne":{if(a)if(S>-I){let L=y?d-p:p+e.height;E=be(h/a,Pe,L),h=E*a}else{let L=b?m+e.width:l-m;h=be(E*a,Pe,L),E=h/a}M(n,g);break}case"nw":{if(a)if(S<I){let L=y?d-p:p+e.height;E=be(h/a,Pe,L),h=E*a}else{let L=b?l-m:m+e.width;h=be(E*a,Pe,L),E=h/a}M(n,g);break}case"se":{if(a)if(S>I){let L=y?p+e.height:d-p;E=be(h/a,Pe,L),h=E*a}else{let L=b?m+e.width:l-m;h=be(E*a,Pe,L),E=h/a}M(n,g);break}case"sw":{if(a)if(-S>I){let L=y?p+e.height:d-p;E=be(h/a,Pe,L),h=E*a}else{let L=b?l-m:m+e.width;h=be(E*a,Pe,L),E=h/a}M(n,g);break}default:break}let k=Bu(e,n,h,E,!!a);return Ta(g.width,g.naturalWidth)&&Ta(g.height,g.naturalHeight)&&(g=null),{x:k[0],y:k[1],width:h,height:E,crop:g}},Bu=(e,t,n,i,o)=>{let[r,s,a,l]=Xt(e,e.width,e.height,!0),d=Pt(r,s),c=Pt(a,l),u=Lu(d,c),[m,p,f,h]=Xt(e,n,i,!0),E=f-m,g=h-p,x=[...d];if(["n","w","nw"].includes(t)&&(x=[c[0]-Math.abs(E),c[1]-Math.abs(g)]),t==="ne"){let A=[d[0],c[1]];x=[A[0],A[1]-Math.abs(g)]}if(t==="sw"){let A=[c[0],d[1]];x=[A[0]-Math.abs(E),A[1]]}o&&(["s","n"].includes(t)&&(x[0]=u[0]-E/2),["e","w"].includes(t)&&(x[1]=u[1]-g/2));let w=e.angle,b=Wt(x,u,w),y=[x[0]+Math.abs(E)/2,x[1]+Math.abs(g)/2],I=Wt(y,u,w);x=Wt(b,I,-w);let S=[...x];return S[0]+=e.x-m,S[1]+=e.y-p,S},va=(e,t)=>{if(e.crop){let{width:n,height:i}=yr(e),[o,r,s,a,l,d]=j(e,t),c=wr(Wt(Pt(o,r),Pt(l,d),e.angle)),u=wr(Wt(Pt(s,r),Pt(l,d),e.angle)),m=Sa(Ma(u,c)),p=wr(Wt(Pt(o,a),Pt(l,d),e.angle)),f=Ma(p,c),h=Sa(f),{cropX:E,cropY:g}=Cu(e.crop,e.scale),x=eo(eo(c,to(m,-E*n/e.crop.naturalWidth)),to(h,-g*i/e.crop.naturalHeight)),w=Aa(eo(eo(x,to(m,n/2)),to(h,i/2))),b=Wt(Aa(x),w,-e.angle);return{...e,x:b[0],y:b[1],width:n,height:i,crop:null}}return e},yr=e=>{if(e.crop){let t=e.width/(e.crop.width/e.crop.naturalWidth),n=e.height/(e.crop.height/e.crop.naturalHeight);return{width:t,height:n}}return{width:e.width,height:e.height}},Cu=(e,t)=>{let n=e.x,i=e.y,o=t[0]===-1,r=t[1]===-1;return o&&(n=e.naturalWidth-Math.abs(n)-e.width),r&&(i=e.naturalHeight-Math.abs(i)-e.height),{cropX:n,cropY:i}},nw=(e,t=!1)=>{let n=e.crop;if(!n)return null;let i=e.scale[0]===-1,o=e.scale[1]===-1,r=n.x,s=n.y;if(i&&(r=n.naturalWidth-n.width-n.x),o&&(s=n.naturalHeight-n.height-n.y),t)return{x:r,y:s};let{width:a,height:l}=yr(e);return{x:r/(n.naturalWidth/a),y:s/(n.naturalHeight/l)}};P();import{pointCenter as Il,pointFrom as C,pointRotateRads as Ae,pointsEqual as Sl,pointDistance as rn,vectorFromPoint as Dp,curveLength as Lp,curvePointAtLength as Bp,lineSegment as Ml}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Cp,KEYS as vn,shouldRotateWithDiscreteAngle as Si,getGridPoint as Al,invariant as Te,isShallowEqual as Gp,getFeatureFlag as Mi}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as Tl,isPathALoop as Op,moveArrowAboveBindable as vl,projectFixedPointOntoDiagonal as Dl}from"@excalidraw/element";P();import{KEYS as cp,arrayToMap as hl,getFeatureFlag as up,invariant as rt,isTransparent as mp}from"@excalidraw/common";import{PRECISION as pp,clamp as Jr,lineSegment as yi,pointDistance as Ot,pointDistanceSq as wi,pointFrom as q,pointFromVector as zn,pointRotateRads as re,pointsEqual as fp,vectorFromPoint as _n,vectorNormalize as To,vectorScale as Hn}from"@excalidraw/math";P();import{invariant as Am,isTransparent as Ka}from"@excalidraw/common";import{curveIntersectLineSegment as Qa,isPointWithinBounds as fo,lineSegment as fi,lineSegmentIntersectionPoints as Ja,pointFrom as me,pointFromVector as Tm,pointRotateRads as Ye,pointsEqual as vm,vectorFromPoint as Dm,vectorNormalize as Lm,vectorScale as Bm}from"@excalidraw/math";import{ellipse as Cm,ellipseSegmentInterceptPoints as Gm}from"@excalidraw/math/ellipse";P();import{DEFAULT_ADAPTIVE_RADIUS as Hu,DEFAULT_PROPORTIONAL_RADIUS as Ir,invariant as _u,LINE_CONFIRM_THRESHOLD as Uu,ROUNDNESS as Sr}from"@excalidraw/common";import{curve as St,curveCatmullRomCubicApproxPoints as Fa,curveOffsetPoints as Na,lineSegment as he,lineSegmentIntersectionPoints as ka,pointDistance as On,pointFrom as H,pointFromArray as Yu,pointFromVector as Wu,pointRotateRads as jt,pointTranslate as Ra,rectangle as Xu,vectorFromPoint as za,vectorNormalize as ju,vectorScale as Mr}from"@excalidraw/math";P();import{ROUNDNESS as ai,assertNever as Gu}from"@excalidraw/common";import{pointsEqual as Da}from"@excalidraw/math";var yn=e=>!!e&&e.type==="image"&&!!e.fileId,xe=e=>!!e&&e.type==="image",La=e=>!!e&&e.type==="embeddable",no=e=>!!e&&e.type==="iframe",io=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),ee=e=>e!=null&&e.type==="text",oo=e=>e!=null&&e.type==="frame",Ba=e=>e!=null&&e.type==="magicframe",K=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Ie=e=>e!=null&&Ou(e.type),Ou=e=>e==="freedraw",Q=e=>e!=null&&Fu(e.type),It=e=>e!=null&&e.type==="line",z=e=>e!=null&&e.type==="arrow",W=e=>z(e)&&e.elbowed,aw=e=>z(e)&&!e.elbowed,ku=e=>z(e)&&!e.elbowed&&!e.roundness,Ru=e=>z(e)&&!e.elbowed&&e.roundness!==null,Fu=e=>e==="arrow"||e==="line",Ce=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&Nu(e.type),Nu=e=>e==="arrow",Ge=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),br=e=>e!=null&&(e.type==="rectangle"||e.type==="diamond"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),li=e=>e!=null&&(e.type==="rectangle"||e.type==="image"||e.type==="text"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="freedraw"),zu=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||z(e)),lw=e=>{let t=e?.type;if(!t)return!1;switch(t){case"text":case"diamond":case"rectangle":case"iframe":case"embeddable":case"ellipse":case"arrow":case"freedraw":case"line":case"frame":case"magicframe":case"image":case"selection":return!0;default:return Gu(t,null),!1}},Pr=e=>e.type==="rectangle"||e.type==="ellipse"||e.type==="diamond",ct=e=>zu(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),ce=e=>e!==null&&"containerId"in e&&e.containerId!==null&&ee(e),dw=e=>!!e.startBinding||!!e.endBinding,Ca=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",Ga=e=>e==="line"||e==="arrow"||e==="diamond",cw=(e,t)=>!!((e===ai.ADAPTIVE_RADIUS||e===ai.LEGACY)&&Ca(t.type)||e===ai.PROPORTIONAL_RADIUS&&Ga(t.type)),uw=e=>Ga(e.type)?{type:ai.PROPORTIONAL_RADIUS}:Ca(e.type)?{type:ai.ADAPTIVE_RADIUS}:null,mw=e=>ku(e)?"sharpArrow":Ru(e)?"curvedArrow":W(e)?"elbowArrow":"line",pw=e=>e.length>3&&Da(e[0],e[e.length-1]),Oa=e=>e.length>3||e.length===3&&!Da(e[0],e[e.length-1]);var di=new WeakMap,Ar=(e,t)=>{let n=di.get(e);if(!n)return;let{version:i,shapes:o}=n;if(i!==e.version){di.delete(e);return}return o.get(t)},Tr=(e,t,n)=>{let i=di.get(e);if(!i){di.set(e,{version:e.version,shapes:new Map([[n,t]])});return}let{version:o,shapes:r}=i;if(o!==e.version){di.set(e,{version:e.version,shapes:new Map([[n,t]])});return}r.set(n,t)};function ro(e){let t=Ar(e,0);if(t)return t;let n=Ha(e),i=[],o=[];for(let s=0;s<n.length;s+=1){let a=n[s],l=n[s-1]&&Yu(n[s-1].data.slice(-2));switch(a.op){case"move":continue;case"lineTo":if(!l)throw new Error("prevPoint is undefined");i.push(he(H(e.x+l[0],e.y+l[1]),H(e.x+a.data[0],e.y+a.data[1])));continue;case"bcurveTo":if(!l)throw new Error("prevPoint is undefined");o.push(St(H(e.x+l[0],e.y+l[1]),H(e.x+a.data[0],e.y+a.data[1]),H(e.x+a.data[2],e.y+a.data[3]),H(e.x+a.data[4],e.y+a.data[5])));continue;default:console.error("Unknown op type",a.op)}}let r=[i,o];return Tr(e,r,0),r}function Vt(e,t=0){let n=Ar(e,t);if(n)return n;let i=Mt(Math.min(e.width,e.height),e);i===0&&(i=.01);let o=Xu(H(e.x,e.y),H(e.x+e.width,e.y+e.height)),r=he(H(o[0][0]+i,o[0][1]),H(o[1][0]-i,o[0][1])),s=he(H(o[1][0],o[0][1]+i),H(o[1][0],o[1][1]-i)),a=he(H(o[0][0]+i,o[1][1]),H(o[1][0]-i,o[1][1])),l=he(H(o[0][0],o[1][1]-i),H(o[0][0],o[0][1]+i)),d=[St(l[1],H(l[1][0]+2/3*(o[0][0]-l[1][0]),l[1][1]+2/3*(o[0][1]-l[1][1])),H(r[0][0]+2/3*(o[0][0]-r[0][0]),r[0][1]+2/3*(o[0][1]-r[0][1])),r[0]),St(r[1],H(r[1][0]+2/3*(o[1][0]-r[1][0]),r[1][1]+2/3*(o[0][1]-r[1][1])),H(s[0][0]+2/3*(o[1][0]-s[0][0]),s[0][1]+2/3*(o[0][1]-s[0][1])),s[0]),St(s[1],H(s[1][0]+2/3*(o[1][0]-s[1][0]),s[1][1]+2/3*(o[1][1]-s[1][1])),H(a[1][0]+2/3*(o[1][0]-a[1][0]),a[1][1]+2/3*(o[1][1]-a[1][1])),a[1]),St(a[0],H(a[0][0]+2/3*(o[0][0]-a[0][0]),a[0][1]+2/3*(o[1][1]-a[0][1])),H(l[0][0]+2/3*(o[0][0]-l[0][0]),l[0][1]+2/3*(o[1][1]-l[0][1])),l[0])],c=t>0?d.map(p=>Fa(Na(p,t))):[[d[0]],[d[1]],[d[2]],[d[3]]],m=[[he(c[0][c[0].length-1][3],c[1][0][0]),he(c[1][c[1].length-1][3],c[2][0][0]),he(c[2][c[2].length-1][3],c[3][0][0]),he(c[3][c[3].length-1][3],c[0][0][0])],c.flat()];return Tr(e,m,t),m}function $t(e,t=0){let n=Ar(e,t);if(n)return n;let[i,o,r,s,a,l,d,c]=kn(e),u=e.roundness?Mt(Math.abs(i-d),e):(i-d)*.01,m=e.roundness?Mt(Math.abs(s-o),e):(s-o)*.01,[p,f,h,E]=[H(e.x+i,e.y+o),H(e.x+r,e.y+s),H(e.x+a,e.y+l),H(e.x+d,e.y+c)],x=[St(H(f[0]-u,f[1]-m),f,f,H(f[0]-u,f[1]+m)),St(H(h[0]+u,h[1]-m),h,h,H(h[0]-u,h[1]-m)),St(H(E[0]+u,E[1]+m),E,E,H(E[0]+u,E[1]-m)),St(H(p[0]-u,p[1]+m),p,p,H(p[0]+u,p[1]+m))].map(y=>Fa(Na(y,t))),b=[[he(x[0][x[0].length-1][3],x[1][0][0]),he(x[1][x[1].length-1][3],x[2][0][0]),he(x[2][x[2].length-1][3],x[3][0][0]),he(x[3][x[3].length-1][3],x[0][0][0])],x.flat()];return Tr(e,b,t),b}var bn=(e,t=1)=>{if(e.length>=3){let[n,i]=[e[0],e[e.length-1]];return On(n,i)<=Uu/t}return!1},Mt=(e,t)=>{if(t.roundness?.type===Sr.PROPORTIONAL_RADIUS||t.roundness?.type===Sr.LEGACY)return e*Ir;if(t.roundness?.type===Sr.ADAPTIVE_RADIUS){let n=t.roundness?.value??Hu,i=n/Ir;return e<=i?e*Ir:n}return 0},Vu=(e,t)=>{let n=e.type==="rectangle"?15:0,i=a=>{let l=ju(za(a[1],a[0])),d=Mr(l,n);return he(Ra(a[0],d),Ra(a[1],Mr(d,-1)))},o=de(e,t),r=i(li(e)?he(jt(H(e.x,e.y),o,e.angle),jt(H(e.x+e.width,e.y+e.height),o,e.angle)):he(jt(H(e.x+e.width/2,e.y),o,e.angle),jt(H(e.x+e.width/2,e.y+e.height),o,e.angle))),s=i(li(e)?he(jt(H(e.x+e.width,e.y),o,e.angle),jt(H(e.x,e.y+e.height),o,e.angle)):he(jt(H(e.x,e.y+e.height/2),o,e.angle),jt(H(e.x+e.width,e.y+e.height/2),o,e.angle)));return[r,s]},vr=(e,t,n,i,o)=>{if(_u(e.points.length>=2,"Arrow must have at least two points"),e.width<3&&e.height<3)return null;let[r,s]=Vu(n,o),a=O.getPointAtIndexGlobalCoordinates(e,i==="start"?1:e.points.length-2,o),l=Wu(Mr(za(t,a),2*On(a,t)+Math.max(On(r[0],r[1]),On(s[0],s[1]))),a),d=he(t,l),c=ka(r,d),u=ka(s,d),m=c&&On(a,c),p=u&&On(a,u),f=null;return m!=null&&p!=null?f=m<p?c:u:f=c||u||null,f&&At(f,n,o)?f:null};P();import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as pm,ARROW_LABEL_WIDTH_FRACTION as fm,BOUND_TEXT_PADDING as ut,DEFAULT_FONT_SIZE as hm,TEXT_ALIGN as Va,VERTICAL_ALIGN as $a,getFontString as mo,isProdEnv as Em,invariant as gm}from"@excalidraw/common";import{pointFrom as Za,pointRotateRads as xm}from"@excalidraw/math";P();var ci={},_a=(e,t)=>{let n=ci[e]||(ci[e]={height:t});return n.height=t,n},Ua=e=>{ci[e]&&delete ci[e]},Mw=e=>ci[e]?.height??null;P();import{BOUND_TEXT_PADDING as ao,DEFAULT_FONT_SIZE as $u,DEFAULT_FONT_FAMILY as Zu,getFontString as qu,isTestEnv as Ku,normalizeEOL as Qu}from"@excalidraw/common";var Ue=(e,t,n)=>{let i=e.split(`
1
+ var hp=Object.create;var Ba=Object.defineProperty;var mp=Object.getOwnPropertyDescriptor;var fp=Object.getOwnPropertyNames;var gp=Object.getPrototypeOf,Ep=Object.prototype.hasOwnProperty;var xp=(e,t)=>()=>(e&&(t=e(e=0)),t);var Eo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var yp=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of fp(t))!Ep.call(e,i)&&i!==n&&Ba(e,i,{get:()=>t[i],enumerable:!(o=mp(t,i))||o.enumerable});return e};var ri=(e,t,n)=>(n=e!=null?hp(gp(e)):{},yp(t||!e||!e.__esModule?Ba(n,"default",{value:e,enumerable:!0}):n,e));var L,I=xp(()=>{L={PROD:!0}});var Rc=Eo((C6,Oc)=>{I();var Gc="Expected a function",Bc=NaN,U0="[object Symbol]",Y0=/^\s+|\s+$/g,X0=/^[-+]0x[0-9a-f]+$/i,$0=/^0b[01]+$/i,Z0=/^0o[0-7]+$/i,q0=parseInt,K0=typeof global=="object"&&global&&global.Object===Object&&global,Q0=typeof self=="object"&&self&&self.Object===Object&&self,J0=K0||Q0||Function("return this")(),ef=Object.prototype,tf=ef.toString,nf=Math.max,of=Math.min,na=function(){return J0.Date.now()};function rf(e,t,n){var o,i,r,s,a,l,d=0,c=!1,p=!1,h=!0;if(typeof e!="function")throw new TypeError(Gc);t=Dc(t)||0,mr(n)&&(c=!!n.leading,p="maxWait"in n,r=p?nf(Dc(n.maxWait)||0,t):r,h="trailing"in n?!!n.trailing:h);function m(S){var A=o,C=i;return o=i=void 0,d=S,s=e.apply(C,A),s}function f(S){return d=S,a=setTimeout(x,t),c?m(S):s}function g(S){var A=S-l,C=S-d,T=t-A;return p?of(T,r-C):T}function E(S){var A=S-l,C=S-d;return l===void 0||A>=t||A<0||p&&C>=r}function x(){var S=na();if(E(S))return y(S);a=setTimeout(x,g(S))}function y(S){return a=void 0,h&&o?m(S):(o=i=void 0,s)}function w(){a!==void 0&&clearTimeout(a),d=0,o=l=i=a=void 0}function M(){return a===void 0?s:y(na())}function b(){var S=na(),A=E(S);if(o=arguments,i=this,l=S,A){if(a===void 0)return f(l);if(p)return a=setTimeout(x,t),m(l)}return a===void 0&&(a=setTimeout(x,t)),s}return b.cancel=w,b.flush=M,b}function sf(e,t,n){var o=!0,i=!0;if(typeof e!="function")throw new TypeError(Gc);return mr(n)&&(o="leading"in n?!!n.leading:o,i="trailing"in n?!!n.trailing:i),rf(e,t,{leading:o,maxWait:t,trailing:i})}function mr(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function af(e){return!!e&&typeof e=="object"}function lf(e){return typeof e=="symbol"||af(e)&&tf.call(e)==U0}function Dc(e){if(typeof e=="number")return e;if(lf(e))return Bc;if(mr(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=mr(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(Y0,"");var n=$0.test(e);return n||Z0.test(e)?q0(e.slice(2),n?2:8):X0.test(e)?Bc:+e}Oc.exports=sf});var Yu=Eo(Q=>{"use strict";I();var Pa=Symbol.for("react.transitional.element"),Ig=Symbol.for("react.portal"),Sg=Symbol.for("react.fragment"),vg=Symbol.for("react.strict_mode"),Ag=Symbol.for("react.profiler"),kg=Symbol.for("react.consumer"),Tg=Symbol.for("react.context"),Lg=Symbol.for("react.forward_ref"),Cg=Symbol.for("react.suspense"),Bg=Symbol.for("react.memo"),zu=Symbol.for("react.lazy"),Ou=Symbol.iterator;function Dg(e){return e===null||typeof e!="object"?null:(e=Ou&&e[Ou]||e["@@iterator"],typeof e=="function"?e:null)}var _u={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Wu=Object.assign,ju={};function fo(e,t,n){this.props=e,this.context=t,this.refs=ju,this.updater=n||_u}fo.prototype.isReactComponent={};fo.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};fo.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Vu(){}Vu.prototype=fo.prototype;function Ia(e,t,n){this.props=e,this.context=t,this.refs=ju,this.updater=n||_u}var Sa=Ia.prototype=new Vu;Sa.constructor=Ia;Wu(Sa,fo.prototype);Sa.isPureReactComponent=!0;var Ru=Array.isArray,me={H:null,A:null,T:null,S:null},Uu=Object.prototype.hasOwnProperty;function va(e,t,n,o,i,r){return n=r.ref,{$$typeof:Pa,type:e,key:t,ref:n!==void 0?n:null,props:r}}function Gg(e,t){return va(e.type,t,void 0,void 0,void 0,e.props)}function Aa(e){return typeof e=="object"&&e!==null&&e.$$typeof===Pa}function Og(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Fu=/\/+/g;function Ma(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Og(""+e.key):t.toString(36)}function Nu(){}function Rg(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(Nu,Nu):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function mo(e,t,n,o,i){var r=typeof e;(r==="undefined"||r==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(r){case"bigint":case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case Pa:case Ig:s=!0;break;case zu:return s=e._init,mo(s(e._payload),t,n,o,i)}}if(s)return i=i(e),s=o===""?"."+Ma(e,0):o,Ru(i)?(n="",s!=null&&(n=s.replace(Fu,"$&/")+"/"),mo(i,t,n,"",function(d){return d})):i!=null&&(Aa(i)&&(i=Gg(i,n+(i.key==null||e&&e.key===i.key?"":(""+i.key).replace(Fu,"$&/")+"/")+s)),t.push(i)),1;s=0;var a=o===""?".":o+":";if(Ru(e))for(var l=0;l<e.length;l++)o=e[l],r=a+Ma(o,l),s+=mo(o,t,n,r,i);else if(l=Dg(e),typeof l=="function")for(e=l.call(e),l=0;!(o=e.next()).done;)o=o.value,r=a+Ma(o,l++),s+=mo(o,t,n,r,i);else if(r==="object"){if(typeof e.then=="function")return mo(Rg(e),t,n,o,i);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return s}function vr(e,t,n){if(e==null)return e;var o=[],i=0;return mo(e,o,"","",function(r){return t.call(n,r,i++)}),o}function Fg(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Hu=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)};function Ng(){}Q.Children={map:vr,forEach:function(e,t,n){vr(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return vr(e,function(){t++}),t},toArray:function(e){return vr(e,function(t){return t})||[]},only:function(e){if(!Aa(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Q.Component=fo;Q.Fragment=Sg;Q.Profiler=Ag;Q.PureComponent=Ia;Q.StrictMode=vg;Q.Suspense=Cg;Q.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=me;Q.act=function(){throw Error("act(...) is not supported in production builds of React.")};Q.cache=function(e){return function(){return e.apply(null,arguments)}};Q.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=Wu({},e.props),i=e.key,r=void 0;if(t!=null)for(s in t.ref!==void 0&&(r=void 0),t.key!==void 0&&(i=""+t.key),t)!Uu.call(t,s)||s==="key"||s==="__self"||s==="__source"||s==="ref"&&t.ref===void 0||(o[s]=t[s]);var s=arguments.length-2;if(s===1)o.children=n;else if(1<s){for(var a=Array(s),l=0;l<s;l++)a[l]=arguments[l+2];o.children=a}return va(e.type,i,void 0,void 0,r,o)};Q.createContext=function(e){return e={$$typeof:Tg,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:kg,_context:e},e};Q.createElement=function(e,t,n){var o,i={},r=null;if(t!=null)for(o in t.key!==void 0&&(r=""+t.key),t)Uu.call(t,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(i[o]=t[o]);var s=arguments.length-2;if(s===1)i.children=n;else if(1<s){for(var a=Array(s),l=0;l<s;l++)a[l]=arguments[l+2];i.children=a}if(e&&e.defaultProps)for(o in s=e.defaultProps,s)i[o]===void 0&&(i[o]=s[o]);return va(e,r,void 0,void 0,null,i)};Q.createRef=function(){return{current:null}};Q.forwardRef=function(e){return{$$typeof:Lg,render:e}};Q.isValidElement=Aa;Q.lazy=function(e){return{$$typeof:zu,_payload:{_status:-1,_result:e},_init:Fg}};Q.memo=function(e,t){return{$$typeof:Bg,type:e,compare:t===void 0?null:t}};Q.startTransition=function(e){var t=me.T,n={};me.T=n;try{var o=e(),i=me.S;i!==null&&i(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(Ng,Hu)}catch(r){Hu(r)}finally{me.T=t}};Q.unstable_useCacheRefresh=function(){return me.H.useCacheRefresh()};Q.use=function(e){return me.H.use(e)};Q.useActionState=function(e,t,n){return me.H.useActionState(e,t,n)};Q.useCallback=function(e,t){return me.H.useCallback(e,t)};Q.useContext=function(e){return me.H.useContext(e)};Q.useDebugValue=function(){};Q.useDeferredValue=function(e,t){return me.H.useDeferredValue(e,t)};Q.useEffect=function(e,t){return me.H.useEffect(e,t)};Q.useId=function(){return me.H.useId()};Q.useImperativeHandle=function(e,t,n){return me.H.useImperativeHandle(e,t,n)};Q.useInsertionEffect=function(e,t){return me.H.useInsertionEffect(e,t)};Q.useLayoutEffect=function(e,t){return me.H.useLayoutEffect(e,t)};Q.useMemo=function(e,t){return me.H.useMemo(e,t)};Q.useOptimistic=function(e,t){return me.H.useOptimistic(e,t)};Q.useReducer=function(e,t,n){return me.H.useReducer(e,t,n)};Q.useRef=function(e){return me.H.useRef(e)};Q.useState=function(e){return me.H.useState(e)};Q.useSyncExternalStore=function(e,t,n){return me.H.useSyncExternalStore(e,t,n)};Q.useTransition=function(){return me.H.useTransition()};Q.version="19.0.0"});var $u=Eo((FM,Xu)=>{"use strict";I();Xu.exports=Yu()});var qu=Eo(Ar=>{"use strict";I();var Hg=Symbol.for("react.transitional.element"),zg=Symbol.for("react.fragment");function Zu(e,t,n){var o=null;if(n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),"key"in t){n={};for(var i in t)i!=="key"&&(n[i]=t[i])}else n=t;return t=n.ref,{$$typeof:Hg,type:e,key:o,ref:t!==void 0?t:null,props:n}}Ar.Fragment=zg;Ar.jsx=Zu;Ar.jsxs=Zu});var ka=Eo((_M,Ku)=>{"use strict";I();Ku.exports=qu()});I();import{toIterable as nE}from"@excalidraw/common";I();import{SHIFT_LOCKING_ANGLE as nn,viewportCoordsToSceneCoords as dr}from"@excalidraw/common";import{normalizeRadians as pc,radiansBetweenAngles as w0,radiansDifference as b0}from"@excalidraw/math";import{pointsEqual as M0}from"@excalidraw/math";I();I();I();I();I();I();I();I();I();function Br(e,t,n){if(e&&e.length){let[o,i]=t,r=Math.PI/180*n,s=Math.cos(r),a=Math.sin(r);for(let l of e){let[d,c]=l;l[0]=(d-o)*s-(c-i)*a+o,l[1]=(d-o)*a+(c-i)*s+i}}}function bp(e,t,n){let o=[];e.forEach(i=>o.push(...i)),Br(o,t,n)}function Mp(e,t){return e[0]===t[0]&&e[1]===t[1]}function Da(e,t,n,o=1){let i=n,r=Math.max(t,.1),s=e[0]&&e[0][0]&&typeof e[0][0]=="number"?[e]:e,a=[0,0];if(i)for(let d of s)Br(d,a,i);let l=Pp(s,r,o);if(i){for(let d of s)Br(d,a,-i);bp(l,a,-i)}return l}function Pp(e,t,n){let o=[];for(let d of e){let c=[...d];Mp(c[0],c[c.length-1])||c.push([c[0][0],c[0][1]]),c.length>2&&o.push(c)}let i=[];t=Math.max(t,.1);let r=[];for(let d of o)for(let c=0;c<d.length-1;c++){let p=d[c],h=d[c+1];if(p[1]!==h[1]){let m=Math.min(p[1],h[1]);r.push({ymin:m,ymax:Math.max(p[1],h[1]),x:m===p[1]?p[0]:h[0],islope:(h[0]-p[0])/(h[1]-p[1])})}}if(r.sort((d,c)=>d.ymin<c.ymin?-1:d.ymin>c.ymin?1:d.x<c.x?-1:d.x>c.x?1:d.ymax===c.ymax?0:(d.ymax-c.ymax)/Math.abs(d.ymax-c.ymax)),!r.length)return i;let s=[],a=r[0].ymin,l=0;for(;s.length||r.length;){if(r.length){let d=-1;for(let p=0;p<r.length&&!(r[p].ymin>a);p++)d=p;r.splice(0,d+1).forEach(p=>{s.push({s:a,edge:p})})}if(s=s.filter(d=>!(d.edge.ymax<=a)),s.sort((d,c)=>d.edge.x===c.edge.x?0:(d.edge.x-c.edge.x)/Math.abs(d.edge.x-c.edge.x)),(n!==1||l%t===0)&&s.length>1)for(let d=0;d<s.length;d=d+2){let c=d+1;if(c>=s.length)break;let p=s[d].edge,h=s[c].edge;i.push([[Math.round(p.x),a],[Math.round(h.x),a]])}a+=n,s.forEach(d=>{d.edge.x=d.edge.x+n*d.edge.islope}),l++}return i}function At(e,t){var n;let o=t.hachureAngle+90,i=t.hachureGap;i<0&&(i=t.strokeWidth*4),i=Math.max(i,.1);let r=1;return t.roughness>=1&&(((n=t.randomizer)===null||n===void 0?void 0:n.next())||Math.random())>.7&&(r=i),Da(e,i,o,r||1)}var an=class{constructor(t){this.helper=t}fillPolygons(t,n){return this._fillPolygons(t,n)}_fillPolygons(t,n){let o=At(t,n);return{type:"fillSketch",ops:this.renderLines(o,n)}}renderLines(t,n){let o=[];for(let i of t)o.push(...this.helper.doubleLineOps(i[0][0],i[0][1],i[1][0],i[1][1],n));return o}};I();I();function ln(e){let t=e[0],n=e[1];return Math.sqrt(Math.pow(t[0]-n[0],2)+Math.pow(t[1]-n[1],2))}var si=class extends an{fillPolygons(t,n){let o=n.hachureGap;o<0&&(o=n.strokeWidth*4),o=Math.max(o,.1);let i=Object.assign({},n,{hachureGap:o}),r=At(t,i),s=Math.PI/180*n.hachureAngle,a=[],l=o*.5*Math.cos(s),d=o*.5*Math.sin(s);for(let[p,h]of r)ln([p,h])&&a.push([[p[0]-l,p[1]+d],[...h]],[[p[0]+l,p[1]-d],[...h]]);return{type:"fillSketch",ops:this.renderLines(a,n)}}};I();var ai=class extends an{fillPolygons(t,n){let o=this._fillPolygons(t,n),i=Object.assign({},n,{hachureAngle:n.hachureAngle+90}),r=this._fillPolygons(t,i);return o.ops=o.ops.concat(r.ops),o}};I();var li=class{constructor(t){this.helper=t}fillPolygons(t,n){n=Object.assign({},n,{hachureAngle:0});let o=At(t,n);return this.dotsOnLines(o,n)}dotsOnLines(t,n){let o=[],i=n.hachureGap;i<0&&(i=n.strokeWidth*4),i=Math.max(i,.1);let r=n.fillWeight;r<0&&(r=n.strokeWidth/2);let s=i/4;for(let a of t){let l=ln(a),d=l/i,c=Math.ceil(d)-1,p=l-c*i,h=(a[0][0]+a[1][0])/2-i/4,m=Math.min(a[0][1],a[1][1]);for(let f=0;f<c;f++){let g=m+p+f*i,E=h-s+Math.random()*2*s,x=g-s+Math.random()*2*s,y=this.helper.ellipse(E,x,r,r,n);o.push(...y.ops)}}return{type:"fillSketch",ops:o}}};I();var di=class{constructor(t){this.helper=t}fillPolygons(t,n){let o=At(t,n);return{type:"fillSketch",ops:this.dashedLine(o,n)}}dashedLine(t,n){let o=n.dashOffset<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashOffset,i=n.dashGap<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashGap,r=[];return t.forEach(s=>{let a=ln(s),l=Math.floor(a/(o+i)),d=(a+i-l*(o+i))/2,c=s[0],p=s[1];c[0]>p[0]&&(c=s[1],p=s[0]);let h=Math.atan((p[1]-c[1])/(p[0]-c[0]));for(let m=0;m<l;m++){let f=m*(o+i),g=f+o,E=[c[0]+f*Math.cos(h)+d*Math.cos(h),c[1]+f*Math.sin(h)+d*Math.sin(h)],x=[c[0]+g*Math.cos(h)+d*Math.cos(h),c[1]+g*Math.sin(h)+d*Math.sin(h)];r.push(...this.helper.doubleLineOps(E[0],E[1],x[0],x[1],n))}}),r}};I();var ci=class{constructor(t){this.helper=t}fillPolygons(t,n){let o=n.hachureGap<0?n.strokeWidth*4:n.hachureGap,i=n.zigzagOffset<0?o:n.zigzagOffset;n=Object.assign({},n,{hachureGap:o+i});let r=At(t,n);return{type:"fillSketch",ops:this.zigzagLines(r,i,n)}}zigzagLines(t,n,o){let i=[];return t.forEach(r=>{let s=ln(r),a=Math.round(s/(2*n)),l=r[0],d=r[1];l[0]>d[0]&&(l=r[1],d=r[0]);let c=Math.atan((d[1]-l[1])/(d[0]-l[0]));for(let p=0;p<a;p++){let h=p*2*n,m=(p+1)*2*n,f=Math.sqrt(2*Math.pow(n,2)),g=[l[0]+h*Math.cos(c),l[1]+h*Math.sin(c)],E=[l[0]+m*Math.cos(c),l[1]+m*Math.sin(c)],x=[g[0]+f*Math.cos(c+Math.PI/4),g[1]+f*Math.sin(c+Math.PI/4)];i.push(...this.helper.doubleLineOps(g[0],g[1],x[0],x[1],o),...this.helper.doubleLineOps(x[0],x[1],E[0],E[1],o))}}),i}};var Ue={};function Ga(e,t){let n=e.fillStyle||"hachure";if(!Ue[n])switch(n){case"zigzag":Ue[n]||(Ue[n]=new si(t));break;case"cross-hatch":Ue[n]||(Ue[n]=new ai(t));break;case"dots":Ue[n]||(Ue[n]=new li(t));break;case"dashed":Ue[n]||(Ue[n]=new di(t));break;case"zigzag-line":Ue[n]||(Ue[n]=new ci(t));break;case"hachure":default:n="hachure",Ue[n]||(Ue[n]=new an(t));break}return Ue[n]}I();function Oa(){return Math.floor(Math.random()*2**31)}var ui=class{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}};I();I();var pi={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function Ip(e){let t=new Array;for(;e!=="";)if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([aAcChHlLmMqQsStTvVzZ])/))t[t.length]={type:0,text:RegExp.$1},e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))t[t.length]={type:1,text:`${parseFloat(RegExp.$1)}`},e=e.substr(RegExp.$1.length);else return[];return t[t.length]={type:2,text:""},t}function Dr(e,t){return e.type===t}function qn(e){let t=[],n=Ip(e),o="BOD",i=0,r=n[i];for(;!Dr(r,2);){let s=0,a=[];if(o==="BOD")if(r.text==="M"||r.text==="m")i++,s=pi[r.text],o=r.text;else return qn("M0,0"+e);else Dr(r,1)?s=pi[o]:(i++,s=pi[r.text],o=r.text);if(i+s<n.length){for(let l=i;l<i+s;l++){let d=n[l];if(Dr(d,1))a[a.length]=+d.text;else throw new Error("Param not a number: "+o+","+d.text)}if(typeof pi[o]=="number"){let l={key:o,data:a};t.push(l),i+=s,r=n[i],o==="M"&&(o="L"),o==="m"&&(o="l")}else throw new Error("Bad segment: "+o)}else throw new Error("Path data ended short")}return t}I();function xo(e){let t=0,n=0,o=0,i=0,r=[];for(let{key:s,data:a}of e)switch(s){case"M":r.push({key:"M",data:[...a]}),[t,n]=a,[o,i]=a;break;case"m":t+=a[0],n+=a[1],r.push({key:"M",data:[t,n]}),o=t,i=n;break;case"L":r.push({key:"L",data:[...a]}),[t,n]=a;break;case"l":t+=a[0],n+=a[1],r.push({key:"L",data:[t,n]});break;case"C":r.push({key:"C",data:[...a]}),t=a[4],n=a[5];break;case"c":{let l=a.map((d,c)=>c%2?d+n:d+t);r.push({key:"C",data:l}),t=l[4],n=l[5];break}case"Q":r.push({key:"Q",data:[...a]}),t=a[2],n=a[3];break;case"q":{let l=a.map((d,c)=>c%2?d+n:d+t);r.push({key:"Q",data:l}),t=l[2],n=l[3];break}case"A":r.push({key:"A",data:[...a]}),t=a[5],n=a[6];break;case"a":t+=a[5],n+=a[6],r.push({key:"A",data:[a[0],a[1],a[2],a[3],a[4],t,n]});break;case"H":r.push({key:"H",data:[...a]}),t=a[0];break;case"h":t+=a[0],r.push({key:"H",data:[t]});break;case"V":r.push({key:"V",data:[...a]}),n=a[0];break;case"v":n+=a[0],r.push({key:"V",data:[n]});break;case"S":r.push({key:"S",data:[...a]}),t=a[2],n=a[3];break;case"s":{let l=a.map((d,c)=>c%2?d+n:d+t);r.push({key:"S",data:l}),t=l[2],n=l[3];break}case"T":r.push({key:"T",data:[...a]}),t=a[0],n=a[1];break;case"t":t+=a[0],n+=a[1],r.push({key:"T",data:[t,n]});break;case"Z":case"z":r.push({key:"Z",data:[]}),t=o,n=i;break}return r}I();function wo(e){let t=[],n="",o=0,i=0,r=0,s=0,a=0,l=0;for(let{key:d,data:c}of e){switch(d){case"M":t.push({key:"M",data:[...c]}),[o,i]=c,[r,s]=c;break;case"C":t.push({key:"C",data:[...c]}),o=c[4],i=c[5],a=c[2],l=c[3];break;case"L":t.push({key:"L",data:[...c]}),[o,i]=c;break;case"H":o=c[0],t.push({key:"L",data:[o,i]});break;case"V":i=c[0],t.push({key:"L",data:[o,i]});break;case"S":{let p=0,h=0;n==="C"||n==="S"?(p=o+(o-a),h=i+(i-l)):(p=o,h=i),t.push({key:"C",data:[p,h,...c]}),a=c[0],l=c[1],o=c[2],i=c[3];break}case"T":{let[p,h]=c,m=0,f=0;n==="Q"||n==="T"?(m=o+(o-a),f=i+(i-l)):(m=o,f=i);let g=o+2*(m-o)/3,E=i+2*(f-i)/3,x=p+2*(m-p)/3,y=h+2*(f-h)/3;t.push({key:"C",data:[g,E,x,y,p,h]}),a=m,l=f,o=p,i=h;break}case"Q":{let[p,h,m,f]=c,g=o+2*(p-o)/3,E=i+2*(h-i)/3,x=m+2*(p-m)/3,y=f+2*(h-f)/3;t.push({key:"C",data:[g,E,x,y,m,f]}),a=p,l=h,o=m,i=f;break}case"A":{let p=Math.abs(c[0]),h=Math.abs(c[1]),m=c[2],f=c[3],g=c[4],E=c[5],x=c[6];p===0||h===0?(t.push({key:"C",data:[o,i,E,x,E,x]}),o=E,i=x):(o!==E||i!==x)&&(Ra(o,i,E,x,p,h,m,f,g).forEach(function(w){t.push({key:"C",data:w})}),o=E,i=x);break}case"Z":t.push({key:"Z",data:[]}),o=r,i=s;break}n=d}return t}function Sp(e){return Math.PI*e/180}function yo(e,t,n){let o=e*Math.cos(n)-t*Math.sin(n),i=e*Math.sin(n)+t*Math.cos(n);return[o,i]}function Ra(e,t,n,o,i,r,s,a,l,d){let c=Sp(s),p=[],h=0,m=0,f=0,g=0;if(d)[h,m,f,g]=d;else{[e,t]=yo(e,t,-c),[n,o]=yo(n,o,-c);let N=(e-n)/2,D=(t-o)/2,q=N*N/(i*i)+D*D/(r*r);q>1&&(q=Math.sqrt(q),i=q*i,r=q*r);let U=a===l?-1:1,le=i*i,H=r*r,v=le*H-le*D*D-H*N*N,W=le*D*D+H*N*N,X=U*Math.sqrt(Math.abs(v/W));f=X*i*D/r+(e+n)/2,g=X*-r*N/i+(t+o)/2,h=Math.asin(parseFloat(((t-g)/r).toFixed(9))),m=Math.asin(parseFloat(((o-g)/r).toFixed(9))),e<f&&(h=Math.PI-h),n<f&&(m=Math.PI-m),h<0&&(h=Math.PI*2+h),m<0&&(m=Math.PI*2+m),l&&h>m&&(h=h-Math.PI*2),!l&&m>h&&(m=m-Math.PI*2)}let E=m-h;if(Math.abs(E)>Math.PI*120/180){let N=m,D=n,q=o;l&&m>h?m=h+Math.PI*120/180*1:m=h+Math.PI*120/180*-1,n=f+i*Math.cos(m),o=g+r*Math.sin(m),p=Ra(n,o,D,q,i,r,s,0,l,[m,N,f,g])}E=m-h;let x=Math.cos(h),y=Math.sin(h),w=Math.cos(m),M=Math.sin(m),b=Math.tan(E/4),S=4/3*i*b,A=4/3*r*b,C=[e,t],T=[e+S*y,t-A*x],F=[n+S*M,o-A*w],O=[n,o];if(T[0]=2*C[0]-T[0],T[1]=2*C[1]-T[1],d)return[T,F,O].concat(p);{p=[T,F,O].concat(p);let N=[];for(let D=0;D<p.length;D+=3){let q=yo(p[D][0],p[D][1],c),U=yo(p[D+1][0],p[D+1][1],c),le=yo(p[D+2][0],p[D+2][1],c);N.push([q[0],q[1],U[0],U[1],le[0],le[1]])}return N}}var vp={randOffset:Tp,randOffsetWithRange:Lp,ellipse:kp,doubleLineOps:Cp};function Gr(e,t,n,o,i){return{type:"path",ops:Nt(e,t,n,o,i)}}function bo(e,t,n){let o=(e||[]).length;if(o>2){let i=[];for(let r=0;r<o-1;r++)i.push(...Nt(e[r][0],e[r][1],e[r+1][0],e[r+1][1],n));return t&&i.push(...Nt(e[o-1][0],e[o-1][1],e[0][0],e[0][1],n)),{type:"path",ops:i}}else if(o===2)return Gr(e[0][0],e[0][1],e[1][0],e[1][1],n);return{type:"path",ops:[]}}function Ap(e,t){return bo(e,!0,t)}function _a(e,t,n,o,i){let r=[[e,t],[e+n,t],[e+n,t+o],[e,t+o]];return Ap(r,i)}function Or(e,t){let n=Na(e,1*(1+t.roughness*.2),t);if(!t.disableMultiStroke){let o=Na(e,1.5*(1+t.roughness*.22),Bp(t));n=n.concat(o)}return{type:"path",ops:n}}function kp(e,t,n,o,i){let r=Rr(n,o,i);return fi(e,t,i,r).opset}function Rr(e,t,n){let o=Math.sqrt(Math.PI*2*Math.sqrt((Math.pow(e/2,2)+Math.pow(t/2,2))/2)),i=Math.ceil(Math.max(n.curveStepCount,n.curveStepCount/Math.sqrt(200)*o)),r=Math.PI*2/i,s=Math.abs(e/2),a=Math.abs(t/2),l=1-n.curveFitting;return s+=z(s*l,n),a+=z(a*l,n),{increment:r,rx:s,ry:a}}function fi(e,t,n,o){let[i,r]=Ha(o.increment,e,t,o.rx,o.ry,1,o.increment*hi(.1,hi(.4,1,n),n),n),s=mi(i,null,n);if(!n.disableMultiStroke&&n.roughness!==0){let[a]=Ha(o.increment,e,t,o.rx,o.ry,1.5,0,n),l=mi(a,null,n);s=s.concat(l)}return{estimatedPoints:r,opset:{type:"path",ops:s}}}function Fr(e,t,n,o,i,r,s,a,l){let d=e,c=t,p=Math.abs(n/2),h=Math.abs(o/2);p+=z(p*.01,l),h+=z(h*.01,l);let m=i,f=r;for(;m<0;)m+=Math.PI*2,f+=Math.PI*2;f-m>Math.PI*2&&(m=0,f=Math.PI*2);let g=Math.PI*2/l.curveStepCount,E=Math.min(g/2,(f-m)/2),x=za(E,d,c,p,h,m,f,1,l);if(!l.disableMultiStroke){let y=za(E,d,c,p,h,m,f,1.5,l);x.push(...y)}return s&&(a?x.push(...Nt(d,c,d+p*Math.cos(m),c+h*Math.sin(m),l),...Nt(d,c,d+p*Math.cos(f),c+h*Math.sin(f),l)):x.push({op:"lineTo",data:[d,c]},{op:"lineTo",data:[d+p*Math.cos(m),c+h*Math.sin(m)]})),{type:"path",ops:x}}function Nr(e,t){let n=wo(xo(qn(e))),o=[],i=[0,0],r=[0,0];for(let{key:s,data:a}of n)switch(s){case"M":{r=[a[0],a[1]],i=[a[0],a[1]];break}case"L":o.push(...Nt(r[0],r[1],a[0],a[1],t)),r=[a[0],a[1]];break;case"C":{let[l,d,c,p,h,m]=a;o.push(...Dp(l,d,c,p,h,m,r,t)),r=[h,m];break}case"Z":o.push(...Nt(r[0],r[1],i[0],i[1],t)),r=[i[0],i[1]];break}return{type:"path",ops:o}}function gi(e,t){let n=[];for(let o of e)if(o.length){let i=t.maxRandomnessOffset||0,r=o.length;if(r>2){n.push({op:"move",data:[o[0][0]+z(i,t),o[0][1]+z(i,t)]});for(let s=1;s<r;s++)n.push({op:"lineTo",data:[o[s][0]+z(i,t),o[s][1]+z(i,t)]})}}return{type:"fillPath",ops:n}}function On(e,t){return Ga(t,vp).fillPolygons(e,t)}function Wa(e,t,n,o,i,r,s){let a=e,l=t,d=Math.abs(n/2),c=Math.abs(o/2);d+=z(d*.01,s),c+=z(c*.01,s);let p=i,h=r;for(;p<0;)p+=Math.PI*2,h+=Math.PI*2;h-p>Math.PI*2&&(p=0,h=Math.PI*2);let m=(h-p)/s.curveStepCount,f=[];for(let g=p;g<=h;g=g+m)f.push([a+d*Math.cos(g),l+c*Math.sin(g)]);return f.push([a+d*Math.cos(h),l+c*Math.sin(h)]),f.push([a,l]),On([f],s)}function Tp(e,t){return z(e,t)}function Lp(e,t,n){return hi(e,t,n)}function Cp(e,t,n,o,i){return Nt(e,t,n,o,i,!0)}function Bp(e){let t=Object.assign({},e);return t.randomizer=void 0,e.seed&&(t.seed=e.seed+1),t}function ja(e){return e.randomizer||(e.randomizer=new ui(e.seed||0)),e.randomizer.next()}function hi(e,t,n,o=1){return n.roughness*o*(ja(n)*(t-e)+e)}function z(e,t,n=1){return hi(-e,e,t,n)}function Nt(e,t,n,o,i,r=!1){let s=r?i.disableMultiStrokeFill:i.disableMultiStroke,a=Fa(e,t,n,o,i,!0,!1);if(s)return a;let l=Fa(e,t,n,o,i,!0,!0);return a.concat(l)}function Fa(e,t,n,o,i,r,s){let a=Math.pow(e-n,2)+Math.pow(t-o,2),l=Math.sqrt(a),d=1;l<200?d=1:l>500?d=.4:d=-.0016668*l+1.233334;let c=i.maxRandomnessOffset||0;c*c*100>a&&(c=l/10);let p=c/2,h=.2+ja(i)*.2,m=i.bowing*i.maxRandomnessOffset*(o-t)/200,f=i.bowing*i.maxRandomnessOffset*(e-n)/200;m=z(m,i,d),f=z(f,i,d);let g=[],E=()=>z(p,i,d),x=()=>z(c,i,d),y=i.preserveVertices;return r&&(s?g.push({op:"move",data:[e+(y?0:E()),t+(y?0:E())]}):g.push({op:"move",data:[e+(y?0:z(c,i,d)),t+(y?0:z(c,i,d))]})),s?g.push({op:"bcurveTo",data:[m+e+(n-e)*h+E(),f+t+(o-t)*h+E(),m+e+2*(n-e)*h+E(),f+t+2*(o-t)*h+E(),n+(y?0:E()),o+(y?0:E())]}):g.push({op:"bcurveTo",data:[m+e+(n-e)*h+x(),f+t+(o-t)*h+x(),m+e+2*(n-e)*h+x(),f+t+2*(o-t)*h+x(),n+(y?0:x()),o+(y?0:x())]}),g}function Na(e,t,n){let o=[];o.push([e[0][0]+z(t,n),e[0][1]+z(t,n)]),o.push([e[0][0]+z(t,n),e[0][1]+z(t,n)]);for(let i=1;i<e.length;i++)o.push([e[i][0]+z(t,n),e[i][1]+z(t,n)]),i===e.length-1&&o.push([e[i][0]+z(t,n),e[i][1]+z(t,n)]);return mi(o,null,n)}function mi(e,t,n){let o=e.length,i=[];if(o>3){let r=[],s=1-n.curveTightness;i.push({op:"move",data:[e[1][0],e[1][1]]});for(let a=1;a+2<o;a++){let l=e[a];r[0]=[l[0],l[1]],r[1]=[l[0]+(s*e[a+1][0]-s*e[a-1][0])/6,l[1]+(s*e[a+1][1]-s*e[a-1][1])/6],r[2]=[e[a+1][0]+(s*e[a][0]-s*e[a+2][0])/6,e[a+1][1]+(s*e[a][1]-s*e[a+2][1])/6],r[3]=[e[a+1][0],e[a+1][1]],i.push({op:"bcurveTo",data:[r[1][0],r[1][1],r[2][0],r[2][1],r[3][0],r[3][1]]})}if(t&&t.length===2){let a=n.maxRandomnessOffset;i.push({op:"lineTo",data:[t[0]+z(a,n),t[1]+z(a,n)]})}}else o===3?(i.push({op:"move",data:[e[1][0],e[1][1]]}),i.push({op:"bcurveTo",data:[e[1][0],e[1][1],e[2][0],e[2][1],e[2][0],e[2][1]]})):o===2&&i.push(...Nt(e[0][0],e[0][1],e[1][0],e[1][1],n));return i}function Ha(e,t,n,o,i,r,s,a){let l=a.roughness===0,d=[],c=[];if(l){e=e/4,c.push([t+o*Math.cos(-e),n+i*Math.sin(-e)]);for(let p=0;p<=Math.PI*2;p=p+e){let h=[t+o*Math.cos(p),n+i*Math.sin(p)];d.push(h),c.push(h)}c.push([t+o*Math.cos(0),n+i*Math.sin(0)]),c.push([t+o*Math.cos(e),n+i*Math.sin(e)])}else{let p=z(.5,a)-Math.PI/2;c.push([z(r,a)+t+.9*o*Math.cos(p-e),z(r,a)+n+.9*i*Math.sin(p-e)]);let h=Math.PI*2+p-.01;for(let m=p;m<h;m=m+e){let f=[z(r,a)+t+o*Math.cos(m),z(r,a)+n+i*Math.sin(m)];d.push(f),c.push(f)}c.push([z(r,a)+t+o*Math.cos(p+Math.PI*2+s*.5),z(r,a)+n+i*Math.sin(p+Math.PI*2+s*.5)]),c.push([z(r,a)+t+.98*o*Math.cos(p+s),z(r,a)+n+.98*i*Math.sin(p+s)]),c.push([z(r,a)+t+.9*o*Math.cos(p+s*.5),z(r,a)+n+.9*i*Math.sin(p+s*.5)])}return[c,d]}function za(e,t,n,o,i,r,s,a,l){let d=r+z(.1,l),c=[];c.push([z(a,l)+t+.9*o*Math.cos(d-e),z(a,l)+n+.9*i*Math.sin(d-e)]);for(let p=d;p<=s;p=p+e)c.push([z(a,l)+t+o*Math.cos(p),z(a,l)+n+i*Math.sin(p)]);return c.push([t+o*Math.cos(s),n+i*Math.sin(s)]),c.push([t+o*Math.cos(s),n+i*Math.sin(s)]),mi(c,null,l)}function Dp(e,t,n,o,i,r,s,a){let l=[],d=[a.maxRandomnessOffset||1,(a.maxRandomnessOffset||1)+.3],c=[0,0],p=a.disableMultiStroke?1:2,h=a.preserveVertices;for(let m=0;m<p;m++)m===0?l.push({op:"move",data:[s[0],s[1]]}):l.push({op:"move",data:[s[0]+(h?0:z(d[0],a)),s[1]+(h?0:z(d[0],a))]}),c=h?[i,r]:[i+z(d[m],a),r+z(d[m],a)],l.push({op:"bcurveTo",data:[e+z(d[m],a),t+z(d[m],a),n+z(d[m],a),o+z(d[m],a),c[0],c[1]]});return l}I();function Mo(e){return[...e]}function Va(e,t=0){let n=e.length;if(n<3)throw new Error("A curve must have at least three points.");let o=[];if(n===3)o.push(Mo(e[0]),Mo(e[1]),Mo(e[2]),Mo(e[2]));else{let i=[];i.push(e[0],e[0]);for(let a=1;a<e.length;a++)i.push(e[a]),a===e.length-1&&i.push(e[a]);let r=[],s=1-t;o.push(Mo(i[0]));for(let a=1;a+2<i.length;a++){let l=i[a];r[0]=[l[0],l[1]],r[1]=[l[0]+(s*i[a+1][0]-s*i[a-1][0])/6,l[1]+(s*i[a+1][1]-s*i[a-1][1])/6],r[2]=[i[a+1][0]+(s*i[a][0]-s*i[a+2][0])/6,i[a+1][1]+(s*i[a][1]-s*i[a+2][1])/6],r[3]=[i[a+1][0],i[a+1][1]],o.push(r[1],r[2],r[3])}}return o}I();function Gp(e,t){return Math.sqrt(Ei(e,t))}function Ei(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function Op(e,t,n){let o=Ei(t,n);if(o===0)return Ei(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/o;return i=Math.max(0,Math.min(1,i)),Ei(e,Rn(t,n,i))}function Rn(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function Rp(e,t){let n=e[t+0],o=e[t+1],i=e[t+2],r=e[t+3],s=3*o[0]-2*n[0]-r[0];s*=s;let a=3*o[1]-2*n[1]-r[1];a*=a;let l=3*i[0]-2*r[0]-n[0];l*=l;let d=3*i[1]-2*r[1]-n[1];return d*=d,s<l&&(s=l),a<d&&(a=d),s+a}function Hr(e,t,n,o){let i=o||[];if(Rp(e,t)<n){let r=e[t+0];i.length?Gp(i[i.length-1],r)>1&&i.push(r):i.push(r),i.push(e[t+3])}else{let s=e[t+0],a=e[t+1],l=e[t+2],d=e[t+3],c=Rn(s,a,.5),p=Rn(a,l,.5),h=Rn(l,d,.5),m=Rn(c,p,.5),f=Rn(p,h,.5),g=Rn(m,f,.5);Hr([s,c,m,g],0,n,i),Hr([g,f,h,d],0,n,i)}return i}function Po(e,t){return xi(e,0,e.length,t)}function xi(e,t,n,o,i){let r=i||[],s=e[t],a=e[n-1],l=0,d=1;for(let c=t+1;c<n-1;++c){let p=Op(e[c],s,a);p>l&&(l=p,d=c)}return Math.sqrt(l)>o?(xi(e,t,d+1,o,r),xi(e,d,n,o,r)):(r.length||r.push(s),r.push(a)),r}function Ht(e,t=.15,n){let o=[],i=(e.length-1)/3;for(let r=0;r<i;r++){let s=r*3;Hr(e,s,t,o)}return n&&n>0?xi(o,0,o.length,n):o}I();function Ua(e,t,n){let o=qn(e),i=wo(xo(o)),r=[],s=[],a=[0,0],l=[],d=()=>{l.length>=4&&s.push(...Ht(l,t)),l=[]},c=()=>{d(),s.length&&(r.push(s),s=[])};for(let{key:h,data:m}of i)switch(h){case"M":c(),a=[m[0],m[1]],s.push(a);break;case"L":d(),s.push([m[0],m[1]]);break;case"C":if(!l.length){let f=s.length?s[s.length-1]:a;l.push([f[0],f[1]])}l.push([m[0],m[1]]),l.push([m[2],m[3]]),l.push([m[4],m[5]]);break;case"Z":d(),s.push([a[0],a[1]]);break}if(c(),!n)return r;let p=[];for(let h of r){let m=Po(h,n);m.length&&p.push(m)}return p}var tt="none",lt=class{constructor(t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Oa()}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,n,o){return{shape:t,sets:n||[],options:o||this.defaultOptions}}line(t,n,o,i,r){let s=this._o(r);return this._d("line",[Gr(t,n,o,i,s)],s)}rectangle(t,n,o,i,r){let s=this._o(r),a=[],l=_a(t,n,o,i,s);if(s.fill){let d=[[t,n],[t+o,n],[t+o,n+i],[t,n+i]];s.fillStyle==="solid"?a.push(gi([d],s)):a.push(On([d],s))}return s.stroke!==tt&&a.push(l),this._d("rectangle",a,s)}ellipse(t,n,o,i,r){let s=this._o(r),a=[],l=Rr(o,i,s),d=fi(t,n,s,l);if(s.fill)if(s.fillStyle==="solid"){let c=fi(t,n,s,l).opset;c.type="fillPath",a.push(c)}else a.push(On([d.estimatedPoints],s));return s.stroke!==tt&&a.push(d.opset),this._d("ellipse",a,s)}circle(t,n,o,i){let r=this.ellipse(t,n,o,o,i);return r.shape="circle",r}linearPath(t,n){let o=this._o(n);return this._d("linearPath",[bo(t,!1,o)],o)}arc(t,n,o,i,r,s,a=!1,l){let d=this._o(l),c=[],p=Fr(t,n,o,i,r,s,a,!0,d);if(a&&d.fill)if(d.fillStyle==="solid"){let h=Object.assign({},d);h.disableMultiStroke=!0;let m=Fr(t,n,o,i,r,s,!0,!1,h);m.type="fillPath",c.push(m)}else c.push(Wa(t,n,o,i,r,s,d));return d.stroke!==tt&&c.push(p),this._d("arc",c,d)}curve(t,n){let o=this._o(n),i=[],r=Or(t,o);if(o.fill&&o.fill!==tt&&t.length>=3)if(o.fillStyle==="solid"){let s=Or(t,Object.assign(Object.assign({},o),{disableMultiStroke:!0,roughness:o.roughness?o.roughness+o.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(s.ops)})}else{let s=Va(t),a=Ht(s,10,(1+o.roughness)/2);i.push(On([a],o))}return o.stroke!==tt&&i.push(r),this._d("curve",i,o)}polygon(t,n){let o=this._o(n),i=[],r=bo(t,!0,o);return o.fill&&(o.fillStyle==="solid"?i.push(gi([t],o)):i.push(On([t],o))),o.stroke!==tt&&i.push(r),this._d("polygon",i,o)}path(t,n){let o=this._o(n),i=[];if(!t)return this._d("path",i,o);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let r=o.fill&&o.fill!=="transparent"&&o.fill!==tt,s=o.stroke!==tt,a=!!(o.simplification&&o.simplification<1),l=a?4-4*(o.simplification||1):(1+o.roughness)/2,d=Ua(t,1,l),c=Nr(t,o);if(r)if(o.fillStyle==="solid")if(d.length===1){let p=Nr(t,Object.assign(Object.assign({},o),{disableMultiStroke:!0,roughness:o.roughness?o.roughness+o.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(p.ops)})}else i.push(gi(d,o));else i.push(On(d,o));return s&&(a?d.forEach(p=>{i.push(bo(p,!1,o))}):i.push(c)),this._d("path",i,o)}opsToPath(t,n){let o="";for(let i of t.ops){let r=typeof n=="number"&&n>=0?i.data.map(s=>+s.toFixed(n)):i.data;switch(i.op){case"move":o+=`M${r[0]} ${r[1]} `;break;case"bcurveTo":o+=`C${r[0]} ${r[1]}, ${r[2]} ${r[3]}, ${r[4]} ${r[5]} `;break;case"lineTo":o+=`L${r[0]} ${r[1]} `;break}}return o.trim()}toPaths(t){let n=t.sets||[],o=t.options||this.defaultOptions,i=[];for(let r of n){let s=null;switch(r.type){case"path":s={d:this.opsToPath(r),stroke:o.stroke,strokeWidth:o.strokeWidth,fill:tt};break;case"fillPath":s={d:this.opsToPath(r),stroke:tt,strokeWidth:0,fill:o.fill||tt};break;case"fillSketch":s=this.fillSketch(r,o);break}s&&i.push(s)}return i}fillSketch(t,n){let o=n.fillWeight;return o<0&&(o=n.strokeWidth/2),{d:this.opsToPath(t),stroke:n.fill||tt,strokeWidth:o,fill:tt}}_mergedShape(t){return t.filter((n,o)=>o===0?!0:n.op!=="move")}};var yi=class{constructor(t,n){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new lt(n)}draw(t){let n=t.sets||[],o=t.options||this.getDefaultOptions(),i=this.ctx,r=t.options.fixedDecimalPlaceDigits;for(let s of n)switch(s.type){case"path":i.save(),i.strokeStyle=o.stroke==="none"?"transparent":o.stroke,i.lineWidth=o.strokeWidth,o.strokeLineDash&&i.setLineDash(o.strokeLineDash),o.strokeLineDashOffset&&(i.lineDashOffset=o.strokeLineDashOffset),this._drawToContext(i,s,r),i.restore();break;case"fillPath":{i.save(),i.fillStyle=o.fill||"";let a=t.shape==="curve"||t.shape==="polygon"||t.shape==="path"?"evenodd":"nonzero";this._drawToContext(i,s,r,a),i.restore();break}case"fillSketch":this.fillSketch(i,s,o);break}}fillSketch(t,n,o){let i=o.fillWeight;i<0&&(i=o.strokeWidth/2),t.save(),o.fillLineDash&&t.setLineDash(o.fillLineDash),o.fillLineDashOffset&&(t.lineDashOffset=o.fillLineDashOffset),t.strokeStyle=o.fill||"",t.lineWidth=i,this._drawToContext(t,n,o.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,n,o,i="nonzero"){t.beginPath();for(let r of n.ops){let s=typeof o=="number"&&o>=0?r.data.map(a=>+a.toFixed(o)):r.data;switch(r.op){case"move":t.moveTo(s[0],s[1]);break;case"bcurveTo":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"lineTo":t.lineTo(s[0],s[1]);break}}n.type==="fillPath"?t.fill(i):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,n,o,i,r){let s=this.gen.line(t,n,o,i,r);return this.draw(s),s}rectangle(t,n,o,i,r){let s=this.gen.rectangle(t,n,o,i,r);return this.draw(s),s}ellipse(t,n,o,i,r){let s=this.gen.ellipse(t,n,o,i,r);return this.draw(s),s}circle(t,n,o,i){let r=this.gen.circle(t,n,o,i);return this.draw(r),r}linearPath(t,n){let o=this.gen.linearPath(t,n);return this.draw(o),o}polygon(t,n){let o=this.gen.polygon(t,n);return this.draw(o),o}arc(t,n,o,i,r,s,a=!1,l){let d=this.gen.arc(t,n,o,i,r,s,a,l);return this.draw(d),d}curve(t,n){let o=this.gen.curve(t,n);return this.draw(o),o}path(t,n){let o=this.gen.path(t,n);return this.draw(o),o}};I();I();var Io="http://www.w3.org/2000/svg";var wi=class{constructor(t,n){this.svg=t,this.gen=new lt(n)}draw(t){let n=t.sets||[],o=t.options||this.getDefaultOptions(),i=this.svg.ownerDocument||window.document,r=i.createElementNS(Io,"g"),s=t.options.fixedDecimalPlaceDigits;for(let a of n){let l=null;switch(a.type){case"path":{l=i.createElementNS(Io,"path"),l.setAttribute("d",this.opsToPath(a,s)),l.setAttribute("stroke",o.stroke),l.setAttribute("stroke-width",o.strokeWidth+""),l.setAttribute("fill","none"),o.strokeLineDash&&l.setAttribute("stroke-dasharray",o.strokeLineDash.join(" ").trim()),o.strokeLineDashOffset&&l.setAttribute("stroke-dashoffset",`${o.strokeLineDashOffset}`);break}case"fillPath":{l=i.createElementNS(Io,"path"),l.setAttribute("d",this.opsToPath(a,s)),l.setAttribute("stroke","none"),l.setAttribute("stroke-width","0"),l.setAttribute("fill",o.fill||""),(t.shape==="curve"||t.shape==="polygon")&&l.setAttribute("fill-rule","evenodd");break}case"fillSketch":{l=this.fillSketch(i,a,o);break}}l&&r.appendChild(l)}return r}fillSketch(t,n,o){let i=o.fillWeight;i<0&&(i=o.strokeWidth/2);let r=t.createElementNS(Io,"path");return r.setAttribute("d",this.opsToPath(n,o.fixedDecimalPlaceDigits)),r.setAttribute("stroke",o.fill||""),r.setAttribute("stroke-width",i+""),r.setAttribute("fill","none"),o.fillLineDash&&r.setAttribute("stroke-dasharray",o.fillLineDash.join(" ").trim()),o.fillLineDashOffset&&r.setAttribute("stroke-dashoffset",`${o.fillLineDashOffset}`),r}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,n){return this.gen.opsToPath(t,n)}line(t,n,o,i,r){let s=this.gen.line(t,n,o,i,r);return this.draw(s)}rectangle(t,n,o,i,r){let s=this.gen.rectangle(t,n,o,i,r);return this.draw(s)}ellipse(t,n,o,i,r){let s=this.gen.ellipse(t,n,o,i,r);return this.draw(s)}circle(t,n,o,i){let r=this.gen.circle(t,n,o,i);return this.draw(r)}linearPath(t,n){let o=this.gen.linearPath(t,n);return this.draw(o)}polygon(t,n){let o=this.gen.polygon(t,n);return this.draw(o)}arc(t,n,o,i,r,s,a=!1,l){let d=this.gen.arc(t,n,o,i,r,s,a,l);return this.draw(d)}curve(t,n){let o=this.gen.curve(t,n);return this.draw(o)}path(t,n){let o=this.gen.path(t,n);return this.draw(o)}};var Fn={canvas(e,t){return new yi(e,t)},svg(e,t){return new wi(e,t)},generator(e){return new lt(e)},newSeed(){return lt.newSeed()}};import{arrayToMap as cc,invariant as Ws,rescalePoints as rc,sizeOf as d0}from"@excalidraw/common";import{degreesToRadians as _s,lineSegment as Ie,pointDistance as c0,pointFrom as B,pointFromArray as uc,pointRotateRads as de}from"@excalidraw/math";I();import{invariant as Fp}from"@excalidraw/common";import{curve as Np,lineSegment as Hp,pointFrom as pe,pointDistance as z2,pointFromArray as zp,pointFromVector as _p,pointRotateRads as ft,polygon as Ya,polygonFromPoints as zr,PRECISION as _2,segmentsIntersectAt as W2,vector as Wp,vectorAdd as jp,vectorFromPoint as Vp,vectorScale as j2}from"@excalidraw/math";import{getElementAbsoluteCoords as U2}from"@excalidraw/element";var Xa=e=>{let{angle:t,width:n,height:o,x:i,y:r}=e,s=i+n/2,a=r+o/2,l=pe(s,a),d;return e.type==="diamond"?d=Ya(ft(pe(s,r),l,t),ft(pe(i+n,a),l,t),ft(pe(s,r+o),l,t),ft(pe(i,a),l,t)):d=Ya(ft(pe(i,r),l,t),ft(pe(i+n,r),l,t),ft(pe(i+n,r+o),l,t),ft(pe(i,r+o),l,t)),{type:"polygon",data:d}};var $a=e=>{let{width:t,height:n,angle:o,x:i,y:r}=e;return{type:"ellipse",data:{center:pe(i+t/2,r+n/2),angle:o,halfWidth:t/2,halfHeight:n/2}}},zt=e=>{if(!e)return[];for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},Za=(e,t=pe(0,0),n,o)=>{let i=l=>ft(pe(l[0]+t[0],l[1]+t[1]),o,n),r=zt(e),s=[],a=pe(0,0);for(let l of r){if(l.op==="move"){let d=zp(l.data);Fp(d!=null,"Ops data is not a point"),a=i(d)}if(l.op==="bcurveTo"){let d=i(pe(l.data[0],l.data[1])),c=i(pe(l.data[2],l.data[3])),p=i(pe(l.data[4],l.data[5]));s.push(Np(a,d,c,p)),a=p}}return{type:"polycurve",data:s}},Up=e=>{let t=e[0],n=[];for(let o=1;o<e.length;o++){let i=e[o];n.push(Hp(t,i)),t=i}return n},qa=(e,t,n=!1)=>{let o=r=>ft(_p(jp(Vp(r),Wp(e.x,e.y))),t,e.angle),i=Up(e.points.map(r=>o(r)));return n?{type:"polygon",data:zr(i.flat())}:{type:"polyline",data:i}},Ka=(e,t,n=pe(0,0),o,i)=>{let r=c=>ft(pe(c[0]+n[0],c[1]+n[1]),i,o);if(e.roundness===null)return{type:"polygon",data:zr(e.points.map(c=>r(c)))};let s=zt(t),a=[],l=!1;for(let c of s)c.op==="move"?(l=!l,l&&a.push(pe(c.data[0],c.data[1]))):c.op==="bcurveTo"?l&&(a.push(pe(c.data[0],c.data[1])),a.push(pe(c.data[2],c.data[3])),a.push(pe(c.data[4],c.data[5]))):c.op==="lineTo"&&l&&a.push(pe(c.data[0],c.data[1]));let d=Ht(a,10,5).map(c=>r(c));return{type:"polygon",data:zr(d)}};I();I();function Qa(e,t,n,o=i=>i){return e*o(.5-t*(.5-n))}function Yp(e){return[-e[0],-e[1]]}function Et(e,t){return[e[0]+t[0],e[1]+t[1]]}function dt(e,t){return[e[0]-t[0],e[1]-t[1]]}function gt(e,t){return[e[0]*t,e[1]*t]}function Xp(e,t){return[e[0]/t,e[1]/t]}function So(e){return[e[1],-e[0]]}function Ja(e,t){return e[0]*t[0]+e[1]*t[1]}function $p(e,t){return e[0]===t[0]&&e[1]===t[1]}function Zp(e){return Math.hypot(e[0],e[1])}function qp(e){return e[0]*e[0]+e[1]*e[1]}function el(e,t){return qp(dt(e,t))}function ol(e){return Xp(e,Zp(e))}function Kp(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function vo(e,t,n){let o=Math.sin(n),i=Math.cos(n),r=e[0]-t[0],s=e[1]-t[1],a=r*i-s*o,l=r*o+s*i;return[a+t[0],l+t[1]]}function _r(e,t,n){return Et(e,gt(dt(t,e),n))}function tl(e,t,n){return Et(e,gt(t,n))}var{min:Kn,PI:Qp}=Math,nl=.275,Ao=Qp+1e-4;function Jp(e,t={}){let{size:n=16,smoothing:o=.5,thinning:i=.5,simulatePressure:r=!0,easing:s=H=>H,start:a={},end:l={},last:d=!1}=t,{cap:c=!0,easing:p=H=>H*(2-H)}=a,{cap:h=!0,easing:m=H=>--H*H*H+1}=l;if(e.length===0||n<=0)return[];let f=e[e.length-1].runningLength,g=a.taper===!1?0:a.taper===!0?Math.max(n,f):a.taper,E=l.taper===!1?0:l.taper===!0?Math.max(n,f):l.taper,x=Math.pow(n*o,2),y=[],w=[],M=e.slice(0,10).reduce((H,v)=>{let W=v.pressure;if(r){let X=Kn(1,v.distance/n),Se=Kn(1,1-X);W=Kn(1,H+(Se-H)*(X*nl))}return(H+W)/2},e[0].pressure),b=Qa(n,i,e[e.length-1].pressure,s),S,A=e[0].vector,C=e[0].point,T=C,F=C,O=T,N=!1;for(let H=0;H<e.length;H++){let{pressure:v}=e[H],{point:W,vector:X,distance:Se,runningLength:vt}=e[H];if(H<e.length-1&&f-vt<3)continue;if(i){if(r){let et=Kn(1,Se/n),at=Kn(1,1-et);v=Kn(1,M+(at-M)*(et*nl))}b=Qa(n,i,v,s)}else b=n/2;S===void 0&&(S=b);let ti=vt<g?p(vt/g):1,Lr=f-vt<E?m((f-vt)/E):1;b=Math.max(.01,b*Math.min(ti,Lr));let ni=(H<e.length-1?e[H+1]:e[H]).vector,go=H<e.length-1?Ja(X,ni):1,Cr=Ja(X,A)<0&&!N,oi=go!==null&&go<0;if(Cr||oi){let et=gt(So(A),b);for(let at=1/13,sn=0;sn<=1;sn+=at)F=vo(dt(W,et),W,Ao*sn),y.push(F),O=vo(Et(W,et),W,Ao*-sn),w.push(O);C=F,T=O,oi&&(N=!0);continue}if(N=!1,H===e.length-1){let et=gt(So(X),b);y.push(dt(W,et)),w.push(Et(W,et));continue}let ii=gt(So(_r(ni,X,go)),b);F=dt(W,ii),(H<=1||el(C,F)>x)&&(y.push(F),C=F),O=Et(W,ii),(H<=1||el(T,O)>x)&&(w.push(O),T=O),M=v,A=X}let D=e[0].point.slice(0,2),q=e.length>1?e[e.length-1].point.slice(0,2):Et(e[0].point,[1,1]),U=[],le=[];if(e.length===1){if(!(g||E)||d){let H=tl(D,ol(So(dt(D,q))),-(S||b)),v=[];for(let W=1/13,X=W;X<=1;X+=W)v.push(vo(H,D,Ao*2*X));return v}}else{if(!(g||E&&e.length===1))if(c)for(let v=1/13,W=v;W<=1;W+=v){let X=vo(w[0],D,Ao*W);U.push(X)}else{let v=dt(y[0],w[0]),W=gt(v,.5),X=gt(v,.51);U.push(dt(D,W),dt(D,X),Et(D,X),Et(D,W))}let H=So(Yp(e[e.length-1].vector));if(E||g&&e.length===1)le.push(q);else if(h){let v=tl(q,H,b);for(let W=1/29,X=W;X<1;X+=W)le.push(vo(v,q,Ao*3*X))}else le.push(Et(q,gt(H,b)),Et(q,gt(H,b*.99)),dt(q,gt(H,b*.99)),dt(q,gt(H,b)))}return y.concat(le,w.reverse(),U)}function e1(e,t={}){var n;let{streamline:o=.5,size:i=16,last:r=!1}=t;if(e.length===0)return[];let s=.15+(1-o)*.85,a=Array.isArray(e[0])?e:e.map(({x:m,y:f,pressure:g=.5})=>[m,f,g]);if(a.length===2){let m=a[1];a=a.slice(0,-1);for(let f=1;f<5;f++)a.push(_r(a[0],m,f/4))}a.length===1&&(a=[...a,[...Et(a[0],[1,1]),...a[0].slice(2)]]);let l=[{point:[a[0][0],a[0][1]],pressure:a[0][2]>=0?a[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],d=!1,c=0,p=l[0],h=a.length-1;for(let m=1;m<a.length;m++){let f=r&&m===h?a[m].slice(0,2):_r(p.point,a[m],s);if($p(p.point,f))continue;let g=Kp(f,p.point);if(c+=g,m<h&&!d){if(c<i)continue;d=!0}p={point:f,pressure:a[m][2]>=0?a[m][2]:.5,vector:ol(dt(p.point,f)),distance:g,runningLength:c},l.push(p)}return l[0].vector=((n=l[1])==null?void 0:n.vector)||[0,0],l}function il(e,t={}){return Jp(e1(e,t),t)}import{pointFrom as he,pointDistance as Jd,pointRotateRads as tn}from"@excalidraw/math";import{ROUGHNESS as Qm,THEME as zs,isTransparent as $o,assertNever as Jm,COLOR_PALETTE as e0,LINE_POLYGON_POINT_MERGE_DISTANCE as t0,applyDarkModeFilter as Zo}from"@excalidraw/common";I();import{isRightAngleRads as Hm,lineSegment as Xd,pointFrom as or,pointRotateRads as Rs}from"@excalidraw/math";import{BOUND_TEXT_PADDING as ir,DEFAULT_REDUCED_GLOBAL_ALPHA as zm,ELEMENT_READY_TO_ERASE_OPACITY as _m,FRAME_STYLE as Uo,DARK_THEME_FILTER as Wm,MIME_TYPES as Ns,THEME as ro,distance as An,getFontString as jm,isRTL as Vm,getVerticalOffset as Um,invariant as Ym,applyDarkModeFilter as sr,isSafari as Xm}from"@excalidraw/common";I();import{pointFrom as _t,pointCenter as t1,pointRotateRads as dn,vectorFromPoint as Wr,vectorNormalize as rl,vectorSubtract as sl,vectorAdd as bi,vectorScale as Mi,pointFromVector as al,clamp as Te,isCloseTo as ll}from"@excalidraw/math";var Le=10,Q2=(e,t,n,o,i,r,s,a)=>{let{width:l,height:d}=jr(e),c=o/l,p=i/d,h=(e.crop?.x??0)/c,m=(e.crop?.y??0)/p,f=dn(_t(r,s),ce(e,t),-e.angle);r=f[0],s=f[1];let g=e.width,E=e.height,x=e.crop??{x:0,y:0,width:o,height:i,naturalWidth:o,naturalHeight:i},y=x.height,w=x.width,M=e.scale[0]===-1,b=e.scale[1]===-1,S=s-e.y,A=r-e.x;n.includes("n")&&(E=Te(e.height-S,Le,b?d-m:e.height+m)),n.includes("s")&&(S=s-e.y-e.height,E=Te(e.height+S,Le,b?e.height+m:d-m)),n.includes("e")&&(A=r-e.x-e.width,g=Te(e.width+A,Le,M?e.width+h:l-h)),n.includes("w")&&(g=Te(e.width-A,Le,M?l-h:e.width+h));let C=O=>{O.height=E*p,O.width=g*c};C(x);let T=(O,N)=>{C(N),O.includes("n")&&(b||(N.y+=y-N.height)),O.includes("s")&&b&&(N.y+=y-N.height),O.includes("e")&&M&&(N.x+=w-N.width),O.includes("w")&&(M||(N.x+=w-N.width))};switch(n){case"n":{if(a){let O=h+e.width/2,N=l-h-e.width/2,D=Math.min(O,N)*2;g=Te(E*a,Le,D),E=g/a}T(n,x),a&&(x.x+=(w-x.width)/2);break}case"s":{if(a){let O=h+e.width/2,N=l-h-e.width/2,D=Math.min(O,N)*2;g=Te(E*a,Le,D),E=g/a}T(n,x),a&&(x.x+=(w-x.width)/2);break}case"w":{if(a){let O=m+e.height/2,N=d-m-e.height/2,D=Math.min(O,N)*2;E=Te(g/a,Le,D),g=E*a}T(n,x),a&&(x.y+=(y-x.height)/2);break}case"e":{if(a){let O=m+e.height/2,N=d-m-e.height/2,D=Math.min(O,N)*2;E=Te(g/a,Le,D),g=E*a}T(n,x),a&&(x.y+=(y-x.height)/2);break}case"ne":{if(a)if(A>-S){let O=b?d-m:m+e.height;E=Te(g/a,Le,O),g=E*a}else{let O=M?h+e.width:l-h;g=Te(E*a,Le,O),E=g/a}T(n,x);break}case"nw":{if(a)if(A<S){let O=b?d-m:m+e.height;E=Te(g/a,Le,O),g=E*a}else{let O=M?l-h:h+e.width;g=Te(E*a,Le,O),E=g/a}T(n,x);break}case"se":{if(a)if(A>S){let O=b?m+e.height:d-m;E=Te(g/a,Le,O),g=E*a}else{let O=M?h+e.width:l-h;g=Te(E*a,Le,O),E=g/a}T(n,x);break}case"sw":{if(a)if(-A>S){let O=b?m+e.height:d-m;E=Te(g/a,Le,O),g=E*a}else{let O=M?l-h:h+e.width;g=Te(E*a,Le,O),E=g/a}T(n,x);break}default:break}let F=n1(e,n,g,E,!!a);return ll(x.width,x.naturalWidth)&&ll(x.height,x.naturalHeight)&&(x=null),{x:F[0],y:F[1],width:g,height:E,crop:x}},n1=(e,t,n,o,i)=>{let[r,s,a,l]=cn(e,e.width,e.height,!0),d=_t(r,s),c=_t(a,l),p=t1(d,c),[h,m,f,g]=cn(e,n,o,!0),E=f-h,x=g-m,y=[...d];if(["n","w","nw"].includes(t)&&(y=[c[0]-Math.abs(E),c[1]-Math.abs(x)]),t==="ne"){let C=[d[0],c[1]];y=[C[0],C[1]-Math.abs(x)]}if(t==="sw"){let C=[c[0],d[1]];y=[C[0]-Math.abs(E),C[1]]}i&&(["s","n"].includes(t)&&(y[0]=p[0]-E/2),["e","w"].includes(t)&&(y[1]=p[1]-x/2));let w=e.angle,M=dn(y,p,w),b=[y[0]+Math.abs(E)/2,y[1]+Math.abs(x)/2],S=dn(b,p,w);y=dn(M,S,-w);let A=[...y];return A[0]+=e.x-h,A[1]+=e.y-m,A},dl=(e,t)=>{if(e.crop){let{width:n,height:o}=jr(e),[i,r,s,a,l,d]=K(e,t),c=Wr(dn(_t(i,r),_t(l,d),e.angle)),p=Wr(dn(_t(s,r),_t(l,d),e.angle)),h=rl(sl(p,c)),m=Wr(dn(_t(i,a),_t(l,d),e.angle)),f=sl(m,c),g=rl(f),{cropX:E,cropY:x}=o1(e.crop,e.scale),y=bi(bi(c,Mi(h,-E*n/e.crop.naturalWidth)),Mi(g,-x*o/e.crop.naturalHeight)),w=al(bi(bi(y,Mi(h,n/2)),Mi(g,o/2))),M=dn(al(y),w,-e.angle);return{...e,x:M[0],y:M[1],width:n,height:o,crop:null}}return e},jr=e=>{if(e.crop){let t=e.width/(e.crop.width/e.crop.naturalWidth),n=e.height/(e.crop.height/e.crop.naturalHeight);return{width:t,height:n}}return{width:e.width,height:e.height}},o1=(e,t)=>{let n=e.x,o=e.y,i=t[0]===-1,r=t[1]===-1;return i&&(n=e.naturalWidth-Math.abs(n)-e.width),r&&(o=e.naturalHeight-Math.abs(o)-e.height),{cropX:n,cropY:o}},J2=(e,t=!1)=>{let n=e.crop;if(!n)return null;let o=e.scale[0]===-1,i=e.scale[1]===-1,r=n.x,s=n.y;if(o&&(r=n.naturalWidth-n.width-n.x),i&&(s=n.naturalHeight-n.height-n.y),t)return{x:r,y:s};let{width:a,height:l}=jr(e);return{x:r/(n.naturalWidth/a),y:s/(n.naturalHeight/l)}};I();import{pointCenter as fd,pointFrom as R,pointRotateRads as He,pointsEqual as gd,pointDistance as Un,vectorFromPoint as nm,curveLength as om,curvePointAtLength as im}from"@excalidraw/math";import{DRAGGING_THRESHOLD as rm,KEYS as Vn,shouldRotateWithDiscreteAngle as jo,getGridPoint as Ed,invariant as Ke,isShallowEqual as sm,getFeatureFlag as oo}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as xd,getSnapOutlineMidPoint as yd,isPathALoop as am,moveArrowAboveBindable as wd,projectFixedPointOntoDiagonal as bd}from"@excalidraw/element";I();import{arrayToMap as ld,getFeatureFlag as Rh,invariant as pt,isTransparent as Fh}from"@excalidraw/common";import{PRECISION as Nh,clamp as Is,lineSegment as $i,pointDistance as bn,pointDistanceSq as Qt,pointFrom as se,pointFromVector as Yi,pointRotateRads as ue,pointsEqual as Hh,vectorFromPoint as zo,vectorNormalize as Ps,vectorScale as Xi}from"@excalidraw/math";I();import{invariant as Nl,isTransparent as Hl}from"@excalidraw/common";import{curveIntersectLineSegment as zl,isPointWithinBounds as Gi,lineSegment as Oo,lineSegmentIntersectionPoints as _l,pointFrom as xe,pointFromVector as nh,pointRotateRads as it,pointsEqual as Wl,vectorFromPoint as oh,vectorNormalize as ih,vectorScale as rh}from"@excalidraw/math";import{ellipse as sh,ellipseSegmentInterceptPoints as ah}from"@excalidraw/math/ellipse";I();import{DEFAULT_ADAPTIVE_RADIUS as u1,DEFAULT_PROPORTIONAL_RADIUS as Ur,invariant as p1,LINE_CONFIRM_THRESHOLD as h1,ROUNDNESS as Yr}from"@excalidraw/common";import{bezierEquation as m1,curve as jt,curveCatmullRomCubicApproxPoints as yl,curveOffsetPoints as wl,lineSegment as Pe,lineSegmentIntersectionPoints as El,pointDistance as Hn,pointFrom as _,pointFromArray as f1,pointFromVector as g1,pointRotateRads as nt,pointTranslate as xl,rectangle as E1,vectorFromPoint as bl,vectorNormalize as x1,vectorScale as Xr}from"@excalidraw/math";I();import{ROUNDNESS as ko,assertNever as i1}from"@excalidraw/common";import{pointsEqual as cl}from"@excalidraw/math";var Nn=e=>!!e&&e.type==="image"&&!!e.fileId,ve=e=>!!e&&e.type==="image",ul=e=>!!e&&e.type==="embeddable",Pi=e=>!!e&&e.type==="iframe",Ii=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),ee=e=>e!=null&&e.type==="text",Si=e=>e!=null&&e.type==="frame",pl=e=>e!=null&&e.type==="magicframe",te=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Ce=e=>e!=null&&r1(e.type),r1=e=>e==="freedraw",ne=e=>e!=null&&l1(e.type),Wt=e=>e!=null&&e.type==="line",V=e=>e!=null&&e.type==="arrow",Y=e=>V(e)&&e.elbowed,ix=e=>V(e)&&!e.elbowed,s1=e=>V(e)&&!e.elbowed&&!e.roundness,a1=e=>V(e)&&!e.elbowed&&e.roundness!==null,l1=e=>e==="arrow"||e==="line",Be=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&d1(e.type),d1=e=>e==="arrow",fe=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),hl=e=>e!=null&&(e.type==="rectangle"||e.type==="diamond"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),To=e=>e!=null&&(e.type==="rectangle"||e.type==="image"||e.type==="text"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="freedraw"),c1=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||V(e)),rx=e=>{let t=e?.type;if(!t)return!1;switch(t){case"text":case"diamond":case"rectangle":case"iframe":case"embeddable":case"ellipse":case"arrow":case"freedraw":case"line":case"frame":case"magicframe":case"image":case"selection":return!0;default:return i1(t,null),!1}},Vr=e=>e.type==="rectangle"||e.type==="ellipse"||e.type==="diamond",kt=e=>c1(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),ge=e=>e!==null&&"containerId"in e&&e.containerId!==null&&ee(e),sx=e=>!!e.startBinding||!!e.endBinding,ml=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",fl=e=>e==="line"||e==="arrow"||e==="diamond",ax=(e,t)=>!!((e===ko.ADAPTIVE_RADIUS||e===ko.LEGACY)&&ml(t.type)||e===ko.PROPORTIONAL_RADIUS&&fl(t.type)),lx=e=>fl(e.type)?{type:ko.PROPORTIONAL_RADIUS}:ml(e.type)?{type:ko.ADAPTIVE_RADIUS}:null,dx=e=>s1(e)?"sharpArrow":a1(e)?"curvedArrow":Y(e)?"elbowArrow":"line",cx=e=>e.length>3&&cl(e[0],e[e.length-1]),gl=e=>e.length>3||e.length===3&&!cl(e[0],e[e.length-1]);var Lo=new WeakMap,$r=(e,t)=>{let n=Lo.get(e);if(!n)return;let{version:o,shapes:i}=n;if(o!==e.version){Lo.delete(e);return}return i.get(t)},Zr=(e,t,n)=>{let o=Lo.get(e);if(!o){Lo.set(e,{version:e.version,shapes:new Map([[n,t]])});return}let{version:i,shapes:r}=o;if(i!==e.version){Lo.set(e,{version:e.version,shapes:new Map([[n,t]])});return}r.set(n,t)};function vi(e){let t=$r(e,0);if(t)return t;let n=Pl(e),o=[],i=[];for(let s=0;s<n.length;s+=1){let a=n[s],l=n[s-1]&&f1(n[s-1].data.slice(-2));switch(a.op){case"move":continue;case"lineTo":if(!l)throw new Error("prevPoint is undefined");o.push(Pe(_(e.x+l[0],e.y+l[1]),_(e.x+a.data[0],e.y+a.data[1])));continue;case"bcurveTo":if(!l)throw new Error("prevPoint is undefined");i.push(jt(_(e.x+l[0],e.y+l[1]),_(e.x+a.data[0],e.y+a.data[1]),_(e.x+a.data[2],e.y+a.data[3]),_(e.x+a.data[4],e.y+a.data[5])));continue;default:console.error("Unknown op type",a.op)}}let r=[o,i];return Zr(e,r,0),r}function un(e,t=0){let n=$r(e,t);if(n)return n;let o=Vt(Math.min(e.width,e.height),e);o===0&&(o=.01);let i=E1(_(e.x,e.y),_(e.x+e.width,e.y+e.height)),r=Pe(_(i[0][0]+o,i[0][1]),_(i[1][0]-o,i[0][1])),s=Pe(_(i[1][0],i[0][1]+o),_(i[1][0],i[1][1]-o)),a=Pe(_(i[0][0]+o,i[1][1]),_(i[1][0]-o,i[1][1])),l=Pe(_(i[0][0],i[1][1]-o),_(i[0][0],i[0][1]+o)),d=[jt(l[1],_(l[1][0]+2/3*(i[0][0]-l[1][0]),l[1][1]+2/3*(i[0][1]-l[1][1])),_(r[0][0]+2/3*(i[0][0]-r[0][0]),r[0][1]+2/3*(i[0][1]-r[0][1])),r[0]),jt(r[1],_(r[1][0]+2/3*(i[1][0]-r[1][0]),r[1][1]+2/3*(i[0][1]-r[1][1])),_(s[0][0]+2/3*(i[1][0]-s[0][0]),s[0][1]+2/3*(i[0][1]-s[0][1])),s[0]),jt(s[1],_(s[1][0]+2/3*(i[1][0]-s[1][0]),s[1][1]+2/3*(i[1][1]-s[1][1])),_(a[1][0]+2/3*(i[1][0]-a[1][0]),a[1][1]+2/3*(i[1][1]-a[1][1])),a[1]),jt(a[0],_(a[0][0]+2/3*(i[0][0]-a[0][0]),a[0][1]+2/3*(i[1][1]-a[0][1])),_(l[0][0]+2/3*(i[0][0]-l[0][0]),l[0][1]+2/3*(i[1][1]-l[0][1])),l[0])],c=t>0?d.map(m=>yl(wl(m,t))):[[d[0]],[d[1]],[d[2]],[d[3]]],h=[[Pe(c[0][c[0].length-1][3],c[1][0][0]),Pe(c[1][c[1].length-1][3],c[2][0][0]),Pe(c[2][c[2].length-1][3],c[3][0][0]),Pe(c[3][c[3].length-1][3],c[0][0][0])],c.flat()];return Zr(e,h,t),h}function Ml(e,t=0){let[n,o,i,r,s,a,l,d]=Qn(e),c=e.roundness?Vt(Math.abs(n-l),e):(n-l)*.01,p=e.roundness?Vt(Math.abs(r-o),e):(r-o)*.01,[h,m,f,g]=[_(e.x+n,e.y+o),_(e.x+i,e.y+r),_(e.x+s,e.y+a),_(e.x+l,e.y+d)];return[jt(_(m[0]-c,m[1]-p),m,m,_(m[0]-c,m[1]+p)),jt(_(f[0]+c,f[1]-p),f,f,_(f[0]-c,f[1]-p)),jt(_(g[0]+c,g[1]+p),g,g,_(g[0]+c,g[1]-p)),jt(_(h[0]-c,h[1]+p),h,h,_(h[0]+c,h[1]+p))]}function pn(e,t=0){let n=$r(e,t);if(n)return n;let i=Ml(e,t).map(a=>yl(wl(a,t))),s=[[Pe(i[0][i[0].length-1][3],i[1][0][0]),Pe(i[1][i[1].length-1][3],i[2][0][0]),Pe(i[2][i[2].length-1][3],i[3][0][0]),Pe(i[3][i[3].length-1][3],i[0][0][0])],i.flat()];return Zr(e,s,t),s}var zn=(e,t=1)=>{if(e.length>=3){let[n,o]=[e[0],e[e.length-1]];return Hn(n,o)<=h1/t}return!1},Vt=(e,t)=>{if(t.roundness?.type===Yr.PROPORTIONAL_RADIUS||t.roundness?.type===Yr.LEGACY)return e*Ur;if(t.roundness?.type===Yr.ADAPTIVE_RADIUS){let n=t.roundness?.value??u1,o=n/Ur;return e<=o?e*Ur:n}return 0},y1=(e,t)=>{let n=e.type==="rectangle"?15:0,o=a=>{let l=x1(bl(a[1],a[0])),d=Xr(l,n);return Pe(xl(a[0],d),xl(a[1],Xr(d,-1)))},i=ce(e,t),r=o(To(e)?Pe(nt(_(e.x,e.y),i,e.angle),nt(_(e.x+e.width,e.y+e.height),i,e.angle)):Pe(nt(_(e.x+e.width/2,e.y),i,e.angle),nt(_(e.x+e.width/2,e.y+e.height),i,e.angle))),s=o(To(e)?Pe(nt(_(e.x+e.width,e.y),i,e.angle),nt(_(e.x,e.y+e.height),i,e.angle)):Pe(nt(_(e.x,e.y+e.height/2),i,e.angle),nt(_(e.x+e.width,e.y+e.height/2),i,e.angle)));return[r,s]},w1=(e,t,n,o)=>{let i=ce(t,n);return(t.type==="diamond"?Ml(t).map(a=>{let l=m1(a,.5),d=nt(l,i,t.angle);return _(d[0],d[1])}):[nt(_(t.x+t.width,t.y+t.height/2),i,t.angle),nt(_(t.x+t.width/2,t.y+t.height),i,t.angle),nt(_(t.x,t.y+t.height/2),i,t.angle),nt(_(t.x+t.width/2,t.y),i,t.angle)]).find(a=>Hn(e,a)<=xt(o)+t.strokeWidth/2&&!Tt({point:e,element:t,threshold:0,elementsMap:n,overrideShouldTestInside:!0}))},qr=(e,t,n,o,i,r,s=!0)=>{if(p1(e.points.length>=2,"Arrow must have at least two points"),e.width<3&&e.height<3)return null;if(s){let x=w1(t,n,i,r);if(x)return x}let[a,l]=y1(n,i),d=G.getPointAtIndexGlobalCoordinates(e,o==="start"?1:e.points.length-2,i);if(e.points.length===2){let x=o==="start"?e.endBinding:e.startBinding,y=x&&i.get(x.elementId),w=x&&y&&Ye(hn(x.fixedPoint),y,i);w&&(d=w)}let c=g1(Xr(bl(t,d),2*Hn(d,t)+Math.max(Hn(a[0],a[1]),Hn(l[0],l[1]))),d),p=Pe(c,d),h=El(a,p),m=El(l,p),f=h&&Hn(d,h),g=m&&Hn(d,m),E=null;return f!=null&&g!=null?E=f<g?h:m:E=h||m||null,E&&Ut(E,n,i)?E:null};I();import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as j1,ARROW_LABEL_WIDTH_FRACTION as V1,BOUND_TEXT_PADDING as Lt,DEFAULT_FONT_SIZE as U1,TEXT_ALIGN as Ll,VERTICAL_ALIGN as Cl,getFontString as Bi,isProdEnv as Y1,invariant as X1}from"@excalidraw/common";import{pointFrom as Bl,pointRotateRads as $1}from"@excalidraw/math";I();var Co={},Il=(e,t)=>{let n=Co[e]||(Co[e]={height:t});return n.height=t,n},Sl=e=>{Co[e]&&delete Co[e]},Ix=e=>Co[e]?.height??null;I();import{BOUND_TEXT_PADDING as ki,DEFAULT_FONT_SIZE as b1,DEFAULT_FONT_FAMILY as M1,getFontString as P1,isTestEnv as I1,normalizeEOL as S1}from"@excalidraw/common";var ot=(e,t,n)=>{let o=e.split(`
2
2
  `).map(a=>a||" ").join(`
3
- `),o=parseFloat(t),r=Ju(i,o,n);return{width:ja(i,t),height:r}},Ya="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),Wa=(e,t)=>{let n=em(e);return n===0?Ue(Ya.split("").join(`
4
- `),e,t).width+ao*2:n+ao*2},lo=(e,t)=>Ue("",e,t).width+ao*2,Dw=()=>ja(Ya,qu({fontSize:$u,fontFamily:Zu}))>0,ui=e=>Qu(e).replace(/\t/g," "),Lr=e=>ui(e).split(`
5
- `),Lw=e=>{let t=Lr(e.text).length;return e.height/t/e.fontSize},co=(e,t)=>e*t,Xa=(e,t)=>co(e,t)+ao*2,so,Bw=e=>{so=e},Dr=class{canvas;constructor(){this.canvas=document.createElement("canvas")}getLineWidth(t,n){let i=this.canvas.getContext("2d");i.font=n;let r=i.measureText(t).width;return Ku()?r*10:r}},Zt=(e,t)=>(so||(so=new Dr),so.getLineWidth(e,t)),ja=(e,t)=>{let n=Lr(e),i=0;return n.forEach(o=>{i=Math.max(i,Zt(o,t))}),i},Ju=(e,t,n)=>{let i=Lr(e).length;return co(t,n)*i},Rn=(()=>{let e={};return{calculate:(o,r)=>{let s=o.charCodeAt(0);if(e[r]||(e[r]=[]),!e[r][s]){let a=Zt(o,r);e[r][s]=a}return e[r][s]},getCache:o=>e[o],clearCache:o=>{e[o]=[]}}})(),Cw=e=>{let t=Rn.getCache(e);if(!t)return 0;let n=t.filter(i=>i!==void 0);return Math.min(...n)},em=e=>{let t=Rn.getCache(e);if(!t)return 0;let n=t.filter(i=>i!==void 0);return Math.max(...n)};P();import{isDevEnv as tm,isTestEnv as nm}from"@excalidraw/common";var Br,uo,Cr,Fw=e=>(Br||(Br=te.class(...Object.values(Tt))),Br.test(e)),im=()=>{if(!uo)try{uo=rm()}catch{uo=om()}return uo},Gr=()=>(Cr||(Cr=sm()),Cr),qe={WHITESPACE:/\s/u,HYPHEN:/-/u,OPENING:/<\(\[\{/u,CLOSING:/>\)\]\}.,:;!\?…\//u},Tt={CHAR:/\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}`'^〃〰〆#&*+-ー/\=|¦〒¬ ̄/u,OPENING:/([{〈《⦅「「『【〖〔〘〚<〝/u,CLOSING:/)]}〉》⦆」」』】〗〕〙〛>。.,、〟‥?!:;・〜〞/u,CURRENCY:/¥₩£¢$/u},Pn={FLAG:/\p{RI}\p{RI}/u,JOINER:/(?:\p{Emoji_Modifier}|\uFE0F\u20E3?|[\u{E0020}-\u{E007E}]+\u{E007F})?/u,ZWJ:/\u200D/u,ANY:/[\p{Emoji}]/u,MOST:/[\p{Extended_Pictographic}\p{Emoji_Presentation}]/u},om=()=>te.or(Gr(),ue.On(qe.HYPHEN,qe.WHITESPACE,Tt.CHAR)),rm=()=>te.or(Gr(),ue.Before(qe.WHITESPACE).Build(),ue.After(qe.WHITESPACE,qe.HYPHEN).Build(),ue.Before(Tt.CHAR,Tt.CURRENCY).NotPrecededBy(qe.OPENING,Tt.OPENING).Build(),ue.After(Tt.CHAR).NotFollowedBy(qe.HYPHEN,qe.CLOSING,Tt.CLOSING).Build(),ue.BeforeMany(Tt.OPENING).NotPrecededBy(qe.OPENING).Build(),ue.AfterMany(Tt.CLOSING).NotFollowedBy(qe.CLOSING).Build(),ue.AfterMany(qe.CLOSING).FollowedBy(qe.OPENING).Build()),sm=()=>te.group(te.or(Pn.FLAG,te.and(Pn.MOST,Pn.JOINER,te.build(`(?:${Pn.ZWJ.source}(?:${Pn.FLAG.source}|${Pn.ANY.source}${Pn.JOINER.source}))*`)))),te={build:e=>new RegExp(e,"u"),join:(...e)=>e.map(t=>t.source).join(""),and:(...e)=>te.build(te.join(...e)),or:(...e)=>te.build(e.map(t=>t.source).join("|")),group:(...e)=>te.build(`(${te.join(...e)})`),class:(...e)=>te.build(`[${te.join(...e)}]`)},ue={On:(...e)=>{let t=te.join(...e);return te.build(`([${t}])`)},Before:(...e)=>{let t=te.join(...e),n=()=>te.build(`(?=[${t}])`);return ue.Chain(n)},After:(...e)=>{let t=te.join(...e),n=()=>te.build(`(?<=[${t}])`);return ue.Chain(n)},BeforeMany:(...e)=>{let t=te.join(...e),n=()=>te.build(`(?<![${t}])(?=[${t}])`);return ue.Chain(n)},AfterMany:(...e)=>{let t=te.join(...e),n=()=>te.build(`(?<=[${t}])(?![${t}])`);return ue.Chain(n)},NotBefore:(...e)=>{let t=te.join(...e),n=()=>te.build(`(?![${t}])`);return ue.Chain(n)},NotAfter:(...e)=>{let t=te.join(...e),n=()=>te.build(`(?<![${t}])`);return ue.Chain(n)},Chain:e=>({Build:e,PreceededBy:(...t)=>{let n=e(),i=ue.After(...t).Build(),o=()=>te.and(i,n);return ue.Chain(o)},FollowedBy:(...t)=>{let n=e(),i=ue.Before(...t).Build(),o=()=>te.and(n,i);return ue.Chain(o)},NotPrecededBy:(...t)=>{let n=e(),i=ue.NotAfter(...t).Build(),o=()=>te.and(i,n);return ue.Chain(o)},NotFollowedBy:(...t)=>{let n=e(),i=ue.NotBefore(...t).Build(),o=()=>te.and(n,i);return ue.Chain(o)}})},am=e=>{let t=im();return e.normalize("NFC").split(t).filter(Boolean)},vt=(e,t,n)=>{if(!Number.isFinite(n)||n<0)return e;let i=[],o=e.split(`
6
- `);for(let r of o){if(Zt(r,t)<=n){i.push(r);continue}let a=lm(r,t,n);i.push(...a)}return i.join(`
7
- `)},lm=(e,t,n)=>{let i=[],r=am(e)[Symbol.iterator](),s="",a=0,l=r.next();for(;!l.done;){let d=l.value,c=s+d,u=um(d)?a+Rn.calculate(d,t):Zt(c,t);if(/\s/.test(d)||u<=n){s=c,a=u,l=r.next();continue}if(s)i.push(s.trimEnd()),s="",a=0;else{let m=dm(d,t,n),p=m[m.length-1]??"",f=m.slice(0,-1);i.push(...f),s=p,a=Zt(p,t),l=r.next()}}if(s){let d=cm(s,t,n);i.push(d)}return i},dm=(e,t,n)=>{if(Gr().test(e))return[e];mm(e);let i=[],o=Array.from(e),r="",s=0;for(let a of o){let l=Rn.calculate(a,t),d=s+l;if(d<=n){r=r+a,s=d;continue}r&&i.push(r),r=a,s=l}return r&&i.push(r),i},cm=(e,t,n)=>{if(!(Zt(e,t)>n))return e;let[,o,r]=e.match(/^(.+?)(\s+)$/)??[e,e.trimEnd(),""],s=Zt(o,t);for(let a of Array.from(r)){let l=Rn.calculate(a,t),d=s+l;if(d>n)break;o=o+a,s=d}return o},um=e=>e.codePointAt(0)!==void 0&&e.codePointAt(1)===void 0,mm=e=>{if((nm()||tm())&&/\s/.test(e))throw new Error("Word should not contain any whitespaces!")};var po=(e,t,n)=>{let i=n.getNonDeletedElementsMap(),o;Em()||gm(!t||!z(t)||e.angle===0,"text element angle must be 0 if bound to arrow container");let r={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height,angle:t?z(t)?0:t.angle:e.angle};r.text=e.text,(t||!e.autoResize)&&(o=t?it(t,e):e.width,r.text=vt(e.originalText,mo(e),o));let s=Ue(r.text,mo(e),e.lineHeight);if(e.autoResize&&(r.width=s.width),r.height=s.height,t){let a=pi(t,e),l=it(t,e);if(!z(t)&&s.height>a){let m=Or(s.height,t.type);n.mutateElement(t,{height:m}),_a(t.id,m)}if(s.width>l){let m=Or(s.width,t.type);n.mutateElement(t,{width:m})}let d={...e,...r},{x:c,y:u}=mi(t,d,i);r.x=c,r.y=u}n.mutateElement(e,r)},In=(e,t,n,i=!1)=>{let o=t.getNonDeletedElementsMap();if(!Dt(e))return;Ua(e.id);let s=V(e,o);if(s&&s.text){if(!e)return;let a=s.text,l=s.height,d=s.width,c=it(e,s),u=pi(e,s),m=e.height;if(i||n!=="n"&&n!=="s"){a&&(a=vt(s.originalText,mo(s),c));let p=Ue(a,mo(s),s.lineHeight);l=p.height,d=p.width}if(l>u){m=Or(l,e.type);let p=m-e.height,f=!z(e)&&(n==="ne"||n==="nw"||n==="n")?e.y-p:e.y;t.mutateElement(e,{height:m,y:f})}t.mutateElement(s,{text:a,width:d,height:l}),z(e)||t.mutateElement(s,mi(e,s,o))}},mi=(e,t,n)=>{if(z(e))return O.getBoundTextElementPosition(e,t,n);let i=kr(e),o=pi(e,t),r=it(e,t),s,a;t.verticalAlign===$a.TOP?a=i.y:t.verticalAlign===$a.BOTTOM?a=i.y+(o-t.height):a=i.y+(o/2-t.height/2),t.textAlign===Va.LEFT?s=i.x:t.textAlign===Va.RIGHT?s=i.x+(r-t.width):s=i.x+(r/2-t.width/2);let l=e.angle??0;if(l!==0){let d=Za(i.x+r/2,i.y+o/2),c=Za(s+t.width/2,a+t.height/2),[u,m]=xm(c,d,l);return{x:u-t.width/2,y:m-t.height/2}}return{x:s,y:a}},Dt=e=>e?.boundElements?.length&&e?.boundElements?.find(t=>t.type==="text")?.id||null,V=(e,t)=>{if(!e)return null;let n=Dt(e);return n&&t.get(n)||null},Se=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,Vw=(e,t,n)=>{if(!z(e))return{x:e.x+e.width/2,y:e.y+e.height/2};if(O.getPointsGlobalCoordinates(e,n).length%2===1){let s=Math.floor(e.points.length/2),a=O.getPointGlobalCoordinates(e,e.points[s],n);return{x:a[0],y:a[1]}}let o=e.points.length/2-1,r=O.getEditorMidPoints(e,n,t)[o];return r||(r=O.getSegmentMidPoint(e,o+1)),{x:r[0],y:r[1]}},kr=e=>{let t=ut,n=ut;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),n+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,n+=e.height/4),{x:e.x+t,y:e.y+n}},$w=(e,t)=>z(t)?0:t?t.angle:e.angle,Zw=(e,t,n)=>{if(z(e))return O.getBoundTextElementPosition(e,t,n)},qw=(e,t)=>e.some(n=>{if(ce(n)){let i=Se(n,t);return!z(i)}return!1}),Kw=(e,t)=>e.some(n=>{if(ce(n)){let i=Se(n,t);return!z(i)}return ee(n)}),wm=new Set(["rectangle","ellipse","diamond","arrow"]),Qw=e=>wm.has(e.type),Or=(e,t)=>{e=Math.ceil(e);let n=ut*2;return t==="ellipse"?Math.round((e+n)/Math.sqrt(2)*2):t==="arrow"?e+n*8:t==="diamond"?2*(e+n):e+n},it=(e,t)=>{let{width:n}=e;if(z(e)){let i=(t?.fontSize??hm)*pm;return Math.max(fm*n,i)}return e.type==="ellipse"?Math.round(n/2*Math.sqrt(2))-ut*2:e.type==="diamond"?Math.round(n/2)-ut*2:n-ut*2},pi=(e,t)=>{let{height:n}=e;return z(e)?n-ut*8*2<=0?t.height:n:e.type==="ellipse"?Math.round(n/2*Math.sqrt(2))-ut*2:e.type==="diamond"?Math.round(n/2)-ut*2:n-ut*2},Jw=(e,t=`
3
+ `),i=parseFloat(t),r=v1(o,i,n);return{width:Tl(o,t),height:r}},vl="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),Al=(e,t)=>{let n=A1(e);return n===0?ot(vl.split("").join(`
4
+ `),e,t).width+ki*2:n+ki*2},Ti=(e,t)=>ot("",e,t).width+ki*2,kx=()=>Tl(vl,P1({fontSize:b1,fontFamily:M1}))>0,Bo=e=>S1(e).replace(/\t/g," "),Qr=e=>Bo(e).split(`
5
+ `),Tx=e=>{let t=Qr(e.text).length;return e.height/t/e.fontSize},Li=(e,t)=>e*t,kl=(e,t)=>Li(e,t)+ki*2,Ai,Lx=e=>{Ai=e},Kr=class{canvas;constructor(){this.canvas=document.createElement("canvas")}getLineWidth(t,n){let o=this.canvas.getContext("2d");o.font=n;let r=o.measureText(t).width;return I1()?r*10:r}},mn=(e,t)=>(Ai||(Ai=new Kr),Ai.getLineWidth(e,t)),Tl=(e,t)=>{let n=Qr(e),o=0;return n.forEach(i=>{o=Math.max(o,mn(i,t))}),o},v1=(e,t,n)=>{let o=Qr(e).length;return Li(t,n)*o},Jn=(()=>{let e={};return{calculate:(i,r)=>{let s=i.charCodeAt(0);if(e[r]||(e[r]=[]),!e[r][s]){let a=mn(i,r);e[r][s]=a}return e[r][s]},getCache:i=>e[i],clearCache:i=>{e[i]=[]}}})(),Cx=e=>{let t=Jn.getCache(e);if(!t)return 0;let n=t.filter(o=>o!==void 0);return Math.min(...n)},A1=e=>{let t=Jn.getCache(e);if(!t)return 0;let n=t.filter(o=>o!==void 0);return Math.max(...n)};I();import{isDevEnv as k1,isTestEnv as T1}from"@excalidraw/common";var Jr,Ci,es,Rx=e=>(Jr||(Jr=ie.class(...Object.values(Yt))),Jr.test(e)),L1=()=>{if(!Ci)try{Ci=B1()}catch{Ci=C1()}return Ci},ts=()=>(es||(es=D1()),es),ct={WHITESPACE:/\s/u,HYPHEN:/-/u,OPENING:/<\(\[\{/u,CLOSING:/>\)\]\}.,:;!\?…\//u},Yt={CHAR:/\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}`'^〃〰〆#&*+-ー/\=|¦〒¬ ̄/u,OPENING:/([{〈《⦅「「『【〖〔〘〚<〝/u,CLOSING:/)]}〉》⦆」」』】〗〕〙〛>。.,、〟‥?!:;・〜〞/u,CURRENCY:/¥₩£¢$/u},_n={FLAG:/\p{RI}\p{RI}/u,JOINER:/(?:\p{Emoji_Modifier}|\uFE0F\u20E3?|[\u{E0020}-\u{E007E}]+\u{E007F})?/u,ZWJ:/\u200D/u,ANY:/[\p{Emoji}]/u,MOST:/[\p{Extended_Pictographic}\p{Emoji_Presentation}]/u},C1=()=>ie.or(ts(),Ee.On(ct.HYPHEN,ct.WHITESPACE,Yt.CHAR)),B1=()=>ie.or(ts(),Ee.Before(ct.WHITESPACE).Build(),Ee.After(ct.WHITESPACE,ct.HYPHEN).Build(),Ee.Before(Yt.CHAR,Yt.CURRENCY).NotPrecededBy(ct.OPENING,Yt.OPENING).Build(),Ee.After(Yt.CHAR).NotFollowedBy(ct.HYPHEN,ct.CLOSING,Yt.CLOSING).Build(),Ee.BeforeMany(Yt.OPENING).NotPrecededBy(ct.OPENING).Build(),Ee.AfterMany(Yt.CLOSING).NotFollowedBy(ct.CLOSING).Build(),Ee.AfterMany(ct.CLOSING).FollowedBy(ct.OPENING).Build()),D1=()=>ie.group(ie.or(_n.FLAG,ie.and(_n.MOST,_n.JOINER,ie.build(`(?:${_n.ZWJ.source}(?:${_n.FLAG.source}|${_n.ANY.source}${_n.JOINER.source}))*`)))),ie={build:e=>new RegExp(e,"u"),join:(...e)=>e.map(t=>t.source).join(""),and:(...e)=>ie.build(ie.join(...e)),or:(...e)=>ie.build(e.map(t=>t.source).join("|")),group:(...e)=>ie.build(`(${ie.join(...e)})`),class:(...e)=>ie.build(`[${ie.join(...e)}]`)},Ee={On:(...e)=>{let t=ie.join(...e);return ie.build(`([${t}])`)},Before:(...e)=>{let t=ie.join(...e),n=()=>ie.build(`(?=[${t}])`);return Ee.Chain(n)},After:(...e)=>{let t=ie.join(...e),n=()=>ie.build(`(?<=[${t}])`);return Ee.Chain(n)},BeforeMany:(...e)=>{let t=ie.join(...e),n=()=>ie.build(`(?<![${t}])(?=[${t}])`);return Ee.Chain(n)},AfterMany:(...e)=>{let t=ie.join(...e),n=()=>ie.build(`(?<=[${t}])(?![${t}])`);return Ee.Chain(n)},NotBefore:(...e)=>{let t=ie.join(...e),n=()=>ie.build(`(?![${t}])`);return Ee.Chain(n)},NotAfter:(...e)=>{let t=ie.join(...e),n=()=>ie.build(`(?<![${t}])`);return Ee.Chain(n)},Chain:e=>({Build:e,PreceededBy:(...t)=>{let n=e(),o=Ee.After(...t).Build(),i=()=>ie.and(o,n);return Ee.Chain(i)},FollowedBy:(...t)=>{let n=e(),o=Ee.Before(...t).Build(),i=()=>ie.and(n,o);return Ee.Chain(i)},NotPrecededBy:(...t)=>{let n=e(),o=Ee.NotAfter(...t).Build(),i=()=>ie.and(o,n);return Ee.Chain(i)},NotFollowedBy:(...t)=>{let n=e(),o=Ee.NotBefore(...t).Build(),i=()=>ie.and(n,o);return Ee.Chain(i)}})},G1=e=>{let t=L1();return e.normalize("NFC").split(t).filter(Boolean)},Xt=(e,t,n)=>R1(e,t,n).map(o=>o.text).join(`
6
+ `),O1=e=>{let t=0;return e.split(`
7
+ `).map(n=>{let o=t,i=o+n.length;return t=i+1,{text:n,start:o,end:i}})},R1=(e,t,n)=>{if(!Number.isFinite(n)||n<0)return O1(e);let o=[],i=0;for(let r of e.split(`
8
+ `))mn(r,t)<=n?o.push({text:r,start:i,end:i+r.length}):o.push(...F1(r,t,n,i)),i+=r.length+1;return o},F1=(e,t,n,o)=>{let i=[],r=G1(e),s="",a=o,l=o,d=0,c=o,p=0;for(;p<r.length;){let h=r[p],m=c,f=m+h.length,g=s+h,E=_1(h)?d+Jn.calculate(h,t):mn(g,t);if(/\s/.test(h)||E<=n){s||(a=m),s=g,l=f,d=E,c=f,p++;continue}if(s)i.push(z1(s,a,l)),s="",a=m,l=m,d=0;else{let x=N1(h,t,n,m),y=x[x.length-1]??{text:"",start:m,end:m},w=x.slice(0,-1);i.push(...w),s=y.text,a=y.start,l=y.end,d=mn(y.text,t),c=f,p++}}if(s){let h=H1(s,a,l,t,n);i.push(h)}return i},N1=(e,t,n,o)=>{if(ts().test(e))return[{text:e,start:o,end:o+e.length}];W1(e);let i=[],r=Array.from(e),s="",a=o,l=o,d=0,c=o;for(let p of r){let h=c,m=h+p.length,f=Jn.calculate(p,t),g=d+f;if(g<=n){s||(a=h),s=s+p,l=m,d=g,c=m;continue}s&&i.push({text:s,start:a,end:l}),s=p,a=h,l=m,d=f,c=m}return s&&i.push({text:s,start:a,end:l}),i},H1=(e,t,n,o,i)=>{if(!(mn(e,o)>i))return{text:e,start:t,end:n};let[,s,a]=e.match(/^(.+?)(\s+)$/)??[e,e.trimEnd(),""],l=mn(s,o);for(let d of Array.from(a)){let c=Jn.calculate(d,o),p=l+c;if(p>i)break;s=s+d,l=p}return{text:s,start:t,end:n-(e.length-s.length)}},z1=(e,t,n)=>{let o=e.trimEnd();return{text:o,start:t,end:n-(e.length-o.length)}},_1=e=>e.codePointAt(0)!==void 0&&e.codePointAt(1)===void 0,W1=e=>{if((T1()||k1())&&/\s/.test(e))throw new Error("Word should not contain any whitespaces!")};var Di=(e,t,n)=>{let o=n.getNonDeletedElementsMap(),i;Y1()||X1(!t||!V(t)||e.angle===0,"text element angle must be 0 if bound to arrow container");let r={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height,angle:t?V(t)?0:t.angle:e.angle};r.text=e.text,(t||!e.autoResize)&&(i=t?yt(t,e):e.width,r.text=Xt(e.originalText,Bi(e),i));let s=ot(r.text,Bi(e),e.lineHeight);if(e.autoResize&&(r.width=s.width),r.height=s.height,t){let a=Go(t,e),l=yt(t,e);if(!V(t)&&s.height>a){let h=ns(s.height,t.type);n.mutateElement(t,{height:h}),Il(t.id,h)}if(s.width>l){let h=ns(s.width,t.type);n.mutateElement(t,{width:h})}let d={...e,...r},{x:c,y:p}=Do(t,d,o);r.x=c,r.y=p}n.mutateElement(e,r)},Wn=(e,t,n,o=!1)=>{let i=t.getNonDeletedElementsMap();if(!$t(e))return;Sl(e.id);let s=J(e,i);if(s&&s.text){if(!e)return;let a=s.text,l=s.height,d=s.width,c=yt(e,s),p=Go(e,s),h=e.height;if(o||n!=="n"&&n!=="s"){a&&(a=Xt(s.originalText,Bi(s),c));let m=ot(a,Bi(s),s.lineHeight);l=m.height,d=m.width}if(l>p){h=ns(l,e.type);let m=h-e.height,f=!V(e)&&(n==="ne"||n==="nw"||n==="n")?e.y-m:e.y;t.mutateElement(e,{height:h,y:f})}t.mutateElement(s,{text:a,width:d,height:l}),V(e)||t.mutateElement(s,Do(e,s,i))}},Do=(e,t,n)=>{if(V(e))return G.getBoundTextElementPosition(e,t,n);let o=os(e),i=Go(e,t),r=yt(e,t),s,a;t.verticalAlign===Cl.TOP?a=o.y:t.verticalAlign===Cl.BOTTOM?a=o.y+(i-t.height):a=o.y+(i/2-t.height/2),t.textAlign===Ll.LEFT?s=o.x:t.textAlign===Ll.RIGHT?s=o.x+(r-t.width):s=o.x+(r/2-t.width/2);let l=e.angle??0;if(l!==0){let d=Bl(o.x+r/2,o.y+i/2),c=Bl(s+t.width/2,a+t.height/2),[p,h]=$1(c,d,l);return{x:p-t.width/2,y:h-t.height/2}}return{x:s,y:a}},$t=e=>e?.boundElements?.length&&e?.boundElements?.find(t=>t.type==="text")?.id||null,J=(e,t)=>{if(!e)return null;let n=$t(e);return n&&t.get(n)||null},De=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,Yx=(e,t,n)=>{if(!V(e))return{x:e.x+e.width/2,y:e.y+e.height/2};if(G.getPointsGlobalCoordinates(e,n).length%2===1){let s=Math.floor(e.points.length/2),a=G.getPointGlobalCoordinates(e,e.points[s],n);return{x:a[0],y:a[1]}}let i=e.points.length/2-1,r=G.getEditorMidPoints(e,n,t)[i];return r||(r=G.getSegmentMidPoint(e,i+1)),{x:r[0],y:r[1]}},os=e=>{let t=Lt,n=Lt;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),n+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,n+=e.height/4),{x:e.x+t,y:e.y+n}},Xx=(e,t)=>V(t)?0:t?t.angle:e.angle,$x=(e,t,n)=>{if(V(e))return G.getBoundTextElementPosition(e,t,n)},Zx=(e,t)=>e.some(n=>{if(ge(n)){let o=De(n,t);return!V(o)}return!1}),qx=(e,t)=>e.some(n=>{if(ge(n)){let o=De(n,t);return!V(o)}return ee(n)}),Z1=new Set(["rectangle","ellipse","diamond","arrow"]),Kx=e=>Z1.has(e.type),ns=(e,t)=>{e=Math.ceil(e);let n=Lt*2;return t==="ellipse"?Math.round((e+n)/Math.sqrt(2)*2):t==="arrow"?e+n*8:t==="diamond"?2*(e+n):e+n},yt=(e,t)=>{let{width:n}=e;if(V(e)){let o=(t?.fontSize??U1)*j1;return Math.max(V1*n,o)}return e.type==="ellipse"?Math.round(n/2*Math.sqrt(2))-Lt*2:e.type==="diamond"?Math.round(n/2)-Lt*2:n-Lt*2},Go=(e,t)=>{let{height:n}=e;return V(e)?n-Lt*8*2<=0?t.height:n:e.type==="ellipse"?Math.round(n/2*Math.sqrt(2))-Lt*2:e.type==="diamond"?Math.round(n/2)-Lt*2:n-Lt*2},Qx=(e,t=`
8
9
 
9
- `)=>e.reduce((i,o)=>(ee(o)&&i.push(o.text),i),[]).join(t);P();import{curvePointDistance as Rr,distanceToLineSegment as Fr,pointRotateRads as Nr}from"@excalidraw/math";import{ellipse as ym,ellipseDistanceFromPoint as bm}from"@excalidraw/math/ellipse";var Sn=(e,t,n)=>{switch(e.type){case"selection":case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return Pm(e,t,n);case"diamond":return Im(e,t,n);case"ellipse":return Sm(e,t,n);case"line":case"arrow":case"freedraw":return Mm(e,n)}},Pm=(e,t,n)=>{let i=de(e,t),o=Nr(n,i,-e.angle),[r,s]=Vt(e);return Math.min(...r.map(a=>Fr(o,a)),...s.map(a=>Rr(a,o)).filter(a=>a!==null))},Im=(e,t,n)=>{let i=de(e,t),o=Nr(n,i,-e.angle),[r,s]=$t(e);return Math.min(...r.map(a=>Fr(o,a)),...s.map(a=>Rr(a,o)).filter(a=>a!==null))},Sm=(e,t,n)=>{let i=de(e,t);return bm(Nr(n,i,-e.angle),ym(i,e.width/2,e.height/2))},Mm=(e,t)=>{let[n,i]=ro(e);return Math.min(...n.map(o=>Fr(t,o)),...i.map(o=>Rr(o,t)))};var ho=e=>{if(e.type==="arrow")return!1;let t=!Ka(e.backgroundColor)||ct(e)||io(e)||ee(e);return e.type==="line"?t&&bn(e.points):e.type==="freedraw"?t&&bn(e.points):t||xe(e)},Om=({point:e,element:t,threshold:n,elementsMap:i,frameNameBound:o=null,overrideShouldTestInside:r=!1})=>{let s=o?fo(me(o.x-n,o.y-n),e,me(o.x+o.width+n,o.y+o.height+n)):!1,a=ae(t,i,!0);return!fo(me(a[0]-n,a[1]-n),Ye(e,mt(a),-t.angle),me(a[2]+n,a[3]+n))&&!s?!1:(r||ho(t))&&At(e,t,i)||qa(e,t,i,n)||s},km=(e,t,n,i=0)=>{let[o,r,s,a]=ae(t,n);return o-=i,r-=i,s+=i,a+=i,fo(me(o,r),e,me(s,a))},xy=(e,t)=>!Om(e)&&!Rm(e.point,e.element,t)&&km(e.point,e.element,t),Rm=(e,t,n)=>{let i=V(t,n);if(!i)return!1;let o=Q(t)?{...i,...O.getBoundTextElementPosition(t,i,n)}:i;return At(e,o,n)},Fm=(e,[t,n],i,o=0)=>{let r=me(t,n),s=!K(e),a=Math.max(1,o),l=[t-a,n-a,t+a,n+a],d=ae(e,i);if(!Mn(l,d))return!1;if(e.frameId){let m=i.get(e.frameId);if(m&&K(m)){let p=ae(m,i);if(!Kt(r,p))return!1}}let c=qt(e,i,fi(de(e,i),r)),u=Sn(e,i,r);return s?c.length===0||u<=o:c.length>0&&u<=a},Eo=(e,t,n,i)=>{let o=[];for(let r=t.length-1;r>=0;--r){let s=t[r];if(Am(!s.isDeleted,"Elements in the function parameter for getAllElementsAtPositionForBinding() should not contain deleted elements"),Ge(s,!1)&&Fm(s,e,n,i?.(s))&&(o.push(s),!Ka(s.backgroundColor)))break}return o},Lt=(e,t,n,i)=>{let o=Eo(e,t,n,i);return!o||o.length===0?null:o.length===1?o[0]:o.sort((r,s)=>s.width**2+s.height**2-(r.width**2+r.height**2)).pop()},qt=(e,t,n,i=0,o=!1)=>{let r=[Math.min(n[0][0]-i,n[1][0]-i),Math.min(n[0][1]-i,n[1][1]-i),Math.max(n[0][0]+i,n[1][0]+i),Math.max(n[0][1]+i,n[1][1]+i)],s=ae(e,t);if(!Mn(r,s))return[];switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"selection":case"magicframe":return zm(e,t,n,i,o);case"diamond":return Hm(e,t,n,i,o);case"ellipse":return _m(e,t,n,i);case"line":case"freedraw":case"arrow":return Nm(e,n,o)}},el=(e,t,n,i,o,r=!1)=>{for(let s of e){let a=go(s[0],s[1],s[2],s[3]),l=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])];if(!Mn(a,l))continue;let d=Qa(s,t);if(d.length>0){for(let c of d)n.push(Ye(c,i,o));if(r)return n}}return n},tl=(e,t,n,i,o,r=!1)=>{for(let s of e){let a=Ja(s,t);if(a&&(n.push(Ye(a,i,o)),r))return n}return n},Nm=(e,t,n=!1)=>{let[i,o]=ro(e),r=[];for(let s of i){let a=Ja(s,t);if(a&&(r.push(a),n))return r}for(let s of o){let a=go(s[0],s[1],s[2],s[3]),l=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])];if(!Mn(a,l))continue;let d=Qa(s,t);if(d.length>0&&(r.push(...d),n))return r}return r},zm=(e,t,n,i=0,o=!1)=>{let r=de(e,t),s=Ye(n[0],r,-e.angle),a=Ye(n[1],r,-e.angle),l=fi(s,a),[d,c]=Vt(e,i),u=[];return tl(d,l,u,r,e.angle,o),o&&u.length>0||el(c,l,u,r,e.angle,o),u},Hm=(e,t,n,i=0,o=!1)=>{let r=de(e,t),s=Ye(n[0],r,-e.angle),a=Ye(n[1],r,-e.angle),l=fi(s,a),[d,c]=$t(e,i),u=[];return tl(d,l,u,r,e.angle,o),o&&u.length>0||el(c,l,u,r,e.angle,o),u},_m=(e,t,n,i=0)=>{let o=de(e,t),r=Ye(n[0],o,-e.angle),s=Ye(n[1],o,-e.angle);return Gm(Cm(o,e.width/2+i,e.height/2+i),fi(r,s)).map(a=>Ye(a,o,e.angle))},qa=(e,t,n,i=1)=>Sn(t,n,e)<=i,At=(e,t,n)=>{if((Q(t)||Ie(t))&&!bn(t.points))return!1;let[i,o,r,s]=ae(t,n);if(!fo(me(i,o),e,me(r,s)))return!1;let a=me((i+r)/2,(o+s)/2),l=Tm(Bm(Lm(Dm(e,a,.1)),Math.max(t.width,t.height)*2),a),d=fi(e,l);return qt(t,n,d).filter((u,m,p)=>p.findIndex(f=>vm(f,u))===m).length%2===1},zr=(e,t,n)=>{let i=(s,a)=>{let{x:l,y:d,width:c,height:u,angle:m}=s,p=de(s,n);if(s.type==="diamond"){let[h,E,g,x,w,b,y,I]=kn(s);return[me(l+h,d+E-a),me(l+g+a,d+x),me(l+w,d+b+a),me(l+y-a,d+I)].map(A=>Ye(A,p,m))}if(s.type==="ellipse"){let h=l+c/2,E=d+u/2,g=c/2,x=u/2;return[me(h,E-x-a),me(h+g+a,E),me(h,E+x+a),me(h-g-a,E)].map(b=>Ye(b,p,m))}return[me(l-a,d-a),me(l+c+a,d-a),me(l+c+a,d+u+a),me(l-a,d+u+a)].map(h=>Ye(h,p,m))},o=-1*Math.max(e.width,e.height)/20;return i(e,o).every(s=>At(s,t,n))};P();import{invariant as nl,isDevEnv as Um,isTestEnv as Ym}from"@excalidraw/common";import{pointFrom as Qt,pointFromVector as xo,pointRotateRads as wo,pointScaleFromOrigin as yo,pointsEqual as Wm,triangleIncludesPoint as Hr,vectorCross as Oe,vectorFromPoint as J,vectorScale as bo}from"@excalidraw/math";var fe=[1,0],we=[0,1],Re=[-1,0],We=[0,-1],Bt=e=>{let[t,n]=e,i=Math.abs(t),o=Math.abs(n);return t>o?fe:t<=-o?Re:n>i?we:We},ke=(e,t)=>Bt(J(e,t)),ot=(e,t)=>Fe(ke(e,t)),pe=(e,t)=>e[0]===t[0]&&e[1]===t[1],Fe=e=>pe(e,fe)||pe(e,Re),Sy=e=>!Fe(e),Xm=(e,t,n)=>{let i=mt(t);(Um()||Ym())&&(nl(e.width>0&&e.height>0,"Diamond element has no width or height"),nl(!Wm(i,n),"The point is too close to the element mid point to determine heading"));let o=.95,r=xo(bo(J(wo(Qt(e.x+e.width/2,e.y),i,e.angle),i),o),i),s=xo(bo(J(wo(Qt(e.x+e.width,e.y+e.height/2),i,e.angle),i),o),i),a=xo(bo(J(wo(Qt(e.x+e.width/2,e.y+e.height),i,e.angle),i),o),i),l=xo(bo(J(wo(Qt(e.x,e.y+e.height/2),i,e.angle),i),o),i);if(Oe(J(n,r),J(r,s))<=0&&Oe(J(n,r),J(r,l))>0)return ke(r,i);if(Oe(J(n,s),J(s,a))<=0&&Oe(J(n,s),J(s,r))>0)return ke(s,i);if(Oe(J(n,a),J(a,l))<=0&&Oe(J(n,a),J(a,s))>0)return ke(a,i);if(Oe(J(n,l),J(l,r))<=0&&Oe(J(n,l),J(l,a))>0)return ke(l,i);if(Oe(J(n,i),J(r,i))<=0&&Oe(J(n,i),J(s,i))>0){let c=e.width>e.height?r:s;return ke(c,i)}else if(Oe(J(n,i),J(s,i))<=0&&Oe(J(n,i),J(a,i))>0){let c=e.width>e.height?a:s;return ke(c,i)}else if(Oe(J(n,i),J(a,i))<=0&&Oe(J(n,i),J(l,i))>0){let c=e.width>e.height?a:l;return ke(c,i)}let d=e.width>e.height?r:l;return ke(d,i)},hi=(e,t,n)=>{let o=mt(t);if(e.type==="diamond")return Xm(e,t,n);let r=yo(Qt(t[0],t[1]),o,2),s=yo(Qt(t[2],t[1]),o,2),a=yo(Qt(t[0],t[3]),o,2),l=yo(Qt(t[2],t[3]),o,2);return Hr([r,s,o],n)?We:Hr([s,l,o],n)?fe:Hr([l,a,o],n)?we:Re},_r=e=>[e[0]===0?0:e[0]>0?-1:1,e[1]===0?0:e[1]>0?-1:1];P();import{getSizeFromPoints as dp,randomInteger as Kr,getUpdatedTimestamp as Qr}from"@excalidraw/common";P();import{clamp as Po,pointDistance as Wr,pointFrom as X,pointScaleFromOrigin as jm,pointsEqual as gi,pointTranslate as Yr,vector as pt,vectorCross as Io,vectorFromPoint as Xr,vectorScale as Vm}from"@excalidraw/math";import{BinaryHeap as $m,invariant as Fn,isAnyTrue as Zm,getSizeFromPoints as il,isDevEnv as qm,arrayToMap as Km}from"@excalidraw/common";var jr=1,ne=40,Qm=(e,t)=>{let n=e.fixedSegments?e.fixedSegments.slice():null;if(n){let i=[];e.points.map(s=>X(e.x+s[0],e.y+s[1])).forEach((s,a,l)=>{if(a<2)return i.push(s);let d=ke(s,l[a-1]),c=ke(l[a-1],l[a-2]);if(pe(d,c)){let u=n?.findIndex(p=>p.index===a-1)??-1,m=n?.findIndex(p=>p.index===a)??-1;m!==-1&&(n[m].start=X(l[a-2][0]-e.x,l[a-2][1]-e.y)),u!==-1&&n.splice(u,1),i.splice(-1,1),n.forEach(p=>{p.index>a-1&&(p.index-=1)})}return i.push(s)});let o=[];i.forEach((s,a,l)=>{if(a<3)return o.push(s);if(Wr(l[a-2],l[a-1])<jr){let d=n?.findIndex(m=>m.index===a-2)??-1,c=n?.findIndex(m=>m.index===a-1)??-1;c!==-1&&n.splice(c,1),d!==-1&&n.splice(d,1),o.splice(-2,2),n.forEach(m=>{m.index>a-2&&(m.index-=2)});let u=ot(s,l[a-1]);return o.push(X(u?s[0]:l[a-2][0],u?l[a-2][1]:s[1]))}o.push(s)});let r=n.filter(s=>s.index!==1&&s.index!==o.length-1);return r.length===0?Gt(Zr(qr($r(e,Vr(e,t,o.map(s=>X(s[0]-e.x,s[1]-e.y))))??[])),r,null,null):(qm()&&Fn(cl(o),"Invalid elbow points with fixed segments"),Gt(o,r,e.startIsSpecial,e.endIsSpecial))}return{x:e.x,y:e.y,points:e.points,fixedSegments:e.fixedSegments,startIsSpecial:e.startIsSpecial,endIsSpecial:e.endIsSpecial}},Jm=(e,t,n)=>{let i=t.map(M=>M.index),r=(e.fixedSegments?.map(M=>M.index)??[]).findIndex(M=>!i.includes(M));if(r===-1||!e.fixedSegments?.[r])return{points:e.points};let s=e.fixedSegments[r].index,a=e.fixedSegments[r-1],l=e.fixedSegments[r+1],d=e.x+(a?a.end[0]:0),c=e.y+(a?a.end[1]:0),u=a?null:e.startBinding,m=l?null:e.endBinding,{startHeading:p,endHeading:f,startGlobalPoint:h,endGlobalPoint:E,hoveredStartElement:g,hoveredEndElement:x,...w}=Vr({x:d,y:c,startBinding:u,endBinding:m,startArrowhead:null,endArrowhead:null,points:e.points},n,[X(0,0),X(e.x+(l?.start[0]??e.points[e.points.length-1][0])-d,e.y+(l?.start[1]??e.points[e.points.length-1][1])-c)],{isDragging:!1}),{points:b}=Gt(Zr(qr($r(e,{startHeading:p,endHeading:f,startGlobalPoint:h,endGlobalPoint:E,hoveredStartElement:g,hoveredEndElement:x,...w})??[])),t,null,null);if(!b||b.length<2)throw new Error("Property 'points' is required in the update returned by normalizeArrowElementUpdate()");let y=[];if(a)for(let M=0;M<a.index;M++)y.push(X(e.x+e.points[M][0],e.y+e.points[M][1]));if(b.forEach(M=>{y.push(X(e.x+(a?a.end[0]:0)+M[0],e.y+(a?a.end[1]:0)+M[1]))}),l)for(let M=l.index;M<e.points.length;M++)y.push(X(e.x+e.points[M][0],e.y+e.points[M][1]));let I=(l?.index??e.points.length)-(a?.index??0)-1,S=t.map(M=>M.index>s?{...M,index:M.index-I+(b.length-1)}:M),A=y.flatMap((M,k)=>{let L=y[k-1],G=y[k+1];if(L&&G){let B=ke(M,L),U=ke(G,M);if(pe(B,U))return S.forEach(N=>{N.index>k&&(N.index-=1)}),[];if(pe(B,_r(U)))return S.forEach(N=>{N.index>k&&(N.index+=1)}),[M,M]}return[M]});return Gt(A,S,!1,!1)},ep=(e,t,n,i,o,r)=>{let s=t.map((y,I)=>e.fixedSegments==null||e.fixedSegments[I]===void 0||e.fixedSegments[I].index!==y.index||(y.start[0]!==e.fixedSegments[I].start[0]&&y.end[0]!==e.fixedSegments[I].end[0])!=(y.start[1]!==e.fixedSegments[I].start[1]&&y.end[1]!==e.fixedSegments[I].end[1])?I:null).filter(y=>y!==null).shift();if(s==null)return{points:e.points};let a=e.fixedSegments?.findIndex(y=>y.index===1)??-1,l=e.fixedSegments?.findIndex(y=>y.index===e.points.length-1)??-1,d=Wr(t[s].start,t[s].end),c=d<ne+5;if(a===-1&&t[s].index===1&&o){let y=Fe(n),S=(y?pe(n,fe):pe(n,we))?c?d/2:ne:c?-d/2:-ne;t[s].start=X(t[s].start[0]+(y?S:0),t[s].start[1]+(y?0:S))}if(l===-1&&t[s].index===e.points.length-1&&r){let y=Fe(i),S=(y?pe(i,fe):pe(i,we))?c?d/2:ne:c?-d/2:-ne;t[s].end=X(t[s].end[0]+(y?S:0),t[s].end[1]+(y?0:S))}let u=t.map(y=>({...y,start:X(e.x+y.start[0],e.y+y.start[1]),end:X(e.x+y.end[0],e.y+y.end[1])})),m=e.points.map((y,I)=>X(e.x+y[0],e.y+y[1])),p=u[s].index-1,f=u[s].index,h=u[s].start,E=u[s].end,g=m[p-1]&&!gi(m[p],m[p-1])?ot(m[p-1],m[p]):void 0,x=m[f+1]&&!gi(m[f],m[f+1])?ot(m[f+1],m[f]):void 0;if(g!==void 0){let y=g?1:0;m[p-1][y]=h[y]}if(m[p]=h,m[f]=E,x!==void 0){let y=x?1:0;m[f+1][y]=E[y]}let w=u.findIndex(y=>y.index===p);if(w!==-1){let y=ot(u[w].end,u[w].start)?1:0;u[w].start[y]=h[y],u[w].end=h}let b=u.findIndex(y=>y.index===f+1);if(b!==-1){let y=ot(u[b].end,u[b].start)?1:0;u[b].end[y]=E[y],u[b].start=E}if(a===-1&&p===0){let y=o?Fe(n):ot(m[1],m[0]);m.unshift(X(y?h[0]:e.x+e.points[0][0],y?e.y+e.points[0][1]:h[1])),o&&m.unshift(X(e.x+e.points[0][0],e.y+e.points[0][1]));for(let I of u)I.index+=o?2:1}if(l===-1&&f===e.points.length-1){let y=Fe(i);m.push(X(y?E[0]:e.x+e.points[e.points.length-1][0],y?e.y+e.points[e.points.length-1][1]:E[1])),r&&m.push(X(e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]))}return Gt(m,u.map(y=>({...y,start:X(y.start[0]-e.x,y.start[1]-e.y),end:X(y.end[0]-e.x,y.end[1]-e.y)})),!1,!1)},tp=(e,t,n,i,o,r,s,a,l)=>{let d=e.startIsSpecial??null,c=e.endIsSpecial??null,u=t.map((E,g)=>g===0?X(e.x+E[0],e.y+E[1]):g===t.length-1?X(e.x+E[0],e.y+E[1]):X(e.x+e.points[g][0],e.y+e.points[g][1])),m=n.map(E=>({...E,start:X(e.x+(E.start[0]-t[0][0]),e.y+(E.start[1]-t[0][1])),end:X(e.x+(E.end[0]-t[0][0]),e.y+(E.end[1]-t[0][1]))})),p=[],f=2+(d?1:0),h=2+(c?1:0);for(;p.length+f<u.length-h;)p.push(u[p.length+f]);{let E=u.at(d?2:1),g=u.at(d?3:2);if(!E||!g)throw new Error(`Second and third points must exist when handling endpoint drag (${d})`);let x=Fe(i),w=Fe(Bt(Xr(E,g)));if(a&&x===w){let b=x?pe(i,fe):pe(i,we);if(p.unshift(X(w?r[0]+(b?ne:-ne):g[0],w?g[1]:r[1]+(b?ne:-ne))),p.unshift(X(x?r[0]+(b?ne:-ne):r[0],x?r[1]:r[1]+(b?ne:-ne))),!d){d=!0;for(let y of m)y.index>1&&(y.index+=1)}}else if(p.unshift(X(w?r[0]:E[0],w?E[1]:r[1])),d){d=!1;for(let b of m)b.index>1&&(b.index-=1)}p.unshift(r)}{let E=u.at(u.length-(c?3:2)),g=u.at(u.length-(c?4:3));if(!E||!g)throw new Error(`Second and third to last points must exist when handling endpoint drag (${c})`);let x=Fe(o),w=ot(g,E);if(l&&x===w){let b=x?pe(o,fe):pe(o,we);p.push(X(w?s[0]+(b?ne:-ne):g[0],w?g[1]:s[1]+(b?ne:-ne))),p.push(X(x?s[0]+(b?ne:-ne):s[0],x?s[1]:s[1]+(b?ne:-ne))),c||(c=!0)}else p.push(X(w?s[0]:E[0],w?E[1]:s[1])),c&&(c=!1)}return p.push(s),Gt(p,m.map(({index:E})=>({index:E,start:p[E-1],end:p[E]})).map(E=>({...E,start:X(E.start[0]-r[0],E.start[1]-r[1]),end:X(E.end[0]-r[0],E.end[1]-r[1])})),d,c)},Jt=1e6,Nn=(e,t,n,i)=>{if(e.points.length<2)return{points:n.points??e.points};v.PROD||(Fn(!n.points||n.points.length>=2,"Updated point array length must match the arrow point length, contain exactly the new start and end points or not be specified at all (i.e. you can't add new points between start and end manually to elbow arrows)"),Fn(!e.fixedSegments||e.fixedSegments.map(y=>y.start[0]===y.end[0]||y.start[1]===y.end[1]).every(Boolean),"Fixed segments must be either horizontal or vertical"),Fn(!n.fixedSegments||n.fixedSegments.map(y=>y.start[0]===y.end[0]||y.start[1]===y.end[1]).every(Boolean),"Updates to fixed segments must be either horizontal or vertical"),Fn(e.points.slice(1).map((y,I)=>y[0]===e.points[I][0]||y[1]===e.points[I][1]),"Elbow arrow segments must be either horizontal or vertical"),Fn(n.fixedSegments?.find(y=>y.index===1&&gi(y.start,(n.points??e.points)[0]))==null&&n.fixedSegments?.find(y=>y.index===(n.points??e.points).length-1&&gi(y.end,(n.points??e.points)[(n.points??e.points).length-1]))==null,"The first and last segments cannot be fixed"));let o=n.fixedSegments??e.fixedSegments??[],r=n.points?n.points&&n.points.length===2?e.points.map((y,I)=>I===0?n.points[0]:I===e.points.length-1?n.points[1]:y):n.points.slice():e.points.slice(),{startBinding:s,endBinding:a,...l}=n,d=typeof s<"u"?s:e.startBinding,c=typeof a<"u"?a:e.endBinding,u=d&&Mo(d.elementId,t),m=c&&Mo(c.elementId,t),p=cl(r);if(d&&!u&&p||c&&!m&&p||t.size===0&&p||Object.keys(l).length===0&&(u?.id!==d?.elementId||m?.id!==c?.elementId))return Gt(r.map(y=>X(e.x+y[0],e.y+y[1])),e.fixedSegments,e.startIsSpecial,e.endIsSpecial);let{startHeading:f,endHeading:h,startGlobalPoint:E,endGlobalPoint:g,hoveredStartElement:x,hoveredEndElement:w,...b}=Vr({x:e.x,y:e.y,startBinding:d,endBinding:c,startArrowhead:e.startArrowhead,endArrowhead:e.endArrowhead,points:e.points},t,r,i);return t.size===0&&p?Gt(r.map(y=>X(e.x+y[0],e.y+y[1])),e.fixedSegments,e.startIsSpecial,e.endIsSpecial):!n.points&&!n.fixedSegments&&!n.startBinding&&!n.endBinding?Qm(e,t):n.startBinding===e.startBinding&&n.endBinding===e.endBinding&&(n.points??[]).every((y,I)=>gi(y,e.points[I]??X(1/0,1/0)))&&p?{}:o.length===0?Gt(Zr(qr($r(e,{startHeading:f,endHeading:h,startGlobalPoint:E,endGlobalPoint:g,hoveredStartElement:x,hoveredEndElement:w,...b})??[])),o,null,null):(e.fixedSegments?.length??0)>o.length?Jm(e,o,t):n.points?n.points&&n.fixedSegments?n:tp(e,r,o,f,h,E,g,x,w):ep(e,o,f,h,x,w)},Vr=(e,t,n,i)=>{let o=Yr(n[0],pt(e.x,e.y)),r=Yr(n[n.length-1],pt(e.x,e.y)),s=null,a=null;if(i?.isDragging){let y=Array.from(t.values());s=al(o,t,y,i?.zoom)||null,a=al(r,t,y,i?.zoom)||null}else s=e.startBinding&&Mo(e.startBinding.elementId,t)||null,a=e.endBinding&&Mo(e.endBinding.elementId,t)||null;let l=rl({...e,angle:0,type:"arrow",elbowed:!0,points:n},"start",e.startBinding?.fixedPoint,o,s,t,i?.isDragging),d=rl({...e,angle:0,type:"arrow",elbowed:!0,points:n},"end",e.endBinding?.fixedPoint,r,a,t,i?.isDragging),c=sl(l,d,s,o,t,i?.zoom),u=sl(d,l,a,r,t,i?.zoom),m=[l[0]-2,l[1]-2,l[0]+2,l[1]+2],p=[d[0]-2,d[1]-2,d[0]+2,d[1]+2],f=s?Ke(s,t,en(c,e.startArrowhead?Ct(s,{elbowed:!0})*6:Ct(s,{elbowed:!0})*2,1)):m,h=a?Ke(a,t,en(u,e.endArrowhead?Ct(a,{elbowed:!0})*6:Ct(a,{elbowed:!0})*2,1)):p,E=Kt(l,a?Ke(a,t,en(u,ne,ne)):p)||Kt(d,s?Ke(s,t,en(c,ne,ne)):m),g=dl(E?[m,p]:[f,h]),x=op(E?m:f,E?p:h,g,E?en(c,!s&&!a?0:ne,0):en(c,!s&&!a?0:ne-(e.startArrowhead?An*6:An*2),ne),E?en(u,!s&&!a?0:ne,0):en(u,!s&&!a?0:ne-(e.endArrowhead?An*6:An*2),ne),E,s&&Ke(s,t),a&&Ke(a,t)),w=ol(x[0],c,l),b=ol(x[1],u,d);return{dynamicAABBs:x,startDonglePosition:w,startGlobalPoint:l,startHeading:c,endDonglePosition:b,endGlobalPoint:d,endHeading:u,commonBounds:g,hoveredStartElement:s,hoveredEndElement:a,boundsOverlap:E,startElementBounds:f,endElementBounds:h}},$r=(e,t)=>{let{dynamicAABBs:n,startDonglePosition:i,startGlobalPoint:o,startHeading:r,endDonglePosition:s,endGlobalPoint:a,endHeading:l,commonBounds:d,hoveredEndElement:c}=t,u=rp(n,i||o,r,s||a,l,d),m=i&&So(i,u),p=s&&So(s,u),f=So(a,u);f&&c&&(f.closed=!0);let h=So(o,u);h&&e.startBinding&&(h.closed=!0);let E=m&&p&&(Kt(m.pos,n[1])||Kt(p.pos,n[0])),g=np(m||h,p||f,u,r||fe,l||fe,E?[]:n);if(g){let x=g.map(w=>[w.pos[0],w.pos[1]]);return m&&x.unshift(o),p&&x.push(a),x}return null},en=(e,t,n)=>{switch(e){case We:return[t,n,n,n];case fe:return[n,t,n,n];case we:return[n,n,t,n]}return[n,n,n,t]},np=(e,t,n,i,o,r)=>{let s=Ur(e.pos,t.pos),a=new $m(l=>l.f);for(a.push(e);a.size()>0;){let l=a.pop();if(!l||l.closed)continue;if(l===t)return ip(e,l);l.closed=!0;let d=ap(l.addr,n);for(let c=0;c<4;c++){let u=d[c];if(!u||u.closed)continue;let m=jm(u.pos,l.pos,.5);if(Zm(...r.map(b=>Kt(m,b))))continue;let p=lp(c),f=l.parent?Bt(Xr(l.pos,l.parent.pos)):i,h=_r(f);if(pe(h,p)||ll(e.addr,u.addr)&&pe(p,i)||ll(t.addr,u.addr)&&pe(p,o))continue;let g=f!==p,x=l.g+Ur(u.pos,l.pos)+(g?Math.pow(s,3):0),w=u.visited;if(!w||x<u.g){let b=sp(u,t,p,o);u.visited=!0,u.parent=l,u.h=Ur(t.pos,u.pos)+b*Math.pow(s,2),u.g=x,u.f=u.g+u.h,w?a.rescoreElement(u):a.push(u)}}}return null},ip=(e,t)=>{let n=t,i=[];for(;n.parent;)i.unshift(n),n=n.parent;return i.unshift(e),i},Ur=(e,t)=>Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1]),op=(e,t,n,i,o,r,s,a)=>{let l=s??e,d=a??t,[c,u,m,p]=i??[0,0,0,0],[f,h,E,g]=o??[0,0,0,0],x=[e[0]>t[2]?e[1]>t[3]||e[3]<t[1]?Math.min((l[0]+d[2])/2,e[0]-p):(l[0]+d[2])/2:e[0]>t[0]?e[0]-p:n[0]-p,e[1]>t[3]?e[0]>t[2]||e[2]<t[0]?Math.min((l[1]+d[3])/2,e[1]-c):(l[1]+d[3])/2:e[1]>t[1]?e[1]-c:n[1]-c,e[2]<t[0]?e[1]>t[3]||e[3]<t[1]?Math.max((l[2]+d[0])/2,e[2]+u):(l[2]+d[0])/2:e[2]<t[2]?e[2]+u:n[2]+u,e[3]<t[1]?e[0]>t[2]||e[2]<t[0]?Math.max((l[3]+d[1])/2,e[3]+m):(l[3]+d[1])/2:e[3]<t[3]?e[3]+m:n[3]+m],w=[t[0]>e[2]?t[1]>e[3]||t[3]<e[1]?Math.min((d[0]+l[2])/2,t[0]-g):(d[0]+l[2])/2:t[0]>e[0]?t[0]-g:n[0]-g,t[1]>e[3]?t[0]>e[2]||t[2]<e[0]?Math.min((d[1]+l[3])/2,t[1]-f):(d[1]+l[3])/2:t[1]>e[1]?t[1]-f:n[1]-f,t[2]<e[0]?t[1]>e[3]||t[3]<e[1]?Math.max((d[2]+l[0])/2,t[2]+h):(d[2]+l[0])/2:t[2]<e[2]?t[2]+h:n[2]+h,t[3]<e[1]?t[0]>e[2]||t[2]<e[0]?Math.max((d[3]+l[1])/2,t[3]+E):(d[3]+l[1])/2:t[3]<e[3]?t[3]+E:n[3]+E],b=dl([x,w]);if(!r&&x[2]-x[0]+w[2]-w[0]>b[2]-b[0]+1e-11&&x[3]-x[1]+w[3]-w[1]>b[3]-b[1]+1e-11){let[y,I]=[(w[0]+w[2])/2,(w[1]+w[3])/2];if(t[0]>e[2]&&e[1]>t[3]){let S=x[2]+(w[0]-x[2])/2,A=w[3]+(x[1]-w[3])/2;return Io(pt(e[2]-y,e[1]-I),pt(e[0]-y,e[3]-I))>0?[[x[0],x[1],S,x[3]],[S,w[1],w[2],w[3]]]:[[x[0],A,x[2],x[3]],[w[0],w[1],w[2],A]]}else if(e[2]<t[0]&&e[3]<t[1]){let S=x[2]+(w[0]-x[2])/2,A=x[3]+(w[1]-x[3])/2;return Io(pt(e[0]-y,e[1]-I),pt(e[2]-y,e[3]-I))>0?[[x[0],x[1],x[2],A],[w[0],A,w[2],w[3]]]:[[x[0],x[1],S,x[3]],[S,w[1],w[2],w[3]]]}else if(e[0]>t[2]&&e[3]<t[1]){let S=w[2]+(x[0]-w[2])/2,A=x[3]+(w[1]-x[3])/2;return Io(pt(e[2]-y,e[1]-I),pt(e[0]-y,e[3]-I))>0?[[S,x[1],x[2],x[3]],[w[0],w[1],S,w[3]]]:[[x[0],x[1],x[2],A],[w[0],A,w[2],w[3]]]}else if(e[0]>t[2]&&e[1]>t[3]){let S=w[2]+(x[0]-w[2])/2,A=w[3]+(x[1]-w[3])/2;return Io(pt(e[0]-y,e[1]-I),pt(e[2]-y,e[3]-I))>0?[[S,x[1],x[2],x[3]],[w[0],w[1],S,w[3]]]:[[x[0],A,x[2],x[3]],[w[0],w[1],w[2],A]]}}return[x,w]},rp=(e,t,n,i,o,r)=>{let s=new Set,a=new Set;n===Re||n===fe?a.add(t[1]):s.add(t[0]),o===Re||o===fe?a.add(i[1]):s.add(i[0]),e.forEach(c=>{s.add(c[0]),s.add(c[2]),a.add(c[1]),a.add(c[3])}),s.add(r[0]),s.add(r[2]),a.add(r[1]),a.add(r[3]);let l=Array.from(a).sort((c,u)=>c-u),d=Array.from(s).sort((c,u)=>c-u);return{row:l.length,col:d.length,data:l.flatMap((c,u)=>d.map((m,p)=>({f:0,g:0,h:0,closed:!1,visited:!1,parent:null,addr:[p,u],pos:[m,c]})))}},ol=(e,t,n)=>{switch(t){case We:return X(n[0],e[1]);case fe:return X(e[2],n[1]);case we:return X(n[0],e[3])}return X(e[0],n[1])},sp=(e,t,n,i)=>{if(i===fe)switch(n){case fe:return e.pos[0]>=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2;case We:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case we:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Re:return e.pos[1]===t.pos[1]?4:2}else if(i===Re)switch(n){case fe:return e.pos[1]===t.pos[1]?4:2;case We:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case we:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case Re:return e.pos[0]<=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2}else if(i===We)switch(n){case fe:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case We:return e.pos[1]>=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case we:return e.pos[0]===t.pos[0]?4:2;case Re:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3}else if(i===we)switch(n){case fe:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case We:return e.pos[0]===t.pos[0]?4:2;case we:return e.pos[1]<=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case Re:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3}return 0},ap=([e,t],n)=>[Ei([e,t-1],n),Ei([e+1,t],n),Ei([e,t+1],n),Ei([e-1,t],n)],Ei=([e,t],n)=>e<0||e>=n.col||t<0||t>=n.row?null:n.data[t*n.col+e]??null,So=(e,t)=>{for(let n=0;n<t.col;n++)for(let i=0;i<t.row;i++){let o=Ei([n,i],t);if(o&&e[0]===o.pos[0]&&e[1]===o.pos[1])return o}return null},dl=e=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1])),Math.max(...e.map(t=>t[2])),Math.max(...e.map(t=>t[3]))],Mo=(e,t)=>{let n=t.get(e);return n&&Ge(n)?n:null},Gt=(e,t,n,i)=>{let o=e[0][0],r=e[0][1],s=e.map(a=>Yr(a,Vm(Xr(e[0]),-1)));return(o<-Jt||o>Jt||r<-Jt||r>Jt||o+s[s.length-1][0]<-Jt||r+s[s.length-1][0]>Jt||o+s[s.length-1][1]<-Jt||r+s[s.length-1][1]>Jt)&&console.error("Elbow arrow normalization is outside reasonable bounds (> 1e6)",{x:o,y:r,points:s,...il(s)}),s=s.map(([a,l])=>X(Po(a,-1e6,1e6),Po(l,-1e6,1e6))),{points:s,x:Po(o,-1e6,1e6),y:Po(r,-1e6,1e6),fixedSegments:(t?.length??0)>0?t:null,...il(s),startIsSpecial:n,endIsSpecial:i}},Zr=e=>{if(e.length>1){let t=Math.abs(e[0][1]-e[1][1])<Math.abs(e[0][0]-e[1][0]);return e.filter((n,i)=>{if(i===0||i===e.length-1)return!0;let o=e[i+1],r=Math.abs(n[1]-o[1])<Math.abs(n[0]-o[0]);return t===r?(t=r,!1):(t=r,!0)})}return e},qr=e=>e.length>=4?e.filter((t,n)=>{if(n===0||n===e.length-1)return!0;let i=e[n-1];return Wr(i,t)>jr}):e,lp=e=>{switch(e){case 0:return We;case 1:return fe;case 2:return we}return Re},rl=(e,t,n,i,o,r,s)=>s?o&&r?Ao(e,o,t,r):i:o?tn(n||[0,0],o,r??Km([o])):i,sl=(e,t,n,i,o,r)=>ul(e,t,n,n&&Ke(n,o,Array(4).fill(Sn(n,o,e))),i,o,r),al=(e,t,n,i)=>Lt(e,n,t,o=>xi(i)),ll=(e,t)=>e[0]===t[0]&&e[1]===t[1],cl=(e,t=jr)=>e.slice(1).map((n,i)=>Math.abs(n[0]-e[i][0])<t||Math.abs(n[1]-e[i][1])<t).every(Boolean);var ye=(e,t,n,i)=>{let o=!1,{points:r,fixedSegments:s,fileId:a}=n;W(e)&&(Object.keys(n).length===0||typeof r<"u"||typeof s<"u")?n={...n,angle:0,...Nn({...e,x:n.x||e.x,y:n.y||e.y},t,n,i)}:typeof r<"u"&&(n={...dp(r),...n});for(let l in n){let d=n[l];if(typeof d<"u"){if(e[l]===d&&(typeof d!="object"||d===null||l==="groupIds"||l==="scale"))continue;if(l==="scale"){let c=e[l],u=d;if(c[0]===u[0]&&c[1]===u[1])continue}else if(l==="points"){let c=e[l],u=d;if(c.length===u.length){let m=!1,p=c.length;for(;--p;){let f=c[p],h=u[p];if(f[0]!==h[0]||f[1]!==h[1]){m=!0;break}}if(!m)continue}}e[l]=d,o=!0}}return o&&((typeof n.height<"u"||typeof n.width<"u"||typeof a<"u"||typeof r<"u")&&Xe.delete(e),e.version=n.version??e.version+1,e.versionNonce=n.versionNonce??Kr(),e.updated=Qr()),e},ge=(e,t,n=!1)=>{let i=!1;for(let o in t){let r=t[o];if(typeof r<"u"){if(e[o]===r&&(typeof r!="object"||r===null))continue;i=!0}}return!i&&!n?e:{...e,...t,version:t.version??e.version+1,versionNonce:t.versionNonce??Kr(),updated:Qr()}},ml=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=Kr(),e.updated=Qr(),e);var El=10,An=5,Ct=(e,t)=>(t.elbowed?An:El)+e.strokeWidth/2,xi=e=>{let t=Math.max(El,15),n=e?.value&&e.value<1?e.value:1;return Jr(t/(n*1.5),t,t*2)},nb=e=>!e[cp.CTRL_OR_CMD],Pi=e=>e.isBindingEnabled,gl=(e,t,n,i,o,r,s)=>{let{start:a,end:l}=es(e,t,n,i,o.getNonDeletedElementsMap(),o.getNonDeletedElements(),r,{...s,finalize:!0});if(pl(e,a,"start",o),pl(e,l,"end",o),a.focusPoint||l.focusPoint){let d=new Map;a.focusPoint&&d.set(0,{point:Un(e,"startBinding",e.startBinding,a.element,o.getNonDeletedElementsMap())||e.points[0]}),l.focusPoint&&d.set(e.points.length-1,{point:Un(e,"endBinding",e.endBinding,l.element,o.getNonDeletedElementsMap())||e.points[e.points.length-1]}),O.movePoints(e,o,d)}return{start:a,end:l}},pl=(e,{mode:t,element:n,focusPoint:i},o,r)=>{t===null?Qe(e,o,r):t!==void 0&&Tn(e,n,t,o,r,i)},xl=(e,t,n,i,o)=>{rt(t.size===1,"Bound elbow arrows cannot be moved");let r=t.entries().next().value;rt(r,"There should be a position update for dragging an elbow arrow endpoint");let[s,{point:a}]=r,l=O.getPointGlobalCoordinates(e,a,n),d=Lt(l,i,n,m=>xi(o)),c=d?{element:d,mode:"orbit",focusPoint:O.getPointAtIndexGlobalCoordinates(e,s,n)}:{mode:null},u={mode:void 0};return s===0?{start:c,end:u}:{start:u,end:c}},hp=(e,t,n,i,o,r,s,a,l,d,c)=>{let u={mode:void 0},m={mode:void 0},p=e.points.length>2,f=O.getPointGlobalCoordinates(e,t.get(o?s:a).point,n),h=Lt(f,i,n);if(o)return h?u={element:h,mode:"inside",focusPoint:f}:u={mode:null},{start:u,end:m};if(r){let E=l?.selectedLinearElement?.initialState.origin;if(h&&e.startBinding?.elementId===h.id){let g=q(h.x+h.width/2,h.y+h.height/2);return{start:p?{mode:void 0}:{mode:"inside",element:h,focusPoint:E??g},end:p?{mode:"orbit",element:h,focusPoint:f}:{mode:"inside",element:h,focusPoint:f}}}if(h&&e.startBinding){let g=e.startBinding;if(Eo(f,i,n).find(w=>w.id===g.elementId)){let w=n.get(e.startBinding.elementId);return rt(w,"Other element must be in the elements map"),{start:p?{mode:void 0}:{mode:w.id!==h.id?"orbit":"inside",element:w,focusPoint:E??q(e.x,e.y)},end:{mode:"orbit",element:h,focusPoint:f}}}}if(e.startBinding&&e.startBinding.elementId!==h?.id){let g=n.get(e.startBinding.elementId);rt(g,"Other element must be in the elements map");let w={mode:!!l.selectedLinearElement?.initialState.arrowStartIsInside?"inside":"orbit",element:g,focusPoint:c?de(g,n):E??q(e.x,e.y)},b=h&&zr(g,h,n),y;if(h){let I=d==="inside"||d==="skip";y={mode:I&&!b?"inside":"orbit",element:h,focusPoint:f}}else y={mode:null};return{start:p?{mode:void 0}:w,end:y}}if(!e.startBinding)return h?m={mode:d==="inside"||d==="skip"?"inside":"orbit",element:h,focusPoint:f}:m={mode:null},{start:u,end:m}}rt(!1,"New arrow creation should not reach here")},fl=(e,t,n,i,o,r,s,a)=>{let l={mode:void 0},d={mode:void 0},c=s.points.length>2,u=Lt(e,o,i),m=n?Eo(e,o,i).some(E=>E.id===n.elementId):!1,p=n?i.get(n.elementId):null,f=m&&p?mp(p.backgroundColor):!1,h=u&&p&&zr(p,u,i);return r==="inside"||r==="skip"?(l=u?{element:!m||!p||f?u:p,focusPoint:e,mode:"inside"}:{mode:null},d=a&&u&&u.id===n?.elementId?{mode:null}:d,{current:l,other:d}):u?u.id===t?.elementId&&t.mode==="inside"?{current:{mode:"inside",focusPoint:e,element:u},other:d}:n?n.elementId===u.id?n.mode==="orbit"?(l={element:u,mode:"orbit",focusPoint:e},d={mode:a?null:void 0},{current:l,other:c?{mode:void 0}:d}):(l={element:u,mode:"inside",focusPoint:e},{current:l,other:c?{mode:void 0}:d}):(m&&p&&!f?l={element:p,mode:"inside",focusPoint:e}:l={element:u,mode:"orbit",focusPoint:e},{current:l,other:c?{mode:void 0}:d}):(l={element:u,mode:"orbit",focusPoint:e},{current:l,other:c?{mode:void 0}:d}):{current:{mode:null},other:d}},es=(e,t,n,i,o,r,s,a)=>up("COMPLEX_BINDINGS")?gp(e,t,o,r,s,a):Ep(e,t,n,i,o,r,s,a),Ep=(e,t,n,i,o,r,s,a)=>{let d=e.points.length-1,c=t.has(0),u=t.has(d),m={mode:void 0},p={mode:void 0};if(rt(e.points.length>1,"Do not attempt to bind linear elements with a single point"),!c&&!u)return{start:m,end:p};if(c&&u)return{start:{mode:null},end:{mode:null}};if(!Pi(s))return m=c?{mode:null}:m,p=u?{mode:null}:p,{start:m,end:p};if(W(e))return xl(e,t,o,r,a?.zoom);let f=c?e.endBinding:e.startBinding,h=t.get(c?0:d)?.point;rt(h,`Local point must be defined for ${c?"start":"end"} dragging`);let E=O.getPointGlobalCoordinates(e,h,o),g=Lt(E,r,o,M=>xi(s.zoom)),x=g&&(a?.angleLocked?At(q(n,i),g,o):At(E,g,o)),w=f?o.get(f.elementId):void 0,b=f&&w&&tn(f.fixedPoint,w,o),y=w&&b&&At(b,w,o);if(f&&f.elementId===g?.id)return rt(!a?.newArrow||s.selectedLinearElement?.initialState.origin,"appState.selectedLinearElement.initialState.origin must be defined for new arrows"),{start:{mode:"inside",element:g,focusPoint:c?E:a?.newArrow?s.selectedLinearElement.initialState.origin:O.getPointAtIndexGlobalCoordinates(e,0,o)},end:{mode:"inside",element:g,focusPoint:u?E:O.getPointAtIndexGlobalCoordinates(e,-1,o)}};if(a?.altKey)return{start:c?g?{mode:"inside",element:g,focusPoint:E}:{mode:null}:m,end:u?g?{mode:"inside",element:g,focusPoint:E}:{mode:null}:p};let I=g?x?{mode:"inside",element:g,focusPoint:E}:{mode:"orbit",element:g,focusPoint:vr(e,E,g,c?"start":"end",o)||E}:{mode:null},S=O.getPointAtIndexGlobalCoordinates(e,c?-1:0,o),A=w&&!y&&s.selectedLinearElement?.initialState.altFocusPoint?{mode:"orbit",element:w,focusPoint:s.selectedLinearElement.initialState.altFocusPoint}:a?.angleLocked&&w?{mode:"orbit",element:w,focusPoint:vr(e,S,w,c?"end":"start",o)||S}:{mode:void 0};return{start:c?I:A,end:u?I:A}},gp=(e,t,n,i,o,r)=>{let s=o.bindMode||"orbit",a=0,l=e.points.length-1,d=t.has(a),c=t.has(l),u={mode:void 0},m={mode:void 0};if(rt(e.points.length>1,"Do not attempt to bind linear elements with a single point"),!d&&!c)return{start:u,end:m};if(d&&c)return{start:{mode:null},end:{mode:null}};if(!Pi(o))return u=d?{mode:null}:u,m=c?{mode:null}:m,{start:u,end:m};if(W(e))return xl(e,t,n,i);if(r?.newArrow){let{start:p,end:f}=hp(e,t,n,i,d,c,a,l,o,s,r?.shiftKey);return{start:p,end:f}}if(d){let p=t.get(a)?.point;rt(p,"Local point must be defined for start dragging");let f=O.getPointGlobalCoordinates(e,p,n),{current:h,other:E}=fl(f,e.startBinding,e.endBinding,n,i,s,e,r?.finalize);return{start:h,end:E}}if(c){let p=t.get(l)?.point;rt(p,"Local point must be defined for end dragging");let f=O.getPointGlobalCoordinates(e,p,n),{current:h,other:E}=fl(f,e.endBinding,e.startBinding,n,i,s,e,r?.finalize);return{start:E,end:h}}return{start:u,end:m}},ib=(e,t,n)=>{e.forEach(i=>{gl(i,new Map,1/0,1/0,t,n)})},Tn=(e,t,n,i,o,r)=>{let s=o.getNonDeletedElementsMap(),a;W(e)?a={elementId:t.id,mode:"orbit",...Ip(e,t,i,s)}:a={elementId:t.id,mode:n,...Lo(e,t,i,s,r)},o.mutateElement(e,{[i==="start"?"startBinding":"endBinding"]:a}),hl(t.boundElements||[]).has(e.id)||o.mutateElement(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},Qe=(e,t,n)=>{let i=t==="start"?"startBinding":"endBinding",o=e[i];if(o==null)return null;let r=e[t==="start"?"endBinding":"startBinding"];if(!r||r.elementId!==o.elementId){let s=n.getNonDeletedElementsMap().get(o.elementId);n.mutateElement(s,{boundElements:s.boundElements?.filter(a=>a.id!==e.id)})}return n.mutateElement(e,{[i]:null}),o.elementId},je=(e,t,n)=>{if(!Ge(e))return;let{simultaneouslyUpdated:i}=n??{},o=wp(i),r=t.getNonDeletedElementsMap();n?.changedElements&&(r=new Map(r),n.changedElements.forEach(s=>{r.set(s.id,s)})),vo(r,e,s=>{if(!z(s)||s.isDeleted||!xp(s,e))return;let a=s.startBinding?r.get(s.startBinding.elementId):null,l=s.endBinding?a?.id===s.endBinding.elementId?a:r.get(s.endBinding.elementId):null;if(o.has(s.id))return;let d=Do(r,s,(u,m)=>{if(u&&Ge(u)&&(m==="startBinding"||m==="endBinding")&&(e.id===s[m]?.elementId||e.id===s[m==="startBinding"?"endBinding":"startBinding"]?.elementId)){let p=Un(s,m,s[m],u,r);if(p)return[m==="startBinding"?0:s.points.length-1,{point:p}]}return null}).filter(u=>u!==null);O.movePoints(s,t,new Map(d),{moveMidPointsWithElement:!!a&&a?.id===l?.id});let c=V(s,r);c&&!c.isDeleted&&In(s,t,!1)})},ob=(e,t,n,i)=>{z(e)?gl(e,new Map,1/0,1/0,t,n):je(e,t,{...i,changedElements:new Map([[e.id,e]])})},xp=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,wp=e=>new Set((e||[]).map(t=>t.id)),ul=(e,t,n,i,o,r,s)=>{let a=Bt(_n(t,e));return!n||!i?a:yp(o,n,r,s)?hi(n,i,e):Bt(_n(e,de(n,r)))},yp=(e,t,n,i)=>{let o=Sn(t,n,e),r=xi(i);return o>r?null:o},Ao=(e,t,n,i,o)=>{let r=W(e),s=O.getPointAtIndexGlobalCoordinates(e,n==="start"?0:-1,i);if(e.points.length<2)return s;let a=br(t)&&r?wl(e,t,i,s):s,l=o&&!r?o[1]:O.getPointAtIndexGlobalCoordinates(e,n==="start"?1:-2,i),d=Ct(t,e),c=Ke(t,i),u=mt(c),m=null;if(r){let p=Fe(hi(t,c,s)),f=bp(e,t,i,a),h=q(p?u[0]:f[0],p?f[1]:u[1]),E=o??yi(h,zn(Hn(To(_n(f,h)),Math.max(t.width,t.height)*2),h));if(m=qt(t,i,E,d).sort(wi)[0],!m){let g=q(p?f[0]:u[0],p?u[1]:f[1]),x=yi(g,zn(Hn(To(_n(f,g)),Math.max(t.width,t.height)*2),g));m=qt(t,i,x,An).sort(wi)[0]}}else{let p=o;if(!p){let f=Hn(To(_n(a,l)),Ot(a,l)+Math.max(t.width,t.height)+d*2);p=o??yi(zn(f,l),zn(Hn(f,-1),l))}m=Ot(a,l)<1?a:qt(t,i,p,d).sort((f,h)=>wi(f,l)-wi(h,l))[0]}return!m||wi(a,m)<pp?a:m},wl=(e,t,n,i)=>{let o=de(t,n),r=re(i,o,-t.angle),s=Ct(t,e);return r[0]<t.x&&r[1]<t.y?r[1]-t.y>-s?re(q(t.x-s,t.y),o,t.angle):re(q(t.x,t.y-s),o,t.angle):r[0]<t.x&&r[1]>t.y+t.height?r[0]-t.x>-s?re(q(t.x,t.y+t.height+s),o,t.angle):re(q(t.x-s,t.y+t.height),o,t.angle):r[0]>t.x+t.width&&r[1]>t.y+t.height?r[0]-t.x<t.width+s?re(q(t.x+t.width,t.y+t.height+s),o,t.angle):re(q(t.x+t.width+s,t.y+t.height),o,t.angle):r[0]>t.x+t.width&&r[1]<t.y?r[0]-t.x<t.width+s?re(q(t.x+t.width,t.y-s),o,t.angle):re(q(t.x+t.width+s,t.y),o,t.angle):i},bp=(e,t,n,i,o=.05)=>{let{x:r,y:s,width:a,height:l,angle:d}=t,c=de(t,n,-.1,-.1),u=re(i,c,-d),m=Ct(t,e),p=Jr(o*l,5,80),f=Jr(o*a,5,80);if(Ot(c,u)<m)return i;if(u[0]<=r+a/2&&u[1]>c[1]-p&&u[1]<c[1]+p)return re(q(r-m,c[1]),c,d);if(u[1]<=s+l/2&&u[0]>c[0]-f&&u[0]<c[0]+f)return re(q(c[0],s-m),c,d);if(u[0]>=r+a/2&&u[1]>c[1]-p&&u[1]<c[1]+p)return re(q(r+a+m,c[1]),c,d);if(u[1]>=s+l/2&&u[0]>c[0]-f&&u[0]<c[0]+f)return re(q(c[0],s+l+m),c,d);if(t.type==="diamond"){let h=m,E=q(r+a/4-h,s+l/4-h),g=q(r+3*a/4+h,s+l/4-h),x=q(r+a/4-h,s+3*l/4+h),w=q(r+3*a/4+h,s+3*l/4+h);if(Ot(E,u)<Math.max(f,p))return re(E,c,d);if(Ot(g,u)<Math.max(f,p))return re(g,c,d);if(Ot(x,u)<Math.max(f,p))return re(x,c,d);if(Ot(w,u)<Math.max(f,p))return re(w,c,d)}return i},Pp=(e,t)=>t.width**2+t.height**2-(e.width**2+e.height**2),Un=(e,t,n,i,o,r)=>{if(n==null||n.elementId!==i.id&&e.points.length>2||fp(e.points[e.points.length-1],q(0,0)))return null;let s=tn(Ii(n.fixedPoint),i,o),a=t==="startBinding"?0:e.points.length-1,l=W(e),d=t==="startBinding"?e.endBinding:e.startBinding,c=d&&o.get(d.elementId),u=ae(i,o),m=c&&ae(c,o),p=c&&Pp(i,c)<(t==="endBinding"?1:0),f=m&&Mn(u,m),h=!1;if(!f&&!l&&e.startBinding&&e.endBinding&&c&&e.points.length===2){let w=tn(e.startBinding.fixedPoint,t==="startBinding"?i:c,o),b=tn(e.endBinding.fixedPoint,t==="endBinding"?i:c,o),y=yi(w,b),I=qt(t==="endBinding"?i:c,o,y,0,!0),S=qt(t==="startBinding"?i:c,o,y,0,!0);I.length>0&&S.length>0&&(h=Ot(I[0],S[0])<40)}let E=(h||f)&&p,g=r;if(!l&&!g){let[w,b,y,I]=O.getElementAbsoluteCoords(e,o),S=q((w+y)/2,(b+I)/2),A=br(i)?wl(e,i,o,s):s,M=re(q(e.x+e.points[a===0?1:e.points.length-2][0],e.y+e.points[a===0?1:e.points.length-2][1]),S,e.angle),k=Ct(i,e),L=Hn(To(_n(A,M)),Ot(A,M)+Math.max(i.width,i.height)+k*2);g=yi(zn(L,M),zn(Hn(L,-1),M))}let x=n.mode==="orbit"&&i?E?s:Ao({...e,points:[a===0?O.createPointAt(e,o,s[0],s[1],null):e.points[0],...e.points.slice(1,-1),a===e.points.length-1?O.createPointAt(e,o,s[0],s[1],null):e.points[e.points.length-1]]},i,a===0?"start":"end",o,g):s;return O.createPointAt(e,o,x[0],x[1],null)},Ip=(e,t,n,i)=>{let o=[t.x,t.y,t.x+t.width,t.y+t.height],r=Ao(e,t,n,i),s=q(o[0]+(o[2]-o[0])/2,o[1]+(o[3]-o[1])/2),a=re(r,s,-t.angle);return{fixedPoint:Ii([(a[0]-t.x)/t.width,(a[1]-t.y)/t.height])}},Lo=(e,t,n,i,o)=>{let r=o||O.getPointAtIndexGlobalCoordinates(e,n==="start"?0:-1,i),s=q(t.x+t.width/2,t.y+t.height/2),a=re(r,s,-t.angle),l=(a[0]-t.x)/t.width,d=(a[1]-t.y)/t.height;return{fixedPoint:Ii([l,d])}},yl=(e,t,n)=>{for(let i of e){if("boundElements"in i&&i.boundElements&&Object.assign(i,{boundElements:i.boundElements.reduce((o,r)=>{let s=t.get(r.id);return s&&o.push({...r,id:s}),o},[])}),"containerId"in i&&i.containerId&&Object.assign(i,{containerId:t.get(i.containerId)??null}),"endBinding"in i&&i.endBinding){let o=t.get(i.endBinding.elementId);Object.assign(i,{endBinding:o?{...i.endBinding,elementId:o}:null})}if("startBinding"in i&&i.startBinding){let o=t.get(i.startBinding.elementId);Object.assign(i,{startBinding:o?{...i.startBinding,elementId:o}:null})}W(i)&&Object.assign(i,Nn(i,n,{points:[i.points[0],i.points[i.points.length-1]]}))}},rb=(e,t)=>{let n=hl(e);for(let i of t)nn.unbindAffected(n,i,(o,r)=>ye(o,n,r)),on.unbindAffected(n,i,(o,r)=>ye(o,n,r))},bi=(e,t,n=[])=>{if(!e)return null;let i=e.filter(o=>!t.has(o.id));return i.push(...n.map(o=>({id:o.id,type:o.type}))),i},bl=new Set(["boundElements","frameId","containerId","startBinding","endBinding"]),vo=(e,t,n)=>{Ge(t)&&(t.boundElements?.slice()??[]).forEach(({id:o})=>{n(e.get(o),"boundElements",o)})},Do=(e,t,n)=>{let i=[];if(t.frameId){let o=t.frameId;i.push(n(e.get(o),"frameId",o))}if(ce(t)){let o=t.containerId;i.push(n(e.get(o),"containerId",o))}if(z(t)){if(t.startBinding){let o=t.startBinding.elementId;i.push(n(e.get(o),"startBinding",o))}if(t.endBinding){let o=t.endBinding.elementId;i.push(n(e.get(o),"endBinding",o))}}return i},nn=class{static unbindAffected(t,n,i){n&&Do(t,n,o=>{!o||o.isDeleted||vo(t,o,(r,s,a)=>{a===n.id&&i(o,{boundElements:bi(o.boundElements,new Set([a]))})})})}static rebindAffected=(t,n,i)=>{!n||n.isDeleted||Do(t,n,(o,r)=>{if(!o||o.isDeleted){i(n,{[r]:null});return}r!=="frameId"&&(o.boundElements?.find(s=>s.id===n.id)||(z(n)&&i(o,{boundElements:bi(o.boundElements,new Set,new Array(n))}),ee(n)&&(o.boundElements?.find(s=>s.type==="text")?i(n,{[r]:null}):i(o,{boundElements:bi(o.boundElements,new Set,new Array(n))}))))})}},on=class{static unbindAffected(t,n,i){n&&vo(t,n,o=>{!o||o.isDeleted||Do(t,o,(r,s,a)=>{a===n.id&&i(o,{[s]:null})})})}static rebindAffected=(t,n,i)=>{!n||n.isDeleted||vo(t,n,(o,r,s)=>{if(!o||o.isDeleted){i(n,{boundElements:bi(n.boundElements,new Set([s]))});return}ee(o)&&((n.boundElements?.slice()??[]).reverse().find(l=>l.type==="text")?.id===o.id?o.containerId!==n.id&&i(o,{containerId:n.id}):(o.containerId!==null&&i(o,{containerId:null}),i(n,{boundElements:bi(n.boundElements,new Set([o.id]))})))})}},tn=(e,t,n)=>{let[i,o]=Ii(e);return re(q(t.x+t.width*i,t.y+t.height*o),de(t,n),t.angle)},Sp=(e,t)=>{let n=e.startBinding&&t.get(e.startBinding.elementId),i=e.endBinding&&t.get(e.endBinding.elementId),o=n&&e.startBinding?tn(e.startBinding.fixedPoint,n,t):q(e.x+e.points[0][0],e.y+e.points[0][1]),r=i&&e.endBinding?tn(e.endBinding.fixedPoint,i,t):q(e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]);return[o,r]},Pl=(e,t)=>{let[n,i]=Sp(e,t);return[O.pointFromAbsoluteCoords(e,n,t),O.pointFromAbsoluteCoords(e,i,t)]},Ii=e=>e&&(Math.abs(e[0]-.5)<1e-4||Math.abs(e[1]-.5)<1e-4)?e.map(t=>Math.abs(t-.5)<1e-4?.5001:t):e,Mp=e=>e.type==="ellipse"||e.type==="diamond"?e.type:"rectangle",Ap={rectangle:[{centerAngle:0,sectorWidth:75,side:"right"},{centerAngle:45,sectorWidth:15,side:"bottom-right"},{centerAngle:90,sectorWidth:75,side:"bottom"},{centerAngle:135,sectorWidth:15,side:"bottom-left"},{centerAngle:180,sectorWidth:75,side:"left"},{centerAngle:225,sectorWidth:15,side:"top-left"},{centerAngle:270,sectorWidth:75,side:"top"},{centerAngle:315,sectorWidth:15,side:"top-right"}],diamond:[{centerAngle:0,sectorWidth:15,side:"right"},{centerAngle:45,sectorWidth:75,side:"bottom-right"},{centerAngle:90,sectorWidth:15,side:"bottom"},{centerAngle:135,sectorWidth:75,side:"bottom-left"},{centerAngle:180,sectorWidth:15,side:"left"},{centerAngle:225,sectorWidth:75,side:"top-left"},{centerAngle:270,sectorWidth:15,side:"top"},{centerAngle:315,sectorWidth:75,side:"top-right"}],ellipse:[{centerAngle:0,sectorWidth:15,side:"right"},{centerAngle:45,sectorWidth:75,side:"bottom-right"},{centerAngle:90,sectorWidth:15,side:"bottom"},{centerAngle:135,sectorWidth:75,side:"bottom-left"},{centerAngle:180,sectorWidth:15,side:"left"},{centerAngle:225,sectorWidth:75,side:"top-left"},{centerAngle:270,sectorWidth:15,side:"top"},{centerAngle:315,sectorWidth:75,side:"top-right"}]},Tp=e=>e.map((t,n)=>{let i=t.sectorWidth/2,o=t.centerAngle-i,r=t.centerAngle+i;return o=(o%360+360)%360,r=(r%360+360)%360,{start:o,end:r,side:t.side}}),vp=(e,t)=>{let[n,i]=e,o=n-.5,r=i-.5,s=Math.atan2(r,o);s<0&&(s+=2*Math.PI);let a=s*180/Math.PI,l=Ap[t],d=Tp(l);for(let m of d)if(m.start<=m.end){if(a>=m.start&&a<=m.end)return m.side}else if(a>=m.start||a<=m.end)return m.side;let c=1/0,u=l[0].side;for(let m of l){let p=Math.abs(a-m.centerAngle);p>180&&(p=360-p),p<c&&(c=p,u=m.side)}return u},sb=(e,t)=>{let n=t.get(e.elementId);if(!n||n.isDeleted||!Ge(n))return null;let i=de(n,t),o=Mp(n),r=vp(Ii(e.fixedPoint),o),s=.01;if(n.type==="diamond"){let[a,l]=$t(n),[d,c,u,m]=a,p,f;switch(r){case"left":{if(l.length>=3){let E=l[2][1];p=E[0]-s,f=E[1]}else{let h=Me(c[1],u[0]);p=h[0]-s,f=h[1]}break}case"right":{if(l.length>=1){let E=l[0][1];p=E[0]+s,f=E[1]}else{let h=Me(m[1],d[0]);p=h[0]+s,f=h[1]}break}case"top":{if(l.length>=4){let E=l[3][1];p=E[0],f=E[1]-s}else{let h=Me(u[1],m[0]);p=h[0],f=h[1]-s}break}case"bottom":{if(l.length>=2){let E=l[1][1];p=E[0],f=E[1]+s}else{let h=Me(d[1],c[0]);p=h[0],f=h[1]+s}break}case"top-right":{let h=Me(m[0],m[1]);p=h[0]+s*.707,f=h[1]-s*.707;break}case"bottom-right":{let h=Me(d[0],d[1]);p=h[0]+s*.707,f=h[1]+s*.707;break}case"bottom-left":{let h=Me(c[0],c[1]);p=h[0]-s*.707,f=h[1]+s*.707;break}case"top-left":{let h=Me(u[0],u[1]);p=h[0]-s*.707,f=h[1]-s*.707;break}default:return null}return re(q(p,f),i,n.angle)}if(n.type==="ellipse"){let a=n.x+n.width/2,l=n.y+n.height/2,d=n.width/2,c=n.height/2,u,m;switch(r){case"top":{u=a,m=l-c-s;break}case"right":{u=a+d+s,m=l;break}case"bottom":{u=a,m=l+c+s;break}case"left":{u=a-d-s,m=l;break}case"top-right":{let p=-Math.PI/4,f=d*Math.cos(p),h=c*Math.sin(p);u=a+f+s*.707,m=l+h-s*.707;break}case"bottom-right":{let p=Math.PI/4,f=d*Math.cos(p),h=c*Math.sin(p);u=a+f+s*.707,m=l+h+s*.707;break}case"bottom-left":{let p=3*Math.PI/4,f=d*Math.cos(p),h=c*Math.sin(p);u=a+f-s*.707,m=l+h+s*.707;break}case"top-left":{let p=-3*Math.PI/4,f=d*Math.cos(p),h=c*Math.sin(p);u=a+f-s*.707,m=l+h-s*.707;break}default:return null}return re(q(u,m),i,n.angle)}if(li(n)){let[a,l]=Vt(n),[d,c,u,m]=a,p,f;switch(r){case"top":{let h=Me(d[0],d[1]);p=h[0],f=h[1]-s;break}case"right":{let h=Me(c[0],c[1]);p=h[0]+s,f=h[1];break}case"bottom":{let h=Me(u[0],u[1]);p=h[0],f=h[1]+s;break}case"left":{let h=Me(m[0],m[1]);p=h[0]-s,f=h[1];break}case"top-left":{if(l.length>=1){let h=l[0],E=h[0],g=h[3],x=Me(E,g);p=x[0]-s*.707,f=x[1]-s*.707}else p=n.x-s,f=n.y-s;break}case"top-right":{if(l.length>=2){let h=l[1],E=h[0],g=h[3],x=Me(E,g);p=x[0]+s*.707,f=x[1]-s*.707}else p=n.x+n.width+s,f=n.y-s;break}case"bottom-right":{if(l.length>=3){let h=l[2],E=h[0],g=h[3],x=Me(E,g);p=x[0]+s*.707,f=x[1]+s*.707}else p=n.x+n.width+s,f=n.y+n.height+s;break}case"bottom-left":{if(l.length>=4){let h=l[3],E=h[0],g=h[3],x=Me(E,g);p=x[0]-s*.707,f=x[1]+s*.707}else p=n.x-s,f=n.y+n.height+s;break}default:return null}return re(q(p,f),i,n.angle)}return null},Me=(e,t)=>q((e[0]+t[0])/2,(e[1]+t[1])/2);var ts=({points:e})=>{let t=e[0][0],n=e[0][1];return{points:e.map(i=>C(i[0]-t,i[1]-n)),offsetX:t,offsetY:n}},O=class e{elementId;selectedPointsIndices;initialState;isDragging;lastUncommittedPoint;lastCommittedPoint;pointerOffset;hoverPointIndex;segmentMidPointHoveredCoords;elbowed;customLineAngle;isEditing;pointerDownState;constructor(t,n,i=!1){this.elementId=t.id,Sl(t.points[0],C(0,0))||(console.error("Linear element is not normalized",Error().stack),ye(t,n,e.getNormalizeElementPointsAndCoords(t))),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.lastCommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.initialState={prevSelectedPointsIndices:null,lastClickedPoint:-1,origin:null,segmentMidpoint:{value:null,index:null,added:!1},arrowStartIsInside:!1,altFocusPoint:null},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null,this.elbowed=W(t)&&t.elbowed,this.customLineAngle=null,this.isEditing=i}static POINT_HANDLE_SIZE=10;static getElement(t,n){let i=n.get(t);return i||null}static handleBoxSelection(t,n,i,o){if(!n.selectedLinearElement?.isEditing||!n.selectionElement)return!1;let{selectedLinearElement:r}=n,{selectedPointsIndices:s,elementId:a}=r,l=e.getElement(a,o);if(!l)return!1;let[d,c,u,m]=j(n.selectionElement,o),f=e.getPointsGlobalCoordinates(l,o).reduce((h,E,g)=>((E[0]>=d&&E[0]<=u&&E[1]>=c&&E[1]<=m||t.shiftKey&&s?.includes(g))&&h.push(g),h),[]).filter(h=>!(W(l)&&h!==0&&h!==l.points.length-1));i({selectedLinearElement:{...r,selectedPointsIndices:f.length?f:null}})}static handlePointerMove(t,n,i,o,r){let s=n.scene.getNonDeletedElementsMap(),a=n.scene.getNonDeletedElements(),{elementId:l}=r,d=e.getElement(l,s);Te(d,"Element being dragged must exist in the scene"),Te(d.points.length>1,"Element must have at least 2 points");let c=d.points.length-1,u=d.points[c],m=d.points[c-1],p=r.customLineAngle??Bl(m,d.points[c]),f=0,h=0;if(Si(t)){let[y,I]=e._getShiftLockedDelta(d,s,m,C(i,o),t[vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize(),p),S=C(y+m[0],I+m[1]);f=S[0]-u[0],h=S[1]-u[1]}else{let y=e.createPointAt(d,s,i-r.pointerOffset.x,o-r.pointerOffset.y,t[vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize());f=y[0]-u[0],h=y[1]-u[1]}let E=null,{positions:g,updates:x}=Ll([c],f,h,i,o,s,d,a,n,Si(t),t.altKey);if(e.movePoints(d,n.scene,g,{startBinding:x?.startBinding,endBinding:x?.endBinding,moveMidPointsWithElement:x?.moveMidPointsWithElement}),Ce(d,!1)&&Pi(n.state)&&(E=x?.suggestedBinding??null),Ce(d)&&vl(e.getPointGlobalCoordinates(d,d.points[d.points.length-1],s),d,a,s,n.scene),n.state.selectedLinearElement?.customLineAngle===p&&r.initialState.altFocusPoint&&(!E||Gp(n.state.suggestedBinding??[],E)))return null;let w=Ce(d)&&d.startBinding&&s.get(d.startBinding.elementId);return{selectedLinearElement:{...r,customLineAngle:p,initialState:{...r.initialState,altFocusPoint:!r.initialState.altFocusPoint&&w&&x?.suggestedBinding?.id!==w.id?Dl(d,C(d.x,d.y),w,"start",s):r.initialState.altFocusPoint}},suggestedBinding:E}}static handlePointDragging(t,n,i,o,r){let s=n.scene.getNonDeletedElementsMap(),a=n.scene.getNonDeletedElements(),{elbowed:l,elementId:d,initialState:c}=r,u=Array.from(r.selectedPointsIndices??[]),{lastClickedPoint:m}=c,p=e.getElement(d,s);Te(p,"Element being dragged must exist in the scene"),Te(p.points.length>1,"Element must have at least 2 points"),Te(u,"There must be selected points in order to drag them"),l&&u.some((T,$)=>T>0&&T!==p.points.length-1?(u[$]=p.points.length-1,m=p.points.length-1,!0):!1),Te(m>-1&&u.includes(m)&&p.points[m],`There must be a valid lastClickedPoint in order to drag it. selectedPointsIndices(${JSON.stringify(u)}) points(0..${p.points.length-1}) lastClickedPoint(${m})`);let f=p.points[m],h=p.points[m===0?1:m-1],E=u.length===1,g=r.customLineAngle??Bl(h,p.points[m]),x=u.includes(0),w=u.includes(p.points.length-1),b=0,y=0;if(Si(t)&&E){let[T,$]=e._getShiftLockedDelta(p,s,h,C(i,o),t[vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize(),g),Z=C(T+h[0],$+h[1]);b=Z[0]-f[0],y=Z[1]-f[1]}else{let T=e.createPointAt(p,s,i-r.pointerOffset.x,o-r.pointerOffset.y,t[vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize());b=T[0]-f[0],y=T[1]-f[1]}let I=null,{positions:S,updates:A}=Ll(u,b,y,i,o,s,p,a,n,Si(t)&&E,t.altKey);e.movePoints(p,n.scene,S,{startBinding:A?.startBinding,endBinding:A?.endBinding,moveMidPointsWithElement:A?.moveMidPointsWithElement}),Ce(p,!1)&&Pi(n.state)&&(x||w)&&(I=A?.suggestedBinding??null),Ce(p)&&x!==w&&vl(e.getPointGlobalCoordinates(p,x?p.points[0]:p.points[p.points.length-1],s),p,a,s,n.scene),V(p,s)&&In(p,n.scene,!1);let k=l?w?[p.points.length-1]:[0]:u,L=l?k[0]:m,G=!x&&!w?e.getPointGlobalCoordinates(p,f,s):null,B=L,U=Ce(p)&&p.startBinding&&s.get(p.startBinding.elementId),N=Ce(p)&&p.endBinding&&s.get(p.endBinding.elementId),Y=w&&U&&A?.suggestedBinding?.id!==U.id?U:x&&N&&A?.suggestedBinding?.id!==N.id?N:null;return{selectedLinearElement:{...r,selectedPointsIndices:k,initialState:{...r.initialState,lastClickedPoint:L,altFocusPoint:!r.initialState.altFocusPoint&&Ce(p)&&Y?Dl(p,C(p.x,p.y),Y,"start",s):r.initialState.altFocusPoint},segmentMidPointHoveredCoords:G,hoverPointIndex:B,isDragging:!0,customLineAngle:g},suggestedBinding:I}}static handlePointerUp(t,n,i,o){let r=o.getNonDeletedElementsMap(),{elementId:s,selectedPointsIndices:a,isDragging:l,initialState:d}=n,c=e.getElement(s,r);if(!c)return n;if(l&&a)for(let u of a)(u===0||u===c.points.length-1)&&Op(c.points,i.zoom.value)&&(It(c)&&o.mutateElement(c,{...Cl(c,!0)},{informMutation:!1,isDragging:!1}),e.movePoints(c,o,new Map([[u,{point:u===0?c.points[c.points.length-1]:c.points[0]}]])));return{...n,segmentMidPointHoveredCoords:null,hoverPointIndex:-1,selectedPointsIndices:l||t.shiftKey?!l&&t.shiftKey&&d.prevSelectedPointsIndices?.includes(d.lastClickedPoint)?a&&a.filter(u=>u!==d.lastClickedPoint):a:a?.includes(d.lastClickedPoint)?[d.lastClickedPoint]:a,isDragging:!1,pointerOffset:{x:0,y:0},customLineAngle:null,initialState:{...n.initialState,origin:null,arrowStartIsInside:!1}}}static getEditorMidPoints=(t,n,i)=>{let o=V(t,n);if(!W(t)&&!i.selectedLinearElement?.isEditing&&t.points.length>2&&!o)return[];let r=e.getPointsGlobalCoordinates(t,n),s=0,a=[];for(;s<r.length-1;){if(e.isSegmentTooShort(t,t.points[s],t.points[s+1],s,i.zoom)){a.push(null),s++;continue}let l=e.getSegmentMidPoint(t,s+1);a.push(l),s++}return a};static getSegmentMidpointHitCoords=(t,n,i,o)=>{let{elementId:r}=t,s=e.getElement(r,o);if(!s)return null;let a=e.getPointIndexUnderCursor(s,o,i.zoom,n.x,n.y);if(!W(s)&&a>=0||e.getPointsGlobalCoordinates(s,o).length>=3&&!i.selectedLinearElement?.isEditing&&!W(s))return null;let d=(e.POINT_HANDLE_SIZE+1)/i.zoom.value,c=t.segmentMidPointHoveredCoords;if(c&&rn(C(c[0],c[1]),C(n.x,n.y))<=d)return c;let u=0,m=e.getEditorMidPoints(s,o,i);for(;u<m.length;){if(m[u]!==null&&rn(m[u],C(n.x,n.y))<=d)return m[u];u++}return null};static isSegmentTooShort(t,n,i,o,r){if(W(t))return o>=0&&o<t.points.length?rn(n,i)*r.value<e.POINT_HANDLE_SIZE/2:!1;let s=rn(n,i);if(t.points.length>2&&t.roundness){let[a,l]=Tl(t);Te(a.length===0&&l.length>0,"Only linears built out of curves are supported"),Te(a.length+l.length>=o,"Invalid segment index while calculating mid point"),s=Lp(l[o])}return s*r.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,n){if(W(t)){Te(t.points.length>=n,"Invalid segment index while calculating elbow arrow mid point");let r=Il(t.points[n-1],t.points[n]);return C(t.x+r[0],t.y+r[1])}let[i,o]=Tl(t);if(Te(i.length===0&&o.length>0||i.length>0&&o.length===0,"Only linears built out of either segments or curves are supported"),Te(i.length+o.length>=n,"Invalid segment index while calculating mid point"),i.length){let r=i[n-1];return Il(r[0],r[1])}if(o.length){let r=o[n-1];return Bp(r,.5)}Te(!1,"Invalid segment type while calculating mid point")}static getSegmentMidPointIndex(t,n,i,o){let r=e.getElement(t.elementId,o);if(!r)return-1;let s=e.getEditorMidPoints(r,o,n),a=0;for(;a<s.length;){if(e.arePointsEqual(i,s[a]))return a+1;a++}return-1}static handlePointerDown(t,n,i,o,r,s){let a=n.state,l=s.getNonDeletedElementsMap(),d={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!r)return d;let{elementId:c}=r,u=e.getElement(c,l);if(!u)return d;let m=e.getSegmentMidpointHitCoords(r,o,a,l),p=C(o.x,o.y),f=null;if(m)f=e.getSegmentMidPointIndex(r,a,m,l);else if(t.altKey&&a.selectedLinearElement?.isEditing)return r.lastUncommittedPoint==null&&(s.mutateElement(u,{points:[...u.points,e.createPointAt(u,l,o.x,o.y,t[vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize())]}),d.didAddPoint=!0),i.scheduleCapture(),d.linearElementEditor={...r,initialState:{prevSelectedPointsIndices:r.selectedPointsIndices,lastClickedPoint:-1,origin:p,segmentMidpoint:{value:m,index:f,added:!1},arrowStartIsInside:!!n.state.newElement&&(n.state.bindMode==="inside"||n.state.bindMode==="skip"),altFocusPoint:null},selectedPointsIndices:[u.points.length-1],lastUncommittedPoint:null},d.didAddPoint=!0,d;let h=e.getPointIndexUnderCursor(u,l,a.zoom,o.x,o.y);(h>=0||m)&&(d.hitElement=u);let[E,g,x,w]=j(u,l),b=(E+x)/2,y=(g+w)/2,I=h>-1&&Ae(C(u.x+u.points[h][0],u.y+u.points[h][1]),C(b,y),u.angle),S=h>-1||t.shiftKey?t.shiftKey||r.selectedPointsIndices?.includes(h)?kp([...r.selectedPointsIndices||[],h]):[h]:null;return d.linearElementEditor={...r,initialState:{prevSelectedPointsIndices:r.selectedPointsIndices,lastClickedPoint:h,origin:p,segmentMidpoint:{value:m,index:f,added:!1},arrowStartIsInside:!!n.state.newElement&&(n.state.bindMode==="inside"||n.state.bindMode==="skip"),altFocusPoint:null},selectedPointsIndices:S,pointerOffset:I?{x:o.x-I[0],y:o.y-I[1]}:{x:0,y:0}},d}static arePointsEqual(t,n){return!t&&!n?!0:!t||!n?!1:Sl(t,n)}static handlePointerMoveInEditMode(t,n,i,o){let r=o.state;if(!r.selectedLinearElement?.isEditing)return null;let{elementId:s,lastUncommittedPoint:a}=r.selectedLinearElement,l=o.scene.getNonDeletedElementsMap(),d=e.getElement(s,l);if(!d)return r.selectedLinearElement;let{points:c}=d,u=c[c.length-1];if(!t.altKey)return u===a&&e.deletePoints(d,o,[c.length-1]),r.selectedLinearElement?.lastUncommittedPoint?{...r.selectedLinearElement,lastUncommittedPoint:null}:r.selectedLinearElement;let m;if(Si(t)&&c.length>=2){let p=c[c.length-2],[f,h]=e._getShiftLockedDelta(d,l,p,C(n,i),t[vn.CTRL_OR_CMD]?null:o.getEffectiveGridSize());m=C(f+p[0],h+p[1])}else m=e.createPointAt(d,l,n-r.selectedLinearElement.pointerOffset.x,i-r.selectedLinearElement.pointerOffset.y,t[vn.CTRL_OR_CMD]||W(d)?null:o.getEffectiveGridSize());return u===a?e.movePoints(d,o.scene,new Map([[d.points.length-1,{point:m}]])):e.addPoints(d,o.scene,[m]),{...r.selectedLinearElement,lastUncommittedPoint:d.points[d.points.length-1]}}static getPointGlobalCoordinates(t,n,i){let[o,r,s,a]=j(t,i),l=(o+s)/2,d=(r+a)/2,{x:c,y:u}=t;return Ae(C(c+n[0],u+n[1]),C(l,d),t.angle)}static getPointsGlobalCoordinates(t,n){let[i,o,r,s]=j(t,n),a=(i+r)/2,l=(o+s)/2;return t.points.map(d=>{let{x:c,y:u}=t;return Ae(C(c+d[0],u+d[1]),C(a,l),t.angle)})}static getPointAtIndexGlobalCoordinates(t,n,i){let o=n<0?t.points.length+n:n,[,,,,r,s]=j(t,i),a=C(r,s),l=t.points[o],{x:d,y:c}=t;return l?Ae(C(d+l[0],c+l[1]),a,t.angle):Ae(C(d,c),a,t.angle)}static pointFromAbsoluteCoords(t,n,i){if(W(t))return C(n[0]-t.x,n[1]-t.y);let[o,r,s,a]=j(t,i),l=(o+s)/2,d=(r+a)/2,[c,u]=Ae(C(n[0],n[1]),C(l,d),-t.angle);return C(c-t.x,u-t.y)}static getPointIndexUnderCursor(t,n,i,o,r){let s=e.getPointsGlobalCoordinates(t,n),a=s.length;for(;--a>-1;){let l=s[a];if(rn(C(o,r),C(l[0],l[1]))*i.value<e.POINT_HANDLE_SIZE+1)return a}return-1}static createPointAt(t,n,i,o,r){let s=Al(i,o,r),[a,l,d,c]=j(t,n),u=(a+d)/2,m=(l+c)/2,[p,f]=Ae(C(s[0],s[1]),C(u,m),-t.angle);return C(p-t.x,f-t.y)}static getNormalizeElementPointsAndCoords(t){let{points:n,offsetX:i,offsetY:o}=ts(t);return{points:n,x:t.x+i,y:t.y+o}}static duplicateSelectedPoints(t,n){Te(t.selectedLinearElement?.isEditing,"Not currently editing a linear element");let i=n.getNonDeletedElementsMap(),{selectedPointsIndices:o,elementId:r}=t.selectedLinearElement,s=e.getElement(r,i);Te(s,"The linear element does not exist in the provided Scene"),Te(o!=null,"There are no selected points to duplicate");let{points:a}=s,l=[],d=!1,c=-1,u=a.reduce((m,p,f)=>{if(++c,m.push(p),o.includes(f)){let E=a[f+1];E||(d=!0),m.push(E?C((p[0]+E[0])/2,(p[1]+E[1])/2):C(p[0],p[1])),l.push(c+1),++c}return m},[]);if(n.mutateElement(s,{points:u}),d){let m=s.points[s.points.length-1];e.movePoints(s,n,new Map([[s.points.length-1,{point:C(m[0]+30,m[1]+30)}]]))}return{...t,selectedLinearElement:{...t.selectedLinearElement,selectedPointsIndices:l}}}static deletePoints(t,n,i){let o=n.state.selectedLinearElement?.isEditing&&n.state.selectedLinearElement?.lastUncommittedPoint===t.points[t.points.length-1],r=t.points.filter((c,u)=>!i.includes(u));It(t)&&t.polygon&&(o||i.includes(0)||i.includes(t.points.length-1))&&(r[0]=C(r[r.length-1][0],r[r.length-1][1]));let{points:a,offsetX:l,offsetY:d}=ts({points:r});e._updatePoints(t,n.scene,a,l,d)}static addPoints(t,n,i){let o=[...t.points,...i];It(t)&&t.polygon&&(o[0]=C(o[o.length-1][0],o[o.length-1][1]));let{points:r,offsetX:s,offsetY:a}=ts({points:o});e._updatePoints(t,n,r,s,a)}static movePoints(t,n,i,o){let{points:r}=t;if(It(t)&&t.polygon){let c=i.get(0),u=i.get(r.length-1);c?i.set(r.length-1,{point:C(c.point[0],c.point[1]),isDragging:c.isDragging}):u&&i.set(0,{point:C(u.point[0],u.point[1]),isDragging:u.isDragging})}let s=i.get(0)?.point??C(0,0),[a,l]=s,d=W(t)?[i.get(0)?.point??r[0],i.get(r.length-1)?.point??r[r.length-1]]:r.map((c,u)=>{let m=i.get(u)?.point??c;return o?.moveMidPointsWithElement&&u!==0&&u!==r.length-1&&!i.has(u)?m:C(m[0]-a,m[1]-l)});e._updatePoints(t,n,d,a,l,o,{isDragging:Array.from(i.values()).some(c=>c.isDragging)})}static shouldAddMidpoint(t,n,i,o){let r=e.getElement(t.elementId,o);if(r&&W(r)||!r)return!1;let{segmentMidpoint:s}=t.initialState;if(s.added||s.value===null||s.index===null||t.initialState.origin===null)return!1;let a=t.initialState.origin,l=rn(a,C(n.x,n.y));return!(!i.selectedLinearElement?.isEditing&&l<Cp/i.zoom.value)}static addMidpoint(t,n,i,o,r){let s=r.getNonDeletedElementsMap(),a=e.getElement(t.elementId,s);if(!a)return;let{segmentMidpoint:l}=t.initialState,d={pointerDownState:t.initialState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,s,n.x,n.y,o&&!W(a)?i.getEffectiveGridSize():null),u=[...a.points.slice(0,l.index),c,...a.points.slice(l.index)];return r.mutateElement(a,{points:u}),d.pointerDownState={...t.initialState,segmentMidpoint:{...t.initialState.segmentMidpoint,added:!0},lastClickedPoint:l.index},d.selectedPointsIndices=[l.index],d}static _updatePoints(t,n,i,o,r,s,a){if(W(t)){let l={};s?.startBinding!==void 0&&(l.startBinding=s.startBinding),s?.endBinding!==void 0&&(l.endBinding=s.endBinding),l.points=Array.from(i),n.mutateElement(t,l,{informMutation:!0,isDragging:a?.isDragging??!1})}else{let l=ns(t,i),d=ns(t,t.points),c=(l[0]+l[2])/2,u=(l[1]+l[3])/2,m=(d[0]+d[2])/2,p=(d[1]+d[3])/2,f=m-c,h=p-u,E=Ae(C(o,r),C(f,h),t.angle);n.mutateElement(t,{...s,points:i,x:t.x+E[0],y:t.y+E[1]})}}static _getShiftLockedDelta(t,n,i,o,r,s){let a=e.getPointGlobalCoordinates(t,i,n);if(W(t))return[o[0]-a[0],o[1]-a[1]];let[l,d]=Al(o[0],o[1],r),{width:c,height:u}=Gl(a[0],a[1],l,d,s);return Ae(C(c,u),C(0,0),-t.angle)}static getBoundTextElementPosition=(t,n,i)=>{e.getPointsGlobalCoordinates(t,i).length<2&&ye(n,i,{isDeleted:!0});let r=0,s=0;if(t.points.length%2===1){let a=Math.floor(t.points.length/2),l=e.getPointGlobalCoordinates(t,t.points[a],i);r=l[0]-n.width/2,s=l[1]-n.height/2}else{let a=t.points.length/2-1,l=e.getSegmentMidPoint(t,a+1);r=l[0]-n.width/2,s=l[1]-n.height/2}return{x:r,y:s}};static getMinMaxXYWithBoundText=(t,n,i,o)=>{let[r,s,a,l]=i,d=(r+a)/2,c=(s+l)/2,{x:u,y:m}=e.getBoundTextElementPosition(t,o,n),p=u+o.width,f=m+o.height,h=C(d,c),E=Ae(C(r,s),h,t.angle),g=Ae(C(a,s),h,t.angle),x=Ae(C(u,m),h,-t.angle),w=Ae(C(p,m),h,-t.angle),b=Ae(C(u,f),h,-t.angle),y=Ae(C(p,f),h,-t.angle);return E[0]<g[0]&&E[1]>=g[1]?(r=Math.min(r,b[0]),a=Math.max(a,Math.max(w[0],y[0])),s=Math.min(s,x[1]),l=Math.max(l,y[1])):E[0]>=g[0]&&E[1]>g[1]?(r=Math.min(r,y[0]),a=Math.max(a,Math.max(x[0],w[0])),s=Math.min(s,b[1]),l=Math.max(l,w[1])):E[0]>=g[0]?(r=Math.min(r,w[0]),a=Math.max(a,b[0]),s=Math.min(s,y[1]),l=Math.max(l,x[1])):E[1]<=g[1]&&(r=Math.min(r,Math.min(w[0],x[0])),a=Math.max(a,y[0]),s=Math.min(s,w[1]),l=Math.max(l,b[1])),[r,s,a,l,d,c]};static getElementAbsoluteCoords=(t,n,i=!1)=>{let o=Xe.generateElementShape(t,null),r=bt(o[0]),[s,a,l,d]=Ai(r),c=s+t.x,u=a+t.y,m=l+t.x,p=d+t.y,f=(c+m)/2,h=(u+p)/2,E=i&&V(t,n);return E?e.getMinMaxXYWithBoundText(t,n,[c,u,m,p],E):[c,u,m,p,f,h]};static moveFixedSegment(t,n,i,o,r){let s=r.getNonDeletedElementsMap(),a=e.getElement(t.elementId,s);if(!a||!W(a))return t;if(n&&n>0&&n<a.points.length){let l=Fe(Bt(Dp(a.points[n],a.points[n-1]))),d=(a.fixedSegments??[]).reduce((p,f)=>(p[f.index]=f,p),{});d[n]={index:n,start:C(l?a.points[n-1][0]:i-a.x,l?o-a.y:a.points[n-1][1]),end:C(l?a.points[n][0]:i-a.x,l?o-a.y:a.points[n][1])};let c=Object.values(d).sort((p,f)=>p.index-f.index),u=c.map(p=>p.index).reduce((p,f)=>f<n?p+1:p,0);r.mutateElement(a,{fixedSegments:c});let m=C(a.x+(a.fixedSegments[u].start[0]+a.fixedSegments[u].end[0])/2,a.y+(a.fixedSegments[u].start[1]+a.fixedSegments[u].end[1])/2);return{...t,segmentMidPointHoveredCoords:m,initialState:{...t.initialState,segmentMidpoint:{added:!1,index:a.fixedSegments[u].index,value:m}}}}return t}static deleteFixedSegment(t,n,i){n.mutateElement(t,{fixedSegments:t.fixedSegments?.filter(o=>o.index!==i)})}},kp=e=>{let t=[...new Set(e.filter(n=>n!==null&&n!==-1))];return t=t.sort((n,i)=>n-i),t.length?t:null},Ll=(e,t,n,i,o,r,s,a,l,d,c)=>{let u=new Map(e.map(Y=>[Y,{point:C(s.points[Y][0]+t,s.points[Y][1]+n),isDragging:!0}]));if(!z(s))return{positions:u};let m=e.includes(0),p=e.includes(s.points.length-1),{start:f,end:h}=es(s,u,i,o,r,a,l.state,{newArrow:!!l.state.newElement,angleLocked:d,altKey:c});if(W(s))return{positions:u,updates:{suggestedBinding:m?f.element:p?h.element:null}};if(m===p)return{positions:u};let E={suggestedBinding:null};f.mode===null?E.startBinding=null:f.mode?(E.startBinding={elementId:f.element.id,mode:f.mode,...Lo(s,f.element,"start",r,f.focusPoint)},m&&(E.startBinding.mode==="orbit"||!Mi("COMPLEX_BINDINGS"))&&(E.suggestedBinding=f.element)):m&&(E.suggestedBinding=l.state.suggestedBinding),h.mode===null?E.endBinding=null:h.mode?(E.endBinding={elementId:h.element.id,mode:h.mode,...Lo(s,h.element,"end",r,h.focusPoint)},p&&(E.endBinding.mode==="orbit"||!Mi("COMPLEX_BINDINGS"))&&(E.suggestedBinding=h.element)):p&&(E.suggestedBinding=l.state.suggestedBinding);let g=m?C(s.points[0][0]+t,s.points[0][1]+n):s.points[0],x=p?C(s.points[s.points.length-1][0]+t,s.points[s.points.length-1][1]+n):s.points[s.points.length-1],w={...s,points:[g,...s.points.slice(1,-1),x],startBinding:E.startBinding===void 0?s.startBinding:E.startBinding===null?null:E.startBinding,endBinding:E.endBinding===void 0?s.endBinding:E.endBinding===null?null:E.endBinding},b=f.focusPoint&&h.focusPoint?Ml(f.focusPoint,h.focusPoint):void 0,y=f.focusPoint&&h.focusPoint?Ml(h.focusPoint,f.focusPoint):void 0,I=s.endBinding&&w.startBinding&&m&&w.startBinding.elementId===s.endBinding.elementId,S=s.startBinding&&w.endBinding&&p&&s.startBinding.elementId===w.endBinding.elementId,A=w.endBinding?h.element??r.get(w.endBinding.elementId):null,M=I?w.points[w.points.length-1]:S&&l.state.bindMode!=="inside"&&Mi("COMPLEX_BINDINGS")?w.points[0]:A&&Un(s,"endBinding",w.endBinding,A,r,y)||w.points[w.points.length-1];w.points[w.points.length-1]=M;let k=w.startBinding?f.element??r.get(w.startBinding.elementId):null,L=S&&Mi("COMPLEX_BINDINGS")?w.points[0]:I&&l.state.bindMode!=="inside"&&Mi("COMPLEX_BINDINGS")?w.points[w.points.length-1]:k&&Un(s,"startBinding",w.startBinding,k,r,b)||w.points[0],G=rn(M,w.points[w.points.length-1])!==0,B=rn(L,w.points[0])!==0,U=new Set(e);k&&B&&U.add(0),A&&G&&U.add(s.points.length-1);let N=Array.from(U);return{updates:E.startBinding||E.suggestedBinding?{startBinding:E.startBinding,suggestedBinding:E.suggestedBinding}:void 0,positions:new Map(N.map(Y=>[Y,Y===0?{point:L,isDragging:!0}:Y===s.points.length-1?{point:M,isDragging:!0}:u.get(Y)]))}},Bl=(e,t)=>Math.atan2(t[1]-e[1],t[0]-e[0]);P();import{arrayToMap as ht}from"@excalidraw/common";import{isPointWithinBounds as of,pointFrom as as}from"@excalidraw/math";P();import{vectorCross as Fl,vectorFromPoint as Bo}from"@excalidraw/math";function Ol(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function Rp(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}var Fp=1e-6;function kl(e,t){let n=Bo(e[1],e[0]),i=Bo(t,e[0]),o=Fl(n,i);return Math.abs(o)<Fp}function is(e,t){let n=Bo(e[1],e[0]),i=Bo(t,e[0]);return Fl(n,i)<0}function Rl(e,t){return kl(e,t[0])||kl(e,t[1])||(is(e,t[0])?!is(e,t[1]):is(e,t[1]))}function Nl(e,t){return Rp(Ol(e),Ol(t))&&Rl(e,t)&&Rl(t,e)}P();import{arrayToMap as Np}from"@excalidraw/common";import{getElementBounds as zp}from"@excalidraw/element";import{isArrowElement as Hp,isExcalidrawElement as _p,isFreeDrawElement as Up,isLinearElement as Yp,isTextElement as Wp}from"@excalidraw/element";import{rangeIncludesValue as Co,pointFrom as kt,pointRotateRads as Xp,rangeInclusive as Go}from"@excalidraw/math";var jp=e=>e.type==="diamond"?[kt(e.width/2,0),kt(e.width,e.height/2),kt(e.width/2,e.height),kt(0,e.height/2)]:[kt(0,0),kt(0+e.width,0),kt(0+e.width,e.height),kt(0,e.height)],Vp=e=>Yp(e)||Up(e)?e.points:jp(e),zl=e=>{let t=e.reduce((n,[i,o])=>(n.minY=Math.min(n.minY,o),n.minX=Math.min(n.minX,i),n.maxX=Math.max(n.maxX,i),n.maxY=Math.max(n.maxY,o),n),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},_l=e=>{let t=Vp(e),{cx:n,cy:i}=zl(t),o=kt(n,i),r=t.map(c=>Xp(c,o,e.angle)),{minX:s,minY:a,maxX:l,maxY:d}=zl(r);return[s+e.x,a+e.y,l+e.x,d+e.y]},Hl=(e,t,n=!1)=>{let i=_l(e),o=t[0]<=i[0]&&t[2]>=i[2]&&t[1]<=i[1]&&t[3]>=i[3];return n?o?!0:i[0]<=t[0]&&i[2]>=t[2]&&i[1]<=t[1]&&i[3]>=t[3]:o},$p=(e,t)=>{let n=_l(e);return(Co(n[0],Go(t[0],t[2]))||Co(t[0],Go(n[0],n[2])))&&(Co(n[1],Go(t[1],t[3]))||Co(t[1],Go(n[1],n[3])))},Ul=({elements:e,bounds:t,type:n,errorMargin:i=0})=>{_p(t)&&(t=zp(t,Np(e)));let o=[t[0]-i,t[1]-i,t[2]+i,t[3]+i],r=new Set;for(let s of e){if(r.has(s.id))continue;if(n==="overlap"?$p(s,o):n==="inside"?Hl(s,o):Hl(s,o,!0)){if(r.add(s.id),s.boundElements)for(let l of s.boundElements)r.add(l.id);Wp(s)&&s.containerId&&r.add(s.containerId),Hp(s)&&(s.startBinding&&r.add(s.startBinding.elementId),s.endBinding&&r.add(s.endBinding?.elementId))}}return e.filter(s=>r.has(s.id))};P();import{arrayToMap as ef,isShallowEqual as tf}from"@excalidraw/common";P();var Zp=(e,t,n)=>{let i=n.reduce((o,r)=>(r.groupIds.includes(e)&&(o[r.id]=!0),o),{});return Object.keys(i).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...i}}},Yl=function(){let e=null,t=null,n=null,i=(r,s,a,l)=>{if(n!==void 0&&s===t&&r===e&&a.editingGroupId===n?.editingGroupId)return n;let d={};for(let m of r){let p=m.groupIds;if(a.editingGroupId){let f=p.indexOf(a.editingGroupId);f>-1&&(p=p.slice(0,f))}if(p.length>0){let f=p[p.length-1];d[f]=!0}}let c={},u=s.reduce((m,p)=>{if(p.isDeleted)return m;let f=p.groupIds.find(h=>d[h]);return f&&(m[p.id]=!0,Array.isArray(c[f])?c[f].push(p.id):c[f]=[p.id]),m},{});for(let m of Object.keys(c))c[m].length<2&&d[m]&&(d[m]=!1);return t=s,e=r,n={editingGroupId:a.editingGroupId,selectedGroupIds:d,selectedElementIds:os({...a.selectedElementIds,...u},l)},n},o=(r,s,a,l)=>{let d=l?l.scene.getSelectedElements({selectedElementIds:r.selectedElementIds,elements:s}):ft(s,r);return d.length?i(d,s,r,a):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:os(r.selectedElementIds,a)}};return o.clearCache=()=>{t=null,e=null,n=null},o}(),qp=(e,t)=>rs(e,t)!=null,rs=(e,t)=>t.groupIds.filter(n=>n!==e.editingGroupId).find(n=>e.selectedGroupIds[n]),Kp=e=>Object.entries(e.selectedGroupIds).filter(([t,n])=>n).map(([t,n])=>t),Wl=(e,t)=>{let n={...t,selectedGroupIds:{}};for(let i of e){let o=i.groupIds;if(t.editingGroupId){let r=o.indexOf(t.editingGroupId);r>-1&&(o=o.slice(0,r))}if(o.length>0){let r=o[o.length-1];n={...n,...Zp(r,n,e)}}}return n.selectedGroupIds},Rb=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),Qp=(e,t)=>e.groupIds.includes(t),ve=(e,t)=>{let n=[];for(let i of e.values())Qp(i,t)&&n.push(i);return n},Jp=(e,t)=>e.groupIds.find(n=>t[n]),Fb=(e,t,n)=>{let i=[...e],o=n?i.indexOf(n):-1,r=o>-1?o:i.length;return i.splice(r,0,t),i},Nb=(e,t)=>e.filter(n=>!t[n]),Oo=(e,t)=>{let n=new Map;return e.forEach(i=>{let o=i.groupIds.length===0?i.id:i.groupIds[i.groupIds.length-1],r=n.get(o)||[],s=V(i,t);s&&r.push(s),n.set(o,[...r,i])}),Array.from(n.values())},Xl=e=>{let t=new Set;for(let[,n]of e)if(!n.isDeleted)for(let i of n.groupIds??[])t.add(i);return t},jl=e=>{let t=e.flatMap(o=>o.groupIds),n=new Map,i=0;for(let o of t)n.set(o,(n.get(o)??0)+1),n.get(o)>i&&(i=n.get(o));return i===e.length},Vl=e=>e.groupIds.length>0,$l=(e,t,n)=>{let i=[...e],o=t?e.indexOf(t):-1,r=o>-1?o:e.length;for(let s=0;s<r;s++)i[s]=n(i[s]);return i},ko=(e,t,n)=>{let i=Kp(n),o=e.filter(u=>!ce(u)),r=new Map,s=new Map,a=u=>{let m=s.get(u.id)||[],p=V(u,t);p&&m.push(p),s.set(u.id,[...m,u])},l=(u,m)=>{let p=r.get(m)||[],f=V(u,t);f&&p.push(f),r.set(m,[...p,u])},d=(u,m)=>{let p=u.groupIds.indexOf(m,0);return u.groupIds.slice(0,p).length>0?l(u,u.groupIds[p-1]):a(u)},c=e.every(u=>qp(n,u));return o.forEach(u=>{let m=Jp(u,n.selectedGroupIds);m?i.length===1&&c?d(u,m):l(u,m):a(u)}),Array.from(r.values()).concat(Array.from(s.values()))};var Zl=e=>{let t=new Set;return e.forEach(n=>{K(n)&&t.add(n.id)}),e.filter(n=>!(n.frameId&&t.has(n.frameId)))},ss=(e,t,n,i=!0)=>{let[o,r,s,a]=j(t,n),l=e.filter(d=>{let[c,u,m,p]=ae(d,n),f=Rt(d,n);if(f){let[h,E,g,x]=ae(f,n);c=Math.max(h,c),u=Math.max(E,u),m=Math.min(g,m),p=Math.min(x,p)}return d.locked===!1&&d.type!=="selection"&&!ce(d)&&o<=c&&r<=u&&s>=m&&a>=p});return l=i?Zl(l):l,l=l.filter(d=>{let c=Rt(d,n);return c?sn(d,c,n):!0}),l},$b=(e,t,n,i)=>{let o=new Set(t.map(r=>r.id));return e.filter(r=>{let s=ql(r,n.width,n.height,n,i);return!o.has(r.id)&&s})},Zb=function(){let e=null,t=null,n=null,i=(o,r)=>(n!=null&&o===e&&r.selectedElementIds===t||(n=o.some(s=>r.selectedElementIds[s.id]),e=o,t=r.selectedElementIds),n);return i.clearCache=()=>{e=null,t=null,n=null},i}(),ft=(e,t,n)=>{let i=new Set,o=[];for(let r of e.values()){if(t.selectedElementIds[r.id]){o.push(r),i.add(r.id);continue}if(n?.includeBoundTextElement&&ce(r)&&t.selectedElementIds[r?.containerId]){o.push(r),i.add(r.id);continue}}if(n?.includeElementsInFrames){let r=[];return o.forEach(s=>{K(s)&&an(e,s.id).forEach(a=>!i.has(a.id)&&r.push(a)),r.push(s)}),r}return o},qb=(e,t)=>t.editingTextElement?[t.editingTextElement]:t.newElement?[t.newElement]:ft(e,t,{includeBoundTextElement:!0}),os=(e,t)=>tf(t.selectedElementIds,e)?t.selectedElementIds:e,nf=(e,t)=>{let n=e.filter(Q);if(n.length===1){let i=n[0],o=i.boundElements?.map(s=>s.id)??[];if(e.every(s=>s.id===i.id||o.includes(s.id)))return new O(i,ef(t))}return null},Kb=(e,t,n)=>({selectedLinearElement:nf(e,t),...Yl({editingGroupId:n.editingGroupId,selectedElementIds:Zl(e).reduce((i,o)=>(ce(o)||(i[o.id]=!0),i),{})},t,n,null)});var Kl=(e,t,n)=>{let i=ht(e);for(let o of t)if(o.frameId){let r=n.get(o.id),s=n.get(o.frameId),a=r&&i.get(r);a&&ye(a,i,{frameId:s??null})}};function Yn(e,t,n){let i=ls(t,n),o=ls(e,n);return i.some(s=>o.some(a=>Nl(s,a)))}var Ql=(e,t,n)=>Ro(ss(e,t,n,!1)).filter(i=>!K(i)&&!i.frameId||i.frameId===t.id),ds=(e,t,n)=>ss([t],e,n).some(i=>i.id===t.id),c0=(e,t)=>{let n=ht(e);return e.filter(i=>Yn(i,t,n))},ln=(e,t,n)=>{let[i,o,r,s]=j(t,n),[a,l,d,c]=De(e);return i<=a&&o<=l&&r>=d&&s>=c},sn=(e,t,n)=>ln([e],t,n)||Yn(e,t,n)||ds(e,t,n),u0=(e,t,n)=>{let[i,o,r,s]=j(t,n);return of(as(i,o),as(e.x,e.y),as(r,s))},m0=(e,t,n)=>{let i=ht(e),o=t.flatMap(r=>ve(e,r));return o.length===0?!0:!!o.find(r=>ln([r],n,i)||Yn(r,n,i))},p0=(e,t,n)=>{let i=ht(e),o=t.flatMap(r=>ve(e,r));return o.length===0?!0:o.find(r=>ln([r],n,i)||Yn(r,n,i))===void 0},f0=e=>{let t=new Map;for(let n of e){let i=K(n)?n.id:n.frameId;i&&!t.has(i)&&t.set(i,an(e,i))}return t},an=(e,t)=>{let n=[];for(let i of e.values())i.frameId===t&&n.push(i);return n},rf=e=>e.filter(t=>K(t)),h0=e=>{let t=ht(rf(e));return e.filter(n=>t.has(n.id)||!n.frameId||!t.has(n.frameId))},E0=(e,t,n,i)=>{let o=an(e,t.id),r=new Set(o),s=new Set([...Ql(e,t,i),...o.filter(m=>ds(m,t,i))]),a=o.filter(m=>!s.has(m)),l=new Set(Array.from(s).flatMap(m=>m.groupIds));for(let m of a)if(!Yn(m,t,i))m.groupIds.length===0&&r.delete(m);else if(m.groupIds.length>0)for(let p of m.groupIds)l.add(p);for(let m of a)if(m.groupIds.length>0){let p=!0;for(let f of m.groupIds)l.has(f)&&(p=!1);p&&r.delete(m)}let d=Array.from(s).filter(m=>m.groupIds.length===0);for(let m of d)r.add(m);let c=Array.from(s).filter(m=>m.groupIds.length>0),u=Wl(c,n);for(let[m,p]of Object.entries(u))if(p){let f=ve(e,m);if(ln(f,t,i))for(let h of f)r.add(h)}return[...r].filter(m=>!(ee(m)&&m.containerId))},g0=(e,t,n)=>sf(Ro(e,Ql(e,t,n)),t,n),sf=(e,t,n)=>{let i=[],o=new Map;for(let r of e){let s=!1;if(r.groupIds.length>0){if(r.groupIds.some(a=>o.get(a)))s=!0;else{let a=new Set(r.groupIds.flatMap(l=>ve(n,l)));s=!ln(Array.from(a),t,n)}r.groupIds.forEach(a=>{o.set(a,s)})}s||i.push(r)}return i},Rt=(e,t)=>e.frameId&&t.get(e.frameId)||null,x0=(e,t)=>{let n=new Set,i=ht(e);e=Ro(e);for(let s of e)K(s)&&s.id!==t.id&&n.add(s.id);let o=new Set,r=[];for(let s of e)if(!(K(s)||s.frameId&&n.has(s.frameId)))if(s.groupIds.length){let a=s.groupIds.at(-1);if(!o.has(a)){o.add(a);let l=ve(e,a);if(l.some(d=>sn(d,t,i)))for(let d of l)r.push(d)}}else sn(s,t,i)&&r.push(s);return r},af=(e,t,n,i)=>{let o=ht(e),r=new Map;for(let d of e.values())d.frameId===n.id&&r.set(d.id,!0);let s=new Set(t.map(d=>d.id)),a=[],l=new Set;for(let d of t)K(d)&&d.id!==n.id&&l.add(d.id);for(let d of Ro(e,t)){if(K(d)||d.frameId&&l.has(d.frameId)||d.frameId&&i.selectedElementIds[d.id]&&i.selectedElementIds[d.frameId])continue;r.has(d.id)||a.push(d);let c=V(d,o);c&&!s.has(c.id)&&!r.has(c.id)&&a.push(c)}for(let d of a)ye(d,o,{frameId:n.id});return e},Jl=(e,t)=>{let n=new Map,i=new Map;for(let o of e)if(o.frameId){n.set(o.id,o);let r=i.get(o.frameId)||[];r.push(o);let s=V(o,t);s&&(n.set(s.id,s),r.push(s)),i.set(o.frameId,r)}for(let[,o]of n)ye(o,t,{frameId:null})},lf=(e,t)=>{let n=an(e,t.id);return Jl(n,ht(e)),e},w0=(e,t,n,i)=>af(lf(e,n),t,n,i.state).slice(),y0=(e,t,n)=>{let i=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),o=new Set(i);if(t.editingGroupId)for(let a of i)a.groupIds.length===0?o.add(a):a.groupIds.flatMap(l=>ve(e,l)).forEach(l=>o.add(l));let r=new Set,s=ht(e);return o.forEach(a=>{a.frameId&&!K(a)&&!ed(a,s,t)&&r.add(a)}),r.size>0&&Jl(r,s),e},Ro=(e,t)=>{let n=new Set,i=t||e;for(let s of i.values()){let a=s.groupIds[s.groupIds.length-1];a&&n.add(a)}let o=new Set;for(let s of n)ve(e,s).some(a=>K(a))&&o.add(s);let r=[];for(let s of i.values())o.has(s.groupIds[s.groupIds.length-1])||r.push(s);return r},df=(e,t,n)=>{let i=ee(e)&&Se(e,t)||e;return i.frameId&&n.selectedElementIds[i.id]&&n.selectedElementIds[i.frameId]?Rt(i,t):n.selectedElementIds[i.id]&&n.selectedElementsAreBeingDragged?n.frameToHighlight:Rt(i,t)},ed=(e,t,n,i)=>{let o=i?.targetFrame??df(e,t,n);if(!o)return!1;let r=ee(e)&&Se(e,t)||e,s=l=>{i?.checkedGroups&&r.groupIds.forEach(d=>{i.checkedGroups?.set(d,l)})};if(!n.selectedElementIds[r.id]||!n.selectedElementsAreBeingDragged||n.selectedElementIds[r.id]&&n.selectedElementIds[o.id])return!0;if(r.groupIds.length===0)return sn(r,o,t);for(let l of r.groupIds)if(i?.checkedGroups?.has(l))return i.checkedGroups.get(l);let a=new Set(r.groupIds.filter(l=>i?.checkedGroups?!i.checkedGroups.has(l):!0).flatMap(l=>ve(t,l)));if(n.editingGroupId&&n.selectedElementsAreBeingDragged){let l=new Set(ft(t,n));if(n.frameToHighlight!==null)return!0;l.forEach(c=>{a.delete(c)})}for(let l of a)if(K(l))return s(!1),!1;for(let l of a)if(sn(l,o,t))return s(!0),!0;return!1},b0=(e,t,n,i,o)=>{if(!n.frameRendering||!n.frameRendering.clip)return!1;let r=Yn(e,t,i)||ds(e,t,i);if(r){for(let s of e.groupIds)o?.set(s,!0);return!0}if(!r&&e.groupIds.length>0&&!ln([e],t,i)){let s=!1;if(n.selectedElementsAreBeingDragged)s=ed(e,i,n,{targetFrame:t,checkedGroups:o});else{s=e.frameId===t.id;for(let a of e.groupIds)o?.set(a,s)}for(let a of e.groupIds)o?.set(a,s);return s}return!1},cf="Frame",uf="AI Frame",mf=e=>oo(e)?cf:uf,P0=e=>e.name===null?mf(e):e.name,I0=(e,t)=>Ul({elements:e,bounds:t,type:"overlap"}).filter(n=>!n.frameId||n.frameId===t.id),S0=e=>{let t=ht(e);return e.length>1&&e.some(n=>n.frameId&&t.has(n.frameId))};var bf=(e,t)=>yn(e)&&!t.imageCache.has(e.fileId),_o=e=>{switch(e.type){case"freedraw":return e.strokeWidth*12;case"text":return e.fontSize/2;case"arrow":return e.endArrowhead||e.endArrowhead?40:20;default:return 20}},Pf=(e,t,n,i,o=1)=>{let r=(t?.opacity??100)*e.opacity/1e4*o;return(n.has(e.id)||i&&i.some(s=>s.id===e.id)||t&&n.has(t.id))&&(r*=hf/100),r},If=(e,t,n)=>{let r=_o(e),[s,a,l,d]=j(e,t),c=Q(e)||Ie(e)?dn(s,l):e.width,u=Q(e)||Ie(e)?dn(a,d):e.height,m=c*window.devicePixelRatio+r*2,p=u*window.devicePixelRatio+r*2,f=n.value;return(m*f>32767||p*f>32767)&&(f=Math.min(32767/m,32767/p)),m*p*f*f>16777216&&(f=Math.sqrt(16777216/(m*p))),m=Math.floor(m*f),p=Math.floor(p*f),{width:m,height:p,scale:f}},id=(e,t,n,i,o)=>{let r=document.createElement("canvas"),s=r.getContext("2d"),a=_o(e),{width:l,height:d,scale:c}=If(e,t,n);if(!l||!d)return null;r.width=l,r.height=d;let u=-100,m=0;if(Q(e)||Ie(e)){let[g,x]=j(e,t);u=e.x>g?dn(e.x,g)*window.devicePixelRatio*c:0,m=e.y>x?dn(e.y,x)*window.devicePixelRatio*c:0,s.translate(u,m)}s.save(),s.translate(a*c,a*c),s.scale(window.devicePixelRatio*c,window.devicePixelRatio*c);let p=wn.canvas(r);zo(e,p,s,i),s.restore();let f=V(e,t),h=document.createElement("canvas"),E=h.getContext("2d");if(z(e)&&f){let[g,x,w,b]=j(e,t),y=Math.max(dn(g,w),dn(x,b));h.width=y*window.devicePixelRatio*c+a*c*10,h.height=y*window.devicePixelRatio*c+a*c*10,E.translate(h.width/2,h.height/2),E.rotate(e.angle),E.drawImage(r,-r.width/2,-r.height/2,r.width,r.height);let[,,,,I,S]=j(f,t);E.rotate(-e.angle);let A=(h.width-r.width)/2,M=(h.height-r.height)/2,k=h.width/2-(I-g)*window.devicePixelRatio*c-A-a*c,L=h.height/2-(S-x)*window.devicePixelRatio*c-M-a*c;E.translate(-k,-L),E.clearRect(-(f.width/2+No)*window.devicePixelRatio*c,-(f.height/2+No)*window.devicePixelRatio*c,(f.width+No*2)*window.devicePixelRatio*c,(f.height+No*2)*window.devicePixelRatio*c)}return{element:e,canvas:r,theme:o.theme,scale:c,zoomValue:n.value,canvasOffsetX:u,canvasOffsetY:m,boundTextElementVersion:V(e,t)?.version||null,containingFrameOpacity:Rt(e,t)?.opacity||100,boundTextCanvas:h,angle:e.angle,imageCrop:xe(e)?e.crop:null}},z0=14,od=typeof document<"u"?document.createElement("img"):{src:""};od.src=`data:${ms.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var rd=typeof document<"u"?document.createElement("img"):{src:""};rd.src=`data:${ms.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;var Sf=(e,t)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);let n=Math.min(e.width,e.height),i=Math.min(n,Math.min(n*.4,100));t.drawImage(e.status==="error"?rd:od,e.width/2-i/2,e.height/2-i/2,i,i)},zo=(e,t,n,i)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{n.lineJoin="round",n.lineCap="round",t.draw(Xe.generateElementShape(e,i));break}case"arrow":case"line":{n.lineJoin="round",n.lineCap="round",Xe.generateElementShape(e,i).forEach(o=>{t.draw(o)});break}case"freedraw":{n.save();let o=Xe.generateElementShape(e,i);for(let r of o)typeof r=="string"?(n.fillStyle=i.theme===vi.DARK?Ho(e.strokeColor):e.strokeColor,n.fill(new Path2D(r))):t.draw(r);n.restore();break}case"image":{n.save();let o=e.fileId!==null?i.imageCache.get(e.fileId):null,r=yn(e)?o?.image:void 0;if(i.theme===vi.DARK&&o?.mimeType===ms.svg&&(n.filter=Ef),r!=null&&!(r instanceof Promise)){e.roundness&&n.roundRect&&(n.beginPath(),n.roundRect(0,0,e.width,e.height,Mt(Math.min(e.width,e.height),e)),n.clip());let{x:a,y:l,width:d,height:c}=e.crop?e.crop:{x:0,y:0,width:r.naturalWidth,height:r.naturalHeight};n.drawImage(r,a,l,d,c,0,0,e.width,e.height)}else Sf(e,n);n.restore();break}default:if(ee(e)){let o=xf(e.text),r=o&&!n.canvas.isConnected;r&&document.body.appendChild(n.canvas),n.canvas.setAttribute("dir",o?"rtl":"ltr"),n.save(),n.font=gf(e),n.fillStyle=i.theme===vi.DARK?Ho(e.strokeColor):e.strokeColor,n.textAlign=e.textAlign;let s=e.text.replace(/\r\n?/g,`
10
+ `)=>e.reduce((o,i)=>(ee(i)&&o.push(i.text),o),[]).join(t);I();import{curvePointDistance as is,distanceToLineSegment as rs,pointRotateRads as ss}from"@excalidraw/math";import{ellipse as q1,ellipseDistanceFromPoint as K1}from"@excalidraw/math/ellipse";var fn=(e,t,n)=>{switch(e.type){case"selection":case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return Q1(e,t,n);case"diamond":return J1(e,t,n);case"ellipse":return eh(e,t,n);case"line":case"arrow":case"freedraw":return th(e,n)}},Q1=(e,t,n)=>{let o=ce(e,t),i=ss(n,o,-e.angle),[r,s]=un(e);return Math.min(...r.map(a=>rs(i,a)),...s.map(a=>is(a,i)).filter(a=>a!==null))},J1=(e,t,n)=>{let o=ce(e,t),i=ss(n,o,-e.angle),[r,s]=pn(e);return Math.min(...r.map(a=>rs(i,a)),...s.map(a=>is(a,i)).filter(a=>a!==null))},eh=(e,t,n)=>{let o=ce(e,t);return K1(ss(n,o,-e.angle),q1(o,e.width/2,e.height/2))},th=(e,t)=>{let[n,o]=vi(e);return Math.min(...n.map(i=>rs(t,i)),...o.map(i=>is(i,t)))};var Oi=e=>{if(e.type==="arrow")return!1;let t=!Hl(e.backgroundColor)||kt(e)||Ii(e)||ee(e);return e.type==="line"?t&&zn(e.points):e.type==="freedraw"?t&&zn(e.points):t||ve(e)},as=null,Dl=null,Gl=1/0,Ol=!1,Rl=!1,Tt=({point:e,element:t,threshold:n,elementsMap:o,frameNameBound:i=null,overrideShouldTestInside:r=!1})=>{if(as&&Wl(e,as)&&Gl<=n&&r===Rl){let p=Dl?.deref();if(p&&p.id===t.id&&p.version===t.version&&p.versionNonce===t.versionNonce)return Ol}let s=i?Gi(xe(i.x-n,i.y-n),e,xe(i.x+i.width+n,i.y+i.height+n)):!1,a=Me(t,o,!0);if(!Gi(xe(a[0]-n,a[1]-n),it(e,Ct(a),-t.angle),xe(a[2]+n,a[3]+n))&&!s)return!1;let c=(r||Oi(t))&&Ut(e,t,o)||Fl(e,t,o,n)||s;return as=e,Dl=new WeakRef(t),Gl=n,Rl=r,Ol=c,c},lh=(e,t,n,o=0)=>{let[i,r,s,a]=Me(t,n);return i-=o,r-=o,s+=o,a+=o,Gi(xe(i,r),e,xe(s,a))},x3=(e,t)=>!Tt(e)&&!dh(e.point,e.element,t)&&lh(e.point,e.element,t),dh=(e,t,n)=>{let o=J(t,n);if(!o)return!1;let i=ne(t)?{...o,...G.getBoundTextElementPosition(t,o,n)}:o;return Ut(e,i,n)},jl=(e,[t,n],o,i=0)=>{let r=xe(t,n),s=!te(e),a=Math.max(1,i),l=[t-a,n-a,t+a,n+a],d=Me(e,o);if(!Ro(l,d))return!1;if(e.frameId){let h=o.get(e.frameId);if(h&&te(h)){let m=Me(h,o);if(!En(r,m))return!1}}let c=gn(e,o,Oo(ce(e,o),r)),p=fn(e,o,r);return s?c.length===0||p<=i:c.length>0&&p<=a},Ri=(e,t,n,o)=>{let i=[];for(let r=t.length-1;r>=0;--r){let s=t[r];if(Nl(!s.isDeleted,"Elements in the function parameter for getAllElementsAtPositionForBinding() should not contain deleted elements"),fe(s,!1)&&jl(s,e,n,o)&&(i.push(s),!Hl(s.backgroundColor)))break}return i},Zt=(e,t,n,o)=>{let i=Ri(e,t,n,o);return!i||i.length===0?null:i.length===1?i[0]:i.sort((r,s)=>s.width**2+s.height**2-(r.width**2+r.height**2)).pop()},Vl=(e,t,n,o,i)=>{let r=[];for(let a=n.length-1;a>=0;--a){let l=n[a];Nl(!l.isDeleted,"Elements in the function parameter for getAllElementsAtPositionForBinding() should not contain deleted elements"),fe(l,!1)&&jl(l,e,o,i)&&r.push(l)}if(!r||r.length===0)return null;if(r.length===1)return r[0];let s=r.filter(a=>fn(a,o,e)<=Fe(a,t)||Ut(e,a,o));return s.length===0?null:s[0]},gn=(e,t,n,o=0,i=!1)=>{let r=[Math.min(n[0][0]-o,n[1][0]-o),Math.min(n[0][1]-o,n[1][1]-o),Math.max(n[0][0]+o,n[1][0]+o),Math.max(n[0][1]+o,n[1][1]+o)],s=Me(e,t);if(!Ro(r,s))return[];switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"selection":case"magicframe":return uh(e,t,n,o,i);case"diamond":return ph(e,t,n,o,i);case"ellipse":return hh(e,t,n,o);case"line":case"freedraw":case"arrow":return ch(e,n,i)}},Ul=(e,t,n,o,i,r=!1)=>{for(let s of e){let a=Fi(s[0],s[1],s[2],s[3]),l=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])];if(!Ro(a,l))continue;let d=zl(s,t);if(d.length>0){for(let c of d)n.push(it(c,o,i));if(r)return n}}return n},Yl=(e,t,n,o,i,r=!1)=>{for(let s of e){let a=_l(s,t);if(a&&(n.push(it(a,o,i)),r))return n}return n},ch=(e,t,n=!1)=>{let[o,i]=vi(e),r=[];for(let s of o){let a=_l(s,t);if(a&&(r.push(a),n))return r}for(let s of i){let a=Fi(s[0],s[1],s[2],s[3]),l=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])];if(!Ro(a,l))continue;let d=zl(s,t);if(d.length>0&&(r.push(...d),n))return r}return r},uh=(e,t,n,o=0,i=!1)=>{let r=ce(e,t),s=it(n[0],r,-e.angle),a=it(n[1],r,-e.angle),l=Oo(s,a),[d,c]=un(e,o),p=[];return Yl(d,l,p,r,e.angle,i),i&&p.length>0||Ul(c,l,p,r,e.angle,i),p},ph=(e,t,n,o=0,i=!1)=>{let r=ce(e,t),s=it(n[0],r,-e.angle),a=it(n[1],r,-e.angle),l=Oo(s,a),[d,c]=pn(e,o),p=[];return Yl(d,l,p,r,e.angle,i),i&&p.length>0||Ul(c,l,p,r,e.angle,i),p},hh=(e,t,n,o=0)=>{let i=ce(e,t),r=it(n[0],i,-e.angle),s=it(n[1],i,-e.angle);return ah(sh(i,e.width/2+o,e.height/2+o),Oo(r,s)).map(a=>it(a,i,e.angle))},Fl=(e,t,n,o=1)=>fn(t,n,e)<=o,Ut=(e,t,n)=>{if((ne(t)||Ce(t))&&!zn(t.points))return!1;let[o,i,r,s]=Me(t,n);if(!Gi(xe(o,i),e,xe(r,s)))return!1;let a=xe((o+r)/2,(i+s)/2),l=nh(rh(ih(oh(e,a,.1)),Math.max(t.width,t.height)*2),a),d=Oo(e,l);return gn(t,n,d).filter((p,h,m)=>m.findIndex(f=>Wl(f,p))===h).length%2===1},ls=(e,t,n)=>{let o=(s,a)=>{let{x:l,y:d,width:c,height:p,angle:h}=s,m=ce(s,n);if(s.type==="diamond"){let[g,E,x,y,w,M,b,S]=Qn(s);return[xe(l+g,d+E-a),xe(l+x+a,d+y),xe(l+w,d+M+a),xe(l+b-a,d+S)].map(C=>it(C,m,h))}if(s.type==="ellipse"){let g=l+c/2,E=d+p/2,x=c/2,y=p/2;return[xe(g,E-y-a),xe(g+x+a,E),xe(g,E+y+a),xe(g-x-a,E)].map(M=>it(M,m,h))}return[xe(l-a,d-a),xe(l+c+a,d-a),xe(l+c+a,d+p+a),xe(l-a,d+p+a)].map(g=>it(g,m,h))},i=-1*Math.max(e.width,e.height)/20;return o(e,i).every(s=>Ut(s,t,n))};I();import{invariant as Xl,isDevEnv as mh,isTestEnv as fh}from"@excalidraw/common";import{pointFrom as xn,pointFromVector as Ni,pointRotateRads as Hi,pointScaleFromOrigin as zi,pointsEqual as gh,triangleIncludesPoint as ds,vectorCross as Xe,vectorFromPoint as oe,vectorScale as _i}from"@excalidraw/math";var we=[1,0],Ae=[0,1],Ze=[-1,0],rt=[0,-1],qt=e=>{let[t,n]=e,o=Math.abs(t),i=Math.abs(n);return t>i?we:t<=-i?Ze:n>o?Ae:rt},$e=(e,t)=>qt(oe(e,t)),wt=(e,t)=>qe($e(e,t)),ye=(e,t)=>e[0]===t[0]&&e[1]===t[1],qe=e=>ye(e,we)||ye(e,Ze),I3=e=>!qe(e),Eh=(e,t,n)=>{let o=Ct(t);(mh()||fh())&&(Xl(e.width>0&&e.height>0,"Diamond element has no width or height"),Xl(!gh(o,n),"The point is too close to the element mid point to determine heading"));let i=.95,r=Ni(_i(oe(Hi(xn(e.x+e.width/2,e.y),o,e.angle),o),i),o),s=Ni(_i(oe(Hi(xn(e.x+e.width,e.y+e.height/2),o,e.angle),o),i),o),a=Ni(_i(oe(Hi(xn(e.x+e.width/2,e.y+e.height),o,e.angle),o),i),o),l=Ni(_i(oe(Hi(xn(e.x,e.y+e.height/2),o,e.angle),o),i),o);if(Xe(oe(n,r),oe(r,s))<=0&&Xe(oe(n,r),oe(r,l))>0)return $e(r,o);if(Xe(oe(n,s),oe(s,a))<=0&&Xe(oe(n,s),oe(s,r))>0)return $e(s,o);if(Xe(oe(n,a),oe(a,l))<=0&&Xe(oe(n,a),oe(a,s))>0)return $e(a,o);if(Xe(oe(n,l),oe(l,r))<=0&&Xe(oe(n,l),oe(l,a))>0)return $e(l,o);if(Xe(oe(n,o),oe(r,o))<=0&&Xe(oe(n,o),oe(s,o))>0){let c=e.width>e.height?r:s;return $e(c,o)}else if(Xe(oe(n,o),oe(s,o))<=0&&Xe(oe(n,o),oe(a,o))>0){let c=e.width>e.height?a:s;return $e(c,o)}else if(Xe(oe(n,o),oe(a,o))<=0&&Xe(oe(n,o),oe(l,o))>0){let c=e.width>e.height?a:l;return $e(c,o)}let d=e.width>e.height?r:l;return $e(d,o)},Fo=(e,t,n)=>{let i=Ct(t);if(e.type==="diamond")return Eh(e,t,n);let r=zi(xn(t[0],t[1]),i,2),s=zi(xn(t[2],t[1]),i,2),a=zi(xn(t[0],t[3]),i,2),l=zi(xn(t[2],t[3]),i,2);return ds([r,s,i],n)?rt:ds([s,l,i],n)?we:ds([l,a,i],n)?Ae:Ze},cs=e=>[e[0]===0?0:e[0]>0?-1:1,e[1]===0?0:e[1]>0?-1:1];I();import{getSizeFromPoints as Oh,randomInteger as bs,getUpdatedTimestamp as Ms}from"@excalidraw/common";I();import{clamp as Wi,pointDistance as hs,pointFrom as Z,pointScaleFromOrigin as xh,pointsEqual as Ho,pointTranslate as ps,vector as Bt,vectorCross as ji,vectorFromPoint as ms,vectorScale as yh}from"@excalidraw/math";import{BinaryHeap as wh,invariant as eo,isAnyTrue as bh,getSizeFromPoints as $l,isDevEnv as Mh,arrayToMap as Ph}from"@excalidraw/common";var fs=1,re=40,Ih=(e,t)=>{let n=e.fixedSegments?e.fixedSegments.slice():null;if(n){let o=[];e.points.map(s=>Z(e.x+s[0],e.y+s[1])).forEach((s,a,l)=>{if(a<2)return o.push(s);let d=$e(s,l[a-1]),c=$e(l[a-1],l[a-2]);if(ye(d,c)){let p=n?.findIndex(m=>m.index===a-1)??-1,h=n?.findIndex(m=>m.index===a)??-1;h!==-1&&(n[h].start=Z(l[a-2][0]-e.x,l[a-2][1]-e.y)),p!==-1&&n.splice(p,1),o.splice(-1,1),n.forEach(m=>{m.index>a-1&&(m.index-=1)})}return o.push(s)});let i=[];o.forEach((s,a,l)=>{if(a<3)return i.push(s);if(hs(l[a-2],l[a-1])<fs){let d=n?.findIndex(h=>h.index===a-2)??-1,c=n?.findIndex(h=>h.index===a-1)??-1;c!==-1&&n.splice(c,1),d!==-1&&n.splice(d,1),i.splice(-2,2),n.forEach(h=>{h.index>a-2&&(h.index-=2)});let p=wt(s,l[a-1]);return i.push(Z(p?s[0]:l[a-2][0],p?l[a-2][1]:s[1]))}i.push(s)});let r=n.filter(s=>s.index!==1&&s.index!==i.length-1);return r.length===0?Kt(xs(ys(Es(e,gs(e,t,i.map(s=>Z(s[0]-e.x,s[1]-e.y))))??[])),r,null,null):(Mh()&&eo(td(i),"Invalid elbow points with fixed segments"),Kt(i,r,e.startIsSpecial,e.endIsSpecial))}return{x:e.x,y:e.y,points:e.points,fixedSegments:e.fixedSegments,startIsSpecial:e.startIsSpecial,endIsSpecial:e.endIsSpecial}},Sh=(e,t,n)=>{let o=t.map(T=>T.index),r=(e.fixedSegments?.map(T=>T.index)??[]).findIndex(T=>!o.includes(T));if(r===-1||!e.fixedSegments?.[r])return{points:e.points};let s=e.fixedSegments[r].index,a=e.fixedSegments[r-1],l=e.fixedSegments[r+1],d=e.x+(a?a.end[0]:0),c=e.y+(a?a.end[1]:0),p=a?null:e.startBinding,h=l?null:e.endBinding,{startHeading:m,endHeading:f,startGlobalPoint:g,endGlobalPoint:E,hoveredStartElement:x,hoveredEndElement:y,...w}=gs({x:d,y:c,startBinding:p,endBinding:h,startArrowhead:null,endArrowhead:null,points:e.points},n,[Z(0,0),Z(e.x+(l?.start[0]??e.points[e.points.length-1][0])-d,e.y+(l?.start[1]??e.points[e.points.length-1][1])-c)],{isDragging:!1}),{points:M}=Kt(xs(ys(Es(e,{startHeading:m,endHeading:f,startGlobalPoint:g,endGlobalPoint:E,hoveredStartElement:x,hoveredEndElement:y,...w})??[])),t,null,null);if(!M||M.length<2)throw new Error("Property 'points' is required in the update returned by normalizeArrowElementUpdate()");let b=[];if(a)for(let T=0;T<a.index;T++)b.push(Z(e.x+e.points[T][0],e.y+e.points[T][1]));if(M.forEach(T=>{b.push(Z(e.x+(a?a.end[0]:0)+T[0],e.y+(a?a.end[1]:0)+T[1]))}),l)for(let T=l.index;T<e.points.length;T++)b.push(Z(e.x+e.points[T][0],e.y+e.points[T][1]));let S=(l?.index??e.points.length)-(a?.index??0)-1,A=t.map(T=>T.index>s?{...T,index:T.index-S+(M.length-1)}:T),C=b.flatMap((T,F)=>{let O=b[F-1],N=b[F+1];if(O&&N){let D=$e(T,O),q=$e(N,T);if(ye(D,q))return A.forEach(U=>{U.index>F&&(U.index-=1)}),[];if(ye(D,cs(q)))return A.forEach(U=>{U.index>F&&(U.index+=1)}),[T,T]}return[T]});return Kt(C,A,!1,!1)},vh=(e,t,n,o,i,r)=>{let s=t.map((b,S)=>e.fixedSegments==null||e.fixedSegments[S]===void 0||e.fixedSegments[S].index!==b.index||(b.start[0]!==e.fixedSegments[S].start[0]&&b.end[0]!==e.fixedSegments[S].end[0])!=(b.start[1]!==e.fixedSegments[S].start[1]&&b.end[1]!==e.fixedSegments[S].end[1])?S:null).filter(b=>b!==null).shift();if(s==null)return{points:e.points};let a=e.fixedSegments?.findIndex(b=>b.index===1)??-1,l=e.fixedSegments?.findIndex(b=>b.index===e.points.length-1)??-1,d=hs(t[s].start,t[s].end),c=d<re+5;if(a===-1&&t[s].index===1&&i){let b=qe(n),A=(b?ye(n,we):ye(n,Ae))?c?d/2:re:c?-d/2:-re;t[s].start=Z(t[s].start[0]+(b?A:0),t[s].start[1]+(b?0:A))}if(l===-1&&t[s].index===e.points.length-1&&r){let b=qe(o),A=(b?ye(o,we):ye(o,Ae))?c?d/2:re:c?-d/2:-re;t[s].end=Z(t[s].end[0]+(b?A:0),t[s].end[1]+(b?0:A))}let p=t.map(b=>({...b,start:Z(e.x+b.start[0],e.y+b.start[1]),end:Z(e.x+b.end[0],e.y+b.end[1])})),h=e.points.map((b,S)=>Z(e.x+b[0],e.y+b[1])),m=p[s].index-1,f=p[s].index,g=p[s].start,E=p[s].end,x=h[m-1]&&!Ho(h[m],h[m-1])?wt(h[m-1],h[m]):void 0,y=h[f+1]&&!Ho(h[f],h[f+1])?wt(h[f+1],h[f]):void 0;if(x!==void 0){let b=x?1:0;h[m-1][b]=g[b]}if(h[m]=g,h[f]=E,y!==void 0){let b=y?1:0;h[f+1][b]=E[b]}let w=p.findIndex(b=>b.index===m);if(w!==-1){let b=wt(p[w].end,p[w].start)?1:0;p[w].start[b]=g[b],p[w].end=g}let M=p.findIndex(b=>b.index===f+1);if(M!==-1){let b=wt(p[M].end,p[M].start)?1:0;p[M].end[b]=E[b],p[M].start=E}if(a===-1&&m===0){let b=i?qe(n):wt(h[1],h[0]);h.unshift(Z(b?g[0]:e.x+e.points[0][0],b?e.y+e.points[0][1]:g[1])),i&&h.unshift(Z(e.x+e.points[0][0],e.y+e.points[0][1]));for(let S of p)S.index+=i?2:1}if(l===-1&&f===e.points.length-1){let b=qe(o);h.push(Z(b?E[0]:e.x+e.points[e.points.length-1][0],b?e.y+e.points[e.points.length-1][1]:E[1])),r&&h.push(Z(e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]))}return Kt(h,p.map(b=>({...b,start:Z(b.start[0]-e.x,b.start[1]-e.y),end:Z(b.end[0]-e.x,b.end[1]-e.y)})),!1,!1)},Ah=(e,t,n,o,i,r,s,a,l)=>{let d=e.startIsSpecial??null,c=e.endIsSpecial??null,p=t.map((E,x)=>x===0?Z(e.x+E[0],e.y+E[1]):x===t.length-1?Z(e.x+E[0],e.y+E[1]):Z(e.x+e.points[x][0],e.y+e.points[x][1])),h=n.map(E=>({...E,start:Z(e.x+(E.start[0]-t[0][0]),e.y+(E.start[1]-t[0][1])),end:Z(e.x+(E.end[0]-t[0][0]),e.y+(E.end[1]-t[0][1]))})),m=[],f=2+(d?1:0),g=2+(c?1:0);for(;m.length+f<p.length-g;)m.push(p[m.length+f]);{let E=p.at(d?2:1),x=p.at(d?3:2);if(!E||!x)throw new Error(`Second and third points must exist when handling endpoint drag (${d})`);let y=qe(o),w=qe(qt(ms(E,x)));if(a&&y===w){let M=y?ye(o,we):ye(o,Ae);if(m.unshift(Z(w?r[0]+(M?re:-re):x[0],w?x[1]:r[1]+(M?re:-re))),m.unshift(Z(y?r[0]+(M?re:-re):r[0],y?r[1]:r[1]+(M?re:-re))),!d){d=!0;for(let b of h)b.index>1&&(b.index+=1)}}else if(m.unshift(Z(w?r[0]:E[0],w?E[1]:r[1])),d){d=!1;for(let M of h)M.index>1&&(M.index-=1)}m.unshift(r)}{let E=p.at(p.length-(c?3:2)),x=p.at(p.length-(c?4:3));if(!E||!x)throw new Error(`Second and third to last points must exist when handling endpoint drag (${c})`);let y=qe(i),w=wt(x,E);if(l&&y===w){let M=y?ye(i,we):ye(i,Ae);m.push(Z(w?s[0]+(M?re:-re):x[0],w?x[1]:s[1]+(M?re:-re))),m.push(Z(y?s[0]+(M?re:-re):s[0],y?s[1]:s[1]+(M?re:-re))),c||(c=!0)}else m.push(Z(w?s[0]:E[0],w?E[1]:s[1])),c&&(c=!1)}return m.push(s),Kt(m,h.map(({index:E})=>({index:E,start:m[E-1],end:m[E]})).map(E=>({...E,start:Z(E.start[0]-r[0],E.start[1]-r[1]),end:Z(E.end[0]-r[0],E.end[1]-r[1])})),d,c)},yn=1e6,to=(e,t,n,o)=>{if(e.points.length<2)return{points:n.points??e.points};L.PROD||(eo(!n.points||n.points.length>=2,"Updated point array length must match the arrow point length, contain exactly the new start and end points or not be specified at all (i.e. you can't add new points between start and end manually to elbow arrows)"),eo(!e.fixedSegments||e.fixedSegments.map(b=>b.start[0]===b.end[0]||b.start[1]===b.end[1]).every(Boolean),"Fixed segments must be either horizontal or vertical"),eo(!n.fixedSegments||n.fixedSegments.map(b=>b.start[0]===b.end[0]||b.start[1]===b.end[1]).every(Boolean),"Updates to fixed segments must be either horizontal or vertical"),eo(e.points.slice(1).map((b,S)=>b[0]===e.points[S][0]||b[1]===e.points[S][1]),"Elbow arrow segments must be either horizontal or vertical"),eo(n.fixedSegments?.find(b=>b.index===1&&Ho(b.start,(n.points??e.points)[0]))==null&&n.fixedSegments?.find(b=>b.index===(n.points??e.points).length-1&&Ho(b.end,(n.points??e.points)[(n.points??e.points).length-1]))==null,"The first and last segments cannot be fixed"));let i=n.fixedSegments??e.fixedSegments??[],r=n.points?n.points&&n.points.length===2?e.points.map((b,S)=>S===0?n.points[0]:S===e.points.length-1?n.points[1]:b):n.points.slice():e.points.slice(),{startBinding:s,endBinding:a,...l}=n,d=typeof s<"u"?s:e.startBinding,c=typeof a<"u"?a:e.endBinding,p=d&&Ui(d.elementId,t),h=c&&Ui(c.elementId,t),m=td(r);if(d&&!p&&m||c&&!h&&m||t.size===0&&m||Object.keys(l).length===0&&(p?.id!==d?.elementId||h?.id!==c?.elementId))return Kt(r.map(b=>Z(e.x+b[0],e.y+b[1])),e.fixedSegments,e.startIsSpecial,e.endIsSpecial);let{startHeading:f,endHeading:g,startGlobalPoint:E,endGlobalPoint:x,hoveredStartElement:y,hoveredEndElement:w,...M}=gs({x:e.x,y:e.y,startBinding:d,endBinding:c,startArrowhead:e.startArrowhead,endArrowhead:e.endArrowhead,points:e.points},t,r,o);return t.size===0&&m?Kt(r.map(b=>Z(e.x+b[0],e.y+b[1])),e.fixedSegments,e.startIsSpecial,e.endIsSpecial):!n.points&&!n.fixedSegments&&!n.startBinding&&!n.endBinding?Ih(e,t):n.startBinding===e.startBinding&&n.endBinding===e.endBinding&&(n.points??[]).every((b,S)=>Ho(b,e.points[S]??Z(1/0,1/0)))&&m?{}:i.length===0?Kt(xs(ys(Es(e,{startHeading:f,endHeading:g,startGlobalPoint:E,endGlobalPoint:x,hoveredStartElement:y,hoveredEndElement:w,...M})??[])),i,null,null):(e.fixedSegments?.length??0)>i.length?Sh(e,i,t):n.points?n.points&&n.fixedSegments?n:Ah(e,r,i,f,g,E,x,y,w):vh(e,i,f,g,y,w)},gs=(e,t,n,o)=>{let i=ps(n[0],Bt(e.x,e.y)),r=ps(n[n.length-1],Bt(e.x,e.y)),s=null,a=null;if(o?.isDragging&&o?.isBindingEnabled!==!1){let b=Array.from(t.values());s=Ql(i,t,b,o?.zoom)||null,a=Ql(r,t,b,o?.zoom)||null}else s=e.startBinding&&Ui(e.startBinding.elementId,t)||null,a=e.endBinding&&Ui(e.endBinding.elementId,t)||null;let l=ql({...e,angle:0,type:"arrow",elbowed:!0,points:n},"start",e.startBinding?.fixedPoint,i,s,t,o?.isDragging,o?.isBindingEnabled,o?.isMidpointSnappingEnabled),d=ql({...e,angle:0,type:"arrow",elbowed:!0,points:n},"end",e.endBinding?.fixedPoint,r,a,t,o?.isDragging,o?.isBindingEnabled,o?.isMidpointSnappingEnabled),c=Kl(l,d,s,i,t,o?.zoom),p=Kl(d,l,a,r,t,o?.zoom),h=[l[0]-2,l[1]-2,l[0]+2,l[1]+2],m=[d[0]-2,d[1]-2,d[0]+2,d[1]+2],f=s?ut(s,t,wn(c,e.startArrowhead?Fe(s,{elbowed:!0})*6:Fe(s,{elbowed:!0})*2,1)):h,g=a?ut(a,t,wn(p,e.endArrowhead?Fe(a,{elbowed:!0})*6:Fe(a,{elbowed:!0})*2,1)):m,E=En(l,a?ut(a,t,wn(p,re,re)):m)||En(d,s?ut(s,t,wn(c,re,re)):h),x=ed(E?[h,m]:[f,g]),y=Lh(E?h:f,E?m:g,x,E?wn(c,!s&&!a?0:re,0):wn(c,!s&&!a?0:re-(e.startArrowhead?jn*6:jn*2),re),E?wn(p,!s&&!a?0:re,0):wn(p,!s&&!a?0:re-(e.endArrowhead?jn*6:jn*2),re),E,s&&ut(s,t),a&&ut(a,t)),w=Zl(y[0],c,l),M=Zl(y[1],p,d);return{dynamicAABBs:y,startDonglePosition:w,startGlobalPoint:l,startHeading:c,endDonglePosition:M,endGlobalPoint:d,endHeading:p,commonBounds:x,hoveredStartElement:s,hoveredEndElement:a,boundsOverlap:E,startElementBounds:f,endElementBounds:g}},Es=(e,t)=>{let{dynamicAABBs:n,startDonglePosition:o,startGlobalPoint:i,startHeading:r,endDonglePosition:s,endGlobalPoint:a,endHeading:l,commonBounds:d,hoveredEndElement:c}=t,p=Ch(n,o||i,r,s||a,l,d),h=o&&Vi(o,p),m=s&&Vi(s,p),f=Vi(a,p);f&&c&&(f.closed=!0);let g=Vi(i,p);g&&e.startBinding&&(g.closed=!0);let E=h&&m&&(En(h.pos,n[1])||En(m.pos,n[0])),x=kh(h||g,m||f,p,r||we,l||we,E?[]:n);if(x){let y=x.map(w=>[w.pos[0],w.pos[1]]);return h&&y.unshift(i),m&&y.push(a),y}return null},wn=(e,t,n)=>{switch(e){case rt:return[t,n,n,n];case we:return[n,t,n,n];case Ae:return[n,n,t,n]}return[n,n,n,t]},kh=(e,t,n,o,i,r)=>{let s=us(e.pos,t.pos),a=new wh(l=>l.f);for(a.push(e);a.size()>0;){let l=a.pop();if(!l||l.closed)continue;if(l===t)return Th(e,l);l.closed=!0;let d=Dh(l.addr,n);for(let c=0;c<4;c++){let p=d[c];if(!p||p.closed)continue;let h=xh(p.pos,l.pos,.5);if(bh(...r.map(M=>En(h,M))))continue;let m=Gh(c),f=l.parent?qt(ms(l.pos,l.parent.pos)):o,g=cs(f);if(ye(g,m)||Jl(e.addr,p.addr)&&ye(m,o)||Jl(t.addr,p.addr)&&ye(m,i))continue;let x=f!==m,y=l.g+us(p.pos,l.pos)+(x?Math.pow(s,3):0),w=p.visited;if(!w||y<p.g){let M=Bh(p,t,m,i);p.visited=!0,p.parent=l,p.h=us(t.pos,p.pos)+M*Math.pow(s,2),p.g=y,p.f=p.g+p.h,w?a.rescoreElement(p):a.push(p)}}}return null},Th=(e,t)=>{let n=t,o=[];for(;n.parent;)o.unshift(n),n=n.parent;return o.unshift(e),o},us=(e,t)=>Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1]),Lh=(e,t,n,o,i,r,s,a)=>{let l=s??e,d=a??t,[c,p,h,m]=o??[0,0,0,0],[f,g,E,x]=i??[0,0,0,0],y=[e[0]>t[2]?e[1]>t[3]||e[3]<t[1]?Math.min((l[0]+d[2])/2,e[0]-m):(l[0]+d[2])/2:e[0]>t[0]?e[0]-m:n[0]-m,e[1]>t[3]?e[0]>t[2]||e[2]<t[0]?Math.min((l[1]+d[3])/2,e[1]-c):(l[1]+d[3])/2:e[1]>t[1]?e[1]-c:n[1]-c,e[2]<t[0]?e[1]>t[3]||e[3]<t[1]?Math.max((l[2]+d[0])/2,e[2]+p):(l[2]+d[0])/2:e[2]<t[2]?e[2]+p:n[2]+p,e[3]<t[1]?e[0]>t[2]||e[2]<t[0]?Math.max((l[3]+d[1])/2,e[3]+h):(l[3]+d[1])/2:e[3]<t[3]?e[3]+h:n[3]+h],w=[t[0]>e[2]?t[1]>e[3]||t[3]<e[1]?Math.min((d[0]+l[2])/2,t[0]-x):(d[0]+l[2])/2:t[0]>e[0]?t[0]-x:n[0]-x,t[1]>e[3]?t[0]>e[2]||t[2]<e[0]?Math.min((d[1]+l[3])/2,t[1]-f):(d[1]+l[3])/2:t[1]>e[1]?t[1]-f:n[1]-f,t[2]<e[0]?t[1]>e[3]||t[3]<e[1]?Math.max((d[2]+l[0])/2,t[2]+g):(d[2]+l[0])/2:t[2]<e[2]?t[2]+g:n[2]+g,t[3]<e[1]?t[0]>e[2]||t[2]<e[0]?Math.max((d[3]+l[1])/2,t[3]+E):(d[3]+l[1])/2:t[3]<e[3]?t[3]+E:n[3]+E],M=ed([y,w]);if(!r&&y[2]-y[0]+w[2]-w[0]>M[2]-M[0]+1e-11&&y[3]-y[1]+w[3]-w[1]>M[3]-M[1]+1e-11){let[b,S]=[(w[0]+w[2])/2,(w[1]+w[3])/2];if(t[0]>e[2]&&e[1]>t[3]){let A=y[2]+(w[0]-y[2])/2,C=w[3]+(y[1]-w[3])/2;return ji(Bt(e[2]-b,e[1]-S),Bt(e[0]-b,e[3]-S))>0?[[y[0],y[1],A,y[3]],[A,w[1],w[2],w[3]]]:[[y[0],C,y[2],y[3]],[w[0],w[1],w[2],C]]}else if(e[2]<t[0]&&e[3]<t[1]){let A=y[2]+(w[0]-y[2])/2,C=y[3]+(w[1]-y[3])/2;return ji(Bt(e[0]-b,e[1]-S),Bt(e[2]-b,e[3]-S))>0?[[y[0],y[1],y[2],C],[w[0],C,w[2],w[3]]]:[[y[0],y[1],A,y[3]],[A,w[1],w[2],w[3]]]}else if(e[0]>t[2]&&e[3]<t[1]){let A=w[2]+(y[0]-w[2])/2,C=y[3]+(w[1]-y[3])/2;return ji(Bt(e[2]-b,e[1]-S),Bt(e[0]-b,e[3]-S))>0?[[A,y[1],y[2],y[3]],[w[0],w[1],A,w[3]]]:[[y[0],y[1],y[2],C],[w[0],C,w[2],w[3]]]}else if(e[0]>t[2]&&e[1]>t[3]){let A=w[2]+(y[0]-w[2])/2,C=w[3]+(y[1]-w[3])/2;return ji(Bt(e[0]-b,e[1]-S),Bt(e[2]-b,e[3]-S))>0?[[A,y[1],y[2],y[3]],[w[0],w[1],A,w[3]]]:[[y[0],C,y[2],y[3]],[w[0],w[1],w[2],C]]}}return[y,w]},Ch=(e,t,n,o,i,r)=>{let s=new Set,a=new Set;n===Ze||n===we?a.add(t[1]):s.add(t[0]),i===Ze||i===we?a.add(o[1]):s.add(o[0]),e.forEach(c=>{s.add(c[0]),s.add(c[2]),a.add(c[1]),a.add(c[3])}),s.add(r[0]),s.add(r[2]),a.add(r[1]),a.add(r[3]);let l=Array.from(a).sort((c,p)=>c-p),d=Array.from(s).sort((c,p)=>c-p);return{row:l.length,col:d.length,data:l.flatMap((c,p)=>d.map((h,m)=>({f:0,g:0,h:0,closed:!1,visited:!1,parent:null,addr:[m,p],pos:[h,c]})))}},Zl=(e,t,n)=>{switch(t){case rt:return Z(n[0],e[1]);case we:return Z(e[2],n[1]);case Ae:return Z(n[0],e[3])}return Z(e[0],n[1])},Bh=(e,t,n,o)=>{if(o===we)switch(n){case we:return e.pos[0]>=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2;case rt:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Ae:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Ze:return e.pos[1]===t.pos[1]?4:2}else if(o===Ze)switch(n){case we:return e.pos[1]===t.pos[1]?4:2;case rt:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case Ae:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case Ze:return e.pos[0]<=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2}else if(o===rt)switch(n){case we:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case rt:return e.pos[1]>=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case Ae:return e.pos[0]===t.pos[0]?4:2;case Ze:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3}else if(o===Ae)switch(n){case we:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case rt:return e.pos[0]===t.pos[0]?4:2;case Ae:return e.pos[1]<=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case Ze:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3}return 0},Dh=([e,t],n)=>[No([e,t-1],n),No([e+1,t],n),No([e,t+1],n),No([e-1,t],n)],No=([e,t],n)=>e<0||e>=n.col||t<0||t>=n.row?null:n.data[t*n.col+e]??null,Vi=(e,t)=>{for(let n=0;n<t.col;n++)for(let o=0;o<t.row;o++){let i=No([n,o],t);if(i&&e[0]===i.pos[0]&&e[1]===i.pos[1])return i}return null},ed=e=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1])),Math.max(...e.map(t=>t[2])),Math.max(...e.map(t=>t[3]))],Ui=(e,t)=>{let n=t.get(e);return n&&fe(n)?n:null},Kt=(e,t,n,o)=>{let i=e[0][0],r=e[0][1],s=e.map(a=>ps(a,yh(ms(e[0]),-1)));return(i<-yn||i>yn||r<-yn||r>yn||i+s[s.length-1][0]<-yn||r+s[s.length-1][0]>yn||i+s[s.length-1][1]<-yn||r+s[s.length-1][1]>yn)&&console.error("Elbow arrow normalization is outside reasonable bounds (> 1e6)",{x:i,y:r,points:s,...$l(s)}),s=s.map(([a,l])=>Z(Wi(a,-1e6,1e6),Wi(l,-1e6,1e6))),{points:s,x:Wi(i,-1e6,1e6),y:Wi(r,-1e6,1e6),fixedSegments:(t?.length??0)>0?t:null,...$l(s),startIsSpecial:n,endIsSpecial:o}},xs=e=>{if(e.length>1){let t=Math.abs(e[0][1]-e[1][1])<Math.abs(e[0][0]-e[1][0]);return e.filter((n,o)=>{if(o===0||o===e.length-1)return!0;let i=e[o+1],r=Math.abs(n[1]-i[1])<Math.abs(n[0]-i[0]);return t===r?(t=r,!1):(t=r,!0)})}return e},ys=e=>e.length>=4?e.filter((t,n)=>{if(n===0||n===e.length-1)return!0;let o=e[n-1];return hs(o,t)>fs}):e,Gh=e=>{switch(e){case 0:return rt;case 1:return we;case 2:return Ae}return Ze},ql=(e,t,n,o,i,r,s,a=!0,l=!0)=>s?a&&i&&r?ws(e,i,t,r,void 0,l):o:i?Ye(n||[0,0],i,r??Ph([i])):o,Kl=(e,t,n,o,i,r)=>nd(e,t,n,n&&ut(n,i,Array(4).fill(fn(n,i,e))),o,i,r),Ql=(e,t,n,o)=>Zt(e,n,t,xt(o)),Jl=(e,t)=>e[0]===t[0]&&e[1]===t[1],td=(e,t=fs)=>e.slice(1).map((n,o)=>Math.abs(n[0]-e[o][0])<t||Math.abs(n[1]-e[o][1])<t).every(Boolean);var ke=(e,t,n,o)=>{let i=!1,{points:r,fixedSegments:s,fileId:a}=n;Y(e)&&(Object.keys(n).length===0||typeof r<"u"||typeof s<"u")?n={...n,angle:0,...to({...e,x:n.x||e.x,y:n.y||e.y},t,n,o)}:typeof r<"u"&&(n={...Oh(r),...n});for(let l in n){let d=n[l];if(typeof d<"u"){if(e[l]===d&&(typeof d!="object"||d===null||l==="groupIds"||l==="scale"))continue;if(l==="scale"){let c=e[l],p=d;if(c[0]===p[0]&&c[1]===p[1])continue}else if(l==="points"){let c=e[l],p=d;if(c.length===p.length){let h=!1,m=c.length;for(;--m;){let f=c[m],g=p[m];if(f[0]!==g[0]||f[1]!==g[1]){h=!0;break}}if(!h)continue}}e[l]=d,i=!0}}return i&&((typeof n.height<"u"||typeof n.width<"u"||typeof a<"u"||typeof r<"u")&&st.delete(e),e.version=n.version??e.version+1,e.versionNonce=n.versionNonce??bs(),e.updated=Ms()),e},Ne=(e,t,n=!1)=>{let o=!1;for(let i in t){let r=t[i];if(typeof r<"u"){if(e[i]===r&&(typeof r!="object"||r===null))continue;o=!0}}return!o&&!n?e:{...e,...t,version:t.version??e.version+1,versionNonce:t.versionNonce??bs(),updated:Ms()}},od=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=bs(),e.updated=Ms(),e);var dd=5,jn=5,zh=10,Wo=10/1.5,Fe=(e,t)=>(t.elbowed?jn:dd)+e.strokeWidth/2,xt=e=>{let t=Math.max(dd,15),n=e?.value&&e.value<1?e.value:1;return Is(t/(n*1.5),t,t*2)},Dt=e=>e.isBindingEnabled,_h=(e,t,n,o,i,r,s)=>{let{start:a,end:l}=Ss(e,t,n,o,i.getNonDeletedElementsMap(),i.getNonDeletedElements(),r,{...s,finalize:!0});if(id(e,a,"start",i,r.isBindingEnabled),id(e,l,"end",i,r.isBindingEnabled),a.focusPoint||l.focusPoint){let d=new Map;a.focusPoint&&d.set(0,{point:bt(e,"startBinding",e.startBinding,a.element,i.getNonDeletedElementsMap())||e.points[0]}),l.focusPoint&&d.set(e.points.length-1,{point:bt(e,"endBinding",e.endBinding,l.element,i.getNonDeletedElementsMap())||e.points[e.points.length-1]}),G.movePoints(e,i,d)}return{start:a,end:l}},id=(e,{mode:t,element:n,focusPoint:o},i,r,s=!0)=>{t===null?Oe(e,i,r):t!==void 0&&Gt(e,n,t,i,r,o,s)},cd=(e,t,n,o,i)=>{pt(t.size===1,"Bound elbow arrows cannot be moved");let r=t.entries().next().value;pt(r,"There should be a position update for dragging an elbow arrow endpoint");let[s,{point:a}]=r,l=G.getPointGlobalCoordinates(e,a,n),d=Zt(l,o,n,xt(i)),c=d?{element:d,mode:"orbit",focusPoint:G.getPointAtIndexGlobalCoordinates(e,s,n)}:{mode:null},p={mode:void 0};return s===0?{start:c,end:p}:{start:p,end:c}},Wh=(e,t,n,o,i,r,s,a,l,d,c)=>{let p={mode:void 0},h={mode:void 0},m=e.points.length>2,f=G.getPointGlobalCoordinates(e,t.get(i?s:a).point,n),g=Zt(f,o,n);if(i)return g?p={element:g,mode:"inside",focusPoint:f}:p={mode:null},{start:p,end:h};if(r){let E=l?.selectedLinearElement?.initialState.origin;if(g&&e.startBinding?.elementId===g.id){let x=se(g.x+g.width/2,g.y+g.height/2);return{start:m?{mode:void 0}:{mode:"inside",element:g,focusPoint:E??x},end:m?{mode:"orbit",element:g,focusPoint:f}:{mode:"inside",element:g,focusPoint:f}}}if(g&&e.startBinding){let x=e.startBinding;if(Ri(f,o,n).find(w=>w.id===x.elementId)){let w=n.get(e.startBinding.elementId);return pt(w,"Other element must be in the elements map"),{start:m?{mode:void 0}:{mode:w.id!==g.id?"orbit":"inside",element:w,focusPoint:E??se(e.x,e.y)},end:{mode:"orbit",element:g,focusPoint:f}}}}if(e.startBinding&&e.startBinding.elementId!==g?.id){let x=n.get(e.startBinding.elementId);pt(x,"Other element must be in the elements map");let w={mode:!!l.selectedLinearElement?.initialState.arrowStartIsInside?"inside":"orbit",element:x,focusPoint:c?ce(x,n):E??se(e.x,e.y)},M=g&&ls(x,g,n),b;if(g){let S=d==="inside"||d==="skip";b={mode:S&&!M?"inside":"orbit",element:g,focusPoint:f}}else b={mode:null};return{start:m?{mode:void 0}:w,end:b}}if(!e.startBinding)return g?h={mode:d==="inside"||d==="skip"?"inside":"orbit",element:g,focusPoint:f}:h={mode:null},{start:p,end:h}}pt(!1,"New arrow creation should not reach here")},rd=(e,t,n,o,i,r,s,a)=>{let l={mode:void 0},d={mode:void 0},c=s.points.length>2,p=Zt(e,i,o),h=n?Ri(e,i,o).some(E=>E.id===n.elementId):!1,m=n?o.get(n.elementId):null,f=h&&m?Fh(m.backgroundColor):!1,g=p&&m&&ls(m,p,o);return r==="inside"||r==="skip"?(l=p?{element:!h||!m||f?p:m,focusPoint:e,mode:"inside"}:{mode:null},d=a&&p&&p.id===n?.elementId?{mode:null}:d,{current:l,other:d}):p?p.id===t?.elementId&&t.mode==="inside"?{current:{mode:"inside",focusPoint:e,element:p},other:d}:n?n.elementId===p.id?n.mode==="orbit"?(l={element:p,mode:"orbit",focusPoint:e},d={mode:a?null:void 0},{current:l,other:c?{mode:void 0}:d}):(l={element:p,mode:"inside",focusPoint:e},{current:l,other:c?{mode:void 0}:d}):(h&&m&&!f?l={element:m,mode:"inside",focusPoint:e}:l={element:p,mode:"orbit",focusPoint:e},{current:l,other:c?{mode:void 0}:d}):(l={element:p,mode:"orbit",focusPoint:e},{current:l,other:c?{mode:void 0}:d}):{current:{mode:null},other:d}},Ss=(e,t,n,o,i,r,s,a)=>Rh("COMPLEX_BINDINGS")?jh(e,t,i,r,s,a):ud(e,t,n,o,i,r,s,a),ud=(e,t,n,o,i,r,s,a)=>{let d=e.points.length-1,c=t.has(0),p=t.has(d),h={mode:void 0},m={mode:void 0};if(pt(e.points.length>1,"Do not attempt to bind linear elements with a single point"),!c&&!p)return{start:h,end:m};if(c&&p)return{start:{mode:null},end:{mode:null}};if(!Dt(s))return h=c?{mode:null}:h,m=p?{mode:null}:m,{start:h,end:m};if(Y(e))return cd(e,t,i,r,a?.zoom);let f=c?e.endBinding:e.startBinding,g=t.get(c?0:d)?.point;pt(g,`Local point must be defined for ${c?"start":"end"} dragging`);let E=G.getPointGlobalCoordinates(e,g,i),x=Zt(E,r,i,xt(s.zoom)),y=x&&(a?.angleLocked?Ut(se(n,o),x,i):Ut(E,x,i)),w=f?i.get(f.elementId):void 0,M=f&&w&&Ye(f.fixedPoint,w,i),b=w&&M&&Tt({point:M,element:w,elementsMap:i,threshold:0,overrideShouldTestInside:!0});if(f&&f.elementId===x?.id)return pt(!a?.newArrow||s.selectedLinearElement?.initialState.origin,"appState.selectedLinearElement.initialState.origin must be defined for new arrows"),{start:{mode:"inside",element:x,focusPoint:c?E:a?.newArrow?s.selectedLinearElement.initialState.origin:G.getPointAtIndexGlobalCoordinates(e,0,i)},end:{mode:"inside",element:x,focusPoint:p?E:G.getPointAtIndexGlobalCoordinates(e,-1,i)}};if(a?.altKey)return{start:c?x?{mode:"inside",element:x,focusPoint:E}:{mode:null}:h,end:p?x?{mode:"inside",element:x,focusPoint:E}:{mode:null}:m};let S=x?y?{mode:"inside",element:x,focusPoint:E}:{mode:"orbit",element:x,focusPoint:qr(e,E,x,c?"start":"end",i,s.zoom,s.isMidpointSnappingEnabled)||E}:{mode:null},A=G.getPointAtIndexGlobalCoordinates(e,c?-1:0,i),C=M&&w&&Tt({point:E,element:w,elementsMap:i,threshold:xt(s.zoom),overrideShouldTestInside:!0}),F=(a?.newArrow?s.selectedLinearElement?.initialState.arrowStartIsInside:f?.mode==="inside")?{mode:void 0}:w&&!b&&!C&&s.selectedLinearElement?.initialState.altFocusPoint?{mode:"orbit",element:w,focusPoint:s.selectedLinearElement.initialState.altFocusPoint}:a?.angleLocked&&w?{mode:"orbit",element:w,focusPoint:qr(e,A,w,c?"end":"start",i,s.zoom,s.isMidpointSnappingEnabled)||A}:{mode:void 0};return{start:c?S:F,end:p?S:F}},jh=(e,t,n,o,i,r)=>{let s=i.bindMode||"orbit",a=0,l=e.points.length-1,d=t.has(a),c=t.has(l),p={mode:void 0},h={mode:void 0};if(pt(e.points.length>1,"Do not attempt to bind linear elements with a single point"),!d&&!c)return{start:p,end:h};if(d&&c)return{start:{mode:null},end:{mode:null}};if(!Dt(i))return p=d?{mode:null}:p,h=c?{mode:null}:h,{start:p,end:h};if(Y(e))return cd(e,t,n,o);if(r?.newArrow){let{start:m,end:f}=Wh(e,t,n,o,d,c,a,l,i,s,r?.shiftKey);return{start:m,end:f}}if(d){let m=t.get(a)?.point;pt(m,"Local point must be defined for start dragging");let f=G.getPointGlobalCoordinates(e,m,n),{current:g,other:E}=rd(f,e.startBinding,e.endBinding,n,o,s,e,r?.finalize);return{start:g,end:E}}if(c){let m=t.get(l)?.point;pt(m,"Local point must be defined for end dragging");let f=G.getPointGlobalCoordinates(e,m,n),{current:g,other:E}=rd(f,e.endBinding,e.startBinding,n,o,s,e,r?.finalize);return{start:E,end:g}}return{start:p,end:h}},ny=(e,t,n)=>{e.forEach(o=>{_h(o,new Map,1/0,1/0,t,n)})},Gt=(e,t,n,o,i,r,s=!0)=>{let a=i.getNonDeletedElementsMap(),l;Y(e)?l={elementId:t.id,mode:"orbit",...Zh(e,t,o,a,s)}:l={elementId:t.id,mode:n,...no(e,t,o,a,r)},i.mutateElement(e,{[o==="start"?"startBinding":"endBinding"]:l}),ld(t.boundElements||[]).has(e.id)||i.mutateElement(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},Oe=(e,t,n)=>{let o=t==="start"?"startBinding":"endBinding",i=e[o];if(i==null)return null;let r=e[t==="start"?"endBinding":"startBinding"];if(!r||r.elementId!==i.elementId){let s=n.getNonDeletedElementsMap().get(i.elementId);n.mutateElement(s,{boundElements:s.boundElements?.filter(a=>a.id!==e.id)})}return n.mutateElement(e,{[o]:null}),i.elementId},Re=(e,t,n)=>{if(!fe(e))return;let{simultaneouslyUpdated:o}=n??{},i=Uh(o),r=t.getNonDeletedElementsMap();n?.changedElements&&(r=new Map(r),n.changedElements.forEach(a=>{r.set(a.id,a)})),Zi(r,e,a=>{if(!V(a)||a.isDeleted||!Vh(a,e))return;let l=a.startBinding?r.get(a.startBinding.elementId):null,d=a.endBinding?l?.id===a.endBinding.elementId?l:r.get(a.endBinding.elementId):null;if(i.has(a.id))return;let c=qi(r,a,(h,m)=>{if(h&&fe(h)&&(m==="startBinding"||m==="endBinding")&&(e.id===a[m]?.elementId||e.id===a[m==="startBinding"?"endBinding":"startBinding"]?.elementId)){let f=bt(a,m,a[m],h,r);if(f)return[m==="startBinding"?0:a.points.length-1,{point:f}]}return null}).filter(h=>h!==null);G.movePoints(a,t,new Map(c),{moveMidPointsWithElement:!!l&&l?.id===d?.id});let p=J(a,r);p&&!p.isDeleted&&Wn(a,t,!1)})},sd=(e,t,n,o,i)=>{pt(!Y(e),"Elbow arrows not supported for indirect updates");let r=e[t],s=r&&n.get(r.elementId),a=G.getPointAtIndexGlobalCoordinates(e,t==="startBinding"?0:-1,n),l=s&&Tt({element:s,point:a,elementsMap:n,threshold:xt(i.zoom)}),d=t==="startBinding"?"start":"end";if(Oe(e,d,o),l){let c=t==="startBinding"?0:e.points.length-1,p=e.points[c],h=ud(e,new Map([[c,{point:p}]]),a[0],a[1],n,o.getNonDeletedElements(),i);h[d]&&h[d].element?.id===s.id&&h[d].mode&&Gt(e,s,h[d].mode,d,o,h[d].focusPoint)}},oy=(e,t,n,o)=>{if(V(e)){let i=t.getNonDeletedElementsMap();e.startBinding&&sd(e,"startBinding",i,t,n),e.endBinding&&sd(e,"endBinding",i,t,n)}else Re(e,t,{...o,changedElements:new Map([[e.id,e]])})},Vh=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,Uh=e=>new Set((e||[]).map(t=>t.id)),nd=(e,t,n,o,i,r,s)=>{let a=qt(zo(t,e));return!n||!o?a:Yh(i,n,r,s)?Fo(n,o,e):qt(zo(e,ce(n,r)))},Yh=(e,t,n,o)=>{let i=fn(t,n,e),r=xt(o);return i>r?null:i},ws=(e,t,n,o,i,r=!0)=>{let s=Y(e),a=G.getPointAtIndexGlobalCoordinates(e,n==="start"?0:-1,o);if(e.points.length<2)return a;let l=hl(t)&&s?Xh(e,t,o,a):a,d=i&&!s?i[1]:G.getPointAtIndexGlobalCoordinates(e,n==="start"?1:-2,o),c=Fe(t,e),p=ut(t,o),h=Ct(p),m=null;if(s){let f=qe(Fo(t,p,a)),E=(r?vs(t,o,l,.05,e):void 0)||a,x=se(f?h[0]:E[0],f?E[1]:h[1]),y=i??$i(x,Yi(Xi(Ps(zo(E,x)),Math.max(t.width,t.height)*2),x));if(m=gn(t,o,y,c).sort(Qt)[0],!m){let w=se(f?E[0]:h[0],f?h[1]:E[1]),M=$i(w,Yi(Xi(Ps(zo(E,w)),Math.max(t.width,t.height)*2),w));m=gn(t,o,M,jn).sort(Qt)[0]}}else{let f=i;if(!f){let g=Xi(Ps(zo(l,d)),bn(l,d)+Math.max(t.width,t.height)+c*2);f=i??$i(Yi(g,d),Yi(Xi(g,-1),d))}m=bn(l,d)<1?l:gn(t,o,f,c).sort((g,E)=>Qt(g,d)-Qt(E,d))[0]}return!m||Qt(l,m)<Nh?l:m},Xh=(e,t,n,o)=>{let i=ce(t,n),r=ue(o,i,-t.angle),s=Fe(t,e);return r[0]<t.x&&r[1]<t.y?r[1]-t.y>-s?ue(se(t.x-s,t.y),i,t.angle):ue(se(t.x,t.y-s),i,t.angle):r[0]<t.x&&r[1]>t.y+t.height?r[0]-t.x>-s?ue(se(t.x,t.y+t.height+s),i,t.angle):ue(se(t.x-s,t.y+t.height),i,t.angle):r[0]>t.x+t.width&&r[1]>t.y+t.height?r[0]-t.x<t.width+s?ue(se(t.x+t.width,t.y+t.height+s),i,t.angle):ue(se(t.x+t.width+s,t.y+t.height),i,t.angle):r[0]>t.x+t.width&&r[1]<t.y?r[0]-t.x<t.width+s?ue(se(t.x+t.width,t.y-s),i,t.angle):ue(se(t.x+t.width+s,t.y),i,t.angle):o},vs=(e,t,n,o=.05,i)=>{let{x:r,y:s,width:a,height:l,angle:d}=e,c=ce(e,t,-.1,-.1),p=ue(n,c,-d),h=i?Fe(e,i):0,m=Is(o*l,5,80),f=Is(o*a,5,80);if(!(bn(c,p)<h)){if(p[0]<=r+a/2&&p[1]>c[1]-m&&p[1]<c[1]+m)return ue(se(r-h,c[1]),c,d);if(p[1]<=s+l/2&&p[0]>c[0]-f&&p[0]<c[0]+f)return ue(se(c[0],s-h),c,d);if(p[0]>=r+a/2&&p[1]>c[1]-m&&p[1]<c[1]+m)return ue(se(r+a+h,c[1]),c,d);if(p[1]>=s+l/2&&p[0]>c[0]-f&&p[0]<c[0]+f)return ue(se(c[0],s+l+h),c,d);if(e.type==="diamond"){let g=h,E=se(r+a/4-g,s+l/4-g),x=se(r+3*a/4+g,s+l/4-g),y=se(r+a/4-g,s+3*l/4+g),w=se(r+3*a/4+g,s+3*l/4+g);if(bn(E,p)<Math.max(f,m))return ue(E,c,d);if(bn(x,p)<Math.max(f,m))return ue(x,c,d);if(bn(y,p)<Math.max(f,m))return ue(y,c,d);if(bn(w,p)<Math.max(f,m))return ue(w,c,d)}}},$h=(e,t,n)=>{let o=e[t];if(!o)return{element:null,fixedPoint:null,focusPoint:null,binding:o,mode:null};let i=n.get(o.elementId);return{element:i,fixedPoint:o.fixedPoint,focusPoint:Ye(hn(o.fixedPoint),i,n),binding:o,mode:o.mode}},ad=e=>e.width*e.height,bt=(e,t,n,o,i,r)=>{if(n==null||n.elementId!==o.id&&e.points.length>2||Hh(e.points[e.points.length-1],se(0,0)))return null;let s=Ye(hn(n.fixedPoint),o,i);if(n.mode==="inside")return G.createPointAt(e,i,s[0],s[1],null);let{element:a,focusPoint:l}=$h(e,t==="startBinding"?"endBinding":"startBinding",i),d=G.getPointAtIndexGlobalCoordinates(e,t==="startBinding"?1:-2,i),c=e.points.length===2&&l||d,p=c&&$i(s,c),h=a&&p&&gn(a,i,p,Fe(a,e)).sort((w,M)=>Qt(w,s)-Qt(M,s))[0],m=p&&gn(o,i,p,Fe(o,e)).sort((w,M)=>Qt(w,c)-Qt(M,c))[0],f=e.startArrowhead!==null,g=e.endArrowhead!==null,E=!f&&!g||t==="startBinding"&&f||t==="endBinding"&&g?s:m||s;if(a&&m&&!r&&ad(a)<ad(o)*2&&Tt({element:a,point:m,elementsMap:i,threshold:Fe(a,e),overrideShouldTestInside:!0}))return G.createPointAt(e,i,E[0],E[1],null);let y=bn(a&&(h||l)||d,m||s)<=zh;return a?y?G.createPointAt(e,i,E?.[0]||s[0],E?.[1]||s[1],null):G.createPointAt(e,i,m?.[0]||s[0],m?.[1]||s[1],null):G.createPointAt(e,i,y?s[0]:m?.[0]??s[0],y?s[1]:m?.[1]??s[1],null)},Zh=(e,t,n,o,i=!0,r=!0)=>{let s=[t.x,t.y,t.x+t.width,t.y+t.height],a=i?ws(e,t,n,o,void 0,r):G.getPointAtIndexGlobalCoordinates(e,n==="start"?0:-1,o),l=se(s[0]+(s[2]-s[0])/2,s[1]+(s[3]-s[1])/2),d=ue(a,l,-t.angle);return{fixedPoint:hn([(d[0]-t.x)/t.width,(d[1]-t.y)/t.height])}},no=(e,t,n,o,i)=>{let r=i||G.getPointAtIndexGlobalCoordinates(e,n==="start"?0:-1,o),s=ce(t,o),a=ue(r,s,-t.angle),l=(a[0]-t.x)/t.width,d=(a[1]-t.y)/t.height;return{fixedPoint:hn([l,d])}},pd=(e,t,n)=>{for(let o of e){if("boundElements"in o&&o.boundElements&&Object.assign(o,{boundElements:o.boundElements.reduce((i,r)=>{let s=t.get(r.id);return s&&i.push({...r,id:s}),i},[])}),"containerId"in o&&o.containerId&&Object.assign(o,{containerId:t.get(o.containerId)??null}),"endBinding"in o&&o.endBinding){let i=t.get(o.endBinding.elementId);Object.assign(o,{endBinding:i?{...o.endBinding,elementId:i}:null})}if("startBinding"in o&&o.startBinding){let i=t.get(o.startBinding.elementId);Object.assign(o,{startBinding:i?{...o.startBinding,elementId:i}:null})}Y(o)&&Object.assign(o,to(o,n,{points:[o.points[0],o.points[o.points.length-1]]}))}},iy=(e,t)=>{let n=ld(e);for(let o of t)Mn.unbindAffected(n,o,(i,r)=>ke(i,n,r)),Pn.unbindAffected(n,o,(i,r)=>ke(i,n,r))},_o=(e,t,n=[])=>{if(!e)return null;let o=e.filter(i=>!t.has(i.id));return o.push(...n.map(i=>({id:i.id,type:i.type}))),o},hd=new Set(["boundElements","frameId","containerId","startBinding","endBinding"]),Zi=(e,t,n)=>{fe(t)&&(t.boundElements?.slice()??[]).forEach(({id:i})=>{n(e.get(i),"boundElements",i)})},qi=(e,t,n)=>{let o=[];if(t.frameId){let i=t.frameId;o.push(n(e.get(i),"frameId",i))}if(ge(t)){let i=t.containerId;o.push(n(e.get(i),"containerId",i))}if(V(t)){if(t.startBinding){let i=t.startBinding.elementId;o.push(n(e.get(i),"startBinding",i))}if(t.endBinding){let i=t.endBinding.elementId;o.push(n(e.get(i),"endBinding",i))}}return o},Mn=class{static unbindAffected(t,n,o){n&&qi(t,n,i=>{!i||i.isDeleted||Zi(t,i,(r,s,a)=>{a===n.id&&o(i,{boundElements:_o(i.boundElements,new Set([a]))})})})}static rebindAffected=(t,n,o)=>{!n||n.isDeleted||qi(t,n,(i,r)=>{if(!i||i.isDeleted){o(n,{[r]:null});return}r!=="frameId"&&(i.boundElements?.find(s=>s.id===n.id)||(V(n)&&o(i,{boundElements:_o(i.boundElements,new Set,new Array(n))}),ee(n)&&(i.boundElements?.find(s=>s.type==="text")?o(n,{[r]:null}):o(i,{boundElements:_o(i.boundElements,new Set,new Array(n))}))))})}},Pn=class{static unbindAffected(t,n,o){n&&Zi(t,n,i=>{!i||i.isDeleted||qi(t,i,(r,s,a)=>{a===n.id&&o(i,{[s]:null})})})}static rebindAffected=(t,n,o)=>{!n||n.isDeleted||Zi(t,n,(i,r,s)=>{if(!i||i.isDeleted){o(n,{boundElements:_o(n.boundElements,new Set([s]))});return}ee(i)&&((n.boundElements?.slice()??[]).reverse().find(l=>l.type==="text")?.id===i.id?i.containerId!==n.id&&o(i,{containerId:n.id}):(i.containerId!==null&&o(i,{containerId:null}),o(n,{boundElements:_o(n.boundElements,new Set([i.id]))})))})}},Ye=(e,t,n)=>{let[o,i]=hn(e);return ue(se(t.x+t.width*o,t.y+t.height*i),ce(t,n),t.angle)},qh=(e,t)=>{let n=e.startBinding&&t.get(e.startBinding.elementId),o=e.endBinding&&t.get(e.endBinding.elementId),i=n&&e.startBinding?Ye(e.startBinding.fixedPoint,n,t):se(e.x+e.points[0][0],e.y+e.points[0][1]),r=o&&e.endBinding?Ye(e.endBinding.fixedPoint,o,t):se(e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]);return[i,r]},md=(e,t)=>{let[n,o]=qh(e,t);return[G.pointFromAbsoluteCoords(e,n,t),G.pointFromAbsoluteCoords(e,o,t)]},Kh=e=>Array.isArray(e)&&e.length===2&&e.every(t=>Number.isFinite(t)),hn=e=>{if(!Kh(e))return[.5001,.5001];let t=1e-4;return Math.abs(e[0]-.5)<t||Math.abs(e[1]-.5)<t?e.map(n=>Math.abs(n-.5)<t?.5001:n):e},Qh=e=>e.type==="ellipse"||e.type==="diamond"?e.type:"rectangle",Jh={rectangle:[{centerAngle:0,sectorWidth:75,side:"right"},{centerAngle:45,sectorWidth:15,side:"bottom-right"},{centerAngle:90,sectorWidth:75,side:"bottom"},{centerAngle:135,sectorWidth:15,side:"bottom-left"},{centerAngle:180,sectorWidth:75,side:"left"},{centerAngle:225,sectorWidth:15,side:"top-left"},{centerAngle:270,sectorWidth:75,side:"top"},{centerAngle:315,sectorWidth:15,side:"top-right"}],diamond:[{centerAngle:0,sectorWidth:15,side:"right"},{centerAngle:45,sectorWidth:75,side:"bottom-right"},{centerAngle:90,sectorWidth:15,side:"bottom"},{centerAngle:135,sectorWidth:75,side:"bottom-left"},{centerAngle:180,sectorWidth:15,side:"left"},{centerAngle:225,sectorWidth:75,side:"top-left"},{centerAngle:270,sectorWidth:15,side:"top"},{centerAngle:315,sectorWidth:75,side:"top-right"}],ellipse:[{centerAngle:0,sectorWidth:15,side:"right"},{centerAngle:45,sectorWidth:75,side:"bottom-right"},{centerAngle:90,sectorWidth:15,side:"bottom"},{centerAngle:135,sectorWidth:75,side:"bottom-left"},{centerAngle:180,sectorWidth:15,side:"left"},{centerAngle:225,sectorWidth:75,side:"top-left"},{centerAngle:270,sectorWidth:15,side:"top"},{centerAngle:315,sectorWidth:75,side:"top-right"}]},em=e=>e.map((t,n)=>{let o=t.sectorWidth/2,i=t.centerAngle-o,r=t.centerAngle+o;return i=(i%360+360)%360,r=(r%360+360)%360,{start:i,end:r,side:t.side}}),tm=(e,t)=>{let[n,o]=e,i=n-.5,r=o-.5,s=Math.atan2(r,i);s<0&&(s+=2*Math.PI);let a=s*180/Math.PI,l=Jh[t],d=em(l);for(let h of d)if(h.start<=h.end){if(a>=h.start&&a<=h.end)return h.side}else if(a>=h.start||a<=h.end)return h.side;let c=1/0,p=l[0].side;for(let h of l){let m=Math.abs(a-h.centerAngle);m>180&&(m=360-m),m<c&&(c=m,p=h.side)}return p},ry=(e,t)=>{let n=t.get(e.elementId);if(!n||n.isDeleted||!fe(n))return null;let o=ce(n,t),i=Qh(n),r=tm(hn(e.fixedPoint),i),s=.01;if(n.type==="diamond"){let[a,l]=pn(n),[d,c,p,h]=a,m,f;switch(r){case"left":{if(l.length>=3){let E=l[2][1];m=E[0]-s,f=E[1]}else{let g=Ge(c[1],p[0]);m=g[0]-s,f=g[1]}break}case"right":{if(l.length>=1){let E=l[0][1];m=E[0]+s,f=E[1]}else{let g=Ge(h[1],d[0]);m=g[0]+s,f=g[1]}break}case"top":{if(l.length>=4){let E=l[3][1];m=E[0],f=E[1]-s}else{let g=Ge(p[1],h[0]);m=g[0],f=g[1]-s}break}case"bottom":{if(l.length>=2){let E=l[1][1];m=E[0],f=E[1]+s}else{let g=Ge(d[1],c[0]);m=g[0],f=g[1]+s}break}case"top-right":{let g=Ge(h[0],h[1]);m=g[0]+s*.707,f=g[1]-s*.707;break}case"bottom-right":{let g=Ge(d[0],d[1]);m=g[0]+s*.707,f=g[1]+s*.707;break}case"bottom-left":{let g=Ge(c[0],c[1]);m=g[0]-s*.707,f=g[1]+s*.707;break}case"top-left":{let g=Ge(p[0],p[1]);m=g[0]-s*.707,f=g[1]-s*.707;break}default:return null}return ue(se(m,f),o,n.angle)}if(n.type==="ellipse"){let a=n.x+n.width/2,l=n.y+n.height/2,d=n.width/2,c=n.height/2,p,h;switch(r){case"top":{p=a,h=l-c-s;break}case"right":{p=a+d+s,h=l;break}case"bottom":{p=a,h=l+c+s;break}case"left":{p=a-d-s,h=l;break}case"top-right":{let m=-Math.PI/4,f=d*Math.cos(m),g=c*Math.sin(m);p=a+f+s*.707,h=l+g-s*.707;break}case"bottom-right":{let m=Math.PI/4,f=d*Math.cos(m),g=c*Math.sin(m);p=a+f+s*.707,h=l+g+s*.707;break}case"bottom-left":{let m=3*Math.PI/4,f=d*Math.cos(m),g=c*Math.sin(m);p=a+f-s*.707,h=l+g+s*.707;break}case"top-left":{let m=-3*Math.PI/4,f=d*Math.cos(m),g=c*Math.sin(m);p=a+f-s*.707,h=l+g-s*.707;break}default:return null}return ue(se(p,h),o,n.angle)}if(To(n)){let[a,l]=un(n),[d,c,p,h]=a,m,f;switch(r){case"top":{let g=Ge(d[0],d[1]);m=g[0],f=g[1]-s;break}case"right":{let g=Ge(c[0],c[1]);m=g[0]+s,f=g[1];break}case"bottom":{let g=Ge(p[0],p[1]);m=g[0],f=g[1]+s;break}case"left":{let g=Ge(h[0],h[1]);m=g[0]-s,f=g[1];break}case"top-left":{if(l.length>=1){let g=l[0],E=g[0],x=g[3],y=Ge(E,x);m=y[0]-s*.707,f=y[1]-s*.707}else m=n.x-s,f=n.y-s;break}case"top-right":{if(l.length>=2){let g=l[1],E=g[0],x=g[3],y=Ge(E,x);m=y[0]+s*.707,f=y[1]-s*.707}else m=n.x+n.width+s,f=n.y-s;break}case"bottom-right":{if(l.length>=3){let g=l[2],E=g[0],x=g[3],y=Ge(E,x);m=y[0]+s*.707,f=y[1]+s*.707}else m=n.x+n.width+s,f=n.y+n.height+s;break}case"bottom-left":{if(l.length>=4){let g=l[3],E=g[0],x=g[3],y=Ge(E,x);m=y[0]-s*.707,f=y[1]+s*.707}else m=n.x-s,f=n.y+n.height+s;break}default:return null}return ue(se(m,f),o,n.angle)}return null},Ge=(e,t)=>se((e[0]+t[0])/2,(e[1]+t[1])/2);var As=({points:e})=>{let t=e[0][0],n=e[0][1];return{points:e.map(o=>R(o[0]-t,o[1]-n)),offsetX:t,offsetY:n}},G=class e{elementId;selectedPointsIndices;initialState;isDragging;lastUncommittedPoint;lastCommittedPoint;pointerOffset;hoverPointIndex;segmentMidPointHoveredCoords;hoveredFocusPointBinding;draggedFocusPointBinding;elbowed;customLineAngle;isEditing;pointerDownState;constructor(t,n,o=!1){this.elementId=t.id,gd(t.points[0],R(0,0))||(console.error("Linear element is not normalized",Error().stack),ke(t,n,e.getNormalizeElementPointsAndCoords(t))),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.lastCommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.initialState={prevSelectedPointsIndices:null,lastClickedPoint:-1,origin:null,segmentMidpoint:{value:null,index:null,added:!1},arrowStartIsInside:!1,altFocusPoint:null},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null,this.hoveredFocusPointBinding=null,this.draggedFocusPointBinding=null,this.elbowed=Y(t)&&t.elbowed,this.customLineAngle=null,this.isEditing=o}static POINT_HANDLE_SIZE=10;static getElement(t,n){let o=n.get(t);return o||null}static handleBoxSelection(t,n,o,i){if(!n.selectedLinearElement?.isEditing||!n.selectionElement)return!1;let{selectedLinearElement:r}=n,{selectedPointsIndices:s,elementId:a}=r,l=e.getElement(a,i);if(!l)return!1;let[d,c,p,h]=K(n.selectionElement,i),f=e.getPointsGlobalCoordinates(l,i).reduce((g,E,x)=>((E[0]>=d&&E[0]<=p&&E[1]>=c&&E[1]<=h||t.shiftKey&&s?.includes(x))&&g.push(x),g),[]).filter(g=>!(Y(l)&&g!==0&&g!==l.points.length-1));o({selectedLinearElement:{...r,selectedPointsIndices:f.length?f:null}})}static handlePointerMove(t,n,o,i,r){let s=n.scene.getNonDeletedElementsMap(),a=n.scene.getNonDeletedElements(),{elementId:l}=r,d=e.getElement(l,s);Ke(d,"Element being dragged must exist in the scene"),Ke(d.points.length>1,"Element must have at least 2 points");let c=d.points.length-1,p=d.points[c],h=d.points[c-1],m=r.customLineAngle??Pd(h,d.points[c]),f=0,g=0;if(jo(t)){let[b,S]=e._getShiftLockedDelta(d,s,h,R(o,i),t[Vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize(),m),A=R(b+h[0],S+h[1]);f=A[0]-p[0],g=A[1]-p[1]}else{let b=e.createPointAt(d,s,o-r.pointerOffset.x,i-r.pointerOffset.y,t[Vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize());f=b[0]-p[0],g=b[1]-p[1]}let E=null,{positions:x,updates:y}=Md([c],f,g,o,i,s,d,a,n,jo(t),t.altKey,r);if(e.movePoints(d,n.scene,x,{startBinding:y?.startBinding,endBinding:y?.endBinding,moveMidPointsWithElement:y?.moveMidPointsWithElement},{isBindingEnabled:n.state.isBindingEnabled,isMidpointSnappingEnabled:n.state.isMidpointSnappingEnabled}),Be(d,!1)&&Dt(n.state)&&(E=y?.suggestedBinding??null),Be(d)&&wd(e.getPointGlobalCoordinates(d,d.points[d.points.length-1],s),d,a,s,n.scene),n.state.selectedLinearElement?.customLineAngle===m&&r.initialState.altFocusPoint&&(!E||sm(n.state.suggestedBinding??[],E)))return null;let w=Be(d)&&d.startBinding&&s.get(d.startBinding.elementId);return{selectedLinearElement:{...r,customLineAngle:m,initialState:{...r.initialState,altFocusPoint:!r.initialState.altFocusPoint&&w&&y?.suggestedBinding?.element.id!==w.id?bd(d,R(d.x,d.y),w,"start",s,n.state.zoom,n.state.isMidpointSnappingEnabled):r.initialState.altFocusPoint}},suggestedBinding:E}}static handlePointDragging(t,n,o,i,r){let s=n.scene.getNonDeletedElementsMap(),a=n.scene.getNonDeletedElements(),{elbowed:l,elementId:d,initialState:c}=r,p=Array.from(r.selectedPointsIndices??[]),{lastClickedPoint:h}=c,m=e.getElement(d,s);Ke(m,"Element being dragged must exist in the scene"),Ke(m.points.length>1,"Element must have at least 2 points"),Ke(p,"There must be selected points in order to drag them"),l&&p.some((v,W)=>v>0&&v!==m.points.length-1?(p[W]=m.points.length-1,h=m.points.length-1,!0):!1),(h<0||!p.includes(h)||!m.points[h])&&(console.error(`There must be a valid lastClickedPoint in order to drag it. selectedPointsIndices(${JSON.stringify(p)}) points(0..${m.points.length-1}) lastClickedPoint(${h})`),h=m.points.length-1);let f=m.points[h],g=m.points[h===0?1:h-1],E=p.length===1,x=r.customLineAngle??Pd(g,m.points[h]),y=p.includes(0),w=p.includes(m.points.length-1),M=0,b=0;if(jo(t)&&E){let[v,W]=e._getShiftLockedDelta(m,s,g,R(o,i),t[Vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize(),x),X=R(v+g[0],W+g[1]);M=X[0]-f[0],b=X[1]-f[1]}else{let v=e.createPointAt(m,s,o-r.pointerOffset.x,i-r.pointerOffset.y,t[Vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize());M=v[0]-f[0],b=v[1]-f[1]}let S=null,{positions:A,updates:C}=Md(p,M,b,o,i,s,m,a,n,jo(t)&&E,t.altKey,r);e.movePoints(m,n.scene,A,{startBinding:C?.startBinding,endBinding:C?.endBinding,moveMidPointsWithElement:C?.moveMidPointsWithElement},{isBindingEnabled:n.state.isBindingEnabled,isMidpointSnappingEnabled:n.state.isMidpointSnappingEnabled}),Be(m,!1)&&Dt(n.state)&&(y||w)&&(S=C?.suggestedBinding??null),Be(m)&&y!==w&&wd(e.getPointGlobalCoordinates(m,y?m.points[0]:m.points[m.points.length-1],s),m,a,s,n.scene),J(m,s)&&Wn(m,n.scene,!1);let F=l?w?[m.points.length-1]:[0]:p,O=l?F[0]:h,N=!y&&!w?e.getPointGlobalCoordinates(m,f,s):null,D=O,q=Be(m)&&m.startBinding&&s.get(m.startBinding.elementId),U=Be(m)&&m.endBinding&&s.get(m.endBinding.elementId),le=w&&q&&C?.suggestedBinding?.element.id!==q.id?q:y&&U&&C?.suggestedBinding?.element.id!==U.id?U:null;return{selectedLinearElement:{...r,selectedPointsIndices:F,initialState:{...r.initialState,lastClickedPoint:O,altFocusPoint:!r.initialState.altFocusPoint&&Be(m)&&le?bd(m,R(m.x,m.y),le,"start",s,n.state.zoom,n.state.isMidpointSnappingEnabled):r.initialState.altFocusPoint},segmentMidPointHoveredCoords:N,hoverPointIndex:D,isDragging:!0,customLineAngle:x},suggestedBinding:S}}static handlePointerUp(t,n,o,i){let r=i.getNonDeletedElementsMap(),{elementId:s,selectedPointsIndices:a,isDragging:l,initialState:d}=n,c=e.getElement(s,r);if(!c)return n;if(l&&a)for(let p of a)(p===0||p===c.points.length-1)&&am(c.points,o.zoom.value)&&(Wt(c)&&i.mutateElement(c,{...Id(c,!0)},{informMutation:!1,isDragging:!1}),e.movePoints(c,i,new Map([[p,{point:p===0?c.points[c.points.length-1]:c.points[0]}]])));return{...n,segmentMidPointHoveredCoords:null,hoverPointIndex:-1,selectedPointsIndices:l||t.shiftKey?!l&&t.shiftKey&&d.prevSelectedPointsIndices?.includes(d.lastClickedPoint)?a&&a.filter(p=>p!==d.lastClickedPoint):a:a?.includes(d.lastClickedPoint)?[d.lastClickedPoint]:a,isDragging:!1,customLineAngle:null,initialState:{...n.initialState,origin:null,arrowStartIsInside:!1}}}static getEditorMidPoints=(t,n,o)=>{let i=J(t,n);if(!Y(t)&&!o.selectedLinearElement?.isEditing&&t.points.length>2&&!i)return[];let r=e.getPointsGlobalCoordinates(t,n),s=0,a=[];for(;s<r.length-1;){if(e.isSegmentTooShort(t,t.points[s],t.points[s+1],s,o.zoom)){a.push(null),s++;continue}let l=e.getSegmentMidPoint(t,s+1);a.push(l),s++}return a};static getSegmentMidpointHitCoords=(t,n,o,i)=>{let{elementId:r}=t,s=e.getElement(r,i);if(!s)return null;let a=e.getPointIndexUnderCursor(s,i,o.zoom,n.x,n.y);if(!Y(s)&&a>=0||e.getPointsGlobalCoordinates(s,i).length>=3&&!o.selectedLinearElement?.isEditing&&!Y(s))return null;let d=(e.POINT_HANDLE_SIZE+1)/o.zoom.value,c=t.segmentMidPointHoveredCoords;if(c&&Un(R(c[0],c[1]),R(n.x,n.y))<=d)return c;let p=0,h=e.getEditorMidPoints(s,i,o);for(;p<h.length;){if(h[p]!==null&&Un(h[p],R(n.x,n.y))<=d)return h[p];p++}return null};static isSegmentTooShort(t,n,o,i,r){if(Y(t))return i>=0&&i<t.points.length?Un(n,o)*r.value<e.POINT_HANDLE_SIZE/2:!1;let s=Un(n,o);if(t.points.length>2&&t.roundness){let[a,l]=xd(t);Ke(a.length===0&&l.length>0,"Only linears built out of curves are supported"),Ke(a.length+l.length>=i,"Invalid segment index while calculating mid point"),s=om(l[i])}return s*r.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,n){if(Y(t)){Ke(t.points.length>=n,"Invalid segment index while calculating elbow arrow mid point");let r=fd(t.points[n-1],t.points[n]);return R(t.x+r[0],t.y+r[1])}let[o,i]=xd(t);if(Ke(o.length===0&&i.length>0||o.length>0&&i.length===0,"Only linears built out of either segments or curves are supported"),Ke(o.length+i.length>=n,"Invalid segment index while calculating mid point"),o.length){let r=o[n-1];return fd(r[0],r[1])}if(i.length){let r=i[n-1];return im(r,.5)}Ke(!1,"Invalid segment type while calculating mid point")}static getSegmentMidPointIndex(t,n,o,i){let r=e.getElement(t.elementId,i);if(!r)return-1;let s=e.getEditorMidPoints(r,i,n),a=0;for(;a<s.length;){if(e.arePointsEqual(o,s[a]))return a+1;a++}return-1}static handlePointerDown(t,n,o,i,r,s){let a=n.state,l=s.getNonDeletedElementsMap(),d={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!r)return d;let{elementId:c}=r,p=e.getElement(c,l);if(!p)return d;let h=e.getSegmentMidpointHitCoords(r,i,a,l),m=R(i.x,i.y),f=null;if(h)f=e.getSegmentMidPointIndex(r,a,h,l);else if(t.altKey&&a.selectedLinearElement?.isEditing)return r.lastUncommittedPoint==null&&(s.mutateElement(p,{points:[...p.points,e.createPointAt(p,l,i.x,i.y,t[Vn.CTRL_OR_CMD]?null:n.getEffectiveGridSize())]}),d.didAddPoint=!0),o.scheduleCapture(),d.linearElementEditor={...r,initialState:{prevSelectedPointsIndices:r.selectedPointsIndices,lastClickedPoint:-1,origin:m,segmentMidpoint:{value:h,index:f,added:!1},arrowStartIsInside:!!n.state.newElement&&(n.state.bindMode==="inside"||n.state.bindMode==="skip"),altFocusPoint:null},selectedPointsIndices:[p.points.length-1],lastUncommittedPoint:null},d.didAddPoint=!0,d;let g=e.getPointIndexUnderCursor(p,l,a.zoom,i.x,i.y);(g>=0||h)&&(d.hitElement=p);let[E,x,y,w]=K(p,l),M=(E+y)/2,b=(x+w)/2,S=g>-1&&He(R(p.x+p.points[g][0],p.y+p.points[g][1]),R(M,b),p.angle),A=g>-1||t.shiftKey?t.shiftKey||r.selectedPointsIndices?.includes(g)?lm([...r.selectedPointsIndices||[],g]):[g]:null;return d.linearElementEditor={...r,initialState:{prevSelectedPointsIndices:r.selectedPointsIndices,lastClickedPoint:g,origin:m,segmentMidpoint:{value:h,index:f,added:!1},arrowStartIsInside:!!n.state.newElement&&(n.state.bindMode==="inside"||n.state.bindMode==="skip"),altFocusPoint:null},selectedPointsIndices:A,pointerOffset:S?{x:i.x-S[0],y:i.y-S[1]}:{x:0,y:0}},d}static arePointsEqual(t,n){return!t&&!n?!0:!t||!n?!1:gd(t,n)}static handlePointerMoveInEditMode(t,n,o,i){let r=i.state;if(!r.selectedLinearElement?.isEditing)return null;let{elementId:s,lastUncommittedPoint:a}=r.selectedLinearElement,l=i.scene.getNonDeletedElementsMap(),d=e.getElement(s,l);if(!d)return r.selectedLinearElement;let{points:c}=d,p=c[c.length-1];if(!t.altKey)return p===a&&e.deletePoints(d,i,[c.length-1]),r.selectedLinearElement?.lastUncommittedPoint?{...r.selectedLinearElement,lastUncommittedPoint:null}:r.selectedLinearElement;let h;if(jo(t)&&c.length>=2){let m=c[c.length-2],[f,g]=e._getShiftLockedDelta(d,l,m,R(n,o),t[Vn.CTRL_OR_CMD]?null:i.getEffectiveGridSize());h=R(f+m[0],g+m[1])}else h=e.createPointAt(d,l,n-r.selectedLinearElement.pointerOffset.x,o-r.selectedLinearElement.pointerOffset.y,t[Vn.CTRL_OR_CMD]||Y(d)?null:i.getEffectiveGridSize());return p===a?e.movePoints(d,i.scene,new Map([[d.points.length-1,{point:h}]])):e.addPoints(d,i.scene,[h]),{...r.selectedLinearElement,lastUncommittedPoint:d.points[d.points.length-1]}}static getPointGlobalCoordinates(t,n,o){let[i,r,s,a]=K(t,o),l=(i+s)/2,d=(r+a)/2,{x:c,y:p}=t;return He(R(c+n[0],p+n[1]),R(l,d),t.angle)}static getPointsGlobalCoordinates(t,n){let[o,i,r,s]=K(t,n),a=(o+r)/2,l=(i+s)/2;return t.points.map(d=>{let{x:c,y:p}=t;return He(R(c+d[0],p+d[1]),R(a,l),t.angle)})}static getPointAtIndexGlobalCoordinates(t,n,o){let i=n<0?t.points.length+n:n,[,,,,r,s]=K(t,o),a=R(r,s),l=t.points[i],{x:d,y:c}=t;return l?He(R(d+l[0],c+l[1]),a,t.angle):He(R(d,c),a,t.angle)}static pointFromAbsoluteCoords(t,n,o){if(Y(t))return R(n[0]-t.x,n[1]-t.y);let[i,r,s,a]=K(t,o),l=(i+s)/2,d=(r+a)/2,[c,p]=He(R(n[0],n[1]),R(l,d),-t.angle);return R(c-t.x,p-t.y)}static getPointIndexUnderCursor(t,n,o,i,r){let s=e.getPointsGlobalCoordinates(t,n),a=s.length;for(;--a>-1;){let l=s[a];if(Un(R(i,r),R(l[0],l[1]))*o.value<e.POINT_HANDLE_SIZE+1)return a}return-1}static createPointAt(t,n,o,i,r){let s=Ed(o,i,r),[a,l,d,c]=K(t,n),p=(a+d)/2,h=(l+c)/2,[m,f]=He(R(s[0],s[1]),R(p,h),-t.angle);return R(m-t.x,f-t.y)}static getNormalizeElementPointsAndCoords(t){let{points:n,offsetX:o,offsetY:i}=As(t);return{points:n,x:t.x+o,y:t.y+i}}static duplicateSelectedPoints(t,n){Ke(t.selectedLinearElement?.isEditing,"Not currently editing a linear element");let o=n.getNonDeletedElementsMap(),{selectedPointsIndices:i,elementId:r}=t.selectedLinearElement,s=e.getElement(r,o);Ke(s,"The linear element does not exist in the provided Scene"),Ke(i!=null,"There are no selected points to duplicate");let{points:a}=s,l=[],d=!1,c=-1,p=a.reduce((h,m,f)=>{if(++c,h.push(m),i.includes(f)){let E=a[f+1];E||(d=!0),h.push(E?R((m[0]+E[0])/2,(m[1]+E[1])/2):R(m[0],m[1])),l.push(c+1),++c}return h},[]);if(n.mutateElement(s,{points:p}),d){let h=s.points[s.points.length-1];e.movePoints(s,n,new Map([[s.points.length-1,{point:R(h[0]+30,h[1]+30)}]]))}return{...t,selectedLinearElement:{...t.selectedLinearElement,selectedPointsIndices:l}}}static deletePoints(t,n,o){let i=n.state.selectedLinearElement?.isEditing&&n.state.selectedLinearElement?.lastUncommittedPoint===t.points[t.points.length-1],r=t.points.filter((c,p)=>!o.includes(p));Wt(t)&&t.polygon&&(i||o.includes(0)||o.includes(t.points.length-1))&&(r[0]=R(r[r.length-1][0],r[r.length-1][1]));let{points:a,offsetX:l,offsetY:d}=As({points:r});e._updatePoints(t,n.scene,a,l,d)}static addPoints(t,n,o){let i=[...t.points,...o];Wt(t)&&t.polygon&&(i[0]=R(i[i.length-1][0],i[i.length-1][1]));let{points:r,offsetX:s,offsetY:a}=As({points:i});e._updatePoints(t,n,r,s,a)}static movePoints(t,n,o,i,r){let{points:s}=t;if(Wt(t)&&t.polygon){let p=o.get(0),h=o.get(s.length-1);p?o.set(s.length-1,{point:R(p.point[0],p.point[1]),isDragging:p.isDragging}):h&&o.set(0,{point:R(h.point[0],h.point[1]),isDragging:h.isDragging})}let a=o.get(0)?.point??R(0,0),[l,d]=a,c=Y(t)?[o.get(0)?.point??s[0],o.get(s.length-1)?.point??s[s.length-1]]:s.map((p,h)=>{let m=o.get(h)?.point??p;return i?.moveMidPointsWithElement&&h!==0&&h!==s.length-1&&!o.has(h)?m:R(m[0]-l,m[1]-d)});e._updatePoints(t,n,c,l,d,i,{isDragging:Array.from(o.values()).some(p=>p.isDragging),isBindingEnabled:r?.isBindingEnabled,isMidpointSnappingEnabled:r?.isMidpointSnappingEnabled})}static shouldAddMidpoint(t,n,o,i){let r=e.getElement(t.elementId,i);if(r&&Y(r)||!r)return!1;let{segmentMidpoint:s}=t.initialState;if(s.added||s.value===null||s.index===null||t.initialState.origin===null)return!1;let a=t.initialState.origin,l=Un(a,R(n.x,n.y));return!(!o.selectedLinearElement?.isEditing&&l<rm/o.zoom.value)}static addMidpoint(t,n,o,i,r){let s=r.getNonDeletedElementsMap(),a=e.getElement(t.elementId,s);if(!a)return;let{segmentMidpoint:l}=t.initialState,d={pointerDownState:t.initialState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,s,n.x,n.y,i&&!Y(a)?o.getEffectiveGridSize():null),p=[...a.points.slice(0,l.index),c,...a.points.slice(l.index)];return r.mutateElement(a,{points:p}),d.pointerDownState={...t.initialState,segmentMidpoint:{...t.initialState.segmentMidpoint,added:!0},lastClickedPoint:l.index},d.selectedPointsIndices=[l.index],d}static _updatePoints(t,n,o,i,r,s,a){if(Y(t)){let l={};s?.startBinding!==void 0&&(l.startBinding=s.startBinding),s?.endBinding!==void 0&&(l.endBinding=s.endBinding),l.points=Array.from(o),n.mutateElement(t,l,{informMutation:!0,isDragging:a?.isDragging??!1,isBindingEnabled:a?.isBindingEnabled,isMidpointSnappingEnabled:a?.isMidpointSnappingEnabled})}else{let l=ks(t,o),d=ks(t,t.points),c=(l[0]+l[2])/2,p=(l[1]+l[3])/2,h=(d[0]+d[2])/2,m=(d[1]+d[3])/2,f=h-c,g=m-p,E=He(R(i,r),R(f,g),t.angle);n.mutateElement(t,{...s,points:o,x:t.x+E[0],y:t.y+E[1]})}}static _getShiftLockedDelta(t,n,o,i,r,s){let a=e.getPointGlobalCoordinates(t,o,n);if(Y(t))return[i[0]-a[0],i[1]-a[1]];let[l,d]=Ed(i[0],i[1],r),{width:c,height:p}=Sd(a[0],a[1],l,d,s);return He(R(c,p),R(0,0),-t.angle)}static getBoundTextElementPosition=(t,n,o)=>{e.getPointsGlobalCoordinates(t,o).length<2&&ke(n,o,{isDeleted:!0});let r=0,s=0;if(t.points.length%2===1){let a=Math.floor(t.points.length/2),l=e.getPointGlobalCoordinates(t,t.points[a],o);r=l[0]-n.width/2,s=l[1]-n.height/2}else{let a=t.points.length/2-1,l=e.getSegmentMidPoint(t,a+1);r=l[0]-n.width/2,s=l[1]-n.height/2}return{x:r,y:s}};static getMinMaxXYWithBoundText=(t,n,o,i)=>{let[r,s,a,l]=o,d=(r+a)/2,c=(s+l)/2,{x:p,y:h}=e.getBoundTextElementPosition(t,i,n),m=p+i.width,f=h+i.height,g=R(d,c),E=He(R(r,s),g,t.angle),x=He(R(a,s),g,t.angle),y=He(R(p,h),g,-t.angle),w=He(R(m,h),g,-t.angle),M=He(R(p,f),g,-t.angle),b=He(R(m,f),g,-t.angle);return E[0]<x[0]&&E[1]>=x[1]?(r=Math.min(r,M[0]),a=Math.max(a,Math.max(w[0],b[0])),s=Math.min(s,y[1]),l=Math.max(l,b[1])):E[0]>=x[0]&&E[1]>x[1]?(r=Math.min(r,b[0]),a=Math.max(a,Math.max(y[0],w[0])),s=Math.min(s,M[1]),l=Math.max(l,w[1])):E[0]>=x[0]?(r=Math.min(r,w[0]),a=Math.max(a,M[0]),s=Math.min(s,b[1]),l=Math.max(l,y[1])):E[1]<=x[1]&&(r=Math.min(r,Math.min(w[0],y[0])),a=Math.max(a,b[0]),s=Math.min(s,w[1]),l=Math.max(l,M[1])),[r,s,a,l,d,c]};static getElementAbsoluteCoords=(t,n,o=!1)=>{let i=st.generateElementShape(t,null),r=zt(i[0]),[s,a,l,d]=Vo(r),c=s+t.x,p=a+t.y,h=l+t.x,m=d+t.y,f=(c+h)/2,g=(p+m)/2,E=o&&J(t,n);return E?e.getMinMaxXYWithBoundText(t,n,[c,p,h,m],E):[c,p,h,m,f,g]};static moveFixedSegment(t,n,o,i,r){let s=r.getNonDeletedElementsMap(),a=e.getElement(t.elementId,s);if(!a||!Y(a))return t;if(n&&n>0&&n<a.points.length){let l=qe(qt(nm(a.points[n],a.points[n-1]))),d=(a.fixedSegments??[]).reduce((m,f)=>(m[f.index]=f,m),{});d[n]={index:n,start:R(l?a.points[n-1][0]:o-a.x,l?i-a.y:a.points[n-1][1]),end:R(l?a.points[n][0]:o-a.x,l?i-a.y:a.points[n][1])};let c=Object.values(d).sort((m,f)=>m.index-f.index),p=c.map(m=>m.index).reduce((m,f)=>f<n?m+1:m,0);r.mutateElement(a,{fixedSegments:c});let h=R(a.x+(a.fixedSegments[p].start[0]+a.fixedSegments[p].end[0])/2,a.y+(a.fixedSegments[p].start[1]+a.fixedSegments[p].end[1])/2);return{...t,segmentMidPointHoveredCoords:h,initialState:{...t.initialState,segmentMidpoint:{added:!1,index:a.fixedSegments[p].index,value:h}}}}return t}static deleteFixedSegment(t,n,o){n.mutateElement(t,{fixedSegments:t.fixedSegments?.filter(i=>i.index!==o)})}},lm=e=>{let t=[...new Set(e.filter(n=>n!==null&&n!==-1))];return t=t.sort((n,o)=>n-o),t.length?t:null},Md=(e,t,n,o,i,r,s,a,l,d,c,p)=>{let h=new Map(e.map(U=>[U,{point:R(s.points[U][0]+t,s.points[U][1]+n),isDragging:!0}]));if(!V(s))return{positions:h};let m=e.includes(0),f=e.includes(s.points.length-1),{start:g,end:E}=Ss(s,h,o,i,r,a,l.state,{newArrow:!!l.state.newElement,angleLocked:d,altKey:c});if(Y(s)){let U=m?g.element:f?E.element:null;return{positions:h,updates:{suggestedBinding:U?{element:U,midPoint:l.state.isMidpointSnappingEnabled?vs(U,r,R(o-p.pointerOffset.x,i-p.pointerOffset.y)):void 0}:null}}}if(!m&&!f){let U={...s,points:s.points.map((H,v)=>h.get(v)?.point??H)},le=new Map(h);if(s.startBinding){let H=r.get(s.startBinding.elementId);if(H){let v=bt(U,"startBinding",s.startBinding,H,r)??null;v&&le.set(0,{point:v,isDragging:!0})}}if(s.endBinding){let H=r.get(s.endBinding.elementId);if(H){let v=bt(U,"endBinding",s.endBinding,H,r)??null;v&&le.set(s.points.length-1,{point:v,isDragging:!0})}}return{positions:le}}if(m===f)return{positions:h};let x={suggestedBinding:null};g.mode===null?x.startBinding=null:g.mode?(x.startBinding={elementId:g.element.id,mode:g.mode,...no(s,g.element,"start",r,g.focusPoint)},m&&(x.startBinding.mode==="orbit"||!oo("COMPLEX_BINDINGS"))&&(x.suggestedBinding=g.element?{element:g.element,midPoint:yd(R(o-p.pointerOffset.x,i-p.pointerOffset.y),g.element,r,l.state.zoom)}:null)):m&&(x.suggestedBinding=l.state.suggestedBinding),E.mode===null?x.endBinding=null:E.mode?(x.endBinding={elementId:E.element.id,mode:E.mode,...no(s,E.element,"end",r,E.focusPoint)},f&&(x.endBinding.mode==="orbit"||!oo("COMPLEX_BINDINGS"))&&(x.suggestedBinding=E.element?{element:E.element,midPoint:yd(R(o-p.pointerOffset.x,i-p.pointerOffset.y),E.element,r,l.state.zoom)}:null)):f&&(x.suggestedBinding=l.state.suggestedBinding);let y=m?R(s.points[0][0]+t,s.points[0][1]+n):s.points[0],w=f?R(s.points[s.points.length-1][0]+t,s.points[s.points.length-1][1]+n):s.points[s.points.length-1],M={...s,points:[y,...s.points.slice(1,-1),w],startBinding:x.startBinding===void 0?s.startBinding:x.startBinding===null?null:x.startBinding,endBinding:x.endBinding===void 0?s.endBinding:x.endBinding===null?null:x.endBinding},b=s.endBinding&&M.startBinding&&m&&M.startBinding.elementId===s.endBinding.elementId,S=s.startBinding&&M.endBinding&&f&&s.startBinding.elementId===M.endBinding.elementId,A=M.endBinding?E.element??r.get(M.endBinding.elementId):null,C=b?M.points[M.points.length-1]:S&&l.state.bindMode!=="inside"&&oo("COMPLEX_BINDINGS")?M.points[0]:A&&bt(s,"endBinding",M.endBinding,A,r,f)||M.points[M.points.length-1];M.points[M.points.length-1]=C;let T=M.startBinding?g.element??r.get(M.startBinding.elementId):null,F=S&&oo("COMPLEX_BINDINGS")?M.points[0]:b&&l.state.bindMode!=="inside"&&oo("COMPLEX_BINDINGS")?C:T&&bt(s,"startBinding",M.startBinding,T,r,m)||M.points[0],O=!b&&!(S&&l.state.bindMode!=="inside"&&oo("COMPLEX_BINDINGS"))&&!!A,N=Un(F,M.points[0])!==0,D=new Set(e);T&&N&&D.add(0),A&&O&&D.add(s.points.length-1);let q=Array.from(D);return{updates:x,positions:new Map(q.map(U=>[U,U===0?{point:F,isDragging:!0}:U===s.points.length-1?{point:C,isDragging:!0}:h.get(U)]))}},Pd=(e,t)=>Math.atan2(t[1]-e[1],t[0]-e[0]);I();import{arrayToMap as Rt}from"@excalidraw/common";import{isPointWithinBounds as Lm,pointFrom as Ds}from"@excalidraw/math";I();import{vectorCross as Td,vectorFromPoint as Ki}from"@excalidraw/math";function vd(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function dm(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}var cm=1e-6;function Ad(e,t){let n=Ki(e[1],e[0]),o=Ki(t,e[0]),i=Td(n,o);return Math.abs(i)<cm}function Ts(e,t){let n=Ki(e[1],e[0]),o=Ki(t,e[0]);return Td(n,o)<0}function kd(e,t){return Ad(e,t[0])||Ad(e,t[1])||(Ts(e,t[0])?!Ts(e,t[1]):Ts(e,t[1]))}function Ld(e,t){return dm(vd(e),vd(t))&&kd(e,t)&&kd(t,e)}I();import{arrayToMap as um}from"@excalidraw/common";import{getElementBounds as pm}from"@excalidraw/element";import{isArrowElement as hm,isExcalidrawElement as mm,isFreeDrawElement as fm,isLinearElement as gm,isTextElement as Em}from"@excalidraw/element";import{rangeIncludesValue as Qi,pointFrom as Jt,pointRotateRads as xm,rangeInclusive as Ji}from"@excalidraw/math";var ym=e=>e.type==="diamond"?[Jt(e.width/2,0),Jt(e.width,e.height/2),Jt(e.width/2,e.height),Jt(0,e.height/2)]:[Jt(0,0),Jt(0+e.width,0),Jt(0+e.width,e.height),Jt(0,e.height)],wm=e=>gm(e)||fm(e)?e.points:ym(e),Cd=e=>{let t=e.reduce((n,[o,i])=>(n.minY=Math.min(n.minY,i),n.minX=Math.min(n.minX,o),n.maxX=Math.max(n.maxX,o),n.maxY=Math.max(n.maxY,i),n),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},Dd=e=>{let t=wm(e),{cx:n,cy:o}=Cd(t),i=Jt(n,o),r=t.map(c=>xm(c,i,e.angle)),{minX:s,minY:a,maxX:l,maxY:d}=Cd(r);return[s+e.x,a+e.y,l+e.x,d+e.y]},Bd=(e,t,n=!1)=>{let o=Dd(e),i=t[0]<=o[0]&&t[2]>=o[2]&&t[1]<=o[1]&&t[3]>=o[3];return n?i?!0:o[0]<=t[0]&&o[2]>=t[2]&&o[1]<=t[1]&&o[3]>=t[3]:i},bm=(e,t)=>{let n=Dd(e);return(Qi(n[0],Ji(t[0],t[2]))||Qi(t[0],Ji(n[0],n[2])))&&(Qi(n[1],Ji(t[1],t[3]))||Qi(t[1],Ji(n[1],n[3])))},Gd=({elements:e,bounds:t,type:n,errorMargin:o=0})=>{mm(t)&&(t=pm(t,um(e)));let i=[t[0]-o,t[1]-o,t[2]+o,t[3]+o],r=new Set;for(let s of e){if(r.has(s.id))continue;if(n==="overlap"?bm(s,i):n==="inside"?Bd(s,i):Bd(s,i,!0)){if(r.add(s.id),s.boundElements)for(let l of s.boundElements)r.add(l.id);Em(s)&&s.containerId&&r.add(s.containerId),hm(s)&&(s.startBinding&&r.add(s.startBinding.elementId),s.endBinding&&r.add(s.endBinding?.elementId))}}return e.filter(s=>r.has(s.id))};I();import{arrayToMap as Am,isShallowEqual as km}from"@excalidraw/common";I();var Mm=(e,t,n)=>{let o=n.reduce((i,r)=>(r.groupIds.includes(e)&&(i[r.id]=!0),i),{});return Object.keys(o).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...o}}},Od=function(){let e=null,t=null,n=null,o=(r,s,a,l)=>{if(n!==void 0&&s===t&&r===e&&a.editingGroupId===n?.editingGroupId)return n;let d={};for(let h of r){let m=h.groupIds;if(a.editingGroupId){let f=m.indexOf(a.editingGroupId);f>-1&&(m=m.slice(0,f))}if(m.length>0){let f=m[m.length-1];d[f]=!0}}let c={},p=s.reduce((h,m)=>{if(m.isDeleted)return h;let f=m.groupIds.find(g=>d[g]);return f&&(h[m.id]=!0,Array.isArray(c[f])?c[f].push(m.id):c[f]=[m.id]),h},{});for(let h of Object.keys(c))c[h].length<2&&d[h]&&(d[h]=!1);return t=s,e=r,n={editingGroupId:a.editingGroupId,selectedGroupIds:d,selectedElementIds:Ls({...a.selectedElementIds,...p},l)},n},i=(r,s,a,l)=>{let d=l?l.scene.getSelectedElements({selectedElementIds:r.selectedElementIds,elements:s}):Ot(s,r);return d.length?o(d,s,r,a):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Ls(r.selectedElementIds,a)}};return i.clearCache=()=>{t=null,e=null,n=null},i}(),Pm=(e,t)=>Cs(e,t)!=null,Cs=(e,t)=>t.groupIds.filter(n=>n!==e.editingGroupId).find(n=>e.selectedGroupIds[n]),Im=e=>Object.entries(e.selectedGroupIds).filter(([t,n])=>n).map(([t,n])=>t),Rd=(e,t)=>{let n={...t,selectedGroupIds:{}};for(let o of e){let i=o.groupIds;if(t.editingGroupId){let r=i.indexOf(t.editingGroupId);r>-1&&(i=i.slice(0,r))}if(i.length>0){let r=i[i.length-1];n={...n,...Mm(r,n,e)}}}return n.selectedGroupIds},Oy=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),Sm=(e,t)=>e.groupIds.includes(t),ze=(e,t)=>{let n=[];for(let o of e.values())Sm(o,t)&&n.push(o);return n},vm=(e,t)=>e.groupIds.find(n=>t[n]),Ry=(e,t,n)=>{let o=[...e],i=n?o.indexOf(n):-1,r=i>-1?i:o.length;return o.splice(r,0,t),o},Fy=(e,t)=>e.filter(n=>!t[n]),er=(e,t)=>{let n=new Map;return e.forEach(o=>{let i=o.groupIds.length===0?o.id:o.groupIds[o.groupIds.length-1],r=n.get(i)||[],s=J(o,t);s&&r.push(s),n.set(i,[...r,o])}),Array.from(n.values())},Fd=e=>{let t=new Set;for(let[,n]of e)if(!n.isDeleted)for(let o of n.groupIds??[])t.add(o);return t},Nd=e=>{let t=e.flatMap(i=>i.groupIds),n=new Map,o=0;for(let i of t)n.set(i,(n.get(i)??0)+1),n.get(i)>o&&(o=n.get(i));return o===e.length},Hd=e=>e.groupIds.length>0,zd=(e,t,n)=>{let o=[...e],i=t?e.indexOf(t):-1,r=i>-1?i:e.length;for(let s=0;s<r;s++)o[s]=n(o[s]);return o},tr=(e,t,n)=>{let o=Im(n),i=e.filter(p=>!ge(p)),r=new Map,s=new Map,a=p=>{let h=s.get(p.id)||[],m=J(p,t);m&&h.push(m),s.set(p.id,[...h,p])},l=(p,h)=>{let m=r.get(h)||[],f=J(p,t);f&&m.push(f),r.set(h,[...m,p])},d=(p,h)=>{let m=p.groupIds.indexOf(h,0);return p.groupIds.slice(0,m).length>0?l(p,p.groupIds[m-1]):a(p)},c=e.every(p=>Pm(n,p));return i.forEach(p=>{let h=vm(p,n.selectedGroupIds);h?o.length===1&&c?d(p,h):l(p,h):a(p)}),Array.from(r.values()).concat(Array.from(s.values()))};var _d=e=>{let t=new Set;return e.forEach(n=>{te(n)&&t.add(n.id)}),e.filter(n=>!(n.frameId&&t.has(n.frameId)))},Bs=(e,t,n,o=!0)=>{let[i,r,s,a]=K(t,n),l=e.filter(d=>{let[c,p,h,m]=Me(d,n),f=en(d,n);if(f){let[g,E,x,y]=Me(f,n);c=Math.max(g,c),p=Math.max(E,p),h=Math.min(x,h),m=Math.min(y,m)}return d.locked===!1&&d.type!=="selection"&&!ge(d)&&i<=c&&r<=p&&s>=h&&a>=m});return l=o?_d(l):l,l=l.filter(d=>{let c=en(d,n);return c?In(d,c,n):!0}),l},Xy=(e,t,n,o)=>{let i=new Set(t.map(r=>r.id));return e.filter(r=>{let s=Wd(r,n.width,n.height,n,o);return!i.has(r.id)&&s})},$y=function(){let e=null,t=null,n=null,o=(i,r)=>(n!=null&&i===e&&r.selectedElementIds===t||(n=i.some(s=>r.selectedElementIds[s.id]),e=i,t=r.selectedElementIds),n);return o.clearCache=()=>{e=null,t=null,n=null},o}(),Ot=(e,t,n)=>{let o=new Set,i=[];for(let r of e.values()){if(t.selectedElementIds[r.id]){i.push(r),o.add(r.id);continue}if(n?.includeBoundTextElement&&ge(r)&&t.selectedElementIds[r?.containerId]){i.push(r),o.add(r.id);continue}}if(n?.includeElementsInFrames){let r=[];return i.forEach(s=>{te(s)&&Sn(e,s.id).forEach(a=>!o.has(a.id)&&r.push(a)),r.push(s)}),r}return i},Zy=(e,t)=>t.editingTextElement?[t.editingTextElement]:t.newElement?[t.newElement]:Ot(e,t,{includeBoundTextElement:!0}),Ls=(e,t)=>km(t.selectedElementIds,e)?t.selectedElementIds:e,Tm=(e,t)=>{let n=e.filter(ne);if(n.length===1){let o=n[0],i=o.boundElements?.map(s=>s.id)??[];if(e.every(s=>s.id===o.id||i.includes(s.id)))return new G(o,Am(t))}return null},qy=(e,t,n)=>({selectedLinearElement:Tm(e,t),...Od({editingGroupId:n.editingGroupId,selectedElementIds:_d(e).reduce((o,i)=>(ge(i)||(o[i.id]=!0),o),{})},t,n,null)}),Ky=(e,t)=>t.editingTextElement||e.length===1&&ee(e[0])&&e[0]||null;var jd=(e,t,n)=>{let o=Rt(e);for(let i of t)if(i.frameId){let r=n.get(i.id),s=n.get(i.frameId),a=r&&o.get(r);a&&ke(a,o,{frameId:s??null})}};function io(e,t,n){let o=Gs(t,n),i=Gs(e,n);return o.some(s=>i.some(a=>Ld(s,a)))}var Vd=(e,t,n)=>nr(Bs(e,t,n,!1)).filter(o=>!te(o)&&!o.frameId||o.frameId===t.id),Os=(e,t,n)=>Bs([t],e,n).some(o=>o.id===t.id),cw=(e,t)=>{let n=Rt(e);return e.filter(o=>io(o,t,n))},vn=(e,t,n)=>{let[o,i,r,s]=K(t,n),[a,l,d,c]=_e(e);return o<=a&&i<=l&&r>=d&&s>=c},In=(e,t,n)=>vn([e],t,n)||io(e,t,n)||Os(e,t,n),uw=(e,t,n)=>{let[o,i,r,s]=K(t,n);return Lm(Ds(o,i),Ds(e.x,e.y),Ds(r,s))},pw=(e,t,n)=>{let o=Rt(e),i=t.flatMap(r=>ze(e,r));return i.length===0?!0:!!i.find(r=>vn([r],n,o)||io(r,n,o))},hw=(e,t,n)=>{let o=Rt(e),i=t.flatMap(r=>ze(e,r));return i.length===0?!0:i.find(r=>vn([r],n,o)||io(r,n,o))===void 0},mw=e=>{let t=new Map;for(let n of e){let o=te(n)?n.id:n.frameId;o&&!t.has(o)&&t.set(o,Sn(e,o))}return t},Sn=(e,t)=>{let n=[];for(let o of e.values())o.frameId===t&&n.push(o);return n},Cm=e=>e.filter(t=>te(t)),fw=e=>{let t=Rt(Cm(e));return e.filter(n=>t.has(n.id)||!n.frameId||!t.has(n.frameId))},gw=(e,t,n,o)=>{let i=Sn(e,t.id),r=new Set(i),s=new Set([...Vd(e,t,o),...i.filter(h=>Os(h,t,o))]),a=i.filter(h=>!s.has(h)),l=new Set(Array.from(s).flatMap(h=>h.groupIds));for(let h of a)if(!io(h,t,o))h.groupIds.length===0&&r.delete(h);else if(h.groupIds.length>0)for(let m of h.groupIds)l.add(m);for(let h of a)if(h.groupIds.length>0){let m=!0;for(let f of h.groupIds)l.has(f)&&(m=!1);m&&r.delete(h)}let d=Array.from(s).filter(h=>h.groupIds.length===0);for(let h of d)r.add(h);let c=Array.from(s).filter(h=>h.groupIds.length>0),p=Rd(c,n);for(let[h,m]of Object.entries(p))if(m){let f=ze(e,h);if(vn(f,t,o))for(let g of f)r.add(g)}return[...r].filter(h=>!(ee(h)&&h.containerId))},Ew=(e,t,n)=>Bm(nr(e,Vd(e,t,n)),t,n),Bm=(e,t,n)=>{let o=[],i=new Map;for(let r of e){let s=!1;if(r.groupIds.length>0){if(r.groupIds.some(a=>i.get(a)))s=!0;else{let a=new Set(r.groupIds.flatMap(l=>ze(n,l)));s=!vn(Array.from(a),t,n)}r.groupIds.forEach(a=>{i.set(a,s)})}s||o.push(r)}return o},en=(e,t)=>e.frameId&&t.get(e.frameId)||null,xw=(e,t)=>{let n=new Set,o=Rt(e);e=nr(e);for(let s of e)te(s)&&s.id!==t.id&&n.add(s.id);let i=new Set,r=[];for(let s of e)if(!(te(s)||s.frameId&&n.has(s.frameId)))if(s.groupIds.length){let a=s.groupIds.at(-1);if(!i.has(a)){i.add(a);let l=ze(e,a);if(l.some(d=>In(d,t,o)))for(let d of l)r.push(d)}}else In(s,t,o)&&r.push(s);return r},Dm=(e,t,n,o)=>{let i=Rt(e),r=new Map;for(let d of e.values())d.frameId===n.id&&r.set(d.id,!0);let s=new Set(t.map(d=>d.id)),a=[],l=new Set;for(let d of t)te(d)&&d.id!==n.id&&l.add(d.id);for(let d of nr(e,t)){if(te(d)||d.frameId&&l.has(d.frameId)||d.frameId&&o.selectedElementIds[d.id]&&o.selectedElementIds[d.frameId])continue;r.has(d.id)||a.push(d);let c=J(d,i);c&&!s.has(c.id)&&!r.has(c.id)&&a.push(c)}for(let d of a)ke(d,i,{frameId:n.id});return e},Ud=(e,t)=>{let n=new Map,o=new Map;for(let i of e)if(i.frameId){n.set(i.id,i);let r=o.get(i.frameId)||[];r.push(i);let s=J(i,t);s&&(n.set(s.id,s),r.push(s)),o.set(i.frameId,r)}for(let[,i]of n)ke(i,t,{frameId:null})},Gm=(e,t)=>{let n=Sn(e,t.id);return Ud(n,Rt(e)),e},yw=(e,t,n,o)=>Dm(Gm(e,n),t,n,o.state).slice(),ww=(e,t,n)=>{let o=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),i=new Set(o);if(t.editingGroupId)for(let a of o)a.groupIds.length===0?i.add(a):a.groupIds.flatMap(l=>ze(e,l)).forEach(l=>i.add(l));let r=new Set,s=Rt(e);return i.forEach(a=>{a.frameId&&!te(a)&&!Yd(a,s,t)&&r.add(a)}),r.size>0&&Ud(r,s),e},nr=(e,t)=>{let n=new Set,o=t||e;for(let s of o.values()){let a=s.groupIds[s.groupIds.length-1];a&&n.add(a)}let i=new Set;for(let s of n)ze(e,s).some(a=>te(a))&&i.add(s);let r=[];for(let s of o.values())i.has(s.groupIds[s.groupIds.length-1])||r.push(s);return r},Om=(e,t,n)=>{let o=ee(e)&&De(e,t)||e;return o.frameId&&n.selectedElementIds[o.id]&&n.selectedElementIds[o.frameId]?en(o,t):n.selectedElementIds[o.id]&&n.selectedElementsAreBeingDragged?n.frameToHighlight:en(o,t)},Yd=(e,t,n,o)=>{let i=o?.targetFrame??Om(e,t,n);if(!i)return!1;let r=ee(e)&&De(e,t)||e,s=l=>{o?.checkedGroups&&r.groupIds.forEach(d=>{o.checkedGroups?.set(d,l)})};if(!n.selectedElementIds[r.id]||!n.selectedElementsAreBeingDragged||n.selectedElementIds[r.id]&&n.selectedElementIds[i.id])return!0;if(r.groupIds.length===0)return In(r,i,t);for(let l of r.groupIds)if(o?.checkedGroups?.has(l))return o.checkedGroups.get(l);let a=new Set(r.groupIds.filter(l=>o?.checkedGroups?!o.checkedGroups.has(l):!0).flatMap(l=>ze(t,l)));if(n.editingGroupId&&n.selectedElementsAreBeingDragged){let l=new Set(Ot(t,n));if(n.frameToHighlight!==null)return!0;l.forEach(c=>{a.delete(c)})}for(let l of a)if(te(l))return s(!1),!1;for(let l of a)if(In(l,i,t))return s(!0),!0;return!1},bw=(e,t,n,o,i)=>{if(!n.frameRendering||!n.frameRendering.clip)return!1;let r=io(e,t,o)||Os(e,t,o);if(r){for(let s of e.groupIds)i?.set(s,!0);return!0}if(!r&&e.groupIds.length>0&&!vn([e],t,o)){let s=!1;if(n.selectedElementsAreBeingDragged)s=Yd(e,o,n,{targetFrame:t,checkedGroups:i});else{s=e.frameId===t.id;for(let a of e.groupIds)i?.set(a,s)}for(let a of e.groupIds)i?.set(a,s);return s}return!1},Rm="Frame",Fm="AI Frame",Nm=e=>Si(e)?Rm:Fm,Mw=e=>e.name===null?Nm(e):e.name,Pw=(e,t)=>Gd({elements:e,bounds:t,type:"overlap"}).filter(n=>!n.frameId||n.frameId===t.id),Iw=e=>{let t=Rt(e);return e.length>1&&e.some(n=>n.frameId&&t.has(n.frameId))};var $m=(e,t)=>Nn(e)&&!t.imageCache.has(e.fileId),ar=e=>{switch(e.type){case"freedraw":return e.strokeWidth*12;case"text":return e.fontSize/2;case"arrow":return e.endArrowhead||e.endArrowhead?40:20;default:return 20}},Zm=(e,t,n,o,i=1)=>{let r=(t?.opacity??100)*e.opacity/1e4*i;return(n.has(e.id)||o&&o.some(s=>s.id===e.id)||t&&n.has(t.id))&&(r*=_m/100),r},qm=(e,t,n)=>{let r=ar(e),[s,a,l,d]=K(e,t),c=ne(e)||Ce(e)?An(s,l):e.width,p=ne(e)||Ce(e)?An(a,d):e.height,h=c*window.devicePixelRatio+r*2,m=p*window.devicePixelRatio+r*2,f=n.value;return(h*f>32767||m*f>32767)&&(f=Math.min(32767/h,32767/m)),h*m*f*f>16777216&&(f=Math.sqrt(16777216/(h*m))),h=Math.floor(h*f),m=Math.floor(m*f),{width:h,height:m,scale:f}},Zd=(e,t,n,o,i)=>{let r=document.createElement("canvas"),s=r.getContext("2d"),a=ar(e),{width:l,height:d,scale:c}=qm(e,t,n);if(!l||!d)return null;r.width=l,r.height=d;let p=-100,h=0;if(ne(e)||Ce(e)){let[x,y]=K(e,t);p=e.x>x?An(e.x,x)*window.devicePixelRatio*c:0,h=e.y>y?An(e.y,y)*window.devicePixelRatio*c:0,s.translate(p,h)}s.save(),s.translate(a*c,a*c),s.scale(window.devicePixelRatio*c,window.devicePixelRatio*c);let m=Fn.canvas(r);rr(e,m,s,o),s.restore();let f=J(e,t),g=document.createElement("canvas"),E=g.getContext("2d");if(V(e)&&f){let[x,y,w,M]=K(e,t),b=Math.max(An(x,w),An(y,M));g.width=b*window.devicePixelRatio*c+a*c*10,g.height=b*window.devicePixelRatio*c+a*c*10,E.translate(g.width/2,g.height/2),E.rotate(e.angle),E.drawImage(r,-r.width/2,-r.height/2,r.width,r.height);let[,,,,S,A]=K(f,t);E.rotate(-e.angle);let C=(g.width-r.width)/2,T=(g.height-r.height)/2,F=g.width/2-(S-x)*window.devicePixelRatio*c-C-a*c,O=g.height/2-(A-y)*window.devicePixelRatio*c-T-a*c;E.translate(-F,-O),E.clearRect(-(f.width/2+ir)*window.devicePixelRatio*c,-(f.height/2+ir)*window.devicePixelRatio*c,(f.width+ir*2)*window.devicePixelRatio*c,(f.height+ir*2)*window.devicePixelRatio*c)}return{element:e,canvas:r,theme:i.theme,scale:c,zoomValue:n.value,canvasOffsetX:p,canvasOffsetY:h,boundTextElementVersion:J(e,t)?.version||null,containingFrameOpacity:en(e,t)?.opacity||100,boundTextCanvas:g,angle:e.angle,imageCrop:ve(e)?e.crop:null}},Hw=14,qd=typeof document<"u"?document.createElement("img"):{src:""};qd.src=`data:${Ns.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var Kd=typeof document<"u"?document.createElement("img"):{src:""};Kd.src=`data:${Ns.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;var Km=(e,t,n)=>{t.fillStyle=n===ro.DARK?"#2E2E2E":"#E7E7E7",t.fillRect(0,0,e.width,e.height);let o=Math.min(e.width,e.height),i=Math.min(o,Math.min(o*.4,100));t.drawImage(e.status==="error"?Kd:qd,e.width/2-i/2,e.height/2-i/2,i,i)},rr=(e,t,n,o)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{n.lineJoin="round",n.lineCap="round",t.draw(st.generateElementShape(e,o));break}case"arrow":case"line":{n.lineJoin="round",n.lineCap="round",st.generateElementShape(e,o).forEach(i=>{t.draw(i)});break}case"freedraw":{n.save();let i=st.generateElementShape(e,o);for(let r of i)typeof r=="string"?(n.fillStyle=o.theme===ro.DARK?sr(e.strokeColor):e.strokeColor,n.fill(new Path2D(r))):t.draw(r);n.restore();break}case"image":{n.save();let i=e.fileId!==null?o.imageCache.get(e.fileId):null,r=Nn(e)?i?.image:void 0;if(r!=null&&!(r instanceof Promise)){e.roundness&&n.roundRect&&(n.beginPath(),n.roundRect(0,0,e.width,e.height,Vt(Math.min(e.width,e.height),e)),n.clip());let{x:s,y:a,width:l,height:d}=e.crop?e.crop:{x:0,y:0,width:r.naturalWidth,height:r.naturalHeight},c=o.theme===ro.DARK&&i?.mimeType===Ns.svg;if(c&&Xm){let p=window.devicePixelRatio||1,h=document.createElement("canvas");h.width=e.width*p,h.height=e.height*p;let m=h.getContext("2d");if(m){m.scale(p,p),m.drawImage(r,s,a,l,d,0,0,e.width,e.height);let f=m.getImageData(0,0,h.width,h.height),g=f.data;for(let E=0;E<g.length;E+=4)g[E]=255-g[E],g[E+1]=255-g[E+1],g[E+2]=255-g[E+2];m.putImageData(f,0,0),n.drawImage(h,0,0,h.width,h.height,0,0,e.width,e.height)}}else c&&(n.filter=Wm),n.drawImage(r,s,a,l,d,0,0,e.width,e.height)}else Km(e,n,o.theme);n.restore();break}default:if(ee(e)){let i=Vm(e.text),r=i&&!n.canvas.isConnected;r&&document.body.appendChild(n.canvas),n.canvas.setAttribute("dir",i?"rtl":"ltr"),n.save(),n.font=jm(e),n.fillStyle=o.theme===ro.DARK?sr(e.strokeColor):e.strokeColor,n.textAlign=e.textAlign;let s=e.text.replace(/\r\n?/g,`
10
11
  `).split(`
11
- `),a=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,l=co(e.fontSize,e.lineHeight),d=wf(e.fontFamily,e.fontSize,l);for(let c=0;c<s.length;c++)n.fillText(s[c],a,c*l+d);n.restore(),r&&n.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},Di=new WeakMap,nd=(e,t,n,i)=>{let o=n?i.zoom:{value:1},r=Di.get(e),s=r&&r.zoomValue!==o.value&&!i?.shouldCacheIgnoreZoom,a=V(e,t),l=a?.version||null,d=xe(e)?e.crop:null,c=Rt(e,t)?.opacity||100;if(!r||s||r.theme!==i.theme||r.boundTextElementVersion!==l||r.imageCrop!==d||r.containingFrameOpacity!==c||z(e)&&a&&e.angle!==r.angle){let u=id(e,t,o,n,i);return u?(Di.set(e,u),u):null}return r},us=(e,t,n,i,o)=>{let r=e.element,s=_o(r),a=e.scale,[l,d,c,u]=j(r,o),m=((l+c)/2+i.scrollX)*window.devicePixelRatio,p=((d+u)/2+i.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let f=V(r,o);if(z(r)&&f){let h=(e.boundTextCanvas.width-e.canvas.width)/2,E=(e.boundTextCanvas.height-e.canvas.height)/2;t.translate(m,p),t.drawImage(e.boundTextCanvas,-(c-l)/2*window.devicePixelRatio-h/a-s,-(u-d)/2*window.devicePixelRatio-E/a-s,e.boundTextCanvas.width/a,e.boundTextCanvas.height/a)}else if(t.translate(m,p),t.rotate(r.angle),"scale"in e.element&&!bf(r,n)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-m,-p),t.drawImage(e.canvas,(l+i.scrollX)*window.devicePixelRatio-s*e.scale/e.scale,(d+i.scrollY)*window.devicePixelRatio-s*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),v.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&ct(r)){let h=V(r,o),E=kr(r);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((E.x+i.scrollX)*window.devicePixelRatio,(E.y+i.scrollY)*window.devicePixelRatio,it(r,h)*window.devicePixelRatio,pi(r,h)*window.devicePixelRatio)}t.restore()},H0=(e,t,n,i)=>{t.save(),t.translate(e.x+n.scrollX,e.y+n.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let o=.5/n.zoom.value;t.fillRect(o,o,e.width,e.height),t.lineWidth=1/n.zoom.value,t.strokeStyle=i,t.strokeRect(o,o,e.width,e.height),t.restore()},_0=(e,t,n,i,o,r,s)=>{let a=s.openDialog?.name==="elementLinkSelector"&&!s.selectedElementIds[e.id]&&!s.hoveredElementIds[e.id];switch(o.globalAlpha=Pf(e,Rt(e,t),r.elementsPendingErasure,r.pendingFlowchartNodes,a?ff:1),e.type){case"magicframe":case"frame":{s.frameRendering.enabled&&s.frameRendering.outline&&(o.save(),o.translate(e.x+s.scrollX,e.y+s.scrollY),o.fillStyle="rgba(0, 0, 200, 0.04)",o.lineWidth=Ti.strokeWidth/s.zoom.value,o.strokeStyle=s.theme===vi.DARK?Ho(Ti.strokeColor):Ti.strokeColor,Ba(e)&&(o.strokeStyle=s.theme===vi.LIGHT?"#7affd7":Ho("#1d8264")),Ti.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,e.width,e.height,Ti.radius/s.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,e.width,e.height),o.restore());break}case"freedraw":{if(r.isExporting){let[l,d,c,u]=j(e,t),m=(l+c)/2+s.scrollX,p=(d+u)/2+s.scrollY,f=(c-l)/2-(e.x-l),h=(u-d)/2-(e.y-d);o.save(),o.translate(m,p),o.rotate(e.angle),o.translate(-f,-h),zo(e,i,o,r),o.restore()}else{let l=nd(e,n,r,s);if(!l)return;us(l,o,r,s,n)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(r.isExporting){let[l,d,c,u]=j(e,t),m=(l+c)/2+s.scrollX,p=(d+u)/2+s.scrollY,f=(c-l)/2-(e.x-l),h=(u-d)/2-(e.y-d);if(ee(e)){let g=Se(e,t);if(z(g)){let x=O.getBoundTextElementPosition(g,e,t);f=(c-l)/2-(x.x-l),h=(u-d)/2-(x.y-d)}}o.save(),o.translate(m,p);let E=V(e,t);if(z(e)&&E){let g=document.createElement("canvas"),x=g.getContext("2d"),w=Math.max(dn(l,c),dn(d,u)),b=_o(e);g.width=w*s.exportScale+b*10*s.exportScale,g.height=w*s.exportScale+b*10*s.exportScale,x.translate(g.width/2,g.height/2),x.scale(s.exportScale,s.exportScale),f=e.width/2-(e.x-l),h=e.height/2-(e.y-d),x.rotate(e.angle);let y=wn.canvas(g);x.translate(-f,-h),zo(e,y,x,r),x.translate(f,h),x.rotate(-e.angle);let[,,,,I,S]=j(E,t),A=(l+c)/2-I,M=(d+u)/2-S;x.translate(-A,-M),x.clearRect(-E.width/2,-E.height/2,E.width,E.height),o.scale(1/s.exportScale,1/s.exportScale),o.drawImage(g,-g.width/2,-g.height/2,g.width,g.height)}else o.rotate(e.angle),e.type==="image"&&o.scale(e.scale[0],e.scale[1]),o.translate(-f,-h),zo(e,i,o,r);o.restore()}else{let l=nd(e,n,r,s);if(!l)return;let d=o.imageSmoothingEnabled;if(!s?.shouldCacheIgnoreZoom&&(!e.angle||pf(e.angle))&&(o.imageSmoothingEnabled=!1),e.id===s.croppingElementId&&xe(l.element)&&l.element.crop!==null){o.save(),o.globalAlpha=.1;let c=id(va(l.element,t),n,s.zoom,r,s);c&&us(c,o,r,s,n),o.restore()}us(l,o,r,s,n),o.imageSmoothingEnabled=d}break}default:throw new Error(`Unimplemented type ${e.type}`)}o.globalAlpha=1};function U0(e,t,n){let i=ae({...e,angle:0},n),o=Fo((i[0]+i[2])/2,(i[1]+i[3])/2);return yf(t.length>=2,"Freepath outline must have at least 2 points"),t.slice(2).reduce((r,s)=>(r.push(td(r[r.length-1][1],cs(Fo(s[0]+e.x,s[1]+e.y),o,e.angle))),r),[td(cs(Fo(t[0][0]+e.x,t[0][1]+e.y),o,e.angle),cs(Fo(t[1][0]+e.x,t[1][1]+e.y),o,e.angle))])}P();var X0=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",j0=e=>e==="rectangle"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line"||e==="text"||e==="embeddable",V0=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",$0=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",sd=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image",Z0=e=>e==="arrow",q0=e=>e==="arrow";var Xe=class e{static rg=new $e;static cache=new WeakMap;static get=(t,n)=>{let i=e.cache.get(t);if(i&&(n===null||i.theme===n))return i.shape};static delete=t=>{e.cache.delete(t),Di.delete(t)};static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,n)=>{let i=n?.isExporting?void 0:e.get(t,n?n.theme:null);if(i!==void 0)return i;Di.delete(t);let o=Bf(t,e.rg,n||{isExporting:!1,canvasBackgroundColor:Tf.white,embedsValidationStatus:null,theme:ps.LIGHT});return n?.isExporting||e.cache.set(t,{shape:o,theme:n?.theme||ps.LIGHT}),o}},Df=e=>[8,8+e],ud=e=>[1.5,6+e];function Lf(e){let t=e.roughness,n=Math.max(e.width,e.height),i=Math.min(e.width,e.height);return i>=20&&n>=50||i>=15&&e.roundness&&sd(e.type)||Q(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}var Ne=(e,t=!1,n=!1)=>{let i={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?Df(e.strokeWidth):e.strokeStyle==="dotted"?ud(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:Lf(e),stroke:n?Uo(e.strokeColor):e.strokeColor,preserveVertices:t||e.roughness<Mf.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return i.fillStyle=e.fillStyle,i.fill=Li(e.backgroundColor)?void 0:n?Uo(e.backgroundColor):e.backgroundColor,e.type==="ellipse"&&(i.curveFitting=1),i;case"line":case"freedraw":return bn(e.points)&&(i.fillStyle=e.fillStyle,i.fill=e.backgroundColor==="transparent"?void 0:n?Uo(e.backgroundColor):e.backgroundColor),i;case"arrow":return i;default:throw new Error(`Unimplemented type ${e.type}`)}},ld=(e,t,n)=>io(e)&&(t||La(e)&&n?.get(e.id)!==!0)&&Li(e.backgroundColor)&&Li(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:no(e)?{...e,strokeColor:Li(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Li(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,dd=(e,t,n,i,o,r,s,a)=>{let l=fs(e,t,n,i);if(l===null)return[];let d=(u,m)=>{if(u===null)return[];let[,,p,f,h,E]=u;return[o.line(p,f,h,E,m)]},c=a?Uo(e.strokeColor):e.strokeColor;switch(i){case"dot":case"circle":case"circle_outline":{let[u,m,p]=l;return delete r.strokeLineDash,[o.circle(u,m,p,{...r,fill:i==="circle_outline"?s:c,fillStyle:"solid",stroke:c,roughness:Math.min(.5,r.roughness||0)})]}case"triangle":case"triangle_outline":{let[u,m,p,f,h,E]=l;return delete r.strokeLineDash,[o.polygon([[u,m],[p,f],[h,E],[u,m]],{...r,fill:i==="triangle_outline"?s:c,fillStyle:"solid",roughness:Math.min(1,r.roughness||0)})]}case"diamond":case"diamond_outline":{let[u,m,p,f,h,E,g,x]=l;return delete r.strokeLineDash,[o.polygon([[u,m],[p,f],[h,E],[g,x],[u,m]],{...r,fill:i==="diamond_outline"?s:c,fillStyle:"solid",roughness:Math.min(1,r.roughness||0)})]}case"crowfoot_one":return d(l,r);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[u,m,p,f,h,E]=l;if(e.strokeStyle==="dotted"){let g=ud(e.strokeWidth-1);r.strokeLineDash=[g[0],g[1]-1]}else delete r.strokeLineDash;return r.roughness=Math.min(1,r.roughness||0),[o.line(p,f,u,m,r),o.line(h,E,u,m,r),...i==="crowfoot_one_or_many"?d(fs(e,t,n,"crowfoot_one"),r):[]]}}},Ha=e=>{let t=new $e,n={seed:e.seed,disableMultiStroke:!0,disableMultiStrokeFill:!0,roughness:0,preserveVertices:!0},i=mt(e.points.reduce((o,r)=>[Math.min(e.x+r[0],o[0]),Math.min(e.y+r[1],o[1]),Math.max(e.x+r[0],o[2]),Math.max(e.y+r[1],o[3])],[1/0,1/0,-1/0,-1/0]));switch(e.type){case"line":case"arrow":{let o=e.points.length?e.points:[le(0,0)];return W(e)?t.path(md(o,16),n).sets[0].ops:e.roundness?t.curve(o,n).sets[0].ops.slice(0,e.points.length).map((r,s)=>{if(s===0){let a=Ft(le(e.x+r.data[0],e.y+r.data[1]),i,e.angle);return{op:"move",data:le(a[0]-e.x,a[1]-e.y)}}return{op:"bcurveTo",data:[Ft(le(e.x+r.data[0],e.y+r.data[1]),i,e.angle),Ft(le(e.x+r.data[2],e.y+r.data[3]),i,e.angle),Ft(le(e.x+r.data[4],e.y+r.data[5]),i,e.angle)].map(a=>le(a[0]-e.x,a[1]-e.y)).flat()}}):o.map((r,s)=>{let a=Ft(le(e.x+r[0],e.y+r[1]),i,e.angle);return{op:s===0?"move":"lineTo",data:le(a[0]-e.x,a[1]-e.y)}})}case"freedraw":{if(e.points.length<2)return[];let o=ni(e.points,.75);return t.curve(o,n).sets[0].ops.slice(0,e.points.length).map((r,s)=>{if(s===0){let a=Ft(le(e.x+r.data[0],e.y+r.data[1]),i,e.angle);return{op:"move",data:le(a[0]-e.x,a[1]-e.y)}}return{op:"bcurveTo",data:[Ft(le(e.x+r.data[0],e.y+r.data[1]),i,e.angle),Ft(le(e.x+r.data[2],e.y+r.data[3]),i,e.angle),Ft(le(e.x+r.data[4],e.y+r.data[5]),i,e.angle)].map(a=>le(a[0]-e.x,a[1]-e.y)).flat()}})}}},Bf=(e,t,{isExporting:n,canvasBackgroundColor:i,embedsValidationStatus:o,theme:r})=>{let s=r===ps.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let a;if(e.roundness){let l=e.width,d=e.height,c=Mt(Math.min(l,d),e);a=t.path(`M ${c} 0 L ${l-c} 0 Q ${l} 0, ${l} ${c} L ${l} ${d-c} Q ${l} ${d}, ${l-c} ${d} L ${c} ${d} Q 0 ${d}, 0 ${d-c} L 0 ${c} Q 0 0, ${c} 0`,Ne(ld(e,n,o),!0,s))}else a=t.rectangle(0,0,e.width,e.height,Ne(ld(e,n,o),!1,s));return a}case"diamond":{let a,[l,d,c,u,m,p,f,h]=kn(e);if(e.roundness){let E=Mt(Math.abs(l-f),e),g=Mt(Math.abs(u-d),e);a=t.path(`M ${l+E} ${d+g} L ${c-E} ${u-g}
12
- C ${c} ${u}, ${c} ${u}, ${c-E} ${u+g}
13
- L ${m+E} ${p-g}
14
- C ${m} ${p}, ${m} ${p}, ${m-E} ${p-g}
15
- L ${f+E} ${h+g}
16
- C ${f} ${h}, ${f} ${h}, ${f+E} ${h-g}
17
- L ${l-E} ${d+g}
18
- C ${l} ${d}, ${l} ${d}, ${l+E} ${d+g}`,Ne(e,!0,s))}else a=t.polygon([[l,d],[c,u],[m,p],[f,h]],Ne(e,!1,s));return a}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,Ne(e,!1,s));case"line":case"arrow":{let a,l=Ne(e,!1,s),d=e.points.length?e.points:[le(0,0)];if(W(e)?d.every(c=>Math.abs(c[0])<=1e6&&Math.abs(c[1])<=1e6)?a=[t.path(md(d,16),Ne(e,!0,s))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(d)),a=[]):e.roundness?a=[t.curve(d,l)]:l.fill?a=[t.polygon(d,l)]:a=[t.linearPath(d,l)],e.type==="arrow"){let{startArrowhead:c=null,endArrowhead:u="arrow"}=e;if(c!==null){let m=dd(e,a,"start",c,t,l,i,s);a.push(...m)}if(u!==null){let m=dd(e,a,"end",u,t,l,i,s);a.push(...m)}}return a}case"freedraw":{let a=[];if(bn(e.points)){let l=ni(e.points,.75);a.push(t.curve(l,{...Ne(e,!1,s),stroke:"none"}))}return a.push(Cf(e)),a}case"frame":case"magicframe":case"text":case"image":return null;default:return Af(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},md=(e,t)=>{let n=[];for(let o=1;o<e.length-1;o+=1){let r=e[o-1],s=e[o+1],a=e[o],l=ot(a,r),d=ot(s,a),c=Math.min(t,ad(e[o],s)/2,ad(e[o],r)/2);l?r[0]<a[0]?n.push([e[o][0]-c,e[o][1]]):n.push([e[o][0]+c,e[o][1]]):r[1]<a[1]?n.push([e[o][0],e[o][1]-c]):n.push([e[o][0],e[o][1]+c]),n.push(e[o]),d?s[0]<a[0]?n.push([e[o][0]-c,e[o][1]]):n.push([e[o][0]+c,e[o][1]]):s[1]<a[1]?n.push([e[o][0],e[o][1]-c]):n.push([e[o][0],e[o][1]+c])}let i=[`M ${e[0][0]} ${e[0][1]}`];for(let o=0;o<n.length;o+=3)i.push(`L ${n[o][0]} ${n[o][1]}`),i.push(`Q ${n[o+1][0]} ${n[o+1][1]}, ${n[o+2][0]} ${n[o+2][1]}`);return i.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),i.join(" ")},pd=(e,t)=>{switch(e.type){case"rectangle":case"diamond":case"frame":case"magicframe":case"embeddable":case"image":case"iframe":case"text":case"selection":return ma(e);case"arrow":case"line":{let n=Xe.generateElementShape(e,null)[0],[,,,,i,o]=j(e,t);return ho(e)?Ea(e,n,le(e.x,e.y),e.angle,le(i,o)):fa(n,le(e.x,e.y),e.angle,le(i,o))}case"ellipse":return pa(e);case"freedraw":{let[,,,,n,i]=j(e,t);return ha(e,le(n,i),ho(e))}}},Cl=(e,t)=>{let n=[...e.points];if(t){if(!Oa(e.points))return null;let o=n[0],r=n[n.length-1];Math.hypot(o[0]-r[0],o[1]-r[1])>vf||n.length<4?n.push(le(o[0],o[1])):n[n.length-1]=le(o[0],o[1])}return{polygon:t,points:n}},Cf=e=>kf(Gf(e)),Gf=e=>{let t=e.simulatePressure?e.points:e.points.length?e.points.map(([n,i],o)=>[n,i,e.pressures[o]]):[[0,0,.5]];return Ia(t,{simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:n=>Math.sin(n*Math.PI/2),last:!0})},cd=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],Of=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,kf=e=>{if(!e.length)return"";let t=e.length-1;return e.reduce((n,i,o,r)=>(o===t?n.push(i,cd(i,r[0]),"L",r[0],"Z"):n.push(i,cd(i,r[o+1])),n),["M",e[0],"Q"]).join(" ").replace(Of,"$1")};var gs=class e{static boundsCache=new WeakMap;static nonRotatedBoundsCache=new WeakMap;static getBounds(t,n,i=!1){let o=i&&t.angle!==0?e.nonRotatedBoundsCache.get(t):e.boundsCache.get(t);if(o?.version&&o.version===t.version&&!ce(t))return o.bounds;if(i&&t.angle!==0){let s=e.calculateBounds({...t,angle:0},n);return e.nonRotatedBoundsCache.set(t,{version:t.version,bounds:s}),s}let r=e.calculateBounds(t,n);return e.boundsCache.set(t,{version:t.version,bounds:r}),r}static calculateBounds(t,n){let i,[o,r,s,a,l,d]=j(t,n);if(Ie(t)){let[c,u,m,p]=xs(t.points.map(([f,h])=>oe(D(f,h),D(l-t.x,d-t.y),t.angle)));return[c+t.x,u+t.y,m+t.x,p+t.y]}else if(Q(t))i=Wf(t,l,d,n);else if(t.type==="diamond"){let[c,u]=oe(D(l,r),D(l,d),t.angle),[m,p]=oe(D(l,a),D(l,d),t.angle),[f,h]=oe(D(o,d),D(l,d),t.angle),[E,g]=oe(D(s,d),D(l,d),t.angle),x=Math.min(c,m,f,E),w=Math.min(u,p,h,g),b=Math.max(c,m,f,E),y=Math.max(u,p,h,g);i=[x,w,b,y]}else if(t.type==="ellipse"){let c=(s-o)/2,u=(a-r)/2,m=Math.cos(t.angle),p=Math.sin(t.angle),f=Math.hypot(c*m,u*p),h=Math.hypot(u*m,c*p);i=[l-f,d-h,l+f,d+h]}else{let[c,u]=oe(D(o,r),D(l,d),t.angle),[m,p]=oe(D(o,a),D(l,d),t.angle),[f,h]=oe(D(s,a),D(l,d),t.angle),[E,g]=oe(D(s,r),D(l,d),t.angle),x=Math.min(c,m,f,E),w=Math.min(u,p,h,g),b=Math.max(c,m,f,E),y=Math.max(u,p,h,g);i=[x,w,b,y]}return i}},j=(e,t,n=!1)=>{if(Ie(e))return Hf(e);if(Q(e))return O.getElementAbsoluteCoords(e,t,n);if(ee(e)){let i=t?Se(e,t):null;if(z(i)){let{x:o,y:r}=O.getBoundTextElementPosition(i,e,t);return[o,r,o+e.width,r+e.height,o+e.width/2,r+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]},ls=(e,t)=>{let n=pd(e,t),[i,o,r,s,a,l]=j(e,t),d=D(a,l);if(n.type==="polycurve"){let g=n.data.map(w=>yt(w,10)),x=[];if(It(e)&&!e.polygon||z(e))for(let w of g){let b=0;for(;b<w.length-1;)x.push(Ee(D(w[b][0],w[b][1]),D(w[b+1][0],w[b+1][1]))),b++}else{let w=g.flat(),b=0;for(;b<w.length-1;)x.push(Ee(D(w[b][0],w[b][1]),D(w[b+1][0],w[b+1][1]))),b++}return x}else{if(n.type==="polyline")return n.data;if(Nf(e)){let[E,g]=Vt(e),x=g.map(b=>Ed(b,d,e.angle)).flat();return[...hd(E,d,e.angle),...x]}else if(e.type==="diamond"){let[E,g]=$t(e),x=g.map(b=>Ed(b,d,e.angle)).flat();return[...hd(E,d,e.angle),...x]}else if(n.type==="polygon"){if(ee(e)){let x=Se(e,t);if(x&&Q(x))return[Ee(D(i,o),D(r,o)),Ee(D(r,o),D(r,s)),Ee(D(r,s),D(i,s)),Ee(D(i,s),D(i,o))]}let E=n.data,g=[];for(let x=0;x<E.length-1;x++)g.push(Ee(E[x],E[x+1]));return g}else if(n.type==="ellipse")return zf(e)}let[c,u,m,p,,,f,h]=[[i,o],[r,o],[i,s],[r,s],[a,o],[a,s],[i,l],[r,l]].map(E=>oe(E,d,e.angle));return[Ee(c,u),Ee(m,p),Ee(c,m),Ee(u,p),Ee(c,h),Ee(m,h),Ee(u,f),Ee(p,f)]},Nf=e=>e!=null&&(e.type==="rectangle"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),hd=(e,t,n)=>e.map(i=>Ee(oe(i[0],t,n),oe(i[1],t,n))),Ed=(e,t,n)=>{let i=yt(e,10),o=0,r=[];for(;o<i.length-1;)r.push(Ee(oe(D(i[o][0],i[o][1]),t,n),oe(D(i[o+1][0],i[o+1][1]),t,n))),o++;return r},zf=e=>{let t=D(e.x+e.width/2,e.y+e.height/2),n=e.width/2,i=e.height/2,o=[],r=[],s=90,a=Math.PI*2/s;for(let l=0;l<s;l++){let d=l*a,c=t[0]+n*Math.cos(d),u=t[1]+i*Math.sin(d);r.push(oe(D(c,u),t,e.angle))}for(let l=0;l<r.length-1;l++)o.push(Ee(r[l],r[l+1]));return o.push(Ee(r[r.length-1],r[0])),o},A1=e=>[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2],kn=e=>{let t=Math.floor(e.width/2)+1,n=0,i=e.width,o=Math.floor(e.height/2)+1,r=t,s=e.height;return[t,n,i,o,r,s,0,o]},gd=(e,t,n,i,o)=>{let r=1-e;return Math.pow(r,3)*t+3*Math.pow(r,2)*e*n+3*r*Math.pow(e,2)*i+Math.pow(e,3)*o},xd=(e,t,n,i)=>{let o=t-e,r=n-t,s=i-n,a=3*o-6*r+3*s,l=6*r-6*o,d=3*o,c=l*l-4*a*d;if(!(c>=0))return!1;let m=null,p=null,f=1/0,h=1/0;return a===0?f=h=-d/l:(f=(-l+Math.sqrt(c))/(2*a),h=(-l-Math.sqrt(c))/(2*a)),f>=0&&f<=1&&(m=gd(f,e,t,n,i)),h>=0&&h<=1&&(p=gd(h,e,t,n,i)),[m,p]},go=(e,t,n,i)=>{let o=xd(e[0],t[0],n[0],i[0]),r=xd(e[1],t[1],n[1],i[1]),s=Math.min(e[0],i[0]),a=Math.max(e[0],i[0]);if(o){let c=o.filter(u=>u!==null);s=Math.min(s,...c),a=Math.max(a,...c)}let l=Math.min(e[1],i[1]),d=Math.max(e[1],i[1]);if(r){let c=r.filter(u=>u!==null);l=Math.min(l,...c),d=Math.max(d,...c)}return[s,l,a,d]},Ai=(e,t)=>{let n=D(0,0),{minX:i,minY:o,maxX:r,maxY:s}=e.reduce((a,{op:l,data:d})=>{if(l==="move"){let c=yd(d);Es(c!=null,"Op data is not a point"),n=c}else if(l==="bcurveTo"){let c=D(d[0],d[1]),u=D(d[2],d[3]),m=D(d[4],d[5]),p=t?t(c):c,f=t?t(u):u,h=t?t(m):m,E=t?t(n):n;n=m;let[g,x,w,b]=go(E,p,f,h);a.minX=Math.min(a.minX,g),a.minY=Math.min(a.minY,x),a.maxX=Math.max(a.maxX,w),a.maxY=Math.max(a.maxY,b)}return a},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[i,o,r,s]},xs=e=>{let t=1/0,n=1/0,i=-1/0,o=-1/0;for(let[r,s]of e)t=Math.min(t,r),n=Math.min(n,s),i=Math.max(i,r),o=Math.max(o,s);return[t,n,i,o]},Hf=e=>{let[t,n,i,o]=xs(e.points),r=t+e.x,s=n+e.y,a=i+e.x,l=o+e.y;return[r,s,a,l,(r+a)/2,(s+l)/2]},_f=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},Uf=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},fs=(e,t,n,i)=>{if(t.length<1)return null;let o=bt(t[0]);if(o.length<1)return null;let r=n==="start"?1:o.length-1,s=o[r].data;Es(s.length===6,"Op data length is not 6");let a=D(s[4],s[5]),l=D(s[2],s[3]),d=D(s[0],s[1]),c=o[r-1],u=D(0,0);if(c.op==="move"){let N=yd(c.data);Es(N!=null,"Op data is not a point"),u=N}else c.op==="bcurveTo"&&(u=D(c.data[4],c.data[5]));let m=(N,Y)=>Math.pow(1-N,3)*a[Y]+3*N*Math.pow(1-N,2)*l[Y]+3*Math.pow(N,2)*(1-N)*d[Y]+u[Y]*Math.pow(N,3),[p,f]=n==="start"?u:a,[h,E]=[m(.3,0),m(.3,1)],g=Math.hypot(p-h,f-E),x=(p-h)/g,w=(f-E)/g,b=_f(i),y=0;{let[N,Y]=n==="end"?e.points[e.points.length-1]:e.points[0],[F,T]=e.points.length>1?n==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];y=Math.hypot(N-F,Y-T)}let S=Math.min(b,y*(i==="diamond"||i==="diamond_outline"?.25:.5)),A=p-x*S,M=f-w*S;if(i==="dot"||i==="circle"||i==="circle_outline"){let N=Math.hypot(M-f,A-p)+e.strokeWidth-2;return[p,f,N]}let k=Uf(i);if(i==="crowfoot_many"||i==="crowfoot_one_or_many"){let[N,Y]=oe(D(p,f),D(A,M),hs(-k)),[F,T]=oe(D(p,f),D(A,M),hs(k));return[A,M,N,Y,F,T]}let[L,G]=oe(D(A,M),D(p,f),-k*Math.PI/180),[B,U]=oe(D(A,M),D(p,f),hs(k));if(i==="diamond"||i==="diamond_outline"){let N,Y;if(n==="start"){let[F,T]=e.points.length>1?e.points[1]:[0,0];[N,Y]=oe(D(p+S*2,f),D(p,f),Math.atan2(T-f,F-p))}else{let[F,T]=e.points.length>1?e.points[e.points.length-2]:[0,0];[N,Y]=oe(D(p-S*2,f),D(p,f),Math.atan2(f-T,p-F))}return[p,f,L,G,N,Y,B,U]}return[p,f,L,G,B,U]},Yf=e=>{let t=wn.generator(),n=Ne(e),i=e.roundness?"curve":n.fill?"polygon":"linearPath";return t[i](e.points,n)},Wf=(e,t,n,i)=>{let o=V(e,i);if(e.points.length<2){let[u,m]=e.points[0],[p,f]=oe(D(e.x+u,e.y+m),D(t,n),e.angle),h=[p,f,p,f];if(o){let E=O.getMinMaxXYWithBoundText(e,i,[p,f,p,f],o);h=[E[0],E[1],E[2],E[3]]}return h}let s=Xe.get(e,null)?.[0]??Yf(e),a=bt(s),d=Ai(a,([u,m])=>oe(D(e.x+u,e.y+m),D(t,n),e.angle)),c=[d[0],d[1],d[2],d[3]];if(o){let u=O.getMinMaxXYWithBoundText(e,i,c,o);c=[u[0],u[1],u[2],u[3]]}return c},ae=(e,t,n=!1)=>gs.getBounds(e,t,n),De=(e,t)=>{if(!Rf(e))return[0,0,0,0];let n=1/0,i=-1/0,o=1/0,r=-1/0,s=t||wd(e);return e.forEach(a=>{let[l,d,c,u]=ae(a,s);n=Math.min(n,l),o=Math.min(o,d),i=Math.max(i,c),r=Math.max(r,u)}),[n,o,i,r]},T1=(e,t)=>{let[n,i,o,r]=De(e);return[n+t.x,i+t.y,o+t.x,r+t.y]},Xt=(e,t,n,i)=>{if(!(Q(e)||Ie(e)))return[e.x,e.y,e.x+t,e.y+n];let o=fd(0,t,fd(1,n,e.points,i),i),r;if(Ie(e))r=xs(o);else{let c=wn.generator(),u=e.roundness?c.curve(o,Ne(e)):c.linearPath(o,Ne(e)),m=bt(u);r=Ai(m)}let[s,a,l,d]=r;return[s+e.x,a+e.y,l+e.x,d+e.y]},ns=(e,t)=>{let n=wn.generator(),i=e.roundness==null?n.linearPath(t,Ne(e)):n.curve(t,Ne(e)),o=bt(i),[r,s,a,l]=Ai(o);return[r+e.x,s+e.y,a+e.x,l+e.y]},v1=(e,t)=>{if(!e.length)return[0,0,0,0];let n=1/0,i=e[0],o=wd(e);return e.forEach(r=>{let[s,a,l,d]=ae(r,o),c=Ff(D((s+l)/2,(a+d)/2),D(t.x,t.y));c<n&&(n=c,i=r)}),ae(i,o)},Le=e=>{let[t,n,i,o]=De(e);return{minX:t,minY:n,maxX:i,maxY:o,width:i-t,height:o-n,midX:(t+i)/2,midY:(n+o)/2}},D1=({scrollX:e,scrollY:t,width:n,height:i,zoom:o})=>[-e,-t,-e+n/o.value,-t+i/o.value],mt=e=>D(e[0]+(e[2]-e[0])/2,e[1]+(e[3]-e[1])/2),Ke=(e,t,n)=>{let i={minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height,midX:e.x+e.width/2,midY:e.y+e.height/2},o=de(e,t),[r,s]=oe(D(i.minX,i.minY),o,e.angle),[a,l]=oe(D(i.maxX,i.minY),o,e.angle),[d,c]=oe(D(i.maxX,i.maxY),o,e.angle),[u,m]=oe(D(i.minX,i.maxY),o,e.angle),p=[Math.min(r,a,d,u),Math.min(s,l,c,m),Math.max(r,a,d,u),Math.max(s,l,c,m)];if(n){let[f,h,E,g]=n;return[p[0]-g,p[1]-f,p[2]+h,p[3]+E]}return p},Kt=(e,t)=>e[0]>t[0]&&e[0]<t[2]&&e[1]>t[1]&&e[1]<t[3],Mn=(e,t)=>{if(e==null||t==null)return!1;let[n,i,o,r]=e,[s,a,l,d]=t;return n<l&&o>s&&i<d&&r>a},de=(e,t,n=0,i=0)=>{if(Q(e)){let[s,a,l,d]=j(e,t),[c,u]=D((s+l)/2,(a+d)/2);return D(c+n,u+i)}let[o,r]=mt(ae(e,t));return D(o+n,r+i)};var $f=.1,Pd=e=>Q(e)||Ie(e)?e.points.length<2||e.points.length===2&&z(e)&&Vf(e.points[0],e.points[e.points.length-1],$f):e.width===0&&e.height===0,ql=(e,t,n,i,o)=>{let[r,s,a,l]=ae(e,o),d=Yo({clientX:i.offsetLeft,clientY:i.offsetTop},i),c=Yo({clientX:i.offsetLeft+t,clientY:i.offsetTop+n},i);return d.x<=a&&d.y<=l&&c.x>=r&&c.y>=s},F1=(e,t,n,i,o,r)=>{let[s,a,l,d]=De(e,o),c=Yo({clientX:i.offsetLeft+(r?.left||0),clientY:i.offsetTop+(r?.top||0)},i),u=Yo({clientX:i.offsetLeft+t-(r?.right||0),clientY:i.offsetTop+n-(r?.bottom||0)},i);return s>=c.x&&a>=c.y&&l<=u.x&&d<=u.y},ws=(e,t,n)=>{let i=Math.abs(t),o=Math.abs(n);if(e==="line"||e==="arrow"||e==="freedraw"){let r=Math.round(Math.atan(o/i)/Nt)*Nt;r===0?n=0:r===Math.PI/2?t=0:n=i*Math.tan(r)*Math.sign(n)||n}else e!=="selection"&&(n=i*Math.sign(n));return{width:t,height:n}},Gl=(e,t,n,i,o)=>{let r=n-e,s=i-t,a=Math.atan2(s,r),l=Math.round(a/Nt)*Nt;if(o){let d=Math.floor(o/Nt)*Nt;Xf(a,d,d+Nt)&&(jf(a,o)<Nt/6?l=o:bd(a)>bd(o)?l=d+Nt:l=d)}if(l===0)s=0;else if(l===Math.PI/2)r=0;else{let d=Math.tan(l),c=-1,u=t-d*e,m=-1/d,p=-1,f=i-m*n,h=(c*f-p*u)/(d*p-m*c),E=(u*m-f*d)/(d*p-m*c);r=h-e,s=E-t}return{width:r,height:s}},N1=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let n=Math.abs(e.width);t.width=n,t.x=e.x-n}if(e.height<0){let n=Math.abs(e.height);t.height=n,t.y=e.y-n}return t};P();var W1=(e,t,n,i)=>{let o=ko(e,n.getNonDeletedElementsMap(),i),r=Le(e);return o.flatMap(s=>{let a=Zf(s,r,t);return s.map(l=>{let d=n.mutateElement(l,{x:l.x+a.x,y:l.y+a.y});return je(l,n,{simultaneouslyUpdated:s}),d})})},Zf=(e,t,{axis:n,position:i})=>{let o=Le(e),[r,s]=n==="x"?["minX","maxX"]:["minY","maxY"],a={x:0,y:0};return i==="start"?{...a,[n]:t[r]-o[r]}:i==="end"?{...a,[n]:t[s]-o[s]}:{...a,[n]:(t[r]+t[s])/2-(o[r]+o[s])/2}};P();P();var Wo=class{root;gap;constructor(t=0){this.root=null,this.gap=t}fit(t){let n=t.length,i=n>0?t[0].w:0,o=n>0?t[0].h:0;this.root={x:0,y:0,w:i,h:o};for(let r=0;r<n;r++){let s=t[r],a=this.findNode(this.root,s.w,s.h);a?s.fit=this.splitNode(a,s.w,s.h):s.fit=this.growNode(s.w,s.h)}}findNode(t,n,i){return t?t.used?this.findNode(t.right||null,n,i)||this.findNode(t.down||null,n,i):n<=t.w&&i<=t.h?t:null:null}splitNode(t,n,i){return t.used=!0,t.down={x:t.x,y:t.y+i+this.gap,w:t.w,h:t.h-i-this.gap},t.right={x:t.x+n+this.gap,y:t.y,w:t.w-n-this.gap,h:i},t}growNode(t,n){if(!this.root)return null;let i=t<=this.root.w,o=n<=this.root.h,r=o&&this.root.h>=this.root.w+t+this.gap,s=i&&this.root.w>=this.root.h+n+this.gap;return r?this.growRight(t,n):s?this.growDown(t,n):o?this.growRight(t,n):i?this.growDown(t,n):null}growRight(t,n){if(!this.root)return null;this.root={used:!0,x:0,y:0,w:this.root.w+t+this.gap,h:this.root.h,down:this.root,right:{x:this.root.w+this.gap,y:0,w:t,h:this.root.h}};let i=this.findNode(this.root,t,n);return i?this.splitNode(i,t,n):null}growDown(t,n){if(!this.root)return null;this.root={used:!0,x:0,y:0,w:this.root.w,h:this.root.h+n+this.gap,down:{x:0,y:this.root.h+this.gap,w:this.root.w,h:n},right:this.root};let i=this.findNode(this.root,t,n);return i?this.splitNode(i,t,n):null}};var qf=(e,t,n)=>{let i=Le(t),o=n.x-i.minX,r=n.y-i.minY;t.forEach(s=>{e.mutateElement(s,{x:s.x+o,y:s.y+r})})},Id=(e,t,n)=>{let i=t.flatMap(d=>d.group),o=Le(i),r={x:o.minX,y:o.minY},s=t.sort((d,c)=>Math.max(c.boundingBox.width,c.boundingBox.height)-Math.max(d.boundingBox.width,d.boundingBox.height)).map(d=>({w:d.boundingBox.width,h:d.boundingBox.height,group:d.group}));new Wo(n).fit(s);let l=[];for(let d=0;d<s.length;d++){let c=s[d];c.fit&&l.push(c)}return l.forEach(d=>{qf(e,d.group,{x:r.x+(d.fit?.x??0),y:r.y+(d.fit?.y??0)})}),l.flatMap(d=>d.group)},Q1=(e,t,n,i,o)=>{let s=Oo(t,n).map(a=>({group:a,boundingBox:Le(a)}));switch(i){case"bin-packing":return Id(e,s,o);default:return console.warn(`Unimplemented algorithm [${i}] - using bin-packing`),Id(e,s,o)}};P();import{arrayToMap as Wh,arrayToObject as zt,assertNever as ec,isDevEnv as pn,isShallowEqual as tc,isTestEnv as fn,randomInteger as Jd}from"@excalidraw/common";P();import{assertNever as ah,COLOR_PALETTE as lh,isDevEnv as dh,isTestEnv as ch,randomId as uh,Emitter as Ad,toIterable as Wn}from"@excalidraw/common";P();import{ORIG_ID as eh,randomId as Md,randomInteger as th,arrayToMap as nh,castArray as ys,findLastIndex as Bi,getUpdatedTimestamp as ih,isTestEnv as oh}from"@excalidraw/common";P();import{arrayToMapWithIndex as Kf}from"@excalidraw/common";var Qf=e=>{let t=e.slice(),n=new Set,i=r=>{let s=r[0]?.groupIds?.join(""),a=[r[0]],l=[];for(let d of r.slice(1))d.groupIds?.join("")===s?a.push(d):l.push(d);return l.length?[...a,...i(l)]:a},o=new Map;return t.forEach((r,s)=>{if(!o.has(r.id))if(r.groupIds?.length){let a=r.groupIds[r.groupIds.length-1],l=t.slice(s).filter(d=>{let c=d?.groupIds?.some(u=>u===a);return c&&o.set(d.id,!0),c});for(let d of i(l))n.add(d)}else n.add(r)}),n.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...n]},Jf=e=>{let t=Kf(e),n=e.slice(),i=new Set;return n.forEach((o,r)=>{o&&(o.boundElements?.length?(i.add(o),n[r]=null,o.boundElements.forEach(s=>{let a=t.get(s.id);a&&s.type==="text"&&(i.add(a[0]),n[a[1]]=null)})):o.type==="text"&&o.containerId&&t.get(o.containerId)?.[0].boundElements?.find(a=>a.id===o.id)||(i.add(o),n[r]=null))}),i.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...i]},Sd=e=>Jf(Qf(e));var rh=(e,t,n,i)=>{let o=Ps(n);return oh()&&sh(o,n.id),o.id=Md(),o.updated=ih(),i&&(o.seed=th(),ml(o)),o.groupIds=$l(o.groupIds,e,r=>(t.has(r)||t.set(r,Md()),t.get(r))),o},mP=e=>{let{elements:t}=e,n="appState"in e?e.appState:{editingGroupId:null,selectedGroupIds:{}},i=new Map,o=new Map,r=[],s=[],a=new Map,l=new Map,d=new Map,c=nh(t),u=e.type==="in-place"?e.idsOfElementsToDuplicate:new Map(t.map(E=>[E.id,E]));if(e.type==="in-place")for(let E of Object.keys(e.appState.selectedGroupIds))t.filter(g=>g.groupIds?.includes(E)).forEach(g=>u.set(g.id,g));t=Sd(t);let m=t.slice(),p=E=>{let x=ys(E).reduce((w,b)=>{if(i.has(b.id))return w;i.set(b.id,!0);let y=rh(n.editingGroupId,o,b,e.randomizeSeed);return i.set(y.id,!0),d.set(y.id,y),a.set(b.id,y.id),l.set(y.id,b),s.push(b),r.push(y),w.push(y),w},[]);return Array.isArray(E)?x:x[0]||null},f=(E,g)=>{if(g){if(E>m.length-1){m.push(...ys(g));return}m.splice(E+1,0,...ys(g))}},h=new Set(t.filter(E=>u.has(E.id)&&K(E)).map(E=>E.id));for(let E of t){if(i.has(E.id)||!u.has(E.id))continue;let g=rs(n,E);if(g){let x=ve(t,g).flatMap(b=>K(b)?[...an(t,b.id),b]:[b]),w=Bi(m,b=>b.groupIds?.includes(g));f(w,p(x));continue}if(!(E.frameId&&h.has(E.frameId))){if(K(E)){let x=E.id,w=an(t,x),b=Bi(m,y=>y.frameId===x||y.id===x);f(b,p([...w,E]));continue}if(ct(E)){let x=V(E,c),w=Bi(m,b=>b.id===E.id||"containerId"in b&&b.containerId===E.id);x?f(w,p([E,x])):f(w,p(E));continue}if(ce(E)){let x=Se(E,c),w=Bi(m,b=>b.id===E.id||b.id===x?.id);x?f(w,p([x,E])):f(w,p(E));continue}f(Bi(m,x=>x.id===E.id),p(E))}}if(yl(r,a,d),Kl(m,s,a),e.overrides)for(let E of r){let g=l.get(E.id);g&&Object.assign(E,e.overrides({duplicateElement:E,origElement:g,origIdToDuplicateId:a}))}return{duplicatedElements:r,duplicateElementsMap:d,elementsWithDuplicates:m,origIdToDuplicateId:a}},bs=(e,t=0)=>{if(e==null||typeof e!="object")return e;let n=Object.prototype.toString.call(e);if(n==="[object Object]"){let i=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let o in e)if(e.hasOwnProperty(o)){if(t===0&&(o==="shape"||o==="canvas"))continue;i[o]=bs(e[o],t+1)}return i}if(Array.isArray(e)){let i=e.length,o=new Array(i);for(;i--;)o[i]=bs(e[i],t+1);return o}return v.DEV&&n!=="[object Object]"&&n!=="[object Array]"&&n.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${n}. This value will not be cloned!`),e},Ps=e=>bs(e),sh=(e,t)=>{Object.defineProperty(e,eh,{value:t,writable:!1,enumerable:!1})};var ze={IMMEDIATELY:"IMMEDIATELY",NEVER:"NEVER",EVENTUALLY:"EVENTUALLY"},Td=class{constructor(t){this.app=t}onDurableIncrementEmitter=new Ad;onStoreIncrementEmitter=new Ad;scheduledMacroActions=new Set;scheduledMicroActions=[];_snapshot=mn.empty();get snapshot(){return this._snapshot}set snapshot(t){this._snapshot=t}scheduleAction(t){this.scheduledMacroActions.add(t),this.satisfiesScheduledActionsInvariant()}scheduleCapture(){this.scheduleAction(ze.IMMEDIATELY)}scheduleMicroAction(t){let{action:n}=t,i;if("change"in t)i=t.change;else{let r=mn.create(this.app.scene.getElementsMapIncludingDeleted(),this.app.state),s=r.maybeClone(n,t.elements?Ld(t.elements):void 0,t.appState);i=Ci.create(r,s)}let o="delta"in t?t.delta:void 0;this.scheduledMicroActions.push(()=>this.processAction({action:n,change:i,delta:o}))}commit(t,n){this.flushMicroActions();try{let i=this.getScheduledMacroAction();this.processAction({action:i,elements:t,appState:n})}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledMacroActions=new Set}}clear(){this.snapshot=mn.empty(),this.scheduledMacroActions=new Set}emitDurableIncrement(t,n=void 0,i=void 0){let o=this.snapshot,r,s;if(n?r=n:r=Ci.create(o,t),i?s=i:s=Ms.calculate(o,t),!s.isEmpty()){let a=new Is(r,s);this.onDurableIncrementEmitter.trigger(a),this.onStoreIncrementEmitter.trigger(a)}}emitEphemeralIncrement(t,n=void 0){let i;if(n)i=n;else{let r=this.snapshot;i=Ci.create(r,t)}let o=new Ss(i);this.onStoreIncrementEmitter.trigger(o)}applyChangeToSnapshot(t){let n=this.snapshot,i=this.snapshot.applyChange(t);return n===i?null:i}maybeCloneSnapshot(t,n,i){if(!n&&!i)return null;let o=this.snapshot,r=this.snapshot.maybeClone(t,n,i);return o===r?null:r}flushMicroActions(){for(let t of this.scheduledMicroActions)try{t()}catch(n){console.error("Failed to execute scheduled micro action",n)}this.scheduledMicroActions=[]}processAction(t){let{action:n}=t;if(n===ze.EVENTUALLY&&!this.onStoreIncrementEmitter.subscribers.length)return;let i;if("change"in t?i=this.applyChangeToSnapshot(t.change):i=this.maybeCloneSnapshot(n,t.elements,t.appState),!i)return;let o="change"in t?t.change:void 0,r="delta"in t?t.delta:void 0;try{switch(n){case ze.IMMEDIATELY:this.emitDurableIncrement(i,o,r);break;case ze.NEVER:case ze.EVENTUALLY:this.emitEphemeralIncrement(i,o);break;default:ah(n,"Unknown store action")}}finally{switch(n){case ze.IMMEDIATELY:case ze.NEVER:this.snapshot=i;break}}}getScheduledMacroAction(){let t;return this.scheduledMacroActions.has(ze.IMMEDIATELY)?t=ze.IMMEDIATELY:this.scheduledMacroActions.has(ze.NEVER)?t=ze.NEVER:t=ze.EVENTUALLY,t}satisfiesScheduledActionsInvariant(){if(!(this.scheduledMacroActions.size>=0&&this.scheduledMacroActions.size<=Object.keys(ze).length)){let t=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledMacroActions.size}".`;if(console.error(t,this.scheduledMacroActions.values()),ch()||dh())throw new Error(t)}}},Ci=class e{constructor(t,n){this.elements=t;this.appState=n}static create(t,n){let i=n.getChangedElements(t),o=n.getChangedAppState(t);return new e(i,o)}},Xo=class{constructor(t,n){this.type=t;this.change=n}static isDurable(t){return t.type==="durable"}static isEphemeral(t){return t.type==="ephemeral"}},Is=class extends Xo{constructor(n,i){super("durable",n);this.change=n;this.delta=i}},Ss=class extends Xo{constructor(n){super("ephemeral",n);this.change=n}},Ms=class e{constructor(t,n,i){this.id=t;this.elements=n;this.appState=i}static create(t,n,i={id:uh()}){return new this(i.id,t,n)}static calculate(t,n){let i=n.metadata.didElementsChange?un.calculate(t.elements,n.elements):un.empty(),o=n.metadata.didAppStateChange?cn.calculate(t.appState,n.appState):cn.empty();return this.create(i,o)}static restore(t){let{id:n,elements:i,appState:o}=t;return new this(n,un.restore(i),cn.restore(o))}static load({id:t,elements:{added:n,removed:i,updated:o},appState:{delta:r}}){let s=un.create(n,i,o),a=cn.create(r);return new this(t,s,a)}static squash(...t){let n=e.empty();for(let i of t)n.elements.squash(i.elements),n.appState.squash(i.appState);return n}static inverse(t){return this.create(t.elements.inverse(),t.appState.inverse())}static applyTo(t,n,i,o){let[r,s]=t.elements.applyTo(n,mn.empty().elements,o),[a,l]=t.appState.applyTo(i,r);return[r,a,s||l]}static applyLatestChanges(t,n,i,o){return this.create(t.elements.applyLatestChanges(n,i,o),t.appState,{id:t.id})}static empty(){return e.create(un.empty(),cn.empty())}isEmpty(){return this.elements.isEmpty()&&this.appState.isEmpty()}},mn=class e{constructor(t,n,i={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=t;this.appState=n;this.metadata=i}_lastChangedElementsHash=0;_lastChangedAppStateHash=0;static create(t,n,i={didElementsChange:!1,didAppStateChange:!1}){return new e(t,vd(n)?n:Xn(n),i)}static empty(){return new e(new Map,mh(),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}getChangedElements(t){let n={};for(let i of Wn(t.elements))this.elements.get(i.id)||(n[i.id]=ge(i,{isDeleted:!0}));for(let i of Wn(this.elements))t.elements.get(i.id)!==i&&(n[i.id]=i);return n}getChangedAppState(t){return _.getRightDifferences(t.appState,this.appState).reduce((n,i)=>Object.assign(n,{[i]:this.appState[i]}),{})}isEmpty(){return this.metadata.isEmpty}applyChange(t){let n=new Map(this.elements);for(let[o,r]of Object.entries(t.elements))n.set(o,r);let i=Xn({...this.appState,...t.appState});return e.create(n,i,{didElementsChange:Object.keys(t.elements).length>0,didAppStateChange:Object.keys(t.appState).length>0})}maybeClone(t,n,i){let o={shouldCompareHashes:!1};t===ze.EVENTUALLY&&(o.shouldCompareHashes=!0);let r=this.maybeCreateElementsSnapshot(n,o),s=this.maybeCreateAppStateSnapshot(i,o),a=!1,l=!1;return this.elements!==r&&(a=!0),this.appState!==s&&(l=!0),!a&&!l?this:new e(r,s,{didElementsChange:a,didAppStateChange:l})}maybeCreateAppStateSnapshot(t,n={shouldCompareHashes:!1}){if(!t)return this.appState;let i=vd(t)?t:Xn(t);return this.detectChangedAppState(i,n)?i:this.appState}maybeCreateElementsSnapshot(t,n={shouldCompareHashes:!1}){if(!t)return this.elements;let i=this.detectChangedElements(t,n);return i?.size?this.createElementsSnapshot(i):this.elements}detectChangedAppState(t,n={shouldCompareHashes:!1}){if(this.appState===t)return;let i=_.isRightDifferent(this.appState,t);if(!i)return;let o=Cd(JSON.stringify(t));if(!(n.shouldCompareHashes&&this._lastChangedAppStateHash===o))return this._lastChangedAppStateHash=o,i}detectChangedElements(t,n={shouldCompareHashes:!1}){if(this.elements===t)return;let i=new Map;for(let r of Wn(this.elements))t.get(r.id)||i.set(r.id,ge(r,{isDeleted:!0}));for(let r of Wn(t)){let s=this.elements.get(r.id);if(!s||s.version<r.version){if(xe(r)&&!yn(r))continue;i.set(r.id,r)}}if(!i.size)return;let o=Bd(i);if(!(n.shouldCompareHashes&&this._lastChangedElementsHash===o))return this._lastChangedElementsHash=o,i}createElementsSnapshot(t){let n=new Map;for(let i of Wn(this.elements))n.set(i.id,i);for(let i of Wn(t))n.set(i.id,Ps(i));return n}},Dd="__observedAppState",mh=()=>({name:null,editingGroupId:null,viewBackgroundColor:lh.white,selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null,croppingElementId:null,activeLockedId:null,lockedMultiSelections:{}}),Xn=e=>{let t={name:e.name,editingGroupId:e.editingGroupId,viewBackgroundColor:e.viewBackgroundColor,selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,croppingElementId:e.croppingElementId,activeLockedId:e.activeLockedId,lockedMultiSelections:e.lockedMultiSelections,selectedLinearElement:e.selectedLinearElement?{elementId:e.selectedLinearElement.elementId,isEditing:!!e.selectedLinearElement.isEditing}:null};return Reflect.defineProperty(t,Dd,{value:!0,enumerable:!1}),t},vd=e=>!!Reflect.get(e,Dd);P();P();var kd="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function Vn(e,t,n){let i=n[0];if(t!=null&&e>=t)throw new Error(e+" >= "+t);if(e.slice(-1)===i||t&&t.slice(-1)===i)throw new Error("trailing zero");if(t){let s=0;for(;(e[s]||i)===t[s];)s++;if(s>0)return t.slice(0,s)+Vn(e.slice(s),t.slice(s),n)}let o=e?n.indexOf(e[0]):0,r=t!=null?n.indexOf(t[0]):n.length;if(r-o>1){let s=Math.round(.5*(o+r));return n[s]}else return t&&t.length>1?t.slice(0,1):n[o]+Vn(e.slice(1),null,n)}function Rd(e){if(e.length!==Fd(e[0]))throw new Error("invalid integer part of order key: "+e)}function Fd(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw new Error("invalid order key head: "+e)}function Gi(e){let t=Fd(e[0]);if(t>e.length)throw new Error("invalid order key: "+e);return e.slice(0,t)}function Gd(e,t){if(e==="A"+t[0].repeat(26))throw new Error("invalid order key: "+e);let n=Gi(e);if(e.slice(n.length).slice(-1)===t[0])throw new Error("invalid order key: "+e)}function Od(e,t){Rd(e);let[n,...i]=e.split(""),o=!0;for(let r=i.length-1;o&&r>=0;r--){let s=t.indexOf(i[r])+1;s===t.length?i[r]=t[0]:(i[r]=t[s],o=!1)}if(o){if(n==="Z")return"a"+t[0];if(n==="z")return null;let r=String.fromCharCode(n.charCodeAt(0)+1);return r>"a"?i.push(t[0]):i.pop(),r+i.join("")}else return n+i.join("")}function ph(e,t){Rd(e);let[n,...i]=e.split(""),o=!0;for(let r=i.length-1;o&&r>=0;r--){let s=t.indexOf(i[r])-1;s===-1?i[r]=t.slice(-1):(i[r]=t[s],o=!1)}if(o){if(n==="a")return"Z"+t.slice(-1);if(n==="A")return null;let r=String.fromCharCode(n.charCodeAt(0)-1);return r<"Z"?i.push(t.slice(-1)):i.pop(),r+i.join("")}else return n+i.join("")}function jn(e,t,n=kd){if(e!=null&&Gd(e,n),t!=null&&Gd(t,n),e!=null&&t!=null&&e>=t)throw new Error(e+" >= "+t);if(e==null){if(t==null)return"a"+n[0];let l=Gi(t),d=t.slice(l.length);if(l==="A"+n[0].repeat(26))return l+Vn("",d,n);if(l<t)return l;let c=ph(l,n);if(c==null)throw new Error("cannot decrement any more");return c}if(t==null){let l=Gi(e),d=e.slice(l.length),c=Od(l,n);return c??l+Vn(d,null,n)}let i=Gi(e),o=e.slice(i.length),r=Gi(t),s=t.slice(r.length);if(i===r)return i+Vn(o,s,n);let a=Od(i,n);if(a==null)throw new Error("cannot increment any more");return a<t?a:i+Vn(o,null,n)}function jo(e,t,n,i=kd){if(n===0)return[];if(n===1)return[jn(e,t,i)];if(t==null){let s=jn(e,t,i),a=[s];for(let l=0;l<n-1;l++)s=jn(s,t,i),a.push(s);return a}if(e==null){let s=jn(e,t,i),a=[s];for(let l=0;l<n-1;l++)s=jn(e,s,i),a.push(s);return a.reverse(),a}let o=Math.floor(n/2),r=jn(e,t,i);return[...jo(e,r,o,i),r,...jo(r,t,n-o-1,i)]}import{arrayToMap as Vo}from"@excalidraw/common";var As=class extends Error{code="ELEMENT_HAS_INVALID_INDEX"},fh=(e,{shouldThrow:t=!1,includeBoundTextValidation:n=!1,ignoreLogs:i,reconciliationContext:o})=>{let r=[],s=l=>`${l?.index}:${l?.id}:${l?.type}:${l?.isDeleted}:${l?.version}:${l?.versionNonce}`,a=e.map(l=>l.index);for(let[l,d]of a.entries()){let c=a[l-1],u=a[l+1];if(Ts(d,c,u)||r.push(`Fractional indices invariant has been compromised: "${s(e[l-1])}", "${s(e[l])}", "${s(e[l+1])}"`),n&&ct(e[l])){let m=e[l],p=V(m,Vo(e));p&&p.index<=m.index&&r.push(`Fractional indices invariant for bound elements has been compromised: "${s(p)}", "${s(m)}"`)}}if(r.length){let l=new As,d=[];if(o&&(d.push("Additional reconciliation context:"),d.push(o.localElements.map(c=>s(c))),d.push(o.remoteElements.map(c=>s(c)))),i||console.error(r.join(`
12
+ `),a=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,l=Li(e.fontSize,e.lineHeight),d=Um(e.fontFamily,e.fontSize,l);for(let c=0;c<s.length;c++)n.fillText(s[c],a,c*l+d);n.restore(),r&&n.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},Yo=new WeakMap,$d=(e,t,n,o)=>{let i=n?o.zoom:{value:1},r=Yo.get(e),s=r&&r.zoomValue!==i.value&&!o?.shouldCacheIgnoreZoom,a=J(e,t),l=a?.version||null,d=ve(e)?e.crop:null,c=en(e,t)?.opacity||100;if(!r||s||r.theme!==o.theme||r.boundTextElementVersion!==l||r.imageCrop!==d||r.containingFrameOpacity!==c||V(e)&&a&&e.angle!==r.angle){let p=Zd(e,t,i,n,o);return p?(Yo.set(e,p),p):null}return r},Fs=(e,t,n,o,i)=>{let r=e.element,s=ar(r),a=e.scale,[l,d,c,p]=K(r,i),h=((l+c)/2+o.scrollX)*window.devicePixelRatio,m=((d+p)/2+o.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let f=J(r,i);if(V(r)&&f){let g=(e.boundTextCanvas.width-e.canvas.width)/2,E=(e.boundTextCanvas.height-e.canvas.height)/2;t.translate(h,m),t.drawImage(e.boundTextCanvas,-(c-l)/2*window.devicePixelRatio-g/a-s,-(p-d)/2*window.devicePixelRatio-E/a-s,e.boundTextCanvas.width/a,e.boundTextCanvas.height/a)}else if(t.translate(h,m),t.rotate(r.angle),"scale"in e.element&&!$m(r,n)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-h,-m),t.drawImage(e.canvas,(l+o.scrollX)*window.devicePixelRatio-s*e.scale/e.scale,(d+o.scrollY)*window.devicePixelRatio-s*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),L.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&kt(r)){let g=J(r,i),E=os(r);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((E.x+o.scrollX)*window.devicePixelRatio,(E.y+o.scrollY)*window.devicePixelRatio,yt(r,g)*window.devicePixelRatio,Go(r,g)*window.devicePixelRatio)}t.restore()},zw=(e,t,n,o)=>{t.save(),t.translate(e.x+n.scrollX,e.y+n.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let i=.5/n.zoom.value;t.fillRect(i,i,e.width,e.height),t.lineWidth=1/n.zoom.value,t.strokeStyle=o,t.strokeRect(i,i,e.width,e.height),t.restore()},_w=(e,t,n,o,i,r,s)=>{let a=s.openDialog?.name==="elementLinkSelector"&&!s.selectedElementIds[e.id]&&!s.hoveredElementIds[e.id];switch(i.globalAlpha=Zm(e,en(e,t),r.elementsPendingErasure,r.pendingFlowchartNodes,a?zm:1),e.type){case"magicframe":case"frame":{s.frameRendering.enabled&&s.frameRendering.outline&&(i.save(),i.translate(e.x+s.scrollX,e.y+s.scrollY),i.fillStyle="rgba(0, 0, 200, 0.04)",i.lineWidth=Uo.strokeWidth/s.zoom.value,i.strokeStyle=s.theme===ro.DARK?sr(Uo.strokeColor):Uo.strokeColor,pl(e)&&(i.strokeStyle=s.theme===ro.LIGHT?"#7affd7":sr("#1d8264")),Uo.radius&&i.roundRect?(i.beginPath(),i.roundRect(0,0,e.width,e.height,Uo.radius/s.zoom.value),i.stroke(),i.closePath()):i.strokeRect(0,0,e.width,e.height),i.restore());break}case"freedraw":{if(r.isExporting){let[l,d,c,p]=K(e,t),h=(l+c)/2+s.scrollX,m=(d+p)/2+s.scrollY,f=(c-l)/2-(e.x-l),g=(p-d)/2-(e.y-d);i.save(),i.translate(h,m),i.rotate(e.angle),i.translate(-f,-g),rr(e,o,i,r),i.restore()}else{let l=$d(e,n,r,s);if(!l)return;Fs(l,i,r,s,n)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(r.isExporting){let[l,d,c,p]=K(e,t),h=(l+c)/2+s.scrollX,m=(d+p)/2+s.scrollY,f=(c-l)/2-(e.x-l),g=(p-d)/2-(e.y-d);if(ee(e)){let x=De(e,t);if(V(x)){let y=G.getBoundTextElementPosition(x,e,t);f=(c-l)/2-(y.x-l),g=(p-d)/2-(y.y-d)}}i.save(),i.translate(h,m);let E=J(e,t);if(V(e)&&E){let x=document.createElement("canvas"),y=x.getContext("2d"),w=Math.max(An(l,c),An(d,p)),M=ar(e);x.width=w*s.exportScale+M*10*s.exportScale,x.height=w*s.exportScale+M*10*s.exportScale,y.translate(x.width/2,x.height/2),y.scale(s.exportScale,s.exportScale),f=e.width/2-(e.x-l),g=e.height/2-(e.y-d),y.rotate(e.angle);let b=Fn.canvas(x);y.translate(-f,-g),rr(e,b,y,r),y.translate(f,g),y.rotate(-e.angle);let[,,,,S,A]=K(E,t),C=(l+c)/2-S,T=(d+p)/2-A;y.translate(-C,-T),y.clearRect(-E.width/2,-E.height/2,E.width,E.height),i.scale(1/s.exportScale,1/s.exportScale),i.drawImage(x,-x.width/2,-x.height/2,x.width,x.height)}else i.rotate(e.angle),e.type==="image"&&i.scale(e.scale[0],e.scale[1]),i.translate(-f,-g),rr(e,o,i,r);i.restore()}else{let l=$d(e,n,r,s);if(!l)return;let d=i.imageSmoothingEnabled;if(!s?.shouldCacheIgnoreZoom&&(!e.angle||Hm(e.angle))&&(i.imageSmoothingEnabled=!1),e.id===s.croppingElementId&&ve(l.element)&&l.element.crop!==null){i.save(),i.globalAlpha=.1;let c=Zd(dl(l.element,t),n,s.zoom,r,s);c&&Fs(c,i,r,s,n),i.restore()}Fs(l,i,r,s,n),i.imageSmoothingEnabled=d}break}default:throw new Error(`Unimplemented type ${e.type}`)}i.globalAlpha=1};function Ww(e,t,n){let o=Me({...e,angle:0},n),i=or((o[0]+o[2])/2,(o[1]+o[3])/2);return Ym(t.length>=2,"Freepath outline must have at least 2 points"),t.slice(2).reduce((r,s)=>(r.push(Xd(r[r.length-1][1],Rs(or(s[0]+e.x,s[1]+e.y),i,e.angle))),r),[Xd(Rs(or(t[0][0]+e.x,t[0][1]+e.y),i,e.angle),Rs(or(t[1][0]+e.x,t[1][1]+e.y),i,e.angle))])}I();var Uw=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",Yw=e=>e==="rectangle"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line"||e==="text"||e==="embeddable",Xw=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",$w=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",Qd=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image",Zw=e=>e==="arrow",qw=e=>e==="arrow";var st=class e{static rg=new lt;static cache=new WeakMap;static get=(t,n)=>{let o=e.cache.get(t);if(o&&(n===null||o.theme===n))return o.shape};static delete=t=>{e.cache.delete(t),Yo.delete(t)};static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,n)=>{let o=n?.isExporting?void 0:e.get(t,n?n.theme:null);if(o!==void 0)return o;Yo.delete(t);let i=i0(t,e.rg,n||{isExporting:!1,canvasBackgroundColor:e0.white,embedsValidationStatus:null,theme:zs.LIGHT});return n?.isExporting||e.cache.set(t,{shape:i,theme:n?.theme||zs.LIGHT}),i}},n0=e=>[8,8+e],oc=e=>[1.5,6+e];function o0(e){let t=e.roughness,n=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&n>=50||o>=15&&e.roundness&&Qd(e.type)||ne(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}var Qe=(e,t=!1,n=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?n0(e.strokeWidth):e.strokeStyle==="dotted"?oc(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:o0(e),stroke:n?Zo(e.strokeColor):e.strokeColor,preserveVertices:t||e.roughness<Qm.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=$o(e.backgroundColor)?void 0:n?Zo(e.backgroundColor):e.backgroundColor,e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return zn(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:n?Zo(e.backgroundColor):e.backgroundColor),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},ec=(e,t,n)=>Ii(e)&&(t||ul(e)&&n?.get(e.id)!==!0)&&$o(e.backgroundColor)&&$o(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Pi(e)?{...e,strokeColor:$o(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:$o(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Xo=(e,t,n)=>{if(t===null)return[];let[,,o,i,r,s]=t;return[e.line(o,i,r,s,n)]},lr=(e,t,n)=>{if(t===null)return[];let[o,i,r,s,a,l]=t;return[e.line(r,s,o,i,n),e.line(a,l,o,i,n)]},Yn=(e,t)=>{let n={...t};if(e.strokeStyle==="dotted"){let o=oc(e.strokeWidth-1);n.strokeLineDash=[o[0],o[1]-1]}else delete n.strokeLineDash;return n.roughness=Math.min(1,n.roughness||0),n},Hs=(e,t,n,o,i,r=1)=>{if(o===null)return[];let[s,a,l]=o,d={...t,fill:i,fillStyle:"solid",stroke:n,roughness:Math.min(.5,t.roughness||0)};return delete d.strokeLineDash,[e.circle(s,a,l*r,d)]},tc=(e,t,n,o,i,r,s,a)=>{if(o===null)return[];let l=a?Zo(e.strokeColor):e.strokeColor,d=a?Zo(s):s,c=-.25,p=.8;switch(o){case"circle":case"circle_outline":return Hs(i,r,l,We(e,t,n,o),o==="circle_outline"?d:l);case"triangle":case"triangle_outline":{let h=We(e,t,n,o);if(h===null)return[];let[m,f,g,E,x,y]=h,w={...r,fill:o==="triangle_outline"?d:l,fillStyle:"solid",roughness:Math.min(1,r.roughness||0)};return delete w.strokeLineDash,[i.polygon([[m,f],[g,E],[x,y],[m,f]],w)]}case"diamond":case"diamond_outline":{let h=We(e,t,n,o);if(h===null)return[];let[m,f,g,E,x,y,w,M]=h,b={...r,fill:o==="diamond_outline"?d:l,fillStyle:"solid",roughness:Math.min(1,r.roughness||0)};return delete b.strokeLineDash,[i.polygon([[m,f],[g,E],[x,y],[w,M],[m,f]],b)]}case"cardinality_one":return Xo(i,We(e,t,n,o),Yn(e,r));case"cardinality_many":return lr(i,We(e,t,n,o),Yn(e,r));case"cardinality_one_or_many":{let h=Yn(e,r);return[...lr(i,We(e,t,n,"cardinality_many"),h),...Xo(i,We(e,t,n,"cardinality_one",c),h)]}case"cardinality_exactly_one":{let h=Yn(e,r);return[...Xo(i,We(e,t,n,"cardinality_one",-.5),h),...Xo(i,We(e,t,n,"cardinality_one"),h)]}case"cardinality_zero_or_one":{let h=Yn(e,r);return[...Hs(i,r,l,We(e,t,n,"circle_outline",1.5),d,p),...Xo(i,We(e,t,n,"cardinality_one",-.5),h)]}case"cardinality_zero_or_many":{let h=Yn(e,r);return[...lr(i,We(e,t,n,"cardinality_many"),h),...Hs(i,r,l,We(e,t,n,"circle_outline",1.5),d,p)]}case"bar":case"arrow":default:return lr(i,We(e,t,n,o),Yn(e,r))}},Pl=e=>{let t=new lt,n={seed:e.seed,disableMultiStroke:!0,disableMultiStrokeFill:!0,roughness:0,preserveVertices:!0},o=Ct(e.points.reduce((i,r)=>[Math.min(e.x+r[0],i[0]),Math.min(e.y+r[1],i[1]),Math.max(e.x+r[0],i[2]),Math.max(e.y+r[1],i[3])],[1/0,1/0,-1/0,-1/0]));switch(e.type){case"line":case"arrow":{let i=e.points.length?e.points:[he(0,0)];return Y(e)?t.path(ic(i,16),n).sets[0].ops:e.roundness?t.curve(i,n).sets[0].ops.slice(0,e.points.length).map((r,s)=>{if(s===0){let a=tn(he(e.x+r.data[0],e.y+r.data[1]),o,e.angle);return{op:"move",data:he(a[0]-e.x,a[1]-e.y)}}return{op:"bcurveTo",data:[tn(he(e.x+r.data[0],e.y+r.data[1]),o,e.angle),tn(he(e.x+r.data[2],e.y+r.data[3]),o,e.angle),tn(he(e.x+r.data[4],e.y+r.data[5]),o,e.angle)].map(a=>he(a[0]-e.x,a[1]-e.y)).flat()}}):i.map((r,s)=>{let a=tn(he(e.x+r[0],e.y+r[1]),o,e.angle);return{op:s===0?"move":"lineTo",data:he(a[0]-e.x,a[1]-e.y)}})}case"freedraw":{if(e.points.length<2)return[];let i=Po(e.points,.75);return t.curve(i,n).sets[0].ops.slice(0,e.points.length).map((r,s)=>{if(s===0){let a=tn(he(e.x+r.data[0],e.y+r.data[1]),o,e.angle);return{op:"move",data:he(a[0]-e.x,a[1]-e.y)}}return{op:"bcurveTo",data:[tn(he(e.x+r.data[0],e.y+r.data[1]),o,e.angle),tn(he(e.x+r.data[2],e.y+r.data[3]),o,e.angle),tn(he(e.x+r.data[4],e.y+r.data[5]),o,e.angle)].map(a=>he(a[0]-e.x,a[1]-e.y)).flat()}})}}},i0=(e,t,{isExporting:n,canvasBackgroundColor:o,embedsValidationStatus:i,theme:r})=>{let s=r===zs.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let a;if(e.roundness){let l=e.width,d=e.height,c=Vt(Math.min(l,d),e);a=t.path(`M ${c} 0 L ${l-c} 0 Q ${l} 0, ${l} ${c} L ${l} ${d-c} Q ${l} ${d}, ${l-c} ${d} L ${c} ${d} Q 0 ${d}, 0 ${d-c} L 0 ${c} Q 0 0, ${c} 0`,Qe(ec(e,n,i),!0,s))}else a=t.rectangle(0,0,e.width,e.height,Qe(ec(e,n,i),!1,s));return a}case"diamond":{let a,[l,d,c,p,h,m,f,g]=Qn(e);if(e.roundness){let E=Vt(Math.abs(l-f),e),x=Vt(Math.abs(p-d),e);a=t.path(`M ${l+E} ${d+x} L ${c-E} ${p-x}
13
+ C ${c} ${p}, ${c} ${p}, ${c-E} ${p+x}
14
+ L ${h+E} ${m-x}
15
+ C ${h} ${m}, ${h} ${m}, ${h-E} ${m-x}
16
+ L ${f+E} ${g+x}
17
+ C ${f} ${g}, ${f} ${g}, ${f+E} ${g-x}
18
+ L ${l-E} ${d+x}
19
+ C ${l} ${d}, ${l} ${d}, ${l+E} ${d+x}`,Qe(e,!0,s))}else a=t.polygon([[l,d],[c,p],[h,m],[f,g]],Qe(e,!1,s));return a}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,Qe(e,!1,s));case"line":case"arrow":{let a,l=Qe(e,!1,s),d=e.points.length?e.points:[he(0,0)];if(Y(e)?d.every(c=>Math.abs(c[0])<=1e6&&Math.abs(c[1])<=1e6)?a=[t.path(ic(d,16),Qe(e,!0,s))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(d)),a=[]):e.roundness?a=[t.curve(d,l)]:l.fill?a=[t.polygon(d,l)]:a=[t.linearPath(d,l)],e.type==="arrow"){let{startArrowhead:c=null,endArrowhead:p="arrow"}=e;if(c!==null){let h=tc(e,a,"start",c,t,l,o,s);a.push(...h)}if(p!==null){let h=tc(e,a,"end",p,t,l,o,s);a.push(...h)}}return a}case"freedraw":{let a=[];if(zn(e.points)){let l=Po(e.points,.75);a.push(t.curve(l,{...Qe(e,!1,s),stroke:"none"}))}return a.push(r0(e)),a}case"frame":case"magicframe":case"text":case"image":return null;default:return Jm(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},ic=(e,t)=>{let n=[];for(let i=1;i<e.length-1;i+=1){let r=e[i-1],s=e[i+1],a=e[i],l=wt(a,r),d=wt(s,a),c=Math.min(t,Jd(e[i],s)/2,Jd(e[i],r)/2);l?r[0]<a[0]?n.push([e[i][0]-c,e[i][1]]):n.push([e[i][0]+c,e[i][1]]):r[1]<a[1]?n.push([e[i][0],e[i][1]-c]):n.push([e[i][0],e[i][1]+c]),n.push(e[i]),d?s[0]<a[0]?n.push([e[i][0]-c,e[i][1]]):n.push([e[i][0]+c,e[i][1]]):s[1]<a[1]?n.push([e[i][0],e[i][1]-c]):n.push([e[i][0],e[i][1]+c])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let i=0;i<n.length;i+=3)o.push(`L ${n[i][0]} ${n[i][1]}`),o.push(`Q ${n[i+1][0]} ${n[i+1][1]}, ${n[i+2][0]} ${n[i+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")},qo=(e,t)=>{switch(e.type){case"rectangle":case"diamond":case"frame":case"magicframe":case"embeddable":case"image":case"iframe":case"text":case"selection":return Xa(e);case"arrow":case"line":{let n=st.generateElementShape(e,null)[0],[,,,,o,i]=K(e,t);return Oi(e)?Ka(e,n,he(e.x,e.y),e.angle,he(o,i)):Za(n,he(e.x,e.y),e.angle,he(o,i))}case"ellipse":return $a(e);case"freedraw":{let[,,,,n,o]=K(e,t);return qa(e,he(n,o),Oi(e))}}},Id=(e,t)=>{let n=[...e.points];if(t){if(!gl(e.points))return null;let i=n[0],r=n[n.length-1];Math.hypot(i[0]-r[0],i[1]-r[1])>t0||n.length<4?n.push(he(i[0],i[1])):n[n.length-1]=he(i[0],i[1])}return{polygon:t,points:n}},r0=e=>l0(s0(e)),s0=e=>{let t=e.simulatePressure?e.points:e.points.length?e.points.map(([n,o],i)=>[n,o,e.pressures[i]]):[[0,0,.5]];return il(t,{simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:n=>Math.sin(n*Math.PI/2),last:!0})},nc=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],a0=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,l0=e=>{if(!e.length)return"";let t=e.length-1;return e.reduce((n,o,i,r)=>(i===t?n.push(o,nc(o,r[0]),"L",r[0],"Z"):n.push(o,nc(o,r[i+1])),n),["M",e[0],"Q"]).join(" ").replace(a0,"$1")};var js=class e{static boundsCache=new WeakMap;static nonRotatedBoundsCache=new WeakMap;static getBounds(t,n,o=!1){let i=o&&t.angle!==0?e.nonRotatedBoundsCache.get(t):e.boundsCache.get(t);if(i?.version&&i.version===t.version&&!ge(t))return i.bounds;if(o&&t.angle!==0){let s=e.calculateBounds({...t,angle:0},n);return e.nonRotatedBoundsCache.set(t,{version:t.version,bounds:s}),s}let r=e.calculateBounds(t,n);return e.boundsCache.set(t,{version:t.version,bounds:r}),r}static calculateBounds(t,n){let o,[i,r,s,a,l,d]=K(t,n);if(Ce(t)){let[c,p,h,m]=Vs(t.points.map(([f,g])=>de(B(f,g),B(l-t.x,d-t.y),t.angle)));return[c+t.x,p+t.y,h+t.x,m+t.y]}else if(ne(t))o=y0(t,l,d,n);else if(t.type==="diamond"){let[c,p]=de(B(l,r),B(l,d),t.angle),[h,m]=de(B(l,a),B(l,d),t.angle),[f,g]=de(B(i,d),B(l,d),t.angle),[E,x]=de(B(s,d),B(l,d),t.angle),y=Math.min(c,h,f,E),w=Math.min(p,m,g,x),M=Math.max(c,h,f,E),b=Math.max(p,m,g,x);o=[y,w,M,b]}else if(t.type==="ellipse"){let c=(s-i)/2,p=(a-r)/2,h=Math.cos(t.angle),m=Math.sin(t.angle),f=Math.hypot(c*h,p*m),g=Math.hypot(p*h,c*m);o=[l-f,d-g,l+f,d+g]}else{let[c,p]=de(B(i,r),B(l,d),t.angle),[h,m]=de(B(i,a),B(l,d),t.angle),[f,g]=de(B(s,a),B(l,d),t.angle),[E,x]=de(B(s,r),B(l,d),t.angle),y=Math.min(c,h,f,E),w=Math.min(p,m,g,x),M=Math.max(c,h,f,E),b=Math.max(p,m,g,x);o=[y,w,M,b]}return o}},K=(e,t,n=!1)=>{if(Ce(e))return h0(e);if(ne(e))return G.getElementAbsoluteCoords(e,t,n);if(ee(e)){let o=t?De(e,t):null;if(V(o)){let{x:i,y:r}=G.getBoundTextElementPosition(o,e,t);return[i,r,i+e.width,r+e.height,i+e.width/2,r+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]},Gs=(e,t)=>{let n=qo(e,t),[o,i,r,s,a,l]=K(e,t),d=B(a,l);if(n.type==="polycurve"){let x=n.data.map(w=>Ht(w,10)),y=[];if(Wt(e)&&!e.polygon||V(e))for(let w of x){let M=0;for(;M<w.length-1;)y.push(Ie(B(w[M][0],w[M][1]),B(w[M+1][0],w[M+1][1]))),M++}else{let w=x.flat(),M=0;for(;M<w.length-1;)y.push(Ie(B(w[M][0],w[M][1]),B(w[M+1][0],w[M+1][1]))),M++}return y}else{if(n.type==="polyline")return n.data;if(u0(e)){let[E,x]=un(e),y=x.map(M=>ac(M,d,e.angle)).flat();return[...sc(E,d,e.angle),...y]}else if(e.type==="diamond"){let[E,x]=pn(e),y=x.map(M=>ac(M,d,e.angle)).flat();return[...sc(E,d,e.angle),...y]}else if(n.type==="polygon"){if(ee(e)){let y=De(e,t);if(y&&ne(y))return[Ie(B(o,i),B(r,i)),Ie(B(r,i),B(r,s)),Ie(B(r,s),B(o,s)),Ie(B(o,s),B(o,i))]}let E=n.data,x=[];for(let y=0;y<E.length-1;y++)x.push(Ie(E[y],E[y+1]));return x}else if(n.type==="ellipse")return p0(e)}let[c,p,h,m,,,f,g]=[[o,i],[r,i],[o,s],[r,s],[a,i],[a,s],[o,l],[r,l]].map(E=>de(E,d,e.angle));return[Ie(c,p),Ie(h,m),Ie(c,h),Ie(p,m),Ie(c,g),Ie(h,g),Ie(p,f),Ie(m,f)]},u0=e=>e!=null&&(e.type==="rectangle"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),sc=(e,t,n)=>e.map(o=>Ie(de(o[0],t,n),de(o[1],t,n))),ac=(e,t,n)=>{let o=Ht(e,10),i=0,r=[];for(;i<o.length-1;)r.push(Ie(de(B(o[i][0],o[i][1]),t,n),de(B(o[i+1][0],o[i+1][1]),t,n))),i++;return r},p0=e=>{let t=B(e.x+e.width/2,e.y+e.height/2),n=e.width/2,o=e.height/2,i=[],r=[],s=90,a=Math.PI*2/s;for(let l=0;l<s;l++){let d=l*a,c=t[0]+n*Math.cos(d),p=t[1]+o*Math.sin(d);r.push(de(B(c,p),t,e.angle))}for(let l=0;l<r.length-1;l++)i.push(Ie(r[l],r[l+1]));return i.push(Ie(r[r.length-1],r[0])),i},vb=e=>[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2],Qn=e=>{let t=Math.floor(e.width/2)+1,n=0,o=e.width,i=Math.floor(e.height/2)+1,r=t,s=e.height;return[t,n,o,i,r,s,0,i]},lc=(e,t,n,o,i)=>{let r=1-e;return Math.pow(r,3)*t+3*Math.pow(r,2)*e*n+3*r*Math.pow(e,2)*o+Math.pow(e,3)*i},dc=(e,t,n,o)=>{let i=t-e,r=n-t,s=o-n,a=3*i-6*r+3*s,l=6*r-6*i,d=3*i,c=l*l-4*a*d;if(!(c>=0))return!1;let h=null,m=null,f=1/0,g=1/0;return a===0?f=g=-d/l:(f=(-l+Math.sqrt(c))/(2*a),g=(-l-Math.sqrt(c))/(2*a)),f>=0&&f<=1&&(h=lc(f,e,t,n,o)),g>=0&&g<=1&&(m=lc(g,e,t,n,o)),[h,m]},Fi=(e,t,n,o)=>{let i=dc(e[0],t[0],n[0],o[0]),r=dc(e[1],t[1],n[1],o[1]),s=Math.min(e[0],o[0]),a=Math.max(e[0],o[0]);if(i){let c=i.filter(p=>p!==null);s=Math.min(s,...c),a=Math.max(a,...c)}let l=Math.min(e[1],o[1]),d=Math.max(e[1],o[1]);if(r){let c=r.filter(p=>p!==null);l=Math.min(l,...c),d=Math.max(d,...c)}return[s,l,a,d]},Vo=(e,t)=>{let n=B(0,0),{minX:o,minY:i,maxX:r,maxY:s}=e.reduce((a,{op:l,data:d})=>{if(l==="move"){let c=uc(d);Ws(c!=null,"Op data is not a point"),n=c}else if(l==="bcurveTo"){let c=B(d[0],d[1]),p=B(d[2],d[3]),h=B(d[4],d[5]),m=t?t(c):c,f=t?t(p):p,g=t?t(h):h,E=t?t(n):n;n=h;let[x,y,w,M]=Fi(E,m,f,g);a.minX=Math.min(a.minX,x),a.minY=Math.min(a.minY,y),a.maxX=Math.max(a.maxX,w),a.maxY=Math.max(a.maxY,M)}return a},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[o,i,r,s]},Vs=e=>{let t=1/0,n=1/0,o=-1/0,i=-1/0;for(let[r,s]of e)t=Math.min(t,r),n=Math.min(n,s),o=Math.max(o,r),i=Math.max(i,s);return[t,n,o,i]},h0=e=>{let[t,n,o,i]=Vs(e.points),r=t+e.x,s=n+e.y,a=o+e.x,l=i+e.y;return[r,s,a,l,(r+a)/2,(s+l)/2]},m0=20,f0=15,g0=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"cardinality_many":case"cardinality_one_or_many":case"cardinality_zero_or_many":return f0;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return m0;default:return 15}},E0=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},We=(e,t,n,o,i=0)=>{if(o===null||t.length<1)return null;let r=zt(t[0]);if(r.length<1)return null;let s=n==="start"?1:r.length-1,a=r[s].data;Ws(a.length===6,"Op data length is not 6");let l=B(a[4],a[5]),d=B(a[2],a[3]),c=B(a[0],a[1]),p=r[s-1],h=B(0,0);if(p.op==="move"){let v=uc(p.data);Ws(v!=null,"Op data is not a point"),h=v}else p.op==="bcurveTo"&&(h=B(p.data[4],p.data[5]));let m=(v,W)=>Math.pow(1-v,3)*l[W]+3*v*Math.pow(1-v,2)*d[W]+3*Math.pow(v,2)*(1-v)*c[W]+h[W]*Math.pow(v,3),[f,g]=n==="start"?h:l,[E,x]=[m(.3,0),m(.3,1)],y=Math.hypot(f-E,g-x),w=(f-E)/y,M=(g-x)/y,b=g0(o),S=0;{let[v,W]=n==="end"?e.points[e.points.length-1]:e.points[0],[X,Se]=e.points.length>1?n==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];S=Math.hypot(v-X,W-Se)}let C=Math.min(b,S*(o==="diamond"||o==="diamond_outline"?.25:.5)),T=f-w*C*i,F=g-M*C*i,O=T-w*C,N=F-M*C;if(o==="circle"||o==="circle_outline"){let v=Math.hypot(N-F,O-T)+e.strokeWidth-2;return[T,F,v]}let D=E0(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[v,W]=de(B(T,F),B(O,N),_s(-D)),[X,Se]=de(B(T,F),B(O,N),_s(D));return[O,N,v,W,X,Se]}let[q,U]=de(B(O,N),B(T,F),-D*Math.PI/180),[le,H]=de(B(O,N),B(T,F),_s(D));if(o==="diamond"||o==="diamond_outline"){let v,W;if(n==="start"){let[X,Se]=e.points.length>1?e.points[1]:[0,0];[v,W]=de(B(T+C*2,F),B(T,F),Math.atan2(Se-F,X-T))}else{let[X,Se]=e.points.length>1?e.points[e.points.length-2]:[0,0];[v,W]=de(B(T-C*2,F),B(T,F),Math.atan2(F-Se,T-X))}return[T,F,q,U,v,W,le,H]}return[T,F,q,U,le,H]},x0=e=>{let t=Fn.generator(),n=Qe(e),o=e.roundness?"curve":n.fill?"polygon":"linearPath";return t[o](e.points,n)},y0=(e,t,n,o)=>{let i=J(e,o);if(e.points.length<2){let[p,h]=e.points[0],[m,f]=de(B(e.x+p,e.y+h),B(t,n),e.angle),g=[m,f,m,f];if(i){let E=G.getMinMaxXYWithBoundText(e,o,[m,f,m,f],i);g=[E[0],E[1],E[2],E[3]]}return g}let s=st.get(e,null)?.[0]??x0(e),a=zt(s),d=Vo(a,([p,h])=>de(B(e.x+p,e.y+h),B(t,n),e.angle)),c=[d[0],d[1],d[2],d[3]];if(i){let p=G.getMinMaxXYWithBoundText(e,o,c,i);c=[p[0],p[1],p[2],p[3]]}return c},Me=(e,t,n=!1)=>js.getBounds(e,t,n),_e=(e,t)=>{if(!d0(e))return[0,0,0,0];let n=1/0,o=-1/0,i=1/0,r=-1/0,s=t||cc(e);return e.forEach(a=>{let[l,d,c,p]=Me(a,s);n=Math.min(n,l),i=Math.min(i,d),o=Math.max(o,c),r=Math.max(r,p)}),[n,i,o,r]},Ab=(e,t)=>{let[n,o,i,r]=_e(e);return[n+t.x,o+t.y,i+t.x,r+t.y]},cn=(e,t,n,o)=>{if(!(ne(e)||Ce(e)))return[e.x,e.y,e.x+t,e.y+n];let i=rc(0,t,rc(1,n,e.points,o),o),r;if(Ce(e))r=Vs(i);else{let c=Fn.generator(),p=e.roundness?c.curve(i,Qe(e)):c.linearPath(i,Qe(e)),h=zt(p);r=Vo(h)}let[s,a,l,d]=r;return[s+e.x,a+e.y,l+e.x,d+e.y]},ks=(e,t)=>{let n=Fn.generator(),o=e.roundness==null?n.linearPath(t,Qe(e)):n.curve(t,Qe(e)),i=zt(o),[r,s,a,l]=Vo(i);return[r+e.x,s+e.y,a+e.x,l+e.y]},kb=(e,t)=>{if(!e.length)return[0,0,0,0];let n=1/0,o=e[0],i=cc(e);return e.forEach(r=>{let[s,a,l,d]=Me(r,i),c=c0(B((s+l)/2,(a+d)/2),B(t.x,t.y));c<n&&(n=c,o=r)}),Me(o,i)},je=e=>{let[t,n,o,i]=_e(e);return{minX:t,minY:n,maxX:o,maxY:i,width:o-t,height:i-n,midX:(t+o)/2,midY:(n+i)/2}},Tb=({scrollX:e,scrollY:t,width:n,height:o,zoom:i})=>[-e,-t,-e+n/i.value,-t+o/i.value],Ct=e=>B(e[0]+(e[2]-e[0])/2,e[1]+(e[3]-e[1])/2),ut=(e,t,n)=>{let o={minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height,midX:e.x+e.width/2,midY:e.y+e.height/2},i=ce(e,t),[r,s]=de(B(o.minX,o.minY),i,e.angle),[a,l]=de(B(o.maxX,o.minY),i,e.angle),[d,c]=de(B(o.maxX,o.maxY),i,e.angle),[p,h]=de(B(o.minX,o.maxY),i,e.angle),m=[Math.min(r,a,d,p),Math.min(s,l,c,h),Math.max(r,a,d,p),Math.max(s,l,c,h)];if(n){let[f,g,E,x]=n;return[m[0]-x,m[1]-f,m[2]+g,m[3]+E]}return m},En=(e,t)=>e[0]>t[0]&&e[0]<t[2]&&e[1]>t[1]&&e[1]<t[3],Ro=(e,t)=>{if(e==null||t==null)return!1;let[n,o,i,r]=e,[s,a,l,d]=t;return n<l&&i>s&&o<d&&r>a},ce=(e,t,n=0,o=0)=>{if(ne(e)){let[s,a,l,d]=K(e,t),[c,p]=B((s+l)/2,(a+d)/2);return B(c+n,p+o)}let[i,r]=Ct(Me(e,t));return B(i+n,r+o)};var P0=.1,hc=e=>ne(e)||Ce(e)?e.points.length<2||e.points.length===2&&V(e)&&M0(e.points[0],e.points[e.points.length-1],P0):e.width===0&&e.height===0,Wd=(e,t,n,o,i)=>{let[r,s,a,l]=Me(e,i),d=dr({clientX:o.offsetLeft,clientY:o.offsetTop},o),c=dr({clientX:o.offsetLeft+t,clientY:o.offsetTop+n},o);return d.x<=a&&d.y<=l&&c.x>=r&&c.y>=s},Fb=(e,t,n,o,i,r)=>{let[s,a,l,d]=_e(e,i),c=dr({clientX:o.offsetLeft+(r?.left||0),clientY:o.offsetTop+(r?.top||0)},o),p=dr({clientX:o.offsetLeft+t-(r?.right||0),clientY:o.offsetTop+n-(r?.bottom||0)},o);return s>=c.x&&a>=c.y&&l<=p.x&&d<=p.y},Us=(e,t,n)=>{let o=Math.abs(t),i=Math.abs(n);if(e==="line"||e==="arrow"||e==="freedraw"){let r=Math.round(Math.atan(i/o)/nn)*nn;r===0?n=0:r===Math.PI/2?t=0:n=o*Math.tan(r)*Math.sign(n)||n}else e!=="selection"&&(n=o*Math.sign(n));return{width:t,height:n}},Sd=(e,t,n,o,i)=>{let r=n-e,s=o-t,a=Math.atan2(s,r),l=Math.round(a/nn)*nn;if(i){let d=Math.floor(i/nn)*nn;w0(a,d,d+nn)&&(b0(a,i)<nn/6?l=i:pc(a)>pc(i)?l=d+nn:l=d)}if(l===0)s=0;else if(l===Math.PI/2)r=0;else{let d=Math.tan(l),c=-1,p=t-d*e,h=-1/d,m=-1,f=o-h*n,g=(c*f-m*p)/(d*m-h*c),E=(p*h-f*d)/(d*m-h*c);r=g-e,s=E-t}return{width:r,height:s}},Nb=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let n=Math.abs(e.width);t.width=n,t.x=e.x-n}if(e.height<0){let n=Math.abs(e.height);t.height=n,t.y=e.y-n}return t};I();var Vb=(e,t,n,o)=>{let i=tr(e,n.getNonDeletedElementsMap(),o),r=je(e);return i.flatMap(s=>{let a=I0(s,r,t);return s.map(l=>{let d=n.mutateElement(l,{x:l.x+a.x,y:l.y+a.y});return Re(l,n,{simultaneouslyUpdated:s}),d})})},I0=(e,t,{axis:n,position:o})=>{let i=je(e),[r,s]=n==="x"?["minX","maxX"]:["minY","maxY"],a={x:0,y:0};return o==="start"?{...a,[n]:t[r]-i[r]}:o==="end"?{...a,[n]:t[s]-i[s]}:{...a,[n]:(t[r]+t[s])/2-(i[r]+i[s])/2}};I();I();var cr=class{root;gap;constructor(t=0){this.root=null,this.gap=t}fit(t){let n=t.length,o=n>0?t[0].w:0,i=n>0?t[0].h:0;this.root={x:0,y:0,w:o,h:i};for(let r=0;r<n;r++){let s=t[r],a=this.findNode(this.root,s.w,s.h);a?s.fit=this.splitNode(a,s.w,s.h):s.fit=this.growNode(s.w,s.h)}}findNode(t,n,o){return t?t.used?this.findNode(t.right||null,n,o)||this.findNode(t.down||null,n,o):n<=t.w&&o<=t.h?t:null:null}splitNode(t,n,o){return t.used=!0,t.down={x:t.x,y:t.y+o+this.gap,w:t.w,h:t.h-o-this.gap},t.right={x:t.x+n+this.gap,y:t.y,w:t.w-n-this.gap,h:o},t}growNode(t,n){if(!this.root)return null;let o=t<=this.root.w,i=n<=this.root.h,r=i&&this.root.h>=this.root.w+t+this.gap,s=o&&this.root.w>=this.root.h+n+this.gap;return r?this.growRight(t,n):s?this.growDown(t,n):i?this.growRight(t,n):o?this.growDown(t,n):null}growRight(t,n){if(!this.root)return null;this.root={used:!0,x:0,y:0,w:this.root.w+t+this.gap,h:this.root.h,down:this.root,right:{x:this.root.w+this.gap,y:0,w:t,h:this.root.h}};let o=this.findNode(this.root,t,n);return o?this.splitNode(o,t,n):null}growDown(t,n){if(!this.root)return null;this.root={used:!0,x:0,y:0,w:this.root.w,h:this.root.h+n+this.gap,down:{x:0,y:this.root.h+this.gap,w:this.root.w,h:n},right:this.root};let o=this.findNode(this.root,t,n);return o?this.splitNode(o,t,n):null}};var S0=(e,t,n)=>{let o=je(t),i=n.x-o.minX,r=n.y-o.minY;t.forEach(s=>{e.mutateElement(s,{x:s.x+i,y:s.y+r})})},mc=(e,t,n)=>{let o=t.flatMap(d=>d.group),i=je(o),r={x:i.minX,y:i.minY},s=t.sort((d,c)=>Math.max(c.boundingBox.width,c.boundingBox.height)-Math.max(d.boundingBox.width,d.boundingBox.height)).map(d=>({w:d.boundingBox.width,h:d.boundingBox.height,group:d.group}));new cr(n).fit(s);let l=[];for(let d=0;d<s.length;d++){let c=s[d];c.fit&&l.push(c)}return l.forEach(d=>{S0(e,d.group,{x:r.x+(d.fit?.x??0),y:r.y+(d.fit?.y??0)})}),l.flatMap(d=>d.group)},Qb=(e,t,n,o,i)=>{let s=er(t,n).map(a=>({group:a,boundingBox:je(a)}));switch(o){case"bin-packing":return mc(e,s,i);default:return console.warn(`Unimplemented algorithm [${o}] - using bin-packing`),mc(e,s,i)}};I();import{arrayToMap as wf,arrayToObject as on,assertNever as Uc,isDevEnv as Cn,isShallowEqual as Yc,isTestEnv as Bn,randomInteger as Vc}from"@excalidraw/common";I();import{assertNever as R0,COLOR_PALETTE as F0,isDevEnv as N0,isTestEnv as H0,randomId as z0,Emitter as Ec,toIterable as so}from"@excalidraw/common";I();import{ORIG_ID as T0,randomId as gc,randomInteger as L0,arrayToMap as C0,castArray as Ys,findLastIndex as Ko,getUpdatedTimestamp as B0,isTestEnv as D0}from"@excalidraw/common";I();import{arrayToMapWithIndex as v0}from"@excalidraw/common";var A0=e=>{let t=e.slice(),n=new Set,o=r=>{let s=r[0]?.groupIds?.join(""),a=[r[0]],l=[];for(let d of r.slice(1))d.groupIds?.join("")===s?a.push(d):l.push(d);return l.length?[...a,...o(l)]:a},i=new Map;return t.forEach((r,s)=>{if(!i.has(r.id))if(r.groupIds?.length){let a=r.groupIds[r.groupIds.length-1],l=t.slice(s).filter(d=>{let c=d?.groupIds?.some(p=>p===a);return c&&i.set(d.id,!0),c});for(let d of o(l))n.add(d)}else n.add(r)}),n.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...n]},k0=e=>{let t=v0(e),n=e.slice(),o=new Set;return n.forEach((i,r)=>{i&&(i.boundElements?.length?(o.add(i),n[r]=null,i.boundElements.forEach(s=>{let a=t.get(s.id);a&&s.type==="text"&&(o.add(a[0]),n[a[1]]=null)})):i.type==="text"&&i.containerId&&t.get(i.containerId)?.[0].boundElements?.find(a=>a.id===i.id)||(o.add(i),n[r]=null))}),o.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...o]},fc=e=>k0(A0(e));var G0=(e,t,n,o)=>{let i=$s(n);return D0()&&O0(i,n.id),i.id=gc(),i.updated=B0(),o&&(i.seed=L0(),od(i)),i.groupIds=zd(i.groupIds,e,r=>(t.has(r)||t.set(r,gc()),t.get(r))),i},p6=e=>{let{elements:t}=e,n="appState"in e?e.appState:{editingGroupId:null,selectedGroupIds:{}},o=new Map,i=new Map,r=[],s=[],a=new Map,l=new Map,d=new Map,c=C0(t),p=e.type==="in-place"?e.idsOfElementsToDuplicate:new Map(t.map(E=>[E.id,E]));if(e.type==="in-place")for(let E of Object.keys(e.appState.selectedGroupIds))t.filter(x=>x.groupIds?.includes(E)).forEach(x=>p.set(x.id,x));t=fc(t);let h=t.slice(),m=E=>{let y=Ys(E).reduce((w,M)=>{if(o.has(M.id))return w;o.set(M.id,!0);let b=G0(n.editingGroupId,i,M,e.randomizeSeed);return o.set(b.id,!0),d.set(b.id,b),a.set(M.id,b.id),l.set(b.id,M),s.push(M),r.push(b),w.push(b),w},[]);return Array.isArray(E)?y:y[0]||null},f=(E,x)=>{if(x){if(E>h.length-1){h.push(...Ys(x));return}h.splice(E+1,0,...Ys(x))}},g=new Set(t.filter(E=>p.has(E.id)&&te(E)).map(E=>E.id));for(let E of t){if(o.has(E.id)||!p.has(E.id))continue;let x=Cs(n,E);if(x){let y=ze(t,x).flatMap(M=>te(M)?[...Sn(t,M.id),M]:[M]),w=Ko(h,M=>M.groupIds?.includes(x));f(w,m(y));continue}if(!(E.frameId&&g.has(E.frameId))){if(te(E)){let y=E.id,w=Sn(t,y),M=Ko(h,b=>b.frameId===y||b.id===y);f(M,m([...w,E]));continue}if(kt(E)){let y=J(E,c),w=Ko(h,M=>M.id===E.id||"containerId"in M&&M.containerId===E.id);y?f(w,m([E,y])):f(w,m(E));continue}if(ge(E)){let y=De(E,c),w=Ko(h,M=>M.id===E.id||M.id===y?.id);y?f(w,m([y,E])):f(w,m(E));continue}f(Ko(h,y=>y.id===E.id),m(E))}}if(pd(r,a,d),jd(h,s,a),e.overrides)for(let E of r){let x=l.get(E.id);x&&Object.assign(E,e.overrides({duplicateElement:E,origElement:x,origIdToDuplicateId:a}))}return{duplicatedElements:r,duplicateElementsMap:d,elementsWithDuplicates:h,origIdToDuplicateId:a}},Xs=(e,t=0)=>{if(e==null||typeof e!="object")return e;let n=Object.prototype.toString.call(e);if(n==="[object Object]"){let o=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let i in e)if(e.hasOwnProperty(i)){if(t===0&&(i==="shape"||i==="canvas"))continue;o[i]=Xs(e[i],t+1)}return o}if(Array.isArray(e)){let o=e.length,i=new Array(o);for(;o--;)i[o]=Xs(e[o],t+1);return i}return L.DEV&&n!=="[object Object]"&&n!=="[object Array]"&&n.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${n}. This value will not be cloned!`),e},$s=e=>Xs(e),O0=(e,t)=>{Object.defineProperty(e,T0,{value:t,writable:!1,enumerable:!1})};var Je={IMMEDIATELY:"IMMEDIATELY",NEVER:"NEVER",EVENTUALLY:"EVENTUALLY"},xc=class{constructor(t){this.app=t}onDurableIncrementEmitter=new Ec;onStoreIncrementEmitter=new Ec;scheduledMacroActions=new Set;scheduledMicroActions=[];_snapshot=Ln.empty();get snapshot(){return this._snapshot}set snapshot(t){this._snapshot=t}scheduleAction(t){this.scheduledMacroActions.add(t),this.satisfiesScheduledActionsInvariant()}scheduleCapture(){this.scheduleAction(Je.IMMEDIATELY)}scheduleMicroAction(t){let{action:n}=t,o;if("change"in t)o=t.change;else{let r=Ln.create(this.app.scene.getElementsMapIncludingDeleted(),this.app.state),s=r.maybeClone(n,t.elements?bc(t.elements):void 0,t.appState);o=Qo.create(r,s)}let i="delta"in t?t.delta:void 0;this.scheduledMicroActions.push(()=>this.processAction({action:n,change:o,delta:i}))}commit(t,n){this.flushMicroActions();try{let o=this.getScheduledMacroAction();this.processAction({action:o,elements:t,appState:n})}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledMacroActions=new Set}}clear(){this.snapshot=Ln.empty(),this.scheduledMacroActions=new Set}emitDurableIncrement(t,n=void 0,o=void 0){let i=this.snapshot,r,s;if(n?r=n:r=Qo.create(i,t),o?s=o:s=Ks.calculate(i,t),!s.isEmpty()){let a=new Zs(r,s);this.onDurableIncrementEmitter.trigger(a),this.onStoreIncrementEmitter.trigger(a)}}emitEphemeralIncrement(t,n=void 0){let o;if(n)o=n;else{let r=this.snapshot;o=Qo.create(r,t)}let i=new qs(o);this.onStoreIncrementEmitter.trigger(i)}applyChangeToSnapshot(t){let n=this.snapshot,o=this.snapshot.applyChange(t);return n===o?null:o}maybeCloneSnapshot(t,n,o){if(!n&&!o)return null;let i=this.snapshot,r=this.snapshot.maybeClone(t,n,o);return i===r?null:r}flushMicroActions(){for(let t of this.scheduledMicroActions)try{t()}catch(n){console.error("Failed to execute scheduled micro action",n)}this.scheduledMicroActions=[]}processAction(t){let{action:n}=t;if(n===Je.EVENTUALLY&&!this.onStoreIncrementEmitter.subscribers.length)return;let o;if("change"in t?o=this.applyChangeToSnapshot(t.change):o=this.maybeCloneSnapshot(n,t.elements,t.appState),!o)return;let i="change"in t?t.change:void 0,r="delta"in t?t.delta:void 0;try{switch(n){case Je.IMMEDIATELY:this.emitDurableIncrement(o,i,r);break;case Je.NEVER:case Je.EVENTUALLY:this.emitEphemeralIncrement(o,i);break;default:R0(n,"Unknown store action")}}finally{switch(n){case Je.IMMEDIATELY:case Je.NEVER:this.snapshot=o;break}}}getScheduledMacroAction(){let t;return this.scheduledMacroActions.has(Je.IMMEDIATELY)?t=Je.IMMEDIATELY:this.scheduledMacroActions.has(Je.NEVER)?t=Je.NEVER:t=Je.EVENTUALLY,t}satisfiesScheduledActionsInvariant(){if(!(this.scheduledMacroActions.size>=0&&this.scheduledMacroActions.size<=Object.keys(Je).length)){let t=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledMacroActions.size}".`;if(console.error(t,this.scheduledMacroActions.values()),H0()||N0())throw new Error(t)}}},Qo=class e{constructor(t,n){this.elements=t;this.appState=n}static create(t,n){let o=n.getChangedElements(t),i=n.getChangedAppState(t);return new e(o,i)}},ur=class{constructor(t,n){this.type=t;this.change=n}static isDurable(t){return t.type==="durable"}static isEphemeral(t){return t.type==="ephemeral"}},Zs=class extends ur{constructor(n,o){super("durable",n);this.change=n;this.delta=o}},qs=class extends ur{constructor(n){super("ephemeral",n);this.change=n}},Ks=class e{constructor(t,n,o){this.id=t;this.elements=n;this.appState=o}static create(t,n,o={id:z0()}){return new this(o.id,t,n)}static calculate(t,n){let o=n.metadata.didElementsChange?Tn.calculate(t.elements,n.elements):Tn.empty(),i=n.metadata.didAppStateChange?kn.calculate(t.appState,n.appState):kn.empty();return this.create(o,i)}static restore(t){let{id:n,elements:o,appState:i}=t;return new this(n,Tn.restore(o),kn.restore(i))}static load({id:t,elements:{added:n,removed:o,updated:i},appState:{delta:r}}){let s=Tn.create(n,o,i),a=kn.create(r);return new this(t,s,a)}static squash(...t){let n=e.empty();for(let o of t)n.elements.squash(o.elements),n.appState.squash(o.appState);return n}static inverse(t){return this.create(t.elements.inverse(),t.appState.inverse())}static applyTo(t,n,o,i){let[r,s]=t.elements.applyTo(n,Ln.empty().elements,i),[a,l]=t.appState.applyTo(o,r);return[r,a,s||l]}static applyLatestChanges(t,n,o,i){return this.create(t.elements.applyLatestChanges(n,o,i),t.appState,{id:t.id})}static empty(){return e.create(Tn.empty(),kn.empty())}isEmpty(){return this.elements.isEmpty()&&this.appState.isEmpty()}},Ln=class e{constructor(t,n,o={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=t;this.appState=n;this.metadata=o}_lastChangedElementsHash=0;_lastChangedAppStateHash=0;static create(t,n,o={didElementsChange:!1,didAppStateChange:!1}){return new e(t,yc(n)?n:ao(n),o)}static empty(){return new e(new Map,_0(),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}getChangedElements(t){let n={};for(let o of so(t.elements))this.elements.get(o.id)||(n[o.id]=Ne(o,{isDeleted:!0}));for(let o of so(this.elements))t.elements.get(o.id)!==o&&(n[o.id]=o);return n}getChangedAppState(t){return $.getRightDifferences(t.appState,this.appState).reduce((n,o)=>Object.assign(n,{[o]:this.appState[o]}),{})}isEmpty(){return this.metadata.isEmpty}applyChange(t){let n=new Map(this.elements);for(let[i,r]of Object.entries(t.elements))n.set(i,r);let o=ao({...this.appState,...t.appState});return e.create(n,o,{didElementsChange:Object.keys(t.elements).length>0,didAppStateChange:Object.keys(t.appState).length>0})}maybeClone(t,n,o){let i={shouldCompareHashes:!1};t===Je.EVENTUALLY&&(i.shouldCompareHashes=!0);let r=this.maybeCreateElementsSnapshot(n,i),s=this.maybeCreateAppStateSnapshot(o,i),a=!1,l=!1;return this.elements!==r&&(a=!0),this.appState!==s&&(l=!0),!a&&!l?this:new e(r,s,{didElementsChange:a,didAppStateChange:l})}maybeCreateAppStateSnapshot(t,n={shouldCompareHashes:!1}){if(!t)return this.appState;let o=yc(t)?t:ao(t);return this.detectChangedAppState(o,n)?o:this.appState}maybeCreateElementsSnapshot(t,n={shouldCompareHashes:!1}){if(!t)return this.elements;let o=this.detectChangedElements(t,n);return o?.size?this.createElementsSnapshot(o):this.elements}detectChangedAppState(t,n={shouldCompareHashes:!1}){if(this.appState===t)return;let o=$.isRightDifferent(this.appState,t);if(!o)return;let i=Pc(JSON.stringify(t));if(!(n.shouldCompareHashes&&this._lastChangedAppStateHash===i))return this._lastChangedAppStateHash=i,o}detectChangedElements(t,n={shouldCompareHashes:!1}){if(this.elements===t)return;let o=new Map;for(let r of so(this.elements))t.get(r.id)||o.set(r.id,Ne(r,{isDeleted:!0}));for(let r of so(t)){let s=this.elements.get(r.id);if(!s||s.version<r.version){if(ve(r)&&!Nn(r))continue;o.set(r.id,r)}}if(!o.size)return;let i=Mc(o);if(!(n.shouldCompareHashes&&this._lastChangedElementsHash===i))return this._lastChangedElementsHash=i,o}createElementsSnapshot(t){let n=new Map;for(let o of so(this.elements))n.set(o.id,o);for(let o of so(t))n.set(o.id,$s(o));return n}},wc="__observedAppState",_0=()=>({name:null,editingGroupId:null,viewBackgroundColor:F0.white,selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null,croppingElementId:null,activeLockedId:null,lockedMultiSelections:{}}),ao=e=>{let t={name:e.name,editingGroupId:e.editingGroupId,viewBackgroundColor:e.viewBackgroundColor,selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,croppingElementId:e.croppingElementId,activeLockedId:e.activeLockedId,lockedMultiSelections:e.lockedMultiSelections,selectedLinearElement:e.selectedLinearElement?{elementId:e.selectedLinearElement.elementId,isEditing:!!e.selectedLinearElement.isEditing}:null};return Reflect.defineProperty(t,wc,{value:!0,enumerable:!1}),t},yc=e=>!!Reflect.get(e,wc);I();I();var vc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function co(e,t,n){let o=n[0];if(t!=null&&e>=t)throw new Error(e+" >= "+t);if(e.slice(-1)===o||t&&t.slice(-1)===o)throw new Error("trailing zero");if(t){let s=0;for(;(e[s]||o)===t[s];)s++;if(s>0)return t.slice(0,s)+co(e.slice(s),t.slice(s),n)}let i=e?n.indexOf(e[0]):0,r=t!=null?n.indexOf(t[0]):n.length;if(r-i>1){let s=Math.round(.5*(i+r));return n[s]}else return t&&t.length>1?t.slice(0,1):n[i]+co(e.slice(1),null,n)}function Ac(e){if(e.length!==kc(e[0]))throw new Error("invalid integer part of order key: "+e)}function kc(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw new Error("invalid order key head: "+e)}function Jo(e){let t=kc(e[0]);if(t>e.length)throw new Error("invalid order key: "+e);return e.slice(0,t)}function Ic(e,t){if(e==="A"+t[0].repeat(26))throw new Error("invalid order key: "+e);let n=Jo(e);if(e.slice(n.length).slice(-1)===t[0])throw new Error("invalid order key: "+e)}function Sc(e,t){Ac(e);let[n,...o]=e.split(""),i=!0;for(let r=o.length-1;i&&r>=0;r--){let s=t.indexOf(o[r])+1;s===t.length?o[r]=t[0]:(o[r]=t[s],i=!1)}if(i){if(n==="Z")return"a"+t[0];if(n==="z")return null;let r=String.fromCharCode(n.charCodeAt(0)+1);return r>"a"?o.push(t[0]):o.pop(),r+o.join("")}else return n+o.join("")}function W0(e,t){Ac(e);let[n,...o]=e.split(""),i=!0;for(let r=o.length-1;i&&r>=0;r--){let s=t.indexOf(o[r])-1;s===-1?o[r]=t.slice(-1):(o[r]=t[s],i=!1)}if(i){if(n==="a")return"Z"+t.slice(-1);if(n==="A")return null;let r=String.fromCharCode(n.charCodeAt(0)-1);return r<"Z"?o.push(t.slice(-1)):o.pop(),r+o.join("")}else return n+o.join("")}function lo(e,t,n=vc){if(e!=null&&Ic(e,n),t!=null&&Ic(t,n),e!=null&&t!=null&&e>=t)throw new Error(e+" >= "+t);if(e==null){if(t==null)return"a"+n[0];let l=Jo(t),d=t.slice(l.length);if(l==="A"+n[0].repeat(26))return l+co("",d,n);if(l<t)return l;let c=W0(l,n);if(c==null)throw new Error("cannot decrement any more");return c}if(t==null){let l=Jo(e),d=e.slice(l.length),c=Sc(l,n);return c??l+co(d,null,n)}let o=Jo(e),i=e.slice(o.length),r=Jo(t),s=t.slice(r.length);if(o===r)return o+co(i,s,n);let a=Sc(o,n);if(a==null)throw new Error("cannot increment any more");return a<t?a:o+co(i,null,n)}function pr(e,t,n,o=vc){if(n===0)return[];if(n===1)return[lo(e,t,o)];if(t==null){let s=lo(e,t,o),a=[s];for(let l=0;l<n-1;l++)s=lo(s,t,o),a.push(s);return a}if(e==null){let s=lo(e,t,o),a=[s];for(let l=0;l<n-1;l++)s=lo(e,s,o),a.push(s);return a.reverse(),a}let i=Math.floor(n/2),r=lo(e,t,o);return[...pr(e,r,i,o),r,...pr(r,t,n-i-1,o)]}import{arrayToMap as hr}from"@excalidraw/common";var Qs=class extends Error{code="ELEMENT_HAS_INVALID_INDEX"},j0=(e,{shouldThrow:t=!1,includeBoundTextValidation:n=!1,ignoreLogs:o,reconciliationContext:i})=>{let r=[],s=l=>`${l?.index}:${l?.id}:${l?.type}:${l?.isDeleted}:${l?.version}:${l?.versionNonce}`,a=e.map(l=>l.index);for(let[l,d]of a.entries()){let c=a[l-1],p=a[l+1];if(Js(d,c,p)||r.push(`Fractional indices invariant has been compromised: "${s(e[l-1])}", "${s(e[l])}", "${s(e[l+1])}"`),n&&kt(e[l])){let h=e[l],m=J(h,hr(e));m&&m.index<=h.index&&r.push(`Fractional indices invariant for bound elements has been compromised: "${s(m)}", "${s(h)}"`)}}if(r.length){let l=new Qs,d=[];if(i&&(d.push("Additional reconciliation context:"),d.push(i.localElements.map(c=>s(c))),d.push(i.remoteElements.map(c=>s(c)))),o||console.error(r.join(`
19
20
 
20
- `),l.stack,e.map(c=>s(c)),...d),t)throw l}},zd=e=>e.sort((t,n)=>Nd(t)&&Nd(n)?t.index<n.index?-1:t.index>n.index?1:t.id<n.id?-1:1:1),Oi=(e,t)=>{try{let n=Vo(e),i=hh(e,t),o=Ds(e,i),r=e.map(s=>{let a=o.get(s);return a?{...s,index:a.index}:s});fh(r,{includeBoundTextValidation:!1,shouldThrow:!0,ignoreLogs:!0});for(let[s,{index:a}]of o)ye(s,n,{index:a})}catch{vs(e)}return e},vs=e=>{let t=Vo(e),n=Hd(e),i=Ds(e,n);for(let[o,{index:r}]of i)ye(o,t,{index:r});return e},Ld=e=>{let t=Vo(e),n=Hd(e),i=Ds(e,n);for(let[o,{index:r}]of i)t.set(o.id,ge(o,{index:r}));return t},hh=(e,t)=>{let n=[],i=0;for(;i<e.length;)if(t.has(e[i].id)){let o=[i-1,i];for(;++i<e.length&&t.has(e[i].id);)o.push(i);o.push(i),n.push(o)}else i++;return n},Hd=e=>{let t=[],n,i,o=-1,r=0,s=d=>{let c=e[o]?e[o].index:void 0,u=e[d-1]?.index;return!c&&u||c&&u&&u>c?[u,d-1]:[c,o]},a=d=>{let c=e[r]?e[r].index:void 0;if(c&&d<r)return[c,r];let u=r;for(;++u<e.length;){let m=e[u]?.index;if(!c&&m||c&&m&&m>c)return[m,u]}return[void 0,u]},l=0;for(;l<e.length;){let d=e[l].index;if([n,o]=s(l),[i,r]=a(l),Ts(d,n,i))l++;else{let c=[o,l];for(;++l<e.length;){let u=e[l].index,[m,p]=s(l),[f,h]=a(l);if(Ts(u,m,f))break;[n,o]=[m,p],[i,r]=[f,h],c.push(l)}c.push(r),t.push(c)}}return t},Ts=(e,t,n)=>e?t&&n?t<e&&e<n:!t&&n?e<n:t&&!n?t<e:!!e:!1,Ds=(e,t)=>{let n=new Map;for(let i of t){let o=i.shift(),r=i.pop(),s=jo(e[o]?.index,e[r]?.index,i.length);for(let a=0;a<i.length;a++){let l=e[i[a]];n.set(l,{index:s[a]})}}return n},Nd=e=>!!e.index;P();var Qd=$c(Xd(),1);import{randomInteger as Gh,arrayToMap as jd,toBrandedType as Vd,isDevEnv as $d,isTestEnv as Zd,toArray as Oh}from"@excalidraw/common";import{isNonDeletedElement as kh}from"@excalidraw/element";import{isFrameLikeElement as Rh}from"@excalidraw/element";import{getElementsInGroup as Fh}from"@excalidraw/element";import{syncInvalidIndices as Nh,syncMovedIndices as qd,validateFractionalIndices as zh}from"@excalidraw/element";import{getSelectedElements as Hh}from"@excalidraw/element";import{mutateElement as _h}from"@excalidraw/element";var Kd=e=>{let t=new Map,n=[];for(let i of e)i.isDeleted||(n.push(i),t.set(i.id,i));return{elementsMap:t,elements:n}},Uh=(0,Qd.default)(e=>{($d()||Zd()||window?.DEBUG_FRACTIONAL_INDICES)&&zh(e,{shouldThrow:$d()||Zd(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1}),Yh=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],n="";for(let i of t)n+=`${i}:${e[i]?"1":"0"}`;return n},$n=class{callbacks=new Set;nonDeletedElements=[];nonDeletedElementsMap=Vd(new Map);elements=[];nonDeletedFramesLikes=[];frames=[];elementsMap=Vd(new Map);selectedElementsCache={selectedElementIds:null,elements:null,cache:new Map};sceneNonce;getSceneNonce(){return this.sceneNonce}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}constructor(t=null,n){t&&this.replaceAllElements(t,n)}getSelectedElements(t){let n=Yh(t),i=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===i&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let r=this.selectedElementsCache.cache.get(n);if(r)return r}else t?.elements==null&&this.selectedElementsCache.cache.clear();let o=Hh(i,{selectedElementIds:t.selectedElementIds},t);return t?.elements==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(n,o)),o}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getNonDeletedElement(t){let n=this.getElement(t);return n&&kh(n)?n:null}mapElements(t){let n=!1,i=this.elements.map(o=>{let r=t(o);return r!==o&&(n=!0),r});return n&&this.replaceAllElements(i),n}replaceAllElements(t,n){let i=Oh(t),o=[];n?.skipValidation||Uh(i),this.elements=Nh(i),this.elementsMap.clear(),this.elements.forEach(s=>{Rh(s)&&o.push(s),this.elementsMap.set(s.id,s)});let r=Kd(this.elements);this.nonDeletedElements=r.elements,this.nonDeletedElementsMap=r.elementsMap,this.frames=o,this.nonDeletedFramesLikes=Kd(this.frames).elements,this.triggerUpdate()}triggerUpdate(){this.sceneNonce=Gh();for(let t of Array.from(this.callbacks))t()}onUpdate(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),this.callbacks.clear()}insertElementAtIndex(t,n){if(!Number.isFinite(n)||n<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let i=[...this.elements.slice(0,n),t,...this.elements.slice(n)];qd(i,jd([t])),this.replaceAllElements(i)}insertElementsAtIndex(t,n){if(!t.length)return;if(!Number.isFinite(n)||n<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let i=[...this.elements.slice(0,n),...t,...this.elements.slice(n)];qd(i,jd(t)),this.replaceAllElements(i)}insertElement=t=>{let n=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,n)};insertElements=t=>{if(!t.length)return;let n=t[0]?.frameId?this.getElementIndex(t[0].frameId):this.elements.length;this.insertElementsAtIndex(t,n)};getElementIndex(t){return this.elements.findIndex(n=>n.id===t)}getContainerElement=t=>t&&t.containerId&&this.getElement(t.containerId)||null;getElementsFromId=t=>{let n=this.getNonDeletedElementsMap(),i=n.get(t);return i?[i]:Fh(n,t)};mutateElement(t,n,i={informMutation:!0,isDragging:!1}){let o=this.getNonDeletedElementsMap(),{version:r}=t,{version:s}=_h(t,o,n,i);return this.elementsMap.has(t.id)&&r!==s&&i.informMutation&&this.triggerUpdate(),t}};var _=class e{constructor(t,n){this.deleted=t;this.inserted=n}static create(t,n,i,o){let r=i&&o!=="inserted"?i(t,"deleted"):t,s=i&&o!=="deleted"?i(n,"inserted"):n;return new e(r,s)}static calculate(t,n,i,o){if(t===n)return e.empty();let r={},s={};for(let d of this.getDifferences(t,n))r[d]=t[d],s[d]=n[d];let[a,l]=o?o(r,s):[r,s];return e.create(a,l,i)}static empty(){return new e({},{})}static isEmpty(t){return!Object.keys(t.deleted).length&&!Object.keys(t.inserted).length}static merge(t,n,i=e.empty()){return e.create({...t.deleted,...n.deleted,...i.deleted},{...t.inserted,...n.inserted,...i.inserted})}static mergeObjects(t,n,i={}){let o={...t};for(let r of Object.keys(i))delete o[r];return{...o,...n}}static mergeArrays(t,n,i,o){return Object.values(e.mergeObjects(zt(t??[],o),zt(n??[],o),zt(i??[],o)))}static diffObjects(t,n,i,o){if(!t[i]&&!n[i])return;let r=t[i]!==null&&typeof t[i]=="object",s=n[i]!==null&&typeof n[i]=="object";if(r||s){let a=t[i]??{},l=n[i]??{},d=e.getLeftDifferences(a,l).reduce((u,m)=>(u[m]=o(a[m]),u),{}),c=e.getRightDifferences(a,l).reduce((u,m)=>(u[m]=o(l[m]),u),{});Object.keys(d).length||Object.keys(c).length?(Reflect.set(t,i,d),Reflect.set(n,i,c)):(Reflect.deleteProperty(t,i),Reflect.deleteProperty(n,i))}else t[i]===n[i]&&(Reflect.deleteProperty(t,i),Reflect.deleteProperty(n,i))}static diffArrays(t,n,i,o){if(!(!t[i]&&!n[i])&&(Array.isArray(t[i])||Array.isArray(n[i]))){let r=Array.isArray(t[i])?t[i]:[],s=Array.isArray(n[i])?n[i]:[],a=zt(e.getLeftDifferences(zt(r,o),zt(s,o)),d=>d),l=zt(e.getRightDifferences(zt(r,o),zt(s,o)),d=>d);if(Object.keys(a).length||Object.keys(l).length){let d=r.filter(u=>a[o?o(u):String(u)]),c=s.filter(u=>l[o?o(u):String(u)]);Reflect.set(t,i,d),Reflect.set(n,i,c)}else Reflect.deleteProperty(t,i),Reflect.deleteProperty(n,i)}}static isLeftDifferent(t,n,i=!1){return!!this.distinctKeysIterator("left",t,n,i).next().value}static isRightDifferent(t,n,i=!1){return!!this.distinctKeysIterator("right",t,n,i).next().value}static isInnerDifferent(t,n,i=!1){return!!!!this.distinctKeysIterator("inner",t,n,i).next().value}static isDifferent(t,n,i=!1){return!!!!this.distinctKeysIterator("full",t,n,i).next().value}static getLeftDifferences(t,n,i=!1){return Array.from(this.distinctKeysIterator("left",t,n,i)).sort()}static getRightDifferences(t,n,i=!1){return Array.from(this.distinctKeysIterator("right",t,n,i)).sort()}static getInnerDifferences(t,n,i=!1){return Array.from(this.distinctKeysIterator("inner",t,n,i)).sort()}static getDifferences(t,n,i=!1){return Array.from(this.distinctKeysIterator("full",t,n,i)).sort()}static*distinctKeysIterator(t,n,i,o=!1){if(n===i)return;let r=[];t==="left"?r=Object.keys(n):t==="right"?r=Object.keys(i):t==="inner"?r=Object.keys(n).filter(s=>s in i):t==="full"?r=Array.from(new Set([...Object.keys(n),...Object.keys(i)])):ec(t,`Unknown distinctKeysIterator's join param "${t}"`,!0);for(let s of r){let a=n[s],l=i[s];if(a!==l){if(!o&&typeof a=="object"&&typeof l=="object"&&a!==null&&l!==null&&tc(a,l))continue;yield s}}}},cn=class e{constructor(t){this.delta=t}static create(t){return new e(t)}static calculate(t,n){let i=_.calculate(t,n,e.orderAppStateKeys,e.postProcess);return new e(i)}static restore(t){let{delta:n}=t;return new e(n)}static empty(){return new e(_.create({},{}))}inverse(){let t=_.create(this.delta.inserted,this.delta.deleted);return new e(t)}squash(t){if(t.isEmpty())return this;let n=_.mergeObjects(this.delta.deleted.selectedElementIds??{},t.delta.deleted.selectedElementIds??{}),i=_.mergeObjects(this.delta.inserted.selectedElementIds??{},t.delta.inserted.selectedElementIds??{}),o=_.mergeObjects(this.delta.deleted.selectedGroupIds??{},t.delta.deleted.selectedGroupIds??{}),r=_.mergeObjects(this.delta.inserted.selectedGroupIds??{},t.delta.inserted.selectedGroupIds??{}),s=_.mergeObjects(this.delta.deleted.lockedMultiSelections??{},t.delta.deleted.lockedMultiSelections??{}),a=_.mergeObjects(this.delta.inserted.lockedMultiSelections??{},t.delta.inserted.lockedMultiSelections??{}),l={},d={};return(Object.keys(n).length||Object.keys(i).length)&&(d.selectedElementIds=n,l.selectedElementIds=i),(Object.keys(o).length||Object.keys(r).length)&&(d.selectedGroupIds=o,l.selectedGroupIds=r),(Object.keys(s).length||Object.keys(a).length)&&(d.lockedMultiSelections=s,l.lockedMultiSelections=a),this.delta=_.merge(this.delta,t.delta,_.create(d,l)),this}applyTo(t,n){try{let{selectedElementIds:i={},selectedGroupIds:o={},lockedMultiSelections:r={}}=this.delta.deleted,{selectedElementIds:s={},selectedGroupIds:a={},lockedMultiSelections:l={},selectedLinearElement:d,...c}=this.delta.inserted,u=_.mergeObjects(t.selectedElementIds,s,i),m=_.mergeObjects(t.selectedGroupIds,a,o),p=_.mergeObjects(t.lockedMultiSelections,l,r),f=d&&n.has(d.elementId)?new O(n.get(d.elementId),n,d.isEditing):null,h={...t,...c,selectedElementIds:u,selectedGroupIds:m,lockedMultiSelections:p,selectedLinearElement:typeof d<"u"?f:t.selectedLinearElement},E=this.filterInvisibleChanges(t,h,n);return[h,E]}catch(i){if(console.error("Couldn't apply appstate change",i),fn()||pn())throw i;return[t,!1]}}isEmpty(){return _.isEmpty(this.delta)}filterInvisibleChanges(t,n,i){let o=Xn(t),r=Xn(n),s=_.isRightDifferent(e.stripElementsProps(o),e.stripElementsProps(r)),a=_.isRightDifferent(e.stripStandaloneProps(o),e.stripStandaloneProps(r));if(!s&&!a)return!1;let l={value:s};if(a){let d=_.getRightDifferences(e.stripStandaloneProps(o),e.stripStandaloneProps(r)),c=new Set;(d.includes("editingGroupId")||d.includes("selectedGroupIds"))&&(c=Xl(i));for(let u of d)switch(u){case"selectedElementIds":n[u]=e.filterSelectedElements(n[u],i,l);break;case"selectedGroupIds":n[u]=e.filterSelectedGroups(n[u],c,l);break;case"croppingElementId":{let x=n[u];if(!x)l.value=!0;else{let w=i.get(x);w&&!w.isDeleted?l.value=!0:n[u]=null}break}case"editingGroupId":let m=n[u];m?c.has(m)?l.value=!0:n[u]=null:l.value=!0;break;case"selectedLinearElement":let p=n[u];if(!p)l.value=!0;else{let x=i.get(p.elementId);x&&!x.isDeleted?l.value=!0:n[u]=null}break;case"lockedMultiSelections":let f=t[u]||{},h=n[u]||{};tc(f,h)||(l.value=!0);break;case"activeLockedId":let E=t[u]||null,g=n[u]||null;E!==g&&(l.value=!0);break;default:ec(u,`Unknown ObservedElementsAppState's key "${u}"`,!0)}}return l.value}static filterSelectedElements(t,n,i){let o=Object.keys(t);if(!o.length)return i.value=!0,t;let r={...t};for(let s of o){let a=n.get(s);a&&!a.isDeleted?i.value=!0:delete r[s]}return r}static filterSelectedGroups(t,n,i){if(!Object.keys(t).length)return i.value=!0,t;let r={...t};for(let s of Object.keys(r))n.has(s)?i.value=!0:delete r[s];return r}static stripElementsProps(t){let{editingGroupId:n,selectedGroupIds:i,selectedElementIds:o,selectedLinearElement:r,croppingElementId:s,lockedMultiSelections:a,activeLockedId:l,...d}=t;return d}static stripStandaloneProps(t){let{name:n,viewBackgroundColor:i,...o}=t;return o}static postProcess(t,n){try{_.diffObjects(t,n,"selectedElementIds",i=>!0),_.diffObjects(t,n,"selectedGroupIds",i=>i??!1),_.diffObjects(t,n,"lockedMultiSelections",i=>i??{})}catch(i){if(console.error("Couldn't postprocess appstate change deltas."),fn()||pn())throw i}finally{return[t,n]}}static orderAppStateKeys(t){let n={};for(let i of Object.keys(t).sort())n[i]=t[i];return n}},un=class e{constructor(t,n,i){this.added=t;this.removed=n;this.updated=i}static create(t,n,i,o={shouldRedistribute:!1}){let r;if(o.shouldRedistribute){let s={},a={},l={},d=[...Object.entries(t),...Object.entries(n),...Object.entries(i)];for(let[c,u]of d)this.satisfiesAddition(u)?s[c]=u:this.satisfiesRemoval(u)?a[c]=u:l[c]=u;r=new e(s,a,l)}else r=new e(t,n,i);return(fn()||pn())&&(e.validate(r,"added",this.satisfiesAddition),e.validate(r,"removed",this.satisfiesRemoval),e.validate(r,"updated",this.satisfiesUpdate)),r}static restore(t){let{added:n,removed:i,updated:o}=t;return e.create(n,i,o)}static satisfiesAddition=({deleted:t,inserted:n})=>t.isDeleted===!0&&!n.isDeleted;static satisfiesRemoval=({deleted:t,inserted:n})=>!t.isDeleted&&n.isDeleted===!0;static satisfiesUpdate=({deleted:t,inserted:n})=>!!t.isDeleted==!!n.isDeleted;static satisfiesCommmonInvariants=({deleted:t,inserted:n})=>!!(Number.isInteger(t.version)&&Number.isInteger(n.version)&&t.version>=0&&n.version>=0&&t.version!==n.version);static satisfiesUniqueInvariants=(t,n)=>{let{added:i,removed:o,updated:r}=t;return[i[n],o[n],r[n]].filter(Boolean).length===1};static validate(t,n,i){for(let[o,r]of Object.entries(t[n]))if(!this.satisfiesCommmonInvariants(r)||!this.satisfiesUniqueInvariants(t,o)||!i(r))throw console.error(`Broken invariant for "${n}" delta, element "${o}", delta:`,r),new Error(`ElementsDelta invariant broken for element "${o}".`)}static calculate(t,n){if(t===n)return e.empty();let i={},o={},r={};for(let s of t.values())if(!n.get(s.id)){let l={...s},d={isDeleted:!0,version:s.version+1,versionNonce:Jd()},c=_.create(l,d,e.stripIrrelevantProps);s.isDeleted?r[s.id]=c:o[s.id]=c}for(let s of n.values()){let a=t.get(s.id);if(!a){let l={isDeleted:!0,version:s.version-1,versionNonce:Jd()},d={...s},c=_.create(l,d,e.stripIrrelevantProps);s.isDeleted?r[s.id]=c:i[s.id]=c;continue}if(a.versionNonce!==s.versionNonce){let l=_.calculate(a,s,e.stripIrrelevantProps,e.postProcess);if(typeof a.isDeleted=="boolean"&&typeof s.isDeleted=="boolean"&&a.isDeleted!==s.isDeleted){a.isDeleted&&!s.isDeleted?i[s.id]=l:o[s.id]=l;continue}r[s.id]=l}}return e.create(i,o,r)}static empty(){return e.create({},{},{})}inverse(){let t=r=>{let s={};for(let[a,{inserted:l,deleted:d}]of Object.entries(r))s[a]=_.create({...l},{...d});return s},n=t(this.added),i=t(this.removed),o=t(this.updated);return e.create(i,n,o)}isEmpty(){return Object.keys(this.added).length===0&&Object.keys(this.removed).length===0&&Object.keys(this.updated).length===0}applyLatestChanges(t,n,i){let o=(d,c)=>(u,m)=>{let p;switch(m){case"deleted":p=d;break;case"inserted":p=c;break}if(!p)return console.error("Element not found when trying to apply latest changes"),u;let f={};for(let h of Object.keys(u))switch(h){case"boundElements":f[h]=u[h];break;default:f[h]=p[h]}return f},r=d=>{let c={};for(let[u,m]of Object.entries(d)){let p=t.get(u),f=n.get(u),h=null;p||f?h=_.create(m.deleted,m.inserted,o(p,f),i):h=m,_.isInnerDifferent(h.deleted,h.inserted)&&(c[u]=h)}return c},s=r(this.added),a=r(this.removed),l=r(this.updated);return e.create(s,a,l,{shouldRedistribute:!0})}applyTo(t,n=mn.empty().elements,i){let o=new Map(t),r,s={containsVisibleDifference:!1,containsZindexDifference:!1,applyDirection:void 0};try{let a=e.createApplier(t,o,n,s,i),l=a(this.added),d=a(this.removed),c=a(this.updated),u=this.resolveConflicts(t,o,s.applyDirection);r=new Map([...l,...d,...c,...u])}catch(a){if(console.error("Couldn't apply elements delta",a),fn()||pn())throw a;return[t,!0]}try{o=e.reorderElements(o,r,s),e.redrawElements(o,r)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),fn()||pn())throw a}finally{return[o,s.containsVisibleDifference]}}squash(t){if(t.isEmpty())return this;let{added:n,removed:i,updated:o}=t,r=(s,a)=>{let l=_.mergeArrays(s.deleted.boundElements??[],a.deleted.boundElements??[],void 0,c=>c.id)??[],d=_.mergeArrays(s.inserted.boundElements??[],a.inserted.boundElements??[],void 0,c=>c.id)??[];if(!(!l.length&&!d.length))return _.create({boundElements:l},{boundElements:d})};for(let[s,a]of Object.entries(n)){let l=this.added[s]??this.removed[s]??this.updated[s];if(!l)this.added[s]=a;else{let d=r(l,a);delete this.removed[s],delete this.updated[s],this.added[s]=_.merge(l,a,d)}}for(let[s,a]of Object.entries(i)){let l=this.added[s]??this.removed[s]??this.updated[s];if(!l)this.removed[s]=a;else{let d=r(l,a);delete this.added[s],delete this.updated[s],this.removed[s]=_.merge(l,a,d)}}for(let[s,a]of Object.entries(o)){let l=this.added[s]??this.removed[s]??this.updated[s];if(!l)this.updated[s]=a;else{let d=r(l,a),c=_.merge(l,a,d);l===this.added[s]?this.added[s]=c:l===this.removed[s]?this.removed[s]=c:this.updated[s]=c}}return(fn()||pn())&&(e.validate(this,"added",e.satisfiesAddition),e.validate(this,"removed",e.satisfiesRemoval),e.validate(this,"updated",e.satisfiesUpdate)),this}static createApplier=(t,n,i,o,r)=>s=>{let a=e.createGetter(n,i,o);return Object.entries(s).reduce((l,[d,c])=>{let u=a(d,c.inserted);if(u){let m=e.applyDelta(u,c,o,r);if(n.set(m.id,m),l.set(m.id,m),!o.applyDirection){let p=t.get(d);p&&(o.applyDirection=p.version>m.version?"backward":"forward")}}return l},new Map)};static createGetter=(t,n,i)=>(o,r)=>{let s=t.get(o);return s||(s=n.get(o),s?(i.containsZindexDifference=!0,(!r.isDeleted||r.isDeleted&&!s.isDeleted)&&(i.containsVisibleDifference=!0)):s=ge({id:o,version:1},{...r})),s};static applyDelta(t,n,i,o){let r={};for(let s of Object.keys(n.inserted)){if(s==="boundElements"||o?.excludedProperties?.has(s))continue;let a=n.inserted[s];Reflect.set(r,s,a)}if(n.deleted.boundElements?.length||n.inserted.boundElements?.length){let s=_.mergeArrays(t.boundElements,n.inserted.boundElements,n.deleted.boundElements,a=>a.id);Object.assign(r,{boundElements:s})}if(!i.containsVisibleDifference){let{index:s,...a}=r,l=e.checkForVisibleDifference(t,a);i.containsVisibleDifference=l}return i.containsZindexDifference||(i.containsZindexDifference=n.deleted.index!==n.inserted.index),ge(t,r,!0)}static checkForVisibleDifference(t,n){return t.isDeleted&&n.isDeleted!==!1?!1:t.isDeleted&&n.isDeleted===!1||t.isDeleted===!1&&n.isDeleted?!0:_.isRightDifferent(t,n)}resolveConflicts(t,n,i="forward"){let o=new Map,r=(a,l)=>{let d=n.get(a.id);if(!d)return;let c=t.get(a.id),u=i==="forward"?d.version+1:d.version-1,m=l,p;c===d?p=ge(d,{...m,version:u},!0):p=ye(d,n,{...m,version:c?.version!==d.version?d.version:u}),o.set(p.id,p),n.set(p.id,p)};for(let a of Object.keys(this.removed))e.unbindAffected(t,n,a,r);for(let a of Object.keys(this.added))e.rebindAffected(t,n,a,r);for(let[a]of Array.from(Object.entries(this.updated)).filter(([l,d])=>Object.keys({...d.deleted,...d.inserted}).find(c=>bl.has(c)))){let l=n.get(a);!l||l.isDeleted||e.rebindAffected(t,n,a,r)}let s=new Map(Array.from(t).filter(([a])=>o.has(a)));return this.squash(e.calculate(s,o)),o}static unbindAffected(t,n,i,o){let r=()=>t.get(i),s=()=>n.get(i);nn.unbindAffected(n,r(),o),nn.unbindAffected(n,s(),o),on.unbindAffected(n,r(),o),on.unbindAffected(n,s(),o)}static rebindAffected(t,n,i,o){let r=()=>t.get(i),s=()=>n.get(i);nn.unbindAffected(n,r(),o),nn.rebindAffected(n,s(),o),on.unbindAffected(n,r(),(a,l)=>{ee(a)&&o(a,l)}),on.rebindAffected(n,s(),o)}static redrawElements(t,n){try{let i=new $n(t,{skipValidation:!0});e.redrawTextBoundingBoxes(i,n),e.redrawBoundArrows(i,n)}catch(i){if(console.error("Couldn't redraw elements",i),fn()||pn())throw i}finally{return t}}static redrawTextBoundingBoxes(t,n){let i=t.getNonDeletedElementsMap(),o=new Map;for(let r of n.values()){if(ce(r)){let{containerId:s}=r,a=s?i.get(s):void 0;a&&o.set(a.id,{container:a,boundText:r})}if(ct(r)){let s=Dt(r),a=s?i.get(s):void 0;a&&o.set(r.id,{container:r,boundText:a})}}for(let{container:r,boundText:s}of o.values())r.isDeleted||s.isDeleted||po(s,r,t)}static redrawBoundArrows(t,n){for(let i of n.values())!i.isDeleted&&Ge(i)&&je(i,t,{changedElements:n})}static reorderElements(t,n,i){if(!i.containsZindexDifference)return t;let o=Array.from(t.values()),r=zd([...o]),s=_.getRightDifferences(o,r,!0).reduce((a,l)=>{let d=o[Number(l)];return d&&n.has(d.id)&&a.set(d.id,d),a},new Map);return!i.containsVisibleDifference&&s.size&&(i.containsVisibleDifference=!0),Wh(Oi(r,s))}static postProcess(t,n){try{_.diffArrays(t,n,"boundElements",r=>r.id);let i=t.points??[],o=n.points??[];_.isDifferent(i,o)||(Reflect.deleteProperty(t,"points"),Reflect.deleteProperty(n,"points"))}catch(i){if(console.error("Couldn't postprocess elements delta."),fn()||pn())throw i}finally{return[t,n]}}static stripIrrelevantProps(t){let{id:n,updated:i,...o}=t;return o}};P();var oI=(e,t,n,i)=>{let[o,r,s,a]=n.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],l=Le(e),d=ko(e,t,i).map(p=>[p,Le(p)]).sort((p,f)=>p[1][r]-f[1][r]),c=0;for(let p of d)c+=p[1][a];let u=(l[a]-c)/(d.length-1);if(u<0){let p=d.findIndex(g=>g[1][o]===l[o]),f=d.findIndex(g=>g[1][s]===l[s]),h=(d[f][1][r]-d[p][1][r])/(d.length-1),E=d[p][1][r];return d.flatMap(([g,x],w)=>{let b={x:0,y:0};return w!==p&&w!==f&&(E+=h,b[n.axis]=E-x[r]),g.map(y=>ge(y,{x:y.x+b.x,y:y.y+b.y}))})}let m=l[o];return d.flatMap(([p,f])=>{let h={x:0,y:0};return h[n.axis]=m-f[o],m+=u,m+=f[a],p.map(E=>ge(E,{x:E.x+h.x,y:E.y+h.y}))})};P();import{TEXT_AUTOWRAP_THRESHOLD as Xh,getGridPoint as jh,getFontString as Vh,DRAGGING_THRESHOLD as $h}from"@excalidraw/common";var fI=(e,t,n,i,o,r)=>{if(t.length===1&&W(t[0])&&(t[0].startBinding||t[0].endBinding))return;let s=t.filter(m=>{if(W(m)&&m.startBinding&&m.endBinding){let p=t.find(h=>h.id===m.startBinding?.elementId),f=t.find(h=>h.id===m.endBinding?.elementId);return p&&f}return!0}),a=new Set(s),l=s.filter(m=>K(m)).map(m=>m.id);if(l.length>0)for(let m of i.getNonDeletedElements())m.frameId!==null&&l.includes(m.frameId)&&a.add(m);let d=[];for(let m of a){let p=e.originalElements.get(m.id);if(!p)return;d.push(p)}let c=Zh(De(d),n,o,r),u=new Set(Array.from(a,m=>m.id));a.forEach(m=>{let p=!z(m),f=p||(m.startBinding?u.has(m.startBinding.elementId):!1),h=p||(m.endBinding?u.has(m.endBinding.elementId):!1);if(z(m)){if(a.size>1||Math.max(Math.abs(c.x),Math.abs(c.y))>$h||!m.startBinding&&!m.endBinding){Bs(e,m,i,c);let E=m.startBinding&&!f,g=m.endBinding&&!h;(E||g)&&(E&&Qe(m,"start",i),g&&Qe(m,"end",i))}}else{Bs(e,m,i,c);let E=V(m,i.getNonDeletedElementsMap());E&&Bs(e,E,i,c),je(m,i,{simultaneouslyUpdated:Array.from(a)})}})},Zh=(e,t,n,i)=>{let[o,r]=e,s=o+t.x+n.x,a=r+t.y+n.y;if(n.x===0||n.y===0){let[l,d]=jh(o+t.x,r+t.y,i);n.x===0&&(s=l),n.y===0&&(a=d)}return{x:s-o,y:a-r}},Bs=(e,t,n,i)=>{let o=e.originalElements.get(t.id)??t,r=o.x+i.x,s=o.y+i.y;n.mutateElement(t,{x:r,y:s})},hI=(e,t,n)=>{let[i,o]=De(e);return[t-i,n-o]},EI=({newElement:e,elementType:t,originX:n,originY:i,x:o,y:r,width:s,height:a,shouldMaintainAspectRatio:l,shouldResizeFromCenter:d,zoom:c,scene:u,widthAspectRatio:m=null,originOffset:p=null,informMutation:f=!0})=>{l&&e.type!=="selection"&&(m?a=s/m:(Math.abs(r-i)>Math.abs(o-n)?{width:s,height:a}=ws(t,a,o<n?-s:s):{width:s,height:a}=ws(t,s,r<i?-a:a),a<0&&(a=-a)));let h=o<n?n-s:n,E=r<i?i-a:i;d&&(s+=s,a+=a,h=n-s/2,E=i-a/2);let g=null;if(ee(e)){a=e.height;let x=lo(Vh({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);s=Math.max(s,x),Math.abs(o-n)>Xh/c&&(g={autoResize:!1}),E=i,d&&(h=n-s/2)}if(s!==0&&a!==0){let x=null;xe(e)&&(x={initialWidth:s,initialHeight:a}),u.mutateElement(e,{x:h+(p?.x??0),y:E+(p?.y??0),width:s,height:a,...g,...x},{informMutation:f,isDragging:!1})}};P();import{ELEMENT_LINK_KEY as Zo,normalizeLink as nc}from"@excalidraw/common";var bI=(e,t)=>{let n=window.location.href;try{let i=new URL(n);return i.searchParams.set(Zo,e),nc(i.toString())}catch(i){console.error(i)}return nc(n)},PI=(e,t)=>{if(e.length>0&&qh(e)){if(e.length===1)return{id:e[0].id,type:"element"};if(e.length>1){let n=Object.keys(t.selectedGroupIds)[0];return n?{id:n,type:"group"}:{id:e[0].groupIds[0],type:"group"}}}return null},qh=e=>!!(e.length===1||e.length>1&&jl(e)),II=e=>{try{let t=new URL(e);return t.searchParams.has(Zo)&&t.host===window.location.host}catch{return!1}},SI=e=>{try{let{searchParams:t}=new URL(e);if(t.has(Zo))return t.get(Zo)}catch{}return null};P();import{FONT_FAMILY as lE,VERTICAL_ALIGN as dE,escapeDoubleQuotes as Cs,getFontString as cE}from"@excalidraw/common";P();import{DEFAULT_ELEMENT_PROPS as hn,DEFAULT_FONT_FAMILY as Kh,DEFAULT_FONT_SIZE as Qh,DEFAULT_TEXT_ALIGN as Jh,DEFAULT_VERTICAL_ALIGN as eE,VERTICAL_ALIGN as tE,randomInteger as nE,randomId as iE,getFontString as qo,getUpdatedTimestamp as oE,getLineHeight as rE}from"@excalidraw/common";var st=(e,{x:t,y:n,strokeColor:i=hn.strokeColor,backgroundColor:o=hn.backgroundColor,fillStyle:r=hn.fillStyle,strokeWidth:s=hn.strokeWidth,strokeStyle:a=hn.strokeStyle,roughness:l=hn.roughness,opacity:d=hn.opacity,width:c=0,height:u=0,angle:m=0,groupIds:p=[],frameId:f=null,index:h=null,roundness:E=null,boundElements:g=null,link:x=null,locked:w=hn.locked,...b})=>((t<-1e6||t>1e6||n<-1e6||n>1e6||c<-1e6||c>1e6||u<-1e6||u>1e6)&&console.error("New element size or position is too large",{x:t,y:n,width:c,height:u,points:b.points}),{id:b.id||iE(),type:e,x:t,y:n,width:c,height:u,angle:m,strokeColor:i,backgroundColor:o,fillStyle:r,strokeWidth:s,strokeStyle:a,roughness:l,opacity:d,groupIds:p,frameId:f,index:h,roundness:E,seed:b.seed??nE(),version:b.version||1,versionNonce:b.versionNonce??0,isDeleted:!1,boundElements:g,updated:oE(),link:x,locked:w,customData:b.customData}),Dn=e=>st(e.type,e),OI=e=>st("embeddable",e),kI=e=>({...st("iframe",e)}),ic=e=>ge({...st("frame",e),type:"frame",name:e?.name||null},{}),oc=e=>ge({...st("magicframe",e),type:"magicframe",name:e?.name||null},{}),rc=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),Ln=e=>{let t=e.fontFamily||Kh,n=e.fontSize||Qh,i=e.lineHeight||rE(t),o=ui(e.text),r=Ue(o,qo({fontFamily:t,fontSize:n}),i),s=e.textAlign||Jh,a=e.verticalAlign||eE,l=rc({textAlign:s,verticalAlign:a},r),d={...st("text",e),text:o,fontSize:n,fontFamily:t,textAlign:s,verticalAlign:a,x:e.x-l.x,y:e.y-l.y,width:r.width,height:r.height,containerId:e.containerId||null,originalText:e.originalText??o,autoResize:e.autoResize??!0,lineHeight:i};return ge(d,{})},sE=(e,t,n)=>{let{width:i,height:o}=Ue(n,qo(e),e.lineHeight);e.autoResize||(i=e.width);let{textAlign:r,verticalAlign:s}=e,a,l;if(r==="center"&&s===tE.MIDDLE&&!e.containerId&&e.autoResize){let d=Ue(e.text,qo(e),e.lineHeight),c=rc(e,{width:i-d.width,height:o-d.height});a=e.x-c.x,l=e.y-c.y}else{let[d,c,u,m]=j(e,t),[p,f,h,E]=Xt(e,i,o,!1),g=(d-p)/2,x=(c-f)/2,w=(u-h)/2,b=(m-E)/2;[a,l]=aE({s:!0,e:r==="center"||r==="left",w:r==="center"||r==="right"},e.x,e.y,e.angle,g,x,w,b)}return{width:i,height:o,x:Number.isFinite(a)?a:e.x,y:Number.isFinite(l)?l:e.y}},aE=(e,t,n,i,o,r,s,a)=>{let l=Math.cos(i),d=Math.sin(i);return e.e&&e.w?t+=o+s:e.e?(t+=o*(1+l),n+=o*d,t+=s*(1-l),n+=s*-d):e.w&&(t+=o*(1-l),n+=o*-d,t+=s*(1+l),n+=s*d),e.n&&e.s?n+=r+a:e.n?(t+=r*d,n+=r*(1-l),t+=a*-d,n+=a*(1+l)):e.s&&(t+=r*-d,n+=r*(1+l),t+=a*d,n+=a*(1-l)),[t,n]},RI=(e,t,n,i=e.text)=>{if(e.isDeleted)return;(t||!e.autoResize)&&(i=vt(i,qo(e),t?it(t,e):e.width));let o=sE(e,n,i);return{text:i,...o}},FI=e=>({...st(e.type,e),points:e.points||[],pressures:e.pressures||[],simulatePressure:e.simulatePressure}),sc=e=>{let t={...st(e.type,e),points:e.points||[],startBinding:null,endBinding:null,startArrowhead:null,endArrowhead:null};return It(t)?{...t,polygon:e.polygon??!1}:t},Ko=e=>e.elbowed?{...st(e.type,e),points:e.points||[],startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null,elbowed:!0,fixedSegments:e.fixedSegments||[],startIsSpecial:!1,endIsSpecial:!1}:{...st(e.type,e),points:e.points||[],startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null,elbowed:!1},ac=e=>({...st("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1],crop:e.crop??null});var Et=new Map,uE=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)/,mE=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}\.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,pE=/^https:\/\/(?:www\.)?figma\.com/,lc=/^https:\/\/gist\.github\.com\/([\w_-]+)\/([\w_-]+)/,fE=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist\.github\.com\/.*?)\.js["']/i,hE=/^(?:https?:\/\/)?forms\.microsoft\.com\//,dc=/(?:https?:\/\/)?(?:(?:w){3}\.)?(?:twitter|x)\.com\/[^/]+\/status\/(\d+)/,EE=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:twitter|x)\.com\/[^"']*)/i,gE=/^https:\/\/(?:www\.)?val\.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,xE=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,cc=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,uc=/^(?:http(?:s)?:\/\/)?(?:www\.)?reddit\.com\/r\/([a-zA-Z0-9_]+)\/comments\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9_]+)\/?(?:\?[^#\s]*)?(?:#[^\s]*)?$/,wE=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:www\.)?reddit\.com\/[^"']*)/i,yE=e=>{let t;try{let s=new URL(e.startsWith("http")?e:`https://${e}`);t=s.searchParams.get("t")||s.searchParams.get("start")}catch{t=e.match(/[?&#](?:t|start)=([^&#\s]+)/)?.[1]}if(!t)return 0;if(/^\d+$/.test(t))return parseInt(t,10);let n=t.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/);if(!n)return 0;let[,i="0",o="0",r="0"]=n;return parseInt(i)*3600+parseInt(o)*60+parseInt(r)},Os=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","link.excalidraw.com","gist.github.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","val.town","giphy.com","reddit.com","forms.microsoft.com"]),mc=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","reddit.com","forms.microsoft.com"]),Gs=e=>`<html><body>${e}</body></html>`,WI=e=>{if(!e)return null;if(Et.has(e))return Et.get(e);let t=e,n=mc.has(ks(e,mc)||""),i="generic",o={w:560,h:840},r=e.match(uE);if(r?.[2]){let d=yE(t),c=d>0?`&start=${d}`:"",u=e.includes("shorts");switch(i="video",r[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${r[2]}?enablejsapi=1${c}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${r[2]}&enablejsapi=1${c}`;break;default:e=`https://www.youtube.com/embed/${r[2]}?enablejsapi=1${c}`;break}return o=u?{w:315,h:560}:{w:560,h:315},Et.set(t,{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}}let s=e.match(mE);if(s?.[1]){let d=s?.[1],c=/^\d+$/.test(d)?void 0:new URIError("Invalid embed link format");return i="video",e=`https://player.vimeo.com/video/${d}?api=1`,o={w:560,h:315},Et.set(t,{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:o,type:i,error:c,sandbox:{allowSameOrigin:n}}}if(e.match(pE))return i="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,o={w:550,h:550},Et.set(t,{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}};let l=e.match(gE);if(l)return e=l[1]==="embed"?l[0]:l[0].replace("/v","/embed"),Et.set(t,{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}};if(hE.test(e)&&!e.includes("embed=true")&&(e+=e.includes("?")?"&embed=true":"?embed=true"),dc.test(e)){let d=e.match(dc)[1],c=Cs(`https://twitter.com/x/status/${d}`),u={type:"document",srcdoc:m=>Gs(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${m}"><a href="${c}"></a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`),intrinsicSize:{w:480,h:480},sandbox:{allowSameOrigin:n}};return Et.set(t,u),u}if(uc.test(e)){let[,d,c,u]=e.match(uc),m=Cs(`https://reddit.com/r/${d}/comments/${c}/${u}`),p={type:"document",srcdoc:f=>Gs(`<blockquote class="reddit-embed-bq" data-embed-theme="${f}"><a href="${m}"></a><br></blockquote><script async="" src="https://embed.reddit.com/widgets.js" charset="UTF-8"><\/script>`),intrinsicSize:{w:480,h:480},sandbox:{allowSameOrigin:n}};return Et.set(t,p),p}if(lc.test(e)){let[,d,c]=e.match(lc),u=Cs(`https://gist.github.com/${d}/${c}`),m={type:"document",srcdoc:()=>Gs(`
21
- <script src="${u}.js"><\/script>
21
+ `),l.stack,e.map(c=>s(c)),...d),t)throw l}},Lc=e=>e.sort((t,n)=>Tc(t)&&Tc(n)?t.index<n.index?-1:t.index>n.index?1:t.id<n.id?-1:1:1),ei=(e,t)=>{try{let n=hr(e),o=V0(e,t),i=ta(e,o),r=e.map(s=>{let a=i.get(s);return a?{...s,index:a.index}:s});j0(r,{includeBoundTextValidation:!1,shouldThrow:!0,ignoreLogs:!0});for(let[s,{index:a}]of i)ke(s,n,{index:a})}catch{ea(e)}return e},ea=e=>{let t=hr(e),n=Cc(e),o=ta(e,n);for(let[i,{index:r}]of o)ke(i,t,{index:r});return e},bc=e=>{let t=hr(e),n=Cc(e),o=ta(e,n);for(let[i,{index:r}]of o)t.set(i.id,Ne(i,{index:r}));return t},V0=(e,t)=>{let n=[],o=0;for(;o<e.length;)if(t.has(e[o].id)){let i=[o-1,o];for(;++o<e.length&&t.has(e[o].id);)i.push(o);i.push(o),n.push(i)}else o++;return n},Cc=e=>{let t=[],n,o,i=-1,r=0,s=d=>{let c=e[i]?e[i].index:void 0,p=e[d-1]?.index;return!c&&p||c&&p&&p>c?[p,d-1]:[c,i]},a=d=>{let c=e[r]?e[r].index:void 0;if(c&&d<r)return[c,r];let p=r;for(;++p<e.length;){let h=e[p]?.index;if(!c&&h||c&&h&&h>c)return[h,p]}return[void 0,p]},l=0;for(;l<e.length;){let d=e[l].index;if([n,i]=s(l),[o,r]=a(l),Js(d,n,o))l++;else{let c=[i,l];for(;++l<e.length;){let p=e[l].index,[h,m]=s(l),[f,g]=a(l);if(Js(p,h,f))break;[n,i]=[h,m],[o,r]=[f,g],c.push(l)}c.push(r),t.push(c)}}return t},Js=(e,t,n)=>e?t&&n?t<e&&e<n:!t&&n?e<n:t&&!n?t<e:!!e:!1,ta=(e,t)=>{let n=new Map;for(let o of t){let i=o.shift(),r=o.pop(),s=pr(e[i]?.index,e[r]?.index,o.length);for(let a=0;a<o.length;a++){let l=e[o[a]];n.set(l,{index:s[a]})}}return n},Tc=e=>!!e.index;I();var jc=ri(Rc(),1);import{randomInteger as df,arrayToMap as Fc,toBrandedType as Nc,isDevEnv as Hc,isTestEnv as zc,toArray as cf}from"@excalidraw/common";import{isNonDeletedElement as uf}from"@excalidraw/element";import{isFrameLikeElement as pf}from"@excalidraw/element";import{getElementsInGroup as hf}from"@excalidraw/element";import{syncInvalidIndices as mf,syncMovedIndices as _c,validateFractionalIndices as ff}from"@excalidraw/element";import{getSelectedElements as gf}from"@excalidraw/element";import{mutateElement as Ef}from"@excalidraw/element";var Wc=e=>{let t=new Map,n=[];for(let o of e)o.isDeleted||(n.push(o),t.set(o.id,o));return{elementsMap:t,elements:n}},xf=(0,jc.default)(e=>{(Hc()||zc()||window?.DEBUG_FRACTIONAL_INDICES)&&ff(e,{shouldThrow:Hc()||zc(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1}),yf=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],n="";for(let o of t)n+=`${o}:${e[o]?"1":"0"}`;return n},uo=class{callbacks=new Set;nonDeletedElements=[];nonDeletedElementsMap=Nc(new Map);elements=[];nonDeletedFramesLikes=[];frames=[];elementsMap=Nc(new Map);selectedElementsCache={selectedElementIds:null,elements:null,cache:new Map};sceneNonce;getSceneNonce(){return this.sceneNonce}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}constructor(t=null,n){t&&this.replaceAllElements(t,n)}getSelectedElements(t){let n=yf(t),o=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===o&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let r=this.selectedElementsCache.cache.get(n);if(r)return r}else t?.elements==null&&this.selectedElementsCache.cache.clear();let i=gf(o,{selectedElementIds:t.selectedElementIds},t);return t?.elements==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(n,i)),i}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getNonDeletedElement(t){let n=this.getElement(t);return n&&uf(n)?n:null}mapElements(t){let n=!1,o=this.elements.map(i=>{let r=t(i);return r!==i&&(n=!0),r});return n&&this.replaceAllElements(o),n}replaceAllElements(t,n){let o=cf(t),i=[];n?.skipValidation||xf(o),this.elements=mf(o),this.elementsMap.clear(),this.elements.forEach(s=>{pf(s)&&i.push(s),this.elementsMap.set(s.id,s)});let r=Wc(this.elements);this.nonDeletedElements=r.elements,this.nonDeletedElementsMap=r.elementsMap,this.frames=i,this.nonDeletedFramesLikes=Wc(this.frames).elements,this.triggerUpdate()}triggerUpdate(){this.sceneNonce=df();for(let t of Array.from(this.callbacks))t()}onUpdate(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),this.callbacks.clear()}insertElementAtIndex(t,n){if(!Number.isFinite(n)||n<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,n),t,...this.elements.slice(n)];_c(o,Fc([t])),this.replaceAllElements(o)}insertElementsAtIndex(t,n){if(!t.length)return;if(!Number.isFinite(n)||n<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,n),...t,...this.elements.slice(n)];_c(o,Fc(t)),this.replaceAllElements(o)}insertElement=t=>{let n=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,n)};insertElements=t=>{if(!t.length)return;let n=t[0]?.frameId?this.getElementIndex(t[0].frameId):this.elements.length;this.insertElementsAtIndex(t,n)};getElementIndex(t){return this.elements.findIndex(n=>n.id===t)}getContainerElement=t=>t&&t.containerId&&this.getElement(t.containerId)||null;getElementsFromId=t=>{let n=this.getNonDeletedElementsMap(),o=n.get(t);return o?[o]:hf(n,t)};mutateElement(t,n,o={informMutation:!0,isDragging:!1}){let i=this.getNonDeletedElementsMap(),{version:r}=t,{version:s}=Ef(t,i,n,o);return this.elementsMap.has(t.id)&&r!==s&&o.informMutation&&this.triggerUpdate(),t}};var $=class e{constructor(t,n){this.deleted=t;this.inserted=n}static create(t,n,o,i){let r=o&&i!=="inserted"?o(t,"deleted"):t,s=o&&i!=="deleted"?o(n,"inserted"):n;return new e(r,s)}static calculate(t,n,o,i){if(t===n)return e.empty();let r={},s={};for(let d of this.getDifferences(t,n))r[d]=t[d],s[d]=n[d];let[a,l]=i?i(r,s):[r,s];return e.create(a,l,o)}static empty(){return new e({},{})}static isEmpty(t){return!Object.keys(t.deleted).length&&!Object.keys(t.inserted).length}static merge(t,n,o=e.empty()){return e.create({...t.deleted,...n.deleted,...o.deleted},{...t.inserted,...n.inserted,...o.inserted})}static mergeObjects(t,n,o={}){let i={...t};for(let r of Object.keys(o))delete i[r];return{...i,...n}}static mergeArrays(t,n,o,i){return Object.values(e.mergeObjects(on(t??[],i),on(n??[],i),on(o??[],i)))}static diffObjects(t,n,o,i){if(!t[o]&&!n[o])return;let r=t[o]!==null&&typeof t[o]=="object",s=n[o]!==null&&typeof n[o]=="object";if(r||s){let a=t[o]??{},l=n[o]??{},d=e.getLeftDifferences(a,l).reduce((p,h)=>(p[h]=i(a[h]),p),{}),c=e.getRightDifferences(a,l).reduce((p,h)=>(p[h]=i(l[h]),p),{});Object.keys(d).length||Object.keys(c).length?(Reflect.set(t,o,d),Reflect.set(n,o,c)):(Reflect.deleteProperty(t,o),Reflect.deleteProperty(n,o))}else t[o]===n[o]&&(Reflect.deleteProperty(t,o),Reflect.deleteProperty(n,o))}static diffArrays(t,n,o,i){if(!(!t[o]&&!n[o])&&(Array.isArray(t[o])||Array.isArray(n[o]))){let r=Array.isArray(t[o])?t[o]:[],s=Array.isArray(n[o])?n[o]:[],a=on(e.getLeftDifferences(on(r,i),on(s,i)),d=>d),l=on(e.getRightDifferences(on(r,i),on(s,i)),d=>d);if(Object.keys(a).length||Object.keys(l).length){let d=r.filter(p=>a[i?i(p):String(p)]),c=s.filter(p=>l[i?i(p):String(p)]);Reflect.set(t,o,d),Reflect.set(n,o,c)}else Reflect.deleteProperty(t,o),Reflect.deleteProperty(n,o)}}static isLeftDifferent(t,n,o=!1){return!!this.distinctKeysIterator("left",t,n,o).next().value}static isRightDifferent(t,n,o=!1){return!!this.distinctKeysIterator("right",t,n,o).next().value}static isInnerDifferent(t,n,o=!1){return!!!!this.distinctKeysIterator("inner",t,n,o).next().value}static isDifferent(t,n,o=!1){return!!!!this.distinctKeysIterator("full",t,n,o).next().value}static getLeftDifferences(t,n,o=!1){return Array.from(this.distinctKeysIterator("left",t,n,o)).sort()}static getRightDifferences(t,n,o=!1){return Array.from(this.distinctKeysIterator("right",t,n,o)).sort()}static getInnerDifferences(t,n,o=!1){return Array.from(this.distinctKeysIterator("inner",t,n,o)).sort()}static getDifferences(t,n,o=!1){return Array.from(this.distinctKeysIterator("full",t,n,o)).sort()}static*distinctKeysIterator(t,n,o,i=!1){if(n===o)return;let r=[];t==="left"?r=Object.keys(n):t==="right"?r=Object.keys(o):t==="inner"?r=Object.keys(n).filter(s=>s in o):t==="full"?r=Array.from(new Set([...Object.keys(n),...Object.keys(o)])):Uc(t,`Unknown distinctKeysIterator's join param "${t}"`,!0);for(let s of r){let a=n[s],l=o[s];if(a!==l){if(!i&&typeof a=="object"&&typeof l=="object"&&a!==null&&l!==null&&Yc(a,l))continue;yield s}}}},kn=class e{constructor(t){this.delta=t}static create(t){return new e(t)}static calculate(t,n){let o=$.calculate(t,n,e.orderAppStateKeys,e.postProcess);return new e(o)}static restore(t){let{delta:n}=t;return new e(n)}static empty(){return new e($.create({},{}))}inverse(){let t=$.create(this.delta.inserted,this.delta.deleted);return new e(t)}squash(t){if(t.isEmpty())return this;let n=$.mergeObjects(this.delta.deleted.selectedElementIds??{},t.delta.deleted.selectedElementIds??{}),o=$.mergeObjects(this.delta.inserted.selectedElementIds??{},t.delta.inserted.selectedElementIds??{}),i=$.mergeObjects(this.delta.deleted.selectedGroupIds??{},t.delta.deleted.selectedGroupIds??{}),r=$.mergeObjects(this.delta.inserted.selectedGroupIds??{},t.delta.inserted.selectedGroupIds??{}),s=$.mergeObjects(this.delta.deleted.lockedMultiSelections??{},t.delta.deleted.lockedMultiSelections??{}),a=$.mergeObjects(this.delta.inserted.lockedMultiSelections??{},t.delta.inserted.lockedMultiSelections??{}),l={},d={};return(Object.keys(n).length||Object.keys(o).length)&&(d.selectedElementIds=n,l.selectedElementIds=o),(Object.keys(i).length||Object.keys(r).length)&&(d.selectedGroupIds=i,l.selectedGroupIds=r),(Object.keys(s).length||Object.keys(a).length)&&(d.lockedMultiSelections=s,l.lockedMultiSelections=a),this.delta=$.merge(this.delta,t.delta,$.create(d,l)),this}applyTo(t,n){try{let{selectedElementIds:o={},selectedGroupIds:i={},lockedMultiSelections:r={}}=this.delta.deleted,{selectedElementIds:s={},selectedGroupIds:a={},lockedMultiSelections:l={},selectedLinearElement:d,...c}=this.delta.inserted,p=$.mergeObjects(t.selectedElementIds,s,o),h=$.mergeObjects(t.selectedGroupIds,a,i),m=$.mergeObjects(t.lockedMultiSelections,l,r),f=d&&n.has(d.elementId)?new G(n.get(d.elementId),n,d.isEditing):null,g={...t,...c,selectedElementIds:p,selectedGroupIds:h,lockedMultiSelections:m,selectedLinearElement:typeof d<"u"?f:t.selectedLinearElement},E=this.filterInvisibleChanges(t,g,n);return[g,E]}catch(o){if(console.error("Couldn't apply appstate change",o),Bn()||Cn())throw o;return[t,!1]}}isEmpty(){return $.isEmpty(this.delta)}filterInvisibleChanges(t,n,o){let i=ao(t),r=ao(n),s=$.isRightDifferent(e.stripElementsProps(i),e.stripElementsProps(r)),a=$.isRightDifferent(e.stripStandaloneProps(i),e.stripStandaloneProps(r));if(!s&&!a)return!1;let l={value:s};if(a){let d=$.getRightDifferences(e.stripStandaloneProps(i),e.stripStandaloneProps(r)),c=new Set;(d.includes("editingGroupId")||d.includes("selectedGroupIds"))&&(c=Fd(o));for(let p of d)switch(p){case"selectedElementIds":n[p]=e.filterSelectedElements(n[p],o,l);break;case"selectedGroupIds":n[p]=e.filterSelectedGroups(n[p],c,l);break;case"croppingElementId":{let y=n[p];if(!y)l.value=!0;else{let w=o.get(y);w&&!w.isDeleted?l.value=!0:n[p]=null}break}case"editingGroupId":let h=n[p];h?c.has(h)?l.value=!0:n[p]=null:l.value=!0;break;case"selectedLinearElement":let m=n[p];if(!m)l.value=!0;else{let y=o.get(m.elementId);y&&!y.isDeleted?l.value=!0:n[p]=null}break;case"lockedMultiSelections":let f=t[p]||{},g=n[p]||{};Yc(f,g)||(l.value=!0);break;case"activeLockedId":let E=t[p]||null,x=n[p]||null;E!==x&&(l.value=!0);break;default:Uc(p,`Unknown ObservedElementsAppState's key "${p}"`,!0)}}return l.value}static filterSelectedElements(t,n,o){let i=Object.keys(t);if(!i.length)return o.value=!0,t;let r={...t};for(let s of i){let a=n.get(s);a&&!a.isDeleted?o.value=!0:delete r[s]}return r}static filterSelectedGroups(t,n,o){if(!Object.keys(t).length)return o.value=!0,t;let r={...t};for(let s of Object.keys(r))n.has(s)?o.value=!0:delete r[s];return r}static stripElementsProps(t){let{editingGroupId:n,selectedGroupIds:o,selectedElementIds:i,selectedLinearElement:r,croppingElementId:s,lockedMultiSelections:a,activeLockedId:l,...d}=t;return d}static stripStandaloneProps(t){let{name:n,viewBackgroundColor:o,...i}=t;return i}static postProcess(t,n){try{$.diffObjects(t,n,"selectedElementIds",o=>!0),$.diffObjects(t,n,"selectedGroupIds",o=>o??!1),$.diffObjects(t,n,"lockedMultiSelections",o=>o??{})}catch(o){if(console.error("Couldn't postprocess appstate change deltas."),Bn()||Cn())throw o}finally{return[t,n]}}static orderAppStateKeys(t){let n={};for(let o of Object.keys(t).sort())n[o]=t[o];return n}},Tn=class e{constructor(t,n,o){this.added=t;this.removed=n;this.updated=o}static create(t,n,o,i={shouldRedistribute:!1}){let r;if(i.shouldRedistribute){let s={},a={},l={},d=[...Object.entries(t),...Object.entries(n),...Object.entries(o)];for(let[c,p]of d)this.satisfiesAddition(p)?s[c]=p:this.satisfiesRemoval(p)?a[c]=p:l[c]=p;r=new e(s,a,l)}else r=new e(t,n,o);return(Bn()||Cn())&&(e.validate(r,"added",this.satisfiesAddition),e.validate(r,"removed",this.satisfiesRemoval),e.validate(r,"updated",this.satisfiesUpdate)),r}static restore(t){let{added:n,removed:o,updated:i}=t;return e.create(n,o,i)}static satisfiesAddition=({deleted:t,inserted:n})=>t.isDeleted===!0&&!n.isDeleted;static satisfiesRemoval=({deleted:t,inserted:n})=>!t.isDeleted&&n.isDeleted===!0;static satisfiesUpdate=({deleted:t,inserted:n})=>!!t.isDeleted==!!n.isDeleted;static satisfiesCommmonInvariants=({deleted:t,inserted:n})=>!!(Number.isInteger(t.version)&&Number.isInteger(n.version)&&t.version>=0&&n.version>=0&&t.version!==n.version);static satisfiesUniqueInvariants=(t,n)=>{let{added:o,removed:i,updated:r}=t;return[o[n],i[n],r[n]].filter(Boolean).length===1};static validate(t,n,o){for(let[i,r]of Object.entries(t[n]))if(!this.satisfiesCommmonInvariants(r)||!this.satisfiesUniqueInvariants(t,i)||!o(r))throw console.error(`Broken invariant for "${n}" delta, element "${i}", delta:`,r),new Error(`ElementsDelta invariant broken for element "${i}".`)}static calculate(t,n){if(t===n)return e.empty();let o={},i={},r={};for(let s of t.values())if(!n.get(s.id)){let l={...s},d={isDeleted:!0,version:s.version+1,versionNonce:Vc()},c=$.create(l,d,e.stripIrrelevantProps);s.isDeleted?r[s.id]=c:i[s.id]=c}for(let s of n.values()){let a=t.get(s.id);if(!a){let l={isDeleted:!0,version:s.version-1,versionNonce:Vc()},d={...s},c=$.create(l,d,e.stripIrrelevantProps);s.isDeleted?r[s.id]=c:o[s.id]=c;continue}if(a.versionNonce!==s.versionNonce){let l=$.calculate(a,s,e.stripIrrelevantProps,e.postProcess);if(typeof a.isDeleted=="boolean"&&typeof s.isDeleted=="boolean"&&a.isDeleted!==s.isDeleted){a.isDeleted&&!s.isDeleted?o[s.id]=l:i[s.id]=l;continue}r[s.id]=l}}return e.create(o,i,r)}static empty(){return e.create({},{},{})}inverse(){let t=r=>{let s={};for(let[a,{inserted:l,deleted:d}]of Object.entries(r))s[a]=$.create({...l},{...d});return s},n=t(this.added),o=t(this.removed),i=t(this.updated);return e.create(o,n,i)}isEmpty(){return Object.keys(this.added).length===0&&Object.keys(this.removed).length===0&&Object.keys(this.updated).length===0}applyLatestChanges(t,n,o){let i=(d,c)=>(p,h)=>{let m;switch(h){case"deleted":m=d;break;case"inserted":m=c;break}if(!m)return console.error("Element not found when trying to apply latest changes"),p;let f={};for(let g of Object.keys(p))switch(g){case"boundElements":f[g]=p[g];break;default:f[g]=m[g]}return f},r=d=>{let c={};for(let[p,h]of Object.entries(d)){let m=t.get(p),f=n.get(p),g=null;m||f?g=$.create(h.deleted,h.inserted,i(m,f),o):g=h,$.isInnerDifferent(g.deleted,g.inserted)&&(c[p]=g)}return c},s=r(this.added),a=r(this.removed),l=r(this.updated);return e.create(s,a,l,{shouldRedistribute:!0})}applyTo(t,n=Ln.empty().elements,o){let i=new Map(t),r,s={containsVisibleDifference:!1,containsZindexDifference:!1,applyDirection:void 0};try{let a=e.createApplier(t,i,n,s,o),l=a(this.added),d=a(this.removed),c=a(this.updated),p=this.resolveConflicts(t,i,s.applyDirection);r=new Map([...l,...d,...c,...p])}catch(a){if(console.error("Couldn't apply elements delta",a),Bn()||Cn())throw a;return[t,!0]}try{i=e.reorderElements(i,r,s),e.redrawElements(i,r)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),Bn()||Cn())throw a}finally{return[i,s.containsVisibleDifference]}}squash(t){if(t.isEmpty())return this;let{added:n,removed:o,updated:i}=t,r=(s,a)=>{let l=$.mergeArrays(s.deleted.boundElements??[],a.deleted.boundElements??[],void 0,c=>c.id)??[],d=$.mergeArrays(s.inserted.boundElements??[],a.inserted.boundElements??[],void 0,c=>c.id)??[];if(!(!l.length&&!d.length))return $.create({boundElements:l},{boundElements:d})};for(let[s,a]of Object.entries(n)){let l=this.added[s]??this.removed[s]??this.updated[s];if(!l)this.added[s]=a;else{let d=r(l,a);delete this.removed[s],delete this.updated[s],this.added[s]=$.merge(l,a,d)}}for(let[s,a]of Object.entries(o)){let l=this.added[s]??this.removed[s]??this.updated[s];if(!l)this.removed[s]=a;else{let d=r(l,a);delete this.added[s],delete this.updated[s],this.removed[s]=$.merge(l,a,d)}}for(let[s,a]of Object.entries(i)){let l=this.added[s]??this.removed[s]??this.updated[s];if(!l)this.updated[s]=a;else{let d=r(l,a),c=$.merge(l,a,d);l===this.added[s]?this.added[s]=c:l===this.removed[s]?this.removed[s]=c:this.updated[s]=c}}return(Bn()||Cn())&&(e.validate(this,"added",e.satisfiesAddition),e.validate(this,"removed",e.satisfiesRemoval),e.validate(this,"updated",e.satisfiesUpdate)),this}static createApplier=(t,n,o,i,r)=>s=>{let a=e.createGetter(n,o,i);return Object.entries(s).reduce((l,[d,c])=>{let p=a(d,c.inserted);if(p){let h=e.applyDelta(p,c,i,r);if(n.set(h.id,h),l.set(h.id,h),!i.applyDirection){let m=t.get(d);m&&(i.applyDirection=m.version>h.version?"backward":"forward")}}return l},new Map)};static createGetter=(t,n,o)=>(i,r)=>{let s=t.get(i);return s||(s=n.get(i),s?(o.containsZindexDifference=!0,(!r.isDeleted||r.isDeleted&&!s.isDeleted)&&(o.containsVisibleDifference=!0)):s=Ne({id:i,version:1},{...r})),s};static applyDelta(t,n,o,i){let r={};for(let s of Object.keys(n.inserted)){if(s==="boundElements"||i?.excludedProperties?.has(s))continue;let a=n.inserted[s];Reflect.set(r,s,a)}if(n.deleted.boundElements?.length||n.inserted.boundElements?.length){let s=$.mergeArrays(t.boundElements,n.inserted.boundElements,n.deleted.boundElements,a=>a.id);Object.assign(r,{boundElements:s})}if(!o.containsVisibleDifference){let{index:s,...a}=r,l=e.checkForVisibleDifference(t,a);o.containsVisibleDifference=l}return o.containsZindexDifference||(o.containsZindexDifference=n.deleted.index!==n.inserted.index),Ne(t,r,!0)}static checkForVisibleDifference(t,n){return t.isDeleted&&n.isDeleted!==!1?!1:t.isDeleted&&n.isDeleted===!1||t.isDeleted===!1&&n.isDeleted?!0:$.isRightDifferent(t,n)}resolveConflicts(t,n,o="forward"){let i=new Map,r=(a,l)=>{let d=n.get(a.id);if(!d)return;let c=t.get(a.id),p=o==="forward"?d.version+1:d.version-1,h=l,m;c===d?m=Ne(d,{...h,version:p},!0):m=ke(d,n,{...h,version:c?.version!==d.version?d.version:p}),i.set(m.id,m),n.set(m.id,m)};for(let a of Object.keys(this.removed))e.unbindAffected(t,n,a,r);for(let a of Object.keys(this.added))e.rebindAffected(t,n,a,r);for(let[a]of Array.from(Object.entries(this.updated)).filter(([l,d])=>Object.keys({...d.deleted,...d.inserted}).find(c=>hd.has(c)))){let l=n.get(a);!l||l.isDeleted||e.rebindAffected(t,n,a,r)}let s=new Map(Array.from(t).filter(([a])=>i.has(a)));return this.squash(e.calculate(s,i)),i}static unbindAffected(t,n,o,i){let r=()=>t.get(o),s=()=>n.get(o);Mn.unbindAffected(n,r(),i),Mn.unbindAffected(n,s(),i),Pn.unbindAffected(n,r(),i),Pn.unbindAffected(n,s(),i)}static rebindAffected(t,n,o,i){let r=()=>t.get(o),s=()=>n.get(o);Mn.unbindAffected(n,r(),i),Mn.rebindAffected(n,s(),i),Pn.unbindAffected(n,r(),(a,l)=>{ee(a)&&i(a,l)}),Pn.rebindAffected(n,s(),i)}static redrawElements(t,n){try{let o=new uo(t,{skipValidation:!0});e.redrawTextBoundingBoxes(o,n),e.redrawBoundArrows(o,n)}catch(o){if(console.error("Couldn't redraw elements",o),Bn()||Cn())throw o}finally{return t}}static redrawTextBoundingBoxes(t,n){let o=t.getNonDeletedElementsMap(),i=new Map;for(let r of n.values()){if(ge(r)){let{containerId:s}=r,a=s?o.get(s):void 0;a&&i.set(a.id,{container:a,boundText:r})}if(kt(r)){let s=$t(r),a=s?o.get(s):void 0;a&&i.set(r.id,{container:r,boundText:a})}}for(let{container:r,boundText:s}of i.values())r.isDeleted||s.isDeleted||Di(s,r,t)}static redrawBoundArrows(t,n){for(let o of n.values())!o.isDeleted&&fe(o)&&Re(o,t,{changedElements:n})}static reorderElements(t,n,o){if(!o.containsZindexDifference)return t;let i=Array.from(t.values()),r=Lc([...i]),s=$.getRightDifferences(i,r,!0).reduce((a,l)=>{let d=i[Number(l)];return d&&n.has(d.id)&&a.set(d.id,d),a},new Map);return!o.containsVisibleDifference&&s.size&&(o.containsVisibleDifference=!0),wf(ei(r,s))}static postProcess(t,n){try{$.diffArrays(t,n,"boundElements",r=>r.id);let o=t.points??[],i=n.points??[];$.isDifferent(o,i)||(Reflect.deleteProperty(t,"points"),Reflect.deleteProperty(n,"points"))}catch(o){if(console.error("Couldn't postprocess elements delta."),Bn()||Cn())throw o}finally{return[t,n]}}static stripIrrelevantProps(t){let{id:n,updated:o,...i}=t;return i}};I();var i4=(e,t,n,o,i)=>{let[r,s,a,l]=n.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],d=je(e),c=tr(e,t,o).map(f=>[f,je(f)]).sort((f,g)=>f[1][s]-g[1][s]),p=0;for(let f of c)p+=f[1][l];let h=(d[l]-p)/(c.length-1);if(h<0){let f=c.findIndex(y=>y[1][r]===d[r]),g=c.findIndex(y=>y[1][a]===d[a]),E=(c[g][1][s]-c[f][1][s])/(c.length-1),x=c[f][1][s];return c.flatMap(([y,w],M)=>{let b={x:0,y:0};return M!==f&&M!==g&&(x+=E,b[n.axis]=x-w[s]),y.map(S=>{let A=i.mutateElement(S,{x:S.x+b.x,y:S.y+b.y});return Re(S,i,{simultaneouslyUpdated:y}),A})})}let m=d[r];return c.flatMap(([f,g])=>{let E={x:0,y:0};return E[n.axis]=m-g[r],m+=h,m+=g[l],f.map(x=>{let y=i.mutateElement(x,{x:x.x+E.x,y:x.y+E.y});return Re(x,i,{simultaneouslyUpdated:f}),y})})};I();import{TEXT_AUTOWRAP_THRESHOLD as bf,getGridPoint as Mf,getFontString as Pf,DRAGGING_THRESHOLD as If}from"@excalidraw/common";var m4=(e,t,n,o,i,r)=>{if(t.length===1&&Y(t[0])&&(t[0].startBinding||t[0].endBinding))return;let s=t.filter(h=>{if(Y(h)&&h.startBinding&&h.endBinding){let m=t.find(g=>g.id===h.startBinding?.elementId),f=t.find(g=>g.id===h.endBinding?.elementId);return m&&f}return!0}),a=new Set(s),l=s.filter(h=>te(h)).map(h=>h.id);if(l.length>0)for(let h of o.getNonDeletedElements())h.frameId!==null&&l.includes(h.frameId)&&a.add(h);let d=[];for(let h of a){let m=e.originalElements.get(h.id);if(!m)return;d.push(m)}let c=Sf(_e(d),n,i,r),p=new Set(Array.from(a,h=>h.id));a.forEach(h=>{let m=!V(h),f=m||(h.startBinding?p.has(h.startBinding.elementId):!1),g=m||(h.endBinding?p.has(h.endBinding.elementId):!1);if(V(h)){if(a.size>1||Math.max(Math.abs(c.x),Math.abs(c.y))>If||!h.startBinding&&!h.endBinding){oa(e,h,o,c);let E=h.startBinding&&!f,x=h.endBinding&&!g;(E||x)&&(E&&Oe(h,"start",o),x&&Oe(h,"end",o))}}else{oa(e,h,o,c);let E=J(h,o.getNonDeletedElementsMap());E&&oa(e,E,o,c),Re(h,o,{simultaneouslyUpdated:Array.from(a)})}})},Sf=(e,t,n,o)=>{let[i,r]=e,s=i+t.x+n.x,a=r+t.y+n.y;if(n.x===0||n.y===0){let[l,d]=Mf(i+t.x,r+t.y,o);n.x===0&&(s=l),n.y===0&&(a=d)}return{x:s-i,y:a-r}},oa=(e,t,n,o)=>{let i=e.originalElements.get(t.id)??t,r=i.x+o.x,s=i.y+o.y;n.mutateElement(t,{x:r,y:s})},f4=(e,t,n)=>{let[o,i]=_e(e);return[t-o,n-i]},g4=({newElement:e,elementType:t,originX:n,originY:o,x:i,y:r,width:s,height:a,shouldMaintainAspectRatio:l,shouldResizeFromCenter:d,zoom:c,scene:p,widthAspectRatio:h=null,originOffset:m=null,informMutation:f=!0})=>{l&&e.type!=="selection"&&(h?a=s/h:(Math.abs(r-o)>Math.abs(i-n)?{width:s,height:a}=Us(t,a,i<n?-s:s):{width:s,height:a}=Us(t,s,r<o?-a:a),a<0&&(a=-a)));let g=i<n?n-s:n,E=r<o?o-a:o;d&&(s+=s,a+=a,g=n-s/2,E=o-a/2);let x=null;if(ee(e)){a=e.height;let y=Ti(Pf({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);s=Math.max(s,y),Math.abs(i-n)>bf/c&&(x={autoResize:!1}),E=o,d&&(g=n-s/2)}if(s!==0&&a!==0){let y=null;ve(e)&&(y={initialWidth:s,initialHeight:a}),p.mutateElement(e,{x:g+(m?.x??0),y:E+(m?.y??0),width:s,height:a,...x,...y},{informMutation:f,isDragging:!1})}};I();import{ELEMENT_LINK_KEY as fr,normalizeLink as Xc}from"@excalidraw/common";var b4=(e,t)=>{let n=window.location.href;try{let o=new URL(n);return o.searchParams.set(fr,e),Xc(o.toString())}catch(o){console.error(o)}return Xc(n)},M4=(e,t)=>{if(e.length>0&&vf(e)){if(e.length===1)return{id:e[0].id,type:"element"};if(e.length>1){let n=Object.keys(t.selectedGroupIds)[0];return n?{id:n,type:"group"}:{id:e[0].groupIds[0],type:"group"}}}return null},vf=e=>!!(e.length===1||e.length>1&&Nd(e)),P4=e=>{try{let t=new URL(e);return t.searchParams.has(fr)&&t.host===window.location.host}catch{return!1}},I4=e=>{try{let{searchParams:t}=new URL(e);if(t.has(fr))return t.get(fr)}catch{}return null};I();import{FONT_FAMILY as Nf,VERTICAL_ALIGN as Hf,escapeDoubleQuotes as ia,getFontString as zf}from"@excalidraw/common";I();import{DEFAULT_ELEMENT_PROPS as Dn,DEFAULT_FONT_FAMILY as Af,DEFAULT_FONT_SIZE as kf,DEFAULT_TEXT_ALIGN as Tf,DEFAULT_VERTICAL_ALIGN as Lf,VERTICAL_ALIGN as Cf,randomInteger as Bf,randomId as Df,getFontString as gr,getUpdatedTimestamp as Gf,getLineHeight as Of}from"@excalidraw/common";var Mt=(e,{x:t,y:n,strokeColor:o=Dn.strokeColor,backgroundColor:i=Dn.backgroundColor,fillStyle:r=Dn.fillStyle,strokeWidth:s=Dn.strokeWidth,strokeStyle:a=Dn.strokeStyle,roughness:l=Dn.roughness,opacity:d=Dn.opacity,width:c=0,height:p=0,angle:h=0,groupIds:m=[],frameId:f=null,index:g=null,roundness:E=null,boundElements:x=null,link:y=null,locked:w=Dn.locked,...M})=>((t<-1e6||t>1e6||n<-1e6||n>1e6||c<-1e6||c>1e6||p<-1e6||p>1e6)&&console.error("New element size or position is too large",{x:t,y:n,width:c,height:p,points:M.points}),{id:M.id||Df(),type:e,x:t,y:n,width:c,height:p,angle:h,strokeColor:o,backgroundColor:i,fillStyle:r,strokeWidth:s,strokeStyle:a,roughness:l,opacity:d,groupIds:m,frameId:f,index:g,roundness:E,seed:M.seed??Bf(),version:M.version||1,versionNonce:M.versionNonce??0,isDeleted:!1,boundElements:x,updated:Gf(),link:y,locked:w,customData:M.customData}),Xn=e=>Mt(e.type,e),G4=e=>Mt("embeddable",e),O4=e=>({...Mt("iframe",e)}),$c=e=>Ne({...Mt("frame",e),type:"frame",name:e?.name||null},{}),Zc=e=>Ne({...Mt("magicframe",e),type:"magicframe",name:e?.name||null},{}),qc=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),$n=e=>{let t=e.fontFamily||Af,n=e.fontSize||kf,o=e.lineHeight||Of(t),i=Bo(e.text),r=ot(i,gr({fontFamily:t,fontSize:n}),o),s=e.textAlign||Tf,a=e.verticalAlign||Lf,l=qc({textAlign:s,verticalAlign:a},r),d={...Mt("text",e),text:i,fontSize:n,fontFamily:t,textAlign:s,verticalAlign:a,x:e.x-l.x,y:e.y-l.y,width:r.width,height:r.height,containerId:e.containerId||null,originalText:e.originalText??i,autoResize:e.autoResize??!0,lineHeight:o};return Ne(d,{})},Rf=(e,t,n)=>{let{width:o,height:i}=ot(n,gr(e),e.lineHeight);e.autoResize||(o=e.width);let{textAlign:r,verticalAlign:s}=e,a,l;if(r==="center"&&s===Cf.MIDDLE&&!e.containerId&&e.autoResize){let d=ot(e.text,gr(e),e.lineHeight),c=qc(e,{width:o-d.width,height:i-d.height});a=e.x-c.x,l=e.y-c.y}else{let[d,c,p,h]=K(e,t),[m,f,g,E]=cn(e,o,i,!1),x=(d-m)/2,y=(c-f)/2,w=(p-g)/2,M=(h-E)/2;[a,l]=Ff({s:!0,e:r==="center"||r==="left",w:r==="center"||r==="right"},e.x,e.y,e.angle,x,y,w,M)}return{width:o,height:i,x:Number.isFinite(a)?a:e.x,y:Number.isFinite(l)?l:e.y}},Ff=(e,t,n,o,i,r,s,a)=>{let l=Math.cos(o),d=Math.sin(o);return e.e&&e.w?t+=i+s:e.e?(t+=i*(1+l),n+=i*d,t+=s*(1-l),n+=s*-d):e.w&&(t+=i*(1-l),n+=i*-d,t+=s*(1+l),n+=s*d),e.n&&e.s?n+=r+a:e.n?(t+=r*d,n+=r*(1-l),t+=a*-d,n+=a*(1+l)):e.s&&(t+=r*-d,n+=r*(1+l),t+=a*d,n+=a*(1-l)),[t,n]},R4=(e,t,n,o=e.text)=>{if(e.isDeleted)return;(t||!e.autoResize)&&(o=Xt(o,gr(e),t?yt(t,e):e.width));let i=Rf(e,n,o);return{text:o,...i}},F4=e=>({...Mt(e.type,e),points:e.points||[],pressures:e.pressures||[],simulatePressure:e.simulatePressure}),Kc=e=>{let t={...Mt(e.type,e),points:e.points||[],startBinding:null,endBinding:null,startArrowhead:null,endArrowhead:null};return Wt(t)?{...t,polygon:e.polygon??!1}:t},Er=e=>e.elbowed?{...Mt(e.type,e),points:e.points||[],startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null,elbowed:!0,fixedSegments:e.fixedSegments||[],startIsSpecial:!1,endIsSpecial:!1}:{...Mt(e.type,e),points:e.points||[],startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null,elbowed:!1},Qc=e=>({...Mt("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1],crop:e.crop??null});var Pt=new Map,_f=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)/,Wf=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}\.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,jf=/^https:\/\/(?:www\.)?figma\.com/,Jc=/^https:\/\/gist\.github\.com\/([\w_-]+)\/([\w_-]+)/,Vf=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist\.github\.com\/.*?)\.js["']/i,Uf=/^(?:https?:\/\/)?forms\.microsoft\.com\//,eu=/(?:https?:\/\/)?(?:(?:w){3}\.)?(?:twitter|x)\.com\/[^/]+\/status\/(\d+)/,Yf=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:twitter|x)\.com\/[^"']*)/i,Xf=/^https:\/\/(?:www\.)?val\.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,$f=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,tu=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,nu=/^(?:http(?:s)?:\/\/)?(?:www\.)?reddit\.com\/r\/([a-zA-Z0-9_]+)\/comments\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9_]+)\/?(?:\?[^#\s]*)?(?:#[^\s]*)?$/,Zf=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:www\.)?reddit\.com\/[^"']*)/i,iu=e=>{let t;try{let s=new URL(e.startsWith("http")?e:`https://${e}`);t=s.searchParams.get("t")||s.searchParams.get("start")}catch{t=e.match(/[?&#](?:t|start)=([^&#\s]+)/)?.[1]}if(!t)return 0;if(/^\d+$/.test(t))return parseInt(t,10);let n=t.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/);if(!n)return 0;let[,o="0",i="0",r="0"]=n;return parseInt(o)*3600+parseInt(i)*60+parseInt(r)},qf=e=>{try{let t=new URL(e.startsWith("http")?e:`https://${e}`);if(t.hostname.replace(/^www\./,"")!=="drive.google.com")return null;let o=null,i=t.pathname.match(/^\/file\/d\/([^/]+)(?:\/|$)/);if(i?.[1]?o=i[1]:(t.pathname==="/open"||t.pathname==="/uc")&&(o=t.searchParams.get("id")),!o||!/^[a-zA-Z0-9_-]+$/.test(o))return null;let r=t.searchParams.get("resourcekey"),s=iu(t.toString());return{fileId:o,resourceKey:r&&/^[a-zA-Z0-9_-]+$/.test(r)?r:void 0,timestamp:s>0?s:void 0}}catch{return null}},sa=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","drive.google.com","figma.com","link.excalidraw.com","gist.github.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","val.town","giphy.com","reddit.com","forms.microsoft.com"]),ou=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","drive.google.com","figma.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","reddit.com","forms.microsoft.com"]),ra=e=>`<html><body>${e}</body></html>`,V4=e=>{if(!e)return null;if(Pt.has(e))return Pt.get(e);let t=e,n=ou.has(aa(e,ou)||""),o="generic",i={w:560,h:840},r=e.match(_f);if(r?.[2]){let c=iu(t),p=c>0?`&start=${c}`:"",h=e.includes("shorts");switch(o="video",r[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${r[2]}?enablejsapi=1${p}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${r[2]}&enablejsapi=1${p}`;break;default:e=`https://www.youtube.com/embed/${r[2]}?enablejsapi=1${p}`;break}return i=h?{w:315,h:560}:{w:560,h:315},Pt.set(t,{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}}}let s=e.match(Wf);if(s?.[1]){let c=s?.[1],p=/^\d+$/.test(c)?void 0:new URIError("Invalid embed link format");return o="video",e=`https://player.vimeo.com/video/${c}?api=1`,i={w:560,h:315},Pt.set(t,{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:i,type:o,error:p,sandbox:{allowSameOrigin:n}}}let a=qf(e);if(a){o="video";let c=new URLSearchParams;a.resourceKey&&c.set("resourcekey",a.resourceKey),a.timestamp&&c.set("t",`${a.timestamp}`);let p=c.toString();return e=`https://drive.google.com/file/d/${a.fileId}/preview${p?`?${p}`:""}`,i={w:560,h:315},Pt.set(t,{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}}}if(e.match(jf))return o="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,i={w:550,h:550},Pt.set(t,{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}};let d=e.match(Xf);if(d)return e=d[1]==="embed"?d[0]:d[0].replace("/v","/embed"),Pt.set(t,{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}};if(Uf.test(e)&&!e.includes("embed=true")&&(e+=e.includes("?")?"&embed=true":"?embed=true"),eu.test(e)){let c=e.match(eu)[1],p=ia(`https://twitter.com/x/status/${c}`),h={type:"document",srcdoc:m=>ra(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${m}"><a href="${p}"></a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`),intrinsicSize:{w:480,h:480},sandbox:{allowSameOrigin:n}};return Pt.set(t,h),h}if(nu.test(e)){let[,c,p,h]=e.match(nu),m=ia(`https://reddit.com/r/${c}/comments/${p}/${h}`),f={type:"document",srcdoc:g=>ra(`<blockquote class="reddit-embed-bq" data-embed-theme="${g}"><a href="${m}"></a><br></blockquote><script async="" src="https://embed.reddit.com/widgets.js" charset="UTF-8"><\/script>`),intrinsicSize:{w:480,h:480},sandbox:{allowSameOrigin:n}};return Pt.set(t,f),f}if(Jc.test(e)){let[,c,p]=e.match(Jc),h=ia(`https://gist.github.com/${c}/${p}`),m={type:"document",srcdoc:()=>ra(`
22
+ <script src="${h}.js"><\/script>
22
23
  <style type="text/css">
23
24
  * { margin: 0px; }
24
25
  table, .gist { height: 100%; }
25
26
  .gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
26
27
  </style>
27
- `),intrinsicSize:{w:550,h:720},sandbox:{allowSameOrigin:n}};return Et.set(e,m),m}return Et.set(e,{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}},XI=e=>{let t;no(e)?t="IFrame element":t=!e.link||e?.link===""?"Empty Web-Embed":e.link;let n=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),i=lE.Helvetica,o=cE({fontSize:n,fontFamily:i});return Ln({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:i,fontSize:n,text:vt(t,o,e.width-20),textAlign:"center",verticalAlign:dE.MIDDLE,angle:e.angle??0})},ks=(e,t)=>{try{let{hostname:n}=new URL(e),i=n.replace(/^www\./,"");if(t instanceof Set){if(Os.has(i))return i;let r=i.replace(/^([^.]+)/,"*");return Os.has(r)?r:null}let o=t.replace(/^www\./,"");if(i===o)return o}catch{}return null},jI=e=>{let t=e.match(EE);if(t&&t.length===2)return t[1];let n=e.match(wE);if(n&&n.length===2)return n[1];let i=e.match(fE);if(i&&i.length===2)return i[1];if(cc.test(e))return`https://giphy.com/embed/${cc.exec(e)[1]}`;let o=e.match(xE);return o&&o.length===2?o[1]:e},VI=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){let n=t(e);if(typeof n=="boolean")return n}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(let n of t)if(n instanceof RegExp){if(e.match(n))return!0}else if(ks(e,n))return!0;return!1}}return!!ks(e,Os)};P();import{KEYS as Qo,invariant as Jo,toBrandedType as bE}from"@excalidraw/common";import{pointFrom as pc}from"@excalidraw/math";var Zn=100,Bn=100,aS=e=>{switch(e){case Qo.ARROW_UP:return"up";case Qo.ARROW_DOWN:return"down";case Qo.ARROW_RIGHT:return"right";case Qo.ARROW_LEFT:return"left";default:return"right"}},Ec=(e,t,n,i)=>{let o=[...n.values()].reduce((r,s)=>{let a;if(W(s)&&(a=s[e==="predecessors"?"startBinding":"endBinding"])&&s[e==="predecessors"?"endBinding":"startBinding"]?.elementId===t.id){let l=n.get(a.elementId);if(!l)return r;Jo(Ge(l),"not an ExcalidrawBindableElement");let d=e==="predecessors"?s.points[s.points.length-1]:[0,0],c=hi(t,Ke(t,n),[d[0]+s.x,d[1]+s.y]);r.push({relative:l,heading:c})}return r},[]);switch(i){case"up":return o.filter(r=>pe(r.heading,We)).map(r=>r.relative);case"down":return o.filter(r=>pe(r.heading,we)).map(r=>r.relative);case"right":return o.filter(r=>pe(r.heading,fe)).map(r=>r.relative);case"left":return o.filter(r=>pe(r.heading,Re)).map(r=>r.relative)}},Rs=(e,t,n)=>Ec("successors",e,t,n),Fs=(e,t,n)=>Ec("predecessors",e,t,n),PE=(e,t,n)=>{let i=Bn+e.width;if(n==="up"||n==="down"){let a=Zn+e.height,l=e.x,d=e.x+e.width;if(t.every(c=>c.x+c.width<l||c.x>d))return{x:0,y:a*(n==="up"?-1:1)}}else if(n==="right"||n==="left"){let a=e.y,l=e.y+e.height;if(t.every(d=>d.y+d.height<a||d.y>l))return{x:(Bn+e.width)*(n==="left"?-1:1),y:0}}if(n==="up"||n==="down"){let a=Zn+e.height,l=(t.length===0,a),d=t.length===0?0:(t.length+1)%2===0?(t.length+1)/2*i:t.length/2*i*-1;return n==="up"?{x:d,y:l*-1}:{x:d,y:l}}let o=Zn+e.height,r=(t.length===0,Bn+e.width),s=t.length===0?0:(t.length+1)%2===0?(t.length+1)/2*o:t.length/2*o*-1;return n==="left"?{x:r*-1,y:s}:{x:r,y:s}},IE=(e,t,n,i)=>{let o=i.getNonDeletedElementsMap(),r=Rs(e,o,n),s=Fs(e,o,n),a=PE(e,[...r,...s],n),l=Dn({type:e.type,x:e.x+a.x,y:e.y+a.y,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});Jo(Pr(l),"not an ExcalidrawFlowchartNodeElement");let d=gc(e,l,n,t,i);return{nextNode:l,bindingArrow:d}},SE=(e,t,n,i,o)=>{let r=[];for(let s=0;s<o;s++){let a,l;if(n==="left"||n==="right"){let u=Zn*(o-1)+o*e.height,m=e.y+e.height/2-u/2,p=Bn+e.width;n==="left"&&(p*=-1),a=e.x+p;let f=(Zn+e.height)*s;l=m+f}else{let u=Bn*(o-1)+o*e.width,m=e.x+e.width/2-u/2,p=Zn+e.height;n==="up"&&(p*=-1),l=e.y+p;let f=(Bn+e.width)*s;a=m+f}let d=Dn({type:e.type,x:a,y:l,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});Jo(Pr(d),"not an ExcalidrawFlowchartNodeElement");let c=gc(e,d,n,t,i);r.push(d),r.push(c)}return r},gc=(e,t,n,i,o)=>{let r,s;switch(n){case"up":{r=e.x+e.width/2,s=e.y-6;break}case"down":{r=e.x+e.width/2,s=e.y+e.height+6;break}case"right":{r=e.x+e.width+6,s=e.y+e.height/2;break}case"left":{r=e.x-6,s=e.y+e.height/2;break}}let l,d;switch(n){case"up":{l=t.x+t.width/2-r,d=t.y+t.height-s+6;break}case"down":{l=t.x+t.width/2-r,d=t.y-s-6;break}case"right":{l=t.x-r-6,d=t.y-s+t.height/2;break}case"left":{l=t.x+t.width-r+6,d=t.y-s+t.height/2;break}}let c=Ko({type:"arrow",x:r,y:s,startArrowhead:null,endArrowhead:i.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[pc(0,0),pc(l,d)],elbowed:!0}),u=o.getNonDeletedElementsMap();Tn(c,e,"orbit","start",o),Tn(c,t,"orbit","end",o);let m=new Map;m.set(e.id,e),m.set(t.id,t),m.set(c.id,c),O.movePoints(c,o,new Map([[1,{point:c.points[1]}]]));let p=Nn(c,bE(new Map([...u.entries(),[e.id,e],[t.id,t],[c.id,c]])),{points:c.points});return{...c,...p}},fc=class{isExploring=!1;sameLevelNodes=[];sameLevelIndex=0;direction=null;visitedNodes=new Set;clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(t,n,i){if(!Ge(t))return null;if(i!==this.direction&&this.clear(),this.visitedNodes.has(t.id)||this.visitedNodes.add(t.id),this.isExploring&&i===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let o=[...Rs(t,n,i),...Fs(t,n,i)];if(o.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=o,this.direction=i,this.visitedNodes.add(o[0].id),o[0].id;if(i===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(t.id);let s=["up","right","down","left"].filter(a=>a!==i).map(a=>[...Rs(t,n,a),...Fs(t,n,a)]).flat().filter(a=>!this.visitedNodes.has(a.id));for(let a of s)if(!this.visitedNodes.has(a.id))return this.visitedNodes.add(a.id),this.isExploring=!0,this.direction=i,a.id}return null}},hc=class{isCreatingChart=!1;numberOfNodes=0;direction="right";pendingNodes=null;createNodes(t,n,i,o){let r=o.getNonDeletedElementsMap();if(i!==this.direction){let{nextNode:s,bindingArrow:a}=IE(t,n,i,o);this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=i,this.pendingNodes=[s,a]}else{this.numberOfNodes+=1;let s=SE(t,n,i,o,this.numberOfNodes);this.isCreatingChart=!0,this.direction=i,this.pendingNodes=s}if(t.frameId){let s=r.get(t.frameId);Jo(s&&oo(s),"not an ExcalidrawFrameElement"),s&&this.pendingNodes.every(a=>ln([a],s,r)||sn(a,s,r))&&(this.pendingNodes=this.pendingNodes.map(a=>ye(a,r,{frameId:t.frameId})))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},lS=(e,t)=>{for(let[,n]of t)if(n.type==="arrow"&&(n.startBinding?.elementId===e.id||n.endBinding?.elementId===e.id))return!0;return!1};P();import{MIME_TYPES as xc,SVG_NS as ME}from"@excalidraw/common";var AE=e=>new Promise((t,n)=>{let i=new Image;i.onload=()=>{t(i)},i.onerror=o=>{n(o)},i.src=e}),pS=async({fileIds:e,files:t,imageCache:n})=>{let i=new Map,o=new Map;return await Promise.all(e.reduce((r,s)=>{let a=t[s];return a&&!i.has(s)?(i.set(s,!0),r.concat((async()=>{try{if(a.mimeType===xc.binary)throw new Error("Only images can be added to ImageCache");let l=AE(a.dataURL),d={image:l,mimeType:a.mimeType};n.set(s,d);let c=await l;n.set(s,{...d,image:c})}catch{o.set(s,!0)}})())):r},[])),{imageCache:n,updatedFiles:i,erroredFiles:o}},fS=e=>e.filter(t=>yn(t)),TE=e=>e?.nodeName.toLowerCase()==="svg",hS=e=>{let t=new DOMParser().parseFromString(e,xc.svg),n=t.querySelector("svg");if(t.querySelector("parsererror")||!TE(n))throw new Error("Invalid SVG");{n.hasAttribute("xmlns")||n.setAttribute("xmlns",ME);let o=n.getAttribute("width"),r=n.getAttribute("height");(o?.includes("%")||o==="auto")&&(o=null),(r?.includes("%")||r==="auto")&&(r=null);let s=n.getAttribute("viewBox");if(!o||!r){if(o=o||"50",r=r||"50",s){let a=s.match(/\d+ +\d+ +(\d+(?:\.\d+)?) +(\d+(?:\.\d+)?)/);a&&([,o,r]=a)}n.setAttribute("width",o),n.setAttribute("height",r)}return s||n.setAttribute("viewBox",`0 0 ${o} ${r}`),n.outerHTML}};P();var vE=e=>({x:(e.minX+e.maxX)/2,y:(e.minY+e.maxY)/2}),wc=(e,t)=>{switch(e){case"height":return t.height;case"width":return t.width;case"size":return t.width*t.height;case"scale":return(t.width+t.height)/2}},DE=(e,t,n)=>n==="first"?wc(e,t[0].boundingBox):t.reduce((o,r)=>o+wc(e,r.boundingBox),0)/t.length,LE=(e,t,n)=>{switch(e){case"height":return t/n.height;case"width":return t/n.width;case"size":return Math.sqrt(t/(n.width*n.height));case"scale":return t/((n.width+n.height)/2)}},yS=(e,t,n,i="average",o="size")=>{let s=Oo(t,n).map(d=>({group:d,boundingBox:Le(d)}));if(s.length===0)return t;let a=DE(o,s,i),l=[];return s.forEach(d=>{let c=LE(o,a,d.boundingBox);if(!Number.isFinite(c)||c<=0)return;let u=vE(d.boundingBox);d.group.forEach(m=>{let p={x:m.x+m.width/2,y:m.y+m.height/2},f={x:u.x+(p.x-u.x)*c,y:u.y+(p.y-u.y)*c},h=m.width*c,E=m.height*c;e.mutateElement(m,{x:f.x-h/2,y:f.y-E/2,width:h,height:E}),l.push(m)})}),l};P();var MS=(e,t,n,i=50)=>{if(!e||e.length===0)return[];let o=[],r=Array.isArray(e[0])?e:e.map(p=>[p]),s=r.length,a=Math.max(1,Math.ceil(Math.sqrt(s))),l=[];for(let p=0;p<s;p+=a)l.push(r.slice(p,p+a));let d=0,c=l.map(p=>{let f=0,h=0,E=p.map(g=>{let[x,w,b,y]=De(g);return{elements:g,bounds:[x,w,b,y],width:b-x,height:y-w}});return E.forEach((g,x)=>{f+=g.width,x<E.length-1&&(f+=i),g.height>h&&(h=g.height)}),d+=h,{unitBounds:E,width:f,maxHeight:h}}),u=d+Math.max(0,l.length-1)*i,m=n-u/2;return c.forEach(p=>{let{unitBounds:f,width:h,maxHeight:E}=p,g=t-h/2;f.forEach(x=>{let[w,b]=x.bounds,y=g-w,I=m-b;x.elements.forEach(S=>{o.push(ge(S,{x:S.x+y,y:S.y+I}))}),g+=x.width+i}),m+=E+i}),o};P();import{pointCenter as BE,normalizeRadians as tr,pointFrom as ie,pointRotateRads as at}from"@excalidraw/math";import{MIN_FONT_SIZE as zs,SHIFT_LOCKING_ANGLE as nr,rescalePoints as yc,getFontString as er}from"@excalidraw/common";var NS=(e,t,n,i,o,r,s,a,l,d,c)=>{let u=i.getNonDeletedElementsMap();if(n.length===1){let[m]=n;if(t==="rotation")W(m)||(CE(m,i,a,l,o),je(m,i));else if(t){let p=n[0].id,f=u.get(p),h=e.get(p);if(f&&h){let{nextWidth:E,nextHeight:g}=FE(f,h,t,a,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r});RE(E,g,f,h,e,i,t,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r})}}return ee(m)&&je(m,i),!0}else if(n.length>1){if(t==="rotation")return OE(e,n,i,a,l,o,d,c),!0;if(t){let{nextWidth:m,nextHeight:p,flipByX:f,flipByY:h,originalBoundingBox:E}=NE(n,e,u,t,a,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r});return zE(n,u,t,i,e,{shouldResizeFromCenter:r,shouldMaintainAspectRatio:s,flipByX:f,flipByY:h,nextWidth:m,nextHeight:p,originalBoundingBox:E}),!0}}return!1},CE=(e,t,n,i,o)=>{let[r,s,a,l]=j(e,t.getNonDeletedElementsMap()),d=(r+a)/2,c=(s+l)/2,u;K(e)?u=0:(u=5*Math.PI/2+Math.atan2(i-c,n-d),o&&(u=u+nr/2,u=u-u%nr),u=tr(u));let m=Dt(e),p={angle:u};if(Ce(e)&&(p={...p},e.startBinding&&Qe(e,"start",t),e.endBinding&&Qe(e,"end",t)),t.mutateElement(e,p),m){let f=t.getElement(m);if(f&&!z(e)){let{x:h,y:E}=mi(e,f,t.getNonDeletedElementsMap());t.mutateElement(f,{angle:u,x:h,y:E})}}},bc=(e,t,n,i)=>Q(e)||Ie(e)?{points:yc(0,t,yc(1,n,e.points,i),i)}:{},Hs=(e,t,n)=>{let i=e.width;if(ce(e)){let s=Se(e,t);s&&(i=it(s,e))}let r=e.fontSize*(n/i);return r<zs?null:{size:r}},GE=(e,t,n,i,o,r,s)=>{let a=n.getNonDeletedElementsMap(),l=t.width*(s/t.height),d=Hs(t,a,l);if(d!==null){if(i.includes("n")||i.includes("s")){let c=ie(e.x,e.y),u=Ns(c,e.width,e.height,l,s,e.angle,i,!1,o);n.mutateElement(t,{fontSize:d.size,width:l,height:s,x:u.x,y:u.y});return}if(i==="e"||i==="w"){let c=lo(er({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),u=Math.max(c,r),m=vt(t.originalText,er(t),Math.abs(u)),p=Ue(m,er(t),t.lineHeight),f=p.height,h=ie(e.x,e.y),E=Ns(h,e.width,e.height,u,f,t.angle,i,!1,o),g={width:Math.abs(u),height:Math.abs(p.height),x:E.x,y:E.y,text:m,autoResize:!1};n.mutateElement(t,g)}}},OE=(e,t,n,i,o,r,s,a)=>{let l=n.getNonDeletedElementsMap(),d=5*Math.PI/2+Math.atan2(o-a,i-s);r&&(d+=nr/2,d-=d%nr);let c=new Map(t.map(u=>[u.id,u]));for(let u of t)if(!K(u)){let[m,p,f,h]=j(u,l),E=(m+f)/2,g=(p+h)/2,x=e.get(u.id)?.angle??u.angle,[w,b]=at(ie(E,g),ie(s,a),d+x-u.angle),y=W(u)?{points:Pl(u,l)}:{x:u.x+(w-E),y:u.y+(b-g),angle:tr(d+x)};n.mutateElement(u,y),je(u,n,{simultaneouslyUpdated:t}),Ce(u)&&(u.startBinding&&(c.has(u.startBinding.elementId)||Qe(u,"start",n)),u.endBinding&&(c.has(u.endBinding.elementId)||Qe(u,"end",n)));let I=V(u,l);if(I&&!z(u)){let{x:S,y:A}=mi(u,I,l);n.mutateElement(I,{x:S,y:A,angle:tr(d+x)})}}n.triggerUpdate()},zS=(e,t,n,i,o)=>{let[r,s,a,l]=t.length===1?j(t[0],n):De(t),d=(r+a)/2,c=(s+l)/2,u=t.length===1?t[0].angle:0;switch([i,o]=at(ie(i,o),ie(d,c),-u),e){case"n":return at(ie(i-(r+a)/2,o-s),ie(0,0),u);case"s":return at(ie(i-(r+a)/2,o-l),ie(0,0),u);case"w":return at(ie(i-r,o-(s+l)/2),ie(0,0),u);case"e":return at(ie(i-a,o-(s+l)/2),ie(0,0),u);case"nw":return at(ie(i-r,o-s),ie(0,0),u);case"ne":return at(ie(i-a,o-s),ie(0,0),u);case"sw":return at(ie(i-r,o-l),ie(0,0),u);case"se":return at(ie(i-a,o-l),ie(0,0),u);default:return[0,0]}},HS=(e,t)=>{let[,[n,i]]=t.points;return e==="nw"&&(n<0||i<0)||e==="ne"&&n>=0||e==="sw"&&n<=0||e==="se"&&(n>0||i>0)?"end":"origin"},kE=(e,t,n)=>{if(n)return"center";if(t)switch(e){case"n":return"south-side";case"e":return"west-side";case"s":return"north-side";case"w":return"east-side";case"ne":return"bottom-left";case"nw":return"bottom-right";case"se":return"top-left";case"sw":return"top-right"}return["e","se","s"].includes(e)?"top-left":["n","nw","w"].includes(e)?"bottom-right":e==="ne"?"bottom-left":"top-right"},Ns=(e,t,n,i,o,r,s,a,l)=>{let d=kE(s,a,l),[c,u]=e;switch(d){case"top-left":return{x:c+(t-i)/2+(i-t)/2*Math.cos(r)+(n-o)/2*Math.sin(r),y:u+(n-o)/2+(i-t)/2*Math.sin(r)+(o-n)/2*Math.cos(r)};case"top-right":return{x:c+(t-i)/2*(Math.cos(r)+1)+(n-o)/2*Math.sin(r),y:u+(n-o)/2+(t-i)/2*Math.sin(r)+(o-n)/2*Math.cos(r)};case"bottom-left":return{x:c+(t-i)/2*(1-Math.cos(r))+(o-n)/2*Math.sin(r),y:u+(n-o)/2*(Math.cos(r)+1)+(i-t)/2*Math.sin(r)};case"bottom-right":return{x:c+(t-i)/2*(Math.cos(r)+1)+(o-n)/2*Math.sin(r),y:u+(n-o)/2*(Math.cos(r)+1)+(t-i)/2*Math.sin(r)};case"center":return{x:c-(i-t)/2,y:u-(o-n)/2};case"east-side":return{x:c+(t-i)/2*(Math.cos(r)+1),y:u+(t-i)/2*Math.sin(r)+(n-o)/2};case"west-side":return{x:c+(t-i)/2*(1-Math.cos(r)),y:u+(i-t)/2*Math.sin(r)+(n-o)/2};case"north-side":return{x:c+(t-i)/2+(n-o)/2*Math.sin(r),y:u+(o-n)/2*(Math.cos(r)-1)};case"south-side":return{x:c+(t-i)/2+(o-n)/2*Math.sin(r),y:u+(n-o)/2*(Math.cos(r)+1)}}},RE=(e,t,n,i,o,r,s,{shouldInformMutation:a=!0,shouldMaintainAspectRatio:l=!1,shouldResizeFromCenter:d=!1}={})=>{if(ee(n)&&ee(i))return GE(i,n,r,s,d,e,t);let c={},u=r.getNonDeletedElementsMap(),m=V(n,u);if(m){let E=o.get(m.id);if(E&&(c={fontSize:E.fontSize}),l){let g={...n,width:e,height:t},x=Hs(m,u,it(g,m));if(x===null)return;c={fontSize:x.size}}else{let g=Wa(er(m),m.lineHeight),x=Xa(m.fontSize,m.lineHeight);e=Math.max(e,g),t=Math.max(t,x)}}let p=bc(i,e,t,!0),f=ie(i.x,i.y);if(Q(i)){let[E,g]=ae(i,o);f=ie(E,g)}let h=Ns(f,i.width,i.height,e,t,i.angle,s,l,d);if(Q(i)&&p.points){let E=i.x-f[0],g=i.y-f[1];h.x+=E,h.y+=g;let x=p.points[0][0],w=p.points[0][1];h.x+=x,h.y+=w,p.points=p.points.map(b=>ie(b[0]-x,b[1]-w))}if(e<0&&(h.x=h.x+e),t<0&&(h.y=h.y+t),"scale"in n&&"scale"in i&&r.mutateElement(n,{scale:[(Math.sign(e)||i.scale[0])*i.scale[0],(Math.sign(t)||i.scale[1])*i.scale[1]]}),z(n)&&m&&l){let E=e/n.width*m.fontSize;if(E<zs)return;c.fontSize=E}if(e!==0&&t!==0&&Number.isFinite(h.x)&&Number.isFinite(h.y)){let E={...h,width:Math.abs(e),height:Math.abs(t),...p};Ce(n)&&(n.startBinding&&(E={...E},n.startBinding&&Qe(n,"start",r)),n.endBinding&&(E={...E,endBinding:null})),r.mutateElement(n,E,{informMutation:a,isDragging:!1}),m&&c!=null&&r.mutateElement(m,{fontSize:c.fontSize}),In(n,r,s,l),je(n,r)}},FE=(e,t,n,i,o,{shouldMaintainAspectRatio:r=!1,shouldResizeFromCenter:s=!1}={})=>{let[a,l,d,c]=Xt(t,t.width,t.height,!0),u=ie(a,l),m=ie(d,c),p=BE(u,m),f=at(ie(i,o),p,-t.angle),[h,E,g,x]=Xt(e,e.width,e.height,!0),w=g-h,b=x-E,y=m[0]-u[0],I=m[1]-u[1],S=y/w,A=I/b;n.includes("e")&&(S=(f[0]-u[0])/w),n.includes("s")&&(A=(f[1]-u[1])/b),n.includes("w")&&(S=(m[0]-f[0])/w),n.includes("n")&&(A=(m[1]-f[1])/b);let M=e.width*S,k=e.height*A;if(s&&(M=2*M-t.width,k=2*k-t.height),r){let L=Math.abs(M)/t.width,G=Math.abs(k)/t.height;if(n.length===1&&(k*=L,M*=G),n.length===2){let B=Math.max(L,G);M=t.width*B*Math.sign(M),k=t.height*B*Math.sign(k)}}return{nextWidth:M,nextHeight:k}},NE=(e,t,n,i,o,r,{shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:a=!1}={})=>{let l=e.map(B=>t.get(B.id)),d=l.reduce((B,U)=>{if(!Q(U))return B;let N=Dt(U);if(!N)return B;let Y=t.get(N)??null;return ce(Y)?[...B,{...Y,...O.getBoundTextElementPosition(U,Y,n)}]:B},[]),c=Le(l.map(B=>B).concat(d)),{minX:u,minY:m,maxX:p,maxY:f,midX:h,midY:E}=c,g=p-u,x=f-m,w={ne:[u,f],se:[u,m],sw:[p,m],nw:[p,f],e:[u,m+x/2],w:[p,m+x/2],n:[u+g/2,f],s:[u+g/2,m]},[b,y]=a?[h,E]:w[i],I=a?2:1,S=Math.max(Math.abs(o-b)/g||0,Math.abs(r-y)/x||0)*I,A=i.includes("e")||i.includes("w")?Math.abs(o-b)*I:g,M=i.includes("n")||i.includes("s")?Math.abs(r-y)*I:x;s&&(A=g*S*Math.sign(o-b),M=x*S*Math.sign(r-y));let k={ne:[o<b,r>y],se:[o<b,r<y],sw:[o>b,r<y],nw:[o>b,r>y],e:[o<b,!1],w:[o>b,!1],n:[!1,r>y],s:[!1,r<y]},[L,G]=k[i].map(B=>B);return{originalBoundingBox:c,nextWidth:A,nextHeight:M,flipByX:L,flipByY:G}},zE=(e,t,n,i,o,{shouldMaintainAspectRatio:r=!1,shouldResizeFromCenter:s=!1,flipByX:a=!1,flipByY:l=!1,nextHeight:d,nextWidth:c,originalBoundingBox:u}={})=>{if(c===void 0&&d===void 0&&a===void 0&&l===void 0||d===0||c===0)return;o||(o=t);let m=e.reduce((I,S)=>{let A=o.get(S.id);return A&&I.push({orig:A,latest:S}),I},[]),p;if(u)p=u;else{let I=m.reduce((S,{orig:A})=>{if(!Q(A))return S;let M=Dt(A);if(!M)return S;let k=o.get(M)??null;return ce(k)?[...S,{...k,...O.getBoundTextElementPosition(A,k,t)}]:S},[]);p=Le(m.map(({orig:S})=>S).concat(I))}let{minX:f,minY:h,maxX:E,maxY:g,midX:x,midY:w}=p,b=E-f,y=g-h;if(c===void 0&&d===void 0&&(c=b,d=y),r&&(c===void 0?c=d*(b/y):d===void 0?d=c*(y/b):Math.abs(c/d-b/y)>.001&&(c=d*(b/y))),c&&d){let I=n.includes("e")||n.includes("w")?Math.abs(c)/b:1,S=n.includes("n")||n.includes("s")?Math.abs(d)/y:1,A;n.length===1?A=n.includes("e")||n.includes("w")?I:S:A=Math.max(Math.abs(c)/b||0,Math.abs(d)/y||0);let M={ne:[f,g],se:[f,h],sw:[E,h],nw:[E,g],e:[f,h+y/2],w:[E,h+y/2],n:[f+b/2,g],s:[f+b/2,h]},[k,L]=s?[x,w]:M[n],G=r||m.some(T=>T.latest.angle!==0||ee(T.latest)||Vl(T.latest));G&&(I=A,S=A);let[B,U]=[a?-1:1,l?-1:1],N=[];for(let{orig:T,latest:$}of m){if(ee(T)&&ce(T))continue;let Z=T.width*I,gt=T.height*S,lt=tr(T.angle*B*U),ki=Q(T)||Ie(T),ar=T.x-k,Ri=T.y-L,qn=a&&!ki?Z:0,lr=l&&!ki?gt:0,Fi=k+B*(ar*I+qn),Ni=L+U*(Ri*S+lr),He=bc(T,Z*B,gt*U,!1),Ve={x:Fi,y:Ni,width:Z,height:gt,angle:lt,...He};if(W(T)&&(T.startBinding&&(Ve.startBinding={...T.startBinding,fixedPoint:[a?-T.startBinding.fixedPoint[0]+1:T.startBinding.fixedPoint[0],l?-T.startBinding.fixedPoint[1]+1:T.startBinding.fixedPoint[1]]}),T.endBinding&&(Ve.endBinding={...T.endBinding,fixedPoint:[a?-T.endBinding.fixedPoint[0]+1:T.endBinding.fixedPoint[0],l?-T.endBinding.fixedPoint[1]+1:T.endBinding.fixedPoint[1]]}),T.fixedSegments&&He.points&&(Ve.fixedSegments=T.fixedSegments.map(xt=>({...xt,start:He.points[xt.index-1],end:He.points[xt.index]})))),xe(T)&&(Ve.scale=[T.scale[0]*B,T.scale[1]*U]),ee(T)){let xt=Hs(T,t,Z);if(!xt)return;Ve.fontSize=xt.size}let _t=o.get(Dt(T)??"");if(_t)if(G){let xt=_t.fontSize*A;if(xt<zs)return;Ve.boundTextFontSize=xt}else Ve.boundTextFontSize=_t.fontSize;N.push({element:$,update:Ve})}let Y=N.map(({element:T})=>T),F=new Map(N.map(({element:T})=>[T.id,T]));for(let{element:T,update:{boundTextFontSize:$,...Z}}of N){let{angle:gt}=Z;i.mutateElement(T,Z),je(T,i,{simultaneouslyUpdated:Y}),Ce(T)&&(T.startBinding&&(F.has(T.startBinding.elementId)||Qe(T,"start",i)),T.endBinding&&(F.has(T.endBinding.elementId)||Qe(T,"end",i)));let lt=V(T,t);lt&&$&&(i.mutateElement(lt,{fontSize:$,angle:Q(T)?void 0:gt}),In(T,i,n,!0))}i.triggerUpdate()}};P();import{pointFrom as Je,pointOnLineSegment as Tc,pointRotateRads as or}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as js}from"@excalidraw/common";P();import{DEFAULT_TRANSFORM_HANDLE_SPACING as Us}from"@excalidraw/common";import{pointFrom as Pc,pointRotateRads as HE}from"@excalidraw/math";var Ic={mouse:8,pen:16,touch:28},_E=16,Mc={e:!0,s:!0,n:!0,w:!0},VS={e:!0,s:!0,n:!0,w:!0},$S={e:!0,s:!0,n:!0,w:!0,rotation:!0},Sc={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},_s={e:!0,s:!0,n:!0,w:!0},Ht=(e,t,n,i,o,r,s)=>{let[a,l]=HE(Pc(e+n/2,t+i/2),Pc(o,r),s);return[a-n/2,l-i/2,n,i]},ir=e=>!(e.formFactor==="phone"&&e.userAgent.isMobileDevice),Ys=e=>ir(e)?Mc:{},Ws=([e,t,n,i,o,r],s,a,l,d={},c=4,u=Us)=>{let m=Ic[l],p=m/a.value,f=m/a.value,h=m/a.value,E=m/a.value,g=n-e,x=i-t,w=c/a.value,b=(m-u*2)/(2*a.value),y={nw:d.nw?void 0:Ht(e-w-h+b,t-w-E+b,p,f,o,r,s),ne:d.ne?void 0:Ht(n+w-b,t-w-E+b,p,f,o,r,s),sw:d.sw?void 0:Ht(e-w-h+b,i+w-b,p,f,o,r,s),se:d.se?void 0:Ht(n+w-b,i+w-b,p,f,o,r,s),rotation:d.rotation?void 0:Ht(e+g/2-p/2,t-w-E+b-_E/a.value,p,f,o,r,s)},I=5*Ic.mouse/a.value;return Math.abs(g)>I&&(d.n||(y.n=Ht(e+g/2-p/2,t-w-E+b,p,f,o,r,s)),d.s||(y.s=Ht(e+g/2-p/2,i+w-b,p,f,o,r,s))),Math.abs(x)>I&&(d.w||(y.w=Ht(e-w-h+b,t+x/2-f/2,p,f,o,r,s)),d.e||(y.e=Ht(n+w-b,t+x/2-f/2,p,f,o,r,s))),y},Ac=(e,t,n,i="mouse",o=Mc)=>{if(e.locked||W(e))return{};if(e.type==="freedraw"||Q(e)){if(e.points.length===2){let[,s]=e.points;s[0]===0||s[1]===0?o=_s:s[0]>0&&s[1]<0?o=Sc:s[0]>0&&s[1]>0?o=_s:s[0]<0&&s[1]>0?o=Sc:s[0]<0&&s[1]<0&&(o=_s)}}else K(e)&&(o={...o,rotation:!0});let r=Q(e)?Us+8:xe(e)?0:Us;return Ws(j(e,n,!0),e.angle,t,i,o,r,xe(e)?0:void 0)},ZS=(e,t,n)=>{if(t.selectedLinearElement?.isEditing||t.selectedLinearElement?.isDragging)return!1;if(e.length>1)return!0;let i=e[0];return W(i)?!1:Q(i)?i.points.length>2&&!n.userAgent.isMobileDevice:!0};var Vs=(e,t,n)=>t>=e[0]&&t<=e[0]+e[2]&&n>=e[1]&&n<=e[1]+e[3],UE=(e,t,n,i,o,r,s,a)=>{if(!n.selectedElementIds[e.id])return!1;let{rotation:l,...d}=Ac(e,r,t,s,Ys(a));if(l&&Vs(l,i,o))return"rotation";let c=Object.keys(d).filter(u=>{let m=d[u];return m?Vs(m,i,o):!1});if(c.length>0)return c[0];if(ir(a)){let[u,m,p,f,h,E]=j(e,t);if(!(Q(e)&&e.points.length<=2)){let g=xe(e)?0:js/r.value,x=js/r.value,w=vc(Je(u-g,m-g),Je(p+g,f+g),Je(h,E),e.angle);for(let[b,y]of Object.entries(w))if(Tc(Je(i,o),y,x))return b}}return!1},iM=(e,t,n,i,o,r,s,a)=>e.reduce((l,d)=>{if(l)return l;let c=UE(d,s,t,n,i,o,r,a);return c?{element:d,transformHandleType:c}:null},null),oM=([e,t,n,i],o,r,s,a,l)=>{let d=Ws([e,t,n,i,(e+n)/2,(t+i)/2],0,s,a,Ys(l)),c=Object.keys(d).find(u=>{let m=d[u];return m&&Vs(m,o,r)});if(c)return c;if(ir(l)){let u=(e+n)/2,m=(t+i)/2,p=js/s.value,f=vc(Je(e-p,t-p),Je(n+p,i+p),Je(u,m),0);for(let[h,E]of Object.entries(f))if(Tc(Je(o,r),E,p))return h}return!1},Xs=["ns","nesw","ew","nwse"],YE=(e,t)=>{let n=Xs.indexOf(e);if(n>=0){let i=Math.round(t/(Math.PI/4));e=Xs[(n+i)%Xs.length]}return e},rM=e=>{let{element:t,transformHandleType:n}=e,i=t&&Math.sign(t.height)*Math.sign(t.width)===-1,o=null;switch(n){case"n":case"s":o="ns";break;case"w":case"e":o="ew";break;case"nw":case"se":i?o="nesw":o="nwse";break;case"ne":case"sw":i?o="nwse":o="nesw";break;case"rotation":return"grab"}return o&&t&&(o=YE(o,t.angle)),o?`${o}-resize`:""},vc=([e,t],[n,i],o,r)=>{let s=or(Je(e,t),o,r),a=or(Je(n,t),o,r),l=or(Je(e,i),o,r),d=or(Je(n,i),o,r);return{n:[s,a],e:[a,d],s:[d,l],w:[l,s]}};P();var dM=(e,t)=>!!(!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(e.activeTool.type!=="custom"&&(e.editingTextElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="lasso"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||ft(t,e).length));P();import{pointFrom as rr}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as WE,DEFAULT_FONT_SIZE as XE,TEXT_ALIGN as jE,VERTICAL_ALIGN as VE,getSizeFromPoints as $E,randomId as ZE,arrayToMap as qE,assertNever as $s,cloneJSON as Lc,getFontString as KE,isDevEnv as QE,toBrandedType as JE,getLineHeight as eg}from"@excalidraw/common";var sr={width:100,height:0},En=100,tg=(e,t,n)=>{let i=Ln({x:0,y:0,textAlign:jE.CENTER,verticalAlign:VE.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:i.id})}),po(i,e,n),[e,i]},Dc=(e,t,n,i,o)=>{let r,s;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let c=t?.width??En,u=t?.height??En,m;t.id&&(m=i.getElement(t.id),m||console.error(`No element for start binding with id ${t.id} found`));let p=t.x||e.x-c,f=t.y||e.y-u/2,h=m?m.type:t.type;if(h){if(h==="text"){let E="";m&&m.type==="text"?E=m.text:t.type==="text"&&(E=t.text),E||console.error(`No text found for start binding text element for ${e.id}`),r=Ln({x:p,y:f,type:"text",...m,...t,text:E}),Object.assign(r,{x:t.x||e.x-r.width,y:t.y||e.y-r.height/2})}else switch(h){case"rectangle":case"ellipse":case"diamond":{r=Dn({x:p,y:f,width:c,height:u,...m,...t,type:h});break}default:$s(e,`Unhandled element start type "${t.type}"`,!0)}Tn(e,r,"orbit","start",o)}}if(n){let c=n?.height??En,u=n?.width??En,m;n.id&&(m=i.getElement(n.id),m||console.error(`No element for end binding with id ${n.id} found`));let p=n.x||e.x+e.width,f=n.y||e.y-c/2,h=m?m.type:n.type;if(h){if(h==="text"){let E="";m&&m.type==="text"?E=m.text:n.type==="text"&&(E=n.text),E||console.error(`No text found for end binding text element for ${e.id}`),s=Ln({x:p,y:f,type:"text",...m,...n,text:E}),Object.assign(s,{y:n.y||e.y-s.height/2})}else switch(h){case"rectangle":case"ellipse":case"diamond":{s=Dn({x:p,y:f,width:u,height:c,...m,...n,type:h});break}default:$s(e,`Unhandled element end type "${h}"`,!0)}Tn(e,s,"orbit","end",o)}}if(e.points.length<2)return{linearElement:e,startBoundElement:r,endBoundElement:s};let a=e.points.length-1,l=.5,d=Lc(e.points);return e.points[a][0]>e.points[a-1][0]&&(d[0][0]=l,d[a][0]-=l),e.points[a][0]<e.points[a-1][0]&&(d[0][0]=-l,d[a][0]+=l),e.points[a][1]>e.points[a-1][1]&&(d[0][1]=l,d[a][1]-=l),e.points[a][1]<e.points[a-1][1]&&(d[0][1]=-l,d[a][1]+=l),Object.assign(e,O.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:r,endBoundElement:s}},Zs=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>vs(Array.from(this.excalidrawElements.values()));getElementsMap=()=>JE(qE(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},IM=(e,t)=>{if(!e)return[];let n=Lc(e),i=new Zs,o=new Map,r=new Map;for(let l of n){let d,c=l.id;switch(t?.regenerateIds!==!1&&Object.assign(l,{id:ZE()}),l.type){case"rectangle":case"ellipse":case"diamond":{let m=l?.label?.text&&l.width===void 0?0:l?.width||En,p=l?.label?.text&&l.height===void 0?0:l?.height||En;d=Dn({...l,width:m,height:p});break}case"line":{let m=l.width||sr.width,p=l.height||sr.height;d=sc({width:m,height:p,points:[rr(0,0),rr(m,p)],...l});break}case"arrow":{let m=l.width||sr.width,p=l.height||sr.height;d=Ko({width:m,height:p,endArrowhead:"arrow",points:[rr(0,0),rr(m,p)],...l,type:"arrow"}),Object.assign(d,$E(d.points));break}case"text":{let m=l?.fontFamily||WE,p=l?.fontSize||XE,f=l?.lineHeight||eg(m),h=l.text??"",E=ui(h),g=Ue(E,KE({fontFamily:m,fontSize:p}),f);d=Ln({width:g.width,height:g.height,fontFamily:m,fontSize:p,...l});break}case"image":{d=ac({width:l?.width||En,height:l?.height||En,...l});break}case"frame":{d=ic({x:0,y:0,...l});break}case"magicframe":{d=oc({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{d=l;break}default:d=l,$s(l,`Unhandled element type "${l.type}"`,!0)}i.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(i.add(d),o.set(d.id,l),c&&r.set(c,d.id))}let s=i.getElementsMap(),a=new $n(s);for(let[l,d]of o){let c=i.getElement(l);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[u,m]=tg(c,d?.label,a);if(i.add(u),i.add(m),z(u)){let p=d.type==="arrow"?d?.start:void 0,f=d.type==="arrow"?d?.end:void 0;if(p&&p.id){let x=r.get(p.id);x&&Object.assign(p,{id:x})}if(f&&f.id){let x=r.get(f.id);x&&Object.assign(f,{id:x})}let{linearElement:h,startBoundElement:E,endBoundElement:g}=Dc(u,p,f,i,a);u=h,i.add(h),i.add(E),i.add(g)}}else switch(d.type){case"arrow":{let{start:u,end:m}=d;if(u&&u.id){let E=r.get(u.id);Object.assign(u,{id:E})}if(m&&m.id){let E=r.get(m.id);Object.assign(m,{id:E})}let{linearElement:p,startBoundElement:f,endBoundElement:h}=Dc(c,u,m,i,a);i.add(p),i.add(f),i.add(h);break}}break}}}for(let[l,d]of o){if(d.type!=="frame"&&d.type!=="magicframe")continue;let c=i.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let u=[];d.children.forEach(y=>{let I=r.get(y);if(!I)throw new Error(`Element with ${y} wasn't mapped correctly`);let S=i.getElement(I);if(!S)throw new Error(`Frame element with id ${I} doesn't exist`);Object.assign(S,{frameId:c.id}),S?.boundElements?.forEach(A=>{let M=i.getElement(A.id);if(!M)throw new Error(`Bound element with id ${A.id} doesn't exist`);Object.assign(M,{frameId:c.id}),u.push(M)}),u.push(S)});let[m,p,f,h]=De(u),E=10;m=m-E,p=p-E,f=f+E,h=h+E;let g=c?.x||m,x=c?.y||p,w=c?.width||f-m,b=c?.height||h-p;Object.assign(c,{x:g,y:x,width:w,height:b}),QE()&&d.children.length&&(c?.x||c?.y||c?.width||c?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return i.getElements()};P();import{arrayToMap as Cc,findIndex as Gc,findLastIndex as Oc}from"@excalidraw/common";var qs=(e,t)=>e.frameId===t||e.id===t,kc=(e,t,n)=>{let i=[],o=[],r=null,s=-1,a=Cc(n||ft(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++s<e.length;){let l=e[s];a.get(l.id)?(o.length&&(i=i.concat(o),o=[]),i.push(s),r=s+1):l.isDeleted&&r===s?(r=s+1,o.push(s)):o=[]}return i},ng=e=>{let t=0;return e.reduce((n,i,o)=>(o>0&&e[o-1]!==i-1&&(t=++t),(n[t]||(n[t]=[])).push(i),n),[])},Bc=(e,t,n,i)=>{if("containerId"in e&&e.containerId){let o=i.getElement(e.containerId);if(o)return n==="left"?Math.min(t.indexOf(o),t.indexOf(e)):Math.max(t.indexOf(o),t.indexOf(e))}else{let o=e.boundElements?.find(r=>r.type!=="arrow")?.id;if(o){let r=i.getElement(o);if(r)return n==="left"?Math.min(t.indexOf(r),t.indexOf(e)):Math.max(t.indexOf(r),t.indexOf(e))}}},ig=(e,t)=>{let n=-1,i=-1;return e.forEach((o,r)=>{qs(o,t)&&(n===-1&&(n=r),i=r)}),n===-1?[]:e.slice(n,i+1)},GM=(e,t,n,i,o)=>{let r=Lt(e,n,i);if(!r)return n;let s=V(r,i),a=ee(r)?Se(r,i):null,l=[r.id,s?.id,a?.id].filter(u=>!!u),d=n.findIndex(u=>l.includes(u.id)),c=n.findIndex(u=>u.id===t.id);if(c!==-1&&d!==-1&&c<d){let u=Array.from(n),m=u.splice(c,1)[0];u.splice(d,0,m),o.replaceAllElements(u)}return n},og=(e,t,n,i,o,r)=>{let s=t[n],a=m=>m.isDeleted?!1:o?m.frameId===o:e.editingGroupId?m.groupIds.includes(e.editingGroupId):!0,l=i==="left"?Oc(t,m=>a(m),Math.max(0,n-1)):Gc(t,m=>a(m),n+1),d=t[l];if(!d)return-1;if(e.editingGroupId){if(s?.groupIds.join("")===d?.groupIds.join(""))return Bc(d,t,i,r)??l;if(!d?.groupIds.includes(e.editingGroupId))return-1}if(!o&&(d.frameId||K(d))){let m=ig(t,d.frameId||d.id);return i==="left"?t.indexOf(m[0]):t.indexOf(m[m.length-1])}if(!d.groupIds.length)return Bc(d,t,i,r)??l;let c=e.editingGroupId?d.groupIds[d.groupIds.indexOf(e.editingGroupId)-1]:d.groupIds[d.groupIds.length-1],u=ve(t,c);return u.length?i==="left"?t.indexOf(u[0]):t.indexOf(u[u.length-1]):l},Rc=(e,t)=>t.reduce((n,i)=>{let o=e[i];return n.set(o.id,o),n},new Map),Fc=(e,t,n,i)=>{let o=kc(e,t),r=Rc(e,o),s=ng(o);n==="right"&&(s=s.reverse());let a=new Set(o.filter(l=>K(e[l])).map(l=>e[l].id));return s.forEach((l,d)=>{let c=l[0],u=l[l.length-1],m=n==="left"?c:u,p=l.some(w=>{let b=e[w];return b.frameId&&a.has(b.frameId)})?null:e[m]?.frameId,f=og(t,e,m,n,p,i);if(f===-1||m===f)return;let h=n==="left"?e.slice(0,f):e.slice(0,c),E=e.slice(c,u+1),g=n==="left"?e.slice(f,c):e.slice(u+1,f+1),x=n==="left"?e.slice(u+1):e.slice(f+1);e=n==="left"?[...h,...E,...g,...x]:[...h,...g,...E,...x]}),Oi(e,r),e},Nc=(e,t,n,i,o)=>{let r=kc(e,t,o),s=Rc(e,r),a=[],l,d;if(n==="left"){if(i)l=Gc(e,f=>qs(f,i));else if(t.editingGroupId){let f=ve(e,t.editingGroupId);if(!f.length)return e;l=e.indexOf(f[0])}else l=0;d=r[r.length-1]}else{if(i)d=Oc(e,f=>qs(f,i));else if(t.editingGroupId){let f=ve(e,t.editingGroupId);if(!f.length)return e;d=e.indexOf(f[f.length-1])}else d=e.length-1;l=r[0]}l===-1&&(l=0);for(let f=l;f<d+1;f++)r.includes(f)||a.push(e[f]);let c=Array.from(s.values()),u=e.slice(0,l),m=e.slice(d+1),p=n==="left"?[...u,...c,...a,...m]:[...u,...a,...c,...m];return Oi(p,s),p};function zc(e,t,n,i){let o=Cc(ft(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),r={regularElements:[],frameChildren:new Map},s=new Set;for(let d of e)o.has(d.id)&&K(d)&&s.add(d.id);for(let d of e)if(o.has(d.id))if(K(d)||d.frameId&&s.has(d.frameId))r.regularElements.push(d);else if(!d.frameId)r.regularElements.push(d);else{let c=r.frameChildren.get(d.frameId)||[];c.push(d),r.frameChildren.set(d.frameId,c)}let a=e,l=Array.from(r.frameChildren.entries());for(let[d,c]of l)a=i(e,t,n,d,c);return i(a,t,n,null,r.regularElements)}var OM=(e,t,n)=>Fc(e,t,"left",n),kM=(e,t,n)=>Fc(e,t,"right",n),RM=(e,t)=>zc(e,t,"left",Nc),FM=(e,t)=>zc(e,t,"right",Nc);var UM=e=>e.reduce((t,n)=>t+n.version,0),Bd=e=>{let t=5381;for(let n of rg(e))t=(t<<5)+t+n.versionNonce;return t>>>0},Cd=e=>{let t=5381;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);t=(t<<5)+t+i}return t>>>0},YM=e=>e.filter(t=>!t.isDeleted&&!Pd(t)),WM=e=>e.filter(t=>!t.isDeleted),XM=e=>!e.isDeleted;export{cn as AppStateDelta,El as BASE_BINDING_GAP,An as BASE_BINDING_GAP_ELBOW,ne as BASE_PADDING,on as BindableElement,nn as BoundElement,ze as CaptureUpdateAction,z0 as DEFAULT_LINK_SIZE,Mc as DEFAULT_OMIT_SIDES,_ as Delta,Is as DurableIncrement,gs as ElementBounds,un as ElementsDelta,Ss as EphemeralIncrement,hc as FlowChartCreator,fc as FlowChartNavigator,we as HEADING_DOWN,Re as HEADING_LEFT,fe as HEADING_RIGHT,We as HEADING_UP,$f as INVISIBLY_SMALL_ELEMENT_SIZE,As as InvalidFractionalIndexError,O as LinearElementEditor,Pe as MINIMAL_CROP_SIZE,$S as OMIT_SIDES_FOR_FRAME,VS as OMIT_SIDES_FOR_MULTIPLE_ELEMENTS,$n as Scene,Xe as ShapeCache,Td as Store,Ci as StoreChange,Ms as StoreDelta,Xo as StoreIncrement,mn as StoreSnapshot,Ke as aabbForElement,af as addElementsToFrame,SE as addNewNodes,Fb as addToGroup,W1 as alignElements,Q1 as arrangeElements,wl as avoidRectangularCorner,Tn as bindBindingElement,Kl as bindElementsToFramesAfterDuplication,gl as bindOrUnbindBindingElement,ib as bindOrUnbindBindingElements,Ao as bindPointToSnapToElementOutline,bl as bindingProperties,ml as bumpVersion,Ip as calculateFixedPointForElbowArrowBinding,Lo as calculateFixedPointForNonElbowArrowBinding,cw as canApplyRoundnessTypeToElement,Oa as canBecomePolygon,sd as canChangeRoundness,qh as canCreateLinkFromElements,q0 as canHaveArrowheads,ir as canResizeFromSides,Rn as charWidth,pe as compareHeading,mi as computeBoundTextPosition,Or as computeContainerDimensionForBoundText,Fw as containsCJK,IM as convertToExcalidrawElements,XI as createPlaceholderEmbeddableLabel,Gs as createSrcDoc,tw as cropElement,$t as deconstructDiamondElement,ro as deconstructLinearOrFreeDrawElement,Vt as deconstructRectanguloidElement,Ps as deepCopyElement,bI as defaultGetElementLinkFromSelection,Lw as detectLineHeight,Sn as distanceToElement,oI as distributeElements,Mn as doBoundsIntersect,EI as dragNewElement,fI as dragSelectedElements,rh as duplicateElement,mP as duplicateElements,Rb as editGroupForSelectedElement,de as elementCenterPoint,sn as elementOverlapsWithFrame,Di as elementWithCanvasCache,ln as elementsAreInFrameBounds,jl as elementsAreInSameGroup,VI as embeddableURLValidator,Zl as excludeElementsInFramesFromSelection,x0 as filterElementsEligibleAsFrameChildren,rb as fixBindingsAfterDeletion,yl as fixDuplicatedBindingsAfterDuplication,_r as flipHeading,S0 as frameAndChildrenSelectedTogether,Ha as generateLinearCollisionShape,Ne as generateRoughOptions,Eo as getAllHoveredElementAtPoint,Xa as getApproxMinLineHeight,Wa as getApproxMinLineWidth,Pl as getArrowLocalFixedPoints,Uf as getArrowheadAngle,fs as getArrowheadPoints,_f as getArrowheadSize,Ct as getBindingGap,sb as getBindingSideMidPoint,es as getBindingStrategyForDraggingBindingElementEndpoints,V as getBoundTextElement,Dt as getBoundTextElementId,Zw as getBoundTextElementPosition,pi as getBoundTextMaxHeight,it as getBoundTextMaxWidth,xs as getBoundsFromPoints,mt as getCenterForBounds,v1 as getClosestElementBounds,Le as getCommonBoundingBox,De as getCommonBounds,Vw as getContainerCenter,kr as getContainerCoords,Se as getContainerElement,Rt as getContainingFrame,Mt as getCornerRadius,go as getCubicBezierCurveBound,rM as getCursorForResizingElement,mf as getDefaultFrameName,uw as getDefaultRoundnessTypeForElement,kn as getDiamondPoints,hI as getDragOffsetXY,T1 as getDraggedElementsBounds,j as getElementAbsoluteCoords,ae as getElementBounds,ls as getElementLineSegments,ns as getElementPointsCoords,pd as getElementShape,iM as getElementWithTransformHandleType,Ql as getElementsCompletelyInFrame,ve as getElementsInGroup,g0 as getElementsInNewFrame,E0 as getElementsInResizingFrame,c0 as getElementsIntersectingFrame,I0 as getElementsOverlappingFrame,ss as getElementsWithinSelection,WI as getEmbedLink,nw as getFlipAdjustedCropPosition,an as getFrameChildren,rf as getFrameLikeElements,P0 as getFrameLikeTitle,U0 as getFreedrawOutlineAsSegments,Gf as getFreedrawOutlinePoints,tn as getGlobalFixedPointForBindableElement,Sp as getGlobalFixedPoints,ul as getHeadingForElbowArrowSnap,Lt as getHoveredElementForBinding,fS as getInitializedImageElements,co as getLineHeightInPx,Zt as getLineWidth,mw as getLinearElementSubType,aS as getLinkDirectionFromKey,PI as getLinkIdAndTypeFromSelection,Gl as getLockedLinearCursorAlignSize,em as getMaxCharWidth,Oo as getMaximumGroups,Cw as getMinCharWidth,Ai as getMinMaxXYFromCurvePathOps,lo as getMinTextElementWidth,$l as getNewGroupIdsForDuplication,WM as getNonDeletedElements,Xl as getNonDeletedGroupIds,N1 as getNormalizedDimensions,Xn as getObservedAppState,Ys as getOmitSidesForEditorInterface,Mw as getOriginalContainerHeightFromCache,ws as getPerfectElementSize,Fs as getPredecessors,A1 as getRectangleBoxAbsoluteCoords,Pf as getRenderOpacity,HS as getResizeArrowDirection,zS as getResizeOffsetXY,Xt as getResizedElementAbsoluteCoords,h0 as getRootElements,UM as getSceneVersion,ft as getSelectedElements,ko as getSelectedElementsByGroup,rs as getSelectedGroupForElement,Jp as getSelectedGroupIdForElement,Kp as getSelectedGroupIds,Kb as getSelectionStateForElements,qb as getTargetElements,df as getTargetFrame,$w as getTextElementAngle,Jw as getTextFromElements,Ju as getTextHeight,ja as getTextWidth,oM as getTransformHandleTypeFromCoords,Ac as getTransformHandles,Ws as getTransformHandlesFromCoords,va as getUncroppedImageElement,yr as getUncroppedWidthAndHeight,$b as getVisibleAndNonSelectedElements,YM as getVisibleElements,D1 as getVisibleSceneBounds,f0 as groupByFrameLikes,m0 as groupsAreAtLeastIntersectingTheFrame,p0 as groupsAreCompletelyOutOfFrame,In as handleBindTextResize,X0 as hasBackground,ct as hasBoundTextElement,ZS as hasBoundingBox,j0 as hasStrokeColor,$0 as hasStrokeStyle,V0 as hasStrokeWidth,Bd as hashElementsVersion,Cd as hashString,ke as headingForPoint,hi as headingForPointFromElement,ot as headingForPointIsHorizontal,Fe as headingIsHorizontal,Sy as headingIsVertical,Rm as hitElementBoundText,km as hitElementBoundingBox,xy as hitElementBoundingBoxOnly,Om as hitElementItself,qt as intersectElementWithLineSegment,dw as isArrowBoundToElement,z as isArrowElement,Ge as isBindableElement,zr as isBindableElementInsideOtherBindable,Ce as isBindingElement,Nu as isBindingElementType,Pi as isBindingEnabled,ce as isBoundToContainer,u0 as isCursorInFrame,Ru as isCurvedArrow,W as isElbowArrow,F1 as isElementCompletelyInViewport,ds as isElementContainingFrame,ed as isElementInFrame,Qp as isElementInGroup,ql as isElementInViewport,Yn as isElementIntersectingFrame,II as isElementLink,La as isEmbeddableElement,lw as isExcalidrawElement,Pr as isFlowchartNodeElement,oo as isFrameElement,K as isFrameLikeElement,Ie as isFreeDrawElement,Ou as isFreeDrawElementType,TE as isHTMLSVGElement,no as isIframeElement,io as isIframeLikeElement,xe as isImageElement,Vl as isInGroup,yn as isInitializedImageElement,Pd as isInvisiblySmallElement,It as isLineElement,Q as isLinearElement,Fu as isLinearElementType,Ba as isMagicFrameElement,Dw as isMeasureTextSupported,lS as isNodeInFlowchart,XM as isNonDeletedElement,bn as isPathALoop,At as isPointInElement,li as isRectangularElement,br as isRectanguloidElement,qp as isSelectedViaGroup,ku as isSharpArrow,aw as isSimpleArrow,Zb as isSomeElementSelected,zu as isTextBindableContainer,ee as isTextElement,Ca as isUsingAdaptiveRadius,Ga as isUsingProportionalRadius,pw as isValidPolygon,Qw as isValidTextContainer,AE as loadHTMLImageElement,os as makeNextSelectedElementIds,xi as maxBindingDistance_simple,jI as maybeParseEmbedSrc,Hs as measureFontSizeFromWidth,Ue as measureText,RM as moveAllLeft,FM as moveAllRight,GM as moveArrowAboveBindable,OM as moveOneLeft,kM as moveOneRight,ye as mutateElement,Ko as newArrowElement,Dn as newElement,ge as newElementWith,OI as newEmbeddableElement,ic as newFrameElement,FI as newFreeDrawElement,kI as newIframeElement,ac as newImageElement,sc as newLinearElement,oc as newMagicFrameElement,Ln as newTextElement,yS as normaliseElements,Sd as normalizeElementOrder,Ii as normalizeFixedPoint,hS as normalizeSVG,ui as normalizeText,Ro as omitGroupsContainingFrameLikes,sf as omitPartialGroups,zd as orderByFractionalIndex,ci as originalContainerCache,SI as parseElementLinkFromURL,am as parseTokens,Kt as pointInsideBounds,MS as positionElementsOnGrid,vr as projectFixedPointOntoDiagonal,po as redrawTextBoundingBox,RI as refreshTextDimensions,lf as removeAllElementsFromFrame,Jl as removeElementsFromFrame,Nb as removeFromSelectedGroups,_0 as renderElement,H0 as renderSelectionElement,w0 as replaceAllElementsInFrame,bc as rescalePointsInElement,Ua as resetOriginalContainerCache,zE as resizeMultipleElements,RE as resizeSingleElement,GE as resizeSingleTextElement,UE as resizeTest,Zp as selectGroup,Yl as selectGroupsForSelectedElements,Wl as selectGroupsFromGivenElements,Bw as setCustomTextMetricsProvider,qw as shouldAllowVerticalAlign,b0 as shouldApplyFrameClip,nb as shouldEnableBindingForPointerEvent,ho as shouldTestInside,dM as showSelectedShapeActions,Kw as suppportsHorizontalAlign,vs as syncInvalidIndices,Ld as syncInvalidIndicesImmutable,Oi as syncMovedIndices,Cl as toggleLinePolygonState,Z0 as toolIsArrow,NS as transformElements,Qe as unbindBindingElement,ob as updateBindings,je as updateBoundElements,Un as updateBoundPoint,Nn as updateElbowArrowPoints,y0 as updateFrameMembershipOfSelectedElements,pS as updateImageCache,_a as updateOriginalContainerCache,cl as validateElbowPoints,fh as validateFractionalIndices,Bt as vectorToHeading,vt as wrapText};
28
+ `),intrinsicSize:{w:550,h:720},sandbox:{allowSameOrigin:n}};return Pt.set(e,m),m}return Pt.set(e,{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:i,type:o,sandbox:{allowSameOrigin:n}}},U4=e=>{let t;Pi(e)?t="IFrame element":t=!e.link||e?.link===""?"Empty Web-Embed":e.link;let n=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),o=Nf.Helvetica,i=zf({fontSize:n,fontFamily:o});return $n({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:o,fontSize:n,text:Xt(t,i,e.width-20),textAlign:"center",verticalAlign:Hf.MIDDLE,angle:e.angle??0})},aa=(e,t)=>{try{let{hostname:n}=new URL(e),o=n.replace(/^www\./,"");if(t instanceof Set){if(sa.has(o))return o;let r=o.replace(/^([^.]+)/,"*");return sa.has(r)?r:null}let i=t.replace(/^www\./,"");if(o===i)return i}catch{}return null},Y4=e=>{let t=e.match(Yf);if(t&&t.length===2)return t[1];let n=e.match(Zf);if(n&&n.length===2)return n[1];let o=e.match(Vf);if(o&&o.length===2)return o[1];if(tu.test(e))return`https://giphy.com/embed/${tu.exec(e)[1]}`;let i=e.match($f);return i&&i.length===2?i[1]:e},X4=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){let n=t(e);if(typeof n=="boolean")return n}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(let n of t)if(n instanceof RegExp){if(e.match(n))return!0}else if(aa(e,n))return!0;return!1}}return!!aa(e,sa)};I();import{KEYS as xr,invariant as yr,toBrandedType as Kf}from"@excalidraw/common";import{pointFrom as ru}from"@excalidraw/math";var po=100,Zn=100,a5=e=>{switch(e){case xr.ARROW_UP:return"up";case xr.ARROW_DOWN:return"down";case xr.ARROW_RIGHT:return"right";case xr.ARROW_LEFT:return"left";default:return"right"}},lu=(e,t,n,o)=>{let i=[...n.values()].reduce((r,s)=>{let a;if(Y(s)&&(a=s[e==="predecessors"?"startBinding":"endBinding"])&&s[e==="predecessors"?"endBinding":"startBinding"]?.elementId===t.id){let l=n.get(a.elementId);if(!l)return r;yr(fe(l),"not an ExcalidrawBindableElement");let d=e==="predecessors"?s.points[s.points.length-1]:[0,0],c=Fo(t,ut(t,n),[d[0]+s.x,d[1]+s.y]);r.push({relative:l,heading:c})}return r},[]);switch(o){case"up":return i.filter(r=>ye(r.heading,rt)).map(r=>r.relative);case"down":return i.filter(r=>ye(r.heading,Ae)).map(r=>r.relative);case"right":return i.filter(r=>ye(r.heading,we)).map(r=>r.relative);case"left":return i.filter(r=>ye(r.heading,Ze)).map(r=>r.relative)}},la=(e,t,n)=>lu("successors",e,t,n),da=(e,t,n)=>lu("predecessors",e,t,n),Qf=(e,t,n)=>{let o=Zn+e.width;if(n==="up"||n==="down"){let a=po+e.height,l=e.x,d=e.x+e.width;if(t.every(c=>c.x+c.width<l||c.x>d))return{x:0,y:a*(n==="up"?-1:1)}}else if(n==="right"||n==="left"){let a=e.y,l=e.y+e.height;if(t.every(d=>d.y+d.height<a||d.y>l))return{x:(Zn+e.width)*(n==="left"?-1:1),y:0}}if(n==="up"||n==="down"){let a=po+e.height,l=(t.length===0,a),d=t.length===0?0:(t.length+1)%2===0?(t.length+1)/2*o:t.length/2*o*-1;return n==="up"?{x:d,y:l*-1}:{x:d,y:l}}let i=po+e.height,r=(t.length===0,Zn+e.width),s=t.length===0?0:(t.length+1)%2===0?(t.length+1)/2*i:t.length/2*i*-1;return n==="left"?{x:r*-1,y:s}:{x:r,y:s}},Jf=(e,t,n,o)=>{let i=o.getNonDeletedElementsMap(),r=la(e,i,n),s=da(e,i,n),a=Qf(e,[...r,...s],n),l=Xn({type:e.type,x:e.x+a.x,y:e.y+a.y,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});yr(Vr(l),"not an ExcalidrawFlowchartNodeElement");let d=du(e,l,n,t,o);return{nextNode:l,bindingArrow:d}},eg=(e,t,n,o,i)=>{let r=[];for(let s=0;s<i;s++){let a,l;if(n==="left"||n==="right"){let p=po*(i-1)+i*e.height,h=e.y+e.height/2-p/2,m=Zn+e.width;n==="left"&&(m*=-1),a=e.x+m;let f=(po+e.height)*s;l=h+f}else{let p=Zn*(i-1)+i*e.width,h=e.x+e.width/2-p/2,m=po+e.height;n==="up"&&(m*=-1),l=e.y+m;let f=(Zn+e.width)*s;a=h+f}let d=Xn({type:e.type,x:a,y:l,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});yr(Vr(d),"not an ExcalidrawFlowchartNodeElement");let c=du(e,d,n,t,o);r.push(d),r.push(c)}return r},du=(e,t,n,o,i)=>{let r,s;switch(n){case"up":{r=e.x+e.width/2,s=e.y-6;break}case"down":{r=e.x+e.width/2,s=e.y+e.height+6;break}case"right":{r=e.x+e.width+6,s=e.y+e.height/2;break}case"left":{r=e.x-6,s=e.y+e.height/2;break}}let l,d;switch(n){case"up":{l=t.x+t.width/2-r,d=t.y+t.height-s+6;break}case"down":{l=t.x+t.width/2-r,d=t.y-s-6;break}case"right":{l=t.x-r-6,d=t.y-s+t.height/2;break}case"left":{l=t.x+t.width-r+6,d=t.y-s+t.height/2;break}}let c=Er({type:"arrow",x:r,y:s,startArrowhead:null,endArrowhead:o.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[ru(0,0),ru(l,d)],elbowed:!0}),p=i.getNonDeletedElementsMap();Gt(c,e,"orbit","start",i),Gt(c,t,"orbit","end",i);let h=new Map;h.set(e.id,e),h.set(t.id,t),h.set(c.id,c),G.movePoints(c,i,new Map([[1,{point:c.points[1]}]]));let m=to(c,Kf(new Map([...p.entries(),[e.id,e],[t.id,t],[c.id,c]])),{points:c.points});return{...c,...m}},su=class{isExploring=!1;sameLevelNodes=[];sameLevelIndex=0;direction=null;visitedNodes=new Set;clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(t,n,o){if(!fe(t))return null;if(o!==this.direction&&this.clear(),this.visitedNodes.has(t.id)||this.visitedNodes.add(t.id),this.isExploring&&o===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let i=[...la(t,n,o),...da(t,n,o)];if(i.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=i,this.direction=o,this.visitedNodes.add(i[0].id),i[0].id;if(o===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(t.id);let s=["up","right","down","left"].filter(a=>a!==o).map(a=>[...la(t,n,a),...da(t,n,a)]).flat().filter(a=>!this.visitedNodes.has(a.id));for(let a of s)if(!this.visitedNodes.has(a.id))return this.visitedNodes.add(a.id),this.isExploring=!0,this.direction=o,a.id}return null}},au=class{isCreatingChart=!1;numberOfNodes=0;direction="right";pendingNodes=null;createNodes(t,n,o,i){let r=i.getNonDeletedElementsMap();if(o!==this.direction){let{nextNode:s,bindingArrow:a}=Jf(t,n,o,i);this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=o,this.pendingNodes=[s,a]}else{this.numberOfNodes+=1;let s=eg(t,n,o,i,this.numberOfNodes);this.isCreatingChart=!0,this.direction=o,this.pendingNodes=s}if(t.frameId){let s=r.get(t.frameId);yr(s&&Si(s),"not an ExcalidrawFrameElement"),s&&this.pendingNodes.every(a=>vn([a],s,r)||In(a,s,r))&&(this.pendingNodes=this.pendingNodes.map(a=>ke(a,r,{frameId:t.frameId})))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},l5=(e,t)=>{for(let[,n]of t)if(n.type==="arrow"&&(n.startBinding?.elementId===e.id||n.endBinding?.elementId===e.id))return!0;return!1};I();import{pointDistance as ho,pointFrom as ua}from"@excalidraw/math";import{invariant as wu}from"@excalidraw/common";I();import{arrayToMap as uu,findIndex as pu,findLastIndex as hu}from"@excalidraw/common";var ca=(e,t)=>e.frameId===t||e.id===t,mu=(e,t,n)=>{let o=[],i=[],r=null,s=-1,a=uu(n||Ot(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++s<e.length;){let l=e[s];a.get(l.id)?(i.length&&(o=o.concat(i),i=[]),o.push(s),r=s+1):l.isDeleted&&r===s?(r=s+1,i.push(s)):i=[]}return o},tg=e=>{let t=0;return e.reduce((n,o,i)=>(i>0&&e[i-1]!==o-1&&(t=++t),(n[t]||(n[t]=[])).push(o),n),[])},cu=(e,t,n,o)=>{if("containerId"in e&&e.containerId){let i=o.getElement(e.containerId);if(i)return n==="left"?Math.min(t.indexOf(i),t.indexOf(e)):Math.max(t.indexOf(i),t.indexOf(e))}else{let i=e.boundElements?.find(r=>r.type!=="arrow")?.id;if(i){let r=o.getElement(i);if(r)return n==="left"?Math.min(t.indexOf(r),t.indexOf(e)):Math.max(t.indexOf(r),t.indexOf(e))}}},ng=(e,t)=>{let n=-1,o=-1;return e.forEach((i,r)=>{ca(i,t)&&(n===-1&&(n=r),o=r)}),n===-1?[]:e.slice(n,o+1)},fu=(e,t,n,o,i,r)=>{let s=r||Zt(e,n,o);if(!s)return n;let a=J(s,o),l=ee(s)?De(s,o):null,d=[s.id,a?.id,l?.id].filter(h=>!!h),c=n.findIndex(h=>d.includes(h.id)),p=n.findIndex(h=>h.id===t.id);if(p!==-1&&c!==-1&&p<c){let h=Array.from(n),m=h.splice(p,1)[0];h.splice(c,0,m),i.replaceAllElements(h)}return n},og=(e,t,n,o,i,r)=>{let s=t[n],a=h=>h.isDeleted?!1:i?h.frameId===i:e.editingGroupId?h.groupIds.includes(e.editingGroupId):!0,l=o==="left"?hu(t,h=>a(h),Math.max(0,n-1)):pu(t,h=>a(h),n+1),d=t[l];if(!d)return-1;if(e.editingGroupId){if(s?.groupIds.join("")===d?.groupIds.join(""))return cu(d,t,o,r)??l;if(!d?.groupIds.includes(e.editingGroupId))return-1}if(!i&&(d.frameId||te(d))){let h=ng(t,d.frameId||d.id);return o==="left"?t.indexOf(h[0]):t.indexOf(h[h.length-1])}if(!d.groupIds.length)return cu(d,t,o,r)??l;let c=e.editingGroupId?d.groupIds[d.groupIds.indexOf(e.editingGroupId)-1]:d.groupIds[d.groupIds.length-1],p=ze(t,c);return p.length?o==="left"?t.indexOf(p[0]):t.indexOf(p[p.length-1]):l},gu=(e,t)=>t.reduce((n,o)=>{let i=e[o];return n.set(i.id,i),n},new Map),Eu=(e,t,n,o)=>{let i=mu(e,t),r=gu(e,i),s=tg(i);n==="right"&&(s=s.reverse());let a=new Set(i.filter(l=>te(e[l])).map(l=>e[l].id));return s.forEach((l,d)=>{let c=l[0],p=l[l.length-1],h=n==="left"?c:p,m=l.some(w=>{let M=e[w];return M.frameId&&a.has(M.frameId)})?null:e[h]?.frameId,f=og(t,e,h,n,m,o);if(f===-1||h===f)return;let g=n==="left"?e.slice(0,f):e.slice(0,c),E=e.slice(c,p+1),x=n==="left"?e.slice(f,c):e.slice(p+1,f+1),y=n==="left"?e.slice(p+1):e.slice(f+1);e=n==="left"?[...g,...E,...x,...y]:[...g,...x,...E,...y]}),ei(e,r),e},xu=(e,t,n,o,i)=>{let r=mu(e,t,i),s=gu(e,r),a=[],l,d;if(n==="left"){if(o)l=pu(e,f=>ca(f,o));else if(t.editingGroupId){let f=ze(e,t.editingGroupId);if(!f.length)return e;l=e.indexOf(f[0])}else l=0;d=r[r.length-1]}else{if(o)d=hu(e,f=>ca(f,o));else if(t.editingGroupId){let f=ze(e,t.editingGroupId);if(!f.length)return e;d=e.indexOf(f[f.length-1])}else d=e.length-1;l=r[0]}l===-1&&(l=0);for(let f=l;f<d+1;f++)r.includes(f)||a.push(e[f]);let c=Array.from(s.values()),p=e.slice(0,l),h=e.slice(d+1),m=n==="left"?[...p,...c,...a,...h]:[...p,...a,...c,...h];return ei(m,s),m};function yu(e,t,n,o){let i=uu(Ot(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),r={regularElements:[],frameChildren:new Map},s=new Set;for(let d of e)i.has(d.id)&&te(d)&&s.add(d.id);for(let d of e)if(i.has(d.id))if(te(d)||d.frameId&&s.has(d.frameId))r.regularElements.push(d);else if(!d.frameId)r.regularElements.push(d);else{let c=r.frameChildren.get(d.frameId)||[];c.push(d),r.frameChildren.set(d.frameId,c)}let a=e,l=Array.from(r.frameChildren.entries());for(let[d,c]of l)a=o(e,t,n,d,c);return o(a,t,n,null,r.regularElements)}var x5=(e,t,n)=>Eu(e,t,"left",n),y5=(e,t,n)=>Eu(e,t,"right",n),w5=(e,t)=>yu(e,t,"left",xu),b5=(e,t)=>yu(e,t,"right",xu);var wr=(e,t,n,o,i,r,s=!1)=>{if(Y(t)||!Dt(i)||t.points.length!==2)return!1;if(!s){let l=t.startBinding?.elementId===n.id?0:t.points.length-1,d=G.getPointAtIndexGlobalCoordinates(t,l,o);if(ho(e,d)<Wo*1.5/i.zoom.value)return!1}let a=G.getPointAtIndexGlobalCoordinates(t,r==="end"?t.points.length-1:0,o);return ho(e,a)>=Wo*1.5/i.zoom.value&&Tt({element:n,elementsMap:o,point:e,threshold:Fe(n,t),overrideShouldTestInside:!0})},ig=(e,t,n,o,i,r,s)=>{let a=new Map,l=n?"startBinding":"endBinding",d=n?"endBinding":"startBinding",c=e[l],p=e[d];if(c&&t){let h=t&&p&&c.elementId===p.elementId;s||h?c={...c,mode:"inside"}:c={...c,mode:"orbit"};let m=n?0:e.points.length-1,f=bt(e,l,c,t,o,!0);f&&a.set(m,{point:f})}if(p&&p.mode==="orbit"){let h=o.get(p.elementId);if(h&&fe(h)&&Dt(r)){let m=t&&p.elementId===t.id;s||m?p={...p,mode:"inside"}:p={...p,mode:"orbit"};let f=n?e.points.length-1:0,g=bt(e,d,p,h,o);g&&a.set(f,{point:g})}}a.size>0&&G.movePoints(e,i,a,{[l]:c,[d]:p})},bu=(e,t,n,o,i,r,s)=>{let a=G.getElement(e.elementId,t);if(!a||!Be(a)||Y(a)||!e.hoveredFocusPointBinding||!e.draggedFocusPointBinding)return;let l=e.draggedFocusPointBinding==="start",d=l?a.startBinding:a.endBinding,{x:c,y:p}=e.pointerOffset,h=ua(n.x-c,n.y-p),m=l?"startBinding":"endBinding",f=Vl(h,a,o.getNonDeletedElements(),t,xt(i.zoom));if(f&&Dt(i)){a[m]&&f.id!==d?.elementId&&Oe(a,e.draggedFocusPointBinding,o);let g=s&&a[m]?.mode==="orbit"?"inside":!s&&a[m]?.mode==="inside"?"orbit":null;(!a[m]||g)&&Gt(a,f,g||"orbit",e.draggedFocusPointBinding,o,h),o.mutateElement(a,{[m]:{...a[m],elementId:f.id,mode:g||a[m]?.mode||"orbit",...no(a,f,e.draggedFocusPointBinding,t,h)}})}else{let g=new Map,E=l?0:a.points.length-1;g.set(E,{point:G.createPointAt(a,t,h[0],h[1],r)}),G.movePoints(a,o,g),a[m]&&Oe(a,l?"start":"end",o)}ig(a,f,l,t,o,i,s),f&&Dt(i)&&fu(h,a,o.getElementsIncludingDeleted(),t,o,f)},C5=(e,t,n,o)=>{let i=ua(t.origin.x,t.origin.y),r=Wo*1.5/o.zoom.value;if(e.startBinding?.elementId){let s=n.get(e.startBinding.elementId);if(s&&fe(s)&&!s.isDeleted){let a=Ye(e.startBinding.fixedPoint,s,n);if(wr(a,e,s,n,o,"start")&&ho(i,a)<=r)return{hitFocusPoint:"start",pointerOffset:{x:i[0]-a[0],y:i[1]-a[1]}}}}if(e.endBinding?.elementId){let s=n.get(e.endBinding.elementId);if(s&&fe(s)&&!s.isDeleted){let a=Ye(e.endBinding.fixedPoint,s,n);if(wr(a,e,s,n,o,"end")&&ho(i,a)<=r)return{hitFocusPoint:"end",pointerOffset:{x:i[0]-a[0],y:i[1]-a[1]}}}}return{hitFocusPoint:null,pointerOffset:{x:0,y:0}}},B5=(e,t)=>{wu(e.draggedFocusPointBinding,"Must have a dragged focus point at pointer release");let n=G.getElement(e.elementId,t.getNonDeletedElementsMap());wu(n,"Arrow must be in the scene");let o=e.draggedFocusPointBinding==="start"?"startBinding":"endBinding",i=e.draggedFocusPointBinding==="start"?"endBinding":"startBinding",r=n[o]?.elementId,s=n[i]?.elementId,a=r&&t.getNonDeletedElements().find(d=>d.id!==r&&d.id!==s&&fe(d)&&d.boundElements?.find(({id:c})=>c===n.id));a&&t.mutateElement(a,{boundElements:a.boundElements?.filter(({id:d})=>d!==n.id)});let l=r&&t.getNonDeletedElementsMap().get(r);l&&t.mutateElement(l,{boundElements:[...(l.boundElements||[])?.filter(({id:d})=>d!==n.id),{id:n.id,type:"arrow"}]})},D5=(e,t,n,o,i)=>{let r=o.getNonDeletedElementsMap(),s=ua(t,n),a=Wo*1.5/i.zoom.value;if(e.startBinding?.elementId){let l=r.get(e.startBinding.elementId);if(l&&fe(l)&&!l.isDeleted){let d=Ye(e.startBinding.fixedPoint,l,r);if(wr(d,e,l,r,i,"start")&&ho(s,d)<=a)return"start"}}if(e.endBinding?.elementId){let l=r.get(e.endBinding.elementId);if(l&&fe(l)&&!l.isDeleted){let d=Ye(e.endBinding.fixedPoint,l,r);if(wr(d,e,l,r,i,"end")&&ho(s,d)<=a)return"end"}}return null};I();import{MIME_TYPES as Mu,SVG_NS as rg}from"@excalidraw/common";var sg=e=>new Promise((t,n)=>{let o=new Image;o.onload=()=>{t(o)},o.onerror=i=>{n(i)},o.src=e}),N5=async({fileIds:e,files:t,imageCache:n})=>{let o=new Map,i=new Map;return await Promise.all(e.reduce((r,s)=>{let a=t[s];return a&&!o.has(s)?(o.set(s,!0),r.concat((async()=>{try{if(a.mimeType===Mu.binary)throw new Error("Only images can be added to ImageCache");let l=sg(a.dataURL),d={image:l,mimeType:a.mimeType};n.set(s,d);let c=await l;n.set(s,{...d,image:c})}catch{i.set(s,!0)}})())):r},[])),{imageCache:n,updatedFiles:o,erroredFiles:i}},H5=e=>e.filter(t=>Nn(t)),ag=e=>e?.nodeName.toLowerCase()==="svg",z5=e=>{let t=new DOMParser().parseFromString(e,Mu.svg),n=t.querySelector("svg");if(t.querySelector("parsererror")||!ag(n))throw new Error("Invalid SVG");{n.hasAttribute("xmlns")||n.setAttribute("xmlns",rg);let i=n.getAttribute("width"),r=n.getAttribute("height");(i?.includes("%")||i==="auto")&&(i=null),(r?.includes("%")||r==="auto")&&(r=null);let s=n.getAttribute("viewBox");if(!i||!r){if(i=i||"50",r=r||"50",s){let a=s.match(/\d+ +\d+ +(\d+(?:\.\d+)?) +(\d+(?:\.\d+)?)/);a&&([,i,r]=a)}n.setAttribute("width",i),n.setAttribute("height",r)}return s||n.setAttribute("viewBox",`0 0 ${i} ${r}`),n.outerHTML}};I();var lg=e=>({x:(e.minX+e.maxX)/2,y:(e.minY+e.maxY)/2}),Pu=(e,t)=>{switch(e){case"height":return t.height;case"width":return t.width;case"size":return t.width*t.height;case"scale":return(t.width+t.height)/2}},dg=(e,t,n)=>n==="first"?Pu(e,t[0].boundingBox):t.reduce((i,r)=>i+Pu(e,r.boundingBox),0)/t.length,cg=(e,t,n)=>{switch(e){case"height":return t/n.height;case"width":return t/n.width;case"size":return Math.sqrt(t/(n.width*n.height));case"scale":return t/((n.width+n.height)/2)}},U5=(e,t,n,o="average",i="size")=>{let s=er(t,n).map(d=>({group:d,boundingBox:je(d)}));if(s.length===0)return t;let a=dg(i,s,o),l=[];return s.forEach(d=>{let c=cg(i,a,d.boundingBox);if(!Number.isFinite(c)||c<=0)return;let p=lg(d.boundingBox);d.group.forEach(h=>{let m={x:h.x+h.width/2,y:h.y+h.height/2},f={x:p.x+(m.x-p.x)*c,y:p.y+(m.y-p.y)*c},g=h.width*c,E=h.height*c;e.mutateElement(h,{x:f.x-g/2,y:f.y-E/2,width:g,height:E}),l.push(h)})}),l};I();var q5=(e,t,n,o=50)=>{if(!e||e.length===0)return[];let i=[],r=Array.isArray(e[0])?e:e.map(m=>[m]),s=r.length,a=Math.max(1,Math.ceil(Math.sqrt(s))),l=[];for(let m=0;m<s;m+=a)l.push(r.slice(m,m+a));let d=0,c=l.map(m=>{let f=0,g=0,E=m.map(x=>{let[y,w,M,b]=_e(x);return{elements:x,bounds:[y,w,M,b],width:M-y,height:b-w}});return E.forEach((x,y)=>{f+=x.width,y<E.length-1&&(f+=o),x.height>g&&(g=x.height)}),d+=g,{unitBounds:E,width:f,maxHeight:g}}),p=d+Math.max(0,l.length-1)*o,h=n-p/2;return c.forEach(m=>{let{unitBounds:f,width:g,maxHeight:E}=m,x=t-g/2;f.forEach(y=>{let[w,M]=y.bounds,b=x-w,S=h-M;y.elements.forEach(A=>{i.push(Ne(A,{x:A.x+b,y:A.y+S}))}),x+=y.width+o}),h+=E+o}),i};I();import{pointCenter as ug,normalizeRadians as Mr,pointFrom as ae,pointRotateRads as It}from"@excalidraw/math";import{MIN_FONT_SIZE as ha,SHIFT_LOCKING_ANGLE as Pr,rescalePoints as Iu,getFontString as br}from"@excalidraw/common";var dM=(e,t,n,o,i,r,s,a,l,d,c)=>{let p=o.getNonDeletedElementsMap();if(n.length===1){let[h]=n;if(t==="rotation")Y(h)||(pg(h,o,a,l,i),Re(h,o));else if(t){let m=n[0].id,f=p.get(m),g=e.get(m);if(f&&g){let{nextWidth:E,nextHeight:x}=Eg(f,g,t,a,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r});gg(E,x,f,g,e,o,t,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r})}}return ee(h)&&Re(h,o),!0}else if(n.length>1){if(t==="rotation")return mg(e,n,o,a,l,i,d,c),!0;if(t){let{nextWidth:h,nextHeight:m,flipByX:f,flipByY:g,originalBoundingBox:E}=xg(n,e,p,t,a,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r});return yg(n,p,t,o,e,{shouldResizeFromCenter:r,shouldMaintainAspectRatio:s,flipByX:f,flipByY:g,nextWidth:h,nextHeight:m,originalBoundingBox:E}),!0}}return!1},pg=(e,t,n,o,i)=>{let[r,s,a,l]=K(e,t.getNonDeletedElementsMap()),d=(r+a)/2,c=(s+l)/2,p;te(e)?p=0:(p=5*Math.PI/2+Math.atan2(o-c,n-d),i&&(p=p+Pr/2,p=p-p%Pr),p=Mr(p));let h=$t(e),m={angle:p};if(Be(e)&&(m={...m},e.startBinding&&Oe(e,"start",t),e.endBinding&&Oe(e,"end",t)),t.mutateElement(e,m),h){let f=t.getElement(h);if(f&&!V(e)){let{x:g,y:E}=Do(e,f,t.getNonDeletedElementsMap());t.mutateElement(f,{angle:p,x:g,y:E})}}},Su=(e,t,n,o)=>ne(e)||Ce(e)?{points:Iu(0,t,Iu(1,n,e.points,o),o)}:{},ma=(e,t,n)=>{let o=e.width;if(ge(e)){let s=De(e,t);s&&(o=yt(s,e))}let r=e.fontSize*(n/o);return r<ha?null:{size:r}},hg=(e,t,n,o,i,r,s)=>{let a=n.getNonDeletedElementsMap(),l=t.width*(s/t.height),d=ma(t,a,l);if(d!==null){if(o.includes("n")||o.includes("s")){let c=ae(e.x,e.y),p=pa(c,e.width,e.height,l,s,e.angle,o,!1,i);n.mutateElement(t,{fontSize:d.size,width:l,height:s,x:p.x,y:p.y});return}if(o==="e"||o==="w"){let c=Ti(br({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),p=Math.max(c,r),h=Xt(t.originalText,br(t),Math.abs(p)),m=ot(h,br(t),t.lineHeight),f=m.height,g=ae(e.x,e.y),E=pa(g,e.width,e.height,p,f,t.angle,o,!1,i),x={width:Math.abs(p),height:Math.abs(m.height),x:E.x,y:E.y,text:h,autoResize:!1};n.mutateElement(t,x)}}},mg=(e,t,n,o,i,r,s,a)=>{let l=n.getNonDeletedElementsMap(),d=5*Math.PI/2+Math.atan2(i-a,o-s);r&&(d+=Pr/2,d-=d%Pr);let c=new Map(t.map(p=>[p.id,p]));for(let p of t)if(!te(p)){let[h,m,f,g]=K(p,l),E=(h+f)/2,x=(m+g)/2,y=e.get(p.id)?.angle??p.angle,[w,M]=It(ae(E,x),ae(s,a),d+y-p.angle),b=Y(p)?{points:md(p,l)}:{x:p.x+(w-E),y:p.y+(M-x),angle:Mr(d+y)};n.mutateElement(p,b),Re(p,n,{simultaneouslyUpdated:t}),Be(p)&&(p.startBinding&&(c.has(p.startBinding.elementId)||Oe(p,"start",n)),p.endBinding&&(c.has(p.endBinding.elementId)||Oe(p,"end",n)));let S=J(p,l);if(S&&!V(p)){let{x:A,y:C}=Do(p,S,l);n.mutateElement(S,{x:A,y:C,angle:Mr(d+y)})}}n.triggerUpdate()},cM=(e,t,n,o,i)=>{let[r,s,a,l]=t.length===1?K(t[0],n):_e(t),d=(r+a)/2,c=(s+l)/2,p=t.length===1?t[0].angle:0;switch([o,i]=It(ae(o,i),ae(d,c),-p),e){case"n":return It(ae(o-(r+a)/2,i-s),ae(0,0),p);case"s":return It(ae(o-(r+a)/2,i-l),ae(0,0),p);case"w":return It(ae(o-r,i-(s+l)/2),ae(0,0),p);case"e":return It(ae(o-a,i-(s+l)/2),ae(0,0),p);case"nw":return It(ae(o-r,i-s),ae(0,0),p);case"ne":return It(ae(o-a,i-s),ae(0,0),p);case"sw":return It(ae(o-r,i-l),ae(0,0),p);case"se":return It(ae(o-a,i-l),ae(0,0),p);default:return[0,0]}},uM=(e,t)=>{let[,[n,o]]=t.points;return e==="nw"&&(n<0||o<0)||e==="ne"&&n>=0||e==="sw"&&n<=0||e==="se"&&(n>0||o>0)?"end":"origin"},fg=(e,t,n)=>{if(n)return"center";if(t)switch(e){case"n":return"south-side";case"e":return"west-side";case"s":return"north-side";case"w":return"east-side";case"ne":return"bottom-left";case"nw":return"bottom-right";case"se":return"top-left";case"sw":return"top-right"}return["e","se","s"].includes(e)?"top-left":["n","nw","w"].includes(e)?"bottom-right":e==="ne"?"bottom-left":"top-right"},pa=(e,t,n,o,i,r,s,a,l)=>{let d=fg(s,a,l),[c,p]=e;switch(d){case"top-left":return{x:c+(t-o)/2+(o-t)/2*Math.cos(r)+(n-i)/2*Math.sin(r),y:p+(n-i)/2+(o-t)/2*Math.sin(r)+(i-n)/2*Math.cos(r)};case"top-right":return{x:c+(t-o)/2*(Math.cos(r)+1)+(n-i)/2*Math.sin(r),y:p+(n-i)/2+(t-o)/2*Math.sin(r)+(i-n)/2*Math.cos(r)};case"bottom-left":return{x:c+(t-o)/2*(1-Math.cos(r))+(i-n)/2*Math.sin(r),y:p+(n-i)/2*(Math.cos(r)+1)+(o-t)/2*Math.sin(r)};case"bottom-right":return{x:c+(t-o)/2*(Math.cos(r)+1)+(i-n)/2*Math.sin(r),y:p+(n-i)/2*(Math.cos(r)+1)+(t-o)/2*Math.sin(r)};case"center":return{x:c-(o-t)/2,y:p-(i-n)/2};case"east-side":return{x:c+(t-o)/2*(Math.cos(r)+1),y:p+(t-o)/2*Math.sin(r)+(n-i)/2};case"west-side":return{x:c+(t-o)/2*(1-Math.cos(r)),y:p+(o-t)/2*Math.sin(r)+(n-i)/2};case"north-side":return{x:c+(t-o)/2+(n-i)/2*Math.sin(r),y:p+(i-n)/2*(Math.cos(r)-1)};case"south-side":return{x:c+(t-o)/2+(i-n)/2*Math.sin(r),y:p+(n-i)/2*(Math.cos(r)+1)}}},gg=(e,t,n,o,i,r,s,{shouldInformMutation:a=!0,shouldMaintainAspectRatio:l=!1,shouldResizeFromCenter:d=!1}={})=>{if(ee(n)&&ee(o))return hg(o,n,r,s,d,e,t);let c={},p=r.getNonDeletedElementsMap(),h=J(n,p);if(h){let E=i.get(h.id);if(E&&(c={fontSize:E.fontSize}),l){let x={...n,width:e,height:t},y=ma(h,p,yt(x,h));if(y===null)return;c={fontSize:y.size}}else{let x=Al(br(h),h.lineHeight),y=kl(h.fontSize,h.lineHeight);e=Math.max(e,x),t=Math.max(t,y)}}let m=Su(o,e,t,!0),f=ae(o.x,o.y);if(ne(o)){let[E,x]=Me(o,i);f=ae(E,x)}let g=pa(f,o.width,o.height,e,t,o.angle,s,l,d);if(ne(o)&&m.points){let E=o.x-f[0],x=o.y-f[1];g.x+=E,g.y+=x;let y=m.points[0][0],w=m.points[0][1];g.x+=y,g.y+=w,m.points=m.points.map(M=>ae(M[0]-y,M[1]-w))}if(e<0&&(g.x=g.x+e),t<0&&(g.y=g.y+t),"scale"in n&&"scale"in o&&r.mutateElement(n,{scale:[(Math.sign(e)||o.scale[0])*o.scale[0],(Math.sign(t)||o.scale[1])*o.scale[1]]}),V(n)&&h&&l){let E=e/n.width*h.fontSize;if(E<ha)return;c.fontSize=E}if(e!==0&&t!==0&&Number.isFinite(g.x)&&Number.isFinite(g.y)){let E={...g,width:Math.abs(e),height:Math.abs(t),...m};Be(n)&&(n.startBinding&&(E={...E},n.startBinding&&Oe(n,"start",r)),n.endBinding&&(E={...E,endBinding:null})),r.mutateElement(n,E,{informMutation:a,isDragging:!1}),h&&c!=null&&r.mutateElement(h,{fontSize:c.fontSize}),Wn(n,r,s,l),Re(n,r)}},Eg=(e,t,n,o,i,{shouldMaintainAspectRatio:r=!1,shouldResizeFromCenter:s=!1}={})=>{let[a,l,d,c]=cn(t,t.width,t.height,!0),p=ae(a,l),h=ae(d,c),m=ug(p,h),f=It(ae(o,i),m,-t.angle),[g,E,x,y]=cn(e,e.width,e.height,!0),w=x-g,M=y-E,b=h[0]-p[0],S=h[1]-p[1],A=b/w,C=S/M;n.includes("e")&&(A=(f[0]-p[0])/w),n.includes("s")&&(C=(f[1]-p[1])/M),n.includes("w")&&(A=(h[0]-f[0])/w),n.includes("n")&&(C=(h[1]-f[1])/M);let T=e.width*A,F=e.height*C;if(s&&(T=2*T-t.width,F=2*F-t.height),r){let O=Math.abs(T)/t.width,N=Math.abs(F)/t.height;if(n.length===1&&(F*=O,T*=N),n.length===2){let D=Math.max(O,N);T=t.width*D*Math.sign(T),F=t.height*D*Math.sign(F)}}return{nextWidth:T,nextHeight:F}},xg=(e,t,n,o,i,r,{shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:a=!1}={})=>{let l=e.map(D=>t.get(D.id)),d=l.reduce((D,q)=>{if(!ne(q))return D;let U=$t(q);if(!U)return D;let le=t.get(U)??null;return ge(le)?[...D,{...le,...G.getBoundTextElementPosition(q,le,n)}]:D},[]),c=je(l.map(D=>D).concat(d)),{minX:p,minY:h,maxX:m,maxY:f,midX:g,midY:E}=c,x=m-p,y=f-h,w={ne:[p,f],se:[p,h],sw:[m,h],nw:[m,f],e:[p,h+y/2],w:[m,h+y/2],n:[p+x/2,f],s:[p+x/2,h]},[M,b]=a?[g,E]:w[o],S=a?2:1,A=Math.max(Math.abs(i-M)/x||0,Math.abs(r-b)/y||0)*S,C=o.includes("e")||o.includes("w")?Math.abs(i-M)*S:x,T=o.includes("n")||o.includes("s")?Math.abs(r-b)*S:y;s&&(C=x*A*Math.sign(i-M),T=y*A*Math.sign(r-b));let F={ne:[i<M,r>b],se:[i<M,r<b],sw:[i>M,r<b],nw:[i>M,r>b],e:[i<M,!1],w:[i>M,!1],n:[!1,r>b],s:[!1,r<b]},[O,N]=F[o].map(D=>D);return{originalBoundingBox:c,nextWidth:C,nextHeight:T,flipByX:O,flipByY:N}},yg=(e,t,n,o,i,{shouldMaintainAspectRatio:r=!1,shouldResizeFromCenter:s=!1,flipByX:a=!1,flipByY:l=!1,nextHeight:d,nextWidth:c,originalBoundingBox:p}={})=>{if(c===void 0&&d===void 0&&a===void 0&&l===void 0||d===0||c===0)return;i||(i=t);let h=e.reduce((S,A)=>{let C=i.get(A.id);return C&&S.push({orig:C,latest:A}),S},[]),m;if(p)m=p;else{let S=h.reduce((A,{orig:C})=>{if(!ne(C))return A;let T=$t(C);if(!T)return A;let F=i.get(T)??null;return ge(F)?[...A,{...F,...G.getBoundTextElementPosition(C,F,t)}]:A},[]);m=je(h.map(({orig:A})=>A).concat(S))}let{minX:f,minY:g,maxX:E,maxY:x,midX:y,midY:w}=m,M=E-f,b=x-g;if(c===void 0&&d===void 0&&(c=M,d=b),r&&(c===void 0?c=d*(M/b):d===void 0?d=c*(b/M):Math.abs(c/d-M/b)>.001&&(c=d*(M/b))),c&&d){let S=n.includes("e")||n.includes("w")?Math.abs(c)/M:1,A=n.includes("n")||n.includes("s")?Math.abs(d)/b:1,C;n.length===1?C=n.includes("e")||n.includes("w")?S:A:C=Math.max(Math.abs(c)/M||0,Math.abs(d)/b||0);let T={ne:[f,x],se:[f,g],sw:[E,g],nw:[E,x],e:[f,g+b/2],w:[E,g+b/2],n:[f+M/2,x],s:[f+M/2,g]},[F,O]=s?[y,w]:T[n],N=r||h.some(v=>v.latest.angle!==0||ee(v.latest)||Hd(v.latest));N&&(S=C,A=C);let[D,q]=[a?-1:1,l?-1:1],U=[];for(let{orig:v,latest:W}of h){if(ee(v)&&ge(v))continue;let X=v.width*S,Se=v.height*A,vt=Mr(v.angle*D*q),ti=ne(v)||Ce(v),Lr=v.x-F,ni=v.y-O,go=a&&!ti?X:0,Cr=l&&!ti?Se:0,oi=F+D*(Lr*S+go),ii=O+q*(ni*A+Cr),et=Su(v,X*D,Se*q,!1),at={x:oi,y:ii,width:X,height:Se,angle:vt,...et};if(Y(v)&&(v.startBinding&&(at.startBinding={...v.startBinding,fixedPoint:[a?-v.startBinding.fixedPoint[0]+1:v.startBinding.fixedPoint[0],l?-v.startBinding.fixedPoint[1]+1:v.startBinding.fixedPoint[1]]}),v.endBinding&&(at.endBinding={...v.endBinding,fixedPoint:[a?-v.endBinding.fixedPoint[0]+1:v.endBinding.fixedPoint[0],l?-v.endBinding.fixedPoint[1]+1:v.endBinding.fixedPoint[1]]}),v.fixedSegments&&et.points&&(at.fixedSegments=v.fixedSegments.map(Ft=>({...Ft,start:et.points[Ft.index-1],end:et.points[Ft.index]})))),ve(v)&&(at.scale=[v.scale[0]*D,v.scale[1]*q]),ee(v)){let Ft=ma(v,t,X);if(!Ft)return;at.fontSize=Ft.size}let sn=i.get($t(v)??"");if(sn)if(N){let Ft=sn.fontSize*C;if(Ft<ha)return;at.boundTextFontSize=Ft}else at.boundTextFontSize=sn.fontSize;U.push({element:W,update:at})}let le=U.map(({element:v})=>v),H=new Map(U.map(({element:v})=>[v.id,v]));for(let{element:v,update:{boundTextFontSize:W,...X}}of U){let{angle:Se}=X;o.mutateElement(v,X),Re(v,o,{simultaneouslyUpdated:le}),Be(v)&&(v.startBinding&&(H.has(v.startBinding.elementId)||Oe(v,"start",o)),v.endBinding&&(H.has(v.endBinding.elementId)||Oe(v,"end",o)));let vt=J(v,t);vt&&W&&(o.mutateElement(vt,{fontSize:W,angle:ne(v)?void 0:Se}),Wn(v,o,n,!0))}o.triggerUpdate()}};I();import{pointFrom as ht,pointOnLineSegment as Cu,pointRotateRads as Sr}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as wa}from"@excalidraw/common";I();import{DEFAULT_TRANSFORM_HANDLE_SPACING as ga}from"@excalidraw/common";import{pointFrom as vu,pointRotateRads as wg}from"@excalidraw/math";var Au={mouse:8,pen:16,touch:28},bg=16,Tu={e:!0,s:!0,n:!0,w:!0},xM={e:!0,s:!0,n:!0,w:!0},yM={e:!0,s:!0,n:!0,w:!0,rotation:!0},ku={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},fa={e:!0,s:!0,n:!0,w:!0},rn=(e,t,n,o,i,r,s)=>{let[a,l]=wg(vu(e+n/2,t+o/2),vu(i,r),s);return[a-n/2,l-o/2,n,o]},Ir=e=>!(e.formFactor==="phone"&&e.userAgent.isMobileDevice),Ea=e=>Ir(e)?Tu:{},xa=([e,t,n,o,i,r],s,a,l,d={},c=4,p=ga)=>{let h=Au[l],m=h/a.value,f=h/a.value,g=h/a.value,E=h/a.value,x=n-e,y=o-t,w=c/a.value,M=(h-p*2)/(2*a.value),b={nw:d.nw?void 0:rn(e-w-g+M,t-w-E+M,m,f,i,r,s),ne:d.ne?void 0:rn(n+w-M,t-w-E+M,m,f,i,r,s),sw:d.sw?void 0:rn(e-w-g+M,o+w-M,m,f,i,r,s),se:d.se?void 0:rn(n+w-M,o+w-M,m,f,i,r,s),rotation:d.rotation?void 0:rn(e+x/2-m/2,t-w-E+M-bg/a.value,m,f,i,r,s)},S=5*Au.mouse/a.value;return Math.abs(x)>S&&(d.n||(b.n=rn(e+x/2-m/2,t-w-E+M,m,f,i,r,s)),d.s||(b.s=rn(e+x/2-m/2,o+w-M,m,f,i,r,s))),Math.abs(y)>S&&(d.w||(b.w=rn(e-w-g+M,t+y/2-f/2,m,f,i,r,s)),d.e||(b.e=rn(n+w-M,t+y/2-f/2,m,f,i,r,s))),b},Lu=(e,t,n,o="mouse",i=Tu)=>{if(e.locked||Y(e))return{};if(e.type==="freedraw"||ne(e)){if(e.points.length===2){let[,s]=e.points;s[0]===0||s[1]===0?i=fa:s[0]>0&&s[1]<0?i=ku:s[0]>0&&s[1]>0?i=fa:s[0]<0&&s[1]>0?i=ku:s[0]<0&&s[1]<0&&(i=fa)}}else te(e)&&(i={...i,rotation:!0});let r=ne(e)?ga+8:ve(e)?0:ga;return xa(K(e,n,!0),e.angle,t,o,i,r,ve(e)?0:void 0)},wM=(e,t,n)=>{if(t.selectedLinearElement?.isEditing||t.selectedLinearElement?.isDragging)return!1;if(e.length>1)return!0;let o=e[0];return Y(o)?!1:ne(o)?o.points.length>2&&!n.userAgent.isMobileDevice:!0};var ba=(e,t,n)=>t>=e[0]&&t<=e[0]+e[2]&&n>=e[1]&&n<=e[1]+e[3],Mg=(e,t,n,o,i,r,s,a)=>{if(!n.selectedElementIds[e.id])return!1;let{rotation:l,...d}=Lu(e,r,t,s,Ea(a));if(l&&ba(l,o,i))return"rotation";let c=Object.keys(d).filter(p=>{let h=d[p];return h?ba(h,o,i):!1});if(c.length>0)return c[0];if(Ir(a)){let[p,h,m,f,g,E]=K(e,t);if(!(ne(e)&&e.points.length<=2)){let x=ve(e)?0:wa/r.value,y=wa/r.value,w=Bu(ht(p-x,h-x),ht(m+x,f+x),ht(g,E),e.angle);for(let[M,b]of Object.entries(w))if(Cu(ht(o,i),b,y))return M}}return!1},kM=(e,t,n,o,i,r,s,a)=>e.reduce((l,d)=>{if(l)return l;let c=Mg(d,s,t,n,o,i,r,a);return c?{element:d,transformHandleType:c}:null},null),TM=([e,t,n,o],i,r,s,a,l)=>{let d=xa([e,t,n,o,(e+n)/2,(t+o)/2],0,s,a,Ea(l)),c=Object.keys(d).find(p=>{let h=d[p];return h&&ba(h,i,r)});if(c)return c;if(Ir(l)){let p=(e+n)/2,h=(t+o)/2,m=wa/s.value,f=Bu(ht(e-m,t-m),ht(n+m,o+m),ht(p,h),0);for(let[g,E]of Object.entries(f))if(Cu(ht(i,r),E,m))return g}return!1},ya=["ns","nesw","ew","nwse"],Pg=(e,t)=>{let n=ya.indexOf(e);if(n>=0){let o=Math.round(t/(Math.PI/4));e=ya[(n+o)%ya.length]}return e},LM=e=>{let{element:t,transformHandleType:n}=e,o=t&&Math.sign(t.height)*Math.sign(t.width)===-1,i=null;switch(n){case"n":case"s":i="ns";break;case"w":case"e":i="ew";break;case"nw":case"se":o?i="nesw":i="nwse";break;case"ne":case"sw":o?i="nwse":i="nesw";break;case"rotation":return"grab"}return i&&t&&(i=Pg(i,t.angle)),i?`${i}-resize`:""},Bu=([e,t],[n,o],i,r)=>{let s=Sr(ht(e,t),i,r),a=Sr(ht(n,t),i,r),l=Sr(ht(e,o),i,r),d=Sr(ht(n,o),i,r);return{n:[s,a],e:[a,d],s:[d,l],w:[l,s]}};I();import{KEYS as mt}from"@excalidraw/common";I();I();function Du(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=Du(e[t]))&&(o&&(o+=" "),o+=n);else for(t in e)e[t]&&(o&&(o+=" "),o+=t);return o}function Gu(){for(var e=0,t,n,o="";e<arguments.length;)(t=arguments[e++])&&(n=Du(t))&&(o&&(o+=" "),o+=n);return o}var be=ri($u(),1),u=ri(ka(),1);import{THEME as _g}from"@excalidraw/common";var St=e=>"var(--icon-fill-color)",Qu=e=>e===_g.LIGHT?"#fff":"#1e1e1e",P=(e,t=512)=>{let{width:n=512,height:o=n,mirror:i,style:r,...s}=typeof t=="number"?{width:t}:t;return(0,u.jsx)("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${n} ${o}`,className:Gu({"rtl-mirror":i}),style:r,...s,children:typeof e=="string"?(0,u.jsx)("path",{fill:"currentColor",d:e}):e})},k={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},j={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Ve={width:40,height:20},UM=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("rect",{x:3,y:8,width:18,height:4,rx:1}),(0,u.jsx)("line",{x1:12,y1:8,x2:12,y2:21}),(0,u.jsx)("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),(0,u.jsx)("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),k),YM=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),(0,u.jsx)("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),(0,u.jsx)("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),(0,u.jsx)("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),(0,u.jsx)("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),k),XM=P((0,u.jsxs)("svg",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,u.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),k),$M=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("circle",{cx:"12",cy:"12",r:"1"}),(0,u.jsx)("circle",{cx:"12",cy:"19",r:"1"}),(0,u.jsx)("circle",{cx:"12",cy:"5",r:"1"})]}),k),ZM=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,u.jsx)("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,u.jsx)("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),k),qM=P((0,u.jsxs)("svg",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),(0,u.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),(0,u.jsx)("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),k),KM=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M6.5 9.5l3.5 -3"}),(0,u.jsx)("path",{d:"M14 5.5l3 1.5"}),(0,u.jsx)("path",{d:"M18.5 10l-2.5 7"}),(0,u.jsx)("path",{d:"M13.5 17.5l-7 -5"})]}),k),QM=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),(0,u.jsx)("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),(0,u.jsx)("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:(0,u.jsx)("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),(0,u.jsx)("g",{mask:"url(#UnlockedIcon)",children:(0,u.jsx)("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),j),JM=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),(0,u.jsx)("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),(0,u.jsx)("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),j),eP=P((0,u.jsx)("g",{fill:"currentColor",children:(0,u.jsx)("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),tP=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),(0,u.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),(0,u.jsx)("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),nP=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),(0,u.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),(0,u.jsx)("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),oP=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),(0,u.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),(0,u.jsx)("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),iP=P((0,u.jsx)("g",{fill:"currentColor",children:(0,u.jsx)("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),Ta=P((0,u.jsxs)("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),(0,u.jsx)("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),rP=P((0,u.jsxs)("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[(0,u.jsx)("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),(0,u.jsx)("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Ju=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),k),ep=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),k),tp=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("circle",{cx:"12",cy:"12",r:"9"})]}),k),np=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),(0,u.jsx)("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),(0,u.jsx)("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),k),op=P((0,u.jsx)("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),j),sP=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),(0,u.jsx)("path",{d:"M16 7h4"}),(0,u.jsx)("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),k),ip=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),(0,u.jsx)("path",{d:"m11.25 5.417 3.333 3.333"})]}),j),rp=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),(0,u.jsx)("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),(0,u.jsx)("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,u.jsx)("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,u.jsx)("polyline",{points:"5 20 11 4 13 4 20 20"})]}),k),aP=P((0,u.jsxs)("g",{stroke:"currentColor",strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 7v-2h13v2"}),(0,u.jsx)("path",{d:"M10 5v14"}),(0,u.jsx)("path",{d:"M12 19h-4"}),(0,u.jsx)("path",{d:"M15 13v-1h6v1"}),(0,u.jsx)("path",{d:"M18 12v7"}),(0,u.jsx)("path",{d:"M17 19h2"})]}),k),sp=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M12.5 6.667h.01"}),(0,u.jsx)("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),(0,u.jsx)("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),(0,u.jsx)("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),j),ap=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),(0,u.jsx)("path",{d:"M18 13.3l-6.3 -6.3"})]}),k),lP=P((0,u.jsx)("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),j),dP=P((0,u.jsx)("path",{d:"M5 10h10",strokeWidth:"1.25"}),j),cP=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M21 21l-6 -6"}),(0,u.jsx)("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),(0,u.jsx)("path",{d:"M3 4v4h4"})]}),k),uP=P((0,u.jsx)("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),j),pP=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("polyline",{points:"12 16 18 10 12 4"}),(0,u.jsx)("polyline",{points:"8 4 2 10 8 16"})]}),j),hP=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),(0,u.jsx)("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),j),mP=P((0,u.jsx)("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),j),fP=P((0,u.jsx)("g",{stroke:"currentColor",strokeLinejoin:"round",children:(0,u.jsx)("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...j,strokeWidth:1.5}),gP=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),(0,u.jsx)("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),(0,u.jsx)("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),k),EP=P((0,u.jsx)("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),j),xP=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,u.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),(0,u.jsx)("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),k),yP=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,u.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),(0,u.jsx)("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),k),wP=P((0,u.jsx)("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),j),bP=P((0,u.jsx)("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),j),MP=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),(0,u.jsx)("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),j),PP=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),(0,u.jsx)("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),k),IP=P((0,u.jsx)("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),SP=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),(0,u.jsx)("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),j),vP=P("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),AP=P("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),kP=P((0,u.jsx)("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),j),TP=P("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),LP=P("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),CP=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),(0,u.jsx)("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),(0,u.jsx)("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),k),BP=P((0,u.jsx)("g",{strokeWidth:1.5,children:(0,u.jsx)("path",{d:"M6 18l12 -12"})}),k),DP=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M15 8h.01"}),(0,u.jsx)("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),(0,u.jsx)("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),(0,u.jsx)("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),(0,u.jsx)("path",{d:"M19 16v6"}),(0,u.jsx)("path",{d:"M22 19l-3 3l-3 -3"})]}),k),GP=P("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),OP=P("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),RP=P("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),FP=P("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),NP=P("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),HP=P((0,u.jsx)("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),j),zP=P((0,u.jsx)("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),j),_P=P("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),WP=P((0,u.jsx)("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),j),jP=P("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),VP=P("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),UP=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),(0,u.jsx)("path",{d:"M12 14v-11"}),(0,u.jsx)("path",{d:"M9 6l3 -3l3 3"})]}),k),YP=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),(0,u.jsx)("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),XP=P((0,u.jsx)("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),lp=(0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M12 10l0 10"}),(0,u.jsx)("path",{d:"M12 10l4 4"}),(0,u.jsx)("path",{d:"M12 10l-4 4"}),(0,u.jsx)("path",{d:"M4 4l16 0"})]}),dp=(0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M12 5l0 14"}),(0,u.jsx)("path",{d:"M16 9l-4 -4"}),(0,u.jsx)("path",{d:"M8 9l4 -4"})]}),$P=P(dp,k),ZP=P(dp,{...k,style:{transform:"rotate(180deg)"}}),qP=P(lp,k),KP=P(lp,{...k,style:{transform:"rotate(180deg)"}}),QP=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),JP=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),eI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),tI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),nI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),oI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),iI=P((0,u.jsxs)("g",{stroke:"currentColor",strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),j),rI=P((0,u.jsxs)("g",{stroke:"currentColor",strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),(0,u.jsx)("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),j),sI=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,u.jsx)("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),(0,u.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),(0,u.jsx)("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),k),aI=P("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),lI=P("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),dI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:(0,u.jsx)("path",{d:"M15 5 5 15M5 5l10 10"})}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),cI=P("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),uI=P("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),pI=P("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),hI=be.default.memo(({theme:e})=>P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{d:"M25 26H111V111H25",fill:St(e)}),(0,u.jsx)("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:St(e),strokeWidth:"2"}),(0,u.jsx)("path",{d:"M100 100H160V160H100",fill:St(e)}),(0,u.jsx)("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:St(e),strokeWidth:"2"}),(0,u.jsxs)("g",{fill:Qu(e),stroke:St(e),strokeWidth:"6",children:[(0,u.jsx)("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),(0,u.jsx)("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),(0,u.jsx)("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),(0,u.jsx)("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),mI=be.default.memo(({theme:e})=>P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{d:"M25 26H111V111H25",fill:St(e)}),(0,u.jsx)("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:St(e),strokeWidth:"2"}),(0,u.jsx)("path",{d:"M100 100H160V160H100",fill:St(e)}),(0,u.jsx)("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:St(e),strokeWidth:"2"}),(0,u.jsxs)("g",{fill:Qu(e),stroke:St(e),strokeWidth:"6",children:[(0,u.jsx)("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),(0,u.jsx)("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),(0,u.jsx)("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),(0,u.jsx)("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),(0,u.jsx)("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),(0,u.jsx)("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),fI=P((0,u.jsx)("g",{strokeWidth:1.25,children:(0,u.jsx)("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),j),gI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),(0,u.jsx)("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:(0,u.jsx)("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),(0,u.jsx)("g",{mask:"url(#FillHachureIcon)",children:(0,u.jsx)("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),j),EI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("g",{clipPath:"url(#a)",children:[(0,u.jsx)("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),(0,u.jsx)("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:(0,u.jsx)("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,u.jsx)("g",{mask:"url(#FillCrossHatchIcon)",children:(0,u.jsx)("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),xI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("g",{clipPath:"url(#a)",children:(0,u.jsx)("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...j,fill:"currentColor"}),yI=P((0,u.jsx)(u.Fragment,{children:(0,u.jsx)("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),j),wI=P((0,u.jsx)("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),j),bI=P((0,u.jsx)("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),j),MI=be.default.memo(({theme:e})=>P((0,u.jsx)("path",{d:"M6 10H34",stroke:St(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),PI=P((0,u.jsxs)("g",{strokeWidth:"2",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M5 12h2"}),(0,u.jsx)("path",{d:"M17 12h2"}),(0,u.jsx)("path",{d:"M11 12h2"})]}),k),II=P((0,u.jsxs)("g",{strokeWidth:"2",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 12v.01"}),(0,u.jsx)("path",{d:"M8 12v.01"}),(0,u.jsx)("path",{d:"M12 12v.01"}),(0,u.jsx)("path",{d:"M16 12v.01"}),(0,u.jsx)("path",{d:"M20 12v.01"})]}),k),SI=P((0,u.jsx)("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),j),vI=P((0,u.jsx)("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),j),AI=P((0,u.jsx)("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),j),kI=P((0,u.jsxs)("svg",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),(0,u.jsx)("path",{d:"M13.3333 3.33331V3.34331"}),(0,u.jsx)("path",{d:"M16.6667 3.33331V3.34331"}),(0,u.jsx)("path",{d:"M16.6667 6.66669V6.67669"}),(0,u.jsx)("path",{d:"M16.6667 10V10.01"}),(0,u.jsx)("path",{d:"M3.33334 13.3333V13.3433"}),(0,u.jsx)("path",{d:"M16.6667 13.3333V13.3433"}),(0,u.jsx)("path",{d:"M3.33334 16.6667V16.6767"}),(0,u.jsx)("path",{d:"M6.66666 16.6667V16.6767"}),(0,u.jsx)("path",{d:"M10 16.6667V16.6767"}),(0,u.jsx)("path",{d:"M13.3333 16.6667V16.6767"}),(0,u.jsx)("path",{d:"M16.6667 16.6667V16.6767"})]}),j),TI=P((0,u.jsxs)("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),(0,u.jsx)("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),(0,u.jsx)("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),(0,u.jsx)("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),(0,u.jsx)("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),(0,u.jsx)("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),(0,u.jsx)("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),(0,u.jsx)("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),(0,u.jsx)("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),(0,u.jsx)("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),(0,u.jsx)("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),(0,u.jsx)("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),k),LI=be.default.memo(({flip:e=!1})=>P((0,u.jsxs)("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[(0,u.jsx)("path",{d:"M7,11 H19"}),(0,u.jsx)("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),Ve)),CI=be.default.memo(({flip:e=!1})=>P((0,u.jsx)("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:(0,u.jsx)("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),Ve)),BI=be.default.memo(({flip:e=!1})=>P((0,u.jsxs)("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[(0,u.jsx)("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),(0,u.jsx)("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Ve)),DI=be.default.memo(({flip:e=!1})=>P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[(0,u.jsx)("path",{d:"M7,11 H23"}),(0,u.jsx)("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Ve)),GI=be.default.memo(({flip:e=!1})=>P((0,u.jsxs)("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[(0,u.jsx)("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),(0,u.jsx)("circle",{cx:"29",cy:"11",r:"4"})]}),Ve)),OI=be.default.memo(({flip:e=!1})=>P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[(0,u.jsx)("path",{d:"M7,11 H25",strokeLinecap:"round"}),(0,u.jsx)("circle",{cx:"29",cy:"11",r:"4"})]}),Ve)),RI=be.default.memo(({flip:e=!1})=>P((0,u.jsxs)("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[(0,u.jsx)("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),(0,u.jsx)("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Ve)),FI=be.default.memo(({flip:e=!1})=>P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[(0,u.jsx)("path",{d:"M7,11 H21"}),(0,u.jsx)("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Ve)),NI=be.default.memo(({flip:e=!1})=>P((0,u.jsx)("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:(0,u.jsx)("path",{d:"M11,11 H31 M31,5 V17"})}),Ve)),HI=be.default.memo(({flip:e=!1})=>P((0,u.jsx)("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:(0,u.jsx)("path",{d:"M35,11 H7 M15,5 V17"})}),Ve)),zI=be.default.memo(({flip:e=!1})=>P((0,u.jsx)("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:(0,u.jsx)("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),Ve)),_I=be.default.memo(({flip:e=!1})=>P((0,u.jsx)("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:(0,u.jsx)("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),Ve)),WI=be.default.memo(({flip:e=!1})=>P((0,u.jsx)("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:(0,u.jsx)("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),Ve)),jI=be.default.memo(({flip:e=!1})=>P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[(0,u.jsx)("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),(0,u.jsx)("circle",{cx:"15",cy:"11",r:"4"})]}),Ve)),VI=be.default.memo(({flip:e=!1})=>P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[(0,u.jsx)("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),(0,u.jsx)("circle",{cx:"23",cy:"11",r:"4"})]}),Ve)),UI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("g",{clipPath:"url(#a)",children:(0,u.jsx)("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),YI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("g",{clipPath:"url(#a)",children:(0,u.jsx)("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),XI=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("g",{clipPath:"url(#a)",children:(0,u.jsx)("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,u.jsx)("defs",{children:(0,u.jsx)("clipPath",{id:"a",children:(0,u.jsx)("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),j),$I=P((0,u.jsx)(u.Fragment,{children:(0,u.jsx)("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),j),ZI=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 7v-2h13v2"}),(0,u.jsx)("path",{d:"M10 5v14"}),(0,u.jsx)("path",{d:"M12 19h-4"}),(0,u.jsx)("path",{d:"M15 13v-1h6v1"}),(0,u.jsx)("path",{d:"M18 12v7"}),(0,u.jsx)("path",{d:"M17 19h2"})]}),k),qI=P((0,u.jsx)(u.Fragment,{children:(0,u.jsxs)("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M7 12h10"}),(0,u.jsx)("path",{d:"M7 5v14"}),(0,u.jsx)("path",{d:"M17 5v14"}),(0,u.jsx)("path",{d:"M15 19h4"}),(0,u.jsx)("path",{d:"M15 5h4"}),(0,u.jsx)("path",{d:"M5 19h4"}),(0,u.jsx)("path",{d:"M5 5h4"})]})}),k),KI=P((0,u.jsx)(u.Fragment,{children:(0,u.jsx)("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:(0,u.jsx)("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),j),QI=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M7 8l-4 4l4 4"}),(0,u.jsx)("path",{d:"M17 8l4 4l-4 4"}),(0,u.jsx)("path",{d:"M14 4l-4 16"})]}),k);var JI=P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),(0,u.jsx)("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),(0,u.jsx)("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),k),eS=P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),(0,u.jsx)("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),(0,u.jsx)("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),k),tS=P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),(0,u.jsx)("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),(0,u.jsx)("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),k),nS=be.default.memo(({theme:e})=>P((0,u.jsxs)("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),(0,u.jsx)("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),k)),oS=be.default.memo(({theme:e})=>P((0,u.jsxs)("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),(0,u.jsx)("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),k)),iS=be.default.memo(({theme:e})=>P((0,u.jsxs)("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),(0,u.jsx)("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),(0,u.jsx)("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),k)),rS=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M21 19h-18l9 -15"}),(0,u.jsx)("path",{d:"M20.615 15.171h.015"}),(0,u.jsx)("path",{d:"M19.515 11.771h.015"}),(0,u.jsx)("path",{d:"M17.715 8.671h.015"}),(0,u.jsx)("path",{d:"M15.415 5.971h.015"})]}),k),sS=P((0,u.jsx)("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),aS=P((0,u.jsx)("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),lS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),(0,u.jsx)("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),(0,u.jsx)("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),(0,u.jsx)("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),k),dS=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),(0,u.jsx)("path",{d:"M7 11l5 5l5 -5"}),(0,u.jsx)("path",{d:"M12 4l0 12"})]}),k),cS=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),(0,u.jsx)("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),k),uS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),(0,u.jsx)("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),(0,u.jsx)("path",{d:"M9.15 14.85l8.85 -10.85"}),(0,u.jsx)("path",{d:"M6 4l8.85 10.85"})]}),k),pS=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),(0,u.jsx)("path",{d:"M12 17l0 .01"}),(0,u.jsx)("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),k),hS=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M7 4v16l13 -8z"})]}),k),mS=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),k),fS=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M5 12l5 5l10 -10"})]}),k),gS=P((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),(0,u.jsx)("path",{d:"M12 9v4"}),(0,u.jsx)("path",{d:"M12 17h.01"})]}),k),ES=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M11 7l6 6"}),(0,u.jsx)("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),k),xS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M12 3l-4 7h8z"}),(0,u.jsx)("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),(0,u.jsx)("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),k),yS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 7l16 0"}),(0,u.jsx)("path",{d:"M4 17l16 0"}),(0,u.jsx)("path",{d:"M7 4l0 16"}),(0,u.jsx)("path",{d:"M17 4l0 16"})]}),k),wS=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),(0,u.jsx)("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),k),bS=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),(0,u.jsx)("path",{d:"M4 15l8 4l8 -4"}),(0,u.jsx)("path",{d:"M12 4v7"}),(0,u.jsx)("path",{d:"M15 8l-3 3l-3 -3"})]}),k),MS=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{d:"M4.16602 10H15.8327"}),(0,u.jsx)("path",{d:"M12.5 13.3333L15.8333 10"}),(0,u.jsx)("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),j),PS=P((0,u.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[(0,u.jsx)("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),(0,u.jsx)("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),IS=P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z"}),(0,u.jsx)("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),(0,u.jsx)("path",{d:"M15 6l3 3"}),(0,u.jsx)("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),(0,u.jsx)("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),k),SS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z"}),(0,u.jsx)("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),(0,u.jsx)("path",{d:"M15 6l3 3"}),(0,u.jsx)("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),(0,u.jsx)("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),k),vS=P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),(0,u.jsx)("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),(0,u.jsx)("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),(0,u.jsx)("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),(0,u.jsx)("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),(0,u.jsx)("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),k),AS=P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),(0,u.jsx)("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),(0,u.jsx)("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),(0,u.jsx)("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),k),kS=P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),(0,u.jsx)("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),k),TS=P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),(0,u.jsx)("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),(0,u.jsx)("path",{d:"M3 3l18 18"})]}),k),LS=P((0,u.jsxs)("g",{stroke:"currentColor",fill:"none",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),(0,u.jsx)("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),(0,u.jsx)("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),(0,u.jsx)("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),(0,u.jsx)("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),(0,u.jsx)("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),k),CS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),(0,u.jsx)("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),(0,u.jsx)("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),(0,u.jsx)("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),(0,u.jsx)("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),(0,u.jsx)("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),k),BS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),(0,u.jsx)("path",{d:"M21 21l-6 -6"})]}),k),DS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),(0,u.jsx)("path",{d:"M12 7v5l3 3"}),(0,u.jsx)("path",{d:"M19 16l-2 3h4l-2 3"})]}),k),GS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M12 8l0 4l2 2"}),(0,u.jsx)("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),k),OS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),(0,u.jsx)("path",{d:"M5 10a7 7 0 0 0 14 0"}),(0,u.jsx)("path",{d:"M8 21l8 0"}),(0,u.jsx)("path",{d:"M12 17l0 4"})]}),k),RS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 3l18 18"}),(0,u.jsx)("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),(0,u.jsx)("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),(0,u.jsx)("path",{d:"M8 21l8 0"}),(0,u.jsx)("path",{d:"M12 17l0 4"})]}),k),FS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),k),NS=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),(0,u.jsx)("path",{d:"M12 20v.01"}),(0,u.jsx)("path",{d:"M16 20v.01"}),(0,u.jsx)("path",{d:"M8 20v.01"}),(0,u.jsx)("path",{d:"M4 20v.01"}),(0,u.jsx)("path",{d:"M4 16v.01"}),(0,u.jsx)("path",{d:"M4 12v.01"}),(0,u.jsx)("path",{d:"M4 8v.01"}),(0,u.jsx)("path",{d:"M4 4v.01"}),(0,u.jsx)("path",{d:"M8 4v.01"}),(0,u.jsx)("path",{d:"M12 4v.01"}),(0,u.jsx)("path",{d:"M16 4v.01"}),(0,u.jsx)("path",{d:"M20 4v.01"}),(0,u.jsx)("path",{d:"M20 8v.01"}),(0,u.jsx)("path",{d:"M20 12v.01"}),(0,u.jsx)("path",{d:"M20 16v.01"}),(0,u.jsx)("path",{d:"M20 20v.01"})]}),k),HS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M5 3v18"}),(0,u.jsx)("path",{d:"M19 21v-18"}),(0,u.jsx)("path",{d:"M5 7h14"}),(0,u.jsx)("path",{d:"M5 15h14"}),(0,u.jsx)("path",{d:"M8 13v4"}),(0,u.jsx)("path",{d:"M11 13v4"}),(0,u.jsx)("path",{d:"M16 13v4"}),(0,u.jsx)("path",{d:"M14 5v4"}),(0,u.jsx)("path",{d:"M11 5v4"}),(0,u.jsx)("path",{d:"M8 5v4"}),(0,u.jsx)("path",{d:"M3 21h18"})]}),k),zS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 12l18 0"}),(0,u.jsx)("path",{d:"M7 16l10 0l-10 5l0 -5"}),(0,u.jsx)("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),k),_S=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M12 3l0 18"}),(0,u.jsx)("path",{d:"M16 7l0 10l5 0l-5 -10"}),(0,u.jsx)("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),k),WS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),(0,u.jsx)("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),(0,u.jsx)("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),k),jS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),(0,u.jsx)("path",{d:"M22 22l-3 -3"}),(0,u.jsx)("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),(0,u.jsx)("path",{d:"M3 11v-1"}),(0,u.jsx)("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),(0,u.jsx)("path",{d:"M10 3h1"}),(0,u.jsx)("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),k),VS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),(0,u.jsx)("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),(0,u.jsx)("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),(0,u.jsx)("path",{d:"M10 15l2 6l2 -6"}),(0,u.jsx)("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),k),US=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),(0,u.jsx)("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),(0,u.jsx)("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),(0,u.jsx)("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),(0,u.jsx)("path",{d:"M11 21v-6l3 6v-6"})]}),k),YS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),(0,u.jsx)("path",{d:"M4 8l5 0"}),(0,u.jsx)("path",{d:"M15 8l4 0"})]}),k),XS=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),(0,u.jsx)("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),(0,u.jsx)("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),(0,u.jsx)("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),(0,u.jsx)("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),k),$S=P((0,u.jsxs)("g",{stroke:"currentColor",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...k,strokeWidth:1.5}),ZS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),(0,u.jsx)("path",{d:"M21 12h-13l3 -3"}),(0,u.jsx)("path",{d:"M11 15l-3 -3"})]}),k),qS=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),(0,u.jsx)("path",{d:"M10 9l5 3l-5 3z"})]}),k),KS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 6h18"}),(0,u.jsx)("path",{d:"M3 12h18"}),(0,u.jsx)("path",{d:"M3 18h18"}),(0,u.jsx)("path",{d:"M6 3v18"}),(0,u.jsx)("path",{d:"M12 3v18"}),(0,u.jsx)("path",{d:"M18 3v18"})]}),k),QS=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),(0,u.jsx)("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),(0,u.jsx)("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),k),JS=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M6 18l12 -12"}),(0,u.jsx)("path",{d:"M18 10v-4h-4"})]}),k),ev=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),(0,u.jsx)("path",{d:"M18 4l3 3l-3 3"})]}),k),tv=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{d:"M16,12L20,9L16,6"}),(0,u.jsx)("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),k),nv=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M6 9l6 6l6 -6"})]}),k),ov=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M6 15l6 -6l6 6"})]}),k),iv=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M6 15l6 -6l6 6"})]}),k),rv=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),(0,u.jsx)("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),k),sv=P((0,u.jsxs)("g",{children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M5 7l0 10"}),(0,u.jsx)("path",{d:"M7 5l10 0"}),(0,u.jsx)("path",{d:"M7 19l10 0"}),(0,u.jsx)("path",{d:"M19 7l0 10"})]}),k),av=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),(0,u.jsx)("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),(0,u.jsx)("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),(0,u.jsx)("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),(0,u.jsx)("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),(0,u.jsx)("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),(0,u.jsx)("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),(0,u.jsx)("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),(0,u.jsx)("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),k),lv=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),(0,u.jsx)("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),(0,u.jsx)("polyline",{points:"2 8 3 6 4 8"}),(0,u.jsx)("polyline",{points:"2 12 3 14 4 12"}),(0,u.jsx)("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),(0,u.jsx)("polyline",{points:"9 17 7 18 9 19"}),(0,u.jsx)("polyline",{points:"15 17 17 18 15 19"})]}),k),dv=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),(0,u.jsx)("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),k),cv=P((0,u.jsx)("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:(0,u.jsx)("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),uv=P((0,u.jsxs)("g",{strokeWidth:1.5,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M4 6l8 0"}),(0,u.jsx)("path",{d:"M16 6l4 0"}),(0,u.jsx)("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M4 12l2 0"}),(0,u.jsx)("path",{d:"M10 12l10 0"}),(0,u.jsx)("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M4 18l11 0"}),(0,u.jsx)("path",{d:"M19 18l1 0"})]}),k),pv=P((0,u.jsxs)("g",{strokeWidth:1,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),k),hv=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),(0,u.jsx)("path",{d:"M13.5 6.5l4 4"})]}),k),mv=P((0,u.jsxs)("g",{strokeWidth:1,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M11 7l-5 5l5 5"}),(0,u.jsx)("path",{d:"M17 7l-5 5l5 5"})]}),k),fv=P((0,u.jsxs)("g",{strokeWidth:"1.75",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),(0,u.jsx)("path",{d:"M15 4l0 16"})]}),k),gv=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),k),Ev=P((0,u.jsxs)("g",{strokeWidth:"1.25",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M3 4l18 0"}),(0,u.jsx)("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),(0,u.jsx)("path",{d:"M12 16l0 4"}),(0,u.jsx)("path",{d:"M9 20l6 0"}),(0,u.jsx)("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),k);var xv=P((0,u.jsxs)("g",{strokeWidth:"1.5",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("polyline",{points:"9 6 15 12 9 18"})]}),k),yv=P((0,u.jsxs)("g",{strokeWidth:1.25,children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,u.jsx)("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M4 6l8 0"}),(0,u.jsx)("path",{d:"M16 6l4 0"}),(0,u.jsx)("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M4 12l2 0"}),(0,u.jsx)("path",{d:"M10 12l10 0"}),(0,u.jsx)("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),(0,u.jsx)("path",{d:"M4 18l11 0"}),(0,u.jsx)("path",{d:"M19 18l1 0"})]}),k);var cp=[{icon:Ta,value:"selection",key:mt.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Ju,value:"rectangle",key:mt.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:ep,value:"diamond",key:mt.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:tp,value:"ellipse",key:mt.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:np,value:"arrow",key:mt.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:op,value:"line",key:mt.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:ip,value:"freedraw",key:[mt.P,mt.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:rp,value:"text",key:mt.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:sp,value:"image",key:[mt.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:ap,value:"eraser",key:mt.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}],Wg=e=>e.state.preferredSelectionTool.type==="lasso"?[{value:"lasso",icon:Ta,key:mt.V,fillable:!0,myocSimplifiedMode:!0},...cp.slice(1)]:cp,Av=(e,t)=>Wg(t).find((o,i)=>o.numericKey!=null&&e===o.numericKey?.toString()||o.key&&(typeof o.key=="string"?o.key===e:o.key.includes(e)))?.value||null,kv=(e,t)=>{let n=J(e,t);return n?e.type==="arrow"?qo({...n,...G.getBoundTextElementPosition(e,n,t)},t):qo(n,t):null};I();var Bv=(e,t)=>!!(!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(e.activeTool.type!=="custom"&&(e.editingTextElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="lasso"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||Ot(t,e).length));I();import{pointFrom as kr}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as jg,DEFAULT_FONT_SIZE as Vg,TEXT_ALIGN as Ug,VERTICAL_ALIGN as Yg,getSizeFromPoints as Xg,randomId as $g,arrayToMap as Zg,assertNever as La,cloneJSON as pp,getFontString as qg,isDevEnv as Kg,toBrandedType as Qg,getLineHeight as Jg}from"@excalidraw/common";var Tr={width:100,height:0},Gn=100,eE=(e,t,n)=>{let o=$n({x:0,y:0,textAlign:Ug.CENTER,verticalAlign:Yg.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:o.id})}),Di(o,e,n),[e,o]},up=(e,t,n,o,i)=>{let r,s;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let c=t?.width??Gn,p=t?.height??Gn,h;t.id&&(h=o.getElement(t.id),h||console.error(`No element for start binding with id ${t.id} found`));let m=t.x||e.x-c,f=t.y||e.y-p/2,g=h?h.type:t.type;if(g){if(g==="text"){let E="";h&&h.type==="text"?E=h.text:t.type==="text"&&(E=t.text),E||console.error(`No text found for start binding text element for ${e.id}`),r=$n({x:m,y:f,type:"text",...h,...t,text:E}),Object.assign(r,{x:t.x||e.x-r.width,y:t.y||e.y-r.height/2})}else switch(g){case"rectangle":case"ellipse":case"diamond":{r=Xn({x:m,y:f,width:c,height:p,...h,...t,type:g});break}default:La(e,`Unhandled element start type "${t.type}"`,!0)}Gt(e,r,"orbit","start",i)}}if(n){let c=n?.height??Gn,p=n?.width??Gn,h;n.id&&(h=o.getElement(n.id),h||console.error(`No element for end binding with id ${n.id} found`));let m=n.x||e.x+e.width,f=n.y||e.y-c/2,g=h?h.type:n.type;if(g){if(g==="text"){let E="";h&&h.type==="text"?E=h.text:n.type==="text"&&(E=n.text),E||console.error(`No text found for end binding text element for ${e.id}`),s=$n({x:m,y:f,type:"text",...h,...n,text:E}),Object.assign(s,{y:n.y||e.y-s.height/2})}else switch(g){case"rectangle":case"ellipse":case"diamond":{s=Xn({x:m,y:f,width:p,height:c,...h,...n,type:g});break}default:La(e,`Unhandled element end type "${g}"`,!0)}Gt(e,s,"orbit","end",i)}}if(e.points.length<2)return{linearElement:e,startBoundElement:r,endBoundElement:s};let a=e.points.length-1,l=.5,d=pp(e.points);return e.points[a][0]>e.points[a-1][0]&&(d[0][0]=l,d[a][0]-=l),e.points[a][0]<e.points[a-1][0]&&(d[0][0]=-l,d[a][0]+=l),e.points[a][1]>e.points[a-1][1]&&(d[0][1]=l,d[a][1]-=l),e.points[a][1]<e.points[a-1][1]&&(d[0][1]=-l,d[a][1]+=l),Object.assign(e,G.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:r,endBoundElement:s}},Ca=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>ea(Array.from(this.excalidrawElements.values()));getElementsMap=()=>Qg(Zg(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},Yv=(e,t)=>{if(!e)return[];let n=pp(e),o=new Ca,i=new Map,r=new Map;for(let l of n){let d,c=l.id;switch(t?.regenerateIds!==!1&&Object.assign(l,{id:$g()}),l.type){case"rectangle":case"ellipse":case"diamond":{let h=l?.label?.text&&l.width===void 0?0:l?.width||Gn,m=l?.label?.text&&l.height===void 0?0:l?.height||Gn;d=Xn({...l,width:h,height:m});break}case"line":{let h=l.width||Tr.width,m=l.height||Tr.height;d=Kc({width:h,height:m,points:[kr(0,0),kr(h,m)],...l});break}case"arrow":{let h=l.width||Tr.width,m=l.height||Tr.height;d=Er({width:h,height:m,endArrowhead:"arrow",points:[kr(0,0),kr(h,m)],...l,type:"arrow"}),Object.assign(d,Xg(d.points));break}case"text":{let h=l?.fontFamily||jg,m=l?.fontSize||Vg,f=l?.lineHeight||Jg(h),g=l.text??"",E=Bo(g),x=ot(E,qg({fontFamily:h,fontSize:m}),f);d=$n({width:x.width,height:x.height,fontFamily:h,fontSize:m,...l});break}case"image":{d=Qc({width:l?.width||Gn,height:l?.height||Gn,...l});break}case"frame":{d=$c({x:0,y:0,...l});break}case"magicframe":{d=Zc({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{d=l;break}default:d=l,La(l,`Unhandled element type "${l.type}"`,!0)}o.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(o.add(d),i.set(d.id,l),c&&r.set(c,d.id))}let s=o.getElementsMap(),a=new uo(s);for(let[l,d]of i){let c=o.getElement(l);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[p,h]=eE(c,d?.label,a);if(o.add(p),o.add(h),V(p)){let m=d.type==="arrow"?d?.start:void 0,f=d.type==="arrow"?d?.end:void 0;if(m&&m.id){let y=r.get(m.id);y&&Object.assign(m,{id:y})}if(f&&f.id){let y=r.get(f.id);y&&Object.assign(f,{id:y})}let{linearElement:g,startBoundElement:E,endBoundElement:x}=up(p,m,f,o,a);p=g,o.add(g),o.add(E),o.add(x)}}else switch(d.type){case"arrow":{let{start:p,end:h}=d;if(p&&p.id){let E=r.get(p.id);Object.assign(p,{id:E})}if(h&&h.id){let E=r.get(h.id);Object.assign(h,{id:E})}let{linearElement:m,startBoundElement:f,endBoundElement:g}=up(c,p,h,o,a);o.add(m),o.add(f),o.add(g);break}}break}}}for(let[l,d]of i){if(d.type!=="frame"&&d.type!=="magicframe")continue;let c=o.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let p=[];d.children.forEach(b=>{let S=r.get(b);if(!S)throw new Error(`Element with ${b} wasn't mapped correctly`);let A=o.getElement(S);if(!A)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(A,{frameId:c.id}),A?.boundElements?.forEach(C=>{let T=o.getElement(C.id);if(!T)throw new Error(`Bound element with id ${C.id} doesn't exist`);Object.assign(T,{frameId:c.id}),p.push(T)}),p.push(A)});let[h,m,f,g]=_e(p),E=10;h=h-E,m=m-E,f=f+E,g=g+E;let x=c?.x||h,y=c?.y||m,w=c?.width||f-h,M=c?.height||g-m;Object.assign(c,{x,y,width:w,height:M}),Kg()&&d.children.length&&(c?.x||c?.y||c?.width||c?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return o.getElements()};I();var Kv=({app:e,event:t})=>{let n=e.state;if(n.selectedLinearElement&&e.lastPointerMoveCoords){if(n.selectedLinearElement.draggedFocusPointBinding)return bu(n.selectedLinearElement,e.scene.getNonDeletedElementsMap(),e.lastPointerMoveCoords,e.scene,n,e.getEffectiveGridSize(),t.altKey),!0;if(n.selectedLinearElement.hoverPointIndex!==null&&e.lastPointerMoveEvent&&n.selectedLinearElement.initialState.lastClickedPoint>=0&&n.selectedLinearElement.isDragging)return G.handlePointDragging(e.lastPointerMoveEvent,e,e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y,n.selectedLinearElement),!0}return!1};I();var tE=e=>{switch(e){case void 0:case null:return null;case"dot":return"circle";case"crowfoot_one":return"cardinality_one";case"crowfoot_many":return"cardinality_many";case"crowfoot_one_or_many":return"cardinality_one_or_many";default:return e}},e7=e=>{let t=tE(e);return t===null?null:t};var r7=e=>e.reduce((t,n)=>t+n.version,0),Mc=e=>{let t=5381;for(let n of nE(e))t=(t<<5)+t+n.versionNonce;return t>>>0},Pc=e=>{let t=5381;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);t=(t<<5)+t+o}return t>>>0},s7=e=>e.filter(t=>!t.isDeleted&&!hc(t)),a7=e=>e.filter(t=>!t.isDeleted),l7=e=>!e.isDeleted;export{kn as AppStateDelta,zh as BASE_ARROW_MIN_LENGTH,dd as BASE_BINDING_GAP,jn as BASE_BINDING_GAP_ELBOW,re as BASE_PADDING,Pn as BindableElement,Mn as BoundElement,Je as CaptureUpdateAction,Hw as DEFAULT_LINK_SIZE,Tu as DEFAULT_OMIT_SIDES,$ as Delta,Zs as DurableIncrement,js as ElementBounds,Tn as ElementsDelta,qs as EphemeralIncrement,Wo as FOCUS_POINT_SIZE,au as FlowChartCreator,su as FlowChartNavigator,Ae as HEADING_DOWN,Ze as HEADING_LEFT,we as HEADING_RIGHT,rt as HEADING_UP,P0 as INVISIBLY_SMALL_ELEMENT_SIZE,Qs as InvalidFractionalIndexError,G as LinearElementEditor,Le as MINIMAL_CROP_SIZE,yM as OMIT_SIDES_FOR_FRAME,xM as OMIT_SIDES_FOR_MULTIPLE_ELEMENTS,cp as SHAPES,uo as Scene,st as ShapeCache,xc as Store,Qo as StoreChange,Ks as StoreDelta,ur as StoreIncrement,Ln as StoreSnapshot,ut as aabbForElement,Dm as addElementsToFrame,eg as addNewNodes,Ry as addToGroup,Vb as alignElements,Qb as arrangeElements,Xh as avoidRectangularCorner,Gt as bindBindingElement,jd as bindElementsToFramesAfterDuplication,_h as bindOrUnbindBindingElement,ny as bindOrUnbindBindingElements,ws as bindPointToSnapToElementOutline,hd as bindingProperties,od as bumpVersion,Zh as calculateFixedPointForElbowArrowBinding,no as calculateFixedPointForNonElbowArrowBinding,ax as canApplyRoundnessTypeToElement,gl as canBecomePolygon,Qd as canChangeRoundness,vf as canCreateLinkFromElements,qw as canHaveArrowheads,Ir as canResizeFromSides,Jn as charWidth,ye as compareHeading,Do as computeBoundTextPosition,ns as computeContainerDimensionForBoundText,Rx as containsCJK,Yv as convertToExcalidrawElements,U4 as createPlaceholderEmbeddableLabel,ra as createSrcDoc,Q2 as cropElement,pn as deconstructDiamondElement,vi as deconstructLinearOrFreeDrawElement,un as deconstructRectanguloidElement,$s as deepCopyElement,b4 as defaultGetElementLinkFromSelection,Tx as detectLineHeight,fn as distanceToElement,i4 as distributeElements,Ro as doBoundsIntersect,g4 as dragNewElement,m4 as dragSelectedElements,G0 as duplicateElement,p6 as duplicateElements,Oy as editGroupForSelectedElement,ce as elementCenterPoint,In as elementOverlapsWithFrame,Yo as elementWithCanvasCache,vn as elementsAreInFrameBounds,Nd as elementsAreInSameGroup,X4 as embeddableURLValidator,_d as excludeElementsInFramesFromSelection,xw as filterElementsEligibleAsFrameChildren,Av as findShapeByKey,iy as fixBindingsAfterDeletion,pd as fixDuplicatedBindingsAfterDuplication,cs as flipHeading,Iw as frameAndChildrenSelectedTogether,Pl as generateLinearCollisionShape,Qe as generateRoughOptions,Ky as getActiveTextElement,Ri as getAllHoveredElementAtPoint,kl as getApproxMinLineHeight,Al as getApproxMinLineWidth,md as getArrowLocalFixedPoints,E0 as getArrowheadAngle,e7 as getArrowheadForPicker,We as getArrowheadPoints,g0 as getArrowheadSize,Fe as getBindingGap,ry as getBindingSideMidPoint,Ss as getBindingStrategyForDraggingBindingElementEndpoints,J as getBoundTextElement,$t as getBoundTextElementId,$x as getBoundTextElementPosition,Go as getBoundTextMaxHeight,yt as getBoundTextMaxWidth,kv as getBoundTextShape,Vs as getBoundsFromPoints,Ct as getCenterForBounds,kb as getClosestElementBounds,je as getCommonBoundingBox,_e as getCommonBounds,Yx as getContainerCenter,os as getContainerCoords,De as getContainerElement,en as getContainingFrame,Vt as getCornerRadius,Fi as getCubicBezierCurveBound,LM as getCursorForResizingElement,Nm as getDefaultFrameName,lx as getDefaultRoundnessTypeForElement,Ml as getDiamondBaseCorners,Qn as getDiamondPoints,f4 as getDragOffsetXY,Ab as getDraggedElementsBounds,K as getElementAbsoluteCoords,Me as getElementBounds,Gs as getElementLineSegments,ks as getElementPointsCoords,qo as getElementShape,kM as getElementWithTransformHandleType,Vd as getElementsCompletelyInFrame,ze as getElementsInGroup,Ew as getElementsInNewFrame,gw as getElementsInResizingFrame,cw as getElementsIntersectingFrame,Pw as getElementsOverlappingFrame,Bs as getElementsWithinSelection,V4 as getEmbedLink,J2 as getFlipAdjustedCropPosition,Sn as getFrameChildren,Cm as getFrameLikeElements,Mw as getFrameLikeTitle,Ww as getFreedrawOutlineAsSegments,s0 as getFreedrawOutlinePoints,Ye as getGlobalFixedPointForBindableElement,qh as getGlobalFixedPoints,nd as getHeadingForElbowArrowSnap,Zt as getHoveredElementForBinding,Vl as getHoveredElementForFocusPoint,H5 as getInitializedImageElements,Li as getLineHeightInPx,mn as getLineWidth,dx as getLinearElementSubType,a5 as getLinkDirectionFromKey,M4 as getLinkIdAndTypeFromSelection,Sd as getLockedLinearCursorAlignSize,A1 as getMaxCharWidth,er as getMaximumGroups,Cx as getMinCharWidth,Vo as getMinMaxXYFromCurvePathOps,Ti as getMinTextElementWidth,zd as getNewGroupIdsForDuplication,a7 as getNonDeletedElements,Fd as getNonDeletedGroupIds,Nb as getNormalizedDimensions,ao as getObservedAppState,Ea as getOmitSidesForEditorInterface,Ix as getOriginalContainerHeightFromCache,Us as getPerfectElementSize,da as getPredecessors,vb as getRectangleBoxAbsoluteCoords,Zm as getRenderOpacity,uM as getResizeArrowDirection,cM as getResizeOffsetXY,cn as getResizedElementAbsoluteCoords,fw as getRootElements,r7 as getSceneVersion,Ot as getSelectedElements,tr as getSelectedElementsByGroup,Cs as getSelectedGroupForElement,vm as getSelectedGroupIdForElement,Im as getSelectedGroupIds,qy as getSelectionStateForElements,w1 as getSnapOutlineMidPoint,Zy as getTargetElements,Om as getTargetFrame,Xx as getTextElementAngle,Qx as getTextFromElements,v1 as getTextHeight,Tl as getTextWidth,Wg as getToolbarTools,TM as getTransformHandleTypeFromCoords,Lu as getTransformHandles,xa as getTransformHandlesFromCoords,dl as getUncroppedImageElement,jr as getUncroppedWidthAndHeight,Xy as getVisibleAndNonSelectedElements,s7 as getVisibleElements,Tb as getVisibleSceneBounds,R1 as getWrappedTextLines,mw as groupByFrameLikes,pw as groupsAreAtLeastIntersectingTheFrame,hw as groupsAreCompletelyOutOfFrame,Wn as handleBindTextResize,bu as handleFocusPointDrag,D5 as handleFocusPointHover,C5 as handleFocusPointPointerDown,B5 as handleFocusPointPointerUp,Uw as hasBackground,kt as hasBoundTextElement,wM as hasBoundingBox,Yw as hasStrokeColor,$w as hasStrokeStyle,Xw as hasStrokeWidth,Mc as hashElementsVersion,Pc as hashString,$e as headingForPoint,Fo as headingForPointFromElement,wt as headingForPointIsHorizontal,qe as headingIsHorizontal,I3 as headingIsVertical,dh as hitElementBoundText,lh as hitElementBoundingBox,x3 as hitElementBoundingBoxOnly,Tt as hitElementItself,gn as intersectElementWithLineSegment,sx as isArrowBoundToElement,V as isArrowElement,fe as isBindableElement,ls as isBindableElementInsideOtherBindable,Be as isBindingElement,d1 as isBindingElementType,Dt as isBindingEnabled,ge as isBoundToContainer,uw as isCursorInFrame,a1 as isCurvedArrow,Y as isElbowArrow,Fb as isElementCompletelyInViewport,Os as isElementContainingFrame,Yd as isElementInFrame,Sm as isElementInGroup,Wd as isElementInViewport,io as isElementIntersectingFrame,P4 as isElementLink,ul as isEmbeddableElement,rx as isExcalidrawElement,Kh as isFixedPoint,Vr as isFlowchartNodeElement,wr as isFocusPointVisible,Si as isFrameElement,te as isFrameLikeElement,Ce as isFreeDrawElement,r1 as isFreeDrawElementType,ag as isHTMLSVGElement,Pi as isIframeElement,Ii as isIframeLikeElement,ve as isImageElement,Hd as isInGroup,Nn as isInitializedImageElement,hc as isInvisiblySmallElement,Wt as isLineElement,ne as isLinearElement,l1 as isLinearElementType,pl as isMagicFrameElement,kx as isMeasureTextSupported,l5 as isNodeInFlowchart,l7 as isNonDeletedElement,zn as isPathALoop,Ut as isPointInElement,To as isRectangularElement,hl as isRectanguloidElement,Pm as isSelectedViaGroup,s1 as isSharpArrow,ix as isSimpleArrow,$y as isSomeElementSelected,c1 as isTextBindableContainer,ee as isTextElement,ml as isUsingAdaptiveRadius,fl as isUsingProportionalRadius,cx as isValidPolygon,Kx as isValidTextContainer,sg as loadHTMLImageElement,Ls as makeNextSelectedElementIds,xt as maxBindingDistance_simple,Kv as maybeHandleArrowPointlikeDrag,Y4 as maybeParseEmbedSrc,ma as measureFontSizeFromWidth,ot as measureText,w5 as moveAllLeft,b5 as moveAllRight,fu as moveArrowAboveBindable,x5 as moveOneLeft,y5 as moveOneRight,ke as mutateElement,Er as newArrowElement,Xn as newElement,Ne as newElementWith,G4 as newEmbeddableElement,$c as newFrameElement,F4 as newFreeDrawElement,O4 as newIframeElement,Qc as newImageElement,Kc as newLinearElement,Zc as newMagicFrameElement,$n as newTextElement,U5 as normaliseElements,tE as normalizeArrowhead,fc as normalizeElementOrder,hn as normalizeFixedPoint,z5 as normalizeSVG,Bo as normalizeText,nr as omitGroupsContainingFrameLikes,Bm as omitPartialGroups,Lc as orderByFractionalIndex,Co as originalContainerCache,I4 as parseElementLinkFromURL,G1 as parseTokens,En as pointInsideBounds,q5 as positionElementsOnGrid,qr as projectFixedPointOntoDiagonal,Di as redrawTextBoundingBox,R4 as refreshTextDimensions,Gm as removeAllElementsFromFrame,Ud as removeElementsFromFrame,Fy as removeFromSelectedGroups,_w as renderElement,zw as renderSelectionElement,yw as replaceAllElementsInFrame,Su as rescalePointsInElement,Sl as resetOriginalContainerCache,yg as resizeMultipleElements,gg as resizeSingleElement,hg as resizeSingleTextElement,Mg as resizeTest,Mm as selectGroup,Od as selectGroupsForSelectedElements,Rd as selectGroupsFromGivenElements,Lx as setCustomTextMetricsProvider,Zx as shouldAllowVerticalAlign,bw as shouldApplyFrameClip,Oi as shouldTestInside,Bv as showSelectedShapeActions,vs as snapToMid,qx as suppportsHorizontalAlign,ea as syncInvalidIndices,bc as syncInvalidIndicesImmutable,ei as syncMovedIndices,Id as toggleLinePolygonState,Zw as toolIsArrow,dM as transformElements,Oe as unbindBindingElement,oy as updateBindings,Re as updateBoundElements,bt as updateBoundPoint,to as updateElbowArrowPoints,ww as updateFrameMembershipOfSelectedElements,N5 as updateImageCache,Il as updateOriginalContainerCache,td as validateElbowPoints,j0 as validateFractionalIndices,qt as vectorToHeading,Xt as wrapText};
29
+ /*! Bundled license information:
30
+
31
+ react/cjs/react.production.js:
32
+ (**
33
+ * @license React
34
+ * react.production.js
35
+ *
36
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
37
+ *
38
+ * This source code is licensed under the MIT license found in the
39
+ * LICENSE file in the root directory of this source tree.
40
+ *)
41
+
42
+ react/cjs/react-jsx-runtime.production.js:
43
+ (**
44
+ * @license React
45
+ * react-jsx-runtime.production.js
46
+ *
47
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
48
+ *
49
+ * This source code is licensed under the MIT license found in the
50
+ * LICENSE file in the root directory of this source tree.
51
+ *)
52
+ */