35 lines
527 KiB
JavaScript
35 lines
527 KiB
JavaScript
|
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./subset-worker.chunk-CXi44O4x.js","./chunk-EIO257PC-Dq8JiXSZ.js","./chunk-SRAX5OIU-w1svEpmY.js","./package-Bop5TfAT.js","./runtime-core.esm-bundler-DO-WTVbd.js","./package-OvxnQO7z.css","./subset-shared.chunk-WzaeClRm.js","./image-GAAHSSAO-Di-5eHoS.js","./pica-Dfy4NaK_.js"])))=>i.map(i=>d[i]);
|
||
|
|
import{D as e,M as t,r as n}from"./package-Bop5TfAT.js";import{t as r}from"./chunk-ZUYEQ4TG-BzFOpW--.js";import{i}from"./chunk-SRAX5OIU-w1svEpmY.js";var a=e((e=>{(function(t){typeof DO_NOT_EXPORT_CRC>`u`?typeof e==`object`?t(e):typeof define==`function`&&define.amd?define(function(){var e={};return t(e),e}):t({}):t({})})(function(e){e.version=`0.3.0`;function t(){for(var e=0,t=Array(256),n=0;n!=256;++n)e=n,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,t[n]=e;return typeof Int32Array<`u`?new Int32Array(t):t}var n=t(),r=typeof Buffer<`u`;function i(e){if(e.length>32768&&r)return o(new Buffer(e));for(var t=-1,i=e.length-1,a=0;a<i;)t=n[(t^e.charCodeAt(a++))&255]^t>>>8,t=n[(t^e.charCodeAt(a++))&255]^t>>>8;return a===i&&(t=t>>>8^n[(t^e.charCodeAt(a))&255]),t^-1}function a(e){if(e.length>1e4)return o(e);for(var t=-1,r=0,i=e.length-3;r<i;)t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255];for(;r<i+3;)t=t>>>8^n[(t^e[r++])&255];return t^-1}function o(e){for(var t=-1,r=0,i=e.length-7;r<i;)t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255];for(;r<i+7;)t=t>>>8^n[(t^e[r++])&255];return t^-1}function s(e){for(var t=-1,r=0,i=e.length,a,o;r<i;)a=e.charCodeAt(r++),a<128?t=t>>>8^n[(t^a)&255]:a<2048?(t=t>>>8^n[(t^(192|a>>6&31))&255],t=t>>>8^n[(t^(128|a&63))&255]):a>=55296&&a<57344?(a=(a&1023)+64,o=e.charCodeAt(r++)&1023,t=t>>>8^n[(t^(240|a>>8&7))&255],t=t>>>8^n[(t^(128|a>>2&63))&255],t=t>>>8^n[(t^(128|o>>6&15|a&3))&255],t=t>>>8^n[(t^(128|o&63))&255]):(t=t>>>8^n[(t^(224|a>>12&15))&255],t=t>>>8^n[(t^(128|a>>6&63))&255],t=t>>>8^n[(t^(128|a&63))&255]);return t^-1}e.table=n,e.bstr=i,e.buf=a,e.str=s})})),o=e(((e,t)=>{var n=a();t.exports=s;var r=new Uint8Array(4),i=new Int32Array(r.buffer),o=new Uint32Array(r.buffer);function s(e){if(e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)throw Error(`Invalid .png file header`);if(e[4]!==13||e[5]!==10)throw Error(`Invalid .png file header: possibly caused by DOS-Unix line ending conversion?`);if(e[6]!==26)throw Error(`Invalid .png file header`);if(e[7]!==10)throw Error(`Invalid .png file header: possibly caused by DOS-Unix line ending conversion?`);for(var t=!1,a=[],s=8;s<e.length;){r[3]=e[s++],r[2]=e[s++],r[1]=e[s++],r[0]=e[s++];var c=o[0]+4,l=new Uint8Array(c);l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++];var u=String.fromCharCode(l[0])+String.fromCharCode(l[1])+String.fromCharCode(l[2])+String.fromCharCode(l[3]);if(!a.length&&u!==`IHDR`)throw Error(`IHDR header missing`);if(u===`IEND`){t=!0,a.push({name:u,data:new Uint8Array});break}for(var d=4;d<c;d++)l[d]=e[s++];r[3]=e[s++],r[2]=e[s++],r[1]=e[s++],r[0]=e[s++];var f=i[0];if(n.buf(l)!==f)throw Error(`CRC values for `+u+` header do not match, PNG file is likely corrupted`);var p=new Uint8Array(l.buffer.slice(4));a.push({name:u,data:p})}if(!t)throw Error(`.png file ended prematurely: no IEND header was found`);return a}})),s=e(((e,t)=>{t.exports=n;function n(e,t){if(e=String(e),t=String(t),!/^[\x00-\xFF]+$/.test(e)||!/^[\x00-\xFF]+$/.test(t))throw 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 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),i=0,a,o=0;o<e.length;o++){if(!(a=e.charCodeAt(o)))throw Error(`0x00 character is not permitted in tEXt keywords`);r[i++]=a}r[i++]=0;for(var s=0;s<t.length;s++){if(!(a=t.charCodeAt(s)))throw Error(`0x00 character is not permitted in tEXt content`);r[i++]=a}return{name:`tEXt`,data:r}}})),c=e(((e,t)=>{t.exports=n;function n(e){e.data&&e.name&&(e=e.data);for(var t=!0,n=``,r=``,i=0;i<e.length;i++){var a=e[i];if(t)a?r+=String.fromCha
|
||
|
|
`),Yu=e=>e,Xu=async(e,...t)=>new Promise(n=>{n(e(...t))}),Zu=(...e)=>Math.max(...e.map(e=>+!!e))>0,Qu=class{constructor(e,t){i(this,`pool`),i(this,`entries`,{}),this.pool=new Fi.default(e,t)}all(){let e=e=>{if(e.data.result){let[t,n]=e.data.result;this.entries[t]=n}};return this.pool.addEventListener(`fulfilled`,e),this.pool.start().then(()=>(setTimeout(()=>{this.pool.removeEventListener(`fulfilled`,e)}),Object.values(this.entries)))}},$u=e=>e.replace(/"/g,`"`),ed=e=>Array.isArray(e)?e:[e],td=e=>!!e&&e.type===`image`&&!!e.fileId,nd=e=>!!e&&e.type===`image`,rd=e=>!!e&&e.type===`embeddable`,id=e=>!!e&&e.type===`iframe`,ad=e=>!!e&&(e.type===`iframe`||e.type===`embeddable`),V=e=>e!=null&&e.type===`text`,od=e=>e!=null&&e.type===`frame`,sd=e=>e!=null&&e.type===`magicframe`,cd=e=>e!=null&&(e.type===`frame`||e.type===`magicframe`),ld=e=>e!=null&&ud(e.type),ud=e=>e===`freedraw`,dd=e=>e!=null&&fd(e.type),H=e=>e!=null&&e.type===`arrow`,U=e=>H(e)&&e.elbowed,fd=e=>e===`arrow`||e===`line`,pd=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&md(e.type),md=e=>e===`arrow`,hd=(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),gd=e=>e!=null&&(e.type===`rectangle`||e.type===`diamond`||e.type===`image`||e.type===`iframe`||e.type===`embeddable`||e.type===`frame`||e.type===`magicframe`||e.type===`text`&&!e.containerId),_d=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type===`rectangle`||e.type===`diamond`||e.type===`ellipse`||H(e)),vd=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 Bu(t,null),!1}},yd=e=>e.type===`rectangle`||e.type===`ellipse`||e.type===`diamond`,bd=e=>_d(e)&&!!e.boundElements?.some(({type:e})=>e===`text`),xd=e=>e!==null&&`containerId`in e&&e.containerId!==null&&V(e),Sd=e=>e===`rectangle`||e===`embeddable`||e===`iframe`||e===`image`,Cd=e=>e===`line`||e===`arrow`||e===`diamond`,wd=(e,t)=>!!((e===xc.ADAPTIVE_RADIUS||e===xc.LEGACY)&&Sd(t.type)||e===xc.PROPORTIONAL_RADIUS&&Cd(t.type)),Td=e=>Cd(e.type)?{type:xc.PROPORTIONAL_RADIUS}:Sd(e.type)?{type:xc.ADAPTIVE_RADIUS}:null,Ed=e=>Object.hasOwn(e,`fixedPoint`)&&e.fixedPoint!=null,Dd=(e,t,n)=>{let r=e.split(`
|
||
|
|
`).map(e=>e||` `).join(`
|
||
|
|
`),i=Vd(r,parseFloat(t),n);return{width:Bd(r,t),height:i}},Od=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`.toLocaleUpperCase(),kd=(e,t)=>{let n=Ud(e);return n===0?Dd(Od.split(``).join(`
|
||
|
|
`),e,t).width+10:n+10},Ad=(e,t)=>Dd(``,e,t).width+10,jd=()=>Bd(Od,$l({fontSize:20,fontFamily:Hs}))>0,Md=e=>Ju(e).replace(/\t/g,` `),Nd=e=>Md(e).split(`
|
||
|
|
`),Pd=e=>{let t=Nd(e.text).length;return e.height/t/e.fontSize},Fd=(e,t)=>e*t,Id=(e,t)=>Fd(e,t)+10,Ld,Rd=class{constructor(){i(this,`canvas`),this.canvas=document.createElement(`canvas`)}getLineWidth(e,t){let n=this.canvas.getContext(`2d`);n.font=t;let r=n.measureText(e).width;return ku()?r*10:r}},zd=(e,t)=>(Ld||=new Rd,Ld.getLineWidth(e,t)),Bd=(e,t)=>{let n=Nd(e),r=0;return n.forEach(e=>{r=Math.max(r,zd(e,t))}),r},Vd=(e,t,n)=>{let r=Nd(e).length;return Fd(t,n)*r},Hd=(()=>{let e={};return{calculate:(t,n)=>{let r=t.charCodeAt(0);if(e[n]||(e[n]=[]),!e[n][r]){let i=zd(t,n);e[n][r]=i}return e[n][r]},getCache:t=>e[t],clearCache:t=>{e[t]=[]}}})(),Ud=e=>{let t=Hd.getCache(e);if(!t)return 0;let n=t.filter(e=>e!==void 0);return Math.max(...n)},Wd,Gd,Kd,qd=e=>(Wd||=W.class(...Object.values(Zd)),Wd.test(e)),Jd=()=>{if(!Gd)try{Gd=ef()}catch{Gd=$d()}return Gd},Yd=()=>(Kd||=tf(),Kd),Xd={WHITESPACE:/\s/u,HYPHEN:/-/u,OPENING:/<\(\[\{/u,CLOSING:/>\)\]\}.,:;!\?…\//u},Zd={CHAR:/\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}`'^〃〰〆#&*+-ー/\=|¦〒¬ ̄/u,OPENING:/([{〈《⦅「「『【〖〔〘〚<〝/u,CLOSING:/)]}〉》⦆」」』】〗〕〙〛>。.,、〟‥?!:;・〜〞/u,CURRENCY:/¥₩£¢$/u},Qd={FLAG:/\p{RI}\p{RI}/u,JOINER:/(?:\p{Emoji_Modifier}|\uFE0F\u20E3?|[\u{E0020}-\u{E007E}]+\u{E007F})?/u,ZWJ:/\u200D/u,ANY:/[\p{Emoji}]/u,MOST:/[\p{Extended_Pictographic}\p{Emoji_Presentation}]/u},$d=()=>W.or(Yd(),nf.On(Xd.HYPHEN,Xd.WHITESPACE,Zd.CHAR)),ef=()=>W.or(Yd(),nf.Before(Xd.WHITESPACE).Build(),nf.After(Xd.WHITESPACE,Xd.HYPHEN).Build(),nf.Before(Zd.CHAR,Zd.CURRENCY).NotPrecededBy(Xd.OPENING,Zd.OPENING).Build(),nf.After(Zd.CHAR).NotFollowedBy(Xd.HYPHEN,Xd.CLOSING,Zd.CLOSING).Build(),nf.BeforeMany(Zd.OPENING).NotPrecededBy(Xd.OPENING).Build(),nf.AfterMany(Zd.CLOSING).NotFollowedBy(Xd.CLOSING).Build(),nf.AfterMany(Xd.CLOSING).FollowedBy(Xd.OPENING).Build()),tf=()=>W.group(W.or(Qd.FLAG,W.and(Qd.MOST,Qd.JOINER,W.build(`(?:${Qd.ZWJ.source}(?:${Qd.FLAG.source}|${Qd.ANY.source}${Qd.JOINER.source}))*`)))),W={build:e=>new RegExp(e,`u`),join:(...e)=>e.map(e=>e.source).join(``),and:(...e)=>W.build(W.join(...e)),or:(...e)=>W.build(e.map(e=>e.source).join(`|`)),group:(...e)=>W.build(`(${W.join(...e)})`),class:(...e)=>W.build(`[${W.join(...e)}]`)},nf={On:(...e)=>{let t=W.join(...e);return W.build(`([${t}])`)},Before:(...e)=>{let t=W.join(...e);return nf.Chain(()=>W.build(`(?=[${t}])`))},After:(...e)=>{let t=W.join(...e);return nf.Chain(()=>W.build(`(?<=[${t}])`))},BeforeMany:(...e)=>{let t=W.join(...e);return nf.Chain(()=>W.build(`(?<![${t}])(?=[${t}])`))},AfterMany:(...e)=>{let t=W.join(...e);return nf.Chain(()=>W.build(`(?<=[${t}])(?![${t}])`))},NotBefore:(...e)=>{let t=W.join(...e);return nf.Chain(()=>W.build(`(?![${t}])`))},NotAfter:(...e)=>{let t=W.join(...e);return nf.Chain(()=>W.build(`(?<![${t}])`))},Chain:e=>({Build:e,PreceededBy:(...t)=>{let n=e(),r=nf.After(...t).Build();return nf.Chain(()=>W.and(r,n))},FollowedBy:(...t)=>{let n=e(),r=nf.Before(...t).Build();return nf.Chain(()=>W.and(n,r))},NotPrecededBy:(...t)=>{let n=e(),r=nf.NotAfter(...t).Build();return nf.Chain(()=>W.and(r,n))},NotFollowedBy:(...t)=>{let n=e(),r=nf.NotBefore(...t).Build();return nf.Chain(()=>W.and(n,r))}})},rf=e=>{let t=Jd();return e.normalize(`NFC`).split(t).filter(Boolean)},af=(e,t,n)=>{if(!Number.isFinite(n)||n<0)return e;let r=[],i=e.split(`
|
||
|
|
`);for(let e of i){if(zd(e,t)<=n){r.push(e);continue}let i=of(e,t,n);r.push(...i)}return r.join(`
|
||
|
|
`)},of=(e,t,n)=>{let r=[],i=rf(e)[Symbol.iterator](),a=``,o=0,s=i.next();for(;!s.done;){let e=s.value,c=a+e,l=lf(e)?o+Hd.calculate(e,t):zd(c,t);if(/\s/.test(e)||l<=n){a=c,o=l,s=i.next();continue}if(a)r.push(a.trimEnd()),a=``,o=0;else{let c=sf(e,t,n),l=c[c.length-1]??``,u=c.slice(0,-1);r.push(...u),a=l,o=zd(l,t),s=i.next()}}if(a){let e=cf(a,t,n);r.push(e)}return r},sf=(e,t,n)=>{if(Yd().test(e))return[e];uf(e);let r=[],i=Array.from(e),a=``,o=0;for(let e of i){let i=Hd.calculate(e,t),s=o+i;if(s<=n){a+=e,o=s;continue}a&&r.push(a),a=e,o=i}return a&&r.push(a),r},cf=(e,t,n)=>{if(!(zd(e,t)>n))return e;let[,r,i]=e.match(/^(.+?)(\s+)$/)??[e,e.trimEnd(),``],a=zd(r,t);for(let e of Array.from(i)){let i=Hd.calculate(e,t),o=a+i;if(o>n)break;r+=e,a=o}return r},lf=e=>e.codePointAt(0)!==void 0&&e.codePointAt(1)===void 0,uf=e=>{if((r.MODE===Ms.TEST||r.DEV)&&/\s/.test(e))throw Error(`Word should not contain any whitespaces!`)},df=class{};i(df,`rg`,new Za),i(df,`cache`,new WeakMap),i(df,`get`,e=>df.cache.get(e)),i(df,`set`,(e,t)=>df.cache.set(e,t)),i(df,`delete`,e=>df.cache.delete(e)),i(df,`destroy`,()=>{df.cache=new WeakMap}),i(df,`generateElementShape`,(e,t)=>{let n=t?.isExporting?void 0:df.get(e);if(n!==void 0)return n;u_.delete(e);let r=q_(e,df.rg,t||{isExporting:!1,canvasBackgroundColor:M.white,embedsValidationStatus:null});return df.cache.set(e,r),r});var ff=df,pf=e=>`var(--icon-fill-color)`,mf=e=>e===zs.LIGHT?Ai.white:`#1e1e1e`,G=(e,t=512)=>{let{width:n=512,height:r=n,mirror:i,style:a,...o}=typeof t==`number`?{width:t}:t;return(0,j.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,role:`img`,viewBox:`0 0 ${n} ${r}`,className:jo({"rtl-mirror":i}),style:a,...o,children:typeof e==`string`?(0,j.jsx)(`path`,{fill:`currentColor`,d:e}):e})},K={width:24,height:24,fill:`none`,strokeWidth:2,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`},q={width:20,height:20,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`};G((0,j.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,j.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,j.jsx)(`rect`,{x:3,y:8,width:18,height:4,rx:1}),(0,j.jsx)(`line`,{x1:12,y1:8,x2:12,y2:21}),(0,j.jsx)(`path`,{d:`M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7`}),(0,j.jsx)(`path`,{d:`M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5`})]}),K);var hf=G((0,j.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,j.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,j.jsx)(`path`,{d:`M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,j.jsx)(`path`,{d:`M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,j.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3`,y2:`19`}),(0,j.jsx)(`line`,{x1:`12`,y1:`6`,x2:`12`,y2:`19`}),(0,j.jsx)(`line`,{x1:`21`,y1:`6`,x2:`21`,y2:`19`})]}),K),gf=G((0,j.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,j.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,j.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,j.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),K),_f=G((0,j.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,j.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,j.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,j.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`}),(0,j.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`})]}),K),vf=G((0,j.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,j.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,j.jsx)(`path`,{d:`M9 4v6l-2 4v2h10v-2l-2 -4v-6`}),(0,j.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`21`}),(0,j.jsx)(`line`,{x1:`8`,y1:`4`,x2:`16`,y2:`4`})]}),K),yf=G((0,j.jsxs)(`g`,{children:[(0,j.jsx)(`path`,{d:`M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z`,stroke:`currentColor`,strokeWidth:`1.25`}),(0,j.jsx)(`path`,{d:`M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z`,stroke:`currentColor`,strokeWidth:`1.25`}),(0,j.jsx)(`mask`,{id:`UnlockedIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:6,y:1,width:9,height:9,children:(0,j.jsx)(`path`,{stroke:`none`,d:`M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.6
|
||
|
|
`).split(`
|
||
|
|
`),a=e.textAlign===`center`?e.width/2:e.textAlign===`right`?e.width:0,o=Fd(e.fontSize,e.lineHeight),s=Uh(e.fontFamily,e.fontSize,o);for(let e=0;e<i.length;e++)n.fillText(i[e],a,e*o+s);n.restore(),r&&n.canvas.remove()}else throw Error(`Unimplemented type ${e.type}`)}},u_=new WeakMap,d_=(e,t,n,r)=>{let i=n?r.zoom:Qg.zoom,a=u_.get(e),o=a&&a.zoomValue!==i.value&&!r?.shouldCacheIgnoreZoom,s=jb(e,t),c=s?.version||null,l=nd(e)?e.crop:null,u=CT(e,t)?.opacity||100;if(!a||o||a.theme!==r.theme||a.boundTextElementVersion!==c||a.imageCrop!==l||a.containingFrameOpacity!==u||H(e)&&s&&e.angle!==a.angle){let a=i_(e,t,i,n,r);return a?(u_.set(e,a),a):null}return a},f_=(e,t,n,i,a)=>{let o=e.element,s=t_(o),c=e.scale,[l,u,d,f]=Y(o,a),p=((l+d)/2+i.scrollX)*window.devicePixelRatio,m=((u+f)/2+i.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let h=jb(o,a);if(H(o)&&h){let n=(e.boundTextCanvas.width-e.canvas.width)/2,r=(e.boundTextCanvas.height-e.canvas.height)/2;t.translate(p,m),t.drawImage(e.boundTextCanvas,-(d-l)/2*window.devicePixelRatio-n/c-s,-(f-u)/2*window.devicePixelRatio-r/c-s,e.boundTextCanvas.width/c,e.boundTextCanvas.height/c)}else if(t.translate(p,m),t.rotate(o.angle),`scale`in e.element&&!$g(o,n)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-p,-m),t.drawImage(e.canvas,(l+i.scrollX)*window.devicePixelRatio-s*e.scale/e.scale,(u+i.scrollY)*window.devicePixelRatio-s*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),r.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX===`true`&&bd(o)){let e=jb(o,a),n=Pb(o);t.strokeStyle=`#c92a2a`,t.lineWidth=3,t.strokeRect((n.x+i.scrollX)*window.devicePixelRatio,(n.y+i.scrollY)*window.devicePixelRatio,Vb(o,e)*window.devicePixelRatio,Hb(o,e)*window.devicePixelRatio)}t.restore()},p_=(e,t,n,r)=>{t.save(),t.translate(e.x+n.scrollX,e.y+n.scrollY),t.fillStyle=`rgba(0, 0, 200, 0.04)`;let i=.5/n.zoom.value;t.fillRect(i,i,e.width,e.height),t.lineWidth=1/n.zoom.value,t.strokeStyle=r,t.strokeRect(i,i,e.width,e.height),t.restore()},m_=(e,t,n,r,i,a,o)=>{let s=o.openDialog?.name===`elementLinkSelector`&&!o.selectedElementIds[e.id]&&!o.hoveredElementIds[e.id];switch(i.globalAlpha=n_(e,CT(e,t),a.elementsPendingErasure,a.pendingFlowchartNodes,s?Pc:1),e.type){case`magicframe`:case`frame`:o.frameRendering.enabled&&o.frameRendering.outline&&(i.save(),i.translate(e.x+o.scrollX,e.y+o.scrollY),i.fillStyle=`rgba(0, 0, 200, 0.04)`,i.lineWidth=Bs.strokeWidth/o.zoom.value,i.strokeStyle=Bs.strokeColor,sd(e)&&(i.strokeStyle=o.theme===zs.LIGHT?`#7affd7`:`#1d8264`),Bs.radius&&i.roundRect?(i.beginPath(),i.roundRect(0,0,e.width,e.height,Bs.radius/o.zoom.value),i.stroke(),i.closePath()):i.strokeRect(0,0,e.width,e.height),i.restore());break;case`freedraw`:if(ff.generateElementShape(e,null),a.isExporting){let[n,s,c,l]=Y(e,t),u=(n+c)/2+o.scrollX,d=(s+l)/2+o.scrollY,f=(c-n)/2-(e.x-n),p=(l-s)/2-(e.y-s);i.save(),i.translate(u,d),i.rotate(e.angle),i.translate(-f,-p),l_(e,r,i,a,o),i.restore()}else{let t=d_(e,n,a,o);if(!t)return;f_(t,i,a,o,n)}break;case`rectangle`:case`diamond`:case`ellipse`:case`line`:case`arrow`:case`image`:case`text`:case`iframe`:case`embeddable`:if(ff.generateElementShape(e,a),a.isExporting){let[n,s,c,l]=Y(e,t),u=(n+c)/2+o.scrollX,d=(s+l)/2+o.scrollY,f=(c-n)/2-(e.x-n),p=(l-s)/2-(e.y-s);if(V(e)){let r=Mb(e,t);if(H(r)){let i=Z.getBoundTextElementPosition(r,e,t);f=(c-n)/2-(i.x-n),p=(l-s)/2-(i.y-s)}}i.save(),i.translate(u,d),e_(e,a,o)&&(i.filter=`none`);let m=jb(e,t);if(H(e)&&m){let r=document.createElement(`canvas`),u=r.getContext(`2d`),d=Math.max(ou(n,c),ou(s,l)),h=t_(e);r.width=d*o.exportScale+h*10*o.exportScale,r.height=d*o.exportScale+h*10*o.exportScale,u.translate(r.width/2,r.height/2),u.scale(o.exportScale,o.exportScale),f=e.width/2-(e.x-n),p=e.height/2-(e.y-s),u.rotate(e.angle);let g=to.canvas(r);u.translate(-f,-p),l_(e,g,u,a,o),u.translate(f,p),u.rotate(-e.angle);let[,,,,_,v]=Y(m,t),y=(n+c)/2-_,b=(s+l)/2-v;u.translate(-y,-b),u.clearRect(-m.width/2,-m.height/2,m.width,m.height),i.scale(1/o.exportScale,1/o.exportScale),i.drawImage(r,-r.widt
|
||
|
|
C ${a} ${o}, ${a} ${o}, ${a-d} ${o+f}
|
||
|
|
L ${s+d} ${c-f}
|
||
|
|
C ${s} ${c}, ${s} ${c}, ${s-d} ${c-f}
|
||
|
|
L ${l+d} ${u+f}
|
||
|
|
C ${l} ${u}, ${l} ${u}, ${l+d} ${u-f}
|
||
|
|
L ${r-d} ${i+f}
|
||
|
|
C ${r} ${i}, ${r} ${i}, ${r+d} ${i+f}`,W_(e,!0))}else n=t.polygon([[r,i],[a,o],[s,c],[l,u]],W_(e));return n}case`ellipse`:return t.ellipse(e.width/2,e.height/2,e.width,e.height,W_(e));case`line`:case`arrow`:{let n,i=W_(e),a=e.points.length?e.points:[L(0,0)];if(U(e)?a.every(e=>Math.abs(e[0])<=1e6&&Math.abs(e[1])<=1e6)?n=[t.path(J_(a,16),W_(e,!0))]:(console.error(`Elbow arrow with extreme point positions detected. Arrow not rendered.`,e.id,JSON.stringify(a)),n=[]):n=e.roundness?[t.curve(a,i)]:i.fill?[t.polygon(a,i)]:[t.linearPath(a,i)],e.type===`arrow`){let{startArrowhead:a=null,endArrowhead:o=`arrow`}=e;if(a!==null){let o=K_(e,n,`start`,a,t,i,r);n.push(...o)}if(o!==null){let a=K_(e,n,`end`,o,t,i,r);n.push(...a)}}return n}case`freedraw`:{let n;if(g_(e),Wg(e.points)){let r=Bo(e.points,.75);n=t.curve(r,{...W_(e),stroke:`none`})}else n=null;return n}case`frame`:case`magicframe`:case`text`:case`image`:return null;default:return Bu(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},J_=(e,t)=>{let n=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],o=e[r],s=I_(o,i),c=I_(a,o),l=Math.min(t,hl(e[r],a)/2,hl(e[r],i)/2);s?i[0]<o[0]?n.push([e[r][0]-l,e[r][1]]):n.push([e[r][0]+l,e[r][1]]):i[1]<o[1]?n.push([e[r][0],e[r][1]-l]):n.push([e[r][0],e[r][1]+l]),n.push(e[r]),c?a[0]<o[0]?n.push([e[r][0]-l,e[r][1]]):n.push([e[r][0]+l,e[r][1]]):a[1]<o[1]?n.push([e[r][0],e[r][1]-l]):n.push([e[r][0],e[r][1]+l])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let e=0;e<n.length;e+=3)r.push(`L ${n[e][0]} ${n[e][1]}`),r.push(`Q ${n[e+1][0]} ${n[e+1][1]}, ${n[e+2][0]} ${n[e+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(` `)},Y_=e=>{let t=e.map(e=>e[0]),n=e.map(e=>e[1]);return{width:Math.max(...t)-Math.min(...t),height:Math.max(...n)-Math.min(...n)}},X_=(e,t,n,r)=>{let i=n.map(t=>t[e]),a=Math.max(...i),o=Math.min(...i),s=a-o,c=s===0?1:t/s,l=1/0,u=n.map(t=>{let n=t[e]*c,r=[...t];return r[e]=n,n<l&&(l=n),r});if(!r||u.length===2)return u;let d=o-l;return u.map(t=>t.map((t,n)=>n===e?t+d:t))},Z_=class e{static getBounds(t,n){let r=e.boundsCache.get(t);if(r?.version&&r.version===t.version&&!xd(t))return r.bounds;let i=e.calculateBounds(t,n);return e.boundsCache.set(t,{version:t.version,bounds:i}),i}static calculateBounds(e,t){let n,[r,i,a,o,s,c]=Y(e,t);if(ld(e)){let[t,n,r,i]=av(e.points.map(([t,n])=>z(L(t,n),L(s-e.x,c-e.y),e.angle)));return[t+e.x,n+e.y,r+e.x,i+e.y]}else if(dd(e))n=dv(e,s,c,t);else if(e.type===`diamond`){let[t,l]=z(L(s,i),L(s,c),e.angle),[u,d]=z(L(s,o),L(s,c),e.angle),[f,p]=z(L(r,c),L(s,c),e.angle),[m,h]=z(L(a,c),L(s,c),e.angle);n=[Math.min(t,u,f,m),Math.min(l,d,p,h),Math.max(t,u,f,m),Math.max(l,d,p,h)]}else if(e.type===`ellipse`){let t=(a-r)/2,l=(o-i)/2,u=Math.cos(e.angle),d=Math.sin(e.angle),f=Math.hypot(t*u,l*d),p=Math.hypot(l*u,t*d);n=[s-f,c-p,s+f,c+p]}else{let[t,l]=z(L(r,i),L(s,c),e.angle),[u,d]=z(L(r,o),L(s,c),e.angle),[f,p]=z(L(a,o),L(s,c),e.angle),[m,h]=z(L(a,i),L(s,c),e.angle);n=[Math.min(t,u,f,m),Math.min(l,d,p,h),Math.max(t,u,f,m),Math.max(l,d,p,h)]}return n}};i(Z_,`boundsCache`,new WeakMap);var Q_=Z_,Y=(e,t,n=!1)=>{if(ld(e))return ov(e);if(dd(e))return Z.getElementAbsoluteCoords(e,t,n);if(V(e)){let n=t?Mb(e,t):null;if(H(n)){let{x:r,y:i}=Z.getBoundTextElementPosition(n,e,t);return[r,i,r+e.width,i+e.height,r+e.width/2,i+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]},$_=(e,t)=>{let[n,r,i,a,o,s]=Y(e,t),c=L(o,s);if(dd(e)||ld(e)){let t=[],n=0;for(;n<e.points.length-1;)t.push(B(z(L(e.points[n][0]+e.x,e.points[n][1]+e.y),c,e.angle),z(L(e.points[n+1][0]+e.x,e.points[n+1][1]+e.y),c,e.angle))),n++;return t}let[l,u,d,f,p,m,h,g]=[[n,r],[i,r],[n,a],[i,a],[o,r],[o,a],[n,s],[i,s]].map(t=>z(t,c,e.angle));return e.type===`diamond`?[B(p,h),B(p,g),B(m,h),B(m,g)]:e.type===`ellipse`?[B(p,h),B(p,g),B(m,h),B(m,g),B(p,h),B(p,g),B(m,h),B(m,g)]:[B(l,u),B(d,f),B(l,d),B(u,f),B(l,g),B(d,g),B(u,h),B(f,h)]},ev=e=>{let t=Math.floor(e.width/2)+1,n=e.width,r=Math.floor(e.height/2)+1;return[t,0,n,r,t,e.height,0,r]},tv=(e,t,n,r,i)=>{let a=1-e;return a**3*t+3*a**2*e*n+3*a*e**2*r+e**
|
||
|
|
|
||
|
|
`)=>e.reduce((e,t)=>(V(t)&&e.push(t.text),e),[]).join(t),Wb=e=>(e=e.trim(),e&&(0,Uo.sanitizeUrl)($u(e))),Gb=e=>!!(e?.includes(location.origin)||e?.startsWith(`/`)),Kb=e=>{if(e=Wb(e),e.startsWith(`/`))return`${location.origin}${e}`;try{new URL(e)}catch{return`about:blank`}return e},qb=[],Jb=e=>(qb=qb.concat(e),e),Yb=`<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">`,Xb=`<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"/>`,Zb=`<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"/>`,Qb=`data:${N.svg},${encodeURIComponent(`${Yb}${Zb}</svg>`)}`,$b=`data:${N.svg},${encodeURIComponent(`${Yb}${Xb}${Zb}</svg>`)}`,ex=e=>{e&&(e.style.cursor=``)},tx=(e,t)=>{e&&(e.style.cursor=t)},nx,rx,ix=(e,t)=>{(!nx||nx.theme!==t)&&(()=>{let e=t===zs.DARK;nx=document.createElement(`canvas`),nx.theme=t,nx.height=20,nx.width=20;let n=nx.getContext(`2d`);n.lineWidth=1,n.beginPath(),n.arc(nx.width/2,nx.height/2,5,0,2*Math.PI),n.fillStyle=e?Ai.black:Ai.white,n.fill(),n.strokeStyle=e?Ai.white:Ai.black,n.stroke(),rx=nx.toDataURL(N.svg)})(),tx(e,`url(${rx}) ${20/2} ${20/2}, auto`)},ax=(e,t)=>{if(e)if(t.activeTool.type===`selection`)ex(e);else if(Gc(t))e.style.cursor=Os.GRAB;else if(Wc(t))ix(e,t.theme);else if(t.activeTool.type===`laser`){let n=t.theme===zs.LIGHT?Qb:$b;e.style.cursor=`url(${n}), auto`}else [`image`,`custom`].includes(t.activeTool.type)?t.activeTool.type!==`image`&&(e.style.cursor=Os.AUTO):e.style.cursor=Os.CROSSHAIR},ox=new Qi(Date.now()),sx=0,cx=()=>Math.floor(ox.next()*2**31),lx=()=>ku()?`id${sx++}`:ji(),ux=(e,{x:t,y:n,strokeColor:r=wc.strokeColor,backgroundColor:i=wc.backgroundColor,fillStyle:a=wc.fillStyle,strokeWidth:o=wc.strokeWidth,strokeStyle:s=wc.strokeStyle,roughness:c=wc.roughness,opacity:l=wc.opacity,width:u=0,height:d=0,angle:f=0,groupIds:p=[],frameId:m=null,index:h=null,roundness:g=null,boundElements:_=null,link:v=null,locked:y=wc.locked,...b})=>((t<-1e6||t>1e6||n<-1e6||n>1e6||u<-1e6||u>1e6||d<-1e6||d>1e6)&&console.error(`New element size or position is too large`,{x:t,y:n,width:u,height:d,points:b.points}),{id:b.id||lx(),type:e,x:t,y:n,width:u,height:d,angle:f,strokeColor:r,backgroundColor:i,fillStyle:a,strokeWidth:o,strokeStyle:s,roughness:c,opacity:l,groupIds:p,frameId:m,index:h,roundness:g,seed:b.seed??cx(),version:b.version||1,versionNonce:b.versionNonce??0,isDeleted:!1,boundElements:_,updated:wu(),link:v,locked:y,customData:b.customData}),dx=e=>ux(e.type,e),fx=e=>ux(`embeddable`,e),px=e=>({...ux(`iframe`,e)}),mx=e=>ZT({...ux(`frame`,e),type:`frame`,name:e?.name||null},{}),hx=e=>ZT({...ux(`magicframe`,e),type:`magicframe`,name:e?.name||null},{}),gx=(e,t)=>({x:e.textAlign===`center`?t.width/2:e.textAlign===`right`?t.width:0,y:e.verticalAlign===`middle`?t.height/2:0}),_x=e=>{let t=e.fontFamily||Hs,n=e.fontSize||20,r=e.lineHeight||Wh(t),i=Md(e.text),a=Dd(i,$l({fontFamily:t,fontSize:n}),r),o=e.textAlign||`left`,s=e.verticalAlign||`top`,c=gx({textAlign:o,verticalAlign:s},a);return ZT({...ux(`text`,e),text:i,fontSize:n,fontFamily:t,textAlign:o,verticalAlign:s,x:e.x-c.x,y:e.y-c.y,width:a.width,height:a.height,containerId:e.containerId||null,originalText:e.originalText??i,autoResize:e.autoResize??!0,lineHeight:r},{})},vx=(e,t,n)=>{let{width:r,height:i}=Dd(n,$l(e),e.lineHeight);e.autoResize||(r=e.width);let{textAlign:a,verticalAlign:o}=e,s,c;if(a===`center`&&o===gc.MIDDLE&&!e.containerId&&e.autoResize){let t=Dd(e.text,$l(e),e.lineHeight),n=gx(e,{width:r-t.width,height:i-t.height});s=e.x-n.x,c=e.y-n.y}else{let[n,o,l,u]=Y(e,t),[d,f,p,m]=hv(e,r,i,!1),h=(n-d)/2,g=(o-f)/2,_=(l-p)/2,v=(u-m)/2;[s,c]=yx({s:!0,e:a===`center`||a==
|
||
|
|
|
||
|
|
`),n.stack,e.map(e=>o(e)),...s),t)throw n}},Mx=e=>e.sort((e,t)=>zx(e)&&zx(t)?e.index<t.index?-1:e.index>t.index?1:e.id<t.id?-1:1:1),Nx=(e,t)=>{try{let n=Rx(e,Fx(e,t));jx(e.map(e=>n.has(e)?{...e,...n.get(e)}:e),{includeBoundTextValidation:!1,shouldThrow:!0,ignoreLogs:!0});for(let[e,t]of n)$(e,t,!1)}catch{Px(e)}return e},Px=e=>{let t=Rx(e,Ix(e));for(let[e,n]of t)$(e,n,!1);return e},Fx=(e,t)=>{let n=[],r=0;for(;r<e.length;)if(t.has(e[r].id)){let i=[r-1,r];for(;++r<e.length&&t.has(e[r].id);)i.push(r);i.push(r),n.push(i)}else r++;return n},Ix=e=>{let t=[],n,r,i=-1,a=0,o=t=>{let n=e[i]?e[i].index:void 0,r=e[t-1]?.index;return!n&&r||n&&r&&r>n?[r,t-1]:[n,i]},s=t=>{let n=e[a]?e[a].index:void 0;if(n&&t<a)return[n,a];let r=a;for(;++r<e.length;){let t=e[r]?.index;if(!n&&t||n&&t&&t>n)return[t,r]}return[void 0,r]},c=0;for(;c<e.length;){let l=e[c].index;if([n,i]=o(c),[r,a]=s(c),Lx(l,n,r))c++;else{let l=[i,c];for(;++c<e.length;){let t=e[c].index,[u,d]=o(c),[f,p]=s(c);if(Lx(t,u,f))break;[n,i]=[u,d],[r,a]=[f,p],l.push(c)}l.push(a),t.push(l)}}return t},Lx=(e,t,n)=>e?t&&n?t<e&&e<n:!t&&n?e<n:t&&!n?t<e:!!e:!1,Rx=(e,t)=>{let n=new Map;for(let r of t){let t=r.shift(),i=r.pop(),a=$o(e[t]?.index,e[i]?.index,r.length);for(let t=0;t<r.length;t++){let i=e[r[t]];n.set(i,{index:a[t]})}}return n},zx=e=>!!e.index,Bx=class e{constructor(e,t){this.deleted=e,this.inserted=t}static create(t,n,r,i){return new e(r&&i!==`inserted`?r(t):t,r&&i!==`deleted`?r(n):n)}static calculate(t,n,r,i){if(t===n)return e.empty();let a={},o={};for(let e of this.distinctKeysIterator(`full`,t,n))a[e]=t[e],o[e]=n[e];let[s,c]=i?i(a,o):[a,o];return e.create(s,c,r)}static empty(){return new e({},{})}static isEmpty(e){return!Object.keys(e.deleted).length&&!Object.keys(e.inserted).length}static mergeObjects(e,t,n){let r={...e};for(let e of Object.keys(n))delete r[e];return{...r,...t}}static mergeArrays(t,n,r,i){return Object.values(e.mergeObjects(Du(t??[],i),Du(n??[],i),Du(r??[],i)))}static diffObjects(t,n,r,i){if(!(!t[r]&&!n[r])&&(typeof t[r]==`object`||typeof n[r]==`object`)){let a=t[r]??{},o=n[r]??{},s=e.getLeftDifferences(a,o).reduce((e,t)=>(e[t]=i(a[t]),e),{}),c=e.getRightDifferences(a,o).reduce((e,t)=>(e[t]=i(o[t]),e),{});Object.keys(s).length||Object.keys(c).length?(Reflect.set(t,r,s),Reflect.set(n,r,c)):(Reflect.deleteProperty(t,r),Reflect.deleteProperty(n,r))}}static diffArrays(t,n,r,i){if(!(!t[r]&&!n[r])&&(Array.isArray(t[r])||Array.isArray(n[r]))){let a=Array.isArray(t[r])?t[r]:[],o=Array.isArray(n[r])?n[r]:[],s=Du(e.getLeftDifferences(Du(a,i),Du(o,i))),c=Du(e.getRightDifferences(Du(a,i),Du(o,i)));if(Object.keys(s).length||Object.keys(c).length){let e=a.filter(e=>s[i?i(e):String(e)]),l=o.filter(e=>c[i?i(e):String(e)]);Reflect.set(t,r,e),Reflect.set(n,r,l)}else Reflect.deleteProperty(t,r),Reflect.deleteProperty(n,r)}}static isLeftDifferent(e,t,n=!1){return!!this.distinctKeysIterator(`left`,e,t,n).next().value}static isRightDifferent(e,t,n=!1){return!!this.distinctKeysIterator(`right`,e,t,n).next().value}static getLeftDifferences(e,t,n=!1){return Array.from(this.distinctKeysIterator(`left`,e,t,n))}static getRightDifferences(e,t,n=!1){return Array.from(this.distinctKeysIterator(`right`,e,t,n))}static*distinctKeysIterator(e,t,n,r=!1){if(t===n)return;let i=[];e===`left`?i=Object.keys(t):e===`right`?i=Object.keys(n):e===`full`?i=Array.from(new Set([...Object.keys(t),...Object.keys(n)])):Bu(e,`Unknown distinctKeysIterator's join param "${e}"`,!0);for(let e of i){let i=t[e],a=n[e];if(i!==a){if(!r&&typeof i==`object`&&typeof a==`object`&&i!==null&&a!==null&&Ru(i,a))continue;yield e}}}},Vx=class e{constructor(e){this.delta=e}static calculate(t,n){return new e(Bx.calculate(t,n,void 0,e.postProcess))}static empty(){return new e(Bx.create({},{}))}inverse(){return new e(Bx.create(this.delta.inserted,this.delta.deleted))}applyTo(e,t){try{let{selectedElementIds:n={},selectedGroupIds:r={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:o,editingLinearElementId:s,...c}=this.delta.inserted,l=Bx.mergeObjects(e.selectedElementIds,i,n),u=Bx.mergeObject
|
||
|
|
<script src="${i}.js"><\/script>
|
||
|
|
<style type="text/css">
|
||
|
|
* { margin: 0px; }
|
||
|
|
table, .gist { height: 100%; }
|
||
|
|
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
||
|
|
</style>
|
||
|
|
`),intrinsicSize:{w:550,h:720},sandbox:{allowSameOrigin:n}};return Qx.set(e,a),a}return Qx.set(e,{link:e,intrinsicSize:i,type:r,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:i,type:r,sandbox:{allowSameOrigin:n}}},hS=e=>{let t;t=id(e)?`IFrame element`:!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=Is.Helvetica,i=$l({fontSize:n,fontFamily:r});return _x({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor===`transparent`?`black`:e.strokeColor,backgroundColor:`transparent`,fontFamily:r,fontSize:n,text:af(t,i,e.width-20),textAlign:`center`,verticalAlign:gc.MIDDLE,angle:e.angle??0})};Jb({name:`setEmbeddableAsActiveTool`,trackEvent:{category:`toolbar`},target:`Tool`,label:`toolBar.embeddable`,perform:(e,t,n,r)=>{let i=su(t,{type:`embeddable`});return ax(r.canvas,{...t,activeTool:i}),{elements:e,appState:{...t,activeTool:su(t,{type:`embeddable`})},captureUpdate:Jx.EVENTUALLY}}});var gS=(e,t)=>{try{let{hostname:n}=new URL(e),r=n.replace(/^www\./,``);if(t instanceof Set){if(dS.has(r))return r;let e=r.replace(/^([^.]+)/,`*`);return dS.has(e)?e:null}let i=t.replace(/^www\./,``);if(r===i)return i}catch{}return null},_S=e=>{let t=e.match(aS);if(t&&t.length===2)return t[1];let n=e.match(uS);if(n&&n.length===2)return n[1];let r=e.match(rS);if(r&&r.length===2)return r[1];if(cS.test(e))return`https://giphy.com/embed/${cS.exec(e)[1]}`;let i=e.match(sS);return i&&i.length===2?i[1]:e},vS=(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(gS(e,n))return!0;return!1}}return!!gS(e,dS)},yS=(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)},bS=(e,t,n,r,i)=>{if(!r.enabled||!r.clip)return null;let a=CT(e,i);if(a){let e=t.ownerDocument.createElementNS(P,`g`);return e.setAttributeNS(P,`clip-path`,`url(#${a.id})`),n.forEach(t=>e.appendChild(t)),e}return null},xS=(e,t,n,r,i,a,o,s)=>{let c={x:a,y:o},[l,u,d,f]=Y(e,t),p=(d-l)/2-(e.x-l),m=(f-u)/2-(e.y-u);if(V(e)){let n=Mb(e,t);if(H(n)){let[r,i,s,c]=Y(n,t),l=Z.getBoundTextElementPosition(n,e,t);p=(s-r)/2-(l.x-r),m=(c-i)/2-(l.y-i),a=a+l.x-e.x,o=o+l.y-e.y}}let h=180*e.angle/Math.PI,g=r;if(e.link){let t=r.ownerDocument.createElementNS(P,`a`);t.setAttribute(`href`,Wb(e.link)),g.appendChild(t),g=t}let _=(e,t)=>{ku()&&e.setAttribute(`data-id`,t.id),g.appendChild(e)},v=(CT(e,t)?.opacity??100)*e.opacity/1e4;switch(e.type){case`selection`:throw Error(`Selection rendering is not supported for SVG`);case`rectangle`:case`diamond`:case`ellipse`:{let r=yS(n,ff.generateElementShape(e,null),lc);v!==1&&(r.setAttribute(`stroke-opacity`,`${v}`),r.setAttribute(`fill-opacity`,`${v}`)),r.setAttribute(`stroke-linecap`,`round`),r.setAttribute(`transform`,`translate(${a||0} ${o||0}) rotate(${h} ${p} ${m})`),_(bS(e,g,[r],s.frameRendering,t)||r,e);break}case`iframe`:case`embeddable`:{let l=ff.generateElementShape(e,s),u=yS(n,l,lc),d=e.opacity/100;d!==1&&(u.setAttribute(`stroke-opacity`,`${d}`),u.setAttribute(`fill-opacity`,`${d}`)),u.setAttribute(`stroke-linecap`,`round`),u.setAttribute(`transform`,`translate(${a||0} ${o||0}) rotate(${h} ${p} ${m})`),_(u,e);let f=hS(e);xS(f,t,n,g,i,f.x+c.x-e.x,f.y+c.y-e.y,s);let v=yS(n,l,lc);for(v.setAttribute(`stroke-linecap`,`round`),v.setAttribute(`transform`,`translate(${a||0} ${o||0}) rotate(${h} ${p} ${m})`);v.firstChild;)v.removeChild(v.firstChild);let y=Ug(Math.min(e.width,e.height),e),b=mS(Kb(e.link||``));if(s.renderEmbeddables===!1||b?.type===`document`){let t=r.ownerDocument.createElementNS(P,`a`);t.setAttribute(`href`,Wb(e.link||``)),t.setAttribute(`target`,`_blank`),t.setAttribute(`rel`,`noopener noreferrer`),t.style.borderRadius=`${y}px`,v.appendChild(t)}else{let t=r.ownerDocument.createElementNS(P,`foreignObject`);t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.style.border=`none`
|
||
|
|
`).split(`
|
||
|
|
`),c=Fd(e.fontSize,e.lineHeight),l=e.textAlign===`center`?e.width/2:e.textAlign===`right`?e.width:0,u=Uh(e.fontFamily,e.fontSize,c),d=pu(e.text)?`rtl`:`ltr`,f=e.textAlign===`center`?`middle`:e.textAlign===`right`||d===`rtl`?`end`:`start`;for(let t=0;t<i.length;t++){let a=r.ownerDocument.createElementNS(P,`text`);a.textContent=i[t],a.setAttribute(`x`,`${l}`),a.setAttribute(`y`,`${t*c+u}`),a.setAttribute(`font-family`,Ql(e)),a.setAttribute(`font-size`,`${e.fontSize}px`),a.setAttribute(`fill`,e.strokeColor),a.setAttribute(`text-anchor`,f),a.setAttribute(`style`,`white-space: pre;`),a.setAttribute(`direction`,d),a.setAttribute(`dominant-baseline`,`alphabetic`),n.appendChild(a)}_(bS(e,g,[n],s.frameRendering,t)||n,e)}else throw Error(`Unimplemented type ${e.type}`)}},SS=(e,t,n,r,i,a)=>{r&&(e.filter(e=>!ad(e)).forEach(e=>{if(!e.isDeleted){if(V(e)&&e.containerId&&t.has(e.containerId))return;try{xS(e,t,n,r,i,e.x+a.offsetX,e.y+a.offsetY,a);let o=jb(e,t);o&&xS(o,t,n,r,i,o.x+a.offsetX,o.y+a.offsetY,a)}catch(e){console.error(e)}}}),e.filter(e=>ad(e)).forEach(e=>{if(!e.isDeleted)try{xS(e,t,n,r,i,e.x+a.offsetX,e.y+a.offsetY,a)}catch(e){console.error(e)}}))},CS=500,wS=e=>{let t=e.extensions?.reduce((e,t)=>(e.push(N[t]),e),[]),n=e.extensions?.reduce((e,t)=>t===`jpg`?e.concat(`.jpg`,`.jpeg`):e.concat(`.${t}`),[]);return ns({description:e.description,extensions:n,mimeTypes:t,multiple:e.multiple??!1,legacySetup:(t,n,r)=>{let i=eu(n,CS),a=()=>{o(),document.addEventListener(`keyup`,i),document.addEventListener(`pointerup`,i),i()},o=()=>{r.files?.length&&t(e.multiple?[...r.files]:r.files[0])};requestAnimationFrame(()=>{window.addEventListener(`focus`,a)});let s=window.setInterval(()=>{o()},CS);return e=>{clearInterval(s),i.cancel(),window.removeEventListener(`focus`,a),document.removeEventListener(`keyup`,i),document.removeEventListener(`pointerup`,i),e&&(console.warn(`Opening the file was canceled (legacy-fs).`),e(new ph))}}})},TS=(e,t)=>is(e,{fileName:`${t.name}.${t.extension}`,description:t.description,extensions:[`.${t.extension}`],mimeTypes:t.mimeTypes},t.fileHandle),ES=(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},DS=(e,t,n,r)=>{let i={type:$s.excalidraw,version:pc.excalidraw,source:ec,elements:r===`local`?XE(e):YE(e),appState:r===`local`?Hc(t):Uc(t),files:r===`local`?ES(e,n):void 0};return JSON.stringify(i,null,2)},OS=async(e,t,n,r=t.name||`Untitled`)=>{let i=DS(e,t,n,`local`);return{fileHandle:await TS(new Blob([i],{type:N.excalidraw}),{name:r,extension:`excalidraw`,description:`Excalidraw file`,fileHandle:eD(t.fileHandle)?null:t.fileHandle})}},kS=async(e,t)=>{let n=await wS({description:`Excalidraw files`});return iD(await bD(n),e,t,n.handle)},AS=e=>e?.type===$s.excalidraw&&(!e.elements||Array.isArray(e.elements)&&(!e.appState||typeof e.appState==`object`)),jS=e=>typeof e==`object`&&e&&e.type===$s.excalidrawLibrary&&(e.version===1||e.version===2),MS=e=>{let t={type:$s.excalidrawLibrary,version:pc.excalidrawLibrary,source:ec,libraryItems:e};return JSON.stringify(t,null,2)},NS=async e=>{let t=MS(e);await TS(new Blob([t],{type:N.excalidrawlib}),{name:`library`,extension:`excalidrawlib`,description:`Excalidraw library file`})},PS=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>{t(r)},r.onerror=e=>{n(e)},r.src=e}),FS=async({fileIds:e,files:t,imageCache:n})=>{let r=new Map,i=new Map;return await Promise.all(e.reduce((e,a)=>{let o=t[a];return o&&!r.has(a)?(r.set(a,!0),e.concat((async()=>{try{if(o.mimeType===N.binary)throw Error(`Only images can be added to ImageCache`);let e=PS(o.dataURL),t={image:e,mimeType:o.mimeType};n.set(a,t);let r=await e;n.set(a,{...t,image:r})}catch{i.set(a,!0)}})())):e},[])),{imageCache:n,updatedFiles:r,erroredFiles:i}},IS=e=>e.filter(e=>td(e)),LS=e=>e?.nodeName.toLowerCase()===`svg`,RS=e=>{let t=new DOMParser().parseFromString(e,N.svg),n=t.querySelector(`svg`);if(t.querySelector(`parsererror`)||!LS(n))throw Error(`Invalid SVG`);{n.hasAttribute(`xmlns`)||n.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`);let e=n.getAttribute(`width`),t=n
|
||
|
|
`,w=v.ownerDocument.createElementNS(P,`style`);if(w.classList.add(`style-fonts`),w.appendChild(document.createTextNode(`${C}${S.join(C)}`)),y.appendChild(w),t.exportBackground&&s){let e=v.ownerDocument.createElementNS(P,`rect`);e.setAttribute(`x`,`0`),e.setAttribute(`y`,`0`),e.setAttribute(`width`,`${m}`),e.setAttribute(`height`,`${h}`),e.setAttribute(`fill`,s),v.appendChild(e)}let T=to.svg(v),E=r?.renderEmbeddables??!1;return SS(d,Yu(Tu(d)),T,v,n||{},{offsetX:g,offsetY:_,isExporting:!0,exportWithDarkMode:o,renderEmbeddables:E,frameRendering:i,canvasBackgroundColor:s,embedsValidationStatus:E?new Map(d.filter(e=>cd(e)).map(e=>[e.id,!0])):new Map,reuseImages:r?.reuseImages??!0}),v},pC=({payload:e,metadataElement:t})=>{let n=TD(JSON.stringify(DD({text:e})),!0);t.appendChild(dC(`payload-type:${N.excalidraw}`)),t.appendChild(dC(`payload-version:2`)),t.appendChild(dC(`payload-start`)),t.appendChild(document.createTextNode(n)),t.appendChild(dC(`payload-end`))},mC=({svg:e})=>{if(e.includes(`payload-type:${N.excalidraw}`)){let t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw Error(`INVALID`);let n=(e.match(/<!-- payload-version:(\d+) -->/)?.[1]||`1`)!==`1`;try{let e=ED(t[1],n),r=JSON.parse(e);if(!(`encoded`in r)){if(`type`in r&&r.type===$s.excalidraw)return e;throw Error(`FAILED`)}return OD(r)}catch(e){throw console.error(e),Error(`FAILED`)}}throw Error(`INVALID`)},hC=(e,t)=>{let[n,r,i,a]=pv(e);return[n,r,ou(n,i)+t*2,ou(r,a)+t*2]},gC=(e,t,n)=>{let[,,r,i]=hC(e,t).map(e=>Math.trunc(e*n));return[r,i]},_C=class{constructor(e){this.scoreFunction=e,i(this,`content`,[])}sinkDown(e){let t=this.content[e];for(;e>0;){let n=(e+1>>1)-1,r=this.content[n];if(this.scoreFunction(t)<this.scoreFunction(r))this.content[n]=t,this.content[e]=r,e=n;else break}}bubbleUp(e){let t=this.content.length,n=this.content[e],r=this.scoreFunction(n);for(;;){let i=e+1<<1,a=i-1,o=null,s=0;if(a<t){let e=this.content[a];s=this.scoreFunction(e),s<r&&(o=a)}if(i<t){let e=this.content[i];this.scoreFunction(e)<(o===null?r:s)&&(o=i)}if(o!==null)this.content[e]=this.content[o],this.content[o]=n,e=o;else break}}push(e){this.content.push(e),this.sinkDown(this.content.length-1)}pop(){if(this.content.length===0)return null;let e=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.bubbleUp(0)),e}remove(e){if(this.content.length===0)return;let t=this.content.indexOf(e),n=this.content.pop();t<this.content.length&&(this.content[t]=n,this.scoreFunction(n)<this.scoreFunction(e)?this.sinkDown(t):this.bubbleUp(t))}size(){return this.content.length}rescoreElement(e){this.sinkDown(this.content.indexOf(e))}},vC=1,Q=40,yC=(e,t)=>{let n=e.fixedSegments?e.fixedSegments.slice():null;if(n){let i=[];e.points.map(t=>L(e.x+t[0],e.y+t[1])).forEach((t,r,a)=>{if(r<2)return i.push(t);if(L_(F_(t,a[r-1]),F_(a[r-1],a[r-2]))){let t=n?.findIndex(e=>e.index===r-1)??-1,o=n?.findIndex(e=>e.index===r)??-1;o!==-1&&(n[o].start=L(a[r-2][0]-e.x,a[r-2][1]-e.y)),t!==-1&&n.splice(t,1),i.splice(-1,1),n.forEach(e=>{e.index>r-1&&--e.index})}return i.push(t)});let a=[];i.forEach((e,t,r)=>{if(t<3)return a.push(e);if(hl(r[t-2],r[t-1])<vC){let i=n?.findIndex(e=>e.index===t-2)??-1,o=n?.findIndex(e=>e.index===t-1)??-1;o!==-1&&n.splice(o,1),i!==-1&&n.splice(i,1),a.splice(-2,2),n.forEach(e=>{e.index>t-2&&(e.index-=2)});let s=I_(e,r[t-1]);return a.push(L(s?e[0]:r[t-2][0],s?r[t-2][1]:e[1]))}a.push(e)});let o=n.filter(e=>e.index!==1&&e.index!==a.length-1);return o.length===0?BC(VC(HC(EC(e,TC(e,t,a.map(t=>L(t[0]-e.x,t[1]-e.y)),e.startBinding&&zC(e.startBinding.elementId,t),e.endBinding&&zC(e.endBinding.elementId,t)))??[])),o,null,null):(r.DEV&&Vu(JC(a),`Invalid elbow points with fixed segments`),BC(a,o,e.startIsSpecial,e.endIsSpecial))}return{x:e.x,y:e.y,points:e.points,fixedSegments:e.fixedSegments,startIsSpecial:e.startIsSpecial,endIsSpecial:e.endIsSpecial}},bC=(e,t,n)=>{let r=t.map(e=>e.index),i=(e.fixedSegments?.map(e=>e.index)??[]).findIndex(e=>!r.includes(e));if(i===-1||!e.fixedSegments?.[i])return{points:e.points};let a=e.fixedSegments[i].index,o=e
|
||
|
|
`).map(e=>e.trim().split(` `));if(t.length&&t[0].length!==2&&(t=e.trim().split(`
|
||
|
|
`).map(e=>e.trim().split(`,`))),t.length===0)return{type:mw,reason:`No values`};let n=t[0].length;if(!t.every(e=>e.length===n))return{type:mw,reason:`All rows don't have same number of columns`};let r=vw(t);if(r.type!==hw){let e=vw(yw(t));if(e.type===hw)return e}return r},xw=hs(os),Sw={fillStyle:`hachure`,fontFamily:Hs,fontSize:20,opacity:100,roughness:1,strokeColor:M.black,roundness:null,strokeStyle:`solid`,strokeWidth:1,verticalAlign:gc.MIDDLE,locked:!1},Cw=e=>({chartWidth:(uw+dw)*e.values.length+dw,chartHeight:fw+dw*2}),ww=(e,t,n,r,i)=>e.labels?.map((e,a)=>_x({groupIds:[r],backgroundColor:i,...Sw,text:e.length>8?`${e.slice(0,5)}...`:e,x:t+a*(uw+dw)+dw*2,y:n+dw/2,width:uw,angle:5.87,fontSize:16,textAlign:`center`,verticalAlign:`top`}))||[],Tw=(e,t,n,r,i)=>{let a=_x({groupIds:[r],backgroundColor:i,...Sw,x:t-dw,y:n-dw,text:`0`,textAlign:`right`});return[a,_x({groupIds:[r],backgroundColor:i,...Sw,x:t-dw,y:n-fw-a.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:`right`})]},Ew=(e,t,n,r,i)=>{let{chartWidth:a,chartHeight:o}=Cw(e);return[Sx({backgroundColor:i,groupIds:[r],...Sw,type:`line`,x:t,y:n,width:a,points:[L(0,0),L(a,0)]}),Sx({backgroundColor:i,groupIds:[r],...Sw,type:`line`,x:t,y:n,height:o,points:[L(0,0),L(0,-o)]}),Sx({backgroundColor:i,groupIds:[r],...Sw,type:`line`,x:t,y:n-fw-dw,strokeStyle:`dotted`,width:a,opacity:pw,points:[L(0,0),L(a,0)]})]},Dw=(e,t,n,r,i,a)=>{let{chartWidth:o,chartHeight:s}=Cw(e),c=e.title?_x({backgroundColor:i,groupIds:[r],...Sw,text:e.title,x:t+o/2,y:n-fw-dw*2-20,roundness:null,textAlign:`center`}):null,l=a?dx({backgroundColor:i,groupIds:[r],...Sw,type:`rectangle`,x:t,y:n-s,width:o,height:s,strokeColor:M.black,fillStyle:`solid`,opacity:6}):null;return[...l?[l]:[],...c?[c]:[],...ww(e,t,n,r,i),...Tw(e,t,n,r,i),...Ew(e,t,n,r,i)]},Ow=(e,t,n)=>{let i=Math.max(...e.values),a=lx(),o=xw[Math.floor(Math.random()*xw.length)];return[...e.values.map((e,r)=>{let s=e/i*fw;return dx({backgroundColor:o,groupIds:[a],...Sw,type:`rectangle`,x:t+r*(uw+dw)+dw,y:n-s-dw,width:uw,height:s})}),...Dw(e,t,n,a,o,r.DEV)]},kw=(e,t,n)=>{let i=Math.max(...e.values),a=lx(),o=xw[Math.floor(Math.random()*xw.length)],s=0,c=[];for(let t of e.values){let e=s*(uw+dw),n=-(t/i)*fw;c.push([e,n]),s++}let l=Math.max(...c.map(e=>e[0])),u=Math.max(...c.map(e=>e[1])),d=Math.min(...c.map(e=>e[0])),f=Math.min(...c.map(e=>e[1])),p=Sx({backgroundColor:o,groupIds:[a],...Sw,type:`line`,x:t+dw+uw/2,y:n-dw,height:u-f,width:l-d,strokeWidth:2,points:c}),m=e.values.map((e,r)=>{let s=r*(uw+dw)+dw/2,c=-(e/i)*fw+dw/2;return dx({backgroundColor:o,groupIds:[a],...Sw,fillStyle:`solid`,strokeWidth:2,type:`ellipse`,x:t+s+uw/2,y:n+c-dw*2,width:dw,height:dw})}),h=e.values.map((e,r)=>{let s=r*(uw+dw)+dw/2,c=e/i*fw+dw/2+dw;return Sx({backgroundColor:o,groupIds:[a],...Sw,type:`line`,x:t+s+uw/2+dw/2,y:n-c,height:c,strokeStyle:`dotted`,opacity:pw,points:[L(0,0),L(0,c)]})});return[...Dw(e,t,n,a,o,r.DEV),p,...h,...m]},Aw=(e,t,n,r)=>e===`line`?kw(t,n,r):Ow(t,n,r);`clipboard`in navigator&&`readText`in navigator.clipboard;var jw=`clipboard`in navigator&&`writeText`in navigator.clipboard,Mw=`clipboard`in navigator&&`write`in navigator.clipboard&&`ClipboardItem`in window&&`toBlob`in HTMLCanvasElement.prototype,Nw=e=>!!([$s.excalidraw,$s.excalidrawClipboard,$s.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Pw=({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,i]of Object.entries(e)){if(typeof i!=`string`){t||=[],t.push(i);continue}try{if(n.clipboardData?.setData(r,i),n.clipboardData?.getData(r)!==i)throw Error(`Failed to set "${r}" as clipboardData item`)}catch(e){throw Error(e.message)}}if(t){let e=-1;for(let r of t){e++;try{if(n.clipboardData?.items.add(r),n.clipboardData?.files[e]!==r)throw Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(e){throw Error(e.message)}}}return n},Fw=({elements:e,files:t})=>{let n=Tu(e),r=new Set(e.filter(e=>cd(e))),i=!1,a=e.reduce((e,n)=>(td(n)&&(i=!0,t&&t[n.fi
|
||
|
|
`).trim()}:n:{type:`text`,value:(e.clipboardData?.getData(N.text)||``).trim()}}catch{return{type:`text`,value:``}}},Hw=async(e,t=!1)=>{let n=await Vw(e,t);if(n.type===`mixedContent`)return{mixedContent:n.value};try{let e=!t&&Lw(n.value);if(e)return e}catch(e){console.error(e)}try{let e=JSON.parse(n.value),r=e.type===$s.excalidrawClipboardWithAPI;if(Nw(e))return{elements:e.elements,files:e.files,text:t?JSON.stringify(e.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:n.value}},Uw=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[N.png]:e})])}catch(t){if(Fu(e))await navigator.clipboard.write([new window.ClipboardItem({[N.png]:await e})]);else throw t}},Ww=async(e,t)=>{if(jw)try{await navigator.clipboard.writeText(e||``);return}catch(e){console.error(e)}try{if(t){if(t.clipboardData?.setData(N.text,e||``),t.clipboardData?.getData(N.text)!==e)throw Error(`Failed to setData on clipboardEvent`);return}}catch(e){console.error(e)}if(!Gw(e))throw Error(`Error copying to clipboard.`)},Gw=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 i=!1;try{n.select(),n.setSelectionRange(0,n.value.length),i=document.execCommand(`copy`)}catch(e){console.error(e)}return n.remove(),i},Kw=({elements:e,appState:t,files:n,maxWidthOrHeight:r,getDimensions:i,exportPadding:a,exportingFrame:o})=>{let{elements:s,appState:c}=sw({elements:e,appState:t},null,null),{exportBackground:l,viewBackgroundColor:u}=c;return uC(s,{...c,offsetTop:0,offsetLeft:0,width:0,height:0},n||{},{exportBackground:l,exportPadding:a,viewBackgroundColor:u,exportingFrame:o},(e,n)=>{let a=document.createElement(`canvas`);if(r){typeof i==`function`&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let o=Math.max(e,n),s=r<o?r/o:t?.exportScale??1;return a.width=e*s,a.height=n*s,{canvas:a,scale:s}}let o=i?.(e,n)||{width:e,height:n};return a.width=o.width,a.height=o.height,{canvas:a,scale:o.scale??1}})},qw=async e=>{let{mimeType:t=N.png,quality:n}=e;t===N.png&&typeof n==`number`&&console.warn(`"quality" will be ignored for "${N.png}" mimeType`),t===`image/jpg`&&(t=N.jpg),t===N.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${N.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await Kw(e);return n||=/image\/jpe?g/.test(t)?.92:.8,new Promise((i,a)=>{r.toBlob(async n=>{if(!n)return a(Error(`couldn't export to blob`));n&&t===N.png&&e.appState?.exportEmbedScene&&(n=await AD({blob:n,metadata:DS(e.elements,e.appState,e.files||{},`local`)})),i(n)},t,n)})},Jw=async({elements:e,appState:t=zc(),files:n={},exportPadding:r,renderEmbeddables:i,exportingFrame:a,skipInliningFonts:o,reuseImages:s})=>{let{elements:c,appState:l}=sw({elements:e,appState:t},null,null);return fC(c,{...l,exportPadding:r},n,{exportingFrame:a,renderEmbeddables:i,skipInliningFonts:o,reuseImages:s})},Yw=e=>e.type===`diamond`?[L(e.width/2,0),L(e.width,e.height/2),L(e.width/2,e.height),L(0,e.height/2)]:[L(0,0),L(0+e.width,0),L(0+e.width,e.height),L(0,e.height)],Xw=e=>dd(e)||ld(e)?e.points:Yw(e),Zw=e=>{let t=e.reduce((e,[t,n])=>(e.minY=Math.min(e.minY,n),e.minX=Math.min(e.minX,t),e.maxX=Math.max(e.maxX,t),e.maxY=Math.max(e.maxY,n),e),{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},Qw=e=>{let t=Xw(e),{cx:n,cy:r}=Zw(t),i=L(n,r),{minX:a,minY:o,maxX:s,maxY:c}=Zw(t.map(t=>z(t,i,e.angle)));return[a+e.x,o+e.y,s+e.x,c+e.y]},$w=(e,t,n=!1)=>{let r=Qw(e),i=t[0]<=r[0]&&t[2]>=r[2]&&t[1]<=r[1]&&t[3]>=r[3];return n?i?!0:r[0]<=t[0]&&r[2]>=t[2]&&r[1]<=t[1]&&r[3]>=t[3]:i},eT=(e,t)=>{let n=Qw(e);return(Ul(n[0],Bl(t[0],t[2]))||Ul(t[0],Bl(n[0],n[2])))&&(Ul(n[1],Bl(t[1],t[3]))||Ul(t[1],Bl(n[1],n[3])))
|