@drawo-app/drawo 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -236,7 +236,7 @@ display: flex;
236
236
  padding: 8px 0px!important;
237
237
  `},value:Q,children:u.jsx("svg",{width:ne.width/2,viewBox:ne.viewBox,fill:"none",style:{cssText:`
238
238
  scale: 0.8;
239
- `},xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:ne.path,strokeWidth:ne.strokeWidth,strokeLinecap:ne.strokeLinecap,fill:ne.fill,stroke:ne.stroke})})},`${Q}-${z}-end`)})})]})]})},fe=()=>u.jsxs(ya,{open:m==="line-stroke-width",onOpenChange:te=>{te?g("line-stroke-width"):m==="line-stroke-width"&&g(null)},value:String($),onValueChange:te=>{g(null),f(b.map(O=>O.id),Number(te))},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{className:"draw-stroke-trigger",style:{gap:"0px",width:"fit-content"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:i.selectionBar.strokeWidth})}),u.jsx("span",{className:"draw-stroke-option-line-wrap",children:f5(J5,Math.max(0,Ko.findIndex(te=>te===$)))})]})}),u.jsx(Pr,{children:u.jsx("p",{children:i.selectionBar.strokeWidth})})]}),u.jsx(ba,{position:"popper",children:Ko.map((te,O)=>u.jsx(Hr,{check:!1,value:String(te),className:"draw-stroke-select-item",children:u.jsx("span",{className:"draw-stroke-option-line-wrap",children:f5(J5,O)})},te))})]});return r.length>1?B.length===r.length?Z():u.jsx(u.Fragment,{}):B.length>0?Z():b.length>0?u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[ee(),fe(),u.jsx("div",{className:"selectionbar-separator"}),K()]}):n==="draw"||n==="marker"||n==="quill"?Z():u.jsx(u.Fragment,{})};function hse({className:t,type:e,value:r,onValueChange:n,...i}){const[a,s]=T.useState(typeof r=="number"&&Number.isFinite(r)?r:10);T.useEffect(()=>{typeof r=="number"&&Number.isFinite(r)&&s(r)},[r]);const o=A=>{Number.isFinite(A)&&(s(A),n(A))};return u.jsxs("div",{className:"drawo-numberinput-container",children:[u.jsx("button",{onClick:()=>{o((Number.isFinite(a)?a:10)-1)},children:u.jsx(sO,{})}),u.jsx("input",{type:e,"data-slot":"input",className:"drawo-numberinput"+(t?" "+t:""),...i,value:a,onChange:A=>{const l=Number.parseInt(A.target.value,10);Number.isFinite(l)&&o(l)}}),u.jsx("button",{onClick:()=>{o((Number.isFinite(a)?a:10)+1)},children:u.jsx(oO,{})})]})}const QT=({scene:t,selectedIds:e,localeMessages:r,editor:n,editingText:i,setEditingText:a,worldToScreen:s,toggleEditorMark:o,onTextCommit:A,onTextFontFamilyChange:l,onTextFontSizeChange:c,onTextFontWeightChange:f,onTextFontStyleChange:d,onTextAlignChange:h,onTextColorChange:C,shapeColors:p,customDrawColorPickerWrapRef:w,customDrawColorPickerContentRef:m,customDrawColorPickerColor:g,setCustomDrawColorPickerColor:B,activeSelectId:b,setActiveSelectId:L})=>{const E=u9(t.elements,e),I=$i(E,Oe=>Oe.textAlign),k=g$(I),M=$i(E,Oe=>Oe.fontFamily),H=$i(E,Oe=>Oe.fontSize),F=typeof H=="number"&&Number.isFinite(H),D=$i(E,Oe=>Oe.fontWeight),U=$i(E,Oe=>Oe.fontStyle),R=$i(E,Oe=>Oe.color)??"multi",$=R==="multi"?E[0]?.color??t.settings.shapeDefaults.textColor:R,re=[...p[0],...p[1]],Z=re.some(Oe=>Oe!=="multi"&&Oe.toLowerCase()===$.toLowerCase())?$:"multi",ee=re.some(Oe=>Oe!=="multi"&&Oe.toLowerCase()===$.toLowerCase()),K=P.useRef(!1),[fe,te]=P.useState(!1),O=D==="bold"||D==="700"||D==="800"||D==="900",Q=U==="italic",z=(()=>{if(!i)return null;try{return G.marks(n)??null}catch{return null}})(),ne=i&&(i.style.fontWeight==="bold"||i.style.fontWeight==="700"||i.style.fontWeight==="800"||i.style.fontWeight==="900"),he=i?.style.fontStyle==="italic",le=z?.bold===!0||z?.bold!==!1&&ne,Be=z?.italic===!0||z?.italic!==!1&&he,V=Oe=>Ic(Oe.text).every(Qe=>Qe.children.every(Xe=>Xe.strikethrough===!0)),oe=E.length>0&&E.every(Oe=>V(Oe)),de=i?le:O,ve=i?Be:Q,Re=i?z?.strikethrough===!0:oe,Pe=()=>{const Oe=!oe;for(const Me of E){const Xe=Ic(Me.text).map(at=>({...at,children:at.children.map(pt=>({...pt,strikethrough:Oe}))}));A(Me.id,lf(Xe))}},Y=()=>{i&&requestAnimationFrame(()=>{try{Bt.focus(n)}catch{return}})},He=Oe=>{te(!0),L("text-color"),B(Kp(Oe))},tt=Oe=>{const Me=E.map(Qe=>Qe.id);C(Me,Oe),i&&Me.includes(i.id)&&a(Qe=>Qe&&{...Qe,style:{...Qe.style,color:Oe}}),Y()};return u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[u.jsx("div",{ref:w,style:{position:"relative",display:"inline-flex"},children:u.jsxs(ya,{open:b==="text-color",onOpenChange:Oe=>{if(Oe){te(!1),L("text-color");return}if(K.current){K.current=!1;return}fe&&te(!1),L(null)},value:String(Z),onValueChange:Oe=>{if(Oe==="multi"){He($);return}L(null),tt(Oe)},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{onPointerDown:Oe=>{Z==="multi"&&(Oe.preventDefault(),Oe.stopPropagation(),He($))},style:{gap:"0px",width:"fit-content"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:r.selectionBar.textColor})}),u.jsx("div",{style:{width:"20px",borderRadius:"100%",border:"1px solid #ffffff20",height:"20px",background:$}})]})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textColor})})]}),u.jsxs(ba,{position:"popper",className:"drawo-colorselect-content",children:[u.jsx("div",{children:u.jsx(ws,{colors:p[0],currentColor:$,uniColor:Oe=>Oe,renderItem:({color:Oe,isMulti:Me,swatch:Qe})=>u.jsx(Hr,{value:Oe,className:"drawo-colorselect-item",check:!1,onPointerDown:Me?Xe=>{Xe.preventDefault(),Xe.stopPropagation(),K.current=!0,He($)}:void 0,onSelect:Me?Xe=>{Xe.preventDefault(),Xe.stopPropagation(),K.current=!0,He($)}:void 0,children:Qe},Oe)})}),u.jsx("div",{children:u.jsx(ws,{colors:p[1],realTotalColors:re,currentColor:$,uniColor:Oe=>Oe,renderItem:({color:Oe,isMulti:Me,swatch:Qe})=>u.jsx(Hr,{value:Oe,className:"drawo-colorselect-item",check:!1,onPointerDown:Me?Xe=>{Xe.preventDefault(),Xe.stopPropagation(),K.current=!0,He($)}:void 0,onSelect:Me?Xe=>{Xe.preventDefault(),Xe.stopPropagation(),K.current=!0,He($)}:void 0,children:Qe},Oe)})})]})]})}),u.jsxs(Tr,{open:b==="text-color"&&(fe||!ee),children:[u.jsx(Nr,{asChild:!0,children:u.jsx("div",{className:"selectionbar-separator"})}),u.jsx(Pr,{className:"drawo-content-color drawo-ultrainferior-colorcontent3",side:"bottom",style:{background:"transparent"},children:u.jsx("div",{ref:m,onPointerDown:Oe=>Oe.stopPropagation(),children:u.jsx(u2,{color:g,onChange:Oe=>{const Me=Oe.hexa||Oe.hex;Me&&(B(Me),tt(Me))}})})})]}),u.jsxs(ya,{open:b==="text-font-family",onOpenChange:Oe=>{Oe?L("text-font-family"):b==="text-font-family"&&L(null)},value:M,onValueChange:Oe=>{L(null),l(E.map(Me=>Me.id),Oe),Y()},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{style:{gap:"0px"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:r.selectionBar.fontFamily})}),M==="Shantell Sans"?u.jsx(VZ,{}):M==="Cascadia Code"?u.jsx(_Z,{}):M==="Imbue"?u.jsx(HZ,{}):u.jsx(jZ,{})]})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.fontFamily})})]}),u.jsxs(ba,{position:"popper",children:[u.jsx(Hr,{check:!1,value:"Rubik",children:r.fontFamilies.simple}),u.jsx(Hr,{check:!1,value:"Shantell Sans",children:r.fontFamilies.handwritten}),u.jsx(Hr,{check:!1,value:"Imbue",children:r.fontFamilies.elegant}),u.jsx(Hr,{check:!1,value:"Cascadia Code",children:r.fontFamilies.technical})]})]}),u.jsx("div",{className:"selectionbar-separator"}),u.jsxs(ya,{open:b==="text-font-size",onOpenChange:Oe=>{Oe?L("text-font-size"):b==="text-font-size"&&L(null)},value:F?String(H):void 0,onValueChange:Oe=>{L(null);const Me=Number.parseInt(Oe,10);Number.isFinite(Me)&&(c(E.map(Qe=>Qe.id),Me),Y())},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{style:{gap:"0px"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:""})}),F?H:"-"]})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.fontSize})})]}),u.jsxs(ba,{position:"popper",children:[u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"16",children:[r.fontSizes.small,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"16"})]}),u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"24",children:[r.fontSizes.medium,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"24"})]}),u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"40",children:[r.fontSizes.large,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"40"})]}),u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"64",children:[r.fontSizes.extraLarge,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"64"})]}),u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"96",children:[r.fontSizes.huge,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"96"})]}),u.jsx(pte,{}),u.jsx(hse,{value:H,onValueChange:Oe=>{Number.isFinite(Oe)&&(c(E.map(Me=>Me.id),Oe),Y())},placeholder:r.fontSizes.placeholder,type:"number"})]})]}),u.jsx("div",{className:"selectionbar-separator"}),u.jsxs("div",{style:{display:"flex"},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",onPointerDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation()},onClick:()=>{if(i){o("bold"),Bt.focus(n);return}f(E.map(Oe=>Oe.id),de?"200":"700")},className:"toggle-selectionbar-button"+(de?" active":""),children:u.jsx(Vz,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.bold})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",onPointerDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation()},onClick:()=>{if(i){o("italic"),Bt.focus(n);return}d(E.map(Oe=>Oe.id),ve?"normal":"italic")},className:"toggle-selectionbar-button"+(ve?" active":""),children:u.jsx(oZ,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.italic})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",onPointerDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation()},onClick:()=>{if(i){o("strikethrough"),Bt.focus(n);return}Pe()},className:"toggle-selectionbar-button"+(Re?" active":""),children:u.jsx(EZ,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.strikethrough||"Strikethrough (Ctrl+S)"})})]}),u.jsx("div",{className:"selectionbar-separator"}),u.jsxs(ya,{open:b==="text-align",onOpenChange:Oe=>{Oe?L("text-align"):b==="text-align"&&L(null)},value:k,onValueChange:Oe=>{L(null);const Me=Oe==="center"?"center":Oe==="end"?"end":"left",Qe=E.map(at=>at.id);if(h(Qe,Me),!i||!Qe.includes(i.id)){Y();return}const Xe=t.elements.find(at=>at.id===i.id);a(at=>{if(!at)return at;const pt=Xe&&(Xe.type==="rectangle"||Xe.type==="circle")?Gu(Xe,Me):at.anchorX,pe=Uo(pt,at.width,Me),Ke=s(pe,at.anchorY);return{...at,anchorX:pt,left:Ke.x,style:{...at.style,textAlign:Me}}}),Y()},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{style:{gap:"0px"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:""})}),k==="left"?u.jsx(wm,{}):k==="center"?u.jsx(mm,{}):u.jsx(ym,{})]})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textAlign})})]}),u.jsxs(ba,{position:"popper",className:"drawo-colorselect-content",children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx(Hr,{check:!1,className:"drawo-textAlign-item",value:"left",children:u.jsx(wm,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textAlignDirection.left})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx(Hr,{check:!1,className:"drawo-textAlign-item",value:"center",children:u.jsx(mm,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textAlignDirection.center})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx(Hr,{check:!1,className:"drawo-textAlign-item",value:"end",children:u.jsx(ym,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textAlignDirection.right})})]})]})]})]})]})},_T=({left:t,top:e,toolbarKey:r,viewportWidth:n,children:i})=>{const a=P.useRef(null),[s,o]=P.useState(0);P.useEffect(()=>{const l=a.current;if(!l)return;const c=new ResizeObserver(f=>{const d=f[0]?.contentRect.width??l.offsetWidth;o(d)});return c.observe(l),o(l.offsetWidth),()=>{c.disconnect()}},[r]);const A=P.useMemo(()=>{const l=s/2,c=8,f=l+c,d=Math.max(f,n-l-c);return Math.min(Math.max(t,f),d)},[t,s,n]);return u.jsx("div",{ref:a,className:"selection-toolbar",onPointerDown:l=>{l.stopPropagation()},onMouseDown:l=>{l.stopPropagation()},style:{left:A,top:e},children:i},r)},HT=({editorWrapRef:t,editor:e,editingText:r,editingDocument:n,editorSessionKey:i,cameraZoom:a,setEditingDocument:s,setEditingText:o,toThemeColor:A,getTextLineHeight:l,onEditorChange:c,onCommitEditingText:f,onToggleEditorMark:d})=>{const h=m=>m instanceof HTMLElement?!!(m.closest(".selection-toolbar")||m.closest(".select-content")||m.closest('[data-slot="select-content"]')||m.closest('[data-slot="select-trigger"]')):!1,C=()=>{requestAnimationFrame(()=>{const m=document.activeElement;t.current?.contains(m)||h(m)||f()})},p=m=>{if((m.ctrlKey||m.metaKey)&&m.key==="Enter"){m.preventDefault(),f();return}if((m.ctrlKey||m.metaKey)&&m.key.toLowerCase()==="b"){m.preventDefault(),d("bold");return}if((m.ctrlKey||m.metaKey)&&m.key.toLowerCase()==="i"){m.preventDefault(),d("italic");return}if((m.ctrlKey||m.metaKey)&&m.key.toLowerCase()==="s"){m.preventDefault(),d("strikethrough");return}m.key==="Escape"&&(s(null),o(null))},w=P.useCallback(({attributes:m,children:g,leaf:B})=>{const b=B;return u.jsx("span",{...m,style:{fontWeight:b.bold===!0?700:b.bold===!1?400:void 0,fontStyle:b.italic===!0?"italic":b.italic===!1?"normal":void 0,textDecorationLine:b.strikethrough===!0?"line-through":"none",textDecorationColor:b.strikethrough===!0?"currentColor":void 0,textDecorationThickness:b.strikethrough===!0?"0.05em":void 0},children:g})},[]);return r?u.jsx("div",{ref:t,style:{position:"absolute",left:r.left,top:r.top,width:r.width,height:r.height,maxWidth:r.maxWidth,margin:0,padding:0,border:"none",outline:"none",cursor:'url("/cursors/text.svg") 12 12, auto',background:"transparent",boxShadow:"none",color:A(r.style.color),fontFamily:r.style.fontFamily,fontSize:r.style.fontSize*a,fontWeight:r.style.fontWeight,fontStyle:r.style.fontStyle,textAlign:r.style.textAlign,lineHeight:`${l(r.style.fontSize)*a}px`},children:u.jsx(x1e,{editor:e,initialValue:n??Ic(r.value),onChange:c,children:u.jsx(C1e,{className:"canvas-text-editor-input",renderLeaf:w,onBlur:C,onKeyDown:p,spellCheck:!1,style:{width:"100%",height:"100%",minHeight:`${r.style.fontSize*a}px`,outline:"none",whiteSpace:"pre",wordBreak:"normal",background:"transparent",color:"inherit",WebkitTextFillColor:"currentColor",caretColor:"currentColor"}})},`${r.id}-${i}`)}):null},dse=(t,e)=>{const r=Zc(1-t/e);return Math.pow(r,1.3)},kA=(t,e)=>{const r=Xc(t);return r?`rgba(${r.r}, ${r.g}, ${r.b}, ${Zc(r.a*e)})`:t},pse=typeof navigator<"u"&&/firefox/i.test(navigator.userAgent),gse=(t,e,r)=>{const i=[];let a=0,s=0;for(let o=0;o<t.length-1;o++){const A=t[o===0?0:o-1],l=t[o],c=t[o+1],f=t[o+2]||t[o+1];for(let d=0;d<=1;d+=1/3){const h=d*d,C=h*d,p=(c.x-A.x)*.5,w=(f.x-l.x)*.5,m=l.x+p*d+(3*(c.x-l.x)-2*p-w)*h+(2*(l.x-c.x)+p+w)*C,g=(c.y-A.y)*.5,B=(f.y-l.y)*.5,b=l.y+g*d+(3*(c.y-l.y)-2*g-B)*h+(2*(l.y-c.y)+g+B)*C,L=l.t+(c.t-l.t)*d,E=dse(e-L,r.lifetime),I=Math.max(r.minWidth,r.baseWidth*E);if(I<=r.minWidth+.01)continue;const k=i[i.length-1];k&&k.x===m&&k.y===b||(i.push({x:m,y:b,widthPx:I}),a+=I,s=Math.max(s,I))}}return{samples:i,maxWidthPx:s,avgWidthPx:i.length>0?a/i.length:r.minWidth}},Cse=t=>{const e=new Path2D;e.moveTo(t[0].x,t[0].y);for(let r=1;r<t.length;r++){const n=t[r];e.lineTo(n.x,n.y)}return e},h5=(t,e,r,n)=>{t.strokeStyle=n.strokeColor,t.lineWidth=n.widthPx/r.zoom,t.shadowColor=n.shadowColor,t.shadowBlur=n.shadowBlurPx/r.zoom,t.shadowOffsetX=0,t.shadowOffsetY=0,t.stroke(e)},vse=(t,e,r,n,i)=>{t.shadowBlur=0,t.shadowColor="rgba(0, 0, 0, 0)",t.shadowOffsetX=0,t.shadowOffsetY=0,t.strokeStyle=n,t.lineWidth=i/r.zoom,t.stroke(e)},mse=(t,e,r,n,i)=>{if(e.length<2)return;const{samples:a,maxWidthPx:s,avgWidthPx:o}=gse(e,r,i);if(a.length<2)return;const A=Cse(a);if(t.lineJoin="round",t.lineCap="round",i.shadow){const l=Math.max(i.minWidth,o),c=document.querySelector("html")?.classList.contains("dark");pse?h5(t,A,n,{strokeColor:kA(i.color,1),shadowColor:kA(i.color,1),widthPx:l,shadowBlurPx:Math.max(18,s*2.5)}):(h5(t,A,n,{strokeColor:kA(i.color,1),shadowColor:kA(i.color,.75),widthPx:l,shadowBlurPx:Math.max(60,s*7)}),h5(t,A,n,{strokeColor:kA(i.color,1),shadowColor:kA(i.color,.9),widthPx:l,shadowBlurPx:Math.max(30,s*3.5)}),h5(t,A,n,{strokeColor:kA(i.color,1),shadowColor:c?"rgba(0,0,0,0.55)":"rgba(255, 255, 255, 0.55)",widthPx:l,shadowBlurPx:Math.max(12,s*1.2)}))}vse(t,A,n,i.color,Math.max(i.minWidth,o))},wse=()=>`laser-${Gi("draw")}`,yse=600,Xf=(t,e)=>t.map(r=>({...r,points:r.points.filter(n=>e-n.t<=yse)})).filter(r=>r.points.length>0),Bse=(t,e,r,n)=>Xf(e?t.map(i=>{if(i.id!==e)return i;const a=i.points[i.points.length-1],s=.3/n;return a&&Math.hypot(r.x-a.x,r.y-a.y)<s?i:{...i,points:[...i.points,r]}}):t,r.t),bse=()=>{const[t,e]=P.useState([]),[r,n]=P.useState(()=>performance.now()),i=P.useRef(null),a=P.useCallback(A=>{const l=performance.now(),c=wse();n(l),e(f=>[...Xf(f,l),{id:c,points:[{x:A.x,y:A.y,t:l}]}]),i.current=c},[]),s=P.useCallback((A,l)=>{const c=performance.now();n(c),e(f=>Bse(f,i.current,{x:A.x,y:A.y,t:c},l))},[]),o=P.useCallback(()=>{i.current=null},[]);return P.useEffect(()=>{if(t.length===0)return;let A=0;const l=()=>{const c=performance.now();n(c),e(f=>Xf(f,c)),A=window.requestAnimationFrame(l)};return A=window.requestAnimationFrame(l),()=>{window.cancelAnimationFrame(A)}},[t.length]),{laserTrails:t,laserNow:r,startLaserTrail:a,appendLaserPoint:s,clearActiveLaserTrail:o}};function xse(t){return u.jsx(sV,{"data-slot":"context-menu",...t})}function Lse({className:t,...e}){return u.jsx(oV,{"data-slot":"context-menu-trigger",className:"drawo-contextmenu-trigger"+(t?" "+t:""),...e})}function gB(t){return u.jsx(fV,{"data-slot":"context-menu-sub",...t})}function Ese({className:t,...e}){return u.jsx(AV,{children:u.jsx(lV,{"data-slot":"context-menu-content",className:"drawo-contextmenu-content"+(t?" "+t:""),...e})})}function Ta({className:t,inset:e,disabled:r=!1,variant:n="default",...i}){return u.jsx(uV,{"data-slot":"context-menu-item","data-inset":e,"data-disabled":r,"data-variant":n,className:"drawo-contextmenu-item"+(t?" "+t:""),...i})}function CB({className:t,inset:e,children:r,...n}){return u.jsxs(hV,{"data-slot":"context-menu-sub-trigger","data-inset":e,className:"drawo-contextmenu-subtrigger"+(t?" "+t:""),...n,children:[r,u.jsx(Mz,{className:"drawo-contextmenu-chevron"})]})}function vB({className:t,...e}){return u.jsx(dV,{"data-slot":"context-menu-sub-content",className:"drawo-contextmenu-subcontent"+(t?" "+t:""),...e})}function Ud({className:t,...e}){return u.jsx(cV,{"data-slot":"context-menu-separator",className:"drawo-contextmenu-separator"+(t?" "+t:""),...e})}const VT=({children:t,hasSelection:e,canFlipSelection:r,selectionType:n,selectionOpacity:i,hasElements:a,localeMessages:s,canUngroupSelection:o,onCut:A,onCopy:l,onPaste:c,onDuplicate:f,onDelete:d,onGroup:h,onUngroup:C,onSelectAll:p,onMoveForward:w,onBringToFront:m,onSendToBack:g,onMoveBackward:B,onFlipHorizontal:b,onFlipVertical:L,onSelectionOpacityChange:E})=>{const I=e&&n==="multiple",k=P.useMemo(()=>typeof i!="number"||!Number.isFinite(i)?100:Math.max(0,Math.min(100,Math.round(i))),[i]),[M,H]=P.useState(k),[F,D]=P.useState(String(k));P.useEffect(()=>{H(k),D(String(k))},[k,e]);const U=R=>{const $=Math.max(0,Math.min(100,Math.round(R)));H($),D(String($)),E($)};return u.jsxs(xse,{children:[u.jsx(Lse,{children:t}),u.jsxs(Ese,{children:[e&&u.jsxs(u.Fragment,{children:[u.jsxs(Ta,{onClick:A,children:[u.jsx(bZ,{}),s.contextMenu.cut,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()})," + ",u.jsx("span",{children:"X"})]})]}),u.jsxs(Ta,{onClick:l,children:[u.jsx(zz,{}),s.contextMenu.copy,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()})," + ",u.jsx("span",{children:"C"})]})]})]}),u.jsxs(Ta,{onClick:c,children:[u.jsx(LZ,{}),s.contextMenu.paste,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()})," + ",u.jsx("span",{children:"V"})]})]}),e&&u.jsxs(u.Fragment,{children:[u.jsxs(Ta,{onClick:f,children:[u.jsx(Zz,{}),s.contextMenu.duplicate,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()}),"+",u.jsx("span",{children:"D"})]})]}),u.jsxs(Ta,{onClick:d,variant:"destructive",children:[u.jsx(MZ,{}),s.contextMenu.delete,u.jsx("span",{className:"drawo-keybind",children:u.jsx("span",{children:"Del"})})]})]}),(I||o||e)&&u.jsx(Ud,{}),(I||o)&&u.jsxs(u.Fragment,{children:[I&&u.jsxs(Ta,{onClick:h,children:[u.jsx(cO,{}),s.contextMenu.group,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()}),"+",u.jsx("span",{children:"G"})]})]}),o&&u.jsxs(Ta,{onClick:C,children:[u.jsx(Gz,{}),s.contextMenu.ungroup,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()}),"+",u.jsx("span",{children:hd()}),"+",u.jsx("span",{children:"G"})]})]})]}),e&&u.jsxs(u.Fragment,{children:[u.jsxs(gB,{children:[u.jsxs(CB,{children:[u.jsx(AZ,{}),s.contextMenu.layers.text]}),u.jsxs(vB,{children:[u.jsxs(Ta,{onClick:m,children:[u.jsx(nX,{}),s.contextMenu.layers.bringToFront]}),u.jsxs(Ta,{onClick:w,children:[u.jsx(iX,{}),s.contextMenu.layers.bringForward]}),u.jsxs(Ta,{onClick:g,children:[u.jsx(tX,{}),s.contextMenu.layers.sendToBack]}),u.jsxs(Ta,{onClick:B,children:[u.jsx(rX,{}),s.contextMenu.layers.sendBackward]})]})]}),u.jsxs(gB,{children:[u.jsxs(CB,{children:[u.jsx(tZ,{}),s.selectionBar.opacity,"..."]}),u.jsx(vB,{className:"drawo-contextmenu-opacity-subcontent",children:u.jsxs("div",{className:"drawo-contextmenu-opacity-popover",onPointerDown:R=>R.stopPropagation(),onClick:R=>R.stopPropagation(),children:[u.jsxs("div",{className:"drawo-contextmenu-opacity-header",children:[u.jsx("span",{children:s.selectionBar.opacity}),u.jsxs("div",{className:"drawo-contextmenu-opacity-input-wrap",children:[u.jsx("input",{className:"drawo-input drawo-numberinput drawo-contextmenu-opacity-input",type:"number",min:0,max:100,step:1,value:F,onChange:R=>{const $=R.target.value.replace(/[^0-9]/g,"");D($)},onBlur:()=>{const R=Number.parseInt(F,10);U(Number.isFinite(R)?R:M)},onKeyDown:R=>{if(R.key==="Enter"){const $=Number.parseInt(F,10);U(Number.isFinite($)?$:M),R.currentTarget.blur();return}R.key==="Escape"&&(D(String(M)),R.currentTarget.blur())}}),u.jsx("span",{className:"drawo-contextmenu-opacity-unit",children:"%"})]})]}),u.jsx(X2,{className:"drawo-contextmenu-opacity-slider",value:[M],min:0,max:100,step:1,onValueChange:R=>{const $=R[0]??M;H($),D(String(Math.round($)))},onValueCommit:R=>{U(R[0]??M)}})]})})]}),u.jsx(Ud,{}),u.jsxs(Ta,{disabled:!r,onClick:b,children:[u.jsx(kZ,{}),"Voltear horizontalmente",u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:hd()}),"+",u.jsx("span",{children:"H"})]})]}),u.jsxs(Ta,{disabled:!r,onClick:L,children:[u.jsx(DZ,{}),"Voltear verticalmente",u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:hd()}),"+",u.jsx("span",{children:"V"})]})]})]}),u.jsx(Ud,{}),u.jsxs(Ta,{disabled:!a,onClick:p,children:[u.jsx(Yz,{}),s.contextMenu.selectEverything,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()})," + ",u.jsx("span",{children:"A"})]})]})]})]})},hu=()=>performance.now(),Sse=220,Fse=4,Dse=4,mB=t=>t.type!=="text",kse=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,wB=(t,e,r)=>t+(e-t)*r,yB=(t,e,r,n,i)=>{const a=6/n;t.save(),t.strokeStyle=i,t.lineWidth=1/n,t.lineCap="round",t.setLineDash([]),t.beginPath(),t.moveTo(e-a/2,r-a/2),t.lineTo(e+a/2,r+a/2),t.moveTo(e+a/2,r-a/2),t.lineTo(e-a/2,r+a/2),t.stroke(),t.restore()},Mse=(t,e,r,n)=>{if(e.length!==0){t.save(),t.strokeStyle=n,t.fillStyle=n,t.lineWidth=1/r,t.setLineDash([6/r,4/r]);for(const i of e)t.beginPath(),i.kind==="spacing"&&i.segmentStart&&i.segmentEnd?(t.moveTo(i.segmentStart.x,i.segmentStart.y),t.lineTo(i.segmentEnd.x,i.segmentEnd.y)):i.axis==="x"?(t.moveTo(i.value,i.start),t.lineTo(i.value,i.end)):(t.moveTo(i.start,i.value),t.lineTo(i.end,i.value)),t.stroke(),yB(t,i.movingPoint.x,i.movingPoint.y,r,n),yB(t,i.targetPoint.x,i.targetPoint.y,r,n);t.restore()}},c9=(t,e,r)=>{if(e.type==="circle"){t.beginPath(),t.ellipse(e.x+e.width/2,e.y+e.height/2,e.width/2,e.height/2,0,0,Math.PI*2);return}a1(t,e.x,e.y,e.width,e.height,r)},Ise=(t,e,r,n)=>{if(e.fillStyle==="none")return;const i=n(e.fill);if(t.save(),e.fillStyle==="solid"){t.fillStyle=i,c9(t,e,r),t.fill(),t.restore();return}const a=8,s=Math.max(1,e.strokeWidth),o=Math.hypot(e.width,e.height)+Math.max(e.width,e.height)*2;c9(t,e,r),t.clip(),t.strokeStyle=i,t.lineWidth=s,t.lineCap="round",t.lineJoin="round";for(let A=e.x-o;A<=e.x+e.width+o;A+=a)t.beginPath(),t.moveTo(A,e.y+e.height+o),t.lineTo(A+o,e.y-o),t.stroke();t.restore()},Ose=(t,e,r,n)=>{e.strokeStyle!=="none"&&(t.save(),t.strokeStyle=n(e.stroke),t.lineCap="round",t.lineJoin="round",t.lineWidth=Math.max(1,e.strokeWidth),e.strokeStyle==="dashed"?t.setLineDash([8,4]):t.setLineDash([]),c9(t,e,r),t.stroke(),t.restore())},WT=({scene:t,shapeColors:e,strokeColors:r,alignmentGuides:n,interactionMode:i,drawingTool:a,localeMessages:s,onPointerDown:o,onPointerMove:A,onPointerUp:l,onWheelPan:c,onWheelZoom:f,onCreateElement:d,onCreateDrawElement:h,onCreateLinePathElement:C,onDrawingToolComplete:p,onDropImageFiles:w,onSelectElements:m,onCopySelection:g,onCutSelection:B,onPasteAt:b,onDuplicateSelection:L,onDeleteSelection:E,onGroupSelection:I,onUngroupSelection:k,onSelectGroupForElement:M,onReorderSelection:H,onFlipSelection:F,onTextFontFamilyChange:D,onTextFontSizeChange:U,onTextFontWeightChange:R,onTextFontStyleChange:$,onTextAlignChange:re,onTextColorChange:Z,onDrawStrokeWidthChange:ee,onDrawStrokeColorChange:K,onShapeFillColorChange:fe,onShapeFillStyleChange:te,onElementsOpacityChange:O,onShapeStrokeColorChange:Q,onShapeStrokeWidthChange:z,onShapeStrokeStyleChange:ne,onDrawDefaultStrokeColorChange:he,onLineStartCapChange:le,onLineEndCapChange:Be,onLineEditStart:V,onLineGeometryChange:oe,onRectangleBorderRadiusChange:de,onGroupResizeStart:ve,onGroupRotateStart:Re,onResizeStart:Pe,onRotateStart:Y,onTextCommit:He})=>{const tt=P.useRef(null),Oe=P.useRef(null),Me=P.useRef(null),[Qe,Xe]=P.useState(null),[at,pt]=P.useState(null),[pe,Ke]=P.useState(0),ie=P.useMemo(()=>F1e(L1e(Kne())),[pe]),ge=P.useRef(new Map),me=P.useRef(null),[Se,Ze]=P.useState(()=>({width:window.innerWidth,height:window.innerHeight})),[Le,be]=P.useState("default"),[ze,st]=P.useState(null),[vt,Rt]=P.useState(null),[yt,Tt]=P.useState(null),[bt,mt]=P.useState(!1),[Nt,ct]=P.useState(!1),[Ct,Vt]=P.useState(null),[_n,ar]=P.useState([]),[Wt,Ur]=P.useState(null),[At,Xt]=P.useState(null),[Wr,qr]=P.useState(null),sn=P.useRef(!1),[,Mt]=P.useState(0),[Kt,mr]=P.useState(null),{laserTrails:hn,laserNow:rr,startLaserTrail:lr,appendLaserPoint:Fr,clearActiveLaserTrail:jr}=bse(),Zr=P.useRef(null),Cn=P.useRef(null),[vi,Hn]=P.useState(!1),[Dt,we]=P.useState(!1),[lt,It]=P.useState(t.settings.drawDefaults.drawStroke),[Dr,Xr]=P.useState(null),[$r,Yr]=P.useState(null),[en,kn]=P.useState(null),[l1,_e]=P.useState(null),[Et,xt]=P.useState(null),[kr,zt]=P.useState(null),[ur,jt]=P.useState(null),xr=j=>{if(!j)return null;const _=ge.current.get(j);if(_)return _;const Ge=new window.Image;Ge.decoding="async",Ge.onload=()=>{Mt(ke=>ke+1)},Ge.onerror=()=>{Mt(ke=>ke+1)};const Ne=me.current;return Ne&&(Ge.style.cssText="position:absolute;width:1px;height:1px;",Ne.appendChild(Ge)),Ge.src=j,ge.current.set(j,Ge),Ge},Mr=P.useRef(null),vn=P.useRef(null),$n=P.useRef(null),Ei=P.useRef(null),Ni=P.useRef(null),Gn=P.useRef(null),Pi=P.useRef(!1),Mn=P.useRef(!1),Ha=P.useRef(!1),Da=P.useRef(null),Ar=use(t),Ts=Ar.length>0,mi=Ar.length===1,ii=mi?Ar[0]:null,Ri=t.elements.filter(j=>Ar.includes(j.id)),Ns=j=>{const _=j.opacity;return typeof _!="number"||!Number.isFinite(_)?100:Math.max(0,Math.min(100,_))},as=Ri.map(Ns),Gl=as.length===0?100:as.every(j=>j===as[0])?as[0]:null,mo=Ri.some(j=>mB(j)),zl=Ar.length===1&&(Ri[0]?.type==="draw"||Ri[0]?.type==="image")?Ri[0].type:"multiple",ss=Ri.some(j=>j.groupId),wo=Ri.length>0&&Ri.every(j=>j.groupId&&j.groupId===Ri[0]?.groupId)?Ri[0]?.groupId??null:null,Va=wo?t.elements.filter(j=>j.groupId===wo).map(j=>j.id):[],Zl=!!wo&&Va.length>1&&Va.length===Ar.length&&Va.every(j=>Ar.includes(j)),Ps=Ar.length===1&&!!Ri[0]?.groupId,qe=t.camera,Rs=t.settings.theme==="dark"||t.settings.theme==="system"&&document.documentElement.classList.contains("dark"),E2=Rs&&t.settings.colorScheme==="drawo",Us=P.useCallback(j=>!j||j.points.length<2?!1:(C(j.points),qr(null),$n.current=null,Ur(null),be("crosshair"),!0),[C]),Xl=j=>{const _=RT(t.elements,Ar).filter(ke=>(ke.drawMode??"draw")===j);if(_.length===0){const ke=j==="marker"?t.settings.drawDefaults.markerStroke:j==="quill"?t.settings.drawDefaults.quillStroke:t.settings.drawDefaults.drawStroke;return{drawMode:j,stroke:ke,strokeWidth:j==="marker"?t.settings.drawDefaults.markerStrokeWidth:j==="quill"?t.settings.drawDefaults.quillStrokeWidth:t.settings.drawDefaults.drawStrokeWidth}}const Ge=_[0].stroke,Ne=_[0].strokeWidth;return{drawMode:j,stroke:typeof Ge=="string"&&Ge.trim().length>0?Ge:j==="marker"?t.settings.drawDefaults.markerStroke:j==="quill"?t.settings.drawDefaults.quillStroke:t.settings.drawDefaults.drawStroke,strokeWidth:typeof Ne=="number"&&Number.isFinite(Ne)?Math.max(1,Ne):j==="marker"?t.settings.drawDefaults.markerStrokeWidth:j==="quill"?t.settings.drawDefaults.quillStrokeWidth:t.settings.drawDefaults.drawStrokeWidth}},In=j=>{const _=typeof j=="string"&&j.trim().length>0?j:t.settings.shapeDefaults.textColor;return E2?Rf(_):_},Vn=P.useCallback((j,_)=>({x:j/qe.zoom+qe.x,y:_/qe.zoom+qe.y}),[qe.x,qe.y,qe.zoom]),Ui=P.useCallback((j,_)=>({x:(j-qe.x)*qe.zoom,y:(_-qe.y)*qe.zoom}),[qe.x,qe.y,qe.zoom]),Wa=P.useCallback((j,_,Ge)=>{const Ne=Gc(_),ke=Ne.map(je=>GM(j,Ge,je)),Te=Math.max(16,...ke),Ye=Mf(Ge.fontSize),$e=Ge.fontSize+(Ne.length-1)*Ye;return{lines:Ne,lineWidths:ke,width:Te,height:$e,lineHeight:Ye}},[]),js=P.useRef(new Map),os=(j,_,Ge,Ne)=>{const ke=`${Ge}::${Ne.fontFamily}::${Ne.fontSize}::${Ne.fontWeight}::${Ne.fontStyle}`,Te=js.current.get(_);if(Te&&Te.cacheKey===ke)return Te.layout;const Ye=Wa(j,Ge,Ne);if(js.current.set(_,{cacheKey:ke,layout:Ye}),js.current.size>6e3){const $e=js.current.keys().next().value;typeof $e=="string"&&js.current.delete($e)}return Ye},gA=(j,_,Ge,Ne,ke,Te)=>{const Ye=Te?os(j,Te,_,ke):Wa(j,_,ke);return Ye.lines.forEach(($e,je)=>{const ft=Ye.lineWidths[je]??0,Ft=Uo(Ge,ft,ke.textAlign),gt=Ne+je*Ye.lineHeight;let Jt=Ft;for(const er of $e.runs){if(!er.text)continue;j.font=yc(ke,er);const or=j.measureText(er.text).width;if(j.fillText(er.text,Jt,gt),er.strikethrough){const ye=j.strokeStyle,sr=j.lineWidth;if(j.strokeStyle=j.fillStyle,j.lineWidth=Math.max(ke.fontSize*.04,.75),er.strikethrough){const nr=gt-ke.fontSize*.3;j.beginPath(),j.moveTo(Jt,nr),j.lineTo(Jt+or,nr),j.stroke()}j.strokeStyle=ye,j.lineWidth=sr}Jt+=or}}),Ye},u1=(j,_,Ge,Ne,ke,Te)=>{const Ye=Te?os(j,Te,_,ke):Wa(j,_,ke),$e=Ne-Ye.height/2;return Ye.lines.forEach((je,ft)=>{const Ft=Ye.lineWidths[ft]??0;let gt=Uo(Ge,Ft,ke.textAlign);const Jt=$e+ke.fontSize+ft*Ye.lineHeight;for(const er of je.runs){if(!er.text)continue;j.font=yc(ke,er);const or=j.measureText(er.text).width;if(j.fillText(er.text,gt,Jt),er.strikethrough){const ye=j.strokeStyle,sr=j.lineWidth;if(j.strokeStyle=j.fillStyle,j.lineWidth=Math.max(ke.fontSize*.04,.75),er.strikethrough){const nr=Jt-ke.fontSize*.3;j.beginPath(),j.moveTo(gt,nr),j.lineTo(gt+or,nr),j.stroke()}j.strokeStyle=ye,j.lineWidth=sr}gt+=or}}),Ye};P.useEffect(()=>{if(!(vi||Dt||Dr==="shape-fill-color"||Dr==="shape-stroke-color"||Dr==="text-color"))return;const _=Ne=>{const ke=Ne.target;ke&&(Zr.current?.contains(ke)||Cn.current?.contains(ke)||(Hn(!1),we(!1),Xr(null)))},Ge=Ne=>{Ne.key==="Escape"&&(Hn(!1),we(!1),Xr(null))};return window.addEventListener("pointerdown",_),window.addEventListener("keydown",Ge),()=>{window.removeEventListener("pointerdown",_),window.removeEventListener("keydown",Ge)}},[Dr,vi,Dt]);const S2=(j,_,Ge,Ne)=>{if(V1(j))return null;const{start:ke,end:Te,throughPoint:Ye}=Wp(j),$e=Math.max(7/Ne,$u/(2.3*Ne));return Math.hypot(_-ke.x,Ge-ke.y)<=$e?"start":Math.hypot(_-Te.x,Ge-Te.y)<=$e?"end":Math.hypot(_-Ye.x,Ge-Ye.y)<=$e?"control":null},Qs=(j,_,Ge,Ne)=>{if(!V1(j)||!j.points)return null;const ke=Math.max(7/Ne,$u/(2.15*Ne));let Te=null,Ye=Number.POSITIVE_INFINITY;for(let $e=0;$e<j.points.length;$e++){const je=j.points[$e],ft=Math.hypot(_-je.x,Ge-je.y);ft<=ke&&ft<Ye&&(Te=$e,Ye=ft)}return Te},F2=(j,_,Ge=!0)=>{if(j.type==="rectangle"||j.type==="circle"||j.type==="image"||j.type==="svg")return{x:j.x,y:j.y,width:j.width,height:j.height};if(j.type==="draw")return m$(j);if(j.type==="line")return zu(j);const Ne=_?Wa(_,j.text,{fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle}).width:Math.max(16,hA(j)),ke=Uo(j.x,Ne,j.textAlign),Te=p2(j),Ye={x:ke,y:j.y-j.fontSize,width:Ne,height:Te};if(!Ge)return Ye;const $e=f$/qe.zoom;return{x:Ye.x-$e,y:Ye.y-$e,width:Ye.width+$e*2,height:Ye.height+$e*2}},Ka=(j,_,Ge=!0)=>{const Ne=t.elements.find(ke=>ke.id===j);return Ne?F2(Ne,_,Ge):null},ka=(j,_,Ge,Ne)=>{const ke=$u/Ge,Te=c$/Ge,Ye=["nw","ne","se","sw"],$e=je=>{const ft=lI(_,je),Ft=vt===je,gt=ze===je;let Jt=1,er=2/Ge,fr=.1,or=1/Ge;gt?(Jt=1.35,er=8/Ge,fr=.25,or=2.5/Ge):Ft&&(Jt=1.2,er=5/Ge,fr=.18,or=1.5/Ge);const ye=ke*Jt,sr=ye/2,nr=ft.x-sr,ir=ft.y-sr;if(j.save(),j.shadowColor=`rgba(0, 0, 0, ${fr})`,j.shadowBlur=er,j.shadowOffsetX=0,j.shadowOffsetY=1.5/Ge,j.fillStyle=gt?Ne:In(t.settings.shapeDefaults.fill),j.strokeStyle=Ne,j.lineWidth=or,a1(j,nr,ir,ye,ye,Te*Jt),j.fill(),j.stroke(),(Ft||gt)&&(j.strokeStyle=Ne,j.globalAlpha=gt?.15:.08,j.lineWidth=(4+(gt?2:0))/Ge,a1(j,nr,ir,ye,ye,Te*Jt),j.stroke(),j.globalAlpha=1),Ft||gt){j.fillStyle=gt?"rgba(255, 255, 255, 0.25)":"rgba(255, 255, 255, 0.15)";const mn=ye*.5;j.beginPath(),j.arc(ft.x,ft.y,mn/2,0,Math.PI*2),j.fill()}j.restore()};for(const je of Ye)$e(je)},F1=(j,_,Ge=!0)=>{if(j.length===0)return null;const Ne=j.map(je=>Ka(je,_,Ge)).filter(je=>je!==null);if(Ne.length===0)return null;const ke=Math.min(...Ne.map(je=>je.x)),Te=Math.min(...Ne.map(je=>je.y)),Ye=Math.max(...Ne.map(je=>je.x+je.width)),$e=Math.max(...Ne.map(je=>je.y+je.height));return{x:ke,y:Te,width:Ye-ke,height:$e-Te}},qa=j=>{if(Kt)return;const _=t.elements.filter(je=>Ar.includes(je.id)&&mB(je));if(_.length===0)return;const Ge=_.map(je=>({id:je.id,bounds:F2(je)})),Ne=Math.min(...Ge.map(je=>je.bounds.x)),ke=Math.min(...Ge.map(je=>je.bounds.y)),Te=Math.max(...Ge.map(je=>je.bounds.x+je.bounds.width)),Ye=Math.max(...Ge.map(je=>je.bounds.y+je.bounds.height)),$e=new Map;for(const je of Ge){const ft=N1(je.bounds),Ft=j==="horizontal"?Ne+Te-(je.bounds.x+je.bounds.width):je.bounds.x,gt=j==="vertical"?ke+Ye-(je.bounds.y+je.bounds.height):je.bounds.y;$e.set(je.id,{fromCenterX:ft.x,fromCenterY:ft.y,toCenterX:ft.x+(Ft-je.bounds.x),toCenterY:ft.y+(gt-je.bounds.y)})}mr({axis:j,startedAt:hu(),durationMs:Sse,items:$e})};P.useEffect(()=>{if(!Kt)return;let j=0;const _=()=>{if(hu()-Kt.startedAt>=Kt.durationMs){mr(null),F(Kt.axis);return}Mt(Ne=>Ne+1),j=requestAnimationFrame(_)};return j=requestAnimationFrame(_),()=>{cancelAnimationFrame(j)}},[Kt,F]);const yo=t.elements.some(j=>j.type==="image"&&j.isAnimated===!0);P.useEffect(()=>{if(!yo)return;let j=0;const _=()=>{Mt(Ge=>Ge+1),j=requestAnimationFrame(_)};return j=requestAnimationFrame(_),()=>{cancelAnimationFrame(j)}},[yo]),P.useEffect(()=>{vn.current=Wr},[Wr]),P.useEffect(()=>{a!=="line"&&(vn.current&&Us(vn.current),$n.current&&($n.current=null,qr(null)))},[Us,a]);const D1=(()=>{if(Ar.length===0||bt||ze||yt||Et||ur!==null)return null;const j=F1(Ar,void 0,!0);if(!j)return null;const _=Ui(j.x,j.y),Ge=Ui(j.x+j.width,j.y+j.height),Ne=(_.x+Ge.x)/2,ke=Math.max(8,Math.min(_.y-42,Se.height-46));return{left:Ne,top:ke,key:Ar.join("|")}})(),CA=(j,_)=>{if(Qe)return null;const Ge=tt.current;if(!Ge)return null;const Ne=Ge.getContext("2d");if(!Ne)return null;if(Ar.length>1){const ft=F1(Ar,Ne,!0);return ft?W0(ft,j,_,qe.zoom):null}if(!ii)return null;const ke=t.elements.find(ft=>ft.id===ii);if(ke?.type==="line")return null;ke?.type==="text"&&(Ne.font=su(ke));const Te=Ka(ii,Ne);if(!Te)return null;const Ye=(ke?.rotation??0)*Math.PI/180,$e=N1(Te),je=ku(j,_,$e.x,$e.y,-Ye);return W0(Te,je.x,je.y,qe.zoom)},_s=(j,_,Ge,Ne)=>{const ke=Math.min(j.width,j.height)/2,Ye=Math.max(0,Math.min(_,ke))+Qv/Ge;return Ne==="nw"?{x:j.x+Ye,y:j.y+Ye}:Ne==="ne"?{x:j.x+j.width-Ye,y:j.y+Ye}:Ne==="se"?{x:j.x+j.width-Ye,y:j.y+j.height-Ye}:{x:j.x+Ye,y:j.y+j.height-Ye}},D2=()=>{if(!ii)return null;const j=t.elements.find(_=>_.id===ii);return!j||j.type!=="rectangle"?null:j},$a=(j,_,Ge,Ne)=>{const ke={x:j.x,y:j.y,width:j.width,height:j.height},Te=["nw","ne","se","sw"],Ye=jv/(2*Ne);for(const $e of Te){const je=_s(ke,j.borderRadius,Ne,$e);if(Math.hypot(_-je.x,Ge-je.y)<=Ye)return $e}return null},k1=()=>u9(t.elements,Ar).some(ke=>ke.type==="text")||Qe?u.jsx(QT,{scene:t,selectedIds:Ar,localeMessages:s,editor:ie,editingText:Qe,setEditingText:Xe,worldToScreen:Ui,toggleEditorMark:tn,onTextCommit:He,onTextFontFamilyChange:D,onTextFontSizeChange:U,onTextFontWeightChange:R,onTextFontStyleChange:$,onTextAlignChange:re,onTextColorChange:Z,shapeColors:e,customDrawColorPickerWrapRef:Zr,customDrawColorPickerContentRef:Cn,customDrawColorPickerColor:lt,setCustomDrawColorPickerColor:It,activeSelectId:Dr,setActiveSelectId:Xr}):cse(t.elements,Ar).length>0?u.jsx(ST,{}):PT(t.elements,Ar).length>0?u.jsx(UT,{scene:t,shapeColors:e,selectedIds:Ar,localeMessages:s,customDrawColorPickerWrapRef:Zr,customDrawColorPickerContentRef:Cn,customDrawColorPickerColor:lt,setCustomDrawColorPickerColor:It,onShapeFillColorChange:fe,onShapeFillStyleChange:te,onShapeStrokeColorChange:Q,onShapeStrokeWidthChange:z,onShapeStrokeStyleChange:ne,uniColor:Jr,activeSelectId:Dr,setActiveSelectId:Xr}):u.jsx(jT,{scene:t,strokeColors:r,selectedIds:Ar,drawingTool:a,localeMessages:s,customDrawColorPickerWrapRef:Zr,customDrawColorPickerContentRef:Cn,isCustomDrawColorPickerOpen:vi,setIsCustomDrawColorPickerOpen:Hn,customDrawColorPickerColor:lt,setCustomDrawColorPickerColor:It,onDrawStrokeWidthChange:ee,onDrawStrokeColorChange:K,onDrawDefaultStrokeColorChange:he,onLineStartCapChange:le,onLineEndCapChange:Be,uniColor:Jr,activeSelectId:Dr,setActiveSelectId:Xr}),Ga=(j,_,Ge)=>{if(Mn.current&&!Qe)return"grab";if(a&&a!=="image")return"crosshair";const Ne=D2();if(Ne){const Ye={x:Ne.x,y:Ne.y,width:Ne.width,height:Ne.height},$e=N1(Ye),je=ku(j,_,$e.x,$e.y,-Ne.rotation*Math.PI/180);if($a(Ne,je.x,je.y,qe.zoom))return"pointer"}if(i==="pan")return"grab";if(ii){const Ye=t.elements.find($e=>$e.id===ii&&$e.type==="line");if(Ye){const $e=rd(Ye,j,_);if(V1(Ye)){const je=Qs(Ye,$e.x,$e.y,qe.zoom);if(zt(je),_e(null),je!==null)return"pointer"}else{const je=S2(Ye,$e.x,$e.y,qe.zoom);if(_e(je),zt(null),je)return"pointer"}}else _e(null),zt(null)}else _e(null),zt(null);const ke=CA(j,_);return ke?(Rt(ke.mode==="resize"?ke.handle:null),ke.mode==="resize"?Au(ke.handle):lu(ke.handle)):(Rt(null),Du(t.elements,j,_)?Ge?"clone":"grab":"default")},vA=j=>{const _=Math.min(j.startX,j.currentX),Ge=Math.min(j.startY,j.currentY),Ne=Math.abs(j.currentX-j.startX),ke=Math.abs(j.currentY-j.startY);return{x:_,y:Ge,width:Ne,height:ke}},mA=j=>{const _=j.currentX-j.startX,Ge=j.currentY-j.startY;if(j.fromCenter){let Ne=Math.abs(_),ke=Math.abs(Ge);if(j.lockAspect){const Te=Math.max(Ne,ke);Ne=Te,ke=Te}return{x:j.startX-Ne,y:j.startY-ke,width:Ne*2,height:ke*2}}if(j.lockAspect){const Ne=Math.max(Math.abs(_),Math.abs(Ge));return{x:_>=0?j.startX:j.startX-Ne,y:Ge>=0?j.startY:j.startY-Ne,width:Ne,height:Ne}}return{x:Math.min(j.startX,j.currentX),y:Math.min(j.startY,j.currentY),width:Math.abs(_),height:Math.abs(Ge)}},ha=(j,_,Ge,Ne)=>{const ke=Ge-j,Te=Ne-_;if(ke===0&&Te===0)return{x:Ge,y:Ne};const Ye=Math.atan2(Te,ke),$e=Math.round(Ye/(Math.PI/4))*(Math.PI/4),je=Math.hypot(ke,Te);return{x:j+Math.cos($e)*je,y:_+Math.sin($e)*je}},wA=j=>{if(j.lockAspect){const _=ha(j.startX,j.startY,j.currentX,j.currentY);return{startX:j.startX,startY:j.startY,endX:_.x,endY:_.y}}return{startX:j.startX,startY:j.startY,endX:j.currentX,endY:j.currentY}},x=(j,_)=>j.x<_.x+_.width&&j.x+j.width>_.x&&j.y<_.y+_.height&&j.y+j.height>_.y,W=j=>{const Ge=tt.current?.getContext("2d"),Ne=vA(j),ke=new Set;for(const Te of t.elements){Te.type==="text"&&Ge&&(Ge.font=su(Te));const Ye=Ka(Te.id,Ge,!0);if(!(!Ye||!x(Ne,Ye))){if(!Te.groupId){ke.add(Te.id);continue}for(const $e of t.elements)$e.groupId===Te.groupId&&ke.add($e.id)}}return[...ke]},Ae=P.useCallback(j=>{const _=tt.current;if(!_)return;const Ge=_.getContext("2d");if(!Ge)return;if(Ke(gt=>gt+1),j.type==="text"){pt(Ic(j.text));const gt=Wa(Ge,j.text,{fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle}),Jt=Uo(j.x,gt.width,j.textAlign),er=Ui(Jt,j.y-j.fontSize);Xe({id:j.id,value:j.text,anchorX:j.x,anchorY:j.y-j.fontSize,left:er.x,top:er.y,width:gt.width*qe.zoom,height:gt.height*qe.zoom,style:{fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle,color:j.color,textAlign:j.textAlign}});return}const Ne={id:j.id,x:Gu(j,j.textAlign),y:j.y+j.height/2,text:j.text,fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle,color:j.color,textAlign:j.textAlign},ke=Wa(Ge,Ne.text,{fontFamily:Ne.fontFamily,fontSize:Ne.fontSize,fontWeight:Ne.fontWeight,fontStyle:Ne.fontStyle}),Te=Math.max(16,j.width-P8*2),Ye=Math.min(ke.width,Te),$e=Gu(j,j.textAlign),je=j.y+j.height/2-ke.height/2,ft=Uo($e,Ye,j.textAlign),Ft=Ui(ft,je);pt(Ic(j.text)),Xe({id:j.id,value:j.text,anchorX:$e,anchorY:je,left:Ft.x,top:Ft.y,width:Ye*qe.zoom,height:ke.height*qe.zoom,maxWidth:Te*qe.zoom,style:{fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle,color:j.color,textAlign:j.textAlign}})},[qe.zoom,Wa,Ui]),Ce=j=>{if(!Qe)return;const _=at?lf(at):Qe.value;He(Qe.id,_);try{ut.deselect(ie)}catch{}pt(null),Xe(null)};P.useEffect(()=>{const j=()=>{Ze({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",j),()=>{window.removeEventListener("resize",j)}},[]),P.useEffect(()=>{const j=tt.current;if(!j)return;const _=Ge=>{if(Qe){Ge.preventDefault();return}const Ne=j.getBoundingClientRect(),ke=Ge.clientX-Ne.left,Te=Ge.clientY-Ne.top;if(Ge.preventDefault(),Ge.ctrlKey||Ge.metaKey){f(ke,Te,Ge.deltaY);return}const Ye=Ge.shiftKey&&Math.abs(Ge.deltaX)<Math.abs(Ge.deltaY)?Ge.deltaY:Ge.deltaX,$e=Ge.shiftKey&&Math.abs(Ge.deltaX)<Math.abs(Ge.deltaY)?0:Ge.deltaY;c(Ye,$e)};return j.addEventListener("wheel",_,{passive:!1}),()=>{j.removeEventListener("wheel",_)}},[Qe,c,f]),P.useEffect(()=>{const j=tt.current;if(!j)return;const _=j.getContext("2d");if(!_)return;const Ge=getComputedStyle(j),Ne=Ge.getPropertyValue("--accent").trim()||"#7c5cff",ke=$v(Ge.getPropertyValue("--accent-rgb"))||$v(Ne)||"124, 92, 255",Te=`rgba(${ke}, 0.45)`,Ye=`rgba(${ke}, 0.12)`,$e=Rs?"#ff9b9b":"#ff7a7a",je=Kt?Math.min(1,Math.max(0,(hu()-Kt.startedAt)/Kt.durationMs)):null,ft=je===null?null:kse(je),Ft=(ye,sr,nr)=>{if(!Kt||ft===null)return;const ir=Kt.items.get(nr);if(!ir)return;const mn=wB(ir.fromCenterX,ir.toCenterX,ft),ji=wB(ir.fromCenterY,ir.toCenterY,ft),Zn=Kt.axis==="horizontal"?1-ft*2:1,Hi=Kt.axis==="vertical"?1-ft*2:1,za=Math.abs(Zn)<.001?Zn<0?-.001:.001:Zn,Xn=Math.abs(Hi)<.001?Hi<0?-.001:.001:Hi,Qr=N1(sr);ye.translate(mn,ji),ye.scale(za,Xn),ye.translate(-Qr.x,-Qr.y)};if(_.fillStyle=t.settings.drawDefaults.canvas,_.fillRect(0,0,j.width,j.height),_.save(),_.setTransform(qe.zoom,0,0,qe.zoom,-qe.x*qe.zoom,-qe.y*qe.zoom),t.settings.showGrid){const ye=Math.max(4,t.settings.gridSize),sr=Math.max(1,Math.ceil(h$/(ye*qe.zoom))),nr=ye*sr,ir=qe.x,mn=qe.y,ji=qe.x+j.width/qe.zoom,Zn=qe.y+j.height/qe.zoom,Hi=Math.floor(ir/nr)*nr,za=Math.floor(mn/nr)*nr,Xn=Rs?"#ffffff10":"#B3B2B370";if(t.settings.gridStyle==="squares"){_.strokeStyle=Xn,_.lineWidth=1/qe.zoom,_.beginPath();for(let Qr=Hi;Qr<=ji;Qr+=nr)_.moveTo(Qr,mn),_.lineTo(Qr,Zn);for(let Qr=za;Qr<=Zn;Qr+=nr)_.moveTo(ir,Qr),_.lineTo(ji,Qr);_.stroke()}else{const Qr=2/qe.zoom,M1=Qr/2;_.fillStyle=Xn;for(let Lt=Hi;Lt<=ji;Lt+=nr)for(let rn=za;rn<=Zn;rn+=nr)_.fillRect(Lt-M1,rn-M1,Qr,Qr)}}const gt=new Set(Ar),Jt=Ct!==null?new Set(_n):null,er=Math.max(160/qe.zoom,48),fr={x:qe.x-er,y:qe.y-er,width:j.width/qe.zoom+er*2,height:j.height/qe.zoom+er*2},or=ye=>!(ye.x+ye.width<fr.x||ye.x>fr.x+fr.width||ye.y+ye.height<fr.y||ye.y>fr.y+fr.height);for(const ye of t.elements){const sr=gt.has(ye.id),nr=sr&&(!Zl||Ar.length===1),ir=Ct!==null&&Jt?.has(ye.id)&&!sr,mn=Ar.length>1,ji=ye.rotation*Math.PI/180,Zn=Ns(ye)/100;if(!sr&&!ir&&Qe?.id!==ye.id){let Lt=null;if(ye.type==="draw"||ye.type==="image"||ye.type==="rectangle"||ye.type==="circle"?Lt={x:ye.x,y:ye.y,width:ye.width,height:ye.height}:ye.type==="line"&&(Lt=zu(ye)),Lt&&!or(Lt))continue}if(ye.type==="draw"){const Lt=ye.drawMode??"draw",rn={x:ye.x,y:ye.y,width:ye.width,height:ye.height},on={x:rn.x-ye.x,y:rn.y-ye.y,width:rn.width,height:rn.height},wi=N1(rn);if(_.save(),Ft(_,rn,ye.id),_.translate(wi.x,wi.y),_.rotate(ji),_.translate(-wi.x,-wi.y),_.translate(ye.x,ye.y),ye.points.length>0){const Lr=j8(Lt,Rs),Bo=_.globalCompositeOperation,Ma=_.globalAlpha;_.globalCompositeOperation=Lr.compositeOperation,_.globalAlpha*=Lr.opacity*Zn;const yi=U8(ye.strokeWidth);_.strokeStyle=In(ye.stroke),_.fillStyle=In(ye.stroke),_.lineWidth=yi,_.lineJoin="round",_.lineCap=Q8();const Si=ye.points;Si.length===1?Lt==="marker"?nl(_,Si,yi):Lt==="quill"?il(_,Si,yi,t.settings.quillDrawOptimizations):(_.beginPath(),_.arc(Si[0].x,Si[0].y,_.lineWidth/2,0,Math.PI*2),_.fillStyle=In(ye.stroke),_.fill()):Si.length>1&&(Lt==="marker"?nl(_,Si,yi):Lt==="quill"?il(_,Si,yi,t.settings.quillDrawOptimizations):(_.beginPath(),Uf(_,Si),_.stroke())),_.globalCompositeOperation=Bo,_.globalAlpha=Ma}nr?(_.strokeStyle=mn?Te:Ne,_.lineWidth=1/qe.zoom,_.strokeRect(on.x,on.y,on.width,on.height),mi&&ka(_,on,qe.zoom,Ne)):ir&&(_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(on.x,on.y,on.width,on.height)),_.restore();continue}if(ye.type==="image"){const Lt=ye,rn={x:Lt.x,y:Lt.y,width:Lt.width,height:Lt.height},on=N1(rn),wi=Lt.src?xr(Lt.src):null,Lr=Math.min(16/qe.zoom,Math.min(Lt.width,Lt.height)/6);_.save(),Ft(_,rn,Lt.id),_.translate(on.x,on.y),_.rotate(ji),_.translate(-on.x,-on.y);const Bo=_.globalAlpha;_.globalAlpha*=Zn,(Lt.flipX||Lt.flipY)&&(_.translate(on.x,on.y),_.scale(Lt.flipX?-1:1,Lt.flipY?-1:1),_.translate(-on.x,-on.y)),_.shadowColor="rgba(15, 23, 42, 0.14)",_.shadowBlur=18/qe.zoom,_.shadowOffsetY=6/qe.zoom,_.fillStyle=In(t.settings.shapeDefaults.fill),a1(_,Lt.x,Lt.y,Lt.width,Lt.height,Lr),_.fill(),_.save(),a1(_,Lt.x,Lt.y,Lt.width,Lt.height,Lr),_.clip(),wi&&wi.complete&&wi.naturalWidth>0&&wi.naturalHeight>0?_.drawImage(wi,Lt.x,Lt.y,Lt.width,Lt.height):(_.fillStyle=In("#e6e7e8"),_.fillRect(Lt.x,Lt.y,Lt.width,Lt.height)),_.restore(),_.shadowColor="transparent",_.strokeStyle=In("rgba(15, 23, 42, 0.08)"),_.lineWidth=1/qe.zoom,a1(_,Lt.x,Lt.y,Lt.width,Lt.height,Lr),_.stroke(),_.globalAlpha=Bo,nr?(_.strokeStyle=mn?Te:Ne,_.lineWidth=1/qe.zoom,_.strokeRect(Lt.x,Lt.y,Lt.width,Lt.height)):ir&&(_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(Lt.x,Lt.y,Lt.width,Lt.height)),nr&&mi&&ka(_,rn,qe.zoom,Ne),_.restore();continue}if(ye.type==="rectangle"||ye.type==="circle"){const Lt={x:ye.x,y:ye.y,width:ye.width,height:ye.height},rn=N1(Lt),on=ye.type==="rectangle"?Math.max(0,Math.min(ye.borderRadius,Math.min(ye.width,ye.height)/2)):0;_.save(),Ft(_,Lt,ye.id),_.translate(rn.x,rn.y),_.rotate(ji),_.translate(-rn.x,-rn.y);const wi=_.globalAlpha;if(_.globalAlpha*=Zn,Ise(_,ye,on,In),Ose(_,ye,on,In),Qe?.id!==ye.id&&ye.text.trim().length>0){const Lr={id:`${ye.id}-shape-text`,x:Gu(ye,ye.textAlign),y:ye.y+ye.height/2,text:ye.text,fontFamily:ye.fontFamily,fontSize:ye.fontSize,fontWeight:ye.fontWeight,fontStyle:ye.fontStyle,color:ye.color,textAlign:ye.textAlign};_.save(),ye.type==="circle"?(_.beginPath(),_.ellipse(ye.x+ye.width/2,ye.y+ye.height/2,ye.width/2,ye.height/2,0,0,Math.PI*2),_.clip()):(a1(_,ye.x,ye.y,ye.width,ye.height,on),_.clip()),_.font=su(Lr),_.fillStyle=In(Lr.color),_.textAlign="left",_.textBaseline="alphabetic",u1(_,Lr.text,Lr.x,ye.y+ye.height/2,{fontFamily:Lr.fontFamily,fontSize:Lr.fontSize,fontWeight:Lr.fontWeight,fontStyle:Lr.fontStyle,textAlign:Lr.textAlign},`shape:${ye.id}`),_.restore()}if(_.globalAlpha=wi,nr?(_.strokeStyle=mn?Te:Ne,_.lineWidth=1/qe.zoom,_.strokeRect(ye.x,ye.y,ye.width,ye.height)):ir&&(_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(ye.x,ye.y,ye.width,ye.height)),nr&&mi&&(ka(_,Lt,qe.zoom,Ne),ye.type==="rectangle")){const Lr=Ei.current;if(Lr&&$M(ye,Lr.x,Lr.y)){const Ma=["nw","ne","se","sw"],yi=jv/(2*qe.zoom);for(const Si of Ma){const As=_s(Lt,ye.borderRadius,qe.zoom,Si);_.fillStyle=Ne,_.beginPath(),_.arc(As.x,As.y,yi,0,Math.PI*2),_.fill(),_.strokeStyle=In(t.settings.shapeDefaults.fill),_.lineWidth=1/qe.zoom,_.beginPath(),_.arc(As.x,As.y,yi,0,Math.PI*2),_.stroke()}}}_.restore();continue}if(ye.type==="line"){const Lt=ye,rn=zu(Lt);_.save(),Ft(_,rn,Lt.id),cI({ctx:_,lineElement:Lt,elementOpacity:Zn,zoom:qe.zoom,accentColor:Ne,accentSelectionColor:Te,toThemeColor:In,shouldShowElementSelection:nr,isMultiSelection:mn,isMarqueePreview:ir,canTransformSelection:mi,hoveredLineHandle:l1,activeLineHandle:Et,hoveredLinePointIndex:kr,activeLinePointIndex:ur}),_.restore();continue}if(Qe?.id===ye.id||ye.type==="svg")continue;const Hi=os(_,`text:${ye.id}`,ye.text,{fontFamily:ye.fontFamily,fontSize:ye.fontSize,fontWeight:ye.fontWeight,fontStyle:ye.fontStyle}),za=Hi.width,Xn={x:Uo(ye.x,za,ye.textAlign),y:ye.y-ye.fontSize,width:za,height:Hi.height},Qr=N1(Xn);_.save(),_.translate(Qr.x,Qr.y),_.rotate(ji),_.translate(-Qr.x,-Qr.y);const M1=_.globalAlpha;if(_.globalAlpha*=Zn,_.fillStyle=In(ye.color),_.textAlign="left",_.textBaseline="alphabetic",gA(_,ye.text,ye.x,ye.y,{fontFamily:ye.fontFamily,fontSize:ye.fontSize,fontWeight:ye.fontWeight,fontStyle:ye.fontStyle,textAlign:ye.textAlign},`text:${ye.id}`),_.globalAlpha=M1,nr){const Lt=Ka(ye.id,_,!0);if(!Lt){_.restore();continue}_.strokeStyle=Ar.length>1?Te:Ne,_.lineWidth=1/qe.zoom,_.strokeRect(Lt.x,Lt.y,Lt.width,Lt.height),mi&&ka(_,Lt,qe.zoom,Ne)}else if(ir){const Lt=Ka(ye.id,_,!0);Lt&&(_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(Lt.x,Lt.y,Lt.width,Lt.height))}_.restore()}if(Ar.length>1&&!Kt){const ye=F1(Ar,_,!0);ye&&(_.save(),_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.setLineDash([6/qe.zoom,4/qe.zoom]),_.strokeRect(ye.x,ye.y,ye.width,ye.height),_.setLineDash([]),ka(_,ye,qe.zoom,Ne),_.restore())}if(Ps&&!Kt){const ye=F1(Va,_,!0);ye&&(_.save(),_.strokeStyle=Te,_.lineWidth=1/qe.zoom,_.setLineDash([6/qe.zoom,4/qe.zoom]),_.strokeRect(ye.x,ye.y,ye.width,ye.height),_.setLineDash([]),_.restore())}if(Mse(_,n,qe.zoom,$e),Ct){const ye=vA(Ct),sr=8/qe.zoom;_.fillStyle=Ye,_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,a1(_,ye.x,ye.y,ye.width,ye.height,sr),_.fill(),_.stroke()}if(Wt){const ye=mA(Wt);if(Wt.type==="rectangle")_.fillStyle=In(t.settings.shapeDefaults.fill),_.fillRect(ye.x,ye.y,ye.width,ye.height),_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(ye.x,ye.y,ye.width,ye.height);else if(Wt.type==="circle"){const sr=ye.x+ye.width/2,nr=ye.y+ye.height/2;_.fillStyle=In(t.settings.shapeDefaults.fill),_.beginPath(),_.ellipse(sr,nr,ye.width/2,ye.height/2,0,0,Math.PI*2),_.fill(),_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.beginPath(),_.ellipse(sr,nr,ye.width/2,ye.height/2,0,0,Math.PI*2),_.stroke()}else if(Wt.type==="line"){const sr=wA(Wt);_.strokeStyle=Ne,_.lineWidth=2/qe.zoom,_.lineCap="round",_.lineJoin="round",_.beginPath(),_.moveTo(sr.startX,sr.startY),_.lineTo(sr.endX,sr.endY),_.stroke()}else{const sr=Math.max(10,Math.round(ye.height)),nr={x:ye.x,y:ye.y+sr,text:s.canvas.newText,fontFamily:"Shantell Sans, sans-serif",fontSize:sr,fontWeight:"200",fontStyle:"normal",color:t.settings.shapeDefaults.textColor};_.font=su(nr),_.fillStyle=In(nr.color),_.textAlign="left",_.textBaseline="alphabetic",_.fillText(nr.text,nr.x,nr.y)}}if(Wr&&Wr.points.length>0&&Wr.preview){const ye=[...Wr.points,Wr.preview];if(_.strokeStyle=Ne,_.lineWidth=2/qe.zoom,_.lineCap="round",_.lineJoin="round",_.beginPath(),uI(_,ye),_.stroke(),ye.length>1){const sr=Math.max(_.lineWidth*.52,1/qe.zoom);_.fillStyle=Ne;for(let nr=0;nr<ye.length;nr++){const ir=ye[nr];_.beginPath(),_.arc(ir.x,ir.y,sr,0,Math.PI*2),_.fill()}}}if(At&&At.points.length>0){const ye=j8(At.drawMode,Rs),sr=_.globalCompositeOperation,nr=_.globalAlpha;_.globalCompositeOperation=ye.compositeOperation,_.globalAlpha*=ye.opacity,_.save();const ir=U8(At.strokeWidth);_.strokeStyle=In(At.stroke),_.fillStyle=In(At.stroke),_.lineWidth=ir,_.lineJoin="round",_.lineCap=Q8(),At.points.length===1?At.drawMode==="marker"?nl(_,At.points,ir):At.drawMode==="quill"?il(_,At.points,ir,t.settings.quillDrawOptimizations):(_.beginPath(),_.arc(At.points[0].x,At.points[0].y,_.lineWidth/2,0,Math.PI*2),_.fillStyle=In(At.stroke),_.fill()):At.drawMode==="marker"?nl(_,At.points,ir):At.drawMode==="quill"?il(_,At.points,ir,t.settings.quillDrawOptimizations):(_.beginPath(),Uf(_,At.points),_.stroke()),_.restore(),_.globalCompositeOperation=sr,_.globalAlpha=nr}if(hn.length>0){_.save();const ye=t.settings.laserSettings;_.fillStyle=ye.color;for(const sr of hn)sr.points.length!==0&&mse(_,sr.points,rr,qe,ye);_.restore()}_.restore()}),P.useEffect(()=>{if(!Qe){Me.current=null;return}Me.current!==Qe.id&&(Me.current=Qe.id,requestAnimationFrame(()=>{try{Bt.focus(ie);const j=G.end(ie,[]);ut.select(ie,j)}catch(j){console.warn("Failed to focus text editor:",j)}}))},[ie,Qe]),P.useEffect(()=>{const j=_=>{if(_.target instanceof HTMLElement){const ke=_.target.tagName.toLowerCase();if(_.target.isContentEditable||ke==="input"||ke==="textarea"||ke==="select")return}if(_.key==="Escape"&&(vn.current||$n.current)){_.preventDefault(),$n.current=null,qr(null),Ur(null);return}if((_.key===" "||_.code==="Space")&&_.target instanceof HTMLElement&&!_.target.isContentEditable&&_.target.tagName.toLowerCase()!=="input"&&_.target.tagName.toLowerCase()!=="textarea"&&(Mn.current=!0),_.key==="Enter"&&!Qe&&Us(vn.current)){_.preventDefault();return}const Ge=_.key.toLowerCase();if(_.shiftKey&&!_.ctrlKey&&!_.metaKey&&!_.altKey&&!Qe){if(Ge==="h"){if(!mo)return;_.preventDefault(),qa("horizontal");return}if(Ge==="v"){if(!mo)return;_.preventDefault(),qa("vertical");return}}if(_.ctrlKey||_.metaKey){const ke=Ge;if(ke==="b"||ke==="i"){if(Qe)return;const Te=u9(t.elements,Ar);if(Te.length===0)return;if(_.preventDefault(),ke==="b"){const $e=Te.every(je=>je.fontWeight==="700"||je.fontWeight==="800"||je.fontWeight==="900"||je.fontWeight==="bold");R(Te.map(je=>je.id),$e?"200":"700");return}const Ye=Te.every($e=>$e.fontStyle==="italic");$(Te.map($e=>$e.id),Ye?"normal":"italic");return}}if(_.key!=="Enter"||Qe)return;const Ne=t.elements.find(ke=>ke.id===ii);!Ne||Ne.type!=="text"&&Ne.type!=="rectangle"&&Ne.type!=="circle"||(_.preventDefault(),Ae(Ne))};return window.addEventListener("keydown",j),()=>{window.removeEventListener("keydown",j)}},[Ae,mo,qe.zoom,Us,qa,Wa,Ui,t.elements,ii,Ar,Qe,R,$]),P.useEffect(()=>{const j=_=>{(_.key===" "||_.code==="Space")&&(Mn.current=!1,Ha.current=!1)};return window.addEventListener("keyup",j),()=>{window.removeEventListener("keyup",j)}},[]),P.useEffect(()=>{if(!Qe)return;const j=24,_=1,Ge=Qe.left+Qe.width-Se.width,Ne=-Qe.left,ke=Qe.top+Qe.height-Se.height,Te=-Qe.top;let Ye=0,$e=0;Ge>-j+_?Ye=Ge+j:Ne>-j+_&&(Ye=-(Ne+j)),ke>-j+_?$e=ke+j:Te>-j+_&&($e=-(Te+j)),Math.abs(Ye)<=_&&(Ye=0),Math.abs($e)<=_&&($e=0),(Ye!==0||$e!==0)&&c(Ye,$e)},[qe.zoom,Se.height,Se.width,Qe,c]),P.useEffect(()=>{const j=()=>{sn.current||(sn.current=!0,setTimeout(()=>{Mt(_=>_+1)},0))};return window.__FONTS_LOADED__&&(sn.current=!0),window.addEventListener("fontsLoaded",j),()=>{window.removeEventListener("fontsLoaded",j)}},[]);const Ie=j=>{Array.from(j.dataTransfer.items).some(_=>_.kind==="file")&&(j.preventDefault(),j.dataTransfer.dropEffect="copy")},Je=j=>{const _=Array.from(j.dataTransfer.files).filter($e=>$e.type.startsWith("image/"));if(_.length===0)return;j.preventDefault();const Ge=tt.current;if(!Ge)return;const Ne=Ge.getBoundingClientRect(),ke=j.clientX-Ne.left,Te=j.clientY-Ne.top,Ye=Vn(ke,Te);w(_,Ye.x,Ye.y)},ot=j=>{const _=tt.current;if(!_)return;const Ge=_.getBoundingClientRect(),Ne=j.clientX-Ge.left,ke=j.clientY-Ge.top,Te=Vn(Ne,ke);if(Ei.current=Te,Da.current=null,j.button===1){j.preventDefault(),Pi.current=!0,Gn.current={screenX:Ne,screenY:ke},Mr.current=null,xt(null),jt(null),Tt(null),st(null),Vt(null),mt(!1),ct(!1),be("grabbing"),_.setPointerCapture(j.pointerId);return}if(i==="pan"){Gn.current={screenX:Ne,screenY:ke},Mr.current=null,xt(null),jt(null),Tt(null),st(null),Vt(null),mt(!1),ct(!1),be("grabbing"),_.setPointerCapture(j.pointerId);return}if(Mn.current&&!Qe&&!a&&!Pi.current){Ha.current=!0,Gn.current={screenX:Ne,screenY:ke},Mr.current=null,xt(null),jt(null),Tt(null),st(null),Vt(null),mt(!1),ct(!1),be("grabbing"),_.setPointerCapture(j.pointerId);return}if(a&&a!=="image"){if(Qe&&Ce(),Mr.current=null,xt(null),jt(null),a==="laser")lr(Te);else if(a==="draw"||a==="marker"||a==="quill"){const Ft=hu(),gt=a,Jt=Xl(gt);Xt({points:[{...Te,t:Ft}],stroke:Jt.stroke,strokeWidth:Jt.strokeWidth,drawMode:gt,isLine:j.shiftKey})}else if(a==="line"){const Ft=vn.current;Ft&&Ft.points.length>0?$n.current=null:$n.current={screenX:Ne,screenY:ke,startX:Te.x,startY:Te.y},Ur(null)}else Ur({type:a,startX:Te.x,startY:Te.y,currentX:Te.x,currentY:Te.y,fromCenter:j.altKey,lockAspect:j.shiftKey});be(a==="laser"?"laser":a==="draw"?"pencil":a==="quill"?"quill":a==="marker"?"marker":"crosshair"),Tt(null),st(null),Vt(null),mt(!1),ct(!1),_.setPointerCapture(j.pointerId);return}if(Ar.length>1&&!Qe){const Ft=_.getContext("2d");if(Ft){const gt=F1(Ar,Ft,!0);if(gt){const Jt=W0(gt,Te.x,Te.y,qe.zoom);if(Jt?.mode==="resize"){ve(Jt.handle,Te.x,Te.y,gt,Ar),st(Jt.handle),Tt(null),mt(!1),ct(!1),Vt(null),ar([]),be(Au(Jt.handle)),_.setPointerCapture(j.pointerId);return}const er=R8(gt,Te.x,Te.y,qe.zoom);if(er?.mode==="rotate"){const fr=N1(gt);Re(fr.x,fr.y,Te.x,Te.y,Ar),Tt(er.handle),st(null),mt(!1),ct(!1),Vt(null),ar([]),be(lu(er.handle)),_.setPointerCapture(j.pointerId);return}}}}if(ii&&!Qe){const Ft=_.getContext("2d");if(Ft){const gt=t.elements.find(er=>er.id===ii);if(gt?.type==="line"){const er=rd(gt,Te.x,Te.y);if(V1(gt)){const or=Qs(gt,er.x,er.y,qe.zoom);if(or!==null){V(),Mr.current={id:gt.id,handle:"point",pointIndex:or,startLine:{x:gt.x,y:gt.y,width:gt.width,height:gt.height,controlPoint:null,points:gt.points?[...gt.points]:[]}},jt(or),zt(or),xt(null),_e(null),Tt(null),st(null),mt(!1),ct(!1),Vt(null),be("pointer"),_.setPointerCapture(j.pointerId);return}}const fr=S2(gt,er.x,er.y,qe.zoom);if(fr){V(),Mr.current={id:gt.id,handle:fr,startLine:{x:gt.x,y:gt.y,width:gt.width,height:gt.height,controlPoint:gt.controlPoint??null,points:gt.points?[...gt.points]:void 0}},xt(fr),_e(fr),jt(null),zt(null),Tt(null),st(null),mt(!1),ct(!1),Vt(null),be("pointer"),_.setPointerCapture(j.pointerId);return}}gt?.type==="text"&&(Ft.font=su(gt));const Jt=gt?.type==="line"?null:Ka(ii,Ft,!0);if(Jt){const er=t.elements.find(ir=>ir.id===ii),fr=(er?.rotation??0)*Math.PI/180,or=N1(Jt),ye=ku(Te.x,Te.y,or.x,or.y,-fr);if(er?.type==="rectangle"&&$a(er,ye.x,ye.y,qe.zoom)){const ir=$a(er,ye.x,ye.y,qe.zoom);if(!ir)return;Yr(er.id),kn(ir),Tt(null),st(null),mt(!1),ct(!1),Vt(null),be("pointer"),_.setPointerCapture(j.pointerId);return}const sr=W0(Jt,ye.x,ye.y,qe.zoom);if(sr?.mode==="resize"){const ir=Ka(ii,Ft,!1);Pe(ii,sr.handle,Te.x,Te.y,ir??Jt),st(sr.handle),Tt(null),mt(!1),ct(!1),be(Au(sr.handle)),_.setPointerCapture(j.pointerId);return}const nr=R8(Jt,ye.x,ye.y,qe.zoom);if(nr?.mode==="rotate"){Y(ii,or.x,or.y,Te.x,Te.y),Tt(nr.handle),st(null),mt(!1),ct(!1),be(lu(nr.handle)),_.setPointerCapture(j.pointerId);return}}}}Qe&&Ce();const Ye=Du(t.elements,Te.x,Te.y);if(!Ye){Tt(null),st(null),mt(!1),ct(!1),Vt({startX:Te.x,startY:Te.y,currentX:Te.x,currentY:Te.y}),be("default"),_.setPointerCapture(j.pointerId);return}j.shiftKey&&!j.altKey&&Ar.length>1&&Ar.includes(Ye)&&(Da.current={hitId:Ye,selectedIds:[...Ar],startScreenX:Ne,startScreenY:ke,shouldDeselect:!0});const $e=!!Ye,je=t.elements.find(Ft=>Ft.id===Ye),ft=$e&&j.altKey&&!je?.groupId;Tt(null),st(null),Vt(null),mt($e),ct(ft),be($e?ft?"clone":"grabbing":"default"),o(Te.x,Te.y,j.altKey,j.shiftKey,j.ctrlKey||j.metaKey),_.setPointerCapture(j.pointerId)},qt=j=>{const _=tt.current;if(!_)return;const Ge=_.getBoundingClientRect(),Ne=j.clientX-Ge.left,ke=j.clientY-Ge.top,Te=Vn(Ne,ke);Ei.current=Te;const Ye=Da.current;if(Ye?.shouldDeselect&&Math.hypot(Ne-Ye.startScreenX,ke-Ye.startScreenY)>Fse&&(Da.current={...Ye,shouldDeselect:!1}),Pi.current){const je=Gn.current;if(je){const ft=Ne-je.screenX,Ft=ke-je.screenY;(ft!==0||Ft!==0)&&(c(-ft,-Ft),Gn.current={screenX:Ne,screenY:ke})}be("grabbing");return}if(Ha.current){const je=Gn.current;if(je){const ft=Ne-je.screenX,Ft=ke-je.screenY;(ft!==0||Ft!==0)&&(c(-ft,-Ft),Gn.current={screenX:Ne,screenY:ke})}be("grabbing");return}if(i==="pan"){const je=Gn.current;if(je){const ft=Ne-je.screenX,Ft=ke-je.screenY;(ft!==0||Ft!==0)&&(c(-ft,-Ft),Gn.current={screenX:Ne,screenY:ke}),be("grabbing")}else be("grab");return}if(a){if(a==="line"){const je=vn.current;if(je&&je.points.length>0){const Ft=je.points[je.points.length-1],gt=j.shiftKey?ha(Ft.x,Ft.y,Te.x,Te.y):Te;qr({points:je.points,preview:gt}),be("crosshair");return}const ft=$n.current;ft&&Math.hypot(Ne-ft.screenX,ke-ft.screenY)>=Dse&&(Ur({type:"line",startX:ft.startX,startY:ft.startY,currentX:Te.x,currentY:Te.y,fromCenter:!1,lockAspect:j.shiftKey}),$n.current=null)}if(a==="laser")Fr(Te,qe.zoom);else if(a==="draw"||a==="marker"||a==="quill"){const je=hu();Xt(ft=>{if(!ft)return ft;const Ft=j.shiftKey;let gt={...Te,t:je};if(Ft&&ft.points.length>0){const fr=ft.points[0],or=Math.abs(Te.x-fr.x),ye=Math.abs(Te.y-fr.y);or>ye?gt={x:Te.x,y:fr.y,t:je}:gt={x:fr.x,y:Te.y,t:je};const sr=ft.points.length>1?ft.points[1]:null,nr=.5/qe.zoom;return sr&&Math.hypot(gt.x-sr.x,gt.y-sr.y)<nr?ft:{...ft,isLine:!0,points:[fr,gt]}}typeof gt.t!="number"&&(gt={...gt,t:je});const Jt=ft.points[ft.points.length-1],er=2/qe.zoom;return Jt&&Math.hypot(gt.x-Jt.x,gt.y-Jt.y)<er?ft:{...ft,isLine:!1,points:[...ft.points,gt]}})}else Wt&&Ur(je=>{if(!je)return je;if(je.type==="line"){const ft=j.shiftKey?ha(je.startX,je.startY,Te.x,Te.y):Te;return{...je,currentX:ft.x,currentY:ft.y,lockAspect:j.shiftKey}}return{...je,currentX:Te.x,currentY:Te.y,fromCenter:j.altKey,lockAspect:j.shiftKey}});be(a==="laser"?"laser":a==="draw"?"pencil":a==="quill"?"quill":a==="marker"?"marker":"crosshair");return}const $e=Mr.current;if($e){const je=t.elements.find(ft=>ft.id===$e.id&&ft.type==="line");if(je){const ft=rd(je,Te.x,Te.y),Ft={x:$e.startLine.x,y:$e.startLine.y},gt={x:$e.startLine.x+$e.startLine.width,y:$e.startLine.y+$e.startLine.height};let Jt=Ft,er=gt,fr=$e.startLine.controlPoint;if($e.handle==="start"||$e.handle==="point")Jt=j.shiftKey?ha(gt.x,gt.y,ft.x,ft.y):ft;else if($e.handle==="end")er=j.shiftKey?ha(Ft.x,Ft.y,ft.x,ft.y):ft;else if($e.handle==="control"){const ir=(Ft.x+gt.x)/2,mn=(Ft.y+gt.y)/2;fr=j.shiftKey?ha(ir,mn,ft.x,ft.y):{x:ft.x,y:ft.y}}const or=ir=>t.settings.snapToGrid?Math.round(ir/t.settings.gridSize)*t.settings.gridSize:ir,ye={x:or(Jt.x),y:or(Jt.y)},sr={x:or(er.x),y:or(er.y)},nr=fr?{x:or(fr.x),y:or(fr.y)}:null;if($e.handle==="point"&&typeof $e.pointIndex=="number"&&$e.startLine.points&&$e.startLine.points.length>$e.pointIndex){const ir=$e.startLine.points.map((ji,Zn)=>Zn===$e.pointIndex?{x:ye.x,y:ye.y}:ji),mn=El(ir);oe($e.id,{x:mn.x,y:mn.y,width:mn.width,height:mn.height,controlPoint:null,points:ir})}else oe($e.id,{x:ye.x,y:ye.y,width:sr.x-ye.x,height:sr.y-ye.y,controlPoint:nr})}be("pointer");return}if($r){const je=t.elements.find(ft=>ft.id===$r);if(je&&je.type==="rectangle"&&en){const ft={x:je.x,y:je.y,width:je.width,height:je.height},Ft=N1(ft),gt=ku(Te.x,Te.y,Ft.x,Ft.y,-je.rotation*Math.PI/180),Jt=Qv/qe.zoom,er=je.x+je.width,fr=je.y+je.height;let or;en==="nw"?or=Math.min(gt.x-je.x-Jt,gt.y-je.y-Jt):en==="ne"?or=Math.min(er-gt.x-Jt,gt.y-je.y-Jt):en==="se"?or=Math.min(er-gt.x-Jt,fr-gt.y-Jt):or=Math.min(gt.x-je.x-Jt,fr-gt.y-Jt);const ye=Math.max(0,Math.min(or,Math.min(je.width,je.height)/2));de([je.id],ye)}be("pointer");return}if(Ct){Vt(je=>{if(!je)return je;const ft={...je,currentX:Te.x,currentY:Te.y};return ar(W(ft)),ft}),be("default");return}if(A(Te.x,Te.y,j.shiftKey,j.altKey),yt){be(lu(yt));return}if(ze){be(Au(ze));return}if(bt){be(Nt?"clone":"grabbing");return}be(Ga(Te.x,Te.y,j.altKey))},Qt=j=>{const _=tt.current;_?.hasPointerCapture(j.pointerId)&&_.releasePointerCapture(j.pointerId);const Ge=Da.current;if(Da.current=null,i==="pan"){Gn.current=null,Yr(null),kn(null),be("grab");return}if(Pi.current){Pi.current=!1,Gn.current=null,Yr(null),kn(null);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);Ei.current=$e,be(Ga($e.x,$e.y,j.altKey))}else be("default");return}if(Ha.current){Ha.current=!1,Gn.current=null,Yr(null),kn(null);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);Ei.current=$e,be(Ga($e.x,$e.y,j.altKey))}else be("default");return}if(a){if(a==="line"){const ke=$n.current;if(ke){$n.current=null,Ur(null),qr({points:[{x:ke.startX,y:ke.startY}],preview:{x:ke.startX,y:ke.startY}}),Yr(null),kn(null),be("crosshair");return}const Te=vn.current;if(Te&&Te.points.length>0){const Ye=_?.getBoundingClientRect();if(Ye){const $e=j.clientX-Ye.left,je=j.clientY-Ye.top,ft=Vn($e,je),Ft=Te.points[Te.points.length-1],gt=j.shiftKey?ha(Ft.x,Ft.y,ft.x,ft.y):ft;Math.hypot(gt.x-Ft.x,gt.y-Ft.y)>=1?qr({points:[...Te.points,gt],preview:gt}):qr({points:Te.points,preview:gt})}Yr(null),kn(null),be("crosshair");return}}if(a==="laser")jr();else if(a==="draw"||a==="marker"||a==="quill")At&&At.points.length>=1&&h(At.points,{drawMode:At.drawMode,stroke:At.stroke}),Xt(null);else if(Wt){if(Wt.type==="line"){const ke=wA(Wt);Math.hypot(ke.endX-ke.startX,ke.endY-ke.startY)>=1&&d("line",ke.startX,ke.startY,s,{x:ke.startX,y:ke.startY,width:ke.endX-ke.startX,height:ke.endY-ke.startY})}else{const ke=mA(Wt);d(Wt.type,ke.x,ke.y,s,ke)}Ur(null),p()}Yr(null),kn(null),be(a==="laser"?"laser":a==="draw"?"pencil":a==="quill"?"quill":a==="marker"?"marker":"crosshair");return}if(Mr.current){l(),Mr.current=null,xt(null),jt(null);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);Ei.current=$e,be(Ga($e.x,$e.y,j.altKey))}else be("default");return}if($r){Yr(null),kn(null);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);be(Ga($e.x,$e.y,j.altKey))}else be("default");return}if(Ct){const ke=W(Ct),Te=j.shiftKey?Array.from(new Set([...Ar,...ke])):ke;m(Te),Vt(null),ar([]),Tt(null),st(null),mt(!1),ct(!1);const Ye=_?.getBoundingClientRect();if(Ye){const $e=j.clientX-Ye.left,je=j.clientY-Ye.top,ft=Vn($e,je);Ei.current=ft,be(Ga(ft.x,ft.y,j.altKey))}else be("default");return}if(Ge?.shouldDeselect&&!j.altKey){l(),m(Ge.selectedIds.filter(Te=>Te!==Ge.hitId)),Tt(null),st(null),Rt(null),Mr.current=null,xt(null),jt(null),_e(null),zt(null),mt(!1),ct(!1);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);Ei.current=$e,be(Ga($e.x,$e.y,j.altKey))}else be("default");return}l(),Tt(null),st(null),Rt(null),Mr.current=null,xt(null),jt(null),_e(null),zt(null),mt(!1),ct(!1);const Ne=_?.getBoundingClientRect();if(Ne){const ke=j.clientX-Ne.left,Te=j.clientY-Ne.top,Ye=Vn(ke,Te);Ei.current=Ye,be(Ga(Ye.x,Ye.y,j.altKey))}else be("default")},cr=()=>{if(Ei.current=null,Pi.current){be("grabbing");return}if(i==="pan"){be(Gn.current?"grabbing":"grab");return}if(a){a==="laser"?(jr(),be("laser")):be(a==="draw"?"pencil":a==="quill"?"quill":a==="marker"?"marker":"crosshair");return}if(Mr.current||Et||ur!==null){be("pointer");return}if($r){be("pointer");return}if(Ct){be("default");return}if(Rt(null),_e(null),zt(null),yt){be(lu(yt));return}if(ze){be(Au(ze));return}if(bt){be(Nt?"clone":"grabbing");return}be("default")},dr=j=>{if(a==="line"&&Us(vn.current)){j.preventDefault();return}if(i==="pan"||a)return;const _=tt.current;if(!_)return;const Ge=_.getBoundingClientRect(),Ne=j.clientX-Ge.left,ke=j.clientY-Ge.top,Te=Vn(Ne,ke),Ye=Du(t.elements,Te.x,Te.y);if(!Ye)return;const $e=t.elements.find(je=>je.id===Ye);if($e?.groupId&&Ar.length>1&&Ar.includes($e.id)){m([$e.id]);return}if(!(!$e||$e.type!=="text"&&$e.type!=="rectangle"&&$e.type!=="circle")){if(Qe&&Qe.id!==$e.id){Ce(),requestAnimationFrame(()=>{Ae($e)});return}Ae($e)}},Or=j=>{Xe(_=>{if(!_)return _;const Ne=tt.current?.getContext("2d");if(!Ne)return _.value===j?_:{..._,value:j};const ke=Wa(Ne,j,{fontFamily:_.style.fontFamily,fontSize:_.style.fontSize,fontWeight:_.style.fontWeight,fontStyle:_.style.fontStyle}),Te=_.maxWidth?Math.min(ke.width*qe.zoom,_.maxWidth):ke.width*qe.zoom,Ye=Uo(_.anchorX,Te/qe.zoom,_.style.textAlign),$e=Ui(Ye,_.anchorY),je=ke.height*qe.zoom,ft=Math.abs(_.left-$e.x)<.001&&Math.abs(_.top-$e.y)<.001&&Math.abs(_.width-Te)<.001&&Math.abs(_.height-je)<.001;return _.value===j&&ft?_:{..._,value:j,left:$e.x,top:$e.y,width:Te,height:je}})};P.useEffect(()=>{if(!Qe)return;const j=at!==null?lf(at):Qe.value;Or(j)},[qe.x,qe.y,qe.zoom,at,Qe?.id]);const zn=j=>{try{if(ie.selection)try{G.node(ie,ie.selection.anchor.path),G.node(ie,ie.selection.focus.path)}catch{ut.deselect(ie)}const _=j;for(const Ne of _)if(!Ne||typeof Ne!="object")return;if(pt(_),!ie.operations.some(Ne=>Ne.type!=="set_selection"))return;Or(lf(_))}catch(_){console.warn("Editor change failed:",_)}},tn=j=>{let _=null;try{_=G.marks(ie)}catch{return}const Ge=_?.[j];if(j==="bold"||j==="italic"){if(j==="bold"?!!Qe&&(Qe.style.fontWeight==="bold"||Qe.style.fontWeight==="700"||Qe.style.fontWeight==="800"||Qe.style.fontWeight==="900"):!!Qe&&Qe.style.fontStyle==="italic"){G.addMark(ie,j,Ge===!1);return}if(Ge===!0){G.removeMark(ie,j);return}G.addMark(ie,j,!0);return}Ge===!0?G.removeMark(ie,j):G.addMark(ie,j,!0)},Jr=j=>E2?Rf(j):j,dn=j=>{const _=tt.current;if(!_)return;const Ge=_.getBoundingClientRect(),Ne=j.clientX-Ge.left,ke=j.clientY-Ge.top,Te=Vn(Ne,ke);Ni.current=Te,Ei.current=Te;const Ye=Du(t.elements,Te.x,Te.y);if(!Ye){m([]);return}const $e=t.elements.find(ft=>ft.id===Ye);if(!$e)return;const je=j.ctrlKey||j.metaKey;if($e.groupId&&!je){M($e.id);return}(!Ar.includes(Ye)||je)&&m([Ye])},Ln=()=>{const j=Ni.current;j&&b(j.x,j.y)};return u.jsxs("div",{style:{position:"relative",width:Se.width,height:Se.height},children:[u.jsx("div",{ref:me,style:{position:"fixed",top:0,left:0,pointerEvents:"none",opacity:0,zIndex:-9999},"aria-hidden":"true"}),u.jsx(VT,{hasSelection:Ts,canFlipSelection:mo,selectionType:zl,selectionOpacity:Gl,hasElements:t.elements.length>0,canUngroupSelection:ss,onCut:B,localeMessages:s,onCopy:g,onPaste:Ln,onDuplicate:L,onSelectionOpacityChange:j=>{Ts&&O(Ar,j)},onDelete:E,onGroup:I,onUngroup:k,onSelectAll:()=>{t.elements.length!==0&&m(t.elements.map(j=>j.id))},onMoveForward:()=>H("forward"),onBringToFront:()=>H("front"),onSendToBack:()=>H("back"),onMoveBackward:()=>H("backward"),onFlipHorizontal:()=>qa("horizontal"),onFlipVertical:()=>qa("vertical"),children:u.jsx("canvas",{ref:tt,width:Se.width,height:Se.height,onDragOver:Ie,onDrop:Je,onPointerDown:ot,onPointerMove:qt,onPointerUp:Qt,onPointerCancel:Qt,onPointerLeave:cr,onDoubleClick:dr,onContextMenu:dn,onMouseDown:j=>{j.button===1&&j.preventDefault()},onAuxClick:j=>{j.button===1&&j.preventDefault()},style:{display:"block",cursor:'url("/cursors/'+Le+'.svg")'+(["default","pointer","clone","laser"].includes(Le)?"":["marker","pencil","quill"].includes(Le)?" -4 26":" 12 12")+', url("/cursors/default.svg"), auto',touchAction:"none"}})}),t.elements.length===0&&!Wt&&!At&&!Wr&&u.jsx(ET,{}),u.jsx(HT,{editorWrapRef:Oe,editor:ie,editingText:Qe,editingDocument:at,editorSessionKey:pe,cameraZoom:qe.zoom,setEditingDocument:pt,setEditingText:Xe,toThemeColor:In,getTextLineHeight:Mf,onEditorChange:zn,onCommitEditingText:()=>Ce(),onToggleEditorMark:tn}),D1&&u.jsx(_T,{toolbarKey:D1.key,left:D1.left,top:D1.top,viewportWidth:Se.width,children:k1()})]})};function Yf(){const t=v2(),{scene:e,resolvedTheme:r,isPresentationMode:n,interactionMode:i,drawingTool:a,messages:s,handlers:o,setDrawingTool:A}=t,l={scene:e,strokeColors:r.preset.strokeColors,shapeColors:r.preset.shapeColors,alignmentGuides:[],interactionMode:i,drawingTool:a,localeMessages:s,onPointerDown:o.handlePointerDown,onPointerMove:o.handlePointerMove,onPointerUp:o.handlePointerUp,onResizeStart:o.handleResizeStart,onRotateStart:o.handleRotateStart,onTextCommit:o.handleTextCommit,onWheelPan:o.handleWheelPan,onWheelZoom:o.handleWheelZoom,onCreateElement:o.handleCreateElement,onCreateDrawElement:o.handleCreateDrawElement,onCreateLinePathElement:o.handleCreateLinePathElement,onDrawingToolComplete:()=>A(null),onDropImageFiles:o.handleInsertImageFiles,onSelectElements:o.handleSelectElements,onGroupResizeStart:o.handleGroupResizeStart,onGroupRotateStart:o.handleGroupRotateStart,onTextFontFamilyChange:o.handleTextFontFamilyChange,onTextFontSizeChange:o.handleTextFontSizeChange,onTextFontWeightChange:o.handleTextFontWeightChange,onTextFontStyleChange:o.handleTextFontStyleChange,onTextAlignChange:o.handleTextAlignChange,onTextColorChange:o.handleTextColorChange,onDrawStrokeWidthChange:o.handleDrawStrokeWidthChange,onDrawStrokeColorChange:o.handleDrawStrokeColorChange,onShapeFillColorChange:o.handleShapeFillColorChange,onShapeFillStyleChange:o.handleShapeFillStyleChange,onElementsOpacityChange:o.handleElementsOpacityChange,onShapeStrokeColorChange:o.handleShapeStrokeColorChange,onShapeStrokeWidthChange:o.handleShapeStrokeWidthChange,onShapeStrokeStyleChange:o.handleShapeStrokeStyleChange,onDrawDefaultStrokeColorChange:o.handleDrawDefaultStrokeColorChange,onDrawDefaultStrokeWidthChange:o.handleDrawDefaultStrokeWidthChange,onLineStartCapChange:o.handleLineStartCapChange,onLineEndCapChange:o.handleLineEndCapChange,onLineEditStart:o.handleLineEditStart,onLineGeometryChange:o.handleLineGeometryChange,onRectangleBorderRadiusChange:o.handleRectangleBorderRadiusChange,onCopySelection:o.handleCopySelection,onCutSelection:o.handleCutSelection,onPasteAt:o.handlePasteAt,onDuplicateSelection:o.handleDuplicateSelection,onDeleteSelection:o.handleDeleteSelection,onGroupSelection:o.handleGroupSelection,onUngroupSelection:o.handleUngroupSelection,onSelectGroupForElement:o.handleSelectGroupForElement,onReorderSelection:o.handleReorderSelection,onFlipSelection:o.handleFlipSelection};return u.jsx(WT,{...l})}function Tse({className:t,color:e}){return u.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("g",{"clip-path":"url(#clip0_1539_179)",children:u.jsxs("g",{"clip-path":"url(#clip1_1539_179)",children:[u.jsx("path",{d:"M7.99556 10.0703C8.19978 9.56757 8.68826 9.23877 9.23085 9.23877H14.7692C15.3118 9.23877 15.8003 9.56757 16.0045 10.0703L19.2157 17.9747C19.7337 19.2498 20.0001 20.6131 20.0001 21.9895V45.2389H4V21.9895C4 20.6131 4.26635 19.2498 4.78436 17.9747L7.99556 10.0703Z",fill:"white"}),u.jsx("path",{d:"M7.99556 10.0703C8.19978 9.56757 8.68826 9.23877 9.23085 9.23877H14.7692C15.3118 9.23877 15.8003 9.56757 16.0045 10.0703L19.2157 17.9747C19.7337 19.2498 20.0001 20.6131 20.0001 21.9895V45.2389H4V21.9895C4 20.6131 4.26635 19.2498 4.78436 17.9747L7.99556 10.0703Z",fill:"url(#paint0_linear_1539_179)","fill-opacity":"0.6"}),u.jsx("path",{d:"M9.23047 9.48877H14.7695C15.1552 9.48887 15.5071 9.6934 15.7002 10.0181L15.7725 10.1645L18.9844 18.0688C19.4902 19.314 19.75 20.6457 19.75 21.9897V44.9888H4.25V21.9897C4.25 20.6457 4.50979 19.314 5.01562 18.0688L8.22754 10.1645C8.39342 9.75622 8.78976 9.48892 9.23047 9.48877Z",stroke:"black","stroke-opacity":"0.3","stroke-width":"0.5"}),u.jsx("g",{opacity:"0.2",filter:"url(#filter0_f_1539_179)",children:u.jsx("path",{d:"M18.6635 20.6615V44.3282H12.3301V10.3281L14.6634 10.2388L18.6635 20.6615Z",fill:"url(#paint1_linear_1539_179)"})}),u.jsx("g",{filter:"url(#filter1_i_1539_179)",children:u.jsx("path",{d:"M11.383 3.74726C11.6089 3.19493 12.3911 3.19493 12.6171 3.74725L15 9.57232H9L11.383 3.74726Z",fill:e||"#1E1E1E"})}),u.jsx("path",{d:"M11.6143 3.84158C11.7556 3.49681 12.2444 3.49682 12.3857 3.84158L14.6279 9.32205H9.37207L11.6143 3.84158Z",stroke:"black","stroke-opacity":"0.3","stroke-width":"0.5"}),u.jsx("path",{d:"M4.33008 23.9058H19.6635",stroke:"black","stroke-opacity":"0.15","stroke-width":"0.66667"})]})}),u.jsxs("defs",{children:[u.jsxs("filter",{id:"filter0_f_1539_179",x:"10.3301",y:"8.23875",width:"10.3335",height:"38.0894",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feGaussianBlur",{stdDeviation:"1.00001",result:"effect1_foregroundBlur_1539_179"})]}),u.jsxs("filter",{id:"filter1_i_1539_179",x:"7.55999",y:"3.33301",width:"7.44001",height:"6.95926",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),u.jsx("feOffset",{dx:"-1.44001",dy:"0.720004"}),u.jsx("feGaussianBlur",{stdDeviation:"1.08001"}),u.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),u.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0"}),u.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect1_innerShadow_1539_179"})]}),u.jsxs("linearGradient",{id:"paint0_linear_1539_179",x1:"4",y1:"38.2389",x2:"20.0001",y2:"38.2389",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-opacity":"0.1"}),u.jsx("stop",{offset:"0.4","stop-opacity":"0"}),u.jsx("stop",{offset:"1","stop-opacity":"0.15"})]}),u.jsxs("linearGradient",{id:"paint1_linear_1539_179",x1:"12.3301",y1:"1.57206",x2:"17.1673",y2:"36.2341",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-opacity":"0.2"}),u.jsx("stop",{offset:"1","stop-opacity":"0.4"})]}),u.jsx("clipPath",{id:"clip0_1539_179",children:u.jsx("rect",{width:"24",height:"24",fill:"white"})}),u.jsx("clipPath",{id:"clip1_1539_179",children:u.jsx("rect",{width:"16",height:"34",fill:"white",transform:"translate(4 2.57227)"})})]})]})}function Nse({className:t,color:e}){return u.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("g",{"clip-path":"url(#clip0_1571_205)",children:u.jsxs("g",{"clip-path":"url(#clip1_1571_205)",children:[u.jsx("path",{opacity:"0.75",d:"M12 9.66211C12.5694 9.66211 13.1156 9.88833 13.5182 10.291C13.9209 10.6937 14.1471 11.2398 14.1471 11.8093C14.1471 12.3787 13.9209 12.9249 13.5182 13.3276C13.1156 13.7302 12.5694 13.9565 12 13.9565C11.4305 13.9565 10.8843 13.7302 10.4817 13.3276C10.079 12.9249 9.85278 12.3787 9.85278 11.8093C9.85278 11.2398 10.079 10.6937 10.4817 10.291C10.8843 9.88833 11.4305 9.66211 12 9.66211Z",fill:e||"#1E1E1E"}),u.jsx("path",{d:"M12.6409 1.61035C12.9169 1.61035 13.1466 1.8197 13.1863 2.09347C13.6442 5.2482 15.4741 7.95793 18.0518 9.59891C18.2558 9.72882 18.3578 9.97413 18.2961 10.2076L15.5418 20.5366C15.5112 20.6509 15.4438 20.752 15.3499 20.824C15.2561 20.896 15.141 20.935 15.0227 20.9349H8.97679C8.85856 20.9349 8.74364 20.8958 8.64988 20.8238C8.55611 20.7518 8.48875 20.6508 8.45825 20.5366L5.7045 10.2076C5.67486 10.0934 5.68253 9.97277 5.72638 9.86325C5.77022 9.75373 5.84795 9.6611 5.9482 9.59891C8.52588 7.95793 10.3558 5.2482 10.8142 2.09293C10.854 1.82024 11.0832 1.61035 11.3591 1.61035H12.6409ZM12 9.66225C11.4305 9.66225 10.8844 9.88847 10.4817 10.2911C10.0791 10.6938 9.85284 11.24 9.85284 11.8094C9.85284 12.3789 10.0791 12.925 10.4817 13.3277C10.8844 13.7304 11.4305 13.9566 12 13.9566C12.5695 13.9566 13.1156 13.7304 13.5183 13.3277C13.921 12.925 14.1472 12.3789 14.1472 11.8094C14.1472 11.24 13.921 10.6938 13.5183 10.2911C13.1156 9.88847 12.5695 9.66225 12 9.66225Z",fill:"white"}),u.jsxs("mask",{id:"mask0_1571_205",style:{maskType:"luminance"},maskUnits:"userSpaceOnUse",x:"5",y:"1",width:"15",height:"21",children:[u.jsx("path",{d:"M5.14941 1.07373H19.106V21.4719H5.14941V1.07373Z",fill:"white"}),u.jsx("path",{d:"M12.6409 1.61035C12.9169 1.61035 13.1466 1.8197 13.1863 2.09347C13.6442 5.2482 15.4741 7.95793 18.0518 9.59891C18.2558 9.72882 18.3578 9.97413 18.2961 10.2076L15.5418 20.5366C15.5112 20.6509 15.4438 20.752 15.3499 20.824C15.2561 20.896 15.141 20.935 15.0227 20.9349H8.97679C8.85856 20.9349 8.74364 20.8958 8.64988 20.8238C8.55611 20.7518 8.48875 20.6508 8.45825 20.5366L5.7045 10.2076C5.67486 10.0934 5.68253 9.97277 5.72638 9.86325C5.77022 9.75373 5.84795 9.6611 5.9482 9.59891C8.52588 7.95793 10.3558 5.2482 10.8142 2.09293C10.854 1.82024 11.0832 1.61035 11.3591 1.61035H12.6409ZM12 9.66225C11.4305 9.66225 10.8844 9.88847 10.4817 10.2911C10.0791 10.6938 9.85284 11.24 9.85284 11.8094C9.85284 12.3789 10.0791 12.925 10.4817 13.3277C10.8844 13.7304 11.4305 13.9566 12 13.9566C12.5695 13.9566 13.1156 13.7304 13.5183 13.3277C13.921 12.925 14.1472 12.3789 14.1472 11.8094C14.1472 11.24 13.921 10.6938 13.5183 10.2911C13.1156 9.88847 12.5695 9.66225 12 9.66225Z",fill:"black"})]}),u.jsx("g",{mask:"url(#mask0_1571_205)",children:u.jsx("path",{d:"M13.1863 2.09331L12.9206 2.13196C13.3903 5.36667 15.2664 8.14404 17.9074 9.82582L18.0523 9.59929L18.1962 9.37276C15.6824 7.77312 13.8986 5.12995 13.452 2.05466L13.1863 2.09331ZM18.296 10.208L18.0367 10.1388L15.2825 20.4677L15.5417 20.537L15.801 20.6057L18.5548 10.2773L18.296 10.208ZM15.0221 20.9348V20.6664H8.97675V21.2032H15.0227L15.0221 20.9348ZM8.45713 20.5365L8.71694 20.4667L5.96319 10.1382L5.70392 10.2075L5.44465 10.2767L8.1984 20.6052L8.45713 20.5365ZM5.9487 9.59822L6.09309 9.82528C8.73412 8.14351 10.6107 5.36614 11.0799 2.13142L10.8147 2.09277L10.549 2.05412C10.1024 5.12995 8.3181 7.77205 5.80483 9.37276L5.9487 9.59822ZM11.359 1.61019V1.87859H12.6409V1.3418H11.359V1.61019ZM12 9.66209V9.3937C11.3593 9.3937 10.7449 9.6482 10.2919 10.1012C9.83889 10.5542 9.5844 11.1686 9.5844 11.8093H10.1212C10.1212 11.311 10.3191 10.8331 10.6715 10.4808C11.0238 10.1284 11.5017 9.93049 12 9.93049V9.66209ZM9.85279 11.8093H9.5844C9.5844 12.4499 9.83889 13.0643 10.2919 13.5173C10.7449 13.9703 11.3593 14.2248 12 14.2248V13.688C11.5017 13.688 11.0238 13.4901 10.6715 13.1378C10.3191 12.7854 10.1212 12.3076 10.1212 11.8093H9.85279ZM12 13.9564V14.2248C12.6406 14.2248 13.255 13.9703 13.708 13.5173C14.161 13.0643 14.4155 12.4499 14.4155 11.8093H13.8787C13.8787 12.3076 13.6808 12.7854 13.3285 13.1378C12.9761 13.4901 12.4983 13.688 12 13.688V13.9564ZM14.1471 11.8093H14.4155C14.4155 11.1686 14.161 10.5542 13.708 10.1012C13.255 9.6482 12.6406 9.3937 12 9.3937V9.93049C12.4983 9.93049 12.9761 10.1284 13.3285 10.4808C13.6808 10.8331 13.8787 11.311 13.8787 11.8093H14.1471ZM10.8137 2.09331L11.0799 2.13142C11.0887 2.06294 11.1216 1.99985 11.1728 1.9535C11.224 1.90715 11.29 1.88059 11.359 1.87859V1.3418C10.9425 1.3418 10.6065 1.65689 10.5485 2.05412L10.8137 2.09331ZM5.70499 10.2069L5.96426 10.1377C5.9494 10.0786 5.95389 10.0163 5.97708 9.95998C6.00028 9.90364 6.04094 9.85624 6.09309 9.82474L5.9487 9.59822L5.80483 9.37169C5.65629 9.46442 5.54128 9.6022 5.47658 9.76492C5.41187 9.92764 5.40088 10.1068 5.44518 10.2762L5.70499 10.2069ZM8.97675 20.9348V20.6664C8.91763 20.6664 8.86017 20.6468 8.81329 20.6108C8.76641 20.5748 8.73273 20.5243 8.71748 20.4672L8.45821 20.5365L8.1984 20.6052C8.24408 20.7767 8.34569 20.9283 8.48646 21.0365C8.62722 21.1446 8.79978 21.2032 8.97728 21.2032L8.97675 20.9348ZM15.5417 20.537L15.2825 20.4667C15.2673 20.524 15.2336 20.5746 15.1866 20.6108C15.1396 20.6469 15.0819 20.6664 15.0227 20.6664V21.2032C15.2002 21.2032 15.3727 21.1446 15.5135 21.0365C15.6542 20.9283 15.7553 20.7772 15.801 20.6057L15.5417 20.537ZM18.0518 9.59875L17.9079 9.82528C18.018 9.89506 18.0668 10.0239 18.0367 10.1382L18.296 10.208L18.5553 10.2767C18.5995 10.1074 18.5884 9.92837 18.5237 9.76576C18.459 9.60315 18.3446 9.46546 18.1962 9.37276L18.0518 9.59875ZM13.1863 2.09331L13.452 2.05466C13.3946 1.65743 13.058 1.3418 12.6409 1.3418V1.87859C12.7762 1.87859 12.8991 1.98326 12.9206 2.13196L13.1863 2.09331Z",fill:"black","fill-opacity":"0.15"})}),u.jsx("mask",{id:"mask1_1571_205",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"5",y:"1",width:"14",height:"20",children:u.jsx("path",{d:"M12.6409 1.61035C12.9169 1.61035 13.1466 1.8197 13.1863 2.09347C13.6442 5.2482 15.4741 7.95793 18.0518 9.59891C18.2558 9.72882 18.3578 9.97413 18.2961 10.2076L15.5418 20.5366C15.5112 20.6509 15.4438 20.752 15.3499 20.824C15.2561 20.896 15.141 20.935 15.0227 20.9349H8.97679C8.85856 20.9349 8.74364 20.8958 8.64988 20.8238C8.55611 20.7518 8.48875 20.6508 8.45825 20.5366L5.7045 10.2076C5.67486 10.0934 5.68253 9.97277 5.72638 9.86325C5.77022 9.75373 5.84795 9.6611 5.9482 9.59891C8.52588 7.95793 10.3558 5.2482 10.8142 2.09293C10.854 1.82024 11.0832 1.61035 11.3591 1.61035H12.6409ZM12 9.66225C11.4305 9.66225 10.8844 9.88847 10.4817 10.2911C10.0791 10.6938 9.85284 11.24 9.85284 11.8094C9.85284 12.3789 10.0791 12.925 10.4817 13.3277C10.8844 13.7304 11.4305 13.9566 12 13.9566C12.5695 13.9566 13.1156 13.7304 13.5183 13.3277C13.921 12.925 14.1472 12.3789 14.1472 11.8094C14.1472 11.24 13.921 10.6938 13.5183 10.2911C13.1156 9.88847 12.5695 9.66225 12 9.66225Z",fill:"white"})}),u.jsxs("g",{mask:"url(#mask1_1571_205)",children:[u.jsxs("g",{opacity:"0.75",filter:"url(#filter0_f_1571_205)",children:[u.jsx("path",{d:"M13.1272 1.61035C13.4745 5.11347 15.5062 8.12058 18.4006 9.81256L15.4354 20.9349H8.56442L5.59863 9.81256C8.49356 8.12005 10.5253 5.11293 10.8726 1.61035H11.4631V9.17914C10.8114 9.31217 10.2323 9.68243 9.83812 10.2182C9.44391 10.7539 9.26267 11.4169 9.32952 12.0786C9.39637 12.7404 9.70656 13.3538 10.1999 13.7998C10.6933 14.2459 11.3348 14.4928 11.9999 14.4928C12.665 14.4928 13.3065 14.2459 13.7998 13.7998C14.2932 13.3538 14.6034 12.7404 14.6703 12.0786C14.7371 11.4169 14.5559 10.7539 14.1617 10.2182C13.7675 9.68243 13.1884 9.31217 12.5367 9.17914V1.61035H13.1272Z",fill:"url(#paint0_linear_1571_205)"}),u.jsx("path",{d:"M13.1272 1.61035C13.4745 5.11347 15.5062 8.12058 18.4006 9.81256L15.4354 20.9349H8.56442L5.59863 9.81256C8.49356 8.12005 10.5253 5.11293 10.8726 1.61035H11.4631V9.17914C10.8114 9.31217 10.2323 9.68243 9.83812 10.2182C9.44391 10.7539 9.26267 11.4169 9.32952 12.0786C9.39637 12.7404 9.70656 13.3538 10.1999 13.7998C10.6933 14.2459 11.3348 14.4928 11.9999 14.4928C12.665 14.4928 13.3065 14.2459 13.7998 13.7998C14.2932 13.3538 14.6034 12.7404 14.6703 12.0786C14.7371 11.4169 14.5559 10.7539 14.1617 10.2182C13.7675 9.68243 13.1884 9.31217 12.5367 9.17914V1.61035H13.1272Z",fill:"url(#paint1_linear_1571_205)"}),u.jsx("mask",{id:"mask2_1571_205",style:{maskType:"luminance"},maskUnits:"userSpaceOnUse",x:"5",y:"1",width:"14",height:"20",children:u.jsx("path",{d:"M13.1272 1.61035C13.4745 5.11347 15.5062 8.12058 18.4006 9.81256L15.4354 20.9349H8.56442L5.59863 9.81256C8.49356 8.12005 10.5253 5.11293 10.8726 1.61035H11.4631V9.17914C10.8114 9.31217 10.2323 9.68243 9.83812 10.2182C9.44391 10.7539 9.26267 11.4169 9.32952 12.0786C9.39637 12.7404 9.70656 13.3538 10.1999 13.7998C10.6933 14.2459 11.3348 14.4928 11.9999 14.4928C12.665 14.4928 13.3065 14.2459 13.7998 13.7998C14.2932 13.3538 14.6034 12.7404 14.6703 12.0786C14.7371 11.4169 14.5559 10.7539 14.1617 10.2182C13.7675 9.68243 13.1884 9.31217 12.5367 9.17914V1.61035H13.1272Z",fill:"white"})}),u.jsx("g",{mask:"url(#mask2_1571_205)",children:u.jsx("path",{d:"M13.1272 1.61052L13.6608 1.55738L13.6124 1.07373H13.1272V1.61052ZM18.4006 9.81273L18.9197 9.95068L19.0249 9.5556L18.6717 9.34894L18.4006 9.81273ZM15.4354 20.9351V21.4719H15.8477L15.9539 21.0736L15.4354 20.9351ZM8.56444 20.9351L8.0459 21.0736L8.15218 21.4719H8.56444V20.9351ZM5.59866 9.81273L5.32758 9.34894L4.97437 9.55507L5.08011 9.95068L5.59866 9.81273ZM10.8727 1.61052V1.07373H10.3863L10.3385 1.55738L10.8727 1.61052ZM11.4631 1.61052H11.9999V1.07373H11.4631V1.61052ZM11.4631 9.17931L11.5699 9.70537L11.9994 9.61787V9.17931H11.4631ZM12.5367 9.17931H11.9994V9.61787L12.4294 9.70537L12.5367 9.17931ZM12.5367 1.61052V1.07373H11.9999V1.61052H12.5367ZM13.1272 1.61052L12.5925 1.66367C12.9576 5.34339 15.0918 8.50027 18.1301 10.276L18.4006 9.81219L18.6717 9.34894C15.9207 7.74124 13.9909 4.88389 13.6608 1.55738L13.1272 1.61052ZM18.4006 9.81273L17.8821 9.67423L14.9169 20.7966L15.4354 20.9351L15.9539 21.0736L18.9197 9.95068L18.4006 9.81273ZM15.4354 20.9351V20.3983H8.56444V21.4719H15.4354V20.9351ZM8.56444 20.9351L9.08298 20.7966L6.1172 9.67423L5.59866 9.81219L5.08011 9.95068L8.0459 21.0736L8.56444 20.9351ZM5.59866 9.81273L5.8692 10.276C8.90745 8.50027 11.0423 5.34339 11.4073 1.66367L10.8732 1.61052L10.3391 1.55738C10.009 4.88389 8.07918 7.74124 5.32758 9.34894L5.59866 9.81273ZM10.8727 1.61052V2.14732H11.4631V1.07373H10.8727V1.61052ZM11.4631 1.61052H10.9263V9.17931H11.9994L11.9999 1.61052H11.4631ZM11.4631 9.17931L11.3558 8.65325C10.6283 8.80175 9.97445 9.19704 9.50492 9.77221C9.03539 10.3474 8.77901 11.0671 8.77916 11.8096H9.85274C9.85262 11.3147 10.0235 10.8349 10.3364 10.4515C10.6493 10.068 11.0851 9.80447 11.5699 9.70537L11.4631 9.17931ZM9.31595 11.8096H8.77916C8.77916 12.6638 9.11849 13.483 9.7225 14.087C10.3265 14.691 11.1457 15.0304 11.9999 15.0304V13.9568C11.4305 13.9568 10.8843 13.7306 10.4816 13.3279C10.079 12.9252 9.85274 12.3791 9.85274 11.8096H9.31595ZM11.9999 14.4936V15.0304C12.8541 15.0304 13.6733 14.691 14.2773 14.087C14.8813 13.483 15.2207 12.6638 15.2207 11.8096H14.1471C14.1471 12.3791 13.9209 12.9252 13.5182 13.3279C13.1155 13.7306 12.5694 13.9568 11.9999 13.9568V14.4936ZM14.6839 11.8096H15.2207C15.2208 11.067 14.9643 10.3472 14.4947 9.77206C14.0251 9.19688 13.3711 8.80164 12.6435 8.65325L12.5367 9.17931L12.4299 9.70537C12.9148 9.80447 13.3505 10.068 13.6635 10.4515C13.9764 10.8349 14.1472 11.3147 14.1471 11.8096H14.6839ZM12.5367 9.17931H13.0735V1.61052H11.9999L11.9994 9.17931H12.5367ZM12.5367 1.61052V2.14732H13.1272V1.07373H12.5367V1.61052Z",fill:"white","fill-opacity":"0.5"})})]}),u.jsx("path",{d:"M12.0001 0.805176C12.0713 0.805176 12.1395 0.833453 12.1899 0.883787C12.2402 0.934121 12.2685 1.00239 12.2685 1.07357V10.7359C12.2685 10.807 12.2402 10.8753 12.1899 10.9256C12.1395 10.976 12.0713 11.0043 12.0001 11.0043C11.9289 11.0043 11.8606 10.976 11.8103 10.9256C11.76 10.8753 11.7317 10.807 11.7317 10.7359V1.07357C11.7317 1.00239 11.76 0.934121 11.8103 0.883787C11.8606 0.833453 11.9289 0.805176 12.0001 0.805176Z",fill:"black","fill-opacity":"0.15"}),u.jsxs("mask",{id:"mask3_1571_205",style:{maskType:"luminance"},maskUnits:"userSpaceOnUse",x:"11",y:"0",width:"2",height:"12",children:[u.jsx("path",{d:"M11.1948 0.268555H12.8052V11.5412H11.1948V0.268555Z",fill:"white"}),u.jsx("path",{d:"M12.0001 0.805176C12.0713 0.805176 12.1395 0.833453 12.1899 0.883787C12.2402 0.934121 12.2685 1.00239 12.2685 1.07357V10.7359C12.2685 10.807 12.2402 10.8753 12.1899 10.9256C12.1395 10.976 12.0713 11.0043 12.0001 11.0043C11.9289 11.0043 11.8606 10.976 11.8103 10.9256C11.76 10.8753 11.7317 10.807 11.7317 10.7359V1.07357C11.7317 1.00239 11.76 0.934121 11.8103 0.883787C11.8606 0.833453 11.9289 0.805176 12.0001 0.805176Z",fill:"black"})]}),u.jsx("g",{mask:"url(#mask3_1571_205)",children:u.jsx("path",{d:"M12 0.805348V1.34214C11.9288 1.34214 11.8606 1.31386 11.8102 1.26353C11.7599 1.2132 11.7316 1.14493 11.7316 1.07374H12.8052C12.8052 0.860195 12.7204 0.655392 12.5694 0.504389C12.4184 0.353387 12.2136 0.268555 12 0.268555V0.805348ZM12.2684 1.07374H11.7316V10.736H12.8052V1.07374H12.2684ZM12.2684 10.736H11.7316C11.7316 10.6648 11.7599 10.5966 11.8102 10.5462C11.8606 10.4959 11.9288 10.4676 12 10.4676V11.5412C12.2136 11.5412 12.4184 11.4564 12.5694 11.3054C12.7204 11.1544 12.8052 10.9496 12.8052 10.736H12.2684ZM12 11.0044V10.4676C12.0712 10.4676 12.1395 10.4959 12.1898 10.5462C12.2401 10.5966 12.2684 10.6648 12.2684 10.736H11.1948C11.1948 10.9496 11.2797 11.1544 11.4307 11.3054C11.5817 11.4564 11.7865 11.5412 12 11.5412V11.0044ZM11.7316 10.736H12.2684V1.07374H11.1948V10.736H11.7316ZM11.7316 1.07374H12.2684C12.2684 1.14493 12.2401 1.2132 12.1898 1.26353C12.1395 1.31386 12.0712 1.34214 12 1.34214V0.268555C11.7865 0.268555 11.5817 0.353387 11.4307 0.504389C11.2797 0.655392 11.1948 0.860195 11.1948 1.07374H11.7316Z",fill:"white"})})]}),u.jsx("path",{d:"M5.55859 20.9348C5.55859 20.3653 5.78481 19.8192 6.18749 19.4165C6.59016 19.0138 7.1363 18.7876 7.70577 18.7876H16.2945C16.8639 18.7876 17.4101 19.0138 17.8127 19.4165C18.2154 19.8192 18.4416 20.3653 18.4416 20.9348V35.965H5.55859V20.9348Z",fill:"white"}),u.jsx("path",{d:"M16.2944 18.6538L16.4119 18.657C16.9958 18.6872 17.5459 18.9403 17.9485 19.3642C18.3512 19.7882 18.5757 20.3505 18.5758 20.9352V36.0996H5.42432V20.9352C5.42432 20.3301 5.66467 19.7498 6.09251 19.322C6.52036 18.8942 7.10063 18.6538 7.70569 18.6538H16.2944Z",stroke:"black","stroke-opacity":"0.15","stroke-width":"0.268397"}),u.jsx("mask",{id:"mask4_1571_205",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"5",y:"18",width:"14",height:"18",children:u.jsx("path",{d:"M5.55859 20.9353C5.55859 20.3658 5.78481 19.8197 6.18749 19.417C6.59016 19.0143 7.1363 18.7881 7.70577 18.7881H16.2945C16.8639 18.7881 17.4101 19.0143 17.8127 19.417C18.2154 19.8197 18.4416 20.3658 18.4416 20.9353V35.9655H5.55859V20.9353Z",fill:"white"})}),u.jsxs("g",{mask:"url(#mask4_1571_205)",children:[u.jsxs("g",{filter:"url(#filter1_dd_1571_205)",children:[u.jsx("path",{d:"M5.55859 20.9353C5.55859 20.3658 5.78481 19.8197 6.18749 19.417C6.59016 19.0143 7.1363 18.7881 7.70577 18.7881H16.2945C16.8639 18.7881 17.4101 19.0143 17.8127 19.417C18.2154 19.8197 18.4416 20.3658 18.4416 20.9353V35.9655H5.55859V20.9353Z",fill:"white"}),u.jsx("path",{d:"M16.2944 18.6543L16.4119 18.6575C16.9958 18.6876 17.5459 18.9408 17.9485 19.3647C18.3512 19.7887 18.5757 20.351 18.5758 20.9357V36.1001H5.42432V20.9357C5.42432 20.3306 5.66467 19.7503 6.09251 19.3225C6.52036 18.8947 7.10063 18.6543 7.70569 18.6543H16.2944Z",stroke:"black","stroke-opacity":"0.15","stroke-width":"0.268397"})]}),u.jsxs("g",{opacity:"0.75",filter:"url(#filter2_f_1571_205)",children:[u.jsx("path",{d:"M5.55859 20.9353C5.55859 20.3658 5.78481 19.8197 6.18749 19.417C6.59016 19.0143 7.1363 18.7881 7.70577 18.7881H16.2945C16.8639 18.7881 17.4101 19.0143 17.8127 19.417C18.2154 19.8197 18.4416 20.3658 18.4416 20.9353V35.9655H5.55859V20.9353Z",fill:"url(#paint2_linear_1571_205)"}),u.jsx("path",{d:"M7.70568 19.0566H16.2944C16.7927 19.0566 17.2705 19.2546 17.6229 19.6069C17.9752 19.9593 18.1732 20.4371 18.1732 20.9354V35.6972H5.8269V20.9354C5.82695 20.4539 6.01189 19.9908 6.34352 19.6417C6.67515 19.2925 7.12817 19.0841 7.60906 19.0593L7.70568 19.0566Z",stroke:"white","stroke-opacity":"0.5","stroke-width":"0.536793"})]})]})]})}),u.jsxs("defs",{children:[u.jsxs("filter",{id:"filter0_f_1571_205",x:"4.52505",y:"0.536765",width:"14.9492",height:"21.4719",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feGaussianBlur",{stdDeviation:"0.536793",result:"effect1_foregroundBlur_1571_205"})]}),u.jsxs("filter",{id:"filter1_dd_1571_205",x:"3.14287",y:"17.4464",width:"17.7143",height:"22.0087",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),u.jsx("feOffset",{dy:"0.536793"}),u.jsx("feGaussianBlur",{stdDeviation:"0.536793"}),u.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0"}),u.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1571_205"}),u.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),u.jsx("feOffset",{dy:"1.07359"}),u.jsx("feGaussianBlur",{stdDeviation:"1.07359"}),u.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),u.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0"}),u.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1571_205",result:"effect2_dropShadow_1571_205"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect2_dropShadow_1571_205",result:"shape"})]}),u.jsxs("filter",{id:"filter2_f_1571_205",x:"4.48501",y:"17.7145",width:"15.0302",height:"19.3249",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feGaussianBlur",{stdDeviation:"0.536793",result:"effect1_foregroundBlur_1571_205"})]}),u.jsxs("linearGradient",{id:"paint0_linear_1571_205",x1:"4.53739",y1:"10.1244",x2:"19.4624",y2:"10.1244",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{offset:"0.49","stop-color":"#999999","stop-opacity":"0"}),u.jsx("stop",{offset:"1","stop-color":"#999999"})]}),u.jsxs("linearGradient",{id:"paint1_linear_1571_205",x1:"10.134",y1:"1.36987",x2:"13.2506",y2:"18.9257",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{offset:"0.726","stop-color":"#999999","stop-opacity":"0"}),u.jsx("stop",{offset:"1","stop-color":"#999999"})]}),u.jsxs("linearGradient",{id:"paint2_linear_1571_205",x1:"5.55859",y1:"27.3768",x2:"18.4416",y2:"27.3768",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-color":"#AAAAAA","stop-opacity":"0.5"}),u.jsx("stop",{offset:"0.394","stop-color":"#AAAAAA","stop-opacity":"0"}),u.jsx("stop",{offset:"0.832","stop-color":"#999999"})]}),u.jsx("clipPath",{id:"clip0_1571_205",children:u.jsx("rect",{width:"24",height:"24",fill:"white"})}),u.jsx("clipPath",{id:"clip1_1571_205",children:u.jsx("rect",{width:"18.251",height:"36.502",fill:"white",transform:"translate(2.87451)"})})]})]})}function Pse({className:t,color:e}){return u.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsxs("g",{"clip-path":"url(#clip0_1538_150)",children:[u.jsx("path",{d:"M7.95337 5.71142C7.95337 5.36004 8.16295 5.04253 8.48605 4.9044L13.7522 2.65314C14.3313 2.40559 14.9748 2.83041 14.9748 3.46017L14.9748 10.9073L7.95337 10.9073L7.95337 5.71142Z",fill:e||"#FFEE00"}),u.jsx("path",{d:"M7.95337 5.71142C7.95337 5.36004 8.16295 5.04253 8.48605 4.9044L13.7522 2.65314C14.3313 2.40559 14.9748 2.83041 14.9748 3.46017L14.9748 10.9073L7.95337 10.9073L7.95337 5.71142Z",fill:"url(#paint0_linear_1538_150)"}),u.jsx("path",{d:"M14.0947 2.62097C14.4884 2.45264 14.9256 2.74131 14.9259 3.16947L14.9259 10.9171L8.00098 10.9171L8.00098 5.61955L8.00798 5.53139C8.03836 5.32877 8.17118 5.15321 8.36338 5.07104L14.0947 2.62097Z",stroke:"black","stroke-opacity":"0.3","stroke-width":"0.1"}),u.jsx("path",{d:"M8.21993 10.3188C7.31667 10.3188 6.58444 11.0468 6.58444 11.9446C6.58444 17.2642 4.51919 21.2529 0.638381 24.8865C0.238494 25.2609 0.000244048 25.7803 0.000244045 26.3283L0.000244012 31.8114C0.000244008 32.6027 0.641734 33.2442 1.43307 33.2444L21.4927 33.2444C22.2841 33.2444 22.9255 32.6029 22.9255 31.8115L22.9255 26.3283C22.9255 25.7805 22.6873 25.2611 22.2874 24.8867C18.4065 21.253 16.3414 17.2643 16.3414 11.9447C16.3414 11.0469 15.6091 10.3189 14.7059 10.3189L8.21993 10.3188Z",fill:"url(#paint1_linear_1538_150)","fill-opacity":"0.6"}),u.jsx("path",{d:"M8.24279 10.6406C7.34604 10.6406 6.61908 11.3633 6.61908 12.2547C6.61908 17.536 4.56869 21.496 0.715818 25.1035C0.31881 25.4752 0.0822753 25.9908 0.0822753 26.5348L0.0822753 31.9784C0.0822753 32.7641 0.719147 33.4009 1.50478 33.4011L21.42 33.4011C22.2057 33.4011 22.8425 32.7642 22.8425 31.9786L22.8425 26.5348C22.8425 25.991 22.606 25.4753 22.2089 25.1036C18.3561 21.4961 16.3058 17.5361 16.3058 12.2548C16.3058 11.3634 15.5788 10.6407 14.682 10.6407L8.24279 10.6406Z",fill:"white"}),u.jsx("path",{d:"M8.22911 10.9165L14.716 10.9165C15.4232 10.9167 15.9935 11.4863 15.9935 12.1842C15.9935 17.6193 18.1121 21.6982 22.0522 25.3875C22.3839 25.698 22.5768 26.1242 22.5769 26.567L22.5769 32.0507C22.5769 32.6442 22.0958 33.1253 21.5023 33.1253L1.44278 33.1253L1.33224 33.1197C0.790689 33.0643 0.368164 32.6068 0.368164 32.0507L0.368164 26.567C0.368322 26.1795 0.516175 25.8049 0.775344 25.5093L0.892879 25.3875C4.83304 21.6982 6.95297 17.6193 6.95299 12.1842C6.95299 11.5297 7.45337 10.9885 8.09898 10.9235L8.22911 10.9165Z",stroke:"black","stroke-opacity":"0.3","stroke-width":"0.5"}),u.jsx("g",{opacity:"0.1",filter:"url(#filter0_f_1538_150)",children:u.jsx("path",{d:"M15.2885 12.2295L11.9453 12.2295L11.9453 31.8116L21.4975 31.8116L21.4975 26.0801C18.6319 23.2145 15.2885 20.8266 15.2885 12.2295Z",fill:"black"})})]}),u.jsxs("defs",{children:[u.jsxs("filter",{id:"filter0_f_1538_150",x:"9.94529",y:"10.2295",width:"13.5523",height:"23.5821",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feGaussianBlur",{stdDeviation:"1.00001",result:"effect1_foregroundBlur_1538_150"})]}),u.jsxs("linearGradient",{id:"paint0_linear_1538_150",x1:"11.4641",y1:"3.00812",x2:"11.4641",y2:"8.71307",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-color":"white","stop-opacity":"0.8"}),u.jsx("stop",{offset:"1","stop-color":"white","stop-opacity":"0"})]}),u.jsxs("linearGradient",{id:"paint1_linear_1538_150",x1:"0.000244031",y1:"28.7867",x2:"22.9255",y2:"28.7867",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-opacity":"0.1"}),u.jsx("stop",{offset:"0.4","stop-opacity":"0"}),u.jsx("stop",{offset:"1","stop-opacity":"0.15"})]}),u.jsx("clipPath",{id:"clip0_1538_150",children:u.jsx("rect",{width:"24",height:"24",fill:"white"})})]})]})}const KT=({interactionMode:t,drawingTool:e,isPresentationMode:r,messages:n,setInteractionMode:i,setDrawingTool:a,drawDefaults:s,invertPaletteInDarkMode:o,strokeColors:A,onDrawDefaultStrokeColorChange:l,onDrawDefaultStrokeWidthChange:c,onSelectImageFiles:f})=>{const[d,h]=P.useState(!1),C=P.useRef(null),p=F=>{r&&F!=="pan"||i(F)},w=F=>{r||a(F)},m=()=>e==="marker"?"marker":e==="quill"?"quill":"draw",[g,B]=P.useState(e==="marker"?s.markerStroke:e==="quill"?s.quillStroke:s.drawStroke),b=e==="marker"?bc:Ko,L=e==="marker"?AI:J5,E=F=>o?Rf(F):F,I=e==="marker"?s.markerStroke:e==="quill"?s.quillStroke:s.drawStroke;P.useEffect(()=>{B(I)},[I]);const k=F=>{const D=F.hexa||F.hex;if(D){B(D);const U=m();l(U,D)}},M=(F,D)=>{const U=F[D]??F[0];return U?u.jsx("svg",{width:U.width,height:U.height,viewBox:U.viewBox,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:U.path,stroke:U.strokeWidth?"currentColor":void 0,strokeWidth:U.strokeWidth,strokeLinecap:U.strokeWidth?"round":void 0,fill:U.fill})}):null},H=["draw","marker","quill"];return u.jsxs("div",{className:"tool-bar",children:[u.jsx("input",{ref:C,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:F=>{const D=Array.from(F.target.files??[]).filter(U=>U.type.startsWith("image/"));D.length>0&&f(D),F.currentTarget.value=""}}),H.includes(e)?u.jsxs("div",{className:"top-toolbar",children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`drawtool-elem tool-item${e==="draw"?" active":""}`,onClick:()=>{p("select"),w("draw"),h(!1)},children:u.jsx(Tse,{color:E(s.drawStroke),className:"drawtool-icon"})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.pen})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`drawtool-elem tool-item${e==="quill"?" active":""}`,onClick:()=>{p("select"),w("quill"),h(!1)},children:u.jsx(Nse,{color:E(s.quillStroke),className:"drawtool-icon "})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.quill})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`drawtool-elem tool-item${e==="marker"?" active":""}`,onClick:()=>{p("select"),w("marker"),h(!1)},children:u.jsx(Pse,{color:E(s.markerStroke),className:"drawtool-icon"})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.marker})})]}),u.jsx("div",{className:"tool-separator"}),u.jsx(ws,{colors:A,currentColor:I,uniColor:E,renderItem:({color:F,swatch:D})=>u.jsx("div",{className:"drawo-colorselect-item",onClick:()=>{if(F==="multi"){h(U=>!U);return}h(!1),k({hex:F})},children:D},F)}),u.jsxs(Tr,{open:d,children:[u.jsx(Nr,{asChild:!0,children:u.jsx("span",{style:{opacity:0},children:"."})}),u.jsx(Pr,{className:"drawo-content-color inferior",side:"bottom",style:{background:"transparent",padding:0},onPointerDown:F=>F.stopPropagation(),children:u.jsx(u2,{color:g,onChange:k})})]}),u.jsx("div",{className:"tool-separator"}),u.jsxs(ya,{value:String(e==="marker"?s.markerStrokeWidth:e==="quill"?s.quillStrokeWidth:s.drawStrokeWidth),onValueChange:F=>{const D=m();c(D,Number(F))},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx(Ba,{noArrow:!0,className:"draw-stroke-trigger",style:{gap:"0px",width:"fit-content"},children:u.jsx("span",{className:"draw-stroke-option-line-wrap",children:(()=>{const F=e==="marker"?s.markerStrokeWidth:e==="quill"?s.quillStrokeWidth:s.drawStrokeWidth,D=Math.max(0,b.findIndex(U=>U===F));return M(L,D)})()})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.selectionBar?.strokeWidth||"Stroke Width"})})]}),u.jsx(ba,{position:"popper",children:b.map((F,D)=>u.jsx(Hr,{check:!1,value:String(F),className:"draw-stroke-select-item",children:u.jsx("span",{className:"draw-stroke-option-line-wrap",children:M(L,D)})},F))})]})]}):u.jsx(u.Fragment,{}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${t==="select"&&!e?" active":""}`,onClick:()=>{p("select"),w(null)},children:u.jsx(mO,{style:{transform:"translateY(-2px) translateX(-3px) rotate(-46deg)"},strokeWidth:.1})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.selection})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${t==="pan"?" active":""}`,onClick:()=>{p("pan"),w(null)},children:u.jsx(WZ,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.pan})})]}),u.jsx("div",{className:"tool-separator"}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="text"?" active":""}`,onClick:()=>{p("select"),w("text")},children:u.jsx(ug,{strokeWidth:.1})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.text})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="rectangle"?" active":""}`,onClick:()=>{p("select"),w("rectangle")},children:u.jsx(qZ,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.rectangle})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="circle"?" active":""}`,onClick:()=>{p("select"),w("circle")},children:u.jsx(Oz,{strokeWidth:1.5})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.ellipse})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="line"?" active":""}`,onClick:()=>{p("select"),w("line")},children:u.jsx(GZ,{style:{scale:"1.2"}})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.line})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${H.includes(e)?" active":""}`,onClick:()=>{p("select"),w("draw")},children:u.jsx(wO,{strokeWidth:1.5})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.draw})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:"tool-item",onClick:()=>{p("select"),w(null),C.current?.click()},children:u.jsx($Z,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.image})})]}),u.jsx("div",{className:"tool-separator"}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="laser"?" active":""}`,onClick:()=>{p("select"),w("laser")},children:u.jsx(KZ,{strokeWidth:1.5})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.laser})})]})]})};function Jf(){const t=v2(),{scene:e,resolvedTheme:r,isDarkMode:n,isPresentationMode:i,interactionMode:a,drawingTool:s,messages:o,setInteractionMode:A,setDrawingTool:l,handlers:c}=t;return u.jsx(KT,{interactionMode:a,drawingTool:s,isPresentationMode:i,messages:o,setInteractionMode:A,setDrawingTool:l,drawDefaults:e.settings.drawDefaults,invertPaletteInDarkMode:n&&e.settings.colorScheme==="drawo",strokeColors:r.preset.strokeColors,onDrawDefaultStrokeColorChange:c.handleDrawDefaultStrokeColorChange,onDrawDefaultStrokeWidthChange:c.handleDrawDefaultStrokeWidthChange,onSelectImageFiles:f=>c.handleInsertImageFiles?.(f)})}function qT({canUndo:t,canRedo:e,onUndo:r,onRedo:n}){return u.jsxs("div",{className:"undo-bar bottompanel-bar",children:[u.jsx("button",{type:"button",onClick:r,disabled:!t,"aria-label":"Undo",children:u.jsx(_z,{})}),u.jsx("button",{type:"button",onClick:n,disabled:!e,"aria-label":"Redo",children:u.jsx(Hz,{})})]})}function eh(){const t=v2(),{canUndo:e,canRedo:r,undo:n,redo:i}=t;return u.jsx("div",{className:"drawo-bottomleft-bar",children:u.jsx(qT,{canUndo:e,canRedo:r,onUndo:n,onRedo:i})})}function $T({zoomPercent:t,canZoomOut:e,canZoomIn:r,onZoomOut:n,onZoomIn:i,onZoomReset:a}){const s=Math.max(0,Math.min(200,t));return u.jsxs("div",{className:"zoom-bar bottompanel-bar",children:[u.jsx("button",{type:"button",onClick:n,disabled:!e,"aria-label":"Zoom out",children:u.jsx(sO,{strokeWidth:1})}),u.jsx("div",{className:"bottompanel-separator"}),u.jsx("button",{type:"button",onClick:a,"aria-label":"Reset zoom",children:u.jsxs("span",{children:[s,"%"]})}),u.jsx("div",{className:"bottompanel-separator"}),u.jsx("button",{type:"button",onClick:i,disabled:!r,"aria-label":"Zoom in",children:u.jsx(oO,{strokeWidth:1})})]})}function th(){const t=v2(),{scene:e,handlers:r}=t;return u.jsx("div",{className:"drawo-bottomright-bar",children:u.jsx($T,{zoomPercent:Math.round(e.camera.zoom*100),canZoomOut:e.camera.zoom>jh,canZoomIn:e.camera.zoom<Qh,onZoomOut:r.handleZoomOut,onZoomIn:r.handleZoomIn,onZoomReset:r.handleZoomReset})})}function Rse({children:t,className:e,style:r}){const n=v2(),{openTopbarPanel:i}=n,a=i==="sidebar",s=P.useMemo(()=>t?Array.isArray(t)?t:[t]:[],[t]),o=s.some(d=>d?.type===Vf),A=s.some(d=>d?.type===Yf),l=s.some(d=>d?.type===Jf),c=s.some(d=>d?.type===eh),f=s.some(d=>d?.type===th);return u.jsx("div",{className:`app-root ${e??""}`,style:r,children:u.jsx(vK,{children:u.jsx("div",{className:`app-shell ${a?"app-shell--sidebar-open":""}`,children:u.jsxs("div",{className:"app-workspace",children:[o?null:u.jsx(Vf,{}),A?null:u.jsx(Yf,{}),l?null:u.jsx(Jf,{}),c?null:u.jsx(eh,{}),f?null:u.jsx(th,{}),t]})})})})}function Use(t){const{children:e,className:r,style:n,...i}=t;return u.jsx(nO,{...i,children:u.jsx(Rse,{className:r,style:n,children:e})})}const jse=Object.assign(Use,{TopBar:Vf,Canvas:Yf,ToolBar:Jf,UndoBar:eh,ZoomBar:th}),Qse=[{id:"basic",name:"Basic",description:"General shapes and utilities"},{id:"flowchart",name:"Flowchart",description:"Flowchart symbols"},{id:"bpmn",name:"BPMN",description:"BPMN process symbols"},{id:"network",name:"Network",description:"Network infrastructure"},{id:"cloud",name:"Cloud",description:"Cloud services"},{id:"devops",name:"DevOps",description:"DevOps tools"},{id:"security",name:"Security",description:"Security & access"},{id:"devices",name:"Devices",description:"Hardware devices"},{id:"data",name:"Data",description:"Data storage & databases"},{id:"people",name:"People",description:"Users and roles"},{id:"communication",name:"Communication",description:"Messaging & APIs"},{id:"programs",name:"Programs",description:"Software & IDEs"},{id:"languages",name:"Languages",description:"Programming languages"},{id:"aws",name:"AWS",description:"Amazon Web Services"},{id:"custom",name:"Custom",description:"Custom assets"}],GT=[],jd={categories:Qse,assets:GT};function _se(t,e){const r=t.toLowerCase().trim();let n=GT;return e?.categoryId&&(n=n.filter(i=>i.categoryId===e.categoryId)),r?n.filter(i=>i.name.toLowerCase().includes(r)||i.tags.some(a=>a.toLowerCase().includes(r))):n}const BB=t=>null,Hse=(t,e,r,n,i)=>{const a=BB(),s=BB();if(!a&&!s&&null===null)return;const A=l=>{a&&l.getAttribute("fill")!=="none"&&l.setAttribute("fill",a),s&&i!=="none"&&l.getAttribute("stroke")!=="none"&&l.setAttribute("stroke",s)};A(t),t.querySelectorAll("*").forEach(l=>A(l))},Vse=(t,e)=>{if(typeof window>"u")return"";const i=new window.DOMParser().parseFromString(t,"image/svg+xml").documentElement;if(!(i instanceof window.SVGElement)||i.tagName.toLowerCase()!=="svg")return"";Hse(i,e?.fill,e?.stroke,e?.strokeWidth,e?.strokeStyle);const a=i.outerHTML;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`},f9=t=>t.normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"").toLowerCase().trim(),bB=t=>Gc(t).map(e=>e.runs.map(r=>r.text).join("")).join(`
239
+ `},xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:ne.path,strokeWidth:ne.strokeWidth,strokeLinecap:ne.strokeLinecap,fill:ne.fill,stroke:ne.stroke})})},`${Q}-${z}-end`)})})]})]})},fe=()=>u.jsxs(ya,{open:m==="line-stroke-width",onOpenChange:te=>{te?g("line-stroke-width"):m==="line-stroke-width"&&g(null)},value:String($),onValueChange:te=>{g(null),f(b.map(O=>O.id),Number(te))},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{className:"draw-stroke-trigger",style:{gap:"0px",width:"fit-content"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:i.selectionBar.strokeWidth})}),u.jsx("span",{className:"draw-stroke-option-line-wrap",children:f5(J5,Math.max(0,Ko.findIndex(te=>te===$)))})]})}),u.jsx(Pr,{children:u.jsx("p",{children:i.selectionBar.strokeWidth})})]}),u.jsx(ba,{position:"popper",children:Ko.map((te,O)=>u.jsx(Hr,{check:!1,value:String(te),className:"draw-stroke-select-item",children:u.jsx("span",{className:"draw-stroke-option-line-wrap",children:f5(J5,O)})},te))})]});return r.length>1?B.length===r.length?Z():u.jsx(u.Fragment,{}):B.length>0?Z():b.length>0?u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[ee(),fe(),u.jsx("div",{className:"selectionbar-separator"}),K()]}):n==="draw"||n==="marker"||n==="quill"?Z():u.jsx(u.Fragment,{})};function hse({className:t,type:e,value:r,onValueChange:n,...i}){const[a,s]=T.useState(typeof r=="number"&&Number.isFinite(r)?r:10);T.useEffect(()=>{typeof r=="number"&&Number.isFinite(r)&&s(r)},[r]);const o=A=>{Number.isFinite(A)&&(s(A),n(A))};return u.jsxs("div",{className:"drawo-numberinput-container",children:[u.jsx("button",{onClick:()=>{o((Number.isFinite(a)?a:10)-1)},children:u.jsx(sO,{})}),u.jsx("input",{type:e,"data-slot":"input",className:"drawo-numberinput"+(t?" "+t:""),...i,value:a,onChange:A=>{const l=Number.parseInt(A.target.value,10);Number.isFinite(l)&&o(l)}}),u.jsx("button",{onClick:()=>{o((Number.isFinite(a)?a:10)+1)},children:u.jsx(oO,{})})]})}const QT=({scene:t,selectedIds:e,localeMessages:r,editor:n,editingText:i,setEditingText:a,worldToScreen:s,toggleEditorMark:o,onTextCommit:A,onTextFontFamilyChange:l,onTextFontSizeChange:c,onTextFontWeightChange:f,onTextFontStyleChange:d,onTextAlignChange:h,onTextColorChange:C,shapeColors:p,customDrawColorPickerWrapRef:w,customDrawColorPickerContentRef:m,customDrawColorPickerColor:g,setCustomDrawColorPickerColor:B,activeSelectId:b,setActiveSelectId:L})=>{const E=u9(t.elements,e),I=$i(E,Oe=>Oe.textAlign),k=g$(I),M=$i(E,Oe=>Oe.fontFamily),H=$i(E,Oe=>Oe.fontSize),F=typeof H=="number"&&Number.isFinite(H),D=$i(E,Oe=>Oe.fontWeight),U=$i(E,Oe=>Oe.fontStyle),R=$i(E,Oe=>Oe.color)??"multi",$=R==="multi"?E[0]?.color??t.settings.shapeDefaults.textColor:R,re=[...p[0],...p[1]],Z=re.some(Oe=>Oe!=="multi"&&Oe.toLowerCase()===$.toLowerCase())?$:"multi",ee=re.some(Oe=>Oe!=="multi"&&Oe.toLowerCase()===$.toLowerCase()),K=P.useRef(!1),[fe,te]=P.useState(!1),O=D==="bold"||D==="700"||D==="800"||D==="900",Q=U==="italic",z=(()=>{if(!i)return null;try{return G.marks(n)??null}catch{return null}})(),ne=i&&(i.style.fontWeight==="bold"||i.style.fontWeight==="700"||i.style.fontWeight==="800"||i.style.fontWeight==="900"),he=i?.style.fontStyle==="italic",le=z?.bold===!0||z?.bold!==!1&&ne,Be=z?.italic===!0||z?.italic!==!1&&he,V=Oe=>Ic(Oe.text).every(Qe=>Qe.children.every(Xe=>Xe.strikethrough===!0)),oe=E.length>0&&E.every(Oe=>V(Oe)),de=i?le:O,ve=i?Be:Q,Re=i?z?.strikethrough===!0:oe,Pe=()=>{const Oe=!oe;for(const Me of E){const Xe=Ic(Me.text).map(at=>({...at,children:at.children.map(pt=>({...pt,strikethrough:Oe}))}));A(Me.id,lf(Xe))}},Y=()=>{i&&requestAnimationFrame(()=>{try{Bt.focus(n)}catch{return}})},He=Oe=>{te(!0),L("text-color"),B(Kp(Oe))},tt=Oe=>{const Me=E.map(Qe=>Qe.id);C(Me,Oe),i&&Me.includes(i.id)&&a(Qe=>Qe&&{...Qe,style:{...Qe.style,color:Oe}}),Y()};return u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[u.jsx("div",{ref:w,style:{position:"relative",display:"inline-flex"},children:u.jsxs(ya,{open:b==="text-color",onOpenChange:Oe=>{if(Oe){te(!1),L("text-color");return}if(K.current){K.current=!1;return}fe&&te(!1),L(null)},value:String(Z),onValueChange:Oe=>{if(Oe==="multi"){He($);return}L(null),tt(Oe)},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{onPointerDown:Oe=>{Z==="multi"&&(Oe.preventDefault(),Oe.stopPropagation(),He($))},style:{gap:"0px",width:"fit-content"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:r.selectionBar.textColor})}),u.jsx("div",{style:{width:"20px",borderRadius:"100%",border:"1px solid #ffffff20",height:"20px",background:$}})]})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textColor})})]}),u.jsxs(ba,{position:"popper",className:"drawo-colorselect-content",children:[u.jsx("div",{children:u.jsx(ws,{colors:p[0],currentColor:$,uniColor:Oe=>Oe,renderItem:({color:Oe,isMulti:Me,swatch:Qe})=>u.jsx(Hr,{value:Oe,className:"drawo-colorselect-item",check:!1,onPointerDown:Me?Xe=>{Xe.preventDefault(),Xe.stopPropagation(),K.current=!0,He($)}:void 0,onSelect:Me?Xe=>{Xe.preventDefault(),Xe.stopPropagation(),K.current=!0,He($)}:void 0,children:Qe},Oe)})}),u.jsx("div",{children:u.jsx(ws,{colors:p[1],realTotalColors:re,currentColor:$,uniColor:Oe=>Oe,renderItem:({color:Oe,isMulti:Me,swatch:Qe})=>u.jsx(Hr,{value:Oe,className:"drawo-colorselect-item",check:!1,onPointerDown:Me?Xe=>{Xe.preventDefault(),Xe.stopPropagation(),K.current=!0,He($)}:void 0,onSelect:Me?Xe=>{Xe.preventDefault(),Xe.stopPropagation(),K.current=!0,He($)}:void 0,children:Qe},Oe)})})]})]})}),u.jsxs(Tr,{open:b==="text-color"&&(fe||!ee),children:[u.jsx(Nr,{asChild:!0,children:u.jsx("div",{className:"selectionbar-separator"})}),u.jsx(Pr,{className:"drawo-content-color drawo-ultrainferior-colorcontent3",side:"bottom",style:{background:"transparent"},children:u.jsx("div",{ref:m,onPointerDown:Oe=>Oe.stopPropagation(),children:u.jsx(u2,{color:g,onChange:Oe=>{const Me=Oe.hexa||Oe.hex;Me&&(B(Me),tt(Me))}})})})]}),u.jsxs(ya,{open:b==="text-font-family",onOpenChange:Oe=>{Oe?L("text-font-family"):b==="text-font-family"&&L(null)},value:M,onValueChange:Oe=>{L(null),l(E.map(Me=>Me.id),Oe),Y()},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{style:{gap:"0px"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:r.selectionBar.fontFamily})}),M==="Shantell Sans"?u.jsx(VZ,{}):M==="Cascadia Code"?u.jsx(_Z,{}):M==="Imbue"?u.jsx(HZ,{}):u.jsx(jZ,{})]})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.fontFamily})})]}),u.jsxs(ba,{position:"popper",children:[u.jsx(Hr,{check:!1,value:"Rubik",children:r.fontFamilies.simple}),u.jsx(Hr,{check:!1,value:"Shantell Sans",children:r.fontFamilies.handwritten}),u.jsx(Hr,{check:!1,value:"Imbue",children:r.fontFamilies.elegant}),u.jsx(Hr,{check:!1,value:"Cascadia Code",children:r.fontFamilies.technical})]})]}),u.jsx("div",{className:"selectionbar-separator"}),u.jsxs(ya,{open:b==="text-font-size",onOpenChange:Oe=>{Oe?L("text-font-size"):b==="text-font-size"&&L(null)},value:F?String(H):void 0,onValueChange:Oe=>{L(null);const Me=Number.parseInt(Oe,10);Number.isFinite(Me)&&(c(E.map(Qe=>Qe.id),Me),Y())},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{style:{gap:"0px"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:""})}),F?H:"-"]})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.fontSize})})]}),u.jsxs(ba,{position:"popper",children:[u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"16",children:[r.fontSizes.small,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"16"})]}),u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"24",children:[r.fontSizes.medium,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"24"})]}),u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"40",children:[r.fontSizes.large,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"40"})]}),u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"64",children:[r.fontSizes.extraLarge,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"64"})]}),u.jsxs(Hr,{check:!1,className:"fontSize-item",value:"96",children:[r.fontSizes.huge,u.jsx("span",{style:{opacity:.5,marginLeft:"auto",display:"flex"},children:"96"})]}),u.jsx(pte,{}),u.jsx(hse,{value:H,onValueChange:Oe=>{Number.isFinite(Oe)&&(c(E.map(Me=>Me.id),Oe),Y())},placeholder:r.fontSizes.placeholder,type:"number"})]})]}),u.jsx("div",{className:"selectionbar-separator"}),u.jsxs("div",{style:{display:"flex"},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",onPointerDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation()},onClick:()=>{if(i){o("bold"),Bt.focus(n);return}f(E.map(Oe=>Oe.id),de?"200":"700")},className:"toggle-selectionbar-button"+(de?" active":""),children:u.jsx(Vz,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.bold})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",onPointerDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation()},onClick:()=>{if(i){o("italic"),Bt.focus(n);return}d(E.map(Oe=>Oe.id),ve?"normal":"italic")},className:"toggle-selectionbar-button"+(ve?" active":""),children:u.jsx(oZ,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.italic})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",onPointerDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation()},onClick:()=>{if(i){o("strikethrough"),Bt.focus(n);return}Pe()},className:"toggle-selectionbar-button"+(Re?" active":""),children:u.jsx(EZ,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.strikethrough||"Strikethrough (Ctrl+S)"})})]}),u.jsx("div",{className:"selectionbar-separator"}),u.jsxs(ya,{open:b==="text-align",onOpenChange:Oe=>{Oe?L("text-align"):b==="text-align"&&L(null)},value:k,onValueChange:Oe=>{L(null);const Me=Oe==="center"?"center":Oe==="end"?"end":"left",Qe=E.map(at=>at.id);if(h(Qe,Me),!i||!Qe.includes(i.id)){Y();return}const Xe=t.elements.find(at=>at.id===i.id);a(at=>{if(!at)return at;const pt=Xe&&(Xe.type==="rectangle"||Xe.type==="circle")?Gu(Xe,Me):at.anchorX,pe=Uo(pt,at.width,Me),Ke=s(pe,at.anchorY);return{...at,anchorX:pt,left:Ke.x,style:{...at.style,textAlign:Me}}}),Y()},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsxs(Ba,{style:{gap:"0px"},children:[u.jsx("span",{style:{width:"0px",overflow:"hidden"},children:u.jsx(Ua,{placeholder:""})}),k==="left"?u.jsx(wm,{}):k==="center"?u.jsx(mm,{}):u.jsx(ym,{})]})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textAlign})})]}),u.jsxs(ba,{position:"popper",className:"drawo-colorselect-content",children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx(Hr,{check:!1,className:"drawo-textAlign-item",value:"left",children:u.jsx(wm,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textAlignDirection.left})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx(Hr,{check:!1,className:"drawo-textAlign-item",value:"center",children:u.jsx(mm,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textAlignDirection.center})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx(Hr,{check:!1,className:"drawo-textAlign-item",value:"end",children:u.jsx(ym,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:r.selectionBar.textAlignDirection.right})})]})]})]})]})]})},_T=({left:t,top:e,toolbarKey:r,viewportWidth:n,children:i})=>{const a=P.useRef(null),[s,o]=P.useState(0);P.useEffect(()=>{const l=a.current;if(!l)return;const c=new ResizeObserver(f=>{const d=f[0]?.contentRect.width??l.offsetWidth;o(d)});return c.observe(l),o(l.offsetWidth),()=>{c.disconnect()}},[r]);const A=P.useMemo(()=>{const l=s/2,c=8,f=l+c,d=Math.max(f,n-l-c);return Math.min(Math.max(t,f),d)},[t,s,n]);return u.jsx("div",{ref:a,className:"selection-toolbar",onPointerDown:l=>{l.stopPropagation()},onMouseDown:l=>{l.stopPropagation()},style:{left:A,top:e},children:i},r)},HT=({editorWrapRef:t,editor:e,editingText:r,editingDocument:n,editorSessionKey:i,cameraZoom:a,setEditingDocument:s,setEditingText:o,toThemeColor:A,getTextLineHeight:l,onEditorChange:c,onCommitEditingText:f,onToggleEditorMark:d})=>{const h=m=>m instanceof HTMLElement?!!(m.closest(".selection-toolbar")||m.closest(".select-content")||m.closest('[data-slot="select-content"]')||m.closest('[data-slot="select-trigger"]')):!1,C=()=>{requestAnimationFrame(()=>{const m=document.activeElement;t.current?.contains(m)||h(m)||f()})},p=m=>{if((m.ctrlKey||m.metaKey)&&m.key==="Enter"){m.preventDefault(),f();return}if((m.ctrlKey||m.metaKey)&&m.key.toLowerCase()==="b"){m.preventDefault(),d("bold");return}if((m.ctrlKey||m.metaKey)&&m.key.toLowerCase()==="i"){m.preventDefault(),d("italic");return}if((m.ctrlKey||m.metaKey)&&m.key.toLowerCase()==="s"){m.preventDefault(),d("strikethrough");return}m.key==="Escape"&&(s(null),o(null))},w=P.useCallback(({attributes:m,children:g,leaf:B})=>{const b=B;return u.jsx("span",{...m,style:{fontWeight:b.bold===!0?700:b.bold===!1?400:void 0,fontStyle:b.italic===!0?"italic":b.italic===!1?"normal":void 0,textDecorationLine:b.strikethrough===!0?"line-through":"none",textDecorationColor:b.strikethrough===!0?"currentColor":void 0,textDecorationThickness:b.strikethrough===!0?"0.05em":void 0},children:g})},[]);return r?u.jsx("div",{ref:t,style:{position:"absolute",left:r.left,top:r.top,width:r.width,height:r.height,maxWidth:r.maxWidth,margin:0,padding:0,border:"none",outline:"none",cursor:'url("../cursors/text.svg") 12 12, auto',background:"transparent",boxShadow:"none",color:A(r.style.color),fontFamily:r.style.fontFamily,fontSize:r.style.fontSize*a,fontWeight:r.style.fontWeight,fontStyle:r.style.fontStyle,textAlign:r.style.textAlign,lineHeight:`${l(r.style.fontSize)*a}px`},children:u.jsx(x1e,{editor:e,initialValue:n??Ic(r.value),onChange:c,children:u.jsx(C1e,{className:"canvas-text-editor-input",renderLeaf:w,onBlur:C,onKeyDown:p,spellCheck:!1,style:{width:"100%",height:"100%",minHeight:`${r.style.fontSize*a}px`,outline:"none",whiteSpace:"pre",wordBreak:"normal",background:"transparent",color:"inherit",WebkitTextFillColor:"currentColor",caretColor:"currentColor"}})},`${r.id}-${i}`)}):null},dse=(t,e)=>{const r=Zc(1-t/e);return Math.pow(r,1.3)},kA=(t,e)=>{const r=Xc(t);return r?`rgba(${r.r}, ${r.g}, ${r.b}, ${Zc(r.a*e)})`:t},pse=typeof navigator<"u"&&/firefox/i.test(navigator.userAgent),gse=(t,e,r)=>{const i=[];let a=0,s=0;for(let o=0;o<t.length-1;o++){const A=t[o===0?0:o-1],l=t[o],c=t[o+1],f=t[o+2]||t[o+1];for(let d=0;d<=1;d+=1/3){const h=d*d,C=h*d,p=(c.x-A.x)*.5,w=(f.x-l.x)*.5,m=l.x+p*d+(3*(c.x-l.x)-2*p-w)*h+(2*(l.x-c.x)+p+w)*C,g=(c.y-A.y)*.5,B=(f.y-l.y)*.5,b=l.y+g*d+(3*(c.y-l.y)-2*g-B)*h+(2*(l.y-c.y)+g+B)*C,L=l.t+(c.t-l.t)*d,E=dse(e-L,r.lifetime),I=Math.max(r.minWidth,r.baseWidth*E);if(I<=r.minWidth+.01)continue;const k=i[i.length-1];k&&k.x===m&&k.y===b||(i.push({x:m,y:b,widthPx:I}),a+=I,s=Math.max(s,I))}}return{samples:i,maxWidthPx:s,avgWidthPx:i.length>0?a/i.length:r.minWidth}},Cse=t=>{const e=new Path2D;e.moveTo(t[0].x,t[0].y);for(let r=1;r<t.length;r++){const n=t[r];e.lineTo(n.x,n.y)}return e},h5=(t,e,r,n)=>{t.strokeStyle=n.strokeColor,t.lineWidth=n.widthPx/r.zoom,t.shadowColor=n.shadowColor,t.shadowBlur=n.shadowBlurPx/r.zoom,t.shadowOffsetX=0,t.shadowOffsetY=0,t.stroke(e)},vse=(t,e,r,n,i)=>{t.shadowBlur=0,t.shadowColor="rgba(0, 0, 0, 0)",t.shadowOffsetX=0,t.shadowOffsetY=0,t.strokeStyle=n,t.lineWidth=i/r.zoom,t.stroke(e)},mse=(t,e,r,n,i)=>{if(e.length<2)return;const{samples:a,maxWidthPx:s,avgWidthPx:o}=gse(e,r,i);if(a.length<2)return;const A=Cse(a);if(t.lineJoin="round",t.lineCap="round",i.shadow){const l=Math.max(i.minWidth,o),c=document.querySelector("html")?.classList.contains("dark");pse?h5(t,A,n,{strokeColor:kA(i.color,1),shadowColor:kA(i.color,1),widthPx:l,shadowBlurPx:Math.max(18,s*2.5)}):(h5(t,A,n,{strokeColor:kA(i.color,1),shadowColor:kA(i.color,.75),widthPx:l,shadowBlurPx:Math.max(60,s*7)}),h5(t,A,n,{strokeColor:kA(i.color,1),shadowColor:kA(i.color,.9),widthPx:l,shadowBlurPx:Math.max(30,s*3.5)}),h5(t,A,n,{strokeColor:kA(i.color,1),shadowColor:c?"rgba(0,0,0,0.55)":"rgba(255, 255, 255, 0.55)",widthPx:l,shadowBlurPx:Math.max(12,s*1.2)}))}vse(t,A,n,i.color,Math.max(i.minWidth,o))},wse=()=>`laser-${Gi("draw")}`,yse=600,Xf=(t,e)=>t.map(r=>({...r,points:r.points.filter(n=>e-n.t<=yse)})).filter(r=>r.points.length>0),Bse=(t,e,r,n)=>Xf(e?t.map(i=>{if(i.id!==e)return i;const a=i.points[i.points.length-1],s=.3/n;return a&&Math.hypot(r.x-a.x,r.y-a.y)<s?i:{...i,points:[...i.points,r]}}):t,r.t),bse=()=>{const[t,e]=P.useState([]),[r,n]=P.useState(()=>performance.now()),i=P.useRef(null),a=P.useCallback(A=>{const l=performance.now(),c=wse();n(l),e(f=>[...Xf(f,l),{id:c,points:[{x:A.x,y:A.y,t:l}]}]),i.current=c},[]),s=P.useCallback((A,l)=>{const c=performance.now();n(c),e(f=>Bse(f,i.current,{x:A.x,y:A.y,t:c},l))},[]),o=P.useCallback(()=>{i.current=null},[]);return P.useEffect(()=>{if(t.length===0)return;let A=0;const l=()=>{const c=performance.now();n(c),e(f=>Xf(f,c)),A=window.requestAnimationFrame(l)};return A=window.requestAnimationFrame(l),()=>{window.cancelAnimationFrame(A)}},[t.length]),{laserTrails:t,laserNow:r,startLaserTrail:a,appendLaserPoint:s,clearActiveLaserTrail:o}};function xse(t){return u.jsx(sV,{"data-slot":"context-menu",...t})}function Lse({className:t,...e}){return u.jsx(oV,{"data-slot":"context-menu-trigger",className:"drawo-contextmenu-trigger"+(t?" "+t:""),...e})}function gB(t){return u.jsx(fV,{"data-slot":"context-menu-sub",...t})}function Ese({className:t,...e}){return u.jsx(AV,{children:u.jsx(lV,{"data-slot":"context-menu-content",className:"drawo-contextmenu-content"+(t?" "+t:""),...e})})}function Ta({className:t,inset:e,disabled:r=!1,variant:n="default",...i}){return u.jsx(uV,{"data-slot":"context-menu-item","data-inset":e,"data-disabled":r,"data-variant":n,className:"drawo-contextmenu-item"+(t?" "+t:""),...i})}function CB({className:t,inset:e,children:r,...n}){return u.jsxs(hV,{"data-slot":"context-menu-sub-trigger","data-inset":e,className:"drawo-contextmenu-subtrigger"+(t?" "+t:""),...n,children:[r,u.jsx(Mz,{className:"drawo-contextmenu-chevron"})]})}function vB({className:t,...e}){return u.jsx(dV,{"data-slot":"context-menu-sub-content",className:"drawo-contextmenu-subcontent"+(t?" "+t:""),...e})}function Ud({className:t,...e}){return u.jsx(cV,{"data-slot":"context-menu-separator",className:"drawo-contextmenu-separator"+(t?" "+t:""),...e})}const VT=({children:t,hasSelection:e,canFlipSelection:r,selectionType:n,selectionOpacity:i,hasElements:a,localeMessages:s,canUngroupSelection:o,onCut:A,onCopy:l,onPaste:c,onDuplicate:f,onDelete:d,onGroup:h,onUngroup:C,onSelectAll:p,onMoveForward:w,onBringToFront:m,onSendToBack:g,onMoveBackward:B,onFlipHorizontal:b,onFlipVertical:L,onSelectionOpacityChange:E})=>{const I=e&&n==="multiple",k=P.useMemo(()=>typeof i!="number"||!Number.isFinite(i)?100:Math.max(0,Math.min(100,Math.round(i))),[i]),[M,H]=P.useState(k),[F,D]=P.useState(String(k));P.useEffect(()=>{H(k),D(String(k))},[k,e]);const U=R=>{const $=Math.max(0,Math.min(100,Math.round(R)));H($),D(String($)),E($)};return u.jsxs(xse,{children:[u.jsx(Lse,{children:t}),u.jsxs(Ese,{children:[e&&u.jsxs(u.Fragment,{children:[u.jsxs(Ta,{onClick:A,children:[u.jsx(bZ,{}),s.contextMenu.cut,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()})," + ",u.jsx("span",{children:"X"})]})]}),u.jsxs(Ta,{onClick:l,children:[u.jsx(zz,{}),s.contextMenu.copy,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()})," + ",u.jsx("span",{children:"C"})]})]})]}),u.jsxs(Ta,{onClick:c,children:[u.jsx(LZ,{}),s.contextMenu.paste,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()})," + ",u.jsx("span",{children:"V"})]})]}),e&&u.jsxs(u.Fragment,{children:[u.jsxs(Ta,{onClick:f,children:[u.jsx(Zz,{}),s.contextMenu.duplicate,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()}),"+",u.jsx("span",{children:"D"})]})]}),u.jsxs(Ta,{onClick:d,variant:"destructive",children:[u.jsx(MZ,{}),s.contextMenu.delete,u.jsx("span",{className:"drawo-keybind",children:u.jsx("span",{children:"Del"})})]})]}),(I||o||e)&&u.jsx(Ud,{}),(I||o)&&u.jsxs(u.Fragment,{children:[I&&u.jsxs(Ta,{onClick:h,children:[u.jsx(cO,{}),s.contextMenu.group,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()}),"+",u.jsx("span",{children:"G"})]})]}),o&&u.jsxs(Ta,{onClick:C,children:[u.jsx(Gz,{}),s.contextMenu.ungroup,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()}),"+",u.jsx("span",{children:hd()}),"+",u.jsx("span",{children:"G"})]})]})]}),e&&u.jsxs(u.Fragment,{children:[u.jsxs(gB,{children:[u.jsxs(CB,{children:[u.jsx(AZ,{}),s.contextMenu.layers.text]}),u.jsxs(vB,{children:[u.jsxs(Ta,{onClick:m,children:[u.jsx(nX,{}),s.contextMenu.layers.bringToFront]}),u.jsxs(Ta,{onClick:w,children:[u.jsx(iX,{}),s.contextMenu.layers.bringForward]}),u.jsxs(Ta,{onClick:g,children:[u.jsx(tX,{}),s.contextMenu.layers.sendToBack]}),u.jsxs(Ta,{onClick:B,children:[u.jsx(rX,{}),s.contextMenu.layers.sendBackward]})]})]}),u.jsxs(gB,{children:[u.jsxs(CB,{children:[u.jsx(tZ,{}),s.selectionBar.opacity,"..."]}),u.jsx(vB,{className:"drawo-contextmenu-opacity-subcontent",children:u.jsxs("div",{className:"drawo-contextmenu-opacity-popover",onPointerDown:R=>R.stopPropagation(),onClick:R=>R.stopPropagation(),children:[u.jsxs("div",{className:"drawo-contextmenu-opacity-header",children:[u.jsx("span",{children:s.selectionBar.opacity}),u.jsxs("div",{className:"drawo-contextmenu-opacity-input-wrap",children:[u.jsx("input",{className:"drawo-input drawo-numberinput drawo-contextmenu-opacity-input",type:"number",min:0,max:100,step:1,value:F,onChange:R=>{const $=R.target.value.replace(/[^0-9]/g,"");D($)},onBlur:()=>{const R=Number.parseInt(F,10);U(Number.isFinite(R)?R:M)},onKeyDown:R=>{if(R.key==="Enter"){const $=Number.parseInt(F,10);U(Number.isFinite($)?$:M),R.currentTarget.blur();return}R.key==="Escape"&&(D(String(M)),R.currentTarget.blur())}}),u.jsx("span",{className:"drawo-contextmenu-opacity-unit",children:"%"})]})]}),u.jsx(X2,{className:"drawo-contextmenu-opacity-slider",value:[M],min:0,max:100,step:1,onValueChange:R=>{const $=R[0]??M;H($),D(String(Math.round($)))},onValueCommit:R=>{U(R[0]??M)}})]})})]}),u.jsx(Ud,{}),u.jsxs(Ta,{disabled:!r,onClick:b,children:[u.jsx(kZ,{}),"Voltear horizontalmente",u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:hd()}),"+",u.jsx("span",{children:"H"})]})]}),u.jsxs(Ta,{disabled:!r,onClick:L,children:[u.jsx(DZ,{}),"Voltear verticalmente",u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:hd()}),"+",u.jsx("span",{children:"V"})]})]})]}),u.jsx(Ud,{}),u.jsxs(Ta,{disabled:!a,onClick:p,children:[u.jsx(Yz,{}),s.contextMenu.selectEverything,u.jsxs("span",{className:"drawo-keybind",children:[u.jsx("span",{children:FA()})," + ",u.jsx("span",{children:"A"})]})]})]})]})},hu=()=>performance.now(),Sse=220,Fse=4,Dse=4,mB=t=>t.type!=="text",kse=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,wB=(t,e,r)=>t+(e-t)*r,yB=(t,e,r,n,i)=>{const a=6/n;t.save(),t.strokeStyle=i,t.lineWidth=1/n,t.lineCap="round",t.setLineDash([]),t.beginPath(),t.moveTo(e-a/2,r-a/2),t.lineTo(e+a/2,r+a/2),t.moveTo(e+a/2,r-a/2),t.lineTo(e-a/2,r+a/2),t.stroke(),t.restore()},Mse=(t,e,r,n)=>{if(e.length!==0){t.save(),t.strokeStyle=n,t.fillStyle=n,t.lineWidth=1/r,t.setLineDash([6/r,4/r]);for(const i of e)t.beginPath(),i.kind==="spacing"&&i.segmentStart&&i.segmentEnd?(t.moveTo(i.segmentStart.x,i.segmentStart.y),t.lineTo(i.segmentEnd.x,i.segmentEnd.y)):i.axis==="x"?(t.moveTo(i.value,i.start),t.lineTo(i.value,i.end)):(t.moveTo(i.start,i.value),t.lineTo(i.end,i.value)),t.stroke(),yB(t,i.movingPoint.x,i.movingPoint.y,r,n),yB(t,i.targetPoint.x,i.targetPoint.y,r,n);t.restore()}},c9=(t,e,r)=>{if(e.type==="circle"){t.beginPath(),t.ellipse(e.x+e.width/2,e.y+e.height/2,e.width/2,e.height/2,0,0,Math.PI*2);return}a1(t,e.x,e.y,e.width,e.height,r)},Ise=(t,e,r,n)=>{if(e.fillStyle==="none")return;const i=n(e.fill);if(t.save(),e.fillStyle==="solid"){t.fillStyle=i,c9(t,e,r),t.fill(),t.restore();return}const a=8,s=Math.max(1,e.strokeWidth),o=Math.hypot(e.width,e.height)+Math.max(e.width,e.height)*2;c9(t,e,r),t.clip(),t.strokeStyle=i,t.lineWidth=s,t.lineCap="round",t.lineJoin="round";for(let A=e.x-o;A<=e.x+e.width+o;A+=a)t.beginPath(),t.moveTo(A,e.y+e.height+o),t.lineTo(A+o,e.y-o),t.stroke();t.restore()},Ose=(t,e,r,n)=>{e.strokeStyle!=="none"&&(t.save(),t.strokeStyle=n(e.stroke),t.lineCap="round",t.lineJoin="round",t.lineWidth=Math.max(1,e.strokeWidth),e.strokeStyle==="dashed"?t.setLineDash([8,4]):t.setLineDash([]),c9(t,e,r),t.stroke(),t.restore())},WT=({scene:t,shapeColors:e,strokeColors:r,alignmentGuides:n,interactionMode:i,drawingTool:a,localeMessages:s,onPointerDown:o,onPointerMove:A,onPointerUp:l,onWheelPan:c,onWheelZoom:f,onCreateElement:d,onCreateDrawElement:h,onCreateLinePathElement:C,onDrawingToolComplete:p,onDropImageFiles:w,onSelectElements:m,onCopySelection:g,onCutSelection:B,onPasteAt:b,onDuplicateSelection:L,onDeleteSelection:E,onGroupSelection:I,onUngroupSelection:k,onSelectGroupForElement:M,onReorderSelection:H,onFlipSelection:F,onTextFontFamilyChange:D,onTextFontSizeChange:U,onTextFontWeightChange:R,onTextFontStyleChange:$,onTextAlignChange:re,onTextColorChange:Z,onDrawStrokeWidthChange:ee,onDrawStrokeColorChange:K,onShapeFillColorChange:fe,onShapeFillStyleChange:te,onElementsOpacityChange:O,onShapeStrokeColorChange:Q,onShapeStrokeWidthChange:z,onShapeStrokeStyleChange:ne,onDrawDefaultStrokeColorChange:he,onLineStartCapChange:le,onLineEndCapChange:Be,onLineEditStart:V,onLineGeometryChange:oe,onRectangleBorderRadiusChange:de,onGroupResizeStart:ve,onGroupRotateStart:Re,onResizeStart:Pe,onRotateStart:Y,onTextCommit:He})=>{const tt=P.useRef(null),Oe=P.useRef(null),Me=P.useRef(null),[Qe,Xe]=P.useState(null),[at,pt]=P.useState(null),[pe,Ke]=P.useState(0),ie=P.useMemo(()=>F1e(L1e(Kne())),[pe]),ge=P.useRef(new Map),me=P.useRef(null),[Se,Ze]=P.useState(()=>({width:window.innerWidth,height:window.innerHeight})),[Le,be]=P.useState("default"),[ze,st]=P.useState(null),[vt,Rt]=P.useState(null),[yt,Tt]=P.useState(null),[bt,mt]=P.useState(!1),[Nt,ct]=P.useState(!1),[Ct,Vt]=P.useState(null),[_n,ar]=P.useState([]),[Wt,Ur]=P.useState(null),[At,Xt]=P.useState(null),[Wr,qr]=P.useState(null),sn=P.useRef(!1),[,Mt]=P.useState(0),[Kt,mr]=P.useState(null),{laserTrails:hn,laserNow:rr,startLaserTrail:lr,appendLaserPoint:Fr,clearActiveLaserTrail:jr}=bse(),Zr=P.useRef(null),Cn=P.useRef(null),[vi,Hn]=P.useState(!1),[Dt,we]=P.useState(!1),[lt,It]=P.useState(t.settings.drawDefaults.drawStroke),[Dr,Xr]=P.useState(null),[$r,Yr]=P.useState(null),[en,kn]=P.useState(null),[l1,_e]=P.useState(null),[Et,xt]=P.useState(null),[kr,zt]=P.useState(null),[ur,jt]=P.useState(null),xr=j=>{if(!j)return null;const _=ge.current.get(j);if(_)return _;const Ge=new window.Image;Ge.decoding="async",Ge.onload=()=>{Mt(ke=>ke+1)},Ge.onerror=()=>{Mt(ke=>ke+1)};const Ne=me.current;return Ne&&(Ge.style.cssText="position:absolute;width:1px;height:1px;",Ne.appendChild(Ge)),Ge.src=j,ge.current.set(j,Ge),Ge},Mr=P.useRef(null),vn=P.useRef(null),$n=P.useRef(null),Ei=P.useRef(null),Ni=P.useRef(null),Gn=P.useRef(null),Pi=P.useRef(!1),Mn=P.useRef(!1),Ha=P.useRef(!1),Da=P.useRef(null),Ar=use(t),Ts=Ar.length>0,mi=Ar.length===1,ii=mi?Ar[0]:null,Ri=t.elements.filter(j=>Ar.includes(j.id)),Ns=j=>{const _=j.opacity;return typeof _!="number"||!Number.isFinite(_)?100:Math.max(0,Math.min(100,_))},as=Ri.map(Ns),Gl=as.length===0?100:as.every(j=>j===as[0])?as[0]:null,mo=Ri.some(j=>mB(j)),zl=Ar.length===1&&(Ri[0]?.type==="draw"||Ri[0]?.type==="image")?Ri[0].type:"multiple",ss=Ri.some(j=>j.groupId),wo=Ri.length>0&&Ri.every(j=>j.groupId&&j.groupId===Ri[0]?.groupId)?Ri[0]?.groupId??null:null,Va=wo?t.elements.filter(j=>j.groupId===wo).map(j=>j.id):[],Zl=!!wo&&Va.length>1&&Va.length===Ar.length&&Va.every(j=>Ar.includes(j)),Ps=Ar.length===1&&!!Ri[0]?.groupId,qe=t.camera,Rs=t.settings.theme==="dark"||t.settings.theme==="system"&&document.documentElement.classList.contains("dark"),E2=Rs&&t.settings.colorScheme==="drawo",Us=P.useCallback(j=>!j||j.points.length<2?!1:(C(j.points),qr(null),$n.current=null,Ur(null),be("crosshair"),!0),[C]),Xl=j=>{const _=RT(t.elements,Ar).filter(ke=>(ke.drawMode??"draw")===j);if(_.length===0){const ke=j==="marker"?t.settings.drawDefaults.markerStroke:j==="quill"?t.settings.drawDefaults.quillStroke:t.settings.drawDefaults.drawStroke;return{drawMode:j,stroke:ke,strokeWidth:j==="marker"?t.settings.drawDefaults.markerStrokeWidth:j==="quill"?t.settings.drawDefaults.quillStrokeWidth:t.settings.drawDefaults.drawStrokeWidth}}const Ge=_[0].stroke,Ne=_[0].strokeWidth;return{drawMode:j,stroke:typeof Ge=="string"&&Ge.trim().length>0?Ge:j==="marker"?t.settings.drawDefaults.markerStroke:j==="quill"?t.settings.drawDefaults.quillStroke:t.settings.drawDefaults.drawStroke,strokeWidth:typeof Ne=="number"&&Number.isFinite(Ne)?Math.max(1,Ne):j==="marker"?t.settings.drawDefaults.markerStrokeWidth:j==="quill"?t.settings.drawDefaults.quillStrokeWidth:t.settings.drawDefaults.drawStrokeWidth}},In=j=>{const _=typeof j=="string"&&j.trim().length>0?j:t.settings.shapeDefaults.textColor;return E2?Rf(_):_},Vn=P.useCallback((j,_)=>({x:j/qe.zoom+qe.x,y:_/qe.zoom+qe.y}),[qe.x,qe.y,qe.zoom]),Ui=P.useCallback((j,_)=>({x:(j-qe.x)*qe.zoom,y:(_-qe.y)*qe.zoom}),[qe.x,qe.y,qe.zoom]),Wa=P.useCallback((j,_,Ge)=>{const Ne=Gc(_),ke=Ne.map(je=>GM(j,Ge,je)),Te=Math.max(16,...ke),Ye=Mf(Ge.fontSize),$e=Ge.fontSize+(Ne.length-1)*Ye;return{lines:Ne,lineWidths:ke,width:Te,height:$e,lineHeight:Ye}},[]),js=P.useRef(new Map),os=(j,_,Ge,Ne)=>{const ke=`${Ge}::${Ne.fontFamily}::${Ne.fontSize}::${Ne.fontWeight}::${Ne.fontStyle}`,Te=js.current.get(_);if(Te&&Te.cacheKey===ke)return Te.layout;const Ye=Wa(j,Ge,Ne);if(js.current.set(_,{cacheKey:ke,layout:Ye}),js.current.size>6e3){const $e=js.current.keys().next().value;typeof $e=="string"&&js.current.delete($e)}return Ye},gA=(j,_,Ge,Ne,ke,Te)=>{const Ye=Te?os(j,Te,_,ke):Wa(j,_,ke);return Ye.lines.forEach(($e,je)=>{const ft=Ye.lineWidths[je]??0,Ft=Uo(Ge,ft,ke.textAlign),gt=Ne+je*Ye.lineHeight;let Jt=Ft;for(const er of $e.runs){if(!er.text)continue;j.font=yc(ke,er);const or=j.measureText(er.text).width;if(j.fillText(er.text,Jt,gt),er.strikethrough){const ye=j.strokeStyle,sr=j.lineWidth;if(j.strokeStyle=j.fillStyle,j.lineWidth=Math.max(ke.fontSize*.04,.75),er.strikethrough){const nr=gt-ke.fontSize*.3;j.beginPath(),j.moveTo(Jt,nr),j.lineTo(Jt+or,nr),j.stroke()}j.strokeStyle=ye,j.lineWidth=sr}Jt+=or}}),Ye},u1=(j,_,Ge,Ne,ke,Te)=>{const Ye=Te?os(j,Te,_,ke):Wa(j,_,ke),$e=Ne-Ye.height/2;return Ye.lines.forEach((je,ft)=>{const Ft=Ye.lineWidths[ft]??0;let gt=Uo(Ge,Ft,ke.textAlign);const Jt=$e+ke.fontSize+ft*Ye.lineHeight;for(const er of je.runs){if(!er.text)continue;j.font=yc(ke,er);const or=j.measureText(er.text).width;if(j.fillText(er.text,gt,Jt),er.strikethrough){const ye=j.strokeStyle,sr=j.lineWidth;if(j.strokeStyle=j.fillStyle,j.lineWidth=Math.max(ke.fontSize*.04,.75),er.strikethrough){const nr=Jt-ke.fontSize*.3;j.beginPath(),j.moveTo(gt,nr),j.lineTo(gt+or,nr),j.stroke()}j.strokeStyle=ye,j.lineWidth=sr}gt+=or}}),Ye};P.useEffect(()=>{if(!(vi||Dt||Dr==="shape-fill-color"||Dr==="shape-stroke-color"||Dr==="text-color"))return;const _=Ne=>{const ke=Ne.target;ke&&(Zr.current?.contains(ke)||Cn.current?.contains(ke)||(Hn(!1),we(!1),Xr(null)))},Ge=Ne=>{Ne.key==="Escape"&&(Hn(!1),we(!1),Xr(null))};return window.addEventListener("pointerdown",_),window.addEventListener("keydown",Ge),()=>{window.removeEventListener("pointerdown",_),window.removeEventListener("keydown",Ge)}},[Dr,vi,Dt]);const S2=(j,_,Ge,Ne)=>{if(V1(j))return null;const{start:ke,end:Te,throughPoint:Ye}=Wp(j),$e=Math.max(7/Ne,$u/(2.3*Ne));return Math.hypot(_-ke.x,Ge-ke.y)<=$e?"start":Math.hypot(_-Te.x,Ge-Te.y)<=$e?"end":Math.hypot(_-Ye.x,Ge-Ye.y)<=$e?"control":null},Qs=(j,_,Ge,Ne)=>{if(!V1(j)||!j.points)return null;const ke=Math.max(7/Ne,$u/(2.15*Ne));let Te=null,Ye=Number.POSITIVE_INFINITY;for(let $e=0;$e<j.points.length;$e++){const je=j.points[$e],ft=Math.hypot(_-je.x,Ge-je.y);ft<=ke&&ft<Ye&&(Te=$e,Ye=ft)}return Te},F2=(j,_,Ge=!0)=>{if(j.type==="rectangle"||j.type==="circle"||j.type==="image"||j.type==="svg")return{x:j.x,y:j.y,width:j.width,height:j.height};if(j.type==="draw")return m$(j);if(j.type==="line")return zu(j);const Ne=_?Wa(_,j.text,{fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle}).width:Math.max(16,hA(j)),ke=Uo(j.x,Ne,j.textAlign),Te=p2(j),Ye={x:ke,y:j.y-j.fontSize,width:Ne,height:Te};if(!Ge)return Ye;const $e=f$/qe.zoom;return{x:Ye.x-$e,y:Ye.y-$e,width:Ye.width+$e*2,height:Ye.height+$e*2}},Ka=(j,_,Ge=!0)=>{const Ne=t.elements.find(ke=>ke.id===j);return Ne?F2(Ne,_,Ge):null},ka=(j,_,Ge,Ne)=>{const ke=$u/Ge,Te=c$/Ge,Ye=["nw","ne","se","sw"],$e=je=>{const ft=lI(_,je),Ft=vt===je,gt=ze===je;let Jt=1,er=2/Ge,fr=.1,or=1/Ge;gt?(Jt=1.35,er=8/Ge,fr=.25,or=2.5/Ge):Ft&&(Jt=1.2,er=5/Ge,fr=.18,or=1.5/Ge);const ye=ke*Jt,sr=ye/2,nr=ft.x-sr,ir=ft.y-sr;if(j.save(),j.shadowColor=`rgba(0, 0, 0, ${fr})`,j.shadowBlur=er,j.shadowOffsetX=0,j.shadowOffsetY=1.5/Ge,j.fillStyle=gt?Ne:In(t.settings.shapeDefaults.fill),j.strokeStyle=Ne,j.lineWidth=or,a1(j,nr,ir,ye,ye,Te*Jt),j.fill(),j.stroke(),(Ft||gt)&&(j.strokeStyle=Ne,j.globalAlpha=gt?.15:.08,j.lineWidth=(4+(gt?2:0))/Ge,a1(j,nr,ir,ye,ye,Te*Jt),j.stroke(),j.globalAlpha=1),Ft||gt){j.fillStyle=gt?"rgba(255, 255, 255, 0.25)":"rgba(255, 255, 255, 0.15)";const mn=ye*.5;j.beginPath(),j.arc(ft.x,ft.y,mn/2,0,Math.PI*2),j.fill()}j.restore()};for(const je of Ye)$e(je)},F1=(j,_,Ge=!0)=>{if(j.length===0)return null;const Ne=j.map(je=>Ka(je,_,Ge)).filter(je=>je!==null);if(Ne.length===0)return null;const ke=Math.min(...Ne.map(je=>je.x)),Te=Math.min(...Ne.map(je=>je.y)),Ye=Math.max(...Ne.map(je=>je.x+je.width)),$e=Math.max(...Ne.map(je=>je.y+je.height));return{x:ke,y:Te,width:Ye-ke,height:$e-Te}},qa=j=>{if(Kt)return;const _=t.elements.filter(je=>Ar.includes(je.id)&&mB(je));if(_.length===0)return;const Ge=_.map(je=>({id:je.id,bounds:F2(je)})),Ne=Math.min(...Ge.map(je=>je.bounds.x)),ke=Math.min(...Ge.map(je=>je.bounds.y)),Te=Math.max(...Ge.map(je=>je.bounds.x+je.bounds.width)),Ye=Math.max(...Ge.map(je=>je.bounds.y+je.bounds.height)),$e=new Map;for(const je of Ge){const ft=N1(je.bounds),Ft=j==="horizontal"?Ne+Te-(je.bounds.x+je.bounds.width):je.bounds.x,gt=j==="vertical"?ke+Ye-(je.bounds.y+je.bounds.height):je.bounds.y;$e.set(je.id,{fromCenterX:ft.x,fromCenterY:ft.y,toCenterX:ft.x+(Ft-je.bounds.x),toCenterY:ft.y+(gt-je.bounds.y)})}mr({axis:j,startedAt:hu(),durationMs:Sse,items:$e})};P.useEffect(()=>{if(!Kt)return;let j=0;const _=()=>{if(hu()-Kt.startedAt>=Kt.durationMs){mr(null),F(Kt.axis);return}Mt(Ne=>Ne+1),j=requestAnimationFrame(_)};return j=requestAnimationFrame(_),()=>{cancelAnimationFrame(j)}},[Kt,F]);const yo=t.elements.some(j=>j.type==="image"&&j.isAnimated===!0);P.useEffect(()=>{if(!yo)return;let j=0;const _=()=>{Mt(Ge=>Ge+1),j=requestAnimationFrame(_)};return j=requestAnimationFrame(_),()=>{cancelAnimationFrame(j)}},[yo]),P.useEffect(()=>{vn.current=Wr},[Wr]),P.useEffect(()=>{a!=="line"&&(vn.current&&Us(vn.current),$n.current&&($n.current=null,qr(null)))},[Us,a]);const D1=(()=>{if(Ar.length===0||bt||ze||yt||Et||ur!==null)return null;const j=F1(Ar,void 0,!0);if(!j)return null;const _=Ui(j.x,j.y),Ge=Ui(j.x+j.width,j.y+j.height),Ne=(_.x+Ge.x)/2,ke=Math.max(8,Math.min(_.y-42,Se.height-46));return{left:Ne,top:ke,key:Ar.join("|")}})(),CA=(j,_)=>{if(Qe)return null;const Ge=tt.current;if(!Ge)return null;const Ne=Ge.getContext("2d");if(!Ne)return null;if(Ar.length>1){const ft=F1(Ar,Ne,!0);return ft?W0(ft,j,_,qe.zoom):null}if(!ii)return null;const ke=t.elements.find(ft=>ft.id===ii);if(ke?.type==="line")return null;ke?.type==="text"&&(Ne.font=su(ke));const Te=Ka(ii,Ne);if(!Te)return null;const Ye=(ke?.rotation??0)*Math.PI/180,$e=N1(Te),je=ku(j,_,$e.x,$e.y,-Ye);return W0(Te,je.x,je.y,qe.zoom)},_s=(j,_,Ge,Ne)=>{const ke=Math.min(j.width,j.height)/2,Ye=Math.max(0,Math.min(_,ke))+Qv/Ge;return Ne==="nw"?{x:j.x+Ye,y:j.y+Ye}:Ne==="ne"?{x:j.x+j.width-Ye,y:j.y+Ye}:Ne==="se"?{x:j.x+j.width-Ye,y:j.y+j.height-Ye}:{x:j.x+Ye,y:j.y+j.height-Ye}},D2=()=>{if(!ii)return null;const j=t.elements.find(_=>_.id===ii);return!j||j.type!=="rectangle"?null:j},$a=(j,_,Ge,Ne)=>{const ke={x:j.x,y:j.y,width:j.width,height:j.height},Te=["nw","ne","se","sw"],Ye=jv/(2*Ne);for(const $e of Te){const je=_s(ke,j.borderRadius,Ne,$e);if(Math.hypot(_-je.x,Ge-je.y)<=Ye)return $e}return null},k1=()=>u9(t.elements,Ar).some(ke=>ke.type==="text")||Qe?u.jsx(QT,{scene:t,selectedIds:Ar,localeMessages:s,editor:ie,editingText:Qe,setEditingText:Xe,worldToScreen:Ui,toggleEditorMark:tn,onTextCommit:He,onTextFontFamilyChange:D,onTextFontSizeChange:U,onTextFontWeightChange:R,onTextFontStyleChange:$,onTextAlignChange:re,onTextColorChange:Z,shapeColors:e,customDrawColorPickerWrapRef:Zr,customDrawColorPickerContentRef:Cn,customDrawColorPickerColor:lt,setCustomDrawColorPickerColor:It,activeSelectId:Dr,setActiveSelectId:Xr}):cse(t.elements,Ar).length>0?u.jsx(ST,{}):PT(t.elements,Ar).length>0?u.jsx(UT,{scene:t,shapeColors:e,selectedIds:Ar,localeMessages:s,customDrawColorPickerWrapRef:Zr,customDrawColorPickerContentRef:Cn,customDrawColorPickerColor:lt,setCustomDrawColorPickerColor:It,onShapeFillColorChange:fe,onShapeFillStyleChange:te,onShapeStrokeColorChange:Q,onShapeStrokeWidthChange:z,onShapeStrokeStyleChange:ne,uniColor:Jr,activeSelectId:Dr,setActiveSelectId:Xr}):u.jsx(jT,{scene:t,strokeColors:r,selectedIds:Ar,drawingTool:a,localeMessages:s,customDrawColorPickerWrapRef:Zr,customDrawColorPickerContentRef:Cn,isCustomDrawColorPickerOpen:vi,setIsCustomDrawColorPickerOpen:Hn,customDrawColorPickerColor:lt,setCustomDrawColorPickerColor:It,onDrawStrokeWidthChange:ee,onDrawStrokeColorChange:K,onDrawDefaultStrokeColorChange:he,onLineStartCapChange:le,onLineEndCapChange:Be,uniColor:Jr,activeSelectId:Dr,setActiveSelectId:Xr}),Ga=(j,_,Ge)=>{if(Mn.current&&!Qe)return"grab";if(a&&a!=="image")return"crosshair";const Ne=D2();if(Ne){const Ye={x:Ne.x,y:Ne.y,width:Ne.width,height:Ne.height},$e=N1(Ye),je=ku(j,_,$e.x,$e.y,-Ne.rotation*Math.PI/180);if($a(Ne,je.x,je.y,qe.zoom))return"pointer"}if(i==="pan")return"grab";if(ii){const Ye=t.elements.find($e=>$e.id===ii&&$e.type==="line");if(Ye){const $e=rd(Ye,j,_);if(V1(Ye)){const je=Qs(Ye,$e.x,$e.y,qe.zoom);if(zt(je),_e(null),je!==null)return"pointer"}else{const je=S2(Ye,$e.x,$e.y,qe.zoom);if(_e(je),zt(null),je)return"pointer"}}else _e(null),zt(null)}else _e(null),zt(null);const ke=CA(j,_);return ke?(Rt(ke.mode==="resize"?ke.handle:null),ke.mode==="resize"?Au(ke.handle):lu(ke.handle)):(Rt(null),Du(t.elements,j,_)?Ge?"clone":"grab":"default")},vA=j=>{const _=Math.min(j.startX,j.currentX),Ge=Math.min(j.startY,j.currentY),Ne=Math.abs(j.currentX-j.startX),ke=Math.abs(j.currentY-j.startY);return{x:_,y:Ge,width:Ne,height:ke}},mA=j=>{const _=j.currentX-j.startX,Ge=j.currentY-j.startY;if(j.fromCenter){let Ne=Math.abs(_),ke=Math.abs(Ge);if(j.lockAspect){const Te=Math.max(Ne,ke);Ne=Te,ke=Te}return{x:j.startX-Ne,y:j.startY-ke,width:Ne*2,height:ke*2}}if(j.lockAspect){const Ne=Math.max(Math.abs(_),Math.abs(Ge));return{x:_>=0?j.startX:j.startX-Ne,y:Ge>=0?j.startY:j.startY-Ne,width:Ne,height:Ne}}return{x:Math.min(j.startX,j.currentX),y:Math.min(j.startY,j.currentY),width:Math.abs(_),height:Math.abs(Ge)}},ha=(j,_,Ge,Ne)=>{const ke=Ge-j,Te=Ne-_;if(ke===0&&Te===0)return{x:Ge,y:Ne};const Ye=Math.atan2(Te,ke),$e=Math.round(Ye/(Math.PI/4))*(Math.PI/4),je=Math.hypot(ke,Te);return{x:j+Math.cos($e)*je,y:_+Math.sin($e)*je}},wA=j=>{if(j.lockAspect){const _=ha(j.startX,j.startY,j.currentX,j.currentY);return{startX:j.startX,startY:j.startY,endX:_.x,endY:_.y}}return{startX:j.startX,startY:j.startY,endX:j.currentX,endY:j.currentY}},x=(j,_)=>j.x<_.x+_.width&&j.x+j.width>_.x&&j.y<_.y+_.height&&j.y+j.height>_.y,W=j=>{const Ge=tt.current?.getContext("2d"),Ne=vA(j),ke=new Set;for(const Te of t.elements){Te.type==="text"&&Ge&&(Ge.font=su(Te));const Ye=Ka(Te.id,Ge,!0);if(!(!Ye||!x(Ne,Ye))){if(!Te.groupId){ke.add(Te.id);continue}for(const $e of t.elements)$e.groupId===Te.groupId&&ke.add($e.id)}}return[...ke]},Ae=P.useCallback(j=>{const _=tt.current;if(!_)return;const Ge=_.getContext("2d");if(!Ge)return;if(Ke(gt=>gt+1),j.type==="text"){pt(Ic(j.text));const gt=Wa(Ge,j.text,{fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle}),Jt=Uo(j.x,gt.width,j.textAlign),er=Ui(Jt,j.y-j.fontSize);Xe({id:j.id,value:j.text,anchorX:j.x,anchorY:j.y-j.fontSize,left:er.x,top:er.y,width:gt.width*qe.zoom,height:gt.height*qe.zoom,style:{fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle,color:j.color,textAlign:j.textAlign}});return}const Ne={id:j.id,x:Gu(j,j.textAlign),y:j.y+j.height/2,text:j.text,fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle,color:j.color,textAlign:j.textAlign},ke=Wa(Ge,Ne.text,{fontFamily:Ne.fontFamily,fontSize:Ne.fontSize,fontWeight:Ne.fontWeight,fontStyle:Ne.fontStyle}),Te=Math.max(16,j.width-P8*2),Ye=Math.min(ke.width,Te),$e=Gu(j,j.textAlign),je=j.y+j.height/2-ke.height/2,ft=Uo($e,Ye,j.textAlign),Ft=Ui(ft,je);pt(Ic(j.text)),Xe({id:j.id,value:j.text,anchorX:$e,anchorY:je,left:Ft.x,top:Ft.y,width:Ye*qe.zoom,height:ke.height*qe.zoom,maxWidth:Te*qe.zoom,style:{fontFamily:j.fontFamily,fontSize:j.fontSize,fontWeight:j.fontWeight,fontStyle:j.fontStyle,color:j.color,textAlign:j.textAlign}})},[qe.zoom,Wa,Ui]),Ce=j=>{if(!Qe)return;const _=at?lf(at):Qe.value;He(Qe.id,_);try{ut.deselect(ie)}catch{}pt(null),Xe(null)};P.useEffect(()=>{const j=()=>{Ze({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",j),()=>{window.removeEventListener("resize",j)}},[]),P.useEffect(()=>{const j=tt.current;if(!j)return;const _=Ge=>{if(Qe){Ge.preventDefault();return}const Ne=j.getBoundingClientRect(),ke=Ge.clientX-Ne.left,Te=Ge.clientY-Ne.top;if(Ge.preventDefault(),Ge.ctrlKey||Ge.metaKey){f(ke,Te,Ge.deltaY);return}const Ye=Ge.shiftKey&&Math.abs(Ge.deltaX)<Math.abs(Ge.deltaY)?Ge.deltaY:Ge.deltaX,$e=Ge.shiftKey&&Math.abs(Ge.deltaX)<Math.abs(Ge.deltaY)?0:Ge.deltaY;c(Ye,$e)};return j.addEventListener("wheel",_,{passive:!1}),()=>{j.removeEventListener("wheel",_)}},[Qe,c,f]),P.useEffect(()=>{const j=tt.current;if(!j)return;const _=j.getContext("2d");if(!_)return;const Ge=getComputedStyle(j),Ne=Ge.getPropertyValue("--accent").trim()||"#7c5cff",ke=$v(Ge.getPropertyValue("--accent-rgb"))||$v(Ne)||"124, 92, 255",Te=`rgba(${ke}, 0.45)`,Ye=`rgba(${ke}, 0.12)`,$e=Rs?"#ff9b9b":"#ff7a7a",je=Kt?Math.min(1,Math.max(0,(hu()-Kt.startedAt)/Kt.durationMs)):null,ft=je===null?null:kse(je),Ft=(ye,sr,nr)=>{if(!Kt||ft===null)return;const ir=Kt.items.get(nr);if(!ir)return;const mn=wB(ir.fromCenterX,ir.toCenterX,ft),ji=wB(ir.fromCenterY,ir.toCenterY,ft),Zn=Kt.axis==="horizontal"?1-ft*2:1,Hi=Kt.axis==="vertical"?1-ft*2:1,za=Math.abs(Zn)<.001?Zn<0?-.001:.001:Zn,Xn=Math.abs(Hi)<.001?Hi<0?-.001:.001:Hi,Qr=N1(sr);ye.translate(mn,ji),ye.scale(za,Xn),ye.translate(-Qr.x,-Qr.y)};if(_.fillStyle=t.settings.drawDefaults.canvas,_.fillRect(0,0,j.width,j.height),_.save(),_.setTransform(qe.zoom,0,0,qe.zoom,-qe.x*qe.zoom,-qe.y*qe.zoom),t.settings.showGrid){const ye=Math.max(4,t.settings.gridSize),sr=Math.max(1,Math.ceil(h$/(ye*qe.zoom))),nr=ye*sr,ir=qe.x,mn=qe.y,ji=qe.x+j.width/qe.zoom,Zn=qe.y+j.height/qe.zoom,Hi=Math.floor(ir/nr)*nr,za=Math.floor(mn/nr)*nr,Xn=Rs?"#ffffff10":"#B3B2B370";if(t.settings.gridStyle==="squares"){_.strokeStyle=Xn,_.lineWidth=1/qe.zoom,_.beginPath();for(let Qr=Hi;Qr<=ji;Qr+=nr)_.moveTo(Qr,mn),_.lineTo(Qr,Zn);for(let Qr=za;Qr<=Zn;Qr+=nr)_.moveTo(ir,Qr),_.lineTo(ji,Qr);_.stroke()}else{const Qr=2/qe.zoom,M1=Qr/2;_.fillStyle=Xn;for(let Lt=Hi;Lt<=ji;Lt+=nr)for(let rn=za;rn<=Zn;rn+=nr)_.fillRect(Lt-M1,rn-M1,Qr,Qr)}}const gt=new Set(Ar),Jt=Ct!==null?new Set(_n):null,er=Math.max(160/qe.zoom,48),fr={x:qe.x-er,y:qe.y-er,width:j.width/qe.zoom+er*2,height:j.height/qe.zoom+er*2},or=ye=>!(ye.x+ye.width<fr.x||ye.x>fr.x+fr.width||ye.y+ye.height<fr.y||ye.y>fr.y+fr.height);for(const ye of t.elements){const sr=gt.has(ye.id),nr=sr&&(!Zl||Ar.length===1),ir=Ct!==null&&Jt?.has(ye.id)&&!sr,mn=Ar.length>1,ji=ye.rotation*Math.PI/180,Zn=Ns(ye)/100;if(!sr&&!ir&&Qe?.id!==ye.id){let Lt=null;if(ye.type==="draw"||ye.type==="image"||ye.type==="rectangle"||ye.type==="circle"?Lt={x:ye.x,y:ye.y,width:ye.width,height:ye.height}:ye.type==="line"&&(Lt=zu(ye)),Lt&&!or(Lt))continue}if(ye.type==="draw"){const Lt=ye.drawMode??"draw",rn={x:ye.x,y:ye.y,width:ye.width,height:ye.height},on={x:rn.x-ye.x,y:rn.y-ye.y,width:rn.width,height:rn.height},wi=N1(rn);if(_.save(),Ft(_,rn,ye.id),_.translate(wi.x,wi.y),_.rotate(ji),_.translate(-wi.x,-wi.y),_.translate(ye.x,ye.y),ye.points.length>0){const Lr=j8(Lt,Rs),Bo=_.globalCompositeOperation,Ma=_.globalAlpha;_.globalCompositeOperation=Lr.compositeOperation,_.globalAlpha*=Lr.opacity*Zn;const yi=U8(ye.strokeWidth);_.strokeStyle=In(ye.stroke),_.fillStyle=In(ye.stroke),_.lineWidth=yi,_.lineJoin="round",_.lineCap=Q8();const Si=ye.points;Si.length===1?Lt==="marker"?nl(_,Si,yi):Lt==="quill"?il(_,Si,yi,t.settings.quillDrawOptimizations):(_.beginPath(),_.arc(Si[0].x,Si[0].y,_.lineWidth/2,0,Math.PI*2),_.fillStyle=In(ye.stroke),_.fill()):Si.length>1&&(Lt==="marker"?nl(_,Si,yi):Lt==="quill"?il(_,Si,yi,t.settings.quillDrawOptimizations):(_.beginPath(),Uf(_,Si),_.stroke())),_.globalCompositeOperation=Bo,_.globalAlpha=Ma}nr?(_.strokeStyle=mn?Te:Ne,_.lineWidth=1/qe.zoom,_.strokeRect(on.x,on.y,on.width,on.height),mi&&ka(_,on,qe.zoom,Ne)):ir&&(_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(on.x,on.y,on.width,on.height)),_.restore();continue}if(ye.type==="image"){const Lt=ye,rn={x:Lt.x,y:Lt.y,width:Lt.width,height:Lt.height},on=N1(rn),wi=Lt.src?xr(Lt.src):null,Lr=Math.min(16/qe.zoom,Math.min(Lt.width,Lt.height)/6);_.save(),Ft(_,rn,Lt.id),_.translate(on.x,on.y),_.rotate(ji),_.translate(-on.x,-on.y);const Bo=_.globalAlpha;_.globalAlpha*=Zn,(Lt.flipX||Lt.flipY)&&(_.translate(on.x,on.y),_.scale(Lt.flipX?-1:1,Lt.flipY?-1:1),_.translate(-on.x,-on.y)),_.shadowColor="rgba(15, 23, 42, 0.14)",_.shadowBlur=18/qe.zoom,_.shadowOffsetY=6/qe.zoom,_.fillStyle=In(t.settings.shapeDefaults.fill),a1(_,Lt.x,Lt.y,Lt.width,Lt.height,Lr),_.fill(),_.save(),a1(_,Lt.x,Lt.y,Lt.width,Lt.height,Lr),_.clip(),wi&&wi.complete&&wi.naturalWidth>0&&wi.naturalHeight>0?_.drawImage(wi,Lt.x,Lt.y,Lt.width,Lt.height):(_.fillStyle=In("#e6e7e8"),_.fillRect(Lt.x,Lt.y,Lt.width,Lt.height)),_.restore(),_.shadowColor="transparent",_.strokeStyle=In("rgba(15, 23, 42, 0.08)"),_.lineWidth=1/qe.zoom,a1(_,Lt.x,Lt.y,Lt.width,Lt.height,Lr),_.stroke(),_.globalAlpha=Bo,nr?(_.strokeStyle=mn?Te:Ne,_.lineWidth=1/qe.zoom,_.strokeRect(Lt.x,Lt.y,Lt.width,Lt.height)):ir&&(_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(Lt.x,Lt.y,Lt.width,Lt.height)),nr&&mi&&ka(_,rn,qe.zoom,Ne),_.restore();continue}if(ye.type==="rectangle"||ye.type==="circle"){const Lt={x:ye.x,y:ye.y,width:ye.width,height:ye.height},rn=N1(Lt),on=ye.type==="rectangle"?Math.max(0,Math.min(ye.borderRadius,Math.min(ye.width,ye.height)/2)):0;_.save(),Ft(_,Lt,ye.id),_.translate(rn.x,rn.y),_.rotate(ji),_.translate(-rn.x,-rn.y);const wi=_.globalAlpha;if(_.globalAlpha*=Zn,Ise(_,ye,on,In),Ose(_,ye,on,In),Qe?.id!==ye.id&&ye.text.trim().length>0){const Lr={id:`${ye.id}-shape-text`,x:Gu(ye,ye.textAlign),y:ye.y+ye.height/2,text:ye.text,fontFamily:ye.fontFamily,fontSize:ye.fontSize,fontWeight:ye.fontWeight,fontStyle:ye.fontStyle,color:ye.color,textAlign:ye.textAlign};_.save(),ye.type==="circle"?(_.beginPath(),_.ellipse(ye.x+ye.width/2,ye.y+ye.height/2,ye.width/2,ye.height/2,0,0,Math.PI*2),_.clip()):(a1(_,ye.x,ye.y,ye.width,ye.height,on),_.clip()),_.font=su(Lr),_.fillStyle=In(Lr.color),_.textAlign="left",_.textBaseline="alphabetic",u1(_,Lr.text,Lr.x,ye.y+ye.height/2,{fontFamily:Lr.fontFamily,fontSize:Lr.fontSize,fontWeight:Lr.fontWeight,fontStyle:Lr.fontStyle,textAlign:Lr.textAlign},`shape:${ye.id}`),_.restore()}if(_.globalAlpha=wi,nr?(_.strokeStyle=mn?Te:Ne,_.lineWidth=1/qe.zoom,_.strokeRect(ye.x,ye.y,ye.width,ye.height)):ir&&(_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(ye.x,ye.y,ye.width,ye.height)),nr&&mi&&(ka(_,Lt,qe.zoom,Ne),ye.type==="rectangle")){const Lr=Ei.current;if(Lr&&$M(ye,Lr.x,Lr.y)){const Ma=["nw","ne","se","sw"],yi=jv/(2*qe.zoom);for(const Si of Ma){const As=_s(Lt,ye.borderRadius,qe.zoom,Si);_.fillStyle=Ne,_.beginPath(),_.arc(As.x,As.y,yi,0,Math.PI*2),_.fill(),_.strokeStyle=In(t.settings.shapeDefaults.fill),_.lineWidth=1/qe.zoom,_.beginPath(),_.arc(As.x,As.y,yi,0,Math.PI*2),_.stroke()}}}_.restore();continue}if(ye.type==="line"){const Lt=ye,rn=zu(Lt);_.save(),Ft(_,rn,Lt.id),cI({ctx:_,lineElement:Lt,elementOpacity:Zn,zoom:qe.zoom,accentColor:Ne,accentSelectionColor:Te,toThemeColor:In,shouldShowElementSelection:nr,isMultiSelection:mn,isMarqueePreview:ir,canTransformSelection:mi,hoveredLineHandle:l1,activeLineHandle:Et,hoveredLinePointIndex:kr,activeLinePointIndex:ur}),_.restore();continue}if(Qe?.id===ye.id||ye.type==="svg")continue;const Hi=os(_,`text:${ye.id}`,ye.text,{fontFamily:ye.fontFamily,fontSize:ye.fontSize,fontWeight:ye.fontWeight,fontStyle:ye.fontStyle}),za=Hi.width,Xn={x:Uo(ye.x,za,ye.textAlign),y:ye.y-ye.fontSize,width:za,height:Hi.height},Qr=N1(Xn);_.save(),_.translate(Qr.x,Qr.y),_.rotate(ji),_.translate(-Qr.x,-Qr.y);const M1=_.globalAlpha;if(_.globalAlpha*=Zn,_.fillStyle=In(ye.color),_.textAlign="left",_.textBaseline="alphabetic",gA(_,ye.text,ye.x,ye.y,{fontFamily:ye.fontFamily,fontSize:ye.fontSize,fontWeight:ye.fontWeight,fontStyle:ye.fontStyle,textAlign:ye.textAlign},`text:${ye.id}`),_.globalAlpha=M1,nr){const Lt=Ka(ye.id,_,!0);if(!Lt){_.restore();continue}_.strokeStyle=Ar.length>1?Te:Ne,_.lineWidth=1/qe.zoom,_.strokeRect(Lt.x,Lt.y,Lt.width,Lt.height),mi&&ka(_,Lt,qe.zoom,Ne)}else if(ir){const Lt=Ka(ye.id,_,!0);Lt&&(_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(Lt.x,Lt.y,Lt.width,Lt.height))}_.restore()}if(Ar.length>1&&!Kt){const ye=F1(Ar,_,!0);ye&&(_.save(),_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.setLineDash([6/qe.zoom,4/qe.zoom]),_.strokeRect(ye.x,ye.y,ye.width,ye.height),_.setLineDash([]),ka(_,ye,qe.zoom,Ne),_.restore())}if(Ps&&!Kt){const ye=F1(Va,_,!0);ye&&(_.save(),_.strokeStyle=Te,_.lineWidth=1/qe.zoom,_.setLineDash([6/qe.zoom,4/qe.zoom]),_.strokeRect(ye.x,ye.y,ye.width,ye.height),_.setLineDash([]),_.restore())}if(Mse(_,n,qe.zoom,$e),Ct){const ye=vA(Ct),sr=8/qe.zoom;_.fillStyle=Ye,_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,a1(_,ye.x,ye.y,ye.width,ye.height,sr),_.fill(),_.stroke()}if(Wt){const ye=mA(Wt);if(Wt.type==="rectangle")_.fillStyle=In(t.settings.shapeDefaults.fill),_.fillRect(ye.x,ye.y,ye.width,ye.height),_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.strokeRect(ye.x,ye.y,ye.width,ye.height);else if(Wt.type==="circle"){const sr=ye.x+ye.width/2,nr=ye.y+ye.height/2;_.fillStyle=In(t.settings.shapeDefaults.fill),_.beginPath(),_.ellipse(sr,nr,ye.width/2,ye.height/2,0,0,Math.PI*2),_.fill(),_.strokeStyle=Ne,_.lineWidth=1/qe.zoom,_.beginPath(),_.ellipse(sr,nr,ye.width/2,ye.height/2,0,0,Math.PI*2),_.stroke()}else if(Wt.type==="line"){const sr=wA(Wt);_.strokeStyle=Ne,_.lineWidth=2/qe.zoom,_.lineCap="round",_.lineJoin="round",_.beginPath(),_.moveTo(sr.startX,sr.startY),_.lineTo(sr.endX,sr.endY),_.stroke()}else{const sr=Math.max(10,Math.round(ye.height)),nr={x:ye.x,y:ye.y+sr,text:s.canvas.newText,fontFamily:"Shantell Sans, sans-serif",fontSize:sr,fontWeight:"200",fontStyle:"normal",color:t.settings.shapeDefaults.textColor};_.font=su(nr),_.fillStyle=In(nr.color),_.textAlign="left",_.textBaseline="alphabetic",_.fillText(nr.text,nr.x,nr.y)}}if(Wr&&Wr.points.length>0&&Wr.preview){const ye=[...Wr.points,Wr.preview];if(_.strokeStyle=Ne,_.lineWidth=2/qe.zoom,_.lineCap="round",_.lineJoin="round",_.beginPath(),uI(_,ye),_.stroke(),ye.length>1){const sr=Math.max(_.lineWidth*.52,1/qe.zoom);_.fillStyle=Ne;for(let nr=0;nr<ye.length;nr++){const ir=ye[nr];_.beginPath(),_.arc(ir.x,ir.y,sr,0,Math.PI*2),_.fill()}}}if(At&&At.points.length>0){const ye=j8(At.drawMode,Rs),sr=_.globalCompositeOperation,nr=_.globalAlpha;_.globalCompositeOperation=ye.compositeOperation,_.globalAlpha*=ye.opacity,_.save();const ir=U8(At.strokeWidth);_.strokeStyle=In(At.stroke),_.fillStyle=In(At.stroke),_.lineWidth=ir,_.lineJoin="round",_.lineCap=Q8(),At.points.length===1?At.drawMode==="marker"?nl(_,At.points,ir):At.drawMode==="quill"?il(_,At.points,ir,t.settings.quillDrawOptimizations):(_.beginPath(),_.arc(At.points[0].x,At.points[0].y,_.lineWidth/2,0,Math.PI*2),_.fillStyle=In(At.stroke),_.fill()):At.drawMode==="marker"?nl(_,At.points,ir):At.drawMode==="quill"?il(_,At.points,ir,t.settings.quillDrawOptimizations):(_.beginPath(),Uf(_,At.points),_.stroke()),_.restore(),_.globalCompositeOperation=sr,_.globalAlpha=nr}if(hn.length>0){_.save();const ye=t.settings.laserSettings;_.fillStyle=ye.color;for(const sr of hn)sr.points.length!==0&&mse(_,sr.points,rr,qe,ye);_.restore()}_.restore()}),P.useEffect(()=>{if(!Qe){Me.current=null;return}Me.current!==Qe.id&&(Me.current=Qe.id,requestAnimationFrame(()=>{try{Bt.focus(ie);const j=G.end(ie,[]);ut.select(ie,j)}catch(j){console.warn("Failed to focus text editor:",j)}}))},[ie,Qe]),P.useEffect(()=>{const j=_=>{if(_.target instanceof HTMLElement){const ke=_.target.tagName.toLowerCase();if(_.target.isContentEditable||ke==="input"||ke==="textarea"||ke==="select")return}if(_.key==="Escape"&&(vn.current||$n.current)){_.preventDefault(),$n.current=null,qr(null),Ur(null);return}if((_.key===" "||_.code==="Space")&&_.target instanceof HTMLElement&&!_.target.isContentEditable&&_.target.tagName.toLowerCase()!=="input"&&_.target.tagName.toLowerCase()!=="textarea"&&(Mn.current=!0),_.key==="Enter"&&!Qe&&Us(vn.current)){_.preventDefault();return}const Ge=_.key.toLowerCase();if(_.shiftKey&&!_.ctrlKey&&!_.metaKey&&!_.altKey&&!Qe){if(Ge==="h"){if(!mo)return;_.preventDefault(),qa("horizontal");return}if(Ge==="v"){if(!mo)return;_.preventDefault(),qa("vertical");return}}if(_.ctrlKey||_.metaKey){const ke=Ge;if(ke==="b"||ke==="i"){if(Qe)return;const Te=u9(t.elements,Ar);if(Te.length===0)return;if(_.preventDefault(),ke==="b"){const $e=Te.every(je=>je.fontWeight==="700"||je.fontWeight==="800"||je.fontWeight==="900"||je.fontWeight==="bold");R(Te.map(je=>je.id),$e?"200":"700");return}const Ye=Te.every($e=>$e.fontStyle==="italic");$(Te.map($e=>$e.id),Ye?"normal":"italic");return}}if(_.key!=="Enter"||Qe)return;const Ne=t.elements.find(ke=>ke.id===ii);!Ne||Ne.type!=="text"&&Ne.type!=="rectangle"&&Ne.type!=="circle"||(_.preventDefault(),Ae(Ne))};return window.addEventListener("keydown",j),()=>{window.removeEventListener("keydown",j)}},[Ae,mo,qe.zoom,Us,qa,Wa,Ui,t.elements,ii,Ar,Qe,R,$]),P.useEffect(()=>{const j=_=>{(_.key===" "||_.code==="Space")&&(Mn.current=!1,Ha.current=!1)};return window.addEventListener("keyup",j),()=>{window.removeEventListener("keyup",j)}},[]),P.useEffect(()=>{if(!Qe)return;const j=24,_=1,Ge=Qe.left+Qe.width-Se.width,Ne=-Qe.left,ke=Qe.top+Qe.height-Se.height,Te=-Qe.top;let Ye=0,$e=0;Ge>-j+_?Ye=Ge+j:Ne>-j+_&&(Ye=-(Ne+j)),ke>-j+_?$e=ke+j:Te>-j+_&&($e=-(Te+j)),Math.abs(Ye)<=_&&(Ye=0),Math.abs($e)<=_&&($e=0),(Ye!==0||$e!==0)&&c(Ye,$e)},[qe.zoom,Se.height,Se.width,Qe,c]),P.useEffect(()=>{const j=()=>{sn.current||(sn.current=!0,setTimeout(()=>{Mt(_=>_+1)},0))};return window.__FONTS_LOADED__&&(sn.current=!0),window.addEventListener("fontsLoaded",j),()=>{window.removeEventListener("fontsLoaded",j)}},[]);const Ie=j=>{Array.from(j.dataTransfer.items).some(_=>_.kind==="file")&&(j.preventDefault(),j.dataTransfer.dropEffect="copy")},Je=j=>{const _=Array.from(j.dataTransfer.files).filter($e=>$e.type.startsWith("image/"));if(_.length===0)return;j.preventDefault();const Ge=tt.current;if(!Ge)return;const Ne=Ge.getBoundingClientRect(),ke=j.clientX-Ne.left,Te=j.clientY-Ne.top,Ye=Vn(ke,Te);w(_,Ye.x,Ye.y)},ot=j=>{const _=tt.current;if(!_)return;const Ge=_.getBoundingClientRect(),Ne=j.clientX-Ge.left,ke=j.clientY-Ge.top,Te=Vn(Ne,ke);if(Ei.current=Te,Da.current=null,j.button===1){j.preventDefault(),Pi.current=!0,Gn.current={screenX:Ne,screenY:ke},Mr.current=null,xt(null),jt(null),Tt(null),st(null),Vt(null),mt(!1),ct(!1),be("grabbing"),_.setPointerCapture(j.pointerId);return}if(i==="pan"){Gn.current={screenX:Ne,screenY:ke},Mr.current=null,xt(null),jt(null),Tt(null),st(null),Vt(null),mt(!1),ct(!1),be("grabbing"),_.setPointerCapture(j.pointerId);return}if(Mn.current&&!Qe&&!a&&!Pi.current){Ha.current=!0,Gn.current={screenX:Ne,screenY:ke},Mr.current=null,xt(null),jt(null),Tt(null),st(null),Vt(null),mt(!1),ct(!1),be("grabbing"),_.setPointerCapture(j.pointerId);return}if(a&&a!=="image"){if(Qe&&Ce(),Mr.current=null,xt(null),jt(null),a==="laser")lr(Te);else if(a==="draw"||a==="marker"||a==="quill"){const Ft=hu(),gt=a,Jt=Xl(gt);Xt({points:[{...Te,t:Ft}],stroke:Jt.stroke,strokeWidth:Jt.strokeWidth,drawMode:gt,isLine:j.shiftKey})}else if(a==="line"){const Ft=vn.current;Ft&&Ft.points.length>0?$n.current=null:$n.current={screenX:Ne,screenY:ke,startX:Te.x,startY:Te.y},Ur(null)}else Ur({type:a,startX:Te.x,startY:Te.y,currentX:Te.x,currentY:Te.y,fromCenter:j.altKey,lockAspect:j.shiftKey});be(a==="laser"?"laser":a==="draw"?"pencil":a==="quill"?"quill":a==="marker"?"marker":"crosshair"),Tt(null),st(null),Vt(null),mt(!1),ct(!1),_.setPointerCapture(j.pointerId);return}if(Ar.length>1&&!Qe){const Ft=_.getContext("2d");if(Ft){const gt=F1(Ar,Ft,!0);if(gt){const Jt=W0(gt,Te.x,Te.y,qe.zoom);if(Jt?.mode==="resize"){ve(Jt.handle,Te.x,Te.y,gt,Ar),st(Jt.handle),Tt(null),mt(!1),ct(!1),Vt(null),ar([]),be(Au(Jt.handle)),_.setPointerCapture(j.pointerId);return}const er=R8(gt,Te.x,Te.y,qe.zoom);if(er?.mode==="rotate"){const fr=N1(gt);Re(fr.x,fr.y,Te.x,Te.y,Ar),Tt(er.handle),st(null),mt(!1),ct(!1),Vt(null),ar([]),be(lu(er.handle)),_.setPointerCapture(j.pointerId);return}}}}if(ii&&!Qe){const Ft=_.getContext("2d");if(Ft){const gt=t.elements.find(er=>er.id===ii);if(gt?.type==="line"){const er=rd(gt,Te.x,Te.y);if(V1(gt)){const or=Qs(gt,er.x,er.y,qe.zoom);if(or!==null){V(),Mr.current={id:gt.id,handle:"point",pointIndex:or,startLine:{x:gt.x,y:gt.y,width:gt.width,height:gt.height,controlPoint:null,points:gt.points?[...gt.points]:[]}},jt(or),zt(or),xt(null),_e(null),Tt(null),st(null),mt(!1),ct(!1),Vt(null),be("pointer"),_.setPointerCapture(j.pointerId);return}}const fr=S2(gt,er.x,er.y,qe.zoom);if(fr){V(),Mr.current={id:gt.id,handle:fr,startLine:{x:gt.x,y:gt.y,width:gt.width,height:gt.height,controlPoint:gt.controlPoint??null,points:gt.points?[...gt.points]:void 0}},xt(fr),_e(fr),jt(null),zt(null),Tt(null),st(null),mt(!1),ct(!1),Vt(null),be("pointer"),_.setPointerCapture(j.pointerId);return}}gt?.type==="text"&&(Ft.font=su(gt));const Jt=gt?.type==="line"?null:Ka(ii,Ft,!0);if(Jt){const er=t.elements.find(ir=>ir.id===ii),fr=(er?.rotation??0)*Math.PI/180,or=N1(Jt),ye=ku(Te.x,Te.y,or.x,or.y,-fr);if(er?.type==="rectangle"&&$a(er,ye.x,ye.y,qe.zoom)){const ir=$a(er,ye.x,ye.y,qe.zoom);if(!ir)return;Yr(er.id),kn(ir),Tt(null),st(null),mt(!1),ct(!1),Vt(null),be("pointer"),_.setPointerCapture(j.pointerId);return}const sr=W0(Jt,ye.x,ye.y,qe.zoom);if(sr?.mode==="resize"){const ir=Ka(ii,Ft,!1);Pe(ii,sr.handle,Te.x,Te.y,ir??Jt),st(sr.handle),Tt(null),mt(!1),ct(!1),be(Au(sr.handle)),_.setPointerCapture(j.pointerId);return}const nr=R8(Jt,ye.x,ye.y,qe.zoom);if(nr?.mode==="rotate"){Y(ii,or.x,or.y,Te.x,Te.y),Tt(nr.handle),st(null),mt(!1),ct(!1),be(lu(nr.handle)),_.setPointerCapture(j.pointerId);return}}}}Qe&&Ce();const Ye=Du(t.elements,Te.x,Te.y);if(!Ye){Tt(null),st(null),mt(!1),ct(!1),Vt({startX:Te.x,startY:Te.y,currentX:Te.x,currentY:Te.y}),be("default"),_.setPointerCapture(j.pointerId);return}j.shiftKey&&!j.altKey&&Ar.length>1&&Ar.includes(Ye)&&(Da.current={hitId:Ye,selectedIds:[...Ar],startScreenX:Ne,startScreenY:ke,shouldDeselect:!0});const $e=!!Ye,je=t.elements.find(Ft=>Ft.id===Ye),ft=$e&&j.altKey&&!je?.groupId;Tt(null),st(null),Vt(null),mt($e),ct(ft),be($e?ft?"clone":"grabbing":"default"),o(Te.x,Te.y,j.altKey,j.shiftKey,j.ctrlKey||j.metaKey),_.setPointerCapture(j.pointerId)},qt=j=>{const _=tt.current;if(!_)return;const Ge=_.getBoundingClientRect(),Ne=j.clientX-Ge.left,ke=j.clientY-Ge.top,Te=Vn(Ne,ke);Ei.current=Te;const Ye=Da.current;if(Ye?.shouldDeselect&&Math.hypot(Ne-Ye.startScreenX,ke-Ye.startScreenY)>Fse&&(Da.current={...Ye,shouldDeselect:!1}),Pi.current){const je=Gn.current;if(je){const ft=Ne-je.screenX,Ft=ke-je.screenY;(ft!==0||Ft!==0)&&(c(-ft,-Ft),Gn.current={screenX:Ne,screenY:ke})}be("grabbing");return}if(Ha.current){const je=Gn.current;if(je){const ft=Ne-je.screenX,Ft=ke-je.screenY;(ft!==0||Ft!==0)&&(c(-ft,-Ft),Gn.current={screenX:Ne,screenY:ke})}be("grabbing");return}if(i==="pan"){const je=Gn.current;if(je){const ft=Ne-je.screenX,Ft=ke-je.screenY;(ft!==0||Ft!==0)&&(c(-ft,-Ft),Gn.current={screenX:Ne,screenY:ke}),be("grabbing")}else be("grab");return}if(a){if(a==="line"){const je=vn.current;if(je&&je.points.length>0){const Ft=je.points[je.points.length-1],gt=j.shiftKey?ha(Ft.x,Ft.y,Te.x,Te.y):Te;qr({points:je.points,preview:gt}),be("crosshair");return}const ft=$n.current;ft&&Math.hypot(Ne-ft.screenX,ke-ft.screenY)>=Dse&&(Ur({type:"line",startX:ft.startX,startY:ft.startY,currentX:Te.x,currentY:Te.y,fromCenter:!1,lockAspect:j.shiftKey}),$n.current=null)}if(a==="laser")Fr(Te,qe.zoom);else if(a==="draw"||a==="marker"||a==="quill"){const je=hu();Xt(ft=>{if(!ft)return ft;const Ft=j.shiftKey;let gt={...Te,t:je};if(Ft&&ft.points.length>0){const fr=ft.points[0],or=Math.abs(Te.x-fr.x),ye=Math.abs(Te.y-fr.y);or>ye?gt={x:Te.x,y:fr.y,t:je}:gt={x:fr.x,y:Te.y,t:je};const sr=ft.points.length>1?ft.points[1]:null,nr=.5/qe.zoom;return sr&&Math.hypot(gt.x-sr.x,gt.y-sr.y)<nr?ft:{...ft,isLine:!0,points:[fr,gt]}}typeof gt.t!="number"&&(gt={...gt,t:je});const Jt=ft.points[ft.points.length-1],er=2/qe.zoom;return Jt&&Math.hypot(gt.x-Jt.x,gt.y-Jt.y)<er?ft:{...ft,isLine:!1,points:[...ft.points,gt]}})}else Wt&&Ur(je=>{if(!je)return je;if(je.type==="line"){const ft=j.shiftKey?ha(je.startX,je.startY,Te.x,Te.y):Te;return{...je,currentX:ft.x,currentY:ft.y,lockAspect:j.shiftKey}}return{...je,currentX:Te.x,currentY:Te.y,fromCenter:j.altKey,lockAspect:j.shiftKey}});be(a==="laser"?"laser":a==="draw"?"pencil":a==="quill"?"quill":a==="marker"?"marker":"crosshair");return}const $e=Mr.current;if($e){const je=t.elements.find(ft=>ft.id===$e.id&&ft.type==="line");if(je){const ft=rd(je,Te.x,Te.y),Ft={x:$e.startLine.x,y:$e.startLine.y},gt={x:$e.startLine.x+$e.startLine.width,y:$e.startLine.y+$e.startLine.height};let Jt=Ft,er=gt,fr=$e.startLine.controlPoint;if($e.handle==="start"||$e.handle==="point")Jt=j.shiftKey?ha(gt.x,gt.y,ft.x,ft.y):ft;else if($e.handle==="end")er=j.shiftKey?ha(Ft.x,Ft.y,ft.x,ft.y):ft;else if($e.handle==="control"){const ir=(Ft.x+gt.x)/2,mn=(Ft.y+gt.y)/2;fr=j.shiftKey?ha(ir,mn,ft.x,ft.y):{x:ft.x,y:ft.y}}const or=ir=>t.settings.snapToGrid?Math.round(ir/t.settings.gridSize)*t.settings.gridSize:ir,ye={x:or(Jt.x),y:or(Jt.y)},sr={x:or(er.x),y:or(er.y)},nr=fr?{x:or(fr.x),y:or(fr.y)}:null;if($e.handle==="point"&&typeof $e.pointIndex=="number"&&$e.startLine.points&&$e.startLine.points.length>$e.pointIndex){const ir=$e.startLine.points.map((ji,Zn)=>Zn===$e.pointIndex?{x:ye.x,y:ye.y}:ji),mn=El(ir);oe($e.id,{x:mn.x,y:mn.y,width:mn.width,height:mn.height,controlPoint:null,points:ir})}else oe($e.id,{x:ye.x,y:ye.y,width:sr.x-ye.x,height:sr.y-ye.y,controlPoint:nr})}be("pointer");return}if($r){const je=t.elements.find(ft=>ft.id===$r);if(je&&je.type==="rectangle"&&en){const ft={x:je.x,y:je.y,width:je.width,height:je.height},Ft=N1(ft),gt=ku(Te.x,Te.y,Ft.x,Ft.y,-je.rotation*Math.PI/180),Jt=Qv/qe.zoom,er=je.x+je.width,fr=je.y+je.height;let or;en==="nw"?or=Math.min(gt.x-je.x-Jt,gt.y-je.y-Jt):en==="ne"?or=Math.min(er-gt.x-Jt,gt.y-je.y-Jt):en==="se"?or=Math.min(er-gt.x-Jt,fr-gt.y-Jt):or=Math.min(gt.x-je.x-Jt,fr-gt.y-Jt);const ye=Math.max(0,Math.min(or,Math.min(je.width,je.height)/2));de([je.id],ye)}be("pointer");return}if(Ct){Vt(je=>{if(!je)return je;const ft={...je,currentX:Te.x,currentY:Te.y};return ar(W(ft)),ft}),be("default");return}if(A(Te.x,Te.y,j.shiftKey,j.altKey),yt){be(lu(yt));return}if(ze){be(Au(ze));return}if(bt){be(Nt?"clone":"grabbing");return}be(Ga(Te.x,Te.y,j.altKey))},Qt=j=>{const _=tt.current;_?.hasPointerCapture(j.pointerId)&&_.releasePointerCapture(j.pointerId);const Ge=Da.current;if(Da.current=null,i==="pan"){Gn.current=null,Yr(null),kn(null),be("grab");return}if(Pi.current){Pi.current=!1,Gn.current=null,Yr(null),kn(null);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);Ei.current=$e,be(Ga($e.x,$e.y,j.altKey))}else be("default");return}if(Ha.current){Ha.current=!1,Gn.current=null,Yr(null),kn(null);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);Ei.current=$e,be(Ga($e.x,$e.y,j.altKey))}else be("default");return}if(a){if(a==="line"){const ke=$n.current;if(ke){$n.current=null,Ur(null),qr({points:[{x:ke.startX,y:ke.startY}],preview:{x:ke.startX,y:ke.startY}}),Yr(null),kn(null),be("crosshair");return}const Te=vn.current;if(Te&&Te.points.length>0){const Ye=_?.getBoundingClientRect();if(Ye){const $e=j.clientX-Ye.left,je=j.clientY-Ye.top,ft=Vn($e,je),Ft=Te.points[Te.points.length-1],gt=j.shiftKey?ha(Ft.x,Ft.y,ft.x,ft.y):ft;Math.hypot(gt.x-Ft.x,gt.y-Ft.y)>=1?qr({points:[...Te.points,gt],preview:gt}):qr({points:Te.points,preview:gt})}Yr(null),kn(null),be("crosshair");return}}if(a==="laser")jr();else if(a==="draw"||a==="marker"||a==="quill")At&&At.points.length>=1&&h(At.points,{drawMode:At.drawMode,stroke:At.stroke}),Xt(null);else if(Wt){if(Wt.type==="line"){const ke=wA(Wt);Math.hypot(ke.endX-ke.startX,ke.endY-ke.startY)>=1&&d("line",ke.startX,ke.startY,s,{x:ke.startX,y:ke.startY,width:ke.endX-ke.startX,height:ke.endY-ke.startY})}else{const ke=mA(Wt);d(Wt.type,ke.x,ke.y,s,ke)}Ur(null),p()}Yr(null),kn(null),be(a==="laser"?"laser":a==="draw"?"pencil":a==="quill"?"quill":a==="marker"?"marker":"crosshair");return}if(Mr.current){l(),Mr.current=null,xt(null),jt(null);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);Ei.current=$e,be(Ga($e.x,$e.y,j.altKey))}else be("default");return}if($r){Yr(null),kn(null);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);be(Ga($e.x,$e.y,j.altKey))}else be("default");return}if(Ct){const ke=W(Ct),Te=j.shiftKey?Array.from(new Set([...Ar,...ke])):ke;m(Te),Vt(null),ar([]),Tt(null),st(null),mt(!1),ct(!1);const Ye=_?.getBoundingClientRect();if(Ye){const $e=j.clientX-Ye.left,je=j.clientY-Ye.top,ft=Vn($e,je);Ei.current=ft,be(Ga(ft.x,ft.y,j.altKey))}else be("default");return}if(Ge?.shouldDeselect&&!j.altKey){l(),m(Ge.selectedIds.filter(Te=>Te!==Ge.hitId)),Tt(null),st(null),Rt(null),Mr.current=null,xt(null),jt(null),_e(null),zt(null),mt(!1),ct(!1);const ke=_?.getBoundingClientRect();if(ke){const Te=j.clientX-ke.left,Ye=j.clientY-ke.top,$e=Vn(Te,Ye);Ei.current=$e,be(Ga($e.x,$e.y,j.altKey))}else be("default");return}l(),Tt(null),st(null),Rt(null),Mr.current=null,xt(null),jt(null),_e(null),zt(null),mt(!1),ct(!1);const Ne=_?.getBoundingClientRect();if(Ne){const ke=j.clientX-Ne.left,Te=j.clientY-Ne.top,Ye=Vn(ke,Te);Ei.current=Ye,be(Ga(Ye.x,Ye.y,j.altKey))}else be("default")},cr=()=>{if(Ei.current=null,Pi.current){be("grabbing");return}if(i==="pan"){be(Gn.current?"grabbing":"grab");return}if(a){a==="laser"?(jr(),be("laser")):be(a==="draw"?"pencil":a==="quill"?"quill":a==="marker"?"marker":"crosshair");return}if(Mr.current||Et||ur!==null){be("pointer");return}if($r){be("pointer");return}if(Ct){be("default");return}if(Rt(null),_e(null),zt(null),yt){be(lu(yt));return}if(ze){be(Au(ze));return}if(bt){be(Nt?"clone":"grabbing");return}be("default")},dr=j=>{if(a==="line"&&Us(vn.current)){j.preventDefault();return}if(i==="pan"||a)return;const _=tt.current;if(!_)return;const Ge=_.getBoundingClientRect(),Ne=j.clientX-Ge.left,ke=j.clientY-Ge.top,Te=Vn(Ne,ke),Ye=Du(t.elements,Te.x,Te.y);if(!Ye)return;const $e=t.elements.find(je=>je.id===Ye);if($e?.groupId&&Ar.length>1&&Ar.includes($e.id)){m([$e.id]);return}if(!(!$e||$e.type!=="text"&&$e.type!=="rectangle"&&$e.type!=="circle")){if(Qe&&Qe.id!==$e.id){Ce(),requestAnimationFrame(()=>{Ae($e)});return}Ae($e)}},Or=j=>{Xe(_=>{if(!_)return _;const Ne=tt.current?.getContext("2d");if(!Ne)return _.value===j?_:{..._,value:j};const ke=Wa(Ne,j,{fontFamily:_.style.fontFamily,fontSize:_.style.fontSize,fontWeight:_.style.fontWeight,fontStyle:_.style.fontStyle}),Te=_.maxWidth?Math.min(ke.width*qe.zoom,_.maxWidth):ke.width*qe.zoom,Ye=Uo(_.anchorX,Te/qe.zoom,_.style.textAlign),$e=Ui(Ye,_.anchorY),je=ke.height*qe.zoom,ft=Math.abs(_.left-$e.x)<.001&&Math.abs(_.top-$e.y)<.001&&Math.abs(_.width-Te)<.001&&Math.abs(_.height-je)<.001;return _.value===j&&ft?_:{..._,value:j,left:$e.x,top:$e.y,width:Te,height:je}})};P.useEffect(()=>{if(!Qe)return;const j=at!==null?lf(at):Qe.value;Or(j)},[qe.x,qe.y,qe.zoom,at,Qe?.id]);const zn=j=>{try{if(ie.selection)try{G.node(ie,ie.selection.anchor.path),G.node(ie,ie.selection.focus.path)}catch{ut.deselect(ie)}const _=j;for(const Ne of _)if(!Ne||typeof Ne!="object")return;if(pt(_),!ie.operations.some(Ne=>Ne.type!=="set_selection"))return;Or(lf(_))}catch(_){console.warn("Editor change failed:",_)}},tn=j=>{let _=null;try{_=G.marks(ie)}catch{return}const Ge=_?.[j];if(j==="bold"||j==="italic"){if(j==="bold"?!!Qe&&(Qe.style.fontWeight==="bold"||Qe.style.fontWeight==="700"||Qe.style.fontWeight==="800"||Qe.style.fontWeight==="900"):!!Qe&&Qe.style.fontStyle==="italic"){G.addMark(ie,j,Ge===!1);return}if(Ge===!0){G.removeMark(ie,j);return}G.addMark(ie,j,!0);return}Ge===!0?G.removeMark(ie,j):G.addMark(ie,j,!0)},Jr=j=>E2?Rf(j):j,dn=j=>{const _=tt.current;if(!_)return;const Ge=_.getBoundingClientRect(),Ne=j.clientX-Ge.left,ke=j.clientY-Ge.top,Te=Vn(Ne,ke);Ni.current=Te,Ei.current=Te;const Ye=Du(t.elements,Te.x,Te.y);if(!Ye){m([]);return}const $e=t.elements.find(ft=>ft.id===Ye);if(!$e)return;const je=j.ctrlKey||j.metaKey;if($e.groupId&&!je){M($e.id);return}(!Ar.includes(Ye)||je)&&m([Ye])},Ln=()=>{const j=Ni.current;j&&b(j.x,j.y)};return u.jsxs("div",{style:{position:"relative",width:Se.width,height:Se.height},children:[u.jsx("div",{ref:me,style:{position:"fixed",top:0,left:0,pointerEvents:"none",opacity:0,zIndex:-9999},"aria-hidden":"true"}),u.jsx(VT,{hasSelection:Ts,canFlipSelection:mo,selectionType:zl,selectionOpacity:Gl,hasElements:t.elements.length>0,canUngroupSelection:ss,onCut:B,localeMessages:s,onCopy:g,onPaste:Ln,onDuplicate:L,onSelectionOpacityChange:j=>{Ts&&O(Ar,j)},onDelete:E,onGroup:I,onUngroup:k,onSelectAll:()=>{t.elements.length!==0&&m(t.elements.map(j=>j.id))},onMoveForward:()=>H("forward"),onBringToFront:()=>H("front"),onSendToBack:()=>H("back"),onMoveBackward:()=>H("backward"),onFlipHorizontal:()=>qa("horizontal"),onFlipVertical:()=>qa("vertical"),children:u.jsx("canvas",{ref:tt,width:Se.width,height:Se.height,onDragOver:Ie,onDrop:Je,onPointerDown:ot,onPointerMove:qt,onPointerUp:Qt,onPointerCancel:Qt,onPointerLeave:cr,onDoubleClick:dr,onContextMenu:dn,onMouseDown:j=>{j.button===1&&j.preventDefault()},onAuxClick:j=>{j.button===1&&j.preventDefault()},style:{display:"block",cursor:'url("../cursors/'+Le+'.svg")'+(["default","pointer","clone","laser"].includes(Le)?"":["marker","pencil","quill"].includes(Le)?" -4 26":" 12 12")+', url("../cursors/default.svg"), auto',touchAction:"none"}})}),t.elements.length===0&&!Wt&&!At&&!Wr&&u.jsx(ET,{}),u.jsx(HT,{editorWrapRef:Oe,editor:ie,editingText:Qe,editingDocument:at,editorSessionKey:pe,cameraZoom:qe.zoom,setEditingDocument:pt,setEditingText:Xe,toThemeColor:In,getTextLineHeight:Mf,onEditorChange:zn,onCommitEditingText:()=>Ce(),onToggleEditorMark:tn}),D1&&u.jsx(_T,{toolbarKey:D1.key,left:D1.left,top:D1.top,viewportWidth:Se.width,children:k1()})]})};function Yf(){const t=v2(),{scene:e,resolvedTheme:r,isPresentationMode:n,interactionMode:i,drawingTool:a,messages:s,handlers:o,setDrawingTool:A}=t,l={scene:e,strokeColors:r.preset.strokeColors,shapeColors:r.preset.shapeColors,alignmentGuides:[],interactionMode:i,drawingTool:a,localeMessages:s,onPointerDown:o.handlePointerDown,onPointerMove:o.handlePointerMove,onPointerUp:o.handlePointerUp,onResizeStart:o.handleResizeStart,onRotateStart:o.handleRotateStart,onTextCommit:o.handleTextCommit,onWheelPan:o.handleWheelPan,onWheelZoom:o.handleWheelZoom,onCreateElement:o.handleCreateElement,onCreateDrawElement:o.handleCreateDrawElement,onCreateLinePathElement:o.handleCreateLinePathElement,onDrawingToolComplete:()=>A(null),onDropImageFiles:o.handleInsertImageFiles,onSelectElements:o.handleSelectElements,onGroupResizeStart:o.handleGroupResizeStart,onGroupRotateStart:o.handleGroupRotateStart,onTextFontFamilyChange:o.handleTextFontFamilyChange,onTextFontSizeChange:o.handleTextFontSizeChange,onTextFontWeightChange:o.handleTextFontWeightChange,onTextFontStyleChange:o.handleTextFontStyleChange,onTextAlignChange:o.handleTextAlignChange,onTextColorChange:o.handleTextColorChange,onDrawStrokeWidthChange:o.handleDrawStrokeWidthChange,onDrawStrokeColorChange:o.handleDrawStrokeColorChange,onShapeFillColorChange:o.handleShapeFillColorChange,onShapeFillStyleChange:o.handleShapeFillStyleChange,onElementsOpacityChange:o.handleElementsOpacityChange,onShapeStrokeColorChange:o.handleShapeStrokeColorChange,onShapeStrokeWidthChange:o.handleShapeStrokeWidthChange,onShapeStrokeStyleChange:o.handleShapeStrokeStyleChange,onDrawDefaultStrokeColorChange:o.handleDrawDefaultStrokeColorChange,onDrawDefaultStrokeWidthChange:o.handleDrawDefaultStrokeWidthChange,onLineStartCapChange:o.handleLineStartCapChange,onLineEndCapChange:o.handleLineEndCapChange,onLineEditStart:o.handleLineEditStart,onLineGeometryChange:o.handleLineGeometryChange,onRectangleBorderRadiusChange:o.handleRectangleBorderRadiusChange,onCopySelection:o.handleCopySelection,onCutSelection:o.handleCutSelection,onPasteAt:o.handlePasteAt,onDuplicateSelection:o.handleDuplicateSelection,onDeleteSelection:o.handleDeleteSelection,onGroupSelection:o.handleGroupSelection,onUngroupSelection:o.handleUngroupSelection,onSelectGroupForElement:o.handleSelectGroupForElement,onReorderSelection:o.handleReorderSelection,onFlipSelection:o.handleFlipSelection};return u.jsx(WT,{...l})}function Tse({className:t,color:e}){return u.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("g",{"clip-path":"url(#clip0_1539_179)",children:u.jsxs("g",{"clip-path":"url(#clip1_1539_179)",children:[u.jsx("path",{d:"M7.99556 10.0703C8.19978 9.56757 8.68826 9.23877 9.23085 9.23877H14.7692C15.3118 9.23877 15.8003 9.56757 16.0045 10.0703L19.2157 17.9747C19.7337 19.2498 20.0001 20.6131 20.0001 21.9895V45.2389H4V21.9895C4 20.6131 4.26635 19.2498 4.78436 17.9747L7.99556 10.0703Z",fill:"white"}),u.jsx("path",{d:"M7.99556 10.0703C8.19978 9.56757 8.68826 9.23877 9.23085 9.23877H14.7692C15.3118 9.23877 15.8003 9.56757 16.0045 10.0703L19.2157 17.9747C19.7337 19.2498 20.0001 20.6131 20.0001 21.9895V45.2389H4V21.9895C4 20.6131 4.26635 19.2498 4.78436 17.9747L7.99556 10.0703Z",fill:"url(#paint0_linear_1539_179)","fill-opacity":"0.6"}),u.jsx("path",{d:"M9.23047 9.48877H14.7695C15.1552 9.48887 15.5071 9.6934 15.7002 10.0181L15.7725 10.1645L18.9844 18.0688C19.4902 19.314 19.75 20.6457 19.75 21.9897V44.9888H4.25V21.9897C4.25 20.6457 4.50979 19.314 5.01562 18.0688L8.22754 10.1645C8.39342 9.75622 8.78976 9.48892 9.23047 9.48877Z",stroke:"black","stroke-opacity":"0.3","stroke-width":"0.5"}),u.jsx("g",{opacity:"0.2",filter:"url(#filter0_f_1539_179)",children:u.jsx("path",{d:"M18.6635 20.6615V44.3282H12.3301V10.3281L14.6634 10.2388L18.6635 20.6615Z",fill:"url(#paint1_linear_1539_179)"})}),u.jsx("g",{filter:"url(#filter1_i_1539_179)",children:u.jsx("path",{d:"M11.383 3.74726C11.6089 3.19493 12.3911 3.19493 12.6171 3.74725L15 9.57232H9L11.383 3.74726Z",fill:e||"#1E1E1E"})}),u.jsx("path",{d:"M11.6143 3.84158C11.7556 3.49681 12.2444 3.49682 12.3857 3.84158L14.6279 9.32205H9.37207L11.6143 3.84158Z",stroke:"black","stroke-opacity":"0.3","stroke-width":"0.5"}),u.jsx("path",{d:"M4.33008 23.9058H19.6635",stroke:"black","stroke-opacity":"0.15","stroke-width":"0.66667"})]})}),u.jsxs("defs",{children:[u.jsxs("filter",{id:"filter0_f_1539_179",x:"10.3301",y:"8.23875",width:"10.3335",height:"38.0894",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feGaussianBlur",{stdDeviation:"1.00001",result:"effect1_foregroundBlur_1539_179"})]}),u.jsxs("filter",{id:"filter1_i_1539_179",x:"7.55999",y:"3.33301",width:"7.44001",height:"6.95926",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),u.jsx("feOffset",{dx:"-1.44001",dy:"0.720004"}),u.jsx("feGaussianBlur",{stdDeviation:"1.08001"}),u.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),u.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0"}),u.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect1_innerShadow_1539_179"})]}),u.jsxs("linearGradient",{id:"paint0_linear_1539_179",x1:"4",y1:"38.2389",x2:"20.0001",y2:"38.2389",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-opacity":"0.1"}),u.jsx("stop",{offset:"0.4","stop-opacity":"0"}),u.jsx("stop",{offset:"1","stop-opacity":"0.15"})]}),u.jsxs("linearGradient",{id:"paint1_linear_1539_179",x1:"12.3301",y1:"1.57206",x2:"17.1673",y2:"36.2341",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-opacity":"0.2"}),u.jsx("stop",{offset:"1","stop-opacity":"0.4"})]}),u.jsx("clipPath",{id:"clip0_1539_179",children:u.jsx("rect",{width:"24",height:"24",fill:"white"})}),u.jsx("clipPath",{id:"clip1_1539_179",children:u.jsx("rect",{width:"16",height:"34",fill:"white",transform:"translate(4 2.57227)"})})]})]})}function Nse({className:t,color:e}){return u.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("g",{"clip-path":"url(#clip0_1571_205)",children:u.jsxs("g",{"clip-path":"url(#clip1_1571_205)",children:[u.jsx("path",{opacity:"0.75",d:"M12 9.66211C12.5694 9.66211 13.1156 9.88833 13.5182 10.291C13.9209 10.6937 14.1471 11.2398 14.1471 11.8093C14.1471 12.3787 13.9209 12.9249 13.5182 13.3276C13.1156 13.7302 12.5694 13.9565 12 13.9565C11.4305 13.9565 10.8843 13.7302 10.4817 13.3276C10.079 12.9249 9.85278 12.3787 9.85278 11.8093C9.85278 11.2398 10.079 10.6937 10.4817 10.291C10.8843 9.88833 11.4305 9.66211 12 9.66211Z",fill:e||"#1E1E1E"}),u.jsx("path",{d:"M12.6409 1.61035C12.9169 1.61035 13.1466 1.8197 13.1863 2.09347C13.6442 5.2482 15.4741 7.95793 18.0518 9.59891C18.2558 9.72882 18.3578 9.97413 18.2961 10.2076L15.5418 20.5366C15.5112 20.6509 15.4438 20.752 15.3499 20.824C15.2561 20.896 15.141 20.935 15.0227 20.9349H8.97679C8.85856 20.9349 8.74364 20.8958 8.64988 20.8238C8.55611 20.7518 8.48875 20.6508 8.45825 20.5366L5.7045 10.2076C5.67486 10.0934 5.68253 9.97277 5.72638 9.86325C5.77022 9.75373 5.84795 9.6611 5.9482 9.59891C8.52588 7.95793 10.3558 5.2482 10.8142 2.09293C10.854 1.82024 11.0832 1.61035 11.3591 1.61035H12.6409ZM12 9.66225C11.4305 9.66225 10.8844 9.88847 10.4817 10.2911C10.0791 10.6938 9.85284 11.24 9.85284 11.8094C9.85284 12.3789 10.0791 12.925 10.4817 13.3277C10.8844 13.7304 11.4305 13.9566 12 13.9566C12.5695 13.9566 13.1156 13.7304 13.5183 13.3277C13.921 12.925 14.1472 12.3789 14.1472 11.8094C14.1472 11.24 13.921 10.6938 13.5183 10.2911C13.1156 9.88847 12.5695 9.66225 12 9.66225Z",fill:"white"}),u.jsxs("mask",{id:"mask0_1571_205",style:{maskType:"luminance"},maskUnits:"userSpaceOnUse",x:"5",y:"1",width:"15",height:"21",children:[u.jsx("path",{d:"M5.14941 1.07373H19.106V21.4719H5.14941V1.07373Z",fill:"white"}),u.jsx("path",{d:"M12.6409 1.61035C12.9169 1.61035 13.1466 1.8197 13.1863 2.09347C13.6442 5.2482 15.4741 7.95793 18.0518 9.59891C18.2558 9.72882 18.3578 9.97413 18.2961 10.2076L15.5418 20.5366C15.5112 20.6509 15.4438 20.752 15.3499 20.824C15.2561 20.896 15.141 20.935 15.0227 20.9349H8.97679C8.85856 20.9349 8.74364 20.8958 8.64988 20.8238C8.55611 20.7518 8.48875 20.6508 8.45825 20.5366L5.7045 10.2076C5.67486 10.0934 5.68253 9.97277 5.72638 9.86325C5.77022 9.75373 5.84795 9.6611 5.9482 9.59891C8.52588 7.95793 10.3558 5.2482 10.8142 2.09293C10.854 1.82024 11.0832 1.61035 11.3591 1.61035H12.6409ZM12 9.66225C11.4305 9.66225 10.8844 9.88847 10.4817 10.2911C10.0791 10.6938 9.85284 11.24 9.85284 11.8094C9.85284 12.3789 10.0791 12.925 10.4817 13.3277C10.8844 13.7304 11.4305 13.9566 12 13.9566C12.5695 13.9566 13.1156 13.7304 13.5183 13.3277C13.921 12.925 14.1472 12.3789 14.1472 11.8094C14.1472 11.24 13.921 10.6938 13.5183 10.2911C13.1156 9.88847 12.5695 9.66225 12 9.66225Z",fill:"black"})]}),u.jsx("g",{mask:"url(#mask0_1571_205)",children:u.jsx("path",{d:"M13.1863 2.09331L12.9206 2.13196C13.3903 5.36667 15.2664 8.14404 17.9074 9.82582L18.0523 9.59929L18.1962 9.37276C15.6824 7.77312 13.8986 5.12995 13.452 2.05466L13.1863 2.09331ZM18.296 10.208L18.0367 10.1388L15.2825 20.4677L15.5417 20.537L15.801 20.6057L18.5548 10.2773L18.296 10.208ZM15.0221 20.9348V20.6664H8.97675V21.2032H15.0227L15.0221 20.9348ZM8.45713 20.5365L8.71694 20.4667L5.96319 10.1382L5.70392 10.2075L5.44465 10.2767L8.1984 20.6052L8.45713 20.5365ZM5.9487 9.59822L6.09309 9.82528C8.73412 8.14351 10.6107 5.36614 11.0799 2.13142L10.8147 2.09277L10.549 2.05412C10.1024 5.12995 8.3181 7.77205 5.80483 9.37276L5.9487 9.59822ZM11.359 1.61019V1.87859H12.6409V1.3418H11.359V1.61019ZM12 9.66209V9.3937C11.3593 9.3937 10.7449 9.6482 10.2919 10.1012C9.83889 10.5542 9.5844 11.1686 9.5844 11.8093H10.1212C10.1212 11.311 10.3191 10.8331 10.6715 10.4808C11.0238 10.1284 11.5017 9.93049 12 9.93049V9.66209ZM9.85279 11.8093H9.5844C9.5844 12.4499 9.83889 13.0643 10.2919 13.5173C10.7449 13.9703 11.3593 14.2248 12 14.2248V13.688C11.5017 13.688 11.0238 13.4901 10.6715 13.1378C10.3191 12.7854 10.1212 12.3076 10.1212 11.8093H9.85279ZM12 13.9564V14.2248C12.6406 14.2248 13.255 13.9703 13.708 13.5173C14.161 13.0643 14.4155 12.4499 14.4155 11.8093H13.8787C13.8787 12.3076 13.6808 12.7854 13.3285 13.1378C12.9761 13.4901 12.4983 13.688 12 13.688V13.9564ZM14.1471 11.8093H14.4155C14.4155 11.1686 14.161 10.5542 13.708 10.1012C13.255 9.6482 12.6406 9.3937 12 9.3937V9.93049C12.4983 9.93049 12.9761 10.1284 13.3285 10.4808C13.6808 10.8331 13.8787 11.311 13.8787 11.8093H14.1471ZM10.8137 2.09331L11.0799 2.13142C11.0887 2.06294 11.1216 1.99985 11.1728 1.9535C11.224 1.90715 11.29 1.88059 11.359 1.87859V1.3418C10.9425 1.3418 10.6065 1.65689 10.5485 2.05412L10.8137 2.09331ZM5.70499 10.2069L5.96426 10.1377C5.9494 10.0786 5.95389 10.0163 5.97708 9.95998C6.00028 9.90364 6.04094 9.85624 6.09309 9.82474L5.9487 9.59822L5.80483 9.37169C5.65629 9.46442 5.54128 9.6022 5.47658 9.76492C5.41187 9.92764 5.40088 10.1068 5.44518 10.2762L5.70499 10.2069ZM8.97675 20.9348V20.6664C8.91763 20.6664 8.86017 20.6468 8.81329 20.6108C8.76641 20.5748 8.73273 20.5243 8.71748 20.4672L8.45821 20.5365L8.1984 20.6052C8.24408 20.7767 8.34569 20.9283 8.48646 21.0365C8.62722 21.1446 8.79978 21.2032 8.97728 21.2032L8.97675 20.9348ZM15.5417 20.537L15.2825 20.4667C15.2673 20.524 15.2336 20.5746 15.1866 20.6108C15.1396 20.6469 15.0819 20.6664 15.0227 20.6664V21.2032C15.2002 21.2032 15.3727 21.1446 15.5135 21.0365C15.6542 20.9283 15.7553 20.7772 15.801 20.6057L15.5417 20.537ZM18.0518 9.59875L17.9079 9.82528C18.018 9.89506 18.0668 10.0239 18.0367 10.1382L18.296 10.208L18.5553 10.2767C18.5995 10.1074 18.5884 9.92837 18.5237 9.76576C18.459 9.60315 18.3446 9.46546 18.1962 9.37276L18.0518 9.59875ZM13.1863 2.09331L13.452 2.05466C13.3946 1.65743 13.058 1.3418 12.6409 1.3418V1.87859C12.7762 1.87859 12.8991 1.98326 12.9206 2.13196L13.1863 2.09331Z",fill:"black","fill-opacity":"0.15"})}),u.jsx("mask",{id:"mask1_1571_205",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"5",y:"1",width:"14",height:"20",children:u.jsx("path",{d:"M12.6409 1.61035C12.9169 1.61035 13.1466 1.8197 13.1863 2.09347C13.6442 5.2482 15.4741 7.95793 18.0518 9.59891C18.2558 9.72882 18.3578 9.97413 18.2961 10.2076L15.5418 20.5366C15.5112 20.6509 15.4438 20.752 15.3499 20.824C15.2561 20.896 15.141 20.935 15.0227 20.9349H8.97679C8.85856 20.9349 8.74364 20.8958 8.64988 20.8238C8.55611 20.7518 8.48875 20.6508 8.45825 20.5366L5.7045 10.2076C5.67486 10.0934 5.68253 9.97277 5.72638 9.86325C5.77022 9.75373 5.84795 9.6611 5.9482 9.59891C8.52588 7.95793 10.3558 5.2482 10.8142 2.09293C10.854 1.82024 11.0832 1.61035 11.3591 1.61035H12.6409ZM12 9.66225C11.4305 9.66225 10.8844 9.88847 10.4817 10.2911C10.0791 10.6938 9.85284 11.24 9.85284 11.8094C9.85284 12.3789 10.0791 12.925 10.4817 13.3277C10.8844 13.7304 11.4305 13.9566 12 13.9566C12.5695 13.9566 13.1156 13.7304 13.5183 13.3277C13.921 12.925 14.1472 12.3789 14.1472 11.8094C14.1472 11.24 13.921 10.6938 13.5183 10.2911C13.1156 9.88847 12.5695 9.66225 12 9.66225Z",fill:"white"})}),u.jsxs("g",{mask:"url(#mask1_1571_205)",children:[u.jsxs("g",{opacity:"0.75",filter:"url(#filter0_f_1571_205)",children:[u.jsx("path",{d:"M13.1272 1.61035C13.4745 5.11347 15.5062 8.12058 18.4006 9.81256L15.4354 20.9349H8.56442L5.59863 9.81256C8.49356 8.12005 10.5253 5.11293 10.8726 1.61035H11.4631V9.17914C10.8114 9.31217 10.2323 9.68243 9.83812 10.2182C9.44391 10.7539 9.26267 11.4169 9.32952 12.0786C9.39637 12.7404 9.70656 13.3538 10.1999 13.7998C10.6933 14.2459 11.3348 14.4928 11.9999 14.4928C12.665 14.4928 13.3065 14.2459 13.7998 13.7998C14.2932 13.3538 14.6034 12.7404 14.6703 12.0786C14.7371 11.4169 14.5559 10.7539 14.1617 10.2182C13.7675 9.68243 13.1884 9.31217 12.5367 9.17914V1.61035H13.1272Z",fill:"url(#paint0_linear_1571_205)"}),u.jsx("path",{d:"M13.1272 1.61035C13.4745 5.11347 15.5062 8.12058 18.4006 9.81256L15.4354 20.9349H8.56442L5.59863 9.81256C8.49356 8.12005 10.5253 5.11293 10.8726 1.61035H11.4631V9.17914C10.8114 9.31217 10.2323 9.68243 9.83812 10.2182C9.44391 10.7539 9.26267 11.4169 9.32952 12.0786C9.39637 12.7404 9.70656 13.3538 10.1999 13.7998C10.6933 14.2459 11.3348 14.4928 11.9999 14.4928C12.665 14.4928 13.3065 14.2459 13.7998 13.7998C14.2932 13.3538 14.6034 12.7404 14.6703 12.0786C14.7371 11.4169 14.5559 10.7539 14.1617 10.2182C13.7675 9.68243 13.1884 9.31217 12.5367 9.17914V1.61035H13.1272Z",fill:"url(#paint1_linear_1571_205)"}),u.jsx("mask",{id:"mask2_1571_205",style:{maskType:"luminance"},maskUnits:"userSpaceOnUse",x:"5",y:"1",width:"14",height:"20",children:u.jsx("path",{d:"M13.1272 1.61035C13.4745 5.11347 15.5062 8.12058 18.4006 9.81256L15.4354 20.9349H8.56442L5.59863 9.81256C8.49356 8.12005 10.5253 5.11293 10.8726 1.61035H11.4631V9.17914C10.8114 9.31217 10.2323 9.68243 9.83812 10.2182C9.44391 10.7539 9.26267 11.4169 9.32952 12.0786C9.39637 12.7404 9.70656 13.3538 10.1999 13.7998C10.6933 14.2459 11.3348 14.4928 11.9999 14.4928C12.665 14.4928 13.3065 14.2459 13.7998 13.7998C14.2932 13.3538 14.6034 12.7404 14.6703 12.0786C14.7371 11.4169 14.5559 10.7539 14.1617 10.2182C13.7675 9.68243 13.1884 9.31217 12.5367 9.17914V1.61035H13.1272Z",fill:"white"})}),u.jsx("g",{mask:"url(#mask2_1571_205)",children:u.jsx("path",{d:"M13.1272 1.61052L13.6608 1.55738L13.6124 1.07373H13.1272V1.61052ZM18.4006 9.81273L18.9197 9.95068L19.0249 9.5556L18.6717 9.34894L18.4006 9.81273ZM15.4354 20.9351V21.4719H15.8477L15.9539 21.0736L15.4354 20.9351ZM8.56444 20.9351L8.0459 21.0736L8.15218 21.4719H8.56444V20.9351ZM5.59866 9.81273L5.32758 9.34894L4.97437 9.55507L5.08011 9.95068L5.59866 9.81273ZM10.8727 1.61052V1.07373H10.3863L10.3385 1.55738L10.8727 1.61052ZM11.4631 1.61052H11.9999V1.07373H11.4631V1.61052ZM11.4631 9.17931L11.5699 9.70537L11.9994 9.61787V9.17931H11.4631ZM12.5367 9.17931H11.9994V9.61787L12.4294 9.70537L12.5367 9.17931ZM12.5367 1.61052V1.07373H11.9999V1.61052H12.5367ZM13.1272 1.61052L12.5925 1.66367C12.9576 5.34339 15.0918 8.50027 18.1301 10.276L18.4006 9.81219L18.6717 9.34894C15.9207 7.74124 13.9909 4.88389 13.6608 1.55738L13.1272 1.61052ZM18.4006 9.81273L17.8821 9.67423L14.9169 20.7966L15.4354 20.9351L15.9539 21.0736L18.9197 9.95068L18.4006 9.81273ZM15.4354 20.9351V20.3983H8.56444V21.4719H15.4354V20.9351ZM8.56444 20.9351L9.08298 20.7966L6.1172 9.67423L5.59866 9.81219L5.08011 9.95068L8.0459 21.0736L8.56444 20.9351ZM5.59866 9.81273L5.8692 10.276C8.90745 8.50027 11.0423 5.34339 11.4073 1.66367L10.8732 1.61052L10.3391 1.55738C10.009 4.88389 8.07918 7.74124 5.32758 9.34894L5.59866 9.81273ZM10.8727 1.61052V2.14732H11.4631V1.07373H10.8727V1.61052ZM11.4631 1.61052H10.9263V9.17931H11.9994L11.9999 1.61052H11.4631ZM11.4631 9.17931L11.3558 8.65325C10.6283 8.80175 9.97445 9.19704 9.50492 9.77221C9.03539 10.3474 8.77901 11.0671 8.77916 11.8096H9.85274C9.85262 11.3147 10.0235 10.8349 10.3364 10.4515C10.6493 10.068 11.0851 9.80447 11.5699 9.70537L11.4631 9.17931ZM9.31595 11.8096H8.77916C8.77916 12.6638 9.11849 13.483 9.7225 14.087C10.3265 14.691 11.1457 15.0304 11.9999 15.0304V13.9568C11.4305 13.9568 10.8843 13.7306 10.4816 13.3279C10.079 12.9252 9.85274 12.3791 9.85274 11.8096H9.31595ZM11.9999 14.4936V15.0304C12.8541 15.0304 13.6733 14.691 14.2773 14.087C14.8813 13.483 15.2207 12.6638 15.2207 11.8096H14.1471C14.1471 12.3791 13.9209 12.9252 13.5182 13.3279C13.1155 13.7306 12.5694 13.9568 11.9999 13.9568V14.4936ZM14.6839 11.8096H15.2207C15.2208 11.067 14.9643 10.3472 14.4947 9.77206C14.0251 9.19688 13.3711 8.80164 12.6435 8.65325L12.5367 9.17931L12.4299 9.70537C12.9148 9.80447 13.3505 10.068 13.6635 10.4515C13.9764 10.8349 14.1472 11.3147 14.1471 11.8096H14.6839ZM12.5367 9.17931H13.0735V1.61052H11.9999L11.9994 9.17931H12.5367ZM12.5367 1.61052V2.14732H13.1272V1.07373H12.5367V1.61052Z",fill:"white","fill-opacity":"0.5"})})]}),u.jsx("path",{d:"M12.0001 0.805176C12.0713 0.805176 12.1395 0.833453 12.1899 0.883787C12.2402 0.934121 12.2685 1.00239 12.2685 1.07357V10.7359C12.2685 10.807 12.2402 10.8753 12.1899 10.9256C12.1395 10.976 12.0713 11.0043 12.0001 11.0043C11.9289 11.0043 11.8606 10.976 11.8103 10.9256C11.76 10.8753 11.7317 10.807 11.7317 10.7359V1.07357C11.7317 1.00239 11.76 0.934121 11.8103 0.883787C11.8606 0.833453 11.9289 0.805176 12.0001 0.805176Z",fill:"black","fill-opacity":"0.15"}),u.jsxs("mask",{id:"mask3_1571_205",style:{maskType:"luminance"},maskUnits:"userSpaceOnUse",x:"11",y:"0",width:"2",height:"12",children:[u.jsx("path",{d:"M11.1948 0.268555H12.8052V11.5412H11.1948V0.268555Z",fill:"white"}),u.jsx("path",{d:"M12.0001 0.805176C12.0713 0.805176 12.1395 0.833453 12.1899 0.883787C12.2402 0.934121 12.2685 1.00239 12.2685 1.07357V10.7359C12.2685 10.807 12.2402 10.8753 12.1899 10.9256C12.1395 10.976 12.0713 11.0043 12.0001 11.0043C11.9289 11.0043 11.8606 10.976 11.8103 10.9256C11.76 10.8753 11.7317 10.807 11.7317 10.7359V1.07357C11.7317 1.00239 11.76 0.934121 11.8103 0.883787C11.8606 0.833453 11.9289 0.805176 12.0001 0.805176Z",fill:"black"})]}),u.jsx("g",{mask:"url(#mask3_1571_205)",children:u.jsx("path",{d:"M12 0.805348V1.34214C11.9288 1.34214 11.8606 1.31386 11.8102 1.26353C11.7599 1.2132 11.7316 1.14493 11.7316 1.07374H12.8052C12.8052 0.860195 12.7204 0.655392 12.5694 0.504389C12.4184 0.353387 12.2136 0.268555 12 0.268555V0.805348ZM12.2684 1.07374H11.7316V10.736H12.8052V1.07374H12.2684ZM12.2684 10.736H11.7316C11.7316 10.6648 11.7599 10.5966 11.8102 10.5462C11.8606 10.4959 11.9288 10.4676 12 10.4676V11.5412C12.2136 11.5412 12.4184 11.4564 12.5694 11.3054C12.7204 11.1544 12.8052 10.9496 12.8052 10.736H12.2684ZM12 11.0044V10.4676C12.0712 10.4676 12.1395 10.4959 12.1898 10.5462C12.2401 10.5966 12.2684 10.6648 12.2684 10.736H11.1948C11.1948 10.9496 11.2797 11.1544 11.4307 11.3054C11.5817 11.4564 11.7865 11.5412 12 11.5412V11.0044ZM11.7316 10.736H12.2684V1.07374H11.1948V10.736H11.7316ZM11.7316 1.07374H12.2684C12.2684 1.14493 12.2401 1.2132 12.1898 1.26353C12.1395 1.31386 12.0712 1.34214 12 1.34214V0.268555C11.7865 0.268555 11.5817 0.353387 11.4307 0.504389C11.2797 0.655392 11.1948 0.860195 11.1948 1.07374H11.7316Z",fill:"white"})})]}),u.jsx("path",{d:"M5.55859 20.9348C5.55859 20.3653 5.78481 19.8192 6.18749 19.4165C6.59016 19.0138 7.1363 18.7876 7.70577 18.7876H16.2945C16.8639 18.7876 17.4101 19.0138 17.8127 19.4165C18.2154 19.8192 18.4416 20.3653 18.4416 20.9348V35.965H5.55859V20.9348Z",fill:"white"}),u.jsx("path",{d:"M16.2944 18.6538L16.4119 18.657C16.9958 18.6872 17.5459 18.9403 17.9485 19.3642C18.3512 19.7882 18.5757 20.3505 18.5758 20.9352V36.0996H5.42432V20.9352C5.42432 20.3301 5.66467 19.7498 6.09251 19.322C6.52036 18.8942 7.10063 18.6538 7.70569 18.6538H16.2944Z",stroke:"black","stroke-opacity":"0.15","stroke-width":"0.268397"}),u.jsx("mask",{id:"mask4_1571_205",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"5",y:"18",width:"14",height:"18",children:u.jsx("path",{d:"M5.55859 20.9353C5.55859 20.3658 5.78481 19.8197 6.18749 19.417C6.59016 19.0143 7.1363 18.7881 7.70577 18.7881H16.2945C16.8639 18.7881 17.4101 19.0143 17.8127 19.417C18.2154 19.8197 18.4416 20.3658 18.4416 20.9353V35.9655H5.55859V20.9353Z",fill:"white"})}),u.jsxs("g",{mask:"url(#mask4_1571_205)",children:[u.jsxs("g",{filter:"url(#filter1_dd_1571_205)",children:[u.jsx("path",{d:"M5.55859 20.9353C5.55859 20.3658 5.78481 19.8197 6.18749 19.417C6.59016 19.0143 7.1363 18.7881 7.70577 18.7881H16.2945C16.8639 18.7881 17.4101 19.0143 17.8127 19.417C18.2154 19.8197 18.4416 20.3658 18.4416 20.9353V35.9655H5.55859V20.9353Z",fill:"white"}),u.jsx("path",{d:"M16.2944 18.6543L16.4119 18.6575C16.9958 18.6876 17.5459 18.9408 17.9485 19.3647C18.3512 19.7887 18.5757 20.351 18.5758 20.9357V36.1001H5.42432V20.9357C5.42432 20.3306 5.66467 19.7503 6.09251 19.3225C6.52036 18.8947 7.10063 18.6543 7.70569 18.6543H16.2944Z",stroke:"black","stroke-opacity":"0.15","stroke-width":"0.268397"})]}),u.jsxs("g",{opacity:"0.75",filter:"url(#filter2_f_1571_205)",children:[u.jsx("path",{d:"M5.55859 20.9353C5.55859 20.3658 5.78481 19.8197 6.18749 19.417C6.59016 19.0143 7.1363 18.7881 7.70577 18.7881H16.2945C16.8639 18.7881 17.4101 19.0143 17.8127 19.417C18.2154 19.8197 18.4416 20.3658 18.4416 20.9353V35.9655H5.55859V20.9353Z",fill:"url(#paint2_linear_1571_205)"}),u.jsx("path",{d:"M7.70568 19.0566H16.2944C16.7927 19.0566 17.2705 19.2546 17.6229 19.6069C17.9752 19.9593 18.1732 20.4371 18.1732 20.9354V35.6972H5.8269V20.9354C5.82695 20.4539 6.01189 19.9908 6.34352 19.6417C6.67515 19.2925 7.12817 19.0841 7.60906 19.0593L7.70568 19.0566Z",stroke:"white","stroke-opacity":"0.5","stroke-width":"0.536793"})]})]})]})}),u.jsxs("defs",{children:[u.jsxs("filter",{id:"filter0_f_1571_205",x:"4.52505",y:"0.536765",width:"14.9492",height:"21.4719",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feGaussianBlur",{stdDeviation:"0.536793",result:"effect1_foregroundBlur_1571_205"})]}),u.jsxs("filter",{id:"filter1_dd_1571_205",x:"3.14287",y:"17.4464",width:"17.7143",height:"22.0087",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),u.jsx("feOffset",{dy:"0.536793"}),u.jsx("feGaussianBlur",{stdDeviation:"0.536793"}),u.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0"}),u.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1571_205"}),u.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),u.jsx("feOffset",{dy:"1.07359"}),u.jsx("feGaussianBlur",{stdDeviation:"1.07359"}),u.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),u.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0"}),u.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1571_205",result:"effect2_dropShadow_1571_205"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect2_dropShadow_1571_205",result:"shape"})]}),u.jsxs("filter",{id:"filter2_f_1571_205",x:"4.48501",y:"17.7145",width:"15.0302",height:"19.3249",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feGaussianBlur",{stdDeviation:"0.536793",result:"effect1_foregroundBlur_1571_205"})]}),u.jsxs("linearGradient",{id:"paint0_linear_1571_205",x1:"4.53739",y1:"10.1244",x2:"19.4624",y2:"10.1244",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{offset:"0.49","stop-color":"#999999","stop-opacity":"0"}),u.jsx("stop",{offset:"1","stop-color":"#999999"})]}),u.jsxs("linearGradient",{id:"paint1_linear_1571_205",x1:"10.134",y1:"1.36987",x2:"13.2506",y2:"18.9257",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{offset:"0.726","stop-color":"#999999","stop-opacity":"0"}),u.jsx("stop",{offset:"1","stop-color":"#999999"})]}),u.jsxs("linearGradient",{id:"paint2_linear_1571_205",x1:"5.55859",y1:"27.3768",x2:"18.4416",y2:"27.3768",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-color":"#AAAAAA","stop-opacity":"0.5"}),u.jsx("stop",{offset:"0.394","stop-color":"#AAAAAA","stop-opacity":"0"}),u.jsx("stop",{offset:"0.832","stop-color":"#999999"})]}),u.jsx("clipPath",{id:"clip0_1571_205",children:u.jsx("rect",{width:"24",height:"24",fill:"white"})}),u.jsx("clipPath",{id:"clip1_1571_205",children:u.jsx("rect",{width:"18.251",height:"36.502",fill:"white",transform:"translate(2.87451)"})})]})]})}function Pse({className:t,color:e}){return u.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsxs("g",{"clip-path":"url(#clip0_1538_150)",children:[u.jsx("path",{d:"M7.95337 5.71142C7.95337 5.36004 8.16295 5.04253 8.48605 4.9044L13.7522 2.65314C14.3313 2.40559 14.9748 2.83041 14.9748 3.46017L14.9748 10.9073L7.95337 10.9073L7.95337 5.71142Z",fill:e||"#FFEE00"}),u.jsx("path",{d:"M7.95337 5.71142C7.95337 5.36004 8.16295 5.04253 8.48605 4.9044L13.7522 2.65314C14.3313 2.40559 14.9748 2.83041 14.9748 3.46017L14.9748 10.9073L7.95337 10.9073L7.95337 5.71142Z",fill:"url(#paint0_linear_1538_150)"}),u.jsx("path",{d:"M14.0947 2.62097C14.4884 2.45264 14.9256 2.74131 14.9259 3.16947L14.9259 10.9171L8.00098 10.9171L8.00098 5.61955L8.00798 5.53139C8.03836 5.32877 8.17118 5.15321 8.36338 5.07104L14.0947 2.62097Z",stroke:"black","stroke-opacity":"0.3","stroke-width":"0.1"}),u.jsx("path",{d:"M8.21993 10.3188C7.31667 10.3188 6.58444 11.0468 6.58444 11.9446C6.58444 17.2642 4.51919 21.2529 0.638381 24.8865C0.238494 25.2609 0.000244048 25.7803 0.000244045 26.3283L0.000244012 31.8114C0.000244008 32.6027 0.641734 33.2442 1.43307 33.2444L21.4927 33.2444C22.2841 33.2444 22.9255 32.6029 22.9255 31.8115L22.9255 26.3283C22.9255 25.7805 22.6873 25.2611 22.2874 24.8867C18.4065 21.253 16.3414 17.2643 16.3414 11.9447C16.3414 11.0469 15.6091 10.3189 14.7059 10.3189L8.21993 10.3188Z",fill:"url(#paint1_linear_1538_150)","fill-opacity":"0.6"}),u.jsx("path",{d:"M8.24279 10.6406C7.34604 10.6406 6.61908 11.3633 6.61908 12.2547C6.61908 17.536 4.56869 21.496 0.715818 25.1035C0.31881 25.4752 0.0822753 25.9908 0.0822753 26.5348L0.0822753 31.9784C0.0822753 32.7641 0.719147 33.4009 1.50478 33.4011L21.42 33.4011C22.2057 33.4011 22.8425 32.7642 22.8425 31.9786L22.8425 26.5348C22.8425 25.991 22.606 25.4753 22.2089 25.1036C18.3561 21.4961 16.3058 17.5361 16.3058 12.2548C16.3058 11.3634 15.5788 10.6407 14.682 10.6407L8.24279 10.6406Z",fill:"white"}),u.jsx("path",{d:"M8.22911 10.9165L14.716 10.9165C15.4232 10.9167 15.9935 11.4863 15.9935 12.1842C15.9935 17.6193 18.1121 21.6982 22.0522 25.3875C22.3839 25.698 22.5768 26.1242 22.5769 26.567L22.5769 32.0507C22.5769 32.6442 22.0958 33.1253 21.5023 33.1253L1.44278 33.1253L1.33224 33.1197C0.790689 33.0643 0.368164 32.6068 0.368164 32.0507L0.368164 26.567C0.368322 26.1795 0.516175 25.8049 0.775344 25.5093L0.892879 25.3875C4.83304 21.6982 6.95297 17.6193 6.95299 12.1842C6.95299 11.5297 7.45337 10.9885 8.09898 10.9235L8.22911 10.9165Z",stroke:"black","stroke-opacity":"0.3","stroke-width":"0.5"}),u.jsx("g",{opacity:"0.1",filter:"url(#filter0_f_1538_150)",children:u.jsx("path",{d:"M15.2885 12.2295L11.9453 12.2295L11.9453 31.8116L21.4975 31.8116L21.4975 26.0801C18.6319 23.2145 15.2885 20.8266 15.2885 12.2295Z",fill:"black"})})]}),u.jsxs("defs",{children:[u.jsxs("filter",{id:"filter0_f_1538_150",x:"9.94529",y:"10.2295",width:"13.5523",height:"23.5821",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[u.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),u.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),u.jsx("feGaussianBlur",{stdDeviation:"1.00001",result:"effect1_foregroundBlur_1538_150"})]}),u.jsxs("linearGradient",{id:"paint0_linear_1538_150",x1:"11.4641",y1:"3.00812",x2:"11.4641",y2:"8.71307",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-color":"white","stop-opacity":"0.8"}),u.jsx("stop",{offset:"1","stop-color":"white","stop-opacity":"0"})]}),u.jsxs("linearGradient",{id:"paint1_linear_1538_150",x1:"0.000244031",y1:"28.7867",x2:"22.9255",y2:"28.7867",gradientUnits:"userSpaceOnUse",children:[u.jsx("stop",{"stop-opacity":"0.1"}),u.jsx("stop",{offset:"0.4","stop-opacity":"0"}),u.jsx("stop",{offset:"1","stop-opacity":"0.15"})]}),u.jsx("clipPath",{id:"clip0_1538_150",children:u.jsx("rect",{width:"24",height:"24",fill:"white"})})]})]})}const KT=({interactionMode:t,drawingTool:e,isPresentationMode:r,messages:n,setInteractionMode:i,setDrawingTool:a,drawDefaults:s,invertPaletteInDarkMode:o,strokeColors:A,onDrawDefaultStrokeColorChange:l,onDrawDefaultStrokeWidthChange:c,onSelectImageFiles:f})=>{const[d,h]=P.useState(!1),C=P.useRef(null),p=F=>{r&&F!=="pan"||i(F)},w=F=>{r||a(F)},m=()=>e==="marker"?"marker":e==="quill"?"quill":"draw",[g,B]=P.useState(e==="marker"?s.markerStroke:e==="quill"?s.quillStroke:s.drawStroke),b=e==="marker"?bc:Ko,L=e==="marker"?AI:J5,E=F=>o?Rf(F):F,I=e==="marker"?s.markerStroke:e==="quill"?s.quillStroke:s.drawStroke;P.useEffect(()=>{B(I)},[I]);const k=F=>{const D=F.hexa||F.hex;if(D){B(D);const U=m();l(U,D)}},M=(F,D)=>{const U=F[D]??F[0];return U?u.jsx("svg",{width:U.width,height:U.height,viewBox:U.viewBox,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:U.path,stroke:U.strokeWidth?"currentColor":void 0,strokeWidth:U.strokeWidth,strokeLinecap:U.strokeWidth?"round":void 0,fill:U.fill})}):null},H=["draw","marker","quill"];return u.jsxs("div",{className:"tool-bar",children:[u.jsx("input",{ref:C,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:F=>{const D=Array.from(F.target.files??[]).filter(U=>U.type.startsWith("image/"));D.length>0&&f(D),F.currentTarget.value=""}}),H.includes(e)?u.jsxs("div",{className:"top-toolbar",children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`drawtool-elem tool-item${e==="draw"?" active":""}`,onClick:()=>{p("select"),w("draw"),h(!1)},children:u.jsx(Tse,{color:E(s.drawStroke),className:"drawtool-icon"})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.pen})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`drawtool-elem tool-item${e==="quill"?" active":""}`,onClick:()=>{p("select"),w("quill"),h(!1)},children:u.jsx(Nse,{color:E(s.quillStroke),className:"drawtool-icon "})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.quill})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`drawtool-elem tool-item${e==="marker"?" active":""}`,onClick:()=>{p("select"),w("marker"),h(!1)},children:u.jsx(Pse,{color:E(s.markerStroke),className:"drawtool-icon"})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.marker})})]}),u.jsx("div",{className:"tool-separator"}),u.jsx(ws,{colors:A,currentColor:I,uniColor:E,renderItem:({color:F,swatch:D})=>u.jsx("div",{className:"drawo-colorselect-item",onClick:()=>{if(F==="multi"){h(U=>!U);return}h(!1),k({hex:F})},children:D},F)}),u.jsxs(Tr,{open:d,children:[u.jsx(Nr,{asChild:!0,children:u.jsx("span",{style:{opacity:0},children:"."})}),u.jsx(Pr,{className:"drawo-content-color inferior",side:"bottom",style:{background:"transparent",padding:0},onPointerDown:F=>F.stopPropagation(),children:u.jsx(u2,{color:g,onChange:k})})]}),u.jsx("div",{className:"tool-separator"}),u.jsxs(ya,{value:String(e==="marker"?s.markerStrokeWidth:e==="quill"?s.quillStrokeWidth:s.drawStrokeWidth),onValueChange:F=>{const D=m();c(D,Number(F))},children:[u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx(Ba,{noArrow:!0,className:"draw-stroke-trigger",style:{gap:"0px",width:"fit-content"},children:u.jsx("span",{className:"draw-stroke-option-line-wrap",children:(()=>{const F=e==="marker"?s.markerStrokeWidth:e==="quill"?s.quillStrokeWidth:s.drawStrokeWidth,D=Math.max(0,b.findIndex(U=>U===F));return M(L,D)})()})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.selectionBar?.strokeWidth||"Stroke Width"})})]}),u.jsx(ba,{position:"popper",children:b.map((F,D)=>u.jsx(Hr,{check:!1,value:String(F),className:"draw-stroke-select-item",children:u.jsx("span",{className:"draw-stroke-option-line-wrap",children:M(L,D)})},F))})]})]}):u.jsx(u.Fragment,{}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${t==="select"&&!e?" active":""}`,onClick:()=>{p("select"),w(null)},children:u.jsx(mO,{style:{transform:"translateY(-2px) translateX(-3px) rotate(-46deg)"},strokeWidth:.1})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.selection})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${t==="pan"?" active":""}`,onClick:()=>{p("pan"),w(null)},children:u.jsx(WZ,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.pan})})]}),u.jsx("div",{className:"tool-separator"}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="text"?" active":""}`,onClick:()=>{p("select"),w("text")},children:u.jsx(ug,{strokeWidth:.1})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.text})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="rectangle"?" active":""}`,onClick:()=>{p("select"),w("rectangle")},children:u.jsx(qZ,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.rectangle})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="circle"?" active":""}`,onClick:()=>{p("select"),w("circle")},children:u.jsx(Oz,{strokeWidth:1.5})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.ellipse})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="line"?" active":""}`,onClick:()=>{p("select"),w("line")},children:u.jsx(GZ,{style:{scale:"1.2"}})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.line})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${H.includes(e)?" active":""}`,onClick:()=>{p("select"),w("draw")},children:u.jsx(wO,{strokeWidth:1.5})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.draw})})]}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:"tool-item",onClick:()=>{p("select"),w(null),C.current?.click()},children:u.jsx($Z,{})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.image})})]}),u.jsx("div",{className:"tool-separator"}),u.jsxs(Tr,{children:[u.jsx(Nr,{asChild:!0,children:u.jsx("button",{type:"button",className:`tool-item${e==="laser"?" active":""}`,onClick:()=>{p("select"),w("laser")},children:u.jsx(KZ,{strokeWidth:1.5})})}),u.jsx(Pr,{children:u.jsx("p",{children:n.toolNames.laser})})]})]})};function Jf(){const t=v2(),{scene:e,resolvedTheme:r,isDarkMode:n,isPresentationMode:i,interactionMode:a,drawingTool:s,messages:o,setInteractionMode:A,setDrawingTool:l,handlers:c}=t;return u.jsx(KT,{interactionMode:a,drawingTool:s,isPresentationMode:i,messages:o,setInteractionMode:A,setDrawingTool:l,drawDefaults:e.settings.drawDefaults,invertPaletteInDarkMode:n&&e.settings.colorScheme==="drawo",strokeColors:r.preset.strokeColors,onDrawDefaultStrokeColorChange:c.handleDrawDefaultStrokeColorChange,onDrawDefaultStrokeWidthChange:c.handleDrawDefaultStrokeWidthChange,onSelectImageFiles:f=>c.handleInsertImageFiles?.(f)})}function qT({canUndo:t,canRedo:e,onUndo:r,onRedo:n}){return u.jsxs("div",{className:"undo-bar bottompanel-bar",children:[u.jsx("button",{type:"button",onClick:r,disabled:!t,"aria-label":"Undo",children:u.jsx(_z,{})}),u.jsx("button",{type:"button",onClick:n,disabled:!e,"aria-label":"Redo",children:u.jsx(Hz,{})})]})}function eh(){const t=v2(),{canUndo:e,canRedo:r,undo:n,redo:i}=t;return u.jsx("div",{className:"drawo-bottomleft-bar",children:u.jsx(qT,{canUndo:e,canRedo:r,onUndo:n,onRedo:i})})}function $T({zoomPercent:t,canZoomOut:e,canZoomIn:r,onZoomOut:n,onZoomIn:i,onZoomReset:a}){const s=Math.max(0,Math.min(200,t));return u.jsxs("div",{className:"zoom-bar bottompanel-bar",children:[u.jsx("button",{type:"button",onClick:n,disabled:!e,"aria-label":"Zoom out",children:u.jsx(sO,{strokeWidth:1})}),u.jsx("div",{className:"bottompanel-separator"}),u.jsx("button",{type:"button",onClick:a,"aria-label":"Reset zoom",children:u.jsxs("span",{children:[s,"%"]})}),u.jsx("div",{className:"bottompanel-separator"}),u.jsx("button",{type:"button",onClick:i,disabled:!r,"aria-label":"Zoom in",children:u.jsx(oO,{strokeWidth:1})})]})}function th(){const t=v2(),{scene:e,handlers:r}=t;return u.jsx("div",{className:"drawo-bottomright-bar",children:u.jsx($T,{zoomPercent:Math.round(e.camera.zoom*100),canZoomOut:e.camera.zoom>jh,canZoomIn:e.camera.zoom<Qh,onZoomOut:r.handleZoomOut,onZoomIn:r.handleZoomIn,onZoomReset:r.handleZoomReset})})}function Rse({children:t,className:e,style:r}){const n=v2(),{openTopbarPanel:i}=n,a=i==="sidebar",s=P.useMemo(()=>t?Array.isArray(t)?t:[t]:[],[t]),o=s.some(d=>d?.type===Vf),A=s.some(d=>d?.type===Yf),l=s.some(d=>d?.type===Jf),c=s.some(d=>d?.type===eh),f=s.some(d=>d?.type===th);return u.jsx("div",{className:`app-root ${e??""}`,style:r,children:u.jsx(vK,{children:u.jsx("div",{className:`app-shell ${a?"app-shell--sidebar-open":""}`,children:u.jsxs("div",{className:"app-workspace",children:[o?null:u.jsx(Vf,{}),A?null:u.jsx(Yf,{}),l?null:u.jsx(Jf,{}),c?null:u.jsx(eh,{}),f?null:u.jsx(th,{}),t]})})})})}function Use(t){const{children:e,className:r,style:n,...i}=t;return u.jsx(nO,{...i,children:u.jsx(Rse,{className:r,style:n,children:e})})}const jse=Object.assign(Use,{TopBar:Vf,Canvas:Yf,ToolBar:Jf,UndoBar:eh,ZoomBar:th}),Qse=[{id:"basic",name:"Basic",description:"General shapes and utilities"},{id:"flowchart",name:"Flowchart",description:"Flowchart symbols"},{id:"bpmn",name:"BPMN",description:"BPMN process symbols"},{id:"network",name:"Network",description:"Network infrastructure"},{id:"cloud",name:"Cloud",description:"Cloud services"},{id:"devops",name:"DevOps",description:"DevOps tools"},{id:"security",name:"Security",description:"Security & access"},{id:"devices",name:"Devices",description:"Hardware devices"},{id:"data",name:"Data",description:"Data storage & databases"},{id:"people",name:"People",description:"Users and roles"},{id:"communication",name:"Communication",description:"Messaging & APIs"},{id:"programs",name:"Programs",description:"Software & IDEs"},{id:"languages",name:"Languages",description:"Programming languages"},{id:"aws",name:"AWS",description:"Amazon Web Services"},{id:"custom",name:"Custom",description:"Custom assets"}],GT=[],jd={categories:Qse,assets:GT};function _se(t,e){const r=t.toLowerCase().trim();let n=GT;return e?.categoryId&&(n=n.filter(i=>i.categoryId===e.categoryId)),r?n.filter(i=>i.name.toLowerCase().includes(r)||i.tags.some(a=>a.toLowerCase().includes(r))):n}const BB=t=>null,Hse=(t,e,r,n,i)=>{const a=BB(),s=BB();if(!a&&!s&&null===null)return;const A=l=>{a&&l.getAttribute("fill")!=="none"&&l.setAttribute("fill",a),s&&i!=="none"&&l.getAttribute("stroke")!=="none"&&l.setAttribute("stroke",s)};A(t),t.querySelectorAll("*").forEach(l=>A(l))},Vse=(t,e)=>{if(typeof window>"u")return"";const i=new window.DOMParser().parseFromString(t,"image/svg+xml").documentElement;if(!(i instanceof window.SVGElement)||i.tagName.toLowerCase()!=="svg")return"";Hse(i,e?.fill,e?.stroke,e?.strokeWidth,e?.strokeStyle);const a=i.outerHTML;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`},f9=t=>t.normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"").toLowerCase().trim(),bB=t=>Gc(t).map(e=>e.runs.map(r=>r.text).join("")).join(`
240
240
  `).trim(),Wse=t=>{if(t.type==="text"){const e=bB(t.text);return e?{id:t.id,label:"Text",typeLabel:"Text",text:e}:null}if(t.type==="rectangle"||t.type==="circle"){const e=bB(t.text);return e?{id:t.id,label:t.type==="rectangle"?"Rectángulo":"Círculo",typeLabel:"Shape",text:e}:null}return null},Kse=(t,e)=>{if(!e)return t;const n=f9(t).indexOf(e);if(n<0)return t;const i=Math.max(0,n-28),a=Math.min(t.length,n+e.length+48),s=i>0?"...":"",o=a<t.length?"...":"";return`${s}${t.slice(i,a)}${o}`},qse=({scene:t,isOpen:e,onOpenChange:r,onFocusElement:n,onInsertLibraryAsset:i})=>{const[a,s]=P.useState("search"),[o,A]=P.useState(""),[l,c]=P.useState(0),[f,d]=P.useState(null),[h,C]=P.useState(null),p=f9(o),w=P.useMemo(()=>{const E=t.elements.map(I=>Wse(I)).filter(I=>I!==null);return p?E.filter(I=>f9(I.text).includes(p)):E},[p,t.elements]),m=w.length===0?0:Math.min(l,w.length-1),g=E=>{if(w.length===0)return;const I=(E%w.length+w.length)%w.length;c(I),n(w[I].id)},B=()=>{w.length!==0&&g(m)},b=E=>{if(E.key==="Enter"){E.preventDefault(),B();return}if(E.key==="ArrowDown"){E.preventDefault(),g(m+1);return}E.key==="ArrowUp"&&(E.preventDefault(),g(m-1))},L=P.useMemo(()=>_se(o,{categoryId:f}),[f,o]);return e?u.jsxs("aside",{id:"search-library-sidebar",className:"sidebar-page-panel",role:"dialog",children:[u.jsxs("div",{className:"sidebar-tabs",role:"tablist","aria-label":"Buscar o librería",children:[u.jsxs("button",{type:"button",className:`sidebar-tab ${a==="search"?"active":""}`,onClick:()=>s("search"),role:"tab","aria-selected":a==="search",children:[u.jsx(nf,{weight:"BoldDuotone",size:15}),"Buscar"]}),u.jsxs("button",{type:"button",className:`sidebar-tab ${a==="library"?"active":""}`,onClick:()=>s("library"),role:"tab","aria-selected":a==="library",children:[u.jsx(SO,{weight:"BoldDuotone",size:15}),"Librería"]}),u.jsx("button",{type:"button",className:"sidebar-page-close",onClick:()=>r(!1),"aria-label":"Cerrar sidebar",children:u.jsx(IZ,{className:"size-4"})})]}),a==="search"?u.jsxs("section",{className:"sidebar-section",children:[u.jsxs("div",{className:"sidebar-search-wrap",children:[u.jsx(nf,{size:16,className:"sidebar-search-icon"}),u.jsx("input",{type:"text",value:o,onChange:E=>{A(E.target.value),c(0)},onKeyDown:b,placeholder:"Buscar texto en elementos...",className:"sidebar-search-input"})]}),u.jsxs("div",{className:"sidebar-search-toolbar",children:[u.jsx("span",{className:"sidebar-search-count",children:w.length===0?"0 resultados":`${m+1}/${w.length}`}),u.jsxs("div",{className:"sidebar-search-actions",children:[u.jsx("button",{type:"button",className:"sidebar-mini-btn",onClick:()=>g(m-1),disabled:w.length===0,title:"Anterior",children:u.jsx(Kz,{className:"size-7"})}),u.jsx("button",{type:"button",className:"sidebar-mini-btn",onClick:()=>g(m+1),disabled:w.length===0,title:"Siguiente",children:u.jsx(uO,{className:"size-7"})})]})]}),u.jsx("div",{className:"sidebar-search-results",children:w.length===0?u.jsxs("div",{className:"sidebar-empty-state",children:[u.jsx(X8,{weight:"BoldDuotone"}),u.jsx("p",{children:"No hay coincidencias con ese texto."})]}):w.map((E,I)=>u.jsxs("button",{type:"button",className:`sidebar-result-item ${m===I?"active":""}`,onClick:()=>g(I),children:[u.jsxs("span",{className:"sidebar-result-meta",children:[u.jsx("span",{className:"sidebar-result-type",children:E.typeLabel.toUpperCase()==="TEXT"?u.jsx(u.Fragment,{children:u.jsx(ug,{})}):E.typeLabel.toUpperCase()==="SHAPE"?u.jsx(u.Fragment,{children:u.jsx(yO,{})}):u.jsx(u.Fragment,{children:E.typeLabel})}),u.jsx("span",{className:"sidebar-result-label",children:E.label})]}),u.jsxs("span",{className:"sidebar-result-text",children:['"',Kse(E.text,p),'"']})]},E.id))})]}):u.jsxs("section",{className:"sidebar-section",children:[u.jsxs("div",{className:"sidebar-search-wrap",children:[u.jsx(nf,{size:16,className:"sidebar-search-icon"}),u.jsx("input",{type:"text",value:o,onChange:E=>A(E.target.value),placeholder:"Buscar assets por nombre o tags...",className:"sidebar-search-input"})]}),u.jsxs("div",{className:"sidebar-library-categories",role:"tablist",children:[u.jsxs("button",{type:"button",className:`sidebar-library-category-pill ${f===null?"active":""}`,onClick:()=>d(null),children:["Todo",u.jsx("span",{children:jd.assets.length})]}),jd.categories.map(E=>{const I=jd.assets.filter(k=>k.categoryId===E.id).length;return u.jsxs("button",{type:"button",className:`sidebar-library-category-pill ${f===E.id?"active":""}`,onClick:()=>d(E.id),title:E.description,children:[E.name,u.jsx("span",{children:I})]},E.id)})]}),u.jsxs("p",{className:"sidebar-library-note",children:[L.length," asset",L.length===1?"":"s"," ","disponible",f?"s en la categoría":"s","."]}),L.length===0?u.jsxs("div",{className:"sidebar-empty-state sidebar-library-empty-state",children:[u.jsx(X8,{weight:"BoldDuotone"}),u.jsx("p",{children:"No hay resultados para tu búsqueda."})]}):u.jsx("div",{className:"sidebar-library-grid",children:L.map(E=>{const I=Vse(E.svg),k=h===E.id;return u.jsxs("button",{type:"button",className:`sidebar-library-asset ${k?"selected":""}`,onClick:()=>{C(E.id),i(E)},title:`${E.name} • ${E.tags.join(", ")}`,children:[u.jsx("div",{className:"sidebar-library-asset-preview",children:I?u.jsx("img",{src:I,alt:E.name,loading:"lazy"}):u.jsx(EO,{})}),u.jsxs("div",{className:"sidebar-library-asset-meta",children:[u.jsx("span",{className:"sidebar-library-asset-name",children:E.name}),u.jsx("span",{className:"sidebar-library-asset-tags",children:E.tags.slice(0,3).join(" · ")})]})]},E.id)})})]})]}):null};function zr(t){"@babel/helpers - typeof";return zr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},zr(t)}var z1=Uint8Array,o1=Uint16Array,Ig=Int32Array,Og=new z1([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Tg=new z1([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),xB=new z1([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),zT=function(t,e){for(var r=new o1(31),n=0;n<31;++n)r[n]=e+=1<<t[n-1];for(var i=new Ig(r[30]),n=1;n<30;++n)for(var a=r[n];a<r[n+1];++a)i[a]=a-r[n]<<5|n;return{b:r,r:i}},ZT=zT(Og,2),$se=ZT.b,h9=ZT.r;$se[28]=258,h9[258]=28;var Gse=zT(Tg,0),LB=Gse.r,d9=new o1(32768);for(var Dn=0;Dn<32768;++Dn){var No=(Dn&43690)>>1|(Dn&21845)<<1;No=(No&52428)>>2|(No&13107)<<2,No=(No&61680)>>4|(No&3855)<<4,d9[Dn]=((No&65280)>>8|(No&255)<<8)>>1}var sc=(function(t,e,r){for(var n=t.length,i=0,a=new o1(e);i<n;++i)t[i]&&++a[t[i]-1];var s=new o1(e);for(i=1;i<e;++i)s[i]=s[i-1]+a[i-1]<<1;var o;if(r){o=new o1(1<<e);var A=15-e;for(i=0;i<n;++i)if(t[i])for(var l=i<<4|t[i],c=e-t[i],f=s[t[i]-1]++<<c,d=f|(1<<c)-1;f<=d;++f)o[d9[f]>>A]=l}else for(o=new o1(n),i=0;i<n;++i)t[i]&&(o[i]=d9[s[t[i]-1]++]>>15-t[i]);return o}),c2=new z1(288);for(var Dn=0;Dn<144;++Dn)c2[Dn]=8;for(var Dn=144;Dn<256;++Dn)c2[Dn]=9;for(var Dn=256;Dn<280;++Dn)c2[Dn]=7;for(var Dn=280;Dn<288;++Dn)c2[Dn]=8;var rh=new z1(32);for(var Dn=0;Dn<32;++Dn)rh[Dn]=5;var zse=sc(c2,9,0),Zse=sc(rh,5,0),XT=function(t){return(t+7)/8|0},Xse=function(t,e,r){return(r==null||r>t.length)&&(r=t.length),new z1(t.subarray(e,r))},Xs=function(t,e,r){r<<=e&7;var n=e/8|0;t[n]|=r,t[n+1]|=r>>8},du=function(t,e,r){r<<=e&7;var n=e/8|0;t[n]|=r,t[n+1]|=r>>8,t[n+2]|=r>>16},Qd=function(t,e){for(var r=[],n=0;n<t.length;++n)t[n]&&r.push({s:n,f:t[n]});var i=r.length,a=r.slice();if(!i)return{t:JT,l:0};if(i==1){var s=new z1(r[0].s+1);return s[r[0].s]=1,{t:s,l:1}}r.sort(function(L,E){return L.f-E.f}),r.push({s:-1,f:25001});var o=r[0],A=r[1],l=0,c=1,f=2;for(r[0]={s:-1,f:o.f+A.f,l:o,r:A};c!=i-1;)o=r[r[l].f<r[f].f?l++:f++],A=r[l!=c&&r[l].f<r[f].f?l++:f++],r[c++]={s:-1,f:o.f+A.f,l:o,r:A};for(var d=a[0].s,n=1;n<i;++n)a[n].s>d&&(d=a[n].s);var h=new o1(d+1),C=p9(r[c-1],h,0);if(C>e){var n=0,p=0,w=C-e,m=1<<w;for(a.sort(function(E,I){return h[I.s]-h[E.s]||E.f-I.f});n<i;++n){var g=a[n].s;if(h[g]>e)p+=m-(1<<C-h[g]),h[g]=e;else break}for(p>>=w;p>0;){var B=a[n].s;h[B]<e?p-=1<<e-h[B]++-1:++n}for(;n>=0&&p;--n){var b=a[n].s;h[b]==e&&(--h[b],++p)}C=e}return{t:new z1(h),l:C}},p9=function(t,e,r){return t.s==-1?Math.max(p9(t.l,e,r+1),p9(t.r,e,r+1)):e[t.s]=r},EB=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new o1(++e),n=0,i=t[0],a=1,s=function(A){r[n++]=A},o=1;o<=e;++o)if(t[o]==i&&o!=e)++a;else{if(!i&&a>2){for(;a>138;a-=138)s(32754);a>2&&(s(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(s(i),--a;a>6;a-=6)s(8304);a>2&&(s(a-3<<5|8208),a=0)}for(;a--;)s(i);a=1,i=t[o]}return{c:r.subarray(0,n),n:e}},pu=function(t,e){for(var r=0,n=0;n<e.length;++n)r+=t[n]*e[n];return r},YT=function(t,e,r){var n=r.length,i=XT(e+2);t[i]=n&255,t[i+1]=n>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var a=0;a<n;++a)t[i+a+4]=r[a];return(i+4+n)*8},SB=function(t,e,r,n,i,a,s,o,A,l,c){Xs(e,c++,r),++i[256];for(var f=Qd(i,15),d=f.t,h=f.l,C=Qd(a,15),p=C.t,w=C.l,m=EB(d),g=m.c,B=m.n,b=EB(p),L=b.c,E=b.n,I=new o1(19),k=0;k<g.length;++k)++I[g[k]&31];for(var k=0;k<L.length;++k)++I[L[k]&31];for(var M=Qd(I,7),H=M.t,F=M.l,D=19;D>4&&!H[xB[D-1]];--D);var U=l+5<<3,R=pu(i,c2)+pu(a,rh)+s,$=pu(i,d)+pu(a,p)+s+14+3*D+pu(I,H)+2*I[16]+3*I[17]+7*I[18];if(A>=0&&U<=R&&U<=$)return YT(e,c,t.subarray(A,A+l));var re,Z,ee,K;if(Xs(e,c,1+($<R)),c+=2,$<R){re=sc(d,h,0),Z=d,ee=sc(p,w,0),K=p;var fe=sc(H,F,0);Xs(e,c,B-257),Xs(e,c+5,E-1),Xs(e,c+10,D-4),c+=14;for(var k=0;k<D;++k)Xs(e,c+3*k,H[xB[k]]);c+=3*D;for(var te=[g,L],O=0;O<2;++O)for(var Q=te[O],k=0;k<Q.length;++k){var z=Q[k]&31;Xs(e,c,fe[z]),c+=H[z],z>15&&(Xs(e,c,Q[k]>>5&127),c+=Q[k]>>12)}}else re=zse,Z=c2,ee=Zse,K=rh;for(var k=0;k<o;++k){var ne=n[k];if(ne>255){var z=ne>>18&31;du(e,c,re[z+257]),c+=Z[z+257],z>7&&(Xs(e,c,ne>>23&31),c+=Og[z]);var he=ne&31;du(e,c,ee[he]),c+=K[he],he>3&&(du(e,c,ne>>5&8191),c+=Tg[he])}else du(e,c,re[ne]),c+=Z[ne]}return du(e,c,re[256]),c+Z[256]},Yse=new Ig([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),JT=new z1(0),Jse=function(t,e,r,n,i,a){var s=a.z||t.length,o=new z1(n+s+5*(1+Math.ceil(s/7e3))+i),A=o.subarray(n,o.length-i),l=a.l,c=(a.r||0)&7;if(e){c&&(A[0]=a.r>>3);for(var f=Yse[e-1],d=f>>13,h=f&8191,C=(1<<r)-1,p=a.p||new o1(32768),w=a.h||new o1(C+1),m=Math.ceil(r/3),g=2*m,B=function(Pe){return(t[Pe]^t[Pe+1]<<m^t[Pe+2]<<g)&C},b=new Ig(25e3),L=new o1(288),E=new o1(32),I=0,k=0,M=a.i||0,H=0,F=a.w||0,D=0;M+2<s;++M){var U=B(M),R=M&32767,$=w[U];if(p[R]=$,w[U]=R,F<=M){var re=s-M;if((I>7e3||H>24576)&&(re>423||!l)){c=SB(t,A,0,b,L,E,k,H,D,M-D,c),H=I=k=0,D=M;for(var Z=0;Z<286;++Z)L[Z]=0;for(var Z=0;Z<30;++Z)E[Z]=0}var ee=2,K=0,fe=h,te=R-$&32767;if(re>2&&U==B(M-te))for(var O=Math.min(d,re)-1,Q=Math.min(32767,M),z=Math.min(258,re);te<=Q&&--fe&&R!=$;){if(t[M+ee]==t[M+ee-te]){for(var ne=0;ne<z&&t[M+ne]==t[M+ne-te];++ne);if(ne>ee){if(ee=ne,K=te,ne>O)break;for(var he=Math.min(te,ne-2),le=0,Z=0;Z<he;++Z){var Be=M-te+Z&32767,V=p[Be],oe=Be-V&32767;oe>le&&(le=oe,$=Be)}}}R=$,$=p[R],te+=R-$&32767}if(K){b[H++]=268435456|h9[ee]<<18|LB[K];var de=h9[ee]&31,ve=LB[K]&31;k+=Og[de]+Tg[ve],++L[257+de],++E[ve],F=M+ee,++I}else b[H++]=t[M],++L[t[M]]}}for(M=Math.max(M,F);M<s;++M)b[H++]=t[M],++L[t[M]];c=SB(t,A,l,b,L,E,k,H,D,M-D,c),l||(a.r=c&7|A[c/8|0]<<3,c-=7,a.h=w,a.p=p,a.i=M,a.w=F)}else{for(var M=a.w||0;M<s+l;M+=65535){var Re=M+65535;Re>=s&&(A[c/8|0]=l,Re=s),c=YT(A,c+1,t.subarray(M,Re))}a.i=s}return Xse(o,0,n+XT(c)+i)},eN=function(){var t=1,e=0;return{p:function(r){for(var n=t,i=e,a=r.length|0,s=0;s!=a;){for(var o=Math.min(s+2655,a);s<o;++s)i+=n+=r[s];n=(n&65535)+15*(n>>16),i=(i&65535)+15*(i>>16)}t=n,e=i},d:function(){return t%=65521,e%=65521,(t&255)<<24|(t&65280)<<8|(e&255)<<8|e>>8}}},eoe=function(t,e,r,n,i){if(!i&&(i={l:1},e.dictionary)){var a=e.dictionary.subarray(-32768),s=new z1(a.length+t.length);s.set(a),s.set(t,a.length),t=s,i.w=a.length}return Jse(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,r,n,i)},tN=function(t,e,r){for(;r;++e)t[e]=r,r>>>=8},toe=function(t,e){var r=e.level,n=r==0?0:r<6?1:r==9?3:2;if(t[0]=120,t[1]=n<<6|(e.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,e.dictionary){var i=eN();i.p(e.dictionary),tN(t,2,i.d())}};function g9(t,e){e||(e={});var r=eN();r.p(t);var n=eoe(t,e,e.dictionary?6:2,4);return toe(n,e),tN(n,n.length-4,r.d()),n}var roe=typeof TextDecoder<"u"&&new TextDecoder,noe=0;try{roe.decode(JT,{stream:!0}),noe=1}catch{}function ioe(t){if(Array.isArray(t))return t}function aoe(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,i,a,s,o=[],A=!0,l=!1;try{if(a=(r=r.call(t)).next,e!==0)for(;!(A=(n=a.call(r)).done)&&(o.push(n.value),o.length!==e);A=!0);}catch(c){l=!0,i=c}finally{try{if(!A&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw i}}return o}}function FB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function soe(t,e){if(t){if(typeof t=="string")return FB(t,e);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?FB(t,e):void 0}}function ooe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
241
241
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function DB(t,e){return ioe(t)||aoe(t,e)||soe(t,e)||ooe()}function kB(t,e="utf8"){return new TextDecoder(e).decode(t)}const Aoe=new TextEncoder;function loe(t){return Aoe.encode(t)}const uoe=1024*8,coe=(()=>{const t=new Uint8Array(4),e=new Uint32Array(t.buffer);return!((e[0]=1)&t[0])})(),_d={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class Ng{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(e=uoe,r={}){let n=!1;typeof e=="number"?e=new ArrayBuffer(e):(n=!0,this.lastWrittenByte=e.byteLength);const i=r.offset?r.offset>>>0:0,a=e.byteLength-i;let s=i;(ArrayBuffer.isView(e)||e instanceof Ng)&&(e.byteLength!==e.buffer.byteLength&&(s=e.byteOffset+i),e=e.buffer),n?this.lastWrittenByte=a:this.lastWrittenByte=0,this.buffer=e,this.length=a,this.byteLength=a,this.byteOffset=s,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,s,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){const n=(this.offset+e)*2,i=new Uint8Array(n);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=n,this.byteLength=n,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,"uint8")}readArray(e,r){const n=_d[r].BYTES_PER_ELEMENT*e,i=this.byteOffset+this.offset,a=this.buffer.slice(i,i+n);if(this.littleEndian===coe&&r!=="uint8"&&r!=="int8"){const o=new Uint8Array(this.buffer.slice(i,i+n));o.reverse();const A=new _d[r](o.buffer);return this.offset+=n,A.reverse(),A}const s=new _d[r](a);return this.offset+=n,s}readInt16(){const e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){const e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){const e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){const e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){const e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){const e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){const e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){const e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let r="";for(let n=0;n<e;n++)r+=this.readChar();return r}readUtf8(e=1){return kB(this.readBytes(e))}decodeText(e=1,r="utf8"){return kB(this.readBytes(e),r)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let r=0;r<e.length;r++)this._data.setUint8(this.offset++,e[r]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let r=0;r<e.length;r++)this.writeUint8(e.charCodeAt(r));return this}writeUtf8(e){return this.writeBytes(loe(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function Vl(t){let e=t.length;for(;--e>=0;)t[e]=0}const foe=3,hoe=258,rN=29,doe=256,poe=doe+1+rN,nN=30,goe=512,Coe=new Array((poe+2)*2);Vl(Coe);const voe=new Array(nN*2);Vl(voe);const moe=new Array(goe);Vl(moe);const woe=new Array(hoe-foe+1);Vl(woe);const yoe=new Array(rN);Vl(yoe);const Boe=new Array(nN);Vl(Boe);const boe=(t,e,r,n)=>{let i=t&65535|0,a=t>>>16&65535|0,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do i=i+e[n++]|0,a=a+i|0;while(--s);i%=65521,a%=65521}return i|a<<16|0};var C9=boe;const xoe=()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t}return e},Loe=new Uint32Array(xoe()),Eoe=(t,e,r,n)=>{const i=Loe,a=n+r;t^=-1;for(let s=n;s<a;s++)t=t>>>8^i[(t^e[s])&255];return t^-1};var fs=Eoe,v9={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},iN={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const Soe=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Foe=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(const n in r)Soe(r,n)&&(t[n]=r[n])}}return t},Doe=t=>{let e=0;for(let n=0,i=t.length;n<i;n++)e+=t[n].length;const r=new Uint8Array(e);for(let n=0,i=0,a=t.length;n<a;n++){let s=t[n];r.set(s,i),i+=s.length}return r},aN={assign:Foe,flattenChunks:Doe};let sN=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{sN=!1}const Oc=new Uint8Array(256);for(let t=0;t<256;t++)Oc[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Oc[254]=Oc[254]=1;var koe=t=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(t);let e,r,n,i,a,s=t.length,o=0;for(i=0;i<s;i++)r=t.charCodeAt(i),(r&64512)===55296&&i+1<s&&(n=t.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),o+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(o),a=0,i=0;a<o;i++)r=t.charCodeAt(i),(r&64512)===55296&&i+1<s&&(n=t.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[a++]=r:r<2048?(e[a++]=192|r>>>6,e[a++]=128|r&63):r<65536?(e[a++]=224|r>>>12,e[a++]=128|r>>>6&63,e[a++]=128|r&63):(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63,e[a++]=128|r>>>6&63,e[a++]=128|r&63);return e};const Moe=(t,e)=>{if(e<65534&&t.subarray&&sN)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r};var Ioe=(t,e)=>{const r=e||t.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(t.subarray(0,e));let n,i;const a=new Array(r*2);for(i=0,n=0;n<r;){let s=t[n++];if(s<128){a[i++]=s;continue}let o=Oc[s];if(o>4){a[i++]=65533,n+=o-1;continue}for(s&=o===2?31:o===3?15:7;o>1&&n<r;)s=s<<6|t[n++]&63,o--;if(o>1){a[i++]=65533;continue}s<65536?a[i++]=s:(s-=65536,a[i++]=55296|s>>10&1023,a[i++]=56320|s&1023)}return Moe(a,i)},Ooe=(t,e)=>{e=e||t.length,e>t.length&&(e=t.length);let r=e-1;for(;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+Oc[t[r]]>e?r:e},m9={string2buf:koe,buf2string:Ioe,utf8border:Ooe};function Toe(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Noe=Toe;const d5=16209,Poe=16191;var Roe=function(e,r){let n,i,a,s,o,A,l,c,f,d,h,C,p,w,m,g,B,b,L,E,I,k,M,H;const F=e.state;n=e.next_in,M=e.input,i=n+(e.avail_in-5),a=e.next_out,H=e.output,s=a-(r-e.avail_out),o=a+(e.avail_out-257),A=F.dmax,l=F.wsize,c=F.whave,f=F.wnext,d=F.window,h=F.hold,C=F.bits,p=F.lencode,w=F.distcode,m=(1<<F.lenbits)-1,g=(1<<F.distbits)-1;e:do{C<15&&(h+=M[n++]<<C,C+=8,h+=M[n++]<<C,C+=8),B=p[h&m];t:for(;;){if(b=B>>>24,h>>>=b,C-=b,b=B>>>16&255,b===0)H[a++]=B&65535;else if(b&16){L=B&65535,b&=15,b&&(C<b&&(h+=M[n++]<<C,C+=8),L+=h&(1<<b)-1,h>>>=b,C-=b),C<15&&(h+=M[n++]<<C,C+=8,h+=M[n++]<<C,C+=8),B=w[h&g];r:for(;;){if(b=B>>>24,h>>>=b,C-=b,b=B>>>16&255,b&16){if(E=B&65535,b&=15,C<b&&(h+=M[n++]<<C,C+=8,C<b&&(h+=M[n++]<<C,C+=8)),E+=h&(1<<b)-1,E>A){e.msg="invalid distance too far back",F.mode=d5;break e}if(h>>>=b,C-=b,b=a-s,E>b){if(b=E-b,b>c&&F.sane){e.msg="invalid distance too far back",F.mode=d5;break e}if(I=0,k=d,f===0){if(I+=l-b,b<L){L-=b;do H[a++]=d[I++];while(--b);I=a-E,k=H}}else if(f<b){if(I+=l+f-b,b-=f,b<L){L-=b;do H[a++]=d[I++];while(--b);if(I=0,f<L){b=f,L-=b;do H[a++]=d[I++];while(--b);I=a-E,k=H}}}else if(I+=f-b,b<L){L-=b;do H[a++]=d[I++];while(--b);I=a-E,k=H}for(;L>2;)H[a++]=k[I++],H[a++]=k[I++],H[a++]=k[I++],L-=3;L&&(H[a++]=k[I++],L>1&&(H[a++]=k[I++]))}else{I=a-E;do H[a++]=H[I++],H[a++]=H[I++],H[a++]=H[I++],L-=3;while(L>2);L&&(H[a++]=H[I++],L>1&&(H[a++]=H[I++]))}}else if((b&64)===0){B=w[(B&65535)+(h&(1<<b)-1)];continue r}else{e.msg="invalid distance code",F.mode=d5;break e}break}}else if((b&64)===0){B=p[(B&65535)+(h&(1<<b)-1)];continue t}else if(b&32){F.mode=Poe;break e}else{e.msg="invalid literal/length code",F.mode=d5;break e}break}}while(n<i&&a<o);L=C>>3,n-=L,C-=L<<3,h&=(1<<C)-1,e.next_in=n,e.next_out=a,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=a<o?257+(o-a):257-(a-o),F.hold=h,F.bits=C};const H2=15,MB=852,IB=592,OB=0,Hd=1,TB=2,Uoe=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),joe=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Qoe=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),_oe=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),Hoe=(t,e,r,n,i,a,s,o)=>{const A=o.bits;let l=0,c=0,f=0,d=0,h=0,C=0,p=0,w=0,m=0,g=0,B,b,L,E,I,k=null,M;const H=new Uint16Array(H2+1),F=new Uint16Array(H2+1);let D=null,U,R,$;for(l=0;l<=H2;l++)H[l]=0;for(c=0;c<n;c++)H[e[r+c]]++;for(h=A,d=H2;d>=1&&H[d]===0;d--);if(h>d&&(h=d),d===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,o.bits=1,0;for(f=1;f<d&&H[f]===0;f++);for(h<f&&(h=f),w=1,l=1;l<=H2;l++)if(w<<=1,w-=H[l],w<0)return-1;if(w>0&&(t===OB||d!==1))return-1;for(F[1]=0,l=1;l<H2;l++)F[l+1]=F[l]+H[l];for(c=0;c<n;c++)e[r+c]!==0&&(s[F[e[r+c]]++]=c);if(t===OB?(k=D=s,M=20):t===Hd?(k=Uoe,D=joe,M=257):(k=Qoe,D=_oe,M=0),g=0,c=0,l=f,I=a,C=h,p=0,L=-1,m=1<<h,E=m-1,t===Hd&&m>MB||t===TB&&m>IB)return 1;for(;;){U=l-p,s[c]+1<M?(R=0,$=s[c]):s[c]>=M?(R=D[s[c]-M],$=k[s[c]-M]):(R=96,$=0),B=1<<l-p,b=1<<C,f=b;do b-=B,i[I+(g>>p)+b]=U<<24|R<<16|$|0;while(b!==0);for(B=1<<l-1;g&B;)B>>=1;if(B!==0?(g&=B-1,g+=B):g=0,c++,--H[l]===0){if(l===d)break;l=e[r+s[c]]}if(l>h&&(g&E)!==L){for(p===0&&(p=h),I+=f,C=l-p,w=1<<C;C+p<d&&(w-=H[C+p],!(w<=0));)C++,w<<=1;if(m+=1<<C,t===Hd&&m>MB||t===TB&&m>IB)return 1;L=g&E,i[L]=h<<24|C<<16|I-a|0}}return g!==0&&(i[I+g]=l-p<<24|64<<16|0),o.bits=h,0};var oc=Hoe;const Voe=0,oN=1,AN=2,{Z_FINISH:NB,Z_BLOCK:Woe,Z_TREES:p5,Z_OK:f2,Z_STREAM_END:Koe,Z_NEED_DICT:qoe,Z_STREAM_ERROR:x1,Z_DATA_ERROR:lN,Z_MEM_ERROR:uN,Z_BUF_ERROR:$oe,Z_DEFLATED:PB}=iN,Yh=16180,RB=16181,UB=16182,jB=16183,QB=16184,_B=16185,HB=16186,VB=16187,WB=16188,KB=16189,nh=16190,Ys=16191,Vd=16192,qB=16193,Wd=16194,$B=16195,GB=16196,zB=16197,ZB=16198,g5=16199,C5=16200,XB=16201,YB=16202,JB=16203,eb=16204,tb=16205,Kd=16206,rb=16207,nb=16208,Un=16209,cN=16210,fN=16211,Goe=852,zoe=592,Zoe=15,Xoe=Zoe,ib=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function Yoe(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const w2=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<Yh||e.mode>fN?1:0},hN=t=>{if(w2(t))return x1;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=Yh,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(Goe),e.distcode=e.distdyn=new Int32Array(zoe),e.sane=1,e.back=-1,f2},dN=t=>{if(w2(t))return x1;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,hN(t)},pN=(t,e)=>{let r;if(w2(t))return x1;const n=t.state;return e<0?(r=0,e=-e):(r=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?x1:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,dN(t))},gN=(t,e)=>{if(!t)return x1;const r=new Yoe;t.state=r,r.strm=t,r.window=null,r.mode=Yh;const n=pN(t,e);return n!==f2&&(t.state=null),n},Joe=t=>gN(t,Xoe);let ab=!0,qd,$d;const eAe=t=>{if(ab){qd=new Int32Array(512),$d=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(oc(oN,t.lens,0,288,qd,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;oc(AN,t.lens,0,32,$d,0,t.work,{bits:5}),ab=!1}t.lencode=qd,t.lenbits=9,t.distcode=$d,t.distbits=5},CN=(t,e,r,n)=>{let i;const a=t.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(e.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),a.window.set(e.subarray(r-n,r-n+i),a.wnext),n-=i,n?(a.window.set(e.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},tAe=(t,e)=>{let r,n,i,a,s,o,A,l,c,f,d,h,C,p,w=0,m,g,B,b,L,E,I,k;const M=new Uint8Array(4);let H,F;const D=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(w2(t)||!t.output||!t.input&&t.avail_in!==0)return x1;r=t.state,r.mode===Ys&&(r.mode=Vd),s=t.next_out,i=t.output,A=t.avail_out,a=t.next_in,n=t.input,o=t.avail_in,l=r.hold,c=r.bits,f=o,d=A,k=f2;e:for(;;)switch(r.mode){case Yh:if(r.wrap===0){r.mode=Vd;break}for(;c<16;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.wrap&2&&l===35615){r.wbits===0&&(r.wbits=15),r.check=0,M[0]=l&255,M[1]=l>>>8&255,r.check=fs(r.check,M,2,0),l=0,c=0,r.mode=RB;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg="incorrect header check",r.mode=Un;break}if((l&15)!==PB){t.msg="unknown compression method",r.mode=Un;break}if(l>>>=4,c-=4,I=(l&15)+8,r.wbits===0&&(r.wbits=I),I>15||I>r.wbits){t.msg="invalid window size",r.mode=Un;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=l&512?KB:Ys,l=0,c=0;break;case RB:for(;c<16;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.flags=l,(r.flags&255)!==PB){t.msg="unknown compression method",r.mode=Un;break}if(r.flags&57344){t.msg="unknown header flags set",r.mode=Un;break}r.head&&(r.head.text=l>>8&1),r.flags&512&&r.wrap&4&&(M[0]=l&255,M[1]=l>>>8&255,r.check=fs(r.check,M,2,0)),l=0,c=0,r.mode=UB;case UB:for(;c<32;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}r.head&&(r.head.time=l),r.flags&512&&r.wrap&4&&(M[0]=l&255,M[1]=l>>>8&255,M[2]=l>>>16&255,M[3]=l>>>24&255,r.check=fs(r.check,M,4,0)),l=0,c=0,r.mode=jB;case jB:for(;c<16;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}r.head&&(r.head.xflags=l&255,r.head.os=l>>8),r.flags&512&&r.wrap&4&&(M[0]=l&255,M[1]=l>>>8&255,r.check=fs(r.check,M,2,0)),l=0,c=0,r.mode=QB;case QB:if(r.flags&1024){for(;c<16;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}r.length=l,r.head&&(r.head.extra_len=l),r.flags&512&&r.wrap&4&&(M[0]=l&255,M[1]=l>>>8&255,r.check=fs(r.check,M,2,0)),l=0,c=0}else r.head&&(r.head.extra=null);r.mode=_B;case _B:if(r.flags&1024&&(h=r.length,h>o&&(h=o),h&&(r.head&&(I=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+h),I)),r.flags&512&&r.wrap&4&&(r.check=fs(r.check,n,h,a)),o-=h,a+=h,r.length-=h),r.length))break e;r.length=0,r.mode=HB;case HB:if(r.flags&2048){if(o===0)break e;h=0;do I=n[a+h++],r.head&&I&&r.length<65536&&(r.head.name+=String.fromCharCode(I));while(I&&h<o);if(r.flags&512&&r.wrap&4&&(r.check=fs(r.check,n,h,a)),o-=h,a+=h,I)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=VB;case VB:if(r.flags&4096){if(o===0)break e;h=0;do I=n[a+h++],r.head&&I&&r.length<65536&&(r.head.comment+=String.fromCharCode(I));while(I&&h<o);if(r.flags&512&&r.wrap&4&&(r.check=fs(r.check,n,h,a)),o-=h,a+=h,I)break e}else r.head&&(r.head.comment=null);r.mode=WB;case WB:if(r.flags&512){for(;c<16;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.wrap&4&&l!==(r.check&65535)){t.msg="header crc mismatch",r.mode=Un;break}l=0,c=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Ys;break;case KB:for(;c<32;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}t.adler=r.check=ib(l),l=0,c=0,r.mode=nh;case nh:if(r.havedict===0)return t.next_out=s,t.avail_out=A,t.next_in=a,t.avail_in=o,r.hold=l,r.bits=c,qoe;t.adler=r.check=1,r.mode=Ys;case Ys:if(e===Woe||e===p5)break e;case Vd:if(r.last){l>>>=c&7,c-=c&7,r.mode=Kd;break}for(;c<3;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}switch(r.last=l&1,l>>>=1,c-=1,l&3){case 0:r.mode=qB;break;case 1:if(eAe(r),r.mode=g5,e===p5){l>>>=2,c-=2;break e}break;case 2:r.mode=GB;break;case 3:t.msg="invalid block type",r.mode=Un}l>>>=2,c-=2;break;case qB:for(l>>>=c&7,c-=c&7;c<32;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if((l&65535)!==(l>>>16^65535)){t.msg="invalid stored block lengths",r.mode=Un;break}if(r.length=l&65535,l=0,c=0,r.mode=Wd,e===p5)break e;case Wd:r.mode=$B;case $B:if(h=r.length,h){if(h>o&&(h=o),h>A&&(h=A),h===0)break e;i.set(n.subarray(a,a+h),s),o-=h,a+=h,A-=h,s+=h,r.length-=h;break}r.mode=Ys;break;case GB:for(;c<14;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.nlen=(l&31)+257,l>>>=5,c-=5,r.ndist=(l&31)+1,l>>>=5,c-=5,r.ncode=(l&15)+4,l>>>=4,c-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=Un;break}r.have=0,r.mode=zB;case zB:for(;r.have<r.ncode;){for(;c<3;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}r.lens[D[r.have++]]=l&7,l>>>=3,c-=3}for(;r.have<19;)r.lens[D[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,H={bits:r.lenbits},k=oc(Voe,r.lens,0,19,r.lencode,0,r.work,H),r.lenbits=H.bits,k){t.msg="invalid code lengths set",r.mode=Un;break}r.have=0,r.mode=ZB;case ZB:for(;r.have<r.nlen+r.ndist;){for(;w=r.lencode[l&(1<<r.lenbits)-1],m=w>>>24,g=w>>>16&255,B=w&65535,!(m<=c);){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(B<16)l>>>=m,c-=m,r.lens[r.have++]=B;else{if(B===16){for(F=m+2;c<F;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(l>>>=m,c-=m,r.have===0){t.msg="invalid bit length repeat",r.mode=Un;break}I=r.lens[r.have-1],h=3+(l&3),l>>>=2,c-=2}else if(B===17){for(F=m+3;c<F;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}l>>>=m,c-=m,I=0,h=3+(l&7),l>>>=3,c-=3}else{for(F=m+7;c<F;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}l>>>=m,c-=m,I=0,h=11+(l&127),l>>>=7,c-=7}if(r.have+h>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=Un;break}for(;h--;)r.lens[r.have++]=I}}if(r.mode===Un)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=Un;break}if(r.lenbits=9,H={bits:r.lenbits},k=oc(oN,r.lens,0,r.nlen,r.lencode,0,r.work,H),r.lenbits=H.bits,k){t.msg="invalid literal/lengths set",r.mode=Un;break}if(r.distbits=6,r.distcode=r.distdyn,H={bits:r.distbits},k=oc(AN,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,H),r.distbits=H.bits,k){t.msg="invalid distances set",r.mode=Un;break}if(r.mode=g5,e===p5)break e;case g5:r.mode=C5;case C5:if(o>=6&&A>=258){t.next_out=s,t.avail_out=A,t.next_in=a,t.avail_in=o,r.hold=l,r.bits=c,Roe(t,d),s=t.next_out,i=t.output,A=t.avail_out,a=t.next_in,n=t.input,o=t.avail_in,l=r.hold,c=r.bits,r.mode===Ys&&(r.back=-1);break}for(r.back=0;w=r.lencode[l&(1<<r.lenbits)-1],m=w>>>24,g=w>>>16&255,B=w&65535,!(m<=c);){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(g&&(g&240)===0){for(b=m,L=g,E=B;w=r.lencode[E+((l&(1<<b+L)-1)>>b)],m=w>>>24,g=w>>>16&255,B=w&65535,!(b+m<=c);){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}l>>>=b,c-=b,r.back+=b}if(l>>>=m,c-=m,r.back+=m,r.length=B,g===0){r.mode=tb;break}if(g&32){r.back=-1,r.mode=Ys;break}if(g&64){t.msg="invalid literal/length code",r.mode=Un;break}r.extra=g&15,r.mode=XB;case XB:if(r.extra){for(F=r.extra;c<F;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=YB;case YB:for(;w=r.distcode[l&(1<<r.distbits)-1],m=w>>>24,g=w>>>16&255,B=w&65535,!(m<=c);){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if((g&240)===0){for(b=m,L=g,E=B;w=r.distcode[E+((l&(1<<b+L)-1)>>b)],m=w>>>24,g=w>>>16&255,B=w&65535,!(b+m<=c);){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}l>>>=b,c-=b,r.back+=b}if(l>>>=m,c-=m,r.back+=m,g&64){t.msg="invalid distance code",r.mode=Un;break}r.offset=B,r.extra=g&15,r.mode=JB;case JB:if(r.extra){for(F=r.extra;c<F;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=Un;break}r.mode=eb;case eb:if(A===0)break e;if(h=d-A,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=Un;break}h>r.wnext?(h-=r.wnext,C=r.wsize-h):C=r.wnext-h,h>r.length&&(h=r.length),p=r.window}else p=i,C=s-r.offset,h=r.length;h>A&&(h=A),A-=h,r.length-=h;do i[s++]=p[C++];while(--h);r.length===0&&(r.mode=C5);break;case tb:if(A===0)break e;i[s++]=r.length,A--,r.mode=C5;break;case Kd:if(r.wrap){for(;c<32;){if(o===0)break e;o--,l|=n[a++]<<c,c+=8}if(d-=A,t.total_out+=d,r.total+=d,r.wrap&4&&d&&(t.adler=r.check=r.flags?fs(r.check,i,d,s-d):C9(r.check,i,d,s-d)),d=A,r.wrap&4&&(r.flags?l:ib(l))!==r.check){t.msg="incorrect data check",r.mode=Un;break}l=0,c=0}r.mode=rb;case rb:if(r.wrap&&r.flags){for(;c<32;){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.wrap&4&&l!==(r.total&4294967295)){t.msg="incorrect length check",r.mode=Un;break}l=0,c=0}r.mode=nb;case nb:k=Koe;break e;case Un:k=lN;break e;case cN:return uN;case fN:default:return x1}return t.next_out=s,t.avail_out=A,t.next_in=a,t.avail_in=o,r.hold=l,r.bits=c,(r.wsize||d!==t.avail_out&&r.mode<Un&&(r.mode<Kd||e!==NB))&&CN(t,t.output,t.next_out,d-t.avail_out),f-=t.avail_in,d-=t.avail_out,t.total_in+=f,t.total_out+=d,r.total+=d,r.wrap&4&&d&&(t.adler=r.check=r.flags?fs(r.check,i,d,t.next_out-d):C9(r.check,i,d,t.next_out-d)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Ys?128:0)+(r.mode===g5||r.mode===Wd?256:0),(f===0&&d===0||e===NB)&&k===f2&&(k=$oe),k},rAe=t=>{if(w2(t))return x1;let e=t.state;return e.window&&(e.window=null),t.state=null,f2},nAe=(t,e)=>{if(w2(t))return x1;const r=t.state;return(r.wrap&2)===0?x1:(r.head=e,e.done=!1,f2)},iAe=(t,e)=>{const r=e.length;let n,i,a;return w2(t)||(n=t.state,n.wrap!==0&&n.mode!==nh)?x1:n.mode===nh&&(i=1,i=C9(i,e,r,0),i!==n.check)?lN:(a=CN(t,e,r,r),a?(n.mode=cN,uN):(n.havedict=1,f2))};var aAe=dN,sAe=pN,oAe=hN,AAe=Joe,lAe=gN,uAe=tAe,cAe=rAe,fAe=nAe,hAe=iAe,dAe="pako inflate (from Nodeca project)",io={inflateReset:aAe,inflateReset2:sAe,inflateResetKeep:oAe,inflateInit:AAe,inflateInit2:lAe,inflate:uAe,inflateEnd:cAe,inflateGetHeader:fAe,inflateSetDictionary:hAe,inflateInfo:dAe};function pAe(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var gAe=pAe;const vN=Object.prototype.toString,{Z_NO_FLUSH:CAe,Z_FINISH:vAe,Z_OK:Tc,Z_STREAM_END:Gd,Z_NEED_DICT:zd,Z_STREAM_ERROR:mAe,Z_DATA_ERROR:sb,Z_MEM_ERROR:wAe}=iN;function i0(t){this.options=aN.assign({chunkSize:1024*64,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Noe,this.strm.avail_out=0;let r=io.inflateInit2(this.strm,e.windowBits);if(r!==Tc)throw new Error(v9[r]);if(this.header=new gAe,io.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=m9.string2buf(e.dictionary):vN.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=io.inflateSetDictionary(this.strm,e.dictionary),r!==Tc)))throw new Error(v9[r])}i0.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let a,s,o;if(this.ended)return!1;for(e===~~e?s=e:s=e===!0?vAe:CAe,vN.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),a=io.inflate(r,s),a===zd&&i&&(a=io.inflateSetDictionary(r,i),a===Tc?a=io.inflate(r,s):a===sb&&(a=zd));r.avail_in>0&&a===Gd&&r.state.wrap>0&&t[r.next_in]!==0;)io.inflateReset(r),a=io.inflate(r,s);switch(a){case mAe:case sb:case zd:case wAe:return this.onEnd(a),this.ended=!0,!1}if(o=r.avail_out,r.next_out&&(r.avail_out===0||a===Gd))if(this.options.to==="string"){let A=m9.utf8border(r.output,r.next_out),l=r.next_out-A,c=m9.buf2string(r.output,A);r.next_out=l,r.avail_out=n-l,l&&r.output.set(r.output.subarray(A,A+l),0),this.onData(c)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(!(a===Tc&&o===0)){if(a===Gd)return a=io.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(r.avail_in===0)break}}return!0};i0.prototype.onData=function(t){this.chunks.push(t)};i0.prototype.onEnd=function(t){t===Tc&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=aN.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function yAe(t,e){const r=new i0(e);if(r.push(t),r.err)throw r.msg||v9[r.err];return r.result}var BAe=i0,bAe=yAe,xAe={Inflate:BAe,inflate:bAe};const{Inflate:LAe,inflate:EAe}=xAe;var ob=LAe,SAe=EAe;const mN=[];for(let t=0;t<256;t++){let e=t;for(let r=0;r<8;r++)e&1?e=3988292384^e>>>1:e=e>>>1;mN[t]=e}const Ab=4294967295;function FAe(t,e,r){let n=t;for(let i=0;i<r;i++)n=mN[(n^e[i])&255]^n>>>8;return n}function DAe(t,e){return(FAe(Ab,t,e)^Ab)>>>0}function lb(t,e,r){const n=t.readUint32(),i=DAe(new Uint8Array(t.buffer,t.byteOffset+t.offset-e-4,e),e);if(i!==n)throw new Error(`CRC mismatch for chunk ${r}. Expected ${n}, found ${i}`)}function wN(t,e,r){for(let n=0;n<r;n++)e[n]=t[n]}function yN(t,e,r,n){let i=0;for(;i<n;i++)e[i]=t[i];for(;i<r;i++)e[i]=t[i]+e[i-n]&255}function BN(t,e,r,n){let i=0;if(r.length===0)for(;i<n;i++)e[i]=t[i];else for(;i<n;i++)e[i]=t[i]+r[i]&255}function bN(t,e,r,n,i){let a=0;if(r.length===0){for(;a<i;a++)e[a]=t[a];for(;a<n;a++)e[a]=t[a]+(e[a-i]>>1)&255}else{for(;a<i;a++)e[a]=t[a]+(r[a]>>1)&255;for(;a<n;a++)e[a]=t[a]+(e[a-i]+r[a]>>1)&255}}function xN(t,e,r,n,i){let a=0;if(r.length===0){for(;a<i;a++)e[a]=t[a];for(;a<n;a++)e[a]=t[a]+e[a-i]&255}else{for(;a<i;a++)e[a]=t[a]+r[a]&255;for(;a<n;a++)e[a]=t[a]+kAe(e[a-i],r[a],r[a-i])&255}}function kAe(t,e,r){const n=t+e-r,i=Math.abs(n-t),a=Math.abs(n-e),s=Math.abs(n-r);return i<=a&&i<=s?t:a<=s?e:r}function MAe(t,e,r,n,i,a){switch(t){case 0:wN(e,r,i);break;case 1:yN(e,r,i,a);break;case 2:BN(e,r,n,i);break;case 3:bN(e,r,n,i,a);break;case 4:xN(e,r,n,i,a);break;default:throw new Error(`Unsupported filter: ${t}`)}}const IAe=new Uint16Array([255]),OAe=new Uint8Array(IAe.buffer),TAe=OAe[0]===255;function NAe(t){const{data:e,width:r,height:n,channels:i,depth:a}=t,s=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],o=Math.ceil(a/8)*i,A=new Uint8Array(n*r*o);let l=0;for(let c=0;c<7;c++){const f=s[c],d=Math.ceil((r-f.x)/f.xStep),h=Math.ceil((n-f.y)/f.yStep);if(d<=0||h<=0)continue;const C=d*o,p=new Uint8Array(C);for(let w=0;w<h;w++){const m=e[l++],g=e.subarray(l,l+C);l+=C;const B=new Uint8Array(C);MAe(m,g,B,p,C,o),p.set(B);for(let b=0;b<d;b++){const L=f.x+b*f.xStep,E=f.y+w*f.yStep;if(!(L>=r||E>=n))for(let I=0;I<o;I++)A[(E*r+L)*o+I]=B[b*o+I]}}}if(a===16){const c=new Uint16Array(A.buffer);if(TAe)for(let f=0;f<c.length;f++)c[f]=PAe(c[f]);return c}else return A}function PAe(t){return(t&255)<<8|t>>8&255}const RAe=new Uint16Array([255]),UAe=new Uint8Array(RAe.buffer),jAe=UAe[0]===255,QAe=new Uint8Array(0);function ub(t){const{data:e,width:r,height:n,channels:i,depth:a}=t,s=Math.ceil(a/8)*i,o=Math.ceil(a/8*i*r),A=new Uint8Array(n*o);let l=QAe,c=0,f,d;for(let h=0;h<n;h++){switch(f=e.subarray(c+1,c+1+o),d=A.subarray(h*o,(h+1)*o),e[c]){case 0:wN(f,d,o);break;case 1:yN(f,d,o,s);break;case 2:BN(f,d,l,o);break;case 3:bN(f,d,l,o,s);break;case 4:xN(f,d,l,o,s);break;default:throw new Error(`Unsupported filter: ${e[c]}`)}l=d,c+=o+1}if(a===16){const h=new Uint16Array(A.buffer);if(jAe)for(let C=0;C<h.length;C++)h[C]=_Ae(h[C]);return h}else return A}function _Ae(t){return(t&255)<<8|t>>8&255}const uf=Uint8Array.of(137,80,78,71,13,10,26,10);function cb(t){if(!HAe(t.readBytes(uf.length)))throw new Error("wrong PNG signature")}function HAe(t){if(t.length<uf.length)return!1;for(let e=0;e<uf.length;e++)if(t[e]!==uf[e])return!1;return!0}const VAe="tEXt",WAe=0,LN=new TextDecoder("latin1");function KAe(t){if($Ae(t),t.length===0||t.length>79)throw new Error("keyword length must be between 1 and 79")}const qAe=/^[\u0000-\u00FF]*$/;function $Ae(t){if(!qAe.test(t))throw new Error("invalid latin1 text")}function GAe(t,e,r){const n=EN(e);t[n]=zAe(e,r-n.length-1)}function EN(t){for(t.mark();t.readByte()!==WAe;);const e=t.offset;t.reset();const r=LN.decode(t.readBytes(e-t.offset-1));return t.skip(1),KAe(r),r}function zAe(t,e){return LN.decode(t.readBytes(e))}const r1={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},Zd={UNKNOWN:-1,DEFLATE:0},fb={UNKNOWN:-1,ADAPTIVE:0},Xd={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},v5={NONE:0,BACKGROUND:1,PREVIOUS:2},Yd={SOURCE:0,OVER:1};class ZAe extends Ng{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(e,r={}){super(e);const{checkCrc:n=!1}=r;this._checkCrc=n,this._inflator=new ob,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=Zd.UNKNOWN,this._filterMethod=fb.UNKNOWN,this._interlaceMethod=Xd.UNKNOWN,this._colorType=r1.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(cb(this);!this._end;){const e=this.readUint32(),r=this.readChars(4);this.decodeChunk(e,r)}return this.decodeImage(),this._png}decodeApng(){for(cb(this);!this._end;){const e=this.readUint32(),r=this.readChars(4);this.decodeApngChunk(e,r)}return this.decodeApngImage(),this._apng}decodeChunk(e,r){const n=this.offset;switch(r){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(e);break;case"IDAT":this.decodeIDAT(e);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(e);break;case"iCCP":this.decodeiCCP(e);break;case VAe:GAe(this._png.text,this,e);break;case"pHYs":this.decodepHYs();break;default:this.skip(e);break}if(this.offset-n!==e)throw new Error(`Length mismatch while decoding chunk ${r}`);this._checkCrc?lb(this,e+4,r):this.skip(4)}decodeApngChunk(e,r){const n=this.offset;switch(r!=="fdAT"&&r!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),r){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(e);break;default:this.decodeChunk(e,r),this.offset=n+e;break}if(this.offset-n!==e)throw new Error(`Length mismatch while decoding chunk ${r}`);this._checkCrc?lb(this,e+4,r):this.skip(4)}decodeIHDR(){const e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=XAe(this.readUint8());const r=this.readUint8();this._colorType=r;let n;switch(r){case r1.GREYSCALE:n=1;break;case r1.TRUECOLOUR:n=3;break;case r1.INDEXED_COLOUR:n=1;break;case r1.GREYSCALE_ALPHA:n=2;break;case r1.TRUECOLOUR_ALPHA:n=4;break;case r1.UNKNOWN:default:throw new Error(`Unknown color type: ${r}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==Zd.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(e)}decodePLTE(e){if(e%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);const r=e/3;this._hasPalette=!0;const n=[];this._palette=n;for(let i=0;i<r;i++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;const r=e,n=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,n,r)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let r=e,n=this.offset+this.byteOffset;if(n+=4,r-=4,this._inflator.push(new Uint8Array(this.buffer,n,r)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodetRNS(e){switch(this._colorType){case r1.GREYSCALE:case r1.TRUECOLOUR:{if(e%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let r=0;r<e/2;r++)this._transparency[r]=this.readUint16();break}case r1.INDEXED_COLOUR:{if(e>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let r=0;for(;r<e;r++){const n=this.readByte();this._palette[r].push(n)}for(;r<this._palette.length;r++)this._palette[r].push(255);break}case r1.UNKNOWN:case r1.GREYSCALE_ALPHA:case r1.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){const r=EN(this),n=this.readUint8();if(n!==Zd.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${n}`);const i=this.readBytes(e-r.length-2);this._png.iccEmbeddedProfile={name:r,profile:SAe(i)}}decodepHYs(){const e=this.readUint32(),r=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:r,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){const r={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=ub({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)r.data=n.data;else{const i=this._apng.frames.at(e-1);this.disposeFrame(n,i,r),this.addFrameDataToCanvas(r,n)}this._apng.frames.push(r)}}return this._apng}disposeFrame(e,r,n){switch(e.disposeOp){case v5.NONE:break;case v5.BACKGROUND:for(let i=0;i<this._png.height;i++)for(let a=0;a<this._png.width;a++){const s=(i*e.width+a)*this._png.channels;for(let o=0;o<this._png.channels;o++)n.data[s+o]=0}break;case v5.PREVIOUS:n.data.set(r.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(e,r){const n=1<<this._png.depth,i=(a,s)=>{const o=((a+r.yOffset)*this._png.width+r.xOffset+s)*this._png.channels,A=(a*r.width+s)*this._png.channels;return{index:o,frameIndex:A}};switch(r.blendOp){case Yd.SOURCE:for(let a=0;a<r.height;a++)for(let s=0;s<r.width;s++){const{index:o,frameIndex:A}=i(a,s);for(let l=0;l<this._png.channels;l++)e.data[o+l]=r.data[A+l]}break;case Yd.OVER:for(let a=0;a<r.height;a++)for(let s=0;s<r.width;s++){const{index:o,frameIndex:A}=i(a,s);for(let l=0;l<this._png.channels;l++){const c=r.data[A+this._png.channels-1]/n,f=l%(this._png.channels-1)===0?1:r.data[A+l],d=Math.floor(c*f+(1-c)*e.data[o+l]);e.data[o+l]+=d}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);const e=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==fb.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===Xd.NO_INTERLACE)this._png.data=ub({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===Xd.ADAM7)this._png.data=NAe({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const e=this._inflator.result,r=this._frames.at(-1);r?r.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:v5.NONE,blendOp:Yd.SOURCE,data:e}),this._inflator=new ob,this._writingDataChunks=!1}}function XAe(t){if(t!==1&&t!==2&&t!==4&&t!==8&&t!==16)throw new Error(`invalid bit depth: ${t}`);return t}var hb;(function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.METRE=1]="METRE"})(hb||(hb={}));function YAe(t,e){return new ZAe(t,e).decode()}var hr=(function(){return typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this})();function Jd(){hr.console&&typeof hr.console.log=="function"&&hr.console.log.apply(hr.console,arguments)}var gn={log:Jd,warn:function(t){hr.console&&(typeof hr.console.warn=="function"?hr.console.warn.apply(hr.console,arguments):Jd.call(null,arguments))},error:function(t){hr.console&&(typeof hr.console.error=="function"?hr.console.error.apply(hr.console,arguments):Jd(t))}};function e7(t,e,r){var n=new XMLHttpRequest;n.open("GET",t),n.responseType="blob",n.onload=function(){RA(n.response,e,r)},n.onerror=function(){gn.error("could not download file")},n.send()}function db(t){var e=new XMLHttpRequest;e.open("HEAD",t,!1);try{e.send()}catch{}return e.status>=200&&e.status<=299}function m5(t){try{t.dispatchEvent(new MouseEvent("click"))}catch{var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}var RA=hr.saveAs||((typeof window>"u"?"undefined":zr(window))!=="object"||window!==hr?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(t,e,r){var n=hr.URL||hr.webkitURL,i=document.createElement("a");e=e||t.name||"download",i.download=e,i.rel="noopener",typeof t=="string"?(i.href=t,i.origin!==location.origin?db(i.href)?e7(t,e,r):m5(i,i.target="_blank"):m5(i)):(i.href=n.createObjectURL(t),setTimeout(function(){n.revokeObjectURL(i.href)},4e4),setTimeout(function(){m5(i)},0))}:"msSaveOrOpenBlob"in navigator?function(t,e,r){if(e=e||t.name||"download",typeof t=="string")if(db(t))e7(t,e,r);else{var n=document.createElement("a");n.href=t,n.target="_blank",setTimeout(function(){m5(n)})}else navigator.msSaveOrOpenBlob((function(i,a){return a===void 0?a={autoBom:!1}:zr(a)!=="object"&&(gn.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(i.type)?new Blob(["\uFEFF",i],{type:i.type}):i})(t,r),e)}:function(t,e,r,n){if((n=n||open("","_blank"))&&(n.document.title=n.document.body.innerText="downloading..."),typeof t=="string")return e7(t,e,r);var i=t.type==="application/octet-stream",a=/constructor/i.test(hr.HTMLElement)||hr.safari,s=/CriOS\/[\d]+/.test(navigator.userAgent);if((s||i&&a)&&(typeof FileReader>"u"?"undefined":zr(FileReader))==="object"){var o=new FileReader;o.onloadend=function(){var c=o.result;c=s?c:c.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=c:location=c,n=null},o.readAsDataURL(t)}else{var A=hr.URL||hr.webkitURL,l=A.createObjectURL(t);n?n.location=l:location.href=l,n=null,setTimeout(function(){A.revokeObjectURL(l)},4e4)}});function SN(t){var e;t=t||"",this.ok=!1,t.charAt(0)=="#"&&(t=t.substr(1,6)),t={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"}[t=(t=t.replace(/ /g,"")).toLowerCase()]||t;for(var r=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(o){return[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(o){return[parseInt(o[1],16),parseInt(o[2],16),parseInt(o[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(o){return[parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16),parseInt(o[3]+o[3],16)]}}],n=0;n<r.length;n++){var i=r[n].re,a=r[n].process,s=i.exec(t);s&&(e=a(s),this.r=e[0],this.g=e[1],this.b=e[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var o=this.r.toString(16),A=this.g.toString(16),l=this.b.toString(16);return o.length==1&&(o="0"+o),A.length==1&&(A="0"+A),l.length==1&&(l="0"+l),"#"+o+A+l}}var cf=hr.atob.bind(hr),pb=hr.btoa.bind(hr);function t7(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];r=ta(r,n,i,a,e[0],7,-680876936),a=ta(a,r,n,i,e[1],12,-389564586),i=ta(i,a,r,n,e[2],17,606105819),n=ta(n,i,a,r,e[3],22,-1044525330),r=ta(r,n,i,a,e[4],7,-176418897),a=ta(a,r,n,i,e[5],12,1200080426),i=ta(i,a,r,n,e[6],17,-1473231341),n=ta(n,i,a,r,e[7],22,-45705983),r=ta(r,n,i,a,e[8],7,1770035416),a=ta(a,r,n,i,e[9],12,-1958414417),i=ta(i,a,r,n,e[10],17,-42063),n=ta(n,i,a,r,e[11],22,-1990404162),r=ta(r,n,i,a,e[12],7,1804603682),a=ta(a,r,n,i,e[13],12,-40341101),i=ta(i,a,r,n,e[14],17,-1502002290),r=ra(r,n=ta(n,i,a,r,e[15],22,1236535329),i,a,e[1],5,-165796510),a=ra(a,r,n,i,e[6],9,-1069501632),i=ra(i,a,r,n,e[11],14,643717713),n=ra(n,i,a,r,e[0],20,-373897302),r=ra(r,n,i,a,e[5],5,-701558691),a=ra(a,r,n,i,e[10],9,38016083),i=ra(i,a,r,n,e[15],14,-660478335),n=ra(n,i,a,r,e[4],20,-405537848),r=ra(r,n,i,a,e[9],5,568446438),a=ra(a,r,n,i,e[14],9,-1019803690),i=ra(i,a,r,n,e[3],14,-187363961),n=ra(n,i,a,r,e[8],20,1163531501),r=ra(r,n,i,a,e[13],5,-1444681467),a=ra(a,r,n,i,e[2],9,-51403784),i=ra(i,a,r,n,e[7],14,1735328473),r=na(r,n=ra(n,i,a,r,e[12],20,-1926607734),i,a,e[5],4,-378558),a=na(a,r,n,i,e[8],11,-2022574463),i=na(i,a,r,n,e[11],16,1839030562),n=na(n,i,a,r,e[14],23,-35309556),r=na(r,n,i,a,e[1],4,-1530992060),a=na(a,r,n,i,e[4],11,1272893353),i=na(i,a,r,n,e[7],16,-155497632),n=na(n,i,a,r,e[10],23,-1094730640),r=na(r,n,i,a,e[13],4,681279174),a=na(a,r,n,i,e[0],11,-358537222),i=na(i,a,r,n,e[3],16,-722521979),n=na(n,i,a,r,e[6],23,76029189),r=na(r,n,i,a,e[9],4,-640364487),a=na(a,r,n,i,e[12],11,-421815835),i=na(i,a,r,n,e[15],16,530742520),r=ia(r,n=na(n,i,a,r,e[2],23,-995338651),i,a,e[0],6,-198630844),a=ia(a,r,n,i,e[7],10,1126891415),i=ia(i,a,r,n,e[14],15,-1416354905),n=ia(n,i,a,r,e[5],21,-57434055),r=ia(r,n,i,a,e[12],6,1700485571),a=ia(a,r,n,i,e[3],10,-1894986606),i=ia(i,a,r,n,e[10],15,-1051523),n=ia(n,i,a,r,e[1],21,-2054922799),r=ia(r,n,i,a,e[8],6,1873313359),a=ia(a,r,n,i,e[15],10,-30611744),i=ia(i,a,r,n,e[6],15,-1560198380),n=ia(n,i,a,r,e[13],21,1309151649),r=ia(r,n,i,a,e[4],6,-145523070),a=ia(a,r,n,i,e[11],10,-1120210379),i=ia(i,a,r,n,e[2],15,718787259),n=ia(n,i,a,r,e[9],21,-343485551),t[0]=Zo(r,t[0]),t[1]=Zo(n,t[1]),t[2]=Zo(i,t[2]),t[3]=Zo(a,t[3])}function Jh(t,e,r,n,i,a){return e=Zo(Zo(e,t),Zo(n,a)),Zo(e<<i|e>>>32-i,r)}function ta(t,e,r,n,i,a,s){return Jh(e&r|~e&n,t,e,i,a,s)}function ra(t,e,r,n,i,a,s){return Jh(e&n|r&~n,t,e,i,a,s)}function na(t,e,r,n,i,a,s){return Jh(e^r^n,t,e,i,a,s)}function ia(t,e,r,n,i,a,s){return Jh(r^(e|~n),t,e,i,a,s)}function FN(t){var e,r=t.length,n=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=t.length;e+=64)t7(n,JAe(t.substring(e-64,e)));t=t.substring(e-64);var i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<t.length;e++)i[e>>2]|=t.charCodeAt(e)<<(e%4<<3);if(i[e>>2]|=128<<(e%4<<3),e>55)for(t7(n,i),e=0;e<16;e++)i[e]=0;return i[14]=8*r,t7(n,i),n}function JAe(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}var gb="0123456789abcdef".split("");function e2e(t){for(var e="",r=0;r<4;r++)e+=gb[t>>8*r+4&15]+gb[t>>8*r&15];return e}function t2e(t){return String.fromCharCode(255&t,(65280&t)>>8,(16711680&t)>>16,(4278190080&t)>>24)}function w9(t){return FN(t).map(t2e).join("")}var r2e=(function(t){for(var e=0;e<t.length;e++)t[e]=e2e(t[e]);return t.join("")})(FN("hello"))!="5d41402abc4b2a76b9719d911017c592";function Zo(t,e){if(r2e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}return t+e&4294967295}function y9(t,e){var r,n,i,a;if(t!==r){for(var s=(i=t,a=1+(256/t.length|0),new Array(a+1).join(i)),o=[],A=0;A<256;A++)o[A]=A;var l=0;for(A=0;A<256;A++){var c=o[A];l=(l+c+s.charCodeAt(A))%256,o[A]=o[l],o[l]=c}r=t,n=o}else o=n;var f=e.length,d=0,h=0,C="";for(A=0;A<f;A++)h=(h+(c=o[d=(d+1)%256]))%256,o[d]=o[h],o[h]=c,s=o[(o[d]+o[h])%256],C+=String.fromCharCode(e.charCodeAt(A)^s);return C}var Cb={print:4,modify:8,copy:16,"annot-forms":32};function Y2(t,e,r,n){this.v=1,this.r=2;var i=192;t.forEach(function(o){if(Cb.perm!==void 0)throw new Error("Invalid permission: "+o);i+=Cb[o]}),this.padding="(¿N^NuŠAd\0NVÿú\b..\0¶Ðh>€/\f©þdSiz";var a=(e+this.padding).substr(0,32),s=(r+this.padding).substr(0,32);this.O=this.processOwnerPassword(a,s),this.P=-(1+(255^i)),this.encryptionKey=w9(a+this.O+this.lsbFirstWord(this.P)+this.hexToBytes(n)).substr(0,5),this.U=y9(this.encryptionKey,this.padding)}function J2(t){if(/[^\u0000-\u00ff]/.test(t))throw new Error("Invalid PDF Name Object: "+t+", Only accept ASCII characters.");for(var e="",r=t.length,n=0;n<r;n++){var i=t.charCodeAt(n);e+=i<33||i===35||i===37||i===40||i===41||i===47||i===60||i===62||i===91||i===93||i===123||i===125||i>126?"#"+("0"+i.toString(16)).slice(-2):t[n]}return e}function vb(t){if(zr(t)!=="object")throw new Error("Invalid Context passed to initialize PubSub (jsPDF-module)");var e={};this.subscribe=function(r,n,i){if(i=i||!1,typeof r!="string"||typeof n!="function"||typeof i!="boolean")throw new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)");e.hasOwnProperty(r)||(e[r]={});var a=Math.random().toString(35);return e[r][a]=[n,!!i],a},this.unsubscribe=function(r){for(var n in e)if(e[n][r])return delete e[n][r],Object.keys(e[n]).length===0&&delete e[n],!0;return!1},this.publish=function(r){if(e.hasOwnProperty(r)){var n=Array.prototype.slice.call(arguments,1),i=[];for(var a in e[r]){var s=e[r][a];try{s[0].apply(t,n)}catch(o){hr.console&&gn.error("jsPDF PubSub Error",o.message,o)}s[1]&&i.push(a)}i.length&&i.forEach(this.unsubscribe)}},this.getTopics=function(){return e}}function Nc(t){if(!(this instanceof Nc))return new Nc(t);var e="opacity,stroke-opacity".split(",");for(var r in t)t.hasOwnProperty(r)&&e.indexOf(r)>=0&&(this[r]=t[r]);this.id="",this.objectNumber=-1}function DN(t,e){this.gState=t,this.matrix=e,this.id="",this.objectNumber=-1}function $o(t,e,r,n,i){if(!(this instanceof $o))return new $o(t,e,r,n,i);this.type=t==="axial"?2:3,this.coords=e,this.colors=r,DN.call(this,n,i)}function WA(t,e,r,n,i){if(!(this instanceof WA))return new WA(t,e,r,n,i);this.boundingBox=t,this.xStep=e,this.yStep=r,this.stream="",this.cloneIndex=0,DN.call(this,n,i)}function Zt(t){var e,r=typeof arguments[0]=="string"?arguments[0]:"p",n=arguments[1],i=arguments[2],a=arguments[3],s=[],o=1,A=16,l="S",c=null;zr(t=t||{})==="object"&&(r=t.orientation,n=t.unit||n,i=t.format||i,a=t.compress||t.compressPdf||a,(c=t.encryption||null)!==null&&(c.userPassword=c.userPassword||"",c.ownerPassword=c.ownerPassword||"",c.userPermissions=c.userPermissions||[]),o=typeof t.userUnit=="number"?Math.abs(t.userUnit):1,t.precision!==void 0&&(e=t.precision),t.floatPrecision!==void 0&&(A=t.floatPrecision),l=t.defaultPathOperation||"S"),s=t.filters||(a===!0?["FlateEncode"]:s),n=n||"mm",r=(""+(r||"P")).toLowerCase();var f=t.putOnlyUsedFonts||!1,d={},h={internal:{},__private__:{}};h.__private__.PubSub=vb;var C="1.3",p=h.__private__.getPdfVersion=function(){return C};h.__private__.setPdfVersion=function(x){C=x};var w={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};h.__private__.getPageFormats=function(){return w};var m=h.__private__.getPageFormat=function(x){return w[x]};i=i||"a4";var g="compat",B="advanced",b=g;function L(){this.saveGraphicsState(),Y(new At(Ze,0,0,-Ze,0,ha()*Ze).toString()+" cm"),this.setFontSize(this.getFontSize()/Ze),l="n",b=B}function E(){this.restoreGraphicsState(),l="S",b=g}var I=h.__private__.combineFontStyleAndFontWeight=function(x,W){if(x=="bold"&&W=="normal"||x=="bold"&&W==400||x=="normal"&&W=="italic"||x=="bold"&&W=="italic")throw new Error("Invalid Combination of fontweight and fontstyle");return W&&(x=W==400||W==="normal"?x==="italic"?"italic":"normal":W!=700&&W!=="bold"||x!=="normal"?(W==700?"bold":W)+""+x:"bold"),x};h.advancedAPI=function(x){var W=b===g;return W&&L.call(this),typeof x!="function"||(x(this),W&&E.call(this)),this},h.compatAPI=function(x){var W=b===B;return W&&E.call(this),typeof x!="function"||(x(this),W&&L.call(this)),this},h.isAdvancedAPI=function(){return b===B};var k,M=function(x){if(b!==B)throw new Error(x+" is only available in 'advanced' API mode. You need to call advancedAPI() first.")},H=h.roundToPrecision=h.__private__.roundToPrecision=function(x,W){var Ae=e||W;if(isNaN(x)||isNaN(Ae))throw new Error("Invalid argument passed to jsPDF.roundToPrecision");return x.toFixed(Ae).replace(/0+$/,"")};k=h.hpf=h.__private__.hpf=typeof A=="number"?function(x){if(isNaN(x))throw new Error("Invalid argument passed to jsPDF.hpf");return H(x,A)}:A==="smart"?function(x){if(isNaN(x))throw new Error("Invalid argument passed to jsPDF.hpf");return H(x,x>-1&&x<1?16:5)}:function(x){if(isNaN(x))throw new Error("Invalid argument passed to jsPDF.hpf");return H(x,16)};var F=h.f2=h.__private__.f2=function(x){if(isNaN(x))throw new Error("Invalid argument passed to jsPDF.f2");return H(x,2)},D=h.__private__.f3=function(x){if(isNaN(x))throw new Error("Invalid argument passed to jsPDF.f3");return H(x,3)},U=h.scale=h.__private__.scale=function(x){if(isNaN(x))throw new Error("Invalid argument passed to jsPDF.scale");return b===g?x*Ze:b===B?x:void 0},R=function(x){return U((function(W){return b===g?ha()-W:b===B?W:void 0})(x))};h.__private__.setPrecision=h.setPrecision=function(x){typeof parseInt(x,10)=="number"&&(e=parseInt(x,10))};var $,re="00000000000000000000000000000000",Z=h.__private__.getFileId=function(){return re},ee=h.__private__.setFileId=function(x){return re=x!==void 0&&/^[a-fA-F0-9]{32}$/.test(x)?x.toUpperCase():re.split("").map(function(){return"ABCDEF0123456789".charAt(Math.floor(16*Math.random()))}).join(""),c!==null&&(Mn=new Y2(c.userPermissions,c.userPassword,c.ownerPassword,re)),re};h.setFileId=function(x){return ee(x),this},h.getFileId=function(){return Z()};var K=h.__private__.convertDateToPDFDate=function(x){var W=x.getTimezoneOffset(),Ae=W<0?"+":"-",Ce=Math.floor(Math.abs(W/60)),Ie=Math.abs(W%60),Je=[Ae,z(Ce),"'",z(Ie),"'"].join("");return["D:",x.getFullYear(),z(x.getMonth()+1),z(x.getDate()),z(x.getHours()),z(x.getMinutes()),z(x.getSeconds()),Je].join("")},fe=h.__private__.convertPDFDateToDate=function(x){var W=parseInt(x.substr(2,4),10),Ae=parseInt(x.substr(6,2),10)-1,Ce=parseInt(x.substr(8,2),10),Ie=parseInt(x.substr(10,2),10),Je=parseInt(x.substr(12,2),10),ot=parseInt(x.substr(14,2),10);return new Date(W,Ae,Ce,Ie,Je,ot,0)},te=h.__private__.setCreationDate=function(x){var W;if(x===void 0&&(x=new Date),x instanceof Date)W=K(x);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(x))throw new Error("Invalid argument passed to jsPDF.setCreationDate");W=x}return $=W},O=h.__private__.getCreationDate=function(x){var W=$;return x==="jsDate"&&(W=fe($)),W};h.setCreationDate=function(x){return te(x),this},h.getCreationDate=function(x){return O(x)};var Q,z=h.__private__.padd2=function(x){return("0"+parseInt(x)).slice(-2)},ne=h.__private__.padd2Hex=function(x){return("00"+(x=x.toString())).substr(x.length)},he=0,le=[],Be=[],V=0,oe=[],de=[],ve=!1,Re=Be;h.__private__.setCustomOutputDestination=function(x){ve=!0,Re=x};var Pe=function(x){ve||(Re=x)};h.__private__.resetCustomOutputDestination=function(){ve=!1,Re=Be};var Y=h.__private__.out=function(x){return x=x.toString(),V+=x.length+1,Re.push(x),Re},He=h.__private__.write=function(x){return Y(arguments.length===1?x.toString():Array.prototype.join.call(arguments," "))},tt=h.__private__.getArrayBuffer=function(x){for(var W=x.length,Ae=new ArrayBuffer(W),Ce=new Uint8Array(Ae);W--;)Ce[W]=x.charCodeAt(W);return Ae},Oe=[["Helvetica","helvetica","normal","WinAnsiEncoding"],["Helvetica-Bold","helvetica","bold","WinAnsiEncoding"],["Helvetica-Oblique","helvetica","italic","WinAnsiEncoding"],["Helvetica-BoldOblique","helvetica","bolditalic","WinAnsiEncoding"],["Courier","courier","normal","WinAnsiEncoding"],["Courier-Bold","courier","bold","WinAnsiEncoding"],["Courier-Oblique","courier","italic","WinAnsiEncoding"],["Courier-BoldOblique","courier","bolditalic","WinAnsiEncoding"],["Times-Roman","times","normal","WinAnsiEncoding"],["Times-Bold","times","bold","WinAnsiEncoding"],["Times-Italic","times","italic","WinAnsiEncoding"],["Times-BoldItalic","times","bolditalic","WinAnsiEncoding"],["ZapfDingbats","zapfdingbats","normal",null],["Symbol","symbol","normal",null]];h.__private__.getStandardFonts=function(){return Oe};var Me=t.fontSize||16;h.__private__.setFontSize=h.setFontSize=function(x){return Me=b===B?x/Ze:x,this};var Qe,Xe=h.__private__.getFontSize=h.getFontSize=function(){return b===g?Me:Me*Ze},at=t.R2L||!1;h.__private__.setR2L=h.setR2L=function(x){return at=x,this},h.__private__.getR2L=h.getR2L=function(){return at};var pt,pe=h.__private__.setZoomMode=function(x){if(/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(x))Qe=x;else if(isNaN(x)){if([void 0,null,"fullwidth","fullheight","fullpage","original"].indexOf(x)===-1)throw new Error('zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "'+x+'" is not recognized.');Qe=x}else Qe=parseInt(x,10)};h.__private__.getZoomMode=function(){return Qe};var Ke,ie=h.__private__.setPageMode=function(x){if([void 0,null,"UseNone","UseOutlines","UseThumbs","FullScreen"].indexOf(x)==-1)throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "'+x+'" is not recognized.');pt=x};h.__private__.getPageMode=function(){return pt};var ge=h.__private__.setLayoutMode=function(x){if([void 0,null,"continuous","single","twoleft","tworight","two"].indexOf(x)==-1)throw new Error('Layout mode must be one of continuous, single, twoleft, tworight. "'+x+'" is not recognized.');Ke=x};h.__private__.getLayoutMode=function(){return Ke},h.__private__.setDisplayMode=h.setDisplayMode=function(x,W,Ae){return pe(x),ge(W),ie(Ae),this};var me={title:"",subject:"",author:"",keywords:"",creator:""};h.__private__.getDocumentProperty=function(x){if(Object.keys(me).indexOf(x)===-1)throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");return me[x]},h.__private__.getDocumentProperties=function(){return me},h.__private__.setDocumentProperties=h.setProperties=h.setDocumentProperties=function(x){for(var W in me)me.hasOwnProperty(W)&&x[W]&&(me[W]=x[W]);return this},h.__private__.setDocumentProperty=function(x,W){if(Object.keys(me).indexOf(x)===-1)throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");return me[x]=W};var Se,Ze,Le,be,ze,st={},vt={},Rt=[],yt={},Tt={},bt={},mt={},Nt=null,ct=0,Ct=[],Vt=new vb(h),_n=t.hotfixes||[],ar={},Wt={},Ur=[],At=function x(W,Ae,Ce,Ie,Je,ot){if(!(this instanceof x))return new x(W,Ae,Ce,Ie,Je,ot);isNaN(W)&&(W=1),isNaN(Ae)&&(Ae=0),isNaN(Ce)&&(Ce=0),isNaN(Ie)&&(Ie=1),isNaN(Je)&&(Je=0),isNaN(ot)&&(ot=0),this._matrix=[W,Ae,Ce,Ie,Je,ot]};Object.defineProperty(At.prototype,"sx",{get:function(){return this._matrix[0]},set:function(x){this._matrix[0]=x}}),Object.defineProperty(At.prototype,"shy",{get:function(){return this._matrix[1]},set:function(x){this._matrix[1]=x}}),Object.defineProperty(At.prototype,"shx",{get:function(){return this._matrix[2]},set:function(x){this._matrix[2]=x}}),Object.defineProperty(At.prototype,"sy",{get:function(){return this._matrix[3]},set:function(x){this._matrix[3]=x}}),Object.defineProperty(At.prototype,"tx",{get:function(){return this._matrix[4]},set:function(x){this._matrix[4]=x}}),Object.defineProperty(At.prototype,"ty",{get:function(){return this._matrix[5]},set:function(x){this._matrix[5]=x}}),Object.defineProperty(At.prototype,"a",{get:function(){return this._matrix[0]},set:function(x){this._matrix[0]=x}}),Object.defineProperty(At.prototype,"b",{get:function(){return this._matrix[1]},set:function(x){this._matrix[1]=x}}),Object.defineProperty(At.prototype,"c",{get:function(){return this._matrix[2]},set:function(x){this._matrix[2]=x}}),Object.defineProperty(At.prototype,"d",{get:function(){return this._matrix[3]},set:function(x){this._matrix[3]=x}}),Object.defineProperty(At.prototype,"e",{get:function(){return this._matrix[4]},set:function(x){this._matrix[4]=x}}),Object.defineProperty(At.prototype,"f",{get:function(){return this._matrix[5]},set:function(x){this._matrix[5]=x}}),Object.defineProperty(At.prototype,"rotation",{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(At.prototype,"scaleX",{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(At.prototype,"scaleY",{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(At.prototype,"isIdentity",{get:function(){return this.sx===1&&this.shy===0&&this.shx===0&&this.sy===1&&this.tx===0&&this.ty===0}}),At.prototype.join=function(x){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map(k).join(x)},At.prototype.multiply=function(x){var W=x.sx*this.sx+x.shy*this.shx,Ae=x.sx*this.shy+x.shy*this.sy,Ce=x.shx*this.sx+x.sy*this.shx,Ie=x.shx*this.shy+x.sy*this.sy,Je=x.tx*this.sx+x.ty*this.shx+this.tx,ot=x.tx*this.shy+x.ty*this.sy+this.ty;return new At(W,Ae,Ce,Ie,Je,ot)},At.prototype.decompose=function(){var x=this.sx,W=this.shy,Ae=this.shx,Ce=this.sy,Ie=this.tx,Je=this.ty,ot=Math.sqrt(x*x+W*W),qt=(x/=ot)*Ae+(W/=ot)*Ce;Ae-=x*qt,Ce-=W*qt;var Qt=Math.sqrt(Ae*Ae+Ce*Ce);return qt/=Qt,x*(Ce/=Qt)<W*(Ae/=Qt)&&(x=-x,W=-W,qt=-qt,ot=-ot),{scale:new At(ot,0,0,Qt,0,0),translate:new At(1,0,0,1,Ie,Je),rotate:new At(x,W,-W,x,0,0),skew:new At(1,0,qt,1,0,0)}},At.prototype.toString=function(x){return this.join(" ")},At.prototype.inversed=function(){var x=this.sx,W=this.shy,Ae=this.shx,Ce=this.sy,Ie=this.tx,Je=this.ty,ot=1/(x*Ce-W*Ae),qt=Ce*ot,Qt=-W*ot,cr=-Ae*ot,dr=x*ot;return new At(qt,Qt,cr,dr,-qt*Ie-cr*Je,-Qt*Ie-dr*Je)},At.prototype.applyToPoint=function(x){var W=x.x*this.sx+x.y*this.shx+this.tx,Ae=x.x*this.shy+x.y*this.sy+this.ty;return new qa(W,Ae)},At.prototype.applyToRectangle=function(x){var W=this.applyToPoint(x),Ae=this.applyToPoint(new qa(x.x+x.w,x.y+x.h));return new yo(W.x,W.y,Ae.x-W.x,Ae.y-W.y)},At.prototype.clone=function(){var x=this.sx,W=this.shy,Ae=this.shx,Ce=this.sy,Ie=this.tx,Je=this.ty;return new At(x,W,Ae,Ce,Ie,Je)},h.Matrix=At;var Xt=h.matrixMult=function(x,W){return W.multiply(x)},Wr=new At(1,0,0,1,0,0);h.unitMatrix=h.identityMatrix=Wr;var qr=function(x,W){if(!Tt[x]){var Ae=(W instanceof $o?"Sh":"P")+(Object.keys(yt).length+1).toString(10);W.id=Ae,Tt[x]=Ae,yt[Ae]=W,Vt.publish("addPattern",W)}};h.ShadingPattern=$o,h.TilingPattern=WA,h.addShadingPattern=function(x,W){return M("addShadingPattern()"),qr(x,W),this},h.beginTilingPattern=function(x){M("beginTilingPattern()"),CA(x.boundingBox[0],x.boundingBox[1],x.boundingBox[2]-x.boundingBox[0],x.boundingBox[3]-x.boundingBox[1],x.matrix)},h.endTilingPattern=function(x,W){M("endTilingPattern()"),W.stream=de[Q].join(`
242
242
  `),qr(x,W),Vt.publish("endTilingPattern",W),Ur.pop().restore()};var sn,Mt=h.__private__.newObject=function(){var x=Kt();return mr(x,!0),x},Kt=h.__private__.newObjectDeferred=function(){return he++,le[he]=function(){return V},he},mr=function(x,W){return W=typeof W=="boolean"&&W,le[x]=V,W&&Y(x+" 0 obj"),x},hn=h.__private__.newAdditionalObject=function(){var x={objId:Kt(),content:""};return oe.push(x),x},rr=Kt(),lr=Kt(),Fr=h.__private__.decodeColorString=function(x){var W=x.split(" ");if(W.length!==2||W[1]!=="g"&&W[1]!=="G")W.length!==5||W[4]!=="k"&&W[4]!=="K"||(W=[(1-W[0])*(1-W[3]),(1-W[1])*(1-W[3]),(1-W[2])*(1-W[3]),"r"]);else{var Ae=parseFloat(W[0]);W=[Ae,Ae,Ae,"r"]}for(var Ce="#",Ie=0;Ie<3;Ie++)Ce+=("0"+Math.floor(255*parseFloat(W[Ie])).toString(16)).slice(-2);return Ce},jr=h.__private__.encodeColorString=function(x){var W;typeof x=="string"&&(x={ch1:x});var Ae=x.ch1,Ce=x.ch2,Ie=x.ch3,Je=x.ch4,ot=x.pdfColorType==="draw"?["G","RG","K"]:["g","rg","k"];if(typeof Ae=="string"&&Ae.charAt(0)!=="#"){var qt=new SN(Ae);if(qt.ok)Ae=qt.toHex();else if(!/^\d*\.?\d*$/.test(Ae))throw new Error('Invalid color "'+Ae+'" passed to jsPDF.encodeColorString.')}if(typeof Ae=="string"&&/^#[0-9A-Fa-f]{3}$/.test(Ae)&&(Ae="#"+Ae[1]+Ae[1]+Ae[2]+Ae[2]+Ae[3]+Ae[3]),typeof Ae=="string"&&/^#[0-9A-Fa-f]{6}$/.test(Ae)){var Qt=parseInt(Ae.substr(1),16);Ae=Qt>>16&255,Ce=Qt>>8&255,Ie=255&Qt}if(Ce===void 0||Je===void 0&&Ae===Ce&&Ce===Ie)W=typeof Ae=="string"?Ae+" "+ot[0]:x.precision===2?F(Ae/255)+" "+ot[0]:D(Ae/255)+" "+ot[0];else if(Je===void 0||zr(Je)==="object"){if(Je&&!isNaN(Je.a)&&Je.a===0)return["1.","1.","1.",ot[1]].join(" ");W=typeof Ae=="string"?[Ae,Ce,Ie,ot[1]].join(" "):x.precision===2?[F(Ae/255),F(Ce/255),F(Ie/255),ot[1]].join(" "):[D(Ae/255),D(Ce/255),D(Ie/255),ot[1]].join(" ")}else W=typeof Ae=="string"?[Ae,Ce,Ie,Je,ot[2]].join(" "):x.precision===2?[F(Ae),F(Ce),F(Ie),F(Je),ot[2]].join(" "):[D(Ae),D(Ce),D(Ie),D(Je),ot[2]].join(" ");return W},Zr=h.__private__.getFilters=function(){return s},Cn=h.__private__.putStream=function(x){var W=(x=x||{}).data||"",Ae=x.filters||Zr(),Ce=x.alreadyAppliedFilters||[],Ie=x.addLength1||!1,Je=W.length,ot=x.objectId,qt=function(dn){return dn};if(c!==null&&ot===void 0)throw new Error("ObjectId must be passed to putStream for file encryption");c!==null&&(qt=Mn.encryptor(ot,0));var Qt={};Ae===!0&&(Ae=["FlateEncode"]);var cr=x.additionalKeyValues||[],dr=(Qt=Zt.API.processDataByFilters!==void 0?Zt.API.processDataByFilters(W,Ae):{data:W,reverseChain:[]}).reverseChain+(Array.isArray(Ce)?Ce.join(" "):Ce.toString());if(Qt.data.length!==0&&(cr.push({key:"Length",value:Qt.data.length}),Ie===!0&&cr.push({key:"Length1",value:Je})),dr.length!=0)if(dr.split("/").length-1==1)cr.push({key:"Filter",value:dr});else{cr.push({key:"Filter",value:"["+dr+"]"});for(var Or=0;Or<cr.length;Or+=1)if(cr[Or].key==="DecodeParms"){for(var zn=[],tn=0;tn<Qt.reverseChain.split("/").length-1;tn+=1)zn.push("null");zn.push(cr[Or].value),cr[Or].value="["+zn.join(" ")+"]"}}Y("<<");for(var Jr=0;Jr<cr.length;Jr++)Y("/"+cr[Jr].key+" "+cr[Jr].value);Y(">>"),Qt.data.length!==0&&(Y("stream"),Y(qt(Qt.data)),Y("endstream"))},vi=h.__private__.putPage=function(x){var W=x.number,Ae=x.data,Ce=x.objId,Ie=x.contentsObjId;mr(Ce,!0),Y("<</Type /Page"),Y("/Parent "+x.rootDictionaryObjId+" 0 R"),Y("/Resources "+x.resourceDictionaryObjId+" 0 R"),Y("/MediaBox ["+parseFloat(k(x.mediaBox.bottomLeftX))+" "+parseFloat(k(x.mediaBox.bottomLeftY))+" "+k(x.mediaBox.topRightX)+" "+k(x.mediaBox.topRightY)+"]"),x.cropBox!==null&&Y("/CropBox ["+k(x.cropBox.bottomLeftX)+" "+k(x.cropBox.bottomLeftY)+" "+k(x.cropBox.topRightX)+" "+k(x.cropBox.topRightY)+"]"),x.bleedBox!==null&&Y("/BleedBox ["+k(x.bleedBox.bottomLeftX)+" "+k(x.bleedBox.bottomLeftY)+" "+k(x.bleedBox.topRightX)+" "+k(x.bleedBox.topRightY)+"]"),x.trimBox!==null&&Y("/TrimBox ["+k(x.trimBox.bottomLeftX)+" "+k(x.trimBox.bottomLeftY)+" "+k(x.trimBox.topRightX)+" "+k(x.trimBox.topRightY)+"]"),x.artBox!==null&&Y("/ArtBox ["+k(x.artBox.bottomLeftX)+" "+k(x.artBox.bottomLeftY)+" "+k(x.artBox.topRightX)+" "+k(x.artBox.topRightY)+"]"),typeof x.userUnit=="number"&&x.userUnit!==1&&Y("/UserUnit "+x.userUnit),Vt.publish("putPage",{objId:Ce,pageContext:Ct[W],pageNumber:W,page:Ae}),Y("/Contents "+Ie+" 0 R"),Y(">>"),Y("endobj");var Je=Ae.join(`