@oh-just-another/diagram 0.3.11 → 0.3.13

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.
@@ -1,6 +1,6 @@
1
- var ge=Object.defineProperty;var a0=(e,o)=>{for(var l in o)ge(e,l,{get:o[l],enumerable:!0})};var po=(e,o)=>Math.max(e.width,e.height)*o,Z=(e,o,l)=>l?.minTextScreenPx!==void 0&&e*o<l.minTextScreenPx;var yo=new Map,v=(e,o)=>{yo.set(e,o)},fo=e=>yo.get(e);var Ao=[{text:"Type something",weight:40},{text:"Place for text",weight:20},{text:"Start typing\u2026",weight:12},{text:"Your text here",weight:10},{text:"Add a note",weight:8},{text:"What's on your mind?",weight:6},{text:"Words go here",weight:5},{text:"Say it in a few words",weight:4},{text:"Lorem ipsum? No \u2014 your words.",weight:3},{text:"Blank is a state of mind",weight:2},{text:"Insert genius here",weight:2},{text:"The cursor is waiting patiently",weight:1}];var _0=(e,o,l)=>{if(!e||e.type==="sharp")return 0;let r=Math.min(Math.abs(o),Math.abs(l));if(r<=0)return 0;if(e.value!==void 0)return Math.max(0,Math.min(e.value,r/2));let t=32/.25;return r<=t?r*.25:32};var _e=e=>{let o=2166136261;for(let l=0;l<e.length;l++)o^=e.charCodeAt(l),o=Math.imul(o,16777619)>>>0;return o},$=(e,o=Ao)=>{let l=o.reduce((t,s)=>t+Math.max(1,s.weight),0);if(l<=0||o.length===0)return"";let r=_e(e)%l;for(let t of o)if(r-=Math.max(1,t.weight),r<0)return t.text;return o[o.length-1]?.text??""};var mo=e=>{if(!e)return"";let o=Object.entries(e).filter(([,l])=>l!==void 0).sort(([l],[r])=>l<r?-1:l>r?1:0);return JSON.stringify(o)},uo=e=>{let o=[];for(let l of e){if(l.text==="")continue;let r=o[o.length-1];r!==void 0&&mo(r.style)===mo(l.style)?o[o.length-1]={text:r.text+l.text,...r.style!==void 0?{style:r.style}:{}}:o.push(l)}return o},ke=e=>{let o=e.runs;return o!==void 0&&o.length>0?uo(o):e.text===""?[]:[{text:e.text}]},k0=(e,o,l)=>{let r=Math.min(o,l),t=Math.max(o,l),s=[],i=0;for(let a of ke(e)){let n=i,f=i+a.text.length;i=f;let d=Math.max(n,r),p=Math.min(f,t);d>=p||s.push({text:a.text.slice(d-n,p-n),...a.style!==void 0?{style:a.style}:{}})}return s};var E0=e=>{let o=1;for(let l of e)l===`
2
- `&&o++;return o};var bo=(e,o)=>e?.[o]??{};var w0=(e,o)=>{let l=[],r=new Map;for(let t=0;t<o;t++){let s=bo(e,t),i=s.indent??0;if(s.list==="numbered"){let a=(r.get(i)??0)+1;r.set(i,a);for(let n of[...r.keys()])n>i&&r.delete(n);l.push(`${String(a)}.`)}else{if(s.list===void 0)r.clear();else for(let a of[...r.keys()])a>=i&&r.delete(a);l.push(s.list==="bullet"?"\u2022":null)}}return l};var g=e=>{if(e===void 0)throw new Error("required value is undefined");return e};var h={};a0(h,{ZERO:()=>go,add:()=>we,angle:()=>Me,cross:()=>Oe,distance:()=>Se,distanceSq:()=>_o,div:()=>Re,dot:()=>Ie,equals:()=>ze,length:()=>xo,lengthSq:()=>ho,lerp:()=>De,midpoint:()=>Ce,mul:()=>ve,negate:()=>Le,normalize:()=>Pe,of:()=>Ee,perp:()=>Be,rotate:()=>Fe,rotateAround:()=>Ne,sub:()=>Te});var go=Object.freeze({x:0,y:0}),Ee=(e,o)=>({x:e,y:o}),we=(e,o)=>({x:e.x+o.x,y:e.y+o.y}),Te=(e,o)=>({x:e.x-o.x,y:e.y-o.y}),ve=(e,o)=>({x:e.x*o,y:e.y*o}),Re=(e,o)=>({x:e.x/o,y:e.y/o}),Le=e=>({x:-e.x,y:-e.y}),Ie=(e,o)=>e.x*o.x+e.y*o.y,Oe=(e,o)=>e.x*o.y-e.y*o.x,ho=e=>e.x*e.x+e.y*e.y,xo=e=>Math.sqrt(ho(e)),_o=(e,o)=>{let l=o.x-e.x,r=o.y-e.y;return l*l+r*r},Se=(e,o)=>Math.sqrt(_o(e,o)),Pe=e=>{let o=xo(e);return o===0?go:{x:e.x/o,y:e.y/o}},De=(e,o,l)=>({x:e.x+(o.x-e.x)*l,y:e.y+(o.y-e.y)*l}),Ce=(e,o)=>({x:(e.x+o.x)/2,y:(e.y+o.y)/2}),Me=e=>Math.atan2(e.y,e.x),Fe=(e,o)=>{let l=Math.cos(o),r=Math.sin(o);return{x:e.x*l-e.y*r,y:e.x*r+e.y*l}},Ne=(e,o,l)=>{let r=Math.cos(l),t=Math.sin(l),s=e.x-o.x,i=e.y-o.y;return{x:o.x+(s*r-i*t),y:o.y+(s*t+i*r)}},Be=e=>({x:-e.y,y:e.x}),ze=(e,o,l=0)=>l===0?e.x===o.x&&e.y===o.y:Math.abs(e.x-o.x)<=l&&Math.abs(e.y-o.y)<=l;var I={};a0(I,{IDENTITY:()=>He,applyToBounds:()=>Ye,applyToPoint:()=>J,decompose:()=>Ve,equals:()=>qe,inverse:()=>Xe,multiply:()=>Ke,of:()=>We,rotation:()=>je,scaling:()=>Ue,translation:()=>Ge});var He=Object.freeze({a:1,b:0,c:0,d:1,e:0,f:0}),We=(e,o,l,r,t,s)=>({a:e,b:o,c:l,d:r,e:t,f:s}),Ge=(e,o)=>({a:1,b:0,c:0,d:1,e,f:o}),Ue=(e,o=e)=>({a:e,b:0,c:0,d:o,e:0,f:0}),je=e=>{let o=Math.cos(e),l=Math.sin(e);return{a:o,b:l,c:-l,d:o,e:0,f:0}},Ke=(e,o)=>({a:e.a*o.a+e.c*o.b,b:e.b*o.a+e.d*o.b,c:e.a*o.c+e.c*o.d,d:e.b*o.c+e.d*o.d,e:e.a*o.e+e.c*o.f+e.e,f:e.b*o.e+e.d*o.f+e.f}),Xe=e=>{let o=e.a*e.d-e.b*e.c;if(o===0)throw new Error("Cannot invert singular matrix");return{a:e.d/o,b:-e.b/o,c:-e.c/o,d:e.a/o,e:(e.c*e.f-e.d*e.e)/o,f:(e.b*e.e-e.a*e.f)/o}},J=(e,o)=>({x:e.a*o.x+e.c*o.y+e.e,y:e.b*o.x+e.d*o.y+e.f}),Ye=(e,o)=>{let l=J(e,{x:o.x,y:o.y}),r=J(e,{x:o.x+o.width,y:o.y}),t=J(e,{x:o.x,y:o.y+o.height}),s=J(e,{x:o.x+o.width,y:o.y+o.height}),i=Math.min(l.x,r.x,t.x,s.x),a=Math.min(l.y,r.y,t.y,s.y),n=Math.max(l.x,r.x,t.x,s.x),f=Math.max(l.y,r.y,t.y,s.y);return{x:i,y:a,width:n-i,height:f-a}},Ve=e=>{let o=Math.sqrt(e.a*e.a+e.b*e.b),l=Math.sqrt(e.c*e.c+e.d*e.d),t=e.a*e.d-e.b*e.c<0?-l:l;return{translation:{x:e.e,y:e.f},rotation:Math.atan2(e.b,e.a),scale:{x:o,y:t}}},qe=(e,o,l=0)=>{let r=["a","b","c","d","e","f"];return l===0?r.every(t=>e[t]===o[t]):r.every(t=>Math.abs(e[t]-o[t])<=l)};var R={};a0(R,{EMPTY:()=>ko,centerOf:()=>Qe,contains:()=>ll,containsBounds:()=>rl,equals:()=>sl,expand:()=>tl,fromCenter:()=>Je,fromPoints:()=>$e,intersection:()=>Eo,intersects:()=>el,isEmpty:()=>T0,maxX:()=>D,maxY:()=>C,normalize:()=>il,of:()=>Ze,union:()=>ol});var ko=Object.freeze({x:0,y:0,width:0,height:0}),Ze=(e,o,l,r)=>({x:e,y:o,width:l,height:r}),$e=e=>{if(e.length===0)return ko;let o=1/0,l=1/0,r=-1/0,t=-1/0;for(let s of e)s.x<o&&(o=s.x),s.y<l&&(l=s.y),s.x>r&&(r=s.x),s.y>t&&(t=s.y);return{x:o,y:l,width:r-o,height:t-l}},Je=(e,o,l)=>({x:e.x-o/2,y:e.y-l/2,width:o,height:l}),Qe=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),D=e=>e.x+e.width,C=e=>e.y+e.height,T0=e=>e.width<=0||e.height<=0,ol=(e,o)=>{if(T0(e))return o;if(T0(o))return e;let l=Math.min(e.x,o.x),r=Math.min(e.y,o.y),t=Math.max(D(e),D(o)),s=Math.max(C(e),C(o));return{x:l,y:r,width:t-l,height:s-r}},Eo=(e,o)=>{let l=Math.max(e.x,o.x),r=Math.max(e.y,o.y),t=Math.min(D(e),D(o)),s=Math.min(C(e),C(o));return t<=l||s<=r?null:{x:l,y:r,width:t-l,height:s-r}},el=(e,o)=>Eo(e,o)!==null,ll=(e,o)=>o.x>=e.x&&o.x<=D(e)&&o.y>=e.y&&o.y<=C(e),rl=(e,o)=>o.x>=e.x&&o.y>=e.y&&D(o)<=D(e)&&C(o)<=C(e),tl=(e,o)=>({x:e.x-o,y:e.y-o,width:e.width+2*o,height:e.height+2*o}),il=e=>({x:e.width<0?e.x+e.width:e.x,y:e.height<0?e.y+e.height:e.y,width:Math.abs(e.width),height:Math.abs(e.height)}),sl=(e,o,l=0)=>l===0?e.x===o.x&&e.y===o.y&&e.width===o.width&&e.height===o.height:Math.abs(e.x-o.x)<=l&&Math.abs(e.y-o.y)<=l&&Math.abs(e.width-o.width)<=l&&Math.abs(e.height-o.height)<=l;var Q={};a0(Q,{offsetClosedPath:()=>al,signedArea:()=>nl});var al=(e,o)=>{if(e.length<3||o===0)return e.map(n=>({x:n.x,y:n.y}));let l=0,r=0;for(let n of e)l+=n.x,r+=n.y;l/=e.length,r/=e.length;let t=e.length,s=new Array(t),i=new Array(t);for(let n=0;n<t;n++){let f=g(e[n]),d=g(e[(n+1)%t]),p=d.x-f.x,c=d.y-f.y,y=Math.hypot(p,c)||1;s[n]=-c/y,i[n]=p/y}let a=[];for(let n=0;n<t;n++){let f=(n-1+t)%t,d=g(s[f]),p=g(i[f]),c=g(s[n]),y=g(i[n]),A=d+c,m=p+y,u=Math.hypot(A,m);u<1e-6?(A=d,m=p):(A/=u,m/=u);let x=g(e[n]),S=l-x.x,L=r-x.y,E=A*S+m*L>=0?1:-1,b=A*d+m*p,k=b>1e-6?o/b:o;a.push({x:x.x+E*A*k,y:x.y+E*m*k})}return a},nl=e=>{let o=0;for(let l=0;l<e.length;l++){let r=g(e[l]),t=g(e[(l+1)%e.length]);o+=r.x*t.y-t.x*r.y}return o/2};var cl=null;var wo=()=>cl;var n0=e=>e.type==="text";var v0=e=>e.stroke??e.fill??"#000",To=new Map,w=(e,o)=>{To.set(e,o)};var c0=e=>{let o=To.get(e.type);if(!o)throw new Error(`No bounder registered for shape type: ${e.type}`);return o(e)},R0=e=>{let o=c0(e),l=[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x,y:o.y+o.height},{x:o.x+o.width,y:o.y+o.height}],r=Math.sin(e.rotation),t=Math.cos(e.rotation),s=l.map(i=>{let a=i.x*e.scale.x,n=i.y*e.scale.y;return{x:e.position.x+(a*t-n*r),y:e.position.y+(a*r+n*t)}});return R.fromPoints(s)};w("rectangle",e=>({x:0,y:0,width:e.width,height:e.height}));w("ellipse",e=>({x:0,y:0,width:e.width,height:e.height}));w("polygon",e=>R.fromPoints(e.points));w("sticky",e=>({x:0,y:0,width:e.width,height:e.height}));w("emoji",e=>({x:0,y:0,width:e.size,height:e.size}));w("path",e=>{let o=[],l={x:0,y:0};for(let r of e.commands)switch(r.kind){case"M":case"L":o.push(r.to),l=r.to;break;case"Q":o.push(r.control,r.to),l=r.to;break;case"C":o.push(r.control1,r.control2,r.to),l=r.to;break;case"Z":break}return R.fromPoints(o)});w("text",e=>{let o=e.fontSize*1.2,l=(e.text===""?$(e.id):e.text).split(`
3
- `),r=wo(),t={bold:e.style.fontWeight==="bold",italic:e.style.fontStyle==="italic"},s=a=>{if(r){let n=r(a,e.fontFamily,e.fontSize,t);if(n!==null)return n}return a.length*e.fontSize*.6};if(e.maxWidth===void 0){let a=0;for(let n of l)a=Math.max(a,s(n));return a=Math.max(a,e.fontSize*.5),{x:0,y:0,width:a,height:Math.max(1,l.length)*o}}let i=0;for(let a of l)i+=Math.max(1,Math.ceil(s(a)/e.maxWidth));return{x:0,y:0,width:e.maxWidth,height:Math.max(1,i)*o}});w("image",e=>({x:0,y:0,width:e.width,height:e.height}));w("template",e=>({x:0,y:0,width:e.width,height:e.height}));w("brush",e=>{if(e.points.length===0)return{x:0,y:0,width:0,height:0};let o=1/0,l=1/0,r=-1/0,t=-1/0;for(let s of e.points)s.x-s.width<o&&(o=s.x-s.width),s.y-s.width<l&&(l=s.y-s.width),s.x+s.width>r&&(r=s.x+s.width),s.y+s.width>t&&(t=s.y+s.width);return{x:o,y:l,width:r-o,height:t-l}});w("group",()=>({x:0,y:0,width:0,height:0}));w("frame",e=>({x:0,y:0,width:e.width,height:e.height}));w("block-arrow",e=>({x:0,y:0,width:e.width,height:e.height}));var L0=(e,o)=>e.order<o.order?-1:e.order>o.order?1:0;var I0=e=>[...e.layers.values()].sort(L0),p0=(e,o)=>[...e.elements.values()].filter(l=>l.layerId===o).sort(L0);var O0=e=>{let o=e.length;if(o<2)return[];let l=p=>{let c=g(e[p]);return{x:c.x,y:c.y}},r=p=>g(e[p]).width,t=[],s=[];for(let p=0;p<o-1;p++){let c=h.sub(l(p+1),l(p)),y=h.lengthSq(c)>0?h.normalize(c):{x:1,y:0};t.push(y),s.push(h.perp(y))}let i=[],a=[];for(let p=0;p<o;p++){let c=r(p),y=l(p);if(p===0){let x=g(s[0]);i.push(h.add(y,h.mul(x,c))),a.push(h.sub(y,h.mul(x,c)));continue}if(p===o-1){let x=g(s[o-2]);i.push(h.add(y,h.mul(x,c))),a.push(h.sub(y,h.mul(x,c)));continue}let A=g(s[p-1]),m=g(s[p]),u=h.cross(g(t[p-1]),g(t[p]));if(Math.abs(u)<1e-9){i.push(h.add(y,h.mul(A,c))),a.push(h.sub(y,h.mul(A,c)));continue}u>0?(i.push(...vo(y,A,m,c,1)),a.push(...Ro(y,A,m,c,-1))):(i.push(...Ro(y,A,m,c,1)),a.push(...vo(y,A,m,c,-1)))}let n=Lo(l(o-1),g(s[o-2]),r(o-1),!1),f=Lo(l(0),g(s[0]),r(0),!0),d=[];for(let p of i)d.push(p);for(let p of n)d.push(p);for(let p=a.length-1;p>=0;p--)d.push(g(a[p]));for(let p of f)d.push(p);return d},vo=(e,o,l,r,t)=>{let s=h.normalize(h.add(o,l)),i=h.dot(s,o);return i>.001&&1/i<=2.5?[h.add(e,h.mul(s,t*(r/i)))]:[h.add(e,h.mul(o,t*r)),h.add(e,h.mul(l,t*r))]},Ro=(e,o,l,r,t)=>Io(e,r,h.angle(h.mul(o,t)),h.angle(h.mul(l,t))),Lo=(e,o,l,r)=>{let t=h.angle(o)+(r?Math.PI:0);return Io(e,l,t,t-Math.PI)},Io=(e,o,l,r)=>{let t=r-l;for(;t>Math.PI+1e-9;)t-=2*Math.PI;for(;t<-Math.PI-1e-9;)t+=2*Math.PI;let s=Math.max(1,Math.ceil(Math.abs(t)/.35)),i=[];for(let a=0;a<=s;a++){let n=l+t*a/s;i.push({x:e.x+o*Math.cos(n),y:e.y+o*Math.sin(n)})}return i};var pl=new Map,d0=(e,o)=>{pl.set(e,o)};var dl=Object.freeze({pan:{x:0,y:0},zoom:1,rotation:0,size:{width:0,height:0},gridEnabled:!1}),S0=e=>{let o=I.translation(-e.pan.x,-e.pan.y),l=I.rotation(e.rotation),r=I.scaling(e.zoom);return I.multiply(r,I.multiply(l,o))};var P0={gray1:"#111111",gray2:"#191919",gray3:"#222222",gray4:"#2a2a2a",gray5:"#313131",gray6:"#3a3a3a",gray7:"#484848",gray8:"#606060",gray9:"#6e6e6e",gray10:"#7b7b7b",gray11:"#b4b4b4",gray12:"#eeeeee"};var y0={tomato1:"#181111",tomato2:"#1f1513",tomato3:"#391714",tomato4:"#4e1511",tomato5:"#5e1c16",tomato6:"#6e2920",tomato7:"#853a2d",tomato8:"#ac4d39",tomato9:"#e54d2e",tomato10:"#ec6142",tomato11:"#ff977d",tomato12:"#fbd3cb"};var D0={plum1:"#181118",plum2:"#201320",plum3:"#351a35",plum4:"#451d47",plum5:"#512454",plum6:"#5e3061",plum7:"#734079",plum8:"#92549c",plum9:"#ab4aba",plum10:"#b658c4",plum11:"#e796f3",plum12:"#f4d4f4"};var F={iris1:"#13131e",iris2:"#171625",iris3:"#202248",iris4:"#262a65",iris5:"#303374",iris6:"#3d3e82",iris7:"#4a4a95",iris8:"#5958b1",iris9:"#5b5bd6",iris10:"#6e6ade",iris11:"#b1a9ff",iris12:"#e0dffe"};var C0={cyan1:"#0b161a",cyan2:"#101b20",cyan3:"#082c36",cyan4:"#003848",cyan5:"#004558",cyan6:"#045468",cyan7:"#12677e",cyan8:"#11809c",cyan9:"#00a2c7",cyan10:"#23afd0",cyan11:"#4ccce6",cyan12:"#b6ecf7"};var M0={grass1:"#0e1511",grass2:"#141a15",grass3:"#1b2a1e",grass4:"#1d3a24",grass5:"#25482d",grass6:"#2d5736",grass7:"#366740",grass8:"#3e7949",grass9:"#46a758",grass10:"#53b365",grass11:"#71d083",grass12:"#c2f0c2"};var F0={amber1:"#16120c",amber2:"#1d180f",amber3:"#302008",amber4:"#3f2700",amber5:"#4d3000",amber6:"#5c3d05",amber7:"#714f19",amber8:"#8f6424",amber9:"#ffc53d",amber10:"#ffd60a",amber11:"#ffca16",amber12:"#ffe7b3"};var W={gray1:"#fcfcfc",gray2:"#f9f9f9",gray3:"#f0f0f0",gray4:"#e8e8e8",gray5:"#e0e0e0",gray6:"#d9d9d9",gray7:"#cecece",gray8:"#bbbbbb",gray9:"#8d8d8d",gray10:"#838383",gray11:"#646464",gray12:"#202020"};var N={tomato1:"#fffcfc",tomato2:"#fff8f7",tomato3:"#feebe7",tomato4:"#ffdcd3",tomato5:"#ffcdc2",tomato6:"#fdbdaf",tomato7:"#f5a898",tomato8:"#ec8e7b",tomato9:"#e54d2e",tomato10:"#dd4425",tomato11:"#d13415",tomato12:"#5c271f"};var N0={plum1:"#fefcff",plum2:"#fdf7fd",plum3:"#fbebfb",plum4:"#f7def8",plum5:"#f2d1f3",plum6:"#e9c2ec",plum7:"#deade3",plum8:"#cf91d8",plum9:"#ab4aba",plum10:"#a144af",plum11:"#953ea3",plum12:"#53195d"};var O={iris1:"#fdfdff",iris2:"#f8f8ff",iris3:"#f0f1fe",iris4:"#e6e7ff",iris5:"#dadcff",iris6:"#cbcdff",iris7:"#b8baf8",iris8:"#9b9ef0",iris9:"#5b5bd6",iris10:"#5151cd",iris11:"#5753c6",iris12:"#272962"};var B0={cyan1:"#fafdfe",cyan2:"#f2fafb",cyan3:"#def7f9",cyan4:"#caf1f6",cyan5:"#b5e9f0",cyan6:"#9ddde7",cyan7:"#7dcedc",cyan8:"#3db9cf",cyan9:"#00a2c7",cyan10:"#0797b9",cyan11:"#107d98",cyan12:"#0d3c48"};var G={grass1:"#fbfefb",grass2:"#f5fbf5",grass3:"#e9f6e9",grass4:"#daf1db",grass5:"#c9e8ca",grass6:"#b2ddb5",grass7:"#94ce9a",grass8:"#65ba74",grass9:"#46a758",grass10:"#3e9b4f",grass11:"#2a7e3b",grass12:"#203c25"};var U={amber1:"#fefdfb",amber2:"#fefbe9",amber3:"#fff7c2",amber4:"#ffee9c",amber5:"#fbe577",amber6:"#f3d673",amber7:"#e9c162",amber8:"#e2a336",amber9:"#ffc53d",amber10:"#ffba18",amber11:"#ab6400",amber12:"#4f3422"};var o0=(e,o)=>{let l=e[o];if(l===void 0)throw new Error(`Missing color token: ${o}`);return l},T=(e,o)=>({fill:o0(e,`${o}4`),solid:o0(e,`${o}9`),solidHover:o0(e,`${o}10`),textLow:o0(e,`${o}11`),textHigh:o0(e,`${o}12`)}),yl={light:{tomato:T(N,"tomato"),amber:T(U,"amber"),grass:T(G,"grass"),cyan:T(B0,"cyan"),iris:T(O,"iris"),plum:T(N0,"plum"),gray:T(W,"gray")},dark:{tomato:T(y0,"tomato"),amber:T(F0,"amber"),grass:T(M0,"grass"),cyan:T(C0,"cyan"),iris:T(F,"iris"),plum:T(D0,"plum"),gray:T(P0,"gray")}},fl={light:{tomato:N.tomato2,amber:U.amber2,grass:G.grass2,cyan:B0.cyan2,iris:O.iris2,plum:N0.plum2,gray:W.gray2},dark:{tomato:y0.tomato2,amber:F0.amber2,grass:M0.grass2,cyan:C0.cyan2,iris:F.iris2,plum:D0.plum2,gray:P0.gray2}},z0={light:{canvas:"#f5f5f5",bg:"#ffffff",bgSolid:"#ffffff",border:"rgba(0, 0, 0, 0.08)",text:"#1a1a1a",textMuted:"#6b6b6b",hoverOverlay:"rgba(0, 0, 0, 0.05)"},dark:{canvas:"#f5f5f5",bg:"#252525",bgSolid:"#252525",border:"rgba(255, 255, 255, 0.08)",text:"#e8e8e8",textMuted:"#9a9a9a",hoverOverlay:"rgba(255, 255, 255, 0.06)"}},Al={light:{accent:O.iris9,accentHover:O.iris10,selectedBg:O.iris4,selectedFg:O.iris11,danger:N.tomato9},dark:{accent:F.iris9,accentHover:F.iris10,selectedBg:F.iris4,selectedFg:F.iris11,danger:y0.tomato9}},Oo=W.gray6,So=W.gray9,ml={rectangle:{fill:O.iris3,stroke:O.iris9,strokeWidth:2},ellipse:{fill:N.tomato3,stroke:N.tomato9,strokeWidth:2},flowchart:{fill:G.grass3,stroke:G.grass9,strokeWidth:2},sticky:{fill:U.amber3,stroke:U.amber9,strokeWidth:1}},ul={stroke:W.gray12,strokeWidth:1.5},bl={added:G.grass9,removed:N.tomato9,modified:U.amber9};var Po=z0.light.textMuted,Do="#bbb";var H0=.06,Co=1.4,Mo=.4,W0=.5,Fo=10,No=64,Bo="#fff9b1",G0=4,f0=10,zo="#8a8a6f",Ho="rgba(0, 0, 0, 0.18)",U0=4,j0=9,K0=5,j=14,Wo=4,Go="rgba(0, 0, 0, 0.08)",Uo="#555",X0=10,e0=16,Y0=6,A0=4,V0="rgba(255, 255, 255, 0.85)",jo="#333",Ko="#5b5bd6",q0=80;var Z0=.92,$0=.5;var Xo=.4,Yo=.5,J0=.1,Q0=.9,Vo="#888",qo="#ffffff",Zo="#222",$o="#ddd";var oo=1.2,gl=(e,o,l,r,t,s,i)=>{let a={indentX:i,para:s},n=()=>t.length===0||g(t[t.length-1]).para!==s;if(e===""){t.push({text:"",start:o,end:o,width:0,...a,paraFirst:n()});return}let f=[],d=/\S+/g,p;for(;(p=d.exec(e))!==null;)f.push({s:p.index,e:p.index+p[0].length});if(f.length===0){t.push({text:e,start:o,end:o+e.length,width:r(e),...a,paraFirst:n()});return}let c=0,y=(m,u)=>{let x=e.slice(m,u);t.push({text:x,start:o+m,end:o+u,width:r(x),...a,paraFirst:n()})},A=0;for(;A<f.length;){let m=g(f[A]);if(r(e.slice(c,m.e))<=l){A++;continue}if(m.s>c){y(c,m.s),c=m.s;continue}let u=m.s+1;for(;u<m.e&&r(e.slice(c,u+1))<=l;)u++;if(u>=m.e){A++;continue}y(c,u),c=u,m.s=u}y(c,e.length)},l0=(e,o,l)=>{let r=l.fontSize*(l.lineHeightFactor??oo),t=[],s=0,i=0;for(let f=0;f<=e.length;f++)if(f===e.length||e[f]===`
4
- `){let d=e.slice(s,f),p=l.paragraphs?.[i],y=((p?.indent??0)+(p?.list!==void 0?1:0))*Co*l.fontSize;if(l.maxWidth===void 0)t.push({text:d,start:s,end:f,width:o(d),indentX:y,para:i,paraFirst:!0});else{let A=Math.max(l.fontSize,l.maxWidth-y);gl(d,s,A,o,t,i,y)}s=f+1,i++}t.length===0&&t.push({text:"",start:0,end:0,width:0,indentX:0,para:0,paraFirst:!0});let a=0;for(let f of t)a=Math.max(a,f.width+f.indentX);let n=l.maxWidth??a;return{lines:t,lineHeight:r,blockWidth:n}},hl=(e,o,l)=>l==="center"?o/2-e/2:l==="right"?o-e:0,eo=(e,o,l)=>hl(e.width,o-e.indentX,l)+e.indentX;var xl=new Map;var _l=()=>typeof performance<"u"?performance.now():0;var lo=(e,o=_l(e))=>{if(!e.animationKind)return e.src;let l=xl.get(e.animationKind);if(!l)return e.src;try{return l.getFrameAt(e.animationData,o)}catch{return e.src}};var kl=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],K=e=>{if(typeof e!="object"||e===null)return!1;let o=globalThis;for(let l of kl){let r=o[l];if(typeof r=="function"&&e instanceof r)return!0}return!1};var r0=(e,o)=>{let l=e.fill!==void 0&&e.fill!=="transparent",r=e.stroke!==void 0&&e.stroke!=="transparent"&&(e.strokeWidth??1)>0;return l&&o.setFill(e.fill),r&&(o.setStroke(e.stroke),o.setStrokeWidth(e.strokeWidth??1),e.lineCap&&o.setLineCap(e.lineCap),e.lineJoin&&o.setLineJoin(e.lineJoin),e.dashArray&&o.setDashArray(e.dashArray)),e.opacity!==void 0&&o.setOpacity(e.opacity),{fill:l,stroke:r}},wl=(e,o)=>{let{fill:l,stroke:r}=r0(e.style,o);if(!l&&!r)return;let t=_0(e.style.roundness,e.width,e.height);if(l&&(o.beginPath(),t>0?M(o,0,0,e.width,e.height,t):o.rect(0,0,e.width,e.height),o.fill()),r){let s=g0(e.style),i=s,a=s,n=e.width-2*s,f=e.height-2*s;if(n<=0||f<=0)return;let d=t>0?Math.max(0,t-s):0;o.beginPath(),d>0?M(o,i,a,n,f,d):o.rect(i,a,n,f),o.stroke()}},g0=e=>{let o=e.strokeAlign??"center";if(o==="center")return 0;let l=(e.strokeWidth??1)/2;return o==="inside"?l:-l},M=(e,o,l,r,t,s)=>{e.moveTo(o+s,l),e.lineTo(o+r-s,l),e.quadraticCurveTo(o+r,l,o+r,l+s),e.lineTo(o+r,l+t-s),e.quadraticCurveTo(o+r,l+t,o+r-s,l+t),e.lineTo(o+s,l+t),e.quadraticCurveTo(o,l+t,o,l+t-s),e.lineTo(o,l+s),e.quadraticCurveTo(o,l,o+s,l),e.closePath()},Tl=(e,o)=>{let{fill:l,stroke:r}=r0(e.style,o);if(!l&&!r)return;let t=e.width/2,s=e.height/2;if(l&&(o.beginPath(),o.ellipse(t,s,t,s),o.fill()),r){let i=g0(e.style),a=t-i,n=s-i;if(a<=0||n<=0)return;o.beginPath(),o.ellipse(t,s,a,n),o.stroke()}},vl=(e,o)=>{if(e.points.length<2)return;let{fill:l,stroke:r}=r0(e.style,o);if(!(!l&&!r)&&(l&&(o.beginPath(),b0(o,e.points),o.fill()),r)){let t=g0(e.style),s=t!==0?Q.offsetClosedPath(e.points,t):e.points;o.beginPath(),b0(o,s),o.stroke()}},b0=(e,o)=>{let l=o[0];if(l!==void 0){e.moveTo(l.x,l.y);for(let r=1;r<o.length;r++){let t=o[r];t!==void 0&&e.lineTo(t.x,t.y)}e.closePath()}},Rl=(e,o)=>{if(e.commands.length===0)return;let{fill:l,stroke:r}=r0(e.style,o);if(!(!l&&!r)){o.beginPath();for(let t of e.commands)switch(t.kind){case"M":o.moveTo(t.to.x,t.to.y);break;case"L":o.lineTo(t.to.x,t.to.y);break;case"Q":o.quadraticCurveTo(t.control.x,t.control.y,t.to.x,t.to.y);break;case"C":o.bezierCurveTo(t.control1.x,t.control1.y,t.control2.x,t.control2.y,t.to.x,t.to.y);break;case"Z":o.closePath();break}l&&o.fill(),r&&o.stroke()}},Jo=e=>q0/Math.max(1,Math.min(e.width,e.height)),Qo=(e,o)=>Math.min(e.width,e.height)*o>=q0,oe=(e,o)=>1/Math.max(o>0?o:1,Jo(e)),ee=(e,o,l=1)=>{let r=oe(e,l),t=A0*r,s=e0*r,i=G0+2,a=[],n=i,f=e.height+t;for(let d of e.reactions??[]){let c=d.users?.length??d.count??0,y=`${d.glyph} ${String(c)}`,A=(o(y)+2*Y0)*r;n>i&&n+A>e.width&&(n=i,f+=s+t),a.push({glyph:d.glyph,label:y,x:n,y:f,width:A,height:s}),n+=A+t}return n>i&&n+s>e.width&&(n=i,f+=s+t),{pills:a,add:{x:n,y:f,width:s,height:s}}};var Ll=(e,o,l)=>{let r=e.style.fill??Bo;e.style.opacity!==void 0&&o.setOpacity(e.style.opacity);let t=e.width,s=e.height,i=G0;if(o.setFill(Ho),o.beginPath(),M(o,1,U0,t-2,s-2,i),o.fill(),o.setFill(r),o.beginPath(),M(o,0,0,t,s,i),o.fill(),l?.content?.stickyTags!==!1&&e.tags!==void 0&&e.tags.length>0){o.setFont("system-ui, sans-serif",j0,{}),o.setTextAlign("left"),o.setTextBaseline("top");let c=i+2,y=s-j-3;for(let A of e.tags){let m=o.measureText(A).width+2*K0;if(c+m>t-i)break;o.setFill(Go),o.beginPath(),M(o,c,y,m,j,j/2),o.fill(),o.setFill(Uo),o.fillText(A,c+K0,y+(j-j0)/2),c+=m+Wo}}if(l?.content?.stickyAuthor!==!1&&e.showAuthor===!0&&e.authorName!==void 0&&e.authorName!==""){o.setFont("system-ui, sans-serif",f0,{}),o.setTextAlign("left"),o.setTextBaseline("top"),o.setFill(zo);let c=e.tags!==void 0&&e.tags.length>0?s-j-f0-8:s-f0-4;o.fillText(e.authorName,i+2,c)}let a=l?.zoom??1,n=oe(e,a),f=Qo(e,a),d=f&&l?.content?.stickyReactions!==!1,p=f&&l?.content?.stickyAddButton!==!1&&l?.hoveredElement===e.id;if(d||p){o.setFont("system-ui, sans-serif",X0,{}),o.setTextAlign("left"),o.setTextBaseline("top");let c=ee(e,y=>o.measureText(y).width,a);if(d)for(let y of c.pills)o.setFill(V0),o.beginPath(),M(o,y.x,y.y,y.width,y.height,y.height/2),o.fill(),o.setFill(jo),o.save(),o.translate(y.x,y.y),o.scale(n,n),o.fillText(y.label,Y0,(e0-X0)/2),o.restore();if(p){let y=c.add;o.setFill(V0),o.beginPath(),M(o,y.x,y.y,y.width,y.height,y.height/2),o.fill();let A=y.x+y.width/2,m=y.y+y.height/2,u=y.height*.22,x=1.4*n;o.setFill(Ko),o.beginPath(),o.rect(A-u,m-x/2,u*2,x),o.fill(),o.beginPath(),o.rect(A-x/2,m-u,x,u*2),o.fill()}}},Il=(e,o)=>{e.style.opacity!==void 0&&o.setOpacity(e.style.opacity),o.setFont("system-ui, sans-serif",e.size,{}),o.setTextAlign("left"),o.setTextBaseline("top"),o.setFill(e.style.fill??"#000"),o.fillText(e.glyph,0,0)},m0=new Map,Ol=(e,o,l,r,t,s)=>{let i=Math.round(r("Mg \u0432\u043E\u0434\u043E\u0451\u043C")/t*1e3),a=`${e}|${String(Math.round(o))}x${String(Math.round(l))}|${String(i)}`,n=m0.get(a);if(n!==void 0)return n;let f=c=>{let y=W0*c,A=o-2*y;if(A<c)return!1;let u=l0(e,x=>r(x)*c/t,{fontSize:c,maxWidth:A,...s!==void 0?{paragraphs:s}:{}});return u.lines.length*u.lineHeight<=l-2*y},d=Fo,p=No;for(;p-d>1;){let c=Math.floor((d+p)/2);f(c)?d=c:p=c}return m0.size>512&&m0.clear(),m0.set(a,d),d},le=(e,o)=>{let l=e.label;if(l===void 0)return null;let r=c0(e),t=l.autoFit===!0&&l.text!==""?Ol(l.text,r.width,r.height,o,l.fontSize,l.paragraphs):l.fontSize,s=W0*t,i=Math.max(t,r.width-2*s),a=t===l.fontSize?o:V=>o(V)*t/l.fontSize,n=l.style?.textBaseline??"middle",f={textAlign:"center",...l.style,textBaseline:"top"},d=l0(l.text,a,{fontSize:t,maxWidth:i,...l.paragraphs!==void 0?{paragraphs:l.paragraphs}:{}}),p=Math.max(0,r.height-2*s),c=Math.max(0,Math.floor(p/d.lineHeight)),y=e.metadata?.labelScrollLines,A=Math.max(0,d.lines.length-c),m=Math.max(0,Math.min(A,typeof y=="number"?Math.floor(y):0)),u={id:e.id,layerId:e.layerId,type:"text",position:{x:0,y:0},rotation:0,scale:{x:1,y:1},order:e.order,style:f,text:l.text,fontFamily:l.fontFamily,fontSize:t,maxWidth:i,clipStart:m,clipLines:c,...l.runs!==void 0?{runs:l.runs}:{},...l.paragraphs!==void 0?{paragraphs:l.paragraphs}:{}},x=Math.min(d.lines.length-m,c)*d.lineHeight,L=(n==="top"?r.y+s:n==="bottom"?r.y+r.height-x-s:r.y+Math.max(s,(r.height-x)/2))-m*d.lineHeight;return{synthetic:u,offsetX:r.x+s,offsetY:L,windowTop:m*d.lineHeight,windowBottom:(m+c)*d.lineHeight}},io=(e,o,l)=>{let r=e.label;if(r===void 0||r.text===""||l&&!r.autoFit&&Z(r.fontSize,l.zoom,l.lod))return;let t=r.style?.fontWeight,s=r.style?.fontStyle;o.setFont(r.fontFamily,r.fontSize,{...t?{weight:t}:{},...s?{style:s}:{}});let i=le(e,a=>o.measureText(a).width);i&&(l&&Z(i.synthetic.fontSize,l.zoom,l.lod)||(o.save(),o.translate(i.offsetX,i.offsetY),ao(i.synthetic,o),o.restore()))},so=e=>{let o=e;if(o.clipLines===void 0)return;let l=o.clipStart??0;return{start:l,end:l+o.clipLines}},re=(e,o,l,r)=>{if(e.paragraphs===void 0)return;let t=e.style.textAlign??"left",s=w0(e.paragraphs,E0(e.text)),i=Mo*e.fontSize;l.setFill(r);let a=so(e);o.lines.forEach((n,f)=>{if(a!==void 0&&(f<a.start||f>=a.end)||!n.paraFirst)return;let d=s[n.para];if(d==null)return;let p=l.measureText(d).width,c=eo(n,o.blockWidth,t);l.fillText(d,c-i-p,f*o.lineHeight)})},Sl=(e,o)=>{let l=e.style.textAlign??"left",r=e.fontSize;o.setTextAlign("left"),o.setTextBaseline(e.style.textBaseline??"top");let t=d=>{let p=d?.fontWeight??e.style.fontWeight,c=d?.fontStyle??e.style.fontStyle;o.setFont(e.fontFamily,r,{...p?{weight:p}:{},...c?{style:c}:{}})};t(void 0);let s=l0(e.text,d=>o.measureText(d).width,{fontSize:r,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{},...e.paragraphs!==void 0?{paragraphs:e.paragraphs}:{}}),i=s.lines.map(d=>{let p=k0(e,d.start,d.end).map(y=>(t(y.style),{text:y.text,style:y.style,width:o.measureText(y.text).width})),c=p.reduce((y,A)=>y+A.width,0);return{segs:p,total:c}}),a=e.maxWidth??i.reduce((d,p,c)=>Math.max(d,p.total+g(s.lines[c]).indentX),0),n=Math.max(1,r*H0),f=so(e);i.forEach((d,p)=>{if(f!==void 0&&(p<f.start||p>=f.end))return;let c=p*s.lineHeight,y=g(s.lines[p]).indentX,A=y+(l==="center"?(a-y)/2-d.total/2:l==="right"?a-y-d.total:0);for(let m of d.segs){let u=m.style?.fill??e.style.fill??"#000",x=m.style?.opacity??e.style.opacity;t(m.style),x!==void 0&&o.setOpacity(x);let S=m.style?.highlight??e.style.highlight;m.width>0&&S!==void 0&&S!=="transparent"&&(o.setFill(S),o.beginPath(),o.rect(A,c,m.width,s.lineHeight),o.fill()),o.setFill(u),o.fillText(m.text,A,c);let L=m.style?.textDecoration??e.style.textDecoration;m.width>0&&(L?.underline||L?.strikethrough)&&(L.underline&&(o.beginPath(),o.rect(A,c+r*Z0,m.width,n),o.fill()),L.strikethrough&&(o.beginPath(),o.rect(A,c+r*$0-n/2,m.width,n),o.fill())),A+=m.width}}),t(void 0),re(e,s,o,e.style.fill??"#000")},ao=(e,o,l)=>{if(e.text===""&&l?.textPlaceholders===!0){let{runs:p,...c}=e;ao({...c,text:$(e.id),style:{...e.style,fill:Po}},o);return}if(e.runs!==void 0&&e.runs.length>0){Sl(e,o);return}let r=e.style.textAlign??"left",t=e.style.fontWeight,s=e.style.fontStyle;o.setFont(e.fontFamily,e.fontSize,{...t?{weight:t}:{},...s?{style:s}:{}}),o.setTextAlign("left"),o.setTextBaseline(e.style.textBaseline??"top");let i=e.style.fill??"#000";o.setFill(i),e.style.opacity!==void 0&&o.setOpacity(e.style.opacity);let a=e.fontSize,n;if(e.maxWidth===void 0&&!e.text.includes(`
5
- `)&&e.paragraphs===void 0)n=[{text:e.text,x:0,width:o.measureText(e.text).width,top:0}];else{let p=A=>o.measureText(A).width,c=l0(e.text,p,{fontSize:a,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{},...e.paragraphs!==void 0?{paragraphs:e.paragraphs}:{}});n=c.lines.map((A,m)=>({text:A.text,x:eo(A,c.blockWidth,r),width:A.width,top:m*c.lineHeight}));let y=so(e);y!==void 0&&(n=n.filter((A,m)=>m>=y.start&&m<y.end)),re(e,c,o,i)}let f=e.style.highlight;if(f!==void 0&&f!=="transparent"){let p=a*oo;o.setFill(f);for(let c of n)c.width<=0||(o.beginPath(),o.rect(c.x,c.top,c.width,p),o.fill());o.setFill(i)}for(let p of n)o.fillText(p.text,p.x,p.top);let d=e.style.textDecoration;if(d?.underline||d?.strikethrough){let p=Math.max(1,a*H0);for(let c of n)c.width<=0||(d.underline&&(o.beginPath(),o.rect(c.x,c.top+a*Z0,c.width,p),o.fill()),d.strikethrough&&(o.beginPath(),o.rect(c.x,c.top+a*$0-p/2,c.width,p),o.fill()))}},Pl=(e,o)=>{let l=e.points;if(l.length===0)return;if(e.style.opacity!==void 0&&o.setOpacity(e.style.opacity),e.closed===!0&&e.style.fill!==void 0&&l.length>=3){o.setFill(e.style.fill),o.setStroke(null),o.beginPath();let s=g(l[0]);o.moveTo(s.x,s.y);for(let i=1;i<l.length;i++){let a=g(l[i]);o.lineTo(a.x,a.y)}o.closePath(),o.fill()}let r=v0(e.style);if(o.setFill(r),o.setStroke(null),l.length===1){let s=g(l[0]);o.beginPath(),o.ellipse(s.x,s.y,s.width,s.width),o.fill();return}let t=O0(l);if(t.length>=3){o.beginPath();let s=g(t[0]);o.moveTo(s.x,s.y);for(let i=1;i<t.length;i++){let a=g(t[i]);o.lineTo(a.x,a.y)}o.closePath(),o.fill()}},Dl=(e,o,l)=>{let r=l?.clock?.(e),t=e.animationKind?lo(e,r):e.metadata?.image??lo(e,r);if(!K(t)&&(t==null||e.fileId))return;let s=e.metadata?.animated===!0||e.animationKind!==void 0,i=e.mask;i&&(o.save(),o.beginPath(),te(o,i,e.width,e.height),o.clip()),o.drawImage(t,0,0,e.width,e.height,s,e.crop,e.alt),i&&o.restore()},te=(e,o,l,r)=>{switch(o.kind){case"ellipse":e.ellipse(l/2,r/2,l/2,r/2);return;case"round-rect":{let t=Math.max(0,Math.min(.5,o.radius))*Math.min(l,r);M(e,0,0,l,r,t);return}case"polygon":{let t=o.points;if(t.length<3)return;let s=g(t[0]);e.moveTo(s.x*l,s.y*r);for(let i=1;i<t.length;i++){let a=g(t[i]);e.lineTo(a.x*l,a.y*r)}e.closePath();return}}},no=()=>{v("rectangle",wl),v("ellipse",Tl),v("polygon",vl),v("path",Rl),v("text",ao),v("image",Dl),v("group",()=>{}),v("frame",Nl),d0("frame",()=>({top:24})),v("block-arrow",Cl),v("brush",Pl),v("sticky",Ll),d0("sticky",e=>{let o=e,l=(o.reactions?.length??0)+1,r=1/Jo(o);return{bottom:U0+(A0+e0)*r*l+2,right:(A0+e0)*r+2}}),v("emoji",Il)},Cl=(e,o)=>{let{fill:l,stroke:r}=r0(e.style,o),t=e.direction??"right",s=Math.max(J0,Math.min(Q0,e.headRatio??Xo)),i=Math.max(J0,Math.min(Q0,e.bodyThickness??Yo)),a=e.width,n=e.height,f=a*s,d=a-f,p=n*i/2,c=n/2,y=[[0,c-p],[d,c-p],[d,0],[a,c],[d,n],[d,c+p],[0,c+p]];t!=="right"&&(y=y.map(([m,u])=>Ml([m,u],t,a,n)));let A=y.map(([m,u])=>({x:m,y:u}));if(l&&(o.beginPath(),b0(o,A),o.fill()),r){let m=g0(e.style),u=m!==0?Q.offsetClosedPath(A,m):A;o.beginPath(),b0(o,u),o.stroke()}},Ml=([e,o],l,r,t)=>{switch(l){case"left":return[r-e,o];case"up":return[o*(r/t),t-e*(t/r)];case"down":return[(t-o)*(r/t),e*(t/r)]}},to="\u2026",Fl=(e,o,l)=>{if(o<=0)return"";if(l.measureText(e).width<=o)return e;let r=0,t=e.length;for(;r<t;){let s=Math.ceil((r+t)/2);l.measureText(e.slice(0,s)+to).width<=o?r=s:t=s-1}return r>0?e.slice(0,r)+to:to},Nl=(e,o,l)=>{o.setFill(e.style.fill??qo),o.setStroke(null),o.setDashArray(null),o.beginPath(),o.rect(0,0,e.width,e.height),o.fill();let r=(l?.zoom??1)*(e.scale.x||1);o.setFill(null),o.setStroke(Vo),o.setStrokeWidth(1/(r||1)),o.setDashArray(null),o.beginPath(),o.rect(0,0,e.width,e.height),o.stroke();let t=e.name??"Frame";o.setFont("system-ui, sans-serif",12);let s=e.width-16,i=o.measureText(t).width<=s,a=i?t:Fl(t,s,o),n=i?Math.min(o.measureText(t).width+16,e.width):e.width;o.setFill(Zo),o.beginPath(),o.rect(0,-24,n,24),o.fill(),o.setFill($o),o.setTextBaseline("middle"),o.setTextAlign("left"),o.fillText(a,8,-24/2)};var ie=(e,o)=>{let l=new Map,r=s=>{e.setOpacity(s*o)},t={get(s,i){if(i==="setOpacity")return r;if(l.has(i))return l.get(i);let a=Reflect.get(s,i),n=typeof a=="function"?a.bind(s):a;return l.set(i,n),n}};return new Proxy(e,t)};var t0=class{entries=new Map;get(o){let l=this.entries.get(o.id);if(l){if(l.ref!==o){this.entries.delete(o.id);return}return l.value}}set(o,l){return this.entries.set(o.id,{ref:o,value:l}),l}getOrCompute(o,l){let r=this.get(o);return r!==void 0?r:this.set(o,l(o))}invalidate(o){this.entries.delete(o)}clear(){this.entries.clear()}prune(o){for(let l of this.entries.keys())o.elements.has(l)||this.entries.delete(l)}get size(){return this.entries.size}},zi=new t0,X=(e,o)=>e.getOrCompute(o,R0);var B=class{cap;onEvict;map=new Map;constructor(o,l){this.cap=o,this.onEvict=l}get(o){let l=this.map.get(o);if(l!==void 0)return this.map.delete(o),this.map.set(o,l),l}has(o){return this.map.has(o)}set(o,l){for(this.map.delete(o),this.map.set(o,l);this.map.size>this.cap;){let r=this.map.keys().next().value,t=this.map.get(r);this.map.delete(r),t!==void 0&&this.onEvict?.(r,t)}}delete(o){return this.map.delete(o)}clear(){this.map.clear()}get size(){return this.map.size}keys(){return this.map.keys()}values(){return this.map.values()}};var se=e=>e<=0?1:2**Math.round(Math.log2(e));var co=(e,o,l={})=>{let r=S0(e.viewport),t=l.dirtyWorld;if(!l.skipClear)if(t){let E=[I.applyToPoint(r,{x:t.x,y:t.y}),I.applyToPoint(r,{x:t.x+t.width,y:t.y+t.height})],b=R.expand(R.fromPoints(E),2);o.clear(b)}else o.clear();o.save(),o.setTransform(r);let s=l.boundsCache??new t0,i=l.viewport,a=null;i&&l.spatialIndex&&(a=l.spatialIndex.query(i));let n=e.viewport.zoom,f=l.clock,d={zoom:n,...f?{clock:f}:{},...l.content?{content:l.content}:{},...l.hoveredElement!==void 0?{hoveredElement:l.hoveredElement}:{},...l.textPlaceholders===!0?{textPlaceholders:!0}:{}},p=l.lod,c=p?.placeholderMaxScreenPx,y=l.placeholderFill??Do,A=l.layerCompositeCache,m=l.dirtyLayerIds,u=l.compositeLayerBitmap,x=se(n),S=E=>{let b=null;for(let k of p0(e,E)){let q=X(s,k);b=b?R.union(b,q):q}return b},L=l.dimOpacity,V=l.dimElements!==void 0&&L!==void 0?ie(o,L):null;for(let E of I0(e))if(E.visible){if(A&&u){m?.has(E.id)&&A.invalidateLayer(E.id);let b=A.get(E.id,x);if(b===void 0){let k=u(E.id,x,e);k!==null&&(A.set(E.id,x,k),b=k)}if(b!==void 0){let k=S(E.id);k&&o.drawImage(b,k.x,k.y,k.width,k.height);continue}}for(let b of p0(e,E.id)){if(l.hideElements?.has(b.id)||a&&!a.has(b.id))continue;if(i){let P=X(s,b);if(!R.intersects(P,i))continue}if(t){let P=X(s,b);if(!R.intersects(P,t))continue}if(n0(b)&&Z(b.fontSize,n,p))continue;if(c!==void 0&&po(X(s,b),n)<c){let P=X(s,b);o.setFill(y),o.setStrokeWidth(0),o.beginPath(),o.rect(P.x,P.y,P.width,P.height),o.fill();continue}let k=fo(b.type);if(!k){l.onUnknownElement?.(b);continue}o.save();let q=V!==null&&l.dimElements?.has(b.id)===!0,H=q?V:o;q&&H.setOpacity(1),H.translate(b.position.x,b.position.y),b.rotation!==0&&H.rotate(b.rotation),(b.scale.x!==1||b.scale.y!==1)&&H.scale(b.scale.x,b.scale.y),k(b,H,d),b.label!==void 0&&!n0(b)&&io(b,H,p?.minTextScreenPx!==void 0?{zoom:n,lod:p}:void 0),o.restore()}}o.restore()};var Y="Roboto",i0="PT Serif",s0="Roboto Mono",ae=e=>{let o=e.toLowerCase();return o.includes("mono")?s0:o.includes("sans")?Y:o.includes("serif")||o.includes("slab")||o.includes("georgia")||o.includes("times")?i0:Y},Bl=[{family:Y,weight:"400",style:"normal",url:new URL("../fonts/Roboto-Regular.woff2",import.meta.url)},{family:Y,weight:"700",style:"normal",url:new URL("../fonts/Roboto-Bold.woff2",import.meta.url)},{family:Y,weight:"400",style:"italic",url:new URL("../fonts/Roboto-Italic.woff2",import.meta.url)},{family:Y,weight:"700",style:"italic",url:new URL("../fonts/Roboto-BoldItalic.woff2",import.meta.url)},{family:i0,weight:"400",style:"normal",url:new URL("../fonts/PTSerif-Regular.woff2",import.meta.url)},{family:i0,weight:"700",style:"normal",url:new URL("../fonts/PTSerif-Bold.woff2",import.meta.url)},{family:i0,weight:"400",style:"italic",url:new URL("../fonts/PTSerif-Italic.woff2",import.meta.url)},{family:i0,weight:"700",style:"italic",url:new URL("../fonts/PTSerif-BoldItalic.woff2",import.meta.url)},{family:s0,weight:"400",style:"normal",url:new URL("../fonts/RobotoMono-Regular.woff2",import.meta.url)},{family:s0,weight:"700",style:"normal",url:new URL("../fonts/RobotoMono-Bold.woff2",import.meta.url)},{family:s0,weight:"400",style:"italic",url:new URL("../fonts/RobotoMono-Italic.woff2",import.meta.url)},{family:s0,weight:"700",style:"italic",url:new URL("../fonts/RobotoMono-BoldItalic.woff2",import.meta.url)}],ne=async(e=globalThis)=>{let o=e.fonts;!o||typeof FontFace>"u"||await Promise.allSettled(Bl.map(async l=>{let r=new FontFace(l.family,`url(${l.url.href})`,{weight:l.weight,style:l.style});await r.load(),o.add(r)}))};var pe=e=>{let o=e;return typeof o.naturalWidth=="number"&&o.naturalWidth>0?{width:o.naturalWidth,height:o.naturalHeight??o.naturalWidth}:typeof o.videoWidth=="number"&&o.videoWidth>0?{width:o.videoWidth,height:o.videoHeight??o.videoWidth}:typeof o.width=="number"&&o.width>0&&typeof o.height=="number"?{width:o.width,height:o.height}:null},ce=new Set,de=e=>{if(typeof console>"u")return;let o=typeof e=="string"?e.startsWith("blob:")?"dead-blob-url":"string-src":e==null?"empty":"stale-object";ce.has(o)||(ce.add(o),console.warn(`[renderer] skipped a non-drawable image source (kind: ${o}). The shape's image handle isn't a live HTMLImageElement / canvas / bitmap and it has no Scene.files bytes to rehydrate from (shapes with a fileId are skipped silently while rehydration is in flight) \u2014 the image will stay blank.`))};var h0=class{ctx;_width;_height;dpr;constructor(o,l,r,t=1){this.ctx=o,this._width=l,this._height=r,this.dpr=t}get size(){return{width:this._width,height:this._height}}resize(o,l,r){this._width=o,this._height=l,r!==void 0&&(this.dpr=r)}setFill(o){this.ctx.fillStyle=o??"transparent"}setStroke(o){this.ctx.strokeStyle=o??"transparent"}setStrokeWidth(o){this.ctx.lineWidth=o}setOpacity(o){this.ctx.globalAlpha=o}setLineCap(o){this.ctx.lineCap=o}setLineJoin(o){this.ctx.lineJoin=o}setDashArray(o){this.ctx.setLineDash(o?[...o]:[])}setFont(o,l,r){let t=r?.style==="italic"?"italic ":"",s=r?.weight==="bold"?"bold ":"";this.ctx.font=`${t}${s}${l}px "${ae(o)}", ${o}`}setTextAlign(o){this.ctx.textAlign=o==="center"?"center":o}setTextBaseline(o){this.ctx.textBaseline=o==="middle"?"middle":o==="top"?"top":"bottom"}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(o,l){this.ctx.translate(o,l)}rotate(o){this.ctx.rotate(o)}scale(o,l){this.ctx.scale(o,l)}setTransform(o){let l=this.dpr;this.ctx.setTransform(l*o.a,l*o.b,l*o.c,l*o.d,l*o.e,l*o.f)}resetTransform(){this.ctx.setTransform(this.dpr,0,0,this.dpr,0,0)}beginPath(){this.ctx.beginPath()}closePath(){this.ctx.closePath()}moveTo(o,l){this.ctx.moveTo(o,l)}lineTo(o,l){this.ctx.lineTo(o,l)}quadraticCurveTo(o,l,r,t){this.ctx.quadraticCurveTo(o,l,r,t)}bezierCurveTo(o,l,r,t,s,i){this.ctx.bezierCurveTo(o,l,r,t,s,i)}rect(o,l,r,t){this.ctx.rect(o,l,r,t)}ellipse(o,l,r,t){this.ctx.ellipse(o,l,r,t,0,0,Math.PI*2)}fill(o){this.ctx.fill(o)}stroke(){this.ctx.stroke()}clip(o){this.ctx.clip(o)}fillText(o,l,r,t){t!==void 0?this.ctx.fillText(o,l,r,t):this.ctx.fillText(o,l,r)}measureText(o){return{width:this.ctx.measureText(o).width}}drawImage(o,l,r,t,s,i,a){if(!K(o)){de(o);return}if(a&&(a.x!==0||a.y!==0||a.width!==1||a.height!==1)){let n=pe(o);if(n){this.ctx.drawImage(o,a.x*n.width,a.y*n.height,a.width*n.width,a.height*n.height,l,r,t,s);return}}this.ctx.drawImage(o,l,r,t,s)}clear(o){this.dirtyRect=null,o?this.ctx.clearRect(o.x,o.y,o.width,o.height):(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}dirtyRect=null;markDirty(o){if(!this.dirtyRect){this.dirtyRect=o;return}let l=Math.min(this.dirtyRect.x,o.x),r=Math.min(this.dirtyRect.y,o.y),t=Math.max(this.dirtyRect.x+this.dirtyRect.width,o.x+o.width),s=Math.max(this.dirtyRect.y+this.dirtyRect.height,o.y+o.height);this.dirtyRect={x:l,y:r,width:t-l,height:s-r}}getDirtyRect(){return this.dirtyRect}};var Hl=0,Wl=1,Gl=2,Ul=3,jl=4,Kl=5,Xl=6,Yl=7,Vl=8,ql=9,Zl=10,$l=11,Jl=12,Ql=13,or=14,er=15,lr=16,rr=17,tr=18,ir=19,sr=20,ar=21,nr=22,cr=23,pr=24,dr=25,yr=26,fr=27,Ar=28,mr=29,ur=30,br=31,gr=32,ye=-1,hr=-1,xr=["butt","round","square"];var _r=["miter","round","bevel"];var kr=["left","center","right"];var Er=["top","middle","bottom"];var x0={nonzero:1,evenodd:2},fe={normal:1,bold:2},Ae={normal:1,italic:2},wr=0,me=1;var ue=(e,o,l,r=new B(64))=>{let t=new Float64Array(o),s=0,i=()=>{let f=t[s++];if(f===void 0)throw new Error("replayPackedFrame: truncated stream");return f},a=f=>{let d=l[f];if(d===void 0)throw new Error(`replayPackedFrame: bad string index ${String(f)}`);return d},n=(f,d)=>{let p=f[d];if(p===void 0)throw new Error(`replayPackedFrame: bad enum code ${String(d)}`);return p};for(;s<t.length;){let f=i();switch(f){case Hl:{let d=i();e.setFill(d===ye?null:a(d));break}case Wl:{let d=i();e.setStroke(d===ye?null:a(d));break}case Gl:e.setStrokeWidth(i());break;case Ul:e.setOpacity(i());break;case jl:e.setLineCap(n(xr,i()));break;case Kl:e.setLineJoin(n(_r,i()));break;case Xl:{let d=i();if(d===hr)e.setDashArray(null);else{let p=[];for(let c=0;c<d;c++)p.push(i());e.setDashArray(p)}break}case Yl:{let d=a(i()),p=i();if(i()===wr){e.setFont(d,p);break}let c=i(),y=i(),A={};c===fe.normal?A.weight="normal":c===fe.bold&&(A.weight="bold"),y===Ae.normal?A.style="normal":y===Ae.italic&&(A.style="italic"),e.setFont(d,p,A);break}case Vl:e.setTextAlign(n(kr,i()));break;case ql:e.setTextBaseline(n(Er,i()));break;case Zl:e.save();break;case $l:e.restore();break;case Jl:e.translate(i(),i());break;case Ql:e.rotate(i());break;case or:e.scale(i(),i());break;case er:e.setTransform({a:i(),b:i(),c:i(),d:i(),e:i(),f:i()});break;case lr:e.resetTransform();break;case rr:e.beginPath();break;case tr:e.closePath();break;case ir:e.moveTo(i(),i());break;case sr:e.lineTo(i(),i());break;case ar:e.quadraticCurveTo(i(),i(),i(),i());break;case nr:e.bezierCurveTo(i(),i(),i(),i(),i(),i());break;case cr:e.rect(i(),i(),i(),i());break;case pr:e.ellipse(i(),i(),i(),i());break;case dr:{let d=i();d===x0.nonzero?e.fill("nonzero"):d===x0.evenodd?e.fill("evenodd"):e.fill();break}case yr:e.stroke();break;case gr:{let d=i();d===x0.nonzero?e.clip("nonzero"):d===x0.evenodd?e.clip("evenodd"):e.clip();break}case fr:{let d=a(i()),p=i(),c=i();i()===me?e.fillText(d,p,c,i()):e.fillText(d,p,c);break}case Ar:if(i()===me){let d={x:i(),y:i(),width:i(),height:i()};e.clear(d)}else e.clear();break;case mr:e.markDirty?.({x:i(),y:i(),width:i(),height:i()});break;case ur:i(),i();break;case br:{let d=i(),p=i(),c=i(),y=i(),A=i(),m=r.get(d);m&&e.drawImage(m,p,c,y,A);break}default:throw new Error(`replayPackedFrame: unknown opcode ${String(f)}`)}}};var _={canvas:null,target:null,dpr:1,images:new B(64,(e,o)=>{o.close()})},be=!1,Tr=()=>{be||(no(),be=!0)},z=(e,o)=>{o&&o.length>0?self.postMessage(e,o):self.postMessage(e)},vr=(e,o,l,r)=>{ne(self),_.canvas=e,_.dpr=r,e.width=Math.max(1,Math.round(o*r)),e.height=Math.max(1,Math.round(l*r));let t=e.getContext("2d");if(!t)throw new Error("OffscreenCanvas 2D context unavailable");t.setTransform(r,0,0,r,0,0),_.target=new h0(t,o,l,r),z({type:"ready"})},Rr=(e,o)=>{if(!_.canvas||!_.target)return;_.canvas.width=Math.max(1,Math.round(e*_.dpr)),_.canvas.height=Math.max(1,Math.round(o*_.dpr));let l=_.canvas.getContext("2d");l&&(l.setTransform(_.dpr,0,0,_.dpr,0,0),_.target.resize(e,o,_.dpr))},Lr=e=>{if(!_.canvas||!_.target){z({type:"error",message:"Worker not initialised"});return}Tr();let o=_.canvas.getContext("2d");if(o===null){z({type:"error",message:"Worker not initialised"});return}o.save(),o.setTransform(_.dpr,0,0,_.dpr,0,0),o.clearRect(0,0,_.target.size.width,_.target.size.height),co(e,_.target),o.restore();let l=_.canvas.transferToImageBitmap();z({type:"frame-done",bitmap:l},[l])},Ir=e=>{if(!_.target){z({type:"error",message:"Worker not initialised"});return}for(let{id:o,bitmap:l}of e.bitmaps){let r=_.images.get(o);r&&r!==l&&r.close(),_.images.set(o,l)}ue(_.target,e.buffer,e.strings,_.images)};self.addEventListener("message",e=>{let o=e.data;try{switch(o.type){case"init":vr(o.canvas,o.width,o.height,o.dpr);break;case"resize":Rr(o.width,o.height);break;case"snapshot":Lr(o.scene);break;case"replay":Ir(o);break;case"frame":z({type:"error",message:"patch-stream frames not implemented"});break}}catch(l){z({type:"error",message:l instanceof Error?l.message:String(l)})}});
1
+ var ge=Object.defineProperty;var a0=(e,o)=>{for(var l in o)ge(e,l,{get:o[l],enumerable:!0})};var po=(e,o)=>Math.max(e.width,e.height)*o,Z=(e,o,l)=>l?.minTextScreenPx!==void 0&&e*o<l.minTextScreenPx;var yo=new Map,L=(e,o)=>{yo.set(e,o)},fo=e=>yo.get(e);var Ao=[{text:"Type something",weight:40},{text:"Place for text",weight:20},{text:"Start typing\u2026",weight:12},{text:"Your text here",weight:10},{text:"Add a note",weight:8},{text:"What's on your mind?",weight:6},{text:"Words go here",weight:5},{text:"Say it in a few words",weight:4},{text:"Lorem ipsum? No \u2014 your words.",weight:3},{text:"Blank is a state of mind",weight:2},{text:"Insert genius here",weight:2},{text:"The cursor is waiting patiently",weight:1}];var _0=(e,o,l)=>{if(!e||e.type==="sharp")return 0;let r=Math.min(Math.abs(o),Math.abs(l));if(r<=0)return 0;if(e.value!==void 0)return Math.max(0,Math.min(e.value,r/2));let t=32/.25;return r<=t?r*.25:32};var _e=e=>{let o=2166136261;for(let l=0;l<e.length;l++)o^=e.charCodeAt(l),o=Math.imul(o,16777619)>>>0;return o},$=(e,o=Ao)=>{let l=o.reduce((t,s)=>t+Math.max(1,s.weight),0);if(l<=0||o.length===0)return"";let r=_e(e)%l;for(let t of o)if(r-=Math.max(1,t.weight),r<0)return t.text;return o[o.length-1]?.text??""};var mo=e=>{if(!e)return"";let o=Object.entries(e).filter(([,l])=>l!==void 0).sort(([l],[r])=>l<r?-1:l>r?1:0);return JSON.stringify(o)},uo=e=>{let o=[];for(let l of e){if(l.text==="")continue;let r=o[o.length-1];r!==void 0&&mo(r.style)===mo(l.style)?o[o.length-1]={text:r.text+l.text,...r.style!==void 0?{style:r.style}:{}}:o.push(l)}return o},Ee=e=>{let o=e.runs;return o!==void 0&&o.length>0?uo(o):e.text===""?[]:[{text:e.text}]},E0=(e,o,l)=>{let r=Math.min(o,l),t=Math.max(o,l),s=[],i=0;for(let a of Ee(e)){let n=i,f=i+a.text.length;i=f;let d=Math.max(n,r),p=Math.min(f,t);d>=p||s.push({text:a.text.slice(d-n,p-n),...a.style!==void 0?{style:a.style}:{}})}return s};var k0=e=>{let o=1;for(let l of e)l===`
2
+ `&&o++;return o};var bo=(e,o)=>e?.[o]??{};var T0=(e,o)=>{let l=[],r=new Map;for(let t=0;t<o;t++){let s=bo(e,t),i=s.indent??0;if(s.list==="numbered"){let a=(r.get(i)??0)+1;r.set(i,a);for(let n of[...r.keys()])n>i&&r.delete(n);l.push(`${String(a)}.`)}else{if(s.list===void 0)r.clear();else for(let a of[...r.keys()])a>=i&&r.delete(a);l.push(s.list==="bullet"?"\u2022":null)}}return l};var g=e=>{if(e===void 0)throw new Error("required value is undefined");return e};var h={};a0(h,{ZERO:()=>go,add:()=>Te,angle:()=>Me,cross:()=>Se,distance:()=>Oe,distanceSq:()=>_o,div:()=>Re,dot:()=>Ie,equals:()=>ze,length:()=>xo,lengthSq:()=>ho,lerp:()=>De,midpoint:()=>Ce,mul:()=>Le,negate:()=>ve,normalize:()=>Pe,of:()=>ke,perp:()=>Be,rotate:()=>Ne,rotateAround:()=>Fe,sub:()=>we});var go=Object.freeze({x:0,y:0}),ke=(e,o)=>({x:e,y:o}),Te=(e,o)=>({x:e.x+o.x,y:e.y+o.y}),we=(e,o)=>({x:e.x-o.x,y:e.y-o.y}),Le=(e,o)=>({x:e.x*o,y:e.y*o}),Re=(e,o)=>({x:e.x/o,y:e.y/o}),ve=e=>({x:-e.x,y:-e.y}),Ie=(e,o)=>e.x*o.x+e.y*o.y,Se=(e,o)=>e.x*o.y-e.y*o.x,ho=e=>e.x*e.x+e.y*e.y,xo=e=>Math.sqrt(ho(e)),_o=(e,o)=>{let l=o.x-e.x,r=o.y-e.y;return l*l+r*r},Oe=(e,o)=>Math.sqrt(_o(e,o)),Pe=e=>{let o=xo(e);return o===0?go:{x:e.x/o,y:e.y/o}},De=(e,o,l)=>({x:e.x+(o.x-e.x)*l,y:e.y+(o.y-e.y)*l}),Ce=(e,o)=>({x:(e.x+o.x)/2,y:(e.y+o.y)/2}),Me=e=>Math.atan2(e.y,e.x),Ne=(e,o)=>{let l=Math.cos(o),r=Math.sin(o);return{x:e.x*l-e.y*r,y:e.x*r+e.y*l}},Fe=(e,o,l)=>{let r=Math.cos(l),t=Math.sin(l),s=e.x-o.x,i=e.y-o.y;return{x:o.x+(s*r-i*t),y:o.y+(s*t+i*r)}},Be=e=>({x:-e.y,y:e.x}),ze=(e,o,l=0)=>l===0?e.x===o.x&&e.y===o.y:Math.abs(e.x-o.x)<=l&&Math.abs(e.y-o.y)<=l;var I={};a0(I,{IDENTITY:()=>He,applyToBounds:()=>Ye,applyToPoint:()=>J,decompose:()=>Ve,equals:()=>qe,inverse:()=>Xe,multiply:()=>Ke,of:()=>We,rotation:()=>je,scaling:()=>Ue,translation:()=>Ge});var He=Object.freeze({a:1,b:0,c:0,d:1,e:0,f:0}),We=(e,o,l,r,t,s)=>({a:e,b:o,c:l,d:r,e:t,f:s}),Ge=(e,o)=>({a:1,b:0,c:0,d:1,e,f:o}),Ue=(e,o=e)=>({a:e,b:0,c:0,d:o,e:0,f:0}),je=e=>{let o=Math.cos(e),l=Math.sin(e);return{a:o,b:l,c:-l,d:o,e:0,f:0}},Ke=(e,o)=>({a:e.a*o.a+e.c*o.b,b:e.b*o.a+e.d*o.b,c:e.a*o.c+e.c*o.d,d:e.b*o.c+e.d*o.d,e:e.a*o.e+e.c*o.f+e.e,f:e.b*o.e+e.d*o.f+e.f}),Xe=e=>{let o=e.a*e.d-e.b*e.c;if(o===0)throw new Error("Cannot invert singular matrix");return{a:e.d/o,b:-e.b/o,c:-e.c/o,d:e.a/o,e:(e.c*e.f-e.d*e.e)/o,f:(e.b*e.e-e.a*e.f)/o}},J=(e,o)=>({x:e.a*o.x+e.c*o.y+e.e,y:e.b*o.x+e.d*o.y+e.f}),Ye=(e,o)=>{let l=J(e,{x:o.x,y:o.y}),r=J(e,{x:o.x+o.width,y:o.y}),t=J(e,{x:o.x,y:o.y+o.height}),s=J(e,{x:o.x+o.width,y:o.y+o.height}),i=Math.min(l.x,r.x,t.x,s.x),a=Math.min(l.y,r.y,t.y,s.y),n=Math.max(l.x,r.x,t.x,s.x),f=Math.max(l.y,r.y,t.y,s.y);return{x:i,y:a,width:n-i,height:f-a}},Ve=e=>{let o=Math.sqrt(e.a*e.a+e.b*e.b),l=Math.sqrt(e.c*e.c+e.d*e.d),t=e.a*e.d-e.b*e.c<0?-l:l;return{translation:{x:e.e,y:e.f},rotation:Math.atan2(e.b,e.a),scale:{x:o,y:t}}},qe=(e,o,l=0)=>{let r=["a","b","c","d","e","f"];return l===0?r.every(t=>e[t]===o[t]):r.every(t=>Math.abs(e[t]-o[t])<=l)};var R={};a0(R,{EMPTY:()=>Eo,centerOf:()=>Qe,contains:()=>ll,containsBounds:()=>rl,equals:()=>sl,expand:()=>tl,fromCenter:()=>Je,fromPoints:()=>$e,intersection:()=>ko,intersects:()=>el,isEmpty:()=>w0,maxX:()=>D,maxY:()=>C,normalize:()=>il,of:()=>Ze,union:()=>ol});var Eo=Object.freeze({x:0,y:0,width:0,height:0}),Ze=(e,o,l,r)=>({x:e,y:o,width:l,height:r}),$e=e=>{if(e.length===0)return Eo;let o=1/0,l=1/0,r=-1/0,t=-1/0;for(let s of e)s.x<o&&(o=s.x),s.y<l&&(l=s.y),s.x>r&&(r=s.x),s.y>t&&(t=s.y);return{x:o,y:l,width:r-o,height:t-l}},Je=(e,o,l)=>({x:e.x-o/2,y:e.y-l/2,width:o,height:l}),Qe=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),D=e=>e.x+e.width,C=e=>e.y+e.height,w0=e=>e.width<=0||e.height<=0,ol=(e,o)=>{if(w0(e))return o;if(w0(o))return e;let l=Math.min(e.x,o.x),r=Math.min(e.y,o.y),t=Math.max(D(e),D(o)),s=Math.max(C(e),C(o));return{x:l,y:r,width:t-l,height:s-r}},ko=(e,o)=>{let l=Math.max(e.x,o.x),r=Math.max(e.y,o.y),t=Math.min(D(e),D(o)),s=Math.min(C(e),C(o));return t<=l||s<=r?null:{x:l,y:r,width:t-l,height:s-r}},el=(e,o)=>ko(e,o)!==null,ll=(e,o)=>o.x>=e.x&&o.x<=D(e)&&o.y>=e.y&&o.y<=C(e),rl=(e,o)=>o.x>=e.x&&o.y>=e.y&&D(o)<=D(e)&&C(o)<=C(e),tl=(e,o)=>({x:e.x-o,y:e.y-o,width:e.width+2*o,height:e.height+2*o}),il=e=>({x:e.width<0?e.x+e.width:e.x,y:e.height<0?e.y+e.height:e.y,width:Math.abs(e.width),height:Math.abs(e.height)}),sl=(e,o,l=0)=>l===0?e.x===o.x&&e.y===o.y&&e.width===o.width&&e.height===o.height:Math.abs(e.x-o.x)<=l&&Math.abs(e.y-o.y)<=l&&Math.abs(e.width-o.width)<=l&&Math.abs(e.height-o.height)<=l;var Q={};a0(Q,{offsetClosedPath:()=>al,signedArea:()=>nl});var al=(e,o)=>{if(e.length<3||o===0)return e.map(n=>({x:n.x,y:n.y}));let l=0,r=0;for(let n of e)l+=n.x,r+=n.y;l/=e.length,r/=e.length;let t=e.length,s=new Array(t),i=new Array(t);for(let n=0;n<t;n++){let f=g(e[n]),d=g(e[(n+1)%t]),p=d.x-f.x,c=d.y-f.y,y=Math.hypot(p,c)||1;s[n]=-c/y,i[n]=p/y}let a=[];for(let n=0;n<t;n++){let f=(n-1+t)%t,d=g(s[f]),p=g(i[f]),c=g(s[n]),y=g(i[n]),A=d+c,m=p+y,u=Math.hypot(A,m);u<1e-6?(A=d,m=p):(A/=u,m/=u);let x=g(e[n]),O=l-x.x,v=r-x.y,k=A*O+m*v>=0?1:-1,b=A*d+m*p,E=b>1e-6?o/b:o;a.push({x:x.x+k*A*E,y:x.y+k*m*E})}return a},nl=e=>{let o=0;for(let l=0;l<e.length;l++){let r=g(e[l]),t=g(e[(l+1)%e.length]);o+=r.x*t.y-t.x*r.y}return o/2};var cl=null;var To=()=>cl;var n0=e=>e.type==="text";var L0=e=>e.stroke??e.fill??"#000",wo=new Map,T=(e,o)=>{wo.set(e,o)};var c0=e=>{let o=wo.get(e.type);if(!o)throw new Error(`No bounder registered for shape type: ${e.type}`);return o(e)},R0=e=>{let o=c0(e),l=[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x,y:o.y+o.height},{x:o.x+o.width,y:o.y+o.height}],r=Math.sin(e.rotation),t=Math.cos(e.rotation),s=l.map(i=>{let a=i.x*e.scale.x,n=i.y*e.scale.y;return{x:e.position.x+(a*t-n*r),y:e.position.y+(a*r+n*t)}});return R.fromPoints(s)};T("rectangle",e=>({x:0,y:0,width:e.width,height:e.height}));T("ellipse",e=>({x:0,y:0,width:e.width,height:e.height}));T("polygon",e=>R.fromPoints(e.points));T("sticky",e=>({x:0,y:0,width:e.width,height:e.height}));T("emoji",e=>({x:0,y:0,width:e.size,height:e.size}));T("path",e=>{let o=[],l={x:0,y:0};for(let r of e.commands)switch(r.kind){case"M":case"L":o.push(r.to),l=r.to;break;case"Q":o.push(r.control,r.to),l=r.to;break;case"C":o.push(r.control1,r.control2,r.to),l=r.to;break;case"Z":break}return R.fromPoints(o)});T("text",e=>{let o=e.fontSize*1.2,l=(e.text===""?$(e.id):e.text).split(`
3
+ `),r=To(),t={bold:e.style.fontWeight==="bold",italic:e.style.fontStyle==="italic"},s=a=>{if(r){let n=r(a,e.fontFamily,e.fontSize,t);if(n!==null)return n}return a.length*e.fontSize*.6};if(e.maxWidth===void 0){let a=0;for(let n of l)a=Math.max(a,s(n));return a=Math.max(a,e.fontSize*.5),{x:0,y:0,width:a,height:Math.max(1,l.length)*o}}let i=0;for(let a of l)i+=Math.max(1,Math.ceil(s(a)/e.maxWidth));return{x:0,y:0,width:e.maxWidth,height:Math.max(1,i)*o}});T("image",e=>({x:0,y:0,width:e.width,height:e.height}));T("template",e=>({x:0,y:0,width:e.width,height:e.height}));T("brush",e=>{if(e.points.length===0)return{x:0,y:0,width:0,height:0};let o=1/0,l=1/0,r=-1/0,t=-1/0;for(let s of e.points)s.x-s.width<o&&(o=s.x-s.width),s.y-s.width<l&&(l=s.y-s.width),s.x+s.width>r&&(r=s.x+s.width),s.y+s.width>t&&(t=s.y+s.width);return{x:o,y:l,width:r-o,height:t-l}});T("group",()=>({x:0,y:0,width:0,height:0}));T("frame",e=>({x:0,y:0,width:e.width,height:e.height}));T("block-arrow",e=>({x:0,y:0,width:e.width,height:e.height}));var v0=(e,o)=>e.order<o.order?-1:e.order>o.order?1:0;var I0=e=>[...e.layers.values()].sort(v0),p0=(e,o)=>[...e.elements.values()].filter(l=>l.layerId===o).sort(v0);var S0=e=>{let o=e.length;if(o<2)return[];let l=p=>{let c=g(e[p]);return{x:c.x,y:c.y}},r=p=>g(e[p]).width,t=[],s=[];for(let p=0;p<o-1;p++){let c=h.sub(l(p+1),l(p)),y=h.lengthSq(c)>0?h.normalize(c):{x:1,y:0};t.push(y),s.push(h.perp(y))}let i=[],a=[];for(let p=0;p<o;p++){let c=r(p),y=l(p);if(p===0){let x=g(s[0]);i.push(h.add(y,h.mul(x,c))),a.push(h.sub(y,h.mul(x,c)));continue}if(p===o-1){let x=g(s[o-2]);i.push(h.add(y,h.mul(x,c))),a.push(h.sub(y,h.mul(x,c)));continue}let A=g(s[p-1]),m=g(s[p]),u=h.cross(g(t[p-1]),g(t[p]));if(Math.abs(u)<1e-9){i.push(h.add(y,h.mul(A,c))),a.push(h.sub(y,h.mul(A,c)));continue}u>0?(i.push(...Lo(y,A,m,c,1)),a.push(...Ro(y,A,m,c,-1))):(i.push(...Ro(y,A,m,c,1)),a.push(...Lo(y,A,m,c,-1)))}let n=vo(l(o-1),g(s[o-2]),r(o-1),!1),f=vo(l(0),g(s[0]),r(0),!0),d=[];for(let p of i)d.push(p);for(let p of n)d.push(p);for(let p=a.length-1;p>=0;p--)d.push(g(a[p]));for(let p of f)d.push(p);return d},Lo=(e,o,l,r,t)=>{let s=h.normalize(h.add(o,l)),i=h.dot(s,o);return i>.001&&1/i<=2.5?[h.add(e,h.mul(s,t*(r/i)))]:[h.add(e,h.mul(o,t*r)),h.add(e,h.mul(l,t*r))]},Ro=(e,o,l,r,t)=>Io(e,r,h.angle(h.mul(o,t)),h.angle(h.mul(l,t))),vo=(e,o,l,r)=>{let t=h.angle(o)+(r?Math.PI:0);return Io(e,l,t,t-Math.PI)},Io=(e,o,l,r)=>{let t=r-l;for(;t>Math.PI+1e-9;)t-=2*Math.PI;for(;t<-Math.PI-1e-9;)t+=2*Math.PI;let s=Math.max(1,Math.ceil(Math.abs(t)/.35)),i=[];for(let a=0;a<=s;a++){let n=l+t*a/s;i.push({x:e.x+o*Math.cos(n),y:e.y+o*Math.sin(n)})}return i};var pl=new Map,d0=(e,o)=>{pl.set(e,o)};var dl=Object.freeze({pan:{x:0,y:0},zoom:1,rotation:0,size:{width:0,height:0},gridEnabled:!1}),O0=e=>{let o=I.translation(-e.pan.x,-e.pan.y),l=I.rotation(e.rotation),r=I.scaling(e.zoom);return I.multiply(r,I.multiply(l,o))};var P0={gray1:"#111111",gray2:"#191919",gray3:"#222222",gray4:"#2a2a2a",gray5:"#313131",gray6:"#3a3a3a",gray7:"#484848",gray8:"#606060",gray9:"#6e6e6e",gray10:"#7b7b7b",gray11:"#b4b4b4",gray12:"#eeeeee"};var y0={tomato1:"#181111",tomato2:"#1f1513",tomato3:"#391714",tomato4:"#4e1511",tomato5:"#5e1c16",tomato6:"#6e2920",tomato7:"#853a2d",tomato8:"#ac4d39",tomato9:"#e54d2e",tomato10:"#ec6142",tomato11:"#ff977d",tomato12:"#fbd3cb"};var D0={plum1:"#181118",plum2:"#201320",plum3:"#351a35",plum4:"#451d47",plum5:"#512454",plum6:"#5e3061",plum7:"#734079",plum8:"#92549c",plum9:"#ab4aba",plum10:"#b658c4",plum11:"#e796f3",plum12:"#f4d4f4"};var N={iris1:"#13131e",iris2:"#171625",iris3:"#202248",iris4:"#262a65",iris5:"#303374",iris6:"#3d3e82",iris7:"#4a4a95",iris8:"#5958b1",iris9:"#5b5bd6",iris10:"#6e6ade",iris11:"#b1a9ff",iris12:"#e0dffe"};var C0={cyan1:"#0b161a",cyan2:"#101b20",cyan3:"#082c36",cyan4:"#003848",cyan5:"#004558",cyan6:"#045468",cyan7:"#12677e",cyan8:"#11809c",cyan9:"#00a2c7",cyan10:"#23afd0",cyan11:"#4ccce6",cyan12:"#b6ecf7"};var M0={grass1:"#0e1511",grass2:"#141a15",grass3:"#1b2a1e",grass4:"#1d3a24",grass5:"#25482d",grass6:"#2d5736",grass7:"#366740",grass8:"#3e7949",grass9:"#46a758",grass10:"#53b365",grass11:"#71d083",grass12:"#c2f0c2"};var N0={amber1:"#16120c",amber2:"#1d180f",amber3:"#302008",amber4:"#3f2700",amber5:"#4d3000",amber6:"#5c3d05",amber7:"#714f19",amber8:"#8f6424",amber9:"#ffc53d",amber10:"#ffd60a",amber11:"#ffca16",amber12:"#ffe7b3"};var W={gray1:"#fcfcfc",gray2:"#f9f9f9",gray3:"#f0f0f0",gray4:"#e8e8e8",gray5:"#e0e0e0",gray6:"#d9d9d9",gray7:"#cecece",gray8:"#bbbbbb",gray9:"#8d8d8d",gray10:"#838383",gray11:"#646464",gray12:"#202020"};var F={tomato1:"#fffcfc",tomato2:"#fff8f7",tomato3:"#feebe7",tomato4:"#ffdcd3",tomato5:"#ffcdc2",tomato6:"#fdbdaf",tomato7:"#f5a898",tomato8:"#ec8e7b",tomato9:"#e54d2e",tomato10:"#dd4425",tomato11:"#d13415",tomato12:"#5c271f"};var F0={plum1:"#fefcff",plum2:"#fdf7fd",plum3:"#fbebfb",plum4:"#f7def8",plum5:"#f2d1f3",plum6:"#e9c2ec",plum7:"#deade3",plum8:"#cf91d8",plum9:"#ab4aba",plum10:"#a144af",plum11:"#953ea3",plum12:"#53195d"};var S={iris1:"#fdfdff",iris2:"#f8f8ff",iris3:"#f0f1fe",iris4:"#e6e7ff",iris5:"#dadcff",iris6:"#cbcdff",iris7:"#b8baf8",iris8:"#9b9ef0",iris9:"#5b5bd6",iris10:"#5151cd",iris11:"#5753c6",iris12:"#272962"};var B0={cyan1:"#fafdfe",cyan2:"#f2fafb",cyan3:"#def7f9",cyan4:"#caf1f6",cyan5:"#b5e9f0",cyan6:"#9ddde7",cyan7:"#7dcedc",cyan8:"#3db9cf",cyan9:"#00a2c7",cyan10:"#0797b9",cyan11:"#107d98",cyan12:"#0d3c48"};var G={grass1:"#fbfefb",grass2:"#f5fbf5",grass3:"#e9f6e9",grass4:"#daf1db",grass5:"#c9e8ca",grass6:"#b2ddb5",grass7:"#94ce9a",grass8:"#65ba74",grass9:"#46a758",grass10:"#3e9b4f",grass11:"#2a7e3b",grass12:"#203c25"};var U={amber1:"#fefdfb",amber2:"#fefbe9",amber3:"#fff7c2",amber4:"#ffee9c",amber5:"#fbe577",amber6:"#f3d673",amber7:"#e9c162",amber8:"#e2a336",amber9:"#ffc53d",amber10:"#ffba18",amber11:"#ab6400",amber12:"#4f3422"};var o0=(e,o)=>{let l=e[o];if(l===void 0)throw new Error(`Missing color token: ${o}`);return l},w=(e,o)=>({fill:o0(e,`${o}4`),solid:o0(e,`${o}9`),solidHover:o0(e,`${o}10`),textLow:o0(e,`${o}11`),textHigh:o0(e,`${o}12`)}),yl={light:{tomato:w(F,"tomato"),amber:w(U,"amber"),grass:w(G,"grass"),cyan:w(B0,"cyan"),iris:w(S,"iris"),plum:w(F0,"plum"),gray:w(W,"gray")},dark:{tomato:w(y0,"tomato"),amber:w(N0,"amber"),grass:w(M0,"grass"),cyan:w(C0,"cyan"),iris:w(N,"iris"),plum:w(D0,"plum"),gray:w(P0,"gray")}},fl={light:{tomato:F.tomato2,amber:U.amber2,grass:G.grass2,cyan:B0.cyan2,iris:S.iris2,plum:F0.plum2,gray:W.gray2},dark:{tomato:y0.tomato2,amber:N0.amber2,grass:M0.grass2,cyan:C0.cyan2,iris:N.iris2,plum:D0.plum2,gray:P0.gray2}},z0={light:{canvas:"#f5f5f5",bg:"#ffffff",bgSolid:"#ffffff",border:"rgba(0, 0, 0, 0.08)",text:"#1a1a1a",textMuted:"#6b6b6b",hoverOverlay:"rgba(0, 0, 0, 0.05)"},dark:{canvas:"#f5f5f5",bg:"#252525",bgSolid:"#252525",border:"rgba(255, 255, 255, 0.08)",text:"#e8e8e8",textMuted:"#9a9a9a",hoverOverlay:"rgba(255, 255, 255, 0.06)"}},Al={light:{accent:S.iris9,accentHover:S.iris10,selectedBg:S.iris4,selectedFg:S.iris11,danger:F.tomato9},dark:{accent:N.iris9,accentHover:N.iris10,selectedBg:N.iris4,selectedFg:N.iris11,danger:y0.tomato9}},So=W.gray6,Oo=W.gray9,ml={rectangle:{fill:S.iris3,stroke:S.iris9,strokeWidth:2},ellipse:{fill:F.tomato3,stroke:F.tomato9,strokeWidth:2},flowchart:{fill:G.grass3,stroke:G.grass9,strokeWidth:2},sticky:{fill:U.amber3,stroke:U.amber9,strokeWidth:1}},ul={stroke:W.gray12,strokeWidth:1.5},bl={added:G.grass9,removed:F.tomato9,modified:U.amber9};var Po=z0.light.textMuted,Do="#bbb";var H0=.06,Co=1.4,Mo=.4,W0=.5,No=10,Fo=64,Bo="#fff9b1",G0=4,f0=10,zo="#8a8a6f",Ho="rgba(0, 0, 0, 0.18)",U0=4,j0=9,K0=5,j=14,Wo=4,Go="rgba(0, 0, 0, 0.08)",Uo="#555",X0=10,e0=16,Y0=6,A0=4,V0="rgba(255, 255, 255, 0.85)",jo="#333",Ko="#5b5bd6",q0=80;var Z0=.92,$0=.5;var Xo=.4,Yo=.5,J0=.1,Q0=.9,Vo="#888",qo="#ffffff",Zo="#222",$o="#ddd";var oo=1.2,gl=(e,o,l,r,t,s,i)=>{let a={indentX:i,para:s},n=()=>t.length===0||g(t[t.length-1]).para!==s;if(e===""){t.push({text:"",start:o,end:o,width:0,...a,paraFirst:n()});return}let f=[],d=/\S+/g,p;for(;(p=d.exec(e))!==null;)f.push({s:p.index,e:p.index+p[0].length});if(f.length===0){t.push({text:e,start:o,end:o+e.length,width:r(e),...a,paraFirst:n()});return}let c=0,y=(m,u)=>{let x=e.slice(m,u);t.push({text:x,start:o+m,end:o+u,width:r(x),...a,paraFirst:n()})},A=0;for(;A<f.length;){let m=g(f[A]);if(r(e.slice(c,m.e))<=l){A++;continue}if(m.s>c){y(c,m.s),c=m.s;continue}let u=m.s+1;for(;u<m.e&&r(e.slice(c,u+1))<=l;)u++;if(u>=m.e){A++;continue}y(c,u),c=u,m.s=u}y(c,e.length)},l0=(e,o,l)=>{let r=l.fontSize*(l.lineHeightFactor??oo),t=[],s=0,i=0;for(let f=0;f<=e.length;f++)if(f===e.length||e[f]===`
4
+ `){let d=e.slice(s,f),p=l.paragraphs?.[i],y=((p?.indent??0)+(p?.list!==void 0?1:0))*Co*l.fontSize;if(l.maxWidth===void 0)t.push({text:d,start:s,end:f,width:o(d),indentX:y,para:i,paraFirst:!0});else{let A=Math.max(l.fontSize,l.maxWidth-y);gl(d,s,A,o,t,i,y)}s=f+1,i++}t.length===0&&t.push({text:"",start:0,end:0,width:0,indentX:0,para:0,paraFirst:!0});let a=0;for(let f of t)a=Math.max(a,f.width+f.indentX);let n=l.maxWidth??a;return{lines:t,lineHeight:r,blockWidth:n}},hl=(e,o,l)=>l==="center"?o/2-e/2:l==="right"?o-e:0,eo=(e,o,l)=>hl(e.width,o-e.indentX,l)+e.indentX;var xl=new Map;var _l=()=>typeof performance<"u"?performance.now():0;var lo=(e,o=_l(e))=>{if(!e.animationKind)return e.src;let l=xl.get(e.animationKind);if(!l)return e.src;try{return l.getFrameAt(e.animationData,o)}catch{return e.src}};var El=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],K=e=>{if(typeof e!="object"||e===null)return!1;let o=globalThis;for(let l of El){let r=o[l];if(typeof r=="function"&&e instanceof r)return!0}return!1};var r0=(e,o)=>{let l=e.fill!==void 0&&e.fill!=="transparent",r=e.stroke!==void 0&&e.stroke!=="transparent"&&(e.strokeWidth??1)>0;return l&&o.setFill(e.fill),r&&(o.setStroke(e.stroke),o.setStrokeWidth(e.strokeWidth??1),e.lineCap&&o.setLineCap(e.lineCap),e.lineJoin&&o.setLineJoin(e.lineJoin),e.dashArray&&o.setDashArray(e.dashArray)),e.opacity!==void 0&&o.setOpacity(e.opacity),{fill:l,stroke:r}},Tl=(e,o)=>{let{fill:l,stroke:r}=r0(e.style,o);if(!l&&!r)return;let t=_0(e.style.roundness,e.width,e.height);if(l&&(o.beginPath(),t>0?M(o,0,0,e.width,e.height,t):o.rect(0,0,e.width,e.height),o.fill()),r){let s=g0(e.style),i=s,a=s,n=e.width-2*s,f=e.height-2*s;if(n<=0||f<=0)return;let d=t>0?Math.max(0,t-s):0;o.beginPath(),d>0?M(o,i,a,n,f,d):o.rect(i,a,n,f),o.stroke()}},g0=e=>{let o=e.strokeAlign??"center";if(o==="center")return 0;let l=(e.strokeWidth??1)/2;return o==="inside"?l:-l},M=(e,o,l,r,t,s)=>{e.moveTo(o+s,l),e.lineTo(o+r-s,l),e.quadraticCurveTo(o+r,l,o+r,l+s),e.lineTo(o+r,l+t-s),e.quadraticCurveTo(o+r,l+t,o+r-s,l+t),e.lineTo(o+s,l+t),e.quadraticCurveTo(o,l+t,o,l+t-s),e.lineTo(o,l+s),e.quadraticCurveTo(o,l,o+s,l),e.closePath()},wl=(e,o)=>{let{fill:l,stroke:r}=r0(e.style,o);if(!l&&!r)return;let t=e.width/2,s=e.height/2;if(l&&(o.beginPath(),o.ellipse(t,s,t,s),o.fill()),r){let i=g0(e.style),a=t-i,n=s-i;if(a<=0||n<=0)return;o.beginPath(),o.ellipse(t,s,a,n),o.stroke()}},Ll=(e,o)=>{if(e.points.length<2)return;let{fill:l,stroke:r}=r0(e.style,o);if(!(!l&&!r)&&(l&&(o.beginPath(),b0(o,e.points),o.fill()),r)){let t=g0(e.style),s=t!==0?Q.offsetClosedPath(e.points,t):e.points;o.beginPath(),b0(o,s),o.stroke()}},b0=(e,o)=>{let l=o[0];if(l!==void 0){e.moveTo(l.x,l.y);for(let r=1;r<o.length;r++){let t=o[r];t!==void 0&&e.lineTo(t.x,t.y)}e.closePath()}},Rl=(e,o)=>{if(e.commands.length===0)return;let{fill:l,stroke:r}=r0(e.style,o);if(!(!l&&!r)){o.beginPath();for(let t of e.commands)switch(t.kind){case"M":o.moveTo(t.to.x,t.to.y);break;case"L":o.lineTo(t.to.x,t.to.y);break;case"Q":o.quadraticCurveTo(t.control.x,t.control.y,t.to.x,t.to.y);break;case"C":o.bezierCurveTo(t.control1.x,t.control1.y,t.control2.x,t.control2.y,t.to.x,t.to.y);break;case"Z":o.closePath();break}l&&o.fill(),r&&o.stroke()}},Jo=e=>q0/Math.max(1,Math.min(e.width,e.height)),Qo=(e,o)=>Math.min(e.width,e.height)*o>=q0,oe=(e,o)=>1/Math.max(o>0?o:1,Jo(e)),ee=(e,o,l=1)=>{let r=oe(e,l),t=A0*r,s=e0*r,i=G0+2,a=[],n=i,f=e.height+t;for(let d of e.reactions??[]){let c=d.users?.length??d.count??0,y=`${d.glyph} ${String(c)}`,A=(o(y)+2*Y0)*r;n>i&&n+A>e.width&&(n=i,f+=s+t),a.push({glyph:d.glyph,label:y,x:n,y:f,width:A,height:s}),n+=A+t}return n>i&&n+s>e.width&&(n=i,f+=s+t),{pills:a,add:{x:n,y:f,width:s,height:s}}};var vl=(e,o,l)=>{let r=e.style.fill??Bo;e.style.opacity!==void 0&&o.setOpacity(e.style.opacity);let t=e.width,s=e.height,i=G0;if(o.setFill(Ho),o.beginPath(),M(o,1,U0,t-2,s-2,i),o.fill(),o.setFill(r),o.beginPath(),M(o,0,0,t,s,i),o.fill(),l?.content?.stickyTags!==!1&&e.tags!==void 0&&e.tags.length>0){o.setFont("system-ui, sans-serif",j0,{}),o.setTextAlign("left"),o.setTextBaseline("top");let c=i+2,y=s-j-3;for(let A of e.tags){let m=o.measureText(A).width+2*K0;if(c+m>t-i)break;o.setFill(Go),o.beginPath(),M(o,c,y,m,j,j/2),o.fill(),o.setFill(Uo),o.fillText(A,c+K0,y+(j-j0)/2),c+=m+Wo}}if(l?.content?.stickyAuthor!==!1&&e.showAuthor===!0&&e.authorName!==void 0&&e.authorName!==""){o.setFont("system-ui, sans-serif",f0,{}),o.setTextAlign("left"),o.setTextBaseline("top"),o.setFill(zo);let c=e.tags!==void 0&&e.tags.length>0?s-j-f0-8:s-f0-4;o.fillText(e.authorName,i+2,c)}let a=l?.zoom??1,n=oe(e,a),f=Qo(e,a),d=f&&l?.content?.stickyReactions!==!1,p=f&&l?.content?.stickyAddButton!==!1&&l?.hoveredElement===e.id;if(d||p){o.setFont("system-ui, sans-serif",X0,{}),o.setTextAlign("left"),o.setTextBaseline("top");let c=ee(e,y=>o.measureText(y).width,a);if(d)for(let y of c.pills)o.setFill(V0),o.beginPath(),M(o,y.x,y.y,y.width,y.height,y.height/2),o.fill(),o.setFill(jo),o.save(),o.translate(y.x,y.y),o.scale(n,n),o.fillText(y.label,Y0,(e0-X0)/2),o.restore();if(p){let y=c.add;o.setFill(V0),o.beginPath(),M(o,y.x,y.y,y.width,y.height,y.height/2),o.fill();let A=y.x+y.width/2,m=y.y+y.height/2,u=y.height*.22,x=1.4*n;o.setFill(Ko),o.beginPath(),o.rect(A-u,m-x/2,u*2,x),o.fill(),o.beginPath(),o.rect(A-x/2,m-u,x,u*2),o.fill()}}},Il=(e,o)=>{e.style.opacity!==void 0&&o.setOpacity(e.style.opacity),o.setFont("system-ui, sans-serif",e.size,{}),o.setTextAlign("left"),o.setTextBaseline("top"),o.setFill(e.style.fill??"#000"),o.fillText(e.glyph,0,0)},m0=new Map,Sl=(e,o,l,r,t,s)=>{let i=Math.round(r("Mg \u0432\u043E\u0434\u043E\u0451\u043C")/t*1e3),a=`${e}|${String(Math.round(o))}x${String(Math.round(l))}|${String(i)}`,n=m0.get(a);if(n!==void 0)return n;let f=c=>{let y=W0*c,A=o-2*y;if(A<c)return!1;let u=l0(e,x=>r(x)*c/t,{fontSize:c,maxWidth:A,...s!==void 0?{paragraphs:s}:{}});return u.lines.length*u.lineHeight<=l-2*y},d=No,p=Fo;for(;p-d>1;){let c=Math.floor((d+p)/2);f(c)?d=c:p=c}return m0.size>512&&m0.clear(),m0.set(a,d),d},le=(e,o)=>{let l=e.label;if(l===void 0)return null;let r=c0(e),t=l.autoFit===!0&&l.text!==""?Sl(l.text,r.width,r.height,o,l.fontSize,l.paragraphs):l.fontSize,s=W0*t,i=Math.max(t,r.width-2*s),a=t===l.fontSize?o:V=>o(V)*t/l.fontSize,n=l.style?.textBaseline??"middle",f={textAlign:"center",...l.style,textBaseline:"top"},d=l0(l.text,a,{fontSize:t,maxWidth:i,...l.paragraphs!==void 0?{paragraphs:l.paragraphs}:{}}),p=Math.max(0,r.height-2*s),c=Math.max(0,Math.floor(p/d.lineHeight)),y=e.metadata?.labelScrollLines,A=Math.max(0,d.lines.length-c),m=Math.max(0,Math.min(A,typeof y=="number"?Math.floor(y):0)),u={id:e.id,layerId:e.layerId,type:"text",position:{x:0,y:0},rotation:0,scale:{x:1,y:1},order:e.order,style:f,text:l.text,fontFamily:l.fontFamily,fontSize:t,maxWidth:i,clipStart:m,clipLines:c,...l.runs!==void 0?{runs:l.runs}:{},...l.paragraphs!==void 0?{paragraphs:l.paragraphs}:{}},x=Math.min(d.lines.length-m,c)*d.lineHeight,v=(n==="top"?r.y+s:n==="bottom"?r.y+r.height-x-s:r.y+Math.max(s,(r.height-x)/2))-m*d.lineHeight;return{synthetic:u,offsetX:r.x+s,offsetY:v,windowTop:m*d.lineHeight,windowBottom:(m+c)*d.lineHeight}},io=(e,o,l)=>{let r=e.label;if(r===void 0||r.text===""||l&&!r.autoFit&&Z(r.fontSize,l.zoom,l.lod))return;let t=r.style?.fontWeight,s=r.style?.fontStyle;o.setFont(r.fontFamily,r.fontSize,{...t?{weight:t}:{},...s?{style:s}:{}});let i=le(e,a=>o.measureText(a).width);i&&(l&&Z(i.synthetic.fontSize,l.zoom,l.lod)||(o.save(),o.translate(i.offsetX,i.offsetY),ao(i.synthetic,o),o.restore()))},so=e=>{let o=e;if(o.clipLines===void 0)return;let l=o.clipStart??0;return{start:l,end:l+o.clipLines}},re=(e,o,l,r)=>{if(e.paragraphs===void 0)return;let t=e.style.textAlign??"left",s=T0(e.paragraphs,k0(e.text)),i=Mo*e.fontSize;l.setFill(r);let a=so(e);o.lines.forEach((n,f)=>{if(a!==void 0&&(f<a.start||f>=a.end)||!n.paraFirst)return;let d=s[n.para];if(d==null)return;let p=l.measureText(d).width,c=eo(n,o.blockWidth,t);l.fillText(d,c-i-p,f*o.lineHeight)})},Ol=(e,o)=>{let l=e.style.textAlign??"left",r=e.fontSize;o.setTextAlign("left"),o.setTextBaseline(e.style.textBaseline??"top");let t=d=>{let p=d?.fontWeight??e.style.fontWeight,c=d?.fontStyle??e.style.fontStyle;o.setFont(e.fontFamily,r,{...p?{weight:p}:{},...c?{style:c}:{}})};t(void 0);let s=l0(e.text,d=>o.measureText(d).width,{fontSize:r,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{},...e.paragraphs!==void 0?{paragraphs:e.paragraphs}:{}}),i=s.lines.map(d=>{let p=E0(e,d.start,d.end).map(y=>(t(y.style),{text:y.text,style:y.style,width:o.measureText(y.text).width})),c=p.reduce((y,A)=>y+A.width,0);return{segs:p,total:c}}),a=e.maxWidth??i.reduce((d,p,c)=>Math.max(d,p.total+g(s.lines[c]).indentX),0),n=Math.max(1,r*H0),f=so(e);i.forEach((d,p)=>{if(f!==void 0&&(p<f.start||p>=f.end))return;let c=p*s.lineHeight,y=g(s.lines[p]).indentX,A=y+(l==="center"?(a-y)/2-d.total/2:l==="right"?a-y-d.total:0);for(let m of d.segs){let u=m.style?.fill??e.style.fill??"#000",x=m.style?.opacity??e.style.opacity;t(m.style),x!==void 0&&o.setOpacity(x);let O=m.style?.highlight??e.style.highlight;m.width>0&&O!==void 0&&O!=="transparent"&&(o.setFill(O),o.beginPath(),o.rect(A,c,m.width,s.lineHeight),o.fill()),o.setFill(u),o.fillText(m.text,A,c);let v=m.style?.textDecoration??e.style.textDecoration;m.width>0&&(v?.underline||v?.strikethrough)&&(v.underline&&(o.beginPath(),o.rect(A,c+r*Z0,m.width,n),o.fill()),v.strikethrough&&(o.beginPath(),o.rect(A,c+r*$0-n/2,m.width,n),o.fill())),A+=m.width}}),t(void 0),re(e,s,o,e.style.fill??"#000")},ao=(e,o,l)=>{if(e.text===""&&l?.textPlaceholders===!0){let{runs:p,...c}=e;ao({...c,text:$(e.id),style:{...e.style,fill:Po}},o);return}if(e.runs!==void 0&&e.runs.length>0){Ol(e,o);return}let r=e.style.textAlign??"left",t=e.style.fontWeight,s=e.style.fontStyle;o.setFont(e.fontFamily,e.fontSize,{...t?{weight:t}:{},...s?{style:s}:{}}),o.setTextAlign("left"),o.setTextBaseline(e.style.textBaseline??"top");let i=e.style.fill??"#000";o.setFill(i),e.style.opacity!==void 0&&o.setOpacity(e.style.opacity);let a=e.fontSize,n;if(e.maxWidth===void 0&&!e.text.includes(`
5
+ `)&&e.paragraphs===void 0)n=[{text:e.text,x:0,width:o.measureText(e.text).width,top:0}];else{let p=A=>o.measureText(A).width,c=l0(e.text,p,{fontSize:a,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{},...e.paragraphs!==void 0?{paragraphs:e.paragraphs}:{}});n=c.lines.map((A,m)=>({text:A.text,x:eo(A,c.blockWidth,r),width:A.width,top:m*c.lineHeight}));let y=so(e);y!==void 0&&(n=n.filter((A,m)=>m>=y.start&&m<y.end)),re(e,c,o,i)}let f=e.style.highlight;if(f!==void 0&&f!=="transparent"){let p=a*oo;o.setFill(f);for(let c of n)c.width<=0||(o.beginPath(),o.rect(c.x,c.top,c.width,p),o.fill());o.setFill(i)}for(let p of n)o.fillText(p.text,p.x,p.top);let d=e.style.textDecoration;if(d?.underline||d?.strikethrough){let p=Math.max(1,a*H0);for(let c of n)c.width<=0||(d.underline&&(o.beginPath(),o.rect(c.x,c.top+a*Z0,c.width,p),o.fill()),d.strikethrough&&(o.beginPath(),o.rect(c.x,c.top+a*$0-p/2,c.width,p),o.fill()))}},Pl=(e,o)=>{let l=e.points;if(l.length===0)return;if(e.style.opacity!==void 0&&o.setOpacity(e.style.opacity),e.closed===!0&&e.style.fill!==void 0&&l.length>=3){o.setFill(e.style.fill),o.setStroke(null),o.beginPath();let s=g(l[0]);o.moveTo(s.x,s.y);for(let i=1;i<l.length;i++){let a=g(l[i]);o.lineTo(a.x,a.y)}o.closePath(),o.fill()}let r=L0(e.style);if(o.setFill(r),o.setStroke(null),l.length===1){let s=g(l[0]);o.beginPath(),o.ellipse(s.x,s.y,s.width,s.width),o.fill();return}let t=S0(l);if(t.length>=3){o.beginPath();let s=g(t[0]);o.moveTo(s.x,s.y);for(let i=1;i<t.length;i++){let a=g(t[i]);o.lineTo(a.x,a.y)}o.closePath(),o.fill()}},Dl=(e,o,l)=>{let r=l?.clock?.(e),t=e.animationKind?lo(e,r):e.metadata?.image??lo(e,r);if(!K(t)&&(t==null||e.fileId))return;let s=e.metadata?.animated===!0||e.animationKind!==void 0,i=e.mask;i&&(o.save(),o.beginPath(),te(o,i,e.width,e.height),o.clip()),o.drawImage(t,0,0,e.width,e.height,s,e.crop,e.alt),i&&o.restore()},te=(e,o,l,r)=>{switch(o.kind){case"ellipse":e.ellipse(l/2,r/2,l/2,r/2);return;case"round-rect":{let t=Math.max(0,Math.min(.5,o.radius))*Math.min(l,r);M(e,0,0,l,r,t);return}case"polygon":{let t=o.points;if(t.length<3)return;let s=g(t[0]);e.moveTo(s.x*l,s.y*r);for(let i=1;i<t.length;i++){let a=g(t[i]);e.lineTo(a.x*l,a.y*r)}e.closePath();return}}},no=()=>{L("rectangle",Tl),L("ellipse",wl),L("polygon",Ll),L("path",Rl),L("text",ao),L("image",Dl),L("group",()=>{}),L("frame",Fl),d0("frame",()=>({top:24})),L("block-arrow",Cl),L("brush",Pl),L("sticky",vl),d0("sticky",e=>{let o=e,l=(o.reactions?.length??0)+1,r=1/Jo(o);return{bottom:U0+(A0+e0)*r*l+2,right:(A0+e0)*r+2}}),L("emoji",Il)},Cl=(e,o)=>{let{fill:l,stroke:r}=r0(e.style,o),t=e.direction??"right",s=Math.max(J0,Math.min(Q0,e.headRatio??Xo)),i=Math.max(J0,Math.min(Q0,e.bodyThickness??Yo)),a=e.width,n=e.height,f=a*s,d=a-f,p=n*i/2,c=n/2,y=[[0,c-p],[d,c-p],[d,0],[a,c],[d,n],[d,c+p],[0,c+p]];t!=="right"&&(y=y.map(([m,u])=>Ml([m,u],t,a,n)));let A=y.map(([m,u])=>({x:m,y:u}));if(l&&(o.beginPath(),b0(o,A),o.fill()),r){let m=g0(e.style),u=m!==0?Q.offsetClosedPath(A,m):A;o.beginPath(),b0(o,u),o.stroke()}},Ml=([e,o],l,r,t)=>{switch(l){case"left":return[r-e,o];case"up":return[o*(r/t),t-e*(t/r)];case"down":return[(t-o)*(r/t),e*(t/r)]}},to="\u2026",Nl=(e,o,l)=>{if(o<=0)return"";if(l.measureText(e).width<=o)return e;let r=0,t=e.length;for(;r<t;){let s=Math.ceil((r+t)/2);l.measureText(e.slice(0,s)+to).width<=o?r=s:t=s-1}return r>0?e.slice(0,r)+to:to},Fl=(e,o,l)=>{o.setFill(e.style.fill??qo),o.setStroke(null),o.setDashArray(null),o.beginPath(),o.rect(0,0,e.width,e.height),o.fill();let r=(l?.zoom??1)*(e.scale.x||1);o.setFill(null),o.setStroke(Vo),o.setStrokeWidth(1/(r||1)),o.setDashArray(null),o.beginPath(),o.rect(0,0,e.width,e.height),o.stroke();let t=e.name??"Frame";o.setFont("system-ui, sans-serif",12);let s=e.width-16,i=o.measureText(t).width<=s,a=i?t:Nl(t,s,o),n=i?Math.min(o.measureText(t).width+16,e.width):e.width;o.setFill(Zo),o.beginPath(),o.rect(0,-24,n,24),o.fill(),o.setFill($o),o.setTextBaseline("middle"),o.setTextAlign("left"),o.fillText(a,8,-24/2)};var ie=(e,o)=>{let l=new Map,r=s=>{e.setOpacity(s*o)},t={get(s,i){if(i==="setOpacity")return r;if(l.has(i))return l.get(i);let a=Reflect.get(s,i),n=typeof a=="function"?a.bind(s):a;return l.set(i,n),n}};return new Proxy(e,t)};var t0=class{entries=new Map;get(o){let l=this.entries.get(o.id);if(l){if(l.ref!==o){this.entries.delete(o.id);return}return l.value}}set(o,l){return this.entries.set(o.id,{ref:o,value:l}),l}getOrCompute(o,l){let r=this.get(o);return r!==void 0?r:this.set(o,l(o))}invalidate(o){this.entries.delete(o)}clear(){this.entries.clear()}prune(o){for(let l of this.entries.keys())o.elements.has(l)||this.entries.delete(l)}get size(){return this.entries.size}},zi=new t0,X=(e,o)=>e.getOrCompute(o,R0);var B=class{cap;onEvict;map=new Map;constructor(o,l){this.cap=o,this.onEvict=l}get(o){let l=this.map.get(o);if(l!==void 0)return this.map.delete(o),this.map.set(o,l),l}has(o){return this.map.has(o)}set(o,l){for(this.map.delete(o),this.map.set(o,l);this.map.size>this.cap;){let r=this.map.keys().next().value,t=this.map.get(r);this.map.delete(r),t!==void 0&&this.onEvict?.(r,t)}}delete(o){return this.map.delete(o)}clear(){this.map.clear()}get size(){return this.map.size}keys(){return this.map.keys()}values(){return this.map.values()}};var se=e=>e<=0?1:2**Math.round(Math.log2(e));var co=(e,o,l={})=>{let r=O0(e.viewport),t=l.dirtyWorld;if(!l.skipClear)if(t){let k=[I.applyToPoint(r,{x:t.x,y:t.y}),I.applyToPoint(r,{x:t.x+t.width,y:t.y+t.height})],b=R.expand(R.fromPoints(k),2);o.clear(b)}else o.clear();o.save(),o.setTransform(r);let s=l.boundsCache??new t0,i=l.viewport,a=null;i&&l.spatialIndex&&(a=l.spatialIndex.query(i));let n=e.viewport.zoom,f=l.clock,d={zoom:n,...f?{clock:f}:{},...l.content?{content:l.content}:{},...l.hoveredElement!==void 0?{hoveredElement:l.hoveredElement}:{},...l.textPlaceholders===!0?{textPlaceholders:!0}:{}},p=l.lod,c=p?.placeholderMaxScreenPx,y=l.placeholderFill??Do,A=l.layerCompositeCache,m=l.dirtyLayerIds,u=l.compositeLayerBitmap,x=se(n),O=k=>{let b=null;for(let E of p0(e,k)){let q=X(s,E);b=b?R.union(b,q):q}return b},v=l.dimOpacity,V=l.dimElements!==void 0&&v!==void 0?ie(o,v):null;for(let k of I0(e))if(k.visible){if(A&&u){m?.has(k.id)&&A.invalidateLayer(k.id);let b=A.get(k.id,x);if(b===void 0){let E=u(k.id,x,e);E!==null&&(A.set(k.id,x,E),b=E)}if(b!==void 0){let E=O(k.id);E&&o.drawImage(b,E.x,E.y,E.width,E.height);continue}}for(let b of p0(e,k.id)){if(l.hideElements?.has(b.id)||a&&!a.has(b.id))continue;if(i){let P=X(s,b);if(!R.intersects(P,i))continue}if(t){let P=X(s,b);if(!R.intersects(P,t))continue}if(n0(b)&&Z(b.fontSize,n,p))continue;if(c!==void 0&&po(X(s,b),n)<c){let P=X(s,b);o.setFill(y),o.setStrokeWidth(0),o.beginPath(),o.rect(P.x,P.y,P.width,P.height),o.fill();continue}let E=fo(b.type);if(!E){l.onUnknownElement?.(b);continue}o.save();let q=V!==null&&l.dimElements?.has(b.id)===!0,H=q?V:o;q&&H.setOpacity(1),H.translate(b.position.x,b.position.y),b.rotation!==0&&H.rotate(b.rotation),(b.scale.x!==1||b.scale.y!==1)&&H.scale(b.scale.x,b.scale.y),E(b,H,d),b.label!==void 0&&!n0(b)&&io(b,H,p?.minTextScreenPx!==void 0?{zoom:n,lod:p}:void 0),o.restore()}}o.restore()};var Y="Roboto",i0="PT Serif",s0="Roboto Mono",ae=e=>{let o=e.toLowerCase();return o.includes("mono")?s0:o.includes("sans")?Y:o.includes("serif")||o.includes("slab")||o.includes("georgia")||o.includes("times")?i0:Y},Bl=[{family:Y,weight:"400",style:"normal",url:new URL("../fonts/Roboto-Regular.woff2",import.meta.url)},{family:Y,weight:"700",style:"normal",url:new URL("../fonts/Roboto-Bold.woff2",import.meta.url)},{family:Y,weight:"400",style:"italic",url:new URL("../fonts/Roboto-Italic.woff2",import.meta.url)},{family:Y,weight:"700",style:"italic",url:new URL("../fonts/Roboto-BoldItalic.woff2",import.meta.url)},{family:i0,weight:"400",style:"normal",url:new URL("../fonts/PTSerif-Regular.woff2",import.meta.url)},{family:i0,weight:"700",style:"normal",url:new URL("../fonts/PTSerif-Bold.woff2",import.meta.url)},{family:i0,weight:"400",style:"italic",url:new URL("../fonts/PTSerif-Italic.woff2",import.meta.url)},{family:i0,weight:"700",style:"italic",url:new URL("../fonts/PTSerif-BoldItalic.woff2",import.meta.url)},{family:s0,weight:"400",style:"normal",url:new URL("../fonts/RobotoMono-Regular.woff2",import.meta.url)},{family:s0,weight:"700",style:"normal",url:new URL("../fonts/RobotoMono-Bold.woff2",import.meta.url)},{family:s0,weight:"400",style:"italic",url:new URL("../fonts/RobotoMono-Italic.woff2",import.meta.url)},{family:s0,weight:"700",style:"italic",url:new URL("../fonts/RobotoMono-BoldItalic.woff2",import.meta.url)}],ne=async(e=globalThis)=>{let o=e.fonts;!o||typeof FontFace>"u"||await Promise.allSettled(Bl.map(async l=>{let r=new FontFace(l.family,`url(${l.url.href})`,{weight:l.weight,style:l.style});await r.load(),o.add(r)}))};var pe=e=>{let o=e;return typeof o.naturalWidth=="number"&&o.naturalWidth>0?{width:o.naturalWidth,height:o.naturalHeight??o.naturalWidth}:typeof o.videoWidth=="number"&&o.videoWidth>0?{width:o.videoWidth,height:o.videoHeight??o.videoWidth}:typeof o.width=="number"&&o.width>0&&typeof o.height=="number"?{width:o.width,height:o.height}:null},ce=new Set,de=e=>{if(typeof console>"u")return;let o=typeof e=="string"?e.startsWith("blob:")?"dead-blob-url":"string-src":e==null?"empty":"stale-object";ce.has(o)||(ce.add(o),console.warn(`[renderer] skipped a non-drawable image source (kind: ${o}). The shape's image handle isn't a live HTMLImageElement / canvas / bitmap and it has no Scene.files bytes to rehydrate from (shapes with a fileId are skipped silently while rehydration is in flight) \u2014 the image will stay blank.`))};var h0=class{ctx;_width;_height;dpr;constructor(o,l,r,t=1){this.ctx=o,this._width=l,this._height=r,this.dpr=t}get size(){return{width:this._width,height:this._height}}resize(o,l,r){this._width=o,this._height=l,r!==void 0&&(this.dpr=r)}setFill(o){this.ctx.fillStyle=o??"transparent"}setStroke(o){this.ctx.strokeStyle=o??"transparent"}setStrokeWidth(o){this.ctx.lineWidth=o}setOpacity(o){this.ctx.globalAlpha=o}setLineCap(o){this.ctx.lineCap=o}setLineJoin(o){this.ctx.lineJoin=o}setDashArray(o){this.ctx.setLineDash(o?[...o]:[])}setFont(o,l,r){let t=r?.style==="italic"?"italic ":"",s=r?.weight==="bold"?"bold ":"";this.ctx.font=`${t}${s}${l}px "${ae(o)}", ${o}`}setTextAlign(o){this.ctx.textAlign=o==="center"?"center":o}setTextBaseline(o){this.ctx.textBaseline=o==="middle"?"middle":o==="top"?"top":"bottom"}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(o,l){this.ctx.translate(o,l)}rotate(o){this.ctx.rotate(o)}scale(o,l){this.ctx.scale(o,l)}setTransform(o){let l=this.dpr;this.ctx.setTransform(l*o.a,l*o.b,l*o.c,l*o.d,l*o.e,l*o.f)}resetTransform(){this.ctx.setTransform(this.dpr,0,0,this.dpr,0,0)}beginPath(){this.ctx.beginPath()}closePath(){this.ctx.closePath()}moveTo(o,l){this.ctx.moveTo(o,l)}lineTo(o,l){this.ctx.lineTo(o,l)}quadraticCurveTo(o,l,r,t){this.ctx.quadraticCurveTo(o,l,r,t)}bezierCurveTo(o,l,r,t,s,i){this.ctx.bezierCurveTo(o,l,r,t,s,i)}rect(o,l,r,t){this.ctx.rect(o,l,r,t)}ellipse(o,l,r,t){this.ctx.ellipse(o,l,r,t,0,0,Math.PI*2)}fill(o){this.ctx.fill(o)}stroke(){this.ctx.stroke()}clip(o){this.ctx.clip(o)}fillText(o,l,r,t){t!==void 0?this.ctx.fillText(o,l,r,t):this.ctx.fillText(o,l,r)}measureText(o){return{width:this.ctx.measureText(o).width}}drawImage(o,l,r,t,s,i,a){if(!K(o)){de(o);return}if(a&&(a.x!==0||a.y!==0||a.width!==1||a.height!==1)){let n=pe(o);if(n){this.ctx.drawImage(o,a.x*n.width,a.y*n.height,a.width*n.width,a.height*n.height,l,r,t,s);return}}this.ctx.drawImage(o,l,r,t,s)}clear(o){this.dirtyRect=null,o?this.ctx.clearRect(o.x,o.y,o.width,o.height):(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}dirtyRect=null;markDirty(o){if(!this.dirtyRect){this.dirtyRect=o;return}let l=Math.min(this.dirtyRect.x,o.x),r=Math.min(this.dirtyRect.y,o.y),t=Math.max(this.dirtyRect.x+this.dirtyRect.width,o.x+o.width),s=Math.max(this.dirtyRect.y+this.dirtyRect.height,o.y+o.height);this.dirtyRect={x:l,y:r,width:t-l,height:s-r}}getDirtyRect(){return this.dirtyRect}};var Hl=0,Wl=1,Gl=2,Ul=3,jl=4,Kl=5,Xl=6,Yl=7,Vl=8,ql=9,Zl=10,$l=11,Jl=12,Ql=13,or=14,er=15,lr=16,rr=17,tr=18,ir=19,sr=20,ar=21,nr=22,cr=23,pr=24,dr=25,yr=26,fr=27,Ar=28,mr=29,ur=30,br=31,gr=32,ye=-1,hr=-1,xr=["butt","round","square"];var _r=["miter","round","bevel"];var Er=["left","center","right"];var kr=["top","middle","bottom"];var x0={nonzero:1,evenodd:2},fe={normal:1,bold:2},Ae={normal:1,italic:2},Tr=0,me=1;var ue=(e,o,l,r=new B(64))=>{let t=new Float64Array(o),s=0,i=()=>{let f=t[s++];if(f===void 0)throw new Error("replayPackedFrame: truncated stream");return f},a=f=>{let d=l[f];if(d===void 0)throw new Error(`replayPackedFrame: bad string index ${String(f)}`);return d},n=(f,d)=>{let p=f[d];if(p===void 0)throw new Error(`replayPackedFrame: bad enum code ${String(d)}`);return p};for(;s<t.length;){let f=i();switch(f){case Hl:{let d=i();e.setFill(d===ye?null:a(d));break}case Wl:{let d=i();e.setStroke(d===ye?null:a(d));break}case Gl:e.setStrokeWidth(i());break;case Ul:e.setOpacity(i());break;case jl:e.setLineCap(n(xr,i()));break;case Kl:e.setLineJoin(n(_r,i()));break;case Xl:{let d=i();if(d===hr)e.setDashArray(null);else{let p=[];for(let c=0;c<d;c++)p.push(i());e.setDashArray(p)}break}case Yl:{let d=a(i()),p=i();if(i()===Tr){e.setFont(d,p);break}let c=i(),y=i(),A={};c===fe.normal?A.weight="normal":c===fe.bold&&(A.weight="bold"),y===Ae.normal?A.style="normal":y===Ae.italic&&(A.style="italic"),e.setFont(d,p,A);break}case Vl:e.setTextAlign(n(Er,i()));break;case ql:e.setTextBaseline(n(kr,i()));break;case Zl:e.save();break;case $l:e.restore();break;case Jl:e.translate(i(),i());break;case Ql:e.rotate(i());break;case or:e.scale(i(),i());break;case er:e.setTransform({a:i(),b:i(),c:i(),d:i(),e:i(),f:i()});break;case lr:e.resetTransform();break;case rr:e.beginPath();break;case tr:e.closePath();break;case ir:e.moveTo(i(),i());break;case sr:e.lineTo(i(),i());break;case ar:e.quadraticCurveTo(i(),i(),i(),i());break;case nr:e.bezierCurveTo(i(),i(),i(),i(),i(),i());break;case cr:e.rect(i(),i(),i(),i());break;case pr:e.ellipse(i(),i(),i(),i());break;case dr:{let d=i();d===x0.nonzero?e.fill("nonzero"):d===x0.evenodd?e.fill("evenodd"):e.fill();break}case yr:e.stroke();break;case gr:{let d=i();d===x0.nonzero?e.clip("nonzero"):d===x0.evenodd?e.clip("evenodd"):e.clip();break}case fr:{let d=a(i()),p=i(),c=i();i()===me?e.fillText(d,p,c,i()):e.fillText(d,p,c);break}case Ar:if(i()===me){let d={x:i(),y:i(),width:i(),height:i()};e.clear(d)}else e.clear();break;case mr:e.markDirty?.({x:i(),y:i(),width:i(),height:i()});break;case ur:i(),i();break;case br:{let d=i(),p=i(),c=i(),y=i(),A=i(),m=r.get(d);m&&e.drawImage(m,p,c,y,A);break}default:throw new Error(`replayPackedFrame: unknown opcode ${String(f)}`)}}};var _={canvas:null,target:null,dpr:1,images:new B(64,(e,o)=>{o.close()})},be=!1,wr=()=>{be||(no(),be=!0)},z=(e,o)=>{o&&o.length>0?self.postMessage(e,o):self.postMessage(e)},Lr=(e,o,l,r)=>{ne(self),_.canvas=e,_.dpr=r,e.width=Math.max(1,Math.round(o*r)),e.height=Math.max(1,Math.round(l*r));let t=e.getContext("2d");if(!t)throw new Error("OffscreenCanvas 2D context unavailable");t.setTransform(r,0,0,r,0,0),_.target=new h0(t,o,l,r),z({type:"ready"})},Rr=(e,o)=>{if(!_.canvas||!_.target)return;_.canvas.width=Math.max(1,Math.round(e*_.dpr)),_.canvas.height=Math.max(1,Math.round(o*_.dpr));let l=_.canvas.getContext("2d");l&&(l.setTransform(_.dpr,0,0,_.dpr,0,0),_.target.resize(e,o,_.dpr))},vr=e=>{if(!_.canvas||!_.target){z({type:"error",message:"Worker not initialised"});return}wr();let o=_.canvas.getContext("2d");if(o===null){z({type:"error",message:"Worker not initialised"});return}o.save(),o.setTransform(_.dpr,0,0,_.dpr,0,0),o.clearRect(0,0,_.target.size.width,_.target.size.height),co(e,_.target),o.restore();let l=_.canvas.transferToImageBitmap();z({type:"frame-done",bitmap:l},[l])},Ir=e=>{if(!_.target){z({type:"error",message:"Worker not initialised"});return}for(let{id:o,bitmap:l}of e.bitmaps){let r=_.images.get(o);r&&r!==l&&r.close(),_.images.set(o,l)}ue(_.target,e.buffer,e.strings,_.images)};self.addEventListener("message",e=>{let o=e.data;try{switch(o.type){case"init":Lr(o.canvas,o.width,o.height,o.dpr);break;case"resize":Rr(o.width,o.height);break;case"snapshot":vr(o.scene);break;case"replay":Ir(o);break;case"frame":z({type:"error",message:"patch-stream frames not implemented"});break}}catch(l){z({type:"error",message:l instanceof Error?l.message:String(l)})}});
6
6
  //# sourceMappingURL=render-worker.js.map