@excalidraw/excalidraw 0.17.1-f597bd3 → 0.17.1-f59b4f6
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.
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-R7HUEHN5.js → chunk-O74FSJNG.js} +77 -49
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-R7HUEHN5.js.map → chunk-O74FSJNG.js.map} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-CAYW6EUH.js → image-F7EVY5ZQ.js} +2 -2
- package/dist/browser/dev/index.js +4 -3
- package/dist/browser/dev/index.js.map +2 -2
- package/dist/browser/prod/excalidraw-assets/chunk-UVJNWDMS.js +55 -0
- package/dist/browser/prod/excalidraw-assets/image-BSC5ABC2.js +1 -0
- package/dist/browser/prod/index.js +4 -4
- package/dist/dev/index.js +78 -47
- package/dist/dev/index.js.map +2 -2
- package/dist/excalidraw/components/App.js +2 -2
- package/dist/excalidraw/data/url.d.ts +1 -0
- package/dist/excalidraw/data/url.js +4 -1
- package/dist/excalidraw/element/embeddable.js +27 -45
- package/dist/excalidraw/element/types.d.ts +3 -0
- package/dist/excalidraw/renderer/staticScene.js +14 -3
- package/dist/excalidraw/renderer/staticSvgScene.js +10 -0
- package/dist/prod/index.js +26 -26
- package/dist/utils/geometry/shape.d.ts +2 -2
- package/dist/utils/geometry/shape.js +8 -2
- package/package.json +1 -1
- package/dist/browser/prod/excalidraw-assets/chunk-6VLWGOPS.js +0 -55
- package/dist/browser/prod/excalidraw-assets/image-2PF7RELG.js +0 -1
- /package/dist/browser/dev/excalidraw-assets-dev/{image-CAYW6EUH.js.map → image-F7EVY5ZQ.js.map} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import{a as g,b as A}from"./chunk-M2JW2GFW.js";import{d as re,f as xr}from"./chunk-SXMPUQ6M.js";var Ki=re(Zi=>{g();var bl;(function(e){typeof DO_NOT_EXPORT_CRC>"u"?typeof Zi=="object"?e(Zi):typeof define=="function"&&define.amd?define(function(){var t={};return e(t),t}):e(bl={}):e(bl={})})(function(e){e.version="0.3.0";function t(){for(var l=0,c=new Array(256),d=0;d!=256;++d)l=d,l=l&1?-306674912^l>>>1:l>>>1,l=l&1?-306674912^l>>>1:l>>>1,l=l&1?-306674912^l>>>1:l>>>1,l=l&1?-306674912^l>>>1:l>>>1,l=l&1?-306674912^l>>>1:l>>>1,l=l&1?-306674912^l>>>1:l>>>1,l=l&1?-306674912^l>>>1:l>>>1,l=l&1?-306674912^l>>>1:l>>>1,c[d]=l;return typeof Int32Array<"u"?new Int32Array(c):c}var n=t(),r=typeof Buffer<"u";function o(l){if(l.length>32768&&r)return a(new Buffer(l));for(var c=-1,d=l.length-1,u=0;u<d;)c=n[(c^l.charCodeAt(u++))&255]^c>>>8,c=n[(c^l.charCodeAt(u++))&255]^c>>>8;return u===d&&(c=c>>>8^n[(c^l.charCodeAt(u))&255]),c^-1}function i(l){if(l.length>1e4)return a(l);for(var c=-1,d=0,u=l.length-3;d<u;)c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255];for(;d<u+3;)c=c>>>8^n[(c^l[d++])&255];return c^-1}function a(l){for(var c=-1,d=0,u=l.length-7;d<u;)c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255],c=c>>>8^n[(c^l[d++])&255];for(;d<u+7;)c=c>>>8^n[(c^l[d++])&255];return c^-1}function s(l){for(var c=-1,d=0,u=l.length,f,m;d<u;)f=l.charCodeAt(d++),f<128?c=c>>>8^n[(c^f)&255]:f<2048?(c=c>>>8^n[(c^(192|f>>6&31))&255],c=c>>>8^n[(c^(128|f&63))&255]):f>=55296&&f<57344?(f=(f&1023)+64,m=l.charCodeAt(d++)&1023,c=c>>>8^n[(c^(240|f>>8&7))&255],c=c>>>8^n[(c^(128|f>>2&63))&255],c=c>>>8^n[(c^(128|m>>6&15|f&3))&255],c=c>>>8^n[(c^(128|m&63))&255]):(c=c>>>8^n[(c^(224|f>>12&15))&255],c=c>>>8^n[(c^(128|f>>6&63))&255],c=c>>>8^n[(c^(128|f&63))&255]);return c^-1}e.table=n,e.bstr=o,e.buf=i,e.str=s})});var Tl=re((Aw,vl)=>{g();var xp=Ki();vl.exports=bp;var dt=new Uint8Array(4),wp=new Int32Array(dt.buffer),yp=new Uint32Array(dt.buffer);function bp(e){if(e[0]!==137)throw new Error("Invalid .png file header");if(e[1]!==80)throw new Error("Invalid .png file header");if(e[2]!==78)throw new Error("Invalid .png file header");if(e[3]!==71)throw new Error("Invalid .png file header");if(e[4]!==13)throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");if(e[5]!==10)throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");if(e[6]!==26)throw new Error("Invalid .png file header");if(e[7]!==10)throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");for(var t=!1,n=[],r=8;r<e.length;){dt[3]=e[r++],dt[2]=e[r++],dt[1]=e[r++],dt[0]=e[r++];var o=yp[0]+4,i=new Uint8Array(o);i[0]=e[r++],i[1]=e[r++],i[2]=e[r++],i[3]=e[r++];var a=String.fromCharCode(i[0])+String.fromCharCode(i[1])+String.fromCharCode(i[2])+String.fromCharCode(i[3]);if(!n.length&&a!=="IHDR")throw new Error("IHDR header missing");if(a==="IEND"){t=!0,n.push({name:a,data:new Uint8Array(0)});break}for(var s=4;s<o;s++)i[s]=e[r++];dt[3]=e[r++],dt[2]=e[r++],dt[1]=e[r++],dt[0]=e[r++];var l=wp[0],c=xp.buf(i);if(c!==l)throw new Error("CRC values for "+a+" header do not match, PNG file is likely corrupted");var d=new Uint8Array(i.buffer.slice(4));n.push({name:a,data:d})}if(!t)throw new Error(".png file ended prematurely: no IEND header was found");return n}});var _l=re((Sw,Al)=>{g();Al.exports=vp;function vp(e,t){if(e=String(e),t=String(t),!/^[\x00-\xFF]+$/.test(e)||!/^[\x00-\xFF]+$/.test(t))throw new Error("Only Latin-1 characters are permitted in PNG tEXt chunks. You might want to consider base64 encoding and/or zEXt compression");if(e.length>=80)throw new Error('Keyword "'+e+'" is longer than the 79-character limit imposed by the PNG specification');for(var n=e.length+t.length+1,r=new Uint8Array(n),o=0,i,a=0;a<e.length;a++){if(!(i=e.charCodeAt(a)))throw new Error("0x00 character is not permitted in tEXt keywords");r[o++]=i}r[o++]=0;for(var s=0;s<t.length;s++){if(!(i=t.charCodeAt(s)))throw new Error("0x00 character is not permitted in tEXt content");r[o++]=i}return{name:"tEXt",data:r}}});var Il=re((Pw,Sl)=>{g();Sl.exports=Tp;function Tp(e){e.data&&e.name&&(e=e.data);for(var t=!0,n="",r="",o=0;o<e.length;o++){var i=e[o];if(t)i?r+=String.fromCharCode(i):t=!1;else if(i)n+=String.fromCharCode(i);else throw new Error("Invalid NULL character found. 0x00 character is not permitted in tEXt content")}return{keyword:r,text:n}}});var Pl=re(ji=>{g();ji.encode=_l();ji.decode=Il()});var Ll=re((Cw,Ml)=>{g();Ml.exports=function(e,t,n){var r=[],o=e.length;if(o===0)return r;var i=t<0?Math.max(0,t+o):t||0;for(n!==void 0&&(o=n<0?n+o:n);o-- >i;)r[o-i]=e[o];return r}});var Cl=re((Rw,Dl)=>{g();var Ap=Ll(),_p=Ki();Dl.exports=Pp;var ut=new Uint8Array(4),Sp=new Int32Array(ut.buffer),Ip=new Uint32Array(ut.buffer);function Pp(e){var t=8,n=t,r;for(r=0;r<e.length;r++)t+=e[r].data.length,t+=12;var o=new Uint8Array(t);for(o[0]=137,o[1]=80,o[2]=78,o[3]=71,o[4]=13,o[5]=10,o[6]=26,o[7]=10,r=0;r<e.length;r++){var i=e[r],a=i.name,s=i.data,l=s.length,c=[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3)];Ip[0]=l,o[n++]=ut[3],o[n++]=ut[2],o[n++]=ut[1],o[n++]=ut[0],o[n++]=c[0],o[n++]=c[1],o[n++]=c[2],o[n++]=c[3];for(var d=0;d<l;)o[n++]=s[d++];var u=c.concat(Ap(s)),f=_p.buf(u);Sp[0]=f,o[n++]=ut[3],o[n++]=ut[2],o[n++]=ut[1],o[n++]=ut[0]}return o}});var St=re(ve=>{"use strict";g();var Mp=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function Lp(e,t){return Object.prototype.hasOwnProperty.call(e,t)}ve.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(var r in n)Lp(n,r)&&(e[r]=n[r])}}return e};ve.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var Dp={arraySet:function(e,t,n,r,o){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),o);return}for(var i=0;i<r;i++)e[o+i]=t[n+i]},flattenChunks:function(e){var t,n,r,o,i,a;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(a=new Uint8Array(r),o=0,t=0,n=e.length;t<n;t++)i=e[t],a.set(i,o),o+=i.length;return a}},Cp={arraySet:function(e,t,n,r,o){for(var i=0;i<r;i++)e[o+i]=t[n+i]},flattenChunks:function(e){return[].concat.apply([],e)}};ve.setTyped=function(e){e?(ve.Buf8=Uint8Array,ve.Buf16=Uint16Array,ve.Buf32=Int32Array,ve.assign(ve,Dp)):(ve.Buf8=Array,ve.Buf16=Array,ve.Buf32=Array,ve.assign(ve,Cp))};ve.setTyped(Mp)});var tc=re(zn=>{"use strict";g();var kp=St(),Rp=4,kl=0,Rl=1,Fp=2;function Gn(e){for(var t=e.length;--t>=0;)e[t]=0}var Op=0,zl=1,Np=2,Bp=3,Gp=258,ra=29,Ar=256,yr=Ar+1+ra,Bn=30,oa=19,Hl=2*yr+1,fn=15,qi=16,zp=7,ia=256,Ul=16,$l=17,Yl=18,ta=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],go=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Hp=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Wl=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Up=512,It=new Array((yr+2)*2);Gn(It);var wr=new Array(Bn*2);Gn(wr);var br=new Array(Up);Gn(br);var vr=new Array(Gp-Bp+1);Gn(vr);var aa=new Array(ra);Gn(aa);var xo=new Array(Bn);Gn(xo);function Ji(e,t,n,r,o){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=o,this.has_stree=e&&e.length}var Vl,Xl,Zl;function Qi(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Kl(e){return e<256?br[e]:br[256+(e>>>7)]}function Tr(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Se(e,t,n){e.bi_valid>qi-n?(e.bi_buf|=t<<e.bi_valid&65535,Tr(e,e.bi_buf),e.bi_buf=t>>qi-e.bi_valid,e.bi_valid+=n-qi):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function ft(e,t,n){Se(e,n[t*2],n[t*2+1])}function jl(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function $p(e){e.bi_valid===16?(Tr(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function Yp(e,t){var n=t.dyn_tree,r=t.max_code,o=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,l=t.stat_desc.max_length,c,d,u,f,m,p,h=0;for(f=0;f<=fn;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<Hl;c++)d=e.heap[c],f=n[n[d*2+1]*2+1]+1,f>l&&(f=l,h++),n[d*2+1]=f,!(d>r)&&(e.bl_count[f]++,m=0,d>=s&&(m=a[d-s]),p=n[d*2],e.opt_len+=p*(f+m),i&&(e.static_len+=p*(o[d*2+1]+m)));if(h!==0){do{for(f=l-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[l]--,h-=2}while(h>0);for(f=l;f!==0;f--)for(d=e.bl_count[f];d!==0;)u=e.heap[--c],!(u>r)&&(n[u*2+1]!==f&&(e.opt_len+=(f-n[u*2+1])*n[u*2],n[u*2+1]=f),d--)}}function ql(e,t,n){var r=new Array(fn+1),o=0,i,a;for(i=1;i<=fn;i++)r[i]=o=o+n[i-1]<<1;for(a=0;a<=t;a++){var s=e[a*2+1];s!==0&&(e[a*2]=jl(r[s]++,s))}}function Wp(){var e,t,n,r,o,i=new Array(fn+1);for(n=0,r=0;r<ra-1;r++)for(aa[r]=n,e=0;e<1<<ta[r];e++)vr[n++]=r;for(vr[n-1]=r,o=0,r=0;r<16;r++)for(xo[r]=o,e=0;e<1<<go[r];e++)br[o++]=r;for(o>>=7;r<Bn;r++)for(xo[r]=o<<7,e=0;e<1<<go[r]-7;e++)br[256+o++]=r;for(t=0;t<=fn;t++)i[t]=0;for(e=0;e<=143;)It[e*2+1]=8,e++,i[8]++;for(;e<=255;)It[e*2+1]=9,e++,i[9]++;for(;e<=279;)It[e*2+1]=7,e++,i[7]++;for(;e<=287;)It[e*2+1]=8,e++,i[8]++;for(ql(It,yr+1,i),e=0;e<Bn;e++)wr[e*2+1]=5,wr[e*2]=jl(e,5);Vl=new Ji(It,ta,Ar+1,yr,fn),Xl=new Ji(wr,go,0,Bn,fn),Zl=new Ji(new Array(0),Hp,0,oa,zp)}function Jl(e){var t;for(t=0;t<yr;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Bn;t++)e.dyn_dtree[t*2]=0;for(t=0;t<oa;t++)e.bl_tree[t*2]=0;e.dyn_ltree[ia*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Ql(e){e.bi_valid>8?Tr(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Vp(e,t,n,r){Ql(e),r&&(Tr(e,n),Tr(e,~n)),kp.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function Fl(e,t,n,r){var o=t*2,i=n*2;return e[o]<e[i]||e[o]===e[i]&&r[t]<=r[n]}function ea(e,t,n){for(var r=e.heap[n],o=n<<1;o<=e.heap_len&&(o<e.heap_len&&Fl(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!Fl(t,r,e.heap[o],e.depth));)e.heap[n]=e.heap[o],n=o,o<<=1;e.heap[n]=r}function Ol(e,t,n){var r,o,i=0,a,s;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+i*2]<<8|e.pending_buf[e.d_buf+i*2+1],o=e.pending_buf[e.l_buf+i],i++,r===0?ft(e,o,t):(a=vr[o],ft(e,a+Ar+1,t),s=ta[a],s!==0&&(o-=aa[a],Se(e,o,s)),r--,a=Kl(r),ft(e,a,n),s=go[a],s!==0&&(r-=xo[a],Se(e,r,s)));while(i<e.last_lit);ft(e,ia,t)}function na(e,t){var n=t.dyn_tree,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,i=t.stat_desc.elems,a,s,l=-1,c;for(e.heap_len=0,e.heap_max=Hl,a=0;a<i;a++)n[a*2]!==0?(e.heap[++e.heap_len]=l=a,e.depth[a]=0):n[a*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,n[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=r[c*2+1]);for(t.max_code=l,a=e.heap_len>>1;a>=1;a--)ea(e,n,a);c=i;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ea(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=s,n[c*2]=n[a*2]+n[s*2],e.depth[c]=(e.depth[a]>=e.depth[s]?e.depth[a]:e.depth[s])+1,n[a*2+1]=n[s*2+1]=c,e.heap[1]=c++,ea(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Yp(e,t),ql(n,l,e.bl_count)}function Nl(e,t,n){var r,o=-1,i,a=t[0*2+1],s=0,l=7,c=4;for(a===0&&(l=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)i=a,a=t[(r+1)*2+1],!(++s<l&&i===a)&&(s<c?e.bl_tree[i*2]+=s:i!==0?(i!==o&&e.bl_tree[i*2]++,e.bl_tree[Ul*2]++):s<=10?e.bl_tree[$l*2]++:e.bl_tree[Yl*2]++,s=0,o=i,a===0?(l=138,c=3):i===a?(l=6,c=3):(l=7,c=4))}function Bl(e,t,n){var r,o=-1,i,a=t[0*2+1],s=0,l=7,c=4;for(a===0&&(l=138,c=3),r=0;r<=n;r++)if(i=a,a=t[(r+1)*2+1],!(++s<l&&i===a)){if(s<c)do ft(e,i,e.bl_tree);while(--s!==0);else i!==0?(i!==o&&(ft(e,i,e.bl_tree),s--),ft(e,Ul,e.bl_tree),Se(e,s-3,2)):s<=10?(ft(e,$l,e.bl_tree),Se(e,s-3,3)):(ft(e,Yl,e.bl_tree),Se(e,s-11,7));s=0,o=i,a===0?(l=138,c=3):i===a?(l=6,c=3):(l=7,c=4)}}function Xp(e){var t;for(Nl(e,e.dyn_ltree,e.l_desc.max_code),Nl(e,e.dyn_dtree,e.d_desc.max_code),na(e,e.bl_desc),t=oa-1;t>=3&&e.bl_tree[Wl[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Zp(e,t,n,r){var o;for(Se(e,t-257,5),Se(e,n-1,5),Se(e,r-4,4),o=0;o<r;o++)Se(e,e.bl_tree[Wl[o]*2+1],3);Bl(e,e.dyn_ltree,t-1),Bl(e,e.dyn_dtree,n-1)}function Kp(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return kl;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Rl;for(n=32;n<Ar;n++)if(e.dyn_ltree[n*2]!==0)return Rl;return kl}var Gl=!1;function jp(e){Gl||(Wp(),Gl=!0),e.l_desc=new Qi(e.dyn_ltree,Vl),e.d_desc=new Qi(e.dyn_dtree,Xl),e.bl_desc=new Qi(e.bl_tree,Zl),e.bi_buf=0,e.bi_valid=0,Jl(e)}function ec(e,t,n,r){Se(e,(Op<<1)+(r?1:0),3),Vp(e,t,n,!0)}function qp(e){Se(e,zl<<1,3),ft(e,ia,It),$p(e)}function Jp(e,t,n,r){var o,i,a=0;e.level>0?(e.strm.data_type===Fp&&(e.strm.data_type=Kp(e)),na(e,e.l_desc),na(e,e.d_desc),a=Xp(e),o=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=o&&(o=i)):o=i=n+5,n+4<=o&&t!==-1?ec(e,t,n,r):e.strategy===Rp||i===o?(Se(e,(zl<<1)+(r?1:0),3),Ol(e,It,wr)):(Se(e,(Np<<1)+(r?1:0),3),Zp(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),Ol(e,e.dyn_ltree,e.dyn_dtree)),Jl(e),r&&Ql(e)}function Qp(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(vr[n]+Ar+1)*2]++,e.dyn_dtree[Kl(t)*2]++),e.last_lit===e.lit_bufsize-1}zn._tr_init=jp;zn._tr_stored_block=ec;zn._tr_flush_block=Jp;zn._tr_tally=Qp;zn._tr_align=qp});var sa=re((zw,nc)=>{"use strict";g();function eh(e,t,n,r){for(var o=e&65535|0,i=e>>>16&65535|0,a=0;n!==0;){a=n>2e3?2e3:n,n-=a;do o=o+t[r++]|0,i=i+o|0;while(--a);o%=65521,i%=65521}return o|i<<16|0}nc.exports=eh});var la=re((Uw,rc)=>{"use strict";g();function th(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var nh=th();function rh(e,t,n,r){var o=nh,i=r+n;e^=-1;for(var a=r;a<i;a++)e=e>>>8^o[(e^t[a])&255];return e^-1}rc.exports=rh});var wo=re((Yw,oc)=>{"use strict";g();oc.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var mc=re(ht=>{"use strict";g();var Te=St(),ze=tc(),lc=sa(),Yt=la(),oh=wo(),En=0,ih=1,ah=3,Kt=4,ic=5,pt=0,ac=1,He=-2,sh=-3,ca=-5,lh=-1,ch=1,yo=2,dh=3,uh=4,fh=0,mh=2,Ao=8,ph=9,hh=15,Eh=8,gh=29,xh=256,ua=xh+1+gh,wh=30,yh=19,bh=2*ua+1,vh=15,$=3,Xt=258,Xe=Xt+$+1,Th=32,_o=42,fa=69,bo=73,vo=91,To=103,mn=113,Sr=666,le=1,Ir=2,pn=3,$n=4,Ah=3;function Zt(e,t){return e.msg=oh[t],t}function sc(e){return(e<<1)-(e>4?9:0)}function Vt(e){for(var t=e.length;--t>=0;)e[t]=0}function Wt(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(Te.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function Ee(e,t){ze._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Wt(e.strm)}function W(e,t){e.pending_buf[e.pending++]=t}function _r(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function _h(e,t,n,r){var o=e.avail_in;return o>r&&(o=r),o===0?0:(e.avail_in-=o,Te.arraySet(t,e.input,e.next_in,o,n),e.state.wrap===1?e.adler=lc(e.adler,t,o,n):e.state.wrap===2&&(e.adler=Yt(e.adler,t,o,n)),e.next_in+=o,e.total_in+=o,o)}function cc(e,t){var n=e.max_chain_length,r=e.strstart,o,i,a=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-Xe?e.strstart-(e.w_size-Xe):0,c=e.window,d=e.w_mask,u=e.prev,f=e.strstart+Xt,m=c[r+a-1],p=c[r+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(o=t,!(c[o+a]!==p||c[o+a-1]!==m||c[o]!==c[r]||c[++o]!==c[r+1])){r+=2,o++;do;while(c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&r<f);if(i=Xt-(f-r),r=f-Xt,i>a){if(e.match_start=t,a=i,i>=s)break;m=c[r+a-1],p=c[r+a]}}while((t=u[t&d])>l&&--n!==0);return a<=e.lookahead?a:e.lookahead}function hn(e){var t=e.w_size,n,r,o,i,a;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Xe)){Te.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do o=e.head[--n],e.head[n]=o>=t?o-t:0;while(--r);r=t,n=r;do o=e.prev[--n],e.prev[n]=o>=t?o-t:0;while(--r);i+=t}if(e.strm.avail_in===0)break;if(r=_h(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=$)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+$-1])&e.hash_mask,e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<$)););}while(e.lookahead<Xe&&e.strm.avail_in!==0)}function Sh(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(hn(e),e.lookahead===0&&t===En)return le;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,Ee(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-Xe&&(Ee(e,!1),e.strm.avail_out===0))return le}return e.insert=0,t===Kt?(Ee(e,!0),e.strm.avail_out===0?pn:$n):(e.strstart>e.block_start&&(Ee(e,!1),e.strm.avail_out===0),le)}function da(e,t){for(var n,r;;){if(e.lookahead<Xe){if(hn(e),e.lookahead<Xe&&t===En)return le;if(e.lookahead===0)break}if(n=0,e.lookahead>=$&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-Xe&&(e.match_length=cc(e,n)),e.match_length>=$)if(r=ze._tr_tally(e,e.strstart-e.match_start,e.match_length-$),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=$){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=ze._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Ee(e,!1),e.strm.avail_out===0))return le}return e.insert=e.strstart<$-1?e.strstart:$-1,t===Kt?(Ee(e,!0),e.strm.avail_out===0?pn:$n):e.last_lit&&(Ee(e,!1),e.strm.avail_out===0)?le:Ir}function Hn(e,t){for(var n,r,o;;){if(e.lookahead<Xe){if(hn(e),e.lookahead<Xe&&t===En)return le;if(e.lookahead===0)break}if(n=0,e.lookahead>=$&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=$-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-Xe&&(e.match_length=cc(e,n),e.match_length<=5&&(e.strategy===ch||e.match_length===$&&e.strstart-e.match_start>4096)&&(e.match_length=$-1)),e.prev_length>=$&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-$,r=ze._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-$),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=$-1,e.strstart++,r&&(Ee(e,!1),e.strm.avail_out===0))return le}else if(e.match_available){if(r=ze._tr_tally(e,0,e.window[e.strstart-1]),r&&Ee(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return le}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=ze._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<$-1?e.strstart:$-1,t===Kt?(Ee(e,!0),e.strm.avail_out===0?pn:$n):e.last_lit&&(Ee(e,!1),e.strm.avail_out===0)?le:Ir}function Ih(e,t){for(var n,r,o,i,a=e.window;;){if(e.lookahead<=Xt){if(hn(e),e.lookahead<=Xt&&t===En)return le;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=$&&e.strstart>0&&(o=e.strstart-1,r=a[o],r===a[++o]&&r===a[++o]&&r===a[++o])){i=e.strstart+Xt;do;while(r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&r===a[++o]&&o<i);e.match_length=Xt-(i-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=$?(n=ze._tr_tally(e,1,e.match_length-$),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=ze._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Ee(e,!1),e.strm.avail_out===0))return le}return e.insert=0,t===Kt?(Ee(e,!0),e.strm.avail_out===0?pn:$n):e.last_lit&&(Ee(e,!1),e.strm.avail_out===0)?le:Ir}function Ph(e,t){for(var n;;){if(e.lookahead===0&&(hn(e),e.lookahead===0)){if(t===En)return le;break}if(e.match_length=0,n=ze._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Ee(e,!1),e.strm.avail_out===0))return le}return e.insert=0,t===Kt?(Ee(e,!0),e.strm.avail_out===0?pn:$n):e.last_lit&&(Ee(e,!1),e.strm.avail_out===0)?le:Ir}function mt(e,t,n,r,o){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=o}var Un;Un=[new mt(0,0,0,0,Sh),new mt(4,4,8,4,da),new mt(4,5,16,8,da),new mt(4,6,32,32,da),new mt(4,4,16,16,Hn),new mt(8,16,32,32,Hn),new mt(8,16,128,128,Hn),new mt(8,32,128,256,Hn),new mt(32,128,258,1024,Hn),new mt(32,258,258,4096,Hn)];function Mh(e){e.window_size=2*e.w_size,Vt(e.head),e.max_lazy_match=Un[e.level].max_lazy,e.good_match=Un[e.level].good_length,e.nice_match=Un[e.level].nice_length,e.max_chain_length=Un[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=$-1,e.match_available=0,e.ins_h=0}function Lh(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Ao,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Te.Buf16(bh*2),this.dyn_dtree=new Te.Buf16((2*wh+1)*2),this.bl_tree=new Te.Buf16((2*yh+1)*2),Vt(this.dyn_ltree),Vt(this.dyn_dtree),Vt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Te.Buf16(vh+1),this.heap=new Te.Buf16(2*ua+1),Vt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Te.Buf16(2*ua+1),Vt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function dc(e){var t;return!e||!e.state?Zt(e,He):(e.total_in=e.total_out=0,e.data_type=mh,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?_o:mn,e.adler=t.wrap===2?0:1,t.last_flush=En,ze._tr_init(t),pt)}function uc(e){var t=dc(e);return t===pt&&Mh(e.state),t}function Dh(e,t){return!e||!e.state||e.state.wrap!==2?He:(e.state.gzhead=t,pt)}function fc(e,t,n,r,o,i){if(!e)return He;var a=1;if(t===lh&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),o<1||o>ph||n!==Ao||r<8||r>15||t<0||t>9||i<0||i>uh)return Zt(e,He);r===8&&(r=9);var s=new Lh;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=o+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+$-1)/$),s.window=new Te.Buf8(s.w_size*2),s.head=new Te.Buf16(s.hash_size),s.prev=new Te.Buf16(s.w_size),s.lit_bufsize=1<<o+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Te.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=i,s.method=n,uc(e)}function Ch(e,t){return fc(e,t,Ao,hh,Eh,fh)}function kh(e,t){var n,r,o,i;if(!e||!e.state||t>ic||t<0)return e?Zt(e,He):He;if(r=e.state,!e.output||!e.input&&e.avail_in!==0||r.status===Sr&&t!==Kt)return Zt(e,e.avail_out===0?ca:He);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===_o)if(r.wrap===2)e.adler=0,W(r,31),W(r,139),W(r,8),r.gzhead?(W(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),W(r,r.gzhead.time&255),W(r,r.gzhead.time>>8&255),W(r,r.gzhead.time>>16&255),W(r,r.gzhead.time>>24&255),W(r,r.level===9?2:r.strategy>=yo||r.level<2?4:0),W(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(W(r,r.gzhead.extra.length&255),W(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Yt(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=fa):(W(r,0),W(r,0),W(r,0),W(r,0),W(r,0),W(r,r.level===9?2:r.strategy>=yo||r.level<2?4:0),W(r,Ah),r.status=mn);else{var a=Ao+(r.w_bits-8<<4)<<8,s=-1;r.strategy>=yo||r.level<2?s=0:r.level<6?s=1:r.level===6?s=2:s=3,a|=s<<6,r.strstart!==0&&(a|=Th),a+=31-a%31,r.status=mn,_r(r,a),r.strstart!==0&&(_r(r,e.adler>>>16),_r(r,e.adler&65535)),e.adler=1}if(r.status===fa)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=Yt(e.adler,r.pending_buf,r.pending-o,o)),Wt(e),o=r.pending,r.pending===r.pending_buf_size));)W(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=Yt(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=bo)}else r.status=bo;if(r.status===bo)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=Yt(e.adler,r.pending_buf,r.pending-o,o)),Wt(e),o=r.pending,r.pending===r.pending_buf_size)){i=1;break}r.gzindex<r.gzhead.name.length?i=r.gzhead.name.charCodeAt(r.gzindex++)&255:i=0,W(r,i)}while(i!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=Yt(e.adler,r.pending_buf,r.pending-o,o)),i===0&&(r.gzindex=0,r.status=vo)}else r.status=vo;if(r.status===vo)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=Yt(e.adler,r.pending_buf,r.pending-o,o)),Wt(e),o=r.pending,r.pending===r.pending_buf_size)){i=1;break}r.gzindex<r.gzhead.comment.length?i=r.gzhead.comment.charCodeAt(r.gzindex++)&255:i=0,W(r,i)}while(i!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=Yt(e.adler,r.pending_buf,r.pending-o,o)),i===0&&(r.status=To)}else r.status=To;if(r.status===To&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&Wt(e),r.pending+2<=r.pending_buf_size&&(W(r,e.adler&255),W(r,e.adler>>8&255),e.adler=0,r.status=mn)):r.status=mn),r.pending!==0){if(Wt(e),e.avail_out===0)return r.last_flush=-1,pt}else if(e.avail_in===0&&sc(t)<=sc(n)&&t!==Kt)return Zt(e,ca);if(r.status===Sr&&e.avail_in!==0)return Zt(e,ca);if(e.avail_in!==0||r.lookahead!==0||t!==En&&r.status!==Sr){var l=r.strategy===yo?Ph(r,t):r.strategy===dh?Ih(r,t):Un[r.level].func(r,t);if((l===pn||l===$n)&&(r.status=Sr),l===le||l===pn)return e.avail_out===0&&(r.last_flush=-1),pt;if(l===Ir&&(t===ih?ze._tr_align(r):t!==ic&&(ze._tr_stored_block(r,0,0,!1),t===ah&&(Vt(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),Wt(e),e.avail_out===0))return r.last_flush=-1,pt}return t!==Kt?pt:r.wrap<=0?ac:(r.wrap===2?(W(r,e.adler&255),W(r,e.adler>>8&255),W(r,e.adler>>16&255),W(r,e.adler>>24&255),W(r,e.total_in&255),W(r,e.total_in>>8&255),W(r,e.total_in>>16&255),W(r,e.total_in>>24&255)):(_r(r,e.adler>>>16),_r(r,e.adler&65535)),Wt(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?pt:ac)}function Rh(e){var t;return!e||!e.state?He:(t=e.state.status,t!==_o&&t!==fa&&t!==bo&&t!==vo&&t!==To&&t!==mn&&t!==Sr?Zt(e,He):(e.state=null,t===mn?Zt(e,sh):pt))}function Fh(e,t){var n=t.length,r,o,i,a,s,l,c,d;if(!e||!e.state||(r=e.state,a=r.wrap,a===2||a===1&&r.status!==_o||r.lookahead))return He;for(a===1&&(e.adler=lc(e.adler,t,n,0)),r.wrap=0,n>=r.w_size&&(a===0&&(Vt(r.head),r.strstart=0,r.block_start=0,r.insert=0),d=new Te.Buf8(r.w_size),Te.arraySet(d,t,n-r.w_size,r.w_size,0),t=d,n=r.w_size),s=e.avail_in,l=e.next_in,c=e.input,e.avail_in=n,e.next_in=0,e.input=t,hn(r);r.lookahead>=$;){o=r.strstart,i=r.lookahead-($-1);do r.ins_h=(r.ins_h<<r.hash_shift^r.window[o+$-1])&r.hash_mask,r.prev[o&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=o,o++;while(--i);r.strstart=o,r.lookahead=$-1,hn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=$-1,r.match_available=0,e.next_in=l,e.input=c,e.avail_in=s,r.wrap=a,pt}ht.deflateInit=Ch;ht.deflateInit2=fc;ht.deflateReset=uc;ht.deflateResetKeep=dc;ht.deflateSetHeader=Dh;ht.deflate=kh;ht.deflateEnd=Rh;ht.deflateSetDictionary=Fh;ht.deflateInfo="pako deflate (from Nodeca project)"});var ma=re(Yn=>{"use strict";g();var So=St(),pc=!0,hc=!0;try{String.fromCharCode.apply(null,[0])}catch{pc=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{hc=!1}var Pr=new So.Buf8(256);for(Pt=0;Pt<256;Pt++)Pr[Pt]=Pt>=252?6:Pt>=248?5:Pt>=240?4:Pt>=224?3:Pt>=192?2:1;var Pt;Pr[254]=Pr[254]=1;Yn.string2buf=function(e){var t,n,r,o,i,a=e.length,s=0;for(o=0;o<a;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<a&&(r=e.charCodeAt(o+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),o++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new So.Buf8(s),i=0,o=0;i<s;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<a&&(r=e.charCodeAt(o+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),o++)),n<128?t[i++]=n:n<2048?(t[i++]=192|n>>>6,t[i++]=128|n&63):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|n&63):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|n&63);return t};function Ec(e,t){if(t<65534&&(e.subarray&&hc||!e.subarray&&pc))return String.fromCharCode.apply(null,So.shrinkBuf(e,t));for(var n="",r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n}Yn.buf2binstring=function(e){return Ec(e,e.length)};Yn.binstring2buf=function(e){for(var t=new So.Buf8(e.length),n=0,r=t.length;n<r;n++)t[n]=e.charCodeAt(n);return t};Yn.buf2string=function(e,t){var n,r,o,i,a=t||e.length,s=new Array(a*2);for(r=0,n=0;n<a;){if(o=e[n++],o<128){s[r++]=o;continue}if(i=Pr[o],i>4){s[r++]=65533,n+=i-1;continue}for(o&=i===2?31:i===3?15:7;i>1&&n<a;)o=o<<6|e[n++]&63,i--;if(i>1){s[r++]=65533;continue}o<65536?s[r++]=o:(o-=65536,s[r++]=55296|o>>10&1023,s[r++]=56320|o&1023)}return Ec(s,r)};Yn.utf8border=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+Pr[e[n]]>t?n:t}});var pa=re((jw,gc)=>{"use strict";g();function Oh(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}gc.exports=Oh});var bc=re(Dr=>{"use strict";g();var Mr=mc(),Lr=St(),Ea=ma(),ga=wo(),Nh=pa(),yc=Object.prototype.toString,Bh=0,ha=4,Wn=0,xc=1,wc=2,Gh=-1,zh=0,Hh=8;function gn(e){if(!(this instanceof gn))return new gn(e);this.options=Lr.assign({level:Gh,method:Hh,chunkSize:16384,windowBits:15,memLevel:8,strategy:zh,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nh,this.strm.avail_out=0;var n=Mr.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Wn)throw new Error(ga[n]);if(t.header&&Mr.deflateSetHeader(this.strm,t.header),t.dictionary){var r;if(typeof t.dictionary=="string"?r=Ea.string2buf(t.dictionary):yc.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=Mr.deflateSetDictionary(this.strm,r),n!==Wn)throw new Error(ga[n]);this._dict_set=!0}}gn.prototype.push=function(e,t){var n=this.strm,r=this.options.chunkSize,o,i;if(this.ended)return!1;i=t===~~t?t:t===!0?ha:Bh,typeof e=="string"?n.input=Ea.string2buf(e):yc.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new Lr.Buf8(r),n.next_out=0,n.avail_out=r),o=Mr.deflate(n,i),o!==xc&&o!==Wn)return this.onEnd(o),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(i===ha||i===wc))&&(this.options.to==="string"?this.onData(Ea.buf2binstring(Lr.shrinkBuf(n.output,n.next_out))):this.onData(Lr.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&o!==xc);return i===ha?(o=Mr.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===Wn):(i===wc&&(this.onEnd(Wn),n.avail_out=0),!0)};gn.prototype.onData=function(e){this.chunks.push(e)};gn.prototype.onEnd=function(e){e===Wn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Lr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function xa(e,t){var n=new gn(t);if(n.push(e,!0),n.err)throw n.msg||ga[n.err];return n.result}function Uh(e,t){return t=t||{},t.raw=!0,xa(e,t)}function $h(e,t){return t=t||{},t.gzip=!0,xa(e,t)}Dr.Deflate=gn;Dr.deflate=xa;Dr.deflateRaw=Uh;Dr.gzip=$h});var Tc=re((ey,vc)=>{"use strict";g();var Io=30,Yh=12;vc.exports=function(t,n){var r,o,i,a,s,l,c,d,u,f,m,p,h,E,x,w,y,T,b,L,I,_,S,M,v;r=t.state,o=t.next_in,M=t.input,i=o+(t.avail_in-5),a=t.next_out,v=t.output,s=a-(n-t.avail_out),l=a+(t.avail_out-257),c=r.dmax,d=r.wsize,u=r.whave,f=r.wnext,m=r.window,p=r.hold,h=r.bits,E=r.lencode,x=r.distcode,w=(1<<r.lenbits)-1,y=(1<<r.distbits)-1;e:do{h<15&&(p+=M[o++]<<h,h+=8,p+=M[o++]<<h,h+=8),T=E[p&w];t:for(;;){if(b=T>>>24,p>>>=b,h-=b,b=T>>>16&255,b===0)v[a++]=T&65535;else if(b&16){L=T&65535,b&=15,b&&(h<b&&(p+=M[o++]<<h,h+=8),L+=p&(1<<b)-1,p>>>=b,h-=b),h<15&&(p+=M[o++]<<h,h+=8,p+=M[o++]<<h,h+=8),T=x[p&y];n:for(;;){if(b=T>>>24,p>>>=b,h-=b,b=T>>>16&255,b&16){if(I=T&65535,b&=15,h<b&&(p+=M[o++]<<h,h+=8,h<b&&(p+=M[o++]<<h,h+=8)),I+=p&(1<<b)-1,I>c){t.msg="invalid distance too far back",r.mode=Io;break e}if(p>>>=b,h-=b,b=a-s,I>b){if(b=I-b,b>u&&r.sane){t.msg="invalid distance too far back",r.mode=Io;break e}if(_=0,S=m,f===0){if(_+=d-b,b<L){L-=b;do v[a++]=m[_++];while(--b);_=a-I,S=v}}else if(f<b){if(_+=d+f-b,b-=f,b<L){L-=b;do v[a++]=m[_++];while(--b);if(_=0,f<L){b=f,L-=b;do v[a++]=m[_++];while(--b);_=a-I,S=v}}}else if(_+=f-b,b<L){L-=b;do v[a++]=m[_++];while(--b);_=a-I,S=v}for(;L>2;)v[a++]=S[_++],v[a++]=S[_++],v[a++]=S[_++],L-=3;L&&(v[a++]=S[_++],L>1&&(v[a++]=S[_++]))}else{_=a-I;do v[a++]=v[_++],v[a++]=v[_++],v[a++]=v[_++],L-=3;while(L>2);L&&(v[a++]=v[_++],L>1&&(v[a++]=v[_++]))}}else if(b&64){t.msg="invalid distance code",r.mode=Io;break e}else{T=x[(T&65535)+(p&(1<<b)-1)];continue n}break}}else if(b&64)if(b&32){r.mode=Yh;break e}else{t.msg="invalid literal/length code",r.mode=Io;break e}else{T=E[(T&65535)+(p&(1<<b)-1)];continue t}break}}while(o<i&&a<l);L=h>>3,o-=L,h-=L<<3,p&=(1<<h)-1,t.next_in=o,t.next_out=a,t.avail_in=o<i?5+(i-o):5-(o-i),t.avail_out=a<l?257+(l-a):257-(a-l),r.hold=p,r.bits=h}});var Lc=re((ny,Mc)=>{"use strict";g();var Ac=St(),Vn=15,_c=852,Sc=592,Ic=0,wa=1,Pc=2,Wh=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Vh=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Xh=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Zh=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];Mc.exports=function(t,n,r,o,i,a,s,l){var c=l.bits,d=0,u=0,f=0,m=0,p=0,h=0,E=0,x=0,w=0,y=0,T,b,L,I,_,S=null,M=0,v,P=new Ac.Buf16(Vn+1),D=new Ac.Buf16(Vn+1),z=null,O=0,N,C,U;for(d=0;d<=Vn;d++)P[d]=0;for(u=0;u<o;u++)P[n[r+u]]++;for(p=c,m=Vn;m>=1&&P[m]===0;m--);if(p>m&&(p=m),m===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,l.bits=1,0;for(f=1;f<m&&P[f]===0;f++);for(p<f&&(p=f),x=1,d=1;d<=Vn;d++)if(x<<=1,x-=P[d],x<0)return-1;if(x>0&&(t===Ic||m!==1))return-1;for(D[1]=0,d=1;d<Vn;d++)D[d+1]=D[d]+P[d];for(u=0;u<o;u++)n[r+u]!==0&&(s[D[n[r+u]]++]=u);if(t===Ic?(S=z=s,v=19):t===wa?(S=Wh,M-=257,z=Vh,O-=257,v=256):(S=Xh,z=Zh,v=-1),y=0,u=0,d=f,_=a,h=p,E=0,L=-1,w=1<<p,I=w-1,t===wa&&w>_c||t===Pc&&w>Sc)return 1;for(;;){N=d-E,s[u]<v?(C=0,U=s[u]):s[u]>v?(C=z[O+s[u]],U=S[M+s[u]]):(C=96,U=0),T=1<<d-E,b=1<<h,f=b;do b-=T,i[_+(y>>E)+b]=N<<24|C<<16|U|0;while(b!==0);for(T=1<<d-1;y&T;)T>>=1;if(T!==0?(y&=T-1,y+=T):y=0,u++,--P[d]===0){if(d===m)break;d=n[r+s[u]]}if(d>p&&(y&I)!==L){for(E===0&&(E=p),_+=f,h=d-E,x=1<<h;h+E<m&&(x-=P[h+E],!(x<=0));)h++,x<<=1;if(w+=1<<h,t===wa&&w>_c||t===Pc&&w>Sc)return 1;L=y&I,i[L]=p<<24|h<<16|_-a|0}}return y!==0&&(i[_+y]=d-E<<24|64<<16|0),l.bits=p,0}});var ud=re(Ze=>{"use strict";g();var De=St(),_a=sa(),Et=la(),Kh=Tc(),Cr=Lc(),jh=0,nd=1,rd=2,Dc=4,qh=5,Po=6,xn=0,Jh=1,Qh=2,Ue=-2,od=-3,Sa=-4,eE=-5,Cc=8,id=1,kc=2,Rc=3,Fc=4,Oc=5,Nc=6,Bc=7,Gc=8,zc=9,Hc=10,Do=11,Mt=12,ya=13,Uc=14,ba=15,$c=16,Yc=17,Wc=18,Vc=19,Mo=20,Lo=21,Xc=22,Zc=23,Kc=24,jc=25,qc=26,va=27,Jc=28,Qc=29,oe=30,Ia=31,tE=32,nE=852,rE=592,oE=15,iE=oE;function ed(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function aE(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new De.Buf16(320),this.work=new De.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function ad(e){var t;return!e||!e.state?Ue:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=id,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new De.Buf32(nE),t.distcode=t.distdyn=new De.Buf32(rE),t.sane=1,t.back=-1,xn)}function sd(e){var t;return!e||!e.state?Ue:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,ad(e))}function ld(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Ue:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,sd(e))}function cd(e,t){var n,r;return e?(r=new aE,e.state=r,r.window=null,n=ld(e,t),n!==xn&&(e.state=null),n):Ue}function sE(e){return cd(e,iE)}var td=!0,Ta,Aa;function lE(e){if(td){var t;for(Ta=new De.Buf32(512),Aa=new De.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Cr(nd,e.lens,0,288,Ta,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Cr(rd,e.lens,0,32,Aa,0,e.work,{bits:5}),td=!1}e.lencode=Ta,e.lenbits=9,e.distcode=Aa,e.distbits=5}function dd(e,t,n,r){var o,i=e.state;return i.window===null&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new De.Buf8(i.wsize)),r>=i.wsize?(De.arraySet(i.window,t,n-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):(o=i.wsize-i.wnext,o>r&&(o=r),De.arraySet(i.window,t,n-r,o,i.wnext),r-=o,r?(De.arraySet(i.window,t,n-r,r,0),i.wnext=r,i.whave=i.wsize):(i.wnext+=o,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=o))),0}function cE(e,t){var n,r,o,i,a,s,l,c,d,u,f,m,p,h,E=0,x,w,y,T,b,L,I,_,S=new De.Buf8(4),M,v,P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return Ue;n=e.state,n.mode===Mt&&(n.mode=ya),a=e.next_out,o=e.output,l=e.avail_out,i=e.next_in,r=e.input,s=e.avail_in,c=n.hold,d=n.bits,u=s,f=l,_=xn;e:for(;;)switch(n.mode){case id:if(n.wrap===0){n.mode=ya;break}for(;d<16;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if(n.wrap&2&&c===35615){n.check=0,S[0]=c&255,S[1]=c>>>8&255,n.check=Et(n.check,S,2,0),c=0,d=0,n.mode=kc;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=oe;break}if((c&15)!==Cc){e.msg="unknown compression method",n.mode=oe;break}if(c>>>=4,d-=4,I=(c&15)+8,n.wbits===0)n.wbits=I;else if(I>n.wbits){e.msg="invalid window size",n.mode=oe;break}n.dmax=1<<I,e.adler=n.check=1,n.mode=c&512?Hc:Mt,c=0,d=0;break;case kc:for(;d<16;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if(n.flags=c,(n.flags&255)!==Cc){e.msg="unknown compression method",n.mode=oe;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=oe;break}n.head&&(n.head.text=c>>8&1),n.flags&512&&(S[0]=c&255,S[1]=c>>>8&255,n.check=Et(n.check,S,2,0)),c=0,d=0,n.mode=Rc;case Rc:for(;d<32;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}n.head&&(n.head.time=c),n.flags&512&&(S[0]=c&255,S[1]=c>>>8&255,S[2]=c>>>16&255,S[3]=c>>>24&255,n.check=Et(n.check,S,4,0)),c=0,d=0,n.mode=Fc;case Fc:for(;d<16;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}n.head&&(n.head.xflags=c&255,n.head.os=c>>8),n.flags&512&&(S[0]=c&255,S[1]=c>>>8&255,n.check=Et(n.check,S,2,0)),c=0,d=0,n.mode=Oc;case Oc:if(n.flags&1024){for(;d<16;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}n.length=c,n.head&&(n.head.extra_len=c),n.flags&512&&(S[0]=c&255,S[1]=c>>>8&255,n.check=Et(n.check,S,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=Nc;case Nc:if(n.flags&1024&&(m=n.length,m>s&&(m=s),m&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),De.arraySet(n.head.extra,r,i,m,I)),n.flags&512&&(n.check=Et(n.check,r,m,i)),s-=m,i+=m,n.length-=m),n.length))break e;n.length=0,n.mode=Bc;case Bc:if(n.flags&2048){if(s===0)break e;m=0;do I=r[i+m++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I));while(I&&m<s);if(n.flags&512&&(n.check=Et(n.check,r,m,i)),s-=m,i+=m,I)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=Gc;case Gc:if(n.flags&4096){if(s===0)break e;m=0;do I=r[i+m++],n.head&&I&&n.length<65536&&(n.head.comment+=String.fromCharCode(I));while(I&&m<s);if(n.flags&512&&(n.check=Et(n.check,r,m,i)),s-=m,i+=m,I)break e}else n.head&&(n.head.comment=null);n.mode=zc;case zc:if(n.flags&512){for(;d<16;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if(c!==(n.check&65535)){e.msg="header crc mismatch",n.mode=oe;break}c=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Mt;break;case Hc:for(;d<32;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}e.adler=n.check=ed(c),c=0,d=0,n.mode=Do;case Do:if(n.havedict===0)return e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=s,n.hold=c,n.bits=d,Qh;e.adler=n.check=1,n.mode=Mt;case Mt:if(t===qh||t===Po)break e;case ya:if(n.last){c>>>=d&7,d-=d&7,n.mode=va;break}for(;d<3;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}switch(n.last=c&1,c>>>=1,d-=1,c&3){case 0:n.mode=Uc;break;case 1:if(lE(n),n.mode=Mo,t===Po){c>>>=2,d-=2;break e}break;case 2:n.mode=Yc;break;case 3:e.msg="invalid block type",n.mode=oe}c>>>=2,d-=2;break;case Uc:for(c>>>=d&7,d-=d&7;d<32;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",n.mode=oe;break}if(n.length=c&65535,c=0,d=0,n.mode=ba,t===Po)break e;case ba:n.mode=$c;case $c:if(m=n.length,m){if(m>s&&(m=s),m>l&&(m=l),m===0)break e;De.arraySet(o,r,i,m,a),s-=m,i+=m,l-=m,a+=m,n.length-=m;break}n.mode=Mt;break;case Yc:for(;d<14;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if(n.nlen=(c&31)+257,c>>>=5,d-=5,n.ndist=(c&31)+1,c>>>=5,d-=5,n.ncode=(c&15)+4,c>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=oe;break}n.have=0,n.mode=Wc;case Wc:for(;n.have<n.ncode;){for(;d<3;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}n.lens[P[n.have++]]=c&7,c>>>=3,d-=3}for(;n.have<19;)n.lens[P[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,M={bits:n.lenbits},_=Cr(jh,n.lens,0,19,n.lencode,0,n.work,M),n.lenbits=M.bits,_){e.msg="invalid code lengths set",n.mode=oe;break}n.have=0,n.mode=Vc;case Vc:for(;n.have<n.nlen+n.ndist;){for(;E=n.lencode[c&(1<<n.lenbits)-1],x=E>>>24,w=E>>>16&255,y=E&65535,!(x<=d);){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if(y<16)c>>>=x,d-=x,n.lens[n.have++]=y;else{if(y===16){for(v=x+2;d<v;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if(c>>>=x,d-=x,n.have===0){e.msg="invalid bit length repeat",n.mode=oe;break}I=n.lens[n.have-1],m=3+(c&3),c>>>=2,d-=2}else if(y===17){for(v=x+3;d<v;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}c>>>=x,d-=x,I=0,m=3+(c&7),c>>>=3,d-=3}else{for(v=x+7;d<v;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}c>>>=x,d-=x,I=0,m=11+(c&127),c>>>=7,d-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=oe;break}for(;m--;)n.lens[n.have++]=I}}if(n.mode===oe)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=oe;break}if(n.lenbits=9,M={bits:n.lenbits},_=Cr(nd,n.lens,0,n.nlen,n.lencode,0,n.work,M),n.lenbits=M.bits,_){e.msg="invalid literal/lengths set",n.mode=oe;break}if(n.distbits=6,n.distcode=n.distdyn,M={bits:n.distbits},_=Cr(rd,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,M),n.distbits=M.bits,_){e.msg="invalid distances set",n.mode=oe;break}if(n.mode=Mo,t===Po)break e;case Mo:n.mode=Lo;case Lo:if(s>=6&&l>=258){e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=s,n.hold=c,n.bits=d,Kh(e,f),a=e.next_out,o=e.output,l=e.avail_out,i=e.next_in,r=e.input,s=e.avail_in,c=n.hold,d=n.bits,n.mode===Mt&&(n.back=-1);break}for(n.back=0;E=n.lencode[c&(1<<n.lenbits)-1],x=E>>>24,w=E>>>16&255,y=E&65535,!(x<=d);){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if(w&&!(w&240)){for(T=x,b=w,L=y;E=n.lencode[L+((c&(1<<T+b)-1)>>T)],x=E>>>24,w=E>>>16&255,y=E&65535,!(T+x<=d);){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}c>>>=T,d-=T,n.back+=T}if(c>>>=x,d-=x,n.back+=x,n.length=y,w===0){n.mode=qc;break}if(w&32){n.back=-1,n.mode=Mt;break}if(w&64){e.msg="invalid literal/length code",n.mode=oe;break}n.extra=w&15,n.mode=Xc;case Xc:if(n.extra){for(v=n.extra;d<v;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Zc;case Zc:for(;E=n.distcode[c&(1<<n.distbits)-1],x=E>>>24,w=E>>>16&255,y=E&65535,!(x<=d);){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if(!(w&240)){for(T=x,b=w,L=y;E=n.distcode[L+((c&(1<<T+b)-1)>>T)],x=E>>>24,w=E>>>16&255,y=E&65535,!(T+x<=d);){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}c>>>=T,d-=T,n.back+=T}if(c>>>=x,d-=x,n.back+=x,w&64){e.msg="invalid distance code",n.mode=oe;break}n.offset=y,n.extra=w&15,n.mode=Kc;case Kc:if(n.extra){for(v=n.extra;d<v;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=oe;break}n.mode=jc;case jc:if(l===0)break e;if(m=f-l,n.offset>m){if(m=n.offset-m,m>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=oe;break}m>n.wnext?(m-=n.wnext,p=n.wsize-m):p=n.wnext-m,m>n.length&&(m=n.length),h=n.window}else h=o,p=a-n.offset,m=n.length;m>l&&(m=l),l-=m,n.length-=m;do o[a++]=h[p++];while(--m);n.length===0&&(n.mode=Lo);break;case qc:if(l===0)break e;o[a++]=n.length,l--,n.mode=Lo;break;case va:if(n.wrap){for(;d<32;){if(s===0)break e;s--,c|=r[i++]<<d,d+=8}if(f-=l,e.total_out+=f,n.total+=f,f&&(e.adler=n.check=n.flags?Et(n.check,o,f,a-f):_a(n.check,o,f,a-f)),f=l,(n.flags?c:ed(c))!==n.check){e.msg="incorrect data check",n.mode=oe;break}c=0,d=0}n.mode=Jc;case Jc:if(n.wrap&&n.flags){for(;d<32;){if(s===0)break e;s--,c+=r[i++]<<d,d+=8}if(c!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=oe;break}c=0,d=0}n.mode=Qc;case Qc:_=Jh;break e;case oe:_=od;break e;case Ia:return Sa;case tE:default:return Ue}return e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=s,n.hold=c,n.bits=d,(n.wsize||f!==e.avail_out&&n.mode<oe&&(n.mode<va||t!==Dc))&&dd(e,e.output,e.next_out,f-e.avail_out)?(n.mode=Ia,Sa):(u-=e.avail_in,f-=e.avail_out,e.total_in+=u,e.total_out+=f,n.total+=f,n.wrap&&f&&(e.adler=n.check=n.flags?Et(n.check,o,f,e.next_out-f):_a(n.check,o,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Mt?128:0)+(n.mode===Mo||n.mode===ba?256:0),(u===0&&f===0||t===Dc)&&_===xn&&(_=eE),_)}function dE(e){if(!e||!e.state)return Ue;var t=e.state;return t.window&&(t.window=null),e.state=null,xn}function uE(e,t){var n;return!e||!e.state||(n=e.state,!(n.wrap&2))?Ue:(n.head=t,t.done=!1,xn)}function fE(e,t){var n=t.length,r,o,i;return!e||!e.state||(r=e.state,r.wrap!==0&&r.mode!==Do)?Ue:r.mode===Do&&(o=1,o=_a(o,t,n,0),o!==r.check)?od:(i=dd(e,t,n,n),i?(r.mode=Ia,Sa):(r.havedict=1,xn))}Ze.inflateReset=sd;Ze.inflateReset2=ld;Ze.inflateResetKeep=ad;Ze.inflateInit=sE;Ze.inflateInit2=cd;Ze.inflate=cE;Ze.inflateEnd=dE;Ze.inflateGetHeader=uE;Ze.inflateSetDictionary=fE;Ze.inflateInfo="pako inflate (from Nodeca project)"});var Pa=re((ay,fd)=>{"use strict";g();fd.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var pd=re((ly,md)=>{"use strict";g();function mE(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}md.exports=mE});var Ed=re(Rr=>{"use strict";g();var Xn=ud(),kr=St(),Co=ma(),se=Pa(),Ma=wo(),pE=pa(),hE=pd(),hd=Object.prototype.toString;function wn(e){if(!(this instanceof wn))return new wn(e);this.options=kr.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new pE,this.strm.avail_out=0;var n=Xn.inflateInit2(this.strm,t.windowBits);if(n!==se.Z_OK)throw new Error(Ma[n]);if(this.header=new hE,Xn.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Co.string2buf(t.dictionary):hd.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Xn.inflateSetDictionary(this.strm,t.dictionary),n!==se.Z_OK)))throw new Error(Ma[n])}wn.prototype.push=function(e,t){var n=this.strm,r=this.options.chunkSize,o=this.options.dictionary,i,a,s,l,c,d=!1;if(this.ended)return!1;a=t===~~t?t:t===!0?se.Z_FINISH:se.Z_NO_FLUSH,typeof e=="string"?n.input=Co.binstring2buf(e):hd.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new kr.Buf8(r),n.next_out=0,n.avail_out=r),i=Xn.inflate(n,se.Z_NO_FLUSH),i===se.Z_NEED_DICT&&o&&(i=Xn.inflateSetDictionary(this.strm,o)),i===se.Z_BUF_ERROR&&d===!0&&(i=se.Z_OK,d=!1),i!==se.Z_STREAM_END&&i!==se.Z_OK)return this.onEnd(i),this.ended=!0,!1;n.next_out&&(n.avail_out===0||i===se.Z_STREAM_END||n.avail_in===0&&(a===se.Z_FINISH||a===se.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=Co.utf8border(n.output,n.next_out),l=n.next_out-s,c=Co.buf2string(n.output,s),n.next_out=l,n.avail_out=r-l,l&&kr.arraySet(n.output,n.output,s,l,0),this.onData(c)):this.onData(kr.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(d=!0)}while((n.avail_in>0||n.avail_out===0)&&i!==se.Z_STREAM_END);return i===se.Z_STREAM_END&&(a=se.Z_FINISH),a===se.Z_FINISH?(i=Xn.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===se.Z_OK):(a===se.Z_SYNC_FLUSH&&(this.onEnd(se.Z_OK),n.avail_out=0),!0)};wn.prototype.onData=function(e){this.chunks.push(e)};wn.prototype.onEnd=function(e){e===se.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=kr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function La(e,t){var n=new wn(t);if(n.push(e,!0),n.err)throw n.msg||Ma[n.err];return n.result}function EE(e,t){return t=t||{},t.raw=!0,La(e,t)}Rr.Inflate=wn;Rr.inflate=La;Rr.inflateRaw=EE;Rr.ungzip=La});var wd=re((fy,xd)=>{"use strict";g();var gE=St().assign,xE=bc(),wE=Ed(),yE=Pa(),gd={};gE(gd,xE,wE,yE);xd.exports=gd});var kf=re(_i=>{"use strict";g();Object.defineProperty(_i,"__esModule",{value:!0});_i.sanitizeUrl=void 0;var _x=/^([^\w]*)(javascript|data|vbscript)/im,Sx=/&#(\w+)(^\w|;)?/g,Ix=/&(newline|tab);/gi,Px=/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim,Mx=/^.+(:|:)/gim,Lx=[".","/"];function Dx(e){return Lx.indexOf(e[0])>-1}function Cx(e){return e.replace(Sx,function(t,n){return String.fromCharCode(n)})}function kx(e){var t=Cx(e||"").replace(Ix,"").replace(Px,"").trim();if(!t)return"about:blank";if(Dx(t))return t;var n=t.match(Mx);if(!n)return t;var r=n[0];return _x.test(r)?"about:blank":t}_i.sanitizeUrl=kx});g();var gl=xr(Tl(),1),xl=xr(Pl(),1),hp=xr(Cl(),1);g();var Xi=xr(wd(),1);g();g();var Da={};g();var yn={white:"#ffffff",black:"#000000",gray:["#f8f9fa","#f1f3f5","#e9ecef","#dee2e6","#ced4da","#adb5bd","#868e96","#495057","#343a40","#212529"],red:["#fff5f5","#ffe3e3","#ffc9c9","#ffa8a8","#ff8787","#ff6b6b","#fa5252","#f03e3e","#e03131","#c92a2a"],pink:["#fff0f6","#ffdeeb","#fcc2d7","#faa2c1","#f783ac","#f06595","#e64980","#d6336c","#c2255c","#a61e4d"],grape:["#f8f0fc","#f3d9fa","#eebefa","#e599f7","#da77f2","#cc5de8","#be4bdb","#ae3ec9","#9c36b5","#862e9c"],violet:["#f3f0ff","#e5dbff","#d0bfff","#b197fc","#9775fa","#845ef7","#7950f2","#7048e8","#6741d9","#5f3dc4"],indigo:["#edf2ff","#dbe4ff","#bac8ff","#91a7ff","#748ffc","#5c7cfa","#4c6ef5","#4263eb","#3b5bdb","#364fc7"],blue:["#e7f5ff","#d0ebff","#a5d8ff","#74c0fc","#4dabf7","#339af0","#228be6","#1c7ed6","#1971c2","#1864ab"],cyan:["#e3fafc","#c5f6fa","#99e9f2","#66d9e8","#3bc9db","#22b8cf","#15aabf","#1098ad","#0c8599","#0b7285"],teal:["#e6fcf5","#c3fae8","#96f2d7","#63e6be","#38d9a9","#20c997","#12b886","#0ca678","#099268","#087f5b"],green:["#ebfbee","#d3f9d8","#b2f2bb","#8ce99a","#69db7c","#51cf66","#40c057","#37b24d","#2f9e44","#2b8a3e"],lime:["#f4fce3","#e9fac8","#d8f5a2","#c0eb75","#a9e34b","#94d82d","#82c91e","#74b816","#66a80f","#5c940d"],yellow:["#fff9db","#fff3bf","#ffec99","#ffe066","#ffd43b","#fcc419","#fab005","#f59f00","#f08c00","#e67700"],orange:["#fff4e6","#ffe8cc","#ffd8a8","#ffc078","#ffa94d","#ff922b","#fd7e14","#f76707","#e8590c","#d9480f"]};var TE=(e,t)=>t.reduce((n,r)=>(r in e&&(n[r]=e[r]),n),{}),gy=5,xy=5,yd=4,ko=4,Ro=1,Ke=[0,2,4,6,8];var je=(e,t)=>t.map(n=>yn[e][n]),G={transparent:"transparent",black:"#1e1e1e",white:"#ffffff",gray:je("gray",Ke),red:je("red",Ke),pink:je("pink",Ke),grape:je("grape",Ke),violet:je("violet",Ke),blue:je("blue",Ke),cyan:je("cyan",Ke),teal:je("teal",Ke),green:je("green",Ke),yellow:je("yellow",Ke),orange:je("orange",Ke),bronze:["#f8f1ee","#eaddd7","#d2bab0","#a18072","#846358"]},bd=TE(G,["cyan","blue","violet","grape","pink","green","teal","yellow","orange","red"]),wy=[G.black,G.red[ko],G.green[ko],G.blue[ko],G.yellow[ko]],yy=[G.transparent,G.red[Ro],G.green[Ro],G.blue[Ro],G.yellow[Ro]],by=[G.white,"#f8f9fa","#f5faff","#fffce8","#fdf8f6"],vy={transparent:G.transparent,white:G.white,gray:G.gray,black:G.black,bronze:G.bronze,...bd},Ty={transparent:G.transparent,white:G.white,gray:G.gray,black:G.black,bronze:G.bronze,...bd},vd=e=>[G.cyan[e],G.blue[e],G.violet[e],G.grape[e],G.pink[e],G.green[e],G.teal[e],G.yellow[e],G.orange[e],G.red[e]],Ay=(e,t,n)=>`#${((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)}`;var Fo=/Mac|iPod|iPhone|iPad/.test(navigator.platform),My=/^Win/.test(navigator.platform),Ly=/\b(android)\b/i.test(navigator.userAgent),Dy="netscape"in window&&navigator.userAgent.indexOf("rv:")>1&&navigator.userAgent.indexOf("Gecko")>1,AE=navigator.userAgent.indexOf("Chrome")!==-1,Cy=!AE&&navigator.userAgent.indexOf("Safari")!==-1,ky=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,Ry=()=>navigator.brave?.isBrave?.name==="isBrave",Fy=typeof window<"u"&&"ResizeObserver"in window,Oy="Excalidraw",Td=10,Ad=8,Ny=5,By=1,Gy=30,gt=Math.PI/12,zy="red",Oo={TEXT:"text",CROSSHAIR:"crosshair",GRABBING:"grabbing",GRAB:"grab",POINTER:"pointer",MOVE:"move",AUTO:""},Hy={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},Uy={enabled:"all",disabled:"none",inheritFromUI:"var(--ui-pointerEvents)"};var $y={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},_d={TEST:"test",DEVELOPMENT:"development"},Yy={SHAPE_ACTIONS_MENU:"App-menu__left"},ce={Virgil:1,Helvetica:2,Cascadia:3,Assistant:4},Ce={LIGHT:"light",DARK:"dark"},pe={strokeColor:"#bbb",strokeWidth:2,strokeStyle:"solid",fillStyle:"solid",roughness:0,roundness:null,backgroundColor:"transparent",radius:8,nameOffsetY:3,nameColorLightTheme:"#999999",nameColorDarkTheme:"#7a7a7a",nameFontSize:14,nameLineHeight:1.25},Ca="Segoe UI Emoji",No=1,xt=20,qe=ce.Virgil,Zn="left",Bo="top";var Go=2,Wy="#ffffff",Vy="#1e1e1e",Xy="#a2f1a6";var Zy=20,ka={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif"},Sd=["text/plain","text/html"],R={json:"application/json",excalidraw:"application/vnd.excalidraw+json",excalidrawlib:"application/vnd.excalidrawlib+json","excalidraw.svg":"image/svg+xml","excalidraw.png":"image/png",binary:"application/octet-stream",...ka},Ky={png:"png",svg:"svg",clipboard:"clipboard"},Ie={excalidraw:"excalidraw",excalidrawClipboard:"excalidraw/clipboard",excalidrawLibrary:"excalidrawlib",excalidrawClipboardWithAPI:"excalidraw-api/clipboard"},Ra=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,jy=500,qy=300,Jy=500;var Qy=100,eb=.1,Id=.1,tb=300;var zo=Da.themeFilter,nb={addLibrary:"addLibrary"},rb={addLibrary:"addLibrary"},ob={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},ib=730,ab=1e3,sb=500,lb=1229,cb=parseInt(Da.rightSidebarWidth),Kn=2,Pd=[1,2,3],Fa=10,db=1440,ub=2*1024*1024,j="http://www.w3.org/2000/svg";var Oa={excalidraw:2,excalidrawLibrary:2},de=5,Md=.7,Ld=11,Lt={TOP:"top",MIDDLE:"middle",BOTTOM:"bottom"},Na={LEFT:"left",CENTER:"center",RIGHT:"right"},Dd=20,Ho=.25,Cd=32,ke={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},Ba={architect:0,artist:1,cartoonist:2},fb={thin:1,bold:2,extraBold:4},ne={strokeColor:G.black,backgroundColor:G.transparent,fillStyle:"solid",strokeWidth:2,strokeStyle:"solid",roughness:Ba.artist,opacity:100,locked:!1},_E="library",kd={name:"default",defaultTab:_E},mb=new Set(["iframe","embeddable","image"]),pb={selection:"selection",rectangle:"rectangle",diamond:"diamond",ellipse:"ellipse",arrow:"arrow",line:"line",freedraw:"freedraw",text:"text",image:"image",eraser:"eraser",hand:"hand",frame:"frame",magicframe:"magicframe",embeddable:"embeddable",laser:"laser"},hb={OAI_API_KEY:"excalidraw-oai-api-key",MERMAID_TO_EXCALIDRAW:"mermaid-to-excalidraw",PUBLISH_LIBRARY:"publish-library-data"},Rd="Untitled";g();g();g();var Uo=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");g();var SE=Pd.includes(devicePixelRatio)?devicePixelRatio:1,Dt=()=>({showWelcomeScreen:!1,theme:Ce.LIGHT,collaborators:new Map,currentChartType:"bar",currentItemBackgroundColor:ne.backgroundColor,currentItemEndArrowhead:"arrow",currentItemFillStyle:ne.fillStyle,currentItemFontFamily:qe,currentItemFontSize:xt,currentItemOpacity:ne.opacity,currentItemRoughness:ne.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:ne.strokeColor,currentItemRoundness:"round",currentItemStrokeStyle:ne.strokeStyle,currentItemStrokeWidth:ne.strokeWidth,currentItemTextAlign:Zn,cursorButton:"up",activeEmbeddable:null,draggingElement:null,editingElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:"selection",customType:null,locked:ne.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:SE,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:null,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:"mouse",multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,showStats:!1,startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:G.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set}),IE=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},draggingElement:{browser:!1,export:!1,server:!1},editingElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},showStats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1}}),Fd=(e,t)=>{let n={};for(let r of Object.keys(e))if(IE[r]?.[t]){let i=e[r];n[r]=i}return n};var $o=e=>Fd(e,"export"),Od=e=>Fd(e,"server"),Nd=({activeTool:e})=>e.type==="eraser",Bd=({activeTool:e})=>e.type==="hand";g();g();g();g();g();g();var Gd=null;var Cb=()=>{if(Gd)return Gd;let e=new Date,t=e.getFullYear(),n=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0"),o=`${e.getHours()}`.padStart(2,"0"),i=`${e.getMinutes()}`.padStart(2,"0");return`${t}-${n}-${r}-${o}${i}`},kb=e=>e.charAt(0).toUpperCase()+e.slice(1),Rb=e=>e instanceof HTMLElement&&e.className.includes("ToolIcon"),PE=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,Fb=e=>PE(e)||e instanceof Element&&!!e.closest("label, button"),Ob=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type==="text"||e.type==="number"||e.type==="password"),Ga=({fontFamily:e})=>{for(let[t,n]of Object.entries(ce))if(n===e)return`${t}, ${Ca}`;return Ca},ue=({fontSize:e,fontFamily:t})=>`${e}px ${Ga({fontFamily:t})}`,Ud=(e,t)=>{let n=0,r=null,o=(...i)=>{r=i,clearTimeout(n),n=window.setTimeout(()=>{r=null,e(...i)},t)};return o.flush=()=>{if(clearTimeout(n),r){let i=r;r=null,e(...i)}},o.cancel=()=>{r=null,clearTimeout(n)},o},$d=(e,t)=>{let n=null,r=null,o=null,i=s=>{n=window.requestAnimationFrame(()=>{n=null,e(...s),r=null,o&&(r=o,o=null,i(r))})},a=(...s)=>{if(A.MODE==="test"){e(...s);return}r=s,n===null?i(r):t?.trailing&&(o=s)};return a.flush=()=>{n!==null&&(cancelAnimationFrame(n),n=null),r&&(e(...o||r),r=o=null)},a.cancel=()=>{r=o=null,n!==null&&(cancelAnimationFrame(n),n=null)},a},Yd=e=>1-Math.pow(1-e,4),zd=(e,t,n)=>(t-e)*Yd(n)+e,Nb=({fromValues:e,toValues:t,onStep:n,duration:r=250,interpolateValue:o,onStart:i,onEnd:a,onCancel:s})=>{let l=!1,c=0,d;function u(f){if(l)return;d===void 0&&(d=f,i?.());let m=Math.min(f-d,r),p=Yd(m/r),h={};if(Object.keys(e).forEach(E=>{let x=E,w=(t[x]-e[x])*p+e[x];h[x]=w}),n(h),m<r){let E=m/r,x={};Object.keys(e).forEach(w=>{let y=w,T=e[y],b=t[y],L;L=o?o(T,b,E,y):zd(T,b,E),L==null&&(L=zd(T,b,E)),x[y]=L}),n(x),c=window.requestAnimationFrame(u)}else n(t),a?.()}return c=window.requestAnimationFrame(u),()=>{s?.(),l=!0,window.cancelAnimationFrame(c)}},Bb=(e,t)=>{if(!e.length||t<1)return[];let n=0,r=0,o=Array(Math.ceil(e.length/t));for(;n<e.length;)o[r++]=e.slice(n,n+=t);return o};var $e=(e,t)=>Math.abs(e-t),Fr=(e,t)=>t.type==="custom"?{...e.activeTool,type:"custom",customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked};var Gb=e=>(e=e.replace(/\bAlt\b/i,"Alt").replace(/\bShift\b/i,"Shift").replace(/\b(Enter|Return)\b/i,"Enter"),Fo?e.replace(/\bCtrlOrCmd\b/gi,"Cmd").replace(/\bAlt\b/i,"Option"):e.replace(/\bCtrlOrCmd\b/gi,"Ctrl")),Or=({clientX:e,clientY:t},{zoom:n,offsetLeft:r,offsetTop:o,scrollX:i,scrollY:a})=>{let s=(e-r)/n.value-i,l=(t-o)/n.value-a;return{x:s,y:l}},za=({sceneX:e,sceneY:t},{zoom:n,offsetLeft:r,offsetTop:o,scrollX:i,scrollY:a})=>{let s=(e+i)*n.value+r,l=(t+a)*n.value+o;return{x:s,y:l}},zb=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),ME="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF",LE="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",DE=new RegExp(`^[^${ME}]*[${LE}]`),Wo=e=>DE.test(e),jn=e=>{let[t,n]=e;return{x:t,y:n}},Hb=e=>{if(e?.name==="AbortError"){console.warn(e);return}throw e},Ub=(e,t,n=0)=>{n<0&&(n=e.length+n),n=Math.min(e.length,Math.max(n,0));let r=n-1;for(;++r<e.length;)if(t(e[r],r,e))return r;return-1},$b=(e,t,n=e.length-1)=>{n<0&&(n=e.length+n),n=Math.min(e.length-1,Math.max(n,0));let r=n+1;for(;--r>-1;)if(t(e[r],r,e))return r;return-1},jt=e=>{let t=e.length===5&&e.substr(4,1)==="0",n=e.length===9&&e.substr(7,2)==="00";return t||n||e===G.transparent},Yb=()=>{let e,t,n=new Promise((r,o)=>{e=r,t=o});return n.resolve=e,n.reject=t,n};var Wb=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:n}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"||n==="overlay"))return t;t=t.parentElement}return document},Vb=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},Xb=e=>{e.preventDefault(),e.returnValue=""},Wd=e=>Array.from(e).map(t=>`0${t.toString(16)}`.slice(-2)).join(""),Ct=()=>kt()?1:Date.now(),X=e=>e instanceof Map?e:e.reduce((t,n)=>(t.set(typeof n=="string"?n:n.id,n),t),new Map),Zb=e=>e.reduce((t,n,r)=>(t.set(n.id,[n,r]),t),new Map),kt=()=>A.MODE==="test",Kb=()=>A.MODE==="development",jb=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),qb=(e,t)=>{let n=!1;for(let r in t){let o=t[r];if(typeof o<"u"){if(e[r]===o&&(typeof o!="object"||o===null))continue;n=!0}}return n?{...e,...t}:e};var Jb=()=>{try{return window.self===window.top?"top":"iframe"}catch{return"iframe"}};var Vo=e=>!!e&&typeof e=="object"&&"then"in e&&"catch"in e&&"finally"in e,Qb=e=>{let t=e?.querySelectorAll("button, a, input, select, textarea, div[tabindex], label[tabindex]");return t?Array.from(t).filter(n=>n.tabIndex>-1&&!n.disabled):[]},Hd=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,Ha=(e,t,n,r=!1)=>{let o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return r&&console.warn("%cisShallowEqual: objects don't have same properties ->","color: #8B4000",e,t),!1;if(n&&Array.isArray(n)){for(let a of n)if(!(e[a]===t[a]||Hd(e[a],t[a])))return r&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),!1;return!0}return o.every(a=>{let s=n?.[a],l=s?s(e[a],t[a]):e[a]===t[a]||Hd(e[a],t[a]);return!l&&r&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),l})},e1=(e,t,{checkForDefaultPrevented:n=!0}={})=>function(o){if(e?.(o),!n||!o?.defaultPrevented)return t?.(o)},Xo=(e,t,n)=>{if(!t)return e;if(n)return console.error(t),e;throw new Error(t)},t1=e=>{let t,n,r=function(o){let i=Object.entries(o);if(t){let s=!0;for(let[l,c]of i)if(t.get(l)!==c){s=!1;break}if(s)return n}let a=e(o);return t=new Map(i),n=a,a};return r.clear=()=>{t=void 0,n=void 0},r},Vd=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):"includes"in e?e.includes(t):e.hasOwnProperty(t),n1=e=>JSON.parse(JSON.stringify(e)),r1=e=>typeof e=="number"&&Number.isFinite(e),o1=(e,t)=>Ha(e,t)?e:t;function i1(e,t,n,r){return e?(e?.addEventListener?.(t,n,r),()=>{e?.removeEventListener?.(t,n,r)}):()=>{}}var Yo=(e,t)=>(e+t)/2;function a1(e,t=!0){let n=e.length;if(n<4)return"";let r=e[0],o=e[1],i=e[2],a=`M${r[0].toFixed(2)},${r[1].toFixed(2)} Q${o[0].toFixed(2)},${o[1].toFixed(2)} ${Yo(o[0],i[0]).toFixed(2)},${Yo(o[1],i[1]).toFixed(2)} T`;for(let s=2,l=n-1;s<l;s++)r=e[s],o=e[s+1],a+=`${Yo(r[0],o[0]).toFixed(2)},${Yo(r[1],o[1]).toFixed(2)} `;return t&&(a+="Z"),a}var Xd=e=>e.replace(/\r?\n|\r/g,`
|
|
2
|
+
`),bn=e=>e,s1=async(e,...t)=>new Promise(n=>{n(e(...t))});var wt=e=>!!e&&e.type==="image"&&!!e.fileId,Zo=e=>!!e&&e.type==="image",Ko=e=>!!e&&e.type==="embeddable",Nr=e=>!!e&&e.type==="iframe",Je=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),Y=e=>e!=null&&e.type==="text",Br=e=>e!=null&&e.type==="frame",Zd=e=>e!=null&&e.type==="magicframe",J=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),fe=e=>e!=null&&CE(e.type),CE=e=>e==="freedraw",Q=e=>e!=null&&Ua(e.type),ee=e=>e!=null&&e.type==="arrow",Ua=e=>e==="arrow"||e==="line",Qe=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&kE(e.type),kE=e=>e==="arrow",qn=(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),RE=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||ee(e)),$a=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 Xo(t,null),!1}},jo=e=>RE(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),Ye=e=>e!==null&&"containerId"in e&&e.containerId!==null&&Y(e),qo=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",Kd=e=>e==="line"||e==="arrow"||e==="diamond",f1=(e,t)=>!!((e===ke.ADAPTIVE_RADIUS||e===ke.LEGACY)&&qo(t.type)||e===ke.PROPORTIONAL_RADIUS&&Kd(t.type)),m1=e=>Kd(e.type)?{type:ke.PROPORTIONAL_RADIUS}:qo(e.type)?{type:ke.ADAPTIVE_RADIUS}:null;g();g();g();g();g();g();g();g();g();g();g();g();function Ya(e,t,n){if(e&&e.length){let[r,o]=t,i=Math.PI/180*n,a=Math.cos(i),s=Math.sin(i);for(let l of e){let[c,d]=l;l[0]=(c-r)*a-(d-o)*s+r,l[1]=(c-r)*s+(d-o)*a+o}}}function FE(e,t,n){let r=[];e.forEach(o=>r.push(...o)),Ya(r,t,n)}function OE(e,t){return e[0]===t[0]&&e[1]===t[1]}function jd(e,t,n,r=1){let o=n,i=Math.max(t,.1),a=e[0]&&e[0][0]&&typeof e[0][0]=="number"?[e]:e,s=[0,0];if(o)for(let c of a)Ya(c,s,o);let l=NE(a,i,r);if(o){for(let c of a)Ya(c,s,-o);FE(l,s,-o)}return l}function NE(e,t,n){let r=[];for(let c of e){let d=[...c];OE(d[0],d[d.length-1])||d.push([d[0][0],d[0][1]]),d.length>2&&r.push(d)}let o=[];t=Math.max(t,.1);let i=[];for(let c of r)for(let d=0;d<c.length-1;d++){let u=c[d],f=c[d+1];if(u[1]!==f[1]){let m=Math.min(u[1],f[1]);i.push({ymin:m,ymax:Math.max(u[1],f[1]),x:m===u[1]?u[0]:f[0],islope:(f[0]-u[0])/(f[1]-u[1])})}}if(i.sort((c,d)=>c.ymin<d.ymin?-1:c.ymin>d.ymin?1:c.x<d.x?-1:c.x>d.x?1:c.ymax===d.ymax?0:(c.ymax-d.ymax)/Math.abs(c.ymax-d.ymax)),!i.length)return o;let a=[],s=i[0].ymin,l=0;for(;a.length||i.length;){if(i.length){let c=-1;for(let u=0;u<i.length&&!(i[u].ymin>s);u++)c=u;i.splice(0,c+1).forEach(u=>{a.push({s,edge:u})})}if(a=a.filter(c=>!(c.edge.ymax<=s)),a.sort((c,d)=>c.edge.x===d.edge.x?0:(c.edge.x-d.edge.x)/Math.abs(c.edge.x-d.edge.x)),(n!==1||l%t===0)&&a.length>1)for(let c=0;c<a.length;c=c+2){let d=c+1;if(d>=a.length)break;let u=a[c].edge,f=a[d].edge;o.push([[Math.round(u.x),s],[Math.round(f.x),s]])}s+=n,a.forEach(c=>{c.edge.x=c.edge.x+n*c.edge.islope}),l++}return o}function yt(e,t){var n;let r=t.hachureAngle+90,o=t.hachureGap;o<0&&(o=t.strokeWidth*4),o=Math.max(o,.1);let i=1;return t.roughness>=1&&(((n=t.randomizer)===null||n===void 0?void 0:n.next())||Math.random())>.7&&(i=o),jd(e,o,r,i||1)}var qt=class{constructor(t){this.helper=t}fillPolygons(t,n){return this._fillPolygons(t,n)}_fillPolygons(t,n){let r=yt(t,n);return{type:"fillSketch",ops:this.renderLines(r,n)}}renderLines(t,n){let r=[];for(let o of t)r.push(...this.helper.doubleLineOps(o[0][0],o[0][1],o[1][0],o[1][1],n));return r}};g();g();function Jt(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 Jo=class extends qt{fillPolygons(t,n){let r=n.hachureGap;r<0&&(r=n.strokeWidth*4),r=Math.max(r,.1);let o=Object.assign({},n,{hachureGap:r}),i=yt(t,o),a=Math.PI/180*n.hachureAngle,s=[],l=r*.5*Math.cos(a),c=r*.5*Math.sin(a);for(let[u,f]of i)Jt([u,f])&&s.push([[u[0]-l,u[1]+c],[...f]],[[u[0]+l,u[1]-c],[...f]]);return{type:"fillSketch",ops:this.renderLines(s,n)}}};g();var Qo=class extends qt{fillPolygons(t,n){let r=this._fillPolygons(t,n),o=Object.assign({},n,{hachureAngle:n.hachureAngle+90}),i=this._fillPolygons(t,o);return r.ops=r.ops.concat(i.ops),r}};g();var ei=class{constructor(t){this.helper=t}fillPolygons(t,n){n=Object.assign({},n,{hachureAngle:0});let r=yt(t,n);return this.dotsOnLines(r,n)}dotsOnLines(t,n){let r=[],o=n.hachureGap;o<0&&(o=n.strokeWidth*4),o=Math.max(o,.1);let i=n.fillWeight;i<0&&(i=n.strokeWidth/2);let a=o/4;for(let s of t){let l=Jt(s),c=l/o,d=Math.ceil(c)-1,u=l-d*o,f=(s[0][0]+s[1][0])/2-o/4,m=Math.min(s[0][1],s[1][1]);for(let p=0;p<d;p++){let h=m+u+p*o,E=f-a+Math.random()*2*a,x=h-a+Math.random()*2*a,w=this.helper.ellipse(E,x,i,i,n);r.push(...w.ops)}}return{type:"fillSketch",ops:r}}};g();var ti=class{constructor(t){this.helper=t}fillPolygons(t,n){let r=yt(t,n);return{type:"fillSketch",ops:this.dashedLine(r,n)}}dashedLine(t,n){let r=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,i=[];return t.forEach(a=>{let s=Jt(a),l=Math.floor(s/(r+o)),c=(s+o-l*(r+o))/2,d=a[0],u=a[1];d[0]>u[0]&&(d=a[1],u=a[0]);let f=Math.atan((u[1]-d[1])/(u[0]-d[0]));for(let m=0;m<l;m++){let p=m*(r+o),h=p+r,E=[d[0]+p*Math.cos(f)+c*Math.cos(f),d[1]+p*Math.sin(f)+c*Math.sin(f)],x=[d[0]+h*Math.cos(f)+c*Math.cos(f),d[1]+h*Math.sin(f)+c*Math.sin(f)];i.push(...this.helper.doubleLineOps(E[0],E[1],x[0],x[1],n))}}),i}};g();var ni=class{constructor(t){this.helper=t}fillPolygons(t,n){let r=n.hachureGap<0?n.strokeWidth*4:n.hachureGap,o=n.zigzagOffset<0?r:n.zigzagOffset;n=Object.assign({},n,{hachureGap:r+o});let i=yt(t,n);return{type:"fillSketch",ops:this.zigzagLines(i,o,n)}}zigzagLines(t,n,r){let o=[];return t.forEach(i=>{let a=Jt(i),s=Math.round(a/(2*n)),l=i[0],c=i[1];l[0]>c[0]&&(l=i[1],c=i[0]);let d=Math.atan((c[1]-l[1])/(c[0]-l[0]));for(let u=0;u<s;u++){let f=u*2*n,m=(u+1)*2*n,p=Math.sqrt(2*Math.pow(n,2)),h=[l[0]+f*Math.cos(d),l[1]+f*Math.sin(d)],E=[l[0]+m*Math.cos(d),l[1]+m*Math.sin(d)],x=[h[0]+p*Math.cos(d+Math.PI/4),h[1]+p*Math.sin(d+Math.PI/4)];o.push(...this.helper.doubleLineOps(h[0],h[1],x[0],x[1],r),...this.helper.doubleLineOps(x[0],x[1],E[0],E[1],r))}}),o}};var Pe={};function qd(e,t){let n=e.fillStyle||"hachure";if(!Pe[n])switch(n){case"zigzag":Pe[n]||(Pe[n]=new Jo(t));break;case"cross-hatch":Pe[n]||(Pe[n]=new Qo(t));break;case"dots":Pe[n]||(Pe[n]=new ei(t));break;case"dashed":Pe[n]||(Pe[n]=new ti(t));break;case"zigzag-line":Pe[n]||(Pe[n]=new ni(t));break;case"hachure":default:n="hachure",Pe[n]||(Pe[n]=new qt(t));break}return Pe[n]}g();function Jd(){return Math.floor(Math.random()*2**31)}var Jn=class{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}};g();g();var ri={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 BE(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 Wa(e,t){return e.type===t}function Qn(e){let t=[],n=BE(e),r="BOD",o=0,i=n[o];for(;!Wa(i,2);){let a=0,s=[];if(r==="BOD")if(i.text==="M"||i.text==="m")o++,a=ri[i.text],r=i.text;else return Qn("M0,0"+e);else Wa(i,1)?a=ri[r]:(o++,a=ri[i.text],r=i.text);if(o+a<n.length){for(let l=o;l<o+a;l++){let c=n[l];if(Wa(c,1))s[s.length]=+c.text;else throw new Error("Param not a number: "+r+","+c.text)}if(typeof ri[r]=="number"){let l={key:r,data:s};t.push(l),o+=a,i=n[o],r==="M"&&(r="L"),r==="m"&&(r="l")}else throw new Error("Bad segment: "+r)}else throw new Error("Path data ended short")}return t}g();function Gr(e){let t=0,n=0,r=0,o=0,i=[];for(let{key:a,data:s}of e)switch(a){case"M":i.push({key:"M",data:[...s]}),[t,n]=s,[r,o]=s;break;case"m":t+=s[0],n+=s[1],i.push({key:"M",data:[t,n]}),r=t,o=n;break;case"L":i.push({key:"L",data:[...s]}),[t,n]=s;break;case"l":t+=s[0],n+=s[1],i.push({key:"L",data:[t,n]});break;case"C":i.push({key:"C",data:[...s]}),t=s[4],n=s[5];break;case"c":{let l=s.map((c,d)=>d%2?c+n:c+t);i.push({key:"C",data:l}),t=l[4],n=l[5];break}case"Q":i.push({key:"Q",data:[...s]}),t=s[2],n=s[3];break;case"q":{let l=s.map((c,d)=>d%2?c+n:c+t);i.push({key:"Q",data:l}),t=l[2],n=l[3];break}case"A":i.push({key:"A",data:[...s]}),t=s[5],n=s[6];break;case"a":t+=s[5],n+=s[6],i.push({key:"A",data:[s[0],s[1],s[2],s[3],s[4],t,n]});break;case"H":i.push({key:"H",data:[...s]}),t=s[0];break;case"h":t+=s[0],i.push({key:"H",data:[t]});break;case"V":i.push({key:"V",data:[...s]}),n=s[0];break;case"v":n+=s[0],i.push({key:"V",data:[n]});break;case"S":i.push({key:"S",data:[...s]}),t=s[2],n=s[3];break;case"s":{let l=s.map((c,d)=>d%2?c+n:c+t);i.push({key:"S",data:l}),t=l[2],n=l[3];break}case"T":i.push({key:"T",data:[...s]}),t=s[0],n=s[1];break;case"t":t+=s[0],n+=s[1],i.push({key:"T",data:[t,n]});break;case"Z":case"z":i.push({key:"Z",data:[]}),t=r,n=o;break}return i}g();function Hr(e){let t=[],n="",r=0,o=0,i=0,a=0,s=0,l=0;for(let{key:c,data:d}of e){switch(c){case"M":t.push({key:"M",data:[...d]}),[r,o]=d,[i,a]=d;break;case"C":t.push({key:"C",data:[...d]}),r=d[4],o=d[5],s=d[2],l=d[3];break;case"L":t.push({key:"L",data:[...d]}),[r,o]=d;break;case"H":r=d[0],t.push({key:"L",data:[r,o]});break;case"V":o=d[0],t.push({key:"L",data:[r,o]});break;case"S":{let u=0,f=0;n==="C"||n==="S"?(u=r+(r-s),f=o+(o-l)):(u=r,f=o),t.push({key:"C",data:[u,f,...d]}),s=d[0],l=d[1],r=d[2],o=d[3];break}case"T":{let[u,f]=d,m=0,p=0;n==="Q"||n==="T"?(m=r+(r-s),p=o+(o-l)):(m=r,p=o);let h=r+2*(m-r)/3,E=o+2*(p-o)/3,x=u+2*(m-u)/3,w=f+2*(p-f)/3;t.push({key:"C",data:[h,E,x,w,u,f]}),s=m,l=p,r=u,o=f;break}case"Q":{let[u,f,m,p]=d,h=r+2*(u-r)/3,E=o+2*(f-o)/3,x=m+2*(u-m)/3,w=p+2*(f-p)/3;t.push({key:"C",data:[h,E,x,w,m,p]}),s=u,l=f,r=m,o=p;break}case"A":{let u=Math.abs(d[0]),f=Math.abs(d[1]),m=d[2],p=d[3],h=d[4],E=d[5],x=d[6];u===0||f===0?(t.push({key:"C",data:[r,o,E,x,E,x]}),r=E,o=x):(r!==E||o!==x)&&(Qd(r,o,E,x,u,f,m,p,h).forEach(function(y){t.push({key:"C",data:y})}),r=E,o=x);break}case"Z":t.push({key:"Z",data:[]}),r=i,o=a;break}n=c}return t}function GE(e){return Math.PI*e/180}function zr(e,t,n){let r=e*Math.cos(n)-t*Math.sin(n),o=e*Math.sin(n)+t*Math.cos(n);return[r,o]}function Qd(e,t,n,r,o,i,a,s,l,c){let d=GE(a),u=[],f=0,m=0,p=0,h=0;if(c)[f,m,p,h]=c;else{[e,t]=zr(e,t,-d),[n,r]=zr(n,r,-d);let P=(e-n)/2,D=(t-r)/2,z=P*P/(o*o)+D*D/(i*i);z>1&&(z=Math.sqrt(z),o=z*o,i=z*i);let O=s===l?-1:1,N=o*o,C=i*i,U=N*C-N*D*D-C*P*P,V=N*D*D+C*P*P,K=O*Math.sqrt(Math.abs(U/V));p=K*o*D/i+(e+n)/2,h=K*-i*P/o+(t+r)/2,f=Math.asin(parseFloat(((t-h)/i).toFixed(9))),m=Math.asin(parseFloat(((r-h)/i).toFixed(9))),e<p&&(f=Math.PI-f),n<p&&(m=Math.PI-m),f<0&&(f=Math.PI*2+f),m<0&&(m=Math.PI*2+m),l&&f>m&&(f=f-Math.PI*2),!l&&m>f&&(m=m-Math.PI*2)}let E=m-f;if(Math.abs(E)>Math.PI*120/180){let P=m,D=n,z=r;l&&m>f?m=f+Math.PI*120/180*1:m=f+Math.PI*120/180*-1,n=p+o*Math.cos(m),r=h+i*Math.sin(m),u=Qd(n,r,D,z,o,i,a,0,l,[m,P,p,h])}E=m-f;let x=Math.cos(f),w=Math.sin(f),y=Math.cos(m),T=Math.sin(m),b=Math.tan(E/4),L=4/3*o*b,I=4/3*i*b,_=[e,t],S=[e+L*w,t-I*x],M=[n+L*T,r-I*y],v=[n,r];if(S[0]=2*_[0]-S[0],S[1]=2*_[1]-S[1],c)return[S,M,v].concat(u);{u=[S,M,v].concat(u);let P=[];for(let D=0;D<u.length;D+=3){let z=zr(u[D][0],u[D][1],d),O=zr(u[D+1][0],u[D+1][1],d),N=zr(u[D+2][0],u[D+2][1],d);P.push([z[0],z[1],O[0],O[1],N[0],N[1]])}return P}}var zE={randOffset:$E,randOffsetWithRange:YE,ellipse:UE,doubleLineOps:WE};function Va(e,t,n,r,o){return{type:"path",ops:Rt(e,t,n,r,o)}}function Ur(e,t,n){let r=(e||[]).length;if(r>2){let o=[];for(let i=0;i<r-1;i++)o.push(...Rt(e[i][0],e[i][1],e[i+1][0],e[i+1][1],n));return t&&o.push(...Rt(e[r-1][0],e[r-1][1],e[0][0],e[0][1],n)),{type:"path",ops:o}}else if(r===2)return Va(e[0][0],e[0][1],e[1][0],e[1][1],n);return{type:"path",ops:[]}}function HE(e,t){return Ur(e,!0,t)}function ou(e,t,n,r,o){let i=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]];return HE(i,o)}function Xa(e,t){let n=tu(e,1*(1+t.roughness*.2),t);if(!t.disableMultiStroke){let r=tu(e,1.5*(1+t.roughness*.22),VE(t));n=n.concat(r)}return{type:"path",ops:n}}function UE(e,t,n,r,o){let i=Za(n,r,o);return ai(e,t,o,i).opset}function Za(e,t,n){let r=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)*r)),i=Math.PI*2/o,a=Math.abs(e/2),s=Math.abs(t/2),l=1-n.curveFitting;return a+=k(a*l,n),s+=k(s*l,n),{increment:i,rx:a,ry:s}}function ai(e,t,n,r){let[o,i]=nu(r.increment,e,t,r.rx,r.ry,1,r.increment*oi(.1,oi(.4,1,n),n),n),a=ii(o,null,n);if(!n.disableMultiStroke&&n.roughness!==0){let[s]=nu(r.increment,e,t,r.rx,r.ry,1.5,0,n),l=ii(s,null,n);a=a.concat(l)}return{estimatedPoints:i,opset:{type:"path",ops:a}}}function Ka(e,t,n,r,o,i,a,s,l){let c=e,d=t,u=Math.abs(n/2),f=Math.abs(r/2);u+=k(u*.01,l),f+=k(f*.01,l);let m=o,p=i;for(;m<0;)m+=Math.PI*2,p+=Math.PI*2;p-m>Math.PI*2&&(m=0,p=Math.PI*2);let h=Math.PI*2/l.curveStepCount,E=Math.min(h/2,(p-m)/2),x=ru(E,c,d,u,f,m,p,1,l);if(!l.disableMultiStroke){let w=ru(E,c,d,u,f,m,p,1.5,l);x.push(...w)}return a&&(s?x.push(...Rt(c,d,c+u*Math.cos(m),d+f*Math.sin(m),l),...Rt(c,d,c+u*Math.cos(p),d+f*Math.sin(p),l)):x.push({op:"lineTo",data:[c,d]},{op:"lineTo",data:[c+u*Math.cos(m),d+f*Math.sin(m)]})),{type:"path",ops:x}}function ja(e,t){let n=Hr(Gr(Qn(e))),r=[],o=[0,0],i=[0,0];for(let{key:a,data:s}of n)switch(a){case"M":{i=[s[0],s[1]],o=[s[0],s[1]];break}case"L":r.push(...Rt(i[0],i[1],s[0],s[1],t)),i=[s[0],s[1]];break;case"C":{let[l,c,d,u,f,m]=s;r.push(...XE(l,c,d,u,f,m,i,t)),i=[f,m];break}case"Z":r.push(...Rt(i[0],i[1],o[0],o[1],t)),i=[o[0],o[1]];break}return{type:"path",ops:r}}function si(e,t){let n=[];for(let r of e)if(r.length){let o=t.maxRandomnessOffset||0,i=r.length;if(i>2){n.push({op:"move",data:[r[0][0]+k(o,t),r[0][1]+k(o,t)]});for(let a=1;a<i;a++)n.push({op:"lineTo",data:[r[a][0]+k(o,t),r[a][1]+k(o,t)]})}}return{type:"fillPath",ops:n}}function vn(e,t){return qd(t,zE).fillPolygons(e,t)}function iu(e,t,n,r,o,i,a){let s=e,l=t,c=Math.abs(n/2),d=Math.abs(r/2);c+=k(c*.01,a),d+=k(d*.01,a);let u=o,f=i;for(;u<0;)u+=Math.PI*2,f+=Math.PI*2;f-u>Math.PI*2&&(u=0,f=Math.PI*2);let m=(f-u)/a.curveStepCount,p=[];for(let h=u;h<=f;h=h+m)p.push([s+c*Math.cos(h),l+d*Math.sin(h)]);return p.push([s+c*Math.cos(f),l+d*Math.sin(f)]),p.push([s,l]),vn([p],a)}function $E(e,t){return k(e,t)}function YE(e,t,n){return oi(e,t,n)}function WE(e,t,n,r,o){return Rt(e,t,n,r,o,!0)}function VE(e){let t=Object.assign({},e);return t.randomizer=void 0,e.seed&&(t.seed=e.seed+1),t}function au(e){return e.randomizer||(e.randomizer=new Jn(e.seed||0)),e.randomizer.next()}function oi(e,t,n,r=1){return n.roughness*r*(au(n)*(t-e)+e)}function k(e,t,n=1){return oi(-e,e,t,n)}function Rt(e,t,n,r,o,i=!1){let a=i?o.disableMultiStrokeFill:o.disableMultiStroke,s=eu(e,t,n,r,o,!0,!1);if(a)return s;let l=eu(e,t,n,r,o,!0,!0);return s.concat(l)}function eu(e,t,n,r,o,i,a){let s=Math.pow(e-n,2)+Math.pow(t-r,2),l=Math.sqrt(s),c=1;l<200?c=1:l>500?c=.4:c=-.0016668*l+1.233334;let d=o.maxRandomnessOffset||0;d*d*100>s&&(d=l/10);let u=d/2,f=.2+au(o)*.2,m=o.bowing*o.maxRandomnessOffset*(r-t)/200,p=o.bowing*o.maxRandomnessOffset*(e-n)/200;m=k(m,o,c),p=k(p,o,c);let h=[],E=()=>k(u,o,c),x=()=>k(d,o,c),w=o.preserveVertices;return i&&(a?h.push({op:"move",data:[e+(w?0:E()),t+(w?0:E())]}):h.push({op:"move",data:[e+(w?0:k(d,o,c)),t+(w?0:k(d,o,c))]})),a?h.push({op:"bcurveTo",data:[m+e+(n-e)*f+E(),p+t+(r-t)*f+E(),m+e+2*(n-e)*f+E(),p+t+2*(r-t)*f+E(),n+(w?0:E()),r+(w?0:E())]}):h.push({op:"bcurveTo",data:[m+e+(n-e)*f+x(),p+t+(r-t)*f+x(),m+e+2*(n-e)*f+x(),p+t+2*(r-t)*f+x(),n+(w?0:x()),r+(w?0:x())]}),h}function tu(e,t,n){let r=[];r.push([e[0][0]+k(t,n),e[0][1]+k(t,n)]),r.push([e[0][0]+k(t,n),e[0][1]+k(t,n)]);for(let o=1;o<e.length;o++)r.push([e[o][0]+k(t,n),e[o][1]+k(t,n)]),o===e.length-1&&r.push([e[o][0]+k(t,n),e[o][1]+k(t,n)]);return ii(r,null,n)}function ii(e,t,n){let r=e.length,o=[];if(r>3){let i=[],a=1-n.curveTightness;o.push({op:"move",data:[e[1][0],e[1][1]]});for(let s=1;s+2<r;s++){let l=e[s];i[0]=[l[0],l[1]],i[1]=[l[0]+(a*e[s+1][0]-a*e[s-1][0])/6,l[1]+(a*e[s+1][1]-a*e[s-1][1])/6],i[2]=[e[s+1][0]+(a*e[s][0]-a*e[s+2][0])/6,e[s+1][1]+(a*e[s][1]-a*e[s+2][1])/6],i[3]=[e[s+1][0],e[s+1][1]],o.push({op:"bcurveTo",data:[i[1][0],i[1][1],i[2][0],i[2][1],i[3][0],i[3][1]]})}if(t&&t.length===2){let s=n.maxRandomnessOffset;o.push({op:"lineTo",data:[t[0]+k(s,n),t[1]+k(s,n)]})}}else r===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]]})):r===2&&o.push(...Rt(e[0][0],e[0][1],e[1][0],e[1][1],n));return o}function nu(e,t,n,r,o,i,a,s){let l=s.roughness===0,c=[],d=[];if(l){e=e/4,d.push([t+r*Math.cos(-e),n+o*Math.sin(-e)]);for(let u=0;u<=Math.PI*2;u=u+e){let f=[t+r*Math.cos(u),n+o*Math.sin(u)];c.push(f),d.push(f)}d.push([t+r*Math.cos(0),n+o*Math.sin(0)]),d.push([t+r*Math.cos(e),n+o*Math.sin(e)])}else{let u=k(.5,s)-Math.PI/2;d.push([k(i,s)+t+.9*r*Math.cos(u-e),k(i,s)+n+.9*o*Math.sin(u-e)]);let f=Math.PI*2+u-.01;for(let m=u;m<f;m=m+e){let p=[k(i,s)+t+r*Math.cos(m),k(i,s)+n+o*Math.sin(m)];c.push(p),d.push(p)}d.push([k(i,s)+t+r*Math.cos(u+Math.PI*2+a*.5),k(i,s)+n+o*Math.sin(u+Math.PI*2+a*.5)]),d.push([k(i,s)+t+.98*r*Math.cos(u+a),k(i,s)+n+.98*o*Math.sin(u+a)]),d.push([k(i,s)+t+.9*r*Math.cos(u+a*.5),k(i,s)+n+.9*o*Math.sin(u+a*.5)])}return[d,c]}function ru(e,t,n,r,o,i,a,s,l){let c=i+k(.1,l),d=[];d.push([k(s,l)+t+.9*r*Math.cos(c-e),k(s,l)+n+.9*o*Math.sin(c-e)]);for(let u=c;u<=a;u=u+e)d.push([k(s,l)+t+r*Math.cos(u),k(s,l)+n+o*Math.sin(u)]);return d.push([t+r*Math.cos(a),n+o*Math.sin(a)]),d.push([t+r*Math.cos(a),n+o*Math.sin(a)]),ii(d,null,l)}function XE(e,t,n,r,o,i,a,s){let l=[],c=[s.maxRandomnessOffset||1,(s.maxRandomnessOffset||1)+.3],d=[0,0],u=s.disableMultiStroke?1:2,f=s.preserveVertices;for(let m=0;m<u;m++)m===0?l.push({op:"move",data:[a[0],a[1]]}):l.push({op:"move",data:[a[0]+(f?0:k(c[0],s)),a[1]+(f?0:k(c[0],s))]}),d=f?[o,i]:[o+k(c[m],s),i+k(c[m],s)],l.push({op:"bcurveTo",data:[e+k(c[m],s),t+k(c[m],s),n+k(c[m],s),r+k(c[m],s),d[0],d[1]]});return l}g();function $r(e){return[...e]}function su(e,t=0){let n=e.length;if(n<3)throw new Error("A curve must have at least three points.");let r=[];if(n===3)r.push($r(e[0]),$r(e[1]),$r(e[2]),$r(e[2]));else{let o=[];o.push(e[0],e[0]);for(let s=1;s<e.length;s++)o.push(e[s]),s===e.length-1&&o.push(e[s]);let i=[],a=1-t;r.push($r(o[0]));for(let s=1;s+2<o.length;s++){let l=o[s];i[0]=[l[0],l[1]],i[1]=[l[0]+(a*o[s+1][0]-a*o[s-1][0])/6,l[1]+(a*o[s+1][1]-a*o[s-1][1])/6],i[2]=[o[s+1][0]+(a*o[s][0]-a*o[s+2][0])/6,o[s+1][1]+(a*o[s][1]-a*o[s+2][1])/6],i[3]=[o[s+1][0],o[s+1][1]],r.push(i[1],i[2],i[3])}}return r}g();function ZE(e,t){return Math.sqrt(li(e,t))}function li(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function KE(e,t,n){let r=li(t,n);if(r===0)return li(e,t);let o=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return o=Math.max(0,Math.min(1,o)),li(e,Tn(t,n,o))}function Tn(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function jE(e,t){let n=e[t+0],r=e[t+1],o=e[t+2],i=e[t+3],a=3*r[0]-2*n[0]-i[0];a*=a;let s=3*r[1]-2*n[1]-i[1];s*=s;let l=3*o[0]-2*i[0]-n[0];l*=l;let c=3*o[1]-2*i[1]-n[1];return c*=c,a<l&&(a=l),s<c&&(s=c),a+s}function qa(e,t,n,r){let o=r||[];if(jE(e,t)<n){let i=e[t+0];o.length?ZE(o[o.length-1],i)>1&&o.push(i):o.push(i),o.push(e[t+3])}else{let a=e[t+0],s=e[t+1],l=e[t+2],c=e[t+3],d=Tn(a,s,.5),u=Tn(s,l,.5),f=Tn(l,c,.5),m=Tn(d,u,.5),p=Tn(u,f,.5),h=Tn(m,p,.5);qa([a,d,m,h],0,n,o),qa([h,p,f,c],0,n,o)}return o}function lu(e,t){return ci(e,0,e.length,t)}function ci(e,t,n,r,o){let i=o||[],a=e[t],s=e[n-1],l=0,c=1;for(let d=t+1;d<n-1;++d){let u=KE(e[d],a,s);u>l&&(l=u,c=d)}return Math.sqrt(l)>r?(ci(e,t,c+1,r,i),ci(e,c,n,r,i)):(i.length||i.push(a),i.push(s)),i}function er(e,t=.15,n){let r=[],o=(e.length-1)/3;for(let i=0;i<o;i++){let a=i*3;qa(e,a,t,r)}return n&&n>0?ci(r,0,r.length,n):r}g();function cu(e,t,n){let r=Qn(e),o=Hr(Gr(r)),i=[],a=[],s=[0,0],l=[],c=()=>{l.length>=4&&a.push(...er(l,t)),l=[]},d=()=>{c(),a.length&&(i.push(a),a=[])};for(let{key:f,data:m}of o)switch(f){case"M":d(),s=[m[0],m[1]],a.push(s);break;case"L":c(),a.push([m[0],m[1]]);break;case"C":if(!l.length){let p=a.length?a[a.length-1]:s;l.push([p[0],p[1]])}l.push([m[0],m[1]]),l.push([m[2],m[3]]),l.push([m[4],m[5]]);break;case"Z":c(),a.push([s[0],s[1]]);break}if(d(),!n)return i;let u=[];for(let f of i){let m=lu(f,n);m.length&&u.push(m)}return u}var Re="none",et=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 Jd()}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,n,r){return{shape:t,sets:n||[],options:r||this.defaultOptions}}line(t,n,r,o,i){let a=this._o(i);return this._d("line",[Va(t,n,r,o,a)],a)}rectangle(t,n,r,o,i){let a=this._o(i),s=[],l=ou(t,n,r,o,a);if(a.fill){let c=[[t,n],[t+r,n],[t+r,n+o],[t,n+o]];a.fillStyle==="solid"?s.push(si([c],a)):s.push(vn([c],a))}return a.stroke!==Re&&s.push(l),this._d("rectangle",s,a)}ellipse(t,n,r,o,i){let a=this._o(i),s=[],l=Za(r,o,a),c=ai(t,n,a,l);if(a.fill)if(a.fillStyle==="solid"){let d=ai(t,n,a,l).opset;d.type="fillPath",s.push(d)}else s.push(vn([c.estimatedPoints],a));return a.stroke!==Re&&s.push(c.opset),this._d("ellipse",s,a)}circle(t,n,r,o){let i=this.ellipse(t,n,r,r,o);return i.shape="circle",i}linearPath(t,n){let r=this._o(n);return this._d("linearPath",[Ur(t,!1,r)],r)}arc(t,n,r,o,i,a,s=!1,l){let c=this._o(l),d=[],u=Ka(t,n,r,o,i,a,s,!0,c);if(s&&c.fill)if(c.fillStyle==="solid"){let f=Object.assign({},c);f.disableMultiStroke=!0;let m=Ka(t,n,r,o,i,a,!0,!1,f);m.type="fillPath",d.push(m)}else d.push(iu(t,n,r,o,i,a,c));return c.stroke!==Re&&d.push(u),this._d("arc",d,c)}curve(t,n){let r=this._o(n),o=[],i=Xa(t,r);if(r.fill&&r.fill!==Re&&t.length>=3)if(r.fillStyle==="solid"){let a=Xa(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));o.push({type:"fillPath",ops:this._mergedShape(a.ops)})}else{let a=su(t),s=er(a,10,(1+r.roughness)/2);o.push(vn([s],r))}return r.stroke!==Re&&o.push(i),this._d("curve",o,r)}polygon(t,n){let r=this._o(n),o=[],i=Ur(t,!0,r);return r.fill&&(r.fillStyle==="solid"?o.push(si([t],r)):o.push(vn([t],r))),r.stroke!==Re&&o.push(i),this._d("polygon",o,r)}path(t,n){let r=this._o(n),o=[];if(!t)return this._d("path",o,r);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let i=r.fill&&r.fill!=="transparent"&&r.fill!==Re,a=r.stroke!==Re,s=!!(r.simplification&&r.simplification<1),l=s?4-4*(r.simplification||1):(1+r.roughness)/2,c=cu(t,1,l),d=ja(t,r);if(i)if(r.fillStyle==="solid")if(c.length===1){let u=ja(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));o.push({type:"fillPath",ops:this._mergedShape(u.ops)})}else o.push(si(c,r));else o.push(vn(c,r));return a&&(s?c.forEach(u=>{o.push(Ur(u,!1,r))}):o.push(d)),this._d("path",o,r)}opsToPath(t,n){let r="";for(let o of t.ops){let i=typeof n=="number"&&n>=0?o.data.map(a=>+a.toFixed(n)):o.data;switch(o.op){case"move":r+=`M${i[0]} ${i[1]} `;break;case"bcurveTo":r+=`C${i[0]} ${i[1]}, ${i[2]} ${i[3]}, ${i[4]} ${i[5]} `;break;case"lineTo":r+=`L${i[0]} ${i[1]} `;break}}return r.trim()}toPaths(t){let n=t.sets||[],r=t.options||this.defaultOptions,o=[];for(let i of n){let a=null;switch(i.type){case"path":a={d:this.opsToPath(i),stroke:r.stroke,strokeWidth:r.strokeWidth,fill:Re};break;case"fillPath":a={d:this.opsToPath(i),stroke:Re,strokeWidth:0,fill:r.fill||Re};break;case"fillSketch":a=this.fillSketch(i,r);break}a&&o.push(a)}return o}fillSketch(t,n){let r=n.fillWeight;return r<0&&(r=n.strokeWidth/2),{d:this.opsToPath(t),stroke:n.fill||Re,strokeWidth:r,fill:Re}}_mergedShape(t){return t.filter((n,r)=>r===0?!0:n.op!=="move")}};var di=class{constructor(t,n){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new et(n)}draw(t){let n=t.sets||[],r=t.options||this.getDefaultOptions(),o=this.ctx,i=t.options.fixedDecimalPlaceDigits;for(let a of n)switch(a.type){case"path":o.save(),o.strokeStyle=r.stroke==="none"?"transparent":r.stroke,o.lineWidth=r.strokeWidth,r.strokeLineDash&&o.setLineDash(r.strokeLineDash),r.strokeLineDashOffset&&(o.lineDashOffset=r.strokeLineDashOffset),this._drawToContext(o,a,i),o.restore();break;case"fillPath":{o.save(),o.fillStyle=r.fill||"";let s=t.shape==="curve"||t.shape==="polygon"||t.shape==="path"?"evenodd":"nonzero";this._drawToContext(o,a,i,s),o.restore();break}case"fillSketch":this.fillSketch(o,a,r);break}}fillSketch(t,n,r){let o=r.fillWeight;o<0&&(o=r.strokeWidth/2),t.save(),r.fillLineDash&&t.setLineDash(r.fillLineDash),r.fillLineDashOffset&&(t.lineDashOffset=r.fillLineDashOffset),t.strokeStyle=r.fill||"",t.lineWidth=o,this._drawToContext(t,n,r.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,n,r,o="nonzero"){t.beginPath();for(let i of n.ops){let a=typeof r=="number"&&r>=0?i.data.map(s=>+s.toFixed(r)):i.data;switch(i.op){case"move":t.moveTo(a[0],a[1]);break;case"bcurveTo":t.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"lineTo":t.lineTo(a[0],a[1]);break}}n.type==="fillPath"?t.fill(o):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,n,r,o,i){let a=this.gen.line(t,n,r,o,i);return this.draw(a),a}rectangle(t,n,r,o,i){let a=this.gen.rectangle(t,n,r,o,i);return this.draw(a),a}ellipse(t,n,r,o,i){let a=this.gen.ellipse(t,n,r,o,i);return this.draw(a),a}circle(t,n,r,o){let i=this.gen.circle(t,n,r,o);return this.draw(i),i}linearPath(t,n){let r=this.gen.linearPath(t,n);return this.draw(r),r}polygon(t,n){let r=this.gen.polygon(t,n);return this.draw(r),r}arc(t,n,r,o,i,a,s=!1,l){let c=this.gen.arc(t,n,r,o,i,a,s,l);return this.draw(c),c}curve(t,n){let r=this.gen.curve(t,n);return this.draw(r),r}path(t,n){let r=this.gen.path(t,n);return this.draw(r),r}};g();g();var Yr="http://www.w3.org/2000/svg";var ui=class{constructor(t,n){this.svg=t,this.gen=new et(n)}draw(t){let n=t.sets||[],r=t.options||this.getDefaultOptions(),o=this.svg.ownerDocument||window.document,i=o.createElementNS(Yr,"g"),a=t.options.fixedDecimalPlaceDigits;for(let s of n){let l=null;switch(s.type){case"path":{l=o.createElementNS(Yr,"path"),l.setAttribute("d",this.opsToPath(s,a)),l.setAttribute("stroke",r.stroke),l.setAttribute("stroke-width",r.strokeWidth+""),l.setAttribute("fill","none"),r.strokeLineDash&&l.setAttribute("stroke-dasharray",r.strokeLineDash.join(" ").trim()),r.strokeLineDashOffset&&l.setAttribute("stroke-dashoffset",`${r.strokeLineDashOffset}`);break}case"fillPath":{l=o.createElementNS(Yr,"path"),l.setAttribute("d",this.opsToPath(s,a)),l.setAttribute("stroke","none"),l.setAttribute("stroke-width","0"),l.setAttribute("fill",r.fill||""),(t.shape==="curve"||t.shape==="polygon")&&l.setAttribute("fill-rule","evenodd");break}case"fillSketch":{l=this.fillSketch(o,s,r);break}}l&&i.appendChild(l)}return i}fillSketch(t,n,r){let o=r.fillWeight;o<0&&(o=r.strokeWidth/2);let i=t.createElementNS(Yr,"path");return i.setAttribute("d",this.opsToPath(n,r.fixedDecimalPlaceDigits)),i.setAttribute("stroke",r.fill||""),i.setAttribute("stroke-width",o+""),i.setAttribute("fill","none"),r.fillLineDash&&i.setAttribute("stroke-dasharray",r.fillLineDash.join(" ").trim()),r.fillLineDashOffset&&i.setAttribute("stroke-dashoffset",`${r.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,n){return this.gen.opsToPath(t,n)}line(t,n,r,o,i){let a=this.gen.line(t,n,r,o,i);return this.draw(a)}rectangle(t,n,r,o,i){let a=this.gen.rectangle(t,n,r,o,i);return this.draw(a)}ellipse(t,n,r,o,i){let a=this.gen.ellipse(t,n,r,o,i);return this.draw(a)}circle(t,n,r,o){let i=this.gen.circle(t,n,r,o);return this.draw(i)}linearPath(t,n){let r=this.gen.linearPath(t,n);return this.draw(r)}polygon(t,n){let r=this.gen.polygon(t,n);return this.draw(r)}arc(t,n,r,o,i,a,s=!1,l){let c=this.gen.arc(t,n,r,o,i,a,s,l);return this.draw(c)}curve(t,n){let r=this.gen.curve(t,n);return this.draw(r)}path(t,n){let r=this.gen.path(t,n);return this.draw(r)}};var bt={canvas(e,t){return new di(e,t)},svg(e,t){return new ui(e,t)},generator(e){return new et(e)},newSeed(){return et.newSeed()}};g();g();g();function du(e,t,n,r=o=>o){return e*r(.5-t*(.5-n))}function qE(e){return[-e[0],-e[1]]}function nt(e,t){return[e[0]+t[0],e[1]+t[1]]}function We(e,t){return[e[0]-t[0],e[1]-t[1]]}function tt(e,t){return[e[0]*t,e[1]*t]}function JE(e,t){return[e[0]/t,e[1]/t]}function Wr(e){return[e[1],-e[0]]}function uu(e,t){return e[0]*t[0]+e[1]*t[1]}function QE(e,t){return e[0]===t[0]&&e[1]===t[1]}function eg(e){return Math.hypot(e[0],e[1])}function tg(e){return e[0]*e[0]+e[1]*e[1]}function fu(e,t){return tg(We(e,t))}function hu(e){return JE(e,eg(e))}function ng(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function Vr(e,t,n){let r=Math.sin(n),o=Math.cos(n),i=e[0]-t[0],a=e[1]-t[1],s=i*o-a*r,l=i*r+a*o;return[s+t[0],l+t[1]]}function Ja(e,t,n){return nt(e,tt(We(t,e),n))}function mu(e,t,n){return nt(e,tt(t,n))}var{min:tr,PI:rg}=Math,pu=.275,Xr=rg+1e-4;function og(e,t={}){let{size:n=16,smoothing:r=.5,thinning:o=.5,simulatePressure:i=!0,easing:a=C=>C,start:s={},end:l={},last:c=!1}=t,{cap:d=!0,easing:u=C=>C*(2-C)}=s,{cap:f=!0,easing:m=C=>--C*C*C+1}=l;if(e.length===0||n<=0)return[];let p=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,p):s.taper,E=l.taper===!1?0:l.taper===!0?Math.max(n,p):l.taper,x=Math.pow(n*r,2),w=[],y=[],T=e.slice(0,10).reduce((C,U)=>{let V=U.pressure;if(i){let K=tr(1,U.distance/n),ye=tr(1,1-K);V=tr(1,C+(ye-C)*(K*pu))}return(C+V)/2},e[0].pressure),b=du(n,o,e[e.length-1].pressure,a),L,I=e[0].vector,_=e[0].point,S=_,M=_,v=S,P=!1;for(let C=0;C<e.length;C++){let{pressure:U}=e[C],{point:V,vector:K,distance:ye,runningLength:he}=e[C];if(C<e.length-1&&p-he<3)continue;if(o){if(i){let xe=tr(1,ye/n),dn=tr(1,1-xe);U=tr(1,T+(dn-T)*(xe*pu))}b=du(n,o,U,a)}else b=n/2;L===void 0&&(L=b);let ae=he<h?u(he/h):1,ct=p-he<E?m((p-he)/E):1;b=Math.max(.01,b*Math.min(ae,ct));let sn=(C<e.length-1?e[C+1]:e[C]).vector,ge=C<e.length-1?uu(K,sn):1,On=uu(K,I)<0&&!P,ln=ge!==null&&ge<0;if(On||ln){let xe=tt(Wr(I),b);for(let dn=1/13,be=0;be<=1;be+=dn)M=Vr(We(V,xe),V,Xr*be),w.push(M),v=Vr(nt(V,xe),V,Xr*-be),y.push(v);_=M,S=v,ln&&(P=!0);continue}if(P=!1,C===e.length-1){let xe=tt(Wr(K),b);w.push(We(V,xe)),y.push(nt(V,xe));continue}let cn=tt(Wr(Ja(sn,K,ge)),b);M=We(V,cn),(C<=1||fu(_,M)>x)&&(w.push(M),_=M),v=nt(V,cn),(C<=1||fu(S,v)>x)&&(y.push(v),S=v),T=U,I=K}let D=e[0].point.slice(0,2),z=e.length>1?e[e.length-1].point.slice(0,2):nt(e[0].point,[1,1]),O=[],N=[];if(e.length===1){if(!(h||E)||c){let C=mu(D,hu(Wr(We(D,z))),-(L||b)),U=[];for(let V=1/13,K=V;K<=1;K+=V)U.push(Vr(C,D,Xr*2*K));return U}}else{if(!(h||E&&e.length===1))if(d)for(let U=1/13,V=U;V<=1;V+=U){let K=Vr(y[0],D,Xr*V);O.push(K)}else{let U=We(w[0],y[0]),V=tt(U,.5),K=tt(U,.51);O.push(We(D,V),We(D,K),nt(D,K),nt(D,V))}let C=Wr(qE(e[e.length-1].vector));if(E||h&&e.length===1)N.push(z);else if(f){let U=mu(z,C,b);for(let V=1/29,K=V;K<1;K+=V)N.push(Vr(U,z,Xr*3*K))}else N.push(nt(z,tt(C,b)),nt(z,tt(C,b*.99)),We(z,tt(C,b*.99)),We(z,tt(C,b)))}return w.concat(N,y.reverse(),O)}function ig(e,t={}){var n;let{streamline:r=.5,size:o=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-r)*.85,s=Array.isArray(e[0])?e:e.map(({x:m,y:p,pressure:h=.5})=>[m,p,h]);if(s.length===2){let m=s[1];s=s.slice(0,-1);for(let p=1;p<5;p++)s.push(Ja(s[0],m,p/4))}s.length===1&&(s=[...s,[...nt(s[0],[1,1]),...s[0].slice(2)]]);let l=[{point:[s[0][0],s[0][1]],pressure:s[0][2]>=0?s[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,d=0,u=l[0],f=s.length-1;for(let m=1;m<s.length;m++){let p=i&&m===f?s[m].slice(0,2):Ja(u.point,s[m],a);if(QE(u.point,p))continue;let h=ng(p,u.point);if(d+=h,m<f&&!c){if(d<o)continue;c=!0}u={point:p,pressure:s[m][2]>=0?s[m][2]:.5,vector:hu(We(u.point,p)),distance:h,runningLength:d},l.push(u)}return l[0].vector=((n=l[1])==null?void 0:n.vector)||[0,0],l}function Eu(e,t={}){return og(ig(e,t),t)}g();g();g();g();var we=(e,t)=>[0,0,0,0,t,e,1,0];var gu=(e,t)=>[0,0,0,0,t,e,0,0];var An=(e=0,t=0)=>{let n=[0,0,0,0,0,0,0,0];if(t<0||t>7)throw new Error(`Expected \`index\` between 0 and 7, got \`${t}\``);return e!==0&&(n[t]=e),n};var nr=e=>[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7]];var xu=(e,t)=>rs(t)?[e[0]+t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]+t[0],e[1]+t[1],e[2]+t[2],e[3]+t[3],e[4]+t[4],e[5]+t[5],e[6]+t[6],e[7]+t[7]],Qa=(e,t)=>rs(t)?[e[0]-t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3],e[4]-t[4],e[5]-t[5],e[6]-t[6],e[7]-t[7]],Qt=(e,t)=>rs(t)?[e[0]*t,e[1]*t,e[2]*t,e[3]*t,e[4]*t,e[5]*t,e[6]*t,e[7]*t]:[ag(e,t),t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[7]*e[3]+t[0]*e[4]+t[6]*e[5]-t[5]*e[6]+t[3]*e[7],t[5]*e[0]-t[3]*e[1]+t[7]*e[2]+t[1]*e[3]-t[6]*e[4]+t[0]*e[5]+t[4]*e[6]+t[2]*e[7],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]+t[0]*e[7]],ag=(e,t)=>t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],es=(e,t)=>[t[0]*e[0],t[1]*e[0]+t[0]*e[1],t[2]*e[0]+t[0]*e[2],t[3]*e[0]+t[0]*e[3],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[0]*e[4],t[5]*e[0]-t[3]*e[1]+t[1]*e[3]+t[0]*e[5],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]],fi=(e,t)=>[ts(e,t),e[1]*t[7]+e[4]*t[5]-e[5]*t[4]+e[7]*t[1],e[2]*t[7]-e[4]*t[6]+e[6]*t[4]+e[7]*t[2],e[3]*t[7]+e[5]*t[6]-e[6]*t[5]+e[7]*t[3],e[4]*t[7]+e[7]*t[4],e[5]*t[7]+e[7]*t[5],e[6]*t[7]+e[7]*t[6],e[7]*t[7]],ts=(e,t)=>e[0]*t[7]+e[1]*t[6]+e[2]*t[5]+e[3]*t[4]+e[4]*t[3]+e[5]*t[2]+e[6]*t[1]+e[7]*t[0],wu=(e,t)=>[t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[7]*e[3]+t[0]*e[4]+t[3]*e[7],t[5]*e[0]+t[7]*e[2]+t[0]*e[5]+t[2]*e[7],t[6]*e[0]+t[0]*e[6],t[7]*e[0]+t[0]*e[7]],ns=e=>Math.sqrt(Math.abs(e[0]*e[0]-e[2]*e[2]-e[3]*e[3]+e[6]*e[6])),yu=e=>Math.sqrt(Math.abs(e[7]*e[7]-e[5]*e[5]-e[4]*e[4]+e[1]*e[1])),_n=e=>{let t=ns(e);if(t===0||t===1)return e;let n=e[6]<0?-1:1;return Qt(e,n/t)},bu=e=>{let t=yu(e);return t===0||t===1?e:Qt(e,1/t)},rs=e=>typeof e=="number",jv=An(1,1),qv=An(1,2),Jv=An(1,3),Qv=An(1,4),eT=An(1,5),tT=An(1,6),nT=An(1,7);g();g();var mi=(e,t,n)=>_n([0,n,e,t,0,0,0,0]),rr=(e,t)=>_n(fi(t,e)),vu=(e,t)=>wu(e,t),Tu=(e,t)=>vu(rr(e,t),t);var Au=e=>Math.sign(e[1]);var Sn=([e,t])=>[0,0,0,0,t,e,1,0],In=e=>[e[5],e[4]],Su=e=>[0,0,0,0,Math.abs(e[4]),Math.abs(e[5]),1,0],Iu=(e,t)=>_n(es(e,t));var os=(e,t)=>ns(fi(e,t)),en=(e,t)=>ts(e,t);g();var is=e=>[0,0,0,0,e[4],e[5],0,0],Pu=(e,t)=>bu([0,0,0,0,t[4]-e[4],t[5]-e[5],0,0]);g();var as=(e,t)=>xu(Qt(e,Math.sin(t/2)),Math.cos(t/2)),Lu=e=>[1,0,0,0,-(.5*e[5]),.5*e[4],0,0],Du=(e,t)=>{let n=.5*t;return[1,0,0,0,n*e[4],n*e[5],0,0]};var Cu=(e,t)=>Qt(t,e),rt=(e,t)=>_n(Qt(Qt(e,t),nr(e)));g();g();var or=1e-4;var cg=e=>{let t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]},ir=e=>cg(e)?e:[...e,e[0]],ar=e=>e*180/Math.PI,dg=e=>e/180*Math.PI;var ku=(e,t)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)],ug=e=>e[0]===0&&e[1]===0,Oe=(e,t,n)=>{let r=dg(t);return!n||ug(n)?ku(e,r):ku(e.map((o,i)=>o-n[i]),r).map((o,i)=>o+n[i])};var fg=e=>[-e[0],-e[1]],ss=(e,t)=>[e[0]+t[0],e[1]+t[1]],mg=(e,t)=>Fe(...e,...t);var Ru=(e,t,n)=>{let r=ss(e,fg(t));return Oe(r,-ar(n))};var pg=(e,t)=>{let[n,r]=e,[[o,i],[a,s]]=t,l=n-o,c=r-i,d=a-o,u=s-i,f=l*d+c*u,m=d*d+u*u,p=-1;m!==0&&(p=f/m);let h,E;p<0?(h=o,E=i):p>1?(h=a,E=s):(h=o+p*d,E=i+p*u);let x=n-h,w=r-E;return Math.sqrt(x*x+w*w)},pi=(e,t,n=or)=>{let r=pg(e,t);return r===0?!0:r<n},ls=(e,t,n=or)=>t.some(r=>pi(e,r,n));var hg=e=>{let[t,n,r,o]=e;return(i,a)=>Math.pow(1-i,3)*o[a]+3*i*Math.pow(1-i,2)*r[a]+3*Math.pow(i,2)*(1-i)*n[a]+t[a]*Math.pow(i,3)},Eg=(e,t=10)=>{let n=hg(e),r=[n(0,0),n(0,1)],o=[],i=0,a=1/t;for(let s=0;s<t;s++)if(i+=a,i<=1){let l=[n(i,0),n(i,1)];o.push([r,l]),r=l}return o},cs=(e,t,n=or)=>ls(e,Eg(t),n),Fu=(e,t,n=or)=>t.some(r=>cs(e,r,n)),ds=(e,t)=>{let n=e[0],r=e[1],o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){let s=t[i][0],l=t[i][1],c=t[a][0],d=t[a][1];(l>r&&d<=r||l<=r&&d>r)&&n<(c-s)*(r-l)/(d-l)+s&&(o=!o)}return o},Ou=(e,t,n=or)=>{let r=!1,o=ir(t);for(let i=0,a=o.length-1;i<a;i++)if(pi(e,[o[i],o[i+1]],n)){r=!0;break}return r};var gg=(e,t)=>{let{angle:n,halfWidth:r,halfHeight:o,center:i}=t,a=r,s=o,[l,c]=Ru(e,i,n),d=Math.abs(l),u=Math.abs(c),f=.707,m=.707;for(let E=0;E<3;E++){let x=a*f,w=s*m,y=(a*a-s*s)*f**3/a,T=(s*s-a*a)*m**3/s,b=x-y,L=w-T,I=d-y,_=u-T,S=Math.hypot(L,b),M=Math.hypot(_,I);f=Math.min(1,Math.max(0,(I*S/M+y)/a)),m=Math.min(1,Math.max(0,(_*S/M+T)/s));let v=Math.hypot(m,f);f/=v,m/=v}let[p,h]=[a*f*Math.sign(l),s*m*Math.sign(c)];return mg([l,c],[p,h])},Nu=(e,t,n=or)=>gg(e,t)<=n,Bu=(e,t)=>{let{center:n,angle:r,halfWidth:o,halfHeight:i}=t,[a,s]=Ru(e,n,r);return a/o*(a/o)+s/i*(s/i)<=1};var Kr=(e,t,n=0)=>{switch(t.type){case"polygon":return Ou(e,t.data,n);case"ellipse":return Nu(e,t.data,n);case"line":return pi(e,t.data,n);case"polyline":return ls(e,t.data,n);case"curve":return cs(e,t.data,n);case"polycurve":return Fu(e,t.data,n);default:throw Error(`shape ${t} is not implemented`)}},hi=(e,t)=>{switch(t.type){case"polygon":return ds(e,t.data);case"line":return!1;case"curve":return!1;case"ellipse":return Bu(e,t.data);case"polyline":{let n=ir(t.data.flat());return ds(e,n)}case"polycurve":return!1;default:throw Error(`shape ${t} is not implemented`)}};g();g();var xg=(e,t)=>{let[n,r,o,i]=t,{x:a,y:s}=za({sceneX:n,sceneY:r},e),{x:l,y:c}=za({sceneX:o,sceneY:i},e);return l-a>e.width||c-s>e.height},wg=({scenePoint:e,viewportDimensions:t,zoom:n})=>({scrollX:t.width/2/n.value-e.x,scrollY:t.height/2/n.value-e.y}),fs=(e,t)=>{if(e=Gu(e),!e.length)return{scrollX:0,scrollY:0};let[n,r,o,i]=Me(e);xg(t,[n,r,o,i])&&([n,r,o,i]=us(e,Or({clientX:t.scrollX,clientY:t.scrollY},t)));let a=(n+o)/2,s=(r+i)/2;return wg({scenePoint:{x:a,y:s},viewportDimensions:{width:t.width,height:t.height},zoom:t.zoom})};g();var yg=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",AT=e=>e!=="image"&&e!=="frame"&&e!=="magicframe",bg=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",vg=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",ms=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="arrow"||e==="line"||e==="diamond"||e==="image",Tg=e=>e==="arrow",ps=(e,t)=>{let n=null;for(let r=e.length-1;r>=0;--r){let o=e[r];if(!o.isDeleted&&t(o)){n=o;break}}return n};g();var Ag=e=>Math.max(Id,Math.min(e,30)),PT=({viewportX:e,viewportY:t,nextZoom:n},r)=>{let o=e-r.offsetLeft,i=t-r.offsetTop,a=r.zoom.value,s=r.scrollX+(o-o/a),l=r.scrollY+(i-i/a),c=-(o-o/n),d=-(i-i/n);return{scrollX:s+c,scrollY:l+d,zoom:{value:n}}};g();var GT={EQUAL:"Equal",MINUS:"Minus",NUM_ADD:"NumpadAdd",NUM_SUBTRACT:"NumpadSubtract",NUM_ZERO:"Numpad0",BRACKET_RIGHT:"BracketRight",BRACKET_LEFT:"BracketLeft",ONE:"Digit1",TWO:"Digit2",THREE:"Digit3",NINE:"Digit9",QUOTE:"Quote",ZERO:"Digit0",SLASH:"Slash",C:"KeyC",D:"KeyD",H:"KeyH",V:"KeyV",Z:"KeyZ",R:"KeyR",S:"KeyS"},Ne={ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",BACKSPACE:"Backspace",ALT:"Alt",CTRL_OR_CMD:Fo?"metaKey":"ctrlKey",DELETE:"Delete",ENTER:"Enter",ESCAPE:"Escape",QUESTION_MARK:"?",SPACE:" ",TAB:"Tab",CHEVRON_LEFT:"<",CHEVRON_RIGHT:">",PERIOD:".",COMMA:",",SUBTRACT:"-",SLASH:"/",A:"a",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",L:"l",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",V:"v",X:"x",Y:"y",Z:"z",K:"k",W:"w",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9"},zT=e=>e===Ne.ARROW_LEFT||e===Ne.ARROW_RIGHT||e===Ne.ARROW_DOWN||e===Ne.ARROW_UP,HT=e=>e.altKey,UT=e=>e.shiftKey,hs=e=>e.shiftKey;var tA=e=>!e[Ne.CTRL_OR_CMD],gs=e=>e.isBindingEnabled,Vu=(e,t)=>{let n=[];return t.forEach(r=>{let o=e.getNonDeletedElement(r);o!=null&&n.push(o)}),n},jr=(e,t,n,r)=>{let o=new Set,i=new Set;zu(e,t,n,"start",o,i,r),zu(e,n,t,"end",o,i,r);let a=Array.from(i).filter(s=>!o.has(s));Vu(it.getScene(e),a).forEach(s=>{F(s,{boundElements:s.boundElements?.filter(l=>l.type!=="arrow"||l.id!==e.id)})})},zu=(e,t,n,r,o,i,a)=>{if(t!=="keep")if(t!=null)(n==null||(n==="keep"?!xs(e,t,r):r==="start"||n.id!==t.id))&&(Es(e,t,r,a),o.add(t.id));else{let s=Lg(e,r);s!=null&&i.add(s)}},nA=(e,t)=>{e.forEach(n=>{Qe(n)?jr(n,gi(n,"start",t),gi(n,"end",t),t.scene.getNonDeletedElementsMap()):qn(n)&&Pg(n,t.scene.getNonDeletedElementsMap(),t)})},Pg=(e,t,n)=>{Zu(e,n).forEach(([r,o])=>jr(r,o==="end"?"keep":e,o==="start"?"keep":e,t))},rA=(e,t,n,r)=>{t.startBoundElement!=null&&Es(e,t.startBoundElement,"start",r.scene.getNonDeletedElementsMap());let o=qr(n,r);o!=null&&!xs(e,o,"end")&&Es(e,o,"end",r.scene.getNonDeletedElementsMap())},Es=(e,t,n,r)=>{F(e,{[n==="start"?"startBinding":"endBinding"]:{elementId:t.id,...Dg(e,t,n,r)}}),X(t.boundElements||[]).has(e.id)||F(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},xs=(e,t,n)=>{let r=e[n==="start"?"endBinding":"startBinding"];return Mg(e,r?.elementId,t)},Mg=(e,t,n)=>t===n.id&&e.points.length<3,oA=(e,t)=>{e.forEach(n=>{Qe(n)&&jr(n,null,null,t)})},Lg=(e,t)=>{let n=t==="start"?"startBinding":"endBinding",r=e[n];return r==null?null:(F(e,{[n]:null}),r.elementId)},qr=(e,t)=>ps(t.scene.getNonDeletedElements(),r=>qn(r,!1)&&Ku(r,e,t)),Dg=(e,t,n,r)=>{let o=n==="start"?-1:1,i=o===-1?0:e.points.length-1,a=i-o,s=q.getPointAtIndexGlobalCoordinates(e,i,r),l=q.getPointAtIndexGlobalCoordinates(e,a,r);return{focus:Hg(t,l,s,r),gap:Math.max(1,Og(t,s,r))}},tn=(e,t,n)=>{let r=(e.boundElements??[]).filter(l=>l.type==="arrow");if(r.length===0)return;let{newSize:o,simultaneouslyUpdated:i}=n??{},a=kg(i),s=it.getScene(e);Vu(s,r.map(l=>l.id)).forEach(l=>{if(!Q(l))return;let c=e;if(!Cg(l,c))return;let d=Uu(c,l.startBinding,o),u=Uu(c,l.endBinding,o);if(a.has(l.id)){F(l,{startBinding:d,endBinding:u});return}Hu(l,"start",d,e,t),Hu(l,"end",u,e,t),Z(l,s.getNonDeletedElementsMap())&&Pn(l,s.getNonDeletedElementsMap(),!1)})},Cg=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,kg=e=>new Set((e||[]).map(t=>t.id)),Hu=(e,t,n,r,o)=>{if(n==null||n.elementId!==r.id&&e.points.length>2)return;let i=it.getScene(e).getElement(n.elementId);if(i==null)return;let a=t==="start"?-1:1,s=a===-1?0:e.points.length-1,l=s-a,c=q.getPointAtIndexGlobalCoordinates(e,l,o),d=Ug(i,n.focus,c,o),u;if(n.gap===0)u=d;else{let f=$g(i,c,d,n.gap,o);f.length===0?u=d:u=f[0]}q.movePoints(e,[{index:s,point:q.pointFromAbsoluteCoords(e,u,o)}],{[t==="start"?"startBinding":"endBinding"]:n})},Uu=(e,t,n)=>{if(t==null||n==null)return t;let{gap:r,focus:o,elementId:i}=t,{width:a,height:s}=n,{width:l,height:c}=e,d=Math.max(1,Math.min(ju(e,a,s),r*(a<s?a/l:s/c)));return{elementId:i,gap:d,focus:o}},iA=(e,t)=>{let n=new Set(e.map(({id:r})=>r));return e.flatMap(r=>Qe(r,!1)?Rg(r,t).filter(o=>!n.has(o.id)):qn(r,!1)?Zu(r,t).filter(o=>!n.has(o[0].id)):[])},Rg=(e,t)=>[gi(e,"start",t),gi(e,"end",t)].filter(n=>n!=null),gi=(e,t,n)=>qr(Xu(e,t,n.scene.getNonDeletedElementsMap()),n),Xu=(e,t,n)=>{let r=t==="start"?0:-1;return jn(q.getPointAtIndexGlobalCoordinates(e,r,n))},Zu=(e,t)=>{let n=it.getScene(e);return n.getNonDeletedElements().map(r=>{if(!Qe(r,!1))return null;let o=$u(r,"start",e,n.getNonDeletedElementsMap(),t),i=$u(r,"end",e,n.getNonDeletedElementsMap(),t);return!o&&!i?null:[r,o&&i?"both":o?"start":"end",e]}).filter(r=>r!=null)},$u=(e,t,n,r,o)=>e[t==="start"?"startBinding":"endBinding"]==null&&!xs(e,n,t)&&Ku(n,Xu(e,t,r),o),aA=(e,t,n,r)=>{let o=new Set,i=new Set,a=r==="duplicatesServeAsOld";t.forEach(s=>{let{boundElements:l}=s;if(l!=null&&l.length>0&&(l.forEach(c=>{a&&!n.has(c.id)&&o.add(c.id)}),i.add(n.get(s.id))),Qe(s)){if(s.startBinding!=null){let{elementId:c}=s.startBinding;a&&!n.has(c)&&i.add(c)}if(s.endBinding!=null){let{elementId:c}=s.endBinding;a&&!n.has(c)&&i.add(c)}(s.startBinding!=null||s.endBinding!=null)&&o.add(n.get(s.id))}}),e.filter(({id:s})=>o.has(s)).forEach(s=>{let{startBinding:l,endBinding:c}=s;F(s,{startBinding:Yu(l,n),endBinding:Yu(c,n)})}),e.filter(({id:s})=>i.has(s)).forEach(s=>{let{boundElements:l}=s;l!=null&&l.length>0&&F(s,{boundElements:l.map(c=>n.has(c.id)?{id:n.get(c.id),type:c.type}:c)})})},Yu=(e,t)=>{if(e==null)return null;let{elementId:n,focus:r,gap:o}=e;return{focus:r,gap:o,elementId:t.get(n)??n}},sA=(e,t)=>{let n=new Set(t.map(o=>o.id)),r=new Set;t.forEach(o=>{qn(o)?o.boundElements?.forEach(i=>{n.has(i.id)||r.add(i.id)}):Qe(o)&&(o.startBinding&&r.add(o.startBinding.elementId),o.endBinding&&r.add(o.endBinding.elementId))}),e.filter(({id:o})=>r.has(o)).forEach(o=>{qn(o)?F(o,{boundElements:Fg(o.boundElements,n)}):Qe(o)&&F(o,{startBinding:Wu(o.startBinding,n),endBinding:Wu(o.endBinding,n)})})},Wu=(e,t)=>e==null||t.has(e.elementId)?null:e,Fg=(e,t)=>e?e.filter(n=>!t.has(n.id)):null,Ku=(e,{x:t,y:n},r)=>{let o=ju(e,e.width,e.height),i=r.getElementShape(e);return Kr([t,n],i,o)},ju=(e,t,n)=>{let o=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,n);return Math.max(16,Math.min(.25*o,32))},Og=(e,t,n)=>{switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return Ng(e,t,n);case"diamond":return Bg(e,t,n);case"ellipse":return Gg(e,t,n)}},Ng=(e,t,n)=>{let[,r,o,i]=ws(e,t,n);return Math.max(en(r,mi(0,1,-i)),en(r,mi(1,0,-o)))},Bg=(e,t,n)=>{let[,r,o,i]=ws(e,t,n),a=mi(i,o,-i*o);return en(r,a)},Gg=(e,t,n)=>{let[r,o]=zg(e,t,n);return-Au(o)*en(r,o)},zg=(e,t,n)=>{let[,r,o,i]=ws(e,t,n),[a,s]=In(r),l=.707,c=.707,d=o,u=i;[0,1,2,3].forEach(p=>{let h=d*l,E=u*c,x=(d*d-u*u)*l**3/d,w=(u*u-d*d)*c**3/u,y=h-x,T=E-w,b=a-x,L=s-w,I=Math.hypot(T,y),_=Math.hypot(L,b);l=Math.min(1,Math.max(0,(b*I/_+x)/d)),c=Math.min(1,Math.max(0,(L*I/_+w)/u));let S=Math.hypot(c,l);l/=S,c/=S});let f=we(d*l,u*c),m=Tu(r,f);return[r,m]},ws=(e,t,n)=>{let r=Sn(t),[o,i,a,s]=B(e,n),l=bs(o,i,a,s),c=as(l,e.angle),d=rt(c,r),u=Qa(d,is(l)),f=Su(u),m=gu(e.x,e.y),p=Qa(d,m),h=(a-o)/2,E=(s-i)/2;return[p,f,h,E]},ys=(e,t)=>{let[n,r,o,i]=B(e,t),a=bs(n,r,o,i),s=as(a,e.angle),l=nr(Lu(is(a)));return Cu(s,l)},bs=(e,t,n,r)=>we((e+n)/2,(t+r)/2),Hg=(e,t,n,r)=>{let o=ys(e,r),i=rt(o,Sn(t)),a=rt(o,Sn(n)),s=rr(i,a),l=e.height/e.width,c=e.width/2,d=e.height/2,u=s[2],f=s[3],m=s[1],p=Math.abs(f),h=Math.abs(u),E;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":E=m/(c*(h+l*p));break;case"diamond":E=p<h?m/(h*c):m/(p*d);break;case"ellipse":E=m/(c*Math.sqrt(u**2+l**2*f**2));break}return E||0},Ug=(e,t,n,r)=>{if(t===0){let[l,c,d,u]=B(e,r),f=bs(l,c,d,u);return In(f)}let o=ys(e,r),i=rt(o,Sn(n)),a=nr(o),s;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":s=jg(e,t,i);break;case"ellipse":s=Kg(e,t,i);break}return In(rt(a,s))},$g=(e,t,n,r=0,o)=>{let i=ys(e,o),a=rt(i,Sn(t)),s=rt(i,Sn(n)),l=rr(a,s),c=nr(i);return Yg(e,l,a,r).map(u=>In(rt(c,u)))},Yg=(e,t,n,r=0)=>{let o;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":let a=qu(e);o=a.flatMap((s,l)=>{let c=[s,a[(l+1)%4]];return Wg(t,Vg(c,r))}).concat(a.flatMap(s=>Zg(s,r,t)));break;case"ellipse":o=Xg(e,r,t);break}if(o.length<2)return[];let i=o.sort((a,s)=>os(a,n)-os(s,n));return[i[0],i[i.length-1]]},qu=(e,t=1)=>{let n=t*e.width/2,r=t*e.height/2;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return[we(n,r),we(n,-r),we(-n,-r),we(-n,r)];case"diamond":return[we(0,r),we(n,0),we(0,-r),we(-n,0)]}},Wg=(e,t)=>{let[n,r]=t,o=en(n,e),i=en(r,e);return o*i>=0?[]:[Iu(e,rr(n,r))]},Vg=(e,t)=>{let[n,r]=e,o=Du(Pu(n,r),t);return[rt(o,n),rt(o,r)]},Xg=(e,t,n)=>{let r=e.width/2+t,o=e.height/2+t,i=n[2],a=n[3],s=n[1],l=r*r*i*i+o*o*a*a,c=l-s*s;if(l===0||c<=0)return[];let d=Math.sqrt(c),u=-r*r*i*s,f=-o*o*a*s;return[we((u+r*o*a*d)/l,(f-r*o*i*d)/l),we((u-r*o*a*d)/l,(f+r*o*i*d)/l)]},Zg=(e,t,n)=>{if(t===0)return en(n,e)===0?[e]:[];let r=n[2],o=n[3],i=n[1],[a,s]=In(e),l=t,c=r*r+o*o,d=l*l*c-(r*a+o*s+i)**2;if(c===0||d<=0)return[];let u=Math.sqrt(d),f=a*o*o-s*r*o-r*i,m=s*r*r-a*r*o-o*i;return[we((f+o*u)/c,(m-r*u)/c),we((f-o*u)/c,(m+r*u)/c)]},Kg=(e,t,n)=>{let r=Math.abs(t),o=e.width*r/2,i=e.height*r/2,a=Math.sign(t),[s,l]=In(n),c=l===0?1e-4:l,d=s**2*i**2+c**2*o**2,u=(-s*i**2+a*c*Math.sqrt(Math.max(0,d-o**2*i**2)))/d,f=(-u*s-1)/c;f===0&&(f=(Object.is(f,-0)?-1:1)*.01);let m=-(o**2*u)/(f**2*i**2+u**2*o**2);return we(m,(-u*m-1)/f)},jg=(e,t,n)=>{let r=Math.abs(t),o=Math.sign(t),i=qu(e,r),a=0,s=null;return i.forEach(l=>{let c=o*rr(n,l)[1];c>a&&(a=c,s=l)}),s};g();var ie=class e{static rg=new et;static cache=new WeakMap;static get=t=>e.cache.get(t);static set=(t,n)=>e.cache.set(t,n);static delete=t=>e.cache.delete(t);static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,n)=>{let r=n?.isExporting?void 0:e.get(t);if(r!==void 0)return r;xi.delete(t);let o=Ju(t,e.rg,n||{isExporting:!1,canvasBackgroundColor:G.white,embedsValidationStatus:null});return e.cache.set(t,o),o}};var Ft={version:null,points:[],zoom:null},q=class e{elementId;selectedPointsIndices;pointerDownState;isDragging;lastUncommittedPoint;pointerOffset;startBindingElement;endBindingElement;hoverPointIndex;segmentMidPointHoveredCoords;constructor(t){this.elementId=t.id,e.normalizePoints(t),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null}static POINT_HANDLE_SIZE=10;static getElement(t,n){let r=n.get(t);return r||null}static handleBoxSelection(t,n,r,o){if(!n.editingLinearElement||n.draggingElement?.type!=="selection")return!1;let{editingLinearElement:i}=n,{selectedPointsIndices:a,elementId:s}=i,l=e.getElement(s,o);if(!l)return!1;let[c,d,u,f]=B(n.draggingElement,o),p=e.getPointsGlobalCoordinates(l,o).reduce((h,E,x)=>((E[0]>=c&&E[0]<=u&&E[1]>=d&&E[1]<=f||t.shiftKey&&a?.includes(x))&&h.push(x),h),[]);r({editingLinearElement:{...i,selectedPointsIndices:p.length?p:null}})}static handlePointDragging(t,n,r,o,i,a,s){if(!a)return!1;let{selectedPointsIndices:l,elementId:c}=a,d=e.getElement(c,s);if(!d)return!1;let u=d.points[a.pointerDownState.lastClickedPoint];if(l&&u){if(hs(t)&&l.length===1&&d.points.length>1){let m=l[0],p=d.points[m===0?1:m-1],[h,E]=e._getShiftLockedDelta(d,s,p,[r,o],t[Ne.CTRL_OR_CMD]?null:n.gridSize);e.movePoints(d,[{index:m,point:[h+p[0],E+p[1]],isDragging:m===a.pointerDownState.lastClickedPoint}])}else{let m=e.createPointAt(d,s,r-a.pointerOffset.x,o-a.pointerOffset.y,t[Ne.CTRL_OR_CMD]?null:n.gridSize),p=m[0]-u[0],h=m[1]-u[1];e.movePoints(d,l.map(E=>{let x=E===a.pointerDownState.lastClickedPoint?e.createPointAt(d,s,r-a.pointerOffset.x,o-a.pointerOffset.y,t[Ne.CTRL_OR_CMD]?null:n.gridSize):[d.points[E][0]+p,d.points[E][1]+h];return{index:E,point:x,isDragging:E===a.pointerDownState.lastClickedPoint}}))}if(Z(d,s)&&Pn(d,s,!1),Qe(d,!1)){let m=[];l[0]===0&&m.push(jn(e.getPointGlobalCoordinates(d,d.points[0],s)));let h=l[l.length-1];h===d.points.length-1&&m.push(jn(e.getPointGlobalCoordinates(d,d.points[h],s))),m.length&&i(d,m)}return!0}return!1}static handlePointerUp(t,n,r,o){let i=o.scene.getNonDeletedElementsMap(),{elementId:a,selectedPointsIndices:s,isDragging:l,pointerDownState:c}=n,d=e.getElement(a,i);if(!d)return n;let u={};if(l&&s){for(let f of s)if(f===0||f===d.points.length-1){vt(d.points,r.zoom.value)&&e.movePoints(d,[{index:f,point:f===0?d.points[d.points.length-1]:d.points[0]}]);let m=gs(r)?qr(jn(e.getPointAtIndexGlobalCoordinates(d,f,i)),o):null;u[f===0?"startBindingElement":"endBindingElement"]=m}}return{...n,...u,selectedPointsIndices:l||t.shiftKey?!l&&t.shiftKey&&c.prevSelectedPointsIndices?.includes(c.lastClickedPoint)?s&&s.filter(f=>f!==c.lastClickedPoint):s:s?.includes(c.lastClickedPoint)?[c.lastClickedPoint]:s,isDragging:!1,pointerOffset:{x:0,y:0}}}static getEditorMidPoints=(t,n,r)=>{let o=Z(t,n);return!r.editingLinearElement&&t.points.length>2&&!o?[]:(Ft.version===t.version&&Ft.zoom===r.zoom.value||e.updateEditorMidPointsCache(t,n,r),Ft.points)};static updateEditorMidPointsCache=(t,n,r)=>{let o=e.getPointsGlobalCoordinates(t,n),i=0,a=[];for(;i<o.length-1;){if(e.isSegmentTooShort(t,t.points[i],t.points[i+1],r.zoom)){a.push(null),i++;continue}let s=e.getSegmentMidPoint(t,o[i],o[i+1],i+1,n);a.push(s),i++}Ft.points=a,Ft.version=t.version,Ft.zoom=r.zoom.value};static getSegmentMidpointHitCoords=(t,n,r,o)=>{let{elementId:i}=t,a=e.getElement(i,o);if(!a||e.getPointIndexUnderCursor(a,o,r.zoom,n.x,n.y)>=0||e.getPointsGlobalCoordinates(a,o).length>=3&&!r.editingLinearElement)return null;let c=e.POINT_HANDLE_SIZE/r.zoom.value,d=t.segmentMidPointHoveredCoords;if(d&&Fe(d[0],d[1],n.x,n.y)<=c)return d;let u=0,f=e.getEditorMidPoints(a,o,r);for(;u<f.length;){if(f[u]!==null&&Fe(f[u][0],f[u][1],n.x,n.y)<=c)return f[u];u++}return null};static isSegmentTooShort(t,n,r,o){let i=Fe(n[0],n[1],r[0],r[1]);return t.points.length>2&&t.roundness&&(i=Qu(t,r)),i*o.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,n,r,o,i){let a=Jr(n,r);if(t.points.length>2&&t.roundness){let s=vs(t,t.points[o]);if(s){let l=ef(t,t.points[o],.5),[c,d]=Ts(s[0],s[1],s[2],s[3],l);a=e.getPointGlobalCoordinates(t,[c,d],i)}}return a}static getSegmentMidPointIndex(t,n,r,o){let i=e.getElement(t.elementId,o);if(!i)return-1;let a=e.getEditorMidPoints(i,o,n),s=0;for(;s<a.length;){if(e.arePointsEqual(r,a[s]))return s+1;s++}return-1}static handlePointerDown(t,n,r,o,i,a){let s=a.scene.getNonDeletedElementsMap(),l={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!i)return l;let{elementId:c}=i,d=e.getElement(c,s);if(!d)return l;let u=e.getSegmentMidpointHitCoords(i,o,n,s),f=null;if(u&&(f=e.getSegmentMidPointIndex(i,n,u,s)),t.altKey&&n.editingLinearElement)return i.lastUncommittedPoint==null&&(F(d,{points:[...d.points,e.createPointAt(d,s,o.x,o.y,t[Ne.CTRL_OR_CMD]?null:n.gridSize)]}),l.didAddPoint=!0),r.resumeRecording(),l.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:-1,origin:{x:o.x,y:o.y},segmentMidpoint:{value:u,index:f,added:!1}},selectedPointsIndices:[d.points.length-1],lastUncommittedPoint:null,endBindingElement:qr(o,a)},l.didAddPoint=!0,l;let m=e.getPointIndexUnderCursor(d,s,n.zoom,o.x,o.y);if(m>=0||u)l.hitElement=d;else{let{startBindingElement:L,endBindingElement:I}=i;gs(n)&&Qe(d)&&jr(d,L,I,s)}let[p,h,E,x]=B(d,s),w=(p+E)/2,y=(h+x)/2,T=m>-1&&H(d.x+d.points[m][0],d.y+d.points[m][1],w,y,d.angle),b=m>-1||t.shiftKey?t.shiftKey||i.selectedPointsIndices?.includes(m)?qg([...i.selectedPointsIndices||[],m]):[m]:null;return l.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:m,origin:{x:o.x,y:o.y},segmentMidpoint:{value:u,index:f,added:!1}},selectedPointsIndices:b,pointerOffset:T?{x:o.x-T[0],y:o.y-T[1]}:{x:0,y:0}},l}static arePointsEqual(t,n){return!t&&!n?!0:!t||!n?!1:As(t,n)}static handlePointerMove(t,n,r,o,i){if(!o.editingLinearElement)return null;let{elementId:a,lastUncommittedPoint:s}=o.editingLinearElement,l=e.getElement(a,i);if(!l)return o.editingLinearElement;let{points:c}=l,d=c[c.length-1];if(!t.altKey)return d===s&&e.deletePoints(l,[c.length-1]),{...o.editingLinearElement,lastUncommittedPoint:null};let u;if(hs(t)&&c.length>=2){let f=c[c.length-2],[m,p]=e._getShiftLockedDelta(l,i,f,[n,r],t[Ne.CTRL_OR_CMD]?null:o.gridSize);u=[m+f[0],p+f[1]]}else u=e.createPointAt(l,i,n-o.editingLinearElement.pointerOffset.x,r-o.editingLinearElement.pointerOffset.y,t[Ne.CTRL_OR_CMD]?null:o.gridSize);return d===s?e.movePoints(l,[{index:l.points.length-1,point:u}]):e.addPoints(l,o,[{point:u}]),{...o.editingLinearElement,lastUncommittedPoint:l.points[l.points.length-1]}}static getPointGlobalCoordinates(t,n,r){let[o,i,a,s]=B(t,r),l=(o+a)/2,c=(i+s)/2,{x:d,y:u}=t;return[d,u]=H(d+n[0],u+n[1],l,c,t.angle),[d,u]}static getPointsGlobalCoordinates(t,n){let[r,o,i,a]=B(t,n),s=(r+i)/2,l=(o+a)/2;return t.points.map(c=>{let{x:d,y:u}=t;return[d,u]=H(d+c[0],u+c[1],s,l,t.angle),[d,u]})}static getPointAtIndexGlobalCoordinates(t,n,r){let o=n<0?t.points.length+n:n,[i,a,s,l]=B(t,r),c=(i+s)/2,d=(a+l)/2,u=t.points[o],{x:f,y:m}=t;return u?H(f+u[0],m+u[1],c,d,t.angle):H(f,m,c,d,t.angle)}static pointFromAbsoluteCoords(t,n,r){let[o,i,a,s]=B(t,r),l=(o+a)/2,c=(i+s)/2,[d,u]=H(n[0],n[1],l,c,-t.angle);return[d-t.x,u-t.y]}static getPointIndexUnderCursor(t,n,r,o,i){let a=e.getPointsGlobalCoordinates(t,n),s=a.length;for(;--s>-1;){let l=a[s];if(Fe(o,i,l[0],l[1])*r.value<e.POINT_HANDLE_SIZE+1)return s}return-1}static createPointAt(t,n,r,o,i){let a=Qr(r,o,i),[s,l,c,d]=B(t,n),u=(s+c)/2,f=(l+d)/2,[m,p]=H(a[0],a[1],u,f,-t.angle);return[m-t.x,p-t.y]}static getNormalizedPoints(t){let{points:n}=t,r=n[0][0],o=n[0][1];return{points:n.map((i,a)=>[i[0]-r,i[1]-o]),x:t.x+r,y:t.y+o}}static normalizePoints(t){F(t,e.getNormalizedPoints(t))}static duplicateSelectedPoints(t,n){if(!t.editingLinearElement)return!1;let{selectedPointsIndices:r,elementId:o}=t.editingLinearElement,i=e.getElement(o,n);if(!i||r===null)return!1;let{points:a}=i,s=[],l=!1,c=-1,d=a.reduce((u,f,m)=>{if(++c,u.push(f),r.includes(m)){let h=a[m+1];h||(l=!0),u.push(h?[(f[0]+h[0])/2,(f[1]+h[1])/2]:[f[0],f[1]]),s.push(c+1),++c}return u},[]);if(F(i,{points:d}),l){let u=i.points[i.points.length-1];e.movePoints(i,[{index:i.points.length-1,point:[u[0]+30,u[1]+30]}])}return{appState:{...t,editingLinearElement:{...t.editingLinearElement,selectedPointsIndices:s}}}}static deletePoints(t,n){let r=0,o=0;if(n.includes(0)){let s=t.points.find((l,c)=>!n.includes(c));s&&(r=s[0],o=s[1])}let a=t.points.reduce((s,l,c)=>(n.includes(c)||s.push(s.length?[l[0]-r,l[1]-o]:[0,0]),s),[]);e._updatePoints(t,a,r,o)}static addPoints(t,n,r){let a=[...t.points,...r.map(s=>s.point)];e._updatePoints(t,a,0,0)}static movePoints(t,n,r){let{points:o}=t,i=0,a=0,s=n.find(({index:c})=>c===0);s&&(i=s.point[0]+o[s.index][0],a=s.point[1]+o[s.index][1]);let l=o.map((c,d)=>{let u=n.find(f=>f.index===d);if(u){if(s)return c;let f=u.point[0]-o[u.index][0],m=u.point[1]-o[u.index][1];return[c[0]+f,c[1]+m]}return i||a?[c[0]-i,c[1]-a]:c});e._updatePoints(t,l,i,a,r)}static shouldAddMidpoint(t,n,r,o){if(!e.getElement(t.elementId,o))return!1;let{segmentMidpoint:a}=t.pointerDownState;if(a.added||a.value===null||a.index===null||t.pointerDownState.origin===null)return!1;let s=t.pointerDownState.origin,l=Fe(s.x,s.y,n.x,n.y);return!(!r.editingLinearElement&&l<Td/r.zoom.value)}static addMidpoint(t,n,r,o,i){let a=e.getElement(t.elementId,i);if(!a)return;let{segmentMidpoint:s}=t.pointerDownState,l={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,i,n.x,n.y,o?r.gridSize:null),d=[...a.points.slice(0,s.index),c,...a.points.slice(s.index)];return F(a,{points:d}),l.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:s.index},l.selectedPointsIndices=[s.index],l}static _updatePoints(t,n,r,o,i){let a=sr(t,n),s=sr(t,t.points),l=(a[0]+a[2])/2,c=(a[1]+a[3])/2,d=(s[0]+s[2])/2,u=(s[1]+s[3])/2,f=d-l,m=u-c,p=H(r,o,f,m,t.angle);F(t,{...i,points:n,x:t.x+p[0],y:t.y+p[1]})}static _getShiftLockedDelta(t,n,r,o,i){let a=e.getPointGlobalCoordinates(t,r,n),[s,l]=Qr(o[0],o[1],i),{width:c,height:d}=_s(a[0],a[1],s,l);return me([c,d],[0,0],-t.angle)}static getBoundTextElementPosition=(t,n,r)=>{let o=e.getPointsGlobalCoordinates(t,r);o.length<2&&F(n,{isDeleted:!0});let i=0,a=0;if(t.points.length%2===1){let s=Math.floor(t.points.length/2),l=e.getPointGlobalCoordinates(t,t.points[s],r);i=l[0]-n.width/2,a=l[1]-n.height/2}else{let s=t.points.length/2-1,l=Ft.points[s];t.points.length===2&&(l=Jr(o[0],o[1])),(!l||Ft.version!==t.version)&&(l=e.getSegmentMidPoint(t,o[s],o[s+1],s+1,r)),i=l[0]-n.width/2,a=l[1]-n.height/2}return{x:i,y:a}};static getMinMaxXYWithBoundText=(t,n,r,o)=>{let[i,a,s,l]=r,c=(i+s)/2,d=(a+l)/2,{x:u,y:f}=e.getBoundTextElementPosition(t,o,n),m=u+o.width,p=f+o.height,h=me([i,a],[c,d],t.angle),E=me([s,a],[c,d],t.angle),x=me([u,f],[c,d],-t.angle),w=me([m,f],[c,d],-t.angle),y=me([u,p],[c,d],-t.angle),T=me([m,p],[c,d],-t.angle);return h[0]<E[0]&&h[1]>=E[1]?(i=Math.min(i,y[0]),s=Math.max(s,Math.max(w[0],T[0])),a=Math.min(a,x[1]),l=Math.max(l,T[1])):h[0]>=E[0]&&h[1]>E[1]?(i=Math.min(i,T[0]),s=Math.max(s,Math.max(x[0],w[0])),a=Math.min(a,y[1]),l=Math.max(l,w[1])):h[0]>=E[0]?(i=Math.min(i,w[0]),s=Math.max(s,y[0]),a=Math.min(a,T[1]),l=Math.max(l,x[1])):h[1]<=E[1]&&(i=Math.min(i,Math.min(w[0],x[0])),s=Math.max(s,T[0]),a=Math.min(a,w[1]),l=Math.max(l,y[1])),[i,a,s,l,c,d]};static getElementAbsoluteCoords=(t,n,r=!1)=>{let o,i,a,s,l;if(t.points.length<2||!ie.get(t)){let{minX:f,minY:m,maxX:p,maxY:h}=t.points.reduce((E,[x,w])=>(E.minY=Math.min(E.minY,w),E.minX=Math.min(E.minX,x),E.maxX=Math.max(E.maxX,x),E.maxY=Math.max(E.maxY,w),E),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});i=f+t.x,a=m+t.y,s=p+t.x,l=h+t.y}else{let f=ie.generateElementShape(t,null),m=nn(f[0]),[p,h,E,x]=eo(m);i=p+t.x,a=h+t.y,s=E+t.x,l=x+t.y}let c=(i+s)/2,d=(a+l)/2;if(o=[i,a,s,l,c,d],!r)return o;let u=Z(t,n);return u&&(o=e.getMinMaxXYWithBoundText(t,n,[i,a,s,l],u)),o}},qg=e=>{let t=[...new Set(e.filter(n=>n!==null&&n!==-1))];return t=t.sort((n,r)=>n-r),t.length?t:null};g();var to={},tf=(e,t)=>{let n=to[e]||(to[e]={height:t});return n.height=t,n},nf=e=>{to[e]&&delete to[e]},LA=e=>to[e]?.height??null;var Ms=e=>Xd(e).replace(/\t/g," "),Ls=e=>Ms(e).split(`
|
|
3
|
+
`),Jg=(e,t,n)=>{let r,o={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height};o.text=e.text,t&&(r=at(t,e),o.text=cr(e.originalText,ue(e),r));let i=Mn(o.text,ue(e),e.lineHeight);if(o.width=i.width,o.height=i.height,t){let a=ro(t,e),s=at(t,e);if(!ee(t)&&i.height>a){let u=Ps(i.height,t.type);F(t,{height:u}),tf(t.id,u)}if(i.width>s){let u=Ps(i.width,t.type);F(t,{width:u})}let l={...e,...o},{x:c,y:d}=of(t,l,n);o.x=c,o.y=d}F(e,o)},zA=(e,t,n)=>{let r=X(e);t.forEach(o=>{let i=n.get(o.id),a=Ln(o);if(a){let s=n.get(a);if(s){let l=r.get(i);l&&F(l,{boundElements:(o.boundElements||[]).filter(d=>d.id!==s&&d.id!==a).concat({type:"text",id:s})});let c=r.get(s);c&&Y(c)&&F(c,{containerId:l?i:null})}}})},Pn=(e,t,n,r=!1)=>{if(!Ln(e))return;nf(e.id);let i=Z(e,t);if(i&&i.text){if(!e)return;let a=i.text,s=i.height,l=i.width,c=at(e,i),d=ro(e,i),u=e.height;if(r||n!=="n"&&n!=="s"){a&&(a=cr(i.originalText,ue(i),c));let f=Mn(a,ue(i),i.lineHeight);s=f.height,l=f.width}if(s>d){u=Ps(s,e.type);let f=u-e.height,m=!ee(e)&&(n==="ne"||n==="nw"||n==="n")?e.y-f:e.y;F(e,{height:u,y:m})}F(i,{text:a,width:l,height:s}),ee(e)||F(i,of(e,i,t))}},of=(e,t,n)=>{if(ee(e))return q.getBoundTextElementPosition(e,t,n);let r=Cs(e),o=ro(e,t),i=at(e,t),a,s;return t.verticalAlign===Lt.TOP?s=r.y:t.verticalAlign===Lt.BOTTOM?s=r.y+(o-t.height):s=r.y+(o/2-t.height/2),t.textAlign===Na.LEFT?a=r.x:t.textAlign===Na.RIGHT?a=r.x+(i-t.width):a=r.x+(i/2-t.width/2),{x:a,y:s}},Mn=(e,t,n)=>{e=e.split(`
|
|
4
|
+
`).map(a=>a||" ").join(`
|
|
5
|
+
`);let r=parseFloat(t),o=Qg(e,r,n);return{width:Ds(e,t),height:o}},af=e=>{let t=Ls(e.text).length;return e.height/t/e.fontSize},lr=(e,t)=>e*t,wi=(e,t,n)=>{let{unitsPerEm:r,ascender:o,descender:i}=rf[e]||rf[ce.Helvetica],a=t/r,s=n-a*o+a*i;return a*o+s},sf=(e,t)=>lr(e,t)+de*2,Ss,no=(e,t)=>{Ss||(Ss=document.createElement("canvas"));let n=Ss.getContext("2d");n.font=t;let r=n.measureText(e).width;return kt()?r*10:r},Ds=(e,t)=>{let n=Ls(e),r=0;return n.forEach(o=>{r=Math.max(r,no(o,t))}),r},Qg=(e,t,n)=>{let r=Ls(e).length;return lr(t,n)*r},ex=e=>{let t=e.split("-");return t.length>1&&t.forEach((n,r)=>{r!==t.length-1&&(t[r]=n+="-")}),t.join(" ").split(" ")},cr=(e,t,n)=>{if(!Number.isFinite(n)||n<0)return e;let r=[],o=e.split(`
|
|
6
|
+
`),i=no(" ",t),a="",s=0,l=d=>{d.trim()&&r.push(d)},c=()=>{a="",s=0};return o.forEach(d=>{if(Ds(d,t)<=n){r.push(d);return}let f=ex(d);c();let m=0;for(;m<f.length;){let p=no(f[m],t);if(p===n)l(f[m]),m++;else if(p>n){for(l(a),c();f[m].length>0;){let h=String.fromCodePoint(f[m].codePointAt(0)),E=lf.calculate(h,t);s+=E,f[m]=f[m].slice(h.length),s>=n?(l(a),a=h,s=E):a+=h}s+i>=n?(l(a),c()):a.endsWith("-")||(a+=" ",s+=i),m++}else for(;s<n&&m<f.length;){let h=f[m];if(s=no(a+h,t),s>n){l(a),c();break}m++;let E=!h.endsWith("-");if(a+=h,E&&(a+=" "),s+i>=n){E?r.push(a.slice(0,-1)):r.push(a),c();break}}}a.slice(-1)===" "&&(a=a.slice(0,-1),l(a))}),r.join(`
|
|
7
|
+
`)},lf=(()=>{let e={};return{calculate:(r,o)=>{let i=r.charCodeAt(0);if(e[o]||(e[o]=[]),!e[o][i]){let a=no(r,o);e[o][i]=a}return e[o][i]},getCache:r=>e[r]}})(),cf="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),df=(e,t)=>{let n=tx(e);return n===0?Mn(cf.split("").join(`
|
|
8
|
+
`),e,t).width+de*2:n+de*2};var tx=e=>{let t=lf.getCache(e);if(!t)return 0;let n=t.filter(r=>r!==void 0);return Math.max(...n)};var Ln=e=>e?.boundElements?.length&&e?.boundElements?.filter(t=>t.type==="text")[0]?.id||null,Z=(e,t)=>{if(!e)return null;let n=Ln(e);return n&&t.get(n)||null},Ae=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,HA=(e,t,n)=>{if(!ee(e))return{x:e.x+e.width/2,y:e.y+e.height/2};let r=q.getPointsGlobalCoordinates(e,n);if(r.length%2===1){let a=Math.floor(e.points.length/2),s=q.getPointGlobalCoordinates(e,e.points[a],n);return{x:s[0],y:s[1]}}let o=e.points.length/2-1,i=q.getEditorMidPoints(e,n,t)[o];return i||(i=q.getSegmentMidPoint(e,r[o],r[o+1],o+1,n)),{x:i[0],y:i[1]}},Cs=e=>{let t=de,n=de;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}},UA=(e,t)=>!t||ee(t)?e.angle:t.angle;var $A=(e,t)=>e.some(n=>{if(Ye(n)){let r=Ae(n,t);return!ee(r)}return!1}),YA=(e,t)=>e.some(n=>{if(Ye(n)){let r=Ae(n,t);return!ee(r)}return Y(n)}),nx=new Set(["rectangle","ellipse","diamond","arrow"]),WA=e=>nx.has(e.type),Ps=(e,t)=>{e=Math.ceil(e);let n=de*2;return t==="ellipse"?Math.round((e+n)/Math.sqrt(2)*2):t==="arrow"?e+n*8:t==="diamond"?2*(e+n):e+n},at=(e,t)=>{let{width:n}=e;if(ee(e)){let r=(t?.fontSize??xt)*Ld;return Math.max(Md*n,r)}return e.type==="ellipse"?Math.round(n/2*Math.sqrt(2))-de*2:e.type==="diamond"?Math.round(n/2)-de*2:n-de*2},ro=(e,t)=>{let{height:n}=e;return ee(e)?n-de*8*2<=0?t.height:n:e.type==="ellipse"?Math.round(n/2*Math.sqrt(2))-de*2:e.type==="diamond"?Math.round(n/2)-de*2:n-de*2},VA=()=>Ds(cf,ue({fontSize:xt,fontFamily:qe}))>0,Is={[ce.Virgil]:1.25,[ce.Helvetica]:1.15,[ce.Cascadia]:1.2},rf={[ce.Virgil]:{unitsPerEm:1e3,ascender:886,descender:-374},[ce.Helvetica]:{unitsPerEm:2048,ascender:1577,descender:-471},[ce.Cascadia]:{unitsPerEm:2048,ascender:1977,descender:-480},[ce.Assistant]:{unitsPerEm:1e3,ascender:1021,descender:-287}},yi=e=>e in Is?Is[e]:Is[qe];var ks="invert(100%) hue-rotate(180deg) saturate(1.25)",rx=Dt(),hf=(e,t)=>wt(e)&&!t.imageCache.has(e.fileId),Ef=(e,t,n)=>n.theme===Ce.DARK&&wt(e)&&!hf(e,t)&&t.imageCache.get(e.fileId)?.mimeType!==R.svg,vi=e=>e.type==="freedraw"?e.strokeWidth*12:20,ox=(e,t,n)=>{let r=(t?.opacity??100)*e.opacity/1e4;return(n.has(e.id)||t&&n.has(t.id))&&(r*=Dd/100),r},ix=(e,t,n)=>{let i=vi(e),[a,s,l,c]=B(e,t),d=Q(e)||fe(e)?$e(a,l):e.width,u=Q(e)||fe(e)?$e(s,c):e.height,f=d*window.devicePixelRatio+i*2,m=u*window.devicePixelRatio+i*2,p=n.value;return(f*p>32767||m*p>32767)&&(p=Math.min(32767/f,32767/m)),f*m*p*p>16777216&&(p=Math.sqrt(16777216/(f*m))),f=Math.floor(f*p),m=Math.floor(m*p),{width:f,height:m,scale:p}},ax=(e,t,n,r,o)=>{let i=document.createElement("canvas"),a=i.getContext("2d"),s=vi(e),{width:l,height:c,scale:d}=ix(e,t,n);i.width=l,i.height=c;let u=0,f=0;if(Q(e)||fe(e)){let[p,h]=B(e,t);u=e.x>p?$e(e.x,p)*window.devicePixelRatio*d:0,f=e.y>h?$e(e.y,h)*window.devicePixelRatio*d:0,a.translate(u,f)}a.save(),a.translate(s*d,s*d),a.scale(window.devicePixelRatio*d,window.devicePixelRatio*d);let m=bt.canvas(i);return Ef(e,r,o)&&(a.filter=ks),bi(e,m,a,r,o),a.restore(),{element:e,canvas:i,theme:o.theme,scale:d,zoomValue:n.value,canvasOffsetX:u,canvasOffsetY:f,boundTextElementVersion:Z(e,t)?.version||null,containingFrameOpacity:Le(e,t)?.opacity||100}},gf=14,xf=document.createElement("img");xf.src=`data:${R.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 wf=document.createElement("img");wf.src=`data:${R.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 sx=(e,t,n)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);let r=Math.min(e.width,e.height),o=Math.min(r,Math.min(r*.4,100));t.drawImage(e.status==="error"?wf:xf,e.width/2-o/2,e.height/2-o/2,o,o)},bi=(e,t,n,r,o)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{n.lineJoin="round",n.lineCap="round",t.draw(ie.get(e));break}case"arrow":case"line":{n.lineJoin="round",n.lineCap="round",ie.get(e).forEach(i=>{t.draw(i)});break}case"freedraw":{n.save(),n.fillStyle=e.strokeColor;let i=lx(e),a=ie.get(e);a&&t.draw(a),n.fillStyle=e.strokeColor,n.fill(i),n.restore();break}case"image":{let i=wt(e)?r.imageCache.get(e.fileId)?.image:void 0;i!=null&&!(i instanceof Promise)?(e.roundness&&n.roundRect&&(n.beginPath(),n.roundRect(0,0,e.width,e.height,Ot(Math.min(e.width,e.height),e)),n.clip()),n.drawImage(i,0,0,e.width,e.height)):sx(e,n,o.zoom.value);break}default:if(Y(e)){let i=Wo(e.text),a=i&&!n.canvas.isConnected;a&&document.body.appendChild(n.canvas),n.canvas.setAttribute("dir",i?"rtl":"ltr"),n.save(),n.font=ue(e),n.fillStyle=e.strokeColor,n.textAlign=e.textAlign;let s=e.text.replace(/\r\n?/g,`
|
|
9
|
+
`).split(`
|
|
10
|
+
`),l=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,c=lr(e.fontSize,e.lineHeight),d=wi(e.fontFamily,e.fontSize,c);for(let u=0;u<s.length;u++)n.fillText(s[u],l,u*c+d);n.restore(),a&&n.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},xi=new WeakMap,uf=(e,t,n,r)=>{let o=n?r.zoom:rx.zoom,i=xi.get(e),a=i&&i.zoomValue!==o.value&&!r?.shouldCacheIgnoreZoom,s=Z(e,t)?.version||null,l=Le(e,t)?.opacity||100;if(!i||a||i.theme!==r.theme||i.boundTextElementVersion!==s||i.containingFrameOpacity!==l){let c=ax(e,t,o,n,r);return xi.set(e,c),c}return i},ff=(e,t,n,r,o)=>{let i=e.element,a=vi(i),s=e.scale,[l,c,d,u]=B(i,o);fe(i)&&(l=Math.floor(l),d=Math.ceil(d),c=Math.floor(c),u=Math.ceil(u));let f=((l+d)/2+r.scrollX)*window.devicePixelRatio,m=((c+u)/2+r.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let p=Z(i,o);if(ee(i)&&p){let h=document.createElement("canvas"),E=h.getContext("2d"),x=Math.max($e(l,d),$e(c,u));h.width=x*window.devicePixelRatio*s+a*e.scale*10,h.height=x*window.devicePixelRatio*s+a*e.scale*10;let w=(h.width-e.canvas.width)/2,y=(h.height-e.canvas.height)/2;E.translate(h.width/2,h.height/2),E.rotate(i.angle),E.drawImage(e.canvas,-e.canvas.width/2,-e.canvas.height/2,e.canvas.width,e.canvas.height);let[,,,,T,b]=B(p,o);E.rotate(-i.angle);let L=h.width/2-(T-l)*window.devicePixelRatio*s-w-a*s,I=h.height/2-(b-c)*window.devicePixelRatio*s-y-a*s;E.translate(-L,-I),E.clearRect(-(p.width/2+de)*window.devicePixelRatio*s,-(p.height/2+de)*window.devicePixelRatio*s,(p.width+de*2)*window.devicePixelRatio*s,(p.height+de*2)*window.devicePixelRatio*s),t.translate(f,m),t.drawImage(h,-(d-l)/2*window.devicePixelRatio-w/s-a,-(u-c)/2*window.devicePixelRatio-y/s-a,h.width/s,h.height/s)}else if(t.translate(f,m),t.rotate(i.angle),"scale"in e.element&&!hf(i,n)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-f,-m),t.drawImage(e.canvas,(l+r.scrollX)*window.devicePixelRatio-a*e.scale/e.scale,(c+r.scrollY)*window.devicePixelRatio-a*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),A.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&jo(i)){let h=Z(i,o),E=Cs(i);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((E.x+r.scrollX)*window.devicePixelRatio,(E.y+r.scrollY)*window.devicePixelRatio,at(i,h)*window.devicePixelRatio,ro(i,h)*window.devicePixelRatio)}t.restore()},l_=(e,t,n)=>{t.save(),t.translate(e.x+n.scrollX,e.y+n.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let r=.5/n.zoom.value;t.fillRect(r,r,e.width,e.height),t.lineWidth=1/n.zoom.value,t.strokeStyle=" rgb(105, 101, 219)",t.strokeRect(r,r,e.width,e.height),t.restore()},dr=(e,t,n,r,o,i,a)=>{switch(o.globalAlpha=ox(e,Le(e,t),i.elementsPendingErasure),e.type){case"magicframe":case"frame":{a.frameRendering.enabled&&a.frameRendering.outline&&(o.save(),o.translate(e.x+a.scrollX,e.y+a.scrollY),o.fillStyle="rgba(0, 0, 200, 0.04)",o.lineWidth=pe.strokeWidth/a.zoom.value,o.strokeStyle=pe.strokeColor,Zd(e)&&(o.strokeStyle=a.theme===Ce.LIGHT?"#7affd7":"#1d8264"),pe.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,e.width,e.height,pe.radius/a.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,e.width,e.height),o.restore());break}case"freedraw":{if(ie.generateElementShape(e,null),i.isExporting){let[s,l,c,d]=B(e,t),u=(s+c)/2+a.scrollX,f=(l+d)/2+a.scrollY,m=(c-s)/2-(e.x-s),p=(d-l)/2-(e.y-l);o.save(),o.translate(u,f),o.rotate(e.angle),o.translate(-m,-p),bi(e,r,o,i,a),o.restore()}else{let s=uf(e,t,i,a);ff(s,o,i,a,n)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(ie.generateElementShape(e,i),i.isExporting){let[s,l,c,d]=B(e,t),u=(s+c)/2+a.scrollX,f=(l+d)/2+a.scrollY,m=(c-s)/2-(e.x-s),p=(d-l)/2-(e.y-l);if(Y(e)){let E=Ae(e,t);if(ee(E)){let x=q.getBoundTextElementPosition(E,e,t);m=(c-s)/2-(x.x-s),p=(d-l)/2-(x.y-l)}}o.save(),o.translate(u,f),Ef(e,i,a)&&(o.filter="none");let h=Z(e,t);if(ee(e)&&h){let E=document.createElement("canvas"),x=E.getContext("2d"),w=Math.max($e(s,c),$e(l,d)),y=vi(e);E.width=w*a.exportScale+y*10*a.exportScale,E.height=w*a.exportScale+y*10*a.exportScale,x.translate(E.width/2,E.height/2),x.scale(a.exportScale,a.exportScale),m=e.width/2-(e.x-s),p=e.height/2-(e.y-l),x.rotate(e.angle);let T=bt.canvas(E);x.translate(-m,-p),bi(e,T,x,i,a),x.translate(m,p),x.rotate(-e.angle);let[,,,,b,L]=B(h,t),I=(s+c)/2-b,_=(l+d)/2-L;x.translate(-I,-_),x.clearRect(-h.width/2,-h.height/2,h.width,h.height),o.scale(1/a.exportScale,1/a.exportScale),o.drawImage(E,-E.width/2,-E.height/2,E.width,E.height)}else o.rotate(e.angle),e.type==="image"&&o.scale(e.scale[0],e.scale[1]),o.translate(-m,-p),bi(e,r,o,i,a);o.restore()}else{let s=uf(e,t,i,a),l=o.imageSmoothingEnabled;!a?.shouldCacheIgnoreZoom&&(!e.angle||pf(e.angle))&&(o.imageSmoothingEnabled=!1),ff(s,o,i,a,n),o.imageSmoothingEnabled=l}break}default:throw new Error(`Unimplemented type ${e.type}`)}o.globalAlpha=1},yf=new WeakMap([]);function bf(e){let t=Rs(e),n=new Path2D(t);return yf.set(e,n),n}function lx(e){return yf.get(e)}function Rs(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([r,o],i)=>[r,o,e.pressures[i]]):[[0,0,.5]],n={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:r=>Math.sin(r*Math.PI/2),last:!!e.lastCommittedPoint};return dx(Eu(t,n))}function mf(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}var cx=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function dx(e){if(!e.length)return"";let t=e.length-1;return e.reduce((n,r,o,i)=>(o===t?n.push(r,mf(r,i[0]),"L",i[0],"Z"):n.push(r,mf(r,i[o+1])),n),["M",e[0],"Q"]).join(" ").replace(cx,"$1")}g();function Fs(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function ux(e,t,n){let r=Fs(t,n);if(r===0)return Fs(e,t);let o=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return o=Math.max(0,Math.min(1,o)),Fs(e,fx(t,n,o))}function fx(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function vf(e,t){return Os(e,0,e.length,t)}function Os(e,t,n,r,o){let i=o||[],a=e[t],s=e[n-1],l=0,c=1;for(let d=t+1;d<n-1;++d){let u=ux(e[d],a,s);u>l&&(l=u,c=d)}return Math.sqrt(l)>r?(Os(e,t,c+1,r,i),Os(e,c,n,r,i)):(i.length||i.push(a),i.push(s)),i}var mx=e=>[8,8+e],_f=e=>[1.5,6+e];function px(e){let t=e.roughness,n=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&n>=50||r>=15&&e.roundness&&ms(e.type)||Q(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}var Be=(e,t=!1)=>{let n={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?mx(e.strokeWidth):e.strokeStyle==="dotted"?_f(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:px(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<Ba.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return n.fillStyle=e.fillStyle,n.fill=jt(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(n.curveFitting=1),n;case"line":case"freedraw":return vt(e.points)&&(n.fillStyle=e.fillStyle,n.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),n;case"arrow":return n;default:throw new Error(`Unimplemented type ${e.type}`)}},Tf=(e,t,n)=>Je(e)&&(t||Ko(e)&&n?.get(e.id)!==!0)&&jt(e.backgroundColor)&&jt(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Nr(e)?{...e,strokeColor:jt(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:jt(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Af=(e,t,n,r,o,i,a)=>{let s=Bs(e,t,n,r);if(s===null)return[];switch(r){case"dot":case"circle":case"circle_outline":{let[l,c,d]=s;return delete i.strokeLineDash,[o.circle(l,c,d,{...i,fill:r==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[l,c,d,u,f,m]=s;return delete i.strokeLineDash,[o.polygon([[l,c],[d,u],[f,m],[l,c]],{...i,fill:r==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[l,c,d,u,f,m,p,h]=s;return delete i.strokeLineDash,[o.polygon([[l,c],[d,u],[f,m],[p,h],[l,c]],{...i,fill:r==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"bar":case"arrow":default:{let[l,c,d,u,f,m]=s;if(e.strokeStyle==="dotted"){let p=_f(e.strokeWidth-1);i.strokeLineDash=[p[0],p[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[o.line(d,u,l,c,i),o.line(f,m,l,c,i)]}}},Ju=(e,t,{isExporting:n,canvasBackgroundColor:r,embedsValidationStatus:o})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,s=e.height,l=Ot(Math.min(a,s),e);i=t.path(`M ${l} 0 L ${a-l} 0 Q ${a} 0, ${a} ${l} L ${a} ${s-l} Q ${a} ${s}, ${a-l} ${s} L ${l} ${s} Q 0 ${s}, 0 ${s-l} L 0 ${l} Q 0 0, ${l} 0`,Be(Tf(e,n,o),!0))}else i=t.rectangle(0,0,e.width,e.height,Be(Tf(e,n,o),!1));return i}case"diamond":{let i,[a,s,l,c,d,u,f,m]=Ns(e);if(e.roundness){let p=Ot(Math.abs(a-f),e),h=Ot(Math.abs(c-s),e);i=t.path(`M ${a+p} ${s+h} L ${l-p} ${c-h}
|
|
11
|
+
C ${l} ${c}, ${l} ${c}, ${l-p} ${c+h}
|
|
12
|
+
L ${d+p} ${u-h}
|
|
13
|
+
C ${d} ${u}, ${d} ${u}, ${d-p} ${u-h}
|
|
14
|
+
L ${f+p} ${m+h}
|
|
15
|
+
C ${f} ${m}, ${f} ${m}, ${f+p} ${m-h}
|
|
16
|
+
L ${a-p} ${s+h}
|
|
17
|
+
C ${a} ${s}, ${a} ${s}, ${a+p} ${s+h}`,Be(e,!0))}else i=t.polygon([[a,s],[l,c],[d,u],[f,m]],Be(e));return i}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,Be(e));case"line":case"arrow":{let i,a=Be(e),s=e.points.length?e.points:[[0,0]];if(e.roundness?i=[t.curve(s,a)]:a.fill?i=[t.polygon(s,a)]:i=[t.linearPath(s,a)],e.type==="arrow"){let{startArrowhead:l=null,endArrowhead:c="arrow"}=e;if(l!==null){let d=Af(e,i,"start",l,t,a,r);i.push(...d)}if(c!==null){let d=Af(e,i,"end",c,t,a,r);i.push(...d)}}return i}case"freedraw":{let i;if(bf(e),vt(e.points)){let a=vf(e.points,.75);i=t.curve(a,{...Be(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return Xo(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}};g();var Sf=e=>{let t=e.map(r=>r[0]),n=e.map(r=>r[1]);return{width:Math.max(...t)-Math.min(...t),height:Math.max(...n)-Math.min(...n)}},rn=(e,t,n,r)=>{let o=n.map(m=>m[e]),i=Math.max(...o),a=Math.min(...o),s=i-a,l=s===0?1:t/s,c=1/0,d=n.map(m=>{let p=m[e]*l,h=[...m];return h[e]=p,p<c&&(c=p),h});if(!r||d.length===2)return d;let u=a-c;return d.map(m=>m.map((p,h)=>h===e?p+u:p))};var Gs=class e{static boundsCache=new WeakMap;static getBounds(t,n){let r=e.boundsCache.get(t);if(r?.version&&r.version===t.version&&!Ye(t))return r.bounds;let o=e.calculateBounds(t,n);return e.boundsCache.set(t,{version:t.version,bounds:o}),o}static calculateBounds(t,n){let r,[o,i,a,s,l,c]=B(t,n);if(fe(t)){let[d,u,f,m]=Hs(t.points.map(([p,h])=>H(p,h,l-t.x,c-t.y,t.angle)));return[d+t.x,u+t.y,f+t.x,m+t.y]}else if(Q(t))r=yx(t,l,c,n);else if(t.type==="diamond"){let[d,u]=H(l,i,l,c,t.angle),[f,m]=H(l,s,l,c,t.angle),[p,h]=H(o,c,l,c,t.angle),[E,x]=H(a,c,l,c,t.angle),w=Math.min(d,f,p,E),y=Math.min(u,m,h,x),T=Math.max(d,f,p,E),b=Math.max(u,m,h,x);r=[w,y,T,b]}else if(t.type==="ellipse"){let d=(a-o)/2,u=(s-i)/2,f=Math.cos(t.angle),m=Math.sin(t.angle),p=Math.hypot(d*f,u*m),h=Math.hypot(u*f,d*m);r=[l-p,c-h,l+p,c+h]}else{let[d,u]=H(o,i,l,c,t.angle),[f,m]=H(o,s,l,c,t.angle),[p,h]=H(a,s,l,c,t.angle),[E,x]=H(a,i,l,c,t.angle),w=Math.min(d,f,p,E),y=Math.min(u,m,h,x),T=Math.max(d,f,p,E),b=Math.max(u,m,h,x);r=[w,y,T,b]}return r}},B=(e,t,n=!1)=>{if(fe(e))return Ex(e);if(Q(e))return q.getElementAbsoluteCoords(e,t,n);if(Y(e)){let r=t?Ae(e,t):null;if(ee(r)){let o=q.getBoundTextElementPosition(r,e,t);return[o.x,o.y,o.x+e.width,o.y+e.height,o.x+e.width/2,o.y+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]},zs=(e,t)=>{let[n,r,o,i,a,s]=B(e,t),l=[a,s];if(Q(e)||fe(e)){let x=[],w=0;for(;w<e.points.length-1;)x.push([me([e.points[w][0]+e.x,e.points[w][1]+e.y],l,e.angle),me([e.points[w+1][0]+e.x,e.points[w+1][1]+e.y],l,e.angle)]),w++;return x}let[c,d,u,f,m,p,h,E]=[[n,r],[o,r],[n,i],[o,i],[a,r],[a,i],[n,s],[o,s]].map(x=>me(x,l,e.angle));return e.type==="diamond"?[[m,h],[m,E],[p,h],[p,E]]:e.type==="ellipse"?[[m,h],[m,E],[p,h],[p,E],[m,h],[m,E],[p,h],[p,E]]:[[c,d],[u,f],[c,u],[d,f],[c,E],[u,E],[d,h],[f,h]]};var Ns=e=>{let t=Math.floor(e.width/2)+1,n=0,r=e.width,o=Math.floor(e.height/2)+1,i=t,a=e.height;return[t,n,r,o,i,a,0,o]},nn=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},If=(e,t,n,r,o)=>{let i=1-e;return Math.pow(i,3)*t+3*Math.pow(i,2)*e*n+3*i*Math.pow(e,2)*r+Math.pow(e,3)*o},Pf=(e,t,n,r)=>{let o=t-e,i=n-t,a=r-n,s=3*o-6*i+3*a,l=6*i-6*o,c=3*o,d=l*l-4*s*c;if(!(d>=0))return!1;let f=null,m=null,p=1/0,h=1/0;return s===0?p=h=-c/l:(p=(-l+Math.sqrt(d))/(2*s),h=(-l-Math.sqrt(d))/(2*s)),p>=0&&p<=1&&(f=If(p,e,t,n,r)),h>=0&&h<=1&&(m=If(h,e,t,n,r)),[f,m]},hx=(e,t,n,r)=>{let o=Pf(e[0],t[0],n[0],r[0]),i=Pf(e[1],t[1],n[1],r[1]),a=Math.min(e[0],r[0]),s=Math.max(e[0],r[0]);if(o){let d=o.filter(u=>u!==null);a=Math.min(a,...d),s=Math.max(s,...d)}let l=Math.min(e[1],r[1]),c=Math.max(e[1],r[1]);if(i){let d=i.filter(u=>u!==null);l=Math.min(l,...d),c=Math.max(c,...d)}return[a,l,s,c]},eo=(e,t)=>{let n=[0,0],{minX:r,minY:o,maxX:i,maxY:a}=e.reduce((s,{op:l,data:c})=>{if(l==="move")n=c;else if(l==="bcurveTo"){let d=[c[0],c[1]],u=[c[2],c[3]],f=[c[4],c[5]],m=t?t(...d):d,p=t?t(...u):u,h=t?t(...f):f,E=t?t(...n):n;n=f;let[x,w,y,T]=hx(E,m,p,h);s.minX=Math.min(s.minX,x),s.minY=Math.min(s.minY,w),s.maxX=Math.max(s.maxX,y),s.maxY=Math.max(s.maxY,T)}return s},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[r,o,i,a]},Hs=e=>{let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let[i,a]of e)t=Math.min(t,i),n=Math.min(n,a),r=Math.max(r,i),o=Math.max(o,a);return[t,n,r,o]},Ex=e=>{let[t,n,r,o]=Hs(e.points),i=t+e.x,a=n+e.y,s=r+e.x,l=o+e.y;return[i,a,s,l,(i+s)/2,(a+l)/2]},gx=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;default:return 15}},xx=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Bs=(e,t,n,r)=>{let o=nn(t[0]);if(o.length<1)return null;let i=n==="start"?1:o.length-1,a=o[i].data,s=[a[4],a[5]],l=[a[2],a[3]],c=[a[0],a[1]],d=o[i-1],u=[0,0];d.op==="move"?u=d.data:d.op==="bcurveTo"&&(u=[d.data[4],d.data[5]]);let f=(O,N)=>Math.pow(1-O,3)*s[N]+3*O*Math.pow(1-O,2)*l[N]+3*Math.pow(O,2)*(1-O)*c[N]+u[N]*Math.pow(O,3),[m,p]=n==="start"?u:s,[h,E]=[f(.3,0),f(.3,1)],x=Math.hypot(m-h,p-E),w=(m-h)/x,y=(p-E)/x,T=gx(r),b=0;{let[O,N]=n==="end"?e.points[e.points.length-1]:e.points[0],[C,U]=e.points.length>1?n==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];b=Math.hypot(O-C,N-U)}let I=Math.min(T,b*(r==="diamond"||r==="diamond_outline"?.25:.5)),_=m-w*I,S=p-y*I;if(r==="dot"||r==="circle"||r==="circle_outline"){let O=Math.hypot(S-p,_-m)+e.strokeWidth-2;return[m,p,O]}let M=xx(r),[v,P]=H(_,S,m,p,-M*Math.PI/180),[D,z]=H(_,S,m,p,M*Math.PI/180);if(r==="diamond"||r==="diamond_outline"){let O,N;if(n==="start"){let[C,U]=e.points.length>1?e.points[1]:[0,0];[O,N]=H(m+I*2,p,m,p,Math.atan2(U-p,C-m))}else{let[C,U]=e.points.length>1?e.points[e.points.length-2]:[0,0];[O,N]=H(m-I*2,p,m,p,Math.atan2(p-U,m-C))}return[m,p,v,P,O,N,D,z]}return[m,p,v,P,D,z]},wx=e=>{let t=bt.generator(),n=Be(e),r=e.roundness?"curve":n.fill?"polygon":"linearPath";return t[r](e.points,n)},yx=(e,t,n,r)=>{let o=Z(e,r);if(e.points.length<2){let[u,f]=e.points[0],[m,p]=H(e.x+u,e.y+f,t,n,e.angle),h=[m,p,m,p];if(o){let E=q.getMinMaxXYWithBoundText(e,r,[m,p,m,p],o);h=[E[0],E[1],E[2],E[3]]}return h}let a=ie.get(e)?.[0]??wx(e),s=nn(a),c=eo(s,(u,f)=>H(e.x+u,e.y+f,t,n,e.angle)),d=[c[0],c[1],c[2],c[3]];if(o){let u=q.getMinMaxXYWithBoundText(e,r,d,o);d=[u[0],u[1],u[2],u[3]]}return d},Ge=(e,t)=>Gs.getBounds(e,t),Me=e=>{if(!e.length)return[0,0,0,0];let t=1/0,n=-1/0,r=1/0,o=-1/0,i=X(e);return e.forEach(a=>{let[s,l,c,d]=Ge(a,i);t=Math.min(t,s),r=Math.min(r,l),n=Math.max(n,c),o=Math.max(o,d)}),[t,r,n,o]},R_=(e,t)=>{let[n,r,o,i]=Me(e);return[n+t.x,r+t.y,o+t.x,i+t.y]},Dn=(e,t,n,r)=>{if(!(Q(e)||fe(e)))return[e.x,e.y,e.x+t,e.y+n];let o=rn(0,t,rn(1,n,e.points,r),r),i;if(fe(e))i=Hs(o);else{let d=bt.generator(),u=e.roundness?d.curve(o,Be(e)):d.linearPath(o,Be(e)),f=nn(u);i=eo(f)}let[a,s,l,c]=i;return[a+e.x,s+e.y,l+e.x,c+e.y]},sr=(e,t)=>{let n=bt.generator(),r=e.roundness==null?n.linearPath(t,Be(e)):n.curve(t,Be(e)),o=nn(r),[i,a,s,l]=eo(o);return[i+e.x,a+e.y,s+e.x,l+e.y]},us=(e,t)=>{if(!e.length)return[0,0,0,0];let n=1/0,r=e[0],o=X(e);return e.forEach(i=>{let[a,s,l,c]=Ge(i,o),d=Fe((a+l)/2,(s+c)/2,t.x,t.y);d<n&&(n=d,r=i)}),Ge(r,o)},Mf=e=>{let[t,n,r,o]=Me(e);return{minX:t,minY:n,maxX:r,maxY:o,width:r-t,height:o-n,midX:(t+r)/2,midY:(n+o)/2}},F_=({scrollX:e,scrollY:t,width:n,height:r,zoom:o})=>[-e,-t,-e+n/o.value,-t+r/o.value];var H=(e,t,n,r,o)=>[(e-n)*Math.cos(o)-(t-r)*Math.sin(o)+n,(e-n)*Math.sin(o)+(t-r)*Math.cos(o)+r],me=(e,t,n)=>H(e[0],e[1],t[0],t[1],n),Ti=(e,t,n,r,o,i,a,s)=>{let l=Math.cos(r),c=Math.sin(r);return e.e&&e.w?t+=o+a:e.e?(t+=o*(1+l),n+=o*c,t+=a*(1-l),n+=a*-c):e.w&&(t+=o*(1-l),n+=o*-c,t+=a*(1+l),n+=a*c),e.n&&e.s?n+=i+s:e.n?(t+=i*c,n+=i*(1-l),t+=s*-c,n+=s*(1+l)):e.s&&(t+=i*-c,n+=i*(1+l),t+=s*c,n+=s*(1-l)),[t,n]};var Fe=(e,t,n,r)=>{let o=n-e,i=r-t;return Math.hypot(o,i)},Jr=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],vt=(e,t=1)=>{if(e.length>=3){let[n,r]=[e[0],e[e.length-1]];return Fe(n[0],n[1],r[0],r[1])<=Ad/t}return!1};var Ai=(e,t,n)=>t[0]<=Math.max(e[0],n[0])&&t[0]>=Math.min(e[0],n[0])&&t[1]<=Math.max(e[1],n[1])&&t[1]>=Math.min(e[1],n[1]);var Qr=(e,t,n)=>n?[Math.round(e/n)*n,Math.round(t/n)*n]:[e,t],Ot=(e,t)=>{if(t.roundness?.type===ke.PROPORTIONAL_RADIUS||t.roundness?.type===ke.LEGACY)return e*Ho;if(t.roundness?.type===ke.ADAPTIVE_RADIUS){let n=t.roundness?.value??Cd,r=n/Ho;return e<=r?e*Ho:n}return 0},vs=(e,t)=>{let n=ie.generateElementShape(e,null);if(!n)return null;let r=nn(n[0]),o=[0,0],i=0,a=1/0,s=null;for(;i<r.length;){let{op:l,data:c}=r[i];if(l==="move"&&(o=c),l==="bcurveTo"){let d=o,u=[c[0],c[1]],f=[c[2],c[3]],m=[c[4],c[5]],p=Fe(m[0],m[1],t[0],t[1]);p<a&&(a=p,s=[d,u,f,m]),o=m}i++}return s},Ts=(e,t,n,r,o)=>{let i=(l,c)=>Math.pow(1-l,3)*r[c]+3*l*Math.pow(1-l,2)*n[c]+3*Math.pow(l,2)*(1-l)*t[c]+e[c]*Math.pow(l,3),a=i(o,0),s=i(o,1);return[a,s]},bx=(e,t)=>{let n=vs(e,t);if(!n)return[];let r=[],o=1;for(;o>0;){let i=Ts(n[0],n[1],n[2],n[3],o);r.push([i[0],i[1]]),o-=.05}return r.length&&As(r.at(-1),t)&&r.push([t[0],t[1]]),r},Lf=(e,t)=>{let n=[];n[0]=0;let r=bx(e,t),o=0,i=0;for(;o<r.length-1;){let a=Fe(r[o][0],r[o][1],r[o+1][0],r[o+1][1]);i+=a,n.push(i),o++}return n},Qu=(e,t)=>Lf(e,t).at(-1),ef=(e,t,n)=>{let r=Lf(e,t),o=r.length-1,i=r.at(-1),a=n*i,s=0,l=o,c=0;for(;s<l;)c=Math.floor(s+(l-s)/2),r[c]<a?s=c+1:l=c;return r[c]>a&&c--,r[c]===a?c/o:1-(c+(a-r[c])/(r[c+1]-r[c]))/o},As=(e,t)=>e[0]===t[0]&&e[1]===t[1],pf=e=>Math.round(e/Math.PI*1e4)%5e3===0,H_=([e,t],[n,r])=>e<=n?t>=n:e>=n?r>=e:!1,U_=(e,t)=>{let n=Math.max(e[0],t[0]),r=Math.min(e[1],t[1]);return n<=r?[n,r]:null},oo=(e,t,n)=>e>=t&&e<=n;g();var vx=(e,t,n)=>{let r=n.reduce((o,i)=>(i.groupIds.includes(e)&&(o[i.id]=!0),o),{});return Object.keys(r).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,...r}}},Z_=function(){let e=null,t=null,n=null,r=(i,a,s,l)=>{if(n!==void 0&&a===t&&i===e&&s.editingGroupId===n?.editingGroupId)return n;let c={};for(let f of i){let m=f.groupIds;if(s.editingGroupId){let p=m.indexOf(s.editingGroupId);p>-1&&(m=m.slice(0,p))}if(m.length>0){let p=m[m.length-1];c[p]=!0}}let d={},u=a.reduce((f,m)=>{let p=m.groupIds.find(h=>c[h]);return p&&(f[m.id]=!0,Array.isArray(d[p])?d[p].push(m.id):d[p]=[m.id]),f},{});for(let f of Object.keys(d))d[f].length<2&&c[f]&&(c[f]=!1);return t=a,e=i,n={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Us({...s.selectedElementIds,...u},l)},n},o=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):ot(a,i);return c.length?r(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Us(i.selectedElementIds,s)}};return o.clearCache=()=>{t=null,e=null,n=null},o}(),K_=(e,t)=>Tx(e,t)!=null,Tx=(e,t)=>t.groupIds.filter(n=>n!==e.editingGroupId).find(n=>e.selectedGroupIds[n]),j_=e=>Object.entries(e.selectedGroupIds).filter(([t,n])=>n).map(([t,n])=>t),Df=(e,t)=>{let n={...t,selectedGroupIds:{}};for(let r of e){let o=r.groupIds;if(t.editingGroupId){let i=o.indexOf(t.editingGroupId);i>-1&&(o=o.slice(0,i))}if(o.length>0){let i=o[o.length-1];n={...n,...vx(i,n,e)}}}return n.selectedGroupIds},q_=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),Ax=(e,t)=>e.groupIds.includes(t),ur=(e,t)=>{let n=[];for(let r of e.values())Ax(r,t)&&n.push(r);return n},J_=(e,t)=>e.groupIds.find(n=>t[n]),Cf=(e,t,n)=>{let r=[...e],o=t?e.indexOf(t):-1,i=o>-1?o:e.length;for(let a=0;a<i;a++)r[a]=n(r[a]);return r},Q_=(e,t,n)=>{let r=[...e],o=n?r.indexOf(n):-1,i=o>-1?o:r.length;return r.splice(i,0,t),r},eS=(e,t)=>e.filter(n=>!t[n]),tS=(e,t)=>{let n=new Map;return e.forEach(r=>{let o=r.groupIds.length===0?r.id:r.groupIds[r.groupIds.length-1],i=n.get(o)||[],a=Z(r,t);a&&i.push(a),n.set(o,[...i,r])}),Array.from(n.values())};g();g();g();g();g();var Rf=xr(kf(),1),Si=e=>e.replace(/"/g,"""),fr=e=>(e=e.trim(),e&&(0,Rf.sanitizeUrl)(Si(e))),aS=e=>!!(e?.includes(location.origin)||e?.startsWith("/")),Ff=e=>{if(e=fr(e),e.startsWith("/"))return`${location.origin}${e}`;try{new URL(e)}catch{return"about:blank"}return e};g();g();var Of=[],Nf=e=>(Of=Of.concat(e),e);g();var Gf='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',Rx='<path d="M6.164 11.755a5.314 5.314 0 0 1-4.932-5.298 5.314 5.314 0 0 1 5.311-5.311 5.314 5.314 0 0 1 5.307 5.113l8.773 8.773a3.322 3.322 0 0 1 0 4.696l-.895.895a3.322 3.322 0 0 1-4.696 0l-8.868-8.868Z" style="fill:#fff"/>',zf='<path stroke="#1b1b1f" fill="#fff" d="m7.868 11.113 7.773 7.774a2.359 2.359 0 0 0 1.667.691 2.368 2.368 0 0 0 2.357-2.358c0-.625-.248-1.225-.69-1.667L11.201 7.78 9.558 9.469l-1.69 1.643v.001Zm10.273 3.606-3.333 3.333m-3.25-6.583 2 2m-7-7 3 3M3.664 3.625l1 1M2.529 6.922l1.407-.144m5.735-2.932-1.118.866M4.285 9.823l.758-1.194m1.863-6.207-.13 1.408"/>',Fx=`data:${R.svg},${encodeURIComponent(`${Gf}${zf}</svg>`)}`,Ox=`data:${R.svg},${encodeURIComponent(`${Gf}${Rx}${zf}</svg>`)}`,Nx=e=>{e&&(e.style.cursor="")},Bx=(e,t)=>{e&&(e.style.cursor=t)},Tt,Bf,Gx=(e,t)=>{let r=()=>{let o=t===Ce.DARK;Tt=document.createElement("canvas"),Tt.theme=t,Tt.height=20,Tt.width=20;let i=Tt.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Tt.width/2,Tt.height/2,5,0,2*Math.PI),i.fillStyle=o?yn.black:yn.white,i.fill(),i.strokeStyle=o?yn.white:yn.black,i.stroke(),Bf=Tt.toDataURL(R.svg)};(!Tt||Tt.theme!==t)&&r(),Bx(e,`url(${Bf}) ${20/2} ${20/2}, auto`)},Hf=(e,t)=>{if(e)if(t.activeTool.type==="selection")Nx(e);else if(Bd(t))e.style.cursor=Oo.GRAB;else if(Nd(t))Gx(e,t.theme);else if(t.activeTool.type==="laser"){let n=t.theme===Ce.LIGHT?Fx:Ox;e.style.cursor=`url(${n}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=Oo.AUTO):e.style.cursor=Oo.CROSSHAIR};g();g();var zx=new Jn(Date.now()),Hx=0,At=()=>Math.floor(zx.next()*2**31);var st=()=>kt()?`id${Hx++}`:Uo();var Nt=(e,{x:t,y:n,strokeColor:r=ne.strokeColor,backgroundColor:o=ne.backgroundColor,fillStyle:i=ne.fillStyle,strokeWidth:a=ne.strokeWidth,strokeStyle:s=ne.strokeStyle,roughness:l=ne.roughness,opacity:c=ne.opacity,width:d=0,height:u=0,angle:f=0,groupIds:m=[],frameId:p=null,index:h=null,roundness:E=null,boundElements:x=null,link:w=null,locked:y=ne.locked,...T})=>({id:T.id||st(),type:e,x:t,y:n,width:d,height:u,angle:f,strokeColor:r,backgroundColor:o,fillStyle:i,strokeWidth:a,strokeStyle:s,roughness:l,opacity:c,groupIds:m,frameId:p,index:h,roundness:E,seed:T.seed??At(),version:T.version||1,versionNonce:T.versionNonce??0,isDeleted:!1,boundElements:x,updated:Ct(),link:w,locked:y,customData:T.customData}),io=e=>Nt(e.type,e),LS=e=>Nt("embeddable",e),DS=e=>({...Nt("iframe",e)}),CS=e=>kn({...Nt("frame",e),type:"frame",name:e?.name||null},{}),kS=e=>kn({...Nt("magicframe",e),type:"magicframe",name:e?.name||null},{}),Uf=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),_t=e=>{let t=e.fontFamily||qe,n=e.fontSize||xt,r=e.lineHeight||yi(t),o=Ms(e.text),i=Mn(o,ue({fontFamily:t,fontSize:n}),r),a=e.textAlign||Zn,s=e.verticalAlign||Bo,l=Uf({textAlign:a,verticalAlign:s},i);return kn({...Nt("text",e),text:o,fontSize:n,fontFamily:t,textAlign:a,verticalAlign:s,x:e.x-l.x,y:e.y-l.y,width:i.width,height:i.height,containerId:e.containerId||null,originalText:o,lineHeight:r},{})},Ux=(e,t,n)=>{let{width:r,height:o}=Mn(n,ue(e),e.lineHeight),{textAlign:i,verticalAlign:a}=e,s,l;if(i==="center"&&a===Lt.MIDDLE&&!e.containerId){let c=Mn(e.text,ue(e),e.lineHeight),d=Uf(e,{width:r-c.width,height:o-c.height});s=e.x-d.x,l=e.y-d.y}else{let[c,d,u,f]=B(e,t),[m,p,h,E]=Dn(e,r,o,!1),x=(c-m)/2,w=(d-p)/2,y=(u-h)/2,T=(f-E)/2;[s,l]=Ti({s:!0,e:i==="center"||i==="left",w:i==="center"||i==="right"},e.x,e.y,e.angle,x,w,y,T)}return{width:r,height:o,x:Number.isFinite(s)?s:e.x,y:Number.isFinite(l)?l:e.y}},Mi=(e,t,n,r=e.text)=>{if(e.isDeleted)return;t&&(r=cr(r,ue(e),at(t,e)));let o=Ux(e,n,r);return{text:r,...o}},$x=(e,t,n,{text:r,isDeleted:o,originalText:i})=>kn(e,{originalText:i,isDeleted:o??e.isDeleted,...Mi(e,t,n,i)}),RS=e=>({...Nt(e.type,e),points:e.points||[],pressures:[],simulatePressure:e.simulatePressure,lastCommittedPoint:null}),Cn=e=>({...Nt(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null}),Yx=e=>({...Nt("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1]}),Ii=(e,t=0)=>{if(e==null||typeof e!="object")return e;let n=Object.prototype.toString.call(e);if(n==="[object Object]"){let r=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;r[o]=Ii(e[o],t+1)}return r}if(Array.isArray(e)){let r=e.length,o=new Array(r);for(;r--;)o[r]=Ii(e[r],t+1);return o}return A.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=>Ii(e),Pi=e=>{if(kt()&&e){let t=`${e}_copy`;return window.h?.app?.getSceneElementsIncludingDeleted().find(n=>n.id===t)&&(t+="_copy"),t}return st()},Wx=(e,t,n,r)=>{let o=$s(n);return o.id=Pi(o.id),o.boundElements=null,o.updated=Ct(),o.seed=At(),o.groupIds=Cf(o.groupIds,e,i=>(t.has(i)||t.set(i,Pi(i)),t.get(i))),r&&(o=Object.assign(o,r)),o},FS=(e,t)=>{let n=[],r=X(e),o=new Map,i=s=>{if(o.has(s))return o.get(s);if(r.has(s)){let l=Pi(s);return o.set(s,l),l}return null},a=new Map;for(let s of e){let l=Ii(s);if(l.id=i(s.id),t?.randomizeSeed&&(l.seed=At(),ao(l)),l.groupIds&&(l.groupIds=l.groupIds.map(c=>(a.has(c)||a.set(c,Pi(c)),a.get(c)))),"containerId"in l&&l.containerId){let c=i(l.containerId);l.containerId=c}if("boundElements"in l&&l.boundElements&&(l.boundElements=l.boundElements.reduce((c,d)=>{let u=i(d.id);return u&&c.push({...d,id:u}),c},[])),"endBinding"in l&&l.endBinding){let c=i(l.endBinding.elementId);l.endBinding=c?{...l.endBinding,elementId:c}:null}if("startBinding"in l&&l.startBinding){let c=i(l.startBinding.elementId);l.startBinding=c?{...l.startBinding,elementId:c}:null}l.frameId&&(l.frameId=i(l.frameId)),n.push(l)}return n};var Bt=new Map,Vx=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)(?:\?t=|&t=|\?start=|&start=)?([a-zA-Z0-9_-]+)?[^\s]*$/,Xx=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}\.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,Zx=/^https:\/\/(?:www\.)?figma\.com/,$f=/^https:\/\/gist\.github\.com\/([\w_-]+)\/([\w_-]+)/,Kx=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist\.github\.com\/.*?)\.js["']/i,Yf=/(?:https?:\/\/)?(?:(?:w){3}\.)?(?:twitter|x)\.com\/[^/]+\/status\/(\d+)/,jx=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:twitter|x)\.com\/[^"']*)/i,qx=/^https:\/\/(?:www\.)?val\.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,Jx=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,Wf=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,Ys=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","dddice.com"]),Vf=e=>`<html><body>${e}</body></html>`,Zf=e=>{if(!e)return null;if(Bt.has(e))return Bt.get(e);let t=e,n="generic",r={w:560,h:840},o=e.match(Vx);if(o?.[2]){let l=o[3]?`&start=${o[3]}`:"",c=e.includes("shorts");switch(n="video",o[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${o[2]}?enablejsapi=1${l}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${o[2]}&enablejsapi=1${l}`;break;default:e=`https://www.youtube.com/embed/${o[2]}?enablejsapi=1${l}`;break}return r=c?{w:315,h:560}:{w:560,h:315},Bt.set(t,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n}}let i=e.match(Xx);if(i?.[1]){let l=i?.[1],c=/^\d+$/.test(l)?void 0:new URIError("Invalid embed link format");return n="video",e=`https://player.vimeo.com/video/${l}?api=1`,r={w:560,h:315},Bt.set(t,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n,error:c}}if(e.match(Zx))return n="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,r={w:550,h:550},Bt.set(t,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n};let s=e.match(qx);if(s)return e=s[1]==="embed"?s[0]:s[0].replace("/v","/embed"),Bt.set(t,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n};if(Yf.test(e)){let l=e.match(Yf)[1],c=Si(`https://twitter.com/x/status/${l}`),d={type:"document",srcdoc:u=>Vf(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${u}"><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:!0}};return Bt.set(t,d),d}if($f.test(e)){let[,l,c]=e.match($f),d=Si(`https://gist.github.com/${l}/${c}`),u={type:"document",srcdoc:()=>Vf(`
|
|
18
|
+
<script src="${d}.js"><\/script>
|
|
19
|
+
<style type="text/css">
|
|
20
|
+
* { margin: 0px; }
|
|
21
|
+
table, .gist { height: 100%; }
|
|
22
|
+
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
23
|
+
</style>
|
|
24
|
+
`),intrinsicSize:{w:550,h:720}};return Bt.set(e,u),u}return Bt.set(e,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n}},Li=e=>{let t;Nr(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),r=ce.Helvetica,o=ue({fontSize:n,fontFamily:r});return _t({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:r,fontSize:n,text:cr(t,o,e.width-20),textAlign:"center",verticalAlign:Lt.MIDDLE,angle:e.angle??0})},VS=Nf({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,t,n,r)=>{let o=Fr(t,{type:"embeddable"});return Hf(r.canvas,{...t,activeTool:o}),{elements:e,appState:{...t,activeTool:Fr(t,{type:"embeddable"})},commitToHistory:!1}}}),Xf=(e,t)=>{try{let{hostname:n}=new URL(e),r=n.replace(/^www\./,""),o=r.replace(/^([^.]+)/,"*");if(t instanceof Set)return Ys.has(r)||Ys.has(o);if(r===t.replace(/^www\./,""))return!0}catch{}return!1},XS=e=>{let t=e.match(jx);if(t&&t.length===2)return t[1];let n=e.match(Kx);if(n&&n.length===2)return n[1];if(Wf.test(e))return`https://giphy.com/embed/${Wf.exec(e)[1]}`;let r=e.match(Jx);return r&&r.length===2?r[1]:e},ZS=(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(Xf(e,n))return!0;return!1}}return Xf(e,Ys)};var so=(e,t,n)=>{if(typeof n>"u")return e.draw(t);let r={sets:t.sets,shape:t.shape,options:{...t.options,fixedDecimalPlaceDigits:n}};return e.draw(r)},lo=(e,t,n,r,o)=>{if(!r.enabled||!r.clip)return null;let i=Le(e,o);if(i){let a=t.ownerDocument.createElementNS(j,"g");return a.setAttributeNS(j,"clip-path",`url(#${i.id})`),n.forEach(s=>a.appendChild(s)),a}return null},Di=(e,t,n,r,o,i,a,s)=>{let l={x:i,y:a},[c,d,u,f]=B(e,t),m=(u-c)/2-(e.x-c),p=(f-d)/2-(e.y-d);if(Y(e)){let y=Ae(e,t);if(ee(y)){let[T,b,L,I]=B(y,t),_=q.getBoundTextElementPosition(y,e,t);m=(L-T)/2-(_.x-T),p=(I-b)/2-(_.y-b),i=i+_.x-e.x,a=a+_.y-e.y}}let h=180*e.angle/Math.PI,E=r;if(e.link){let y=r.ownerDocument.createElementNS(j,"a");y.setAttribute("href",fr(e.link)),E.appendChild(y),E=y}let x=(y,T)=>{kt()&&y.setAttribute("data-id",T.id),E.appendChild(y)},w=(Le(e,t)?.opacity??100)*e.opacity/1e4;switch(e.type){case"selection":throw new Error("Selection rendering is not supported for SVG");case"rectangle":case"diamond":case"ellipse":{let y=ie.generateElementShape(e,null),T=so(n,y,Kn);w!==1&&(T.setAttribute("stroke-opacity",`${w}`),T.setAttribute("fill-opacity",`${w}`)),T.setAttribute("stroke-linecap","round"),T.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${m} ${p})`);let b=lo(e,E,[T],s.frameRendering,t);x(b||T,e);break}case"iframe":case"embeddable":{let y=ie.generateElementShape(e,s),T=so(n,y,Kn),b=e.opacity/100;b!==1&&(T.setAttribute("stroke-opacity",`${b}`),T.setAttribute("fill-opacity",`${b}`)),T.setAttribute("stroke-linecap","round"),T.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${m} ${p})`),x(T,e);let L=Li(e);Di(L,t,n,E,o,L.x+l.x-e.x,L.y+l.y-e.y,s);let I=so(n,y,Kn);for(I.setAttribute("stroke-linecap","round"),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${m} ${p})`);I.firstChild;)I.removeChild(I.firstChild);let _=Ot(Math.min(e.width,e.height),e),S=Zf(Ff(e.link||""));if(s.renderEmbeddables===!1||S?.type==="document"){let M=r.ownerDocument.createElementNS(j,"a");M.setAttribute("href",fr(e.link||"")),M.setAttribute("target","_blank"),M.setAttribute("rel","noopener noreferrer"),M.style.borderRadius=`${_}px`,I.appendChild(M)}else{let M=r.ownerDocument.createElementNS(j,"foreignObject");M.style.width=`${e.width}px`,M.style.height=`${e.height}px`,M.style.border="none";let v=M.ownerDocument.createElementNS(j,"div");v.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),v.style.width="100%",v.style.height="100%";let P=v.ownerDocument.createElement("iframe");P.src=S?.link??"",P.style.width="100%",P.style.height="100%",P.style.border="none",P.style.borderRadius=`${_}px`,P.style.top="0",P.style.left="0",P.allowFullscreen=!0,v.appendChild(P),M.appendChild(v),I.appendChild(M)}x(I,e);break}case"line":case"arrow":{let y=Z(e,t),T=r.ownerDocument.createElementNS(j,"mask");if(y){T.setAttribute("id",`mask-${e.id}`);let _=r.ownerDocument.createElementNS(j,"rect");i=i||0,a=a||0,_.setAttribute("x","0"),_.setAttribute("y","0"),_.setAttribute("fill","#fff"),_.setAttribute("width",`${e.width+100+i}`),_.setAttribute("height",`${e.height+100+a}`),T.appendChild(_);let S=r.ownerDocument.createElementNS(j,"rect"),M=q.getBoundTextElementPosition(e,y,t),v=i+M.x-e.x,P=a+M.y-e.y;S.setAttribute("x",v.toString()),S.setAttribute("y",P.toString()),S.setAttribute("fill","#000"),S.setAttribute("width",`${y.width}`),S.setAttribute("height",`${y.height}`),S.setAttribute("opacity","1"),T.appendChild(S)}let b=r.ownerDocument.createElementNS(j,"g");y&&b.setAttribute("mask",`url(#mask-${e.id})`),b.setAttribute("stroke-linecap","round"),ie.generateElementShape(e,s).forEach(_=>{let S=so(n,_,Kn);w!==1&&(S.setAttribute("stroke-opacity",`${w}`),S.setAttribute("fill-opacity",`${w}`)),S.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${m} ${p})`),e.type==="line"&&vt(e.points)&&e.backgroundColor!=="transparent"&&S.setAttribute("fill-rule","evenodd"),b.appendChild(S)});let I=lo(e,E,[b,T],s.frameRendering,t);I?(x(I,e),E.appendChild(I)):(x(b,e),E.append(T));break}case"freedraw":{let y=ie.generateElementShape(e,s),T=y?so(n,y,Kn):r.ownerDocument.createElementNS(j,"g");w!==1&&(T.setAttribute("stroke-opacity",`${w}`),T.setAttribute("fill-opacity",`${w}`)),T.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${m} ${p})`),T.setAttribute("stroke","none");let b=r.ownerDocument.createElementNS(j,"path");b.setAttribute("fill",e.strokeColor),b.setAttribute("d",Rs(e)),T.appendChild(b);let L=lo(e,E,[T],s.frameRendering,t);x(L||T,e);break}case"image":{let y=Math.round(e.width),T=Math.round(e.height),b=wt(e)&&o[e.fileId];if(b){let L=`image-${b.id}`,I=r.querySelector(`#${L}`);if(!I){I=r.ownerDocument.createElementNS(j,"symbol"),I.id=L;let v=r.ownerDocument.createElementNS(j,"image");v.setAttribute("width","100%"),v.setAttribute("height","100%"),v.setAttribute("href",b.dataURL),I.appendChild(v),E.prepend(I)}let _=r.ownerDocument.createElementNS(j,"use");if(_.setAttribute("href",`#${L}`),s.exportWithDarkMode&&b.mimeType!==R.svg&&_.setAttribute("filter",ks),_.setAttribute("width",`${y}`),_.setAttribute("height",`${T}`),_.setAttribute("opacity",`${w}`),e.scale[0]!==1||e.scale[1]!==1){let v=e.scale[0]!==1?-y:0,P=e.scale[1]!==1?-T:0;_.setAttribute("transform",`scale(${e.scale[0]}, ${e.scale[1]}) translate(${v} ${P})`)}let S=r.ownerDocument.createElementNS(j,"g");if(S.appendChild(_),S.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${m} ${p})`),e.roundness){let v=r.ownerDocument.createElementNS(j,"clipPath");v.id=`image-clipPath-${e.id}`;let P=r.ownerDocument.createElementNS(j,"rect"),D=Ot(Math.min(e.width,e.height),e);P.setAttribute("width",`${e.width}`),P.setAttribute("height",`${e.height}`),P.setAttribute("rx",`${D}`),P.setAttribute("ry",`${D}`),v.appendChild(P),x(v,e),S.setAttributeNS(j,"clip-path",`url(#${v.id})`)}let M=lo(e,E,[S],s.frameRendering,t);x(M||S,e)}break}case"frame":case"magicframe":{if(s.frameRendering.enabled&&s.frameRendering.outline){let y=document.createElementNS(j,"rect");y.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${m} ${p})`),y.setAttribute("width",`${e.width}px`),y.setAttribute("height",`${e.height}px`),y.setAttribute("rx",pe.radius.toString()),y.setAttribute("ry",pe.radius.toString()),y.setAttribute("fill","none"),y.setAttribute("stroke",pe.strokeColor),y.setAttribute("stroke-width",pe.strokeWidth.toString()),x(y,e)}break}default:if(Y(e)){let y=r.ownerDocument.createElementNS(j,"g");w!==1&&(y.setAttribute("stroke-opacity",`${w}`),y.setAttribute("fill-opacity",`${w}`)),y.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${m} ${p})`);let T=e.text.replace(/\r\n?/g,`
|
|
25
|
+
`).split(`
|
|
26
|
+
`),b=lr(e.fontSize,e.lineHeight),L=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,I=wi(e.fontFamily,e.fontSize,b),_=Wo(e.text)?"rtl":"ltr",S=e.textAlign==="center"?"middle":e.textAlign==="right"||_==="rtl"?"end":"start";for(let v=0;v<T.length;v++){let P=r.ownerDocument.createElementNS(j,"text");P.textContent=T[v],P.setAttribute("x",`${L}`),P.setAttribute("y",`${v*b+I}`),P.setAttribute("font-family",Ga(e)),P.setAttribute("font-size",`${e.fontSize}px`),P.setAttribute("fill",e.strokeColor),P.setAttribute("text-anchor",S),P.setAttribute("style","white-space: pre;"),P.setAttribute("direction",_),P.setAttribute("dominant-baseline","alphabetic"),y.appendChild(P)}let M=lo(e,E,[y],s.frameRendering,t);x(M||y,e)}else throw new Error(`Unimplemented type ${e.type}`)}},Kf=(e,t,n,r,o,i)=>{r&&(e.filter(a=>!Je(a)).forEach(a=>{if(!a.isDeleted){if(Y(a)&&a.containerId&&t.has(a.containerId))return;try{Di(a,t,n,r,o,a.x+i.offsetX,a.y+i.offsetY,i);let s=Z(a,t);s&&Di(s,t,n,r,o,s.x+i.offsetX,s.y+i.offsetY,i)}catch(s){console.error(s)}}}),e.filter(a=>Je(a)).forEach(a=>{if(!a.isDeleted)try{Di(a,t,n,r,o,a.x+i.offsetX,a.y+i.offsetY,i)}catch(s){console.error(s)}}))};g();g();g();var mr=(()=>{if(typeof self>"u")return!1;if("top"in self&&self!==top)try{}catch{return!1}else if("showOpenFilePicker"in self)return"showOpenFilePicker";return!1})(),Qx=mr?import("./file-open-002ab408-MILJ6BM2.js"):import("./file-open-7c801643-BHFKUUBS.js");async function jf(...e){return(await Qx).default(...e)}var u2=mr?import("./directory-open-4ed118d0-57WBH3LL.js"):import("./directory-open-01563666-OLGZGYEQ.js");var e0=mr?import("./file-save-745eba88-CGSHK46Y.js"):import("./file-save-3189631c-IHOU4DOS.js");async function qf(...e){return(await e0).default(...e)}g();var Ci=class extends Error{constructor(t="Couldn't export canvas.",n="CANVAS_ERROR"){super(),this.name=n,this.message=t}},ki=class extends DOMException{constructor(t="Request Aborted"){super(t,"AbortError")}},Gt=class extends Error{code;constructor(t="Image Scene Data Error",n="IMAGE_SCENE_DATA_ERROR"){super(t),this.name="EncodingError",this.code=n}},Ri=class extends Error{code="ELEMENT_HAS_INVALID_INDEX"};var Jf=500,Qf=e=>{let t=e.extensions?.reduce((r,o)=>(r.push(R[o]),r),[]),n=e.extensions?.reduce((r,o)=>o==="jpg"?r.concat(".jpg",".jpeg"):r.concat(`.${o}`),[]);return jf({description:e.description,extensions:n,mimeTypes:t,multiple:e.multiple??!1,legacySetup:(r,o,i)=>{let a=Ud(o,Jf),s=()=>{l(),document.addEventListener("keyup",a),document.addEventListener("pointerup",a),a()},l=()=>{if(i.files?.length){let d=e.multiple?[...i.files]:i.files[0];r(d)}};requestAnimationFrame(()=>{window.addEventListener("focus",s)});let c=window.setInterval(()=>{l()},Jf);return d=>{clearInterval(c),a.cancel(),window.removeEventListener("focus",s),document.removeEventListener("keyup",a),document.removeEventListener("pointerup",a),d&&(console.warn("Opening the file was canceled (legacy-fs)."),d(new ki))}}})},Ws=(e,t)=>qf(e,{fileName:`${t.name}.${t.extension}`,description:t.description,extensions:[`.${t.extension}`]},t.fileHandle);var t0=(e,t)=>{let n={};for(let r of e)!r.isDeleted&&"fileId"in r&&r.fileId&&t[r.fileId]&&(n[r.fileId]=t[r.fileId]);return n},co=(e,t,n,r)=>{let o={type:Ie.excalidraw,version:Oa.excalidraw,source:Ra,elements:r==="local"?Fi(e):rm(e),appState:r==="local"?$o(t):Od(t),files:r==="local"?t0(e,n):void 0};return JSON.stringify(o,null,2)},M2=async(e,t,n,r=t.name||Rd)=>{let o=co(e,t,n,"local"),i=new Blob([o],{type:R.excalidraw});return{fileHandle:await Ws(i,{name:r,extension:"excalidraw",description:"Excalidraw file",fileHandle:em(t.fileHandle)?null:t.fileHandle})}},L2=async(e,t)=>{let n=await Qf({description:"Excalidraw files"});return tm(await Vs(n),e,t,n.handle)},nm=e=>e?.type===Ie.excalidraw&&(!e.elements||Array.isArray(e.elements)&&(!e.appState||typeof e.appState=="object")),Xs=e=>typeof e=="object"&&e&&e.type===Ie.excalidrawLibrary&&(e.version===1||e.version===2),n0=e=>{let t={type:Ie.excalidrawLibrary,version:Oa.excalidrawLibrary,source:Ra,libraryItems:e};return JSON.stringify(t,null,2)},D2=async e=>{let t=n0(e);await Ws(new Blob([t],{type:R.excalidrawlib}),{name:"library",extension:"excalidrawlib",description:"Excalidraw library file"})};g();var r0=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>{t(r)},r.onerror=o=>{n(o)},r.src=e}),om=async({fileIds:e,files:t,imageCache:n})=>{let r=new Map,o=new Map;return await Promise.all(e.reduce((i,a)=>{let s=t[a];return s&&!r.has(a)?(r.set(a,!0),i.concat((async()=>{try{if(s.mimeType===R.binary)throw new Error("Only images can be added to ImageCache");let l=r0(s.dataURL),c={image:l,mimeType:s.mimeType};n.set(a,c);let d=await l;n.set(a,{...c,image:d})}catch{o.set(a,!0)}})())):i},[])),{imageCache:n,updatedFiles:r,erroredFiles:o}},im=e=>e.filter(t=>wt(t)),o0=e=>e?.nodeName.toLowerCase()==="svg",O2=async e=>{let t=new DOMParser().parseFromString(e,R.svg),n=t.querySelector("svg");if(t.querySelector("parsererror")||!o0(n))throw new Error("Invalid SVG");if(n.hasAttribute("xmlns")||n.setAttribute("xmlns",j),!n.hasAttribute("width")||!n.hasAttribute("height")){let o=n.getAttribute("viewBox"),i=n.getAttribute("width")||"50",a=n.getAttribute("height")||"50";if(o){let s=o.match(/\d+ +\d+ +(\d+) +(\d+)/);s&&([,i,a]=s)}n.setAttribute("width",i),n.setAttribute("height",a)}return n.outerHTML};g();g();var lm="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function hr(e,t,n){let r=n[0];if(t!=null&&e>=t)throw new Error(e+" >= "+t);if(e.slice(-1)===r||t&&t.slice(-1)===r)throw new Error("trailing zero");if(t){let a=0;for(;(e[a]||r)===t[a];)a++;if(a>0)return t.slice(0,a)+hr(e.slice(a),t.slice(a),n)}let o=e?n.indexOf(e[0]):0,i=t!=null?n.indexOf(t[0]):n.length;if(i-o>1){let a=Math.round(.5*(o+i));return n[a]}else return t&&t.length>1?t.slice(0,1):n[o]+hr(e.slice(1),null,n)}function cm(e){if(e.length!==dm(e[0]))throw new Error("invalid integer part of order key: "+e)}function dm(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 uo(e){let t=dm(e[0]);if(t>e.length)throw new Error("invalid order key: "+e);return e.slice(0,t)}function am(e,t){if(e==="A"+t[0].repeat(26))throw new Error("invalid order key: "+e);let n=uo(e);if(e.slice(n.length).slice(-1)===t[0])throw new Error("invalid order key: "+e)}function sm(e,t){cm(e);let[n,...r]=e.split(""),o=!0;for(let i=r.length-1;o&&i>=0;i--){let a=t.indexOf(r[i])+1;a===t.length?r[i]=t[0]:(r[i]=t[a],o=!1)}if(o){if(n==="Z")return"a"+t[0];if(n==="z")return null;let i=String.fromCharCode(n.charCodeAt(0)+1);return i>"a"?r.push(t[0]):r.pop(),i+r.join("")}else return n+r.join("")}function i0(e,t){cm(e);let[n,...r]=e.split(""),o=!0;for(let i=r.length-1;o&&i>=0;i--){let a=t.indexOf(r[i])-1;a===-1?r[i]=t.slice(-1):(r[i]=t[a],o=!1)}if(o){if(n==="a")return"Z"+t.slice(-1);if(n==="A")return null;let i=String.fromCharCode(n.charCodeAt(0)-1);return i<"Z"?r.push(t.slice(-1)):r.pop(),i+r.join("")}else return n+r.join("")}function pr(e,t,n=lm){if(e!=null&&am(e,n),t!=null&&am(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=uo(t),c=t.slice(l.length);if(l==="A"+n[0].repeat(26))return l+hr("",c,n);if(l<t)return l;let d=i0(l,n);if(d==null)throw new Error("cannot decrement any more");return d}if(t==null){let l=uo(e),c=e.slice(l.length),d=sm(l,n);return d??l+hr(c,null,n)}let r=uo(e),o=e.slice(r.length),i=uo(t),a=t.slice(i.length);if(r===i)return r+hr(o,a,n);let s=sm(r,n);if(s==null)throw new Error("cannot increment any more");return s<t?s:r+hr(o,null,n)}function Oi(e,t,n,r=lm){if(n===0)return[];if(n===1)return[pr(e,t,r)];if(t==null){let a=pr(e,t,r),s=[a];for(let l=0;l<n-1;l++)a=pr(a,t,r),s.push(a);return s}if(e==null){let a=pr(e,t,r),s=[a];for(let l=0;l<n-1;l++)a=pr(e,a,r),s.push(a);return s.reverse(),s}let o=Math.floor(n/2),i=pr(e,t,r);return[...Oi(e,i,o,r),i,...Oi(i,t,n-o-1,r)]}var Zs=e=>{for(let[t,n]of e.entries()){let r=e[t-1],o=e[t+1];if(!fo(n,r,o))throw new Ri(`Fractional indices invariant for element has been compromised - ["${r}", "${n}", "${o}"] [predecessor, current, successor]`)}};var Ks=(e,t)=>{try{let n=a0(e,t),r=um(e,n);Zs(e.map(o=>r.get(o)?.index||o.index));for(let[o,i]of r)F(o,i,!1)}catch{Rn(e)}return e},Rn=e=>{let t=s0(e),n=um(e,t);for(let[r,o]of n)F(r,o,!1);return e},a0=(e,t)=>{let n=[],r=0;for(;r<e.length;)if(t.has(e[r].id)&&!fo(e[r]?.index,e[r-1]?.index,e[r+1]?.index)){let o=[r-1,r];for(;++r<e.length&&(t.has(e[r].id)&&!fo(e[r]?.index,e[r-1]?.index,e[r+1]?.index));)o.push(r);o.push(r),n.push(o)}else r++;return n},s0=e=>{let t=[],n,r,o=-1,i=0,a=c=>{let d=e[o]?e[o].index:void 0,u=e[c-1]?.index;return!d&&u||d&&u&&u>d?[u,c-1]:[d,o]},s=c=>{let d=e[i]?e[i].index:void 0;if(d&&c<i)return[d,i];let u=i;for(;++u<e.length;){let f=e[u]?.index;if(!d&&f||d&&f&&f>d)return[f,u]}return[void 0,u]},l=0;for(;l<e.length;){let c=e[l].index;if([n,o]=a(l),[r,i]=s(l),fo(c,n,r))l++;else{let d=[o,l];for(;++l<e.length;){let u=e[l].index,[f,m]=a(l),[p,h]=s(l);if(fo(u,f,p))break;[n,o]=[f,m],[r,i]=[p,h],d.push(l)}d.push(i),t.push(d)}}return t},fo=(e,t,n)=>e?t&&n?t<e&&e<n:!t&&n?e<n:t&&!n?t<e:!!e:!1,um=(e,t)=>{let n=new Map;for(let r of t){let o=r.shift(),i=r.pop(),a=Oi(e[o]?.index,e[i]?.index,r.length);for(let s=0;s<r.length;s++){let l=e[r[s]];n.set(l,{index:a[s]})}}return n};g();g();g();g();var fm=e=>{let{angle:t,width:n,height:r,x:o,y:i}=e,a=ar(t),s=o+n/2,l=i+r/2,c=[s,l],d=[];return e.type==="diamond"?d=[Oe([s,i],a,c),Oe([o+n,l],a,c),Oe([s,i+r],a,c),Oe([o,l],a,c)]:d=[Oe([o,i],a,c),Oe([o+n,i],a,c),Oe([o+n,i+r],a,c),Oe([o,i+r],a,c)],{type:"polygon",data:d}},Z2=e=>{let{width:t,height:n,angle:r,x:o,y:i}=e;return{type:"ellipse",data:{center:[o+t/2,i+n/2],angle:r,halfWidth:t/2,halfHeight:n/2}}},mm=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},K2=(e,t=[0,0],n,r)=>{let o=l=>Oe([l[0]+t[0],l[1]+t[1]],ar(n),r),i=mm(e),a=[],s=[0,0];for(let l of i)if(l.op==="move"&&(s=o(l.data)),l.op==="bcurveTo"){let c=o([l.data[0],l.data[1]]),d=o([l.data[2],l.data[3]]),u=o([l.data[4],l.data[5]]);a.push([s,c,d,u]),s=u}return{type:"polycurve",data:a}},l0=e=>{let t=e[0],n=[];for(let r=1;r<e.length;r++){let o=e[r];n.push([t,o]),t=o}return n},j2=(e,t,n=!1)=>{let r=ar(e.angle),o=a=>Oe(ss(a,[e.x,e.y]),r,t),i=l0(e.points.map(a=>o(a)));return n?{type:"polygon",data:ir(i.flat())}:{type:"polyline",data:i}},q2=(e,t,n=[0,0],r,o)=>{let i=d=>Oe([d[0]+n[0],d[1]+n[1]],ar(r),o);if(e.roundness===null)return{type:"polygon",data:ir(e.points.map(d=>i(d)))};let a=mm(t),s=[],l=!1;for(let d of a)d.op==="move"?(l=!l,l&&s.push([d.data[0],d.data[1]])):d.op==="bcurveTo"?l&&(s.push([d.data[0],d.data[1]]),s.push([d.data[2],d.data[3]]),s.push([d.data[4],d.data[5]])):d.op==="lineTo"&&l&&s.push([d.data[0],d.data[1]]);return{type:"polygon",data:er(s,10,5).map(d=>i(d))}};var c0=e=>{if(e.type==="arrow")return!1;let t=!jt(e.backgroundColor)||jo(e)||Je(e)||Y(e);return e.type==="line"?t&&vt(e.points):e.type==="freedraw"?t&&vt(e.points):t||Zo(e)},d0=({x:e,y:t,element:n,shape:r,threshold:o=10,frameNameBound:i=null})=>{let a=c0(n)?hi([e,t],r)||Kr([e,t],r,o):Kr([e,t],r,o);return!a&&i&&(a=hi([e,t],{type:"polygon",data:fm(i).data})),a},js=(e,t,n,r,o=0)=>{let[i,a,s,l]=Ge(n,r);return i-=o,a-=o,s+=o,l+=o,Ai([i,a],[e,t],[s,l])},lI=(e,t)=>!d0(e)&&js(e.x,e.y,e.element,t),cI=(e,t,n)=>n&&hi([e,t],n);var qs=document.createElement("img");qs.src=`data:${R.svg}, ${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1971c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>')}`;var Js=([e,t,n,r],o,i)=>{let a=gf,s=a/i.zoom.value,l=a/i.zoom.value,c=a/i.zoom.value,d=(e+n)/2,u=(t+r)/2,f=(a-8)/(2*i.zoom.value),m=4/i.zoom.value,p=n+m-f,h=t-m-c+f,[E,x]=H(p+s/2,h+l/2,d,u,o);return[E-s/2,x-l/2,s,l]},u0=(e,t,n,[r,o])=>{let i=4/n.zoom.value,[a,s,l,c]=B(e,t),[d,u,f,m]=Js([a,s,l,c],e.angle,n);return r>d-i&&r<d+i+f&&o>u-i&&o<u+m+i},xI=(e,t,n,[r,o],i)=>!e.link||n.selectedElementIds[e.id]?!1:!i&&n.viewModeEnabled&&js(r,o,e,t)?!0:u0(e,t,n,[r,o]);g();var vI=(e,t,n,r,o=!0)=>{e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fill(),o&&e.stroke()},pm=(e,t)=>[e.width/t,e.height/t],hm=({canvas:e,scale:t,normalizedWidth:n,normalizedHeight:r,theme:o,isExporting:i,viewBackgroundColor:a})=>{let s=e.getContext("2d");return s.setTransform(1,0,0,1,0,0),s.scale(t,t),i&&o===Ce.DARK&&(s.filter=zo),typeof a=="string"?((a==="transparent"||a.length===5||a.length===9||/(hsla|rgba)\(/.test(a))&&s.clearRect(0,0,n,r),s.save(),s.fillStyle=a,s.fillRect(0,0,n,r),s.restore()):s.clearRect(0,0,n,r),s};var f0=(e,t,n,r,o,i,a)=>{let l;(E=>(E.Bold="#cccccc",E.Regular="#e5e5e5"))(l||={});let c=-Math.round(o.value/t)*t+n%t,d=-Math.round(o.value/t)*t+r%t,u=Math.min(1/o.value,1),f=1/o.value,m=[u*3,f+(u+f)];e.save(),e.lineWidth=u;for(let p=c;p<c+i+t*2;p+=t){let h=Math.round(p-n)%(5*t)===0;e.beginPath(),e.setLineDash(h?[]:m),e.strokeStyle=h?"#cccccc":"#e5e5e5",e.moveTo(p,d-t),e.lineTo(p,d+a+t*2),e.stroke()}for(let p=d;p<d+a+t*2;p+=t){let h=Math.round(p-r)%(5*t)===0;e.beginPath(),e.setLineDash(h?[]:m),e.strokeStyle=h?"#cccccc":"#e5e5e5",e.moveTo(c-t,p),e.lineTo(c+i+t*2,p),e.stroke()}e.restore()},Em=(e,t,n,r)=>{t.translate(e.x+r.scrollX,e.y+r.scrollY),t.beginPath(),t.roundRect?t.roundRect(0,0,e.width,e.height,pe.radius/r.zoom.value):t.rect(0,0,e.width,e.height),t.clip(),t.translate(-(e.x+r.scrollX),-(e.y+r.scrollY))},zt,gm=(e,t,n,r)=>{if(e.link&&!n.selectedElementIds[e.id]){let[o,i,a,s]=B(e,r),[l,c,d,u]=Js([o,i,a,s],e.angle,n),f=l+d/2,m=c+u/2;if(t.save(),t.translate(n.scrollX+f,n.scrollY+m),t.rotate(e.angle),!zt||zt.zoom!==n.zoom.value){zt=document.createElement("canvas"),zt.zoom=n.zoom.value,zt.width=d*window.devicePixelRatio*n.zoom.value,zt.height=u*window.devicePixelRatio*n.zoom.value;let p=zt.getContext("2d");p.scale(window.devicePixelRatio*n.zoom.value,window.devicePixelRatio*n.zoom.value),p.fillStyle="#fff",p.fillRect(0,0,d,u),p.drawImage(qs,0,0,d,u),p.restore(),t.drawImage(zt,l-f,c-m,d,u)}else t.drawImage(zt,l-f,c-m,d,u);t.restore()}},xm=({canvas:e,rc:t,elementsMap:n,allElementsMap:r,visibleElements:o,scale:i,appState:a,renderConfig:s})=>{if(e===null)return;let{renderGrid:l=!0,isExporting:c}=s,[d,u]=pm(e,i),f=hm({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:u,theme:a.theme,isExporting:c,viewBackgroundColor:a.viewBackgroundColor});f.scale(a.zoom.value,a.zoom.value),l&&a.gridSize&&f0(f,a.gridSize,a.scrollX,a.scrollY,a.zoom,d/a.zoom.value,u/a.zoom.value);let m=new Set;o.forEach(p=>{p.groupIds.length>0&&a.frameToHighlight&&a.selectedElementIds[p.id]&&(on(p,a.frameToHighlight,n)||p.groupIds.find(h=>m.has(h)))&&p.groupIds.forEach(h=>m.add(h))}),o.filter(p=>!Je(p)).forEach(p=>{try{let h=p.frameId||a.frameToHighlight?.id;if(Y(p)&&p.containerId&&n.has(p.containerId))return;if(f.save(),h&&a.frameRendering.enabled&&a.frameRendering.clip){let x=Ni(p,n,a);x&&Bi(p,n,a)&&Em(x,f,s,a),dr(p,n,r,t,f,s,a)}else dr(p,n,r,t,f,s,a);let E=Z(p,r);E&&dr(E,n,r,t,f,s,a),f.restore(),c||gm(p,f,a,n)}catch(h){console.error(h)}}),o.filter(p=>Je(p)).forEach(p=>{try{let h=()=>{if(dr(p,n,r,t,f,s,a),Je(p)&&(c||Ko(p)&&s.embedsValidationStatus.get(p.id)!==!0)&&p.width&&p.height){let x=Li(p);dr(x,n,r,t,f,s,a)}c||gm(p,f,a,n)};if((p.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){f.save();let x=Ni(p,n,a);x&&Bi(p,n,a)&&Em(x,f,s,a),h(),f.restore()}else h()}catch(h){console.error(h)}})},m0=$d(e=>{xm(e)},{trailing:!0}),wm=(e,t)=>{if(t){m0(e);return}xm(e)};var p0="<!-- svg-source:excalidraw -->",h0=(e,t)=>{if(e.width<=t)return e;let r=document.createElement("canvas").getContext("2d");r.font=ue({fontFamily:e.fontFamily,fontSize:e.fontSize});let o=e.text;if(r.measureText(o).width>t)for(let a=o.length;a>0;a--){let s=`${o.slice(0,a)}...`;if(r.measureText(s).width<=t){o=s;break}}return kn(e,{text:o,width:t})},E0=(e,t)=>{let n=[],r=0,o=0;for(let i of e){if(J(i)){Br(i)?r++:o++;let a=_t({x:i.x,y:i.y-pe.nameOffsetY,fontFamily:ce.Assistant,fontSize:pe.nameFontSize,lineHeight:pe.nameLineHeight,strokeColor:t.exportWithDarkMode?pe.nameColorDarkTheme:pe.nameColorLightTheme,text:Am(i,Br(i)?r:o)});a.y-=a.height,a=h0(a,i.width),n.push(a)}n.push(i)}return n},ym=(e,t)=>(t=t||Dt().frameRendering,{enabled:e?!0:t.enabled,outline:e?!1:t.outline,name:e?!1:t.name,clip:e?!0:t.clip}),bm=({elements:e,exportingFrame:t,frameRendering:n,exportWithDarkMode:r})=>{let o;return t?o=_m(e,t):n.enabled&&n.name?o=E0(e,{exportWithDarkMode:r}):o=e,o},vm=async(e,t,n,{exportBackground:r,exportPadding:o=Fa,viewBackgroundColor:i,exportingFrame:a},s=(l,c)=>{let d=document.createElement("canvas");return d.width=l*t.exportScale,d.height=c*t.exportScale,{canvas:d,scale:t.exportScale}})=>{let l=ym(a??null,t.frameRendering??null),c=bm({elements:e,exportingFrame:a,exportWithDarkMode:t.exportWithDarkMode,frameRendering:l});a&&(o=0);let[d,u,f,m]=Qs(a?[a]:tl(c),o),{canvas:p,scale:h=1}=s(f,m),E=Dt(),{imageCache:x}=await om({imageCache:new Map,fileIds:im(c).map(w=>w.fileId),files:n});return wm({canvas:p,rc:bt.canvas(p),elementsMap:bn(X(c)),allElementsMap:bn(X(Rn(e))),visibleElements:c,scale:h,appState:{...t,frameRendering:l,viewBackgroundColor:r?i:null,scrollX:-d+o,scrollY:-u+o,zoom:E.zoom,shouldCacheIgnoreZoom:!1,theme:t.exportWithDarkMode?Ce.DARK:Ce.LIGHT},renderConfig:{canvasBackgroundColor:i,imageCache:x,renderGrid:!1,isExporting:!0,embedsValidationStatus:new Map,elementsPendingErasure:new Set}}),p},Tm=async(e,t,n,r)=>{let o=ym(r?.exportingFrame??null,t.frameRendering??null),{exportPadding:i=Fa,exportWithDarkMode:a=!1,viewBackgroundColor:s,exportScale:l=1,exportEmbedScene:c}=t,{exportingFrame:d=null}=r||{},u=bm({elements:e,exportingFrame:d,exportWithDarkMode:a,frameRendering:o});d&&(i=0);let f="";if(c)try{f=await(await import("./image-BSC5ABC2.js")).encodeSvgMetadata({text:co(e,t,n||{},"local")})}catch(M){console.error(M)}let[m,p,h,E]=Qs(d?[d]:tl(u),i),x=document.createElementNS(j,"svg");x.setAttribute("version","1.1"),x.setAttribute("xmlns",j),x.setAttribute("viewBox",`0 0 ${h} ${E}`),x.setAttribute("width",`${h*l}`),x.setAttribute("height",`${E*l}`),a&&x.setAttribute("filter",zo);let w="https://excalidraw.com/";A.VITE_IS_EXCALIDRAW_NPM_PACKAGE&&(w=window.EXCALIDRAW_ASSET_PATH||`https://unpkg.com/${A.VITE_PKG_NAME}@${A.PKG_VERSION}`,w?.startsWith("/")&&(w=w.replace("/",`${window.location.origin}/`)),w=`${w}/dist/excalidraw-assets/`);let y=-m+i,T=-p+i,b=el(e),L="",I=X(e);for(let M of b){let[v,P,D,z]=B(M,I),O=(D-v)/2-(M.x-v),N=(z-P)/2-(M.y-P);L+=`<clipPath id=${M.id}>
|
|
27
|
+
<rect transform="translate(${M.x+y} ${M.y+T}) rotate(${M.angle} ${O} ${N})"
|
|
28
|
+
width="${M.width}"
|
|
29
|
+
height="${M.height}"
|
|
30
|
+
>
|
|
31
|
+
</rect>
|
|
32
|
+
</clipPath>`}if(x.innerHTML=`
|
|
33
|
+
${p0}
|
|
34
|
+
${f}
|
|
35
|
+
<defs>
|
|
36
|
+
<style class="style-fonts">
|
|
37
|
+
@font-face {
|
|
38
|
+
font-family: "Virgil";
|
|
39
|
+
src: url("${w}Virgil.woff2");
|
|
40
|
+
}
|
|
41
|
+
@font-face {
|
|
42
|
+
font-family: "Cascadia";
|
|
43
|
+
src: url("${w}Cascadia.woff2");
|
|
44
|
+
}
|
|
45
|
+
@font-face {
|
|
46
|
+
font-family: "Assistant";
|
|
47
|
+
src: url("${w}Assistant-Regular.woff2");
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
50
|
+
${L}
|
|
51
|
+
</defs>
|
|
52
|
+
`,t.exportBackground&&s){let M=x.ownerDocument.createElementNS(j,"rect");M.setAttribute("x","0"),M.setAttribute("y","0"),M.setAttribute("width",`${h}`),M.setAttribute("height",`${E}`),M.setAttribute("fill",s),x.appendChild(M)}let _=bt.svg(x),S=r?.renderEmbeddables??!1;return Kf(u,bn(X(u)),_,x,n||{},{offsetX:y,offsetY:T,isExporting:!0,exportWithDarkMode:a,renderEmbeddables:S,frameRendering:o,canvasBackgroundColor:s,embedsValidationStatus:S?new Map(u.filter(M=>J(M)).map(M=>[M.id,!0])):new Map}),x},Qs=(e,t)=>{let[n,r,o,i]=Me(e),a=$e(n,o)+t*2,s=$e(r,i)+t*2;return[n,r,a,s]},JI=(e,t,n)=>{let[,,r,o]=Qs(e,t).map(i=>Math.trunc(i*n));return[r,o]};g();var g0={selection:!0,text:!0,rectangle:!0,diamond:!0,ellipse:!0,line:!0,image:!0,arrow:!0,freedraw:!0,eraser:!1,custom:!0,frame:!0,embeddable:!0,hand:!0,laser:!1,magicframe:!1},x0=e=>Object.keys(ce).includes(e)?ce[e]:qe,Sm=e=>e?{...e,focus:e.focus||0}:null,Er=(e,t)=>{let n={type:t.type||e.type,version:e.version||1,versionNonce:e.versionNonce??0,index:e.index??null,isDeleted:e.isDeleted??!1,id:e.id||st(),fillStyle:e.fillStyle||ne.fillStyle,strokeWidth:e.strokeWidth||ne.strokeWidth,strokeStyle:e.strokeStyle??ne.strokeStyle,roughness:e.roughness??ne.roughness,opacity:e.opacity==null?ne.opacity:e.opacity,angle:e.angle||0,x:t.x??e.x??0,y:t.y??e.y??0,strokeColor:e.strokeColor||ne.strokeColor,backgroundColor:e.backgroundColor||ne.backgroundColor,width:e.width||0,height:e.height||0,seed:e.seed??1,groupIds:e.groupIds??[],frameId:e.frameId??null,roundness:e.roundness?e.roundness:e.strokeSharpness==="round"?{type:qo(e.type)?ke.LEGACY:ke.PROPORTIONAL_RADIUS}:null,boundElements:e.boundElementIds?e.boundElementIds.map(r=>({type:"arrow",id:r})):e.boundElements??[],updated:e.updated??Ct(),link:e.link?fr(e.link):null,locked:e.locked??!1};return("customData"in e||"customData"in t)&&(n.customData="customData"in t?t.customData:e.customData),{...n,...nl(n),...t}},w0=e=>{switch(e.type){case"text":let t=e.fontSize,n=e.fontFamily;if("font"in e){let[i,a]=e.font.split(" ");t=parseFloat(i),n=x0(a)}let r=typeof e.text=="string"&&e.text||"",o=e.lineHeight||(e.height?af(e):yi(e.fontFamily));return e=Er(e,{fontSize:t,fontFamily:n,text:r,textAlign:e.textAlign||Zn,verticalAlign:e.verticalAlign||Bo,containerId:e.containerId??null,originalText:e.originalText||r,lineHeight:o}),!r&&!e.isDeleted&&(e={...e,originalText:r,isDeleted:!0},e=ao(e)),e;case"freedraw":return Er(e,{points:e.points,lastCommittedPoint:null,simulatePressure:e.simulatePressure,pressures:e.pressures});case"image":return Er(e,{status:e.status||"pending",fileId:e.fileId,scale:e.scale||[1,1]});case"line":case"draw":case"arrow":{let{startArrowhead:i=null,endArrowhead:a=e.type==="arrow"?"arrow":null}=e,s=e.x,l=e.y,c=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(c[0][0]!==0||c[0][1]!==0)&&({points:c,x:s,y:l}=q.getNormalizedPoints(e)),Er(e,{type:e.type==="draw"?"line":e.type,startBinding:Sm(e.startBinding),endBinding:Sm(e.endBinding),lastCommittedPoint:null,startArrowhead:i,endArrowhead:a,points:c,x:s,y:l})}case"ellipse":case"rectangle":case"diamond":case"iframe":case"embeddable":return Er(e,{});case"magicframe":case"frame":return Er(e,{name:e.name??null})}return null},y0=(e,t)=>{if(e.boundElements){let n=e.boundElements.slice(),r=new Set;e.boundElements=n.reduce((o,i)=>{let a=t.get(i.id);if(a&&!r.has(i.id)){if(r.add(i.id),a.isDeleted)return o;o.push(i),Y(a)&&!a.containerId&&(a.containerId=e.id)}return o},[])}},b0=(e,t)=>{let n=e.containerId?t.get(e.containerId):null;if(!n){e.containerId=null;return}if(!e.isDeleted&&n.boundElements&&!n.boundElements.find(r=>r.id===e.id)){let r=(n.boundElements||(n.boundElements=[])).slice();r.push({type:"text",id:e.id}),n.boundElements=r}},v0=(e,t)=>{e.frameId&&(t.get(e.frameId)||(e.frameId=null))},Mm=(e,t,n)=>{let r=new Set,o=t?X(t):null,i=Rn((e||[]).reduce((s,l)=>{if(l.type!=="selection"&&!po(l)){let c=w0(l);if(c){let d=o?.get(l.id);d&&d.version>c.version&&(c=ao(c,d.version)),r.has(c.id)&&(c={...c,id:st()}),r.add(c.id),s.push(c)}}return s},[]));if(!n?.repairBindings)return i;let a=X(i);for(let s of i)s.frameId&&v0(s,a),Y(s)&&s.containerId?b0(s,a):s.boundElements&&y0(s,a),n.refreshDimensions&&Y(s)&&Object.assign(s,Mi(s,Ae(s,a),a));return i},T0=(e,t,n)=>{let r=t[e];return r!==void 0?r:n[e]},Im={isSidebarDocked:(e,t)=>["defaultSidebarDockedPreference",e.isSidebarDocked??T0("defaultSidebarDockedPreference",e,t)]},A0=(e,t)=>{e=e||{};let n=Dt(),r={};for(let o of Object.keys(Im))if(o in e){let[i,a]=Im[o](e,n);r[i]=a}for(let[o,i]of Object.entries(n)){let a=e[o],s=t?t[o]:void 0;r[o]=a!==void 0?a:s!==void 0?s:i}return{...r,cursorButton:t?.cursorButton||"up",penDetected:t?.penDetected??(e.penMode?e.penDetected??!1:!1),activeTool:{...Fr(n,r.activeTool.type&&g0[r.activeTool.type]?r.activeTool:{type:"selection"}),lastActiveTool:null,locked:r.activeTool.locked??!1},zoom:typeof e.zoom=="number"?{value:e.zoom}:e.zoom?.value?e.zoom:n.zoom,openSidebar:typeof e.openSidebar=="string"?{name:kd.name}:r.openSidebar}},mo=(e,t,n,r)=>({elements:Mm(e?.elements,n,r),appState:A0(e?.appState,t||null),files:e?.files||{}}),Pm=e=>{let t=Mm(rl(e.elements),null);return t.length?{...e,elements:t}:null},Lm=(e=[],t)=>{let n=[];for(let r of e)if(Array.isArray(r)){let o=Pm({status:t,elements:r,id:st(),created:Date.now()});o&&n.push(o)}else{let o=r,i=Pm({...o,id:o.id||st(),status:o.status||t,created:o.created||Date.now()});i&&n.push(i)}return n};g();g();var lt=32,te=12,an=256,Cm=50,Fn="NOT_SPREADSHEET",gr="VALID_SPREADSHEET",ho=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},ol=(e,t)=>e.slice(1).every(n=>ho(n[t])!==null),Dm=e=>{let t=e[0].length;if(t>2)return{type:Fn,reason:"More than 2 columns"};if(t===1){if(!ol(e,0))return{type:Fn,reason:"Value is not numeric"};let l=ho(e[0][0])===null,c=(l?e.slice(1):e).map(d=>ho(d[0]));return c.length<2?{type:Fn,reason:"Less than two rows"}:{type:gr,spreadsheet:{title:l?e[0][0]:null,labels:null,values:c}}}let n=ol(e,0),r=ol(e,1);if(!n&&!r)return{type:Fn,reason:"Value is not numeric"};let[o,i]=r?[0,1]:[1,0],a=ho(e[0][i])===null,s=a?e.slice(1):e;return s.length<2?{type:Fn,reason:"Less than 2 rows"}:{type:gr,spreadsheet:{title:a?e[0][i]:null,labels:s.map(l=>l[o]),values:s.map(l=>ho(l[i]))}}},_0=e=>{let t=[];for(let n=0;n<e[0].length;n++){let r=[];for(let o=0;o<e.length;o++)r.push(e[o][n]);t.push(r)}return t},km=e=>{let t=e.trim().split(`
|
|
53
|
+
`).map(i=>i.trim().split(" "));if(t.length&&t[0].length!==2&&(t=e.trim().split(`
|
|
54
|
+
`).map(i=>i.trim().split(","))),t.length===0)return{type:Fn,reason:"No values"};let n=t[0].length;if(!t.every(i=>i.length===n))return{type:Fn,reason:"All rows don't have same number of columns"};let o=Dm(t);if(o.type!==gr){let i=Dm(_0(t));if(i.type===gr)return i}return o},Gi=vd(yd),Ve={fillStyle:"hachure",fontFamily:qe,fontSize:xt,opacity:100,roughness:1,strokeColor:G.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Lt.MIDDLE,locked:!1},Rm=e=>{let t=(lt+te)*e.values.length+te,n=an+te*2;return{chartWidth:t,chartHeight:n}},S0=(e,t,n,r,o)=>e.labels?.map((i,a)=>_t({groupIds:[r],backgroundColor:o,...Ve,text:i.length>8?`${i.slice(0,5)}...`:i,x:t+a*(lt+te)+te*2,y:n+te/2,width:lt,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],I0=(e,t,n,r,o)=>{let i=_t({groupIds:[r],backgroundColor:o,...Ve,x:t-te,y:n-te,text:"0",textAlign:"right"}),a=_t({groupIds:[r],backgroundColor:o,...Ve,x:t-te,y:n-an-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},P0=(e,t,n,r,o)=>{let{chartWidth:i,chartHeight:a}=Rm(e),s=Cn({backgroundColor:o,groupIds:[r],...Ve,type:"line",x:t,y:n,startArrowhead:null,endArrowhead:null,width:i,points:[[0,0],[i,0]]}),l=Cn({backgroundColor:o,groupIds:[r],...Ve,type:"line",x:t,y:n,startArrowhead:null,endArrowhead:null,height:a,points:[[0,0],[0,-a]]}),c=Cn({backgroundColor:o,groupIds:[r],...Ve,type:"line",x:t,y:n-an-te,startArrowhead:null,endArrowhead:null,strokeStyle:"dotted",width:i,opacity:Cm,points:[[0,0],[i,0]]});return[s,l,c]},Fm=(e,t,n,r,o,i)=>{let{chartWidth:a,chartHeight:s}=Rm(e),l=e.title?_t({backgroundColor:o,groupIds:[r],...Ve,text:e.title,x:t+a/2,y:n-an-te*2-xt,roundness:null,textAlign:"center"}):null,c=i?io({backgroundColor:o,groupIds:[r],...Ve,type:"rectangle",x:t,y:n-s,width:a,height:s,strokeColor:G.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...l?[l]:[],...S0(e,t,n,r,o),...I0(e,t,n,r,o),...P0(e,t,n,r,o)]},M0=(e,t,n)=>{let r=Math.max(...e.values),o=st(),i=Gi[Math.floor(Math.random()*Gi.length)];return[...e.values.map((s,l)=>{let c=s/r*an;return io({backgroundColor:i,groupIds:[o],...Ve,type:"rectangle",x:t+l*(lt+te)+te,y:n-c-te,width:lt,height:c})}),...Fm(e,t,n,o,i,A.DEV)]},L0=(e,t,n)=>{let r=Math.max(...e.values),o=st(),i=Gi[Math.floor(Math.random()*Gi.length)],a=0,s=[];for(let h of e.values){let E=a*(lt+te),x=-(h/r)*an;s.push([E,x]),a++}let l=Math.max(...s.map(h=>h[0])),c=Math.max(...s.map(h=>h[1])),d=Math.min(...s.map(h=>h[0])),u=Math.min(...s.map(h=>h[1])),f=Cn({backgroundColor:i,groupIds:[o],...Ve,type:"line",x:t+te+lt/2,y:n-te,startArrowhead:null,endArrowhead:null,height:c-u,width:l-d,strokeWidth:2,points:s}),m=e.values.map((h,E)=>{let x=E*(lt+te)+te/2,w=-(h/r)*an+te/2;return io({backgroundColor:i,groupIds:[o],...Ve,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:t+x+lt/2,y:n+w-te*2,width:te,height:te})}),p=e.values.map((h,E)=>{let x=E*(lt+te)+te/2,w=h/r*an+te/2+te;return Cn({backgroundColor:i,groupIds:[o],...Ve,type:"line",x:t+x+lt/2+te/2,y:n-w,startArrowhead:null,endArrowhead:null,height:w,strokeStyle:"dotted",opacity:Cm,points:[[0,0],[0,w]]})});return[...Fm(e,t,n,o,i,A.DEV),f,...p,...m]},wP=(e,t,n,r)=>e==="line"?L0(t,n,r):M0(t,n,r);var LP="clipboard"in navigator&&"readText"in navigator.clipboard,D0="clipboard"in navigator&&"writeText"in navigator.clipboard,DP="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,C0=e=>!!([Ie.excalidraw,Ie.excalidrawClipboard,Ie.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),CP=({types:e,files:t})=>{!e&&!t&&console.warn("createPasteEvent: no types or files provided");let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[r,o]of Object.entries(e))try{if(n.clipboardData?.setData(r,o),n.clipboardData?.getData(r)!==o)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}if(t){let r=-1;for(let o of t){r++;try{if(n.clipboardData?.items.add(o),n.clipboardData?.files[r]!==o)throw new Error(`Failed to set file "${o.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return n},k0=({elements:e,files:t})=>{let n=X(e),r=new Set(e.filter(s=>J(s))),o=!1,i=e.reduce((s,l)=>(wt(l)&&(o=!0,t&&t[l.fileId]&&(s[l.fileId]=t[l.fileId])),s),{});o&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Ie.excalidrawClipboard,elements:e.map(s=>{if(Le(s,n)&&!r.has(Le(s,n))){let l=$s(s);return F(l,{frameId:null}),l}return s}),files:t?i:void 0};return JSON.stringify(a)},Om=async(e,t,n)=>{await il(k0({elements:e,files:t}),n)},R0=e=>{let t=km(e);return t.type===gr?{spreadsheet:t.spreadsheet}:null};function Nm(e){let t=[];for(let n of e.childNodes)if(n.nodeType===3){let r=n.textContent?.trim();r&&t.push({type:"text",value:r})}else if(n instanceof HTMLImageElement){let r=n.getAttribute("src");r&&r.startsWith("http")&&t.push({type:"imageUrl",value:r})}else t=t.concat(Nm(n));return t}var F0=e=>{let t=e.clipboardData?.getData("text/html");if(!t)return null;try{let n=new DOMParser().parseFromString(t,"text/html"),r=Nm(n.body);if(r.length)return{type:"mixedContent",value:r}}catch(n){console.error(`error in parseHTMLFromPaste: ${n.message}`)}return null},kP=async()=>{let e={};try{if(navigator.clipboard?.readText)return{"text/plain":await navigator.clipboard?.readText()}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else throw n}let t;try{t=await navigator.clipboard?.read()}catch(n){if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}for(let n of t)for(let r of n.types)if(Vd(Sd,r))try{e[r]=await(await n.getType(r)).text()}catch(o){console.warn(`Cannot retrieve ${r} from clipboardItem: ${o.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},O0=async(e,t=!1)=>{try{let n=!t&&e&&F0(e);return n?n.value.every(o=>o.type==="text")?{type:"text",value:e.clipboardData?.getData("text/plain")||n.value.map(o=>o.value).join(`
|
|
55
|
+
`).trim()}:n:{type:"text",value:(e.clipboardData?.getData("text/plain")||"").trim()}}catch{return{type:"text",value:""}}},RP=async(e,t=!1)=>{let n=await O0(e,t);if(n.type==="mixedContent")return{mixedContent:n.value};try{let r=!t&&R0(n.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(n.value),o=r.type===Ie.excalidrawClipboardWithAPI;if(C0(r))return{elements:r.elements,files:r.files,text:t?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:o}}catch{}return{text:n.value}},Bm=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[R.png]:e})])}catch(t){if(Vo(e))await navigator.clipboard.write([new window.ClipboardItem({[R.png]:await e})]);else throw t}},il=async(e,t)=>{if(D0)try{await navigator.clipboard.writeText(e||"");return}catch(n){console.error(n)}try{if(t){if(t.clipboardData?.setData("text/plain",e||""),t.clipboardData?.getData("text/plain")!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(n){console.error(n)}if(!N0(e))throw new Error("Error copying to clipboard.")},N0=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",n=document.createElement("textarea");n.style.border="0",n.style.padding="0",n.style.margin="0",n.style.position="absolute",n.style[t?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;n.style.top=`${r}px`,n.style.fontSize="12pt",n.setAttribute("readonly",""),n.value=e,document.body.appendChild(n);let o=!1;try{n.select(),n.setSelectionRange(0,n.value.length),o=document.execCommand("copy")}catch(i){console.error(i)}return n.remove(),o};var B0=({elements:e,appState:t,files:n,maxWidthOrHeight:r,getDimensions:o,exportPadding:i,exportingFrame:a})=>{let{elements:s,appState:l}=mo({elements:e,appState:t},null,null),{exportBackground:c,viewBackgroundColor:d}=l;return vm(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},n||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(u,f)=>{let m=document.createElement("canvas");if(r){typeof o=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let h=Math.max(u,f),E=r<h?r/h:t?.exportScale??1;return m.width=u*E,m.height=f*E,{canvas:m,scale:E}}let p=o?.(u,f)||{width:u,height:f};return m.width=p.width,m.height=p.height,{canvas:m,scale:p.scale??1}})},G0=async e=>{let{mimeType:t=R.png,quality:n}=e;t===R.png&&typeof n=="number"&&console.warn(`"quality" will be ignored for "${R.png}" mimeType`),t==="image/jpg"&&(t=R.jpg),t===R.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${R.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await B0(e);return n=n||(/image\/jpe?g/.test(t)?.92:.8),new Promise((o,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&t===R.png&&e.appState?.exportEmbedScene&&(a=await Gm({blob:a,metadata:co(e.elements,e.appState,e.files||{},"local")})),o(a)},t,n)})},z0=async({elements:e,appState:t=Dt(),files:n={},exportPadding:r,renderEmbeddables:o,exportingFrame:i})=>{let{elements:a,appState:s}=mo({elements:e,appState:t},null,null),l={...s,exportPadding:r};return Tm(a,l,n,{exportingFrame:i,renderEmbeddables:o})},YP=async e=>{if(e.type==="svg"){let t=await z0(e);await il(t.outerHTML)}else if(e.type==="png")await Bm(G0(e));else if(e.type==="json")await Om(e.elements,e.files);else throw new Error("Invalid export type")};g();var H0=e=>e.type==="diamond"?[[e.width/2,0],[e.width,e.height/2],[e.width/2,e.height],[0,e.height/2]]:[[0,0],[0+e.width,0],[0+e.width,e.height],[0,e.height]],U0=e=>Q(e)||fe(e)?e.points:H0(e),zm=e=>{let t=e.reduce((n,[r,o])=>(n.minY=Math.min(n.minY,o),n.minX=Math.min(n.minX,r),n.maxX=Math.max(n.maxX,r),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},Um=e=>{let t=U0(e),{cx:n,cy:r}=zm(t),o=[n,r],i=t.map(d=>me([d[0],d[1]],o,e.angle)),{minX:a,minY:s,maxX:l,maxY:c}=zm(i);return[a+e.x,s+e.y,l+e.x,c+e.y]},Hm=(e,t,n=!1)=>{let r=Um(e),o=t[0]<=r[0]&&t[2]>=r[2]&&t[1]<=r[1]&&t[3]>=r[3];return n?o?!0:r[0]<=t[0]&&r[2]>=t[2]&&r[1]<=t[1]&&r[3]>=t[3]:o},$0=(e,t)=>{let n=Um(e);return(oo(n[0],t[0],t[2])||oo(t[0],n[0],n[2]))&&(oo(n[1],t[1],t[3])||oo(t[1],n[1],n[3]))},$m=({elements:e,bounds:t,type:n,errorMargin:r=0})=>{$a(t)&&(t=Ge(t,X(e)));let o=[t[0]-r,t[1]-r,t[2]+r,t[3]+r],i=new Set;for(let a of e){if(i.has(a.id))continue;if(n==="overlap"?$0(a,o):n==="inside"?Hm(a,o):Hm(a,o,!0)){if(i.add(a.id),a.boundElements)for(let l of a.boundElements)i.add(l.id);Y(a)&&a.containerId&&i.add(a.containerId),ee(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};g();function Ym(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 Xm(e,t){return e[0]*t[1]-t[0]*e[1]}function Y0(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function zi(e,t){return[e[0]-t[0],e[1]-t[1]]}var W0=1e-6;function Wm(e,t){let n=zi(e[1],e[0]),r=zi(t,e[0]),o=Xm(n,r);return Math.abs(o)<W0}function al(e,t){let n=zi(e[1],e[0]),r=zi(t,e[0]);return Xm(n,r)<0}function Vm(e,t){return Wm(e,t[0])||Wm(e,t[1])||(al(e,t[0])?!al(e,t[1]):al(e,t[1]))}function Zm(e,t){return Y0(Ym(e),Ym(t))&&Vm(e,t)&&Vm(t,e)}var gM=(e,t,n)=>{let r=X(e);for(let o of t)if(o.frameId){let i=n.get(o.id),a=n.get(o.frameId);if(i){let s=r.get(i);s&&F(s,{frameId:a??o.frameId},!1)}}};function Km(e,t,n){let r=zs(t,n),o=zs(e,n);return r.some(a=>o.some(s=>Zm(a,s)))}var jm=(e,t,n)=>Hi(Ei(e,t,n,!1)).filter(r=>!J(r)&&!r.frameId||r.frameId===t.id),qm=(e,t,n,r)=>Ei(e,t,r).some(o=>o.id===n.id);var Jm=(e,t,n)=>{let[r,o,i,a]=B(t,n),[s,l,c,d]=Me(e);return r<=s&&o<=l&&i>=c&&a>=d},on=(e,t,n)=>Jm([e],t,n)||Km(e,t,n)||qm([t],e,t,n),xM=(e,t,n)=>{let[r,o,i,a]=B(t,n);return Ai([r,o],[e.x,e.y],[i,a])};var wM=e=>{let t=new Map;for(let n of e){let r=J(n)?n.id:n.frameId;r&&!t.has(r)&&t.set(r,Eo(e,r))}return t},Eo=(e,t)=>{let n=[];for(let r of e.values())r.frameId===t&&n.push(r);return n},el=e=>e.filter(t=>J(t)),tl=e=>{let t=X(el(e));return e.filter(n=>t.has(n.id)||!n.frameId||!t.has(n.frameId))},yM=(e,t,n,r)=>{let o=Eo(e,t.id),i=new Set(o),a=new Set([...jm(e,t,r),...o.filter(f=>qm(e,f,t,r))]),s=o.filter(f=>!a.has(f)),l=new Set(Array.from(a).flatMap(f=>f.groupIds));for(let f of s)if(!Km(f,t,r))f.groupIds.length===0&&i.delete(f);else if(f.groupIds.length>0)for(let m of f.groupIds)l.add(m);for(let f of s)if(f.groupIds.length>0){let m=!0;for(let p of f.groupIds)l.has(p)&&(m=!1);m&&i.delete(f)}let c=Array.from(a).filter(f=>f.groupIds.length===0);for(let f of c)i.add(f);let d=Array.from(a).filter(f=>f.groupIds.length>0),u=Df(d,n);for(let[f,m]of Object.entries(u))if(m){let p=ur(e,f);if(Jm(p,t,r))for(let h of p)i.add(h)}return[...i].filter(f=>!(Y(f)&&f.containerId))},bM=(e,t,n)=>Hi(e,jm(e,t,n)),Le=(e,t)=>e.frameId&&t.get(e.frameId)||null,vM=(e,t)=>{let n=new Set,r=X(e);e=Hi(e);for(let a of e)J(a)&&a.id!==t.id&&n.add(a.id);let o=new Set,i=[];for(let a of e)if(!(J(a)||a.frameId&&n.has(a.frameId)))if(a.groupIds.length){let s=a.groupIds.at(-1);if(!o.has(s)){o.add(s);let l=ur(e,s);if(l.some(c=>on(c,t,r)))for(let c of l)i.push(c)}}else on(a,t,r)&&i.push(a);return i},V0=(e,t,n)=>{let r=X(e),o=new Map;for(let l of e.values())l.frameId===n.id&&o.set(l.id,!0);let i=new Set(t.map(l=>l.id)),a=[],s=new Set;for(let l of t)J(l)&&l.id!==n.id&&s.add(l.id);for(let l of Hi(e,t)){if(J(l)||l.frameId&&s.has(l.frameId))continue;o.has(l.id)||a.push(l);let c=Z(l,r);c&&!i.has(c.id)&&!o.has(c.id)&&a.push(c)}for(let l of a)F(l,{frameId:n.id},!1);return e},Qm=(e,t)=>{let n=new Map,r=new Map;for(let o of e)if(o.frameId){n.set(o.id,o);let i=r.get(o.frameId)||[];i.push(o);let a=Z(o,t);a&&(n.set(a.id,a),i.push(a)),r.set(o.frameId,i)}for(let[,o]of n)F(o,{frameId:null},!1)},X0=(e,t)=>{let n=Eo(e,t.id);return Qm(n,X(e)),e},TM=(e,t,n,r)=>V0(X0(e,n),t,n).slice(),AM=(e,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),o=new Set(r);if(t.editingGroupId)for(let s of r)s.groupIds.length===0?o.add(s):s.groupIds.flatMap(l=>ur(e,l)).forEach(l=>o.add(l));let i=new Set,a=X(e);return o.forEach(s=>{s.frameId&&!J(s)&&!Bi(s,a,t)&&i.add(s)}),i.size>0&&Qm(i,a),e},Hi=(e,t)=>{let n=new Set,r=t||e;for(let a of r.values()){let s=a.groupIds[a.groupIds.length-1];s&&n.add(s)}let o=new Set;for(let a of n)ur(e,a).some(s=>J(s))&&o.add(a);let i=[];for(let a of r.values())o.has(a.groupIds[a.groupIds.length-1])||i.push(a);return i},Ni=(e,t,n)=>{let r=Y(e)&&Ae(e,t)||e;return n.selectedElementIds[r.id]&&n.selectedElementsAreBeingDragged?n.frameToHighlight:Le(r,t)},Bi=(e,t,n)=>{let r=Ni(e,t,n),o=Y(e)&&Ae(e,t)||e;if(r){if(!n.selectedElementIds[e.id]||!n.selectedElementsAreBeingDragged)return!0;if(o.groupIds.length===0)return on(o,r,t);let i=new Set(o.groupIds.flatMap(a=>ur(t,a)));if(n.editingGroupId&&n.selectedElementsAreBeingDragged){let a=new Set(ot(t,n));if(n.frameToHighlight!==null)return!0;a.forEach(l=>{i.delete(l)})}for(let a of i)if(J(a))return!1;for(let a of i)if(on(a,r,t))return!0}return!1},Am=(e,t)=>e.name===null?Br(e)?`Frame ${t}`:`AI Frame $${t}`:e.name,_m=(e,t)=>$m({elements:e,bounds:t,type:"overlap"}).filter(n=>!n.frameId||n.frameId===t.id);var Z0=e=>{let t=new Set;return e.forEach(n=>{J(n)&&t.add(n.id)}),e.filter(n=>!(n.frameId&&t.has(n.frameId)))},Ei=(e,t,n,r=!0)=>{let[o,i,a,s]=B(t,n),l=e.filter(c=>{let[d,u,f,m]=Ge(c,n),p=Le(c,n);if(p){let[h,E,x,w]=Ge(p,n);d=Math.max(h,d),u=Math.max(E,u),f=Math.min(x,f),m=Math.min(w,m)}return c.locked===!1&&c.type!=="selection"&&!Ye(c)&&o<=d&&i<=u&&a>=f&&s>=m});return l=r?Z0(l):l,l=l.filter(c=>{let d=Le(c,n);return d?on(c,d,n):!0}),l},CM=(e,t,n,r)=>{let o=new Set(t.map(i=>i.id));return e.filter(i=>{let a=ep(i,n.width,n.height,n,r);return!o.has(i.id)&&a})},_g=function(){let e=null,t=null,n=null,r=(o,i)=>(n!=null&&o===e&&i.selectedElementIds===t||(n=o.some(a=>i.selectedElementIds[a.id]),e=o,t=i.selectedElementIds),n);return r.clearCache=()=>{e=null,t=null,n=null},r}(),Sg=(e,t,n)=>{let r=Array.from(new Set(ot(e,t).map(o=>n(o))));return r.length===1?r[0]:null},ot=(e,t,n)=>{let r=[];for(let o of e.values()){if(t.selectedElementIds[o.id]){r.push(o);continue}if(n?.includeBoundTextElement&&Ye(o)&&t.selectedElementIds[o?.containerId]){r.push(o);continue}}if(n?.includeElementsInFrames){let o=[];return r.forEach(i=>{J(i)&&Eo(e,i.id).forEach(a=>o.push(a)),o.push(i)}),o}return r},Ig=(e,t)=>t.editingElement?[t.editingElement]:ot(e,t,{includeBoundTextElement:!0}),Us=(e,t)=>Ha(t.selectedElementIds,e)?t.selectedElementIds:e;var tp=e=>{let t=new Map,n=[];for(let r of e)r.isDeleted||(n.push(r),t.set(r.id,r));return{elementsMap:t,elements:n}},K0=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],n="";for(let r of t)n+=`${r}:${e[r]?"1":"0"}`;return n},np=e=>typeof e=="string",sl=class e{static sceneMapByElement=new WeakMap;static sceneMapById=new Map;static mapElementToScene(t,n){np(t)?this.sceneMapById.set(t,n):(this.sceneMapByElement.set(t,n),this.sceneMapById.set(t.id,n))}static getScene(t){return np(t)?this.sceneMapById.get(t)||null:this.sceneMapByElement.get(t)||null}callbacks=new Set;nonDeletedElements=[];nonDeletedElementsMap=bn(new Map);elements=[];nonDeletedFramesLikes=[];frames=[];elementsMap=bn(new Map);selectedElementsCache={selectedElementIds:null,elements:null,cache:new Map};versionNonce;getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(t){let n=K0(t),r=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===r&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let i=this.selectedElementsCache.cache.get(n);if(i)return i}else t?.elements==null&&this.selectedElementsCache.cache.clear();let o=ot(r,{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}getVersionNonce(){return this.versionNonce}getNonDeletedElement(t){let n=this.getElement(t);return n&&rp(n)?n:null}mapElements(t){let n=!1,r=this.elements.map(o=>{let i=t(o);return i!==o&&(n=!0),i});return n&&this.replaceAllElements(r),n}replaceAllElements(t){let n=t instanceof Array?t:Array.from(t.values()),r=[];(A.DEV||A.MODE===_d.TEST)&&Zs(n.map(i=>i.index)),this.elements=Rn(n),this.elementsMap.clear(),this.elements.forEach(i=>{J(i)&&r.push(i),this.elementsMap.set(i.id,i),e.mapElementToScene(i,this)});let o=tp(this.elements);this.nonDeletedElements=o.elements,this.nonDeletedElementsMap=o.elementsMap,this.frames=r,this.nonDeletedFramesLikes=tp(this.frames).elements,this.informMutation()}informMutation(){this.versionNonce=At();for(let t of Array.from(this.callbacks))t()}addCallback(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(),e.sceneMapById.forEach((t,n)=>{t===this&&e.sceneMapById.delete(n)}),this.callbacks.clear()}insertElementAtIndex(t,n){if(!Number.isFinite(n)||n<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let r=[...this.elements.slice(0,n),t,...this.elements.slice(n)];Ks(r,X([t])),this.replaceAllElements(r)}insertElementsAtIndex(t,n){if(!Number.isFinite(n)||n<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let r=[...this.elements.slice(0,n),...t,...this.elements.slice(n)];Ks(r,X(t)),this.replaceAllElements(r)}insertElement=t=>{let n=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,n)};insertElements=t=>{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},it=sl;var F=(e,t,n=!0)=>{let r=!1,{points:o,fileId:i}=t;typeof o<"u"&&(t={...Sf(o),...t});for(let a in t){let s=t[a];if(typeof s<"u"){if(e[a]===s&&(typeof s!="object"||s===null||a==="groupIds"||a==="scale"))continue;if(a==="scale"){let l=e[a],c=s;if(l[0]===c[0]&&l[1]===c[1])continue}else if(a==="points"){let l=e[a],c=s;if(l.length===c.length){let d=!1,u=l.length;for(;--u;){let f=l[u],m=c[u];if(f[0]!==m[0]||f[1]!==m[1]){d=!0;break}}if(!d)continue}}e[a]=s,r=!0}}return r&&((typeof t.height<"u"||typeof t.width<"u"||typeof i<"u"||typeof o<"u")&&ie.delete(e),e.version++,e.versionNonce=At(),e.updated=Ct(),n&&it.getScene(e)?.informMutation()),e},kn=(e,t)=>{let n=!1;for(let r in t){let o=t[r];if(typeof o<"u"){if(e[r]===o&&(typeof o!="object"||o===null))continue;n=!0}}return n?{...e,...t,updated:Ct(),version:e.version+1,versionNonce:At()}:e},ao=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=At(),e.updated=Ct(),e);var po=e=>Q(e)||fe(e)?e.points.length<2:e.width===0&&e.height===0,ep=(e,t,n,r,o)=>{let[i,a,s,l]=Ge(e,o),c=Or({clientX:r.offsetLeft,clientY:r.offsetTop},r),d=Or({clientX:r.offsetLeft+t,clientY:r.offsetTop+n},r);return c.x<=s&&c.y<=l&&d.x>=i&&d.y>=a},Ui=(e,t,n)=>{let r=Math.abs(t),o=Math.abs(n);if(e==="line"||e==="arrow"||e==="freedraw"){let i=Math.round(Math.atan(o/r)/gt)*gt;i===0?n=0:i===Math.PI/2?t=0:n=r*Math.tan(i)*Math.sign(n)||n}else e!=="selection"&&(n=r*Math.sign(n));return{width:t,height:n}},_s=(e,t,n,r)=>{let o=n-e,i=r-t,a=Math.round(Math.atan(i/o)/gt)*gt;if(a===0)i=0;else if(a===Math.PI/2)o=0;else{let s=Math.tan(a),l=-1,c=t-s*e,d=-1/s,u=-1,f=r-d*n,m=(l*f-u*c)/(s*u-d*l),p=(c*d-f*s)/(s*u-d*l);o=m-e,i=p-t}return{width:o,height:i}};var nl=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};g();var op={mouse:8,pen:16,touch:28},j0=16,cl={e:!0,s:!0,n:!0,w:!0},uL={e:!0,s:!0,n:!0,w:!0,rotation:!0},q0={e:!0,s:!0,n:!0,w:!0},ip={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},ll={e:!0,s:!0,n:!0,w:!0},Ht=(e,t,n,r,o,i,a)=>{let[s,l]=H(e+n/2,t+r/2,o,i,a);return[s-n/2,l-r/2,n,r]},$i=([e,t,n,r,o,i],a,s,l,c={},d=4)=>{let u=op[l],f=u/s.value,m=u/s.value,p=u/s.value,h=u/s.value,E=n-e,x=r-t,w=d/s.value,y=(u-Go*2)/(2*s.value),T={nw:c.nw?void 0:Ht(e-w-p+y,t-w-h+y,f,m,o,i,a),ne:c.ne?void 0:Ht(n+w-y,t-w-h+y,f,m,o,i,a),sw:c.sw?void 0:Ht(e-w-p+y,r+w-y,f,m,o,i,a),se:c.se?void 0:Ht(n+w-y,r+w-y,f,m,o,i,a),rotation:c.rotation?void 0:Ht(e+E/2-f/2,t-w-h+y-j0/s.value,f,m,o,i,a)},b=5*op.mouse/s.value;return Math.abs(E)>b&&(c.n||(T.n=Ht(e+E/2-f/2,t-w-h+y,f,m,o,i,a)),c.s||(T.s=Ht(e+E/2-f/2,r+w-y,f,m,o,i,a))),Math.abs(x)>b&&(c.w||(T.w=Ht(e-w-p+y,t+x/2-m/2,f,m,o,i,a)),c.e||(T.e=Ht(n+w-y,t+x/2-m/2,f,m,o,i,a))),T},dl=(e,t,n,r="mouse")=>{if(e.locked)return{};let o={};if(e.type==="freedraw"||Q(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?o=ll:a[0]>0&&a[1]<0?o=ip:a[0]>0&&a[1]>0?o=ll:a[0]<0&&a[1]>0?o=ip:a[0]<0&&a[1]<0&&(o=ll)}}else Y(e)?o=q0:J(e)&&(o={rotation:!0});let i=Q(e)?Go+8:Go;return $i(B(e,n,!0),e.angle,t,r,o,i)},fL=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let n=e[0];return Q(n)?n.points.length>2:!0};g();var fl=(e,t,n)=>t>=e[0]&&t<=e[0]+e[2]&&n>=e[1]&&n<=e[1]+e[3],ap=(e,t,n,r,o,i,a)=>{if(!n.selectedElementIds[e.id])return!1;let{rotation:s,...l}=dl(e,i,t,a);if(s&&fl(s,r,o))return"rotation";let c=Object.keys(l).filter(d=>{let u=l[d];return u?fl(u,r,o):!1});return c.length>0?c[0]:!1},J0=(e,t,n,r,o,i,a)=>e.reduce((s,l)=>{if(s)return s;let c=ap(l,a,t,n,r,o,i);return c?{element:l,transformHandleType:c}:null},null),Q0=([e,t,n,r],o,i,a,s)=>{let l=$i([e,t,n,r,(e+n)/2,(t+r)/2],0,a,s,cl);return Object.keys(l).find(d=>{let u=l[d];return u&&fl(u,o,i)})||!1},ul=["ns","nesw","ew","nwse"],ew=(e,t)=>{let n=ul.indexOf(e);if(n>=0){let r=Math.round(t/(Math.PI/4));e=ul[(n+r)%ul.length]}return e},tw=e=>{let{element:t,transformHandleType:n}=e,r=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":r?o="nesw":o="nwse";break;case"ne":case"sw":r?o="nwse":o="nesw";break;case"rotation":return"grab"}return o&&t&&(o=ew(o,t.angle)),o?`${o}-resize`:""};g();var Yi=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e,nw=(e,t,n,r,o,i,a,s,l,c,d)=>{if(n.length===1){let[u]=n;return t==="rotation"?(rw(u,r,s,l,o),tn(u,r)):Y(u)&&(t==="nw"||t==="ne"||t==="sw"||t==="se")?(aw(u,r,t,i,s,l),tn(u,r)):t&&sw(e,a,u,r,t,i,s,l),!0}else if(n.length>1){if(t==="rotation")return cw(e,n,r,s,l,o,c,d),!0;if(t==="nw"||t==="ne"||t==="sw"||t==="se")return lw(e,n,r,t,i,s,l),!0}return!1},rw=(e,t,n,r,o)=>{let[i,a,s,l]=B(e,t),c=(i+s)/2,d=(a+l)/2,u;J(e)?u=0:(u=5*Math.PI/2+Math.atan2(r-d,n-c),o&&(u+=gt/2,u-=u%gt),u=Yi(u));let f=Ln(e);if(F(e,{angle:u}),f){let m=it.getScene(e)?.getElement(f);m&&!ee(e)&&F(m,{angle:u})}},ow=(e,t,n,r)=>Q(e)||fe(e)?{points:rn(0,t,rn(1,n,e.points,r),r)}:{},ml=(e,t,n)=>{let r=e.width;if(Ye(e)){let a=Ae(e,t);a&&(r=at(a,e))}let i=e.fontSize*(n/r);return i<No?null:{size:i}},iw=(e,t)=>({n:/^(n|ne|nw)$/.test(e)||t&&/^(s|se|sw)$/.test(e),s:/^(s|se|sw)$/.test(e)||t&&/^(n|ne|nw)$/.test(e),w:/^(w|nw|sw)$/.test(e)||t&&/^(e|ne|se)$/.test(e),e:/^(e|ne|se)$/.test(e)||t&&/^(w|nw|sw)$/.test(e)}),aw=(e,t,n,r,o,i)=>{let[a,s,l,c]=B(e,t),d=(a+l)/2,u=(s+c)/2,[f,m]=H(o,i,d,u,-e.angle),p;switch(n){case"se":p=Math.max((f-a)/(l-a),(m-s)/(c-s));break;case"nw":p=Math.max((l-f)/(l-a),(c-m)/(c-s));break;case"ne":p=Math.max((f-a)/(l-a),(c-m)/(c-s));break;case"sw":p=Math.max((l-f)/(l-a),(m-s)/(c-s));break}if(p>0){let h=e.width*p,E=e.height*p,x=ml(e,t,h);if(x===null)return;let[w,y,T,b]=Dn(e,h,E,!1),L=(a-w)/2,I=(s-y)/2,_=(l-T)/2,S=(c-b)/2,[M,v]=Ti(iw(n,r),e.x,e.y,e.angle,L,I,_,S);F(e,{fontSize:x.size,width:h,height:E,x:M,y:v})}},sw=(e,t,n,r,o,i,a,s)=>{let l=e.get(n.id),[c,d,u,f]=Dn(l,l.width,l.height,!0),m=[c,d],p=[u,f],h=Jr(m,p),E=me([a,s],h,-l.angle),[x,w,y,T]=Dn(n,n.width,n.height,!0),b=y-x,L=T-w,I=p[0]-m[0],_=p[1]-m[1],S=I/b,M=_/L,v={},P=Z(n,r);o.includes("e")&&(S=(E[0]-m[0])/b),o.includes("s")&&(M=(E[1]-m[1])/L),o.includes("w")&&(S=(p[0]-E[0])/b),o.includes("n")&&(M=(p[1]-E[1])/L);let D=l.width,z=l.height,O=n.width*S,N=n.height*M;if(i&&(O=2*O-D,N=2*N-z),t){let _e=Math.abs(O)/D,Nn=Math.abs(N)/z;if(o.length===1&&(N*=_e,O*=Nn),o.length===2){let un=Math.max(_e,Nn);O=D*un*Math.sign(O),N=z*un*Math.sign(N)}}if(P){let _e=e.get(P.id);if(_e&&(v={fontSize:_e.fontSize}),t){let Nn={...n,width:O,height:N},un=ml(P,r,at(Nn,P));if(un===null)return;v={fontSize:un.size}}else{let Nn=df(ue(P),P.lineHeight),un=sf(P.fontSize,P.lineHeight);O=Math.max(O,Nn),N=Math.max(N,un)}}let[C,U,V,K]=Dn(l,O,N,!0),ye=V-C,he=K-U,ae=[...m];if(["n","w","nw"].includes(o)&&(ae=[p[0]-Math.abs(ye),p[1]-Math.abs(he)]),o==="ne"){let _e=[m[0],p[1]];ae=[_e[0],_e[1]-Math.abs(he)]}if(o==="sw"){let _e=[p[0],m[1]];ae=[_e[0]-Math.abs(ye),_e[1]]}t&&(["s","n"].includes(o)&&(ae[0]=h[0]-ye/2),["e","w"].includes(o)&&(ae[1]=h[1]-he/2));let ct=O<0,sn=N<0;ct&&(o.includes("e")&&(ae[0]-=Math.abs(ye)),o.includes("w")&&(ae[0]+=Math.abs(ye))),sn&&(o.includes("s")&&(ae[1]-=Math.abs(he)),o.includes("n")&&(ae[1]+=Math.abs(he))),i&&(ae[0]=h[0]-Math.abs(ye)/2,ae[1]=h[1]-Math.abs(he)/2);let ge=l.angle,On=me(ae,h,ge),ln=[ae[0]+Math.abs(ye)/2,ae[1]+Math.abs(he)/2],cn=me(ln,h,ge);ae=me(On,cn,-ge);let xe=[...ae],dn=l.x-C,be=l.y-U;xe[0]+=dn,xe[1]+=be;let Ep=xe[0],gp=xe[1],wl,yl;(Q(n)||fe(n))&&(wl=rn(1,N,l.points,!0),yl=rn(0,O,wl,!0));let $t={width:Math.abs(O),height:Math.abs(N),x:Ep,y:gp,points:yl};if("scale"in n&&"scale"in l&&F(n,{scale:[(Math.sign(V-l.x)||l.scale[0])*l.scale[0],(Math.sign(K-l.y)||l.scale[1])*l.scale[1]]}),ee(n)&&P&&t){let _e=$t.width/n.width*P.fontSize;if(_e<No)return;v.fontSize=_e}$t.width!==0&&$t.height!==0&&Number.isFinite($t.x)&&Number.isFinite($t.y)&&(F(n,$t),tn(n,r,{newSize:{width:$t.width,height:$t.height}}),P&&v!=null&&F(P,{fontSize:v.fontSize}),Pn(n,r,o,t))},lw=(e,t,n,r,o,i,a)=>{let s=t.reduce((v,P)=>{let D=e.get(P.id);return D&&v.push({orig:D,latest:P}),v},[]),l=s.reduce((v,{orig:P})=>{if(!Q(P))return v;let D=Ln(P);if(!D)return v;let z=e.get(D)??null;if(!Ye(z))return v;let O=q.getBoundTextElementPosition(P,z,n);return[...v,{...z,...O}]},[]),{minX:c,minY:d,maxX:u,maxY:f,midX:m,midY:p}=Mf(s.map(({orig:v})=>v).concat(l)),h=r,E={ne:[c,f],se:[c,d],sw:[u,d],nw:[u,f]},[x,w]=o?[m,p]:E[h],y=Math.max(Math.abs(i-x)/(u-c)||0,Math.abs(a-w)/(f-d)||0)*(o?2:1);if(y===0)return;let T={ne:[i>=x,a<=w],se:[i>=x,a>=w],sw:[i<=x,a>=w],nw:[i<=x,a<=w]},[b,L]=T[h].map(v=>v?1:-1),I=b<0,_=L<0,S=[];for(let{orig:v,latest:P}of s){if(Y(v)&&Ye(v))continue;let D=v.width*y,z=v.height*y,O=Yi(v.angle*b*L),N=Q(v)||fe(v),C=v.x-x,U=v.y-w,V=I&&!N?D:0,K=_&&!N?z:0,ye=x+b*(C*y+V),he=w+L*(U*y+K),ae=ow(v,D*b,z*L,!1),ct={x:ye,y:he,width:D,height:z,angle:O,...ae};if(Zo(v)&&s.length===1&&(ct.scale=[v.scale[0]*b,v.scale[1]*L]),Q(v)&&(I||_)){let ge=sr(v,v.points),On=sr({...v,x:ye,y:he},ae.points),ln=[v.x,v.y],cn=[ye,he],xe=dn=>{let be=dn==="x"?0:1;return(On[be+2]-cn[be]-(ln[be]-ge[be])*y+(ge[be+2]-ln[be])*y-(cn[be]-On[be]))/2};I&&(ct.x-=xe("x")),_&&(ct.y-=xe("y"))}if(Y(v)){let ge=ml(v,n,D);if(!ge)return;ct.fontSize=ge.size}let sn=e.get(Ln(v)??"");if(sn){let ge=sn.fontSize*y;if(ge<No)return;ct.boundTextFontSize=ge}S.push({element:P,update:ct})}let M=S.map(({element:v})=>v);for(let{element:v,update:{boundTextFontSize:P,...D}}of S){let{width:z,height:O,angle:N}=D;F(v,D,!1),tn(v,n,{simultaneouslyUpdated:M,newSize:{width:z,height:O}});let C=Z(v,n);C&&P&&(F(C,{fontSize:P,angle:Q(v)?void 0:N},!1),Pn(v,n,r,!0))}it.getScene(S[0].element)?.informMutation()},cw=(e,t,n,r,o,i,a,s)=>{let l=5*Math.PI/2+Math.atan2(o-s,r-a);i&&(l+=gt/2,l-=l%gt),t.filter(c=>!J(c)).forEach(c=>{let[d,u,f,m]=B(c,n),p=(d+f)/2,h=(u+m)/2,E=e.get(c.id)?.angle??c.angle,[x,w]=H(p,h,a,s,l+E-c.angle);F(c,{x:c.x+(x-p),y:c.y+(w-h),angle:Yi(l+E)},!1),tn(c,n,{simultaneouslyUpdated:t});let y=Z(c,n);y&&!ee(c)&&F(y,{x:y.x+(x-p),y:y.y+(w-h),angle:Yi(l+E)},!1)}),it.getScene(t[0])?.informMutation()},dw=(e,t,n,r,o)=>{let[i,a,s,l]=t.length===1?B(t[0],n):Me(t),c=(i+s)/2,d=(a+l)/2,u=t.length===1?t[0].angle:0;switch([r,o]=H(r,o,c,d,-u),e){case"n":return H(r-(i+s)/2,o-a,0,0,u);case"s":return H(r-(i+s)/2,o-l,0,0,u);case"w":return H(r-i,o-(a+l)/2,0,0,u);case"e":return H(r-s,o-(a+l)/2,0,0,u);case"nw":return H(r-i,o-a,0,0,u);case"ne":return H(r-s,o-a,0,0,u);case"sw":return H(r-i,o-l,0,0,u);case"se":return H(r-s,o-l,0,0,u);default:return[0,0]}},uw=(e,t)=>{let[,[n,r]]=t.points;return e==="nw"&&(n<0||r<0)||e==="ne"&&n>=0||e==="sw"&&n<=0||e==="se"&&(n>0||r>0)?"end":"origin"};g();var fw=(e,t,n,r,o,i,a)=>{let s=new Set(t),l=t.filter(u=>J(u)).map(u=>u.id);if(l.length>0)for(let u of o.getNonDeletedElements())u.frameId!==null&&l.includes(u.frameId)&&s.add(u);let c=Me(Array.from(s).map(u=>e.originalElements.get(u.id)??u)),d=mw(c,n,i,a);s.forEach(u=>{if(sp(e,u,d),!ee(u)){let f=Z(u,o.getNonDeletedElementsMap());f&&sp(e,f,d)}tn(u,o.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(s)})})},mw=(e,t,n,r)=>{let[o,i]=e,a=o+t.x+n.x,s=i+t.y+n.y;if(n.x===0||n.y===0){let[l,c]=Qr(o+t.x,i+t.y,r);n.x===0&&(a=l),n.y===0&&(s=c)}return{x:a-o,y:s-i}},sp=(e,t,n)=>{let r=e.originalElements.get(t.id)??t,o=r.x+n.x,i=r.y+n.y;F(t,{x:o,y:i})},pw=(e,t,n)=>{let[r,o]=Me(e);return[t-r,n-o]},hw=(e,t,n,r,o,i,a,s,l,c,d,u=null)=>{l&&e.type!=="selection"&&(d?s=a/d:(Math.abs(i-r)>Math.abs(o-n)?{width:a,height:s}=Ui(t,s,o<n?-a:a):{width:a,height:s}=Ui(t,a,i<r?-s:s),s<0&&(s=-s)));let f=o<n?n-a:n,m=i<r?r-s:r;c&&(a+=a,s+=s,f=n-a/2,m=r-s/2),a!==0&&s!==0&&F(e,{x:f+(u?.x??0),y:m+(u?.y??0),width:a,height:s})};g();var Ew=(e,t)=>!!(!e.viewModeEnabled&&(e.activeTool.type!=="custom"&&(e.editingElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||ot(t,e).length));var jL=e=>e.reduce((t,n)=>t+n.version,0),qL=e=>{let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e[n].versionNonce;return t>>>0},JL=e=>{let t=5381;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)+t+r}return t>>>0},Gu=e=>e.filter(t=>!t.isDeleted&&!po(t)),rl=e=>e.filter(t=>!t.isDeleted),rp=e=>!e.isDeleted,lp=e=>rl(e).map(t=>Ua(t.type)?{...t,lastCommittedPoint:null}:t),rm=e=>lp(e),Fi=e=>lp(e);var dp=async e=>{let t;if(e.type===R.png)try{return await(await import("./image-BSC5ABC2.js")).decodePngMetadata(e)}catch(n){throw n.message==="INVALID"?new Gt("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new Gt("Error: cannot restore image")}else if("text"in Blob?t=await e.text():t=await new Promise(n=>{let r=new FileReader;r.readAsText(e,"utf8"),r.onloadend=()=>{r.readyState===FileReader.DONE&&n(r.result)}}),e.type===R.svg)try{return await(await import("./image-BSC5ABC2.js")).decodeSvgMetadata({svg:t})}catch(n){throw n.message==="INVALID"?new Gt("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new Gt("Error: cannot restore image")}return t};var gw=e=>e&&e.name.match(/\.(json|excalidraw|png|svg)$/)?.[1]||null,vD=e=>e==="png"||e==="svg",em=e=>{let t=gw(e);return t==="png"||t==="svg"},Vi=e=>{let{type:t}=e||{};return!!t&&Object.values(ka).includes(t)},xw=async(e,t,n,r)=>{let o=await dp(e),i;try{try{i=JSON.parse(o)}catch(a){throw Vi(e)?new Gt("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):a}if(nm(i))return{type:R.excalidraw,data:mo({elements:Fi(i.elements||[]),appState:{theme:t?.theme,fileHandle:r||e.handle||null,...$o(i.appState||{}),...t?fs(i.elements||[],t):{}},files:i.files},t,n,{repairBindings:!0,refreshDimensions:!1})};if(Xs(i))return{type:R.excalidrawlib,data:i};throw new Error("Error: invalid file")}catch(a){throw a instanceof Gt?a:new Error("Error: invalid file")}},tm=async(e,t,n,r)=>{let o=await xw(e,t,n,r);if(o.type!==R.excalidraw)throw new Error("Error: invalid file");return o.data},ww=(e,t="unpublished")=>{let n=JSON.parse(e);if(!Xs(n))throw new Error("Invalid library");let r=n.libraryItems||n.library;return Lm(r,t)},TD=async(e,t="unpublished")=>ww(await dp(e),t),AD=async e=>new Promise(async(t,n)=>{try{Vo(e)&&(e=await e),e.toBlob(r=>{if(!r)return n(new Ci("Error: Canvas too big","CANVAS_POSSIBLY_TOO_BIG"));t(r)})}catch(r){n(r)}}),_D=async e=>{try{let t=await window.crypto.subtle.digest("SHA-1",await Ut(e));return Wd(new Uint8Array(t))}catch(t){return console.error(t),Uo(40)}},SD=async e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let o=r.result;t(o)},r.onerror=o=>n(o),r.readAsDataURL(e)}),ID=(e,t="")=>{let n=e.indexOf(","),r=atob(e.slice(n+1)),o=e.slice(0,n).split(":")[1].split(";")[0],i=new ArrayBuffer(r.length),a=new Uint8Array(i);for(let s=0;s<r.length;s++)a[s]=r.charCodeAt(s);return new File([i],t,{type:o})},PD=async(e,t)=>{if(e.type===R.svg)return e;let[n,r]=await Promise.all([import("./pica-GFNRRI3K.js").then(i=>i.default),import("./image-blob-reduce.esm-2RRQLBYF.js").then(i=>i.default)]),o=r({pica:n({features:["js","wasm"]})});if(t.outputType){let{outputType:i}=t;o._create_blob=function(a){return this.pica.toBlob(a.out_canvas,i,.8).then(s=>(a.out_blob=s,a))}}if(!Vi(e))throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"});return new File([await o.toBlob(e,{max:t.maxWidthOrHeight})],e.name,{type:t.outputType||e.type})},MD=(e,t="")=>new File([new TextEncoder().encode(e)],t,{type:R.svg}),LD=async(e,t="")=>{let n;try{n=await fetch(e)}catch{throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"})}if(!n.ok)throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"});let r=await n.blob();if(r.type&&Vi(r)){let o=t||r.name||"";return new File([r],o,{type:r.type})}throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"})},DD=async e=>{let t=e.dataTransfer.files.item(0),n=await yw(e);return{file:t?await Vs(t):null,fileHandle:n}},yw=async e=>{if(mr)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(t){return console.warn(t.name,t.message),null}return null},cp=e=>{let t=null,n=`${[...new Uint8Array(e).slice(0,8)].join(" ")} `,r={png:"137 80 78 71 13 10 26 10 ",jpg:"255 216 255 ",gif:"71 73 70 56 57 97 "};return n===r.png?t=R.png:n.startsWith(r.jpg)?t=R.jpg:n.startsWith(r.gif)&&(t=R.gif),t},Wi=(e,t,n)=>new File([e],n||"",{type:t}),Vs=async e=>{if(e.type){if(Vi(e)){let t=await Ut(e),n=cp(t);n&&n!==e.type&&(e=Wi(t,n,e.name))}}else if(e?.name?.endsWith(".excalidrawlib"))e=Wi(await Ut(e),R.excalidrawlib,e.name);else if(e?.name?.endsWith(".excalidraw"))e=Wi(await Ut(e),R.excalidraw,e.name);else{let t=await Ut(e),n=cp(t);n&&(e=Wi(t,n,e.name))}return e},Ut=e=>"arrayBuffer"in e?e.arrayBuffer():new Promise((t,n)=>{let r=new FileReader;r.onload=o=>{if(!o.target?.result)return n(new Error("Couldn't convert blob to ArrayBuffer"));t(o.target.result)},r.readAsArrayBuffer(e)});var pl=e=>new Promise((t,n)=>{let r=typeof e=="string"?new Blob([new TextEncoder().encode(e)]):new Blob([e instanceof Uint8Array?e:new Uint8Array(e)]),o=new FileReader;o.onload=i=>{if(!i.target||typeof i.target.result!="string")return n(new Error("couldn't convert to byte string"));t(i.target.result)},o.readAsBinaryString(r)}),up=e=>{let t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let r=0,o=e.length;r<o;r++)n[r]=e.charCodeAt(r);return t},fp=e=>new TextDecoder("utf-8").decode(up(e)),mp=async(e,t=!1)=>t?window.btoa(e):window.btoa(await pl(e)),pp=async(e,t=!1)=>t?window.atob(e):fp(window.atob(e)),hl=async({text:e,compress:t})=>{let n;if(t!==!1)try{n=await pl((0,Xi.deflate)(e))}catch(r){console.error("encode: cannot deflate",r)}return{version:"1",encoding:"bstring",compressed:!!n,encoded:n||await pl(e)}},El=async e=>{let t;switch(e.encoding){case"bstring":t=e.compressed?e.encoded:await fp(e.encoded);break;default:throw new Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?(0,Xi.inflate)(new Uint8Array(up(t)),{to:"string"}):t};var bw=async e=>{let n=(0,gl.default)(new Uint8Array(await Ut(e))).find(r=>r.name==="tEXt");return n?xl.default.decode(n.data):null},Gm=async({blob:e,metadata:t})=>{let n=(0,gl.default)(new Uint8Array(await Ut(e))),r=xl.default.encode(R.excalidraw,JSON.stringify(await hl({text:t,compress:!0})));return n.splice(-1,0,r),new Blob([(0,hp.default)(n)],{type:R.png})},XD=async e=>{let t=await bw(e);if(t?.keyword===R.excalidraw)try{let n=JSON.parse(t.text);if(!("encoded"in n)){if("type"in n&&n.type===Ie.excalidraw)return t.text;throw new Error("FAILED")}return await El(n)}catch(n){throw console.error(n),new Error("FAILED")}throw new Error("INVALID")},ZD=async({text:e})=>{let t=await mp(JSON.stringify(await hl({text:e})),!0),n="";return n+=`<!-- payload-type:${R.excalidraw} -->`,n+="<!-- payload-version:2 -->",n+="<!-- payload-start -->",n+=t,n+="<!-- payload-end -->",n},KD=async({svg:e})=>{if(e.includes(`payload-type:${R.excalidraw}`)){let t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw new Error("INVALID");let o=(e.match(/<!-- payload-version:(\d+) -->/)?.[1]||"1")!=="1";try{let i=await pp(t[1],o),a=JSON.parse(i);if(!("encoded"in a)){if("type"in a&&a.type===Ie.excalidraw)return i;throw new Error("FAILED")}return await El(a)}catch(i){throw console.error(i),new Error("FAILED")}}throw new Error("INVALID")};export{yn as a,gy as b,xy as c,ko as d,Ro as e,G as f,wy as g,yy as h,by as i,vy as j,Ty as k,Ay as l,Fo as m,My as n,Dy as o,ky as p,Ry as q,Fy as r,Oy as s,Td as t,Ad as u,Ny as v,By as w,Gy as x,zy as y,Oo as z,Hy as A,Uy as B,$y as C,_d as D,Yy as E,ce as F,Ce as G,pe as H,xt as I,qe as J,Zn as K,Bo as L,Go as M,Wy as N,Vy as O,Xy as P,Zy as Q,ka as R,R as S,Ky as T,Ie as U,Ra as V,jy as W,qy as X,Jy as Y,Qy as Z,eb as _,Id as $,tb as aa,zo as ba,nb as ca,rb as da,ob as ea,ib as fa,ab as ga,sb as ha,lb as ia,cb as ja,Pd as ka,Fa as la,db as ma,ub as na,j as oa,Oa as pa,de as qa,Lt as ra,Na as sa,ke as ta,fb as ua,_E as va,kd as wa,mb as xa,pb as ya,hb as za,Rd as Aa,bt as Ba,Uo as Ca,Cb as Da,kb as Ea,Rb as Fa,PE as Ga,Fb as Ha,Ob as Ia,Ga as Ja,ue as Ka,Ud as La,$d as Ma,Yd as Na,Nb as Oa,Bb as Pa,$e as Qa,Fr as Ra,Gb as Sa,Or as Ta,za as Ua,zb as Va,jn as Wa,Hb as Xa,Ub as Ya,$b as Za,jt as _a,Yb as $a,Wb as ab,Vb as bb,Xb as cb,X as db,Zb as eb,kt as fb,Kb as gb,jb as hb,qb as ib,Jb as jb,Vo as kb,Qb as lb,Ha as mb,e1 as nb,Xo as ob,t1 as pb,Vd as qb,n1 as rb,r1 as sb,o1 as tb,i1 as ub,a1 as vb,Xd as wb,bn as xb,s1 as yb,wt as zb,Zo as Ab,Ko as Bb,Nr as Cb,Je as Db,Y as Eb,Br as Fb,Zd as Gb,J as Hb,Q as Ib,ee as Jb,Ua as Kb,Qe as Lb,kE as Mb,RE as Nb,$a as Ob,jo as Pb,Ye as Qb,qo as Rb,f1 as Sb,m1 as Tb,At as Ub,st as Vb,ki as Wb,Gt as Xb,Ks as Yb,Rn as Zb,it as _b,Sf as $b,me as ac,Fe as bc,vt as cc,Qr as dc,Ot as ec,H_ as fc,U_ as gc,yg as hc,AT as ic,bg as jc,vg as kc,ms as lc,Tg as mc,hi as nc,GT as oc,Ne as pc,zT as qc,HT as rc,UT as sc,hs as tc,tA as uc,gs as vc,jr as wc,nA as xc,rA as yc,Es as zc,Mg as Ac,oA as Bc,qr as Cc,tn as Dc,iA as Ec,aA as Fc,sA as Gc,ju as Hc,q as Ic,to as Jc,tf as Kc,nf as Lc,LA as Mc,Ms as Nc,Jg as Oc,zA as Pc,of as Qc,Mn as Rc,lr as Sc,sf as Tc,Ds as Uc,cr as Vc,df as Wc,Ln as Xc,Z as Yc,Ae as Zc,HA as _c,UA as $c,$A as ad,YA as bd,WA as cd,Ps as dd,at as ed,ro as fd,VA as gd,yi as hd,B as id,Me as jd,R_ as kd,Mf as ld,F_ as md,Dt as nd,Nd as od,Bd as pd,vx as qd,Z_ as rd,K_ as sd,Tx as td,j_ as ud,Df as vd,q_ as wd,Ax as xd,ur as yd,J_ as zd,Q_ as Ad,eS as Bd,tS as Cd,fr as Dd,aS as Ed,Ff as Fd,Of as Gd,Nf as Hd,Nx as Id,Bx as Jd,Gx as Kd,Hf as Ld,io as Md,LS as Nd,DS as Od,CS as Pd,kS as Qd,_t as Rd,Mi as Sd,$x as Td,RS as Ud,Cn as Vd,Yx as Wd,$s as Xd,Wx as Yd,FS as Zd,Vf as _d,Zf as $d,XS as ae,ZS as be,mr as ce,Qf as de,Ws as ee,Mm as fe,A0 as ge,mo as he,Lm as ie,bw as je,Gm as ke,XD as le,ZD as me,KD as ne,gw as oe,vD as pe,em as qe,Vi as re,xw as se,tm as te,ww as ue,TD as ve,AD as we,_D as xe,SD as ye,ID as ze,PD as Ae,MD as Be,LD as Ce,DD as De,Vs as Ee,co as Fe,M2 as Ge,L2 as He,n0 as Ie,D2 as Je,r0 as Ke,om as Le,im as Me,O2 as Ne,fm as Oe,Z2 as Pe,K2 as Qe,j2 as Re,q2 as Se,c0 as Te,d0 as Ue,js as Ve,lI as We,cI as Xe,Js as Ye,u0 as Ze,xI as _e,vI as $e,pm as af,hm as bf,m0 as cf,wm as df,vm as ef,Tm as ff,JI as gf,wP as hf,D0 as if,DP as jf,CP as kf,Om as lf,kP as mf,RP as nf,Bm as of,il as pf,B0 as qf,G0 as rf,z0 as sf,YP as tf,Hm as uf,$0 as vf,$m as wf,gM as xf,on as yf,xM as zf,wM as Af,Eo as Bf,el as Cf,yM as Df,bM as Ef,Le as Ff,vM as Gf,V0 as Hf,Qm as If,X0 as Jf,TM as Kf,AM as Lf,Bi as Mf,Am as Nf,_m as Of,ox as Pf,l_ as Qf,Rs as Rf,ie as Sf,F as Tf,kn as Uf,ao as Vf,po as Wf,ep as Xf,_s as Yf,nl as Zf,cl as _f,uL as $f,$i as ag,dl as bg,fL as cg,J0 as dg,Q0 as eg,tw as fg,nw as gg,lw as hg,dw as ig,uw as jg,fw as kg,pw as lg,hw as mg,Ew as ng,jL as og,qL as pg,JL as qg,rl as rg,rp as sg,Z0 as tg,Ei as ug,CM as vg,_g as wg,Sg as xg,ot as yg,Ig as zg,Us as Ag,wg as Bg,fs as Cg,Ag as Dg,PT as Eg};
|