@excalidraw/excalidraw 0.17.1-f597bd3 → 0.17.1-f59b4f6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
- var mS=Object.defineProperty;var vb=e=>t=>{var r=e[t];if(r)return r();throw new Error("Module not found in bundle: "+t)};var j=(e,t)=>()=>(e&&(t=e(e=0)),t);var Mu=(e,t)=>{for(var r in t)mS(e,r,{get:t[r],enumerable:!0})};var T,f=j(()=>{T={PROD:!0}});var Pu,Cb=j(()=>{Pu={}});import vS from"open-color";var TS,kb,Bi,Ab,Da,Ra,ho,go,se,Mb,$c,Xc,Zc,Lb,Pb,_b,Db,Zt=j(()=>{"use strict";f();TS=(e,t)=>t.reduce((r,o)=>(o in e&&(r[o]=e[o]),r),{}),kb=5,Bi=5,Ab=4,Da=4,Ra=1,ho=[0,2,4,6,8],go=(e,t)=>t.map(r=>vS[e][r]),se={transparent:"transparent",black:"#1e1e1e",white:"#ffffff",gray:go("gray",ho),red:go("red",ho),pink:go("pink",ho),grape:go("grape",ho),violet:go("violet",ho),blue:go("blue",ho),cyan:go("cyan",ho),teal:go("teal",ho),green:go("green",ho),yellow:go("yellow",ho),orange:go("orange",ho),bronze:["#f8f1ee","#eaddd7","#d2bab0","#a18072","#846358"]},Mb=TS(se,["cyan","blue","violet","grape","pink","green","teal","yellow","orange","red"]),$c=[se.black,se.red[Da],se.green[Da],se.blue[Da],se.yellow[Da]],Xc=[se.transparent,se.red[Ra],se.green[Ra],se.blue[Ra],se.yellow[Ra]],Zc=[se.white,"#f8f9fa","#f5faff","#fffce8","#fdf8f6"],Lb={transparent:se.transparent,white:se.white,gray:se.gray,black:se.black,bronze:se.bronze,...Mb},Pb={transparent:se.transparent,white:se.white,gray:se.gray,black:se.black,bronze:se.bronze,...Mb},_b=e=>[se.cyan[e],se.blue[e],se.violet[e],se.grape[e],se.pink[e],se.green[e],se.teal[e],se.yellow[e],se.orange[e],se.red[e]],Db=(e,t,r)=>`#${((1<<24)+(e<<16)+(t<<8)+r).toString(16).slice(1)}`});var rr,jc,O7,mn,SS,B7,Rb,Nb,ns,is,pn,Na,Ob,_u,Bb,No,Du,Ce,Vn,Fi,as,ls,qc,it,oe,$e,Ru,Jc,At,Wt,Yn,Hi,zi,ss,Fb,Hb,un,cs,zb,J,Qc,jt,ds,Gb,Ub,Wb,Vb,Gi,ed,Yb,Oa,td,rd,Nu,Kb,$b,Xb,Zb,jb,Ba,Fa,fo,qb,Ou,Fe,Ui,ht,Jb,Qb,ft,Kn,ex,od,tx,rt,Bu,nd,Qe,ms,kr,id,bt,$r,ad,G=j(()=>{"use strict";f();Cb();Zt();rr=/Mac|iPod|iPhone|iPad/.test(navigator.platform),jc=/^Win/.test(navigator.platform),O7=/\b(android)\b/i.test(navigator.userAgent),mn="netscape"in window&&navigator.userAgent.indexOf("rv:")>1&&navigator.userAgent.indexOf("Gecko")>1,SS=navigator.userAgent.indexOf("Chrome")!==-1,B7=!SS&&navigator.userAgent.indexOf("Safari")!==-1,Rb=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,Nb=()=>navigator.brave?.isBrave?.name==="isBrave",ns=typeof window<"u"&&"ResizeObserver"in window,is="Excalidraw",pn=10,Na=8,Ob=5,_u=1,Bb=30,No=Math.PI/12,Du="red",Ce={TEXT:"text",CROSSHAIR:"crosshair",GRABBING:"grabbing",GRAB:"grab",POINTER:"pointer",MOVE:"move",AUTO:""},Vn={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},Fi={enabled:"all",disabled:"none",inheritFromUI:"var(--ui-pointerEvents)"},as={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},ls={TEST:"test",DEVELOPMENT:"development"},qc={SHAPE_ACTIONS_MENU:"App-menu__left"},it={Virgil:1,Helvetica:2,Cascadia:3,Assistant:4},oe={LIGHT:"light",DARK:"dark"},$e={strokeColor:"#bbb",strokeWidth:2,strokeStyle:"solid",fillStyle:"solid",roughness:0,roundness:null,backgroundColor:"transparent",radius:8,nameOffsetY:3,nameColorLightTheme:"#999999",nameColorDarkTheme:"#7a7a7a",nameFontSize:14,nameLineHeight:1.25},Ru="Segoe UI Emoji",Jc=1,At=20,Wt=it.Virgil,Yn="left",Hi="top",zi=2,ss="#ffffff",Fb="#1e1e1e",Hb="#a2f1a6",un=20,cs={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif"},zb=["text/plain","text/html"],J={json:"application/json",excalidraw:"application/vnd.excalidraw+json",excalidrawlib:"application/vnd.excalidrawlib+json","excalidraw.svg":"image/svg+xml","excalidraw.png":"image/png",binary:"application/octet-stream",...cs},Qc={png:"png",svg:"svg",clipboard:"clipboard"},jt={excalidraw:"excalidraw",excalidrawClipboard:"excalidraw/clipboard",excalidrawLibrary:"excalidrawlib",excalidrawClipboardWithAPI:"excalidraw-api/clipboard"},ds=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,Gb=500,Ub=300,Wb=500,Vb=100,Gi=.1,ed=.1,Yb=300,Oa=Pu.themeFilter,td={addLibrary:"addLibrary"},rd={addLibrary:"addLibrary"},Nu={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},Kb=730,$b=1e3,Xb=500,Zb=1229,jb=parseInt(Pu.rightSidebarWidth),Ba=2,Fa=[1,2,3],fo=10,qb=1440,Ou=2*1024*1024,Fe="http://www.w3.org/2000/svg",Ui={excalidraw:2,excalidrawLibrary:2},ht=5,Jb=.7,Qb=11,ft={TOP:"top",MIDDLE:"middle",BOTTOM:"bottom"},Kn={LEFT:"left",CENTER:"center",RIGHT:"right"},ex=20,od=.25,tx=32,rt={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},Bu={architect:0,artist:1,cartoonist:2},nd={thin:1,bold:2,extraBold:4},Qe={strokeColor:se.black,backgroundColor:se.transparent,fillStyle:"solid",strokeWidth:2,strokeStyle:"solid",roughness:Bu.artist,opacity:100,locked:!1},ms="library",kr={name:"default",defaultTab:ms},id=new Set(["iframe","embeddable","image"]),bt={selection:"selection",rectangle:"rectangle",diamond:"diamond",ellipse:"ellipse",arrow:"arrow",line:"line",freedraw:"freedraw",text:"text",image:"image",eraser:"eraser",hand:"hand",frame:"frame",magicframe:"magicframe",embeddable:"embeddable",laser:"laser"},$r={OAI_API_KEY:"excalidraw-oai-api-key",MERMAID_TO_EXCALIDRAW:"mermaid-to-excalidraw",PUBLISH_LIBRARY:"publish-library-data"},ad="Untitled"});function mt(e,t,r,o){return e?(e?.addEventListener?.(t,r,o),()=>{e?.removeEventListener?.(t,r,o)}):()=>{}}function xx(e,t=!0){let r=e.length;if(r<4)return"";let o=e[0],n=e[1],i=e[2],a=`M${o[0].toFixed(2)},${o[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${sd(n[0],i[0]).toFixed(2)},${sd(n[1],i[1]).toFixed(2)} T`;for(let l=2,s=r-1;l<s;l++)o=e[l],n=e[l+1],a+=`${sd(o[0],n[0]).toFixed(2)},${sd(o[1],n[1]).toFixed(2)} `;return t&&(a+="Z"),a}var ox,Hu,$n,ax,zu,lx,Xr,Ha,Ge,Wi,za,hn,nx,sx,cx,Mt,Xe,R,Ue,Dt,ps,_S,DS,RS,cd,bo,dd,Gu,Uu,or,md,dx,mx,px,ux,gn,$,hx,Ar,gx,pd,Ga,fx,Oo,us,ix,wt,Xn,Zn,bx,hs,Bo,Wu,ud,sd,hd,xo,gs,z=j(()=>{"use strict";f();Zt();G();ox=null,Hu=()=>{if(ox)return ox;let e=new Date,t=e.getFullYear(),r=`${e.getMonth()+1}`.padStart(2,"0"),o=`${e.getDate()}`.padStart(2,"0"),n=`${e.getHours()}`.padStart(2,"0"),i=`${e.getMinutes()}`.padStart(2,"0");return`${t}-${r}-${o}-${n}${i}`},$n=e=>e.charAt(0).toUpperCase()+e.slice(1),ax=e=>e instanceof HTMLElement&&e.className.includes("ToolIcon"),zu=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,lx=e=>zu(e)||e instanceof Element&&!!e.closest("label, button"),Xr=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type==="text"||e.type==="number"||e.type==="password"),Ha=({fontFamily:e})=>{for(let[t,r]of Object.entries(it))if(r===e)return`${t}, ${Ru}`;return Ru},Ge=({fontSize:e,fontFamily:t})=>`${e}px ${Ha({fontFamily:t})}`,Wi=(e,t)=>{let r=0,o=null,n=(...i)=>{o=i,clearTimeout(r),r=window.setTimeout(()=>{o=null,e(...i)},t)};return n.flush=()=>{if(clearTimeout(r),o){let i=o;o=null,e(...i)}},n.cancel=()=>{o=null,clearTimeout(r)},n},za=(e,t)=>{let r=null,o=null,n=null,i=l=>{r=window.requestAnimationFrame(()=>{r=null,e(...l),o=null,n&&(o=n,n=null,i(o))})},a=(...l)=>{if(T.MODE==="test"){e(...l);return}o=l,r===null?i(o):t?.trailing&&(n=l)};return a.flush=()=>{r!==null&&(cancelAnimationFrame(r),r=null),o&&(e(...n||o),o=n=null)},a.cancel=()=>{o=n=null,r!==null&&(cancelAnimationFrame(r),r=null)},a},hn=e=>1-Math.pow(1-e,4),nx=(e,t,r)=>(t-e)*hn(r)+e,sx=({fromValues:e,toValues:t,onStep:r,duration:o=250,interpolateValue:n,onStart:i,onEnd:a,onCancel:l})=>{let s=!1,c=0,d;function m(p){if(s)return;d===void 0&&(d=p,i?.());let u=Math.min(p-d,o),h=hn(u/o),x={};if(Object.keys(e).forEach(E=>{let v=E,w=(t[v]-e[v])*h+e[v];x[v]=w}),r(x),u<o){let E=u/o,v={};Object.keys(e).forEach(w=>{let y=w,I=e[y],P=t[y],C;C=n?n(I,P,E,y):nx(I,P,E),C==null&&(C=nx(I,P,E)),v[y]=C}),r(v),c=window.requestAnimationFrame(m)}else r(t),a?.()}return c=window.requestAnimationFrame(m),()=>{l?.(),s=!0,window.cancelAnimationFrame(c)}},cx=(e,t)=>{if(!e.length||t<1)return[];let r=0,o=0,n=Array(Math.ceil(e.length/t));for(;r<e.length;)n[o++]=e.slice(r,r+=t);return n},Mt=(e,t)=>Math.abs(e-t),Xe=(e,t)=>t.type==="custom"?{...e.activeTool,type:"custom",customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked},R=e=>(e=e.replace(/\bAlt\b/i,"Alt").replace(/\bShift\b/i,"Shift").replace(/\b(Enter|Return)\b/i,"Enter"),rr?e.replace(/\bCtrlOrCmd\b/gi,"Cmd").replace(/\bAlt\b/i,"Option"):e.replace(/\bCtrlOrCmd\b/gi,"Ctrl")),Ue=({clientX:e,clientY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let l=(e-o)/r.value-i,s=(t-n)/r.value-a;return{x:l,y:s}},Dt=({sceneX:e,sceneY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let l=(e+i)*r.value+o,s=(t+a)*r.value+n;return{x:l,y:s}},ps=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),_S="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF",DS="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",RS=new RegExp(`^[^${_S}]*[${DS}]`),cd=e=>RS.test(e),bo=e=>{let[t,r]=e;return{x:t,y:r}},dd=e=>{if(e?.name==="AbortError"){console.warn(e);return}throw e},Gu=(e,t,r=0)=>{r<0&&(r=e.length+r),r=Math.min(e.length,Math.max(r,0));let o=r-1;for(;++o<e.length;)if(t(e[o],o,e))return o;return-1},Uu=(e,t,r=e.length-1)=>{r<0&&(r=e.length+r),r=Math.min(e.length-1,Math.max(r,0));let o=r+1;for(;--o>-1;)if(t(e[o],o,e))return o;return-1},or=e=>{let t=e.length===5&&e.substr(4,1)==="0",r=e.length===9&&e.substr(7,2)==="00";return t||r||e===se.transparent},md=()=>{let e,t,r=new Promise((o,n)=>{e=o,t=n});return r.resolve=e,r.reject=t,r},dx=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:r}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(r==="auto"||r==="scroll"||r==="overlay"))return t;t=t.parentElement}return document},mx=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},px=e=>{e.preventDefault(),e.returnValue=""},ux=e=>Array.from(e).map(t=>`0${t.toString(16)}`.slice(-2)).join(""),gn=()=>Ar()?1:Date.now(),$=e=>e instanceof Map?e:e.reduce((t,r)=>(t.set(typeof r=="string"?r:r.id,r),t),new Map),hx=e=>e.reduce((t,r,o)=>(t.set(r.id,[r,o]),t),new Map),Ar=()=>T.MODE==="test",gx=()=>T.MODE==="development",pd=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),Ga=(e,t)=>{let r=!1;for(let o in t){let n=t[o];if(typeof n<"u"){if(e[o]===n&&(typeof n!="object"||n===null))continue;r=!0}}return r?{...e,...t}:e},fx=()=>{try{return window.self===window.top?"top":"iframe"}catch{return"iframe"}},Oo=e=>!!e&&typeof e=="object"&&"then"in e&&"catch"in e&&"finally"in e,us=e=>{let t=e?.querySelectorAll("button, a, input, select, textarea, div[tabindex], label[tabindex]");return t?Array.from(t).filter(r=>r.tabIndex>-1&&!r.disabled):[]},ix=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,wt=(e,t,r,o=!1)=>{let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return o&&console.warn("%cisShallowEqual: objects don't have same properties ->","color: #8B4000",e,t),!1;if(r&&Array.isArray(r)){for(let a of r)if(!(e[a]===t[a]||ix(e[a],t[a])))return o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),!1;return!0}return n.every(a=>{let l=r?.[a],s=l?l(e[a],t[a]):e[a]===t[a]||ix(e[a],t[a]);return!s&&o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),s})},Xn=(e,t,{checkForDefaultPrevented:r=!0}={})=>function(n){if(e?.(n),!r||!n?.defaultPrevented)return t?.(n)},Zn=(e,t,r)=>{if(!t)return e;if(r)return console.error(t),e;throw new Error(t)},bx=e=>{let t,r,o=function(n){let i=Object.entries(n);if(t){let l=!0;for(let[s,c]of i)if(t.get(s)!==c){l=!1;break}if(l)return r}let a=e(n);return t=new Map(i),r=a,a};return o.clear=()=>{t=void 0,r=void 0},o},hs=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):"includes"in e?e.includes(t):e.hasOwnProperty(t),Bo=e=>JSON.parse(JSON.stringify(e)),Wu=e=>typeof e=="number"&&Number.isFinite(e),ud=(e,t)=>wt(e,t)?e:t;sd=(e,t)=>(e+t)/2;hd=e=>e.replace(/\r?\n|\r/g,`
2
- `),xo=e=>e,gs=async(e,...t)=>new Promise(r=>{r(e(...t))})});var nr,Zr,vt,jr,Vt,U,jn,Vi,Q,Lt,NS,re,Te,fs,Tt,Vu,Ua,Fo,bs,gr,Ne,Ho,Ex,yx,wx,ce=j(()=>{"use strict";f();G();z();nr=e=>!!e&&e.type==="image"&&!!e.fileId,Zr=e=>!!e&&e.type==="image",vt=e=>!!e&&e.type==="embeddable",jr=e=>!!e&&e.type==="iframe",Vt=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),U=e=>e!=null&&e.type==="text",jn=e=>e!=null&&e.type==="frame",Vi=e=>e!=null&&e.type==="magicframe",Q=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Lt=e=>e!=null&&NS(e.type),NS=e=>e==="freedraw",re=e=>e!=null&&fs(e.type),Te=e=>e!=null&&e.type==="arrow",fs=e=>e==="arrow"||e==="line",Tt=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&Vu(e.type),Vu=e=>e==="arrow",Ua=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),Fo=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||Te(e)),bs=e=>{let t=e?.type;if(!t)return!1;switch(t){case"text":case"diamond":case"rectangle":case"iframe":case"embeddable":case"ellipse":case"arrow":case"freedraw":case"line":case"frame":case"magicframe":case"image":case"selection":return!0;default:return Zn(t,null),!1}},gr=e=>Fo(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),Ne=e=>e!==null&&"containerId"in e&&e.containerId!==null&&U(e),Ho=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",Ex=e=>e==="line"||e==="arrow"||e==="diamond",yx=(e,t)=>!!((e===rt.ADAPTIVE_RADIUS||e===rt.LEGACY)&&Ho(t.type)||e===rt.PROPORTIONAL_RADIUS&&Ex(t.type)),wx=e=>Ex(e.type)?{type:rt.PROPORTIONAL_RADIUS}:Ho(e.type)?{type:rt.ADAPTIVE_RADIUS}:null});import{Random as OS}from"roughjs/bin/math";import{nanoid as BS}from"nanoid";var FS,HS,qr,Pt,Eo=j(()=>{"use strict";f();z();FS=new OS(Date.now()),HS=0,qr=()=>Math.floor(FS.next()*2**31),Pt=()=>Ar()?`id${HS++}`:BS()});var gd,zo,yo,fd,qn=j(()=>{"use strict";f();gd=class extends Error{constructor(t="Couldn't export canvas.",r="CANVAS_ERROR"){super(),this.name=r,this.message=t}},zo=class extends DOMException{constructor(t="Request Aborted"){super(t,"AbortError")}},yo=class extends Error{code;constructor(t="Image Scene Data Error",r="IMAGE_SCENE_DATA_ERROR"){super(t),this.name="EncodingError",this.code=r}},fd=class extends Error{code="ELEMENT_HAS_INVALID_INDEX"}});import{generateNKeysBetween as zS}from"fractional-indexing";var Yu,qt,Mr,GS,US,xs,vx,wo=j(()=>{"use strict";f();We();qn();Yu=e=>{for(let[t,r]of e.entries()){let o=e[t-1],n=e[t+1];if(!xs(r,o,n))throw new fd(`Fractional indices invariant for element has been compromised - ["${o}", "${r}", "${n}"] [predecessor, current, successor]`)}},qt=(e,t)=>{try{let r=GS(e,t),o=vx(e,r);Yu(e.map(n=>o.get(n)?.index||n.index));for(let[n,i]of o)F(n,i,!1)}catch{Mr(e)}return e},Mr=e=>{let t=US(e),r=vx(e,t);for(let[o,n]of r)F(o,n,!1);return e},GS=(e,t)=>{let r=[],o=0;for(;o<e.length;)if(t.has(e[o].id)&&!xs(e[o]?.index,e[o-1]?.index,e[o+1]?.index)){let n=[o-1,o];for(;++o<e.length&&(t.has(e[o].id)&&!xs(e[o]?.index,e[o-1]?.index,e[o+1]?.index));)n.push(o);n.push(o),r.push(n)}else o++;return r},US=e=>{let t=[],r,o,n=-1,i=0,a=c=>{let d=e[n]?e[n].index:void 0,m=e[c-1]?.index;return!d&&m||d&&m&&m>d?[m,c-1]:[d,n]},l=c=>{let d=e[i]?e[i].index:void 0;if(d&&c<i)return[d,i];let m=i;for(;++m<e.length;){let p=e[m]?.index;if(!d&&p||d&&p&&p>d)return[p,m]}return[void 0,m]},s=0;for(;s<e.length;){let c=e[s].index;if([r,n]=a(s),[o,i]=l(s),xs(c,r,o))s++;else{let d=[n,s];for(;++s<e.length;){let m=e[s].index,[p,u]=a(s),[h,x]=l(s);if(xs(m,p,h))break;[r,n]=[p,u],[o,i]=[h,x],d.push(s)}d.push(i),t.push(d)}}return t},xs=(e,t,r)=>e?t&&r?t<e&&e<r:!t&&r?e<r:t&&!r?t<e:!!e:!1,vx=(e,t)=>{let r=new Map;for(let o of t){let n=o.shift(),i=o.pop(),a=zS(e[n]?.index,e[i]?.index,o.length);for(let l=0;l<o.length;l++){let s=e[o[l]];r.set(s,{index:a[l]})}}return r}});var Tx,WS,Sx,Ku,pt,Jn=j(()=>{"use strict";f();ge();ce();Qn();Eo();wo();z();z();G();Tx=e=>{let t=new Map,r=[];for(let o of e)o.isDeleted||(r.push(o),t.set(o.id,o));return{elementsMap:t,elements:r}},WS=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],r="";for(let o of t)r+=`${o}:${e[o]?"1":"0"}`;return r},Sx=e=>typeof e=="string",Ku=class e{static sceneMapByElement=new WeakMap;static sceneMapById=new Map;static mapElementToScene(t,r){Sx(t)?this.sceneMapById.set(t,r):(this.sceneMapByElement.set(t,r),this.sceneMapById.set(t.id,r))}static getScene(t){return Sx(t)?this.sceneMapById.get(t)||null:this.sceneMapByElement.get(t)||null}callbacks=new Set;nonDeletedElements=[];nonDeletedElementsMap=xo(new Map);elements=[];nonDeletedFramesLikes=[];frames=[];elementsMap=xo(new Map);selectedElementsCache={selectedElementIds:null,elements:null,cache:new Map};versionNonce;getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(t){let r=WS(t),o=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===o&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let i=this.selectedElementsCache.cache.get(r);if(i)return i}else t?.elements==null&&this.selectedElementsCache.cache.clear();let n=me(o,{selectedElementIds:t.selectedElementIds},t);return t?.elements==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(r,n)),n}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getVersionNonce(){return this.versionNonce}getNonDeletedElement(t){let r=this.getElement(t);return r&&Es(r)?r:null}mapElements(t){let r=!1,o=this.elements.map(n=>{let i=t(n);return i!==n&&(r=!0),i});return r&&this.replaceAllElements(o),r}replaceAllElements(t){let r=t instanceof Array?t:Array.from(t.values()),o=[];(T.DEV||T.MODE===ls.TEST)&&Yu(r.map(i=>i.index)),this.elements=Mr(r),this.elementsMap.clear(),this.elements.forEach(i=>{Q(i)&&o.push(i),this.elementsMap.set(i.id,i),e.mapElementToScene(i,this)});let n=Tx(this.elements);this.nonDeletedElements=n.elements,this.nonDeletedElementsMap=n.elementsMap,this.frames=o,this.nonDeletedFramesLikes=Tx(this.frames).elements,this.informMutation()}informMutation(){this.versionNonce=qr();for(let t of Array.from(this.callbacks))t()}addCallback(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),e.sceneMapById.forEach((t,r)=>{t===this&&e.sceneMapById.delete(r)}),this.callbacks.clear()}insertElementAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),t,...this.elements.slice(r)];qt(o,$([t])),this.replaceAllElements(o)}insertElementsAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),...t,...this.elements.slice(r)];qt(o,$(t)),this.replaceAllElements(o)}insertElement=t=>{let r=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,r)};insertElements=t=>{let r=t[0].frameId?this.getElementIndex(t[0].frameId):this.elements.length;this.insertElementsAtIndex(t,r)};getElementIndex(t){return this.elements.findIndex(r=>r.id===t)}getContainerElement=t=>t&&t.containerId&&this.getElement(t.containerId)||null},pt=Ku});var bd,ei,ys=j(()=>{"use strict";f();bd=e=>{let t=e.map(o=>o[0]),r=e.map(o=>o[1]);return{width:Math.max(...t)-Math.min(...t),height:Math.max(...r)-Math.min(...r)}},ei=(e,t,r,o)=>{let n=r.map(u=>u[e]),i=Math.max(...n),a=Math.min(...n),l=i-a,s=l===0?1:t/l,c=1/0,d=r.map(u=>{let h=u[e]*s,x=[...u];return x[e]=h,h<c&&(c=h),x});if(!o||d.length===2)return d;let m=a-c;return d.map(u=>u.map((h,x)=>x===e?h+m:h))}});var Ee,Ze,xd,xt,ws,ir,Ed,St,vo,$u,Xu,VS,Ix,Cx,kx,Zu,Ax,vs,Ts,Ss,Rt=j(()=>{"use strict";f();G();at();Go();Ee=(e,t,r,o,n)=>[(e-r)*Math.cos(n)-(t-o)*Math.sin(n)+r,(e-r)*Math.sin(n)+(t-o)*Math.cos(n)+o],Ze=(e,t,r)=>Ee(e[0],e[1],t[0],t[1],r),xd=(e,t,r,o,n,i,a,l)=>{let s=Math.cos(o),c=Math.sin(o);return e.e&&e.w?t+=n+a:e.e?(t+=n*(1+s),r+=n*c,t+=a*(1-s),r+=a*-c):e.w&&(t+=n*(1-s),r+=n*-c,t+=a*(1+s),r+=a*c),e.n&&e.s?r+=i+l:e.n?(t+=i*c,r+=i*(1-s),t+=l*-c,r+=l*(1+s)):e.s&&(t+=i*-c,r+=i*(1+s),t+=l*c,r+=l*(1-s)),[t,r]},xt=(e,t,r,o)=>{let n=r-e,i=o-t;return Math.hypot(n,i)},ws=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],ir=(e,t=1)=>{if(e.length>=3){let[r,o]=[e[0],e[e.length-1]];return xt(r[0],r[1],o[0],o[1])<=Na/t}return!1},Ed=(e,t,r)=>t[0]<=Math.max(e[0],r[0])&&t[0]>=Math.min(e[0],r[0])&&t[1]<=Math.max(e[1],r[1])&&t[1]>=Math.min(e[1],r[1]),St=(e,t,r)=>r?[Math.round(e/r)*r,Math.round(t/r)*r]:[e,t],vo=(e,t)=>{if(t.roundness?.type===rt.PROPORTIONAL_RADIUS||t.roundness?.type===rt.LEGACY)return e*od;if(t.roundness?.type===rt.ADAPTIVE_RADIUS){let r=t.roundness?.value??tx,o=r/od;return e<=o?e*od:r}return 0},$u=(e,t)=>{let r=ke.generateElementShape(e,null);if(!r)return null;let o=ti(r[0]),n=[0,0],i=0,a=1/0,l=null;for(;i<o.length;){let{op:s,data:c}=o[i];if(s==="move"&&(n=c),s==="bcurveTo"){let d=n,m=[c[0],c[1]],p=[c[2],c[3]],u=[c[4],c[5]],h=xt(u[0],u[1],t[0],t[1]);h<a&&(a=h,l=[d,m,p,u]),n=u}i++}return l},Xu=(e,t,r,o,n)=>{let i=(s,c)=>Math.pow(1-s,3)*o[c]+3*s*Math.pow(1-s,2)*r[c]+3*Math.pow(s,2)*(1-s)*t[c]+e[c]*Math.pow(s,3),a=i(n,0),l=i(n,1);return[a,l]},VS=(e,t)=>{let r=$u(e,t);if(!r)return[];let o=[],n=1;for(;n>0;){let i=Xu(r[0],r[1],r[2],r[3],n);o.push([i[0],i[1]]),n-=.05}return o.length&&Zu(o.at(-1),t)&&o.push([t[0],t[1]]),o},Ix=(e,t)=>{let r=[];r[0]=0;let o=VS(e,t),n=0,i=0;for(;n<o.length-1;){let a=xt(o[n][0],o[n][1],o[n+1][0],o[n+1][1]);i+=a,r.push(i),n++}return r},Cx=(e,t)=>Ix(e,t).at(-1),kx=(e,t,r)=>{let o=Ix(e,t),n=o.length-1,i=o.at(-1),a=r*i,l=0,s=n,c=0;for(;l<s;)c=Math.floor(l+(s-l)/2),o[c]<a?l=c+1:s=c;return o[c]>a&&c--,o[c]===a?c/n:1-(c+(a-o[c])/(o[c+1]-o[c]))/n},Zu=(e,t)=>e[0]===t[0]&&e[1]===t[1],Ax=e=>Math.round(e/Math.PI*1e4)%5e3===0,vs=([e,t],[r,o])=>e<=r?t>=r:e>=r?o>=e:!1,Ts=(e,t)=>{let r=Math.max(e[0],t[0]),o=Math.min(e[1],t[1]);return r<=o?[r,o]:null},Ss=(e,t,r)=>e>=t&&e<=r});var fn,Is,yd,wd,Wa,Yi,ju,Cs=j(()=>{"use strict";f();ce();fn=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",Is=e=>e!=="image"&&e!=="frame"&&e!=="magicframe",yd=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",wd=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",Wa=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="arrow"||e==="line"||e==="diamond"||e==="image",Yi=e=>e==="arrow",ju=(e,t)=>{let r=null;for(let o=e.length-1;o>=0;--o){let n=e[o];if(!n.isDeleted&&t(n)){r=n;break}}return r}});import{simplify as YS}from"points-on-curve";function $S(e){let t=e.roughness,r=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&r>=50||o>=15&&e.roundness&&Wa(e.type)||re(e)&&r>=50?t:Math.min(t/(r<10?3:2),2.5)}var KS,Px,Lr,Mx,Lx,_x,qu=j(()=>{"use strict";f();ge();Rt();bn();z();G();ce();Cs();KS=e=>[8,8+e],Px=e=>[1.5,6+e];Lr=(e,t=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?KS(e.strokeWidth):e.strokeStyle==="dotted"?Px(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:$S(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<Bu.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return r.fillStyle=e.fillStyle,r.fill=or(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(r.curveFitting=1),r;case"line":case"freedraw":return ir(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),r;case"arrow":return r;default:throw new Error(`Unimplemented type ${e.type}`)}},Mx=(e,t,r)=>Vt(e)&&(t||vt(e)&&r?.get(e.id)!==!0)&&or(e.backgroundColor)&&or(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:jr(e)?{...e,strokeColor:or(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:or(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Lx=(e,t,r,o,n,i,a)=>{let l=Qu(e,t,r,o);if(l===null)return[];switch(o){case"dot":case"circle":case"circle_outline":{let[s,c,d]=l;return delete i.strokeLineDash,[n.circle(s,c,d,{...i,fill:o==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[s,c,d,m,p,u]=l;return delete i.strokeLineDash,[n.polygon([[s,c],[d,m],[p,u],[s,c]],{...i,fill:o==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[s,c,d,m,p,u,h,x]=l;return delete i.strokeLineDash,[n.polygon([[s,c],[d,m],[p,u],[h,x],[s,c]],{...i,fill:o==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"bar":case"arrow":default:{let[s,c,d,m,p,u]=l;if(e.strokeStyle==="dotted"){let h=Px(e.strokeWidth-1);i.strokeLineDash=[h[0],h[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(d,m,s,c,i),n.line(p,u,s,c,i)]}}},_x=(e,t,{isExporting:r,canvasBackgroundColor:o,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=vo(Math.min(a,l),e);i=t.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,Lr(Mx(e,r,n),!0))}else i=t.rectangle(0,0,e.width,e.height,Lr(Mx(e,r,n),!1));return i}case"diamond":{let i,[a,l,s,c,d,m,p,u]=Ju(e);if(e.roundness){let h=vo(Math.abs(a-p),e),x=vo(Math.abs(c-l),e);i=t.path(`M ${a+h} ${l+x} L ${s-h} ${c-x}
1
+ var hS=Object.defineProperty;var Tb=e=>t=>{var r=e[t];if(r)return r();throw new Error("Module not found in bundle: "+t)};var j=(e,t)=>()=>(e&&(t=e(e=0)),t);var Pu=(e,t)=>{for(var r in t)hS(e,r,{get:t[r],enumerable:!0})};var T,f=j(()=>{T={PROD:!0}});var Du,kb=j(()=>{Du={}});import IS from"open-color";var CS,Ab,Bi,Mb,Da,Ra,ho,go,se,Lb,$c,Xc,Zc,Pb,_b,Db,Rb,Zt=j(()=>{"use strict";f();CS=(e,t)=>t.reduce((r,o)=>(o in e&&(r[o]=e[o]),r),{}),Ab=5,Bi=5,Mb=4,Da=4,Ra=1,ho=[0,2,4,6,8],go=(e,t)=>t.map(r=>IS[e][r]),se={transparent:"transparent",black:"#1e1e1e",white:"#ffffff",gray:go("gray",ho),red:go("red",ho),pink:go("pink",ho),grape:go("grape",ho),violet:go("violet",ho),blue:go("blue",ho),cyan:go("cyan",ho),teal:go("teal",ho),green:go("green",ho),yellow:go("yellow",ho),orange:go("orange",ho),bronze:["#f8f1ee","#eaddd7","#d2bab0","#a18072","#846358"]},Lb=CS(se,["cyan","blue","violet","grape","pink","green","teal","yellow","orange","red"]),$c=[se.black,se.red[Da],se.green[Da],se.blue[Da],se.yellow[Da]],Xc=[se.transparent,se.red[Ra],se.green[Ra],se.blue[Ra],se.yellow[Ra]],Zc=[se.white,"#f8f9fa","#f5faff","#fffce8","#fdf8f6"],Pb={transparent:se.transparent,white:se.white,gray:se.gray,black:se.black,bronze:se.bronze,...Lb},_b={transparent:se.transparent,white:se.white,gray:se.gray,black:se.black,bronze:se.bronze,...Lb},Db=e=>[se.cyan[e],se.blue[e],se.violet[e],se.grape[e],se.pink[e],se.green[e],se.teal[e],se.yellow[e],se.orange[e],se.red[e]],Rb=(e,t,r)=>`#${((1<<24)+(e<<16)+(t<<8)+r).toString(16).slice(1)}`});var rr,jc,B7,mn,kS,F7,Nb,Ob,is,as,pn,Na,Bb,Ru,Fb,No,Nu,Ce,Vn,Fi,ls,ss,qc,it,oe,$e,Ou,Jc,At,Wt,Yn,Hi,zi,cs,Hb,zb,un,ds,Gb,J,Qc,jt,ms,Ub,Wb,Vb,Yb,Gi,ed,Kb,Oa,td,rd,Bu,$b,Xb,Zb,jb,qb,Ba,Fa,fo,Jb,Fu,Fe,Ui,ht,Qb,ex,ft,Kn,tx,od,rx,rt,Hu,nd,Qe,ps,kr,id,bt,$r,ad,U=j(()=>{"use strict";f();kb();Zt();rr=/Mac|iPod|iPhone|iPad/.test(navigator.platform),jc=/^Win/.test(navigator.platform),B7=/\b(android)\b/i.test(navigator.userAgent),mn="netscape"in window&&navigator.userAgent.indexOf("rv:")>1&&navigator.userAgent.indexOf("Gecko")>1,kS=navigator.userAgent.indexOf("Chrome")!==-1,F7=!kS&&navigator.userAgent.indexOf("Safari")!==-1,Nb=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,Ob=()=>navigator.brave?.isBrave?.name==="isBrave",is=typeof window<"u"&&"ResizeObserver"in window,as="Excalidraw",pn=10,Na=8,Bb=5,Ru=1,Fb=30,No=Math.PI/12,Nu="red",Ce={TEXT:"text",CROSSHAIR:"crosshair",GRABBING:"grabbing",GRAB:"grab",POINTER:"pointer",MOVE:"move",AUTO:""},Vn={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},Fi={enabled:"all",disabled:"none",inheritFromUI:"var(--ui-pointerEvents)"},ls={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},ss={TEST:"test",DEVELOPMENT:"development"},qc={SHAPE_ACTIONS_MENU:"App-menu__left"},it={Virgil:1,Helvetica:2,Cascadia:3,Assistant:4},oe={LIGHT:"light",DARK:"dark"},$e={strokeColor:"#bbb",strokeWidth:2,strokeStyle:"solid",fillStyle:"solid",roughness:0,roundness:null,backgroundColor:"transparent",radius:8,nameOffsetY:3,nameColorLightTheme:"#999999",nameColorDarkTheme:"#7a7a7a",nameFontSize:14,nameLineHeight:1.25},Ou="Segoe UI Emoji",Jc=1,At=20,Wt=it.Virgil,Yn="left",Hi="top",zi=2,cs="#ffffff",Hb="#1e1e1e",zb="#a2f1a6",un=20,ds={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif"},Gb=["text/plain","text/html"],J={json:"application/json",excalidraw:"application/vnd.excalidraw+json",excalidrawlib:"application/vnd.excalidrawlib+json","excalidraw.svg":"image/svg+xml","excalidraw.png":"image/png",binary:"application/octet-stream",...ds},Qc={png:"png",svg:"svg",clipboard:"clipboard"},jt={excalidraw:"excalidraw",excalidrawClipboard:"excalidraw/clipboard",excalidrawLibrary:"excalidrawlib",excalidrawClipboardWithAPI:"excalidraw-api/clipboard"},ms=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,Ub=500,Wb=300,Vb=500,Yb=100,Gi=.1,ed=.1,Kb=300,Oa=Du.themeFilter,td={addLibrary:"addLibrary"},rd={addLibrary:"addLibrary"},Bu={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},$b=730,Xb=1e3,Zb=500,jb=1229,qb=parseInt(Du.rightSidebarWidth),Ba=2,Fa=[1,2,3],fo=10,Jb=1440,Fu=2*1024*1024,Fe="http://www.w3.org/2000/svg",Ui={excalidraw:2,excalidrawLibrary:2},ht=5,Qb=.7,ex=11,ft={TOP:"top",MIDDLE:"middle",BOTTOM:"bottom"},Kn={LEFT:"left",CENTER:"center",RIGHT:"right"},tx=20,od=.25,rx=32,rt={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},Hu={architect:0,artist:1,cartoonist:2},nd={thin:1,bold:2,extraBold:4},Qe={strokeColor:se.black,backgroundColor:se.transparent,fillStyle:"solid",strokeWidth:2,strokeStyle:"solid",roughness:Hu.artist,opacity:100,locked:!1},ps="library",kr={name:"default",defaultTab:ps},id=new Set(["iframe","embeddable","image"]),bt={selection:"selection",rectangle:"rectangle",diamond:"diamond",ellipse:"ellipse",arrow:"arrow",line:"line",freedraw:"freedraw",text:"text",image:"image",eraser:"eraser",hand:"hand",frame:"frame",magicframe:"magicframe",embeddable:"embeddable",laser:"laser"},$r={OAI_API_KEY:"excalidraw-oai-api-key",MERMAID_TO_EXCALIDRAW:"mermaid-to-excalidraw",PUBLISH_LIBRARY:"publish-library-data"},ad="Untitled"});function pt(e,t,r,o){return e?(e?.addEventListener?.(t,r,o),()=>{e?.removeEventListener?.(t,r,o)}):()=>{}}function Ex(e,t=!0){let r=e.length;if(r<4)return"";let o=e[0],n=e[1],i=e[2],a=`M${o[0].toFixed(2)},${o[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${sd(n[0],i[0]).toFixed(2)},${sd(n[1],i[1]).toFixed(2)} T`;for(let l=2,s=r-1;l<s;l++)o=e[l],n=e[l+1],a+=`${sd(o[0],n[0]).toFixed(2)},${sd(o[1],n[1]).toFixed(2)} `;return t&&(a+="Z"),a}var nx,Gu,$n,lx,Uu,sx,Xr,Ha,Ge,Wi,za,hn,ix,cx,dx,Mt,Xe,R,Ue,Dt,us,NS,OS,BS,cd,bo,dd,Wu,Vu,or,md,mx,px,ux,hx,gn,$,gx,Ar,fx,pd,Ga,bx,Oo,hs,ax,wt,Xn,Zn,xx,gs,Bo,Yu,ud,sd,hd,xo,fs,z=j(()=>{"use strict";f();Zt();U();nx=null,Gu=()=>{if(nx)return nx;let e=new Date,t=e.getFullYear(),r=`${e.getMonth()+1}`.padStart(2,"0"),o=`${e.getDate()}`.padStart(2,"0"),n=`${e.getHours()}`.padStart(2,"0"),i=`${e.getMinutes()}`.padStart(2,"0");return`${t}-${r}-${o}-${n}${i}`},$n=e=>e.charAt(0).toUpperCase()+e.slice(1),lx=e=>e instanceof HTMLElement&&e.className.includes("ToolIcon"),Uu=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,sx=e=>Uu(e)||e instanceof Element&&!!e.closest("label, button"),Xr=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type==="text"||e.type==="number"||e.type==="password"),Ha=({fontFamily:e})=>{for(let[t,r]of Object.entries(it))if(r===e)return`${t}, ${Ou}`;return Ou},Ge=({fontSize:e,fontFamily:t})=>`${e}px ${Ha({fontFamily:t})}`,Wi=(e,t)=>{let r=0,o=null,n=(...i)=>{o=i,clearTimeout(r),r=window.setTimeout(()=>{o=null,e(...i)},t)};return n.flush=()=>{if(clearTimeout(r),o){let i=o;o=null,e(...i)}},n.cancel=()=>{o=null,clearTimeout(r)},n},za=(e,t)=>{let r=null,o=null,n=null,i=l=>{r=window.requestAnimationFrame(()=>{r=null,e(...l),o=null,n&&(o=n,n=null,i(o))})},a=(...l)=>{if(T.MODE==="test"){e(...l);return}o=l,r===null?i(o):t?.trailing&&(n=l)};return a.flush=()=>{r!==null&&(cancelAnimationFrame(r),r=null),o&&(e(...n||o),o=n=null)},a.cancel=()=>{o=n=null,r!==null&&(cancelAnimationFrame(r),r=null)},a},hn=e=>1-Math.pow(1-e,4),ix=(e,t,r)=>(t-e)*hn(r)+e,cx=({fromValues:e,toValues:t,onStep:r,duration:o=250,interpolateValue:n,onStart:i,onEnd:a,onCancel:l})=>{let s=!1,c=0,d;function m(p){if(s)return;d===void 0&&(d=p,i?.());let u=Math.min(p-d,o),h=hn(u/o),x={};if(Object.keys(e).forEach(E=>{let v=E,w=(t[v]-e[v])*h+e[v];x[v]=w}),r(x),u<o){let E=u/o,v={};Object.keys(e).forEach(w=>{let y=w,I=e[y],P=t[y],C;C=n?n(I,P,E,y):ix(I,P,E),C==null&&(C=ix(I,P,E)),v[y]=C}),r(v),c=window.requestAnimationFrame(m)}else r(t),a?.()}return c=window.requestAnimationFrame(m),()=>{l?.(),s=!0,window.cancelAnimationFrame(c)}},dx=(e,t)=>{if(!e.length||t<1)return[];let r=0,o=0,n=Array(Math.ceil(e.length/t));for(;r<e.length;)n[o++]=e.slice(r,r+=t);return n},Mt=(e,t)=>Math.abs(e-t),Xe=(e,t)=>t.type==="custom"?{...e.activeTool,type:"custom",customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked},R=e=>(e=e.replace(/\bAlt\b/i,"Alt").replace(/\bShift\b/i,"Shift").replace(/\b(Enter|Return)\b/i,"Enter"),rr?e.replace(/\bCtrlOrCmd\b/gi,"Cmd").replace(/\bAlt\b/i,"Option"):e.replace(/\bCtrlOrCmd\b/gi,"Ctrl")),Ue=({clientX:e,clientY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let l=(e-o)/r.value-i,s=(t-n)/r.value-a;return{x:l,y:s}},Dt=({sceneX:e,sceneY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let l=(e+i)*r.value+o,s=(t+a)*r.value+n;return{x:l,y:s}},us=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),NS="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF",OS="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",BS=new RegExp(`^[^${NS}]*[${OS}]`),cd=e=>BS.test(e),bo=e=>{let[t,r]=e;return{x:t,y:r}},dd=e=>{if(e?.name==="AbortError"){console.warn(e);return}throw e},Wu=(e,t,r=0)=>{r<0&&(r=e.length+r),r=Math.min(e.length,Math.max(r,0));let o=r-1;for(;++o<e.length;)if(t(e[o],o,e))return o;return-1},Vu=(e,t,r=e.length-1)=>{r<0&&(r=e.length+r),r=Math.min(e.length-1,Math.max(r,0));let o=r+1;for(;--o>-1;)if(t(e[o],o,e))return o;return-1},or=e=>{let t=e.length===5&&e.substr(4,1)==="0",r=e.length===9&&e.substr(7,2)==="00";return t||r||e===se.transparent},md=()=>{let e,t,r=new Promise((o,n)=>{e=o,t=n});return r.resolve=e,r.reject=t,r},mx=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:r}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(r==="auto"||r==="scroll"||r==="overlay"))return t;t=t.parentElement}return document},px=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},ux=e=>{e.preventDefault(),e.returnValue=""},hx=e=>Array.from(e).map(t=>`0${t.toString(16)}`.slice(-2)).join(""),gn=()=>Ar()?1:Date.now(),$=e=>e instanceof Map?e:e.reduce((t,r)=>(t.set(typeof r=="string"?r:r.id,r),t),new Map),gx=e=>e.reduce((t,r,o)=>(t.set(r.id,[r,o]),t),new Map),Ar=()=>T.MODE==="test",fx=()=>T.MODE==="development",pd=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),Ga=(e,t)=>{let r=!1;for(let o in t){let n=t[o];if(typeof n<"u"){if(e[o]===n&&(typeof n!="object"||n===null))continue;r=!0}}return r?{...e,...t}:e},bx=()=>{try{return window.self===window.top?"top":"iframe"}catch{return"iframe"}},Oo=e=>!!e&&typeof e=="object"&&"then"in e&&"catch"in e&&"finally"in e,hs=e=>{let t=e?.querySelectorAll("button, a, input, select, textarea, div[tabindex], label[tabindex]");return t?Array.from(t).filter(r=>r.tabIndex>-1&&!r.disabled):[]},ax=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,wt=(e,t,r,o=!1)=>{let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return o&&console.warn("%cisShallowEqual: objects don't have same properties ->","color: #8B4000",e,t),!1;if(r&&Array.isArray(r)){for(let a of r)if(!(e[a]===t[a]||ax(e[a],t[a])))return o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),!1;return!0}return n.every(a=>{let l=r?.[a],s=l?l(e[a],t[a]):e[a]===t[a]||ax(e[a],t[a]);return!s&&o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),s})},Xn=(e,t,{checkForDefaultPrevented:r=!0}={})=>function(n){if(e?.(n),!r||!n?.defaultPrevented)return t?.(n)},Zn=(e,t,r)=>{if(!t)return e;if(r)return console.error(t),e;throw new Error(t)},xx=e=>{let t,r,o=function(n){let i=Object.entries(n);if(t){let l=!0;for(let[s,c]of i)if(t.get(s)!==c){l=!1;break}if(l)return r}let a=e(n);return t=new Map(i),r=a,a};return o.clear=()=>{t=void 0,r=void 0},o},gs=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):"includes"in e?e.includes(t):e.hasOwnProperty(t),Bo=e=>JSON.parse(JSON.stringify(e)),Yu=e=>typeof e=="number"&&Number.isFinite(e),ud=(e,t)=>wt(e,t)?e:t;sd=(e,t)=>(e+t)/2;hd=e=>e.replace(/\r?\n|\r/g,`
2
+ `),xo=e=>e,fs=async(e,...t)=>new Promise(r=>{r(e(...t))})});var nr,Zr,vt,jr,Vt,G,jn,Vi,Q,Lt,FS,re,Te,bs,Tt,Ku,Ua,Fo,xs,gr,Ne,Ho,yx,wx,vx,ce=j(()=>{"use strict";f();U();z();nr=e=>!!e&&e.type==="image"&&!!e.fileId,Zr=e=>!!e&&e.type==="image",vt=e=>!!e&&e.type==="embeddable",jr=e=>!!e&&e.type==="iframe",Vt=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),G=e=>e!=null&&e.type==="text",jn=e=>e!=null&&e.type==="frame",Vi=e=>e!=null&&e.type==="magicframe",Q=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Lt=e=>e!=null&&FS(e.type),FS=e=>e==="freedraw",re=e=>e!=null&&bs(e.type),Te=e=>e!=null&&e.type==="arrow",bs=e=>e==="arrow"||e==="line",Tt=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&Ku(e.type),Ku=e=>e==="arrow",Ua=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),Fo=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||Te(e)),xs=e=>{let t=e?.type;if(!t)return!1;switch(t){case"text":case"diamond":case"rectangle":case"iframe":case"embeddable":case"ellipse":case"arrow":case"freedraw":case"line":case"frame":case"magicframe":case"image":case"selection":return!0;default:return Zn(t,null),!1}},gr=e=>Fo(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),Ne=e=>e!==null&&"containerId"in e&&e.containerId!==null&&G(e),Ho=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",yx=e=>e==="line"||e==="arrow"||e==="diamond",wx=(e,t)=>!!((e===rt.ADAPTIVE_RADIUS||e===rt.LEGACY)&&Ho(t.type)||e===rt.PROPORTIONAL_RADIUS&&yx(t.type)),vx=e=>yx(e.type)?{type:rt.PROPORTIONAL_RADIUS}:Ho(e.type)?{type:rt.ADAPTIVE_RADIUS}:null});import{Random as HS}from"roughjs/bin/math";import{nanoid as zS}from"nanoid";var GS,US,qr,Pt,Eo=j(()=>{"use strict";f();z();GS=new HS(Date.now()),US=0,qr=()=>Math.floor(GS.next()*2**31),Pt=()=>Ar()?`id${US++}`:zS()});var gd,zo,yo,fd,qn=j(()=>{"use strict";f();gd=class extends Error{constructor(t="Couldn't export canvas.",r="CANVAS_ERROR"){super(),this.name=r,this.message=t}},zo=class extends DOMException{constructor(t="Request Aborted"){super(t,"AbortError")}},yo=class extends Error{code;constructor(t="Image Scene Data Error",r="IMAGE_SCENE_DATA_ERROR"){super(t),this.name="EncodingError",this.code=r}},fd=class extends Error{code="ELEMENT_HAS_INVALID_INDEX"}});import{generateNKeysBetween as WS}from"fractional-indexing";var $u,qt,Mr,VS,YS,Es,Tx,wo=j(()=>{"use strict";f();We();qn();$u=e=>{for(let[t,r]of e.entries()){let o=e[t-1],n=e[t+1];if(!Es(r,o,n))throw new fd(`Fractional indices invariant for element has been compromised - ["${o}", "${r}", "${n}"] [predecessor, current, successor]`)}},qt=(e,t)=>{try{let r=VS(e,t),o=Tx(e,r);$u(e.map(n=>o.get(n)?.index||n.index));for(let[n,i]of o)F(n,i,!1)}catch{Mr(e)}return e},Mr=e=>{let t=YS(e),r=Tx(e,t);for(let[o,n]of r)F(o,n,!1);return e},VS=(e,t)=>{let r=[],o=0;for(;o<e.length;)if(t.has(e[o].id)&&!Es(e[o]?.index,e[o-1]?.index,e[o+1]?.index)){let n=[o-1,o];for(;++o<e.length&&(t.has(e[o].id)&&!Es(e[o]?.index,e[o-1]?.index,e[o+1]?.index));)n.push(o);n.push(o),r.push(n)}else o++;return r},YS=e=>{let t=[],r,o,n=-1,i=0,a=c=>{let d=e[n]?e[n].index:void 0,m=e[c-1]?.index;return!d&&m||d&&m&&m>d?[m,c-1]:[d,n]},l=c=>{let d=e[i]?e[i].index:void 0;if(d&&c<i)return[d,i];let m=i;for(;++m<e.length;){let p=e[m]?.index;if(!d&&p||d&&p&&p>d)return[p,m]}return[void 0,m]},s=0;for(;s<e.length;){let c=e[s].index;if([r,n]=a(s),[o,i]=l(s),Es(c,r,o))s++;else{let d=[n,s];for(;++s<e.length;){let m=e[s].index,[p,u]=a(s),[h,x]=l(s);if(Es(m,p,h))break;[r,n]=[p,u],[o,i]=[h,x],d.push(s)}d.push(i),t.push(d)}}return t},Es=(e,t,r)=>e?t&&r?t<e&&e<r:!t&&r?e<r:t&&!r?t<e:!!e:!1,Tx=(e,t)=>{let r=new Map;for(let o of t){let n=o.shift(),i=o.pop(),a=WS(e[n]?.index,e[i]?.index,o.length);for(let l=0;l<o.length;l++){let s=e[o[l]];r.set(s,{index:a[l]})}}return r}});var Sx,KS,Ix,Xu,ut,Jn=j(()=>{"use strict";f();ge();ce();Qn();Eo();wo();z();z();U();Sx=e=>{let t=new Map,r=[];for(let o of e)o.isDeleted||(r.push(o),t.set(o.id,o));return{elementsMap:t,elements:r}},KS=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],r="";for(let o of t)r+=`${o}:${e[o]?"1":"0"}`;return r},Ix=e=>typeof e=="string",Xu=class e{static sceneMapByElement=new WeakMap;static sceneMapById=new Map;static mapElementToScene(t,r){Ix(t)?this.sceneMapById.set(t,r):(this.sceneMapByElement.set(t,r),this.sceneMapById.set(t.id,r))}static getScene(t){return Ix(t)?this.sceneMapById.get(t)||null:this.sceneMapByElement.get(t)||null}callbacks=new Set;nonDeletedElements=[];nonDeletedElementsMap=xo(new Map);elements=[];nonDeletedFramesLikes=[];frames=[];elementsMap=xo(new Map);selectedElementsCache={selectedElementIds:null,elements:null,cache:new Map};versionNonce;getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(t){let r=KS(t),o=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===o&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let i=this.selectedElementsCache.cache.get(r);if(i)return i}else t?.elements==null&&this.selectedElementsCache.cache.clear();let n=pe(o,{selectedElementIds:t.selectedElementIds},t);return t?.elements==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(r,n)),n}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getVersionNonce(){return this.versionNonce}getNonDeletedElement(t){let r=this.getElement(t);return r&&ys(r)?r:null}mapElements(t){let r=!1,o=this.elements.map(n=>{let i=t(n);return i!==n&&(r=!0),i});return r&&this.replaceAllElements(o),r}replaceAllElements(t){let r=t instanceof Array?t:Array.from(t.values()),o=[];(T.DEV||T.MODE===ss.TEST)&&$u(r.map(i=>i.index)),this.elements=Mr(r),this.elementsMap.clear(),this.elements.forEach(i=>{Q(i)&&o.push(i),this.elementsMap.set(i.id,i),e.mapElementToScene(i,this)});let n=Sx(this.elements);this.nonDeletedElements=n.elements,this.nonDeletedElementsMap=n.elementsMap,this.frames=o,this.nonDeletedFramesLikes=Sx(this.frames).elements,this.informMutation()}informMutation(){this.versionNonce=qr();for(let t of Array.from(this.callbacks))t()}addCallback(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),e.sceneMapById.forEach((t,r)=>{t===this&&e.sceneMapById.delete(r)}),this.callbacks.clear()}insertElementAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),t,...this.elements.slice(r)];qt(o,$([t])),this.replaceAllElements(o)}insertElementsAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),...t,...this.elements.slice(r)];qt(o,$(t)),this.replaceAllElements(o)}insertElement=t=>{let r=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,r)};insertElements=t=>{let r=t[0].frameId?this.getElementIndex(t[0].frameId):this.elements.length;this.insertElementsAtIndex(t,r)};getElementIndex(t){return this.elements.findIndex(r=>r.id===t)}getContainerElement=t=>t&&t.containerId&&this.getElement(t.containerId)||null},ut=Xu});var bd,ei,ws=j(()=>{"use strict";f();bd=e=>{let t=e.map(o=>o[0]),r=e.map(o=>o[1]);return{width:Math.max(...t)-Math.min(...t),height:Math.max(...r)-Math.min(...r)}},ei=(e,t,r,o)=>{let n=r.map(u=>u[e]),i=Math.max(...n),a=Math.min(...n),l=i-a,s=l===0?1:t/l,c=1/0,d=r.map(u=>{let h=u[e]*s,x=[...u];return x[e]=h,h<c&&(c=h),x});if(!o||d.length===2)return d;let m=a-c;return d.map(u=>u.map((h,x)=>x===e?h+m:h))}});var Ee,Ze,xd,xt,vs,ir,Ed,St,vo,Zu,ju,$S,Cx,kx,Ax,qu,Mx,Ts,Ss,Is,Rt=j(()=>{"use strict";f();U();at();Go();Ee=(e,t,r,o,n)=>[(e-r)*Math.cos(n)-(t-o)*Math.sin(n)+r,(e-r)*Math.sin(n)+(t-o)*Math.cos(n)+o],Ze=(e,t,r)=>Ee(e[0],e[1],t[0],t[1],r),xd=(e,t,r,o,n,i,a,l)=>{let s=Math.cos(o),c=Math.sin(o);return e.e&&e.w?t+=n+a:e.e?(t+=n*(1+s),r+=n*c,t+=a*(1-s),r+=a*-c):e.w&&(t+=n*(1-s),r+=n*-c,t+=a*(1+s),r+=a*c),e.n&&e.s?r+=i+l:e.n?(t+=i*c,r+=i*(1-s),t+=l*-c,r+=l*(1+s)):e.s&&(t+=i*-c,r+=i*(1+s),t+=l*c,r+=l*(1-s)),[t,r]},xt=(e,t,r,o)=>{let n=r-e,i=o-t;return Math.hypot(n,i)},vs=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],ir=(e,t=1)=>{if(e.length>=3){let[r,o]=[e[0],e[e.length-1]];return xt(r[0],r[1],o[0],o[1])<=Na/t}return!1},Ed=(e,t,r)=>t[0]<=Math.max(e[0],r[0])&&t[0]>=Math.min(e[0],r[0])&&t[1]<=Math.max(e[1],r[1])&&t[1]>=Math.min(e[1],r[1]),St=(e,t,r)=>r?[Math.round(e/r)*r,Math.round(t/r)*r]:[e,t],vo=(e,t)=>{if(t.roundness?.type===rt.PROPORTIONAL_RADIUS||t.roundness?.type===rt.LEGACY)return e*od;if(t.roundness?.type===rt.ADAPTIVE_RADIUS){let r=t.roundness?.value??rx,o=r/od;return e<=o?e*od:r}return 0},Zu=(e,t)=>{let r=ke.generateElementShape(e,null);if(!r)return null;let o=ti(r[0]),n=[0,0],i=0,a=1/0,l=null;for(;i<o.length;){let{op:s,data:c}=o[i];if(s==="move"&&(n=c),s==="bcurveTo"){let d=n,m=[c[0],c[1]],p=[c[2],c[3]],u=[c[4],c[5]],h=xt(u[0],u[1],t[0],t[1]);h<a&&(a=h,l=[d,m,p,u]),n=u}i++}return l},ju=(e,t,r,o,n)=>{let i=(s,c)=>Math.pow(1-s,3)*o[c]+3*s*Math.pow(1-s,2)*r[c]+3*Math.pow(s,2)*(1-s)*t[c]+e[c]*Math.pow(s,3),a=i(n,0),l=i(n,1);return[a,l]},$S=(e,t)=>{let r=Zu(e,t);if(!r)return[];let o=[],n=1;for(;n>0;){let i=ju(r[0],r[1],r[2],r[3],n);o.push([i[0],i[1]]),n-=.05}return o.length&&qu(o.at(-1),t)&&o.push([t[0],t[1]]),o},Cx=(e,t)=>{let r=[];r[0]=0;let o=$S(e,t),n=0,i=0;for(;n<o.length-1;){let a=xt(o[n][0],o[n][1],o[n+1][0],o[n+1][1]);i+=a,r.push(i),n++}return r},kx=(e,t)=>Cx(e,t).at(-1),Ax=(e,t,r)=>{let o=Cx(e,t),n=o.length-1,i=o.at(-1),a=r*i,l=0,s=n,c=0;for(;l<s;)c=Math.floor(l+(s-l)/2),o[c]<a?l=c+1:s=c;return o[c]>a&&c--,o[c]===a?c/n:1-(c+(a-o[c])/(o[c+1]-o[c]))/n},qu=(e,t)=>e[0]===t[0]&&e[1]===t[1],Mx=e=>Math.round(e/Math.PI*1e4)%5e3===0,Ts=([e,t],[r,o])=>e<=r?t>=r:e>=r?o>=e:!1,Ss=(e,t)=>{let r=Math.max(e[0],t[0]),o=Math.min(e[1],t[1]);return r<=o?[r,o]:null},Is=(e,t,r)=>e>=t&&e<=r});var fn,Cs,yd,wd,Wa,Yi,Ju,ks=j(()=>{"use strict";f();ce();fn=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",Cs=e=>e!=="image"&&e!=="frame"&&e!=="magicframe",yd=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",wd=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",Wa=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="arrow"||e==="line"||e==="diamond"||e==="image",Yi=e=>e==="arrow",Ju=(e,t)=>{let r=null;for(let o=e.length-1;o>=0;--o){let n=e[o];if(!n.isDeleted&&t(n)){r=n;break}}return r}});import{simplify as XS}from"points-on-curve";function jS(e){let t=e.roughness,r=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&r>=50||o>=15&&e.roundness&&Wa(e.type)||re(e)&&r>=50?t:Math.min(t/(r<10?3:2),2.5)}var ZS,_x,Lr,Lx,Px,Dx,Qu=j(()=>{"use strict";f();ge();Rt();bn();z();U();ce();ks();ZS=e=>[8,8+e],_x=e=>[1.5,6+e];Lr=(e,t=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?ZS(e.strokeWidth):e.strokeStyle==="dotted"?_x(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:jS(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<Hu.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return r.fillStyle=e.fillStyle,r.fill=or(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(r.curveFitting=1),r;case"line":case"freedraw":return ir(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),r;case"arrow":return r;default:throw new Error(`Unimplemented type ${e.type}`)}},Lx=(e,t,r)=>Vt(e)&&(t||vt(e)&&r?.get(e.id)!==!0)&&or(e.backgroundColor)&&or(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:jr(e)?{...e,strokeColor:or(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:or(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Px=(e,t,r,o,n,i,a)=>{let l=th(e,t,r,o);if(l===null)return[];switch(o){case"dot":case"circle":case"circle_outline":{let[s,c,d]=l;return delete i.strokeLineDash,[n.circle(s,c,d,{...i,fill:o==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[s,c,d,m,p,u]=l;return delete i.strokeLineDash,[n.polygon([[s,c],[d,m],[p,u],[s,c]],{...i,fill:o==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[s,c,d,m,p,u,h,x]=l;return delete i.strokeLineDash,[n.polygon([[s,c],[d,m],[p,u],[h,x],[s,c]],{...i,fill:o==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"bar":case"arrow":default:{let[s,c,d,m,p,u]=l;if(e.strokeStyle==="dotted"){let h=_x(e.strokeWidth-1);i.strokeLineDash=[h[0],h[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(d,m,s,c,i),n.line(p,u,s,c,i)]}}},Dx=(e,t,{isExporting:r,canvasBackgroundColor:o,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=vo(Math.min(a,l),e);i=t.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,Lr(Lx(e,r,n),!0))}else i=t.rectangle(0,0,e.width,e.height,Lr(Lx(e,r,n),!1));return i}case"diamond":{let i,[a,l,s,c,d,m,p,u]=eh(e);if(e.roundness){let h=vo(Math.abs(a-p),e),x=vo(Math.abs(c-l),e);i=t.path(`M ${a+h} ${l+x} L ${s-h} ${c-x}
3
3
  C ${s} ${c}, ${s} ${c}, ${s-h} ${c+x}
4
4
  L ${d+h} ${m-x}
5
5
  C ${d} ${m}, ${d} ${m}, ${d-h} ${m-x}
6
6
  L ${p+h} ${u+x}
7
7
  C ${p} ${u}, ${p} ${u}, ${p+h} ${u-x}
8
8
  L ${a-h} ${l+x}
9
- C ${a} ${l}, ${a} ${l}, ${a+h} ${l+x}`,Lr(e,!0))}else i=t.polygon([[a,l],[s,c],[d,m],[p,u]],Lr(e));return i}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,Lr(e));case"line":case"arrow":{let i,a=Lr(e),l=e.points.length?e.points:[[0,0]];if(e.roundness?i=[t.curve(l,a)]:a.fill?i=[t.polygon(l,a)]:i=[t.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:c="arrow"}=e;if(s!==null){let d=Lx(e,i,"start",s,t,a,o);i.push(...d)}if(c!==null){let d=Lx(e,i,"end",c,t,a,o);i.push(...d)}}return i}case"freedraw":{let i;if(Dx(e),ir(e.points)){let a=YS(e.points,.75);i=t.curve(a,{...Lr(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return Zn(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}}});var Jt,Rx,Ki,Va,Nx,eh,ri,XS,th,vd,rh,Ox,oh,Bx,$i,Fx,nh,eD,tD,rD,oD,nD,iD,aD,Xi=j(()=>{"use strict";f();Jt=(e,t)=>[0,0,0,0,t,e,1,0],Rx=(e,t)=>[0,0,0,0,t,e,0,0],Ki=(e=0,t=0)=>{let r=[0,0,0,0,0,0,0,0];if(t<0||t>7)throw new Error(`Expected \`index\` between 0 and 7, got \`${t}\``);return e!==0&&(r[t]=e),r},Va=e=>[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7]],Nx=(e,t)=>nh(t)?[e[0]+t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]+t[0],e[1]+t[1],e[2]+t[2],e[3]+t[3],e[4]+t[4],e[5]+t[5],e[6]+t[6],e[7]+t[7]],eh=(e,t)=>nh(t)?[e[0]-t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3],e[4]-t[4],e[5]-t[5],e[6]-t[6],e[7]-t[7]],ri=(e,t)=>nh(t)?[e[0]*t,e[1]*t,e[2]*t,e[3]*t,e[4]*t,e[5]*t,e[6]*t,e[7]*t]:[XS(e,t),t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[7]*e[3]+t[0]*e[4]+t[6]*e[5]-t[5]*e[6]+t[3]*e[7],t[5]*e[0]-t[3]*e[1]+t[7]*e[2]+t[1]*e[3]-t[6]*e[4]+t[0]*e[5]+t[4]*e[6]+t[2]*e[7],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]+t[0]*e[7]],XS=(e,t)=>t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],th=(e,t)=>[t[0]*e[0],t[1]*e[0]+t[0]*e[1],t[2]*e[0]+t[0]*e[2],t[3]*e[0]+t[0]*e[3],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[0]*e[4],t[5]*e[0]-t[3]*e[1]+t[1]*e[3]+t[0]*e[5],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]],vd=(e,t)=>[rh(e,t),e[1]*t[7]+e[4]*t[5]-e[5]*t[4]+e[7]*t[1],e[2]*t[7]-e[4]*t[6]+e[6]*t[4]+e[7]*t[2],e[3]*t[7]+e[5]*t[6]-e[6]*t[5]+e[7]*t[3],e[4]*t[7]+e[7]*t[4],e[5]*t[7]+e[7]*t[5],e[6]*t[7]+e[7]*t[6],e[7]*t[7]],rh=(e,t)=>e[0]*t[7]+e[1]*t[6]+e[2]*t[5]+e[3]*t[4]+e[4]*t[3]+e[5]*t[2]+e[6]*t[1]+e[7]*t[0],Ox=(e,t)=>[t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[7]*e[3]+t[0]*e[4]+t[3]*e[7],t[5]*e[0]+t[7]*e[2]+t[0]*e[5]+t[2]*e[7],t[6]*e[0]+t[0]*e[6],t[7]*e[0]+t[0]*e[7]],oh=e=>Math.sqrt(Math.abs(e[0]*e[0]-e[2]*e[2]-e[3]*e[3]+e[6]*e[6])),Bx=e=>Math.sqrt(Math.abs(e[7]*e[7]-e[5]*e[5]-e[4]*e[4]+e[1]*e[1])),$i=e=>{let t=oh(e);if(t===0||t===1)return e;let r=e[6]<0?-1:1;return ri(e,r/t)},Fx=e=>{let t=Bx(e);return t===0||t===1?e:ri(e,1/t)},nh=e=>typeof e=="number",eD=Ki(1,1),tD=Ki(1,2),rD=Ki(1,3),oD=Ki(1,4),nD=Ki(1,5),iD=Ki(1,6),aD=Ki(1,7)});var Td,Ya,Hx,zx,Gx,ih=j(()=>{"use strict";f();Xi();Td=(e,t,r)=>$i([0,r,e,t,0,0,0,0]),Ya=(e,t)=>$i(vd(t,e)),Hx=(e,t)=>Ox(e,t),zx=(e,t)=>Hx(Ya(e,t),t),Gx=e=>Math.sign(e[1])});var Zi,ji,Wx,Vx,ah,oi,Yx=j(()=>{"use strict";f();Xi();ih();Xi();Zi=([e,t])=>[0,0,0,0,t,e,1,0],ji=e=>[e[5],e[4]],Wx=e=>[0,0,0,0,Math.abs(e[4]),Math.abs(e[5]),1,0],Vx=(e,t)=>$i(th(e,t)),ah=(e,t)=>oh(vd(e,t)),oi=(e,t)=>rh(e,t)});var lh,Kx,sh=j(()=>{"use strict";f();Xi();lh=e=>[0,0,0,0,e[4],e[5],0,0],Kx=(e,t)=>Fx([0,0,0,0,t[4]-e[4],t[5]-e[5],0,0])});var ch,Xx,Zx,jx,To,qx=j(()=>{"use strict";f();Xi();sh();ch=(e,t)=>Nx(ri(e,Math.sin(t/2)),Math.cos(t/2)),Xx=e=>[1,0,0,0,-(.5*e[5]),.5*e[4],0,0],Zx=(e,t)=>{let r=.5*t;return[1,0,0,0,r*e[4],r*e[5],0,0]},jx=(e,t)=>ri(t,e),To=(e,t)=>$i(ri(ri(e,t),Va(e)))});var Ka,qS,As,$a,JS,Jx,QS,Pr,eI,dh,tI,Qx,rI,Sd,mh,oI,nI,ph,e0,uh,t0,iI,r0,o0,hh=j(()=>{"use strict";f();Rt();Ka=1e-4,qS=e=>{let t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},As=e=>qS(e)?e:[...e,e[0]],$a=e=>e*180/Math.PI,JS=e=>e/180*Math.PI,Jx=(e,t)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)],QS=e=>e[0]===0&&e[1]===0,Pr=(e,t,r)=>{let o=JS(t);return!r||QS(r)?Jx(e,o):Jx(e.map((n,i)=>n-r[i]),o).map((n,i)=>n+r[i])},eI=e=>[-e[0],-e[1]],dh=(e,t)=>[e[0]+t[0],e[1]+t[1]],tI=(e,t)=>xt(...e,...t),Qx=(e,t,r)=>{let o=dh(e,eI(t));return Pr(o,-$a(r))},rI=(e,t)=>{let[r,o]=e,[[n,i],[a,l]]=t,s=r-n,c=o-i,d=a-n,m=l-i,p=s*d+c*m,u=d*d+m*m,h=-1;u!==0&&(h=p/u);let x,E;h<0?(x=n,E=i):h>1?(x=a,E=l):(x=n+h*d,E=i+h*m);let v=r-x,w=o-E;return Math.sqrt(v*v+w*w)},Sd=(e,t,r=Ka)=>{let o=rI(e,t);return o===0?!0:o<r},mh=(e,t,r=Ka)=>t.some(o=>Sd(e,o,r)),oI=e=>{let[t,r,o,n]=e;return(i,a)=>Math.pow(1-i,3)*n[a]+3*i*Math.pow(1-i,2)*o[a]+3*Math.pow(i,2)*(1-i)*r[a]+t[a]*Math.pow(i,3)},nI=(e,t=10)=>{let r=oI(e),o=[r(0,0),r(0,1)],n=[],i=0,a=1/t;for(let l=0;l<t;l++)if(i+=a,i<=1){let s=[r(i,0),r(i,1)];n.push([o,s]),o=s}return n},ph=(e,t,r=Ka)=>mh(e,nI(t),r),e0=(e,t,r=Ka)=>t.some(o=>ph(e,o,r)),uh=(e,t)=>{let r=e[0],o=e[1],n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){let l=t[i][0],s=t[i][1],c=t[a][0],d=t[a][1];(s>o&&d<=o||s<=o&&d>o)&&r<(c-l)*(o-s)/(d-s)+l&&(n=!n)}return n},t0=(e,t,r=Ka)=>{let o=!1,n=As(t);for(let i=0,a=n.length-1;i<a;i++)if(Sd(e,[n[i],n[i+1]],r)){o=!0;break}return o},iI=(e,t)=>{let{angle:r,halfWidth:o,halfHeight:n,center:i}=t,a=o,l=n,[s,c]=Qx(e,i,r),d=Math.abs(s),m=Math.abs(c),p=.707,u=.707;for(let E=0;E<3;E++){let v=a*p,w=l*u,y=(a*a-l*l)*p**3/a,I=(l*l-a*a)*u**3/l,P=v-y,C=w-I,_=d-y,D=m-I,H=Math.hypot(C,P),A=Math.hypot(D,_);p=Math.min(1,Math.max(0,(_*H/A+y)/a)),u=Math.min(1,Math.max(0,(D*H/A+I)/l));let M=Math.hypot(u,p);p/=M,u/=M}let[h,x]=[a*p*Math.sign(s),l*u*Math.sign(c)];return tI([s,c],[h,x])},r0=(e,t,r=Ka)=>iI(e,t)<=r,o0=(e,t)=>{let{center:r,angle:o,halfWidth:n,halfHeight:i}=t,[a,l]=Qx(e,r,o);return a/n*(a/n)+l/i*(l/i)<=1}});var Ms,Xa,Id=j(()=>{"use strict";f();hh();Ms=(e,t,r=0)=>{switch(t.type){case"polygon":return t0(e,t.data,r);case"ellipse":return r0(e,t.data,r);case"line":return Sd(e,t.data,r);case"polyline":return mh(e,t.data,r);case"curve":return ph(e,t.data,r);case"polycurve":return e0(e,t.data,r);default:throw Error(`shape ${t} is not implemented`)}},Xa=(e,t)=>{switch(t.type){case"polygon":return uh(e,t.data);case"line":return!1;case"curve":return!1;case"ellipse":return o0(e,t.data);case"polyline":{let r=As(t.data.flat());return uh(e,r)}case"polycurve":return!1;default:throw Error(`shape ${t} is not implemented`)}}});var he,S,Za,Cd,ja,qi,ue=j(()=>{"use strict";f();G();he={EQUAL:"Equal",MINUS:"Minus",NUM_ADD:"NumpadAdd",NUM_SUBTRACT:"NumpadSubtract",NUM_ZERO:"Numpad0",BRACKET_RIGHT:"BracketRight",BRACKET_LEFT:"BracketLeft",ONE:"Digit1",TWO:"Digit2",THREE:"Digit3",NINE:"Digit9",QUOTE:"Quote",ZERO:"Digit0",SLASH:"Slash",C:"KeyC",D:"KeyD",H:"KeyH",V:"KeyV",Z:"KeyZ",R:"KeyR",S:"KeyS"},S={ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",BACKSPACE:"Backspace",ALT:"Alt",CTRL_OR_CMD:rr?"metaKey":"ctrlKey",DELETE:"Delete",ENTER:"Enter",ESCAPE:"Escape",QUESTION_MARK:"?",SPACE:" ",TAB:"Tab",CHEVRON_LEFT:"<",CHEVRON_RIGHT:">",PERIOD:".",COMMA:",",SUBTRACT:"-",SLASH:"/",A:"a",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",L:"l",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",V:"v",X:"x",Y:"y",Z:"z",K:"k",W:"w",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9"},Za=e=>e===S.ARROW_LEFT||e===S.ARROW_RIGHT||e===S.ARROW_DOWN||e===S.ARROW_UP,Cd=e=>e.altKey,ja=e=>e.shiftKey,qi=e=>e.shiftKey});var d0,Uo,m0,xn,n0,Ls,aI,Ps,qa,gh,fh,_s,lI,Wo,sI,So,cI,dI,i0,a0,p0,mI,kd,u0,h0,l0,Ad,s0,Ja,c0,pI,g0,Ds,uI,hI,gI,fI,bI,bh,xh,Eh,xI,EI,yI,wI,f0,vI,TI,SI,II,CI,kI,Jr=j(()=>{"use strict";f();Xi();Yx();sh();ih();qx();at();Id();Ve();ce();We();Jn();Qt();z();ue();ut();d0=e=>!e[S.CTRL_OR_CMD],Uo=e=>e.isBindingEnabled,m0=(e,t)=>{let r=[];return t.forEach(o=>{let n=e.getNonDeletedElement(o);n!=null&&r.push(n)}),r},xn=(e,t,r,o)=>{let n=new Set,i=new Set;n0(e,t,r,"start",n,i,o),n0(e,r,t,"end",n,i,o);let a=Array.from(i).filter(l=>!n.has(l));m0(pt.getScene(e),a).forEach(l=>{F(l,{boundElements:l.boundElements?.filter(s=>s.type!=="arrow"||s.id!==e.id)})})},n0=(e,t,r,o,n,i,a)=>{if(t!=="keep")if(t!=null)(r==null||(r==="keep"?!gh(e,t,o):o==="start"||r.id!==t.id))&&(qa(e,t,o,a),n.add(t.id));else{let l=lI(e,o);l!=null&&i.add(l)}},Ls=(e,t)=>{e.forEach(r=>{Tt(r)?xn(r,kd(r,"start",t),kd(r,"end",t),t.scene.getNonDeletedElementsMap()):Ua(r)&&aI(r,t.scene.getNonDeletedElementsMap(),t)})},aI=(e,t,r)=>{h0(e,r).forEach(([o,n])=>xn(o,n==="end"?"keep":e,n==="start"?"keep":e,t))},Ps=(e,t,r,o)=>{t.startBoundElement!=null&&qa(e,t.startBoundElement,"start",o.scene.getNonDeletedElementsMap());let n=Wo(r,o);n!=null&&!gh(e,n,"end")&&qa(e,n,"end",o.scene.getNonDeletedElementsMap())},qa=(e,t,r,o)=>{F(e,{[r==="start"?"startBinding":"endBinding"]:{elementId:t.id,...sI(e,t,r,o)}}),$(t.boundElements||[]).has(e.id)||F(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},gh=(e,t,r)=>{let o=e[r==="start"?"endBinding":"startBinding"];return fh(e,o?.elementId,t)},fh=(e,t,r)=>t===r.id&&e.points.length<3,_s=(e,t)=>{e.forEach(r=>{Tt(r)&&xn(r,null,null,t)})},lI=(e,t)=>{let r=t==="start"?"startBinding":"endBinding",o=e[r];return o==null?null:(F(e,{[r]:null}),o.elementId)},Wo=(e,t)=>ju(t.scene.getNonDeletedElements(),o=>Ua(o,!1)&&g0(o,e,t)),sI=(e,t,r,o)=>{let n=r==="start"?-1:1,i=n===-1?0:e.points.length-1,a=i-n,l=K.getPointAtIndexGlobalCoordinates(e,i,o),s=K.getPointAtIndexGlobalCoordinates(e,a,o);return{focus:xI(t,s,l,o),gap:Math.max(1,uI(t,l,o))}},So=(e,t,r)=>{let o=(e.boundElements??[]).filter(s=>s.type==="arrow");if(o.length===0)return;let{newSize:n,simultaneouslyUpdated:i}=r??{},a=dI(i),l=pt.getScene(e);m0(l,o.map(s=>s.id)).forEach(s=>{if(!re(s))return;let c=e;if(!cI(s,c))return;let d=a0(c,s.startBinding,n),m=a0(c,s.endBinding,n);if(a.has(s.id)){F(s,{startBinding:d,endBinding:m});return}i0(s,"start",d,e,t),i0(s,"end",m,e,t),pe(s,l.getNonDeletedElementsMap())&&Ji(s,l.getNonDeletedElementsMap(),!1)})},cI=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,dI=e=>new Set((e||[]).map(t=>t.id)),i0=(e,t,r,o,n)=>{if(r==null||r.elementId!==o.id&&e.points.length>2)return;let i=pt.getScene(e).getElement(r.elementId);if(i==null)return;let a=t==="start"?-1:1,l=a===-1?0:e.points.length-1,s=l-a,c=K.getPointAtIndexGlobalCoordinates(e,s,n),d=EI(i,r.focus,c,n),m;if(r.gap===0)m=d;else{let p=yI(i,c,d,r.gap,n);p.length===0?m=d:m=p[0]}K.movePoints(e,[{index:l,point:K.pointFromAbsoluteCoords(e,m,n)}],{[t==="start"?"startBinding":"endBinding"]:r})},a0=(e,t,r)=>{if(t==null||r==null)return t;let{gap:o,focus:n,elementId:i}=t,{width:a,height:l}=r,{width:s,height:c}=e,d=Math.max(1,Math.min(Ds(e,a,l),o*(a<l?a/s:l/c)));return{elementId:i,gap:d,focus:n}},p0=(e,t)=>{let r=new Set(e.map(({id:o})=>o));return e.flatMap(o=>Tt(o,!1)?mI(o,t).filter(n=>!r.has(n.id)):Ua(o,!1)?h0(o,t).filter(n=>!r.has(n[0].id)):[])},mI=(e,t)=>[kd(e,"start",t),kd(e,"end",t)].filter(r=>r!=null),kd=(e,t,r)=>Wo(u0(e,t,r.scene.getNonDeletedElementsMap()),r),u0=(e,t,r)=>{let o=t==="start"?0:-1;return bo(K.getPointAtIndexGlobalCoordinates(e,o,r))},h0=(e,t)=>{let r=pt.getScene(e);return r.getNonDeletedElements().map(o=>{if(!Tt(o,!1))return null;let n=l0(o,"start",e,r.getNonDeletedElementsMap(),t),i=l0(o,"end",e,r.getNonDeletedElementsMap(),t);return!n&&!i?null:[o,n&&i?"both":n?"start":"end",e]}).filter(o=>o!=null)},l0=(e,t,r,o,n)=>e[t==="start"?"startBinding":"endBinding"]==null&&!gh(e,r,t)&&g0(r,u0(e,t,o),n),Ad=(e,t,r,o)=>{let n=new Set,i=new Set,a=o==="duplicatesServeAsOld";t.forEach(l=>{let{boundElements:s}=l;if(s!=null&&s.length>0&&(s.forEach(c=>{a&&!r.has(c.id)&&n.add(c.id)}),i.add(r.get(l.id))),Tt(l)){if(l.startBinding!=null){let{elementId:c}=l.startBinding;a&&!r.has(c)&&i.add(c)}if(l.endBinding!=null){let{elementId:c}=l.endBinding;a&&!r.has(c)&&i.add(c)}(l.startBinding!=null||l.endBinding!=null)&&n.add(r.get(l.id))}}),e.filter(({id:l})=>n.has(l)).forEach(l=>{let{startBinding:s,endBinding:c}=l;F(l,{startBinding:s0(s,r),endBinding:s0(c,r)})}),e.filter(({id:l})=>i.has(l)).forEach(l=>{let{boundElements:s}=l;s!=null&&s.length>0&&F(l,{boundElements:s.map(c=>r.has(c.id)?{id:r.get(c.id),type:c.type}:c)})})},s0=(e,t)=>{if(e==null)return null;let{elementId:r,focus:o,gap:n}=e;return{focus:o,gap:n,elementId:t.get(r)??r}},Ja=(e,t)=>{let r=new Set(t.map(n=>n.id)),o=new Set;t.forEach(n=>{Ua(n)?n.boundElements?.forEach(i=>{r.has(i.id)||o.add(i.id)}):Tt(n)&&(n.startBinding&&o.add(n.startBinding.elementId),n.endBinding&&o.add(n.endBinding.elementId))}),e.filter(({id:n})=>o.has(n)).forEach(n=>{Ua(n)?F(n,{boundElements:pI(n.boundElements,r)}):Tt(n)&&F(n,{startBinding:c0(n.startBinding,r),endBinding:c0(n.endBinding,r)})})},c0=(e,t)=>e==null||t.has(e.elementId)?null:e,pI=(e,t)=>e?e.filter(r=>!t.has(r.id)):null,g0=(e,{x:t,y:r},o)=>{let n=Ds(e,e.width,e.height),i=o.getElementShape(e);return Ms([t,r],i,n)},Ds=(e,t,r)=>{let n=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,r);return Math.max(16,Math.min(.25*n,32))},uI=(e,t,r)=>{switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return hI(e,t,r);case"diamond":return gI(e,t,r);case"ellipse":return fI(e,t,r)}},hI=(e,t,r)=>{let[,o,n,i]=bh(e,t,r);return Math.max(oi(o,Td(0,1,-i)),oi(o,Td(1,0,-n)))},gI=(e,t,r)=>{let[,o,n,i]=bh(e,t,r),a=Td(i,n,-i*n);return oi(o,a)},fI=(e,t,r)=>{let[o,n]=bI(e,t,r);return-Gx(n)*oi(o,n)},bI=(e,t,r)=>{let[,o,n,i]=bh(e,t,r),[a,l]=ji(o),s=.707,c=.707,d=n,m=i;[0,1,2,3].forEach(h=>{let x=d*s,E=m*c,v=(d*d-m*m)*s**3/d,w=(m*m-d*d)*c**3/m,y=x-v,I=E-w,P=a-v,C=l-w,_=Math.hypot(I,y),D=Math.hypot(C,P);s=Math.min(1,Math.max(0,(P*_/D+v)/d)),c=Math.min(1,Math.max(0,(C*_/D+w)/m));let H=Math.hypot(c,s);s/=H,c/=H});let p=Jt(d*s,m*c),u=zx(o,p);return[o,u]},bh=(e,t,r)=>{let o=Zi(t),[n,i,a,l]=te(e,r),s=Eh(n,i,a,l),c=ch(s,e.angle),d=To(c,o),m=eh(d,lh(s)),p=Wx(m),u=Rx(e.x,e.y),h=eh(d,u),x=(a-n)/2,E=(l-i)/2;return[h,p,x,E]},xh=(e,t)=>{let[r,o,n,i]=te(e,t),a=Eh(r,o,n,i),l=ch(a,e.angle),s=Va(Xx(lh(a)));return jx(l,s)},Eh=(e,t,r,o)=>Jt((e+r)/2,(t+o)/2),xI=(e,t,r,o)=>{let n=xh(e,o),i=To(n,Zi(t)),a=To(n,Zi(r)),l=Ya(i,a),s=e.height/e.width,c=e.width/2,d=e.height/2,m=l[2],p=l[3],u=l[1],h=Math.abs(p),x=Math.abs(m),E;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":E=u/(c*(x+s*h));break;case"diamond":E=h<x?u/(x*c):u/(h*d);break;case"ellipse":E=u/(c*Math.sqrt(m**2+s**2*p**2));break}return E||0},EI=(e,t,r,o)=>{if(t===0){let[s,c,d,m]=te(e,o),p=Eh(s,c,d,m);return ji(p)}let n=xh(e,o),i=To(n,Zi(r)),a=Va(n),l;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":l=kI(e,t,i);break;case"ellipse":l=CI(e,t,i);break}return ji(To(a,l))},yI=(e,t,r,o=0,n)=>{let i=xh(e,n),a=To(i,Zi(t)),l=To(i,Zi(r)),s=Ya(a,l),c=Va(i);return wI(e,s,a,o).map(m=>ji(To(c,m)))},wI=(e,t,r,o=0)=>{let n;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":let a=f0(e);n=a.flatMap((l,s)=>{let c=[l,a[(s+1)%4]];return vI(t,TI(c,o))}).concat(a.flatMap(l=>II(l,o,t)));break;case"ellipse":n=SI(e,o,t);break}if(n.length<2)return[];let i=n.sort((a,l)=>ah(a,r)-ah(l,r));return[i[0],i[i.length-1]]},f0=(e,t=1)=>{let r=t*e.width/2,o=t*e.height/2;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return[Jt(r,o),Jt(r,-o),Jt(-r,-o),Jt(-r,o)];case"diamond":return[Jt(0,o),Jt(r,0),Jt(0,-o),Jt(-r,0)]}},vI=(e,t)=>{let[r,o]=t,n=oi(r,e),i=oi(o,e);return n*i>=0?[]:[Vx(e,Ya(r,o))]},TI=(e,t)=>{let[r,o]=e,n=Zx(Kx(r,o),t);return[To(n,r),To(n,o)]},SI=(e,t,r)=>{let o=e.width/2+t,n=e.height/2+t,i=r[2],a=r[3],l=r[1],s=o*o*i*i+n*n*a*a,c=s-l*l;if(s===0||c<=0)return[];let d=Math.sqrt(c),m=-o*o*i*l,p=-n*n*a*l;return[Jt((m+o*n*a*d)/s,(p-o*n*i*d)/s),Jt((m-o*n*a*d)/s,(p+o*n*i*d)/s)]},II=(e,t,r)=>{if(t===0)return oi(r,e)===0?[e]:[];let o=r[2],n=r[3],i=r[1],[a,l]=ji(e),s=t,c=o*o+n*n,d=s*s*c-(o*a+n*l+i)**2;if(c===0||d<=0)return[];let m=Math.sqrt(d),p=a*n*n-l*o*n-o*i,u=l*o*o-a*o*n-n*i;return[Jt((p+n*m)/c,(u-o*m)/c),Jt((p-n*m)/c,(u+o*m)/c)]},CI=(e,t,r)=>{let o=Math.abs(t),n=e.width*o/2,i=e.height*o/2,a=Math.sign(t),[l,s]=ji(r),c=s===0?1e-4:s,d=l**2*i**2+c**2*n**2,m=(-l*i**2+a*c*Math.sqrt(Math.max(0,d-n**2*i**2)))/d,p=(-m*l-1)/c;p===0&&(p=(Object.is(p,-0)?-1:1)*.01);let u=-(n**2*m)/(p**2*i**2+m**2*n**2);return Jt(u,(-m*u-1)/p)},kI=(e,t,r)=>{let o=Math.abs(t),n=Math.sign(t),i=f0(e,o),a=0,l=null;return i.forEach(s=>{let c=n*Ya(r,s)[1];c>a&&(a=c,l=s)}),l}});var En,K,AI,Qt=j(()=>{"use strict";f();Rt();ge();at();We();Jr();z();ce();ue();ut();G();Go();En={version:null,points:[],zoom:null},K=class e{elementId;selectedPointsIndices;pointerDownState;isDragging;lastUncommittedPoint;pointerOffset;startBindingElement;endBindingElement;hoverPointIndex;segmentMidPointHoveredCoords;constructor(t){this.elementId=t.id,e.normalizePoints(t),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null}static POINT_HANDLE_SIZE=10;static getElement(t,r){let o=r.get(t);return o||null}static handleBoxSelection(t,r,o,n){if(!r.editingLinearElement||r.draggingElement?.type!=="selection")return!1;let{editingLinearElement:i}=r,{selectedPointsIndices:a,elementId:l}=i,s=e.getElement(l,n);if(!s)return!1;let[c,d,m,p]=te(r.draggingElement,n),h=e.getPointsGlobalCoordinates(s,n).reduce((x,E,v)=>((E[0]>=c&&E[0]<=m&&E[1]>=d&&E[1]<=p||t.shiftKey&&a?.includes(v))&&x.push(v),x),[]);o({editingLinearElement:{...i,selectedPointsIndices:h.length?h:null}})}static handlePointDragging(t,r,o,n,i,a,l){if(!a)return!1;let{selectedPointsIndices:s,elementId:c}=a,d=e.getElement(c,l);if(!d)return!1;let m=d.points[a.pointerDownState.lastClickedPoint];if(s&&m){if(qi(t)&&s.length===1&&d.points.length>1){let u=s[0],h=d.points[u===0?1:u-1],[x,E]=e._getShiftLockedDelta(d,l,h,[o,n],t[S.CTRL_OR_CMD]?null:r.gridSize);e.movePoints(d,[{index:u,point:[x+h[0],E+h[1]],isDragging:u===a.pointerDownState.lastClickedPoint}])}else{let u=e.createPointAt(d,l,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize),h=u[0]-m[0],x=u[1]-m[1];e.movePoints(d,s.map(E=>{let v=E===a.pointerDownState.lastClickedPoint?e.createPointAt(d,l,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize):[d.points[E][0]+h,d.points[E][1]+x];return{index:E,point:v,isDragging:E===a.pointerDownState.lastClickedPoint}}))}if(pe(d,l)&&Ji(d,l,!1),Tt(d,!1)){let u=[];s[0]===0&&u.push(bo(e.getPointGlobalCoordinates(d,d.points[0],l)));let x=s[s.length-1];x===d.points.length-1&&u.push(bo(e.getPointGlobalCoordinates(d,d.points[x],l))),u.length&&i(d,u)}return!0}return!1}static handlePointerUp(t,r,o,n){let i=n.scene.getNonDeletedElementsMap(),{elementId:a,selectedPointsIndices:l,isDragging:s,pointerDownState:c}=r,d=e.getElement(a,i);if(!d)return r;let m={};if(s&&l){for(let p of l)if(p===0||p===d.points.length-1){ir(d.points,o.zoom.value)&&e.movePoints(d,[{index:p,point:p===0?d.points[d.points.length-1]:d.points[0]}]);let u=Uo(o)?Wo(bo(e.getPointAtIndexGlobalCoordinates(d,p,i)),n):null;m[p===0?"startBindingElement":"endBindingElement"]=u}}return{...r,...m,selectedPointsIndices:s||t.shiftKey?!s&&t.shiftKey&&c.prevSelectedPointsIndices?.includes(c.lastClickedPoint)?l&&l.filter(p=>p!==c.lastClickedPoint):l:l?.includes(c.lastClickedPoint)?[c.lastClickedPoint]:l,isDragging:!1,pointerOffset:{x:0,y:0}}}static getEditorMidPoints=(t,r,o)=>{let n=pe(t,r);return!o.editingLinearElement&&t.points.length>2&&!n?[]:(En.version===t.version&&En.zoom===o.zoom.value||e.updateEditorMidPointsCache(t,r,o),En.points)};static updateEditorMidPointsCache=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,r),i=0,a=[];for(;i<n.length-1;){if(e.isSegmentTooShort(t,t.points[i],t.points[i+1],o.zoom)){a.push(null),i++;continue}let l=e.getSegmentMidPoint(t,n[i],n[i+1],i+1,r);a.push(l),i++}En.points=a,En.version=t.version,En.zoom=o.zoom.value};static getSegmentMidpointHitCoords=(t,r,o,n)=>{let{elementId:i}=t,a=e.getElement(i,n);if(!a||e.getPointIndexUnderCursor(a,n,o.zoom,r.x,r.y)>=0||e.getPointsGlobalCoordinates(a,n).length>=3&&!o.editingLinearElement)return null;let c=e.POINT_HANDLE_SIZE/o.zoom.value,d=t.segmentMidPointHoveredCoords;if(d&&xt(d[0],d[1],r.x,r.y)<=c)return d;let m=0,p=e.getEditorMidPoints(a,n,o);for(;m<p.length;){if(p[m]!==null&&xt(p[m][0],p[m][1],r.x,r.y)<=c)return p[m];m++}return null};static isSegmentTooShort(t,r,o,n){let i=xt(r[0],r[1],o[0],o[1]);return t.points.length>2&&t.roundness&&(i=Cx(t,o)),i*n.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,r,o,n,i){let a=ws(r,o);if(t.points.length>2&&t.roundness){let l=$u(t,t.points[n]);if(l){let s=kx(t,t.points[n],.5),[c,d]=Xu(l[0],l[1],l[2],l[3],s);a=e.getPointGlobalCoordinates(t,[c,d],i)}}return a}static getSegmentMidPointIndex(t,r,o,n){let i=e.getElement(t.elementId,n);if(!i)return-1;let a=e.getEditorMidPoints(i,n,r),l=0;for(;l<a.length;){if(e.arePointsEqual(o,a[l]))return l+1;l++}return-1}static handlePointerDown(t,r,o,n,i,a){let l=a.scene.getNonDeletedElementsMap(),s={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!i)return s;let{elementId:c}=i,d=e.getElement(c,l);if(!d)return s;let m=e.getSegmentMidpointHitCoords(i,n,r,l),p=null;if(m&&(p=e.getSegmentMidPointIndex(i,r,m,l)),t.altKey&&r.editingLinearElement)return i.lastUncommittedPoint==null&&(F(d,{points:[...d.points,e.createPointAt(d,l,n.x,n.y,t[S.CTRL_OR_CMD]?null:r.gridSize)]}),s.didAddPoint=!0),o.resumeRecording(),s.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:-1,origin:{x:n.x,y:n.y},segmentMidpoint:{value:m,index:p,added:!1}},selectedPointsIndices:[d.points.length-1],lastUncommittedPoint:null,endBindingElement:Wo(n,a)},s.didAddPoint=!0,s;let u=e.getPointIndexUnderCursor(d,l,r.zoom,n.x,n.y);if(u>=0||m)s.hitElement=d;else{let{startBindingElement:C,endBindingElement:_}=i;Uo(r)&&Tt(d)&&xn(d,C,_,l)}let[h,x,E,v]=te(d,l),w=(h+E)/2,y=(x+v)/2,I=u>-1&&Ee(d.x+d.points[u][0],d.y+d.points[u][1],w,y,d.angle),P=u>-1||t.shiftKey?t.shiftKey||i.selectedPointsIndices?.includes(u)?AI([...i.selectedPointsIndices||[],u]):[u]:null;return s.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:u,origin:{x:n.x,y:n.y},segmentMidpoint:{value:m,index:p,added:!1}},selectedPointsIndices:P,pointerOffset:I?{x:n.x-I[0],y:n.y-I[1]}:{x:0,y:0}},s}static arePointsEqual(t,r){return!t&&!r?!0:!t||!r?!1:Zu(t,r)}static handlePointerMove(t,r,o,n,i){if(!n.editingLinearElement)return null;let{elementId:a,lastUncommittedPoint:l}=n.editingLinearElement,s=e.getElement(a,i);if(!s)return n.editingLinearElement;let{points:c}=s,d=c[c.length-1];if(!t.altKey)return d===l&&e.deletePoints(s,[c.length-1]),{...n.editingLinearElement,lastUncommittedPoint:null};let m;if(qi(t)&&c.length>=2){let p=c[c.length-2],[u,h]=e._getShiftLockedDelta(s,i,p,[r,o],t[S.CTRL_OR_CMD]?null:n.gridSize);m=[u+p[0],h+p[1]]}else m=e.createPointAt(s,i,r-n.editingLinearElement.pointerOffset.x,o-n.editingLinearElement.pointerOffset.y,t[S.CTRL_OR_CMD]?null:n.gridSize);return d===l?e.movePoints(s,[{index:s.points.length-1,point:m}]):e.addPoints(s,n,[{point:m}]),{...n.editingLinearElement,lastUncommittedPoint:s.points[s.points.length-1]}}static getPointGlobalCoordinates(t,r,o){let[n,i,a,l]=te(t,o),s=(n+a)/2,c=(i+l)/2,{x:d,y:m}=t;return[d,m]=Ee(d+r[0],m+r[1],s,c,t.angle),[d,m]}static getPointsGlobalCoordinates(t,r){let[o,n,i,a]=te(t,r),l=(o+i)/2,s=(n+a)/2;return t.points.map(c=>{let{x:d,y:m}=t;return[d,m]=Ee(d+c[0],m+c[1],l,s,t.angle),[d,m]})}static getPointAtIndexGlobalCoordinates(t,r,o){let n=r<0?t.points.length+r:r,[i,a,l,s]=te(t,o),c=(i+l)/2,d=(a+s)/2,m=t.points[n],{x:p,y:u}=t;return m?Ee(p+m[0],u+m[1],c,d,t.angle):Ee(p,u,c,d,t.angle)}static pointFromAbsoluteCoords(t,r,o){let[n,i,a,l]=te(t,o),s=(n+a)/2,c=(i+l)/2,[d,m]=Ee(r[0],r[1],s,c,-t.angle);return[d-t.x,m-t.y]}static getPointIndexUnderCursor(t,r,o,n,i){let a=e.getPointsGlobalCoordinates(t,r),l=a.length;for(;--l>-1;){let s=a[l];if(xt(n,i,s[0],s[1])*o.value<e.POINT_HANDLE_SIZE+1)return l}return-1}static createPointAt(t,r,o,n,i){let a=St(o,n,i),[l,s,c,d]=te(t,r),m=(l+c)/2,p=(s+d)/2,[u,h]=Ee(a[0],a[1],m,p,-t.angle);return[u-t.x,h-t.y]}static getNormalizedPoints(t){let{points:r}=t,o=r[0][0],n=r[0][1];return{points:r.map((i,a)=>[i[0]-o,i[1]-n]),x:t.x+o,y:t.y+n}}static normalizePoints(t){F(t,e.getNormalizedPoints(t))}static duplicateSelectedPoints(t,r){if(!t.editingLinearElement)return!1;let{selectedPointsIndices:o,elementId:n}=t.editingLinearElement,i=e.getElement(n,r);if(!i||o===null)return!1;let{points:a}=i,l=[],s=!1,c=-1,d=a.reduce((m,p,u)=>{if(++c,m.push(p),o.includes(u)){let x=a[u+1];x||(s=!0),m.push(x?[(p[0]+x[0])/2,(p[1]+x[1])/2]:[p[0],p[1]]),l.push(c+1),++c}return m},[]);if(F(i,{points:d}),s){let m=i.points[i.points.length-1];e.movePoints(i,[{index:i.points.length-1,point:[m[0]+30,m[1]+30]}])}return{appState:{...t,editingLinearElement:{...t.editingLinearElement,selectedPointsIndices:l}}}}static deletePoints(t,r){let o=0,n=0;if(r.includes(0)){let l=t.points.find((s,c)=>!r.includes(c));l&&(o=l[0],n=l[1])}let a=t.points.reduce((l,s,c)=>(r.includes(c)||l.push(l.length?[s[0]-o,s[1]-n]:[0,0]),l),[]);e._updatePoints(t,a,o,n)}static addPoints(t,r,o){let a=[...t.points,...o.map(l=>l.point)];e._updatePoints(t,a,0,0)}static movePoints(t,r,o){let{points:n}=t,i=0,a=0,l=r.find(({index:c})=>c===0);l&&(i=l.point[0]+n[l.index][0],a=l.point[1]+n[l.index][1]);let s=n.map((c,d)=>{let m=r.find(p=>p.index===d);if(m){if(l)return c;let p=m.point[0]-n[m.index][0],u=m.point[1]-n[m.index][1];return[c[0]+p,c[1]+u]}return i||a?[c[0]-i,c[1]-a]:c});e._updatePoints(t,s,i,a,o)}static shouldAddMidpoint(t,r,o,n){if(!e.getElement(t.elementId,n))return!1;let{segmentMidpoint:a}=t.pointerDownState;if(a.added||a.value===null||a.index===null||t.pointerDownState.origin===null)return!1;let l=t.pointerDownState.origin,s=xt(l.x,l.y,r.x,r.y);return!(!o.editingLinearElement&&s<pn/o.zoom.value)}static addMidpoint(t,r,o,n,i){let a=e.getElement(t.elementId,i);if(!a)return;let{segmentMidpoint:l}=t.pointerDownState,s={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,i,r.x,r.y,n?o.gridSize:null),d=[...a.points.slice(0,l.index),c,...a.points.slice(l.index)];return F(a,{points:d}),s.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:l.index},s.selectedPointsIndices=[l.index],s}static _updatePoints(t,r,o,n,i){let a=Qa(t,r),l=Qa(t,t.points),s=(a[0]+a[2])/2,c=(a[1]+a[3])/2,d=(l[0]+l[2])/2,m=(l[1]+l[3])/2,p=d-s,u=m-c,h=Ee(o,n,p,u,t.angle);F(t,{...i,points:r,x:t.x+h[0],y:t.y+h[1]})}static _getShiftLockedDelta(t,r,o,n,i){let a=e.getPointGlobalCoordinates(t,o,r),[l,s]=St(n[0],n[1],i),{width:c,height:d}=el(a[0],a[1],l,s);return Ze([c,d],[0,0],-t.angle)}static getBoundTextElementPosition=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,o);n.length<2&&F(r,{isDeleted:!0});let i=0,a=0;if(t.points.length%2===1){let l=Math.floor(t.points.length/2),s=e.getPointGlobalCoordinates(t,t.points[l],o);i=s[0]-r.width/2,a=s[1]-r.height/2}else{let l=t.points.length/2-1,s=En.points[l];t.points.length===2&&(s=ws(n[0],n[1])),(!s||En.version!==t.version)&&(s=e.getSegmentMidPoint(t,n[l],n[l+1],l+1,o)),i=s[0]-r.width/2,a=s[1]-r.height/2}return{x:i,y:a}};static getMinMaxXYWithBoundText=(t,r,o,n)=>{let[i,a,l,s]=o,c=(i+l)/2,d=(a+s)/2,{x:m,y:p}=e.getBoundTextElementPosition(t,n,r),u=m+n.width,h=p+n.height,x=Ze([i,a],[c,d],t.angle),E=Ze([l,a],[c,d],t.angle),v=Ze([m,p],[c,d],-t.angle),w=Ze([u,p],[c,d],-t.angle),y=Ze([m,h],[c,d],-t.angle),I=Ze([u,h],[c,d],-t.angle);return x[0]<E[0]&&x[1]>=E[1]?(i=Math.min(i,y[0]),l=Math.max(l,Math.max(w[0],I[0])),a=Math.min(a,v[1]),s=Math.max(s,I[1])):x[0]>=E[0]&&x[1]>E[1]?(i=Math.min(i,I[0]),l=Math.max(l,Math.max(v[0],w[0])),a=Math.min(a,y[1]),s=Math.max(s,w[1])):x[0]>=E[0]?(i=Math.min(i,w[0]),l=Math.max(l,y[0]),a=Math.min(a,I[1]),s=Math.max(s,v[1])):x[1]<=E[1]&&(i=Math.min(i,Math.min(w[0],v[0])),l=Math.max(l,I[0]),a=Math.min(a,w[1]),s=Math.max(s,y[1])),[i,a,l,s,c,d]};static getElementAbsoluteCoords=(t,r,o=!1)=>{let n,i,a,l,s;if(t.points.length<2||!ke.get(t)){let{minX:p,minY:u,maxX:h,maxY:x}=t.points.reduce((E,[v,w])=>(E.minY=Math.min(E.minY,w),E.minX=Math.min(E.minX,v),E.maxX=Math.max(E.maxX,v),E.maxY=Math.max(E.maxY,w),E),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});i=p+t.x,a=u+t.y,l=h+t.x,s=x+t.y}else{let p=ke.generateElementShape(t,null),u=ti(p[0]),[h,x,E,v]=Rs(u);i=h+t.x,a=x+t.y,l=E+t.x,s=v+t.y}let c=(i+l)/2,d=(a+s)/2;if(n=[i,a,l,s,c,d],!o)return n;let m=pe(t,r);return m&&(n=e.getMinMaxXYWithBoundText(t,r,[i,a,l,s],m)),n}},AI=e=>{let t=[...new Set(e.filter(r=>r!==null&&r!==-1))];return t=t.sort((r,o)=>r-o),t.length?t:null}});var Qi,ea,Md,b0,Ld=j(()=>{"use strict";f();Qi={},ea=(e,t)=>{let r=Qi[e]||(Qi[e]={height:t});return r.height=t,r},Md=e=>{Qi[e]&&delete Qi[e]},b0=e=>Qi[e]?.height??null});var ni,vh,Yt,Pd,Ji,tl,Io,E0,ii,_d,Dd,yh,Ns,Os,MI,LI,ai,y0,w0,Rd,PI,wn,pe,lt,Nd,Th,v0,T0,S0,_I,I0,yn,fr,ta,C0,wh,x0,_r,ut=j(()=>{"use strict";f();z();We();G();ge();ce();Qt();Ld();ni=e=>hd(e).replace(/\t/g," "),vh=e=>ni(e).split(`
10
- `),Yt=(e,t,r)=>{let o,n={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height};n.text=e.text,t&&(o=fr(t,e),n.text=ai(e.originalText,Ge(e),o));let i=Io(n.text,Ge(e),e.lineHeight);if(n.width=i.width,n.height=i.height,t){let a=ta(t,e),l=fr(t,e);if(!Te(t)&&i.height>a){let m=yn(i.height,t.type);F(t,{height:m}),ea(t.id,m)}if(i.width>l){let m=yn(i.width,t.type);F(t,{width:m})}let s={...e,...n},{x:c,y:d}=tl(t,s,r);n.x=c,n.y=d}F(e,n)},Pd=(e,t,r)=>{let o=$(e);t.forEach(n=>{let i=r.get(n.id),a=wn(n);if(a){let l=r.get(a);if(l){let s=o.get(i);s&&F(s,{boundElements:(n.boundElements||[]).filter(d=>d.id!==l&&d.id!==a).concat({type:"text",id:l})});let c=o.get(l);c&&U(c)&&F(c,{containerId:s?i:null})}}})},Ji=(e,t,r,o=!1)=>{if(!wn(e))return;Md(e.id);let i=pe(e,t);if(i&&i.text){if(!e)return;let a=i.text,l=i.height,s=i.width,c=fr(e,i),d=ta(e,i),m=e.height;if(o||r!=="n"&&r!=="s"){a&&(a=ai(i.originalText,Ge(i),c));let p=Io(a,Ge(i),i.lineHeight);l=p.height,s=p.width}if(l>d){m=yn(l,e.type);let p=m-e.height,u=!Te(e)&&(r==="ne"||r==="nw"||r==="n")?e.y-p:e.y;F(e,{height:m,y:u})}F(i,{text:a,width:s,height:l}),Te(e)||F(i,tl(e,i,t))}},tl=(e,t,r)=>{if(Te(e))return K.getBoundTextElementPosition(e,t,r);let o=Th(e),n=ta(e,t),i=fr(e,t),a,l;return t.verticalAlign===ft.TOP?l=o.y:t.verticalAlign===ft.BOTTOM?l=o.y+(n-t.height):l=o.y+(n/2-t.height/2),t.textAlign===Kn.LEFT?a=o.x:t.textAlign===Kn.RIGHT?a=o.x+(i-t.width):a=o.x+(i/2-t.width/2),{x:a,y:l}},Io=(e,t,r)=>{e=e.split(`
9
+ C ${a} ${l}, ${a} ${l}, ${a+h} ${l+x}`,Lr(e,!0))}else i=t.polygon([[a,l],[s,c],[d,m],[p,u]],Lr(e));return i}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,Lr(e));case"line":case"arrow":{let i,a=Lr(e),l=e.points.length?e.points:[[0,0]];if(e.roundness?i=[t.curve(l,a)]:a.fill?i=[t.polygon(l,a)]:i=[t.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:c="arrow"}=e;if(s!==null){let d=Px(e,i,"start",s,t,a,o);i.push(...d)}if(c!==null){let d=Px(e,i,"end",c,t,a,o);i.push(...d)}}return i}case"freedraw":{let i;if(Rx(e),ir(e.points)){let a=XS(e.points,.75);i=t.curve(a,{...Lr(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return Zn(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}}});var Jt,Nx,Ki,Va,Ox,rh,ri,qS,oh,vd,nh,Bx,ih,Fx,$i,Hx,ah,tD,rD,oD,nD,iD,aD,lD,Xi=j(()=>{"use strict";f();Jt=(e,t)=>[0,0,0,0,t,e,1,0],Nx=(e,t)=>[0,0,0,0,t,e,0,0],Ki=(e=0,t=0)=>{let r=[0,0,0,0,0,0,0,0];if(t<0||t>7)throw new Error(`Expected \`index\` between 0 and 7, got \`${t}\``);return e!==0&&(r[t]=e),r},Va=e=>[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7]],Ox=(e,t)=>ah(t)?[e[0]+t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]+t[0],e[1]+t[1],e[2]+t[2],e[3]+t[3],e[4]+t[4],e[5]+t[5],e[6]+t[6],e[7]+t[7]],rh=(e,t)=>ah(t)?[e[0]-t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3],e[4]-t[4],e[5]-t[5],e[6]-t[6],e[7]-t[7]],ri=(e,t)=>ah(t)?[e[0]*t,e[1]*t,e[2]*t,e[3]*t,e[4]*t,e[5]*t,e[6]*t,e[7]*t]:[qS(e,t),t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[7]*e[3]+t[0]*e[4]+t[6]*e[5]-t[5]*e[6]+t[3]*e[7],t[5]*e[0]-t[3]*e[1]+t[7]*e[2]+t[1]*e[3]-t[6]*e[4]+t[0]*e[5]+t[4]*e[6]+t[2]*e[7],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]+t[0]*e[7]],qS=(e,t)=>t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],oh=(e,t)=>[t[0]*e[0],t[1]*e[0]+t[0]*e[1],t[2]*e[0]+t[0]*e[2],t[3]*e[0]+t[0]*e[3],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[0]*e[4],t[5]*e[0]-t[3]*e[1]+t[1]*e[3]+t[0]*e[5],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]],vd=(e,t)=>[nh(e,t),e[1]*t[7]+e[4]*t[5]-e[5]*t[4]+e[7]*t[1],e[2]*t[7]-e[4]*t[6]+e[6]*t[4]+e[7]*t[2],e[3]*t[7]+e[5]*t[6]-e[6]*t[5]+e[7]*t[3],e[4]*t[7]+e[7]*t[4],e[5]*t[7]+e[7]*t[5],e[6]*t[7]+e[7]*t[6],e[7]*t[7]],nh=(e,t)=>e[0]*t[7]+e[1]*t[6]+e[2]*t[5]+e[3]*t[4]+e[4]*t[3]+e[5]*t[2]+e[6]*t[1]+e[7]*t[0],Bx=(e,t)=>[t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[7]*e[3]+t[0]*e[4]+t[3]*e[7],t[5]*e[0]+t[7]*e[2]+t[0]*e[5]+t[2]*e[7],t[6]*e[0]+t[0]*e[6],t[7]*e[0]+t[0]*e[7]],ih=e=>Math.sqrt(Math.abs(e[0]*e[0]-e[2]*e[2]-e[3]*e[3]+e[6]*e[6])),Fx=e=>Math.sqrt(Math.abs(e[7]*e[7]-e[5]*e[5]-e[4]*e[4]+e[1]*e[1])),$i=e=>{let t=ih(e);if(t===0||t===1)return e;let r=e[6]<0?-1:1;return ri(e,r/t)},Hx=e=>{let t=Fx(e);return t===0||t===1?e:ri(e,1/t)},ah=e=>typeof e=="number",tD=Ki(1,1),rD=Ki(1,2),oD=Ki(1,3),nD=Ki(1,4),iD=Ki(1,5),aD=Ki(1,6),lD=Ki(1,7)});var Td,Ya,zx,Gx,Ux,lh=j(()=>{"use strict";f();Xi();Td=(e,t,r)=>$i([0,r,e,t,0,0,0,0]),Ya=(e,t)=>$i(vd(t,e)),zx=(e,t)=>Bx(e,t),Gx=(e,t)=>zx(Ya(e,t),t),Ux=e=>Math.sign(e[1])});var Zi,ji,Vx,Yx,sh,oi,Kx=j(()=>{"use strict";f();Xi();lh();Xi();Zi=([e,t])=>[0,0,0,0,t,e,1,0],ji=e=>[e[5],e[4]],Vx=e=>[0,0,0,0,Math.abs(e[4]),Math.abs(e[5]),1,0],Yx=(e,t)=>$i(oh(e,t)),sh=(e,t)=>ih(vd(e,t)),oi=(e,t)=>nh(e,t)});var ch,$x,dh=j(()=>{"use strict";f();Xi();ch=e=>[0,0,0,0,e[4],e[5],0,0],$x=(e,t)=>Hx([0,0,0,0,t[4]-e[4],t[5]-e[5],0,0])});var mh,Zx,jx,qx,To,Jx=j(()=>{"use strict";f();Xi();dh();mh=(e,t)=>Ox(ri(e,Math.sin(t/2)),Math.cos(t/2)),Zx=e=>[1,0,0,0,-(.5*e[5]),.5*e[4],0,0],jx=(e,t)=>{let r=.5*t;return[1,0,0,0,r*e[4],r*e[5],0,0]},qx=(e,t)=>ri(t,e),To=(e,t)=>$i(ri(ri(e,t),Va(e)))});var Ka,eI,$a,Xa,tI,Qx,rI,Pr,oI,ph,nI,e0,iI,Sd,uh,aI,lI,hh,t0,gh,r0,sI,o0,n0,fh=j(()=>{"use strict";f();Rt();Ka=1e-4,eI=e=>{let t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},$a=e=>eI(e)?e:[...e,e[0]],Xa=e=>e*180/Math.PI,tI=e=>e/180*Math.PI,Qx=(e,t)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)],rI=e=>e[0]===0&&e[1]===0,Pr=(e,t,r)=>{let o=tI(t);return!r||rI(r)?Qx(e,o):Qx(e.map((n,i)=>n-r[i]),o).map((n,i)=>n+r[i])},oI=e=>[-e[0],-e[1]],ph=(e,t)=>[e[0]+t[0],e[1]+t[1]],nI=(e,t)=>xt(...e,...t),e0=(e,t,r)=>{let o=ph(e,oI(t));return Pr(o,-Xa(r))},iI=(e,t)=>{let[r,o]=e,[[n,i],[a,l]]=t,s=r-n,c=o-i,d=a-n,m=l-i,p=s*d+c*m,u=d*d+m*m,h=-1;u!==0&&(h=p/u);let x,E;h<0?(x=n,E=i):h>1?(x=a,E=l):(x=n+h*d,E=i+h*m);let v=r-x,w=o-E;return Math.sqrt(v*v+w*w)},Sd=(e,t,r=Ka)=>{let o=iI(e,t);return o===0?!0:o<r},uh=(e,t,r=Ka)=>t.some(o=>Sd(e,o,r)),aI=e=>{let[t,r,o,n]=e;return(i,a)=>Math.pow(1-i,3)*n[a]+3*i*Math.pow(1-i,2)*o[a]+3*Math.pow(i,2)*(1-i)*r[a]+t[a]*Math.pow(i,3)},lI=(e,t=10)=>{let r=aI(e),o=[r(0,0),r(0,1)],n=[],i=0,a=1/t;for(let l=0;l<t;l++)if(i+=a,i<=1){let s=[r(i,0),r(i,1)];n.push([o,s]),o=s}return n},hh=(e,t,r=Ka)=>uh(e,lI(t),r),t0=(e,t,r=Ka)=>t.some(o=>hh(e,o,r)),gh=(e,t)=>{let r=e[0],o=e[1],n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){let l=t[i][0],s=t[i][1],c=t[a][0],d=t[a][1];(s>o&&d<=o||s<=o&&d>o)&&r<(c-l)*(o-s)/(d-s)+l&&(n=!n)}return n},r0=(e,t,r=Ka)=>{let o=!1,n=$a(t);for(let i=0,a=n.length-1;i<a;i++)if(Sd(e,[n[i],n[i+1]],r)){o=!0;break}return o},sI=(e,t)=>{let{angle:r,halfWidth:o,halfHeight:n,center:i}=t,a=o,l=n,[s,c]=e0(e,i,r),d=Math.abs(s),m=Math.abs(c),p=.707,u=.707;for(let E=0;E<3;E++){let v=a*p,w=l*u,y=(a*a-l*l)*p**3/a,I=(l*l-a*a)*u**3/l,P=v-y,C=w-I,_=d-y,D=m-I,H=Math.hypot(C,P),A=Math.hypot(D,_);p=Math.min(1,Math.max(0,(_*H/A+y)/a)),u=Math.min(1,Math.max(0,(D*H/A+I)/l));let M=Math.hypot(u,p);p/=M,u/=M}let[h,x]=[a*p*Math.sign(s),l*u*Math.sign(c)];return nI([s,c],[h,x])},o0=(e,t,r=Ka)=>sI(e,t)<=r,n0=(e,t)=>{let{center:r,angle:o,halfWidth:n,halfHeight:i}=t,[a,l]=e0(e,r,o);return a/n*(a/n)+l/i*(l/i)<=1}});var Ms,Za,Id=j(()=>{"use strict";f();fh();Ms=(e,t,r=0)=>{switch(t.type){case"polygon":return r0(e,t.data,r);case"ellipse":return o0(e,t.data,r);case"line":return Sd(e,t.data,r);case"polyline":return uh(e,t.data,r);case"curve":return hh(e,t.data,r);case"polycurve":return t0(e,t.data,r);default:throw Error(`shape ${t} is not implemented`)}},Za=(e,t)=>{switch(t.type){case"polygon":return gh(e,t.data);case"line":return!1;case"curve":return!1;case"ellipse":return n0(e,t.data);case"polyline":{let r=$a(t.data.flat());return gh(e,r)}case"polycurve":return!1;default:throw Error(`shape ${t} is not implemented`)}}});var he,S,ja,Cd,qa,qi,ue=j(()=>{"use strict";f();U();he={EQUAL:"Equal",MINUS:"Minus",NUM_ADD:"NumpadAdd",NUM_SUBTRACT:"NumpadSubtract",NUM_ZERO:"Numpad0",BRACKET_RIGHT:"BracketRight",BRACKET_LEFT:"BracketLeft",ONE:"Digit1",TWO:"Digit2",THREE:"Digit3",NINE:"Digit9",QUOTE:"Quote",ZERO:"Digit0",SLASH:"Slash",C:"KeyC",D:"KeyD",H:"KeyH",V:"KeyV",Z:"KeyZ",R:"KeyR",S:"KeyS"},S={ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",BACKSPACE:"Backspace",ALT:"Alt",CTRL_OR_CMD:rr?"metaKey":"ctrlKey",DELETE:"Delete",ENTER:"Enter",ESCAPE:"Escape",QUESTION_MARK:"?",SPACE:" ",TAB:"Tab",CHEVRON_LEFT:"<",CHEVRON_RIGHT:">",PERIOD:".",COMMA:",",SUBTRACT:"-",SLASH:"/",A:"a",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",L:"l",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",V:"v",X:"x",Y:"y",Z:"z",K:"k",W:"w",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9"},ja=e=>e===S.ARROW_LEFT||e===S.ARROW_RIGHT||e===S.ARROW_DOWN||e===S.ARROW_UP,Cd=e=>e.altKey,qa=e=>e.shiftKey,qi=e=>e.shiftKey});var m0,Uo,p0,xn,i0,Ls,cI,Ps,Ja,bh,xh,_s,dI,Wo,mI,So,pI,uI,a0,l0,u0,hI,kd,h0,g0,s0,Ad,c0,Qa,d0,gI,f0,Ds,fI,bI,xI,EI,yI,Eh,yh,wh,wI,vI,TI,SI,b0,II,CI,kI,AI,MI,LI,Jr=j(()=>{"use strict";f();Xi();Kx();dh();lh();Jx();at();Id();Ve();ce();We();Jn();Qt();z();ue();lt();m0=e=>!e[S.CTRL_OR_CMD],Uo=e=>e.isBindingEnabled,p0=(e,t)=>{let r=[];return t.forEach(o=>{let n=e.getNonDeletedElement(o);n!=null&&r.push(n)}),r},xn=(e,t,r,o)=>{let n=new Set,i=new Set;i0(e,t,r,"start",n,i,o),i0(e,r,t,"end",n,i,o);let a=Array.from(i).filter(l=>!n.has(l));p0(ut.getScene(e),a).forEach(l=>{F(l,{boundElements:l.boundElements?.filter(s=>s.type!=="arrow"||s.id!==e.id)})})},i0=(e,t,r,o,n,i,a)=>{if(t!=="keep")if(t!=null)(r==null||(r==="keep"?!bh(e,t,o):o==="start"||r.id!==t.id))&&(Ja(e,t,o,a),n.add(t.id));else{let l=dI(e,o);l!=null&&i.add(l)}},Ls=(e,t)=>{e.forEach(r=>{Tt(r)?xn(r,kd(r,"start",t),kd(r,"end",t),t.scene.getNonDeletedElementsMap()):Ua(r)&&cI(r,t.scene.getNonDeletedElementsMap(),t)})},cI=(e,t,r)=>{g0(e,r).forEach(([o,n])=>xn(o,n==="end"?"keep":e,n==="start"?"keep":e,t))},Ps=(e,t,r,o)=>{t.startBoundElement!=null&&Ja(e,t.startBoundElement,"start",o.scene.getNonDeletedElementsMap());let n=Wo(r,o);n!=null&&!bh(e,n,"end")&&Ja(e,n,"end",o.scene.getNonDeletedElementsMap())},Ja=(e,t,r,o)=>{F(e,{[r==="start"?"startBinding":"endBinding"]:{elementId:t.id,...mI(e,t,r,o)}}),$(t.boundElements||[]).has(e.id)||F(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},bh=(e,t,r)=>{let o=e[r==="start"?"endBinding":"startBinding"];return xh(e,o?.elementId,t)},xh=(e,t,r)=>t===r.id&&e.points.length<3,_s=(e,t)=>{e.forEach(r=>{Tt(r)&&xn(r,null,null,t)})},dI=(e,t)=>{let r=t==="start"?"startBinding":"endBinding",o=e[r];return o==null?null:(F(e,{[r]:null}),o.elementId)},Wo=(e,t)=>Ju(t.scene.getNonDeletedElements(),o=>Ua(o,!1)&&f0(o,e,t)),mI=(e,t,r,o)=>{let n=r==="start"?-1:1,i=n===-1?0:e.points.length-1,a=i-n,l=K.getPointAtIndexGlobalCoordinates(e,i,o),s=K.getPointAtIndexGlobalCoordinates(e,a,o);return{focus:wI(t,s,l,o),gap:Math.max(1,fI(t,l,o))}},So=(e,t,r)=>{let o=(e.boundElements??[]).filter(s=>s.type==="arrow");if(o.length===0)return;let{newSize:n,simultaneouslyUpdated:i}=r??{},a=uI(i),l=ut.getScene(e);p0(l,o.map(s=>s.id)).forEach(s=>{if(!re(s))return;let c=e;if(!pI(s,c))return;let d=l0(c,s.startBinding,n),m=l0(c,s.endBinding,n);if(a.has(s.id)){F(s,{startBinding:d,endBinding:m});return}a0(s,"start",d,e,t),a0(s,"end",m,e,t),de(s,l.getNonDeletedElementsMap())&&Ji(s,l.getNonDeletedElementsMap(),!1)})},pI=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,uI=e=>new Set((e||[]).map(t=>t.id)),a0=(e,t,r,o,n)=>{if(r==null||r.elementId!==o.id&&e.points.length>2)return;let i=ut.getScene(e).getElement(r.elementId);if(i==null)return;let a=t==="start"?-1:1,l=a===-1?0:e.points.length-1,s=l-a,c=K.getPointAtIndexGlobalCoordinates(e,s,n),d=vI(i,r.focus,c,n),m;if(r.gap===0)m=d;else{let p=TI(i,c,d,r.gap,n);p.length===0?m=d:m=p[0]}K.movePoints(e,[{index:l,point:K.pointFromAbsoluteCoords(e,m,n)}],{[t==="start"?"startBinding":"endBinding"]:r})},l0=(e,t,r)=>{if(t==null||r==null)return t;let{gap:o,focus:n,elementId:i}=t,{width:a,height:l}=r,{width:s,height:c}=e,d=Math.max(1,Math.min(Ds(e,a,l),o*(a<l?a/s:l/c)));return{elementId:i,gap:d,focus:n}},u0=(e,t)=>{let r=new Set(e.map(({id:o})=>o));return e.flatMap(o=>Tt(o,!1)?hI(o,t).filter(n=>!r.has(n.id)):Ua(o,!1)?g0(o,t).filter(n=>!r.has(n[0].id)):[])},hI=(e,t)=>[kd(e,"start",t),kd(e,"end",t)].filter(r=>r!=null),kd=(e,t,r)=>Wo(h0(e,t,r.scene.getNonDeletedElementsMap()),r),h0=(e,t,r)=>{let o=t==="start"?0:-1;return bo(K.getPointAtIndexGlobalCoordinates(e,o,r))},g0=(e,t)=>{let r=ut.getScene(e);return r.getNonDeletedElements().map(o=>{if(!Tt(o,!1))return null;let n=s0(o,"start",e,r.getNonDeletedElementsMap(),t),i=s0(o,"end",e,r.getNonDeletedElementsMap(),t);return!n&&!i?null:[o,n&&i?"both":n?"start":"end",e]}).filter(o=>o!=null)},s0=(e,t,r,o,n)=>e[t==="start"?"startBinding":"endBinding"]==null&&!bh(e,r,t)&&f0(r,h0(e,t,o),n),Ad=(e,t,r,o)=>{let n=new Set,i=new Set,a=o==="duplicatesServeAsOld";t.forEach(l=>{let{boundElements:s}=l;if(s!=null&&s.length>0&&(s.forEach(c=>{a&&!r.has(c.id)&&n.add(c.id)}),i.add(r.get(l.id))),Tt(l)){if(l.startBinding!=null){let{elementId:c}=l.startBinding;a&&!r.has(c)&&i.add(c)}if(l.endBinding!=null){let{elementId:c}=l.endBinding;a&&!r.has(c)&&i.add(c)}(l.startBinding!=null||l.endBinding!=null)&&n.add(r.get(l.id))}}),e.filter(({id:l})=>n.has(l)).forEach(l=>{let{startBinding:s,endBinding:c}=l;F(l,{startBinding:c0(s,r),endBinding:c0(c,r)})}),e.filter(({id:l})=>i.has(l)).forEach(l=>{let{boundElements:s}=l;s!=null&&s.length>0&&F(l,{boundElements:s.map(c=>r.has(c.id)?{id:r.get(c.id),type:c.type}:c)})})},c0=(e,t)=>{if(e==null)return null;let{elementId:r,focus:o,gap:n}=e;return{focus:o,gap:n,elementId:t.get(r)??r}},Qa=(e,t)=>{let r=new Set(t.map(n=>n.id)),o=new Set;t.forEach(n=>{Ua(n)?n.boundElements?.forEach(i=>{r.has(i.id)||o.add(i.id)}):Tt(n)&&(n.startBinding&&o.add(n.startBinding.elementId),n.endBinding&&o.add(n.endBinding.elementId))}),e.filter(({id:n})=>o.has(n)).forEach(n=>{Ua(n)?F(n,{boundElements:gI(n.boundElements,r)}):Tt(n)&&F(n,{startBinding:d0(n.startBinding,r),endBinding:d0(n.endBinding,r)})})},d0=(e,t)=>e==null||t.has(e.elementId)?null:e,gI=(e,t)=>e?e.filter(r=>!t.has(r.id)):null,f0=(e,{x:t,y:r},o)=>{let n=Ds(e,e.width,e.height),i=o.getElementShape(e);return Ms([t,r],i,n)},Ds=(e,t,r)=>{let n=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,r);return Math.max(16,Math.min(.25*n,32))},fI=(e,t,r)=>{switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return bI(e,t,r);case"diamond":return xI(e,t,r);case"ellipse":return EI(e,t,r)}},bI=(e,t,r)=>{let[,o,n,i]=Eh(e,t,r);return Math.max(oi(o,Td(0,1,-i)),oi(o,Td(1,0,-n)))},xI=(e,t,r)=>{let[,o,n,i]=Eh(e,t,r),a=Td(i,n,-i*n);return oi(o,a)},EI=(e,t,r)=>{let[o,n]=yI(e,t,r);return-Ux(n)*oi(o,n)},yI=(e,t,r)=>{let[,o,n,i]=Eh(e,t,r),[a,l]=ji(o),s=.707,c=.707,d=n,m=i;[0,1,2,3].forEach(h=>{let x=d*s,E=m*c,v=(d*d-m*m)*s**3/d,w=(m*m-d*d)*c**3/m,y=x-v,I=E-w,P=a-v,C=l-w,_=Math.hypot(I,y),D=Math.hypot(C,P);s=Math.min(1,Math.max(0,(P*_/D+v)/d)),c=Math.min(1,Math.max(0,(C*_/D+w)/m));let H=Math.hypot(c,s);s/=H,c/=H});let p=Jt(d*s,m*c),u=Gx(o,p);return[o,u]},Eh=(e,t,r)=>{let o=Zi(t),[n,i,a,l]=te(e,r),s=wh(n,i,a,l),c=mh(s,e.angle),d=To(c,o),m=rh(d,ch(s)),p=Vx(m),u=Nx(e.x,e.y),h=rh(d,u),x=(a-n)/2,E=(l-i)/2;return[h,p,x,E]},yh=(e,t)=>{let[r,o,n,i]=te(e,t),a=wh(r,o,n,i),l=mh(a,e.angle),s=Va(Zx(ch(a)));return qx(l,s)},wh=(e,t,r,o)=>Jt((e+r)/2,(t+o)/2),wI=(e,t,r,o)=>{let n=yh(e,o),i=To(n,Zi(t)),a=To(n,Zi(r)),l=Ya(i,a),s=e.height/e.width,c=e.width/2,d=e.height/2,m=l[2],p=l[3],u=l[1],h=Math.abs(p),x=Math.abs(m),E;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":E=u/(c*(x+s*h));break;case"diamond":E=h<x?u/(x*c):u/(h*d);break;case"ellipse":E=u/(c*Math.sqrt(m**2+s**2*p**2));break}return E||0},vI=(e,t,r,o)=>{if(t===0){let[s,c,d,m]=te(e,o),p=wh(s,c,d,m);return ji(p)}let n=yh(e,o),i=To(n,Zi(r)),a=Va(n),l;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":l=LI(e,t,i);break;case"ellipse":l=MI(e,t,i);break}return ji(To(a,l))},TI=(e,t,r,o=0,n)=>{let i=yh(e,n),a=To(i,Zi(t)),l=To(i,Zi(r)),s=Ya(a,l),c=Va(i);return SI(e,s,a,o).map(m=>ji(To(c,m)))},SI=(e,t,r,o=0)=>{let n;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":let a=b0(e);n=a.flatMap((l,s)=>{let c=[l,a[(s+1)%4]];return II(t,CI(c,o))}).concat(a.flatMap(l=>AI(l,o,t)));break;case"ellipse":n=kI(e,o,t);break}if(n.length<2)return[];let i=n.sort((a,l)=>sh(a,r)-sh(l,r));return[i[0],i[i.length-1]]},b0=(e,t=1)=>{let r=t*e.width/2,o=t*e.height/2;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return[Jt(r,o),Jt(r,-o),Jt(-r,-o),Jt(-r,o)];case"diamond":return[Jt(0,o),Jt(r,0),Jt(0,-o),Jt(-r,0)]}},II=(e,t)=>{let[r,o]=t,n=oi(r,e),i=oi(o,e);return n*i>=0?[]:[Yx(e,Ya(r,o))]},CI=(e,t)=>{let[r,o]=e,n=jx($x(r,o),t);return[To(n,r),To(n,o)]},kI=(e,t,r)=>{let o=e.width/2+t,n=e.height/2+t,i=r[2],a=r[3],l=r[1],s=o*o*i*i+n*n*a*a,c=s-l*l;if(s===0||c<=0)return[];let d=Math.sqrt(c),m=-o*o*i*l,p=-n*n*a*l;return[Jt((m+o*n*a*d)/s,(p-o*n*i*d)/s),Jt((m-o*n*a*d)/s,(p+o*n*i*d)/s)]},AI=(e,t,r)=>{if(t===0)return oi(r,e)===0?[e]:[];let o=r[2],n=r[3],i=r[1],[a,l]=ji(e),s=t,c=o*o+n*n,d=s*s*c-(o*a+n*l+i)**2;if(c===0||d<=0)return[];let m=Math.sqrt(d),p=a*n*n-l*o*n-o*i,u=l*o*o-a*o*n-n*i;return[Jt((p+n*m)/c,(u-o*m)/c),Jt((p-n*m)/c,(u+o*m)/c)]},MI=(e,t,r)=>{let o=Math.abs(t),n=e.width*o/2,i=e.height*o/2,a=Math.sign(t),[l,s]=ji(r),c=s===0?1e-4:s,d=l**2*i**2+c**2*n**2,m=(-l*i**2+a*c*Math.sqrt(Math.max(0,d-n**2*i**2)))/d,p=(-m*l-1)/c;p===0&&(p=(Object.is(p,-0)?-1:1)*.01);let u=-(n**2*m)/(p**2*i**2+m**2*n**2);return Jt(u,(-m*u-1)/p)},LI=(e,t,r)=>{let o=Math.abs(t),n=Math.sign(t),i=b0(e,o),a=0,l=null;return i.forEach(s=>{let c=n*Ya(r,s)[1];c>a&&(a=c,l=s)}),l}});var En,K,PI,Qt=j(()=>{"use strict";f();Rt();ge();at();We();Jr();z();ce();ue();lt();U();Go();En={version:null,points:[],zoom:null},K=class e{elementId;selectedPointsIndices;pointerDownState;isDragging;lastUncommittedPoint;pointerOffset;startBindingElement;endBindingElement;hoverPointIndex;segmentMidPointHoveredCoords;constructor(t){this.elementId=t.id,e.normalizePoints(t),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null}static POINT_HANDLE_SIZE=10;static getElement(t,r){let o=r.get(t);return o||null}static handleBoxSelection(t,r,o,n){if(!r.editingLinearElement||r.draggingElement?.type!=="selection")return!1;let{editingLinearElement:i}=r,{selectedPointsIndices:a,elementId:l}=i,s=e.getElement(l,n);if(!s)return!1;let[c,d,m,p]=te(r.draggingElement,n),h=e.getPointsGlobalCoordinates(s,n).reduce((x,E,v)=>((E[0]>=c&&E[0]<=m&&E[1]>=d&&E[1]<=p||t.shiftKey&&a?.includes(v))&&x.push(v),x),[]);o({editingLinearElement:{...i,selectedPointsIndices:h.length?h:null}})}static handlePointDragging(t,r,o,n,i,a,l){if(!a)return!1;let{selectedPointsIndices:s,elementId:c}=a,d=e.getElement(c,l);if(!d)return!1;let m=d.points[a.pointerDownState.lastClickedPoint];if(s&&m){if(qi(t)&&s.length===1&&d.points.length>1){let u=s[0],h=d.points[u===0?1:u-1],[x,E]=e._getShiftLockedDelta(d,l,h,[o,n],t[S.CTRL_OR_CMD]?null:r.gridSize);e.movePoints(d,[{index:u,point:[x+h[0],E+h[1]],isDragging:u===a.pointerDownState.lastClickedPoint}])}else{let u=e.createPointAt(d,l,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize),h=u[0]-m[0],x=u[1]-m[1];e.movePoints(d,s.map(E=>{let v=E===a.pointerDownState.lastClickedPoint?e.createPointAt(d,l,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize):[d.points[E][0]+h,d.points[E][1]+x];return{index:E,point:v,isDragging:E===a.pointerDownState.lastClickedPoint}}))}if(de(d,l)&&Ji(d,l,!1),Tt(d,!1)){let u=[];s[0]===0&&u.push(bo(e.getPointGlobalCoordinates(d,d.points[0],l)));let x=s[s.length-1];x===d.points.length-1&&u.push(bo(e.getPointGlobalCoordinates(d,d.points[x],l))),u.length&&i(d,u)}return!0}return!1}static handlePointerUp(t,r,o,n){let i=n.scene.getNonDeletedElementsMap(),{elementId:a,selectedPointsIndices:l,isDragging:s,pointerDownState:c}=r,d=e.getElement(a,i);if(!d)return r;let m={};if(s&&l){for(let p of l)if(p===0||p===d.points.length-1){ir(d.points,o.zoom.value)&&e.movePoints(d,[{index:p,point:p===0?d.points[d.points.length-1]:d.points[0]}]);let u=Uo(o)?Wo(bo(e.getPointAtIndexGlobalCoordinates(d,p,i)),n):null;m[p===0?"startBindingElement":"endBindingElement"]=u}}return{...r,...m,selectedPointsIndices:s||t.shiftKey?!s&&t.shiftKey&&c.prevSelectedPointsIndices?.includes(c.lastClickedPoint)?l&&l.filter(p=>p!==c.lastClickedPoint):l:l?.includes(c.lastClickedPoint)?[c.lastClickedPoint]:l,isDragging:!1,pointerOffset:{x:0,y:0}}}static getEditorMidPoints=(t,r,o)=>{let n=de(t,r);return!o.editingLinearElement&&t.points.length>2&&!n?[]:(En.version===t.version&&En.zoom===o.zoom.value||e.updateEditorMidPointsCache(t,r,o),En.points)};static updateEditorMidPointsCache=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,r),i=0,a=[];for(;i<n.length-1;){if(e.isSegmentTooShort(t,t.points[i],t.points[i+1],o.zoom)){a.push(null),i++;continue}let l=e.getSegmentMidPoint(t,n[i],n[i+1],i+1,r);a.push(l),i++}En.points=a,En.version=t.version,En.zoom=o.zoom.value};static getSegmentMidpointHitCoords=(t,r,o,n)=>{let{elementId:i}=t,a=e.getElement(i,n);if(!a||e.getPointIndexUnderCursor(a,n,o.zoom,r.x,r.y)>=0||e.getPointsGlobalCoordinates(a,n).length>=3&&!o.editingLinearElement)return null;let c=e.POINT_HANDLE_SIZE/o.zoom.value,d=t.segmentMidPointHoveredCoords;if(d&&xt(d[0],d[1],r.x,r.y)<=c)return d;let m=0,p=e.getEditorMidPoints(a,n,o);for(;m<p.length;){if(p[m]!==null&&xt(p[m][0],p[m][1],r.x,r.y)<=c)return p[m];m++}return null};static isSegmentTooShort(t,r,o,n){let i=xt(r[0],r[1],o[0],o[1]);return t.points.length>2&&t.roundness&&(i=kx(t,o)),i*n.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,r,o,n,i){let a=vs(r,o);if(t.points.length>2&&t.roundness){let l=Zu(t,t.points[n]);if(l){let s=Ax(t,t.points[n],.5),[c,d]=ju(l[0],l[1],l[2],l[3],s);a=e.getPointGlobalCoordinates(t,[c,d],i)}}return a}static getSegmentMidPointIndex(t,r,o,n){let i=e.getElement(t.elementId,n);if(!i)return-1;let a=e.getEditorMidPoints(i,n,r),l=0;for(;l<a.length;){if(e.arePointsEqual(o,a[l]))return l+1;l++}return-1}static handlePointerDown(t,r,o,n,i,a){let l=a.scene.getNonDeletedElementsMap(),s={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!i)return s;let{elementId:c}=i,d=e.getElement(c,l);if(!d)return s;let m=e.getSegmentMidpointHitCoords(i,n,r,l),p=null;if(m&&(p=e.getSegmentMidPointIndex(i,r,m,l)),t.altKey&&r.editingLinearElement)return i.lastUncommittedPoint==null&&(F(d,{points:[...d.points,e.createPointAt(d,l,n.x,n.y,t[S.CTRL_OR_CMD]?null:r.gridSize)]}),s.didAddPoint=!0),o.resumeRecording(),s.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:-1,origin:{x:n.x,y:n.y},segmentMidpoint:{value:m,index:p,added:!1}},selectedPointsIndices:[d.points.length-1],lastUncommittedPoint:null,endBindingElement:Wo(n,a)},s.didAddPoint=!0,s;let u=e.getPointIndexUnderCursor(d,l,r.zoom,n.x,n.y);if(u>=0||m)s.hitElement=d;else{let{startBindingElement:C,endBindingElement:_}=i;Uo(r)&&Tt(d)&&xn(d,C,_,l)}let[h,x,E,v]=te(d,l),w=(h+E)/2,y=(x+v)/2,I=u>-1&&Ee(d.x+d.points[u][0],d.y+d.points[u][1],w,y,d.angle),P=u>-1||t.shiftKey?t.shiftKey||i.selectedPointsIndices?.includes(u)?PI([...i.selectedPointsIndices||[],u]):[u]:null;return s.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:u,origin:{x:n.x,y:n.y},segmentMidpoint:{value:m,index:p,added:!1}},selectedPointsIndices:P,pointerOffset:I?{x:n.x-I[0],y:n.y-I[1]}:{x:0,y:0}},s}static arePointsEqual(t,r){return!t&&!r?!0:!t||!r?!1:qu(t,r)}static handlePointerMove(t,r,o,n,i){if(!n.editingLinearElement)return null;let{elementId:a,lastUncommittedPoint:l}=n.editingLinearElement,s=e.getElement(a,i);if(!s)return n.editingLinearElement;let{points:c}=s,d=c[c.length-1];if(!t.altKey)return d===l&&e.deletePoints(s,[c.length-1]),{...n.editingLinearElement,lastUncommittedPoint:null};let m;if(qi(t)&&c.length>=2){let p=c[c.length-2],[u,h]=e._getShiftLockedDelta(s,i,p,[r,o],t[S.CTRL_OR_CMD]?null:n.gridSize);m=[u+p[0],h+p[1]]}else m=e.createPointAt(s,i,r-n.editingLinearElement.pointerOffset.x,o-n.editingLinearElement.pointerOffset.y,t[S.CTRL_OR_CMD]?null:n.gridSize);return d===l?e.movePoints(s,[{index:s.points.length-1,point:m}]):e.addPoints(s,n,[{point:m}]),{...n.editingLinearElement,lastUncommittedPoint:s.points[s.points.length-1]}}static getPointGlobalCoordinates(t,r,o){let[n,i,a,l]=te(t,o),s=(n+a)/2,c=(i+l)/2,{x:d,y:m}=t;return[d,m]=Ee(d+r[0],m+r[1],s,c,t.angle),[d,m]}static getPointsGlobalCoordinates(t,r){let[o,n,i,a]=te(t,r),l=(o+i)/2,s=(n+a)/2;return t.points.map(c=>{let{x:d,y:m}=t;return[d,m]=Ee(d+c[0],m+c[1],l,s,t.angle),[d,m]})}static getPointAtIndexGlobalCoordinates(t,r,o){let n=r<0?t.points.length+r:r,[i,a,l,s]=te(t,o),c=(i+l)/2,d=(a+s)/2,m=t.points[n],{x:p,y:u}=t;return m?Ee(p+m[0],u+m[1],c,d,t.angle):Ee(p,u,c,d,t.angle)}static pointFromAbsoluteCoords(t,r,o){let[n,i,a,l]=te(t,o),s=(n+a)/2,c=(i+l)/2,[d,m]=Ee(r[0],r[1],s,c,-t.angle);return[d-t.x,m-t.y]}static getPointIndexUnderCursor(t,r,o,n,i){let a=e.getPointsGlobalCoordinates(t,r),l=a.length;for(;--l>-1;){let s=a[l];if(xt(n,i,s[0],s[1])*o.value<e.POINT_HANDLE_SIZE+1)return l}return-1}static createPointAt(t,r,o,n,i){let a=St(o,n,i),[l,s,c,d]=te(t,r),m=(l+c)/2,p=(s+d)/2,[u,h]=Ee(a[0],a[1],m,p,-t.angle);return[u-t.x,h-t.y]}static getNormalizedPoints(t){let{points:r}=t,o=r[0][0],n=r[0][1];return{points:r.map((i,a)=>[i[0]-o,i[1]-n]),x:t.x+o,y:t.y+n}}static normalizePoints(t){F(t,e.getNormalizedPoints(t))}static duplicateSelectedPoints(t,r){if(!t.editingLinearElement)return!1;let{selectedPointsIndices:o,elementId:n}=t.editingLinearElement,i=e.getElement(n,r);if(!i||o===null)return!1;let{points:a}=i,l=[],s=!1,c=-1,d=a.reduce((m,p,u)=>{if(++c,m.push(p),o.includes(u)){let x=a[u+1];x||(s=!0),m.push(x?[(p[0]+x[0])/2,(p[1]+x[1])/2]:[p[0],p[1]]),l.push(c+1),++c}return m},[]);if(F(i,{points:d}),s){let m=i.points[i.points.length-1];e.movePoints(i,[{index:i.points.length-1,point:[m[0]+30,m[1]+30]}])}return{appState:{...t,editingLinearElement:{...t.editingLinearElement,selectedPointsIndices:l}}}}static deletePoints(t,r){let o=0,n=0;if(r.includes(0)){let l=t.points.find((s,c)=>!r.includes(c));l&&(o=l[0],n=l[1])}let a=t.points.reduce((l,s,c)=>(r.includes(c)||l.push(l.length?[s[0]-o,s[1]-n]:[0,0]),l),[]);e._updatePoints(t,a,o,n)}static addPoints(t,r,o){let a=[...t.points,...o.map(l=>l.point)];e._updatePoints(t,a,0,0)}static movePoints(t,r,o){let{points:n}=t,i=0,a=0,l=r.find(({index:c})=>c===0);l&&(i=l.point[0]+n[l.index][0],a=l.point[1]+n[l.index][1]);let s=n.map((c,d)=>{let m=r.find(p=>p.index===d);if(m){if(l)return c;let p=m.point[0]-n[m.index][0],u=m.point[1]-n[m.index][1];return[c[0]+p,c[1]+u]}return i||a?[c[0]-i,c[1]-a]:c});e._updatePoints(t,s,i,a,o)}static shouldAddMidpoint(t,r,o,n){if(!e.getElement(t.elementId,n))return!1;let{segmentMidpoint:a}=t.pointerDownState;if(a.added||a.value===null||a.index===null||t.pointerDownState.origin===null)return!1;let l=t.pointerDownState.origin,s=xt(l.x,l.y,r.x,r.y);return!(!o.editingLinearElement&&s<pn/o.zoom.value)}static addMidpoint(t,r,o,n,i){let a=e.getElement(t.elementId,i);if(!a)return;let{segmentMidpoint:l}=t.pointerDownState,s={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,i,r.x,r.y,n?o.gridSize:null),d=[...a.points.slice(0,l.index),c,...a.points.slice(l.index)];return F(a,{points:d}),s.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:l.index},s.selectedPointsIndices=[l.index],s}static _updatePoints(t,r,o,n,i){let a=el(t,r),l=el(t,t.points),s=(a[0]+a[2])/2,c=(a[1]+a[3])/2,d=(l[0]+l[2])/2,m=(l[1]+l[3])/2,p=d-s,u=m-c,h=Ee(o,n,p,u,t.angle);F(t,{...i,points:r,x:t.x+h[0],y:t.y+h[1]})}static _getShiftLockedDelta(t,r,o,n,i){let a=e.getPointGlobalCoordinates(t,o,r),[l,s]=St(n[0],n[1],i),{width:c,height:d}=tl(a[0],a[1],l,s);return Ze([c,d],[0,0],-t.angle)}static getBoundTextElementPosition=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,o);n.length<2&&F(r,{isDeleted:!0});let i=0,a=0;if(t.points.length%2===1){let l=Math.floor(t.points.length/2),s=e.getPointGlobalCoordinates(t,t.points[l],o);i=s[0]-r.width/2,a=s[1]-r.height/2}else{let l=t.points.length/2-1,s=En.points[l];t.points.length===2&&(s=vs(n[0],n[1])),(!s||En.version!==t.version)&&(s=e.getSegmentMidPoint(t,n[l],n[l+1],l+1,o)),i=s[0]-r.width/2,a=s[1]-r.height/2}return{x:i,y:a}};static getMinMaxXYWithBoundText=(t,r,o,n)=>{let[i,a,l,s]=o,c=(i+l)/2,d=(a+s)/2,{x:m,y:p}=e.getBoundTextElementPosition(t,n,r),u=m+n.width,h=p+n.height,x=Ze([i,a],[c,d],t.angle),E=Ze([l,a],[c,d],t.angle),v=Ze([m,p],[c,d],-t.angle),w=Ze([u,p],[c,d],-t.angle),y=Ze([m,h],[c,d],-t.angle),I=Ze([u,h],[c,d],-t.angle);return x[0]<E[0]&&x[1]>=E[1]?(i=Math.min(i,y[0]),l=Math.max(l,Math.max(w[0],I[0])),a=Math.min(a,v[1]),s=Math.max(s,I[1])):x[0]>=E[0]&&x[1]>E[1]?(i=Math.min(i,I[0]),l=Math.max(l,Math.max(v[0],w[0])),a=Math.min(a,y[1]),s=Math.max(s,w[1])):x[0]>=E[0]?(i=Math.min(i,w[0]),l=Math.max(l,y[0]),a=Math.min(a,I[1]),s=Math.max(s,v[1])):x[1]<=E[1]&&(i=Math.min(i,Math.min(w[0],v[0])),l=Math.max(l,I[0]),a=Math.min(a,w[1]),s=Math.max(s,y[1])),[i,a,l,s,c,d]};static getElementAbsoluteCoords=(t,r,o=!1)=>{let n,i,a,l,s;if(t.points.length<2||!ke.get(t)){let{minX:p,minY:u,maxX:h,maxY:x}=t.points.reduce((E,[v,w])=>(E.minY=Math.min(E.minY,w),E.minX=Math.min(E.minX,v),E.maxX=Math.max(E.maxX,v),E.maxY=Math.max(E.maxY,w),E),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});i=p+t.x,a=u+t.y,l=h+t.x,s=x+t.y}else{let p=ke.generateElementShape(t,null),u=ti(p[0]),[h,x,E,v]=Rs(u);i=h+t.x,a=x+t.y,l=E+t.x,s=v+t.y}let c=(i+l)/2,d=(a+s)/2;if(n=[i,a,l,s,c,d],!o)return n;let m=de(t,r);return m&&(n=e.getMinMaxXYWithBoundText(t,r,[i,a,l,s],m)),n}},PI=e=>{let t=[...new Set(e.filter(r=>r!==null&&r!==-1))];return t=t.sort((r,o)=>r-o),t.length?t:null}});var Qi,ea,Md,x0,Ld=j(()=>{"use strict";f();Qi={},ea=(e,t)=>{let r=Qi[e]||(Qi[e]={height:t});return r.height=t,r},Md=e=>{Qi[e]&&delete Qi[e]},x0=e=>Qi[e]?.height??null});var ni,Sh,Yt,Pd,Ji,rl,Io,y0,ii,_d,Dd,vh,Ns,Os,_I,DI,ai,w0,v0,Rd,RI,wn,de,st,Nd,Ih,T0,S0,I0,NI,C0,yn,fr,ta,k0,Th,E0,_r,lt=j(()=>{"use strict";f();z();We();U();ge();ce();Qt();Ld();ni=e=>hd(e).replace(/\t/g," "),Sh=e=>ni(e).split(`
10
+ `),Yt=(e,t,r)=>{let o,n={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height};n.text=e.text,t&&(o=fr(t,e),n.text=ai(e.originalText,Ge(e),o));let i=Io(n.text,Ge(e),e.lineHeight);if(n.width=i.width,n.height=i.height,t){let a=ta(t,e),l=fr(t,e);if(!Te(t)&&i.height>a){let m=yn(i.height,t.type);F(t,{height:m}),ea(t.id,m)}if(i.width>l){let m=yn(i.width,t.type);F(t,{width:m})}let s={...e,...n},{x:c,y:d}=rl(t,s,r);n.x=c,n.y=d}F(e,n)},Pd=(e,t,r)=>{let o=$(e);t.forEach(n=>{let i=r.get(n.id),a=wn(n);if(a){let l=r.get(a);if(l){let s=o.get(i);s&&F(s,{boundElements:(n.boundElements||[]).filter(d=>d.id!==l&&d.id!==a).concat({type:"text",id:l})});let c=o.get(l);c&&G(c)&&F(c,{containerId:s?i:null})}}})},Ji=(e,t,r,o=!1)=>{if(!wn(e))return;Md(e.id);let i=de(e,t);if(i&&i.text){if(!e)return;let a=i.text,l=i.height,s=i.width,c=fr(e,i),d=ta(e,i),m=e.height;if(o||r!=="n"&&r!=="s"){a&&(a=ai(i.originalText,Ge(i),c));let p=Io(a,Ge(i),i.lineHeight);l=p.height,s=p.width}if(l>d){m=yn(l,e.type);let p=m-e.height,u=!Te(e)&&(r==="ne"||r==="nw"||r==="n")?e.y-p:e.y;F(e,{height:m,y:u})}F(i,{text:a,width:s,height:l}),Te(e)||F(i,rl(e,i,t))}},rl=(e,t,r)=>{if(Te(e))return K.getBoundTextElementPosition(e,t,r);let o=Ih(e),n=ta(e,t),i=fr(e,t),a,l;return t.verticalAlign===ft.TOP?l=o.y:t.verticalAlign===ft.BOTTOM?l=o.y+(n-t.height):l=o.y+(n/2-t.height/2),t.textAlign===Kn.LEFT?a=o.x:t.textAlign===Kn.RIGHT?a=o.x+(i-t.width):a=o.x+(i/2-t.width/2),{x:a,y:l}},Io=(e,t,r)=>{e=e.split(`
11
11
  `).map(a=>a||" ").join(`
12
- `);let o=parseFloat(t),n=MI(e,o,r);return{width:Os(e,t),height:n}},E0=e=>{let t=vh(e.text).length;return e.height/t/e.fontSize},ii=(e,t)=>e*t,_d=(e,t,r)=>{let{unitsPerEm:o,ascender:n,descender:i}=x0[e]||x0[it.Helvetica],a=t/o,l=r-a*n+a*i;return a*n+l},Dd=(e,t)=>ii(e,t)+ht*2,Ns=(e,t)=>{yh||(yh=document.createElement("canvas"));let r=yh.getContext("2d");r.font=t;let o=r.measureText(e).width;return Ar()?o*10:o},Os=(e,t)=>{let r=vh(e),o=0;return r.forEach(n=>{o=Math.max(o,Ns(n,t))}),o},MI=(e,t,r)=>{let o=vh(e).length;return ii(t,r)*o},LI=e=>{let t=e.split("-");return t.length>1&&t.forEach((r,o)=>{o!==t.length-1&&(t[o]=r+="-")}),t.join(" ").split(" ")},ai=(e,t,r)=>{if(!Number.isFinite(r)||r<0)return e;let o=[],n=e.split(`
13
- `),i=Ns(" ",t),a="",l=0,s=d=>{d.trim()&&o.push(d)},c=()=>{a="",l=0};return n.forEach(d=>{if(Os(d,t)<=r){o.push(d);return}let p=LI(d);c();let u=0;for(;u<p.length;){let h=Ns(p[u],t);if(h===r)s(p[u]),u++;else if(h>r){for(s(a),c();p[u].length>0;){let x=String.fromCodePoint(p[u].codePointAt(0)),E=y0.calculate(x,t);l+=E,p[u]=p[u].slice(x.length),l>=r?(s(a),a=x,l=E):a+=x}l+i>=r?(s(a),c()):a.endsWith("-")||(a+=" ",l+=i),u++}else for(;l<r&&u<p.length;){let x=p[u];if(l=Ns(a+x,t),l>r){s(a),c();break}u++;let E=!x.endsWith("-");if(a+=x,E&&(a+=" "),l+i>=r){E?o.push(a.slice(0,-1)):o.push(a),c();break}}}a.slice(-1)===" "&&(a=a.slice(0,-1),s(a))}),o.join(`
14
- `)},y0=(()=>{let e={};return{calculate:(o,n)=>{let i=o.charCodeAt(0);if(e[n]||(e[n]=[]),!e[n][i]){let a=Ns(o,n);e[n][i]=a}return e[n][i]},getCache:o=>e[o]}})(),w0="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),Rd=(e,t)=>{let r=PI(e);return r===0?Io(w0.split("").join(`
15
- `),e,t).width+ht*2:r+ht*2},PI=e=>{let t=y0.getCache(e);if(!t)return 0;let r=t.filter(o=>o!==void 0);return Math.max(...r)},wn=e=>e?.boundElements?.length&&e?.boundElements?.filter(t=>t.type==="text")[0]?.id||null,pe=(e,t)=>{if(!e)return null;let r=wn(e);return r&&t.get(r)||null},lt=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,Nd=(e,t,r)=>{if(!Te(e))return{x:e.x+e.width/2,y:e.y+e.height/2};let o=K.getPointsGlobalCoordinates(e,r);if(o.length%2===1){let a=Math.floor(e.points.length/2),l=K.getPointGlobalCoordinates(e,e.points[a],r);return{x:l[0],y:l[1]}}let n=e.points.length/2-1,i=K.getEditorMidPoints(e,r,t)[n];return i||(i=K.getSegmentMidPoint(e,o[n],o[n+1],n+1,r)),{x:i[0],y:i[1]}},Th=e=>{let t=ht,r=ht;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),r+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,r+=e.height/4),{x:e.x+t,y:e.y+r}},v0=(e,t)=>!t||Te(t)?e.angle:t.angle,T0=(e,t)=>e.some(r=>{if(Ne(r)){let o=lt(r,t);return!Te(o)}return!1}),S0=(e,t)=>e.some(r=>{if(Ne(r)){let o=lt(r,t);return!Te(o)}return U(r)}),_I=new Set(["rectangle","ellipse","diamond","arrow"]),I0=e=>_I.has(e.type),yn=(e,t)=>{e=Math.ceil(e);let r=ht*2;return t==="ellipse"?Math.round((e+r)/Math.sqrt(2)*2):t==="arrow"?e+r*8:t==="diamond"?2*(e+r):e+r},fr=(e,t)=>{let{width:r}=e;if(Te(e)){let o=(t?.fontSize??At)*Qb;return Math.max(Jb*r,o)}return e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-ht*2:e.type==="diamond"?Math.round(r/2)-ht*2:r-ht*2},ta=(e,t)=>{let{height:r}=e;return Te(e)?r-ht*8*2<=0?t.height:r:e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-ht*2:e.type==="diamond"?Math.round(r/2)-ht*2:r-ht*2},C0=()=>Os(w0,Ge({fontSize:At,fontFamily:Wt}))>0,wh={[it.Virgil]:1.25,[it.Helvetica]:1.15,[it.Cascadia]:1.2},x0={[it.Virgil]:{unitsPerEm:1e3,ascender:886,descender:-374},[it.Helvetica]:{unitsPerEm:2048,ascender:1577,descender:-471},[it.Cascadia]:{unitsPerEm:2048,ascender:1977,descender:-480},[it.Assistant]:{unitsPerEm:1e3,ascender:1021,descender:-287}},_r=e=>e in wh?wh[e]:wh[Wt]});import Ih from"roughjs/bin/rough";var Sh,te,Ch,Ju,ti,k0,A0,DI,Rs,kh,RI,NI,OI,Qu,BI,FI,Dr,we,Od,ra,Qa,Ah,br,HI,at=j(()=>{"use strict";f();Rt();qu();ce();ys();ut();Qt();Go();z();Sh=class e{static boundsCache=new WeakMap;static getBounds(t,r){let o=e.boundsCache.get(t);if(o?.version&&o.version===t.version&&!Ne(t))return o.bounds;let n=e.calculateBounds(t,r);return e.boundsCache.set(t,{version:t.version,bounds:n}),n}static calculateBounds(t,r){let o,[n,i,a,l,s,c]=te(t,r);if(Lt(t)){let[d,m,p,u]=kh(t.points.map(([h,x])=>Ee(h,x,s-t.x,c-t.y,t.angle)));return[d+t.x,m+t.y,p+t.x,u+t.y]}else if(re(t))o=FI(t,s,c,r);else if(t.type==="diamond"){let[d,m]=Ee(s,i,s,c,t.angle),[p,u]=Ee(s,l,s,c,t.angle),[h,x]=Ee(n,c,s,c,t.angle),[E,v]=Ee(a,c,s,c,t.angle),w=Math.min(d,p,h,E),y=Math.min(m,u,x,v),I=Math.max(d,p,h,E),P=Math.max(m,u,x,v);o=[w,y,I,P]}else if(t.type==="ellipse"){let d=(a-n)/2,m=(l-i)/2,p=Math.cos(t.angle),u=Math.sin(t.angle),h=Math.hypot(d*p,m*u),x=Math.hypot(m*p,d*u);o=[s-h,c-x,s+h,c+x]}else{let[d,m]=Ee(n,i,s,c,t.angle),[p,u]=Ee(n,l,s,c,t.angle),[h,x]=Ee(a,l,s,c,t.angle),[E,v]=Ee(a,i,s,c,t.angle),w=Math.min(d,p,h,E),y=Math.min(m,u,x,v),I=Math.max(d,p,h,E),P=Math.max(m,u,x,v);o=[w,y,I,P]}return o}},te=(e,t,r=!1)=>{if(Lt(e))return RI(e);if(re(e))return K.getElementAbsoluteCoords(e,t,r);if(U(e)){let o=t?lt(e,t):null;if(Te(o)){let n=K.getBoundTextElementPosition(o,e,t);return[n.x,n.y,n.x+e.width,n.y+e.height,n.x+e.width/2,n.y+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]},Ch=(e,t)=>{let[r,o,n,i,a,l]=te(e,t),s=[a,l];if(re(e)||Lt(e)){let v=[],w=0;for(;w<e.points.length-1;)v.push([Ze([e.points[w][0]+e.x,e.points[w][1]+e.y],s,e.angle),Ze([e.points[w+1][0]+e.x,e.points[w+1][1]+e.y],s,e.angle)]),w++;return v}let[c,d,m,p,u,h,x,E]=[[r,o],[n,o],[r,i],[n,i],[a,o],[a,i],[r,l],[n,l]].map(v=>Ze(v,s,e.angle));return e.type==="diamond"?[[u,x],[u,E],[h,x],[h,E]]:e.type==="ellipse"?[[u,x],[u,E],[h,x],[h,E],[u,x],[u,E],[h,x],[h,E]]:[[c,d],[m,p],[c,m],[d,p],[c,E],[m,E],[d,x],[p,x]]},Ju=e=>{let t=Math.floor(e.width/2)+1,r=0,o=e.width,n=Math.floor(e.height/2)+1,i=t,a=e.height;return[t,r,o,n,i,a,0,n]},ti=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},k0=(e,t,r,o,n)=>{let i=1-e;return Math.pow(i,3)*t+3*Math.pow(i,2)*e*r+3*i*Math.pow(e,2)*o+Math.pow(e,3)*n},A0=(e,t,r,o)=>{let n=t-e,i=r-t,a=o-r,l=3*n-6*i+3*a,s=6*i-6*n,c=3*n,d=s*s-4*l*c;if(!(d>=0))return!1;let p=null,u=null,h=1/0,x=1/0;return l===0?h=x=-c/s:(h=(-s+Math.sqrt(d))/(2*l),x=(-s-Math.sqrt(d))/(2*l)),h>=0&&h<=1&&(p=k0(h,e,t,r,o)),x>=0&&x<=1&&(u=k0(x,e,t,r,o)),[p,u]},DI=(e,t,r,o)=>{let n=A0(e[0],t[0],r[0],o[0]),i=A0(e[1],t[1],r[1],o[1]),a=Math.min(e[0],o[0]),l=Math.max(e[0],o[0]);if(n){let d=n.filter(m=>m!==null);a=Math.min(a,...d),l=Math.max(l,...d)}let s=Math.min(e[1],o[1]),c=Math.max(e[1],o[1]);if(i){let d=i.filter(m=>m!==null);s=Math.min(s,...d),c=Math.max(c,...d)}return[a,s,l,c]},Rs=(e,t)=>{let r=[0,0],{minX:o,minY:n,maxX:i,maxY:a}=e.reduce((l,{op:s,data:c})=>{if(s==="move")r=c;else if(s==="bcurveTo"){let d=[c[0],c[1]],m=[c[2],c[3]],p=[c[4],c[5]],u=t?t(...d):d,h=t?t(...m):m,x=t?t(...p):p,E=t?t(...r):r;r=p;let[v,w,y,I]=DI(E,u,h,x);l.minX=Math.min(l.minX,v),l.minY=Math.min(l.minY,w),l.maxX=Math.max(l.maxX,y),l.maxY=Math.max(l.maxY,I)}return l},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[o,n,i,a]},kh=e=>{let t=1/0,r=1/0,o=-1/0,n=-1/0;for(let[i,a]of e)t=Math.min(t,i),r=Math.min(r,a),o=Math.max(o,i),n=Math.max(n,a);return[t,r,o,n]},RI=e=>{let[t,r,o,n]=kh(e.points),i=t+e.x,a=r+e.y,l=o+e.x,s=n+e.y;return[i,a,l,s,(i+l)/2,(a+s)/2]},NI=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;default:return 15}},OI=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Qu=(e,t,r,o)=>{let n=ti(t[0]);if(n.length<1)return null;let i=r==="start"?1:n.length-1,a=n[i].data,l=[a[4],a[5]],s=[a[2],a[3]],c=[a[0],a[1]],d=n[i-1],m=[0,0];d.op==="move"?m=d.data:d.op==="bcurveTo"&&(m=[d.data[4],d.data[5]]);let p=(Y,ee)=>Math.pow(1-Y,3)*l[ee]+3*Y*Math.pow(1-Y,2)*s[ee]+3*Math.pow(Y,2)*(1-Y)*c[ee]+m[ee]*Math.pow(Y,3),[u,h]=r==="start"?m:l,[x,E]=[p(.3,0),p(.3,1)],v=Math.hypot(u-x,h-E),w=(u-x)/v,y=(h-E)/v,I=NI(o),P=0;{let[Y,ee]=r==="end"?e.points[e.points.length-1]:e.points[0],[xe,le]=e.points.length>1?r==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];P=Math.hypot(Y-xe,ee-le)}let _=Math.min(I,P*(o==="diamond"||o==="diamond_outline"?.25:.5)),D=u-w*_,H=h-y*_;if(o==="dot"||o==="circle"||o==="circle_outline"){let Y=Math.hypot(H-h,D-u)+e.strokeWidth-2;return[u,h,Y]}let A=OI(o),[M,k]=Ee(D,H,u,h,-A*Math.PI/180),[O,X]=Ee(D,H,u,h,A*Math.PI/180);if(o==="diamond"||o==="diamond_outline"){let Y,ee;if(r==="start"){let[xe,le]=e.points.length>1?e.points[1]:[0,0];[Y,ee]=Ee(u+_*2,h,u,h,Math.atan2(le-h,xe-u))}else{let[xe,le]=e.points.length>1?e.points[e.points.length-2]:[0,0];[Y,ee]=Ee(u-_*2,h,u,h,Math.atan2(h-le,u-xe))}return[u,h,M,k,Y,ee,O,X]}return[u,h,M,k,O,X]},BI=e=>{let t=Ih.generator(),r=Lr(e),o=e.roundness?"curve":r.fill?"polygon":"linearPath";return t[o](e.points,r)},FI=(e,t,r,o)=>{let n=pe(e,o);if(e.points.length<2){let[m,p]=e.points[0],[u,h]=Ee(e.x+m,e.y+p,t,r,e.angle),x=[u,h,u,h];if(n){let E=K.getMinMaxXYWithBoundText(e,o,[u,h,u,h],n);x=[E[0],E[1],E[2],E[3]]}return x}let a=ke.get(e)?.[0]??BI(e),l=ti(a),c=Rs(l,(m,p)=>Ee(e.x+m,e.y+p,t,r,e.angle)),d=[c[0],c[1],c[2],c[3]];if(n){let m=K.getMinMaxXYWithBoundText(e,o,d,n);d=[m[0],m[1],m[2],m[3]]}return d},Dr=(e,t)=>Sh.getBounds(e,t),we=e=>{if(!e.length)return[0,0,0,0];let t=1/0,r=-1/0,o=1/0,n=-1/0,i=$(e);return e.forEach(a=>{let[l,s,c,d]=Dr(a,i);t=Math.min(t,l),o=Math.min(o,s),r=Math.max(r,c),n=Math.max(n,d)}),[t,o,r,n]},Od=(e,t)=>{let[r,o,n,i]=we(e);return[r+t.x,o+t.y,n+t.x,i+t.y]},ra=(e,t,r,o)=>{if(!(re(e)||Lt(e)))return[e.x,e.y,e.x+t,e.y+r];let n=ei(0,t,ei(1,r,e.points,o),o),i;if(Lt(e))i=kh(n);else{let d=Ih.generator(),m=e.roundness?d.curve(n,Lr(e)):d.linearPath(n,Lr(e)),p=ti(m);i=Rs(p)}let[a,l,s,c]=i;return[a+e.x,l+e.y,s+e.x,c+e.y]},Qa=(e,t)=>{let r=Ih.generator(),o=e.roundness==null?r.linearPath(t,Lr(e)):r.curve(t,Lr(e)),n=ti(o),[i,a,l,s]=Rs(n);return[i+e.x,a+e.y,l+e.x,s+e.y]},Ah=(e,t)=>{if(!e.length)return[0,0,0,0];let r=1/0,o=e[0],n=$(e);return e.forEach(i=>{let[a,l,s,c]=Dr(i,n),d=xt((a+s)/2,(l+c)/2,t.x,t.y);d<r&&(r=d,o=i)}),Dr(o,n)},br=e=>{let[t,r,o,n]=we(e);return{minX:t,minY:r,maxX:o,maxY:n,width:o-t,height:n-r,midX:(t+o)/2,midY:(r+n)/2}},HI=({scrollX:e,scrollY:t,width:r,height:o,zoom:n})=>[-e,-t,-e+r/n.value,-t+o/n.value]});var zI,ar,GI,M0,Bd,L0,xr,Co,Rr=j(()=>{"use strict";f();Zt();G();zI=Fa.includes(devicePixelRatio)?devicePixelRatio:1,ar=()=>({showWelcomeScreen:!1,theme:oe.LIGHT,collaborators:new Map,currentChartType:"bar",currentItemBackgroundColor:Qe.backgroundColor,currentItemEndArrowhead:"arrow",currentItemFillStyle:Qe.fillStyle,currentItemFontFamily:Wt,currentItemFontSize:At,currentItemOpacity:Qe.opacity,currentItemRoughness:Qe.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:Qe.strokeColor,currentItemRoundness:"round",currentItemStrokeStyle:Qe.strokeStyle,currentItemStrokeWidth:Qe.strokeWidth,currentItemTextAlign:Yn,cursorButton:"up",activeEmbeddable:null,draggingElement:null,editingElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:"selection",customType:null,locked:Qe.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:zI,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:null,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:"mouse",multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,showStats:!1,startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:se.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set}),GI=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},draggingElement:{browser:!1,export:!1,server:!1},editingElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},showStats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1}}),M0=(e,t)=>{let r={};for(let o of Object.keys(e))if(GI[o]?.[t]){let i=e[o];r[o]=i}return r},Bd=e=>M0(e,"export"),L0=e=>M0(e,"server"),xr=({activeTool:e})=>e.type==="eraser",Co=({activeTool:e})=>e.type==="hand"});var Mh,Kt,Fd,Lh,vn,Hd,P0,oa,Je,_0,D0,R0,N0,na,Nr=j(()=>{"use strict";f();Ve();ut();Qn();Mh=(e,t,r)=>{let o=r.reduce((n,i)=>(i.groupIds.includes(e)&&(n[i.id]=!0),n),{});return Object.keys(o).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...o}}},Kt=function(){let e=null,t=null,r=null,o=(i,a,l,s)=>{if(r!==void 0&&a===t&&i===e&&l.editingGroupId===r?.editingGroupId)return r;let c={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let h=u.indexOf(l.editingGroupId);h>-1&&(u=u.slice(0,h))}if(u.length>0){let h=u[u.length-1];c[h]=!0}}let d={},m=a.reduce((p,u)=>{let h=u.groupIds.find(x=>c[x]);return h&&(p[u.id]=!0,Array.isArray(d[h])?d[h].push(u.id):d[h]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return t=a,e=i,r={editingGroupId:l.editingGroupId,selectedGroupIds:c,selectedElementIds:Pe({...l.selectedElementIds,...m},s)},r},n=(i,a,l,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):me(a,i);return c.length?o(c,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Pe(i.selectedElementIds,l)}};return n.clearCache=()=>{t=null,e=null,r=null},n}(),Fd=(e,t)=>Lh(e,t)!=null,Lh=(e,t)=>t.groupIds.filter(r=>r!==e.editingGroupId).find(r=>e.selectedGroupIds[r]),vn=e=>Object.entries(e.selectedGroupIds).filter(([t,r])=>r).map(([t,r])=>t),Hd=(e,t)=>{let r={...t,selectedGroupIds:{}};for(let o of e){let n=o.groupIds;if(t.editingGroupId){let i=n.indexOf(t.editingGroupId);i>-1&&(n=n.slice(0,i))}if(n.length>0){let i=n[n.length-1];r={...r,...Mh(i,r,e)}}}return r.selectedGroupIds},P0=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),oa=(e,t)=>e.groupIds.includes(t),Je=(e,t)=>{let r=[];for(let o of e.values())oa(o,t)&&r.push(o);return r},_0=(e,t)=>e.groupIds.find(r=>t[r]),D0=(e,t,r)=>{let o=[...e],n=t?e.indexOf(t):-1,i=n>-1?n:e.length;for(let a=0;a<i;a++)o[a]=r(o[a]);return o},R0=(e,t,r)=>{let o=[...e],n=r?o.indexOf(r):-1,i=n>-1?n:o.length;return o.splice(i,0,t),o},N0=(e,t)=>e.filter(r=>!t[r]),na=(e,t)=>{let r=new Map;return e.forEach(o=>{let n=o.groupIds.length===0?o.id:o.groupIds[o.groupIds.length-1],i=r.get(n)||[],a=pe(o,t);a&&i.push(a),r.set(n,[...i,o])}),Array.from(r.values())}});import{sanitizeUrl as UI}from"@braintree/sanitize-url";var lr,zd,Gd,rl=j(()=>{"use strict";f();lr=e=>(e=e.trim(),e&&UI(e)),zd=e=>!!(e?.includes(location.origin)||e?.startsWith("/")),Gd=e=>{if(e=lr(e),e.startsWith("/"))return`${location.origin}${e}`;try{new URL(e)}catch{return"about:blank"}return e}});var Ud,B,Ye=j(()=>{"use strict";f();Ud=[],B=e=>(Ud=Ud.concat(e),e)});import Wd from"open-color";var B0,WI,F0,VI,YI,Or,He,Vo,O0,Ph,Br,ol=j(()=>{"use strict";f();G();Rr();B0='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',WI='<path d="M6.164 11.755a5.314 5.314 0 0 1-4.932-5.298 5.314 5.314 0 0 1 5.311-5.311 5.314 5.314 0 0 1 5.307 5.113l8.773 8.773a3.322 3.322 0 0 1 0 4.696l-.895.895a3.322 3.322 0 0 1-4.696 0l-8.868-8.868Z" style="fill:#fff"/>',F0='<path stroke="#1b1b1f" fill="#fff" d="m7.868 11.113 7.773 7.774a2.359 2.359 0 0 0 1.667.691 2.368 2.368 0 0 0 2.357-2.358c0-.625-.248-1.225-.69-1.667L11.201 7.78 9.558 9.469l-1.69 1.643v.001Zm10.273 3.606-3.333 3.333m-3.25-6.583 2 2m-7-7 3 3M3.664 3.625l1 1M2.529 6.922l1.407-.144m5.735-2.932-1.118.866M4.285 9.823l.758-1.194m1.863-6.207-.13 1.408"/>',VI=`data:${J.svg},${encodeURIComponent(`${B0}${F0}</svg>`)}`,YI=`data:${J.svg},${encodeURIComponent(`${B0}${WI}${F0}</svg>`)}`,Or=e=>{e&&(e.style.cursor="")},He=(e,t)=>{e&&(e.style.cursor=t)},Ph=(e,t)=>{let o=()=>{let n=t===oe.DARK;Vo=document.createElement("canvas"),Vo.theme=t,Vo.height=20,Vo.width=20;let i=Vo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Vo.width/2,Vo.height/2,5,0,2*Math.PI),i.fillStyle=n?Wd.black:Wd.white,i.fill(),i.strokeStyle=n?Wd.white:Wd.black,i.stroke(),O0=Vo.toDataURL(J.svg)};(!Vo||Vo.theme!==t)&&o(),He(e,`url(${O0}) ${20/2} ${20/2}, auto`)},Br=(e,t)=>{if(e)if(t.activeTool.type==="selection")Or(e);else if(Co(t))e.style.cursor=Ce.GRAB;else if(xr(t))Ph(e,t.theme);else if(t.activeTool.type==="laser"){let r=t.theme===oe.LIGHT?VI:YI;e.style.cursor=`url(${r}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=Ce.AUTO):e.style.cursor=Ce.CROSSHAIR}});var Tn,Fr,_h,H0,Kd,Bs,z0,Nt,KI,nl,Dh,G0,Qr,Fs,Vd,Sn,Yd,Hs,$d,In=j(()=>{"use strict";f();z();Eo();We();Nr();ge();Rt();at();ut();G();Tn=(e,{x:t,y:r,strokeColor:o=Qe.strokeColor,backgroundColor:n=Qe.backgroundColor,fillStyle:i=Qe.fillStyle,strokeWidth:a=Qe.strokeWidth,strokeStyle:l=Qe.strokeStyle,roughness:s=Qe.roughness,opacity:c=Qe.opacity,width:d=0,height:m=0,angle:p=0,groupIds:u=[],frameId:h=null,index:x=null,roundness:E=null,boundElements:v=null,link:w=null,locked:y=Qe.locked,...I})=>({id:I.id||Pt(),type:e,x:t,y:r,width:d,height:m,angle:p,strokeColor:o,backgroundColor:n,fillStyle:i,strokeWidth:a,strokeStyle:l,roughness:s,opacity:c,groupIds:u,frameId:h,index:x,roundness:E,seed:I.seed??qr(),version:I.version||1,versionNonce:I.versionNonce??0,isDeleted:!1,boundElements:v,updated:gn(),link:w,locked:y,customData:I.customData}),Fr=e=>Tn(e.type,e),_h=e=>Tn("embeddable",e),H0=e=>({...Tn("iframe",e)}),Kd=e=>ne({...Tn("frame",e),type:"frame",name:e?.name||null},{}),Bs=e=>ne({...Tn("magicframe",e),type:"magicframe",name:e?.name||null},{}),z0=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),Nt=e=>{let t=e.fontFamily||Wt,r=e.fontSize||At,o=e.lineHeight||_r(t),n=ni(e.text),i=Io(n,Ge({fontFamily:t,fontSize:r}),o),a=e.textAlign||Yn,l=e.verticalAlign||Hi,s=z0({textAlign:a,verticalAlign:l},i);return ne({...Tn("text",e),text:n,fontSize:r,fontFamily:t,textAlign:a,verticalAlign:l,x:e.x-s.x,y:e.y-s.y,width:i.width,height:i.height,containerId:e.containerId||null,originalText:n,lineHeight:o},{})},KI=(e,t,r)=>{let{width:o,height:n}=Io(r,Ge(e),e.lineHeight),{textAlign:i,verticalAlign:a}=e,l,s;if(i==="center"&&a===ft.MIDDLE&&!e.containerId){let c=Io(e.text,Ge(e),e.lineHeight),d=z0(e,{width:o-c.width,height:n-c.height});l=e.x-d.x,s=e.y-d.y}else{let[c,d,m,p]=te(e,t),[u,h,x,E]=ra(e,o,n,!1),v=(c-u)/2,w=(d-h)/2,y=(m-x)/2,I=(p-E)/2;[l,s]=xd({s:!0,e:i==="center"||i==="left",w:i==="center"||i==="right"},e.x,e.y,e.angle,v,w,y,I)}return{width:o,height:n,x:Number.isFinite(l)?l:e.x,y:Number.isFinite(s)?s:e.y}},nl=(e,t,r,o=e.text)=>{if(e.isDeleted)return;t&&(o=ai(o,Ge(e),fr(t,e)));let n=KI(e,r,o);return{text:o,...n}},Dh=(e,t,r,{text:o,isDeleted:n,originalText:i})=>ne(e,{originalText:i,isDeleted:n??e.isDeleted,...nl(e,t,r,i)}),G0=e=>({...Tn(e.type,e),points:e.points||[],pressures:[],simulatePressure:e.simulatePressure,lastCommittedPoint:null}),Qr=e=>({...Tn(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null}),Fs=e=>({...Tn("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1]}),Vd=(e,t=0)=>{if(e==null||typeof e!="object")return e;let r=Object.prototype.toString.call(e);if(r==="[object Object]"){let o=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(t===0&&(n==="shape"||n==="canvas"))continue;o[n]=Vd(e[n],t+1)}return o}if(Array.isArray(e)){let o=e.length,n=new Array(o);for(;o--;)n[o]=Vd(e[o],t+1);return n}return T.DEV&&r!=="[object Object]"&&r!=="[object Array]"&&r.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${r}. This value will not be cloned!`),e},Sn=e=>Vd(e),Yd=e=>{if(Ar()&&e){let t=`${e}_copy`;return window.h?.app?.getSceneElementsIncludingDeleted().find(r=>r.id===t)&&(t+="_copy"),t}return Pt()},Hs=(e,t,r,o)=>{let n=Sn(r);return n.id=Yd(n.id),n.boundElements=null,n.updated=gn(),n.seed=qr(),n.groupIds=D0(n.groupIds,e,i=>(t.has(i)||t.set(i,Yd(i)),t.get(i))),o&&(n=Object.assign(n,o)),n},$d=(e,t)=>{let r=[],o=$(e),n=new Map,i=l=>{if(n.has(l))return n.get(l);if(o.has(l)){let s=Yd(l);return n.set(l,s),s}return null},a=new Map;for(let l of e){let s=Vd(l);if(s.id=i(l.id),t?.randomizeSeed&&(s.seed=qr(),li(s)),s.groupIds&&(s.groupIds=s.groupIds.map(c=>(a.has(c)||a.set(c,Yd(c)),a.get(c)))),"containerId"in s&&s.containerId){let c=i(s.containerId);s.containerId=c}if("boundElements"in s&&s.boundElements&&(s.boundElements=s.boundElements.reduce((c,d)=>{let m=i(d.id);return m&&c.push({...d,id:m}),c},[])),"endBinding"in s&&s.endBinding){let c=i(s.endBinding.elementId);s.endBinding=c?{...s.endBinding,elementId:c}:null}if("startBinding"in s&&s.startBinding){let c=i(s.startBinding.elementId);s.startBinding=c?{...s.startBinding,elementId:c}:null}s.frameId&&(s.frameId=i(s.frameId)),r.push(s)}return r}});var Cn,$I,XI,ZI,jI,qI,JI,QI,e6,t6,U0,Rh,ia,kn,Xd,o9,W0,V0,il,zs=j(()=>{"use strict";f();Ye();G();z();ol();In();ut();ce();Cn=new Map,$I=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)(?:\?t=|&t=|\?start=|&start=)?([a-zA-Z0-9_-]+)?[^\s]*$/,XI=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,ZI=/^https:\/\/(?:www\.)?figma\.com/,jI=/^https:\/\/gist\.github\.com/,qI=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist.github.com\/.*?)\.js["']/i,JI=/(?:http(?:s)?:\/\/)?(?:(?:w){3}.)?(?:twitter|x).com/,QI=/^<blockquote[\s\S]*?\shref=["'](https:\/\/(?:twitter|x).com\/[^"']*)/i,e6=/^https:\/\/(?:www\.)?val.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,t6=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,U0=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,Rh=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","link.excalidraw.com","gist.github.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","val.town","giphy.com","dddice.com"]),ia=e=>`<html><body>${e}</body></html>`,kn=e=>{if(!e)return null;if(Cn.has(e))return Cn.get(e);let t=e,r="generic",o={w:560,h:840},n=e.match($I);if(n?.[2]){let s=n[3]?`&start=${n[3]}`:"",c=e.includes("shorts");switch(r="video",n[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${n[2]}?enablejsapi=1${s}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${n[2]}&enablejsapi=1${s}`;break;default:e=`https://www.youtube.com/embed/${n[2]}?enablejsapi=1${s}`;break}return o=c?{w:315,h:560}:{w:560,h:315},Cn.set(t,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r}}let i=e.match(XI);if(i?.[1]){let s=i?.[1],c=/^\d+$/.test(s)?void 0:new URIError("Invalid embed link format");return r="video",e=`https://player.vimeo.com/video/${s}?api=1`,o={w:560,h:315},Cn.set(t,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r,error:c}}if(e.match(ZI))return r="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,o={w:550,h:550},Cn.set(t,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r};let l=e.match(e6);if(l)return e=l[1]==="embed"?l[0]:l[0].replace("/v","/embed"),Cn.set(t,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r};if(JI.test(e)){e=e.replace(/\bx.com\b/,"twitter.com");let s;if(/<blockquote/.test(e)){let c=ia(e);s={type:"document",srcdoc:()=>c,intrinsicSize:{w:480,h:480}}}else s={type:"document",srcdoc:c=>ia(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${c}"><a href="${e}"></a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`),intrinsicSize:{w:480,h:480}};return Cn.set(t,s),s}if(jI.test(e)){let s;if(/<script>/.test(e)){let c=ia(e);s={type:"document",srcdoc:()=>c,intrinsicSize:{w:550,h:720}}}else s={type:"document",srcdoc:()=>ia(`
16
- <script src="${e}.js"><\/script>
12
+ `);let o=parseFloat(t),n=_I(e,o,r);return{width:Os(e,t),height:n}},y0=e=>{let t=Sh(e.text).length;return e.height/t/e.fontSize},ii=(e,t)=>e*t,_d=(e,t,r)=>{let{unitsPerEm:o,ascender:n,descender:i}=E0[e]||E0[it.Helvetica],a=t/o,l=r-a*n+a*i;return a*n+l},Dd=(e,t)=>ii(e,t)+ht*2,Ns=(e,t)=>{vh||(vh=document.createElement("canvas"));let r=vh.getContext("2d");r.font=t;let o=r.measureText(e).width;return Ar()?o*10:o},Os=(e,t)=>{let r=Sh(e),o=0;return r.forEach(n=>{o=Math.max(o,Ns(n,t))}),o},_I=(e,t,r)=>{let o=Sh(e).length;return ii(t,r)*o},DI=e=>{let t=e.split("-");return t.length>1&&t.forEach((r,o)=>{o!==t.length-1&&(t[o]=r+="-")}),t.join(" ").split(" ")},ai=(e,t,r)=>{if(!Number.isFinite(r)||r<0)return e;let o=[],n=e.split(`
13
+ `),i=Ns(" ",t),a="",l=0,s=d=>{d.trim()&&o.push(d)},c=()=>{a="",l=0};return n.forEach(d=>{if(Os(d,t)<=r){o.push(d);return}let p=DI(d);c();let u=0;for(;u<p.length;){let h=Ns(p[u],t);if(h===r)s(p[u]),u++;else if(h>r){for(s(a),c();p[u].length>0;){let x=String.fromCodePoint(p[u].codePointAt(0)),E=w0.calculate(x,t);l+=E,p[u]=p[u].slice(x.length),l>=r?(s(a),a=x,l=E):a+=x}l+i>=r?(s(a),c()):a.endsWith("-")||(a+=" ",l+=i),u++}else for(;l<r&&u<p.length;){let x=p[u];if(l=Ns(a+x,t),l>r){s(a),c();break}u++;let E=!x.endsWith("-");if(a+=x,E&&(a+=" "),l+i>=r){E?o.push(a.slice(0,-1)):o.push(a),c();break}}}a.slice(-1)===" "&&(a=a.slice(0,-1),s(a))}),o.join(`
14
+ `)},w0=(()=>{let e={};return{calculate:(o,n)=>{let i=o.charCodeAt(0);if(e[n]||(e[n]=[]),!e[n][i]){let a=Ns(o,n);e[n][i]=a}return e[n][i]},getCache:o=>e[o]}})(),v0="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),Rd=(e,t)=>{let r=RI(e);return r===0?Io(v0.split("").join(`
15
+ `),e,t).width+ht*2:r+ht*2},RI=e=>{let t=w0.getCache(e);if(!t)return 0;let r=t.filter(o=>o!==void 0);return Math.max(...r)},wn=e=>e?.boundElements?.length&&e?.boundElements?.filter(t=>t.type==="text")[0]?.id||null,de=(e,t)=>{if(!e)return null;let r=wn(e);return r&&t.get(r)||null},st=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,Nd=(e,t,r)=>{if(!Te(e))return{x:e.x+e.width/2,y:e.y+e.height/2};let o=K.getPointsGlobalCoordinates(e,r);if(o.length%2===1){let a=Math.floor(e.points.length/2),l=K.getPointGlobalCoordinates(e,e.points[a],r);return{x:l[0],y:l[1]}}let n=e.points.length/2-1,i=K.getEditorMidPoints(e,r,t)[n];return i||(i=K.getSegmentMidPoint(e,o[n],o[n+1],n+1,r)),{x:i[0],y:i[1]}},Ih=e=>{let t=ht,r=ht;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),r+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,r+=e.height/4),{x:e.x+t,y:e.y+r}},T0=(e,t)=>!t||Te(t)?e.angle:t.angle,S0=(e,t)=>e.some(r=>{if(Ne(r)){let o=st(r,t);return!Te(o)}return!1}),I0=(e,t)=>e.some(r=>{if(Ne(r)){let o=st(r,t);return!Te(o)}return G(r)}),NI=new Set(["rectangle","ellipse","diamond","arrow"]),C0=e=>NI.has(e.type),yn=(e,t)=>{e=Math.ceil(e);let r=ht*2;return t==="ellipse"?Math.round((e+r)/Math.sqrt(2)*2):t==="arrow"?e+r*8:t==="diamond"?2*(e+r):e+r},fr=(e,t)=>{let{width:r}=e;if(Te(e)){let o=(t?.fontSize??At)*ex;return Math.max(Qb*r,o)}return e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-ht*2:e.type==="diamond"?Math.round(r/2)-ht*2:r-ht*2},ta=(e,t)=>{let{height:r}=e;return Te(e)?r-ht*8*2<=0?t.height:r:e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-ht*2:e.type==="diamond"?Math.round(r/2)-ht*2:r-ht*2},k0=()=>Os(v0,Ge({fontSize:At,fontFamily:Wt}))>0,Th={[it.Virgil]:1.25,[it.Helvetica]:1.15,[it.Cascadia]:1.2},E0={[it.Virgil]:{unitsPerEm:1e3,ascender:886,descender:-374},[it.Helvetica]:{unitsPerEm:2048,ascender:1577,descender:-471},[it.Cascadia]:{unitsPerEm:2048,ascender:1977,descender:-480},[it.Assistant]:{unitsPerEm:1e3,ascender:1021,descender:-287}},_r=e=>e in Th?Th[e]:Th[Wt]});import kh from"roughjs/bin/rough";var Ch,te,Ah,eh,ti,A0,M0,OI,Rs,Mh,BI,FI,HI,th,zI,GI,Dr,we,Od,ra,el,Lh,br,UI,at=j(()=>{"use strict";f();Rt();Qu();ce();ws();lt();Qt();Go();z();Ch=class e{static boundsCache=new WeakMap;static getBounds(t,r){let o=e.boundsCache.get(t);if(o?.version&&o.version===t.version&&!Ne(t))return o.bounds;let n=e.calculateBounds(t,r);return e.boundsCache.set(t,{version:t.version,bounds:n}),n}static calculateBounds(t,r){let o,[n,i,a,l,s,c]=te(t,r);if(Lt(t)){let[d,m,p,u]=Mh(t.points.map(([h,x])=>Ee(h,x,s-t.x,c-t.y,t.angle)));return[d+t.x,m+t.y,p+t.x,u+t.y]}else if(re(t))o=GI(t,s,c,r);else if(t.type==="diamond"){let[d,m]=Ee(s,i,s,c,t.angle),[p,u]=Ee(s,l,s,c,t.angle),[h,x]=Ee(n,c,s,c,t.angle),[E,v]=Ee(a,c,s,c,t.angle),w=Math.min(d,p,h,E),y=Math.min(m,u,x,v),I=Math.max(d,p,h,E),P=Math.max(m,u,x,v);o=[w,y,I,P]}else if(t.type==="ellipse"){let d=(a-n)/2,m=(l-i)/2,p=Math.cos(t.angle),u=Math.sin(t.angle),h=Math.hypot(d*p,m*u),x=Math.hypot(m*p,d*u);o=[s-h,c-x,s+h,c+x]}else{let[d,m]=Ee(n,i,s,c,t.angle),[p,u]=Ee(n,l,s,c,t.angle),[h,x]=Ee(a,l,s,c,t.angle),[E,v]=Ee(a,i,s,c,t.angle),w=Math.min(d,p,h,E),y=Math.min(m,u,x,v),I=Math.max(d,p,h,E),P=Math.max(m,u,x,v);o=[w,y,I,P]}return o}},te=(e,t,r=!1)=>{if(Lt(e))return BI(e);if(re(e))return K.getElementAbsoluteCoords(e,t,r);if(G(e)){let o=t?st(e,t):null;if(Te(o)){let n=K.getBoundTextElementPosition(o,e,t);return[n.x,n.y,n.x+e.width,n.y+e.height,n.x+e.width/2,n.y+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]},Ah=(e,t)=>{let[r,o,n,i,a,l]=te(e,t),s=[a,l];if(re(e)||Lt(e)){let v=[],w=0;for(;w<e.points.length-1;)v.push([Ze([e.points[w][0]+e.x,e.points[w][1]+e.y],s,e.angle),Ze([e.points[w+1][0]+e.x,e.points[w+1][1]+e.y],s,e.angle)]),w++;return v}let[c,d,m,p,u,h,x,E]=[[r,o],[n,o],[r,i],[n,i],[a,o],[a,i],[r,l],[n,l]].map(v=>Ze(v,s,e.angle));return e.type==="diamond"?[[u,x],[u,E],[h,x],[h,E]]:e.type==="ellipse"?[[u,x],[u,E],[h,x],[h,E],[u,x],[u,E],[h,x],[h,E]]:[[c,d],[m,p],[c,m],[d,p],[c,E],[m,E],[d,x],[p,x]]},eh=e=>{let t=Math.floor(e.width/2)+1,r=0,o=e.width,n=Math.floor(e.height/2)+1,i=t,a=e.height;return[t,r,o,n,i,a,0,n]},ti=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},A0=(e,t,r,o,n)=>{let i=1-e;return Math.pow(i,3)*t+3*Math.pow(i,2)*e*r+3*i*Math.pow(e,2)*o+Math.pow(e,3)*n},M0=(e,t,r,o)=>{let n=t-e,i=r-t,a=o-r,l=3*n-6*i+3*a,s=6*i-6*n,c=3*n,d=s*s-4*l*c;if(!(d>=0))return!1;let p=null,u=null,h=1/0,x=1/0;return l===0?h=x=-c/s:(h=(-s+Math.sqrt(d))/(2*l),x=(-s-Math.sqrt(d))/(2*l)),h>=0&&h<=1&&(p=A0(h,e,t,r,o)),x>=0&&x<=1&&(u=A0(x,e,t,r,o)),[p,u]},OI=(e,t,r,o)=>{let n=M0(e[0],t[0],r[0],o[0]),i=M0(e[1],t[1],r[1],o[1]),a=Math.min(e[0],o[0]),l=Math.max(e[0],o[0]);if(n){let d=n.filter(m=>m!==null);a=Math.min(a,...d),l=Math.max(l,...d)}let s=Math.min(e[1],o[1]),c=Math.max(e[1],o[1]);if(i){let d=i.filter(m=>m!==null);s=Math.min(s,...d),c=Math.max(c,...d)}return[a,s,l,c]},Rs=(e,t)=>{let r=[0,0],{minX:o,minY:n,maxX:i,maxY:a}=e.reduce((l,{op:s,data:c})=>{if(s==="move")r=c;else if(s==="bcurveTo"){let d=[c[0],c[1]],m=[c[2],c[3]],p=[c[4],c[5]],u=t?t(...d):d,h=t?t(...m):m,x=t?t(...p):p,E=t?t(...r):r;r=p;let[v,w,y,I]=OI(E,u,h,x);l.minX=Math.min(l.minX,v),l.minY=Math.min(l.minY,w),l.maxX=Math.max(l.maxX,y),l.maxY=Math.max(l.maxY,I)}return l},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[o,n,i,a]},Mh=e=>{let t=1/0,r=1/0,o=-1/0,n=-1/0;for(let[i,a]of e)t=Math.min(t,i),r=Math.min(r,a),o=Math.max(o,i),n=Math.max(n,a);return[t,r,o,n]},BI=e=>{let[t,r,o,n]=Mh(e.points),i=t+e.x,a=r+e.y,l=o+e.x,s=n+e.y;return[i,a,l,s,(i+l)/2,(a+s)/2]},FI=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;default:return 15}},HI=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},th=(e,t,r,o)=>{let n=ti(t[0]);if(n.length<1)return null;let i=r==="start"?1:n.length-1,a=n[i].data,l=[a[4],a[5]],s=[a[2],a[3]],c=[a[0],a[1]],d=n[i-1],m=[0,0];d.op==="move"?m=d.data:d.op==="bcurveTo"&&(m=[d.data[4],d.data[5]]);let p=(Y,ee)=>Math.pow(1-Y,3)*l[ee]+3*Y*Math.pow(1-Y,2)*s[ee]+3*Math.pow(Y,2)*(1-Y)*c[ee]+m[ee]*Math.pow(Y,3),[u,h]=r==="start"?m:l,[x,E]=[p(.3,0),p(.3,1)],v=Math.hypot(u-x,h-E),w=(u-x)/v,y=(h-E)/v,I=FI(o),P=0;{let[Y,ee]=r==="end"?e.points[e.points.length-1]:e.points[0],[xe,le]=e.points.length>1?r==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];P=Math.hypot(Y-xe,ee-le)}let _=Math.min(I,P*(o==="diamond"||o==="diamond_outline"?.25:.5)),D=u-w*_,H=h-y*_;if(o==="dot"||o==="circle"||o==="circle_outline"){let Y=Math.hypot(H-h,D-u)+e.strokeWidth-2;return[u,h,Y]}let A=HI(o),[M,k]=Ee(D,H,u,h,-A*Math.PI/180),[O,X]=Ee(D,H,u,h,A*Math.PI/180);if(o==="diamond"||o==="diamond_outline"){let Y,ee;if(r==="start"){let[xe,le]=e.points.length>1?e.points[1]:[0,0];[Y,ee]=Ee(u+_*2,h,u,h,Math.atan2(le-h,xe-u))}else{let[xe,le]=e.points.length>1?e.points[e.points.length-2]:[0,0];[Y,ee]=Ee(u-_*2,h,u,h,Math.atan2(h-le,u-xe))}return[u,h,M,k,Y,ee,O,X]}return[u,h,M,k,O,X]},zI=e=>{let t=kh.generator(),r=Lr(e),o=e.roundness?"curve":r.fill?"polygon":"linearPath";return t[o](e.points,r)},GI=(e,t,r,o)=>{let n=de(e,o);if(e.points.length<2){let[m,p]=e.points[0],[u,h]=Ee(e.x+m,e.y+p,t,r,e.angle),x=[u,h,u,h];if(n){let E=K.getMinMaxXYWithBoundText(e,o,[u,h,u,h],n);x=[E[0],E[1],E[2],E[3]]}return x}let a=ke.get(e)?.[0]??zI(e),l=ti(a),c=Rs(l,(m,p)=>Ee(e.x+m,e.y+p,t,r,e.angle)),d=[c[0],c[1],c[2],c[3]];if(n){let m=K.getMinMaxXYWithBoundText(e,o,d,n);d=[m[0],m[1],m[2],m[3]]}return d},Dr=(e,t)=>Ch.getBounds(e,t),we=e=>{if(!e.length)return[0,0,0,0];let t=1/0,r=-1/0,o=1/0,n=-1/0,i=$(e);return e.forEach(a=>{let[l,s,c,d]=Dr(a,i);t=Math.min(t,l),o=Math.min(o,s),r=Math.max(r,c),n=Math.max(n,d)}),[t,o,r,n]},Od=(e,t)=>{let[r,o,n,i]=we(e);return[r+t.x,o+t.y,n+t.x,i+t.y]},ra=(e,t,r,o)=>{if(!(re(e)||Lt(e)))return[e.x,e.y,e.x+t,e.y+r];let n=ei(0,t,ei(1,r,e.points,o),o),i;if(Lt(e))i=Mh(n);else{let d=kh.generator(),m=e.roundness?d.curve(n,Lr(e)):d.linearPath(n,Lr(e)),p=ti(m);i=Rs(p)}let[a,l,s,c]=i;return[a+e.x,l+e.y,s+e.x,c+e.y]},el=(e,t)=>{let r=kh.generator(),o=e.roundness==null?r.linearPath(t,Lr(e)):r.curve(t,Lr(e)),n=ti(o),[i,a,l,s]=Rs(n);return[i+e.x,a+e.y,l+e.x,s+e.y]},Lh=(e,t)=>{if(!e.length)return[0,0,0,0];let r=1/0,o=e[0],n=$(e);return e.forEach(i=>{let[a,l,s,c]=Dr(i,n),d=xt((a+s)/2,(l+c)/2,t.x,t.y);d<r&&(r=d,o=i)}),Dr(o,n)},br=e=>{let[t,r,o,n]=we(e);return{minX:t,minY:r,maxX:o,maxY:n,width:o-t,height:n-r,midX:(t+o)/2,midY:(r+n)/2}},UI=({scrollX:e,scrollY:t,width:r,height:o,zoom:n})=>[-e,-t,-e+r/n.value,-t+o/n.value]});var WI,ar,VI,L0,Bd,P0,xr,Co,Rr=j(()=>{"use strict";f();Zt();U();WI=Fa.includes(devicePixelRatio)?devicePixelRatio:1,ar=()=>({showWelcomeScreen:!1,theme:oe.LIGHT,collaborators:new Map,currentChartType:"bar",currentItemBackgroundColor:Qe.backgroundColor,currentItemEndArrowhead:"arrow",currentItemFillStyle:Qe.fillStyle,currentItemFontFamily:Wt,currentItemFontSize:At,currentItemOpacity:Qe.opacity,currentItemRoughness:Qe.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:Qe.strokeColor,currentItemRoundness:"round",currentItemStrokeStyle:Qe.strokeStyle,currentItemStrokeWidth:Qe.strokeWidth,currentItemTextAlign:Yn,cursorButton:"up",activeEmbeddable:null,draggingElement:null,editingElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:"selection",customType:null,locked:Qe.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:WI,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:null,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:"mouse",multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,showStats:!1,startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:se.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set}),VI=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},draggingElement:{browser:!1,export:!1,server:!1},editingElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},showStats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1}}),L0=(e,t)=>{let r={};for(let o of Object.keys(e))if(VI[o]?.[t]){let i=e[o];r[o]=i}return r},Bd=e=>L0(e,"export"),P0=e=>L0(e,"server"),xr=({activeTool:e})=>e.type==="eraser",Co=({activeTool:e})=>e.type==="hand"});var Ph,Kt,Fd,_h,vn,Hd,_0,oa,Je,D0,R0,N0,O0,na,Nr=j(()=>{"use strict";f();Ve();lt();Qn();Ph=(e,t,r)=>{let o=r.reduce((n,i)=>(i.groupIds.includes(e)&&(n[i.id]=!0),n),{});return Object.keys(o).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...o}}},Kt=function(){let e=null,t=null,r=null,o=(i,a,l,s)=>{if(r!==void 0&&a===t&&i===e&&l.editingGroupId===r?.editingGroupId)return r;let c={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let h=u.indexOf(l.editingGroupId);h>-1&&(u=u.slice(0,h))}if(u.length>0){let h=u[u.length-1];c[h]=!0}}let d={},m=a.reduce((p,u)=>{let h=u.groupIds.find(x=>c[x]);return h&&(p[u.id]=!0,Array.isArray(d[h])?d[h].push(u.id):d[h]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return t=a,e=i,r={editingGroupId:l.editingGroupId,selectedGroupIds:c,selectedElementIds:Pe({...l.selectedElementIds,...m},s)},r},n=(i,a,l,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):pe(a,i);return c.length?o(c,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Pe(i.selectedElementIds,l)}};return n.clearCache=()=>{t=null,e=null,r=null},n}(),Fd=(e,t)=>_h(e,t)!=null,_h=(e,t)=>t.groupIds.filter(r=>r!==e.editingGroupId).find(r=>e.selectedGroupIds[r]),vn=e=>Object.entries(e.selectedGroupIds).filter(([t,r])=>r).map(([t,r])=>t),Hd=(e,t)=>{let r={...t,selectedGroupIds:{}};for(let o of e){let n=o.groupIds;if(t.editingGroupId){let i=n.indexOf(t.editingGroupId);i>-1&&(n=n.slice(0,i))}if(n.length>0){let i=n[n.length-1];r={...r,...Ph(i,r,e)}}}return r.selectedGroupIds},_0=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),oa=(e,t)=>e.groupIds.includes(t),Je=(e,t)=>{let r=[];for(let o of e.values())oa(o,t)&&r.push(o);return r},D0=(e,t)=>e.groupIds.find(r=>t[r]),R0=(e,t,r)=>{let o=[...e],n=t?e.indexOf(t):-1,i=n>-1?n:e.length;for(let a=0;a<i;a++)o[a]=r(o[a]);return o},N0=(e,t,r)=>{let o=[...e],n=r?o.indexOf(r):-1,i=n>-1?n:o.length;return o.splice(i,0,t),o},O0=(e,t)=>e.filter(r=>!t[r]),na=(e,t)=>{let r=new Map;return e.forEach(o=>{let n=o.groupIds.length===0?o.id:o.groupIds[o.groupIds.length-1],i=r.get(n)||[],a=de(o,t);a&&i.push(a),r.set(n,[...i,o])}),Array.from(r.values())}});import{sanitizeUrl as YI}from"@braintree/sanitize-url";var zd,lr,Gd,Ud,ia=j(()=>{"use strict";f();zd=e=>e.replace(/"/g,"&quot;"),lr=e=>(e=e.trim(),e&&YI(zd(e))),Gd=e=>!!(e?.includes(location.origin)||e?.startsWith("/")),Ud=e=>{if(e=lr(e),e.startsWith("/"))return`${location.origin}${e}`;try{new URL(e)}catch{return"about:blank"}return e}});var Wd,B,Ye=j(()=>{"use strict";f();Wd=[],B=e=>(Wd=Wd.concat(e),e)});import Vd from"open-color";var F0,KI,H0,$I,XI,Or,He,Vo,B0,Dh,Br,ol=j(()=>{"use strict";f();U();Rr();F0='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',KI='<path d="M6.164 11.755a5.314 5.314 0 0 1-4.932-5.298 5.314 5.314 0 0 1 5.311-5.311 5.314 5.314 0 0 1 5.307 5.113l8.773 8.773a3.322 3.322 0 0 1 0 4.696l-.895.895a3.322 3.322 0 0 1-4.696 0l-8.868-8.868Z" style="fill:#fff"/>',H0='<path stroke="#1b1b1f" fill="#fff" d="m7.868 11.113 7.773 7.774a2.359 2.359 0 0 0 1.667.691 2.368 2.368 0 0 0 2.357-2.358c0-.625-.248-1.225-.69-1.667L11.201 7.78 9.558 9.469l-1.69 1.643v.001Zm10.273 3.606-3.333 3.333m-3.25-6.583 2 2m-7-7 3 3M3.664 3.625l1 1M2.529 6.922l1.407-.144m5.735-2.932-1.118.866M4.285 9.823l.758-1.194m1.863-6.207-.13 1.408"/>',$I=`data:${J.svg},${encodeURIComponent(`${F0}${H0}</svg>`)}`,XI=`data:${J.svg},${encodeURIComponent(`${F0}${KI}${H0}</svg>`)}`,Or=e=>{e&&(e.style.cursor="")},He=(e,t)=>{e&&(e.style.cursor=t)},Dh=(e,t)=>{let o=()=>{let n=t===oe.DARK;Vo=document.createElement("canvas"),Vo.theme=t,Vo.height=20,Vo.width=20;let i=Vo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Vo.width/2,Vo.height/2,5,0,2*Math.PI),i.fillStyle=n?Vd.black:Vd.white,i.fill(),i.strokeStyle=n?Vd.white:Vd.black,i.stroke(),B0=Vo.toDataURL(J.svg)};(!Vo||Vo.theme!==t)&&o(),He(e,`url(${B0}) ${20/2} ${20/2}, auto`)},Br=(e,t)=>{if(e)if(t.activeTool.type==="selection")Or(e);else if(Co(t))e.style.cursor=Ce.GRAB;else if(xr(t))Dh(e,t.theme);else if(t.activeTool.type==="laser"){let r=t.theme===oe.LIGHT?$I:XI;e.style.cursor=`url(${r}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=Ce.AUTO):e.style.cursor=Ce.CROSSHAIR}});var Tn,Fr,Rh,z0,$d,Bs,G0,Nt,ZI,nl,Nh,U0,Qr,Fs,Yd,Sn,Kd,Hs,Xd,In=j(()=>{"use strict";f();z();Eo();We();Nr();ge();Rt();at();lt();U();Tn=(e,{x:t,y:r,strokeColor:o=Qe.strokeColor,backgroundColor:n=Qe.backgroundColor,fillStyle:i=Qe.fillStyle,strokeWidth:a=Qe.strokeWidth,strokeStyle:l=Qe.strokeStyle,roughness:s=Qe.roughness,opacity:c=Qe.opacity,width:d=0,height:m=0,angle:p=0,groupIds:u=[],frameId:h=null,index:x=null,roundness:E=null,boundElements:v=null,link:w=null,locked:y=Qe.locked,...I})=>({id:I.id||Pt(),type:e,x:t,y:r,width:d,height:m,angle:p,strokeColor:o,backgroundColor:n,fillStyle:i,strokeWidth:a,strokeStyle:l,roughness:s,opacity:c,groupIds:u,frameId:h,index:x,roundness:E,seed:I.seed??qr(),version:I.version||1,versionNonce:I.versionNonce??0,isDeleted:!1,boundElements:v,updated:gn(),link:w,locked:y,customData:I.customData}),Fr=e=>Tn(e.type,e),Rh=e=>Tn("embeddable",e),z0=e=>({...Tn("iframe",e)}),$d=e=>ne({...Tn("frame",e),type:"frame",name:e?.name||null},{}),Bs=e=>ne({...Tn("magicframe",e),type:"magicframe",name:e?.name||null},{}),G0=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),Nt=e=>{let t=e.fontFamily||Wt,r=e.fontSize||At,o=e.lineHeight||_r(t),n=ni(e.text),i=Io(n,Ge({fontFamily:t,fontSize:r}),o),a=e.textAlign||Yn,l=e.verticalAlign||Hi,s=G0({textAlign:a,verticalAlign:l},i);return ne({...Tn("text",e),text:n,fontSize:r,fontFamily:t,textAlign:a,verticalAlign:l,x:e.x-s.x,y:e.y-s.y,width:i.width,height:i.height,containerId:e.containerId||null,originalText:n,lineHeight:o},{})},ZI=(e,t,r)=>{let{width:o,height:n}=Io(r,Ge(e),e.lineHeight),{textAlign:i,verticalAlign:a}=e,l,s;if(i==="center"&&a===ft.MIDDLE&&!e.containerId){let c=Io(e.text,Ge(e),e.lineHeight),d=G0(e,{width:o-c.width,height:n-c.height});l=e.x-d.x,s=e.y-d.y}else{let[c,d,m,p]=te(e,t),[u,h,x,E]=ra(e,o,n,!1),v=(c-u)/2,w=(d-h)/2,y=(m-x)/2,I=(p-E)/2;[l,s]=xd({s:!0,e:i==="center"||i==="left",w:i==="center"||i==="right"},e.x,e.y,e.angle,v,w,y,I)}return{width:o,height:n,x:Number.isFinite(l)?l:e.x,y:Number.isFinite(s)?s:e.y}},nl=(e,t,r,o=e.text)=>{if(e.isDeleted)return;t&&(o=ai(o,Ge(e),fr(t,e)));let n=ZI(e,r,o);return{text:o,...n}},Nh=(e,t,r,{text:o,isDeleted:n,originalText:i})=>ne(e,{originalText:i,isDeleted:n??e.isDeleted,...nl(e,t,r,i)}),U0=e=>({...Tn(e.type,e),points:e.points||[],pressures:[],simulatePressure:e.simulatePressure,lastCommittedPoint:null}),Qr=e=>({...Tn(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null}),Fs=e=>({...Tn("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1]}),Yd=(e,t=0)=>{if(e==null||typeof e!="object")return e;let r=Object.prototype.toString.call(e);if(r==="[object Object]"){let o=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(t===0&&(n==="shape"||n==="canvas"))continue;o[n]=Yd(e[n],t+1)}return o}if(Array.isArray(e)){let o=e.length,n=new Array(o);for(;o--;)n[o]=Yd(e[o],t+1);return n}return T.DEV&&r!=="[object Object]"&&r!=="[object Array]"&&r.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${r}. This value will not be cloned!`),e},Sn=e=>Yd(e),Kd=e=>{if(Ar()&&e){let t=`${e}_copy`;return window.h?.app?.getSceneElementsIncludingDeleted().find(r=>r.id===t)&&(t+="_copy"),t}return Pt()},Hs=(e,t,r,o)=>{let n=Sn(r);return n.id=Kd(n.id),n.boundElements=null,n.updated=gn(),n.seed=qr(),n.groupIds=R0(n.groupIds,e,i=>(t.has(i)||t.set(i,Kd(i)),t.get(i))),o&&(n=Object.assign(n,o)),n},Xd=(e,t)=>{let r=[],o=$(e),n=new Map,i=l=>{if(n.has(l))return n.get(l);if(o.has(l)){let s=Kd(l);return n.set(l,s),s}return null},a=new Map;for(let l of e){let s=Yd(l);if(s.id=i(l.id),t?.randomizeSeed&&(s.seed=qr(),li(s)),s.groupIds&&(s.groupIds=s.groupIds.map(c=>(a.has(c)||a.set(c,Kd(c)),a.get(c)))),"containerId"in s&&s.containerId){let c=i(s.containerId);s.containerId=c}if("boundElements"in s&&s.boundElements&&(s.boundElements=s.boundElements.reduce((c,d)=>{let m=i(d.id);return m&&c.push({...d,id:m}),c},[])),"endBinding"in s&&s.endBinding){let c=i(s.endBinding.elementId);s.endBinding=c?{...s.endBinding,elementId:c}:null}if("startBinding"in s&&s.startBinding){let c=i(s.startBinding.elementId);s.startBinding=c?{...s.startBinding,elementId:c}:null}s.frameId&&(s.frameId=i(s.frameId)),r.push(s)}return r}});var Cn,jI,qI,JI,W0,QI,V0,e6,t6,r6,Y0,Oh,zs,kn,Zd,i9,K0,$0,il,Gs=j(()=>{"use strict";f();Ye();U();z();ol();In();lt();ce();ia();Cn=new Map,jI=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)(?:\?t=|&t=|\?start=|&start=)?([a-zA-Z0-9_-]+)?[^\s]*$/,qI=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}\.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,JI=/^https:\/\/(?:www\.)?figma\.com/,W0=/^https:\/\/gist\.github\.com\/([\w_-]+)\/([\w_-]+)/,QI=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist\.github\.com\/.*?)\.js["']/i,V0=/(?:https?:\/\/)?(?:(?:w){3}\.)?(?:twitter|x)\.com\/[^/]+\/status\/(\d+)/,e6=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:twitter|x)\.com\/[^"']*)/i,t6=/^https:\/\/(?:www\.)?val\.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,r6=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,Y0=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,Oh=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","link.excalidraw.com","gist.github.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","val.town","giphy.com","dddice.com"]),zs=e=>`<html><body>${e}</body></html>`,kn=e=>{if(!e)return null;if(Cn.has(e))return Cn.get(e);let t=e,r="generic",o={w:560,h:840},n=e.match(jI);if(n?.[2]){let s=n[3]?`&start=${n[3]}`:"",c=e.includes("shorts");switch(r="video",n[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${n[2]}?enablejsapi=1${s}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${n[2]}&enablejsapi=1${s}`;break;default:e=`https://www.youtube.com/embed/${n[2]}?enablejsapi=1${s}`;break}return o=c?{w:315,h:560}:{w:560,h:315},Cn.set(t,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r}}let i=e.match(qI);if(i?.[1]){let s=i?.[1],c=/^\d+$/.test(s)?void 0:new URIError("Invalid embed link format");return r="video",e=`https://player.vimeo.com/video/${s}?api=1`,o={w:560,h:315},Cn.set(t,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r,error:c}}if(e.match(JI))return r="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,o={w:550,h:550},Cn.set(t,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r};let l=e.match(t6);if(l)return e=l[1]==="embed"?l[0]:l[0].replace("/v","/embed"),Cn.set(t,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r};if(V0.test(e)){let s=e.match(V0)[1],c=zd(`https://twitter.com/x/status/${s}`),d={type:"document",srcdoc:m=>zs(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${m}"><a href="${c}"></a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`),intrinsicSize:{w:480,h:480},sandbox:{allowSameOrigin:!0}};return Cn.set(t,d),d}if(W0.test(e)){let[,s,c]=e.match(W0),d=zd(`https://gist.github.com/${s}/${c}`),m={type:"document",srcdoc:()=>zs(`
16
+ <script src="${d}.js"><\/script>
17
17
  <style type="text/css">
18
18
  * { margin: 0px; }
19
19
  table, .gist { height: 100%; }
20
20
  .gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
21
21
  </style>
22
- `),intrinsicSize:{w:550,h:720}};return Cn.set(e,s),s}return Cn.set(e,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r}},Xd=e=>{let t;jr(e)?t="IFrame element":t=!e.link||e?.link===""?"Empty Web-Embed":e.link;let r=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),o=it.Helvetica,n=Ge({fontSize:r,fontFamily:o});return Nt({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:o,fontSize:r,text:ai(t,n,e.width-20),textAlign:"center",verticalAlign:ft.MIDDLE,angle:e.angle??0})},o9=B({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,t,r,o)=>{let n=Xe(t,{type:"embeddable"});return Br(o.canvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:Xe(t,{type:"embeddable"})},commitToHistory:!1}}}),W0=(e,t)=>{try{let{hostname:r}=new URL(e),o=r.replace(/^www\./,""),n=o.replace(/^([^.]+)/,"*");if(t instanceof Set)return Rh.has(o)||Rh.has(n);if(o===t.replace(/^www\./,""))return!0}catch{}return!1},V0=e=>{let t=e.match(QI);if(t&&t.length===2)return t[1];let r=e.match(qI);if(r&&r.length===2)return r[1];if(U0.test(e))return`https://giphy.com/embed/${U0.exec(e)[1]}`;let o=e.match(t6);return o&&o.length===2?o[1]:e},il=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){let r=t(e);if(typeof r=="boolean")return r}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(let r of t)if(r instanceof RegExp){if(e.match(r))return!0}else if(W0(e,r))return!0;return!1}}return W0(e,Rh)}});var Gs,Us,Nh,Y0,K0=j(()=>{"use strict";f();G();rl();ge();zs();Qt();ut();ce();er();Rt();Go();z();bn();Gs=(e,t,r)=>{if(typeof r>"u")return e.draw(t);let o={sets:t.sets,shape:t.shape,options:{...t.options,fixedDecimalPlaceDigits:r}};return e.draw(o)},Us=(e,t,r,o,n)=>{if(!o.enabled||!o.clip)return null;let i=Ot(e,n);if(i){let a=t.ownerDocument.createElementNS(Fe,"g");return a.setAttributeNS(Fe,"clip-path",`url(#${i.id})`),r.forEach(l=>a.appendChild(l)),a}return null},Nh=(e,t,r,o,n,i,a,l)=>{let s={x:i,y:a},[c,d,m,p]=te(e,t),u=(m-c)/2-(e.x-c),h=(p-d)/2-(e.y-d);if(U(e)){let y=lt(e,t);if(Te(y)){let[I,P,C,_]=te(y,t),D=K.getBoundTextElementPosition(y,e,t);u=(C-I)/2-(D.x-I),h=(_-P)/2-(D.y-P),i=i+D.x-e.x,a=a+D.y-e.y}}let x=180*e.angle/Math.PI,E=o;if(e.link){let y=o.ownerDocument.createElementNS(Fe,"a");y.setAttribute("href",lr(e.link)),E.appendChild(y),E=y}let v=(y,I)=>{Ar()&&y.setAttribute("data-id",I.id),E.appendChild(y)},w=(Ot(e,t)?.opacity??100)*e.opacity/1e4;switch(e.type){case"selection":throw new Error("Selection rendering is not supported for SVG");case"rectangle":case"diamond":case"ellipse":{let y=ke.generateElementShape(e,null),I=Gs(r,y,Ba);w!==1&&(I.setAttribute("stroke-opacity",`${w}`),I.setAttribute("fill-opacity",`${w}`)),I.setAttribute("stroke-linecap","round"),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`);let P=Us(e,E,[I],l.frameRendering,t);v(P||I,e);break}case"iframe":case"embeddable":{let y=ke.generateElementShape(e,l),I=Gs(r,y,Ba),P=e.opacity/100;P!==1&&(I.setAttribute("stroke-opacity",`${P}`),I.setAttribute("fill-opacity",`${P}`)),I.setAttribute("stroke-linecap","round"),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),v(I,e);let C=Xd(e);Nh(C,t,r,E,n,C.x+s.x-e.x,C.y+s.y-e.y,l);let _=Gs(r,y,Ba);for(_.setAttribute("stroke-linecap","round"),_.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`);_.firstChild;)_.removeChild(_.firstChild);let D=vo(Math.min(e.width,e.height),e),H=kn(Gd(e.link||""));if(l.renderEmbeddables===!1||H?.type==="document"){let A=o.ownerDocument.createElementNS(Fe,"a");A.setAttribute("href",lr(e.link||"")),A.setAttribute("target","_blank"),A.setAttribute("rel","noopener noreferrer"),A.style.borderRadius=`${D}px`,_.appendChild(A)}else{let A=o.ownerDocument.createElementNS(Fe,"foreignObject");A.style.width=`${e.width}px`,A.style.height=`${e.height}px`,A.style.border="none";let M=A.ownerDocument.createElementNS(Fe,"div");M.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),M.style.width="100%",M.style.height="100%";let k=M.ownerDocument.createElement("iframe");k.src=H?.link??"",k.style.width="100%",k.style.height="100%",k.style.border="none",k.style.borderRadius=`${D}px`,k.style.top="0",k.style.left="0",k.allowFullscreen=!0,M.appendChild(k),A.appendChild(M),_.appendChild(A)}v(_,e);break}case"line":case"arrow":{let y=pe(e,t),I=o.ownerDocument.createElementNS(Fe,"mask");if(y){I.setAttribute("id",`mask-${e.id}`);let D=o.ownerDocument.createElementNS(Fe,"rect");i=i||0,a=a||0,D.setAttribute("x","0"),D.setAttribute("y","0"),D.setAttribute("fill","#fff"),D.setAttribute("width",`${e.width+100+i}`),D.setAttribute("height",`${e.height+100+a}`),I.appendChild(D);let H=o.ownerDocument.createElementNS(Fe,"rect"),A=K.getBoundTextElementPosition(e,y,t),M=i+A.x-e.x,k=a+A.y-e.y;H.setAttribute("x",M.toString()),H.setAttribute("y",k.toString()),H.setAttribute("fill","#000"),H.setAttribute("width",`${y.width}`),H.setAttribute("height",`${y.height}`),H.setAttribute("opacity","1"),I.appendChild(H)}let P=o.ownerDocument.createElementNS(Fe,"g");y&&P.setAttribute("mask",`url(#mask-${e.id})`),P.setAttribute("stroke-linecap","round"),ke.generateElementShape(e,l).forEach(D=>{let H=Gs(r,D,Ba);w!==1&&(H.setAttribute("stroke-opacity",`${w}`),H.setAttribute("fill-opacity",`${w}`)),H.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),e.type==="line"&&ir(e.points)&&e.backgroundColor!=="transparent"&&H.setAttribute("fill-rule","evenodd"),P.appendChild(H)});let _=Us(e,E,[P,I],l.frameRendering,t);_?(v(_,e),E.appendChild(_)):(v(P,e),E.append(I));break}case"freedraw":{let y=ke.generateElementShape(e,l),I=y?Gs(r,y,Ba):o.ownerDocument.createElementNS(Fe,"g");w!==1&&(I.setAttribute("stroke-opacity",`${w}`),I.setAttribute("fill-opacity",`${w}`)),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),I.setAttribute("stroke","none");let P=o.ownerDocument.createElementNS(Fe,"path");P.setAttribute("fill",e.strokeColor),P.setAttribute("d",Zd(e)),I.appendChild(P);let C=Us(e,E,[I],l.frameRendering,t);v(C||I,e);break}case"image":{let y=Math.round(e.width),I=Math.round(e.height),P=nr(e)&&n[e.fileId];if(P){let C=`image-${P.id}`,_=o.querySelector(`#${C}`);if(!_){_=o.ownerDocument.createElementNS(Fe,"symbol"),_.id=C;let M=o.ownerDocument.createElementNS(Fe,"image");M.setAttribute("width","100%"),M.setAttribute("height","100%"),M.setAttribute("href",P.dataURL),_.appendChild(M),E.prepend(_)}let D=o.ownerDocument.createElementNS(Fe,"use");if(D.setAttribute("href",`#${C}`),l.exportWithDarkMode&&P.mimeType!==J.svg&&D.setAttribute("filter",Oh),D.setAttribute("width",`${y}`),D.setAttribute("height",`${I}`),D.setAttribute("opacity",`${w}`),e.scale[0]!==1||e.scale[1]!==1){let M=e.scale[0]!==1?-y:0,k=e.scale[1]!==1?-I:0;D.setAttribute("transform",`scale(${e.scale[0]}, ${e.scale[1]}) translate(${M} ${k})`)}let H=o.ownerDocument.createElementNS(Fe,"g");if(H.appendChild(D),H.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),e.roundness){let M=o.ownerDocument.createElementNS(Fe,"clipPath");M.id=`image-clipPath-${e.id}`;let k=o.ownerDocument.createElementNS(Fe,"rect"),O=vo(Math.min(e.width,e.height),e);k.setAttribute("width",`${e.width}`),k.setAttribute("height",`${e.height}`),k.setAttribute("rx",`${O}`),k.setAttribute("ry",`${O}`),M.appendChild(k),v(M,e),H.setAttributeNS(Fe,"clip-path",`url(#${M.id})`)}let A=Us(e,E,[H],l.frameRendering,t);v(A||H,e)}break}case"frame":case"magicframe":{if(l.frameRendering.enabled&&l.frameRendering.outline){let y=document.createElementNS(Fe,"rect");y.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),y.setAttribute("width",`${e.width}px`),y.setAttribute("height",`${e.height}px`),y.setAttribute("rx",$e.radius.toString()),y.setAttribute("ry",$e.radius.toString()),y.setAttribute("fill","none"),y.setAttribute("stroke",$e.strokeColor),y.setAttribute("stroke-width",$e.strokeWidth.toString()),v(y,e)}break}default:if(U(e)){let y=o.ownerDocument.createElementNS(Fe,"g");w!==1&&(y.setAttribute("stroke-opacity",`${w}`),y.setAttribute("fill-opacity",`${w}`)),y.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`);let I=e.text.replace(/\r\n?/g,`
22
+ `),intrinsicSize:{w:550,h:720}};return Cn.set(e,m),m}return Cn.set(e,{link:e,intrinsicSize:o,type:r}),{link:e,intrinsicSize:o,type:r}},Zd=e=>{let t;jr(e)?t="IFrame element":t=!e.link||e?.link===""?"Empty Web-Embed":e.link;let r=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),o=it.Helvetica,n=Ge({fontSize:r,fontFamily:o});return Nt({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:o,fontSize:r,text:ai(t,n,e.width-20),textAlign:"center",verticalAlign:ft.MIDDLE,angle:e.angle??0})},i9=B({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,t,r,o)=>{let n=Xe(t,{type:"embeddable"});return Br(o.canvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:Xe(t,{type:"embeddable"})},commitToHistory:!1}}}),K0=(e,t)=>{try{let{hostname:r}=new URL(e),o=r.replace(/^www\./,""),n=o.replace(/^([^.]+)/,"*");if(t instanceof Set)return Oh.has(o)||Oh.has(n);if(o===t.replace(/^www\./,""))return!0}catch{}return!1},$0=e=>{let t=e.match(e6);if(t&&t.length===2)return t[1];let r=e.match(QI);if(r&&r.length===2)return r[1];if(Y0.test(e))return`https://giphy.com/embed/${Y0.exec(e)[1]}`;let o=e.match(r6);return o&&o.length===2?o[1]:e},il=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){let r=t(e);if(typeof r=="boolean")return r}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(let r of t)if(r instanceof RegExp){if(e.match(r))return!0}else if(K0(e,r))return!0;return!1}}return K0(e,Oh)}});var Us,Ws,jd,X0,Z0=j(()=>{"use strict";f();U();ia();ge();Gs();Qt();lt();ce();er();Rt();Go();z();bn();Us=(e,t,r)=>{if(typeof r>"u")return e.draw(t);let o={sets:t.sets,shape:t.shape,options:{...t.options,fixedDecimalPlaceDigits:r}};return e.draw(o)},Ws=(e,t,r,o,n)=>{if(!o.enabled||!o.clip)return null;let i=Ot(e,n);if(i){let a=t.ownerDocument.createElementNS(Fe,"g");return a.setAttributeNS(Fe,"clip-path",`url(#${i.id})`),r.forEach(l=>a.appendChild(l)),a}return null},jd=(e,t,r,o,n,i,a,l)=>{let s={x:i,y:a},[c,d,m,p]=te(e,t),u=(m-c)/2-(e.x-c),h=(p-d)/2-(e.y-d);if(G(e)){let y=st(e,t);if(Te(y)){let[I,P,C,_]=te(y,t),D=K.getBoundTextElementPosition(y,e,t);u=(C-I)/2-(D.x-I),h=(_-P)/2-(D.y-P),i=i+D.x-e.x,a=a+D.y-e.y}}let x=180*e.angle/Math.PI,E=o;if(e.link){let y=o.ownerDocument.createElementNS(Fe,"a");y.setAttribute("href",lr(e.link)),E.appendChild(y),E=y}let v=(y,I)=>{Ar()&&y.setAttribute("data-id",I.id),E.appendChild(y)},w=(Ot(e,t)?.opacity??100)*e.opacity/1e4;switch(e.type){case"selection":throw new Error("Selection rendering is not supported for SVG");case"rectangle":case"diamond":case"ellipse":{let y=ke.generateElementShape(e,null),I=Us(r,y,Ba);w!==1&&(I.setAttribute("stroke-opacity",`${w}`),I.setAttribute("fill-opacity",`${w}`)),I.setAttribute("stroke-linecap","round"),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`);let P=Ws(e,E,[I],l.frameRendering,t);v(P||I,e);break}case"iframe":case"embeddable":{let y=ke.generateElementShape(e,l),I=Us(r,y,Ba),P=e.opacity/100;P!==1&&(I.setAttribute("stroke-opacity",`${P}`),I.setAttribute("fill-opacity",`${P}`)),I.setAttribute("stroke-linecap","round"),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),v(I,e);let C=Zd(e);jd(C,t,r,E,n,C.x+s.x-e.x,C.y+s.y-e.y,l);let _=Us(r,y,Ba);for(_.setAttribute("stroke-linecap","round"),_.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`);_.firstChild;)_.removeChild(_.firstChild);let D=vo(Math.min(e.width,e.height),e),H=kn(Ud(e.link||""));if(l.renderEmbeddables===!1||H?.type==="document"){let A=o.ownerDocument.createElementNS(Fe,"a");A.setAttribute("href",lr(e.link||"")),A.setAttribute("target","_blank"),A.setAttribute("rel","noopener noreferrer"),A.style.borderRadius=`${D}px`,_.appendChild(A)}else{let A=o.ownerDocument.createElementNS(Fe,"foreignObject");A.style.width=`${e.width}px`,A.style.height=`${e.height}px`,A.style.border="none";let M=A.ownerDocument.createElementNS(Fe,"div");M.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),M.style.width="100%",M.style.height="100%";let k=M.ownerDocument.createElement("iframe");k.src=H?.link??"",k.style.width="100%",k.style.height="100%",k.style.border="none",k.style.borderRadius=`${D}px`,k.style.top="0",k.style.left="0",k.allowFullscreen=!0,M.appendChild(k),A.appendChild(M),_.appendChild(A)}v(_,e);break}case"line":case"arrow":{let y=de(e,t),I=o.ownerDocument.createElementNS(Fe,"mask");if(y){I.setAttribute("id",`mask-${e.id}`);let D=o.ownerDocument.createElementNS(Fe,"rect");i=i||0,a=a||0,D.setAttribute("x","0"),D.setAttribute("y","0"),D.setAttribute("fill","#fff"),D.setAttribute("width",`${e.width+100+i}`),D.setAttribute("height",`${e.height+100+a}`),I.appendChild(D);let H=o.ownerDocument.createElementNS(Fe,"rect"),A=K.getBoundTextElementPosition(e,y,t),M=i+A.x-e.x,k=a+A.y-e.y;H.setAttribute("x",M.toString()),H.setAttribute("y",k.toString()),H.setAttribute("fill","#000"),H.setAttribute("width",`${y.width}`),H.setAttribute("height",`${y.height}`),H.setAttribute("opacity","1"),I.appendChild(H)}let P=o.ownerDocument.createElementNS(Fe,"g");y&&P.setAttribute("mask",`url(#mask-${e.id})`),P.setAttribute("stroke-linecap","round"),ke.generateElementShape(e,l).forEach(D=>{let H=Us(r,D,Ba);w!==1&&(H.setAttribute("stroke-opacity",`${w}`),H.setAttribute("fill-opacity",`${w}`)),H.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),e.type==="line"&&ir(e.points)&&e.backgroundColor!=="transparent"&&H.setAttribute("fill-rule","evenodd"),P.appendChild(H)});let _=Ws(e,E,[P,I],l.frameRendering,t);_?(v(_,e),E.appendChild(_)):(v(P,e),E.append(I));break}case"freedraw":{let y=ke.generateElementShape(e,l),I=y?Us(r,y,Ba):o.ownerDocument.createElementNS(Fe,"g");w!==1&&(I.setAttribute("stroke-opacity",`${w}`),I.setAttribute("fill-opacity",`${w}`)),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),I.setAttribute("stroke","none");let P=o.ownerDocument.createElementNS(Fe,"path");P.setAttribute("fill",e.strokeColor),P.setAttribute("d",qd(e)),I.appendChild(P);let C=Ws(e,E,[I],l.frameRendering,t);v(C||I,e);break}case"image":{let y=Math.round(e.width),I=Math.round(e.height),P=nr(e)&&n[e.fileId];if(P){let C=`image-${P.id}`,_=o.querySelector(`#${C}`);if(!_){_=o.ownerDocument.createElementNS(Fe,"symbol"),_.id=C;let M=o.ownerDocument.createElementNS(Fe,"image");M.setAttribute("width","100%"),M.setAttribute("height","100%"),M.setAttribute("href",P.dataURL),_.appendChild(M),E.prepend(_)}let D=o.ownerDocument.createElementNS(Fe,"use");if(D.setAttribute("href",`#${C}`),l.exportWithDarkMode&&P.mimeType!==J.svg&&D.setAttribute("filter",Bh),D.setAttribute("width",`${y}`),D.setAttribute("height",`${I}`),D.setAttribute("opacity",`${w}`),e.scale[0]!==1||e.scale[1]!==1){let M=e.scale[0]!==1?-y:0,k=e.scale[1]!==1?-I:0;D.setAttribute("transform",`scale(${e.scale[0]}, ${e.scale[1]}) translate(${M} ${k})`)}let H=o.ownerDocument.createElementNS(Fe,"g");if(H.appendChild(D),H.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),e.roundness){let M=o.ownerDocument.createElementNS(Fe,"clipPath");M.id=`image-clipPath-${e.id}`;let k=o.ownerDocument.createElementNS(Fe,"rect"),O=vo(Math.min(e.width,e.height),e);k.setAttribute("width",`${e.width}`),k.setAttribute("height",`${e.height}`),k.setAttribute("rx",`${O}`),k.setAttribute("ry",`${O}`),M.appendChild(k),v(M,e),H.setAttributeNS(Fe,"clip-path",`url(#${M.id})`)}let A=Ws(e,E,[H],l.frameRendering,t);v(A||H,e)}break}case"frame":case"magicframe":{if(l.frameRendering.enabled&&l.frameRendering.outline){let y=document.createElementNS(Fe,"rect");y.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`),y.setAttribute("width",`${e.width}px`),y.setAttribute("height",`${e.height}px`),y.setAttribute("rx",$e.radius.toString()),y.setAttribute("ry",$e.radius.toString()),y.setAttribute("fill","none"),y.setAttribute("stroke",$e.strokeColor),y.setAttribute("stroke-width",$e.strokeWidth.toString()),v(y,e)}break}default:if(G(e)){let y=o.ownerDocument.createElementNS(Fe,"g");w!==1&&(y.setAttribute("stroke-opacity",`${w}`),y.setAttribute("fill-opacity",`${w}`)),y.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${x} ${u} ${h})`);let I=e.text.replace(/\r\n?/g,`
23
23
  `).split(`
24
- `),P=ii(e.fontSize,e.lineHeight),C=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,_=_d(e.fontFamily,e.fontSize,P),D=cd(e.text)?"rtl":"ltr",H=e.textAlign==="center"?"middle":e.textAlign==="right"||D==="rtl"?"end":"start";for(let M=0;M<I.length;M++){let k=o.ownerDocument.createElementNS(Fe,"text");k.textContent=I[M],k.setAttribute("x",`${C}`),k.setAttribute("y",`${M*P+_}`),k.setAttribute("font-family",Ha(e)),k.setAttribute("font-size",`${e.fontSize}px`),k.setAttribute("fill",e.strokeColor),k.setAttribute("text-anchor",H),k.setAttribute("style","white-space: pre;"),k.setAttribute("direction",D),k.setAttribute("dominant-baseline","alphabetic"),y.appendChild(k)}let A=Us(e,E,[y],l.frameRendering,t);v(A||y,e)}else throw new Error(`Unimplemented type ${e.type}`)}},Y0=(e,t,r,o,n,i)=>{o&&(e.filter(a=>!Vt(a)).forEach(a=>{if(!a.isDeleted)try{Nh(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i)}catch(l){console.error(l)}}),e.filter(a=>Vt(a)).forEach(a=>{if(!a.isDeleted)try{Nh(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i)}catch(l){console.error(l)}}))}});import{fileOpen as r6,fileSave as o6,supported as si}from"browser-fs-access";var $0,al,ll,An=j(()=>{"use strict";f();G();qn();z();$0=500,al=e=>{let t=e.extensions?.reduce((o,n)=>(o.push(J[n]),o),[]),r=e.extensions?.reduce((o,n)=>n==="jpg"?o.concat(".jpg",".jpeg"):o.concat(`.${n}`),[]);return r6({description:e.description,extensions:r,mimeTypes:t,multiple:e.multiple??!1,legacySetup:(o,n,i)=>{let a=Wi(n,$0),l=()=>{s(),document.addEventListener("keyup",a),document.addEventListener("pointerup",a),a()},s=()=>{if(i.files?.length){let d=e.multiple?[...i.files]:i.files[0];o(d)}};requestAnimationFrame(()=>{window.addEventListener("focus",l)});let c=window.setInterval(()=>{s()},$0);return d=>{clearInterval(c),a.cancel(),window.removeEventListener("focus",l),document.removeEventListener("keyup",a),document.removeEventListener("pointerup",a),d&&(console.warn("Opening the file was canceled (legacy-fs)."),d(new zo))}}})},ll=(e,t)=>o6(e,{fileName:`${t.name}.${t.extension}`,description:t.description,extensions:[`.${t.extension}`]},t.fileHandle)});var n6,i6,X0,sl,a6,l6,s6,c6,Ws,d6,Z0,q0,ci,j0,aa,cl=j(()=>{"use strict";f();ge();ce();Eo();G();Rr();Qt();We();z();z();ut();rl();wo();n6={selection:!0,text:!0,rectangle:!0,diamond:!0,ellipse:!0,line:!0,image:!0,arrow:!0,freedraw:!0,eraser:!1,custom:!0,frame:!0,embeddable:!0,hand:!0,laser:!1,magicframe:!1},i6=e=>Object.keys(it).includes(e)?it[e]:Wt,X0=e=>e?{...e,focus:e.focus||0}:null,sl=(e,t)=>{let r={type:t.type||e.type,version:e.version||1,versionNonce:e.versionNonce??0,index:e.index??null,isDeleted:e.isDeleted??!1,id:e.id||Pt(),fillStyle:e.fillStyle||Qe.fillStyle,strokeWidth:e.strokeWidth||Qe.strokeWidth,strokeStyle:e.strokeStyle??Qe.strokeStyle,roughness:e.roughness??Qe.roughness,opacity:e.opacity==null?Qe.opacity:e.opacity,angle:e.angle||0,x:t.x??e.x??0,y:t.y??e.y??0,strokeColor:e.strokeColor||Qe.strokeColor,backgroundColor:e.backgroundColor||Qe.backgroundColor,width:e.width||0,height:e.height||0,seed:e.seed??1,groupIds:e.groupIds??[],frameId:e.frameId??null,roundness:e.roundness?e.roundness:e.strokeSharpness==="round"?{type:Ho(e.type)?rt.LEGACY:rt.PROPORTIONAL_RADIUS}:null,boundElements:e.boundElementIds?e.boundElementIds.map(o=>({type:"arrow",id:o})):e.boundElements??[],updated:e.updated??gn(),link:e.link?lr(e.link):null,locked:e.locked??!1};return("customData"in e||"customData"in t)&&(r.customData="customData"in t?t.customData:e.customData),{...r,...Vs(r),...t}},a6=e=>{switch(e.type){case"text":let t=e.fontSize,r=e.fontFamily;if("font"in e){let[i,a]=e.font.split(" ");t=parseFloat(i),r=i6(a)}let o=typeof e.text=="string"&&e.text||"",n=e.lineHeight||(e.height?E0(e):_r(e.fontFamily));return e=sl(e,{fontSize:t,fontFamily:r,text:o,textAlign:e.textAlign||Yn,verticalAlign:e.verticalAlign||Hi,containerId:e.containerId??null,originalText:e.originalText||o,lineHeight:n}),!o&&!e.isDeleted&&(e={...e,originalText:o,isDeleted:!0},e=li(e)),e;case"freedraw":return sl(e,{points:e.points,lastCommittedPoint:null,simulatePressure:e.simulatePressure,pressures:e.pressures});case"image":return sl(e,{status:e.status||"pending",fileId:e.fileId,scale:e.scale||[1,1]});case"line":case"draw":case"arrow":{let{startArrowhead:i=null,endArrowhead:a=e.type==="arrow"?"arrow":null}=e,l=e.x,s=e.y,c=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(c[0][0]!==0||c[0][1]!==0)&&({points:c,x:l,y:s}=K.getNormalizedPoints(e)),sl(e,{type:e.type==="draw"?"line":e.type,startBinding:X0(e.startBinding),endBinding:X0(e.endBinding),lastCommittedPoint:null,startArrowhead:i,endArrowhead:a,points:c,x:l,y:s})}case"ellipse":case"rectangle":case"diamond":case"iframe":case"embeddable":return sl(e,{});case"magicframe":case"frame":return sl(e,{name:e.name??null})}return null},l6=(e,t)=>{if(e.boundElements){let r=e.boundElements.slice(),o=new Set;e.boundElements=r.reduce((n,i)=>{let a=t.get(i.id);if(a&&!o.has(i.id)){if(o.add(i.id),a.isDeleted)return n;n.push(i),U(a)&&!a.containerId&&(a.containerId=e.id)}return n},[])}},s6=(e,t)=>{let r=e.containerId?t.get(e.containerId):null;if(!r){e.containerId=null;return}if(!e.isDeleted&&r.boundElements&&!r.boundElements.find(o=>o.id===e.id)){let o=(r.boundElements||(r.boundElements=[])).slice();o.push({type:"text",id:e.id}),r.boundElements=o}},c6=(e,t)=>{e.frameId&&(t.get(e.frameId)||(e.frameId=null))},Ws=(e,t,r)=>{let o=new Set,n=t?$(t):null,i=Mr((e||[]).reduce((l,s)=>{if(s.type!=="selection"&&!eo(s)){let c=a6(s);if(c){let d=n?.get(s.id);d&&d.version>c.version&&(c=li(c,d.version)),o.has(c.id)&&(c={...c,id:Pt()}),o.add(c.id),l.push(c)}}return l},[]));if(!r?.repairBindings)return i;let a=$(i);for(let l of i)l.frameId&&c6(l,a),U(l)&&l.containerId?s6(l,a):l.boundElements&&l6(l,a),r.refreshDimensions&&U(l)&&Object.assign(l,nl(l,lt(l,a),a));return i},d6=(e,t,r)=>{let o=t[e];return o!==void 0?o:r[e]},Z0={isSidebarDocked:(e,t)=>["defaultSidebarDockedPreference",e.isSidebarDocked??d6("defaultSidebarDockedPreference",e,t)]},q0=(e,t)=>{e=e||{};let r=ar(),o={};for(let n of Object.keys(Z0))if(n in e){let[i,a]=Z0[n](e,r);o[i]=a}for(let[n,i]of Object.entries(r)){let a=e[n],l=t?t[n]:void 0;o[n]=a!==void 0?a:l!==void 0?l:i}return{...o,cursorButton:t?.cursorButton||"up",penDetected:t?.penDetected??(e.penMode?e.penDetected??!1:!1),activeTool:{...Xe(r,o.activeTool.type&&n6[o.activeTool.type]?o.activeTool:{type:"selection"}),lastActiveTool:null,locked:o.activeTool.locked??!1},zoom:typeof e.zoom=="number"?{value:e.zoom}:e.zoom?.value?e.zoom:r.zoom,openSidebar:typeof e.openSidebar=="string"?{name:kr.name}:o.openSidebar}},ci=(e,t,r,o)=>({elements:Ws(e?.elements,r,o),appState:q0(e?.appState,t||null),files:e?.files||{}}),j0=e=>{let t=Ws(be(e.elements),null);return t.length?{...e,elements:t}:null},aa=(e=[],t)=>{let r=[];for(let o of e)if(Array.isArray(o)){let n=j0({status:t,elements:o,id:Pt(),created:Date.now()});n&&r.push(n)}else{let n=o,i=j0({...n,id:n.id||Pt(),status:n.status||t,created:n.created||Date.now()});i&&r.push(i)}return r}});var J0=j(()=>{"use strict";f();G();Er()});import{deflate as m6,inflate as p6}from"pako";var Bh,Q0,eE,tE,rE,Fh,Hh,oE=j(()=>{"use strict";f();J0();Bh=e=>new Promise((t,r)=>{let o=typeof e=="string"?new Blob([new TextEncoder().encode(e)]):new Blob([e instanceof Uint8Array?e:new Uint8Array(e)]),n=new FileReader;n.onload=i=>{if(!i.target||typeof i.target.result!="string")return r(new Error("couldn't convert to byte string"));t(i.target.result)},n.readAsBinaryString(o)}),Q0=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let o=0,n=e.length;o<n;o++)r[o]=e.charCodeAt(o);return t},eE=e=>new TextDecoder("utf-8").decode(Q0(e)),tE=async(e,t=!1)=>t?window.btoa(e):window.btoa(await Bh(e)),rE=async(e,t=!1)=>t?window.atob(e):eE(window.atob(e)),Fh=async({text:e,compress:t})=>{let r;if(t!==!1)try{r=await Bh(m6(e))}catch(o){console.error("encode: cannot deflate",o)}return{version:"1",encoding:"bstring",compressed:!!r,encoded:r||await Bh(e)}},Hh=async e=>{let t;switch(e.encoding){case"bstring":t=e.compressed?e.encoded:await eE(e.encoded);break;default:throw new Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?p6(new Uint8Array(Q0(t)),{to:"string"}):t}});var Ys={};Mu(Ys,{decodePngMetadata:()=>h6,decodeSvgMetadata:()=>f6,encodePngMetadata:()=>zh,encodeSvgMetadata:()=>g6,getTEXtChunk:()=>aE});import nE from"png-chunks-extract";import iE from"png-chunk-text";import u6 from"png-chunks-encode";var aE,zh,h6,g6,f6,dl=j(()=>{"use strict";f();oE();G();Er();aE=async e=>{let r=nE(new Uint8Array(await Mn(e))).find(o=>o.name==="tEXt");return r?iE.decode(r.data):null},zh=async({blob:e,metadata:t})=>{let r=nE(new Uint8Array(await Mn(e))),o=iE.encode(J.excalidraw,JSON.stringify(await Fh({text:t,compress:!0})));return r.splice(-1,0,o),new Blob([u6(r)],{type:J.png})},h6=async e=>{let t=await aE(e);if(t?.keyword===J.excalidraw)try{let r=JSON.parse(t.text);if(!("encoded"in r)){if("type"in r&&r.type===jt.excalidraw)return t.text;throw new Error("FAILED")}return await Hh(r)}catch(r){throw console.error(r),new Error("FAILED")}throw new Error("INVALID")},g6=async({text:e})=>{let t=await tE(JSON.stringify(await Fh({text:e})),!0),r="";return r+=`<!-- payload-type:${J.excalidraw} -->`,r+="<!-- payload-version:2 -->",r+="<!-- payload-start -->",r+=t,r+="<!-- payload-end -->",r},f6=async({svg:e})=>{if(e.includes(`payload-type:${J.excalidraw}`)){let t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw new Error("INVALID");let n=(e.match(/<!-- payload-version:(\d+) -->/)?.[1]||"1")!=="1";try{let i=await rE(t[1],n),a=JSON.parse(i);if(!("encoded"in a)){if("type"in a&&a.type===jt.excalidraw)return i;throw new Error("FAILED")}return await Hh(a)}catch(i){throw console.error(i),new Error("FAILED")}}throw new Error("INVALID")}});import{nanoid as b6}from"nanoid";var sE,Gh,cE,ml,di,qd,pl,Uh,Wh,Ln,dE,Jd,mE,Ks,Vh,pE,uE,x6,lE,jd,$s,Mn,Er=j(()=>{"use strict";f();Rr();G();ge();qn();Ve();z();An();Pn();cl();sE=async e=>{let t;if(e.type===J.png)try{return await(await Promise.resolve().then(()=>(dl(),Ys))).decodePngMetadata(e)}catch(r){throw r.message==="INVALID"?new yo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new yo("Error: cannot restore image")}else if("text"in Blob?t=await e.text():t=await new Promise(r=>{let o=new FileReader;o.readAsText(e,"utf8"),o.onloadend=()=>{o.readyState===FileReader.DONE&&r(o.result)}}),e.type===J.svg)try{return await(await Promise.resolve().then(()=>(dl(),Ys))).decodeSvgMetadata({svg:t})}catch(r){throw r.message==="INVALID"?new yo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new yo("Error: cannot restore image")}return t},Gh=e=>e&&e.name.match(/\.(json|excalidraw|png|svg)$/)?.[1]||null,cE=e=>e==="png"||e==="svg",ml=e=>{let t=Gh(e);return t==="png"||t==="svg"},di=e=>{let{type:t}=e||{};return!!t&&Object.values(cs).includes(t)},qd=async(e,t,r,o)=>{let n=await sE(e),i;try{try{i=JSON.parse(n)}catch(a){throw di(e)?new yo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):a}if(hE(i))return{type:J.excalidraw,data:ci({elements:Qd(i.elements||[]),appState:{theme:t?.theme,fileHandle:o||e.handle||null,...Bd(i.appState||{}),...t?Yo(i.elements||[],t):{}},files:i.files},t,r,{repairBindings:!0,refreshDimensions:!1})};if(Yh(i))return{type:J.excalidrawlib,data:i};throw new Error("Error: invalid file")}catch(a){throw a instanceof yo?a:new Error("Error: invalid file")}},pl=async(e,t,r,o)=>{let n=await qd(e,t,r,o);if(n.type!==J.excalidraw)throw new Error("Error: invalid file");return n.data},Uh=(e,t="unpublished")=>{let r=JSON.parse(e);if(!Yh(r))throw new Error("Invalid library");let o=r.libraryItems||r.library;return aa(o,t)},Wh=async(e,t="unpublished")=>Uh(await sE(e),t),Ln=async e=>new Promise(async(t,r)=>{try{Oo(e)&&(e=await e),e.toBlob(o=>{if(!o)return r(new gd("Error: Canvas too big","CANVAS_POSSIBLY_TOO_BIG"));t(o)})}catch(o){r(o)}}),dE=async e=>{try{let t=await window.crypto.subtle.digest("SHA-1",await Mn(e));return ux(new Uint8Array(t))}catch(t){return console.error(t),b6(40)}},Jd=async e=>new Promise((t,r)=>{let o=new FileReader;o.onload=()=>{let n=o.result;t(n)},o.onerror=n=>r(n),o.readAsDataURL(e)}),mE=(e,t="")=>{let r=e.indexOf(","),o=atob(e.slice(r+1)),n=e.slice(0,r).split(":")[1].split(";")[0],i=new ArrayBuffer(o.length),a=new Uint8Array(i);for(let l=0;l<o.length;l++)a[l]=o.charCodeAt(l);return new File([i],t,{type:n})},Ks=async(e,t)=>{if(e.type===J.svg)return e;let[r,o]=await Promise.all([import("pica").then(i=>i.default),import("image-blob-reduce").then(i=>i.default)]),n=o({pica:r({features:["js","wasm"]})});if(t.outputType){let{outputType:i}=t;n._create_blob=function(a){return this.pica.toBlob(a.out_canvas,i,.8).then(l=>(a.out_blob=l,a))}}if(!di(e))throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"});return new File([await n.toBlob(e,{max:t.maxWidthOrHeight})],e.name,{type:t.outputType||e.type})},Vh=(e,t="")=>new File([new TextEncoder().encode(e)],t,{type:J.svg}),pE=async(e,t="")=>{let r;try{r=await fetch(e)}catch{throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"})}if(!r.ok)throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"});let o=await r.blob();if(o.type&&di(o)){let n=t||o.name||"";return new File([o],n,{type:o.type})}throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"})},uE=async e=>{let t=e.dataTransfer.files.item(0),r=await x6(e);return{file:t?await $s(t):null,fileHandle:r}},x6=async e=>{if(si)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(t){return console.warn(t.name,t.message),null}return null},lE=e=>{let t=null,r=`${[...new Uint8Array(e).slice(0,8)].join(" ")} `,o={png:"137 80 78 71 13 10 26 10 ",jpg:"255 216 255 ",gif:"71 73 70 56 57 97 "};return r===o.png?t=J.png:r.startsWith(o.jpg)?t=J.jpg:r.startsWith(o.gif)&&(t=J.gif),t},jd=(e,t,r)=>new File([e],r||"",{type:t}),$s=async e=>{if(e.type){if(di(e)){let t=await Mn(e),r=lE(t);r&&r!==e.type&&(e=jd(t,r,e.name))}}else if(e?.name?.endsWith(".excalidrawlib"))e=jd(await Mn(e),J.excalidrawlib,e.name);else if(e?.name?.endsWith(".excalidraw"))e=jd(await Mn(e),J.excalidraw,e.name);else{let t=await Mn(e),r=lE(t);r&&(e=jd(t,r,e.name))}return e},Mn=e=>"arrayBuffer"in e?e.arrayBuffer():new Promise((t,r)=>{let o=new FileReader;o.onload=n=>{if(!n.target?.result)return r(new Error("Couldn't convert blob to ArrayBuffer"));t(n.target.result)},o.readAsArrayBuffer(e)})});var E6,mi,em,Kh,hE,Yh,tm,gE,Pn=j(()=>{"use strict";f();An();Rr();G();ge();Er();E6=(e,t)=>{let r={};for(let o of e)!o.isDeleted&&"fileId"in o&&o.fileId&&t[o.fileId]&&(r[o.fileId]=t[o.fileId]);return r},mi=(e,t,r,o)=>{let n={type:jt.excalidraw,version:Ui.excalidraw,source:ds,elements:o==="local"?Qd(e):fE(e),appState:o==="local"?Bd(t):L0(t),files:o==="local"?E6(e,r):void 0};return JSON.stringify(n,null,2)},em=async(e,t,r,o=t.name||ad)=>{let n=mi(e,t,r,"local"),i=new Blob([n],{type:J.excalidraw});return{fileHandle:await ll(i,{name:o,extension:"excalidraw",description:"Excalidraw file",fileHandle:ml(t.fileHandle)?null:t.fileHandle})}},Kh=async(e,t)=>{let r=await al({description:"Excalidraw files"});return pl(await $s(r),e,t,r.handle)},hE=e=>e?.type===jt.excalidraw&&(!e.elements||Array.isArray(e.elements)&&(!e.appState||typeof e.appState=="object")),Yh=e=>typeof e=="object"&&e&&e.type===jt.excalidrawLibrary&&(e.version===1||e.version===2),tm=e=>{let t={type:jt.excalidrawLibrary,version:Ui.excalidrawLibrary,source:ds,libraryItems:e};return JSON.stringify(t,null,2)},gE=async e=>{let t=tm(e);await ll(new Blob([t],{type:J.excalidrawlib}),{name:"library",extension:"excalidrawlib",description:"Excalidraw library file"})}});var $h,rm,om,y6,bE,Xh=j(()=>{"use strict";f();G();ce();$h=e=>new Promise((t,r)=>{let o=new Image;o.onload=()=>{t(o)},o.onerror=n=>{r(n)},o.src=e}),rm=async({fileIds:e,files:t,imageCache:r})=>{let o=new Map,n=new Map;return await Promise.all(e.reduce((i,a)=>{let l=t[a];return l&&!o.has(a)?(o.set(a,!0),i.concat((async()=>{try{if(l.mimeType===J.binary)throw new Error("Only images can be added to ImageCache");let s=$h(l.dataURL),c={image:s,mimeType:l.mimeType};r.set(a,c);let d=await s;r.set(a,{...c,image:d})}catch{n.set(a,!0)}})())):i},[])),{imageCache:r,updatedFiles:o,erroredFiles:n}},om=e=>e.filter(t=>nr(t)),y6=e=>e?.nodeName.toLowerCase()==="svg",bE=async e=>{let t=new DOMParser().parseFromString(e,J.svg),r=t.querySelector("svg");if(t.querySelector("parsererror")||!y6(r))throw new Error("Invalid SVG");if(r.hasAttribute("xmlns")||r.setAttribute("xmlns",Fe),!r.hasAttribute("width")||!r.hasAttribute("height")){let n=r.getAttribute("viewBox"),i=r.getAttribute("width")||"50",a=r.getAttribute("height")||"50";if(n){let l=n.match(/\d+ +\d+ +(\d+) +(\d+)/);l&&([,i,a]=l)}r.setAttribute("width",i),r.setAttribute("height",a)}return r.outerHTML}});import{pointsOnBezierCurves as w6}from"points-on-curve";var nm,xE,EE,yE,v6,wE,vE,Zh=j(()=>{"use strict";f();hh();nm=e=>{let{angle:t,width:r,height:o,x:n,y:i}=e,a=$a(t),l=n+r/2,s=i+o/2,c=[l,s],d=[];return e.type==="diamond"?d=[Pr([l,i],a,c),Pr([n+r,s],a,c),Pr([l,i+o],a,c),Pr([n,s],a,c)]:d=[Pr([n,i],a,c),Pr([n+r,i],a,c),Pr([n+r,i+o],a,c),Pr([n,i+o],a,c)],{type:"polygon",data:d}},xE=e=>{let{width:t,height:r,angle:o,x:n,y:i}=e;return{type:"ellipse",data:{center:[n+t/2,i+r/2],angle:o,halfWidth:t/2,halfHeight:r/2}}},EE=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},yE=(e,t=[0,0],r,o)=>{let n=s=>Pr([s[0]+t[0],s[1]+t[1]],$a(r),o),i=EE(e),a=[],l=[0,0];for(let s of i)if(s.op==="move"&&(l=n(s.data)),s.op==="bcurveTo"){let c=n([s.data[0],s.data[1]]),d=n([s.data[2],s.data[3]]),m=n([s.data[4],s.data[5]]);a.push([l,c,d,m]),l=m}return{type:"polycurve",data:a}},v6=e=>{let t=e[0],r=[];for(let o=1;o<e.length;o++){let n=e[o];r.push([t,n]),t=n}return r},wE=(e,t,r=!1)=>{let o=$a(e.angle),n=a=>Pr(dh(a,[e.x,e.y]),o,t),i=v6(e.points.map(a=>n(a)));return r?{type:"polygon",data:As(i.flat())}:{type:"polyline",data:i}},vE=(e,t=[0,0],r,o)=>{let n=EE(e),i=c=>Pr([c[0]+t[0],c[1]+t[1]],$a(r),o),a=[],l=!1;for(let c of n)c.op==="move"?(l=!l,l&&a.push([c.data[0],c.data[1]])):c.op==="bcurveTo"?l&&(a.push([c.data[0],c.data[1]]),a.push([c.data[2],c.data[3]]),a.push([c.data[4],c.data[5]])):c.op==="lineTo"&&l&&a.push([c.data[0],c.data[1]]);return{type:"polygon",data:w6(a,10,5).map(c=>i(c))}}});var im,ul,la,TE,SE,am=j(()=>{"use strict";f();Rt();at();Zh();Id();z();ce();im=e=>{if(e.type==="arrow")return!1;let t=!or(e.backgroundColor)||gr(e)||Vt(e)||U(e);return e.type==="line"?t&&ir(e.points):e.type==="freedraw"?t&&ir(e.points):t||Zr(e)},ul=({x:e,y:t,element:r,shape:o,threshold:n=10,frameNameBound:i=null})=>{let a=im(r)?Xa([e,t],o)||Ms([e,t],o,n):Ms([e,t],o,n);return!a&&i&&(a=Xa([e,t],{type:"polygon",data:nm(i).data})),a},la=(e,t,r,o,n=0)=>{let[i,a,l,s]=Dr(r,o);return i-=n,a-=n,l+=n,s+=n,Ed([i,a],[e,t],[l,s])},TE=(e,t)=>!ul(e)&&la(e.x,e.y,e.element,t),SE=(e,t,r)=>r&&Xa([e,t],r)});var jh,Xs,qh,lm,sm=j(()=>{"use strict";f();G();at();am();Rt();bn();jh=document.createElement("img");jh.src=`data:${J.svg}, ${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1971c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>')}`;Xs=([e,t,r,o],n,i)=>{let a=IE,l=a/i.zoom.value,s=a/i.zoom.value,c=a/i.zoom.value,d=(e+r)/2,m=(t+o)/2,p=(a-8)/(2*i.zoom.value),u=4/i.zoom.value,h=r+u-p,x=t-u-c+p,[E,v]=Ee(h+l/2,x+s/2,d,m,n);return[E-l/2,v-s/2,l,s]},qh=(e,t,r,[o,n])=>{let i=4/r.zoom.value,[a,l,s,c]=te(e,t),[d,m,p,u]=Xs([a,l,s,c],e.angle,r);return o>d-i&&o<d+i+p&&n>m-i&&n<m+u+i},lm=(e,t,r,[o,n],i)=>!e.link||r.selectedElementIds[e.id]?!1:!i&&r.viewModeEnabled&&la(o,n,e,t)?!0:qh(e,t,r,[o,n])});var Zs,cm,dm,Jh=j(()=>{"use strict";f();G();Zs=(e,t,r,o,n=!0)=>{e.beginPath(),e.arc(t,r,o,0,Math.PI*2),e.fill(),n&&e.stroke()},cm=(e,t)=>[e.width/t,e.height/t],dm=({canvas:e,scale:t,normalizedWidth:r,normalizedHeight:o,theme:n,isExporting:i,viewBackgroundColor:a})=>{let l=e.getContext("2d");return l.setTransform(1,0,0,1,0,0),l.scale(t,t),i&&n===oe.DARK&&(l.filter=Oa),typeof a=="string"?((a==="transparent"||a.length===5||a.length===9||/(hsla|rgba)\(/.test(a))&&l.clearRect(0,0,r,o),l.save(),l.fillStyle=a,l.fillRect(0,0,r,o),l.restore()):l.clearRect(0,0,r,o),l}});var T6,CE,_n,kE,AE,Qh,pm,um=j(()=>{"use strict";f();G();ge();er();ce();bn();zs();sm();Jh();z();T6=(e,t,r,o,n,i,a)=>{let s;(E=>(E.Bold="#cccccc",E.Regular="#e5e5e5"))(s||={});let c=-Math.round(n.value/t)*t+r%t,d=-Math.round(n.value/t)*t+o%t,m=Math.min(1/n.value,1),p=1/n.value,u=[m*3,p+(m+p)];e.save(),e.lineWidth=m;for(let h=c;h<c+i+t*2;h+=t){let x=Math.round(h-r)%(5*t)===0;e.beginPath(),e.setLineDash(x?[]:u),e.strokeStyle=x?"#cccccc":"#e5e5e5",e.moveTo(h,d-t),e.lineTo(h,d+a+t*2),e.stroke()}for(let h=d;h<d+a+t*2;h+=t){let x=Math.round(h-o)%(5*t)===0;e.beginPath(),e.setLineDash(x?[]:u),e.strokeStyle=x?"#cccccc":"#e5e5e5",e.moveTo(c-t,h),e.lineTo(c+i+t*2,h),e.stroke()}e.restore()},CE=(e,t,r,o)=>{t.translate(e.x+o.scrollX,e.y+o.scrollY),t.beginPath(),t.roundRect?t.roundRect(0,0,e.width,e.height,$e.radius/o.zoom.value):t.rect(0,0,e.width,e.height),t.clip(),t.translate(-(e.x+o.scrollX),-(e.y+o.scrollY))},kE=(e,t,r,o)=>{if(e.link&&!r.selectedElementIds[e.id]){let[n,i,a,l]=te(e,o),[s,c,d,m]=Xs([n,i,a,l],e.angle,r),p=s+d/2,u=c+m/2;if(t.save(),t.translate(r.scrollX+p,r.scrollY+u),t.rotate(e.angle),!_n||_n.zoom!==r.zoom.value){_n=document.createElement("canvas"),_n.zoom=r.zoom.value,_n.width=d*window.devicePixelRatio*r.zoom.value,_n.height=m*window.devicePixelRatio*r.zoom.value;let h=_n.getContext("2d");h.scale(window.devicePixelRatio*r.zoom.value,window.devicePixelRatio*r.zoom.value),h.fillStyle="#fff",h.fillRect(0,0,d,m),h.drawImage(jh,0,0,d,m),h.restore(),t.drawImage(_n,s-p,c-u,d,m)}else t.drawImage(_n,s-p,c-u,d,m);t.restore()}},AE=({canvas:e,rc:t,elementsMap:r,allElementsMap:o,visibleElements:n,scale:i,appState:a,renderConfig:l})=>{if(e===null)return;let{renderGrid:s=!0,isExporting:c}=l,[d,m]=cm(e,i),p=dm({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m,theme:a.theme,isExporting:c,viewBackgroundColor:a.viewBackgroundColor});p.scale(a.zoom.value,a.zoom.value),s&&a.gridSize&&T6(p,a.gridSize,a.scrollX,a.scrollY,a.zoom,d/a.zoom.value,m/a.zoom.value);let u=new Set;n.forEach(h=>{h.groupIds.length>0&&a.frameToHighlight&&a.selectedElementIds[h.id]&&(Ko(h,a.frameToHighlight,r)||h.groupIds.find(x=>u.has(x)))&&h.groupIds.forEach(x=>u.add(x))}),n.filter(h=>!Vt(h)).forEach(h=>{try{if((h.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){p.save();let E=mm(h,r,a);E&&sa(h,r,a)&&CE(E,p,l,a),js(h,r,o,t,p,l,a),p.restore()}else js(h,r,o,t,p,l,a);c||kE(h,p,a,r)}catch(x){console.error(x)}}),n.filter(h=>Vt(h)).forEach(h=>{try{let x=()=>{if(js(h,r,o,t,p,l,a),Vt(h)&&(c||vt(h)&&l.embedsValidationStatus.get(h.id)!==!0)&&h.width&&h.height){let v=Xd(h);js(v,r,o,t,p,l,a)}c||kE(h,p,a,r)};if((h.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){p.save();let v=mm(h,r,a);v&&sa(h,r,a)&&CE(v,p,l,a),x(),p.restore()}else x()}catch(x){console.error(x)}})},Qh=za(e=>{AE(e)},{trailing:!0}),pm=(e,t)=>{if(t){Qh(e);return}AE(e)}});import ME from"roughjs/bin/rough";var S6,I6,C6,LE,PE,hm,hl,eg,_E,qs=j(()=>{"use strict";f();at();K0();z();G();Rr();Pn();Xh();er();ge();We();ce();wo();um();S6="<!-- svg-source:excalidraw -->",I6=(e,t)=>{if(e.width<=t)return e;let o=document.createElement("canvas").getContext("2d");o.font=Ge({fontFamily:e.fontFamily,fontSize:e.fontSize});let n=e.text;if(o.measureText(n).width>t)for(let a=n.length;a>0;a--){let l=`${n.slice(0,a)}...`;if(o.measureText(l).width<=t){n=l;break}}return ne(e,{text:n,width:t})},C6=(e,t)=>{let r=[],o=0,n=0;for(let i of e){if(Q(i)){jn(i)?o++:n++;let a=Nt({x:i.x,y:i.y-$e.nameOffsetY,fontFamily:it.Assistant,fontSize:$e.nameFontSize,lineHeight:$e.nameLineHeight,strokeColor:t.exportWithDarkMode?$e.nameColorDarkTheme:$e.nameColorLightTheme,text:gm(i,jn(i)?o:n)});a.y-=a.height,a=I6(a,i.width),r.push(a)}r.push(i)}return r},LE=(e,t)=>(t=t||ar().frameRendering,{enabled:e?!0:t.enabled,outline:e?!1:t.outline,name:e?!1:t.name,clip:e?!0:t.clip}),PE=({elements:e,exportingFrame:t,frameRendering:r,exportWithDarkMode:o})=>{let n;return t?n=gl(e,t):r.enabled&&r.name?n=C6(e,{exportWithDarkMode:o}):n=e,n},hm=async(e,t,r,{exportBackground:o,exportPadding:n=fo,viewBackgroundColor:i,exportingFrame:a},l=(s,c)=>{let d=document.createElement("canvas");return d.width=s*t.exportScale,d.height=c*t.exportScale,{canvas:d,scale:t.exportScale}})=>{let s=LE(a??null,t.frameRendering??null),c=PE({elements:e,exportingFrame:a,exportWithDarkMode:t.exportWithDarkMode,frameRendering:s});a&&(n=0);let[d,m,p,u]=eg(a?[a]:tg(c),n),{canvas:h,scale:x=1}=l(p,u),E=ar(),{imageCache:v}=await rm({imageCache:new Map,fileIds:om(c).map(w=>w.fileId),files:r});return pm({canvas:h,rc:ME.canvas(h),elementsMap:xo($(c)),allElementsMap:xo($(Mr(e))),visibleElements:c,scale:x,appState:{...t,frameRendering:s,viewBackgroundColor:o?i:null,scrollX:-d+n,scrollY:-m+n,zoom:E.zoom,shouldCacheIgnoreZoom:!1,theme:t.exportWithDarkMode?oe.DARK:oe.LIGHT},renderConfig:{canvasBackgroundColor:i,imageCache:v,renderGrid:!1,isExporting:!0,embedsValidationStatus:new Map,elementsPendingErasure:new Set}}),h},hl=async(e,t,r,o)=>{let n=LE(o?.exportingFrame??null,t.frameRendering??null),{exportPadding:i=fo,exportWithDarkMode:a=!1,viewBackgroundColor:l,exportScale:s=1,exportEmbedScene:c}=t,{exportingFrame:d=null}=o||{},m=PE({elements:e,exportingFrame:d,exportWithDarkMode:a,frameRendering:n});d&&(i=0);let p="";if(c)try{p=await(await Promise.resolve().then(()=>(dl(),Ys))).encodeSvgMetadata({text:mi(e,t,r||{},"local")})}catch(A){console.error(A)}let[u,h,x,E]=eg(d?[d]:tg(m),i),v=document.createElementNS(Fe,"svg");v.setAttribute("version","1.1"),v.setAttribute("xmlns",Fe),v.setAttribute("viewBox",`0 0 ${x} ${E}`),v.setAttribute("width",`${x*s}`),v.setAttribute("height",`${E*s}`),a&&v.setAttribute("filter",Oa);let w="https://excalidraw.com/";T.VITE_IS_EXCALIDRAW_NPM_PACKAGE&&(w=window.EXCALIDRAW_ASSET_PATH||`https://unpkg.com/${T.VITE_PKG_NAME}@${T.PKG_VERSION}`,w?.startsWith("/")&&(w=w.replace("/",`${window.location.origin}/`)),w=`${w}/dist/excalidraw-assets/`);let y=-u+i,I=-h+i,P=Js(e),C="",_=$(e);for(let A of P){let[M,k,O,X]=te(A,_),Y=(O-M)/2-(A.x-M),ee=(X-k)/2-(A.y-k);C+=`<clipPath id=${A.id}>
24
+ `),P=ii(e.fontSize,e.lineHeight),C=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,_=_d(e.fontFamily,e.fontSize,P),D=cd(e.text)?"rtl":"ltr",H=e.textAlign==="center"?"middle":e.textAlign==="right"||D==="rtl"?"end":"start";for(let M=0;M<I.length;M++){let k=o.ownerDocument.createElementNS(Fe,"text");k.textContent=I[M],k.setAttribute("x",`${C}`),k.setAttribute("y",`${M*P+_}`),k.setAttribute("font-family",Ha(e)),k.setAttribute("font-size",`${e.fontSize}px`),k.setAttribute("fill",e.strokeColor),k.setAttribute("text-anchor",H),k.setAttribute("style","white-space: pre;"),k.setAttribute("direction",D),k.setAttribute("dominant-baseline","alphabetic"),y.appendChild(k)}let A=Ws(e,E,[y],l.frameRendering,t);v(A||y,e)}else throw new Error(`Unimplemented type ${e.type}`)}},X0=(e,t,r,o,n,i)=>{o&&(e.filter(a=>!Vt(a)).forEach(a=>{if(!a.isDeleted){if(G(a)&&a.containerId&&t.has(a.containerId))return;try{jd(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i);let l=de(a,t);l&&jd(l,t,r,o,n,l.x+i.offsetX,l.y+i.offsetY,i)}catch(l){console.error(l)}}}),e.filter(a=>Vt(a)).forEach(a=>{if(!a.isDeleted)try{jd(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i)}catch(l){console.error(l)}}))}});import{fileOpen as o6,fileSave as n6,supported as si}from"browser-fs-access";var j0,al,ll,An=j(()=>{"use strict";f();U();qn();z();j0=500,al=e=>{let t=e.extensions?.reduce((o,n)=>(o.push(J[n]),o),[]),r=e.extensions?.reduce((o,n)=>n==="jpg"?o.concat(".jpg",".jpeg"):o.concat(`.${n}`),[]);return o6({description:e.description,extensions:r,mimeTypes:t,multiple:e.multiple??!1,legacySetup:(o,n,i)=>{let a=Wi(n,j0),l=()=>{s(),document.addEventListener("keyup",a),document.addEventListener("pointerup",a),a()},s=()=>{if(i.files?.length){let d=e.multiple?[...i.files]:i.files[0];o(d)}};requestAnimationFrame(()=>{window.addEventListener("focus",l)});let c=window.setInterval(()=>{s()},j0);return d=>{clearInterval(c),a.cancel(),window.removeEventListener("focus",l),document.removeEventListener("keyup",a),document.removeEventListener("pointerup",a),d&&(console.warn("Opening the file was canceled (legacy-fs)."),d(new zo))}}})},ll=(e,t)=>n6(e,{fileName:`${t.name}.${t.extension}`,description:t.description,extensions:[`.${t.extension}`]},t.fileHandle)});var i6,a6,q0,sl,l6,s6,c6,d6,Vs,m6,J0,eE,ci,Q0,aa,cl=j(()=>{"use strict";f();ge();ce();Eo();U();Rr();Qt();We();z();z();lt();ia();wo();i6={selection:!0,text:!0,rectangle:!0,diamond:!0,ellipse:!0,line:!0,image:!0,arrow:!0,freedraw:!0,eraser:!1,custom:!0,frame:!0,embeddable:!0,hand:!0,laser:!1,magicframe:!1},a6=e=>Object.keys(it).includes(e)?it[e]:Wt,q0=e=>e?{...e,focus:e.focus||0}:null,sl=(e,t)=>{let r={type:t.type||e.type,version:e.version||1,versionNonce:e.versionNonce??0,index:e.index??null,isDeleted:e.isDeleted??!1,id:e.id||Pt(),fillStyle:e.fillStyle||Qe.fillStyle,strokeWidth:e.strokeWidth||Qe.strokeWidth,strokeStyle:e.strokeStyle??Qe.strokeStyle,roughness:e.roughness??Qe.roughness,opacity:e.opacity==null?Qe.opacity:e.opacity,angle:e.angle||0,x:t.x??e.x??0,y:t.y??e.y??0,strokeColor:e.strokeColor||Qe.strokeColor,backgroundColor:e.backgroundColor||Qe.backgroundColor,width:e.width||0,height:e.height||0,seed:e.seed??1,groupIds:e.groupIds??[],frameId:e.frameId??null,roundness:e.roundness?e.roundness:e.strokeSharpness==="round"?{type:Ho(e.type)?rt.LEGACY:rt.PROPORTIONAL_RADIUS}:null,boundElements:e.boundElementIds?e.boundElementIds.map(o=>({type:"arrow",id:o})):e.boundElements??[],updated:e.updated??gn(),link:e.link?lr(e.link):null,locked:e.locked??!1};return("customData"in e||"customData"in t)&&(r.customData="customData"in t?t.customData:e.customData),{...r,...Ys(r),...t}},l6=e=>{switch(e.type){case"text":let t=e.fontSize,r=e.fontFamily;if("font"in e){let[i,a]=e.font.split(" ");t=parseFloat(i),r=a6(a)}let o=typeof e.text=="string"&&e.text||"",n=e.lineHeight||(e.height?y0(e):_r(e.fontFamily));return e=sl(e,{fontSize:t,fontFamily:r,text:o,textAlign:e.textAlign||Yn,verticalAlign:e.verticalAlign||Hi,containerId:e.containerId??null,originalText:e.originalText||o,lineHeight:n}),!o&&!e.isDeleted&&(e={...e,originalText:o,isDeleted:!0},e=li(e)),e;case"freedraw":return sl(e,{points:e.points,lastCommittedPoint:null,simulatePressure:e.simulatePressure,pressures:e.pressures});case"image":return sl(e,{status:e.status||"pending",fileId:e.fileId,scale:e.scale||[1,1]});case"line":case"draw":case"arrow":{let{startArrowhead:i=null,endArrowhead:a=e.type==="arrow"?"arrow":null}=e,l=e.x,s=e.y,c=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(c[0][0]!==0||c[0][1]!==0)&&({points:c,x:l,y:s}=K.getNormalizedPoints(e)),sl(e,{type:e.type==="draw"?"line":e.type,startBinding:q0(e.startBinding),endBinding:q0(e.endBinding),lastCommittedPoint:null,startArrowhead:i,endArrowhead:a,points:c,x:l,y:s})}case"ellipse":case"rectangle":case"diamond":case"iframe":case"embeddable":return sl(e,{});case"magicframe":case"frame":return sl(e,{name:e.name??null})}return null},s6=(e,t)=>{if(e.boundElements){let r=e.boundElements.slice(),o=new Set;e.boundElements=r.reduce((n,i)=>{let a=t.get(i.id);if(a&&!o.has(i.id)){if(o.add(i.id),a.isDeleted)return n;n.push(i),G(a)&&!a.containerId&&(a.containerId=e.id)}return n},[])}},c6=(e,t)=>{let r=e.containerId?t.get(e.containerId):null;if(!r){e.containerId=null;return}if(!e.isDeleted&&r.boundElements&&!r.boundElements.find(o=>o.id===e.id)){let o=(r.boundElements||(r.boundElements=[])).slice();o.push({type:"text",id:e.id}),r.boundElements=o}},d6=(e,t)=>{e.frameId&&(t.get(e.frameId)||(e.frameId=null))},Vs=(e,t,r)=>{let o=new Set,n=t?$(t):null,i=Mr((e||[]).reduce((l,s)=>{if(s.type!=="selection"&&!eo(s)){let c=l6(s);if(c){let d=n?.get(s.id);d&&d.version>c.version&&(c=li(c,d.version)),o.has(c.id)&&(c={...c,id:Pt()}),o.add(c.id),l.push(c)}}return l},[]));if(!r?.repairBindings)return i;let a=$(i);for(let l of i)l.frameId&&d6(l,a),G(l)&&l.containerId?c6(l,a):l.boundElements&&s6(l,a),r.refreshDimensions&&G(l)&&Object.assign(l,nl(l,st(l,a),a));return i},m6=(e,t,r)=>{let o=t[e];return o!==void 0?o:r[e]},J0={isSidebarDocked:(e,t)=>["defaultSidebarDockedPreference",e.isSidebarDocked??m6("defaultSidebarDockedPreference",e,t)]},eE=(e,t)=>{e=e||{};let r=ar(),o={};for(let n of Object.keys(J0))if(n in e){let[i,a]=J0[n](e,r);o[i]=a}for(let[n,i]of Object.entries(r)){let a=e[n],l=t?t[n]:void 0;o[n]=a!==void 0?a:l!==void 0?l:i}return{...o,cursorButton:t?.cursorButton||"up",penDetected:t?.penDetected??(e.penMode?e.penDetected??!1:!1),activeTool:{...Xe(r,o.activeTool.type&&i6[o.activeTool.type]?o.activeTool:{type:"selection"}),lastActiveTool:null,locked:o.activeTool.locked??!1},zoom:typeof e.zoom=="number"?{value:e.zoom}:e.zoom?.value?e.zoom:r.zoom,openSidebar:typeof e.openSidebar=="string"?{name:kr.name}:o.openSidebar}},ci=(e,t,r,o)=>({elements:Vs(e?.elements,r,o),appState:eE(e?.appState,t||null),files:e?.files||{}}),Q0=e=>{let t=Vs(be(e.elements),null);return t.length?{...e,elements:t}:null},aa=(e=[],t)=>{let r=[];for(let o of e)if(Array.isArray(o)){let n=Q0({status:t,elements:o,id:Pt(),created:Date.now()});n&&r.push(n)}else{let n=o,i=Q0({...n,id:n.id||Pt(),status:n.status||t,created:n.created||Date.now()});i&&r.push(i)}return r}});var tE=j(()=>{"use strict";f();U();Er()});import{deflate as p6,inflate as u6}from"pako";var Fh,rE,oE,nE,iE,Hh,zh,aE=j(()=>{"use strict";f();tE();Fh=e=>new Promise((t,r)=>{let o=typeof e=="string"?new Blob([new TextEncoder().encode(e)]):new Blob([e instanceof Uint8Array?e:new Uint8Array(e)]),n=new FileReader;n.onload=i=>{if(!i.target||typeof i.target.result!="string")return r(new Error("couldn't convert to byte string"));t(i.target.result)},n.readAsBinaryString(o)}),rE=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let o=0,n=e.length;o<n;o++)r[o]=e.charCodeAt(o);return t},oE=e=>new TextDecoder("utf-8").decode(rE(e)),nE=async(e,t=!1)=>t?window.btoa(e):window.btoa(await Fh(e)),iE=async(e,t=!1)=>t?window.atob(e):oE(window.atob(e)),Hh=async({text:e,compress:t})=>{let r;if(t!==!1)try{r=await Fh(p6(e))}catch(o){console.error("encode: cannot deflate",o)}return{version:"1",encoding:"bstring",compressed:!!r,encoded:r||await Fh(e)}},zh=async e=>{let t;switch(e.encoding){case"bstring":t=e.compressed?e.encoded:await oE(e.encoded);break;default:throw new Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?u6(new Uint8Array(rE(t)),{to:"string"}):t}});var Ks={};Pu(Ks,{decodePngMetadata:()=>g6,decodeSvgMetadata:()=>b6,encodePngMetadata:()=>Gh,encodeSvgMetadata:()=>f6,getTEXtChunk:()=>cE});import lE from"png-chunks-extract";import sE from"png-chunk-text";import h6 from"png-chunks-encode";var cE,Gh,g6,f6,b6,dl=j(()=>{"use strict";f();aE();U();Er();cE=async e=>{let r=lE(new Uint8Array(await Mn(e))).find(o=>o.name==="tEXt");return r?sE.decode(r.data):null},Gh=async({blob:e,metadata:t})=>{let r=lE(new Uint8Array(await Mn(e))),o=sE.encode(J.excalidraw,JSON.stringify(await Hh({text:t,compress:!0})));return r.splice(-1,0,o),new Blob([h6(r)],{type:J.png})},g6=async e=>{let t=await cE(e);if(t?.keyword===J.excalidraw)try{let r=JSON.parse(t.text);if(!("encoded"in r)){if("type"in r&&r.type===jt.excalidraw)return t.text;throw new Error("FAILED")}return await zh(r)}catch(r){throw console.error(r),new Error("FAILED")}throw new Error("INVALID")},f6=async({text:e})=>{let t=await nE(JSON.stringify(await Hh({text:e})),!0),r="";return r+=`<!-- payload-type:${J.excalidraw} -->`,r+="<!-- payload-version:2 -->",r+="<!-- payload-start -->",r+=t,r+="<!-- payload-end -->",r},b6=async({svg:e})=>{if(e.includes(`payload-type:${J.excalidraw}`)){let t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw new Error("INVALID");let n=(e.match(/<!-- payload-version:(\d+) -->/)?.[1]||"1")!=="1";try{let i=await iE(t[1],n),a=JSON.parse(i);if(!("encoded"in a)){if("type"in a&&a.type===jt.excalidraw)return i;throw new Error("FAILED")}return await zh(a)}catch(i){throw console.error(i),new Error("FAILED")}}throw new Error("INVALID")}});import{nanoid as x6}from"nanoid";var mE,Uh,pE,ml,di,Qd,pl,Wh,Vh,Ln,uE,em,hE,$s,Yh,gE,fE,E6,dE,Jd,Xs,Mn,Er=j(()=>{"use strict";f();Rr();U();ge();qn();Ve();z();An();Pn();cl();mE=async e=>{let t;if(e.type===J.png)try{return await(await Promise.resolve().then(()=>(dl(),Ks))).decodePngMetadata(e)}catch(r){throw r.message==="INVALID"?new yo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new yo("Error: cannot restore image")}else if("text"in Blob?t=await e.text():t=await new Promise(r=>{let o=new FileReader;o.readAsText(e,"utf8"),o.onloadend=()=>{o.readyState===FileReader.DONE&&r(o.result)}}),e.type===J.svg)try{return await(await Promise.resolve().then(()=>(dl(),Ks))).decodeSvgMetadata({svg:t})}catch(r){throw r.message==="INVALID"?new yo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new yo("Error: cannot restore image")}return t},Uh=e=>e&&e.name.match(/\.(json|excalidraw|png|svg)$/)?.[1]||null,pE=e=>e==="png"||e==="svg",ml=e=>{let t=Uh(e);return t==="png"||t==="svg"},di=e=>{let{type:t}=e||{};return!!t&&Object.values(ds).includes(t)},Qd=async(e,t,r,o)=>{let n=await mE(e),i;try{try{i=JSON.parse(n)}catch(a){throw di(e)?new yo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):a}if(bE(i))return{type:J.excalidraw,data:ci({elements:tm(i.elements||[]),appState:{theme:t?.theme,fileHandle:o||e.handle||null,...Bd(i.appState||{}),...t?Yo(i.elements||[],t):{}},files:i.files},t,r,{repairBindings:!0,refreshDimensions:!1})};if(Kh(i))return{type:J.excalidrawlib,data:i};throw new Error("Error: invalid file")}catch(a){throw a instanceof yo?a:new Error("Error: invalid file")}},pl=async(e,t,r,o)=>{let n=await Qd(e,t,r,o);if(n.type!==J.excalidraw)throw new Error("Error: invalid file");return n.data},Wh=(e,t="unpublished")=>{let r=JSON.parse(e);if(!Kh(r))throw new Error("Invalid library");let o=r.libraryItems||r.library;return aa(o,t)},Vh=async(e,t="unpublished")=>Wh(await mE(e),t),Ln=async e=>new Promise(async(t,r)=>{try{Oo(e)&&(e=await e),e.toBlob(o=>{if(!o)return r(new gd("Error: Canvas too big","CANVAS_POSSIBLY_TOO_BIG"));t(o)})}catch(o){r(o)}}),uE=async e=>{try{let t=await window.crypto.subtle.digest("SHA-1",await Mn(e));return hx(new Uint8Array(t))}catch(t){return console.error(t),x6(40)}},em=async e=>new Promise((t,r)=>{let o=new FileReader;o.onload=()=>{let n=o.result;t(n)},o.onerror=n=>r(n),o.readAsDataURL(e)}),hE=(e,t="")=>{let r=e.indexOf(","),o=atob(e.slice(r+1)),n=e.slice(0,r).split(":")[1].split(";")[0],i=new ArrayBuffer(o.length),a=new Uint8Array(i);for(let l=0;l<o.length;l++)a[l]=o.charCodeAt(l);return new File([i],t,{type:n})},$s=async(e,t)=>{if(e.type===J.svg)return e;let[r,o]=await Promise.all([import("pica").then(i=>i.default),import("image-blob-reduce").then(i=>i.default)]),n=o({pica:r({features:["js","wasm"]})});if(t.outputType){let{outputType:i}=t;n._create_blob=function(a){return this.pica.toBlob(a.out_canvas,i,.8).then(l=>(a.out_blob=l,a))}}if(!di(e))throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"});return new File([await n.toBlob(e,{max:t.maxWidthOrHeight})],e.name,{type:t.outputType||e.type})},Yh=(e,t="")=>new File([new TextEncoder().encode(e)],t,{type:J.svg}),gE=async(e,t="")=>{let r;try{r=await fetch(e)}catch{throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"})}if(!r.ok)throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"});let o=await r.blob();if(o.type&&di(o)){let n=t||o.name||"";return new File([o],n,{type:o.type})}throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"})},fE=async e=>{let t=e.dataTransfer.files.item(0),r=await E6(e);return{file:t?await Xs(t):null,fileHandle:r}},E6=async e=>{if(si)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(t){return console.warn(t.name,t.message),null}return null},dE=e=>{let t=null,r=`${[...new Uint8Array(e).slice(0,8)].join(" ")} `,o={png:"137 80 78 71 13 10 26 10 ",jpg:"255 216 255 ",gif:"71 73 70 56 57 97 "};return r===o.png?t=J.png:r.startsWith(o.jpg)?t=J.jpg:r.startsWith(o.gif)&&(t=J.gif),t},Jd=(e,t,r)=>new File([e],r||"",{type:t}),Xs=async e=>{if(e.type){if(di(e)){let t=await Mn(e),r=dE(t);r&&r!==e.type&&(e=Jd(t,r,e.name))}}else if(e?.name?.endsWith(".excalidrawlib"))e=Jd(await Mn(e),J.excalidrawlib,e.name);else if(e?.name?.endsWith(".excalidraw"))e=Jd(await Mn(e),J.excalidraw,e.name);else{let t=await Mn(e),r=dE(t);r&&(e=Jd(t,r,e.name))}return e},Mn=e=>"arrayBuffer"in e?e.arrayBuffer():new Promise((t,r)=>{let o=new FileReader;o.onload=n=>{if(!n.target?.result)return r(new Error("Couldn't convert blob to ArrayBuffer"));t(n.target.result)},o.readAsArrayBuffer(e)})});var y6,mi,rm,$h,bE,Kh,om,xE,Pn=j(()=>{"use strict";f();An();Rr();U();ge();Er();y6=(e,t)=>{let r={};for(let o of e)!o.isDeleted&&"fileId"in o&&o.fileId&&t[o.fileId]&&(r[o.fileId]=t[o.fileId]);return r},mi=(e,t,r,o)=>{let n={type:jt.excalidraw,version:Ui.excalidraw,source:ms,elements:o==="local"?tm(e):EE(e),appState:o==="local"?Bd(t):P0(t),files:o==="local"?y6(e,r):void 0};return JSON.stringify(n,null,2)},rm=async(e,t,r,o=t.name||ad)=>{let n=mi(e,t,r,"local"),i=new Blob([n],{type:J.excalidraw});return{fileHandle:await ll(i,{name:o,extension:"excalidraw",description:"Excalidraw file",fileHandle:ml(t.fileHandle)?null:t.fileHandle})}},$h=async(e,t)=>{let r=await al({description:"Excalidraw files"});return pl(await Xs(r),e,t,r.handle)},bE=e=>e?.type===jt.excalidraw&&(!e.elements||Array.isArray(e.elements)&&(!e.appState||typeof e.appState=="object")),Kh=e=>typeof e=="object"&&e&&e.type===jt.excalidrawLibrary&&(e.version===1||e.version===2),om=e=>{let t={type:jt.excalidrawLibrary,version:Ui.excalidrawLibrary,source:ms,libraryItems:e};return JSON.stringify(t,null,2)},xE=async e=>{let t=om(e);await ll(new Blob([t],{type:J.excalidrawlib}),{name:"library",extension:"excalidrawlib",description:"Excalidraw library file"})}});var Xh,nm,im,w6,yE,Zh=j(()=>{"use strict";f();U();ce();Xh=e=>new Promise((t,r)=>{let o=new Image;o.onload=()=>{t(o)},o.onerror=n=>{r(n)},o.src=e}),nm=async({fileIds:e,files:t,imageCache:r})=>{let o=new Map,n=new Map;return await Promise.all(e.reduce((i,a)=>{let l=t[a];return l&&!o.has(a)?(o.set(a,!0),i.concat((async()=>{try{if(l.mimeType===J.binary)throw new Error("Only images can be added to ImageCache");let s=Xh(l.dataURL),c={image:s,mimeType:l.mimeType};r.set(a,c);let d=await s;r.set(a,{...c,image:d})}catch{n.set(a,!0)}})())):i},[])),{imageCache:r,updatedFiles:o,erroredFiles:n}},im=e=>e.filter(t=>nr(t)),w6=e=>e?.nodeName.toLowerCase()==="svg",yE=async e=>{let t=new DOMParser().parseFromString(e,J.svg),r=t.querySelector("svg");if(t.querySelector("parsererror")||!w6(r))throw new Error("Invalid SVG");if(r.hasAttribute("xmlns")||r.setAttribute("xmlns",Fe),!r.hasAttribute("width")||!r.hasAttribute("height")){let n=r.getAttribute("viewBox"),i=r.getAttribute("width")||"50",a=r.getAttribute("height")||"50";if(n){let l=n.match(/\d+ +\d+ +(\d+) +(\d+)/);l&&([,i,a]=l)}r.setAttribute("width",i),r.setAttribute("height",a)}return r.outerHTML}});import{pointsOnBezierCurves as v6}from"points-on-curve";var am,wE,vE,TE,T6,SE,IE,jh=j(()=>{"use strict";f();fh();am=e=>{let{angle:t,width:r,height:o,x:n,y:i}=e,a=Xa(t),l=n+r/2,s=i+o/2,c=[l,s],d=[];return e.type==="diamond"?d=[Pr([l,i],a,c),Pr([n+r,s],a,c),Pr([l,i+o],a,c),Pr([n,s],a,c)]:d=[Pr([n,i],a,c),Pr([n+r,i],a,c),Pr([n+r,i+o],a,c),Pr([n,i+o],a,c)],{type:"polygon",data:d}},wE=e=>{let{width:t,height:r,angle:o,x:n,y:i}=e;return{type:"ellipse",data:{center:[n+t/2,i+r/2],angle:o,halfWidth:t/2,halfHeight:r/2}}},vE=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},TE=(e,t=[0,0],r,o)=>{let n=s=>Pr([s[0]+t[0],s[1]+t[1]],Xa(r),o),i=vE(e),a=[],l=[0,0];for(let s of i)if(s.op==="move"&&(l=n(s.data)),s.op==="bcurveTo"){let c=n([s.data[0],s.data[1]]),d=n([s.data[2],s.data[3]]),m=n([s.data[4],s.data[5]]);a.push([l,c,d,m]),l=m}return{type:"polycurve",data:a}},T6=e=>{let t=e[0],r=[];for(let o=1;o<e.length;o++){let n=e[o];r.push([t,n]),t=n}return r},SE=(e,t,r=!1)=>{let o=Xa(e.angle),n=a=>Pr(ph(a,[e.x,e.y]),o,t),i=T6(e.points.map(a=>n(a)));return r?{type:"polygon",data:$a(i.flat())}:{type:"polyline",data:i}},IE=(e,t,r=[0,0],o,n)=>{let i=d=>Pr([d[0]+r[0],d[1]+r[1]],Xa(o),n);if(e.roundness===null)return{type:"polygon",data:$a(e.points.map(d=>i(d)))};let a=vE(t),l=[],s=!1;for(let d of a)d.op==="move"?(s=!s,s&&l.push([d.data[0],d.data[1]])):d.op==="bcurveTo"?s&&(l.push([d.data[0],d.data[1]]),l.push([d.data[2],d.data[3]]),l.push([d.data[4],d.data[5]])):d.op==="lineTo"&&s&&l.push([d.data[0],d.data[1]]);return{type:"polygon",data:v6(l,10,5).map(d=>i(d))}}});var lm,ul,la,CE,kE,sm=j(()=>{"use strict";f();Rt();at();jh();Id();z();ce();lm=e=>{if(e.type==="arrow")return!1;let t=!or(e.backgroundColor)||gr(e)||Vt(e)||G(e);return e.type==="line"?t&&ir(e.points):e.type==="freedraw"?t&&ir(e.points):t||Zr(e)},ul=({x:e,y:t,element:r,shape:o,threshold:n=10,frameNameBound:i=null})=>{let a=lm(r)?Za([e,t],o)||Ms([e,t],o,n):Ms([e,t],o,n);return!a&&i&&(a=Za([e,t],{type:"polygon",data:am(i).data})),a},la=(e,t,r,o,n=0)=>{let[i,a,l,s]=Dr(r,o);return i-=n,a-=n,l+=n,s+=n,Ed([i,a],[e,t],[l,s])},CE=(e,t)=>!ul(e)&&la(e.x,e.y,e.element,t),kE=(e,t,r)=>r&&Za([e,t],r)});var qh,Zs,Jh,cm,dm=j(()=>{"use strict";f();U();at();sm();Rt();bn();qh=document.createElement("img");qh.src=`data:${J.svg}, ${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1971c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>')}`;Zs=([e,t,r,o],n,i)=>{let a=AE,l=a/i.zoom.value,s=a/i.zoom.value,c=a/i.zoom.value,d=(e+r)/2,m=(t+o)/2,p=(a-8)/(2*i.zoom.value),u=4/i.zoom.value,h=r+u-p,x=t-u-c+p,[E,v]=Ee(h+l/2,x+s/2,d,m,n);return[E-l/2,v-s/2,l,s]},Jh=(e,t,r,[o,n])=>{let i=4/r.zoom.value,[a,l,s,c]=te(e,t),[d,m,p,u]=Zs([a,l,s,c],e.angle,r);return o>d-i&&o<d+i+p&&n>m-i&&n<m+u+i},cm=(e,t,r,[o,n],i)=>!e.link||r.selectedElementIds[e.id]?!1:!i&&r.viewModeEnabled&&la(o,n,e,t)?!0:Jh(e,t,r,[o,n])});var js,mm,pm,Qh=j(()=>{"use strict";f();U();js=(e,t,r,o,n=!0)=>{e.beginPath(),e.arc(t,r,o,0,Math.PI*2),e.fill(),n&&e.stroke()},mm=(e,t)=>[e.width/t,e.height/t],pm=({canvas:e,scale:t,normalizedWidth:r,normalizedHeight:o,theme:n,isExporting:i,viewBackgroundColor:a})=>{let l=e.getContext("2d");return l.setTransform(1,0,0,1,0,0),l.scale(t,t),i&&n===oe.DARK&&(l.filter=Oa),typeof a=="string"?((a==="transparent"||a.length===5||a.length===9||/(hsla|rgba)\(/.test(a))&&l.clearRect(0,0,r,o),l.save(),l.fillStyle=a,l.fillRect(0,0,r,o),l.restore()):l.clearRect(0,0,r,o),l}});var S6,ME,_n,LE,PE,eg,hm,gm=j(()=>{"use strict";f();U();ge();er();ce();bn();Gs();dm();Qh();z();lt();S6=(e,t,r,o,n,i,a)=>{let s;(E=>(E.Bold="#cccccc",E.Regular="#e5e5e5"))(s||={});let c=-Math.round(n.value/t)*t+r%t,d=-Math.round(n.value/t)*t+o%t,m=Math.min(1/n.value,1),p=1/n.value,u=[m*3,p+(m+p)];e.save(),e.lineWidth=m;for(let h=c;h<c+i+t*2;h+=t){let x=Math.round(h-r)%(5*t)===0;e.beginPath(),e.setLineDash(x?[]:u),e.strokeStyle=x?"#cccccc":"#e5e5e5",e.moveTo(h,d-t),e.lineTo(h,d+a+t*2),e.stroke()}for(let h=d;h<d+a+t*2;h+=t){let x=Math.round(h-o)%(5*t)===0;e.beginPath(),e.setLineDash(x?[]:u),e.strokeStyle=x?"#cccccc":"#e5e5e5",e.moveTo(c-t,h),e.lineTo(c+i+t*2,h),e.stroke()}e.restore()},ME=(e,t,r,o)=>{t.translate(e.x+o.scrollX,e.y+o.scrollY),t.beginPath(),t.roundRect?t.roundRect(0,0,e.width,e.height,$e.radius/o.zoom.value):t.rect(0,0,e.width,e.height),t.clip(),t.translate(-(e.x+o.scrollX),-(e.y+o.scrollY))},LE=(e,t,r,o)=>{if(e.link&&!r.selectedElementIds[e.id]){let[n,i,a,l]=te(e,o),[s,c,d,m]=Zs([n,i,a,l],e.angle,r),p=s+d/2,u=c+m/2;if(t.save(),t.translate(r.scrollX+p,r.scrollY+u),t.rotate(e.angle),!_n||_n.zoom!==r.zoom.value){_n=document.createElement("canvas"),_n.zoom=r.zoom.value,_n.width=d*window.devicePixelRatio*r.zoom.value,_n.height=m*window.devicePixelRatio*r.zoom.value;let h=_n.getContext("2d");h.scale(window.devicePixelRatio*r.zoom.value,window.devicePixelRatio*r.zoom.value),h.fillStyle="#fff",h.fillRect(0,0,d,m),h.drawImage(qh,0,0,d,m),h.restore(),t.drawImage(_n,s-p,c-u,d,m)}else t.drawImage(_n,s-p,c-u,d,m);t.restore()}},PE=({canvas:e,rc:t,elementsMap:r,allElementsMap:o,visibleElements:n,scale:i,appState:a,renderConfig:l})=>{if(e===null)return;let{renderGrid:s=!0,isExporting:c}=l,[d,m]=mm(e,i),p=pm({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m,theme:a.theme,isExporting:c,viewBackgroundColor:a.viewBackgroundColor});p.scale(a.zoom.value,a.zoom.value),s&&a.gridSize&&S6(p,a.gridSize,a.scrollX,a.scrollY,a.zoom,d/a.zoom.value,m/a.zoom.value);let u=new Set;n.forEach(h=>{h.groupIds.length>0&&a.frameToHighlight&&a.selectedElementIds[h.id]&&(Ko(h,a.frameToHighlight,r)||h.groupIds.find(x=>u.has(x)))&&h.groupIds.forEach(x=>u.add(x))}),n.filter(h=>!Vt(h)).forEach(h=>{try{let x=h.frameId||a.frameToHighlight?.id;if(G(h)&&h.containerId&&r.has(h.containerId))return;if(p.save(),x&&a.frameRendering.enabled&&a.frameRendering.clip){let v=um(h,r,a);v&&sa(h,r,a)&&ME(v,p,l,a),hl(h,r,o,t,p,l,a)}else hl(h,r,o,t,p,l,a);let E=de(h,o);E&&hl(E,r,o,t,p,l,a),p.restore(),c||LE(h,p,a,r)}catch(x){console.error(x)}}),n.filter(h=>Vt(h)).forEach(h=>{try{let x=()=>{if(hl(h,r,o,t,p,l,a),Vt(h)&&(c||vt(h)&&l.embedsValidationStatus.get(h.id)!==!0)&&h.width&&h.height){let v=Zd(h);hl(v,r,o,t,p,l,a)}c||LE(h,p,a,r)};if((h.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){p.save();let v=um(h,r,a);v&&sa(h,r,a)&&ME(v,p,l,a),x(),p.restore()}else x()}catch(x){console.error(x)}})},eg=za(e=>{PE(e)},{trailing:!0}),hm=(e,t)=>{if(t){eg(e);return}PE(e)}});import _E from"roughjs/bin/rough";var I6,C6,k6,DE,RE,fm,gl,tg,NE,qs=j(()=>{"use strict";f();at();Z0();z();U();Rr();Pn();Zh();er();ge();We();ce();wo();gm();I6="<!-- svg-source:excalidraw -->",C6=(e,t)=>{if(e.width<=t)return e;let o=document.createElement("canvas").getContext("2d");o.font=Ge({fontFamily:e.fontFamily,fontSize:e.fontSize});let n=e.text;if(o.measureText(n).width>t)for(let a=n.length;a>0;a--){let l=`${n.slice(0,a)}...`;if(o.measureText(l).width<=t){n=l;break}}return ne(e,{text:n,width:t})},k6=(e,t)=>{let r=[],o=0,n=0;for(let i of e){if(Q(i)){jn(i)?o++:n++;let a=Nt({x:i.x,y:i.y-$e.nameOffsetY,fontFamily:it.Assistant,fontSize:$e.nameFontSize,lineHeight:$e.nameLineHeight,strokeColor:t.exportWithDarkMode?$e.nameColorDarkTheme:$e.nameColorLightTheme,text:bm(i,jn(i)?o:n)});a.y-=a.height,a=C6(a,i.width),r.push(a)}r.push(i)}return r},DE=(e,t)=>(t=t||ar().frameRendering,{enabled:e?!0:t.enabled,outline:e?!1:t.outline,name:e?!1:t.name,clip:e?!0:t.clip}),RE=({elements:e,exportingFrame:t,frameRendering:r,exportWithDarkMode:o})=>{let n;return t?n=fl(e,t):r.enabled&&r.name?n=k6(e,{exportWithDarkMode:o}):n=e,n},fm=async(e,t,r,{exportBackground:o,exportPadding:n=fo,viewBackgroundColor:i,exportingFrame:a},l=(s,c)=>{let d=document.createElement("canvas");return d.width=s*t.exportScale,d.height=c*t.exportScale,{canvas:d,scale:t.exportScale}})=>{let s=DE(a??null,t.frameRendering??null),c=RE({elements:e,exportingFrame:a,exportWithDarkMode:t.exportWithDarkMode,frameRendering:s});a&&(n=0);let[d,m,p,u]=tg(a?[a]:rg(c),n),{canvas:h,scale:x=1}=l(p,u),E=ar(),{imageCache:v}=await nm({imageCache:new Map,fileIds:im(c).map(w=>w.fileId),files:r});return hm({canvas:h,rc:_E.canvas(h),elementsMap:xo($(c)),allElementsMap:xo($(Mr(e))),visibleElements:c,scale:x,appState:{...t,frameRendering:s,viewBackgroundColor:o?i:null,scrollX:-d+n,scrollY:-m+n,zoom:E.zoom,shouldCacheIgnoreZoom:!1,theme:t.exportWithDarkMode?oe.DARK:oe.LIGHT},renderConfig:{canvasBackgroundColor:i,imageCache:v,renderGrid:!1,isExporting:!0,embedsValidationStatus:new Map,elementsPendingErasure:new Set}}),h},gl=async(e,t,r,o)=>{let n=DE(o?.exportingFrame??null,t.frameRendering??null),{exportPadding:i=fo,exportWithDarkMode:a=!1,viewBackgroundColor:l,exportScale:s=1,exportEmbedScene:c}=t,{exportingFrame:d=null}=o||{},m=RE({elements:e,exportingFrame:d,exportWithDarkMode:a,frameRendering:n});d&&(i=0);let p="";if(c)try{p=await(await Promise.resolve().then(()=>(dl(),Ks))).encodeSvgMetadata({text:mi(e,t,r||{},"local")})}catch(A){console.error(A)}let[u,h,x,E]=tg(d?[d]:rg(m),i),v=document.createElementNS(Fe,"svg");v.setAttribute("version","1.1"),v.setAttribute("xmlns",Fe),v.setAttribute("viewBox",`0 0 ${x} ${E}`),v.setAttribute("width",`${x*s}`),v.setAttribute("height",`${E*s}`),a&&v.setAttribute("filter",Oa);let w="https://excalidraw.com/";T.VITE_IS_EXCALIDRAW_NPM_PACKAGE&&(w=window.EXCALIDRAW_ASSET_PATH||`https://unpkg.com/${T.VITE_PKG_NAME}@${T.PKG_VERSION}`,w?.startsWith("/")&&(w=w.replace("/",`${window.location.origin}/`)),w=`${w}/dist/excalidraw-assets/`);let y=-u+i,I=-h+i,P=Js(e),C="",_=$(e);for(let A of P){let[M,k,O,X]=te(A,_),Y=(O-M)/2-(A.x-M),ee=(X-k)/2-(A.y-k);C+=`<clipPath id=${A.id}>
25
25
  <rect transform="translate(${A.x+y} ${A.y+I}) rotate(${A.angle} ${Y} ${ee})"
26
26
  width="${A.width}"
27
27
  height="${A.height}"
28
28
  >
29
29
  </rect>
30
30
  </clipPath>`}if(v.innerHTML=`
31
- ${S6}
31
+ ${I6}
32
32
  ${p}
33
33
  <defs>
34
34
  <style class="style-fonts">
@@ -47,22 +47,22 @@ var mS=Object.defineProperty;var vb=e=>t=>{var r=e[t];if(r)return r();throw new
47
47
  </style>
48
48
  ${C}
49
49
  </defs>
50
- `,t.exportBackground&&l){let A=v.ownerDocument.createElementNS(Fe,"rect");A.setAttribute("x","0"),A.setAttribute("y","0"),A.setAttribute("width",`${x}`),A.setAttribute("height",`${E}`),A.setAttribute("fill",l),v.appendChild(A)}let D=ME.svg(v),H=o?.renderEmbeddables??!1;return Y0(m,xo($(m)),D,v,r||{},{offsetX:y,offsetY:I,isExporting:!0,exportWithDarkMode:a,renderEmbeddables:H,frameRendering:n,canvasBackgroundColor:l,embedsValidationStatus:H?new Map(m.filter(A=>Q(A)).map(A=>[A.id,!0])):new Map}),v},eg=(e,t)=>{let[r,o,n,i]=we(e),a=Mt(r,n)+t*2,l=Mt(o,i)+t*2;return[r,o,a,l]},_E=(e,t,r)=>{let[,,o,n]=eg(e,t).map(i=>Math.trunc(i*r));return[o,n]}});var Ao,je,pi,RE,ca,fl,Qs,rg,DE,k6,NE,fm,to,OE,A6,M6,L6,BE,P6,_6,FE,og=j(()=>{"use strict";f();Zt();G();ge();Eo();Ao=32,je=12,pi=256,RE=50,ca="NOT_SPREADSHEET",fl="VALID_SPREADSHEET",Qs=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},rg=(e,t)=>e.slice(1).every(r=>Qs(r[t])!==null),DE=e=>{let t=e[0].length;if(t>2)return{type:ca,reason:"More than 2 columns"};if(t===1){if(!rg(e,0))return{type:ca,reason:"Value is not numeric"};let s=Qs(e[0][0])===null,c=(s?e.slice(1):e).map(d=>Qs(d[0]));return c.length<2?{type:ca,reason:"Less than two rows"}:{type:fl,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let r=rg(e,0),o=rg(e,1);if(!r&&!o)return{type:ca,reason:"Value is not numeric"};let[n,i]=o?[0,1]:[1,0],a=Qs(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:ca,reason:"Less than 2 rows"}:{type:fl,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>Qs(s[i]))}}},k6=e=>{let t=[];for(let r=0;r<e[0].length;r++){let o=[];for(let n=0;n<e.length;n++)o.push(e[n][r]);t.push(o)}return t},NE=e=>{let t=e.trim().split(`
50
+ `,t.exportBackground&&l){let A=v.ownerDocument.createElementNS(Fe,"rect");A.setAttribute("x","0"),A.setAttribute("y","0"),A.setAttribute("width",`${x}`),A.setAttribute("height",`${E}`),A.setAttribute("fill",l),v.appendChild(A)}let D=_E.svg(v),H=o?.renderEmbeddables??!1;return X0(m,xo($(m)),D,v,r||{},{offsetX:y,offsetY:I,isExporting:!0,exportWithDarkMode:a,renderEmbeddables:H,frameRendering:n,canvasBackgroundColor:l,embedsValidationStatus:H?new Map(m.filter(A=>Q(A)).map(A=>[A.id,!0])):new Map}),v},tg=(e,t)=>{let[r,o,n,i]=we(e),a=Mt(r,n)+t*2,l=Mt(o,i)+t*2;return[r,o,a,l]},NE=(e,t,r)=>{let[,,o,n]=tg(e,t).map(i=>Math.trunc(i*r));return[o,n]}});var Ao,je,pi,BE,ca,bl,Qs,og,OE,A6,FE,xm,to,HE,M6,L6,P6,zE,_6,D6,GE,ng=j(()=>{"use strict";f();Zt();U();ge();Eo();Ao=32,je=12,pi=256,BE=50,ca="NOT_SPREADSHEET",bl="VALID_SPREADSHEET",Qs=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},og=(e,t)=>e.slice(1).every(r=>Qs(r[t])!==null),OE=e=>{let t=e[0].length;if(t>2)return{type:ca,reason:"More than 2 columns"};if(t===1){if(!og(e,0))return{type:ca,reason:"Value is not numeric"};let s=Qs(e[0][0])===null,c=(s?e.slice(1):e).map(d=>Qs(d[0]));return c.length<2?{type:ca,reason:"Less than two rows"}:{type:bl,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let r=og(e,0),o=og(e,1);if(!r&&!o)return{type:ca,reason:"Value is not numeric"};let[n,i]=o?[0,1]:[1,0],a=Qs(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:ca,reason:"Less than 2 rows"}:{type:bl,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>Qs(s[i]))}}},A6=e=>{let t=[];for(let r=0;r<e[0].length;r++){let o=[];for(let n=0;n<e.length;n++)o.push(e[n][r]);t.push(o)}return t},FE=e=>{let t=e.trim().split(`
51
51
  `).map(i=>i.trim().split(" "));if(t.length&&t[0].length!==2&&(t=e.trim().split(`
52
- `).map(i=>i.trim().split(","))),t.length===0)return{type:ca,reason:"No values"};let r=t[0].length;if(!t.every(i=>i.length===r))return{type:ca,reason:"All rows don't have same number of columns"};let n=DE(t);if(n.type!==fl){let i=DE(k6(t));if(i.type===fl)return i}return n},fm=_b(Ab),to={fillStyle:"hachure",fontFamily:Wt,fontSize:At,opacity:100,roughness:1,strokeColor:se.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:ft.MIDDLE,locked:!1},OE=e=>{let t=(Ao+je)*e.values.length+je,r=pi+je*2;return{chartWidth:t,chartHeight:r}},A6=(e,t,r,o,n)=>e.labels?.map((i,a)=>Nt({groupIds:[o],backgroundColor:n,...to,text:i.length>8?`${i.slice(0,5)}...`:i,x:t+a*(Ao+je)+je*2,y:r+je/2,width:Ao,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],M6=(e,t,r,o,n)=>{let i=Nt({groupIds:[o],backgroundColor:n,...to,x:t-je,y:r-je,text:"0",textAlign:"right"}),a=Nt({groupIds:[o],backgroundColor:n,...to,x:t-je,y:r-pi-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},L6=(e,t,r,o,n)=>{let{chartWidth:i,chartHeight:a}=OE(e),l=Qr({backgroundColor:n,groupIds:[o],...to,type:"line",x:t,y:r,startArrowhead:null,endArrowhead:null,width:i,points:[[0,0],[i,0]]}),s=Qr({backgroundColor:n,groupIds:[o],...to,type:"line",x:t,y:r,startArrowhead:null,endArrowhead:null,height:a,points:[[0,0],[0,-a]]}),c=Qr({backgroundColor:n,groupIds:[o],...to,type:"line",x:t,y:r-pi-je,startArrowhead:null,endArrowhead:null,strokeStyle:"dotted",width:i,opacity:RE,points:[[0,0],[i,0]]});return[l,s,c]},BE=(e,t,r,o,n,i)=>{let{chartWidth:a,chartHeight:l}=OE(e),s=e.title?Nt({backgroundColor:n,groupIds:[o],...to,text:e.title,x:t+a/2,y:r-pi-je*2-At,roundness:null,textAlign:"center"}):null,c=i?Fr({backgroundColor:n,groupIds:[o],...to,type:"rectangle",x:t,y:r-l,width:a,height:l,strokeColor:se.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...A6(e,t,r,o,n),...M6(e,t,r,o,n),...L6(e,t,r,o,n)]},P6=(e,t,r)=>{let o=Math.max(...e.values),n=Pt(),i=fm[Math.floor(Math.random()*fm.length)];return[...e.values.map((l,s)=>{let c=l/o*pi;return Fr({backgroundColor:i,groupIds:[n],...to,type:"rectangle",x:t+s*(Ao+je)+je,y:r-c-je,width:Ao,height:c})}),...BE(e,t,r,n,i,T.DEV)]},_6=(e,t,r)=>{let o=Math.max(...e.values),n=Pt(),i=fm[Math.floor(Math.random()*fm.length)],a=0,l=[];for(let x of e.values){let E=a*(Ao+je),v=-(x/o)*pi;l.push([E,v]),a++}let s=Math.max(...l.map(x=>x[0])),c=Math.max(...l.map(x=>x[1])),d=Math.min(...l.map(x=>x[0])),m=Math.min(...l.map(x=>x[1])),p=Qr({backgroundColor:i,groupIds:[n],...to,type:"line",x:t+je+Ao/2,y:r-je,startArrowhead:null,endArrowhead:null,height:c-m,width:s-d,strokeWidth:2,points:l}),u=e.values.map((x,E)=>{let v=E*(Ao+je)+je/2,w=-(x/o)*pi+je/2;return Fr({backgroundColor:i,groupIds:[n],...to,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:t+v+Ao/2,y:r+w-je*2,width:je,height:je})}),h=e.values.map((x,E)=>{let v=E*(Ao+je)+je/2,w=x/o*pi+je/2+je;return Qr({backgroundColor:i,groupIds:[n],...to,type:"line",x:t+v+Ao/2+je/2,y:r-w,startArrowhead:null,endArrowhead:null,height:w,strokeStyle:"dotted",opacity:RE,points:[[0,0],[0,w]]})});return[...BE(e,t,r,n,i,T.DEV),p,...h,...u]},FE=(e,t,r,o)=>e==="line"?_6(t,r,o):P6(t,r,o)});function zE(e){let t=[];for(let r of e.childNodes)if(r.nodeType===3){let o=r.textContent?.trim();o&&t.push({type:"text",value:o})}else if(r instanceof HTMLImageElement){let o=r.getAttribute("src");o&&o.startsWith("http")&&t.push({type:"imageUrl",value:o})}else t=t.concat(zE(r));return t}var UO,bm,bl,D6,HE,R6,xm,N6,O6,GE,B6,Em,ym,Dn,F6,ui=j(()=>{"use strict";f();og();G();ce();In();We();er();z();UO="clipboard"in navigator&&"readText"in navigator.clipboard,bm="clipboard"in navigator&&"writeText"in navigator.clipboard,bl="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,D6=e=>!!([jt.excalidraw,jt.excalidrawClipboard,jt.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),HE=({types:e,files:t})=>{!e&&!t&&console.warn("createPasteEvent: no types or files provided");let r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[o,n]of Object.entries(e))try{if(r.clipboardData?.setData(o,n),r.clipboardData?.getData(o)!==n)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}if(t){let o=-1;for(let n of t){o++;try{if(r.clipboardData?.items.add(n),r.clipboardData?.files[o]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return r},R6=({elements:e,files:t})=>{let r=$(e),o=new Set(e.filter(l=>Q(l))),n=!1,i=e.reduce((l,s)=>(nr(s)&&(n=!0,t&&t[s.fileId]&&(l[s.fileId]=t[s.fileId])),l),{});n&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:jt.excalidrawClipboard,elements:e.map(l=>{if(Ot(l,r)&&!o.has(Ot(l,r))){let s=Sn(l);return F(s,{frameId:null}),s}return l}),files:t?i:void 0};return JSON.stringify(a)},xm=async(e,t,r)=>{await Dn(R6({elements:e,files:t}),r)},N6=e=>{let t=NE(e);return t.type===fl?{spreadsheet:t.spreadsheet}:null};O6=e=>{let t=e.clipboardData?.getData("text/html");if(!t)return null;try{let r=new DOMParser().parseFromString(t,"text/html"),o=zE(r.body);if(o.length)return{type:"mixedContent",value:o}}catch(r){console.error(`error in parseHTMLFromPaste: ${r.message}`)}return null},GE=async()=>{let e={};try{if(navigator.clipboard?.readText)return{"text/plain":await navigator.clipboard?.readText()}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else throw r}let t;try{t=await navigator.clipboard?.read()}catch(r){if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}for(let r of t)for(let o of r.types)if(hs(zb,o))try{e[o]=await(await r.getType(o)).text()}catch(n){console.warn(`Cannot retrieve ${o} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},B6=async(e,t=!1)=>{try{let r=!t&&e&&O6(e);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData("text/plain")||r.value.map(n=>n.value).join(`
53
- `).trim()}:r:{type:"text",value:(e.clipboardData?.getData("text/plain")||"").trim()}}catch{return{type:"text",value:""}}},Em=async(e,t=!1)=>{let r=await B6(e,t);if(r.type==="mixedContent")return{mixedContent:r.value};try{let o=!t&&N6(r.value);if(o)return o}catch(o){console.error(o)}try{let o=JSON.parse(r.value),n=o.type===jt.excalidrawClipboardWithAPI;if(D6(o))return{elements:o.elements,files:o.files,text:t?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:r.value}},ym=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[J.png]:e})])}catch(t){if(Oo(e))await navigator.clipboard.write([new window.ClipboardItem({[J.png]:await e})]);else throw t}},Dn=async(e,t)=>{if(bm)try{await navigator.clipboard.writeText(e||"");return}catch(r){console.error(r)}try{if(t){if(t.clipboardData?.setData("text/plain",e||""),t.clipboardData?.getData("text/plain")!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}if(!F6(e))throw new Error("Error copying to clipboard.")},F6=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",r=document.createElement("textarea");r.style.border="0",r.style.padding="0",r.style.margin="0",r.style.position="absolute",r.style[t?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;r.style.top=`${o}px`,r.style.fontSize="12pt",r.setAttribute("readonly",""),r.value=e,document.body.appendChild(r);let n=!1;try{r.select(),r.setSelectionRange(0,r.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return r.remove(),n}});var hi,wm,xl,H6,da=j(()=>{"use strict";f();qs();Rr();cl();G();dl();Pn();ui();hi=({elements:e,appState:t,files:r,maxWidthOrHeight:o,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=ci({elements:e,appState:t},null,null),{exportBackground:c,viewBackgroundColor:d}=s;return hm(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},r||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let x=Math.max(m,p),E=o<x?o/x:t?.exportScale??1;return u.width=m*E,u.height=p*E,{canvas:u,scale:E}}let h=n?.(m,p)||{width:m,height:p};return u.width=h.width,u.height=h.height,{canvas:u,scale:h.scale??1}})},wm=async e=>{let{mimeType:t=J.png,quality:r}=e;t===J.png&&typeof r=="number"&&console.warn(`"quality" will be ignored for "${J.png}" mimeType`),t==="image/jpg"&&(t=J.jpg),t===J.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${J.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await hi(e);return r=r||(/image\/jpe?g/.test(t)?.92:.8),new Promise((n,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&t===J.png&&e.appState?.exportEmbedScene&&(a=await zh({blob:a,metadata:mi(e.elements,e.appState,e.files||{},"local")})),n(a)},t,r)})},xl=async({elements:e,appState:t=ar(),files:r={},exportPadding:o,renderEmbeddables:n,exportingFrame:i})=>{let{elements:a,appState:l}=ci({elements:e,appState:t},null,null),s={...l,exportPadding:o};return hl(a,s,r,{exportingFrame:i,renderEmbeddables:n})},H6=async e=>{if(e.type==="svg"){let t=await xl(e);await Dn(t.outerHTML)}else if(e.type==="png")await ym(wm(e));else if(e.type==="json")await xm(e.elements,e.files);else throw new Error("Invalid export type")}});var z6,G6,UE,WE,ng,VE,ig,ag=j(()=>{"use strict";f();ce();Rt();at();z();z6=e=>e.type==="diamond"?[[e.width/2,0],[e.width,e.height/2],[e.width/2,e.height],[0,e.height/2]]:[[0,0],[0+e.width,0],[0+e.width,e.height],[0,e.height]],G6=e=>re(e)||Lt(e)?e.points:z6(e),UE=e=>{let t=e.reduce((r,[o,n])=>(r.minY=Math.min(r.minY,n),r.minX=Math.min(r.minX,o),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,n),r),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},WE=e=>{let t=G6(e),{cx:r,cy:o}=UE(t),n=[r,o],i=t.map(d=>Ze([d[0],d[1]],n,e.angle)),{minX:a,minY:l,maxX:s,maxY:c}=UE(i);return[a+e.x,l+e.y,s+e.x,c+e.y]},ng=(e,t,r=!1)=>{let o=WE(e),n=t[0]<=o[0]&&t[2]>=o[2]&&t[1]<=o[1]&&t[3]>=o[3];return r?n?!0:o[0]<=t[0]&&o[2]>=t[2]&&o[1]<=t[1]&&o[3]>=t[3]:n},VE=(e,t)=>{let r=WE(e);return(Ss(r[0],t[0],t[2])||Ss(t[0],r[0],r[2]))&&(Ss(r[1],t[1],t[3])||Ss(t[1],r[1],r[3]))},ig=({elements:e,bounds:t,type:r,errorMargin:o=0})=>{bs(t)&&(t=Dr(t,$(e)));let n=[t[0]-o,t[1]-o,t[2]+o,t[3]+o],i=new Set;for(let a of e){if(i.has(a.id))continue;if(r==="overlap"?VE(a,n):r==="inside"?ng(a,n):ng(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);U(a)&&a.containerId&&i.add(a.containerId),Te(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))}});function YE(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function XE(e,t){return e[0]*t[1]-t[0]*e[1]}function U6(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function vm(e,t){return[e[0]-t[0],e[1]-t[1]]}function KE(e,t){let r=vm(e[1],e[0]),o=vm(t,e[0]),n=XE(r,o);return Math.abs(n)<W6}function lg(e,t){let r=vm(e[1],e[0]),o=vm(t,e[0]);return XE(r,o)<0}function $E(e,t){return KE(e,t[0])||KE(e,t[1])||(lg(e,t[0])?!lg(e,t[1]):lg(e,t[1]))}function ZE(e,t){return U6(YE(e),YE(t))&&$E(e,t)&&$E(t,e)}var W6,jE=j(()=>{"use strict";f();W6=1e-6});var qE=j(()=>{"use strict";f();da();ag();jE()});function JE(e,t,r){let o=Ch(t,r),n=Ch(e,r);return o.some(a=>n.some(l=>ZE(a,l)))}var Tm,QE,ey,ty,Ko,sg,ry,Hr,Js,tg,El,oy,Ot,ny,ec,yl,cg,Sm,$o,Im,mm,sa,gm,gl,er=j(()=>{"use strict";f();ge();Rt();ut();z();We();Ve();Nr();at();qE();ce();Tm=(e,t,r)=>{let o=$(e);for(let n of t)if(n.frameId){let i=r.get(n.id),a=r.get(n.frameId);if(i){let l=o.get(i);l&&F(l,{frameId:a??n.frameId},!1)}}};QE=(e,t,r)=>Im(wl(e,t,r,!1)).filter(o=>!Q(o)&&!o.frameId||o.frameId===t.id),ey=(e,t,r,o)=>wl(e,t,o).some(n=>n.id===r.id),ty=(e,t,r)=>{let[o,n,i,a]=te(t,r),[l,s,c,d]=we(e);return o<=l&&n<=s&&i>=c&&a>=d},Ko=(e,t,r)=>ty([e],t,r)||JE(e,t,r)||ey([t],e,t,r),sg=(e,t,r)=>{let[o,n,i,a]=te(t,r);return Ed([o,n],[e.x,e.y],[i,a])},ry=e=>{let t=new Map;for(let r of e){let o=Q(r)?r.id:r.frameId;o&&!t.has(o)&&t.set(o,Hr(e,o))}return t},Hr=(e,t)=>{let r=[];for(let o of e.values())o.frameId===t&&r.push(o);return r},Js=e=>e.filter(t=>Q(t)),tg=e=>{let t=$(Js(e));return e.filter(r=>t.has(r.id)||!r.frameId||!t.has(r.frameId))},El=(e,t,r,o)=>{let n=Hr(e,t.id),i=new Set(n),a=new Set([...QE(e,t,o),...n.filter(p=>ey(e,p,t,o))]),l=n.filter(p=>!a.has(p)),s=new Set(Array.from(a).flatMap(p=>p.groupIds));for(let p of l)if(!JE(p,t,o))p.groupIds.length===0&&i.delete(p);else if(p.groupIds.length>0)for(let u of p.groupIds)s.add(u);for(let p of l)if(p.groupIds.length>0){let u=!0;for(let h of p.groupIds)s.has(h)&&(u=!1);u&&i.delete(p)}let c=Array.from(a).filter(p=>p.groupIds.length===0);for(let p of c)i.add(p);let d=Array.from(a).filter(p=>p.groupIds.length>0),m=Hd(d,r);for(let[p,u]of Object.entries(m))if(u){let h=Je(e,p);if(ty(h,t,o))for(let x of h)i.add(x)}return[...i].filter(p=>!(U(p)&&p.containerId))},oy=(e,t,r)=>Im(e,QE(e,t,r)),Ot=(e,t)=>e.frameId&&t.get(e.frameId)||null,ny=(e,t)=>{let r=new Set,o=$(e);e=Im(e);for(let a of e)Q(a)&&a.id!==t.id&&r.add(a.id);let n=new Set,i=[];for(let a of e)if(!(Q(a)||a.frameId&&r.has(a.frameId)))if(a.groupIds.length){let l=a.groupIds.at(-1);if(!n.has(l)){n.add(l);let s=Je(e,l);if(s.some(c=>Ko(c,t,o)))for(let c of s)i.push(c)}}else Ko(a,t,o)&&i.push(a);return i},ec=(e,t,r)=>{let o=$(e),n=new Map;for(let s of e.values())s.frameId===r.id&&n.set(s.id,!0);let i=new Set(t.map(s=>s.id)),a=[],l=new Set;for(let s of t)Q(s)&&s.id!==r.id&&l.add(s.id);for(let s of Im(e,t)){if(Q(s)||s.frameId&&l.has(s.frameId))continue;n.has(s.id)||a.push(s);let c=pe(s,o);c&&!i.has(c.id)&&!n.has(c.id)&&a.push(c)}for(let s of a)F(s,{frameId:r.id},!1);return e},yl=(e,t)=>{let r=new Map,o=new Map;for(let n of e)if(n.frameId){r.set(n.id,n);let i=o.get(n.frameId)||[];i.push(n);let a=pe(n,t);a&&(r.set(a.id,a),i.push(a)),o.set(n.frameId,i)}for(let[,n]of r)F(n,{frameId:null},!1)},cg=(e,t)=>{let r=Hr(e,t.id);return yl(r,$(e)),e},Sm=(e,t,r,o)=>ec(cg(e,r),t,r).slice(),$o=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),n=new Set(o);if(t.editingGroupId)for(let l of o)l.groupIds.length===0?n.add(l):l.groupIds.flatMap(s=>Je(e,s)).forEach(s=>n.add(s));let i=new Set,a=$(e);return n.forEach(l=>{l.frameId&&!Q(l)&&!sa(l,a,t)&&i.add(l)}),i.size>0&&yl(i,a),e},Im=(e,t)=>{let r=new Set,o=t||e;for(let a of o.values()){let l=a.groupIds[a.groupIds.length-1];l&&r.add(l)}let n=new Set;for(let a of r)Je(e,a).some(l=>Q(l))&&n.add(a);let i=[];for(let a of o.values())n.has(a.groupIds[a.groupIds.length-1])||i.push(a);return i},mm=(e,t,r)=>{let o=U(e)&&lt(e,t)||e;return r.selectedElementIds[o.id]&&r.selectedElementsAreBeingDragged?r.frameToHighlight:Ot(o,t)},sa=(e,t,r)=>{let o=mm(e,t,r),n=U(e)&&lt(e,t)||e;if(o){if(!r.selectedElementIds[e.id]||!r.selectedElementsAreBeingDragged)return!0;if(n.groupIds.length===0)return Ko(n,o,t);let i=new Set(n.groupIds.flatMap(a=>Je(t,a)));if(r.editingGroupId&&r.selectedElementsAreBeingDragged){let a=new Set(me(t,r));if(r.frameToHighlight!==null)return!0;a.forEach(s=>{i.delete(s)})}for(let a of i)if(Q(a))return!1;for(let a of i)if(Ko(a,o,t))return!0}return!1},gm=(e,t)=>e.name===null?jn(e)?`Frame ${t}`:`AI Frame $${t}`:e.name,gl=(e,t)=>ig({elements:e,bounds:t,type:"overlap"}).filter(r=>!r.frameId||r.frameId===t.id)});import sy from"roughjs/bin/rough";import{getStroke as V6}from"perfect-freehand";function Dx(e){let t=Zd(e),r=new Path2D(t);return hy.set(e,r),r}function Z6(e){return hy.get(e)}function Zd(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([o,n],i)=>[o,n,e.pressures[i]]):[[0,0,.5]],r={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:o=>Math.sin(o*Math.PI/2),last:!!e.lastCommittedPoint};return q6(V6(t,r))}function ly(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function q6(e){if(!e.length)return"";let t=e.length-1;return e.reduce((r,o,n,i)=>(n===t?r.push(o,ly(o,i[0]),"L",i[0],"Z"):r.push(o,ly(o,i[n+1])),r),["M",e[0],"Q"]).join(" ").replace(j6,"$1")}var Oh,Y6,cy,dy,Am,dg,K6,$6,IE,my,py,X6,Cm,km,iy,ay,uy,js,hy,j6,bn=j(()=>{"use strict";f();ce();at();z();Rt();Rr();G();ut();Qt();er();Go();Oh="invert(100%) hue-rotate(180deg) saturate(1.25)",Y6=ar(),cy=(e,t)=>nr(e)&&!t.imageCache.has(e.fileId),dy=(e,t,r)=>r.theme===oe.DARK&&nr(e)&&!cy(e,t)&&t.imageCache.get(e.fileId)?.mimeType!==J.svg,Am=e=>e.type==="freedraw"?e.strokeWidth*12:20,dg=(e,t,r)=>{let o=(t?.opacity??100)*e.opacity/1e4;return(r.has(e.id)||t&&r.has(t.id))&&(o*=ex/100),o},K6=(e,t,r)=>{let i=Am(e),[a,l,s,c]=te(e,t),d=re(e)||Lt(e)?Mt(a,s):e.width,m=re(e)||Lt(e)?Mt(l,c):e.height,p=d*window.devicePixelRatio+i*2,u=m*window.devicePixelRatio+i*2,h=r.value;return(p*h>32767||u*h>32767)&&(h=Math.min(32767/p,32767/u)),p*u*h*h>16777216&&(h=Math.sqrt(16777216/(p*u))),p=Math.floor(p*h),u=Math.floor(u*h),{width:p,height:u,scale:h}},$6=(e,t,r,o,n)=>{let i=document.createElement("canvas"),a=i.getContext("2d"),l=Am(e),{width:s,height:c,scale:d}=K6(e,t,r);i.width=s,i.height=c;let m=0,p=0;if(re(e)||Lt(e)){let[h,x]=te(e,t);m=e.x>h?Mt(e.x,h)*window.devicePixelRatio*d:0,p=e.y>x?Mt(e.y,x)*window.devicePixelRatio*d:0,a.translate(m,p)}a.save(),a.translate(l*d,l*d),a.scale(window.devicePixelRatio*d,window.devicePixelRatio*d);let u=sy.canvas(i);return dy(e,o,n)&&(a.filter=Oh),Cm(e,u,a,o,n),a.restore(),{element:e,canvas:i,theme:n.theme,scale:d,zoomValue:r.value,canvasOffsetX:m,canvasOffsetY:p,boundTextElementVersion:pe(e,t)?.version||null,containingFrameOpacity:Ot(e,t)?.opacity||100}},IE=14,my=document.createElement("img");my.src=`data:${J.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;py=document.createElement("img");py.src=`data:${J.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;X6=(e,t,r)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);let o=Math.min(e.width,e.height),n=Math.min(o,Math.min(o*.4,100));t.drawImage(e.status==="error"?py:my,e.width/2-n/2,e.height/2-n/2,n,n)},Cm=(e,t,r,o,n)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{r.lineJoin="round",r.lineCap="round",t.draw(ke.get(e));break}case"arrow":case"line":{r.lineJoin="round",r.lineCap="round",ke.get(e).forEach(i=>{t.draw(i)});break}case"freedraw":{r.save(),r.fillStyle=e.strokeColor;let i=Z6(e),a=ke.get(e);a&&t.draw(a),r.fillStyle=e.strokeColor,r.fill(i),r.restore();break}case"image":{let i=nr(e)?o.imageCache.get(e.fileId)?.image:void 0;i!=null&&!(i instanceof Promise)?(e.roundness&&r.roundRect&&(r.beginPath(),r.roundRect(0,0,e.width,e.height,vo(Math.min(e.width,e.height),e)),r.clip()),r.drawImage(i,0,0,e.width,e.height)):X6(e,r,n.zoom.value);break}default:if(U(e)){let i=cd(e.text),a=i&&!r.canvas.isConnected;a&&document.body.appendChild(r.canvas),r.canvas.setAttribute("dir",i?"rtl":"ltr"),r.save(),r.font=Ge(e),r.fillStyle=e.strokeColor,r.textAlign=e.textAlign;let l=e.text.replace(/\r\n?/g,`
52
+ `).map(i=>i.trim().split(","))),t.length===0)return{type:ca,reason:"No values"};let r=t[0].length;if(!t.every(i=>i.length===r))return{type:ca,reason:"All rows don't have same number of columns"};let n=OE(t);if(n.type!==bl){let i=OE(A6(t));if(i.type===bl)return i}return n},xm=Db(Mb),to={fillStyle:"hachure",fontFamily:Wt,fontSize:At,opacity:100,roughness:1,strokeColor:se.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:ft.MIDDLE,locked:!1},HE=e=>{let t=(Ao+je)*e.values.length+je,r=pi+je*2;return{chartWidth:t,chartHeight:r}},M6=(e,t,r,o,n)=>e.labels?.map((i,a)=>Nt({groupIds:[o],backgroundColor:n,...to,text:i.length>8?`${i.slice(0,5)}...`:i,x:t+a*(Ao+je)+je*2,y:r+je/2,width:Ao,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],L6=(e,t,r,o,n)=>{let i=Nt({groupIds:[o],backgroundColor:n,...to,x:t-je,y:r-je,text:"0",textAlign:"right"}),a=Nt({groupIds:[o],backgroundColor:n,...to,x:t-je,y:r-pi-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},P6=(e,t,r,o,n)=>{let{chartWidth:i,chartHeight:a}=HE(e),l=Qr({backgroundColor:n,groupIds:[o],...to,type:"line",x:t,y:r,startArrowhead:null,endArrowhead:null,width:i,points:[[0,0],[i,0]]}),s=Qr({backgroundColor:n,groupIds:[o],...to,type:"line",x:t,y:r,startArrowhead:null,endArrowhead:null,height:a,points:[[0,0],[0,-a]]}),c=Qr({backgroundColor:n,groupIds:[o],...to,type:"line",x:t,y:r-pi-je,startArrowhead:null,endArrowhead:null,strokeStyle:"dotted",width:i,opacity:BE,points:[[0,0],[i,0]]});return[l,s,c]},zE=(e,t,r,o,n,i)=>{let{chartWidth:a,chartHeight:l}=HE(e),s=e.title?Nt({backgroundColor:n,groupIds:[o],...to,text:e.title,x:t+a/2,y:r-pi-je*2-At,roundness:null,textAlign:"center"}):null,c=i?Fr({backgroundColor:n,groupIds:[o],...to,type:"rectangle",x:t,y:r-l,width:a,height:l,strokeColor:se.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...M6(e,t,r,o,n),...L6(e,t,r,o,n),...P6(e,t,r,o,n)]},_6=(e,t,r)=>{let o=Math.max(...e.values),n=Pt(),i=xm[Math.floor(Math.random()*xm.length)];return[...e.values.map((l,s)=>{let c=l/o*pi;return Fr({backgroundColor:i,groupIds:[n],...to,type:"rectangle",x:t+s*(Ao+je)+je,y:r-c-je,width:Ao,height:c})}),...zE(e,t,r,n,i,T.DEV)]},D6=(e,t,r)=>{let o=Math.max(...e.values),n=Pt(),i=xm[Math.floor(Math.random()*xm.length)],a=0,l=[];for(let x of e.values){let E=a*(Ao+je),v=-(x/o)*pi;l.push([E,v]),a++}let s=Math.max(...l.map(x=>x[0])),c=Math.max(...l.map(x=>x[1])),d=Math.min(...l.map(x=>x[0])),m=Math.min(...l.map(x=>x[1])),p=Qr({backgroundColor:i,groupIds:[n],...to,type:"line",x:t+je+Ao/2,y:r-je,startArrowhead:null,endArrowhead:null,height:c-m,width:s-d,strokeWidth:2,points:l}),u=e.values.map((x,E)=>{let v=E*(Ao+je)+je/2,w=-(x/o)*pi+je/2;return Fr({backgroundColor:i,groupIds:[n],...to,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:t+v+Ao/2,y:r+w-je*2,width:je,height:je})}),h=e.values.map((x,E)=>{let v=E*(Ao+je)+je/2,w=x/o*pi+je/2+je;return Qr({backgroundColor:i,groupIds:[n],...to,type:"line",x:t+v+Ao/2+je/2,y:r-w,startArrowhead:null,endArrowhead:null,height:w,strokeStyle:"dotted",opacity:BE,points:[[0,0],[0,w]]})});return[...zE(e,t,r,n,i,T.DEV),p,...h,...u]},GE=(e,t,r,o)=>e==="line"?D6(t,r,o):_6(t,r,o)});function WE(e){let t=[];for(let r of e.childNodes)if(r.nodeType===3){let o=r.textContent?.trim();o&&t.push({type:"text",value:o})}else if(r instanceof HTMLImageElement){let o=r.getAttribute("src");o&&o.startsWith("http")&&t.push({type:"imageUrl",value:o})}else t=t.concat(WE(r));return t}var YO,Em,xl,R6,UE,N6,ym,O6,B6,VE,F6,wm,vm,Dn,H6,ui=j(()=>{"use strict";f();ng();U();ce();In();We();er();z();YO="clipboard"in navigator&&"readText"in navigator.clipboard,Em="clipboard"in navigator&&"writeText"in navigator.clipboard,xl="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,R6=e=>!!([jt.excalidraw,jt.excalidrawClipboard,jt.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),UE=({types:e,files:t})=>{!e&&!t&&console.warn("createPasteEvent: no types or files provided");let r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[o,n]of Object.entries(e))try{if(r.clipboardData?.setData(o,n),r.clipboardData?.getData(o)!==n)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}if(t){let o=-1;for(let n of t){o++;try{if(r.clipboardData?.items.add(n),r.clipboardData?.files[o]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return r},N6=({elements:e,files:t})=>{let r=$(e),o=new Set(e.filter(l=>Q(l))),n=!1,i=e.reduce((l,s)=>(nr(s)&&(n=!0,t&&t[s.fileId]&&(l[s.fileId]=t[s.fileId])),l),{});n&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:jt.excalidrawClipboard,elements:e.map(l=>{if(Ot(l,r)&&!o.has(Ot(l,r))){let s=Sn(l);return F(s,{frameId:null}),s}return l}),files:t?i:void 0};return JSON.stringify(a)},ym=async(e,t,r)=>{await Dn(N6({elements:e,files:t}),r)},O6=e=>{let t=FE(e);return t.type===bl?{spreadsheet:t.spreadsheet}:null};B6=e=>{let t=e.clipboardData?.getData("text/html");if(!t)return null;try{let r=new DOMParser().parseFromString(t,"text/html"),o=WE(r.body);if(o.length)return{type:"mixedContent",value:o}}catch(r){console.error(`error in parseHTMLFromPaste: ${r.message}`)}return null},VE=async()=>{let e={};try{if(navigator.clipboard?.readText)return{"text/plain":await navigator.clipboard?.readText()}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else throw r}let t;try{t=await navigator.clipboard?.read()}catch(r){if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}for(let r of t)for(let o of r.types)if(gs(Gb,o))try{e[o]=await(await r.getType(o)).text()}catch(n){console.warn(`Cannot retrieve ${o} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},F6=async(e,t=!1)=>{try{let r=!t&&e&&B6(e);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData("text/plain")||r.value.map(n=>n.value).join(`
53
+ `).trim()}:r:{type:"text",value:(e.clipboardData?.getData("text/plain")||"").trim()}}catch{return{type:"text",value:""}}},wm=async(e,t=!1)=>{let r=await F6(e,t);if(r.type==="mixedContent")return{mixedContent:r.value};try{let o=!t&&O6(r.value);if(o)return o}catch(o){console.error(o)}try{let o=JSON.parse(r.value),n=o.type===jt.excalidrawClipboardWithAPI;if(R6(o))return{elements:o.elements,files:o.files,text:t?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:r.value}},vm=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[J.png]:e})])}catch(t){if(Oo(e))await navigator.clipboard.write([new window.ClipboardItem({[J.png]:await e})]);else throw t}},Dn=async(e,t)=>{if(Em)try{await navigator.clipboard.writeText(e||"");return}catch(r){console.error(r)}try{if(t){if(t.clipboardData?.setData("text/plain",e||""),t.clipboardData?.getData("text/plain")!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}if(!H6(e))throw new Error("Error copying to clipboard.")},H6=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",r=document.createElement("textarea");r.style.border="0",r.style.padding="0",r.style.margin="0",r.style.position="absolute",r.style[t?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;r.style.top=`${o}px`,r.style.fontSize="12pt",r.setAttribute("readonly",""),r.value=e,document.body.appendChild(r);let n=!1;try{r.select(),r.setSelectionRange(0,r.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return r.remove(),n}});var hi,Tm,El,z6,da=j(()=>{"use strict";f();qs();Rr();cl();U();dl();Pn();ui();hi=({elements:e,appState:t,files:r,maxWidthOrHeight:o,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=ci({elements:e,appState:t},null,null),{exportBackground:c,viewBackgroundColor:d}=s;return fm(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},r||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let x=Math.max(m,p),E=o<x?o/x:t?.exportScale??1;return u.width=m*E,u.height=p*E,{canvas:u,scale:E}}let h=n?.(m,p)||{width:m,height:p};return u.width=h.width,u.height=h.height,{canvas:u,scale:h.scale??1}})},Tm=async e=>{let{mimeType:t=J.png,quality:r}=e;t===J.png&&typeof r=="number"&&console.warn(`"quality" will be ignored for "${J.png}" mimeType`),t==="image/jpg"&&(t=J.jpg),t===J.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${J.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await hi(e);return r=r||(/image\/jpe?g/.test(t)?.92:.8),new Promise((n,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&t===J.png&&e.appState?.exportEmbedScene&&(a=await Gh({blob:a,metadata:mi(e.elements,e.appState,e.files||{},"local")})),n(a)},t,r)})},El=async({elements:e,appState:t=ar(),files:r={},exportPadding:o,renderEmbeddables:n,exportingFrame:i})=>{let{elements:a,appState:l}=ci({elements:e,appState:t},null,null),s={...l,exportPadding:o};return gl(a,s,r,{exportingFrame:i,renderEmbeddables:n})},z6=async e=>{if(e.type==="svg"){let t=await El(e);await Dn(t.outerHTML)}else if(e.type==="png")await vm(Tm(e));else if(e.type==="json")await ym(e.elements,e.files);else throw new Error("Invalid export type")}});var G6,U6,YE,KE,ig,$E,ag,lg=j(()=>{"use strict";f();ce();Rt();at();z();G6=e=>e.type==="diamond"?[[e.width/2,0],[e.width,e.height/2],[e.width/2,e.height],[0,e.height/2]]:[[0,0],[0+e.width,0],[0+e.width,e.height],[0,e.height]],U6=e=>re(e)||Lt(e)?e.points:G6(e),YE=e=>{let t=e.reduce((r,[o,n])=>(r.minY=Math.min(r.minY,n),r.minX=Math.min(r.minX,o),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,n),r),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},KE=e=>{let t=U6(e),{cx:r,cy:o}=YE(t),n=[r,o],i=t.map(d=>Ze([d[0],d[1]],n,e.angle)),{minX:a,minY:l,maxX:s,maxY:c}=YE(i);return[a+e.x,l+e.y,s+e.x,c+e.y]},ig=(e,t,r=!1)=>{let o=KE(e),n=t[0]<=o[0]&&t[2]>=o[2]&&t[1]<=o[1]&&t[3]>=o[3];return r?n?!0:o[0]<=t[0]&&o[2]>=t[2]&&o[1]<=t[1]&&o[3]>=t[3]:n},$E=(e,t)=>{let r=KE(e);return(Is(r[0],t[0],t[2])||Is(t[0],r[0],r[2]))&&(Is(r[1],t[1],t[3])||Is(t[1],r[1],r[3]))},ag=({elements:e,bounds:t,type:r,errorMargin:o=0})=>{xs(t)&&(t=Dr(t,$(e)));let n=[t[0]-o,t[1]-o,t[2]+o,t[3]+o],i=new Set;for(let a of e){if(i.has(a.id))continue;if(r==="overlap"?$E(a,n):r==="inside"?ig(a,n):ig(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);G(a)&&a.containerId&&i.add(a.containerId),Te(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))}});function XE(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function qE(e,t){return e[0]*t[1]-t[0]*e[1]}function W6(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function Sm(e,t){return[e[0]-t[0],e[1]-t[1]]}function ZE(e,t){let r=Sm(e[1],e[0]),o=Sm(t,e[0]),n=qE(r,o);return Math.abs(n)<V6}function sg(e,t){let r=Sm(e[1],e[0]),o=Sm(t,e[0]);return qE(r,o)<0}function jE(e,t){return ZE(e,t[0])||ZE(e,t[1])||(sg(e,t[0])?!sg(e,t[1]):sg(e,t[1]))}function JE(e,t){return W6(XE(e),XE(t))&&jE(e,t)&&jE(t,e)}var V6,QE=j(()=>{"use strict";f();V6=1e-6});var ey=j(()=>{"use strict";f();da();lg();QE()});function ty(e,t,r){let o=Ah(t,r),n=Ah(e,r);return o.some(a=>n.some(l=>JE(a,l)))}var Im,ry,oy,ny,Ko,cg,iy,Hr,Js,rg,yl,ay,Ot,ly,ec,wl,dg,Cm,$o,km,um,sa,bm,fl,er=j(()=>{"use strict";f();ge();Rt();lt();z();We();Ve();Nr();at();ey();ce();Im=(e,t,r)=>{let o=$(e);for(let n of t)if(n.frameId){let i=r.get(n.id),a=r.get(n.frameId);if(i){let l=o.get(i);l&&F(l,{frameId:a??n.frameId},!1)}}};ry=(e,t,r)=>km(vl(e,t,r,!1)).filter(o=>!Q(o)&&!o.frameId||o.frameId===t.id),oy=(e,t,r,o)=>vl(e,t,o).some(n=>n.id===r.id),ny=(e,t,r)=>{let[o,n,i,a]=te(t,r),[l,s,c,d]=we(e);return o<=l&&n<=s&&i>=c&&a>=d},Ko=(e,t,r)=>ny([e],t,r)||ty(e,t,r)||oy([t],e,t,r),cg=(e,t,r)=>{let[o,n,i,a]=te(t,r);return Ed([o,n],[e.x,e.y],[i,a])},iy=e=>{let t=new Map;for(let r of e){let o=Q(r)?r.id:r.frameId;o&&!t.has(o)&&t.set(o,Hr(e,o))}return t},Hr=(e,t)=>{let r=[];for(let o of e.values())o.frameId===t&&r.push(o);return r},Js=e=>e.filter(t=>Q(t)),rg=e=>{let t=$(Js(e));return e.filter(r=>t.has(r.id)||!r.frameId||!t.has(r.frameId))},yl=(e,t,r,o)=>{let n=Hr(e,t.id),i=new Set(n),a=new Set([...ry(e,t,o),...n.filter(p=>oy(e,p,t,o))]),l=n.filter(p=>!a.has(p)),s=new Set(Array.from(a).flatMap(p=>p.groupIds));for(let p of l)if(!ty(p,t,o))p.groupIds.length===0&&i.delete(p);else if(p.groupIds.length>0)for(let u of p.groupIds)s.add(u);for(let p of l)if(p.groupIds.length>0){let u=!0;for(let h of p.groupIds)s.has(h)&&(u=!1);u&&i.delete(p)}let c=Array.from(a).filter(p=>p.groupIds.length===0);for(let p of c)i.add(p);let d=Array.from(a).filter(p=>p.groupIds.length>0),m=Hd(d,r);for(let[p,u]of Object.entries(m))if(u){let h=Je(e,p);if(ny(h,t,o))for(let x of h)i.add(x)}return[...i].filter(p=>!(G(p)&&p.containerId))},ay=(e,t,r)=>km(e,ry(e,t,r)),Ot=(e,t)=>e.frameId&&t.get(e.frameId)||null,ly=(e,t)=>{let r=new Set,o=$(e);e=km(e);for(let a of e)Q(a)&&a.id!==t.id&&r.add(a.id);let n=new Set,i=[];for(let a of e)if(!(Q(a)||a.frameId&&r.has(a.frameId)))if(a.groupIds.length){let l=a.groupIds.at(-1);if(!n.has(l)){n.add(l);let s=Je(e,l);if(s.some(c=>Ko(c,t,o)))for(let c of s)i.push(c)}}else Ko(a,t,o)&&i.push(a);return i},ec=(e,t,r)=>{let o=$(e),n=new Map;for(let s of e.values())s.frameId===r.id&&n.set(s.id,!0);let i=new Set(t.map(s=>s.id)),a=[],l=new Set;for(let s of t)Q(s)&&s.id!==r.id&&l.add(s.id);for(let s of km(e,t)){if(Q(s)||s.frameId&&l.has(s.frameId))continue;n.has(s.id)||a.push(s);let c=de(s,o);c&&!i.has(c.id)&&!n.has(c.id)&&a.push(c)}for(let s of a)F(s,{frameId:r.id},!1);return e},wl=(e,t)=>{let r=new Map,o=new Map;for(let n of e)if(n.frameId){r.set(n.id,n);let i=o.get(n.frameId)||[];i.push(n);let a=de(n,t);a&&(r.set(a.id,a),i.push(a)),o.set(n.frameId,i)}for(let[,n]of r)F(n,{frameId:null},!1)},dg=(e,t)=>{let r=Hr(e,t.id);return wl(r,$(e)),e},Cm=(e,t,r,o)=>ec(dg(e,r),t,r).slice(),$o=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),n=new Set(o);if(t.editingGroupId)for(let l of o)l.groupIds.length===0?n.add(l):l.groupIds.flatMap(s=>Je(e,s)).forEach(s=>n.add(s));let i=new Set,a=$(e);return n.forEach(l=>{l.frameId&&!Q(l)&&!sa(l,a,t)&&i.add(l)}),i.size>0&&wl(i,a),e},km=(e,t)=>{let r=new Set,o=t||e;for(let a of o.values()){let l=a.groupIds[a.groupIds.length-1];l&&r.add(l)}let n=new Set;for(let a of r)Je(e,a).some(l=>Q(l))&&n.add(a);let i=[];for(let a of o.values())n.has(a.groupIds[a.groupIds.length-1])||i.push(a);return i},um=(e,t,r)=>{let o=G(e)&&st(e,t)||e;return r.selectedElementIds[o.id]&&r.selectedElementsAreBeingDragged?r.frameToHighlight:Ot(o,t)},sa=(e,t,r)=>{let o=um(e,t,r),n=G(e)&&st(e,t)||e;if(o){if(!r.selectedElementIds[e.id]||!r.selectedElementsAreBeingDragged)return!0;if(n.groupIds.length===0)return Ko(n,o,t);let i=new Set(n.groupIds.flatMap(a=>Je(t,a)));if(r.editingGroupId&&r.selectedElementsAreBeingDragged){let a=new Set(pe(t,r));if(r.frameToHighlight!==null)return!0;a.forEach(s=>{i.delete(s)})}for(let a of i)if(Q(a))return!1;for(let a of i)if(Ko(a,o,t))return!0}return!1},bm=(e,t)=>e.name===null?jn(e)?`Frame ${t}`:`AI Frame $${t}`:e.name,fl=(e,t)=>ag({elements:e,bounds:t,type:"overlap"}).filter(r=>!r.frameId||r.frameId===t.id)});import my from"roughjs/bin/rough";import{getStroke as Y6}from"perfect-freehand";function Rx(e){let t=qd(e),r=new Path2D(t);return by.set(e,r),r}function j6(e){return by.get(e)}function qd(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([o,n],i)=>[o,n,e.pressures[i]]):[[0,0,.5]],r={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:o=>Math.sin(o*Math.PI/2),last:!!e.lastCommittedPoint};return J6(Y6(t,r))}function dy(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function J6(e){if(!e.length)return"";let t=e.length-1;return e.reduce((r,o,n,i)=>(n===t?r.push(o,dy(o,i[0]),"L",i[0],"Z"):r.push(o,dy(o,i[n+1])),r),["M",e[0],"Q"]).join(" ").replace(q6,"$1")}var Bh,K6,py,uy,Lm,mg,$6,X6,AE,hy,gy,Z6,Am,Mm,sy,cy,fy,hl,by,q6,bn=j(()=>{"use strict";f();ce();at();z();Rt();Rr();U();lt();Qt();er();Go();Bh="invert(100%) hue-rotate(180deg) saturate(1.25)",K6=ar(),py=(e,t)=>nr(e)&&!t.imageCache.has(e.fileId),uy=(e,t,r)=>r.theme===oe.DARK&&nr(e)&&!py(e,t)&&t.imageCache.get(e.fileId)?.mimeType!==J.svg,Lm=e=>e.type==="freedraw"?e.strokeWidth*12:20,mg=(e,t,r)=>{let o=(t?.opacity??100)*e.opacity/1e4;return(r.has(e.id)||t&&r.has(t.id))&&(o*=tx/100),o},$6=(e,t,r)=>{let i=Lm(e),[a,l,s,c]=te(e,t),d=re(e)||Lt(e)?Mt(a,s):e.width,m=re(e)||Lt(e)?Mt(l,c):e.height,p=d*window.devicePixelRatio+i*2,u=m*window.devicePixelRatio+i*2,h=r.value;return(p*h>32767||u*h>32767)&&(h=Math.min(32767/p,32767/u)),p*u*h*h>16777216&&(h=Math.sqrt(16777216/(p*u))),p=Math.floor(p*h),u=Math.floor(u*h),{width:p,height:u,scale:h}},X6=(e,t,r,o,n)=>{let i=document.createElement("canvas"),a=i.getContext("2d"),l=Lm(e),{width:s,height:c,scale:d}=$6(e,t,r);i.width=s,i.height=c;let m=0,p=0;if(re(e)||Lt(e)){let[h,x]=te(e,t);m=e.x>h?Mt(e.x,h)*window.devicePixelRatio*d:0,p=e.y>x?Mt(e.y,x)*window.devicePixelRatio*d:0,a.translate(m,p)}a.save(),a.translate(l*d,l*d),a.scale(window.devicePixelRatio*d,window.devicePixelRatio*d);let u=my.canvas(i);return uy(e,o,n)&&(a.filter=Bh),Am(e,u,a,o,n),a.restore(),{element:e,canvas:i,theme:n.theme,scale:d,zoomValue:r.value,canvasOffsetX:m,canvasOffsetY:p,boundTextElementVersion:de(e,t)?.version||null,containingFrameOpacity:Ot(e,t)?.opacity||100}},AE=14,hy=document.createElement("img");hy.src=`data:${J.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;gy=document.createElement("img");gy.src=`data:${J.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;Z6=(e,t,r)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);let o=Math.min(e.width,e.height),n=Math.min(o,Math.min(o*.4,100));t.drawImage(e.status==="error"?gy:hy,e.width/2-n/2,e.height/2-n/2,n,n)},Am=(e,t,r,o,n)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{r.lineJoin="round",r.lineCap="round",t.draw(ke.get(e));break}case"arrow":case"line":{r.lineJoin="round",r.lineCap="round",ke.get(e).forEach(i=>{t.draw(i)});break}case"freedraw":{r.save(),r.fillStyle=e.strokeColor;let i=j6(e),a=ke.get(e);a&&t.draw(a),r.fillStyle=e.strokeColor,r.fill(i),r.restore();break}case"image":{let i=nr(e)?o.imageCache.get(e.fileId)?.image:void 0;i!=null&&!(i instanceof Promise)?(e.roundness&&r.roundRect&&(r.beginPath(),r.roundRect(0,0,e.width,e.height,vo(Math.min(e.width,e.height),e)),r.clip()),r.drawImage(i,0,0,e.width,e.height)):Z6(e,r,n.zoom.value);break}default:if(G(e)){let i=cd(e.text),a=i&&!r.canvas.isConnected;a&&document.body.appendChild(r.canvas),r.canvas.setAttribute("dir",i?"rtl":"ltr"),r.save(),r.font=Ge(e),r.fillStyle=e.strokeColor,r.textAlign=e.textAlign;let l=e.text.replace(/\r\n?/g,`
54
54
  `).split(`
55
- `),s=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,c=ii(e.fontSize,e.lineHeight),d=_d(e.fontFamily,e.fontSize,c);for(let m=0;m<l.length;m++)r.fillText(l[m],s,m*c+d);r.restore(),a&&r.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},km=new WeakMap,iy=(e,t,r,o)=>{let n=r?o.zoom:Y6.zoom,i=km.get(e),a=i&&i.zoomValue!==n.value&&!o?.shouldCacheIgnoreZoom,l=pe(e,t)?.version||null,s=Ot(e,t)?.opacity||100;if(!i||a||i.theme!==o.theme||i.boundTextElementVersion!==l||i.containingFrameOpacity!==s){let c=$6(e,t,n,r,o);return km.set(e,c),c}return i},ay=(e,t,r,o,n)=>{let i=e.element,a=Am(i),l=e.scale,[s,c,d,m]=te(i,n);Lt(i)&&(s=Math.floor(s),d=Math.ceil(d),c=Math.floor(c),m=Math.ceil(m));let p=((s+d)/2+o.scrollX)*window.devicePixelRatio,u=((c+m)/2+o.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let h=pe(i,n);if(Te(i)&&h){let x=document.createElement("canvas"),E=x.getContext("2d"),v=Math.max(Mt(s,d),Mt(c,m));x.width=v*window.devicePixelRatio*l+a*e.scale*10,x.height=v*window.devicePixelRatio*l+a*e.scale*10;let w=(x.width-e.canvas.width)/2,y=(x.height-e.canvas.height)/2;E.translate(x.width/2,x.height/2),E.rotate(i.angle),E.drawImage(e.canvas,-e.canvas.width/2,-e.canvas.height/2,e.canvas.width,e.canvas.height);let[,,,,I,P]=te(h,n);E.rotate(-i.angle);let C=x.width/2-(I-s)*window.devicePixelRatio*l-w-a*l,_=x.height/2-(P-c)*window.devicePixelRatio*l-y-a*l;E.translate(-C,-_),E.clearRect(-(h.width/2+ht)*window.devicePixelRatio*l,-(h.height/2+ht)*window.devicePixelRatio*l,(h.width+ht*2)*window.devicePixelRatio*l,(h.height+ht*2)*window.devicePixelRatio*l),t.translate(p,u),t.drawImage(x,-(d-s)/2*window.devicePixelRatio-w/l-a,-(m-c)/2*window.devicePixelRatio-y/l-a,x.width/l,x.height/l)}else if(t.translate(p,u),t.rotate(i.angle),"scale"in e.element&&!cy(i,r)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-p,-u),t.drawImage(e.canvas,(s+o.scrollX)*window.devicePixelRatio-a*e.scale/e.scale,(c+o.scrollY)*window.devicePixelRatio-a*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),T.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&gr(i)){let x=pe(i,n),E=Th(i);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((E.x+o.scrollX)*window.devicePixelRatio,(E.y+o.scrollY)*window.devicePixelRatio,fr(i,x)*window.devicePixelRatio,ta(i,x)*window.devicePixelRatio)}t.restore()},uy=(e,t,r)=>{t.save(),t.translate(e.x+r.scrollX,e.y+r.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let o=.5/r.zoom.value;t.fillRect(o,o,e.width,e.height),t.lineWidth=1/r.zoom.value,t.strokeStyle=" rgb(105, 101, 219)",t.strokeRect(o,o,e.width,e.height),t.restore()},js=(e,t,r,o,n,i,a)=>{switch(n.globalAlpha=dg(e,Ot(e,t),i.elementsPendingErasure),e.type){case"magicframe":case"frame":{a.frameRendering.enabled&&a.frameRendering.outline&&(n.save(),n.translate(e.x+a.scrollX,e.y+a.scrollY),n.fillStyle="rgba(0, 0, 200, 0.04)",n.lineWidth=$e.strokeWidth/a.zoom.value,n.strokeStyle=$e.strokeColor,Vi(e)&&(n.strokeStyle=a.theme===oe.LIGHT?"#7affd7":"#1d8264"),$e.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,e.width,e.height,$e.radius/a.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,e.width,e.height),n.restore());break}case"freedraw":{if(ke.generateElementShape(e,null),i.isExporting){let[l,s,c,d]=te(e,t),m=(l+c)/2+a.scrollX,p=(s+d)/2+a.scrollY,u=(c-l)/2-(e.x-l),h=(d-s)/2-(e.y-s);n.save(),n.translate(m,p),n.rotate(e.angle),n.translate(-u,-h),Cm(e,o,n,i,a),n.restore()}else{let l=iy(e,t,i,a);ay(l,n,i,a,r)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(ke.generateElementShape(e,i),i.isExporting){let[l,s,c,d]=te(e,t),m=(l+c)/2+a.scrollX,p=(s+d)/2+a.scrollY,u=(c-l)/2-(e.x-l),h=(d-s)/2-(e.y-s);if(U(e)){let E=lt(e,t);if(Te(E)){let v=K.getBoundTextElementPosition(E,e,t);u=(c-l)/2-(v.x-l),h=(d-s)/2-(v.y-s)}}n.save(),n.translate(m,p),dy(e,i,a)&&(n.filter="none");let x=pe(e,t);if(Te(e)&&x){let E=document.createElement("canvas"),v=E.getContext("2d"),w=Math.max(Mt(l,c),Mt(s,d)),y=Am(e);E.width=w*a.exportScale+y*10*a.exportScale,E.height=w*a.exportScale+y*10*a.exportScale,v.translate(E.width/2,E.height/2),v.scale(a.exportScale,a.exportScale),u=e.width/2-(e.x-l),h=e.height/2-(e.y-s),v.rotate(e.angle);let I=sy.canvas(E);v.translate(-u,-h),Cm(e,I,v,i,a),v.translate(u,h),v.rotate(-e.angle);let[,,,,P,C]=te(x,t),_=(l+c)/2-P,D=(s+d)/2-C;v.translate(-_,-D),v.clearRect(-x.width/2,-x.height/2,x.width,x.height),n.scale(1/a.exportScale,1/a.exportScale),n.drawImage(E,-E.width/2,-E.height/2,E.width,E.height)}else n.rotate(e.angle),e.type==="image"&&n.scale(e.scale[0],e.scale[1]),n.translate(-u,-h),Cm(e,o,n,i,a);n.restore()}else{let l=iy(e,t,i,a),s=n.imageSmoothingEnabled;!a?.shouldCacheIgnoreZoom&&(!e.angle||Ax(e.angle))&&(n.imageSmoothingEnabled=!1),ay(l,n,i,a,r),n.imageSmoothingEnabled=s}break}default:throw new Error(`Unimplemented type ${e.type}`)}n.globalAlpha=1},hy=new WeakMap([]);j6=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g});import{RoughGenerator as J6}from"roughjs/bin/generator";var ke,Go=j(()=>{"use strict";f();bn();qu();Zt();ke=class e{static rg=new J6;static cache=new WeakMap;static get=t=>e.cache.get(t);static set=(t,r)=>e.cache.set(t,r);static delete=t=>e.cache.delete(t);static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,r)=>{let o=r?.isExporting?void 0:e.get(t);if(o!==void 0)return o;km.delete(t);let n=_x(t,e.rg,r||{isExporting:!1,canvasBackgroundColor:se.white,embedsValidationStatus:null});return e.cache.set(t,n),n}}});var F,ne,li,We=j(()=>{"use strict";f();Jn();ys();Eo();z();Go();F=(e,t,r=!0)=>{let o=!1,{points:n,fileId:i}=t;typeof n<"u"&&(t={...bd(n),...t});for(let a in t){let l=t[a];if(typeof l<"u"){if(e[a]===l&&(typeof l!="object"||l===null||a==="groupIds"||a==="scale"))continue;if(a==="scale"){let s=e[a],c=l;if(s[0]===c[0]&&s[1]===c[1])continue}else if(a==="points"){let s=e[a],c=l;if(s.length===c.length){let d=!1,m=s.length;for(;--m;){let p=s[m],u=c[m];if(p[0]!==u[0]||p[1]!==u[1]){d=!0;break}}if(!d)continue}}e[a]=l,o=!0}}return o&&((typeof t.height<"u"||typeof t.width<"u"||typeof i<"u"||typeof n<"u")&&ke.delete(e),e.version++,e.versionNonce=qr(),e.updated=gn(),r&&pt.getScene(e)?.informMutation()),e},ne=(e,t)=>{let r=!1;for(let o in t){let n=t[o];if(typeof n<"u"){if(e[o]===n&&(typeof n!="object"||n===null))continue;r=!0}}return r?{...e,...t,updated:gn(),version:e.version+1,versionNonce:qr()}:e},li=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=qr(),e.updated=gn(),e)});var eo,ma,Mm,el,Vs,pa=j(()=>{"use strict";f();We();ce();G();at();z();eo=e=>re(e)||Lt(e)?e.points.length<2:e.width===0&&e.height===0,ma=(e,t,r,o,n)=>{let[i,a,l,s]=Dr(e,n),c=Ue({clientX:o.offsetLeft,clientY:o.offsetTop},o),d=Ue({clientX:o.offsetLeft+t,clientY:o.offsetTop+r},o);return c.x<=l&&c.y<=s&&d.x>=i&&d.y>=a},Mm=(e,t,r)=>{let o=Math.abs(t),n=Math.abs(r);if(e==="line"||e==="arrow"||e==="freedraw"){let i=Math.round(Math.atan(n/o)/No)*No;i===0?r=0:i===Math.PI/2?t=0:r=o*Math.tan(i)*Math.sign(r)||r}else e!=="selection"&&(r=o*Math.sign(r));return{width:t,height:r}},el=(e,t,r,o)=>{let n=r-e,i=o-t,a=Math.round(Math.atan(i/n)/No)*No;if(a===0)i=0;else if(a===Math.PI/2)n=0;else{let l=Math.tan(a),s=-1,c=t-l*e,d=-1/l,m=-1,p=o-d*r,u=(s*p-m*c)/(l*m-d*s),h=(c*d-p*l)/(l*m-d*s);n=u-e,i=h-t}return{width:n,height:i}},Vs=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let r=Math.abs(e.width);t.width=r,t.x=e.x-r}if(e.height<0){let r=Math.abs(e.height);t.height=r,t.y=e.y-r}return t}});var gy,Q6,tc,by,eC,fy,mg,Rn,vl,rc,Lm,oc=j(()=>{"use strict";f();at();Rt();ge();ce();G();gy={mouse:8,pen:16,touch:28},Q6=16,tc={e:!0,s:!0,n:!0,w:!0},by={e:!0,s:!0,n:!0,w:!0,rotation:!0},eC={e:!0,s:!0,n:!0,w:!0},fy={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},mg={e:!0,s:!0,n:!0,w:!0},Rn=(e,t,r,o,n,i,a)=>{let[l,s]=Ee(e+r/2,t+o/2,n,i,a);return[l-r/2,s-o/2,r,o]},vl=([e,t,r,o,n,i],a,l,s,c={},d=4)=>{let m=gy[s],p=m/l.value,u=m/l.value,h=m/l.value,x=m/l.value,E=r-e,v=o-t,w=d/l.value,y=(m-zi*2)/(2*l.value),I={nw:c.nw?void 0:Rn(e-w-h+y,t-w-x+y,p,u,n,i,a),ne:c.ne?void 0:Rn(r+w-y,t-w-x+y,p,u,n,i,a),sw:c.sw?void 0:Rn(e-w-h+y,o+w-y,p,u,n,i,a),se:c.se?void 0:Rn(r+w-y,o+w-y,p,u,n,i,a),rotation:c.rotation?void 0:Rn(e+E/2-p/2,t-w-x+y-Q6/l.value,p,u,n,i,a)},P=5*gy.mouse/l.value;return Math.abs(E)>P&&(c.n||(I.n=Rn(e+E/2-p/2,t-w-x+y,p,u,n,i,a)),c.s||(I.s=Rn(e+E/2-p/2,o+w-y,p,u,n,i,a))),Math.abs(v)>P&&(c.w||(I.w=Rn(e-w-h+y,t+v/2-u/2,p,u,n,i,a)),c.e||(I.e=Rn(r+w-y,t+v/2-u/2,p,u,n,i,a))),I},rc=(e,t,r,o="mouse")=>{if(e.locked)return{};let n={};if(e.type==="freedraw"||re(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=mg:a[0]>0&&a[1]<0?n=fy:a[0]>0&&a[1]>0?n=mg:a[0]<0&&a[1]>0?n=fy:a[0]<0&&a[1]<0&&(n=mg)}}else U(e)?n=eC:Q(e)&&(n={rotation:!0});let i=re(e)?zi+8:zi;return vl(te(e,r,!0),e.angle,t,o,n,i)},Lm=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let r=e[0];return re(r)?r.points.length>2:!0}});var ug,xy,Pm,_m,pg,tC,Dm,Ey=j(()=>{"use strict";f();oc();ug=(e,t,r)=>t>=e[0]&&t<=e[0]+e[2]&&r>=e[1]&&r<=e[1]+e[3],xy=(e,t,r,o,n,i,a)=>{if(!r.selectedElementIds[e.id])return!1;let{rotation:l,...s}=rc(e,i,t,a);if(l&&ug(l,o,n))return"rotation";let c=Object.keys(s).filter(d=>{let m=s[d];return m?ug(m,o,n):!1});return c.length>0?c[0]:!1},Pm=(e,t,r,o,n,i,a)=>e.reduce((l,s)=>{if(l)return l;let c=xy(s,a,t,r,o,n,i);return c?{element:s,transformHandleType:c}:null},null),_m=([e,t,r,o],n,i,a,l)=>{let s=vl([e,t,r,o,(e+r)/2,(t+o)/2],0,a,l,tc);return Object.keys(s).find(d=>{let m=s[d];return m&&ug(m,n,i)})||!1},pg=["ns","nesw","ew","nwse"],tC=(e,t)=>{let r=pg.indexOf(e);if(r>=0){let o=Math.round(t/(Math.PI/4));e=pg[(r+o)%pg.length]}return e},Dm=e=>{let{element:t,transformHandleType:r}=e,o=t&&Math.sign(t.height)*Math.sign(t.width)===-1,n=null;switch(r){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":o?n="nesw":n="nwse";break;case"ne":case"sw":o?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&t&&(n=tC(n,t.angle)),n?`${n}-resize`:""}});var Rm,hg,rC,oC,gg,nC,iC,aC,fg,lC,bg,xg,Eg=j(()=>{"use strict";f();G();ys();Rt();at();ce();We();z();Jr();Jn();ut();Qt();Rm=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e,hg=(e,t,r,o,n,i,a,l,s,c,d)=>{if(r.length===1){let[m]=r;return t==="rotation"?(rC(m,o,l,s,n),So(m,o)):U(m)&&(t==="nw"||t==="ne"||t==="sw"||t==="se")?(iC(m,o,t,i,l,s),So(m,o)):t&&aC(e,a,m,o,t,i,l,s),!0}else if(r.length>1){if(t==="rotation")return lC(e,r,o,l,s,n,c,d),!0;if(t==="nw"||t==="ne"||t==="sw"||t==="se")return fg(e,r,o,t,i,l,s),!0}return!1},rC=(e,t,r,o,n)=>{let[i,a,l,s]=te(e,t),c=(i+l)/2,d=(a+s)/2,m;Q(e)?m=0:(m=5*Math.PI/2+Math.atan2(o-d,r-c),n&&(m+=No/2,m-=m%No),m=Rm(m));let p=wn(e);if(F(e,{angle:m}),p){let u=pt.getScene(e)?.getElement(p);u&&!Te(e)&&F(u,{angle:m})}},oC=(e,t,r,o)=>re(e)||Lt(e)?{points:ei(0,t,ei(1,r,e.points,o),o)}:{},gg=(e,t,r)=>{let o=e.width;if(Ne(e)){let a=lt(e,t);a&&(o=fr(a,e))}let i=e.fontSize*(r/o);return i<Jc?null:{size:i}},nC=(e,t)=>({n:/^(n|ne|nw)$/.test(e)||t&&/^(s|se|sw)$/.test(e),s:/^(s|se|sw)$/.test(e)||t&&/^(n|ne|nw)$/.test(e),w:/^(w|nw|sw)$/.test(e)||t&&/^(e|ne|se)$/.test(e),e:/^(e|ne|se)$/.test(e)||t&&/^(w|nw|sw)$/.test(e)}),iC=(e,t,r,o,n,i)=>{let[a,l,s,c]=te(e,t),d=(a+s)/2,m=(l+c)/2,[p,u]=Ee(n,i,d,m,-e.angle),h;switch(r){case"se":h=Math.max((p-a)/(s-a),(u-l)/(c-l));break;case"nw":h=Math.max((s-p)/(s-a),(c-u)/(c-l));break;case"ne":h=Math.max((p-a)/(s-a),(c-u)/(c-l));break;case"sw":h=Math.max((s-p)/(s-a),(u-l)/(c-l));break}if(h>0){let x=e.width*h,E=e.height*h,v=gg(e,t,x);if(v===null)return;let[w,y,I,P]=ra(e,x,E,!1),C=(a-w)/2,_=(l-y)/2,D=(s-I)/2,H=(c-P)/2,[A,M]=xd(nC(r,o),e.x,e.y,e.angle,C,_,D,H);F(e,{fontSize:v.size,width:x,height:E,x:A,y:M})}},aC=(e,t,r,o,n,i,a,l)=>{let s=e.get(r.id),[c,d,m,p]=ra(s,s.width,s.height,!0),u=[c,d],h=[m,p],x=ws(u,h),E=Ze([a,l],x,-s.angle),[v,w,y,I]=ra(r,r.width,r.height,!0),P=y-v,C=I-w,_=h[0]-u[0],D=h[1]-u[1],H=_/P,A=D/C,M={},k=pe(r,o);n.includes("e")&&(H=(E[0]-u[0])/P),n.includes("s")&&(A=(E[1]-u[1])/C),n.includes("w")&&(H=(h[0]-E[0])/P),n.includes("n")&&(A=(h[1]-E[1])/C);let O=s.width,X=s.height,Y=r.width*H,ee=r.height*A;if(i&&(Y=2*Y-O,ee=2*ee-X),t){let hr=Math.abs(Y)/O,La=Math.abs(ee)/X;if(n.length===1&&(ee*=hr,Y*=La),n.length===2){let Oi=Math.max(hr,La);Y=O*Oi*Math.sign(Y),ee=X*Oi*Math.sign(ee)}}if(k){let hr=e.get(k.id);if(hr&&(M={fontSize:hr.fontSize}),t){let La={...r,width:Y,height:ee},Oi=gg(k,o,fr(La,k));if(Oi===null)return;M={fontSize:Oi.size}}else{let La=Rd(Ge(k),k.lineHeight),Oi=Dd(k.fontSize,k.lineHeight);Y=Math.max(Y,La),ee=Math.max(ee,Oi)}}let[xe,le,V,ve]=ra(s,Y,ee,!0),Re=V-xe,dt=ve-le,Le=[...u];if(["n","w","nw"].includes(n)&&(Le=[h[0]-Math.abs(Re),h[1]-Math.abs(dt)]),n==="ne"){let hr=[u[0],h[1]];Le=[hr[0],hr[1]-Math.abs(dt)]}if(n==="sw"){let hr=[h[0],u[1]];Le=[hr[0]-Math.abs(Re),hr[1]]}t&&(["s","n"].includes(n)&&(Le[0]=x[0]-Re/2),["e","w"].includes(n)&&(Le[1]=x[1]-dt/2));let ur=Y<0,ln=ee<0;ur&&(n.includes("e")&&(Le[0]-=Math.abs(Re)),n.includes("w")&&(Le[0]+=Math.abs(Re))),ln&&(n.includes("s")&&(Le[1]-=Math.abs(dt)),n.includes("n")&&(Le[1]+=Math.abs(dt))),i&&(Le[0]=x[0]-Math.abs(Re)/2,Le[1]=x[1]-Math.abs(dt)/2);let Gt=s.angle,Do=Ze(Le,x,Gt),sn=[Le[0]+Math.abs(Re)/2,Le[1]+Math.abs(dt)/2],Ni=Ze(sn,x,Gt);Le=Ze(Do,Ni,-Gt);let Kr=[...Le],cn=s.x-xe,kt=s.y-le;Kr[0]+=cn,Kr[1]+=kt;let cS=Kr[0],dS=Kr[1],yb,wb;(re(r)||Lt(r))&&(yb=ei(1,ee,s.points,!0),wb=ei(0,Y,yb,!0));let Wn={width:Math.abs(Y),height:Math.abs(ee),x:cS,y:dS,points:wb};if("scale"in r&&"scale"in s&&F(r,{scale:[(Math.sign(V-s.x)||s.scale[0])*s.scale[0],(Math.sign(ve-s.y)||s.scale[1])*s.scale[1]]}),Te(r)&&k&&t){let hr=Wn.width/r.width*k.fontSize;if(hr<Jc)return;M.fontSize=hr}Wn.width!==0&&Wn.height!==0&&Number.isFinite(Wn.x)&&Number.isFinite(Wn.y)&&(F(r,Wn),So(r,o,{newSize:{width:Wn.width,height:Wn.height}}),k&&M!=null&&F(k,{fontSize:M.fontSize}),Ji(r,o,n,t))},fg=(e,t,r,o,n,i,a)=>{let l=t.reduce((M,k)=>{let O=e.get(k.id);return O&&M.push({orig:O,latest:k}),M},[]),s=l.reduce((M,{orig:k})=>{if(!re(k))return M;let O=wn(k);if(!O)return M;let X=e.get(O)??null;if(!Ne(X))return M;let Y=K.getBoundTextElementPosition(k,X,r);return[...M,{...X,...Y}]},[]),{minX:c,minY:d,maxX:m,maxY:p,midX:u,midY:h}=br(l.map(({orig:M})=>M).concat(s)),x=o,E={ne:[c,p],se:[c,d],sw:[m,d],nw:[m,p]},[v,w]=n?[u,h]:E[x],y=Math.max(Math.abs(i-v)/(m-c)||0,Math.abs(a-w)/(p-d)||0)*(n?2:1);if(y===0)return;let I={ne:[i>=v,a<=w],se:[i>=v,a>=w],sw:[i<=v,a>=w],nw:[i<=v,a<=w]},[P,C]=I[x].map(M=>M?1:-1),_=P<0,D=C<0,H=[];for(let{orig:M,latest:k}of l){if(U(M)&&Ne(M))continue;let O=M.width*y,X=M.height*y,Y=Rm(M.angle*P*C),ee=re(M)||Lt(M),xe=M.x-v,le=M.y-w,V=_&&!ee?O:0,ve=D&&!ee?X:0,Re=v+P*(xe*y+V),dt=w+C*(le*y+ve),Le=oC(M,O*P,X*C,!1),ur={x:Re,y:dt,width:O,height:X,angle:Y,...Le};if(Zr(M)&&l.length===1&&(ur.scale=[M.scale[0]*P,M.scale[1]*C]),re(M)&&(_||D)){let Gt=Qa(M,M.points),Do=Qa({...M,x:Re,y:dt},Le.points),sn=[M.x,M.y],Ni=[Re,dt],Kr=cn=>{let kt=cn==="x"?0:1;return(Do[kt+2]-Ni[kt]-(sn[kt]-Gt[kt])*y+(Gt[kt+2]-sn[kt])*y-(Ni[kt]-Do[kt]))/2};_&&(ur.x-=Kr("x")),D&&(ur.y-=Kr("y"))}if(U(M)){let Gt=gg(M,r,O);if(!Gt)return;ur.fontSize=Gt.size}let ln=e.get(wn(M)??"");if(ln){let Gt=ln.fontSize*y;if(Gt<Jc)return;ur.boundTextFontSize=Gt}H.push({element:k,update:ur})}let A=H.map(({element:M})=>M);for(let{element:M,update:{boundTextFontSize:k,...O}}of H){let{width:X,height:Y,angle:ee}=O;F(M,O,!1),So(M,r,{simultaneouslyUpdated:A,newSize:{width:X,height:Y}});let xe=pe(M,r);xe&&k&&(F(xe,{fontSize:k,angle:re(M)?void 0:ee},!1),Ji(M,r,o,!0))}pt.getScene(H[0].element)?.informMutation()},lC=(e,t,r,o,n,i,a,l)=>{let s=5*Math.PI/2+Math.atan2(n-l,o-a);i&&(s+=No/2,s-=s%No),t.filter(c=>!Q(c)).forEach(c=>{let[d,m,p,u]=te(c,r),h=(d+p)/2,x=(m+u)/2,E=e.get(c.id)?.angle??c.angle,[v,w]=Ee(h,x,a,l,s+E-c.angle);F(c,{x:c.x+(v-h),y:c.y+(w-x),angle:Rm(s+E)},!1),So(c,r,{simultaneouslyUpdated:t});let y=pe(c,r);y&&!Te(c)&&F(y,{x:y.x+(v-h),y:y.y+(w-x),angle:Rm(s+E)},!1)}),pt.getScene(t[0])?.informMutation()},bg=(e,t,r,o,n)=>{let[i,a,l,s]=t.length===1?te(t[0],r):we(t),c=(i+l)/2,d=(a+s)/2,m=t.length===1?t[0].angle:0;switch([o,n]=Ee(o,n,c,d,-m),e){case"n":return Ee(o-(i+l)/2,n-a,0,0,m);case"s":return Ee(o-(i+l)/2,n-s,0,0,m);case"w":return Ee(o-i,n-(a+s)/2,0,0,m);case"e":return Ee(o-l,n-(a+s)/2,0,0,m);case"nw":return Ee(o-i,n-a,0,0,m);case"ne":return Ee(o-l,n-a,0,0,m);case"sw":return Ee(o-i,n-s,0,0,m);case"se":return Ee(o-l,n-s,0,0,m);default:return[0,0]}},xg=(e,t)=>{let[,[r,o]]=t.points;return e==="nw"&&(r<0||o<0)||e==="ne"&&r>=0||e==="sw"&&r<=0||e==="se"&&(r>0||o>0)?"end":"origin"}});var yg,sC,yy,wg,Nm,wy=j(()=>{"use strict";f();Jr();at();We();pa();ut();Rt();ce();yg=(e,t,r,o,n,i,a)=>{let l=new Set(t),s=t.filter(m=>Q(m)).map(m=>m.id);if(s.length>0)for(let m of n.getNonDeletedElements())m.frameId!==null&&s.includes(m.frameId)&&l.add(m);let c=we(Array.from(l).map(m=>e.originalElements.get(m.id)??m)),d=sC(c,r,i,a);l.forEach(m=>{if(yy(e,m,d),!Te(m)){let p=pe(m,n.getNonDeletedElementsMap());p&&yy(e,p,d)}So(m,n.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(l)})})},sC=(e,t,r,o)=>{let[n,i]=e,a=n+t.x+r.x,l=i+t.y+r.y;if(r.x===0||r.y===0){let[s,c]=St(n+t.x,i+t.y,o);r.x===0&&(a=s),r.y===0&&(l=c)}return{x:a-n,y:l-i}},yy=(e,t,r)=>{let o=e.originalElements.get(t.id)??t,n=o.x+r.x,i=o.y+r.y;F(t,{x:n,y:i})},wg=(e,t,r)=>{let[o,n]=we(e);return[t-o,r-n]},Nm=(e,t,r,o,n,i,a,l,s,c,d,m=null)=>{s&&e.type!=="selection"&&(d?l=a/d:(Math.abs(i-o)>Math.abs(n-r)?{width:a,height:l}=Mm(t,l,n<r?-a:a):{width:a,height:l}=Mm(t,a,i<o?-l:l),l<0&&(l=-l)));let p=n<r?r-a:r,u=i<o?o-l:o;c&&(a+=a,l+=l,p=r-a/2,u=o-l/2),a!==0&&l!==0&&F(e,{x:p+(m?.x??0),y:u+(m?.y??0),width:a,height:l})}});var ua,vy=j(()=>{"use strict";f();Ve();ua=(e,t)=>!!(!e.viewModeEnabled&&(e.activeTool.type!=="custom"&&(e.editingElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||me(t,e).length))});var cC,vg,Tg,Ty,be,Es,Sy,fE,Qd,ge=j(()=>{"use strict";f();pa();ce();In();at();oc();Ey();Eg();wy();ce();ut();pa();vy();cC=e=>e.reduce((t,r)=>t+r.version,0),vg=e=>{let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e[r].versionNonce;return t>>>0},Tg=e=>{let t=5381;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)+t+o}return t>>>0},Ty=e=>e.filter(t=>!t.isDeleted&&!eo(t)),be=e=>e.filter(t=>!t.isDeleted),Es=e=>!e.isDeleted,Sy=e=>be(e).map(t=>fs(t.type)?{...t,lastCommittedPoint:null}:t),fE=e=>Sy(e),Qd=e=>Sy(e)});var ha,wl,Sg,ze,Ig,me,ga,Pe,Qn=j(()=>{"use strict";f();ge();ce();er();z();pa();ha=e=>{let t=new Set;return e.forEach(r=>{Q(r)&&t.add(r.id)}),e.filter(r=>!(r.frameId&&t.has(r.frameId)))},wl=(e,t,r,o=!0)=>{let[n,i,a,l]=te(t,r),s=e.filter(c=>{let[d,m,p,u]=Dr(c,r),h=Ot(c,r);if(h){let[x,E,v,w]=Dr(h,r);d=Math.max(x,d),m=Math.max(E,m),p=Math.min(v,p),u=Math.min(w,u)}return c.locked===!1&&c.type!=="selection"&&!Ne(c)&&n<=d&&i<=m&&a>=p&&l>=u});return s=o?ha(s):s,s=s.filter(c=>{let d=Ot(c,r);return d?Ko(c,d,r):!0}),s},Sg=(e,t,r,o)=>{let n=new Set(t.map(i=>i.id));return e.filter(i=>{let a=ma(i,r.width,r.height,r,o);return!n.has(i.id)&&a})},ze=function(){let e=null,t=null,r=null,o=(n,i)=>(r!=null&&n===e&&i.selectedElementIds===t||(r=n.some(a=>i.selectedElementIds[a.id]),e=n,t=i.selectedElementIds),r);return o.clearCache=()=>{e=null,t=null,r=null},o}(),Ig=(e,t,r)=>{let o=Array.from(new Set(me(e,t).map(n=>r(n))));return o.length===1?o[0]:null},me=(e,t,r)=>{let o=[];for(let n of e.values()){if(t.selectedElementIds[n.id]){o.push(n);continue}if(r?.includeBoundTextElement&&Ne(n)&&t.selectedElementIds[n?.containerId]){o.push(n);continue}}if(r?.includeElementsInFrames){let n=[];return o.forEach(i=>{Q(i)&&Hr(e,i.id).forEach(a=>n.push(a)),n.push(i)}),n}return o},ga=(e,t)=>t.editingElement?[t.editingElement]:me(e,t,{includeBoundTextElement:!0}),Pe=(e,t)=>wt(t.selectedElementIds,e)?t.selectedElementIds:e});var dC,Cg,Yo,kg=j(()=>{"use strict";f();ge();z();dC=(e,t)=>{let[r,o,n,i]=t,{x:a,y:l}=Dt({sceneX:r,sceneY:o},e),{x:s,y:c}=Dt({sceneX:n,sceneY:i},e);return s-a>e.width||c-l>e.height},Cg=({scenePoint:e,viewportDimensions:t,zoom:r})=>({scrollX:t.width/2/r.value-e.x,scrollY:t.height/2/r.value-e.y}),Yo=(e,t)=>{if(e=Ty(e),!e.length)return{scrollX:0,scrollY:0};let[r,o,n,i]=we(e);dC(t,[r,o,n,i])&&([r,o,n,i]=Ah(e,Ue({clientX:t.scrollX,clientY:t.scrollY},t)));let a=(r+n)/2,l=(o+i)/2;return Cg({scenePoint:{x:a,y:l},viewportDimensions:{width:t.width,height:t.height},zoom:t.zoom})}});var Xo,Nn,Om=j(()=>{"use strict";f();G();Xo=e=>Math.max(ed,Math.min(e,30)),Nn=({viewportX:e,viewportY:t,nextZoom:r},o)=>{let n=e-o.offsetLeft,i=t-o.offsetTop,a=o.zoom.value,l=o.scrollX+(n-n/a),s=o.scrollY+(i-i/a),c=-(n-n/r),d=-(i-i/r);return{scrollX:l+c,scrollY:s+d,zoom:{value:r}}}});var Ve=j(()=>{"use strict";f();Qn();kg();Cs();Om()});f();import QP,{useEffect as e7}from"react";f();import{useEffect as MS,useState as LS}from"react";f();f();import Sb from"./en-CVBEBUBY.json";import gS from"./percentages-UCQDHIQF.json";f();import{unstable_createStore as uS,useAtom as c7}from"jotai";import{useLayoutEffect as m7}from"react";var Be=Symbol(),Xt=uS();import{atom as fS,useAtomValue as bS}from"jotai";var hS=vb({"./locales/ar-SA.json":()=>import("./ar-SA-JA6F2FMJ.json"),"./locales/az-AZ.json":()=>import("./az-AZ-GVIENQVH.json"),"./locales/bg-BG.json":()=>import("./bg-BG-YFNNHCEP.json"),"./locales/bn-BD.json":()=>import("./bn-BD-LMEIWSRD.json"),"./locales/ca-ES.json":()=>import("./ca-ES-C2WGCLOT.json"),"./locales/cs-CZ.json":()=>import("./cs-CZ-F2NDIQMB.json"),"./locales/da-DK.json":()=>import("./da-DK-WBEQB3CJ.json"),"./locales/de-DE.json":()=>import("./de-DE-VEIMCP7R.json"),"./locales/el-GR.json":()=>import("./el-GR-TKRKG5GQ.json"),"./locales/en.json":()=>import("./en-CVBEBUBY.json"),"./locales/es-ES.json":()=>import("./es-ES-TOLWEZNW.json"),"./locales/eu-ES.json":()=>import("./eu-ES-7CDRJQWJ.json"),"./locales/fa-IR.json":()=>import("./fa-IR-527E2XGU.json"),"./locales/fi-FI.json":()=>import("./fi-FI-NLQ7RQGZ.json"),"./locales/fr-FR.json":()=>import("./fr-FR-KUHO4FLU.json"),"./locales/gl-ES.json":()=>import("./gl-ES-NEXX3VBB.json"),"./locales/he-IL.json":()=>import("./he-IL-MED2VGBZ.json"),"./locales/hi-IN.json":()=>import("./hi-IN-5V633W7V.json"),"./locales/hu-HU.json":()=>import("./hu-HU-2FOZGVGR.json"),"./locales/id-ID.json":()=>import("./id-ID-I6BOLXTF.json"),"./locales/it-IT.json":()=>import("./it-IT-WKPQOK4P.json"),"./locales/ja-JP.json":()=>import("./ja-JP-VKA4ISRU.json"),"./locales/kaa.json":()=>import("./kaa-IKPRSBNY.json"),"./locales/kab-KAB.json":()=>import("./kab-KAB-IE4PHQTZ.json"),"./locales/kk-KZ.json":()=>import("./kk-KZ-MNJT6XSV.json"),"./locales/km-KH.json":()=>import("./km-KH-LADGDFXV.json"),"./locales/ko-KR.json":()=>import("./ko-KR-XD7AVF2F.json"),"./locales/ku-TR.json":()=>import("./ku-TR-4XBHKDQA.json"),"./locales/lt-LT.json":()=>import("./lt-LT-QC35R4YH.json"),"./locales/lv-LV.json":()=>import("./lv-LV-GSD5D3BA.json"),"./locales/mr-IN.json":()=>import("./mr-IN-KOLSWM7Y.json"),"./locales/my-MM.json":()=>import("./my-MM-M53KMUET.json"),"./locales/nb-NO.json":()=>import("./nb-NO-XXC6U37A.json"),"./locales/nl-NL.json":()=>import("./nl-NL-HCCJQEUO.json"),"./locales/nn-NO.json":()=>import("./nn-NO-6P7Z2PI2.json"),"./locales/oc-FR.json":()=>import("./oc-FR-JRJKPLNT.json"),"./locales/pa-IN.json":()=>import("./pa-IN-LZWLEPIB.json"),"./locales/percentages.json":()=>import("./percentages-UCQDHIQF.json"),"./locales/pl-PL.json":()=>import("./pl-PL-3WBLCXI2.json"),"./locales/pt-BR.json":()=>import("./pt-BR-O3ZPTUNW.json"),"./locales/pt-PT.json":()=>import("./pt-PT-7AQTSAFO.json"),"./locales/ro-RO.json":()=>import("./ro-RO-HJ65JYWV.json"),"./locales/ru-RU.json":()=>import("./ru-RU-P7ROIYNC.json"),"./locales/si-LK.json":()=>import("./si-LK-7ZSWVION.json"),"./locales/sk-SK.json":()=>import("./sk-SK-NXVBGLYY.json"),"./locales/sl-SI.json":()=>import("./sl-SI-VFTWOYNP.json"),"./locales/sv-SE.json":()=>import("./sv-SE-YONBLQNW.json"),"./locales/ta-IN.json":()=>import("./ta-IN-BSETPMLX.json"),"./locales/th-TH.json":()=>import("./th-TH-URTRDITB.json"),"./locales/tr-TR.json":()=>import("./tr-TR-N5SCAVTB.json"),"./locales/uk-UA.json":()=>import("./uk-UA-LBCYVSQZ.json"),"./locales/vi-VN.json":()=>import("./vi-VN-POZWLIUU.json"),"./locales/zh-CN.json":()=>import("./zh-CN-FUF5V3SC.json"),"./locales/zh-HK.json":()=>import("./zh-HK-OB4VW42C.json"),"./locales/zh-TW.json":()=>import("./zh-TW-5JPVKOM7.json")});var xS=85,Ro={code:"en",label:"English"},_a=[Ro,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>gS[e.code]>=xS).sort((e,t)=>e.label>t.label?1:-1)],Yc="__test__";T.DEV&&_a.unshift({code:Yc,label:"test language"},{code:`${Yc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Pa=Ro,Vc={},Kc=async e=>{if(Pa=e,document.documentElement.dir=Pa.rtl?"rtl":"ltr",document.documentElement.lang=Pa.code,e.code.startsWith(Yc))Vc={};else try{Vc=await hS(`./locales/${Pa.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),Vc=Sb}Xt.set(Ib,e.code)},dn=()=>Pa,Tb=(e,t)=>{for(let r=0;r<t.length;++r){let o=t[r];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},b=(e,t,r)=>{if(Pa.code.startsWith(Yc))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),n=Tb(Vc,o)||Tb(Sb,o)||r;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)n=n.replace(`{{${i}}}`,String(t[i]));return n},Ib=fS(Ro.code),yt=()=>{let e=bS(Ib,Be);return{t:b,langCode:e}};import{useState as IS,useEffect as CS}from"react";f();import ES from"react";import{jsx as Lu}from"react/jsx-runtime";var yS=({size:e="1em",circleWidth:t=8,synchronized:r=!1})=>{let n=-(ES.useRef(Date.now()).current%1600);return Lu("div",{className:"Spinner",children:Lu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":r?`${n}ms`:0},children:Lu("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},Ut=yS;G();import kS from"clsx";import{jsx as Fu,jsxs as AS}from"react/jsx-runtime";var ld=({delay:e,theme:t})=>{let[r,o]=IS(!!e);return CS(()=>{if(!e)return;let n=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(n)},[e]),r?null:AS("div",{className:kS("LoadingMessage",{"LoadingMessage--dark":t===oe.DARK}),children:[Fu("div",{children:Fu(Ut,{})}),Fu("div",{className:"LoadingMessage-text",children:b("labels.loadingScene")})]})};import{jsx as PS}from"react/jsx-runtime";var rx=e=>{let[t,r]=LS(!0);return MS(()=>{let o=async()=>{await Kc(n),r(!1)},n=_a.find(i=>i.code===e.langCode)||Ro;o()},[e.langCode]),t?PS(ld,{theme:e.theme}):e.children};f();import an,{useContext as Di}from"react";import{flushSync as Q1}from"react-dom";import OP from"roughjs/bin/rough";import V5 from"clsx";import{nanoid as BP}from"nanoid";f();f();Ve();ue();f();import Ag,{useEffect as mC,useRef as Iy,useState as pC}from"react";import Cy from"clsx";qn();z();import{jsx as nc,jsxs as ic}from"react/jsx-runtime";var ae=Ag.forwardRef((e,t)=>{let{id:r}=Bt(),o=Ag.useRef(null);Ag.useImperativeHandle(t,()=>o.current);let n=`ToolIcon_size_${e.size}`,[i,a]=pC(!1),l=Iy(!0),s=async d=>{let m="onClick"in e&&e.onClick?.(d);if(Oo(m))try{a(!0),await m}catch(p){if(p instanceof zo)console.warn(p);else throw p}finally{l.current&&a(!1)}};mC(()=>(l.current=!0,()=>{l.current=!1}),[]);let c=Iy(null);if(e.type==="button"||e.type==="icon"||e.type==="submit"){let d=e.type==="icon"?"button":e.type;return ic("button",{className:Cy("ToolIcon_type_button",n,e.className,e.visible&&!e.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!e.hidden,"ToolIcon--selected":e.selected,"ToolIcon--plain":e.type==="icon"}),style:e.style,"data-testid":e["data-testid"],hidden:e.hidden,title:e.title,"aria-label":e["aria-label"],type:d,onClick:s,ref:o,disabled:i||e.isLoading,children:[(e.icon||e.label)&&ic("div",{className:"ToolIcon__icon","aria-hidden":"true",children:[e.icon||e.label,e.keyBindingLabel&&nc("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel}),e.isLoading&&nc(Ut,{})]}),e.showAriaLabel&&ic("div",{className:"ToolIcon__label",children:[e["aria-label"]," ",i&&nc(Ut,{})]}),e.children]})}return ic("label",{className:Cy("ToolIcon",e.className),title:e.title,onPointerDown:d=>{c.current=d.pointerType||null,e.onPointerDown?.({pointerType:d.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{c.current=null})},children:[nc("input",{className:`ToolIcon_type_radio ${n}`,type:"radio",name:e.name,"aria-label":e["aria-label"],"aria-keyshortcuts":e["aria-keyshortcuts"],"data-testid":e["data-testid"],id:`${r}-${e.id}`,onChange:()=>{e.onChange?.({pointerType:c.current})},checked:e.checked,ref:o}),ic("div",{className:"ToolIcon__icon",children:[e.icon,e.keyBindingLabel&&nc("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel})]})]})});ae.defaultProps={visible:!0,className:"",size:"medium"};ae.displayName="ToolButton";Ye();ge();We();Nr();Qt();Jr();ce();z();f();G();import yr from"react";import uC from"open-color";import hC from"clsx";import{Fragment as Ae,jsx as g,jsxs as N}from"react/jsx-runtime";var Mo=e=>"var(--icon-fill-color)",ky=e=>e===oe.LIGHT?uC.white:"#1e1e1e",L=(e,t=512)=>{let{width:r=512,height:o=r,mirror:n,style:i,...a}=typeof t=="number"?{width:t}:t;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${r} ${o}`,className:hC({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},q={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},de={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},KH=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:3,y:8,width:18,height:4,rx:1}),g("line",{x1:12,y1:8,x2:12,y2:21}),g("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),g("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),q),Bm=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),g("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),g("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),q),Ay=L(N("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),q),My=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"12",cy:"19",r:"1"}),g("circle",{cx:"12",cy:"5",r:"1"})]}),q),Ly=L(N("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),g("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),g("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),q),fa=L(N("g",{children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:g("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),g("g",{mask:"url(#UnlockedIcon)",children:g("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),de),Tl=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),g("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),de),Py=L(N(Ae,{children:[g("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),g("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),_y=L(N(Ae,{children:[g("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),g("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),Dy=L(N(Ae,{children:[g("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),g("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),$H=L(g("g",{fill:"currentColor",children:g("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),Ry=L(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),g("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Ny=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),q),Oy=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),q),By=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),q),Fy=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),q),Hy=L(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),de),zy=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),g("path",{d:"M16 7h4"}),g("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),q),Sl=L(N("g",{strokeWidth:"1.25",children:[g("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),g("path",{d:"m11.25 5.417 3.333 3.333"})]}),de),Gy=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),g("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),g("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),g("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),g("polyline",{points:"5 20 11 4 13 4 20 20"})]}),q),Uy=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M12.5 6.667h.01"}),g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),g("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),g("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),de),Wy=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),g("path",{d:"M18 13.3l-6.3 -6.3"})]}),q),Mg=L(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),de),Lg=L(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),de),Vy=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 21l-6 -6"}),g("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),g("path",{d:"M3 4v4h4"})]}),q),Lo=L(g("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),de),Yy=L(N("g",{strokeWidth:"1.25",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),de),ac=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),de),lc=L(g("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),de),sc=L(g("g",{stroke:"currentColor",strokeLinejoin:"round",children:g("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...de,strokeWidth:1.5}),Fm=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),g("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),q),ba=L(g("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),de),Il=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),q),Ky=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),q),Pg=L(g("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),de),Hm=L(g("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),de),$y=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),g("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),de),Xy=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),g("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),q),Zy=L(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),cc=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),g("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),de),jy=L("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),qy=L("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Cl=L(g("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),de),XH=L("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),Jy=L("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),zm=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),g("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),g("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),q),Gm=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8h.01"}),g("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),g("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),g("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),g("path",{d:"M19 16v6"}),g("path",{d:"M22 19l-3 3l-3 -3"})]}),q),Qy=L("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),ZH=L("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),jH=L("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),e2=L("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),qH=L("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),_g=L(g("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),de),Dg=L(g("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),de),t2=L("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),r2=L(g("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),de),JH=L("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),QH=L("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),ez=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),g("path",{d:"M12 14v-11"}),g("path",{d:"M9 6l3 -3l3 3"})]}),q),tz=L(N(Ae,{children:[g("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),g("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),rz=L(g("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),Rg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{d:"M13.889 4.167H8.333c-.767 0-1.389.622-1.389 1.389v5.555c0 .767.622 1.389 1.39 1.389h5.555c.767 0 1.389-.622 1.389-1.389V5.556c0-.767-.622-1.39-1.39-1.39Z",fill:"currentColor"}),g("path",{d:"M12.5 12.5v1.389a1.389 1.389 0 0 1-1.389 1.389H5.556a1.389 1.389 0 0 1-1.39-1.39V8.334a1.389 1.389 0 0 1 1.39-1.389h1.388"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),Ng=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.944 12.5H12.5v1.389a1.389 1.389 0 0 1-1.389 1.389H5.556a1.389 1.389 0 0 1-1.39-1.39V8.334a1.389 1.389 0 0 1 1.39-1.389h1.388",fill:"currentColor"}),g("path",{d:"M13.889 4.167H8.333c-.767 0-1.389.621-1.389 1.389v5.555c0 .767.622 1.389 1.39 1.389h5.555c.767 0 1.389-.622 1.389-1.389V5.556c0-.768-.622-1.39-1.39-1.39Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),Og=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M8.775 6.458h2.45a2.316 2.316 0 0 1 2.317 2.316v2.452a2.316 2.316 0 0 1-2.316 2.316H8.774a2.316 2.316 0 0 1-2.317-2.316V8.774a2.316 2.316 0 0 1 2.317-2.316Z",fill:"currentColor"}),g("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316ZM12.108 3.125h2.45a2.316 2.316 0 0 1 2.317 2.316v2.451a2.316 2.316 0 0 1-2.316 2.316h-2.451a2.316 2.316 0 0 1-2.316-2.316v-2.45a2.316 2.316 0 0 1 2.316-2.317Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),Bg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",children:[g("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316Z",stroke:"currentColor",strokeWidth:"1.25"}),g("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"SendToBackIcon",fill:"#fff",children:g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.167 5.833v2.06a2.941 2.941 0 0 0 2.94 2.94h2.06v.393a2.941 2.941 0 0 1-2.941 2.94h-.393v-2.058a2.941 2.941 0 0 0-2.94-2.941h-2.06v-.393a2.941 2.941 0 0 1 2.942-2.94h.392Z"})}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.167 5.833v2.06a2.941 2.941 0 0 0 2.94 2.94h2.06v.393a2.941 2.941 0 0 1-2.941 2.94h-.393v-2.058a2.941 2.941 0 0 0-2.94-2.941h-2.06v-.393a2.941 2.941 0 0 1 2.942-2.94h.392Z",fill:"currentColor"}),g("path",{d:"M9.167 5.833h1.25v-1.25h-1.25v1.25Zm5 5h1.25v-1.25h-1.25v1.25Zm-3.334 3.334h-1.25v1.25h1.25v-1.25Zm-5-5h-1.25v1.25h1.25v-1.25Zm2.084-3.334v2.06h2.5v-2.06h-2.5Zm0 2.06a4.191 4.191 0 0 0 4.19 4.19v-2.5a1.691 1.691 0 0 1-1.69-1.69h-2.5Zm4.19 4.19h2.06v-2.5h-2.06v2.5Zm.81-1.25v.393h2.5v-.393h-2.5Zm0 .393c0 .933-.758 1.69-1.691 1.69v2.5a4.191 4.191 0 0 0 4.19-4.19h-2.5Zm-1.691 1.69h-.393v2.5h.393v-2.5Zm.857 1.25v-2.058h-2.5v2.059h2.5Zm0-2.058a4.191 4.191 0 0 0-4.19-4.191v2.5c.933 0 1.69.757 1.69 1.69h2.5Zm-4.19-4.191h-2.06v2.5h2.06v-2.5Zm-.81 1.25v-.393h-2.5v.393h2.5Zm0-.393c0-.934.758-1.69 1.692-1.69v-2.5a4.191 4.191 0 0 0-4.192 4.19h2.5Zm1.692-1.69h.392v-2.5h-.392v2.5Z",fill:"currentColor",mask:"url(#SendToBackIcon)"}),g("path",{d:"M12.108 3.125h2.45a2.316 2.316 0 0 1 2.317 2.316v2.451a2.316 2.316 0 0 1-2.316 2.316h-2.451a2.316 2.316 0 0 1-2.316-2.316v-2.45a2.316 2.316 0 0 1 2.316-2.317Z",stroke:"currentColor",strokeWidth:"1.25"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),Fg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),Hg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),zg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),Gg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),o2=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),n2=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),Ug=L(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),g("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),de),Wg=L(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),g("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),de),Um=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"9",cy:"7",r:"4"}),g("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),g("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),g("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),q),oz=L("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),nz=L("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),ro=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M15 5 5 15M5 5l10 10"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),iz=L("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),az=L("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),lz=L("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Vg=yr.memo(({theme:e})=>L(N(Ae,{children:[g("path",{d:"M25 26H111V111H25",fill:Mo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Mo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Mo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Mo(e),strokeWidth:"2"}),N("g",{fill:ky(e),stroke:Mo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Yg=yr.memo(({theme:e})=>L(N(Ae,{children:[g("path",{d:"M25 26H111V111H25",fill:Mo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Mo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Mo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Mo(e),strokeWidth:"2"}),N("g",{fill:ky(e),stroke:Mo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),g("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),i2=L(g("g",{strokeWidth:1.25,children:g("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),de),a2=L(N(Ae,{children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),g("g",{mask:"url(#FillHachureIcon)",children:g("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),de),l2=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:g("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("g",{mask:"url(#FillCrossHatchIcon)",children:g("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),s2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...de,fill:"currentColor"}),Kg=L(g(Ae,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),de),c2=L(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),de),d2=L(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),de),sz=yr.memo(({theme:e})=>L(g("path",{d:"M6 10H34",stroke:Mo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),m2=L(N("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12h2"}),g("path",{d:"M17 12h2"}),g("path",{d:"M11 12h2"})]}),q),p2=L(N("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M8 12v.01"}),g("path",{d:"M12 12v.01"}),g("path",{d:"M16 12v.01"}),g("path",{d:"M20 12v.01"})]}),q),u2=L(g("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),de),h2=L(g("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),de),g2=L(g("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),de),f2=L(N("svg",{strokeWidth:"1.5",children:[g("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),g("path",{d:"M13.3333 3.33331V3.34331"}),g("path",{d:"M16.6667 3.33331V3.34331"}),g("path",{d:"M16.6667 6.66669V6.67669"}),g("path",{d:"M16.6667 10V10.01"}),g("path",{d:"M3.33334 13.3333V13.3433"}),g("path",{d:"M16.6667 13.3333V13.3433"}),g("path",{d:"M3.33334 16.6667V16.6767"}),g("path",{d:"M6.66666 16.6667V16.6767"}),g("path",{d:"M10 16.6667V16.6767"}),g("path",{d:"M13.3333 16.6667V16.6767"}),g("path",{d:"M16.6667 16.6667V16.6767"})]}),de),b2=L(N("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),g("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),g("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),g("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),g("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),g("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),g("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),g("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),g("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),g("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),g("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),g("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),q),x2=L(g("path",{d:"M6 10H34",stroke:"currentColor",strokeWidth:2,fill:"none"}),{width:40,height:20}),E2=yr.memo(({flip:e=!1})=>L(N("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[g("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),g("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),$g=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),y2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[g("path",{d:"M26 10L6 10"}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),w2=yr.memo(({flip:e=!1})=>L(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:g("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),v2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),T2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[g("path",{d:"M6,9.5H27"}),g("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),S2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),I2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),C2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),k2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),A2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),M2=L(g(Ae,{children:g("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),de),Xg=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),q),L2=L(g(Ae,{children:g("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),de),P2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),_2=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),g("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),q),D2=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),g("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),q),R2=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),q),N2=yr.memo(({theme:e})=>L(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),g("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),q)),O2=yr.memo(({theme:e})=>L(N("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),g("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),q)),B2=yr.memo(({theme:e})=>L(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),g("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),g("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),q)),F2=L(g("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),cz=L(g("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Wm=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),g("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),q),Zg=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M7 11l5 5l5 -5"}),g("path",{d:"M12 4l0 12"})]}),q),Vm=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),g("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),q),H2=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M9.15 14.85l8.85 -10.85"}),g("path",{d:"M6 4l8.85 10.85"})]}),q),z2=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),g("path",{d:"M12 17l0 .01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),q),dz=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),q),mz=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),q),pz=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),q),G2=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"})]}),q),U2=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l6 6"}),g("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),q),W2=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l-4 7h8z"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),q),Ym=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 7l16 0"}),g("path",{d:"M4 17l16 0"}),g("path",{d:"M7 4l0 16"}),g("path",{d:"M17 4l0 16"})]}),q),Km=L(g("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),kl=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M4.16602 10H15.8327"}),g("path",{d:"M12.5 13.3333L15.8333 10"}),g("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),de),$m=L(N("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),g("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),Al=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),q),uz=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),q),dc=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),g("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),g("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),g("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),g("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),g("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),q),V2=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),g("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),g("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),g("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),q),Ml=L(N("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),g("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),q),Y2=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),g("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),g("path",{d:"M3 3l18 18"})]}),q),K2=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),q),$2=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),q),Xm=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),g("path",{d:"M21 21l-6 -6"})]}),q),X2=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),g("path",{d:"M12 7v5l3 3"}),g("path",{d:"M19 16l-2 3h4l-2 3"})]}),q),Z2=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),g("path",{d:"M5 10a7 7 0 0 0 14 0"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),q),j2=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 3l18 18"}),g("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),g("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),q),Zm=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),q),q2=L(N("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),g("path",{d:"M12 20v.01"}),g("path",{d:"M16 20v.01"}),g("path",{d:"M8 20v.01"}),g("path",{d:"M4 20v.01"}),g("path",{d:"M4 16v.01"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M4 8v.01"}),g("path",{d:"M4 4v.01"}),g("path",{d:"M8 4v.01"}),g("path",{d:"M12 4v.01"}),g("path",{d:"M16 4v.01"}),g("path",{d:"M20 4v.01"}),g("path",{d:"M20 8v.01"}),g("path",{d:"M20 12v.01"}),g("path",{d:"M20 16v.01"}),g("path",{d:"M20 20v.01"})]}),q),J2=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3v18"}),g("path",{d:"M19 21v-18"}),g("path",{d:"M5 7h14"}),g("path",{d:"M5 15h14"}),g("path",{d:"M8 13v4"}),g("path",{d:"M11 13v4"}),g("path",{d:"M16 13v4"}),g("path",{d:"M14 5v4"}),g("path",{d:"M11 5v4"}),g("path",{d:"M8 5v4"}),g("path",{d:"M3 21h18"})]}),q),Q2=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 12l18 0"}),g("path",{d:"M7 16l10 0l-10 5l0 -5"}),g("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),q),ew=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l0 18"}),g("path",{d:"M16 7l0 10l5 0l-5 -10"}),g("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),q),jg=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),g("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),g("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),q),jm=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),g("path",{d:"M22 22l-3 -3"}),g("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),g("path",{d:"M3 11v-1"}),g("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),g("path",{d:"M10 3h1"}),g("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),q),tw=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),g("path",{d:"M10 15l2 6l2 -6"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),q),rw=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),g("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),g("path",{d:"M11 21v-6l3 6v-6"})]}),q),ow=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),g("path",{d:"M4 8l5 0"}),g("path",{d:"M15 8l4 0"})]}),q),nw=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),g("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),g("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),q),iw=L(N("g",{stroke:"currentColor",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...q,strokeWidth:1.5}),hz=L(N("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12l10 0"}),g("path",{d:"M10 12l4 4"}),g("path",{d:"M10 12l4 -4"}),g("path",{d:"M4 4l0 16"})]}),q),aw=L(N("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),g("path",{d:"M10 9l5 3l-5 3z"})]}),q);import{jsx as fC}from"react/jsx-runtime";var gC=(e,t)=>{let r=new Set(me(e.filter(o=>Q(o)),t).map(o=>o.id));return{elements:e.map(o=>t.selectedElementIds[o.id]?ne(o,{isDeleted:!0}):o.frameId&&r.has(o.frameId)?ne(o,{isDeleted:!0}):Ne(o)&&t.selectedElementIds[o.containerId]?ne(o,{isDeleted:!0}):o),appState:{...t,selectedElementIds:{},selectedGroupIds:{}}}},lw=(e,t)=>{if(e.editingGroupId){let r=Je(be(t),e.editingGroupId);if(r.length)return{...e,selectedElementIds:{[r[0].id]:!0}}}return e},mc=B({name:"deleteSelectedElements",label:"labels.delete",icon:Lo,trackEvent:{category:"element",action:"delete"},perform:(e,t,r,o)=>{if(t.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=t.editingLinearElement,d=o.scene.getNonDeletedElementsMap(),m=K.getElement(a,d);if(!m||l==null)return!1;if(m.points.length<2){let u=e.map(x=>x.id===m.id?ne(x,{isDeleted:!0}):x),h=lw(t,u);return{elements:u,appState:{...h,editingLinearElement:null},commitToHistory:!1}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(m.points.length-1)?null:c};return K.deletePoints(m,l),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},commitToHistory:!0}}let{elements:n,appState:i}=gC(e,t);return Ja(n,e.filter(({id:a})=>t.selectedElementIds[a])),i=lw(i,n),{elements:n,appState:{...i,activeTool:Xe(t,{type:"selection"}),multiElement:null,activeEmbeddable:null},commitToHistory:ze(be(e),t)}},keyTest:(e,t,r)=>(e.key===S.BACKSPACE||e.key===S.DELETE)&&!e[S.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:r})=>fC(ae,{type:"button",icon:Lo,title:b("labels.delete"),"aria-label":b("labels.delete"),onClick:()=>r(null),visible:ze(be(e),t)})});f();f();ce();wo();Nr();Ve();Jn();z();var qg=(e,t)=>e.frameId===t||e.id===t,cw=(e,t,r)=>{let o=[],n=[],i=null,a=-1,l=$(r||me(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let s=e[a];l.get(s.id)?(n.length&&(o=o.concat(n),n=[]),o.push(a),i=a+1):s.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return o},bC=e=>{let t=0;return e.reduce((r,o,n)=>(n>0&&e[n-1]!==o-1&&(t=++t),(r[t]||(r[t]=[])).push(o),r),[])},sw=(e,t,r)=>{if("containerId"in e&&e.containerId)if(r==="left"){let o=pt.getScene(e).getElement(e.containerId);if(o)return t.indexOf(o)}else return t.indexOf(e);else{let o=e.boundElements?.find(n=>n.type!=="arrow")?.id;if(o){if(r==="left")return t.indexOf(e);let n=pt.getScene(e).getElement(o);if(n)return t.indexOf(n)}}},xC=(e,t)=>{let r=-1,o=-1;return e.forEach((n,i)=>{qg(n,t)&&(r===-1&&(r=i),o=i)}),r===-1?[]:e.slice(r,o+1)},EC=(e,t,r,o,n)=>{let i=t[r],a=m=>m.isDeleted?!1:n?m.frameId===n:e.editingGroupId?m.groupIds.includes(e.editingGroupId):!0,l=o==="left"?Uu(t,m=>a(m),Math.max(0,r-1)):Gu(t,m=>a(m),r+1),s=t[l];if(!s)return-1;if(e.editingGroupId){if(i?.groupIds.join("")===s?.groupIds.join(""))return sw(s,t,o)??l;if(!s?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(s.frameId||Q(s))){let m=xC(t,s.frameId||s.id);return o==="left"?t.indexOf(m[0]):t.indexOf(m[m.length-1])}if(!s.groupIds.length)return sw(s,t,o)??l;let c=e.editingGroupId?s.groupIds[s.groupIds.indexOf(e.editingGroupId)-1]:s.groupIds[s.groupIds.length-1],d=Je(t,c);return d.length?o==="left"?t.indexOf(d[0]):t.indexOf(d[d.length-1]):l},dw=(e,t)=>t.reduce((r,o)=>{let n=e[o];return r.set(n.id,n),r},new Map),mw=(e,t,r)=>{let o=cw(e,t),n=dw(e,o),i=bC(o);r==="right"&&(i=i.reverse());let a=new Set(o.filter(l=>Q(e[l])).map(l=>e[l].id));return i.forEach((l,s)=>{let c=l[0],d=l[l.length-1],m=r==="left"?c:d,p=l.some(w=>{let y=e[w];return y.frameId&&a.has(y.frameId)})?null:e[m]?.frameId,u=EC(t,e,m,r,p);if(u===-1||m===u)return;let h=r==="left"?e.slice(0,u):e.slice(0,c),x=e.slice(c,d+1),E=r==="left"?e.slice(u,c):e.slice(d+1,u+1),v=r==="left"?e.slice(d+1):e.slice(u+1);e=r==="left"?[...h,...x,...E,...v]:[...h,...E,...x,...v]}),qt(e,n),e},pw=(e,t,r,o,n)=>{let i=cw(e,t,n),a=dw(e,i),l=[],s,c;if(r==="left"){if(o)s=Gu(e,h=>qg(h,o));else if(t.editingGroupId){let h=Je(e,t.editingGroupId);if(!h.length)return e;s=e.indexOf(h[0])}else s=0;c=i[i.length-1]}else{if(o)c=Uu(e,h=>qg(h,o));else if(t.editingGroupId){let h=Je(e,t.editingGroupId);if(!h.length)return e;c=e.indexOf(h[h.length-1])}else c=e.length-1;s=i[0]}s===-1&&(s=0);for(let h=s;h<c+1;h++)i.includes(h)||l.push(e[h]);let d=Array.from(a.values()),m=e.slice(0,s),p=e.slice(c+1),u=r==="left"?[...m,...d,...l,...p]:[...m,...l,...d,...p];return qt(u,a),u};function uw(e,t,r,o){let n=$(me(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&Q(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(Q(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let d=i.frameChildren.get(c.frameId)||[];d.push(c),i.frameChildren.set(c.frameId,d)}let l=e,s=Array.from(i.frameChildren.entries());for(let[c,d]of s)l=o(e,t,r,c,d);return o(l,t,r,null,i.regularElements)}var hw=(e,t)=>mw(e,t,"left"),gw=(e,t)=>mw(e,t,"right"),fw=(e,t)=>uw(e,t,"left",pw),bw=(e,t)=>uw(e,t,"right",pw);ue();z();Ye();G();import{jsx as qm}from"react/jsx-runtime";var Jg=B({name:"sendBackward",label:"labels.sendBackward",icon:Ng,trackEvent:{category:"element"},perform:(e,t)=>({elements:hw(e,t),appState:t,commitToHistory:!0}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===he.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>qm("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.sendBackward")} \u2014 ${R("CtrlOrCmd+[")}`,children:Ng})}),Qg=B({name:"bringForward",label:"labels.bringForward",icon:Rg,trackEvent:{category:"element"},perform:(e,t)=>({elements:gw(e,t),appState:t,commitToHistory:!0}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===he.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>qm("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.bringForward")} \u2014 ${R("CtrlOrCmd+]")}`,children:Rg})}),ef=B({name:"sendToBack",label:"labels.sendToBack",icon:Bg,trackEvent:{category:"element"},perform:(e,t)=>({elements:fw(e,t),appState:t,commitToHistory:!0}),keyTest:e=>rr?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.BRACKET_LEFT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===he.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>qm("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.sendToBack")} \u2014 ${rr?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")}`,children:Bg})}),tf=B({name:"bringToFront",label:"labels.bringToFront",icon:Og,trackEvent:{category:"element"},perform:(e,t)=>({elements:bw(e,t),appState:t,commitToHistory:!0}),keyTest:e=>rr?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.BRACKET_RIGHT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===he.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>qm("button",{type:"button",className:"zIndexButton",onClick:r=>e(null),title:`${b("labels.bringToFront")} \u2014 ${rr?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")}`,children:Og})});f();ue();Ye();Nr();ge();ce();Qt();Qn();var rf=B({name:"selectAll",label:"labels.selectAll",icon:q2,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,r,o)=>{if(t.editingLinearElement)return!1;let n=ha(e.filter(i=>!i.isDeleted&&!(U(i)&&i.containerId)&&!i.locked)).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...t,...Kt({editingGroupId:null,selectedElementIds:n},be(e),t,o),selectedLinearElement:Object.keys(n).length===1&&re(e[0])?new K(e[0]):null},commitToHistory:!0}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.A});f();ue();Ye();ge();Ve();z();Qt();Nr();Jr();G();ut();ce();f();z();var yC=e=>{let t=e.slice(),r=new Set,o=i=>{let a=i[0]?.groupIds?.join(""),l=[i[0]],s=[];for(let c of i.slice(1))c.groupIds?.join("")===a?l.push(c):s.push(c);return s.length?[...l,...o(s)]:l},n=new Map;return t.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let l=i.groupIds[i.groupIds.length-1],s=t.slice(a).filter(c=>{let d=c?.groupIds?.some(m=>m===l);return d&&n.set(c.id,!0),d});for(let c of o(s))r.add(c)}else r.add(i)}),r.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...r]},wC=e=>{let t=hx(e),r=e.slice(),o=new Set;return r.forEach((n,i)=>{n&&(n.boundElements?.length?(o.add(n),r[i]=null,n.boundElements.forEach(a=>{let l=t.get(a.id);l&&a.type==="text"&&(o.add(l[0]),r[l[1]]=null)})):n.type==="text"&&n.containerId&&t.get(n.containerId)?.[0].boundElements?.find(l=>l.id===n.id)||(o.add(n),r[i]=null))}),o.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...o]},xw=e=>wC(yC(e));er();Qn();wo();import{jsx as TC}from"react/jsx-runtime";var of=B({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ac,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getNonDeletedElementsMap();if(t.editingLinearElement){let i=K.duplicateSelectedPoints(t,n);return i?{elements:e,appState:i.appState,commitToHistory:!0}:!1}return{...vC(e,t),commitToHistory:!0}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.D,PanelComponent:({elements:e,appState:t,updateData:r})=>TC(ae,{type:"button",icon:ac,title:`${b("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":b("labels.duplicateSelection"),onClick:()=>r(null),visible:ze(be(e),t)})}),vC=(e,t)=>{let r=xw(e),o=new Map,n=[],i=[],a=new Map,l=new Map,s=w=>{let y=Hs(t.editingGroupId,o,w,{x:w.x+un/2,y:w.y+un/2});return l.set(y.id,y),a.set(w.id,y.id),i.push(w),n.push(y),y},c=$(me(r,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),d=new Map,m=w=>{for(let y of w)d.set(y.id,!0);return w},p=[],u=-1;for(;++u<r.length;){let w=r[u];if(d.get(w.id))continue;let y=pe(w,$(e)),I=Q(w);if(c.get(w.id)){if(w.groupIds.length||y||I){let P=Lh(t,w);if(P){let C=Je(r,P).flatMap(_=>Q(_)?[...Hr(e,_.id),_]:[_]);p.push(...m([...C,...C.map(_=>s(_))]));continue}if(y){p.push(...m([w,y,s(w),s(y)]));continue}if(I){let C=Hr(r,w.id);p.push(...m([...C,w,...C.map(_=>s(_)),s(w)]));continue}}(!w.frameId||!c.has(w.frameId))&&p.push(...m([w,s(w)]))}else p.push(...m([w]))}let h=[],x=new Map;for(u=p.length;--u>=0;){let w=p[u];x.get(w.id)||(x.set(w.id,!0),h.push(w))}let E=h.reverse();qt(E,$([...i,...n])),Pd(p,i,a),Ad(p,i,a),Tm(E,i,a);let v=ha(n);return{elements:E,appState:{...t,...Kt({editingGroupId:t.editingGroupId,selectedElementIds:v.reduce((w,y)=>(Ne(y)||(w[y.id]=!0),w),{})},be(E),t,null)}}};f();Zt();f();var SC=["ai","command_palette"],fe=(e,t,r,o)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.PROD||!SC.includes(e))return;T.PROD||console.info("trackEvent",{category:e,action:t,label:r,value:o}),window.sa_event&&window.sa_event(t,{category:e,label:r,value:o})}catch(n){console.error("error during analytics",n)}};f();import Ew from"clsx";import{jsx as nf,jsxs as IC}from"react/jsx-runtime";var Zo=e=>nf("div",{className:"buttonList buttonListIcon",children:e.options.map(t=>e.type==="button"?nf("button",{onClick:r=>e.onClick(t.value,r),className:Ew({active:t.active??e.value===t.value}),"data-testid":t.testId,title:t.text,children:t.icon},t.text):IC("label",{className:Ew({active:e.value===t.value}),title:t.text,children:[nf("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});f();z();f();Zt();import CC from"clsx";import{jsx as af}from"react/jsx-runtime";var yw=({onChange:e,type:t,activeColor:r,topPicks:o})=>{let n;return t==="elementStroke"&&(n=$c),t==="elementBackground"&&(n=Xc),t==="canvasBackground"&&(n=Zc),o&&(n=o),n?af("div",{className:"color-picker__top-picks",children:n.map(i=>af("button",{className:CC("color-picker__button",{active:i===r,"is-transparent":i==="transparent"||!i}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:af("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};f();import Mw,{useEffect as Lw,useState as XC}from"react";f();import LC from"clsx";import{useAtom as PC}from"jotai";import{useEffect as _C,useRef as DC}from"react";f();Zt();import{atom as kC}from"jotai";var gi=({palette:e,color:t})=>{for(let[r,o]of Object.entries(e))if(Array.isArray(o)){let n=o.indexOf(t);if(n>-1)return{colorName:r,shade:n}}else if(o===t)return{colorName:r,shade:null};return null},pc=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),lf=({color:e,palette:t})=>!Object.values(t).flat().includes(e),vw=(e,t,r)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[o[t]];return lf({color:l,palette:r})}),i=new Map;return n.forEach(a=>{let l=a[o[t]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,kb)},oo=kC(null),ww=(e,t,r)=>(e*299+t*587+r*114)/1e3>=160?"black":"white",Tw=(e,t)=>{if(t){let i=new Option().style;if(i.color=e,i.color){let a=i.color.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),l=parseInt(a[0]),s=parseInt(a[1]),c=parseInt(a[2]);return ww(l,s,c)}}if(e==="transparent")return"black";let r=parseInt(e.substring(1,3),16),o=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return ww(r,o,n)};f();import{jsxs as MC}from"react/jsx-runtime";var AC=({color:e,keyLabel:t,isCustomColor:r=!1,isShade:o=!1})=>MC("div",{className:"color-picker__button__hotkey-label",style:{color:Tw(e,r)},children:[o&&"\u21E7",t]}),Ll=AC;import{jsx as uc,jsxs as Sw}from"react/jsx-runtime";var Iw=({hex:e,onChange:t,palette:r})=>{let o=gi({color:e||"transparent",palette:r}),[n,i]=PC(oo),a=DC(null);if(_C(()=>{a.current&&n==="shades"&&a.current.focus()},[o,n]),o){let{colorName:l,shade:s}=o,c=r[l];if(Array.isArray(c))return uc("div",{className:"color-picker-content--default shades",children:c.map((d,m)=>Sw("button",{ref:m===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:LC("color-picker__button color-picker__button--large",{active:m===s}),"aria-label":"Shade",title:`${l} - ${m+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{t(d),i("shades")},children:[uc("div",{className:"color-picker__button-outline"}),uc(Ll,{color:d,keyLabel:m+1,isShade:!0})]},m))})}return Sw("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[uc("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),uc("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:b("colorPicker.noShades")})]})};f();import RC from"clsx";import{useAtom as NC}from"jotai";import{useEffect as OC,useRef as BC}from"react";import{jsx as sf,jsxs as HC}from"react/jsx-runtime";var FC=({palette:e,color:t,onChange:r,label:o,activeShade:n})=>{let i=gi({color:t||"transparent",palette:e}),[a,l]=NC(oo),s=BC(null);return OC(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),sf("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,d],m)=>{let p=(Array.isArray(d)?d[n]:d)||"transparent",u=pc[m],h=b(`colors.${c.replace(/\d+/,"")}`,null,"");return HC("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:RC("color-picker__button color-picker__button--large",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{r(p),l("baseColors")},title:`${h}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${h} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[sf("div",{className:"color-picker__button-outline"}),sf(Ll,{color:p,keyLabel:u})]},c)})})},Cw=FC;import{useAtom as ZC}from"jotai";f();import zC from"clsx";import{useAtom as GC}from"jotai";import{useEffect as UC,useRef as WC}from"react";import{jsx as cf,jsxs as VC}from"react/jsx-runtime";var kw=({colors:e,color:t,onChange:r,label:o})=>{let[n,i]=GC(oo),a=WC(null);return UC(()=>{a.current&&a.current.focus()},[t,n]),cf("div",{className:"color-picker-content--default",children:e.map((l,s)=>VC("button",{ref:t===l?a:void 0,tabIndex:-1,type:"button",className:zC("color-picker__button color-picker__button--large",{active:t===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{r(l),i("custom")},title:l,"aria-label":o,style:{"--swatch-color":l},children:[cf("div",{className:"color-picker__button-outline"}),cf(Ll,{color:l,keyLabel:s+1,isCustomColor:!0})]},s))})};f();ue();Zt();var df=(e,t,r)=>{let o=Math.ceil(r/Bi);switch(t=t??-1,e){case"ArrowLeft":{let n=t-1;return n<0?r-1:n}case"ArrowRight":return(t+1)%r;case"ArrowDown":{let n=t+Bi;return n>=r?t%Bi:n}case"ArrowUp":{let n=t-Bi,i=n<0?Bi*o+n:n;return i>=r?void 0:i}}},YC=({e,colorObj:t,onChange:r,palette:o,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return r(o[t.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return r(n[Number(e.key)-1]),i("custom"),!0;if(pc.includes(e.key)){let l=pc.indexOf(e.key),s=Object.keys(o)[l],c=o[s],d=Array.isArray(c)?c[a]:c;return r(d),i("baseColors"),!0}return!1},Aw=({event:e,activeColorPickerSection:t,palette:r,color:o,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:d})=>{if(e[S.CTRL_OR_CMD])return!1;if(e.key===S.ESCAPE)return d(e),!0;if(e.key===S.ALT)return c(!0),!0;if(e.key===S.I)return c(),!0;let m=gi({color:o,palette:r});if(e.key===S.TAB){let p={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},u=Object.entries(p).reduce((w,[y,I])=>(I&&w.push(y),w),[]),h=u.indexOf(t),x=e.shiftKey?-1:1,E=h+x>u.length-1?0:h+x<0?u.length-1:h+x,v=u[E];return v&&a(v),v==="custom"?n(i[0]):v==="baseColors"&&(Object.entries(r).find(([y,I])=>Array.isArray(I)?I.includes(o):I===o?y:null)||n(se.black)),e.preventDefault(),e.stopPropagation(),!0}if(YC({e,colorObj:m,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(t==="shades"&&m){let{shade:p}=m,u=df(e.key,p,Bi);if(u!==void 0)return n(r[m.colorName][u]),!0}if(t==="baseColors"&&m){let{colorName:p}=m,u=Object.keys(r),h=u.indexOf(p),x=df(e.key,h,u.length);if(x!==void 0){let E=u[x],v=r[E];return n(Array.isArray(v)?v[s]:v),!0}}if(t==="custom"){let p=i.indexOf(o),u=df(e.key,p,i.length);if(u!==void 0){let h=i[u];return n(h),!0}}return!1};f();import{jsx as $C}from"react/jsx-runtime";var KC=({children:e})=>$C("div",{className:"color-picker__heading",children:e}),Pl=KC;Zt();ue();G();import{jsx as xa,jsxs as Jm}from"react/jsx-runtime";var Pw=({color:e,onChange:t,label:r,type:o,elements:n,palette:i,updateData:a,children:l,onEyeDropperToggle:s,onEscape:c})=>{let[d]=Mw.useState(()=>o==="canvasBackground"?[]:vw(n,o,i)),[m,p]=ZC(oo),u=gi({color:e,palette:i});Lw(()=>{if(!m){let v=lf({color:e,palette:i}),w=v&&!d.includes(e);p(w?"hex":v?"custom":u?.shade!=null?"shades":"baseColors")}},[m,e,i,p,u,d]);let[h,x]=XC(u?.shade??(o==="elementBackground"?Ra:Da));Lw(()=>{u?.shade!=null&&x(u.shade);let v=w=>{w.key===S.ALT&&s(!1)};return document.addEventListener("keyup",v,{capture:!0}),()=>{document.removeEventListener("keyup",v,{capture:!0})}},[u,s]);let E=Mw.useRef(null);return xa("div",{role:"dialog","aria-modal":"true","aria-label":b("labels.colorPicker"),children:Jm("div",{ref:E,onKeyDown:v=>{Aw({event:v,activeColorPickerSection:m,palette:i,color:e,onChange:t,onEyeDropperToggle:s,customColors:d,setActiveColorPickerSection:p,updateData:a,activeShade:h,onEscape:c})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content",tabIndex:-1,children:[!!d.length&&Jm("div",{children:[xa(Pl,{children:b("colorPicker.mostUsedCustomColors")}),xa(kw,{colors:d,color:e,label:b("colorPicker.mostUsedCustomColors"),onChange:t})]}),Jm("div",{children:[xa(Pl,{children:b("colorPicker.colors")}),xa(Cw,{color:e,label:r,palette:i,onChange:t,activeShade:h})]}),Jm("div",{children:[xa(Pl,{children:b("colorPicker.shades")}),xa(Iw,{hex:e,onChange:t,palette:i})]}),l]})})};import*as jo from"@radix-ui/react-popover";import{useAtom as zw}from"jotai";Zt();import s4 from"clsx";f();import{useCallback as n4,useEffect as pf,useRef as Nw,useState as i4}from"react";import{useAtom as Ow}from"jotai";ue();f();Zt();G();import{atom as QC}from"jotai";import{useEffect as e4,useRef as t4}from"react";import{createPortal as r4}from"react-dom";f();import _w from"react";var mf=_w.createContext(null),Me=()=>_w.useContext(mf);f();import{useState as jC,useLayoutEffect as Dw}from"react";G();var Qm=e=>{let[t,r]=jC(null),o=Ie(),{theme:n}=Me(),{container:i}=Bt();return Dw(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",o.editor.isMobile),t.classList.toggle("theme--dark",n===oe.DARK))},[t,n,o.editor.isMobile,e?.className]),Dw(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),r(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),t};f();G();import{useEffect as qC}from"react";function _l(e,t,r){qC(()=>{function o(n){let i=n;if(!e.current)return;let a=r?.(i,e.current);if(a===!0)return;if(a===!1)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||t(i)}return document.addEventListener("pointerdown",o),document.addEventListener("touchstart",o),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("touchstart",o)}},[e,t,r])}ue();Ve();f();import{useRef as JC}from"react";var Dl=e=>{let t=JC(e);return Object.assign(t.current,e),t.current};import{jsx as o4}from"react/jsx-runtime";var fi=QC(null),Rw=({onCancel:e,onChange:t,onSelect:r,colorPickerType:o})=>{let n=Qm({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Me(),a=bi(),l=wr(),s=me(a,i),c=Dl({app:l,onCancel:e,onChange:t,onSelect:r,selectedElements:s}),{container:d}=Bt();e4(()=>{let p=m.current;if(!p||!l.canvas||!n)return;let u=!1,h=l.canvas.getContext("2d"),x=({clientX:C,clientY:_})=>{let D=h.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(_-i.offsetTop)*window.devicePixelRatio,1,1).data;return Db(D[0],D[1],D[2])},E=({clientX:C,clientY:_,altKey:D})=>{p.style.top=`${_+20}px`,p.style.left=`${C+20}px`;let H=x({clientX:C,clientY:_});u&&c.onChange(o,H,c.selectedElements,{altKey:D}),p.style.background=H},v=()=>{c.onCancel()},w=(C,_)=>{c.onSelect(C,_)},y=C=>{u=!0,C.stopImmediatePropagation()},I=C=>{u=!1,d?.focus(),C.stopImmediatePropagation(),C.preventDefault(),w(x(C),C)},P=C=>{C.key===S.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),v())};return n.tabIndex=-1,n.focus(),E({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",P),n.addEventListener("pointerdown",y),n.addEventListener("pointerup",I),window.addEventListener("pointermove",E,{passive:!0}),window.addEventListener("blur",v),()=>{u=!1,n.removeEventListener("keydown",P),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerup",I),window.removeEventListener("pointermove",E),window.removeEventListener("blur",v)}},[c,l.canvas,n,o,d,i.offsetLeft,i.offsetTop]);let m=t4(null);return _l(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?r4(o4("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),n):null};import a4 from"clsx";z();import{Fragment as l4,jsx as ep,jsxs as Bw}from"react/jsx-runtime";var Fw=({color:e,onChange:t,label:r,colorPickerType:o})=>{let n=Ie(),[i,a]=i4(e),[l,s]=Ow(oo);pf(()=>{a(e)},[e]);let c=n4(h=>{let x=h.toLowerCase(),E=Hw(x);E&&t(E),a(x)},[t]),d=Nw(null),m=Nw(null);pf(()=>{d.current&&d.current.focus()},[l]);let[p,u]=Ow(fi,Be);return pf(()=>()=>{u(null)},[u]),Bw("div",{className:"color-picker__input-label",children:[ep("div",{className:"color-picker__input-hash",children:"#"}),ep("input",{ref:l==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":r,onChange:h=>{c(h.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>s("hex"),onKeyDown:h=>{h.key!==S.TAB&&(h.key===S.ESCAPE&&m.current?.focus(),h.stopPropagation())}}),!n.editor.isMobile&&Bw(l4,{children:[ep("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),ep("div",{ref:m,className:a4("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(h=>h?null:{keepOpenOnAlt:!1,onSelect:x=>t(x),colorPickerType:o}),title:`${b("labels.eyeDropper")} \u2014 ${S.I.toLocaleUpperCase()} or ${R("Alt")} `,children:U2})]})]})};import{useRef as c4}from"react";import{jsx as no,jsxs as tp}from"react/jsx-runtime";var Gw=e=>{let t=new Option().style;return t.color=e,!!t.color},Hw=e=>or(e)?e:Gw(`#${e}`)?`#${e}`:Gw(e)?e:null,d4=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=se,updateData:a})=>{let[,l]=zw(oo),[s,c]=zw(fi,Be),{container:d}=Bt(),m=Ie(),p=tp("div",{children:[no(Pl,{children:b("colorPicker.hexCode")}),no(Fw,{color:t,label:o,onChange:x=>{r(x)},colorPickerType:e})]}),u=c4(null),h=()=>{u.current?.querySelector(".color-picker-content")?.focus()};return no(jo.Portal,{container:d,children:tp(jo.Content,{ref:u,className:"focus-visible-none","data-prevent-outside-click":!0,onFocusOutside:x=>{h(),x.preventDefault()},onPointerDownOutside:x=>{s&&x.preventDefault()},onCloseAutoFocus:x=>{x.stopPropagation(),x.preventDefault(),d&&!lx(document.activeElement)&&d.focus(),a({openPopup:null}),l(null)},side:m.editor.isMobile&&!m.viewport.isLandscape?"bottom":"right",align:m.editor.isMobile&&!m.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-layerUI)",backgroundColor:"var(--popup-bg-color)",maxWidth:"208px",maxHeight:window.innerHeight,padding:"12px",borderRadius:"8px",boxSizing:"border-box",overflowY:"auto",boxShadow:"0px 7px 14px rgba(0, 0, 0, 0.05), 0px 0px 3.12708px rgba(0, 0, 0, 0.0798), 0px 0px 0.931014px rgba(0, 0, 0, 0.1702)"},children:[i?no(Pw,{palette:i,color:t,onChange:x=>{r(x)},onEyeDropperToggle:x=>{c(E=>x?(E=E||{keepOpenOnAlt:!0,onSelect:r,colorPickerType:e},E.keepOpenOnAlt=!0,E):x===!1||E?null:{keepOpenOnAlt:!1,onSelect:r,colorPickerType:e})},onEscape:x=>{s?c(null):Xr(x.target)?h():a({openPopup:null})},label:o,type:e,elements:n,updateData:a,children:p}):p,no(jo.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})},m4=({label:e,color:t,type:r})=>no(jo.Trigger,{type:"button",className:s4("color-picker__button active-color",{"is-transparent":t==="transparent"||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:r==="elementStroke"?b("labels.showStroke"):b("labels.showBackground"),children:no("div",{className:"color-picker__button-outline"})}),hc=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=se,topPicks:a,updateData:l,appState:s})=>no("div",{children:tp("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[no(yw,{activeColor:t,onChange:r,type:e,topPicks:a}),no("div",{style:{width:1,height:"100%",backgroundColor:"var(--default-border-color)",margin:"0 auto"}}),tp(jo.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[no(m4,{color:t,label:o,type:e}),s.openPopup===e&&no(d4,{type:e,color:t,onChange:r,label:o,elements:n,palette:i,updateData:l})]})]})});f();import Ea from"react";f();import{useLayoutEffect as p4,useRef as Uw,useEffect as Ww}from"react";z();ue();import{unstable_batchedUpdates as u4}from"react-dom";import{jsx as h4}from"react/jsx-runtime";var rp=({children:e,left:t,top:r,onCloseRequest:o,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let c=Uw(null);Ww(()=>{let m=c.current;if(!m)return;m.contains(document.activeElement)||m.focus();let p=u=>{if(u.key===S.TAB){let h=us(m),{activeElement:x}=document,E=h.findIndex(v=>v===x);x===m?(u.shiftKey?h[h.length-1]?.focus():h[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):E===0&&u.shiftKey?(h[h.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):E===h.length-1&&!u.shiftKey&&(h[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return m.addEventListener("keydown",p),()=>m.removeEventListener("keydown",p)},[]);let d=Uw(null);return p4(()=>{if(n&&c.current&&r!=null&&t!=null){let m=c.current,{width:p,height:u}=m.getBoundingClientRect();if(d.current?.top===r&&d.current?.left===t)return;d.current={top:r,left:t},p>=l?(m.style.width=`${l}px`,m.style.left="0px",m.style.overflowX="scroll"):t+p-i>l?m.style.left=`${l-p-10}px`:m.style.left=`${t}px`,u>=s?(m.style.height=`${s-20}px`,m.style.top="10px",m.style.overflowY="scroll"):r+u-a>s?m.style.top=`${s-u}px`:m.style.top=`${r}px`}},[r,t,n,l,s,i,a]),Ww(()=>{if(o){let m=p=>{c.current?.contains(p.target)||u4(()=>o(p))};return document.addEventListener("pointerdown",m,!1),()=>document.removeEventListener("pointerdown",m,!1)}},[o]),h4("div",{className:"popover",ref:c,tabIndex:-1,children:e})};ue();import g4 from"clsx";import{Fragment as b4,jsx as xi,jsxs as uf}from"react/jsx-runtime";function f4({options:e,value:t,label:r,onChange:o,onClose:n}){let i=Ea.useRef(),a=Ea.useRef(),l=Ea.useRef(null);return Ea.useEffect(()=>{a.current?a.current.focus():l.current&&l.current.focus()},[]),xi("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":r,onKeyDown:c=>{let d=e.find(m=>m.keyBinding===c.key.toLowerCase());if(!(c.metaKey||c.altKey||c.ctrlKey)&&d){let m=e.indexOf(d);l.current.children[m].focus(),c.preventDefault()}else if(c.key===S.TAB)setTimeout(()=>{let m=a.current,p=document.activeElement;m!==p&&n()},0);else if(Za(c.key)){let{activeElement:m}=document,p=dn().rtl,u=Array.prototype.indexOf.call(l.current.children,m);if(u!==-1){let h=e.length,x=u;switch(c.key){case(p?S.ARROW_LEFT:S.ARROW_RIGHT):case S.ARROW_DOWN:{x=(u+1)%h;break}case(p?S.ARROW_RIGHT:S.ARROW_LEFT):case S.ARROW_UP:{x=(h+u-1)%h;break}}l.current.children[x].focus()}c.preventDefault()}else(c.key===S.ESCAPE||c.key===S.ENTER)&&(c.preventDefault(),n());c.nativeEvent.stopImmediatePropagation(),c.stopPropagation()},children:xi("div",{className:"picker-content",ref:l,children:e.map((c,d)=>uf("button",{className:g4("picker-option",{active:t===c.value}),onClick:m=>{m.currentTarget.focus(),o(c.value)},title:`${c.text} ${c.keyBinding&&`\u2014 ${c.keyBinding.toUpperCase()}`}`,"aria-label":c.text||"none","aria-keyshortcuts":c.keyBinding||void 0,ref:m=>{m&&d===0&&(i.current=m),m&&c.value===t&&(a.current=m)},onFocus:()=>{o(c.value)},children:[c.icon,c.keyBinding&&xi("span",{className:"picker-keybinding",children:c.keyBinding})]},c.text))})})}function hf({value:e,label:t,options:r,onChange:o,group:n=""}){let[i,a]=Ea.useState(!1),l=Ea.useRef(null),s=dn().rtl;return uf("div",{children:[xi("button",{name:n,className:i?"active":"","aria-label":t,onClick:()=>a(!i),ref:l,children:r.find(c=>c.value===e)?.icon}),xi(Ea.Suspense,{fallback:"",children:i?uf(b4,{children:[xi(rp,{onCloseRequest:c=>c.target!==l.current&&a(!1),...s?{right:5.5}:{left:-5.5},children:xi(f4,{options:r.filter(c=>c.showInPicker!==!1),value:e,label:t,onChange:o,onClose:()=>{a(!1),l.current?.focus()}})}),xi("div",{className:"picker-triangle"})]}):null})]})}G();ge();We();ut();ce();ue();Eo();Ve();Cs();z();Ye();import{Fragment as Kw,jsx as Se,jsxs as zr}from"react/jsx-runtime";var Yw=.1,Gr=(e,t,r,o=!1)=>{let n=$(me(e,t,{includeBoundTextElement:o}));return e.map(i=>n.get(i.id)||i.id===t.editingElement?.id?r(i):i)},vr=function(e,t,r,o,n){let i=t.editingElement,a=be(e),l=null;return i&&(l=r(i)),l||(ze(a,t)?l=Ig(o===!0?a:a.filter(c=>o(c)),t,r)??(typeof n=="function"?n(!0):n):l=typeof n=="function"?n(!1):n),l},x4=(e,t)=>Ne(t)?t:F(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2},!1),gf=(e,t,r,o,n)=>{let i=new Set;return{elements:Gr(e,t,a=>{if(U(a)){let l=o(a);i.add(l);let s=ne(a,{fontSize:l});return Yt(s,r.scene.getContainerElement(a),r.scene.getNonDeletedElementsMap()),s=x4(a,s),s}return a},!0),appState:{...t,currentItemFontSize:i.size===1?[...i][0]:n??t.currentItemFontSize},commitToHistory:!0}},E4=B({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemStrokeColor&&{elements:Gr(e,t,o=>Is(o.type)?ne(o,{strokeColor:r.currentItemStrokeColor}):o,!0)},appState:{...t,...r},commitToHistory:!!r.currentItemStrokeColor}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>zr(Kw,{children:[Se("h3",{"aria-hidden":"true",children:b("labels.stroke")}),Se(hc,{topPicks:$c,palette:Lb,type:"elementStroke",label:b("labels.stroke"),color:vr(e,t,n=>n.strokeColor,!0,t.currentItemStrokeColor),onChange:n=>r({currentItemStrokeColor:n}),elements:e,appState:t,updateData:r})]})}),y4=B({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemBackgroundColor&&{elements:Gr(e,t,o=>ne(o,{backgroundColor:r.currentItemBackgroundColor}))},appState:{...t,...r},commitToHistory:!!r.currentItemBackgroundColor}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>zr(Kw,{children:[Se("h3",{"aria-hidden":"true",children:b("labels.background")}),Se(hc,{topPicks:Xc,palette:Pb,type:"elementBackground",label:b("labels.background"),color:vr(e,t,n=>n.backgroundColor,!0,t.currentItemBackgroundColor),onChange:n=>r({currentItemBackgroundColor:n}),elements:e,appState:t,updateData:r})]})}),w4=B({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,r,o)=>(fe("element","changeFillStyle",`${r} (${o.device.editor.isMobile?"mobile":"desktop"})`),{elements:Gr(e,t,n=>ne(n,{fillStyle:r})),appState:{...t,currentItemFillStyle:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=me(e,t),n=o.length>0&&o.every(i=>i.fillStyle==="zigzag");return zr("fieldset",{children:[Se("legend",{children:b("labels.fill")}),Se(Zo,{type:"button",options:[{value:"hachure",text:`${n?b("labels.zigzag"):b("labels.hachure")} (${R("Alt-Click")})`,icon:n?i2:a2,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:b("labels.crossHatch"),icon:l2,testId:"fill-cross-hatch"},{value:"solid",text:b("labels.solid"),icon:s2,testId:"fill-solid"}],value:vr(e,t,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:t.currentItemFillStyle),onClick:(i,a)=>{let l=a.altKey&&i==="hachure"&&o.every(s=>s.fillStyle==="hachure")?"zigzag":i;r(l)}})]})}}),v4=B({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{strokeWidth:r})),appState:{...t,currentItemStrokeWidth:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>zr("fieldset",{children:[Se("legend",{children:b("labels.strokeWidth")}),Se(Zo,{group:"stroke-width",options:[{value:nd.thin,text:b("labels.thin"),icon:Kg,testId:"strokeWidth-thin"},{value:nd.bold,text:b("labels.bold"),icon:c2,testId:"strokeWidth-bold"},{value:nd.extraBold,text:b("labels.extraBold"),icon:d2,testId:"strokeWidth-extraBold"}],value:vr(e,t,o=>o.strokeWidth,o=>o.hasOwnProperty("strokeWidth"),o=>o?null:t.currentItemStrokeWidth),onChange:o=>r(o)})]})}),T4=B({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{seed:qr(),roughness:r})),appState:{...t,currentItemRoughness:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>zr("fieldset",{children:[Se("legend",{children:b("labels.sloppiness")}),Se(Zo,{group:"sloppiness",options:[{value:0,text:b("labels.architect"),icon:u2},{value:1,text:b("labels.artist"),icon:h2},{value:2,text:b("labels.cartoonist"),icon:g2}],value:vr(e,t,o=>o.roughness,o=>o.hasOwnProperty("roughness"),o=>o?null:t.currentItemRoughness),onChange:o=>r(o)})]})}),aY=B({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{strokeStyle:r})),appState:{...t,currentItemStrokeStyle:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>zr("fieldset",{children:[Se("legend",{children:b("labels.strokeStyle")}),Se(Zo,{group:"strokeStyle",options:[{value:"solid",text:b("labels.strokeStyle_solid"),icon:Kg},{value:"dashed",text:b("labels.strokeStyle_dashed"),icon:m2},{value:"dotted",text:b("labels.strokeStyle_dotted"),icon:p2}],value:vr(e,t,o=>o.strokeStyle,o=>o.hasOwnProperty("strokeStyle"),o=>o?null:t.currentItemStrokeStyle),onChange:o=>r(o)})]})}),S4=B({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{opacity:r}),!0),appState:{...t,currentItemOpacity:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>zr("label",{className:"control-label",children:[b("labels.opacity"),Se("input",{type:"range",min:"0",max:"100",step:"10",onChange:o=>r(+o.target.value),value:vr(e,t,o=>o.opacity,!0,t.currentItemOpacity)??void 0})]})}),I4=B({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,r,o)=>gf(e,t,o,()=>r,r),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>zr("fieldset",{children:[Se("legend",{children:b("labels.fontSize")}),Se(Zo,{group:"font-size",options:[{value:16,text:b("labels.small"),icon:C2,testId:"fontSize-small"},{value:20,text:b("labels.medium"),icon:k2,testId:"fontSize-medium"},{value:28,text:b("labels.large"),icon:A2,testId:"fontSize-large"},{value:36,text:b("labels.veryLarge"),icon:M2,testId:"fontSize-veryLarge"}],value:vr(e,t,n=>{if(U(n))return n.fontSize;let i=pe(n,o.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>U(n)||pe(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:t.currentItemFontSize||At),onChange:n=>r(n)})]})}),ff=B({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Xg,trackEvent:!1,perform:(e,t,r,o)=>gf(e,t,o,n=>Math.round(1/(1+Yw)*n.fontSize)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_LEFT||e.key===S.COMMA)}),bf=B({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Xg,trackEvent:!1,perform:(e,t,r,o)=>gf(e,t,o,n=>Math.round(n.fontSize*(1+Yw))),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_RIGHT||e.key===S.PERIOD)}),C4=B({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,r,o)=>({elements:Gr(e,t,n=>{if(U(n)){let i=ne(n,{fontFamily:r,lineHeight:_r(r)});return Yt(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemFontFamily:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=[{value:it.Virgil,text:b("labels.handDrawn"),icon:Sl,testId:"font-family-virgil"},{value:it.Helvetica,text:b("labels.normal"),icon:L2,testId:"font-family-normal"},{value:it.Cascadia,text:b("labels.code"),icon:P2,testId:"font-family-code"}];return zr("fieldset",{children:[Se("legend",{children:b("labels.fontFamily")}),Se(Zo,{group:"font-family",options:n,value:vr(e,t,i=>{if(U(i))return i.fontFamily;let a=pe(i,o.scene.getNonDeletedElementsMap());return a?a.fontFamily:null},i=>U(i)||pe(i,o.scene.getNonDeletedElementsMap())!==null,i=>i?null:t.currentItemFontFamily||Wt),onChange:i=>r(i)})]})}}),k4=B({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,r,o)=>({elements:Gr(e,t,n=>{if(U(n)){let i=ne(n,{textAlign:r});return Yt(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemTextAlign:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=o.scene.getNonDeletedElementsMap();return zr("fieldset",{children:[Se("legend",{children:b("labels.textAlign")}),Se(Zo,{group:"text-align",options:[{value:"left",text:b("labels.left"),icon:_2,testId:"align-left"},{value:"center",text:b("labels.center"),icon:D2,testId:"align-horizontal-center"},{value:"right",text:b("labels.right"),icon:R2,testId:"align-right"}],value:vr(e,t,i=>{if(U(i))return i.textAlign;let a=pe(i,n);return a?a.textAlign:null},i=>U(i)||pe(i,n)!==null,i=>i?null:t.currentItemTextAlign),onChange:i=>r(i)})]})}}),A4=B({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:Gr(e,t,n=>{if(U(n)){let i=ne(n,{verticalAlign:r});return Yt(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Se("fieldset",{children:Se(Zo,{group:"text-align",options:[{value:ft.TOP,text:b("labels.alignTop"),icon:Se(N2,{theme:t.theme}),testId:"align-top"},{value:ft.MIDDLE,text:b("labels.centerVertically"),icon:Se(B2,{theme:t.theme}),testId:"align-middle"},{value:ft.BOTTOM,text:b("labels.alignBottom"),icon:Se(O2,{theme:t.theme}),testId:"align-bottom"}],value:vr(e,t,n=>{if(U(n)&&n.containerId)return n.verticalAlign;let i=pe(n,o.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>U(n)||pe(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:ft.MIDDLE),onChange:n=>r(n)})})}),lY=B({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{roundness:r==="round"?{type:Ho(o.type)?rt.ADAPTIVE_RADIUS:rt.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let n=ga(be(e),t).some(i=>i.roundness?.type===rt.LEGACY);return zr("fieldset",{children:[Se("legend",{children:b("labels.edges")}),Se(Zo,{group:"edges",options:[{value:"sharp",text:b("labels.sharp"),icon:f2},{value:"round",text:b("labels.round"),icon:b2}],value:vr(e,t,i=>n?null:i.roundness?"round":"sharp",i=>i.hasOwnProperty("roundness"),i=>i?null:t.currentItemRoundness),onChange:i=>r(i)})]})}}),Vw=e=>[{value:null,text:b("labels.arrowhead_none"),keyBinding:"q",icon:x2},{value:"arrow",text:b("labels.arrowhead_arrow"),keyBinding:"w",icon:Se(E2,{flip:e})},{value:"bar",text:b("labels.arrowhead_bar"),keyBinding:"e",icon:Se(w2,{flip:e})},{value:"dot",text:b("labels.arrowhead_circle"),keyBinding:null,icon:Se($g,{flip:e}),showInPicker:!1},{value:"circle",text:b("labels.arrowhead_circle"),keyBinding:"r",icon:Se($g,{flip:e}),showInPicker:!1},{value:"circle_outline",text:b("labels.arrowhead_circle_outline"),keyBinding:null,icon:Se(y2,{flip:e}),showInPicker:!1},{value:"triangle",text:b("labels.arrowhead_triangle"),icon:Se(v2,{flip:e}),keyBinding:"t"},{value:"triangle_outline",text:b("labels.arrowhead_triangle_outline"),icon:Se(T2,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond",text:b("labels.arrowhead_diamond"),icon:Se(S2,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond_outline",text:b("labels.arrowhead_diamond_outline"),icon:Se(I2,{flip:e}),keyBinding:null,showInPicker:!1}],sY=B({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>{if(re(o)){let{position:n,type:i}=r;if(n==="start")return ne(o,{startArrowhead:i});if(n==="end")return ne(o,{endArrowhead:i})}return o}),appState:{...t,[r.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:r.type},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=dn().rtl;return zr("fieldset",{children:[Se("legend",{children:b("labels.arrowheads")}),zr("div",{className:"iconSelectList buttonList",children:[Se(hf,{label:"arrowhead_start",options:Vw(!o),value:vr(e,t,n=>re(n)&&Yi(n.type)?n.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:n=>r({position:"start",type:n})}),Se(hf,{label:"arrowhead_end",group:"arrowheads",options:Vw(!!o),value:vr(e,t,n=>re(n)&&Yi(n.type)?n.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:n=>r({position:"end",type:n})})]})]})}});f();G();ge();ue();Ve();kg();Om();z();Ye();f();import{useEffect as M4}from"react";import{jsx as P4}from"react/jsx-runtime";var Rl=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},xf=(e,t,r="bottom")=>{let o=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=t.left+t.width/2-o.width/2;l<0?l=a:l+o.width>=n&&(l=n-o.width-a);let s;r==="bottom"?(s=t.top+t.height+a,s+o.height>=i&&(s=t.top-o.height-a)):(s=t.top-o.height-a,s<0&&(s=t.top+t.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},L4=(e,t,r,o)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=o?"50ch":"10ch",t.style.maxWidth=o?"50ch":"15ch",t.textContent=r;let n=e.getBoundingClientRect();xf(t,n)},Ur=({children:e,label:t,long:r=!1,style:o,disabled:n})=>(M4(()=>()=>Rl().classList.remove("excalidraw-tooltip--visible"),[]),n?null:P4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>L4(i.currentTarget,Rl(),t,r),onPointerLeave:()=>Rl().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));We();Rr();Zt();ol();import{jsx as ip,jsxs as O4}from"react/jsx-runtime";var _4=B({name:"changeViewBackgroundColor",label:"labels.canvasBackground",paletteName:"Change canvas background color",trackEvent:!1,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,r)=>({appState:{...t,...r},commitToHistory:!!r.viewBackgroundColor}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>ip(hc,{palette:null,topPicks:Zc,label:b("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:n=>r({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:r})}),On=B({name:"clearCanvas",label:"labels.clearCanvas",paletteName:"Clear canvas",icon:Lo,trackEvent:{category:"canvas"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled,perform:(e,t,r,o)=>(o.imageCache.clear(),{elements:e.map(n=>ne(n,{isDeleted:!0})),appState:{...ar(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,showStats:t.showStats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:"selection"}:t.activeTool},commitToHistory:!0})}),op=B({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Mg,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Nn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Xo(t.zoom.value+Gi)},t),userToFollow:null},commitToHistory:!1}),PanelComponent:({updateData:e})=>ip(ae,{type:"button",className:"zoom-in-button zoom-button",icon:Mg,title:`${b("buttons.zoomIn")} \u2014 ${R("CtrlOrCmd++")}`,"aria-label":b("buttons.zoomIn"),onClick:()=>{e(null)}}),keyTest:e=>(e.code===he.EQUAL||e.code===he.NUM_ADD)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),np=B({name:"zoomOut",label:"buttons.zoomOut",icon:Lg,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Nn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Xo(t.zoom.value-Gi)},t),userToFollow:null},commitToHistory:!1}),PanelComponent:({updateData:e})=>ip(ae,{type:"button",className:"zoom-out-button zoom-button",icon:Lg,title:`${b("buttons.zoomOut")} \u2014 ${R("CtrlOrCmd+-")}`,"aria-label":b("buttons.zoomOut"),onClick:()=>{e(null)}}),keyTest:e=>(e.code===he.MINUS||e.code===he.NUM_SUBTRACT)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),D4=B({name:"resetZoom",label:"buttons.resetZoom",icon:Vy,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Nn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Xo(1)},t),userToFollow:null},commitToHistory:!1}),PanelComponent:({updateData:e,appState:t})=>ip(Ur,{label:b("buttons.resetZoom"),style:{height:"100%"},children:O4(ae,{type:"button",className:"reset-zoom-button zoom-button",title:b("buttons.resetZoom"),"aria-label":b("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===he.ZERO||e.code===he.NUM_ZERO)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),R4=(e,t)=>{let[r,o,n,i]=e,a=n-r,l=t.width/a,s=i-o,c=t.height/s,d=Math.min(l,c),m=Math.floor(d/Gi)*Gi;return Math.min(Math.max(m,ed),1)},$w=({bounds:e,appState:t,fitToViewport:r=!1,viewportZoomFactor:o=.7})=>{let[n,i,a,l]=e,s=(n+a)/2,c=(i+l)/2,d,m,p;if(r){let u=a-n,h=l-i;d=Math.min(t.width/u,t.height/h)*Math.min(1,Math.max(o,.1)),d=Math.min(Math.max(d,.1),30);let x=t.width;if(t.openSidebar){let v=document.querySelector(".sidebar")?.offsetWidth??0;x=document.documentElement.getAttribute("dir")==="rtl"?t.width+v:t.width-v}m=x/2*(1/d)-s,p=t.height/2*(1/d)-c}else{d=R4(e,{width:t.width,height:t.height});let u=Cg({scenePoint:{x:s,y:c},viewportDimensions:{width:t.width,height:t.height},zoom:{value:d}});m=u.scrollX,p=u.scrollY}return{appState:{...t,scrollX:m,scrollY:p,zoom:{value:d}},commitToHistory:!1}},gc=({targetElements:e,appState:t,fitToViewport:r,viewportZoomFactor:o})=>{let n=we(be(e));return $w({bounds:n,appState:t,fitToViewport:r,viewportZoomFactor:o})},BY=B({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:jm,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return gc({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!1})},keyTest:e=>e.code===he.TWO&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),FY=B({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:jm,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return gc({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!0})},keyTest:e=>e.code===he.THREE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),N4=B({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:jm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>gc({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1}),keyTest:e=>e.code===he.ONE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),ya=B({name:"toggleTheme",label:(e,t)=>t.theme===oe.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===oe.LIGHT?lc:sc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r)=>({appState:{...t,theme:r||(t.theme===oe.LIGHT?oe.DARK:oe.LIGHT)},commitToHistory:!1}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===he.D,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.toggleTheme}),HY=B({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t)=>{let r;return xr(t)?r=Xe(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):r=Xe(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},commitToHistory:!0}},keyTest:e=>e.key===S.E}),Xw=B({name:"toggleHandTool",label:"toolBar.hand",paletteName:"Toggle hand tool",trackEvent:{category:"toolbar"},icon:Wm,viewMode:!1,perform:(e,t,r,o)=>{let n;return Co(t)?n=Xe(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Xe(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),He(o.interactiveCanvas,Ce.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},commitToHistory:!0}},keyTest:e=>!e.altKey&&!e[S.CTRL_OR_CMD]&&e.key===S.H});f();ue();ge();z();Ye();We();Rt();Qt();Jr();ce();ol();import{jsx as B4}from"react/jsx-runtime";var io=B({name:"finalize",label:"",trackEvent:!1,perform:(e,t,r,o)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=o,l=a.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:h}=t.editingLinearElement,x=K.getElement(p,l);if(x)return Tt(x)&&xn(x,u,h,l),{elements:x.points.length<2||eo(x)?e.filter(E=>E.id!==x.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null},commitToHistory:!0}}let s=e,c=t.pendingImageElementId&&a.getElement(t.pendingImageElementId);c&&F(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let d=t.multiElement?t.multiElement:t.editingElement?.type==="freedraw"?t.editingElement:null;if(d){if(d.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:h}=d;(!h||u[u.length-1]!==h)&&F(d,{points:d.points.slice(0,-1)})}eo(d)&&(s=s.filter(u=>u.id!==d.id));let p=ir(d.points,t.zoom.value);if((d.type==="line"||d.type==="freedraw")&&p){let u=d.points,h=u[0];F(d,{points:u.map((x,E)=>E===u.length-1?[h[0],h[1]]:x)})}if(Tt(d)&&!p&&d.points.length>1){let[u,h]=K.getPointAtIndexGlobalCoordinates(d,-1,$(e));Ps(d,t,{x:u,y:h},o)}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!d)&&Or(n);let m;return t.activeTool.type==="eraser"?m=Xe(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):m=Xe(t,{type:"selection"}),{elements:s,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&d?t.activeTool:m,activeEmbeddable:null,draggingElement:null,multiElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[d.id]:!0}:t.selectedElementIds,selectedLinearElement:d&&re(d)?new K(d):t.selectedLinearElement,pendingImageElementId:null},commitToHistory:t.activeTool.type==="freedraw"}},keyTest:(e,t)=>e.key===S.ESCAPE&&(t.editingLinearElement!==null||!t.draggingElement&&t.multiElement===null)||(e.key===S.ESCAPE||e.key===S.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:r})=>B4(ae,{type:"button",icon:e2,title:b("buttons.done"),"aria-label":b("buttons.done"),onClick:t,visible:e.multiElement!=null,size:r?.size||"medium"})});f();f();z();import{useState as F4}from"react";ue();import{jsx as Zw,jsxs as H4}from"react/jsx-runtime";var jw=e=>{let{id:t}=Bt(),[r,o]=F4(e.value),n=a=>{e.ignoreFocus||mx(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===S.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return H4("div",{className:"ProjectName",children:[Zw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Zw("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${t}-filename`,value:r,onChange:a=>o(a.target.value)})]})};f();G();import{jsx as fc}from"react/jsx-runtime";var Jw=e=>{let t=e.title||(e.value===oe.DARK?b("buttons.lightMode"):b("buttons.darkMode"));return fc(ae,{type:"icon",icon:e.value===oe.LIGHT?qw.MOON:qw.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===oe.DARK?oe.LIGHT:oe.DARK),"data-testid":"toggle-dark-mode"})},qw={SUN:fc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:fc("path",{fill:"currentColor",d:"M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"})}),MOON:fc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:fc("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};f();ui();G();ge();ce();Ve();qs();z();Er();An();Pn();er();Er();Pn();var wa=(e,{selectedElementIds:t},r)=>{e=be(e);let o=r&&ze(e,{selectedElementIds:t}),n=null,i=o?me(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return o&&(i.length===1&&Q(i[0])?(n=i[0],i=gl(e,n)):i.length>1&&(i=me(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:Bo(i)}},va=async(e,t,r,o,{exportBackground:n,exportPadding:i=fo,viewBackgroundColor:a,name:l=r.name||ad,fileHandle:s=null,exportingFrame:c=null})=>{if(t.length===0)throw new Error(b("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=hl(t,{exportBackground:n,exportWithDarkMode:r.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:r.exportScale,exportEmbedScene:r.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return ll(m.then(p=>new Blob([p.outerHTML],{type:J.svg})),{description:"Export to SVG",name:l,extension:r.exportEmbedScene?"excalidraw.svg":"svg",fileHandle:s});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await Dn(p)}catch{throw new Error(b("errors.copyToSystemClipboardFailed"))}return}}let d=hm(t,r,o,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Ln(d);return r.exportEmbedScene&&(m=m.then(p=>Promise.resolve().then(()=>(dl(),Ys)).then(({encodePngMetadata:u})=>u({blob:p,metadata:mi(t,r,o,"local")})))),ll(m,{description:"Export to PNG",name:l,extension:"png",fileHandle:s})}else if(e==="clipboard")try{let m=Ln(d);await ym(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):mn&&m.name==="TypeError"?new Error(`${b("alerts.couldNotCopyToClipboard")}
55
+ `),s=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,c=ii(e.fontSize,e.lineHeight),d=_d(e.fontFamily,e.fontSize,c);for(let m=0;m<l.length;m++)r.fillText(l[m],s,m*c+d);r.restore(),a&&r.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},Mm=new WeakMap,sy=(e,t,r,o)=>{let n=r?o.zoom:K6.zoom,i=Mm.get(e),a=i&&i.zoomValue!==n.value&&!o?.shouldCacheIgnoreZoom,l=de(e,t)?.version||null,s=Ot(e,t)?.opacity||100;if(!i||a||i.theme!==o.theme||i.boundTextElementVersion!==l||i.containingFrameOpacity!==s){let c=X6(e,t,n,r,o);return Mm.set(e,c),c}return i},cy=(e,t,r,o,n)=>{let i=e.element,a=Lm(i),l=e.scale,[s,c,d,m]=te(i,n);Lt(i)&&(s=Math.floor(s),d=Math.ceil(d),c=Math.floor(c),m=Math.ceil(m));let p=((s+d)/2+o.scrollX)*window.devicePixelRatio,u=((c+m)/2+o.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let h=de(i,n);if(Te(i)&&h){let x=document.createElement("canvas"),E=x.getContext("2d"),v=Math.max(Mt(s,d),Mt(c,m));x.width=v*window.devicePixelRatio*l+a*e.scale*10,x.height=v*window.devicePixelRatio*l+a*e.scale*10;let w=(x.width-e.canvas.width)/2,y=(x.height-e.canvas.height)/2;E.translate(x.width/2,x.height/2),E.rotate(i.angle),E.drawImage(e.canvas,-e.canvas.width/2,-e.canvas.height/2,e.canvas.width,e.canvas.height);let[,,,,I,P]=te(h,n);E.rotate(-i.angle);let C=x.width/2-(I-s)*window.devicePixelRatio*l-w-a*l,_=x.height/2-(P-c)*window.devicePixelRatio*l-y-a*l;E.translate(-C,-_),E.clearRect(-(h.width/2+ht)*window.devicePixelRatio*l,-(h.height/2+ht)*window.devicePixelRatio*l,(h.width+ht*2)*window.devicePixelRatio*l,(h.height+ht*2)*window.devicePixelRatio*l),t.translate(p,u),t.drawImage(x,-(d-s)/2*window.devicePixelRatio-w/l-a,-(m-c)/2*window.devicePixelRatio-y/l-a,x.width/l,x.height/l)}else if(t.translate(p,u),t.rotate(i.angle),"scale"in e.element&&!py(i,r)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-p,-u),t.drawImage(e.canvas,(s+o.scrollX)*window.devicePixelRatio-a*e.scale/e.scale,(c+o.scrollY)*window.devicePixelRatio-a*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),T.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&gr(i)){let x=de(i,n),E=Ih(i);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((E.x+o.scrollX)*window.devicePixelRatio,(E.y+o.scrollY)*window.devicePixelRatio,fr(i,x)*window.devicePixelRatio,ta(i,x)*window.devicePixelRatio)}t.restore()},fy=(e,t,r)=>{t.save(),t.translate(e.x+r.scrollX,e.y+r.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let o=.5/r.zoom.value;t.fillRect(o,o,e.width,e.height),t.lineWidth=1/r.zoom.value,t.strokeStyle=" rgb(105, 101, 219)",t.strokeRect(o,o,e.width,e.height),t.restore()},hl=(e,t,r,o,n,i,a)=>{switch(n.globalAlpha=mg(e,Ot(e,t),i.elementsPendingErasure),e.type){case"magicframe":case"frame":{a.frameRendering.enabled&&a.frameRendering.outline&&(n.save(),n.translate(e.x+a.scrollX,e.y+a.scrollY),n.fillStyle="rgba(0, 0, 200, 0.04)",n.lineWidth=$e.strokeWidth/a.zoom.value,n.strokeStyle=$e.strokeColor,Vi(e)&&(n.strokeStyle=a.theme===oe.LIGHT?"#7affd7":"#1d8264"),$e.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,e.width,e.height,$e.radius/a.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,e.width,e.height),n.restore());break}case"freedraw":{if(ke.generateElementShape(e,null),i.isExporting){let[l,s,c,d]=te(e,t),m=(l+c)/2+a.scrollX,p=(s+d)/2+a.scrollY,u=(c-l)/2-(e.x-l),h=(d-s)/2-(e.y-s);n.save(),n.translate(m,p),n.rotate(e.angle),n.translate(-u,-h),Am(e,o,n,i,a),n.restore()}else{let l=sy(e,t,i,a);cy(l,n,i,a,r)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(ke.generateElementShape(e,i),i.isExporting){let[l,s,c,d]=te(e,t),m=(l+c)/2+a.scrollX,p=(s+d)/2+a.scrollY,u=(c-l)/2-(e.x-l),h=(d-s)/2-(e.y-s);if(G(e)){let E=st(e,t);if(Te(E)){let v=K.getBoundTextElementPosition(E,e,t);u=(c-l)/2-(v.x-l),h=(d-s)/2-(v.y-s)}}n.save(),n.translate(m,p),uy(e,i,a)&&(n.filter="none");let x=de(e,t);if(Te(e)&&x){let E=document.createElement("canvas"),v=E.getContext("2d"),w=Math.max(Mt(l,c),Mt(s,d)),y=Lm(e);E.width=w*a.exportScale+y*10*a.exportScale,E.height=w*a.exportScale+y*10*a.exportScale,v.translate(E.width/2,E.height/2),v.scale(a.exportScale,a.exportScale),u=e.width/2-(e.x-l),h=e.height/2-(e.y-s),v.rotate(e.angle);let I=my.canvas(E);v.translate(-u,-h),Am(e,I,v,i,a),v.translate(u,h),v.rotate(-e.angle);let[,,,,P,C]=te(x,t),_=(l+c)/2-P,D=(s+d)/2-C;v.translate(-_,-D),v.clearRect(-x.width/2,-x.height/2,x.width,x.height),n.scale(1/a.exportScale,1/a.exportScale),n.drawImage(E,-E.width/2,-E.height/2,E.width,E.height)}else n.rotate(e.angle),e.type==="image"&&n.scale(e.scale[0],e.scale[1]),n.translate(-u,-h),Am(e,o,n,i,a);n.restore()}else{let l=sy(e,t,i,a),s=n.imageSmoothingEnabled;!a?.shouldCacheIgnoreZoom&&(!e.angle||Mx(e.angle))&&(n.imageSmoothingEnabled=!1),cy(l,n,i,a,r),n.imageSmoothingEnabled=s}break}default:throw new Error(`Unimplemented type ${e.type}`)}n.globalAlpha=1},by=new WeakMap([]);q6=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g});import{RoughGenerator as Q6}from"roughjs/bin/generator";var ke,Go=j(()=>{"use strict";f();bn();Qu();Zt();ke=class e{static rg=new Q6;static cache=new WeakMap;static get=t=>e.cache.get(t);static set=(t,r)=>e.cache.set(t,r);static delete=t=>e.cache.delete(t);static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,r)=>{let o=r?.isExporting?void 0:e.get(t);if(o!==void 0)return o;Mm.delete(t);let n=Dx(t,e.rg,r||{isExporting:!1,canvasBackgroundColor:se.white,embedsValidationStatus:null});return e.cache.set(t,n),n}}});var F,ne,li,We=j(()=>{"use strict";f();Jn();ws();Eo();z();Go();F=(e,t,r=!0)=>{let o=!1,{points:n,fileId:i}=t;typeof n<"u"&&(t={...bd(n),...t});for(let a in t){let l=t[a];if(typeof l<"u"){if(e[a]===l&&(typeof l!="object"||l===null||a==="groupIds"||a==="scale"))continue;if(a==="scale"){let s=e[a],c=l;if(s[0]===c[0]&&s[1]===c[1])continue}else if(a==="points"){let s=e[a],c=l;if(s.length===c.length){let d=!1,m=s.length;for(;--m;){let p=s[m],u=c[m];if(p[0]!==u[0]||p[1]!==u[1]){d=!0;break}}if(!d)continue}}e[a]=l,o=!0}}return o&&((typeof t.height<"u"||typeof t.width<"u"||typeof i<"u"||typeof n<"u")&&ke.delete(e),e.version++,e.versionNonce=qr(),e.updated=gn(),r&&ut.getScene(e)?.informMutation()),e},ne=(e,t)=>{let r=!1;for(let o in t){let n=t[o];if(typeof n<"u"){if(e[o]===n&&(typeof n!="object"||n===null))continue;r=!0}}return r?{...e,...t,updated:gn(),version:e.version+1,versionNonce:qr()}:e},li=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=qr(),e.updated=gn(),e)});var eo,ma,Pm,tl,Ys,pa=j(()=>{"use strict";f();We();ce();U();at();z();eo=e=>re(e)||Lt(e)?e.points.length<2:e.width===0&&e.height===0,ma=(e,t,r,o,n)=>{let[i,a,l,s]=Dr(e,n),c=Ue({clientX:o.offsetLeft,clientY:o.offsetTop},o),d=Ue({clientX:o.offsetLeft+t,clientY:o.offsetTop+r},o);return c.x<=l&&c.y<=s&&d.x>=i&&d.y>=a},Pm=(e,t,r)=>{let o=Math.abs(t),n=Math.abs(r);if(e==="line"||e==="arrow"||e==="freedraw"){let i=Math.round(Math.atan(n/o)/No)*No;i===0?r=0:i===Math.PI/2?t=0:r=o*Math.tan(i)*Math.sign(r)||r}else e!=="selection"&&(r=o*Math.sign(r));return{width:t,height:r}},tl=(e,t,r,o)=>{let n=r-e,i=o-t,a=Math.round(Math.atan(i/n)/No)*No;if(a===0)i=0;else if(a===Math.PI/2)n=0;else{let l=Math.tan(a),s=-1,c=t-l*e,d=-1/l,m=-1,p=o-d*r,u=(s*p-m*c)/(l*m-d*s),h=(c*d-p*l)/(l*m-d*s);n=u-e,i=h-t}return{width:n,height:i}},Ys=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let r=Math.abs(e.width);t.width=r,t.x=e.x-r}if(e.height<0){let r=Math.abs(e.height);t.height=r,t.y=e.y-r}return t}});var xy,eC,tc,yy,tC,Ey,pg,Rn,Tl,rc,_m,oc=j(()=>{"use strict";f();at();Rt();ge();ce();U();xy={mouse:8,pen:16,touch:28},eC=16,tc={e:!0,s:!0,n:!0,w:!0},yy={e:!0,s:!0,n:!0,w:!0,rotation:!0},tC={e:!0,s:!0,n:!0,w:!0},Ey={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},pg={e:!0,s:!0,n:!0,w:!0},Rn=(e,t,r,o,n,i,a)=>{let[l,s]=Ee(e+r/2,t+o/2,n,i,a);return[l-r/2,s-o/2,r,o]},Tl=([e,t,r,o,n,i],a,l,s,c={},d=4)=>{let m=xy[s],p=m/l.value,u=m/l.value,h=m/l.value,x=m/l.value,E=r-e,v=o-t,w=d/l.value,y=(m-zi*2)/(2*l.value),I={nw:c.nw?void 0:Rn(e-w-h+y,t-w-x+y,p,u,n,i,a),ne:c.ne?void 0:Rn(r+w-y,t-w-x+y,p,u,n,i,a),sw:c.sw?void 0:Rn(e-w-h+y,o+w-y,p,u,n,i,a),se:c.se?void 0:Rn(r+w-y,o+w-y,p,u,n,i,a),rotation:c.rotation?void 0:Rn(e+E/2-p/2,t-w-x+y-eC/l.value,p,u,n,i,a)},P=5*xy.mouse/l.value;return Math.abs(E)>P&&(c.n||(I.n=Rn(e+E/2-p/2,t-w-x+y,p,u,n,i,a)),c.s||(I.s=Rn(e+E/2-p/2,o+w-y,p,u,n,i,a))),Math.abs(v)>P&&(c.w||(I.w=Rn(e-w-h+y,t+v/2-u/2,p,u,n,i,a)),c.e||(I.e=Rn(r+w-y,t+v/2-u/2,p,u,n,i,a))),I},rc=(e,t,r,o="mouse")=>{if(e.locked)return{};let n={};if(e.type==="freedraw"||re(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=pg:a[0]>0&&a[1]<0?n=Ey:a[0]>0&&a[1]>0?n=pg:a[0]<0&&a[1]>0?n=Ey:a[0]<0&&a[1]<0&&(n=pg)}}else G(e)?n=tC:Q(e)&&(n={rotation:!0});let i=re(e)?zi+8:zi;return Tl(te(e,r,!0),e.angle,t,o,n,i)},_m=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let r=e[0];return re(r)?r.points.length>2:!0}});var hg,wy,Dm,Rm,ug,rC,Nm,vy=j(()=>{"use strict";f();oc();hg=(e,t,r)=>t>=e[0]&&t<=e[0]+e[2]&&r>=e[1]&&r<=e[1]+e[3],wy=(e,t,r,o,n,i,a)=>{if(!r.selectedElementIds[e.id])return!1;let{rotation:l,...s}=rc(e,i,t,a);if(l&&hg(l,o,n))return"rotation";let c=Object.keys(s).filter(d=>{let m=s[d];return m?hg(m,o,n):!1});return c.length>0?c[0]:!1},Dm=(e,t,r,o,n,i,a)=>e.reduce((l,s)=>{if(l)return l;let c=wy(s,a,t,r,o,n,i);return c?{element:s,transformHandleType:c}:null},null),Rm=([e,t,r,o],n,i,a,l)=>{let s=Tl([e,t,r,o,(e+r)/2,(t+o)/2],0,a,l,tc);return Object.keys(s).find(d=>{let m=s[d];return m&&hg(m,n,i)})||!1},ug=["ns","nesw","ew","nwse"],rC=(e,t)=>{let r=ug.indexOf(e);if(r>=0){let o=Math.round(t/(Math.PI/4));e=ug[(r+o)%ug.length]}return e},Nm=e=>{let{element:t,transformHandleType:r}=e,o=t&&Math.sign(t.height)*Math.sign(t.width)===-1,n=null;switch(r){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":o?n="nesw":n="nwse";break;case"ne":case"sw":o?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&t&&(n=rC(n,t.angle)),n?`${n}-resize`:""}});var Om,gg,oC,nC,fg,iC,aC,lC,bg,sC,xg,Eg,yg=j(()=>{"use strict";f();U();ws();Rt();at();ce();We();z();Jr();Jn();lt();Qt();Om=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e,gg=(e,t,r,o,n,i,a,l,s,c,d)=>{if(r.length===1){let[m]=r;return t==="rotation"?(oC(m,o,l,s,n),So(m,o)):G(m)&&(t==="nw"||t==="ne"||t==="sw"||t==="se")?(aC(m,o,t,i,l,s),So(m,o)):t&&lC(e,a,m,o,t,i,l,s),!0}else if(r.length>1){if(t==="rotation")return sC(e,r,o,l,s,n,c,d),!0;if(t==="nw"||t==="ne"||t==="sw"||t==="se")return bg(e,r,o,t,i,l,s),!0}return!1},oC=(e,t,r,o,n)=>{let[i,a,l,s]=te(e,t),c=(i+l)/2,d=(a+s)/2,m;Q(e)?m=0:(m=5*Math.PI/2+Math.atan2(o-d,r-c),n&&(m+=No/2,m-=m%No),m=Om(m));let p=wn(e);if(F(e,{angle:m}),p){let u=ut.getScene(e)?.getElement(p);u&&!Te(e)&&F(u,{angle:m})}},nC=(e,t,r,o)=>re(e)||Lt(e)?{points:ei(0,t,ei(1,r,e.points,o),o)}:{},fg=(e,t,r)=>{let o=e.width;if(Ne(e)){let a=st(e,t);a&&(o=fr(a,e))}let i=e.fontSize*(r/o);return i<Jc?null:{size:i}},iC=(e,t)=>({n:/^(n|ne|nw)$/.test(e)||t&&/^(s|se|sw)$/.test(e),s:/^(s|se|sw)$/.test(e)||t&&/^(n|ne|nw)$/.test(e),w:/^(w|nw|sw)$/.test(e)||t&&/^(e|ne|se)$/.test(e),e:/^(e|ne|se)$/.test(e)||t&&/^(w|nw|sw)$/.test(e)}),aC=(e,t,r,o,n,i)=>{let[a,l,s,c]=te(e,t),d=(a+s)/2,m=(l+c)/2,[p,u]=Ee(n,i,d,m,-e.angle),h;switch(r){case"se":h=Math.max((p-a)/(s-a),(u-l)/(c-l));break;case"nw":h=Math.max((s-p)/(s-a),(c-u)/(c-l));break;case"ne":h=Math.max((p-a)/(s-a),(c-u)/(c-l));break;case"sw":h=Math.max((s-p)/(s-a),(u-l)/(c-l));break}if(h>0){let x=e.width*h,E=e.height*h,v=fg(e,t,x);if(v===null)return;let[w,y,I,P]=ra(e,x,E,!1),C=(a-w)/2,_=(l-y)/2,D=(s-I)/2,H=(c-P)/2,[A,M]=xd(iC(r,o),e.x,e.y,e.angle,C,_,D,H);F(e,{fontSize:v.size,width:x,height:E,x:A,y:M})}},lC=(e,t,r,o,n,i,a,l)=>{let s=e.get(r.id),[c,d,m,p]=ra(s,s.width,s.height,!0),u=[c,d],h=[m,p],x=vs(u,h),E=Ze([a,l],x,-s.angle),[v,w,y,I]=ra(r,r.width,r.height,!0),P=y-v,C=I-w,_=h[0]-u[0],D=h[1]-u[1],H=_/P,A=D/C,M={},k=de(r,o);n.includes("e")&&(H=(E[0]-u[0])/P),n.includes("s")&&(A=(E[1]-u[1])/C),n.includes("w")&&(H=(h[0]-E[0])/P),n.includes("n")&&(A=(h[1]-E[1])/C);let O=s.width,X=s.height,Y=r.width*H,ee=r.height*A;if(i&&(Y=2*Y-O,ee=2*ee-X),t){let hr=Math.abs(Y)/O,La=Math.abs(ee)/X;if(n.length===1&&(ee*=hr,Y*=La),n.length===2){let Oi=Math.max(hr,La);Y=O*Oi*Math.sign(Y),ee=X*Oi*Math.sign(ee)}}if(k){let hr=e.get(k.id);if(hr&&(M={fontSize:hr.fontSize}),t){let La={...r,width:Y,height:ee},Oi=fg(k,o,fr(La,k));if(Oi===null)return;M={fontSize:Oi.size}}else{let La=Rd(Ge(k),k.lineHeight),Oi=Dd(k.fontSize,k.lineHeight);Y=Math.max(Y,La),ee=Math.max(ee,Oi)}}let[xe,le,V,ve]=ra(s,Y,ee,!0),Re=V-xe,mt=ve-le,Le=[...u];if(["n","w","nw"].includes(n)&&(Le=[h[0]-Math.abs(Re),h[1]-Math.abs(mt)]),n==="ne"){let hr=[u[0],h[1]];Le=[hr[0],hr[1]-Math.abs(mt)]}if(n==="sw"){let hr=[h[0],u[1]];Le=[hr[0]-Math.abs(Re),hr[1]]}t&&(["s","n"].includes(n)&&(Le[0]=x[0]-Re/2),["e","w"].includes(n)&&(Le[1]=x[1]-mt/2));let ur=Y<0,ln=ee<0;ur&&(n.includes("e")&&(Le[0]-=Math.abs(Re)),n.includes("w")&&(Le[0]+=Math.abs(Re))),ln&&(n.includes("s")&&(Le[1]-=Math.abs(mt)),n.includes("n")&&(Le[1]+=Math.abs(mt))),i&&(Le[0]=x[0]-Math.abs(Re)/2,Le[1]=x[1]-Math.abs(mt)/2);let Gt=s.angle,Do=Ze(Le,x,Gt),sn=[Le[0]+Math.abs(Re)/2,Le[1]+Math.abs(mt)/2],Ni=Ze(sn,x,Gt);Le=Ze(Do,Ni,-Gt);let Kr=[...Le],cn=s.x-xe,kt=s.y-le;Kr[0]+=cn,Kr[1]+=kt;let pS=Kr[0],uS=Kr[1],wb,vb;(re(r)||Lt(r))&&(wb=ei(1,ee,s.points,!0),vb=ei(0,Y,wb,!0));let Wn={width:Math.abs(Y),height:Math.abs(ee),x:pS,y:uS,points:vb};if("scale"in r&&"scale"in s&&F(r,{scale:[(Math.sign(V-s.x)||s.scale[0])*s.scale[0],(Math.sign(ve-s.y)||s.scale[1])*s.scale[1]]}),Te(r)&&k&&t){let hr=Wn.width/r.width*k.fontSize;if(hr<Jc)return;M.fontSize=hr}Wn.width!==0&&Wn.height!==0&&Number.isFinite(Wn.x)&&Number.isFinite(Wn.y)&&(F(r,Wn),So(r,o,{newSize:{width:Wn.width,height:Wn.height}}),k&&M!=null&&F(k,{fontSize:M.fontSize}),Ji(r,o,n,t))},bg=(e,t,r,o,n,i,a)=>{let l=t.reduce((M,k)=>{let O=e.get(k.id);return O&&M.push({orig:O,latest:k}),M},[]),s=l.reduce((M,{orig:k})=>{if(!re(k))return M;let O=wn(k);if(!O)return M;let X=e.get(O)??null;if(!Ne(X))return M;let Y=K.getBoundTextElementPosition(k,X,r);return[...M,{...X,...Y}]},[]),{minX:c,minY:d,maxX:m,maxY:p,midX:u,midY:h}=br(l.map(({orig:M})=>M).concat(s)),x=o,E={ne:[c,p],se:[c,d],sw:[m,d],nw:[m,p]},[v,w]=n?[u,h]:E[x],y=Math.max(Math.abs(i-v)/(m-c)||0,Math.abs(a-w)/(p-d)||0)*(n?2:1);if(y===0)return;let I={ne:[i>=v,a<=w],se:[i>=v,a>=w],sw:[i<=v,a>=w],nw:[i<=v,a<=w]},[P,C]=I[x].map(M=>M?1:-1),_=P<0,D=C<0,H=[];for(let{orig:M,latest:k}of l){if(G(M)&&Ne(M))continue;let O=M.width*y,X=M.height*y,Y=Om(M.angle*P*C),ee=re(M)||Lt(M),xe=M.x-v,le=M.y-w,V=_&&!ee?O:0,ve=D&&!ee?X:0,Re=v+P*(xe*y+V),mt=w+C*(le*y+ve),Le=nC(M,O*P,X*C,!1),ur={x:Re,y:mt,width:O,height:X,angle:Y,...Le};if(Zr(M)&&l.length===1&&(ur.scale=[M.scale[0]*P,M.scale[1]*C]),re(M)&&(_||D)){let Gt=el(M,M.points),Do=el({...M,x:Re,y:mt},Le.points),sn=[M.x,M.y],Ni=[Re,mt],Kr=cn=>{let kt=cn==="x"?0:1;return(Do[kt+2]-Ni[kt]-(sn[kt]-Gt[kt])*y+(Gt[kt+2]-sn[kt])*y-(Ni[kt]-Do[kt]))/2};_&&(ur.x-=Kr("x")),D&&(ur.y-=Kr("y"))}if(G(M)){let Gt=fg(M,r,O);if(!Gt)return;ur.fontSize=Gt.size}let ln=e.get(wn(M)??"");if(ln){let Gt=ln.fontSize*y;if(Gt<Jc)return;ur.boundTextFontSize=Gt}H.push({element:k,update:ur})}let A=H.map(({element:M})=>M);for(let{element:M,update:{boundTextFontSize:k,...O}}of H){let{width:X,height:Y,angle:ee}=O;F(M,O,!1),So(M,r,{simultaneouslyUpdated:A,newSize:{width:X,height:Y}});let xe=de(M,r);xe&&k&&(F(xe,{fontSize:k,angle:re(M)?void 0:ee},!1),Ji(M,r,o,!0))}ut.getScene(H[0].element)?.informMutation()},sC=(e,t,r,o,n,i,a,l)=>{let s=5*Math.PI/2+Math.atan2(n-l,o-a);i&&(s+=No/2,s-=s%No),t.filter(c=>!Q(c)).forEach(c=>{let[d,m,p,u]=te(c,r),h=(d+p)/2,x=(m+u)/2,E=e.get(c.id)?.angle??c.angle,[v,w]=Ee(h,x,a,l,s+E-c.angle);F(c,{x:c.x+(v-h),y:c.y+(w-x),angle:Om(s+E)},!1),So(c,r,{simultaneouslyUpdated:t});let y=de(c,r);y&&!Te(c)&&F(y,{x:y.x+(v-h),y:y.y+(w-x),angle:Om(s+E)},!1)}),ut.getScene(t[0])?.informMutation()},xg=(e,t,r,o,n)=>{let[i,a,l,s]=t.length===1?te(t[0],r):we(t),c=(i+l)/2,d=(a+s)/2,m=t.length===1?t[0].angle:0;switch([o,n]=Ee(o,n,c,d,-m),e){case"n":return Ee(o-(i+l)/2,n-a,0,0,m);case"s":return Ee(o-(i+l)/2,n-s,0,0,m);case"w":return Ee(o-i,n-(a+s)/2,0,0,m);case"e":return Ee(o-l,n-(a+s)/2,0,0,m);case"nw":return Ee(o-i,n-a,0,0,m);case"ne":return Ee(o-l,n-a,0,0,m);case"sw":return Ee(o-i,n-s,0,0,m);case"se":return Ee(o-l,n-s,0,0,m);default:return[0,0]}},Eg=(e,t)=>{let[,[r,o]]=t.points;return e==="nw"&&(r<0||o<0)||e==="ne"&&r>=0||e==="sw"&&r<=0||e==="se"&&(r>0||o>0)?"end":"origin"}});var wg,cC,Ty,vg,Bm,Sy=j(()=>{"use strict";f();Jr();at();We();pa();lt();Rt();ce();wg=(e,t,r,o,n,i,a)=>{let l=new Set(t),s=t.filter(m=>Q(m)).map(m=>m.id);if(s.length>0)for(let m of n.getNonDeletedElements())m.frameId!==null&&s.includes(m.frameId)&&l.add(m);let c=we(Array.from(l).map(m=>e.originalElements.get(m.id)??m)),d=cC(c,r,i,a);l.forEach(m=>{if(Ty(e,m,d),!Te(m)){let p=de(m,n.getNonDeletedElementsMap());p&&Ty(e,p,d)}So(m,n.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(l)})})},cC=(e,t,r,o)=>{let[n,i]=e,a=n+t.x+r.x,l=i+t.y+r.y;if(r.x===0||r.y===0){let[s,c]=St(n+t.x,i+t.y,o);r.x===0&&(a=s),r.y===0&&(l=c)}return{x:a-n,y:l-i}},Ty=(e,t,r)=>{let o=e.originalElements.get(t.id)??t,n=o.x+r.x,i=o.y+r.y;F(t,{x:n,y:i})},vg=(e,t,r)=>{let[o,n]=we(e);return[t-o,r-n]},Bm=(e,t,r,o,n,i,a,l,s,c,d,m=null)=>{s&&e.type!=="selection"&&(d?l=a/d:(Math.abs(i-o)>Math.abs(n-r)?{width:a,height:l}=Pm(t,l,n<r?-a:a):{width:a,height:l}=Pm(t,a,i<o?-l:l),l<0&&(l=-l)));let p=n<r?r-a:r,u=i<o?o-l:o;c&&(a+=a,l+=l,p=r-a/2,u=o-l/2),a!==0&&l!==0&&F(e,{x:p+(m?.x??0),y:u+(m?.y??0),width:a,height:l})}});var ua,Iy=j(()=>{"use strict";f();Ve();ua=(e,t)=>!!(!e.viewModeEnabled&&(e.activeTool.type!=="custom"&&(e.editingElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||pe(t,e).length))});var dC,Tg,Sg,Cy,be,ys,ky,EE,tm,ge=j(()=>{"use strict";f();pa();ce();In();at();oc();vy();yg();Sy();ce();lt();pa();Iy();dC=e=>e.reduce((t,r)=>t+r.version,0),Tg=e=>{let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e[r].versionNonce;return t>>>0},Sg=e=>{let t=5381;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)+t+o}return t>>>0},Cy=e=>e.filter(t=>!t.isDeleted&&!eo(t)),be=e=>e.filter(t=>!t.isDeleted),ys=e=>!e.isDeleted,ky=e=>be(e).map(t=>bs(t.type)?{...t,lastCommittedPoint:null}:t),EE=e=>ky(e),tm=e=>ky(e)});var ha,vl,Ig,ze,Cg,pe,ga,Pe,Qn=j(()=>{"use strict";f();ge();ce();er();z();pa();ha=e=>{let t=new Set;return e.forEach(r=>{Q(r)&&t.add(r.id)}),e.filter(r=>!(r.frameId&&t.has(r.frameId)))},vl=(e,t,r,o=!0)=>{let[n,i,a,l]=te(t,r),s=e.filter(c=>{let[d,m,p,u]=Dr(c,r),h=Ot(c,r);if(h){let[x,E,v,w]=Dr(h,r);d=Math.max(x,d),m=Math.max(E,m),p=Math.min(v,p),u=Math.min(w,u)}return c.locked===!1&&c.type!=="selection"&&!Ne(c)&&n<=d&&i<=m&&a>=p&&l>=u});return s=o?ha(s):s,s=s.filter(c=>{let d=Ot(c,r);return d?Ko(c,d,r):!0}),s},Ig=(e,t,r,o)=>{let n=new Set(t.map(i=>i.id));return e.filter(i=>{let a=ma(i,r.width,r.height,r,o);return!n.has(i.id)&&a})},ze=function(){let e=null,t=null,r=null,o=(n,i)=>(r!=null&&n===e&&i.selectedElementIds===t||(r=n.some(a=>i.selectedElementIds[a.id]),e=n,t=i.selectedElementIds),r);return o.clearCache=()=>{e=null,t=null,r=null},o}(),Cg=(e,t,r)=>{let o=Array.from(new Set(pe(e,t).map(n=>r(n))));return o.length===1?o[0]:null},pe=(e,t,r)=>{let o=[];for(let n of e.values()){if(t.selectedElementIds[n.id]){o.push(n);continue}if(r?.includeBoundTextElement&&Ne(n)&&t.selectedElementIds[n?.containerId]){o.push(n);continue}}if(r?.includeElementsInFrames){let n=[];return o.forEach(i=>{Q(i)&&Hr(e,i.id).forEach(a=>n.push(a)),n.push(i)}),n}return o},ga=(e,t)=>t.editingElement?[t.editingElement]:pe(e,t,{includeBoundTextElement:!0}),Pe=(e,t)=>wt(t.selectedElementIds,e)?t.selectedElementIds:e});var mC,kg,Yo,Ag=j(()=>{"use strict";f();ge();z();mC=(e,t)=>{let[r,o,n,i]=t,{x:a,y:l}=Dt({sceneX:r,sceneY:o},e),{x:s,y:c}=Dt({sceneX:n,sceneY:i},e);return s-a>e.width||c-l>e.height},kg=({scenePoint:e,viewportDimensions:t,zoom:r})=>({scrollX:t.width/2/r.value-e.x,scrollY:t.height/2/r.value-e.y}),Yo=(e,t)=>{if(e=Cy(e),!e.length)return{scrollX:0,scrollY:0};let[r,o,n,i]=we(e);mC(t,[r,o,n,i])&&([r,o,n,i]=Lh(e,Ue({clientX:t.scrollX,clientY:t.scrollY},t)));let a=(r+n)/2,l=(o+i)/2;return kg({scenePoint:{x:a,y:l},viewportDimensions:{width:t.width,height:t.height},zoom:t.zoom})}});var Xo,Nn,Fm=j(()=>{"use strict";f();U();Xo=e=>Math.max(ed,Math.min(e,30)),Nn=({viewportX:e,viewportY:t,nextZoom:r},o)=>{let n=e-o.offsetLeft,i=t-o.offsetTop,a=o.zoom.value,l=o.scrollX+(n-n/a),s=o.scrollY+(i-i/a),c=-(n-n/r),d=-(i-i/r);return{scrollX:l+c,scrollY:s+d,zoom:{value:r}}}});var Ve=j(()=>{"use strict";f();Qn();Ag();ks();Fm()});f();import e7,{useEffect as t7}from"react";f();import{useEffect as _S,useState as DS}from"react";f();f();import Ib from"./en-CVBEBUBY.json";import xS from"./percentages-UCQDHIQF.json";f();import{unstable_createStore as fS,useAtom as d7}from"jotai";import{useLayoutEffect as p7}from"react";var Be=Symbol(),Xt=fS();import{atom as ES,useAtomValue as yS}from"jotai";var bS=Tb({"./locales/ar-SA.json":()=>import("./ar-SA-JA6F2FMJ.json"),"./locales/az-AZ.json":()=>import("./az-AZ-GVIENQVH.json"),"./locales/bg-BG.json":()=>import("./bg-BG-YFNNHCEP.json"),"./locales/bn-BD.json":()=>import("./bn-BD-LMEIWSRD.json"),"./locales/ca-ES.json":()=>import("./ca-ES-C2WGCLOT.json"),"./locales/cs-CZ.json":()=>import("./cs-CZ-F2NDIQMB.json"),"./locales/da-DK.json":()=>import("./da-DK-WBEQB3CJ.json"),"./locales/de-DE.json":()=>import("./de-DE-VEIMCP7R.json"),"./locales/el-GR.json":()=>import("./el-GR-TKRKG5GQ.json"),"./locales/en.json":()=>import("./en-CVBEBUBY.json"),"./locales/es-ES.json":()=>import("./es-ES-TOLWEZNW.json"),"./locales/eu-ES.json":()=>import("./eu-ES-7CDRJQWJ.json"),"./locales/fa-IR.json":()=>import("./fa-IR-527E2XGU.json"),"./locales/fi-FI.json":()=>import("./fi-FI-NLQ7RQGZ.json"),"./locales/fr-FR.json":()=>import("./fr-FR-KUHO4FLU.json"),"./locales/gl-ES.json":()=>import("./gl-ES-NEXX3VBB.json"),"./locales/he-IL.json":()=>import("./he-IL-MED2VGBZ.json"),"./locales/hi-IN.json":()=>import("./hi-IN-5V633W7V.json"),"./locales/hu-HU.json":()=>import("./hu-HU-2FOZGVGR.json"),"./locales/id-ID.json":()=>import("./id-ID-I6BOLXTF.json"),"./locales/it-IT.json":()=>import("./it-IT-WKPQOK4P.json"),"./locales/ja-JP.json":()=>import("./ja-JP-VKA4ISRU.json"),"./locales/kaa.json":()=>import("./kaa-IKPRSBNY.json"),"./locales/kab-KAB.json":()=>import("./kab-KAB-IE4PHQTZ.json"),"./locales/kk-KZ.json":()=>import("./kk-KZ-MNJT6XSV.json"),"./locales/km-KH.json":()=>import("./km-KH-LADGDFXV.json"),"./locales/ko-KR.json":()=>import("./ko-KR-XD7AVF2F.json"),"./locales/ku-TR.json":()=>import("./ku-TR-4XBHKDQA.json"),"./locales/lt-LT.json":()=>import("./lt-LT-QC35R4YH.json"),"./locales/lv-LV.json":()=>import("./lv-LV-GSD5D3BA.json"),"./locales/mr-IN.json":()=>import("./mr-IN-KOLSWM7Y.json"),"./locales/my-MM.json":()=>import("./my-MM-M53KMUET.json"),"./locales/nb-NO.json":()=>import("./nb-NO-XXC6U37A.json"),"./locales/nl-NL.json":()=>import("./nl-NL-HCCJQEUO.json"),"./locales/nn-NO.json":()=>import("./nn-NO-6P7Z2PI2.json"),"./locales/oc-FR.json":()=>import("./oc-FR-JRJKPLNT.json"),"./locales/pa-IN.json":()=>import("./pa-IN-LZWLEPIB.json"),"./locales/percentages.json":()=>import("./percentages-UCQDHIQF.json"),"./locales/pl-PL.json":()=>import("./pl-PL-3WBLCXI2.json"),"./locales/pt-BR.json":()=>import("./pt-BR-O3ZPTUNW.json"),"./locales/pt-PT.json":()=>import("./pt-PT-7AQTSAFO.json"),"./locales/ro-RO.json":()=>import("./ro-RO-HJ65JYWV.json"),"./locales/ru-RU.json":()=>import("./ru-RU-P7ROIYNC.json"),"./locales/si-LK.json":()=>import("./si-LK-7ZSWVION.json"),"./locales/sk-SK.json":()=>import("./sk-SK-NXVBGLYY.json"),"./locales/sl-SI.json":()=>import("./sl-SI-VFTWOYNP.json"),"./locales/sv-SE.json":()=>import("./sv-SE-YONBLQNW.json"),"./locales/ta-IN.json":()=>import("./ta-IN-BSETPMLX.json"),"./locales/th-TH.json":()=>import("./th-TH-URTRDITB.json"),"./locales/tr-TR.json":()=>import("./tr-TR-N5SCAVTB.json"),"./locales/uk-UA.json":()=>import("./uk-UA-LBCYVSQZ.json"),"./locales/vi-VN.json":()=>import("./vi-VN-POZWLIUU.json"),"./locales/zh-CN.json":()=>import("./zh-CN-FUF5V3SC.json"),"./locales/zh-HK.json":()=>import("./zh-HK-OB4VW42C.json"),"./locales/zh-TW.json":()=>import("./zh-TW-5JPVKOM7.json")});var wS=85,Ro={code:"en",label:"English"},_a=[Ro,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>xS[e.code]>=wS).sort((e,t)=>e.label>t.label?1:-1)],Yc="__test__";T.DEV&&_a.unshift({code:Yc,label:"test language"},{code:`${Yc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Pa=Ro,Vc={},Kc=async e=>{if(Pa=e,document.documentElement.dir=Pa.rtl?"rtl":"ltr",document.documentElement.lang=Pa.code,e.code.startsWith(Yc))Vc={};else try{Vc=await bS(`./locales/${Pa.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),Vc=Ib}Xt.set(Cb,e.code)},dn=()=>Pa,Sb=(e,t)=>{for(let r=0;r<t.length;++r){let o=t[r];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},b=(e,t,r)=>{if(Pa.code.startsWith(Yc))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),n=Sb(Vc,o)||Sb(Ib,o)||r;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)n=n.replace(`{{${i}}}`,String(t[i]));return n},Cb=ES(Ro.code),yt=()=>{let e=yS(Cb,Be);return{t:b,langCode:e}};import{useState as AS,useEffect as MS}from"react";f();import vS from"react";import{jsx as _u}from"react/jsx-runtime";var TS=({size:e="1em",circleWidth:t=8,synchronized:r=!1})=>{let n=-(vS.useRef(Date.now()).current%1600);return _u("div",{className:"Spinner",children:_u("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":r?`${n}ms`:0},children:_u("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},Ut=TS;U();import LS from"clsx";import{jsx as zu,jsxs as PS}from"react/jsx-runtime";var ld=({delay:e,theme:t})=>{let[r,o]=AS(!!e);return MS(()=>{if(!e)return;let n=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(n)},[e]),r?null:PS("div",{className:LS("LoadingMessage",{"LoadingMessage--dark":t===oe.DARK}),children:[zu("div",{children:zu(Ut,{})}),zu("div",{className:"LoadingMessage-text",children:b("labels.loadingScene")})]})};import{jsx as RS}from"react/jsx-runtime";var ox=e=>{let[t,r]=DS(!0);return _S(()=>{let o=async()=>{await Kc(n),r(!1)},n=_a.find(i=>i.code===e.langCode)||Ro;o()},[e.langCode]),t?RS(ld,{theme:e.theme}):e.children};f();import an,{useContext as Di}from"react";import{flushSync as eb}from"react-dom";import BP from"roughjs/bin/rough";import $5 from"clsx";import{nanoid as FP}from"nanoid";f();f();Ve();ue();f();import Mg,{useEffect as pC,useRef as Ay,useState as uC}from"react";import My from"clsx";qn();z();import{jsx as nc,jsxs as ic}from"react/jsx-runtime";var ae=Mg.forwardRef((e,t)=>{let{id:r}=Bt(),o=Mg.useRef(null);Mg.useImperativeHandle(t,()=>o.current);let n=`ToolIcon_size_${e.size}`,[i,a]=uC(!1),l=Ay(!0),s=async d=>{let m="onClick"in e&&e.onClick?.(d);if(Oo(m))try{a(!0),await m}catch(p){if(p instanceof zo)console.warn(p);else throw p}finally{l.current&&a(!1)}};pC(()=>(l.current=!0,()=>{l.current=!1}),[]);let c=Ay(null);if(e.type==="button"||e.type==="icon"||e.type==="submit"){let d=e.type==="icon"?"button":e.type;return ic("button",{className:My("ToolIcon_type_button",n,e.className,e.visible&&!e.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!e.hidden,"ToolIcon--selected":e.selected,"ToolIcon--plain":e.type==="icon"}),style:e.style,"data-testid":e["data-testid"],hidden:e.hidden,title:e.title,"aria-label":e["aria-label"],type:d,onClick:s,ref:o,disabled:i||e.isLoading,children:[(e.icon||e.label)&&ic("div",{className:"ToolIcon__icon","aria-hidden":"true",children:[e.icon||e.label,e.keyBindingLabel&&nc("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel}),e.isLoading&&nc(Ut,{})]}),e.showAriaLabel&&ic("div",{className:"ToolIcon__label",children:[e["aria-label"]," ",i&&nc(Ut,{})]}),e.children]})}return ic("label",{className:My("ToolIcon",e.className),title:e.title,onPointerDown:d=>{c.current=d.pointerType||null,e.onPointerDown?.({pointerType:d.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{c.current=null})},children:[nc("input",{className:`ToolIcon_type_radio ${n}`,type:"radio",name:e.name,"aria-label":e["aria-label"],"aria-keyshortcuts":e["aria-keyshortcuts"],"data-testid":e["data-testid"],id:`${r}-${e.id}`,onChange:()=>{e.onChange?.({pointerType:c.current})},checked:e.checked,ref:o}),ic("div",{className:"ToolIcon__icon",children:[e.icon,e.keyBindingLabel&&nc("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel})]})]})});ae.defaultProps={visible:!0,className:"",size:"medium"};ae.displayName="ToolButton";Ye();ge();We();Nr();Qt();Jr();ce();z();f();U();import yr from"react";import hC from"open-color";import gC from"clsx";import{Fragment as Ae,jsx as g,jsxs as N}from"react/jsx-runtime";var Mo=e=>"var(--icon-fill-color)",Ly=e=>e===oe.LIGHT?hC.white:"#1e1e1e",L=(e,t=512)=>{let{width:r=512,height:o=r,mirror:n,style:i,...a}=typeof t=="number"?{width:t}:t;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${r} ${o}`,className:gC({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},q={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},me={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ZH=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:3,y:8,width:18,height:4,rx:1}),g("line",{x1:12,y1:8,x2:12,y2:21}),g("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),g("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),q),Hm=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),g("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),g("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),q),Py=L(N("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),q),_y=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"12",cy:"19",r:"1"}),g("circle",{cx:"12",cy:"5",r:"1"})]}),q),Dy=L(N("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),g("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),g("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),q),fa=L(N("g",{children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:g("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),g("g",{mask:"url(#UnlockedIcon)",children:g("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),me),Sl=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),g("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),me),Ry=L(N(Ae,{children:[g("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),g("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),Ny=L(N(Ae,{children:[g("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),g("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),Oy=L(N(Ae,{children:[g("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),g("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),jH=L(g("g",{fill:"currentColor",children:g("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),By=L(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),g("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Fy=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),q),Hy=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),q),zy=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),q),Gy=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),q),Uy=L(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),me),Wy=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),g("path",{d:"M16 7h4"}),g("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),q),Il=L(N("g",{strokeWidth:"1.25",children:[g("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),g("path",{d:"m11.25 5.417 3.333 3.333"})]}),me),Vy=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),g("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),g("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),g("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),g("polyline",{points:"5 20 11 4 13 4 20 20"})]}),q),Yy=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M12.5 6.667h.01"}),g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),g("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),g("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),me),Ky=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),g("path",{d:"M18 13.3l-6.3 -6.3"})]}),q),Lg=L(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),me),Pg=L(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),me),$y=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 21l-6 -6"}),g("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),g("path",{d:"M3 4v4h4"})]}),q),Lo=L(g("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),me),Xy=L(N("g",{strokeWidth:"1.25",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),me),ac=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),me),lc=L(g("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),me),sc=L(g("g",{stroke:"currentColor",strokeLinejoin:"round",children:g("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...me,strokeWidth:1.5}),zm=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),g("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),q),ba=L(g("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),me),Cl=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),q),Zy=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),q),_g=L(g("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),me),Gm=L(g("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),me),jy=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),g("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),me),qy=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),g("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),q),Jy=L(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),cc=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),g("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),me),Qy=L("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),e2=L("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),kl=L(g("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),me),qH=L("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),t2=L("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Um=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),g("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),g("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),q),Wm=L(N("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8h.01"}),g("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),g("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),g("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),g("path",{d:"M19 16v6"}),g("path",{d:"M22 19l-3 3l-3 -3"})]}),q),r2=L("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),JH=L("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),QH=L("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),o2=L("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),ez=L("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Dg=L(g("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),me),Rg=L(g("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),me),n2=L("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),i2=L(g("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),me),tz=L("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),rz=L("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),oz=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),g("path",{d:"M12 14v-11"}),g("path",{d:"M9 6l3 -3l3 3"})]}),q),nz=L(N(Ae,{children:[g("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),g("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),iz=L(g("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),Ng=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{d:"M13.889 4.167H8.333c-.767 0-1.389.622-1.389 1.389v5.555c0 .767.622 1.389 1.39 1.389h5.555c.767 0 1.389-.622 1.389-1.389V5.556c0-.767-.622-1.39-1.39-1.39Z",fill:"currentColor"}),g("path",{d:"M12.5 12.5v1.389a1.389 1.389 0 0 1-1.389 1.389H5.556a1.389 1.389 0 0 1-1.39-1.39V8.334a1.389 1.389 0 0 1 1.39-1.389h1.388"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Og=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.944 12.5H12.5v1.389a1.389 1.389 0 0 1-1.389 1.389H5.556a1.389 1.389 0 0 1-1.39-1.39V8.334a1.389 1.389 0 0 1 1.39-1.389h1.388",fill:"currentColor"}),g("path",{d:"M13.889 4.167H8.333c-.767 0-1.389.621-1.389 1.389v5.555c0 .767.622 1.389 1.39 1.389h5.555c.767 0 1.389-.622 1.389-1.389V5.556c0-.768-.622-1.39-1.39-1.39Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Bg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M8.775 6.458h2.45a2.316 2.316 0 0 1 2.317 2.316v2.452a2.316 2.316 0 0 1-2.316 2.316H8.774a2.316 2.316 0 0 1-2.317-2.316V8.774a2.316 2.316 0 0 1 2.317-2.316Z",fill:"currentColor"}),g("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316ZM12.108 3.125h2.45a2.316 2.316 0 0 1 2.317 2.316v2.451a2.316 2.316 0 0 1-2.316 2.316h-2.451a2.316 2.316 0 0 1-2.316-2.316v-2.45a2.316 2.316 0 0 1 2.316-2.317Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Fg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",children:[g("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316Z",stroke:"currentColor",strokeWidth:"1.25"}),g("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"SendToBackIcon",fill:"#fff",children:g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.167 5.833v2.06a2.941 2.941 0 0 0 2.94 2.94h2.06v.393a2.941 2.941 0 0 1-2.941 2.94h-.393v-2.058a2.941 2.941 0 0 0-2.94-2.941h-2.06v-.393a2.941 2.941 0 0 1 2.942-2.94h.392Z"})}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.167 5.833v2.06a2.941 2.941 0 0 0 2.94 2.94h2.06v.393a2.941 2.941 0 0 1-2.941 2.94h-.393v-2.058a2.941 2.941 0 0 0-2.94-2.941h-2.06v-.393a2.941 2.941 0 0 1 2.942-2.94h.392Z",fill:"currentColor"}),g("path",{d:"M9.167 5.833h1.25v-1.25h-1.25v1.25Zm5 5h1.25v-1.25h-1.25v1.25Zm-3.334 3.334h-1.25v1.25h1.25v-1.25Zm-5-5h-1.25v1.25h1.25v-1.25Zm2.084-3.334v2.06h2.5v-2.06h-2.5Zm0 2.06a4.191 4.191 0 0 0 4.19 4.19v-2.5a1.691 1.691 0 0 1-1.69-1.69h-2.5Zm4.19 4.19h2.06v-2.5h-2.06v2.5Zm.81-1.25v.393h2.5v-.393h-2.5Zm0 .393c0 .933-.758 1.69-1.691 1.69v2.5a4.191 4.191 0 0 0 4.19-4.19h-2.5Zm-1.691 1.69h-.393v2.5h.393v-2.5Zm.857 1.25v-2.058h-2.5v2.059h2.5Zm0-2.058a4.191 4.191 0 0 0-4.19-4.191v2.5c.933 0 1.69.757 1.69 1.69h2.5Zm-4.19-4.191h-2.06v2.5h2.06v-2.5Zm-.81 1.25v-.393h-2.5v.393h2.5Zm0-.393c0-.934.758-1.69 1.692-1.69v-2.5a4.191 4.191 0 0 0-4.192 4.19h2.5Zm1.692-1.69h.392v-2.5h-.392v2.5Z",fill:"currentColor",mask:"url(#SendToBackIcon)"}),g("path",{d:"M12.108 3.125h2.45a2.316 2.316 0 0 1 2.317 2.316v2.451a2.316 2.316 0 0 1-2.316 2.316h-2.451a2.316 2.316 0 0 1-2.316-2.316v-2.45a2.316 2.316 0 0 1 2.316-2.317Z",stroke:"currentColor",strokeWidth:"1.25"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Hg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),zg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Gg=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Ug=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),a2=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),l2=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Wg=L(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),g("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),me),Vg=L(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),g("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),me),Vm=L(N("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"9",cy:"7",r:"4"}),g("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),g("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),g("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),q),az=L("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),lz=L("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),ro=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M15 5 5 15M5 5l10 10"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),sz=L("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),cz=L("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),dz=L("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Yg=yr.memo(({theme:e})=>L(N(Ae,{children:[g("path",{d:"M25 26H111V111H25",fill:Mo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Mo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Mo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Mo(e),strokeWidth:"2"}),N("g",{fill:Ly(e),stroke:Mo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Kg=yr.memo(({theme:e})=>L(N(Ae,{children:[g("path",{d:"M25 26H111V111H25",fill:Mo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Mo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Mo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Mo(e),strokeWidth:"2"}),N("g",{fill:Ly(e),stroke:Mo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),g("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),s2=L(g("g",{strokeWidth:1.25,children:g("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),me),c2=L(N(Ae,{children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),g("g",{mask:"url(#FillHachureIcon)",children:g("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),me),d2=L(N(Ae,{children:[N("g",{clipPath:"url(#a)",children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:g("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("g",{mask:"url(#FillCrossHatchIcon)",children:g("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),m2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...me,fill:"currentColor"}),$g=L(g(Ae,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),p2=L(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),me),u2=L(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),me),mz=yr.memo(({theme:e})=>L(g("path",{d:"M6 10H34",stroke:Mo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),h2=L(N("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12h2"}),g("path",{d:"M17 12h2"}),g("path",{d:"M11 12h2"})]}),q),g2=L(N("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M8 12v.01"}),g("path",{d:"M12 12v.01"}),g("path",{d:"M16 12v.01"}),g("path",{d:"M20 12v.01"})]}),q),f2=L(g("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),me),b2=L(g("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),me),x2=L(g("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),me),E2=L(N("svg",{strokeWidth:"1.5",children:[g("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),g("path",{d:"M13.3333 3.33331V3.34331"}),g("path",{d:"M16.6667 3.33331V3.34331"}),g("path",{d:"M16.6667 6.66669V6.67669"}),g("path",{d:"M16.6667 10V10.01"}),g("path",{d:"M3.33334 13.3333V13.3433"}),g("path",{d:"M16.6667 13.3333V13.3433"}),g("path",{d:"M3.33334 16.6667V16.6767"}),g("path",{d:"M6.66666 16.6667V16.6767"}),g("path",{d:"M10 16.6667V16.6767"}),g("path",{d:"M13.3333 16.6667V16.6767"}),g("path",{d:"M16.6667 16.6667V16.6767"})]}),me),y2=L(N("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),g("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),g("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),g("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),g("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),g("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),g("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),g("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),g("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),g("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),g("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),g("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),q),w2=L(g("path",{d:"M6 10H34",stroke:"currentColor",strokeWidth:2,fill:"none"}),{width:40,height:20}),v2=yr.memo(({flip:e=!1})=>L(N("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[g("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),g("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),Xg=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),T2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[g("path",{d:"M26 10L6 10"}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),S2=yr.memo(({flip:e=!1})=>L(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:g("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),I2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),C2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[g("path",{d:"M6,9.5H27"}),g("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),k2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),A2=yr.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),M2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),L2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),P2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),_2=L(g(Ae,{children:g("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),Zg=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),q),D2=L(g(Ae,{children:g("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),me),R2=L(N(Ae,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),N2=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),g("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),q),O2=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),g("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),q),B2=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),q),F2=yr.memo(({theme:e})=>L(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),g("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),q)),H2=yr.memo(({theme:e})=>L(N("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),g("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),q)),z2=yr.memo(({theme:e})=>L(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),g("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),g("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),q)),G2=L(g("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),pz=L(g("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Ym=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),g("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),q),jg=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M7 11l5 5l5 -5"}),g("path",{d:"M12 4l0 12"})]}),q),Km=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),g("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),q),U2=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M9.15 14.85l8.85 -10.85"}),g("path",{d:"M6 4l8.85 10.85"})]}),q),W2=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),g("path",{d:"M12 17l0 .01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),q),uz=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),q),hz=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),q),gz=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),q),V2=L(N(Ae,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"})]}),q),Y2=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l6 6"}),g("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),q),K2=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l-4 7h8z"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),q),$m=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 7l16 0"}),g("path",{d:"M4 17l16 0"}),g("path",{d:"M7 4l0 16"}),g("path",{d:"M17 4l0 16"})]}),q),Xm=L(g("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),Al=L(N("g",{strokeWidth:"1.25",children:[g("path",{d:"M4.16602 10H15.8327"}),g("path",{d:"M12.5 13.3333L15.8333 10"}),g("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),me),Zm=L(N("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),g("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),Ml=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),q),fz=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),q),dc=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),g("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),g("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),g("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),g("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),g("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),q),$2=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),g("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),g("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),g("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),q),Ll=L(N("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),g("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),q),X2=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),g("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),g("path",{d:"M3 3l18 18"})]}),q),Z2=L(N("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),q),j2=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),q),jm=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),g("path",{d:"M21 21l-6 -6"})]}),q),q2=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),g("path",{d:"M12 7v5l3 3"}),g("path",{d:"M19 16l-2 3h4l-2 3"})]}),q),J2=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),g("path",{d:"M5 10a7 7 0 0 0 14 0"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),q),Q2=L(N("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 3l18 18"}),g("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),g("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),q),qm=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),q),ew=L(N("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),g("path",{d:"M12 20v.01"}),g("path",{d:"M16 20v.01"}),g("path",{d:"M8 20v.01"}),g("path",{d:"M4 20v.01"}),g("path",{d:"M4 16v.01"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M4 8v.01"}),g("path",{d:"M4 4v.01"}),g("path",{d:"M8 4v.01"}),g("path",{d:"M12 4v.01"}),g("path",{d:"M16 4v.01"}),g("path",{d:"M20 4v.01"}),g("path",{d:"M20 8v.01"}),g("path",{d:"M20 12v.01"}),g("path",{d:"M20 16v.01"}),g("path",{d:"M20 20v.01"})]}),q),tw=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3v18"}),g("path",{d:"M19 21v-18"}),g("path",{d:"M5 7h14"}),g("path",{d:"M5 15h14"}),g("path",{d:"M8 13v4"}),g("path",{d:"M11 13v4"}),g("path",{d:"M16 13v4"}),g("path",{d:"M14 5v4"}),g("path",{d:"M11 5v4"}),g("path",{d:"M8 5v4"}),g("path",{d:"M3 21h18"})]}),q),rw=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 12l18 0"}),g("path",{d:"M7 16l10 0l-10 5l0 -5"}),g("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),q),ow=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l0 18"}),g("path",{d:"M16 7l0 10l5 0l-5 -10"}),g("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),q),qg=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),g("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),g("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),q),Jm=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),g("path",{d:"M22 22l-3 -3"}),g("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),g("path",{d:"M3 11v-1"}),g("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),g("path",{d:"M10 3h1"}),g("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),q),nw=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),g("path",{d:"M10 15l2 6l2 -6"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),q),iw=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),g("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),g("path",{d:"M11 21v-6l3 6v-6"})]}),q),aw=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),g("path",{d:"M4 8l5 0"}),g("path",{d:"M15 8l4 0"})]}),q),lw=L(N("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),g("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),g("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),q),sw=L(N("g",{stroke:"currentColor",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...q,strokeWidth:1.5}),bz=L(N("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12l10 0"}),g("path",{d:"M10 12l4 4"}),g("path",{d:"M10 12l4 -4"}),g("path",{d:"M4 4l0 16"})]}),q),cw=L(N("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),g("path",{d:"M10 9l5 3l-5 3z"})]}),q);import{jsx as bC}from"react/jsx-runtime";var fC=(e,t)=>{let r=new Set(pe(e.filter(o=>Q(o)),t).map(o=>o.id));return{elements:e.map(o=>t.selectedElementIds[o.id]?ne(o,{isDeleted:!0}):o.frameId&&r.has(o.frameId)?ne(o,{isDeleted:!0}):Ne(o)&&t.selectedElementIds[o.containerId]?ne(o,{isDeleted:!0}):o),appState:{...t,selectedElementIds:{},selectedGroupIds:{}}}},dw=(e,t)=>{if(e.editingGroupId){let r=Je(be(t),e.editingGroupId);if(r.length)return{...e,selectedElementIds:{[r[0].id]:!0}}}return e},mc=B({name:"deleteSelectedElements",label:"labels.delete",icon:Lo,trackEvent:{category:"element",action:"delete"},perform:(e,t,r,o)=>{if(t.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=t.editingLinearElement,d=o.scene.getNonDeletedElementsMap(),m=K.getElement(a,d);if(!m||l==null)return!1;if(m.points.length<2){let u=e.map(x=>x.id===m.id?ne(x,{isDeleted:!0}):x),h=dw(t,u);return{elements:u,appState:{...h,editingLinearElement:null},commitToHistory:!1}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(m.points.length-1)?null:c};return K.deletePoints(m,l),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},commitToHistory:!0}}let{elements:n,appState:i}=fC(e,t);return Qa(n,e.filter(({id:a})=>t.selectedElementIds[a])),i=dw(i,n),{elements:n,appState:{...i,activeTool:Xe(t,{type:"selection"}),multiElement:null,activeEmbeddable:null},commitToHistory:ze(be(e),t)}},keyTest:(e,t,r)=>(e.key===S.BACKSPACE||e.key===S.DELETE)&&!e[S.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:r})=>bC(ae,{type:"button",icon:Lo,title:b("labels.delete"),"aria-label":b("labels.delete"),onClick:()=>r(null),visible:ze(be(e),t)})});f();f();ce();wo();Nr();Ve();Jn();z();var Jg=(e,t)=>e.frameId===t||e.id===t,pw=(e,t,r)=>{let o=[],n=[],i=null,a=-1,l=$(r||pe(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let s=e[a];l.get(s.id)?(n.length&&(o=o.concat(n),n=[]),o.push(a),i=a+1):s.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return o},xC=e=>{let t=0;return e.reduce((r,o,n)=>(n>0&&e[n-1]!==o-1&&(t=++t),(r[t]||(r[t]=[])).push(o),r),[])},mw=(e,t,r)=>{if("containerId"in e&&e.containerId)if(r==="left"){let o=ut.getScene(e).getElement(e.containerId);if(o)return t.indexOf(o)}else return t.indexOf(e);else{let o=e.boundElements?.find(n=>n.type!=="arrow")?.id;if(o){if(r==="left")return t.indexOf(e);let n=ut.getScene(e).getElement(o);if(n)return t.indexOf(n)}}},EC=(e,t)=>{let r=-1,o=-1;return e.forEach((n,i)=>{Jg(n,t)&&(r===-1&&(r=i),o=i)}),r===-1?[]:e.slice(r,o+1)},yC=(e,t,r,o,n)=>{let i=t[r],a=m=>m.isDeleted?!1:n?m.frameId===n:e.editingGroupId?m.groupIds.includes(e.editingGroupId):!0,l=o==="left"?Vu(t,m=>a(m),Math.max(0,r-1)):Wu(t,m=>a(m),r+1),s=t[l];if(!s)return-1;if(e.editingGroupId){if(i?.groupIds.join("")===s?.groupIds.join(""))return mw(s,t,o)??l;if(!s?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(s.frameId||Q(s))){let m=EC(t,s.frameId||s.id);return o==="left"?t.indexOf(m[0]):t.indexOf(m[m.length-1])}if(!s.groupIds.length)return mw(s,t,o)??l;let c=e.editingGroupId?s.groupIds[s.groupIds.indexOf(e.editingGroupId)-1]:s.groupIds[s.groupIds.length-1],d=Je(t,c);return d.length?o==="left"?t.indexOf(d[0]):t.indexOf(d[d.length-1]):l},uw=(e,t)=>t.reduce((r,o)=>{let n=e[o];return r.set(n.id,n),r},new Map),hw=(e,t,r)=>{let o=pw(e,t),n=uw(e,o),i=xC(o);r==="right"&&(i=i.reverse());let a=new Set(o.filter(l=>Q(e[l])).map(l=>e[l].id));return i.forEach((l,s)=>{let c=l[0],d=l[l.length-1],m=r==="left"?c:d,p=l.some(w=>{let y=e[w];return y.frameId&&a.has(y.frameId)})?null:e[m]?.frameId,u=yC(t,e,m,r,p);if(u===-1||m===u)return;let h=r==="left"?e.slice(0,u):e.slice(0,c),x=e.slice(c,d+1),E=r==="left"?e.slice(u,c):e.slice(d+1,u+1),v=r==="left"?e.slice(d+1):e.slice(u+1);e=r==="left"?[...h,...x,...E,...v]:[...h,...E,...x,...v]}),qt(e,n),e},gw=(e,t,r,o,n)=>{let i=pw(e,t,n),a=uw(e,i),l=[],s,c;if(r==="left"){if(o)s=Wu(e,h=>Jg(h,o));else if(t.editingGroupId){let h=Je(e,t.editingGroupId);if(!h.length)return e;s=e.indexOf(h[0])}else s=0;c=i[i.length-1]}else{if(o)c=Vu(e,h=>Jg(h,o));else if(t.editingGroupId){let h=Je(e,t.editingGroupId);if(!h.length)return e;c=e.indexOf(h[h.length-1])}else c=e.length-1;s=i[0]}s===-1&&(s=0);for(let h=s;h<c+1;h++)i.includes(h)||l.push(e[h]);let d=Array.from(a.values()),m=e.slice(0,s),p=e.slice(c+1),u=r==="left"?[...m,...d,...l,...p]:[...m,...l,...d,...p];return qt(u,a),u};function fw(e,t,r,o){let n=$(pe(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&Q(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(Q(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let d=i.frameChildren.get(c.frameId)||[];d.push(c),i.frameChildren.set(c.frameId,d)}let l=e,s=Array.from(i.frameChildren.entries());for(let[c,d]of s)l=o(e,t,r,c,d);return o(l,t,r,null,i.regularElements)}var bw=(e,t)=>hw(e,t,"left"),xw=(e,t)=>hw(e,t,"right"),Ew=(e,t)=>fw(e,t,"left",gw),yw=(e,t)=>fw(e,t,"right",gw);ue();z();Ye();U();import{jsx as Qm}from"react/jsx-runtime";var Qg=B({name:"sendBackward",label:"labels.sendBackward",icon:Og,trackEvent:{category:"element"},perform:(e,t)=>({elements:bw(e,t),appState:t,commitToHistory:!0}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===he.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Qm("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.sendBackward")} \u2014 ${R("CtrlOrCmd+[")}`,children:Og})}),ef=B({name:"bringForward",label:"labels.bringForward",icon:Ng,trackEvent:{category:"element"},perform:(e,t)=>({elements:xw(e,t),appState:t,commitToHistory:!0}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===he.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Qm("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.bringForward")} \u2014 ${R("CtrlOrCmd+]")}`,children:Ng})}),tf=B({name:"sendToBack",label:"labels.sendToBack",icon:Fg,trackEvent:{category:"element"},perform:(e,t)=>({elements:Ew(e,t),appState:t,commitToHistory:!0}),keyTest:e=>rr?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.BRACKET_LEFT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===he.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Qm("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.sendToBack")} \u2014 ${rr?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")}`,children:Fg})}),rf=B({name:"bringToFront",label:"labels.bringToFront",icon:Bg,trackEvent:{category:"element"},perform:(e,t)=>({elements:yw(e,t),appState:t,commitToHistory:!0}),keyTest:e=>rr?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.BRACKET_RIGHT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===he.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Qm("button",{type:"button",className:"zIndexButton",onClick:r=>e(null),title:`${b("labels.bringToFront")} \u2014 ${rr?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")}`,children:Bg})});f();ue();Ye();Nr();ge();ce();Qt();Qn();var of=B({name:"selectAll",label:"labels.selectAll",icon:ew,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,r,o)=>{if(t.editingLinearElement)return!1;let n=ha(e.filter(i=>!i.isDeleted&&!(G(i)&&i.containerId)&&!i.locked)).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...t,...Kt({editingGroupId:null,selectedElementIds:n},be(e),t,o),selectedLinearElement:Object.keys(n).length===1&&re(e[0])?new K(e[0]):null},commitToHistory:!0}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.A});f();ue();Ye();ge();Ve();z();Qt();Nr();Jr();U();lt();ce();f();z();var wC=e=>{let t=e.slice(),r=new Set,o=i=>{let a=i[0]?.groupIds?.join(""),l=[i[0]],s=[];for(let c of i.slice(1))c.groupIds?.join("")===a?l.push(c):s.push(c);return s.length?[...l,...o(s)]:l},n=new Map;return t.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let l=i.groupIds[i.groupIds.length-1],s=t.slice(a).filter(c=>{let d=c?.groupIds?.some(m=>m===l);return d&&n.set(c.id,!0),d});for(let c of o(s))r.add(c)}else r.add(i)}),r.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...r]},vC=e=>{let t=gx(e),r=e.slice(),o=new Set;return r.forEach((n,i)=>{n&&(n.boundElements?.length?(o.add(n),r[i]=null,n.boundElements.forEach(a=>{let l=t.get(a.id);l&&a.type==="text"&&(o.add(l[0]),r[l[1]]=null)})):n.type==="text"&&n.containerId&&t.get(n.containerId)?.[0].boundElements?.find(l=>l.id===n.id)||(o.add(n),r[i]=null))}),o.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...o]},ww=e=>vC(wC(e));er();Qn();wo();import{jsx as SC}from"react/jsx-runtime";var nf=B({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ac,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getNonDeletedElementsMap();if(t.editingLinearElement){let i=K.duplicateSelectedPoints(t,n);return i?{elements:e,appState:i.appState,commitToHistory:!0}:!1}return{...TC(e,t),commitToHistory:!0}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.D,PanelComponent:({elements:e,appState:t,updateData:r})=>SC(ae,{type:"button",icon:ac,title:`${b("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":b("labels.duplicateSelection"),onClick:()=>r(null),visible:ze(be(e),t)})}),TC=(e,t)=>{let r=ww(e),o=new Map,n=[],i=[],a=new Map,l=new Map,s=w=>{let y=Hs(t.editingGroupId,o,w,{x:w.x+un/2,y:w.y+un/2});return l.set(y.id,y),a.set(w.id,y.id),i.push(w),n.push(y),y},c=$(pe(r,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),d=new Map,m=w=>{for(let y of w)d.set(y.id,!0);return w},p=[],u=-1;for(;++u<r.length;){let w=r[u];if(d.get(w.id))continue;let y=de(w,$(e)),I=Q(w);if(c.get(w.id)){if(w.groupIds.length||y||I){let P=_h(t,w);if(P){let C=Je(r,P).flatMap(_=>Q(_)?[...Hr(e,_.id),_]:[_]);p.push(...m([...C,...C.map(_=>s(_))]));continue}if(y){p.push(...m([w,y,s(w),s(y)]));continue}if(I){let C=Hr(r,w.id);p.push(...m([...C,w,...C.map(_=>s(_)),s(w)]));continue}}(!w.frameId||!c.has(w.frameId))&&p.push(...m([w,s(w)]))}else p.push(...m([w]))}let h=[],x=new Map;for(u=p.length;--u>=0;){let w=p[u];x.get(w.id)||(x.set(w.id,!0),h.push(w))}let E=h.reverse();qt(E,$([...i,...n])),Pd(p,i,a),Ad(p,i,a),Im(E,i,a);let v=ha(n);return{elements:E,appState:{...t,...Kt({editingGroupId:t.editingGroupId,selectedElementIds:v.reduce((w,y)=>(Ne(y)||(w[y.id]=!0),w),{})},be(E),t,null)}}};f();Zt();f();var IC=["ai","command_palette"],fe=(e,t,r,o)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.PROD||!IC.includes(e))return;T.PROD||console.info("trackEvent",{category:e,action:t,label:r,value:o}),window.sa_event&&window.sa_event(t,{category:e,label:r,value:o})}catch(n){console.error("error during analytics",n)}};f();import vw from"clsx";import{jsx as af,jsxs as CC}from"react/jsx-runtime";var Zo=e=>af("div",{className:"buttonList buttonListIcon",children:e.options.map(t=>e.type==="button"?af("button",{onClick:r=>e.onClick(t.value,r),className:vw({active:t.active??e.value===t.value}),"data-testid":t.testId,title:t.text,children:t.icon},t.text):CC("label",{className:vw({active:e.value===t.value}),title:t.text,children:[af("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});f();z();f();Zt();import kC from"clsx";import{jsx as lf}from"react/jsx-runtime";var Tw=({onChange:e,type:t,activeColor:r,topPicks:o})=>{let n;return t==="elementStroke"&&(n=$c),t==="elementBackground"&&(n=Xc),t==="canvasBackground"&&(n=Zc),o&&(n=o),n?lf("div",{className:"color-picker__top-picks",children:n.map(i=>lf("button",{className:kC("color-picker__button",{active:i===r,"is-transparent":i==="transparent"||!i}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:lf("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};f();import _w,{useEffect as Dw,useState as ZC}from"react";f();import PC from"clsx";import{useAtom as _C}from"jotai";import{useEffect as DC,useRef as RC}from"react";f();Zt();import{atom as AC}from"jotai";var gi=({palette:e,color:t})=>{for(let[r,o]of Object.entries(e))if(Array.isArray(o)){let n=o.indexOf(t);if(n>-1)return{colorName:r,shade:n}}else if(o===t)return{colorName:r,shade:null};return null},pc=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),sf=({color:e,palette:t})=>!Object.values(t).flat().includes(e),Iw=(e,t,r)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[o[t]];return sf({color:l,palette:r})}),i=new Map;return n.forEach(a=>{let l=a[o[t]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,Ab)},oo=AC(null),Sw=(e,t,r)=>(e*299+t*587+r*114)/1e3>=160?"black":"white",Cw=(e,t)=>{if(t){let i=new Option().style;if(i.color=e,i.color){let a=i.color.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),l=parseInt(a[0]),s=parseInt(a[1]),c=parseInt(a[2]);return Sw(l,s,c)}}if(e==="transparent")return"black";let r=parseInt(e.substring(1,3),16),o=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return Sw(r,o,n)};f();import{jsxs as LC}from"react/jsx-runtime";var MC=({color:e,keyLabel:t,isCustomColor:r=!1,isShade:o=!1})=>LC("div",{className:"color-picker__button__hotkey-label",style:{color:Cw(e,r)},children:[o&&"\u21E7",t]}),Pl=MC;import{jsx as uc,jsxs as kw}from"react/jsx-runtime";var Aw=({hex:e,onChange:t,palette:r})=>{let o=gi({color:e||"transparent",palette:r}),[n,i]=_C(oo),a=RC(null);if(DC(()=>{a.current&&n==="shades"&&a.current.focus()},[o,n]),o){let{colorName:l,shade:s}=o,c=r[l];if(Array.isArray(c))return uc("div",{className:"color-picker-content--default shades",children:c.map((d,m)=>kw("button",{ref:m===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:PC("color-picker__button color-picker__button--large",{active:m===s}),"aria-label":"Shade",title:`${l} - ${m+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{t(d),i("shades")},children:[uc("div",{className:"color-picker__button-outline"}),uc(Pl,{color:d,keyLabel:m+1,isShade:!0})]},m))})}return kw("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[uc("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),uc("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:b("colorPicker.noShades")})]})};f();import NC from"clsx";import{useAtom as OC}from"jotai";import{useEffect as BC,useRef as FC}from"react";import{jsx as cf,jsxs as zC}from"react/jsx-runtime";var HC=({palette:e,color:t,onChange:r,label:o,activeShade:n})=>{let i=gi({color:t||"transparent",palette:e}),[a,l]=OC(oo),s=FC(null);return BC(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),cf("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,d],m)=>{let p=(Array.isArray(d)?d[n]:d)||"transparent",u=pc[m],h=b(`colors.${c.replace(/\d+/,"")}`,null,"");return zC("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:NC("color-picker__button color-picker__button--large",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{r(p),l("baseColors")},title:`${h}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${h} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[cf("div",{className:"color-picker__button-outline"}),cf(Pl,{color:p,keyLabel:u})]},c)})})},Mw=HC;import{useAtom as jC}from"jotai";f();import GC from"clsx";import{useAtom as UC}from"jotai";import{useEffect as WC,useRef as VC}from"react";import{jsx as df,jsxs as YC}from"react/jsx-runtime";var Lw=({colors:e,color:t,onChange:r,label:o})=>{let[n,i]=UC(oo),a=VC(null);return WC(()=>{a.current&&a.current.focus()},[t,n]),df("div",{className:"color-picker-content--default",children:e.map((l,s)=>YC("button",{ref:t===l?a:void 0,tabIndex:-1,type:"button",className:GC("color-picker__button color-picker__button--large",{active:t===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{r(l),i("custom")},title:l,"aria-label":o,style:{"--swatch-color":l},children:[df("div",{className:"color-picker__button-outline"}),df(Pl,{color:l,keyLabel:s+1,isCustomColor:!0})]},s))})};f();ue();Zt();var mf=(e,t,r)=>{let o=Math.ceil(r/Bi);switch(t=t??-1,e){case"ArrowLeft":{let n=t-1;return n<0?r-1:n}case"ArrowRight":return(t+1)%r;case"ArrowDown":{let n=t+Bi;return n>=r?t%Bi:n}case"ArrowUp":{let n=t-Bi,i=n<0?Bi*o+n:n;return i>=r?void 0:i}}},KC=({e,colorObj:t,onChange:r,palette:o,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return r(o[t.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return r(n[Number(e.key)-1]),i("custom"),!0;if(pc.includes(e.key)){let l=pc.indexOf(e.key),s=Object.keys(o)[l],c=o[s],d=Array.isArray(c)?c[a]:c;return r(d),i("baseColors"),!0}return!1},Pw=({event:e,activeColorPickerSection:t,palette:r,color:o,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:d})=>{if(e[S.CTRL_OR_CMD])return!1;if(e.key===S.ESCAPE)return d(e),!0;if(e.key===S.ALT)return c(!0),!0;if(e.key===S.I)return c(),!0;let m=gi({color:o,palette:r});if(e.key===S.TAB){let p={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},u=Object.entries(p).reduce((w,[y,I])=>(I&&w.push(y),w),[]),h=u.indexOf(t),x=e.shiftKey?-1:1,E=h+x>u.length-1?0:h+x<0?u.length-1:h+x,v=u[E];return v&&a(v),v==="custom"?n(i[0]):v==="baseColors"&&(Object.entries(r).find(([y,I])=>Array.isArray(I)?I.includes(o):I===o?y:null)||n(se.black)),e.preventDefault(),e.stopPropagation(),!0}if(KC({e,colorObj:m,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(t==="shades"&&m){let{shade:p}=m,u=mf(e.key,p,Bi);if(u!==void 0)return n(r[m.colorName][u]),!0}if(t==="baseColors"&&m){let{colorName:p}=m,u=Object.keys(r),h=u.indexOf(p),x=mf(e.key,h,u.length);if(x!==void 0){let E=u[x],v=r[E];return n(Array.isArray(v)?v[s]:v),!0}}if(t==="custom"){let p=i.indexOf(o),u=mf(e.key,p,i.length);if(u!==void 0){let h=i[u];return n(h),!0}}return!1};f();import{jsx as XC}from"react/jsx-runtime";var $C=({children:e})=>XC("div",{className:"color-picker__heading",children:e}),_l=$C;Zt();ue();U();import{jsx as xa,jsxs as ep}from"react/jsx-runtime";var Rw=({color:e,onChange:t,label:r,type:o,elements:n,palette:i,updateData:a,children:l,onEyeDropperToggle:s,onEscape:c})=>{let[d]=_w.useState(()=>o==="canvasBackground"?[]:Iw(n,o,i)),[m,p]=jC(oo),u=gi({color:e,palette:i});Dw(()=>{if(!m){let v=sf({color:e,palette:i}),w=v&&!d.includes(e);p(w?"hex":v?"custom":u?.shade!=null?"shades":"baseColors")}},[m,e,i,p,u,d]);let[h,x]=ZC(u?.shade??(o==="elementBackground"?Ra:Da));Dw(()=>{u?.shade!=null&&x(u.shade);let v=w=>{w.key===S.ALT&&s(!1)};return document.addEventListener("keyup",v,{capture:!0}),()=>{document.removeEventListener("keyup",v,{capture:!0})}},[u,s]);let E=_w.useRef(null);return xa("div",{role:"dialog","aria-modal":"true","aria-label":b("labels.colorPicker"),children:ep("div",{ref:E,onKeyDown:v=>{Pw({event:v,activeColorPickerSection:m,palette:i,color:e,onChange:t,onEyeDropperToggle:s,customColors:d,setActiveColorPickerSection:p,updateData:a,activeShade:h,onEscape:c})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content",tabIndex:-1,children:[!!d.length&&ep("div",{children:[xa(_l,{children:b("colorPicker.mostUsedCustomColors")}),xa(Lw,{colors:d,color:e,label:b("colorPicker.mostUsedCustomColors"),onChange:t})]}),ep("div",{children:[xa(_l,{children:b("colorPicker.colors")}),xa(Mw,{color:e,label:r,palette:i,onChange:t,activeShade:h})]}),ep("div",{children:[xa(_l,{children:b("colorPicker.shades")}),xa(Aw,{hex:e,onChange:t,palette:i})]}),l]})})};import*as jo from"@radix-ui/react-popover";import{useAtom as Ww}from"jotai";Zt();import c4 from"clsx";f();import{useCallback as i4,useEffect as uf,useRef as Fw,useState as a4}from"react";import{useAtom as Hw}from"jotai";ue();f();Zt();U();import{atom as e4}from"jotai";import{useEffect as t4,useRef as r4}from"react";import{createPortal as o4}from"react-dom";f();import Nw from"react";var pf=Nw.createContext(null),Me=()=>Nw.useContext(pf);f();import{useState as qC,useLayoutEffect as Ow}from"react";U();var tp=e=>{let[t,r]=qC(null),o=Ie(),{theme:n}=Me(),{container:i}=Bt();return Ow(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",o.editor.isMobile),t.classList.toggle("theme--dark",n===oe.DARK))},[t,n,o.editor.isMobile,e?.className]),Ow(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),r(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),t};f();U();import{useEffect as JC}from"react";function Dl(e,t,r){JC(()=>{function o(n){let i=n;if(!e.current)return;let a=r?.(i,e.current);if(a===!0)return;if(a===!1)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||t(i)}return document.addEventListener("pointerdown",o),document.addEventListener("touchstart",o),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("touchstart",o)}},[e,t,r])}ue();Ve();f();import{useRef as QC}from"react";var Rl=e=>{let t=QC(e);return Object.assign(t.current,e),t.current};import{jsx as n4}from"react/jsx-runtime";var fi=e4(null),Bw=({onCancel:e,onChange:t,onSelect:r,colorPickerType:o})=>{let n=tp({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Me(),a=bi(),l=wr(),s=pe(a,i),c=Rl({app:l,onCancel:e,onChange:t,onSelect:r,selectedElements:s}),{container:d}=Bt();t4(()=>{let p=m.current;if(!p||!l.canvas||!n)return;let u=!1,h=l.canvas.getContext("2d"),x=({clientX:C,clientY:_})=>{let D=h.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(_-i.offsetTop)*window.devicePixelRatio,1,1).data;return Rb(D[0],D[1],D[2])},E=({clientX:C,clientY:_,altKey:D})=>{p.style.top=`${_+20}px`,p.style.left=`${C+20}px`;let H=x({clientX:C,clientY:_});u&&c.onChange(o,H,c.selectedElements,{altKey:D}),p.style.background=H},v=()=>{c.onCancel()},w=(C,_)=>{c.onSelect(C,_)},y=C=>{u=!0,C.stopImmediatePropagation()},I=C=>{u=!1,d?.focus(),C.stopImmediatePropagation(),C.preventDefault(),w(x(C),C)},P=C=>{C.key===S.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),v())};return n.tabIndex=-1,n.focus(),E({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",P),n.addEventListener("pointerdown",y),n.addEventListener("pointerup",I),window.addEventListener("pointermove",E,{passive:!0}),window.addEventListener("blur",v),()=>{u=!1,n.removeEventListener("keydown",P),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerup",I),window.removeEventListener("pointermove",E),window.removeEventListener("blur",v)}},[c,l.canvas,n,o,d,i.offsetLeft,i.offsetTop]);let m=r4(null);return Dl(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?o4(n4("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),n):null};import l4 from"clsx";z();import{Fragment as s4,jsx as rp,jsxs as zw}from"react/jsx-runtime";var Gw=({color:e,onChange:t,label:r,colorPickerType:o})=>{let n=Ie(),[i,a]=a4(e),[l,s]=Hw(oo);uf(()=>{a(e)},[e]);let c=i4(h=>{let x=h.toLowerCase(),E=Uw(x);E&&t(E),a(x)},[t]),d=Fw(null),m=Fw(null);uf(()=>{d.current&&d.current.focus()},[l]);let[p,u]=Hw(fi,Be);return uf(()=>()=>{u(null)},[u]),zw("div",{className:"color-picker__input-label",children:[rp("div",{className:"color-picker__input-hash",children:"#"}),rp("input",{ref:l==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":r,onChange:h=>{c(h.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>s("hex"),onKeyDown:h=>{h.key!==S.TAB&&(h.key===S.ESCAPE&&m.current?.focus(),h.stopPropagation())}}),!n.editor.isMobile&&zw(s4,{children:[rp("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),rp("div",{ref:m,className:l4("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(h=>h?null:{keepOpenOnAlt:!1,onSelect:x=>t(x),colorPickerType:o}),title:`${b("labels.eyeDropper")} \u2014 ${S.I.toLocaleUpperCase()} or ${R("Alt")} `,children:Y2})]})]})};import{useRef as d4}from"react";import{jsx as no,jsxs as op}from"react/jsx-runtime";var Vw=e=>{let t=new Option().style;return t.color=e,!!t.color},Uw=e=>or(e)?e:Vw(`#${e}`)?`#${e}`:Vw(e)?e:null,m4=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=se,updateData:a})=>{let[,l]=Ww(oo),[s,c]=Ww(fi,Be),{container:d}=Bt(),m=Ie(),p=op("div",{children:[no(_l,{children:b("colorPicker.hexCode")}),no(Gw,{color:t,label:o,onChange:x=>{r(x)},colorPickerType:e})]}),u=d4(null),h=()=>{u.current?.querySelector(".color-picker-content")?.focus()};return no(jo.Portal,{container:d,children:op(jo.Content,{ref:u,className:"focus-visible-none","data-prevent-outside-click":!0,onFocusOutside:x=>{h(),x.preventDefault()},onPointerDownOutside:x=>{s&&x.preventDefault()},onCloseAutoFocus:x=>{x.stopPropagation(),x.preventDefault(),d&&!sx(document.activeElement)&&d.focus(),a({openPopup:null}),l(null)},side:m.editor.isMobile&&!m.viewport.isLandscape?"bottom":"right",align:m.editor.isMobile&&!m.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-layerUI)",backgroundColor:"var(--popup-bg-color)",maxWidth:"208px",maxHeight:window.innerHeight,padding:"12px",borderRadius:"8px",boxSizing:"border-box",overflowY:"auto",boxShadow:"0px 7px 14px rgba(0, 0, 0, 0.05), 0px 0px 3.12708px rgba(0, 0, 0, 0.0798), 0px 0px 0.931014px rgba(0, 0, 0, 0.1702)"},children:[i?no(Rw,{palette:i,color:t,onChange:x=>{r(x)},onEyeDropperToggle:x=>{c(E=>x?(E=E||{keepOpenOnAlt:!0,onSelect:r,colorPickerType:e},E.keepOpenOnAlt=!0,E):x===!1||E?null:{keepOpenOnAlt:!1,onSelect:r,colorPickerType:e})},onEscape:x=>{s?c(null):Xr(x.target)?h():a({openPopup:null})},label:o,type:e,elements:n,updateData:a,children:p}):p,no(jo.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})},p4=({label:e,color:t,type:r})=>no(jo.Trigger,{type:"button",className:c4("color-picker__button active-color",{"is-transparent":t==="transparent"||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:r==="elementStroke"?b("labels.showStroke"):b("labels.showBackground"),children:no("div",{className:"color-picker__button-outline"})}),hc=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=se,topPicks:a,updateData:l,appState:s})=>no("div",{children:op("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[no(Tw,{activeColor:t,onChange:r,type:e,topPicks:a}),no("div",{style:{width:1,height:"100%",backgroundColor:"var(--default-border-color)",margin:"0 auto"}}),op(jo.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[no(p4,{color:t,label:o,type:e}),s.openPopup===e&&no(m4,{type:e,color:t,onChange:r,label:o,elements:n,palette:i,updateData:l})]})]})});f();import Ea from"react";f();import{useLayoutEffect as u4,useRef as Yw,useEffect as Kw}from"react";z();ue();import{unstable_batchedUpdates as h4}from"react-dom";import{jsx as g4}from"react/jsx-runtime";var np=({children:e,left:t,top:r,onCloseRequest:o,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let c=Yw(null);Kw(()=>{let m=c.current;if(!m)return;m.contains(document.activeElement)||m.focus();let p=u=>{if(u.key===S.TAB){let h=hs(m),{activeElement:x}=document,E=h.findIndex(v=>v===x);x===m?(u.shiftKey?h[h.length-1]?.focus():h[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):E===0&&u.shiftKey?(h[h.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):E===h.length-1&&!u.shiftKey&&(h[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return m.addEventListener("keydown",p),()=>m.removeEventListener("keydown",p)},[]);let d=Yw(null);return u4(()=>{if(n&&c.current&&r!=null&&t!=null){let m=c.current,{width:p,height:u}=m.getBoundingClientRect();if(d.current?.top===r&&d.current?.left===t)return;d.current={top:r,left:t},p>=l?(m.style.width=`${l}px`,m.style.left="0px",m.style.overflowX="scroll"):t+p-i>l?m.style.left=`${l-p-10}px`:m.style.left=`${t}px`,u>=s?(m.style.height=`${s-20}px`,m.style.top="10px",m.style.overflowY="scroll"):r+u-a>s?m.style.top=`${s-u}px`:m.style.top=`${r}px`}},[r,t,n,l,s,i,a]),Kw(()=>{if(o){let m=p=>{c.current?.contains(p.target)||h4(()=>o(p))};return document.addEventListener("pointerdown",m,!1),()=>document.removeEventListener("pointerdown",m,!1)}},[o]),g4("div",{className:"popover",ref:c,tabIndex:-1,children:e})};ue();import f4 from"clsx";import{Fragment as x4,jsx as xi,jsxs as hf}from"react/jsx-runtime";function b4({options:e,value:t,label:r,onChange:o,onClose:n}){let i=Ea.useRef(),a=Ea.useRef(),l=Ea.useRef(null);return Ea.useEffect(()=>{a.current?a.current.focus():l.current&&l.current.focus()},[]),xi("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":r,onKeyDown:c=>{let d=e.find(m=>m.keyBinding===c.key.toLowerCase());if(!(c.metaKey||c.altKey||c.ctrlKey)&&d){let m=e.indexOf(d);l.current.children[m].focus(),c.preventDefault()}else if(c.key===S.TAB)setTimeout(()=>{let m=a.current,p=document.activeElement;m!==p&&n()},0);else if(ja(c.key)){let{activeElement:m}=document,p=dn().rtl,u=Array.prototype.indexOf.call(l.current.children,m);if(u!==-1){let h=e.length,x=u;switch(c.key){case(p?S.ARROW_LEFT:S.ARROW_RIGHT):case S.ARROW_DOWN:{x=(u+1)%h;break}case(p?S.ARROW_RIGHT:S.ARROW_LEFT):case S.ARROW_UP:{x=(h+u-1)%h;break}}l.current.children[x].focus()}c.preventDefault()}else(c.key===S.ESCAPE||c.key===S.ENTER)&&(c.preventDefault(),n());c.nativeEvent.stopImmediatePropagation(),c.stopPropagation()},children:xi("div",{className:"picker-content",ref:l,children:e.map((c,d)=>hf("button",{className:f4("picker-option",{active:t===c.value}),onClick:m=>{m.currentTarget.focus(),o(c.value)},title:`${c.text} ${c.keyBinding&&`\u2014 ${c.keyBinding.toUpperCase()}`}`,"aria-label":c.text||"none","aria-keyshortcuts":c.keyBinding||void 0,ref:m=>{m&&d===0&&(i.current=m),m&&c.value===t&&(a.current=m)},onFocus:()=>{o(c.value)},children:[c.icon,c.keyBinding&&xi("span",{className:"picker-keybinding",children:c.keyBinding})]},c.text))})})}function gf({value:e,label:t,options:r,onChange:o,group:n=""}){let[i,a]=Ea.useState(!1),l=Ea.useRef(null),s=dn().rtl;return hf("div",{children:[xi("button",{name:n,className:i?"active":"","aria-label":t,onClick:()=>a(!i),ref:l,children:r.find(c=>c.value===e)?.icon}),xi(Ea.Suspense,{fallback:"",children:i?hf(x4,{children:[xi(np,{onCloseRequest:c=>c.target!==l.current&&a(!1),...s?{right:5.5}:{left:-5.5},children:xi(b4,{options:r.filter(c=>c.showInPicker!==!1),value:e,label:t,onChange:o,onClose:()=>{a(!1),l.current?.focus()}})}),xi("div",{className:"picker-triangle"})]}):null})]})}U();ge();We();lt();ce();ue();Eo();Ve();ks();z();Ye();import{Fragment as Zw,jsx as Se,jsxs as zr}from"react/jsx-runtime";var Xw=.1,Gr=(e,t,r,o=!1)=>{let n=$(pe(e,t,{includeBoundTextElement:o}));return e.map(i=>n.get(i.id)||i.id===t.editingElement?.id?r(i):i)},vr=function(e,t,r,o,n){let i=t.editingElement,a=be(e),l=null;return i&&(l=r(i)),l||(ze(a,t)?l=Cg(o===!0?a:a.filter(c=>o(c)),t,r)??(typeof n=="function"?n(!0):n):l=typeof n=="function"?n(!1):n),l},E4=(e,t)=>Ne(t)?t:F(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2},!1),ff=(e,t,r,o,n)=>{let i=new Set;return{elements:Gr(e,t,a=>{if(G(a)){let l=o(a);i.add(l);let s=ne(a,{fontSize:l});return Yt(s,r.scene.getContainerElement(a),r.scene.getNonDeletedElementsMap()),s=E4(a,s),s}return a},!0),appState:{...t,currentItemFontSize:i.size===1?[...i][0]:n??t.currentItemFontSize},commitToHistory:!0}},y4=B({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemStrokeColor&&{elements:Gr(e,t,o=>Cs(o.type)?ne(o,{strokeColor:r.currentItemStrokeColor}):o,!0)},appState:{...t,...r},commitToHistory:!!r.currentItemStrokeColor}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>zr(Zw,{children:[Se("h3",{"aria-hidden":"true",children:b("labels.stroke")}),Se(hc,{topPicks:$c,palette:Pb,type:"elementStroke",label:b("labels.stroke"),color:vr(e,t,n=>n.strokeColor,!0,t.currentItemStrokeColor),onChange:n=>r({currentItemStrokeColor:n}),elements:e,appState:t,updateData:r})]})}),w4=B({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemBackgroundColor&&{elements:Gr(e,t,o=>ne(o,{backgroundColor:r.currentItemBackgroundColor}))},appState:{...t,...r},commitToHistory:!!r.currentItemBackgroundColor}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>zr(Zw,{children:[Se("h3",{"aria-hidden":"true",children:b("labels.background")}),Se(hc,{topPicks:Xc,palette:_b,type:"elementBackground",label:b("labels.background"),color:vr(e,t,n=>n.backgroundColor,!0,t.currentItemBackgroundColor),onChange:n=>r({currentItemBackgroundColor:n}),elements:e,appState:t,updateData:r})]})}),v4=B({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,r,o)=>(fe("element","changeFillStyle",`${r} (${o.device.editor.isMobile?"mobile":"desktop"})`),{elements:Gr(e,t,n=>ne(n,{fillStyle:r})),appState:{...t,currentItemFillStyle:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=pe(e,t),n=o.length>0&&o.every(i=>i.fillStyle==="zigzag");return zr("fieldset",{children:[Se("legend",{children:b("labels.fill")}),Se(Zo,{type:"button",options:[{value:"hachure",text:`${n?b("labels.zigzag"):b("labels.hachure")} (${R("Alt-Click")})`,icon:n?s2:c2,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:b("labels.crossHatch"),icon:d2,testId:"fill-cross-hatch"},{value:"solid",text:b("labels.solid"),icon:m2,testId:"fill-solid"}],value:vr(e,t,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:t.currentItemFillStyle),onClick:(i,a)=>{let l=a.altKey&&i==="hachure"&&o.every(s=>s.fillStyle==="hachure")?"zigzag":i;r(l)}})]})}}),T4=B({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{strokeWidth:r})),appState:{...t,currentItemStrokeWidth:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>zr("fieldset",{children:[Se("legend",{children:b("labels.strokeWidth")}),Se(Zo,{group:"stroke-width",options:[{value:nd.thin,text:b("labels.thin"),icon:$g,testId:"strokeWidth-thin"},{value:nd.bold,text:b("labels.bold"),icon:p2,testId:"strokeWidth-bold"},{value:nd.extraBold,text:b("labels.extraBold"),icon:u2,testId:"strokeWidth-extraBold"}],value:vr(e,t,o=>o.strokeWidth,o=>o.hasOwnProperty("strokeWidth"),o=>o?null:t.currentItemStrokeWidth),onChange:o=>r(o)})]})}),S4=B({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{seed:qr(),roughness:r})),appState:{...t,currentItemRoughness:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>zr("fieldset",{children:[Se("legend",{children:b("labels.sloppiness")}),Se(Zo,{group:"sloppiness",options:[{value:0,text:b("labels.architect"),icon:f2},{value:1,text:b("labels.artist"),icon:b2},{value:2,text:b("labels.cartoonist"),icon:x2}],value:vr(e,t,o=>o.roughness,o=>o.hasOwnProperty("roughness"),o=>o?null:t.currentItemRoughness),onChange:o=>r(o)})]})}),cY=B({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{strokeStyle:r})),appState:{...t,currentItemStrokeStyle:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>zr("fieldset",{children:[Se("legend",{children:b("labels.strokeStyle")}),Se(Zo,{group:"strokeStyle",options:[{value:"solid",text:b("labels.strokeStyle_solid"),icon:$g},{value:"dashed",text:b("labels.strokeStyle_dashed"),icon:h2},{value:"dotted",text:b("labels.strokeStyle_dotted"),icon:g2}],value:vr(e,t,o=>o.strokeStyle,o=>o.hasOwnProperty("strokeStyle"),o=>o?null:t.currentItemStrokeStyle),onChange:o=>r(o)})]})}),I4=B({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{opacity:r}),!0),appState:{...t,currentItemOpacity:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>zr("label",{className:"control-label",children:[b("labels.opacity"),Se("input",{type:"range",min:"0",max:"100",step:"10",onChange:o=>r(+o.target.value),value:vr(e,t,o=>o.opacity,!0,t.currentItemOpacity)??void 0})]})}),C4=B({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,r,o)=>ff(e,t,o,()=>r,r),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>zr("fieldset",{children:[Se("legend",{children:b("labels.fontSize")}),Se(Zo,{group:"font-size",options:[{value:16,text:b("labels.small"),icon:M2,testId:"fontSize-small"},{value:20,text:b("labels.medium"),icon:L2,testId:"fontSize-medium"},{value:28,text:b("labels.large"),icon:P2,testId:"fontSize-large"},{value:36,text:b("labels.veryLarge"),icon:_2,testId:"fontSize-veryLarge"}],value:vr(e,t,n=>{if(G(n))return n.fontSize;let i=de(n,o.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>G(n)||de(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:t.currentItemFontSize||At),onChange:n=>r(n)})]})}),bf=B({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Zg,trackEvent:!1,perform:(e,t,r,o)=>ff(e,t,o,n=>Math.round(1/(1+Xw)*n.fontSize)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_LEFT||e.key===S.COMMA)}),xf=B({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Zg,trackEvent:!1,perform:(e,t,r,o)=>ff(e,t,o,n=>Math.round(n.fontSize*(1+Xw))),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_RIGHT||e.key===S.PERIOD)}),k4=B({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,r,o)=>({elements:Gr(e,t,n=>{if(G(n)){let i=ne(n,{fontFamily:r,lineHeight:_r(r)});return Yt(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemFontFamily:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=[{value:it.Virgil,text:b("labels.handDrawn"),icon:Il,testId:"font-family-virgil"},{value:it.Helvetica,text:b("labels.normal"),icon:D2,testId:"font-family-normal"},{value:it.Cascadia,text:b("labels.code"),icon:R2,testId:"font-family-code"}];return zr("fieldset",{children:[Se("legend",{children:b("labels.fontFamily")}),Se(Zo,{group:"font-family",options:n,value:vr(e,t,i=>{if(G(i))return i.fontFamily;let a=de(i,o.scene.getNonDeletedElementsMap());return a?a.fontFamily:null},i=>G(i)||de(i,o.scene.getNonDeletedElementsMap())!==null,i=>i?null:t.currentItemFontFamily||Wt),onChange:i=>r(i)})]})}}),A4=B({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,r,o)=>({elements:Gr(e,t,n=>{if(G(n)){let i=ne(n,{textAlign:r});return Yt(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemTextAlign:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=o.scene.getNonDeletedElementsMap();return zr("fieldset",{children:[Se("legend",{children:b("labels.textAlign")}),Se(Zo,{group:"text-align",options:[{value:"left",text:b("labels.left"),icon:N2,testId:"align-left"},{value:"center",text:b("labels.center"),icon:O2,testId:"align-horizontal-center"},{value:"right",text:b("labels.right"),icon:B2,testId:"align-right"}],value:vr(e,t,i=>{if(G(i))return i.textAlign;let a=de(i,n);return a?a.textAlign:null},i=>G(i)||de(i,n)!==null,i=>i?null:t.currentItemTextAlign),onChange:i=>r(i)})]})}}),M4=B({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:Gr(e,t,n=>{if(G(n)){let i=ne(n,{verticalAlign:r});return Yt(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Se("fieldset",{children:Se(Zo,{group:"text-align",options:[{value:ft.TOP,text:b("labels.alignTop"),icon:Se(F2,{theme:t.theme}),testId:"align-top"},{value:ft.MIDDLE,text:b("labels.centerVertically"),icon:Se(z2,{theme:t.theme}),testId:"align-middle"},{value:ft.BOTTOM,text:b("labels.alignBottom"),icon:Se(H2,{theme:t.theme}),testId:"align-bottom"}],value:vr(e,t,n=>{if(G(n)&&n.containerId)return n.verticalAlign;let i=de(n,o.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>G(n)||de(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:ft.MIDDLE),onChange:n=>r(n)})})}),dY=B({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>ne(o,{roundness:r==="round"?{type:Ho(o.type)?rt.ADAPTIVE_RADIUS:rt.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:r},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let n=ga(be(e),t).some(i=>i.roundness?.type===rt.LEGACY);return zr("fieldset",{children:[Se("legend",{children:b("labels.edges")}),Se(Zo,{group:"edges",options:[{value:"sharp",text:b("labels.sharp"),icon:E2},{value:"round",text:b("labels.round"),icon:y2}],value:vr(e,t,i=>n?null:i.roundness?"round":"sharp",i=>i.hasOwnProperty("roundness"),i=>i?null:t.currentItemRoundness),onChange:i=>r(i)})]})}}),$w=e=>[{value:null,text:b("labels.arrowhead_none"),keyBinding:"q",icon:w2},{value:"arrow",text:b("labels.arrowhead_arrow"),keyBinding:"w",icon:Se(v2,{flip:e})},{value:"bar",text:b("labels.arrowhead_bar"),keyBinding:"e",icon:Se(S2,{flip:e})},{value:"dot",text:b("labels.arrowhead_circle"),keyBinding:null,icon:Se(Xg,{flip:e}),showInPicker:!1},{value:"circle",text:b("labels.arrowhead_circle"),keyBinding:"r",icon:Se(Xg,{flip:e}),showInPicker:!1},{value:"circle_outline",text:b("labels.arrowhead_circle_outline"),keyBinding:null,icon:Se(T2,{flip:e}),showInPicker:!1},{value:"triangle",text:b("labels.arrowhead_triangle"),icon:Se(I2,{flip:e}),keyBinding:"t"},{value:"triangle_outline",text:b("labels.arrowhead_triangle_outline"),icon:Se(C2,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond",text:b("labels.arrowhead_diamond"),icon:Se(k2,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond_outline",text:b("labels.arrowhead_diamond_outline"),icon:Se(A2,{flip:e}),keyBinding:null,showInPicker:!1}],mY=B({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,r)=>({elements:Gr(e,t,o=>{if(re(o)){let{position:n,type:i}=r;if(n==="start")return ne(o,{startArrowhead:i});if(n==="end")return ne(o,{endArrowhead:i})}return o}),appState:{...t,[r.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:r.type},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=dn().rtl;return zr("fieldset",{children:[Se("legend",{children:b("labels.arrowheads")}),zr("div",{className:"iconSelectList buttonList",children:[Se(gf,{label:"arrowhead_start",options:$w(!o),value:vr(e,t,n=>re(n)&&Yi(n.type)?n.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:n=>r({position:"start",type:n})}),Se(gf,{label:"arrowhead_end",group:"arrowheads",options:$w(!!o),value:vr(e,t,n=>re(n)&&Yi(n.type)?n.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:n=>r({position:"end",type:n})})]})]})}});f();U();ge();ue();Ve();Ag();Fm();z();Ye();f();import{useEffect as L4}from"react";import{jsx as _4}from"react/jsx-runtime";var Nl=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},Ef=(e,t,r="bottom")=>{let o=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=t.left+t.width/2-o.width/2;l<0?l=a:l+o.width>=n&&(l=n-o.width-a);let s;r==="bottom"?(s=t.top+t.height+a,s+o.height>=i&&(s=t.top-o.height-a)):(s=t.top-o.height-a,s<0&&(s=t.top+t.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},P4=(e,t,r,o)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=o?"50ch":"10ch",t.style.maxWidth=o?"50ch":"15ch",t.textContent=r;let n=e.getBoundingClientRect();Ef(t,n)},Ur=({children:e,label:t,long:r=!1,style:o,disabled:n})=>(L4(()=>()=>Nl().classList.remove("excalidraw-tooltip--visible"),[]),n?null:_4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>P4(i.currentTarget,Nl(),t,r),onPointerLeave:()=>Nl().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));We();Rr();Zt();ol();import{jsx as lp,jsxs as B4}from"react/jsx-runtime";var D4=B({name:"changeViewBackgroundColor",label:"labels.canvasBackground",paletteName:"Change canvas background color",trackEvent:!1,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,r)=>({appState:{...t,...r},commitToHistory:!!r.viewBackgroundColor}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>lp(hc,{palette:null,topPicks:Zc,label:b("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:n=>r({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:r})}),On=B({name:"clearCanvas",label:"labels.clearCanvas",paletteName:"Clear canvas",icon:Lo,trackEvent:{category:"canvas"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled,perform:(e,t,r,o)=>(o.imageCache.clear(),{elements:e.map(n=>ne(n,{isDeleted:!0})),appState:{...ar(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,showStats:t.showStats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:"selection"}:t.activeTool},commitToHistory:!0})}),ip=B({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Lg,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Nn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Xo(t.zoom.value+Gi)},t),userToFollow:null},commitToHistory:!1}),PanelComponent:({updateData:e})=>lp(ae,{type:"button",className:"zoom-in-button zoom-button",icon:Lg,title:`${b("buttons.zoomIn")} \u2014 ${R("CtrlOrCmd++")}`,"aria-label":b("buttons.zoomIn"),onClick:()=>{e(null)}}),keyTest:e=>(e.code===he.EQUAL||e.code===he.NUM_ADD)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),ap=B({name:"zoomOut",label:"buttons.zoomOut",icon:Pg,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Nn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Xo(t.zoom.value-Gi)},t),userToFollow:null},commitToHistory:!1}),PanelComponent:({updateData:e})=>lp(ae,{type:"button",className:"zoom-out-button zoom-button",icon:Pg,title:`${b("buttons.zoomOut")} \u2014 ${R("CtrlOrCmd+-")}`,"aria-label":b("buttons.zoomOut"),onClick:()=>{e(null)}}),keyTest:e=>(e.code===he.MINUS||e.code===he.NUM_SUBTRACT)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),R4=B({name:"resetZoom",label:"buttons.resetZoom",icon:$y,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Nn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Xo(1)},t),userToFollow:null},commitToHistory:!1}),PanelComponent:({updateData:e,appState:t})=>lp(Ur,{label:b("buttons.resetZoom"),style:{height:"100%"},children:B4(ae,{type:"button",className:"reset-zoom-button zoom-button",title:b("buttons.resetZoom"),"aria-label":b("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===he.ZERO||e.code===he.NUM_ZERO)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),N4=(e,t)=>{let[r,o,n,i]=e,a=n-r,l=t.width/a,s=i-o,c=t.height/s,d=Math.min(l,c),m=Math.floor(d/Gi)*Gi;return Math.min(Math.max(m,ed),1)},jw=({bounds:e,appState:t,fitToViewport:r=!1,viewportZoomFactor:o=.7})=>{let[n,i,a,l]=e,s=(n+a)/2,c=(i+l)/2,d,m,p;if(r){let u=a-n,h=l-i;d=Math.min(t.width/u,t.height/h)*Math.min(1,Math.max(o,.1)),d=Math.min(Math.max(d,.1),30);let x=t.width;if(t.openSidebar){let v=document.querySelector(".sidebar")?.offsetWidth??0;x=document.documentElement.getAttribute("dir")==="rtl"?t.width+v:t.width-v}m=x/2*(1/d)-s,p=t.height/2*(1/d)-c}else{d=N4(e,{width:t.width,height:t.height});let u=kg({scenePoint:{x:s,y:c},viewportDimensions:{width:t.width,height:t.height},zoom:{value:d}});m=u.scrollX,p=u.scrollY}return{appState:{...t,scrollX:m,scrollY:p,zoom:{value:d}},commitToHistory:!1}},gc=({targetElements:e,appState:t,fitToViewport:r,viewportZoomFactor:o})=>{let n=we(be(e));return jw({bounds:n,appState:t,fitToViewport:r,viewportZoomFactor:o})},zY=B({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Jm,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return gc({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!1})},keyTest:e=>e.code===he.TWO&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),GY=B({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Jm,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return gc({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!0})},keyTest:e=>e.code===he.THREE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),O4=B({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Jm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>gc({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1}),keyTest:e=>e.code===he.ONE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),ya=B({name:"toggleTheme",label:(e,t)=>t.theme===oe.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===oe.LIGHT?lc:sc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r)=>({appState:{...t,theme:r||(t.theme===oe.LIGHT?oe.DARK:oe.LIGHT)},commitToHistory:!1}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===he.D,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.toggleTheme}),UY=B({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t)=>{let r;return xr(t)?r=Xe(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):r=Xe(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},commitToHistory:!0}},keyTest:e=>e.key===S.E}),qw=B({name:"toggleHandTool",label:"toolBar.hand",paletteName:"Toggle hand tool",trackEvent:{category:"toolbar"},icon:Ym,viewMode:!1,perform:(e,t,r,o)=>{let n;return Co(t)?n=Xe(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Xe(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),He(o.interactiveCanvas,Ce.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},commitToHistory:!0}},keyTest:e=>!e.altKey&&!e[S.CTRL_OR_CMD]&&e.key===S.H});f();ue();ge();z();Ye();We();Rt();Qt();Jr();ce();ol();import{jsx as F4}from"react/jsx-runtime";var io=B({name:"finalize",label:"",trackEvent:!1,perform:(e,t,r,o)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=o,l=a.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:h}=t.editingLinearElement,x=K.getElement(p,l);if(x)return Tt(x)&&xn(x,u,h,l),{elements:x.points.length<2||eo(x)?e.filter(E=>E.id!==x.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null},commitToHistory:!0}}let s=e,c=t.pendingImageElementId&&a.getElement(t.pendingImageElementId);c&&F(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let d=t.multiElement?t.multiElement:t.editingElement?.type==="freedraw"?t.editingElement:null;if(d){if(d.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:h}=d;(!h||u[u.length-1]!==h)&&F(d,{points:d.points.slice(0,-1)})}eo(d)&&(s=s.filter(u=>u.id!==d.id));let p=ir(d.points,t.zoom.value);if((d.type==="line"||d.type==="freedraw")&&p){let u=d.points,h=u[0];F(d,{points:u.map((x,E)=>E===u.length-1?[h[0],h[1]]:x)})}if(Tt(d)&&!p&&d.points.length>1){let[u,h]=K.getPointAtIndexGlobalCoordinates(d,-1,$(e));Ps(d,t,{x:u,y:h},o)}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!d)&&Or(n);let m;return t.activeTool.type==="eraser"?m=Xe(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):m=Xe(t,{type:"selection"}),{elements:s,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&d?t.activeTool:m,activeEmbeddable:null,draggingElement:null,multiElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[d.id]:!0}:t.selectedElementIds,selectedLinearElement:d&&re(d)?new K(d):t.selectedLinearElement,pendingImageElementId:null},commitToHistory:t.activeTool.type==="freedraw"}},keyTest:(e,t)=>e.key===S.ESCAPE&&(t.editingLinearElement!==null||!t.draggingElement&&t.multiElement===null)||(e.key===S.ESCAPE||e.key===S.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:r})=>F4(ae,{type:"button",icon:o2,title:b("buttons.done"),"aria-label":b("buttons.done"),onClick:t,visible:e.multiElement!=null,size:r?.size||"medium"})});f();f();z();import{useState as H4}from"react";ue();import{jsx as Jw,jsxs as z4}from"react/jsx-runtime";var Qw=e=>{let{id:t}=Bt(),[r,o]=H4(e.value),n=a=>{e.ignoreFocus||px(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===S.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return z4("div",{className:"ProjectName",children:[Jw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Jw("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${t}-filename`,value:r,onChange:a=>o(a.target.value)})]})};f();U();import{jsx as fc}from"react/jsx-runtime";var tv=e=>{let t=e.title||(e.value===oe.DARK?b("buttons.lightMode"):b("buttons.darkMode"));return fc(ae,{type:"icon",icon:e.value===oe.LIGHT?ev.MOON:ev.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===oe.DARK?oe.LIGHT:oe.DARK),"data-testid":"toggle-dark-mode"})},ev={SUN:fc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:fc("path",{fill:"currentColor",d:"M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"})}),MOON:fc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:fc("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};f();ui();U();ge();ce();Ve();qs();z();Er();An();Pn();er();Er();Pn();var wa=(e,{selectedElementIds:t},r)=>{e=be(e);let o=r&&ze(e,{selectedElementIds:t}),n=null,i=o?pe(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return o&&(i.length===1&&Q(i[0])?(n=i[0],i=fl(e,n)):i.length>1&&(i=pe(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:Bo(i)}},va=async(e,t,r,o,{exportBackground:n,exportPadding:i=fo,viewBackgroundColor:a,name:l=r.name||ad,fileHandle:s=null,exportingFrame:c=null})=>{if(t.length===0)throw new Error(b("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=gl(t,{exportBackground:n,exportWithDarkMode:r.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:r.exportScale,exportEmbedScene:r.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return ll(m.then(p=>new Blob([p.outerHTML],{type:J.svg})),{description:"Export to SVG",name:l,extension:r.exportEmbedScene?"excalidraw.svg":"svg",fileHandle:s});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await Dn(p)}catch{throw new Error(b("errors.copyToSystemClipboardFailed"))}return}}let d=fm(t,r,o,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Ln(d);return r.exportEmbedScene&&(m=m.then(p=>Promise.resolve().then(()=>(dl(),Ks)).then(({encodePngMetadata:u})=>u({blob:p,metadata:mi(t,r,o,"local")})))),ll(m,{description:"Export to PNG",name:l,extension:"png",fileHandle:s})}else if(e==="clipboard")try{let m=Ln(d);await vm(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):mn&&m.name==="TypeError"?new Error(`${b("alerts.couldNotCopyToClipboard")}
56
56
 
57
- ${b("hints.firefox_clipboard_write")}`):new Error(b("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};f();Er();var Qw=async(e,t,r,o)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=t,l=Gh(a);if(!a||!cE(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=wa(e,t,!1);return await va(l,s,t,r,{exportBackground:n,viewBackgroundColor:i,name:o,fileHandle:a,exportingFrame:c}),{fileHandle:a}};ue();Ye();f();import z4 from"clsx";import{jsx as ev,jsxs as G4}from"react/jsx-runtime";var Ta=({children:e,checked:t,onChange:r,className:o})=>G4("div",{className:z4("Checkbox",o,{"is-checked":t}),onClick:n=>{r(!t,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[ev("button",{className:"Checkbox-box",role:"checkbox","aria-checked":t,children:Zy}),ev("div",{className:"Checkbox-label",children:e})]});qs();G();Ve();ge();Er();An();import{Fragment as U4,jsx as Bn,jsxs as W4}from"react/jsx-runtime";var Ef=B({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,r)=>({appState:{...t,name:r},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t,appProps:r,data:o,app:n})=>Bn(jw,{label:b("labels.fileTitle"),value:n.getName(),onChange:i=>t(i),ignoreFocus:o?.ignoreFocus??!1})}),tv=B({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,r)=>({appState:{...t,exportScale:r},commitToHistory:!1}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=be(e),i=ze(o,t)?me(o,t):o;return Bn(U4,{children:Fa.map(a=>{let[l,s]=_E(i,fo,a),c=`${b("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Bn(ae,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===t.exportScale,onChange:()=>r(a)},a)})})}}),yf=B({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,r)=>({appState:{...t,exportBackground:r},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>Bn(Ta,{checked:e.exportBackground,onChange:r=>t(r),children:b("imageExportDialog.label.withBackground")})}),ap=B({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,r)=>({appState:{...t,exportEmbedScene:r},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>W4(Ta,{checked:e.exportEmbedScene,onChange:r=>t(r),children:[b("imageExportDialog.label.embedScene"),Bn(Ur,{label:b("imageExportDialog.tooltip.embedScene"),long:!0,children:Bn("div",{className:"excalidraw-tooltip-icon",children:t2})})]})}),lp=B({name:"saveToActiveFile",label:"buttons.save",icon:ba,trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{let n=!!t.fileHandle;try{let{fileHandle:i}=ml(t.fileHandle)?await Qw(e,t,o.files,o.getName()):await em(e,t,o.files,o.getName());return{commitToHistory:!1,appState:{...t,fileHandle:i,toast:n?{message:i?.name?b("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):b("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{commitToHistory:!1}}},keyTest:e=>e.key===S.S&&e[S.CTRL_OR_CMD]&&!e.shiftKey}),bc=B({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:ba,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,r,o)=>{try{let{fileHandle:n}=await em(e,{...t,fileHandle:null},o.files,o.getName());return{commitToHistory:!1,appState:{...t,openDialog:null,fileHandle:n,toast:{message:b("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{commitToHistory:!1}}},keyTest:e=>e.key===S.S&&e.shiftKey&&e[S.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Bn(ae,{type:"button",icon:qy,title:b("buttons.saveAs"),"aria-label":b("buttons.saveAs"),showAriaLabel:Ie().editor.isMobile,hidden:!si,onClick:()=>e(null),"data-testid":"save-as-button"})}),Nl=B({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{try{let{elements:n,appState:i,files:a}=await Kh(t,e);return{elements:n,appState:i,files:a,commitToHistory:!0}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:o.files,commitToHistory:!1}}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.O}),rv=B({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,r)=>({appState:{...t,exportWithDarkMode:r},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>Bn("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Bn(Jw,{value:e.exportWithDarkMode?oe.DARK:oe.LIGHT,onChange:r=>{t(r===oe.DARK)},title:b("imageExportDialog.label.darkMode")})})});f();ge();ue();Ye();We();G();ut();ce();Ve();var ov="{}",wf=B({name:"copyStyles",label:"labels.copyStyles",icon:jg,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=[],i=e.find(a=>t.selectedElementIds[a.id]);if(n.push(i),i&&gr(i)){let a=pe(i,o.scene.getNonDeletedElementsMap());n.push(a)}return i&&(ov=JSON.stringify(n)),{appState:{...t,toast:{message:b("toast.copyStyles")}},commitToHistory:!1}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.C}),vf=B({name:"pasteStyles",label:"labels.pasteStyles",icon:jg,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=JSON.parse(ov),i=n[0],a=n[1];if(!bs(i))return{elements:e,commitToHistory:!1};let l=me(e,t,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let d=i;if(U(c)&&c.containerId&&(d=a),!d)return c;let m=ne(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?yx(d.roundness.type,c)?d.roundness:wx(c):null});if(U(m)){let p=d.fontSize||At,u=d.fontFamily||Wt;m=ne(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||Yn,lineHeight:d.lineHeight||_r(u)});let h=null;m.containerId&&(h=l.find(x=>U(m)&&x.id===m.containerId)||null),Yt(m,h,o.scene.getNonDeletedElementsMap())}return m.type==="arrow"&&Te(d)&&(m=ne(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),Q(c)&&(m=ne(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),commitToHistory:!0}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.V});f();ge();Ye();ue();import{jsx as nv}from"react/jsx-runtime";var V4=B({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>nv(ae,{type:"button",icon:Fm,"aria-label":b("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})}),Y4=B({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},commitToHistory:!1}),PanelComponent:({elements:e,appState:t,updateData:r})=>nv(ae,{visible:ua(t,be(e)),type:"button",icon:Jy,"aria-label":b("buttons.edit"),onClick:r,selected:t.openMenu==="shape"})}),Sa=B({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Ky,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,r,{focusContainer:o})=>(t.openDialog?.name==="help"&&o(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},commitToHistory:!1}),keyTest:e=>e.key===S.QUESTION_MARK});f();ue();z();Ye();We();Ve();Nr();ge();Eo();ce();er();wo();import{jsx as Ol}from"react/jsx-runtime";var K4=e=>{if(e.length>=2){let t=e[0].groupIds;for(let r of t)if(e.reduce((o,n)=>o&&oa(n,r),!0))return!0}return!1},iv=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return o.length>=2&&!K4(o)},Tf=B({name:"group",label:"labels.group",icon:e=>Ol(Vg,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});if(n.length<2)return{appState:t,elements:e,commitToHistory:!1};let i=vn(t);if(i.length===1){let E=i[0],v=new Set(Je(e,E).map(I=>I.id)),w=new Set(n.map(I=>I.id));if(new Set([...Array.from(v),...Array.from(w)]).size===v.size)return{appState:t,elements:e,commitToHistory:!1}}let a=[...e];new Set(n.map(E=>E.frameId)).size>1&&ry(n).forEach((v,w)=>{yl(v,o.scene.getNonDeletedElementsMap())});let s=Pt(),c=$(n);a=a.map(E=>c.get(E.id)?ne(E,{groupIds:R0(E.groupIds,s,t.editingGroupId)}):E);let d=Je(a,s),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),x=[...a.slice(0,p).filter(E=>!oa(E,s)),...d,...u];return qt(x,$(d)),{appState:{...t,...Mh(s,{...t,selectedGroupIds:{}},be(a))},elements:x,commitToHistory:!0}},predicate:(e,t,r,o)=>iv(e,t,o),keyTest:e=>!e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Ol(ae,{hidden:!iv(e,t,o),type:"button",icon:Ol(Vg,{theme:t.theme}),onClick:()=>r(null),title:`${b("labels.group")} \u2014 ${R("CtrlOrCmd+G")}`,"aria-label":b("labels.group"),visible:ze(be(e),t)})}),Sf=B({name:"ungroup",label:"labels.ungroup",icon:e=>Ol(Yg,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=vn(t),i=$(e);if(n.length===0)return{appState:t,elements:e,commitToHistory:!1};let a=[...e],l=[];a=a.map(p=>{Ne(p)&&l.push(p.id);let u=N0(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:ne(p,{groupIds:u})});let s=Kt(t,be(a),t,null),c=o.scene.getSelectedElements(t),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return Js(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=Sm(a,El(a,p,t,i),p,o))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,h])=>(h&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...s},elements:a,commitToHistory:!0}},keyTest:e=>e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G.toUpperCase(),predicate:(e,t)=>vn(t).length>0,PanelComponent:({elements:e,appState:t,updateData:r})=>Ol(ae,{type:"button",hidden:vn(t).length===0,icon:Ol(Yg,{theme:t.theme}),onClick:()=>r(null),title:`${b("labels.ungroup")} \u2014 ${R("CtrlOrCmd+Shift+G")}`,"aria-label":b("labels.ungroup"),visible:ze(be(e),t)})});f();f();G();f();var sp=(e,t,r,o,n,i,a)=>{e.beginPath(),e.moveTo(t+i,r),e.lineTo(t+o-i,r),e.quadraticCurveTo(t+o,r,t+o,r+i),e.lineTo(t+o,r+n-i),e.quadraticCurveTo(t+o,r+n,t+o-i,r+n),e.lineTo(t+i,r+n),e.quadraticCurveTo(t,r+n,t,r+n-i),e.lineTo(t,r+i),e.quadraticCurveTo(t,r,t+i,r),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};f();function $4(e){let t=0;if(e.length===0)return t;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)-t+o}return t}var Ia=(e,t)=>`hsl(${Math.abs($4(t?.id||e))%37*10}, 100%, 83%)`,av=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},lv=({context:e,renderConfig:t,appState:r,normalizedWidth:o,normalizedHeight:n})=>{for(let[i,a]of t.remotePointerViewportCoords){let{x:l,y:s}=a,c=r.collaborators.get(i);l-=r.offsetLeft,s-=r.offsetTop;let d=11,m=14,p=l<0||l>o-d||s<0||s>n-m;l=Math.max(l,0),l=Math.min(l,o-d),s=Math.max(s,0),s=Math.min(s,n-m);let u=Ia(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let h=t.remotePointerUserStates.get(i),x=p||h==="idle"||h==="away";x&&(e.globalAlpha=.3),t.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let E=r.theme===oe.DARK?"#2f6330":Hb,v=c?.isSpeaking;v&&(e.fillStyle=E,e.strokeStyle=E,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=ss,e.strokeStyle=ss,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),x?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let w=t.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let y=(v?l+0:l)+d/2,I=(v?s+0:s)+m+2,P=5,C=3,_=e.measureText(w),D=_.actualBoundingBoxDescent+_.actualBoundingBoxAscent,H=Math.max(D,12),A=y-1,M=I-1,k=_.width+2+P*2+2,O=H+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(A,M,k,O,8),e.fillStyle=u,e.fill(),e.strokeStyle=ss,e.stroke(),v&&(e.beginPath(),e.roundRect(A-2,M-2,k+4,O+4,8),e.strokeStyle=E,e.stroke())):sp(e,A,M,k,O,8,ss),e.fillStyle=Fb,e.fillText(w,y+P+1,I+C+_.actualBoundingBoxAscent+Math.floor((H-D)/2)+2),v){e.fillStyle=E;let X=8,Y=8,ee=5;e.fillRect(A+k+Y,M+(O/2-X/2),2,X),e.fillRect(A+k+Y+ee,M+(O/2-X*2/2),2,X*2),e.fillRect(A+k+Y+ee*2,M+(O/2-X/2),2,X)}}e.restore(),e.closePath()}};f();import{useState as X4}from"react";import Z4 from"clsx";import{jsx as sv}from"react/jsx-runtime";var If=({color:e,onClick:t,name:r,src:o,className:n})=>{let i=av(r),[a,l]=X4(!1),s=!a&&o,c=s?void 0:{background:e};return sv("div",{className:Z4("Avatar",n),style:c,onClick:t,children:s?sv("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};Ye();import j4 from"clsx";import{jsx as qo,jsxs as cp}from"react/jsx-runtime";var q4=B({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,r)=>!r.socketId||t.userToFollow?.socketId===r.socketId||r.isCurrentUser?{appState:{...t,userToFollow:null},commitToHistory:!1}:{appState:{...t,userToFollow:{socketId:r.socketId,username:r.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},commitToHistory:!1},PanelComponent:({updateData:e,data:t,appState:r})=>{let{socketId:o,collaborator:n,withName:i,isBeingFollowed:a}=t,l=Ia(o,n),s=j4({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?cp("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:b("userList.hint.isSpeaking"),children:[qo("div",{}),qo("div",{}),qo("div",{})]}):n.isMuted?qo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:b("userList.hint.micMuted"),children:j2}):qo("div",{title:b("userList.hint.inCall"),children:Z2}):null;return i?cp("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[qo(If,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),qo("div",{className:"UserList__collaborator-name",children:n.username}),cp("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&qo("div",{className:"UserList__collaborator-status-icon-is-followed",title:b("userList.hint.followStatus"),children:Ml}),c]})]}):cp("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[qo(If,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&qo("div",{className:"UserList__collaborator-status-icon",children:c})]})}});f();Ye();In();Eo();G();var Cf=B({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of id)if(n.some(a=>a.type===i))return{commitToHistory:!1,appState:{...t,errorMessage:b(`errors.libraryElementTypeError.${i}`)}};return o.library.getLatestLibrary().then(i=>o.library.setLibrary([{id:Pt(),status:"unpublished",elements:n.map(Sn),created:Date.now()},...i])).then(()=>({commitToHistory:!1,appState:{...t,toast:{message:b("toast.addedToLibrary")}}})).catch(i=>({commitToHistory:!1,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});f();f();We();at();Nr();var cv=(e,t,r)=>{let o=na(e,t),n=br(e);return o.flatMap(i=>{let a=J4(i,n,r);return i.map(l=>ne(l,{x:l.x+a.x,y:l.y+a.y}))})},J4=(e,t,{axis:r,position:o})=>{let n=br(e),[i,a]=r==="x"?["minX","maxX"]:["minY","maxY"],l={x:0,y:0};return o==="start"?{...l,[r]:t[i]-n[i]}:o==="end"?{...l,[r]:t[a]-n[a]}:{...l,[r]:(t[i]+t[a])/2-(n[i]+n[a])/2}};ge();ce();er();ue();Ve();z();Ye();import{jsx as Fl}from"react/jsx-runtime";var ao=(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>1&&!n.some(i=>Q(i))},Bl=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=$(e),a=cv(n,i,o),l=$(a);return $o(e.map(s=>l.get(s.id)||s),t,r)},Q4=B({name:"alignTop",label:"labels.alignTop",icon:Fg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Bl(e,t,o,{position:"start",axis:"y"}),commitToHistory:!0}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Fl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Fg,onClick:()=>r(null),title:`${b("labels.alignTop")} \u2014 ${R("CtrlOrCmd+Shift+Up")}`,"aria-label":b("labels.alignTop"),visible:ze(be(e),t)})}),ek=B({name:"alignBottom",label:"labels.alignBottom",icon:Hg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Bl(e,t,o,{position:"end",axis:"y"}),commitToHistory:!0}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Fl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Hg,onClick:()=>r(null),title:`${b("labels.alignBottom")} \u2014 ${R("CtrlOrCmd+Shift+Down")}`,"aria-label":b("labels.alignBottom"),visible:ze(be(e),t)})}),tk=B({name:"alignLeft",label:"labels.alignLeft",icon:zg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Bl(e,t,o,{position:"start",axis:"x"}),commitToHistory:!0}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Fl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:zg,onClick:()=>r(null),title:`${b("labels.alignLeft")} \u2014 ${R("CtrlOrCmd+Shift+Left")}`,"aria-label":b("labels.alignLeft"),visible:ze(be(e),t)})}),rk=B({name:"alignRight",label:"labels.alignRight",icon:Gg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Bl(e,t,o,{position:"end",axis:"x"}),commitToHistory:!0}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Fl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Gg,onClick:()=>r(null),title:`${b("labels.alignRight")} \u2014 ${R("CtrlOrCmd+Shift+Right")}`,"aria-label":b("labels.alignRight"),visible:ze(be(e),t)})}),ok=B({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Ug,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Bl(e,t,o,{position:"center",axis:"y"}),commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Fl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Ug,onClick:()=>r(null),title:b("labels.centerVertically"),"aria-label":b("labels.centerVertically"),visible:ze(be(e),t)})}),nk=B({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Wg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Bl(e,t,o,{position:"center",axis:"x"}),commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Fl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Wg,onClick:()=>r(null),title:b("labels.centerHorizontally"),"aria-label":b("labels.centerHorizontally"),visible:ze(be(e),t)})});f();f();We();Nr();at();var dv=(e,t,r)=>{let[o,n,i,a]=r.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],l=br(e),s=na(e,t).map(p=>[p,br(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of s)c+=p[1][a];let d=(l[a]-c)/(s.length-1);if(d<0){let p=s.findIndex(E=>E[1][o]===l[o]),u=s.findIndex(E=>E[1][i]===l[i]),h=(s[u][1][n]-s[p][1][n])/(s.length-1),x=s[p][1][n];return s.flatMap(([E,v],w)=>{let y={x:0,y:0};return w!==p&&w!==u&&(x+=h,y[r.axis]=x-v[n]),E.map(I=>ne(I,{x:I.x+y.x,y:I.y+y.y}))})}let m=l[o];return s.flatMap(([p,u])=>{let h={x:0,y:0};return h[r.axis]=m-u[o],m+=d,m+=u[a],p.map(x=>ne(x,{x:x.x+h.x,y:x.y+h.y}))})};ge();ce();er();ue();Ve();z();Ye();import{jsx as uv}from"react/jsx-runtime";var mv=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length>1&&!r.some(o=>Q(o))},pv=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=dv(n,r.scene.getNonDeletedElementsMap(),o),a=$(i);return $o(e.map(l=>a.get(l.id)||l),t,r)},ik=B({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:pv(e,t,o,{space:"between",axis:"x"}),commitToHistory:!0}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.H,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>uv(ae,{hidden:!mv(t,o),type:"button",icon:o2,onClick:()=>r(null),title:`${b("labels.distributeHorizontally")} \u2014 ${R("Alt+H")}`,"aria-label":b("labels.distributeHorizontally"),visible:ze(be(e),t)})}),ak=B({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:pv(e,t,o,{space:"between",axis:"y"}),commitToHistory:!0}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.V,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>uv(ae,{hidden:!mv(t,o),type:"button",icon:n2,onClick:()=>r(null),title:`${b("labels.distributeVertically")} \u2014 ${R("Alt+V")}`,"aria-label":b("labels.distributeVertically"),visible:ze(be(e),t)})});f();Ye();Ve();ge();Eg();z();ue();at();Jr();er();var kf=B({name:"flipHorizontal",label:"labels.flipHorizontal",icon:ew,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:$o(hv(e,o.scene.getNonDeletedElementsMap(),t,"horizontal",o),t,o),appState:t,commitToHistory:!0}),keyTest:e=>e.shiftKey&&e.code===he.H}),Af=B({name:"flipVertical",label:"labels.flipVertical",icon:Q2,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:$o(hv(e,o.scene.getNonDeletedElementsMap(),t,"vertical",o),t,o),appState:t,commitToHistory:!0}),keyTest:e=>e.shiftKey&&e.code===he.V&&!e[S.CTRL_OR_CMD]}),hv=(e,t,r,o,n)=>{let i=me(be(e),r,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=lk(i,e,t,r,o,n),l=$(a);return e.map(s=>l.get(s.id)||s)},lk=(e,t,r,o,n,i)=>{let{minX:a,minY:l,maxX:s,maxY:c}=br(e);return fg(r,e,r,"nw",!0,n==="horizontal"?s:a,n==="horizontal"?l:c),Uo(o)?Ls(e,i):_s(e,r),e};f();ue();Ye();ui();ge();G();var Hl=B({name:"copy",label:"labels.copy",icon:ac,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await xm(n,o.files,r)}catch(i){return{commitToHistory:!1,appState:{...t,errorMessage:i.message}}}return{commitToHistory:!1}},keyTest:void 0}),Mf=B({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n;try{n=await GE()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),mn?{commitToHistory:!1,appState:{...t,errorMessage:b("hints.firefox_clipboard_write")}}:{commitToHistory:!1,appState:{...t,errorMessage:b("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(HE({types:n}))}catch(i){return console.error(i),{commitToHistory:!1,appState:{...t,errorMessage:b("errors.asyncPasteFailedOnParse")}}}return{commitToHistory:!1}},keyTest:void 0}),dp=B({name:"cut",label:"labels.cut",icon:H2,trackEvent:{category:"element"},perform:(e,t,r,o)=>(Hl.perform(e,t,r,o),mc.perform(e,t,null,o)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.X}),mp=B({name:"copyAsSvg",label:"labels.copyAsSvg",icon:tw,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{commitToHistory:!1};let{exportedElements:n,exportingFrame:i}=wa(e,t,!0);try{return await va("clipboard-svg",n,t,o.files,{...t,exportingFrame:i,name:o.getName()}),{commitToHistory:!1}}catch(a){return console.error(a),{appState:{...t,errorMessage:a.message},commitToHistory:!1}}},predicate:e=>bm&&e.length>0,keywords:["svg","clipboard","copy"]}),pp=B({name:"copyAsPng",label:"labels.copyAsPng",icon:rw,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{commitToHistory:!1};let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=wa(e,t,!0);try{return await va("clipboard",i,t,o.files,{...t,exportingFrame:a,name:o.getName()}),{appState:{...t,toast:{message:b("toast.copyToClipboardAsPng",{exportSelection:n.length?b("toast.selection"):b("toast.canvas"),exportColorScheme:t.exportWithDarkMode?b("buttons.darkMode"):b("buttons.lightMode")})}},commitToHistory:!1}}catch(l){return console.error(l),{appState:{...t,errorMessage:l.message},commitToHistory:!1}}},predicate:e=>bl&&e.length>0,keyTest:e=>e.code===he.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),up=B({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let i=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).reduce((a,l)=>(U(l)&&a.push(l.text),a),[]).join(`
57
+ ${b("hints.firefox_clipboard_write")}`):new Error(b("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};f();Er();var rv=async(e,t,r,o)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=t,l=Uh(a);if(!a||!pE(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=wa(e,t,!1);return await va(l,s,t,r,{exportBackground:n,viewBackgroundColor:i,name:o,fileHandle:a,exportingFrame:c}),{fileHandle:a}};ue();Ye();f();import G4 from"clsx";import{jsx as ov,jsxs as U4}from"react/jsx-runtime";var Ta=({children:e,checked:t,onChange:r,className:o})=>U4("div",{className:G4("Checkbox",o,{"is-checked":t}),onClick:n=>{r(!t,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[ov("button",{className:"Checkbox-box",role:"checkbox","aria-checked":t,children:Jy}),ov("div",{className:"Checkbox-label",children:e})]});qs();U();Ve();ge();Er();An();import{Fragment as W4,jsx as Bn,jsxs as V4}from"react/jsx-runtime";var yf=B({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,r)=>({appState:{...t,name:r},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t,appProps:r,data:o,app:n})=>Bn(Qw,{label:b("labels.fileTitle"),value:n.getName(),onChange:i=>t(i),ignoreFocus:o?.ignoreFocus??!1})}),nv=B({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,r)=>({appState:{...t,exportScale:r},commitToHistory:!1}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=be(e),i=ze(o,t)?pe(o,t):o;return Bn(W4,{children:Fa.map(a=>{let[l,s]=NE(i,fo,a),c=`${b("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Bn(ae,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===t.exportScale,onChange:()=>r(a)},a)})})}}),wf=B({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,r)=>({appState:{...t,exportBackground:r},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>Bn(Ta,{checked:e.exportBackground,onChange:r=>t(r),children:b("imageExportDialog.label.withBackground")})}),sp=B({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,r)=>({appState:{...t,exportEmbedScene:r},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>V4(Ta,{checked:e.exportEmbedScene,onChange:r=>t(r),children:[b("imageExportDialog.label.embedScene"),Bn(Ur,{label:b("imageExportDialog.tooltip.embedScene"),long:!0,children:Bn("div",{className:"excalidraw-tooltip-icon",children:n2})})]})}),cp=B({name:"saveToActiveFile",label:"buttons.save",icon:ba,trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{let n=!!t.fileHandle;try{let{fileHandle:i}=ml(t.fileHandle)?await rv(e,t,o.files,o.getName()):await rm(e,t,o.files,o.getName());return{commitToHistory:!1,appState:{...t,fileHandle:i,toast:n?{message:i?.name?b("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):b("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{commitToHistory:!1}}},keyTest:e=>e.key===S.S&&e[S.CTRL_OR_CMD]&&!e.shiftKey}),bc=B({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:ba,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,r,o)=>{try{let{fileHandle:n}=await rm(e,{...t,fileHandle:null},o.files,o.getName());return{commitToHistory:!1,appState:{...t,openDialog:null,fileHandle:n,toast:{message:b("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{commitToHistory:!1}}},keyTest:e=>e.key===S.S&&e.shiftKey&&e[S.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Bn(ae,{type:"button",icon:e2,title:b("buttons.saveAs"),"aria-label":b("buttons.saveAs"),showAriaLabel:Ie().editor.isMobile,hidden:!si,onClick:()=>e(null),"data-testid":"save-as-button"})}),Ol=B({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{try{let{elements:n,appState:i,files:a}=await $h(t,e);return{elements:n,appState:i,files:a,commitToHistory:!0}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:o.files,commitToHistory:!1}}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.O}),iv=B({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,r)=>({appState:{...t,exportWithDarkMode:r},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>Bn("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Bn(tv,{value:e.exportWithDarkMode?oe.DARK:oe.LIGHT,onChange:r=>{t(r===oe.DARK)},title:b("imageExportDialog.label.darkMode")})})});f();ge();ue();Ye();We();U();lt();ce();Ve();var av="{}",vf=B({name:"copyStyles",label:"labels.copyStyles",icon:qg,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=[],i=e.find(a=>t.selectedElementIds[a.id]);if(n.push(i),i&&gr(i)){let a=de(i,o.scene.getNonDeletedElementsMap());n.push(a)}return i&&(av=JSON.stringify(n)),{appState:{...t,toast:{message:b("toast.copyStyles")}},commitToHistory:!1}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.C}),Tf=B({name:"pasteStyles",label:"labels.pasteStyles",icon:qg,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=JSON.parse(av),i=n[0],a=n[1];if(!xs(i))return{elements:e,commitToHistory:!1};let l=pe(e,t,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let d=i;if(G(c)&&c.containerId&&(d=a),!d)return c;let m=ne(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?wx(d.roundness.type,c)?d.roundness:vx(c):null});if(G(m)){let p=d.fontSize||At,u=d.fontFamily||Wt;m=ne(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||Yn,lineHeight:d.lineHeight||_r(u)});let h=null;m.containerId&&(h=l.find(x=>G(m)&&x.id===m.containerId)||null),Yt(m,h,o.scene.getNonDeletedElementsMap())}return m.type==="arrow"&&Te(d)&&(m=ne(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),Q(c)&&(m=ne(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),commitToHistory:!0}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.V});f();ge();Ye();ue();import{jsx as lv}from"react/jsx-runtime";var Y4=B({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>lv(ae,{type:"button",icon:zm,"aria-label":b("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})}),K4=B({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},commitToHistory:!1}),PanelComponent:({elements:e,appState:t,updateData:r})=>lv(ae,{visible:ua(t,be(e)),type:"button",icon:t2,"aria-label":b("buttons.edit"),onClick:r,selected:t.openMenu==="shape"})}),Sa=B({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Zy,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,r,{focusContainer:o})=>(t.openDialog?.name==="help"&&o(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},commitToHistory:!1}),keyTest:e=>e.key===S.QUESTION_MARK});f();ue();z();Ye();We();Ve();Nr();ge();Eo();ce();er();wo();import{jsx as Bl}from"react/jsx-runtime";var $4=e=>{if(e.length>=2){let t=e[0].groupIds;for(let r of t)if(e.reduce((o,n)=>o&&oa(n,r),!0))return!0}return!1},sv=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return o.length>=2&&!$4(o)},Sf=B({name:"group",label:"labels.group",icon:e=>Bl(Yg,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});if(n.length<2)return{appState:t,elements:e,commitToHistory:!1};let i=vn(t);if(i.length===1){let E=i[0],v=new Set(Je(e,E).map(I=>I.id)),w=new Set(n.map(I=>I.id));if(new Set([...Array.from(v),...Array.from(w)]).size===v.size)return{appState:t,elements:e,commitToHistory:!1}}let a=[...e];new Set(n.map(E=>E.frameId)).size>1&&iy(n).forEach((v,w)=>{wl(v,o.scene.getNonDeletedElementsMap())});let s=Pt(),c=$(n);a=a.map(E=>c.get(E.id)?ne(E,{groupIds:N0(E.groupIds,s,t.editingGroupId)}):E);let d=Je(a,s),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),x=[...a.slice(0,p).filter(E=>!oa(E,s)),...d,...u];return qt(x,$(d)),{appState:{...t,...Ph(s,{...t,selectedGroupIds:{}},be(a))},elements:x,commitToHistory:!0}},predicate:(e,t,r,o)=>sv(e,t,o),keyTest:e=>!e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Bl(ae,{hidden:!sv(e,t,o),type:"button",icon:Bl(Yg,{theme:t.theme}),onClick:()=>r(null),title:`${b("labels.group")} \u2014 ${R("CtrlOrCmd+G")}`,"aria-label":b("labels.group"),visible:ze(be(e),t)})}),If=B({name:"ungroup",label:"labels.ungroup",icon:e=>Bl(Kg,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=vn(t),i=$(e);if(n.length===0)return{appState:t,elements:e,commitToHistory:!1};let a=[...e],l=[];a=a.map(p=>{Ne(p)&&l.push(p.id);let u=O0(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:ne(p,{groupIds:u})});let s=Kt(t,be(a),t,null),c=o.scene.getSelectedElements(t),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return Js(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=Cm(a,yl(a,p,t,i),p,o))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,h])=>(h&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...s},elements:a,commitToHistory:!0}},keyTest:e=>e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G.toUpperCase(),predicate:(e,t)=>vn(t).length>0,PanelComponent:({elements:e,appState:t,updateData:r})=>Bl(ae,{type:"button",hidden:vn(t).length===0,icon:Bl(Kg,{theme:t.theme}),onClick:()=>r(null),title:`${b("labels.ungroup")} \u2014 ${R("CtrlOrCmd+Shift+G")}`,"aria-label":b("labels.ungroup"),visible:ze(be(e),t)})});f();f();U();f();var dp=(e,t,r,o,n,i,a)=>{e.beginPath(),e.moveTo(t+i,r),e.lineTo(t+o-i,r),e.quadraticCurveTo(t+o,r,t+o,r+i),e.lineTo(t+o,r+n-i),e.quadraticCurveTo(t+o,r+n,t+o-i,r+n),e.lineTo(t+i,r+n),e.quadraticCurveTo(t,r+n,t,r+n-i),e.lineTo(t,r+i),e.quadraticCurveTo(t,r,t+i,r),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};f();function X4(e){let t=0;if(e.length===0)return t;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)-t+o}return t}var Ia=(e,t)=>`hsl(${Math.abs(X4(t?.id||e))%37*10}, 100%, 83%)`,cv=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},dv=({context:e,renderConfig:t,appState:r,normalizedWidth:o,normalizedHeight:n})=>{for(let[i,a]of t.remotePointerViewportCoords){let{x:l,y:s}=a,c=r.collaborators.get(i);l-=r.offsetLeft,s-=r.offsetTop;let d=11,m=14,p=l<0||l>o-d||s<0||s>n-m;l=Math.max(l,0),l=Math.min(l,o-d),s=Math.max(s,0),s=Math.min(s,n-m);let u=Ia(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let h=t.remotePointerUserStates.get(i),x=p||h==="idle"||h==="away";x&&(e.globalAlpha=.3),t.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let E=r.theme===oe.DARK?"#2f6330":zb,v=c?.isSpeaking;v&&(e.fillStyle=E,e.strokeStyle=E,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=cs,e.strokeStyle=cs,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),x?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let w=t.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let y=(v?l+0:l)+d/2,I=(v?s+0:s)+m+2,P=5,C=3,_=e.measureText(w),D=_.actualBoundingBoxDescent+_.actualBoundingBoxAscent,H=Math.max(D,12),A=y-1,M=I-1,k=_.width+2+P*2+2,O=H+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(A,M,k,O,8),e.fillStyle=u,e.fill(),e.strokeStyle=cs,e.stroke(),v&&(e.beginPath(),e.roundRect(A-2,M-2,k+4,O+4,8),e.strokeStyle=E,e.stroke())):dp(e,A,M,k,O,8,cs),e.fillStyle=Hb,e.fillText(w,y+P+1,I+C+_.actualBoundingBoxAscent+Math.floor((H-D)/2)+2),v){e.fillStyle=E;let X=8,Y=8,ee=5;e.fillRect(A+k+Y,M+(O/2-X/2),2,X),e.fillRect(A+k+Y+ee,M+(O/2-X*2/2),2,X*2),e.fillRect(A+k+Y+ee*2,M+(O/2-X/2),2,X)}}e.restore(),e.closePath()}};f();import{useState as Z4}from"react";import j4 from"clsx";import{jsx as mv}from"react/jsx-runtime";var Cf=({color:e,onClick:t,name:r,src:o,className:n})=>{let i=cv(r),[a,l]=Z4(!1),s=!a&&o,c=s?void 0:{background:e};return mv("div",{className:j4("Avatar",n),style:c,onClick:t,children:s?mv("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};Ye();import q4 from"clsx";import{jsx as qo,jsxs as mp}from"react/jsx-runtime";var J4=B({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,r)=>!r.socketId||t.userToFollow?.socketId===r.socketId||r.isCurrentUser?{appState:{...t,userToFollow:null},commitToHistory:!1}:{appState:{...t,userToFollow:{socketId:r.socketId,username:r.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},commitToHistory:!1},PanelComponent:({updateData:e,data:t,appState:r})=>{let{socketId:o,collaborator:n,withName:i,isBeingFollowed:a}=t,l=Ia(o,n),s=q4({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?mp("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:b("userList.hint.isSpeaking"),children:[qo("div",{}),qo("div",{}),qo("div",{})]}):n.isMuted?qo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:b("userList.hint.micMuted"),children:Q2}):qo("div",{title:b("userList.hint.inCall"),children:J2}):null;return i?mp("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[qo(Cf,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),qo("div",{className:"UserList__collaborator-name",children:n.username}),mp("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&qo("div",{className:"UserList__collaborator-status-icon-is-followed",title:b("userList.hint.followStatus"),children:Ll}),c]})]}):mp("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[qo(Cf,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&qo("div",{className:"UserList__collaborator-status-icon",children:c})]})}});f();Ye();In();Eo();U();var kf=B({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of id)if(n.some(a=>a.type===i))return{commitToHistory:!1,appState:{...t,errorMessage:b(`errors.libraryElementTypeError.${i}`)}};return o.library.getLatestLibrary().then(i=>o.library.setLibrary([{id:Pt(),status:"unpublished",elements:n.map(Sn),created:Date.now()},...i])).then(()=>({commitToHistory:!1,appState:{...t,toast:{message:b("toast.addedToLibrary")}}})).catch(i=>({commitToHistory:!1,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});f();f();We();at();Nr();var pv=(e,t,r)=>{let o=na(e,t),n=br(e);return o.flatMap(i=>{let a=Q4(i,n,r);return i.map(l=>ne(l,{x:l.x+a.x,y:l.y+a.y}))})},Q4=(e,t,{axis:r,position:o})=>{let n=br(e),[i,a]=r==="x"?["minX","maxX"]:["minY","maxY"],l={x:0,y:0};return o==="start"?{...l,[r]:t[i]-n[i]}:o==="end"?{...l,[r]:t[a]-n[a]}:{...l,[r]:(t[i]+t[a])/2-(n[i]+n[a])/2}};ge();ce();er();ue();Ve();z();Ye();import{jsx as Hl}from"react/jsx-runtime";var ao=(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>1&&!n.some(i=>Q(i))},Fl=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=$(e),a=pv(n,i,o),l=$(a);return $o(e.map(s=>l.get(s.id)||s),t,r)},ek=B({name:"alignTop",label:"labels.alignTop",icon:Hg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Fl(e,t,o,{position:"start",axis:"y"}),commitToHistory:!0}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Hl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Hg,onClick:()=>r(null),title:`${b("labels.alignTop")} \u2014 ${R("CtrlOrCmd+Shift+Up")}`,"aria-label":b("labels.alignTop"),visible:ze(be(e),t)})}),tk=B({name:"alignBottom",label:"labels.alignBottom",icon:zg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Fl(e,t,o,{position:"end",axis:"y"}),commitToHistory:!0}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Hl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:zg,onClick:()=>r(null),title:`${b("labels.alignBottom")} \u2014 ${R("CtrlOrCmd+Shift+Down")}`,"aria-label":b("labels.alignBottom"),visible:ze(be(e),t)})}),rk=B({name:"alignLeft",label:"labels.alignLeft",icon:Gg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Fl(e,t,o,{position:"start",axis:"x"}),commitToHistory:!0}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Hl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Gg,onClick:()=>r(null),title:`${b("labels.alignLeft")} \u2014 ${R("CtrlOrCmd+Shift+Left")}`,"aria-label":b("labels.alignLeft"),visible:ze(be(e),t)})}),ok=B({name:"alignRight",label:"labels.alignRight",icon:Ug,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Fl(e,t,o,{position:"end",axis:"x"}),commitToHistory:!0}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Hl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Ug,onClick:()=>r(null),title:`${b("labels.alignRight")} \u2014 ${R("CtrlOrCmd+Shift+Right")}`,"aria-label":b("labels.alignRight"),visible:ze(be(e),t)})}),nk=B({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Wg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Fl(e,t,o,{position:"center",axis:"y"}),commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Hl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Wg,onClick:()=>r(null),title:b("labels.centerVertically"),"aria-label":b("labels.centerVertically"),visible:ze(be(e),t)})}),ik=B({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Vg,trackEvent:{category:"element"},predicate:ao,perform:(e,t,r,o)=>({appState:t,elements:Fl(e,t,o,{position:"center",axis:"x"}),commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Hl(ae,{hidden:!ao(e,t,null,o),type:"button",icon:Vg,onClick:()=>r(null),title:b("labels.centerHorizontally"),"aria-label":b("labels.centerHorizontally"),visible:ze(be(e),t)})});f();f();We();Nr();at();var uv=(e,t,r)=>{let[o,n,i,a]=r.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],l=br(e),s=na(e,t).map(p=>[p,br(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of s)c+=p[1][a];let d=(l[a]-c)/(s.length-1);if(d<0){let p=s.findIndex(E=>E[1][o]===l[o]),u=s.findIndex(E=>E[1][i]===l[i]),h=(s[u][1][n]-s[p][1][n])/(s.length-1),x=s[p][1][n];return s.flatMap(([E,v],w)=>{let y={x:0,y:0};return w!==p&&w!==u&&(x+=h,y[r.axis]=x-v[n]),E.map(I=>ne(I,{x:I.x+y.x,y:I.y+y.y}))})}let m=l[o];return s.flatMap(([p,u])=>{let h={x:0,y:0};return h[r.axis]=m-u[o],m+=d,m+=u[a],p.map(x=>ne(x,{x:x.x+h.x,y:x.y+h.y}))})};ge();ce();er();ue();Ve();z();Ye();import{jsx as fv}from"react/jsx-runtime";var hv=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length>1&&!r.some(o=>Q(o))},gv=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=uv(n,r.scene.getNonDeletedElementsMap(),o),a=$(i);return $o(e.map(l=>a.get(l.id)||l),t,r)},ak=B({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:gv(e,t,o,{space:"between",axis:"x"}),commitToHistory:!0}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.H,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>fv(ae,{hidden:!hv(t,o),type:"button",icon:a2,onClick:()=>r(null),title:`${b("labels.distributeHorizontally")} \u2014 ${R("Alt+H")}`,"aria-label":b("labels.distributeHorizontally"),visible:ze(be(e),t)})}),lk=B({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:gv(e,t,o,{space:"between",axis:"y"}),commitToHistory:!0}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.V,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>fv(ae,{hidden:!hv(t,o),type:"button",icon:l2,onClick:()=>r(null),title:`${b("labels.distributeVertically")} \u2014 ${R("Alt+V")}`,"aria-label":b("labels.distributeVertically"),visible:ze(be(e),t)})});f();Ye();Ve();ge();yg();z();ue();at();Jr();er();var Af=B({name:"flipHorizontal",label:"labels.flipHorizontal",icon:ow,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:$o(bv(e,o.scene.getNonDeletedElementsMap(),t,"horizontal",o),t,o),appState:t,commitToHistory:!0}),keyTest:e=>e.shiftKey&&e.code===he.H}),Mf=B({name:"flipVertical",label:"labels.flipVertical",icon:rw,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:$o(bv(e,o.scene.getNonDeletedElementsMap(),t,"vertical",o),t,o),appState:t,commitToHistory:!0}),keyTest:e=>e.shiftKey&&e.code===he.V&&!e[S.CTRL_OR_CMD]}),bv=(e,t,r,o,n)=>{let i=pe(be(e),r,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=sk(i,e,t,r,o,n),l=$(a);return e.map(s=>l.get(s.id)||s)},sk=(e,t,r,o,n,i)=>{let{minX:a,minY:l,maxX:s,maxY:c}=br(e);return bg(r,e,r,"nw",!0,n==="horizontal"?s:a,n==="horizontal"?l:c),Uo(o)?Ls(e,i):_s(e,r),e};f();ue();Ye();ui();ge();U();var zl=B({name:"copy",label:"labels.copy",icon:ac,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await ym(n,o.files,r)}catch(i){return{commitToHistory:!1,appState:{...t,errorMessage:i.message}}}return{commitToHistory:!1}},keyTest:void 0}),Lf=B({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n;try{n=await VE()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),mn?{commitToHistory:!1,appState:{...t,errorMessage:b("hints.firefox_clipboard_write")}}:{commitToHistory:!1,appState:{...t,errorMessage:b("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(UE({types:n}))}catch(i){return console.error(i),{commitToHistory:!1,appState:{...t,errorMessage:b("errors.asyncPasteFailedOnParse")}}}return{commitToHistory:!1}},keyTest:void 0}),pp=B({name:"cut",label:"labels.cut",icon:U2,trackEvent:{category:"element"},perform:(e,t,r,o)=>(zl.perform(e,t,r,o),mc.perform(e,t,null,o)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.X}),up=B({name:"copyAsSvg",label:"labels.copyAsSvg",icon:nw,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{commitToHistory:!1};let{exportedElements:n,exportingFrame:i}=wa(e,t,!0);try{return await va("clipboard-svg",n,t,o.files,{...t,exportingFrame:i,name:o.getName()}),{commitToHistory:!1}}catch(a){return console.error(a),{appState:{...t,errorMessage:a.message},commitToHistory:!1}}},predicate:e=>Em&&e.length>0,keywords:["svg","clipboard","copy"]}),hp=B({name:"copyAsPng",label:"labels.copyAsPng",icon:iw,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{commitToHistory:!1};let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=wa(e,t,!0);try{return await va("clipboard",i,t,o.files,{...t,exportingFrame:a,name:o.getName()}),{appState:{...t,toast:{message:b("toast.copyToClipboardAsPng",{exportSelection:n.length?b("toast.selection"):b("toast.canvas"),exportColorScheme:t.exportWithDarkMode?b("buttons.darkMode"):b("buttons.lightMode")})}},commitToHistory:!1}}catch(l){return console.error(l),{appState:{...t,errorMessage:l.message},commitToHistory:!1}}},predicate:e=>xl&&e.length>0,keyTest:e=>e.code===he.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),gp=B({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let i=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).reduce((a,l)=>(G(l)&&a.push(l.text),a),[]).join(`
58
58
 
59
- `);try{Dn(i)}catch{throw new Error(b("errors.copyToSystemClipboardFailed"))}return{commitToHistory:!1}},predicate:(e,t,r,o)=>bm&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(U),keywords:["text","clipboard","copy"]});f();ue();Ye();G();var hp=B({name:"gridMode",label:"labels.showGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.gridSize},perform(e,t){return{appState:{...t,gridSize:this.checked(t)?null:un,objectsSnapModeEnabled:!1},commitToHistory:!1}},checked:e=>e.gridSize!==null,predicate:(e,t,r)=>typeof r.gridModeEnabled>"u",keyTest:e=>e[S.CTRL_OR_CMD]&&e.code===he.QUOTE});f();ue();Ye();var zl=B({name:"zenMode",label:"buttons.zenMode",icon:nw,paletteName:"Toggle zen mode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},commitToHistory:!1}},checked:e=>e.zenModeEnabled,predicate:(e,t,r)=>typeof r.zenModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.Z});f();ue();Ye();var Lf=B({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:ow,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridSize:null},commitToHistory:!1}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,r)=>typeof r.objectsSnapModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.S});f();Ye();ue();var Ei=B({name:"stats",label:"stats.title",icon:J2,paletteName:"Toggle stats",viewMode:!0,trackEvent:{category:"menu"},perform(e,t){return{appState:{...t,showStats:!this.checked(t)},commitToHistory:!1}},checked:e=>e.showStats,keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.SLASH});f();G();ge();We();ut();Ld();ce();z();Ye();wo();var Pf=B({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>o.scene.getSelectedElements(t).some(i=>gr(i)),perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=o.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=pe(a,i);if(l){let{width:s,height:c}=Io(l.originalText,Ge(l),l.lineHeight),d=b0(a.id);Md(a.id);let{x:m,y:p}=tl(a,l,i);F(l,{containerId:null,width:s,height:c,text:l.originalText,x:m,y:p}),F(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:d||a.height})}}),{elements:e,appState:t,commitToHistory:!0}}}),_f=B({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);if(n.length===2){let i=U(n[0])||U(n[1]),a;if(Fo(n[0])?a=n[0]:Fo(n[1])&&(a=n[1]),i&&a&&pe(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i,a;U(n[0])&&Fo(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),F(i,{containerId:a.id,verticalAlign:ft.MIDDLE,textAlign:Kn.CENTER}),F(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Yt(i,a,o.scene.getNonDeletedElementsMap()),ea(a.id,l),{elements:sk(e,a,i),appState:{...t,selectedElementIds:{[a.id]:!0}},commitToHistory:!0}}}),sk=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===r.id);o.splice(n,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i+1,0,r),qt(o,$([t,r])),o},ck=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===t.id);o.splice(n,1);let i=o.findIndex(a=>a.id===r.id);return o.splice(i,0,t),qt(o,$([t,r])),o},gv=B({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=n.every(a=>U(a));return n.length>0&&i},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=e.slice(),a={};for(let l of n)if(U(l)){let s=Fr({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:Ho("rectangle")?rt.ADAPTIVE_RADIUS:rt.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-ht,y:l.y-ht,width:yn(l.width,"rectangle"),height:yn(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&F(m,{startBinding:p,endBinding:u},!1)})}F(l,{containerId:s.id,verticalAlign:ft.MIDDLE,boundElements:null,textAlign:Kn.CENTER},!1),Yt(l,s,o.scene.getNonDeletedElementsMap()),i=ck([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...t,selectedElementIds:a},commitToHistory:!0}}});f();f();z();zs();We();ue();G();at();import{useCallback as fv,useEffect as dk,useLayoutEffect as mk,useRef as pk,useState as uk}from"react";import hk from"clsx";Ve();am();rl();ce();sm();import{jsx as xc,jsxs as bv}from"react/jsx-runtime";var Nf=320,xv=85,Df=5,gk=42,fk=500,Rf=!1,gp=new Map,Ev=({element:e,elementsMap:t,setAppState:r,onLinkOpen:o,setToast:n,updateEmbedValidationStatus:i})=>{let a=Gl(),l=yi(),s=e.link||"",[c,d]=uk(s),m=pk(null),p=a.showHyperlinkPopup==="editor",u=fv(()=>{if(!m.current)return;let w=lr(m.current.value)||null;if(!e.link&&w&&fe("hyperlink","create"),vt(e)){if(a.activeEmbeddable?.element===e&&r({activeEmbeddable:null}),!w){F(e,{link:null}),i(e,!1);return}if(!il(w,l.validateEmbeddable))w&&n({message:b("toast.unableToEmbed"),closable:!0}),e.link&&gp.set(e.id,e.link),F(e,{link:w}),i(e,!1);else{let{width:y,height:I}=e,P=kn(w);P?.error instanceof URIError&&n({message:b("toast.unrecognizedLinkFormat"),closable:!0});let C=P?P.intrinsicSize.w/P.intrinsicSize.h:1,_=gp.get(e.id)!==e.link;F(e,{..._?{width:P?.type==="video"?y>I?y:I*C:y,height:P?.type==="video"&&y>I?y/C:I}:{},link:w}),i(e,!0),gp.has(e.id)&&gp.delete(e.id)}}else F(e,{link:w})},[e,n,l.validateEmbeddable,a.activeEmbeddable,r,i]);mk(()=>()=>{u()},[u]),dk(()=>{let w=null,y=I=>{if(p)return;w&&clearTimeout(w),xk(e,t,a,[I.clientX,I.clientY])&&(w=window.setTimeout(()=>{r({showHyperlinkPopup:!1})},fk))};return window.addEventListener("pointermove",y,!1),()=>{window.removeEventListener("pointermove",y,!1),w&&clearTimeout(w)}},[a,e,p,r,t]);let h=fv(()=>{fe("hyperlink","delete"),F(e,{link:null}),p&&(m.current.value=""),r({showHyperlinkPopup:!1})},[r,e,p]),x=()=>{fe("hyperlink","edit","popup-ui"),r({showHyperlinkPopup:"editor"})},{x:E,y:v}=yv(e,a,t);return a.contextMenu||a.draggingElement||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:bv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${v}px`,left:`${E}px`,width:Nf,padding:Df},onClick:()=>{!e.link&&!p&&r({showHyperlinkPopup:"editor"})},children:[p?xc("input",{className:hk("excalidraw-hyperlinkContainer-input"),placeholder:"Type or paste your link here",ref:m,value:c,onChange:w=>d(w.target.value),autoFocus:!0,onKeyDown:w=>{w.stopPropagation(),w[S.CTRL_OR_CMD]&&w.key===S.K&&w.preventDefault(),(w.key===S.ENTER||w.key===S.ESCAPE)&&(u(),r({showHyperlinkPopup:"info"}))}}):e.link?xc("a",{href:lr(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:zd(e.link)?"_self":"_blank",onClick:w=>{if(e.link&&o){let y=pd("excalidraw-link",w.nativeEvent);o({...e,link:lr(e.link)},y),y.defaultPrevented&&w.preventDefault()}},rel:"noopener noreferrer",children:e.link}):xc("div",{className:"excalidraw-hyperlinkContainer-link",children:b("labels.link.empty")}),bv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!p&&xc(ae,{type:"button",title:b("buttons.edit"),"aria-label":b("buttons.edit"),label:b("buttons.edit"),onClick:x,className:"excalidraw-hyperlinkContainer--edit",icon:Sl}),s&&!vt(e)&&xc(ae,{type:"button",title:b("buttons.remove"),"aria-label":b("buttons.remove"),label:b("buttons.remove"),onClick:h,className:"excalidraw-hyperlinkContainer--remove",icon:Lo})]})]})},yv=(e,t,r)=>{let[o,n]=te(e,r),{x:i,y:a}=Dt({sceneX:o+e.width/2,sceneY:n},t),l=i-t.offsetLeft-Nf/2,s=a-t.offsetTop-xv;return{x:l,y:s}},Of=(e,t)=>{let r=me(e,t);return r[0]?.link?vt(r[0])?"labels.link.editEmbed":"labels.link.edit":vt(r[0])?"labels.link.createEmbed":"labels.link.create"},Ec=null,wv=(e,t,r)=>{Ec&&clearTimeout(Ec),Ec=window.setTimeout(()=>bk(e,t,r),Yb)},bk=(e,t,r)=>{if(!e.link)return;let o=Rl();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=e.link;let[n,i,a,l]=te(e,r),[s,c,d,m]=Xs([n,i,a,l],e.angle,t),p=Dt({sceneX:s,sceneY:c},t);xf(o,{left:p.x,top:p.y,width:d,height:m},"top"),fe("hyperlink","tooltip","link-icon"),Rf=!0},vv=()=>{Ec&&clearTimeout(Ec),Rf&&(Rf=!1,Rl().classList.remove("excalidraw-tooltip--visible"))},xk=(e,t,r,[o,n])=>{let{x:i,y:a}=Ue({clientX:o,clientY:n},r),l=15/r.zoom.value;if(la(i,a,e,t))return!1;let[s,c,d]=te(e,t);if(i>=s&&i<=d&&a>=c-xv&&a<=c)return!1;let{x:m,y:p}=yv(e,r,t);return!(o>=m-l&&o<=m+Nf+Df*2+l&&n>=p-l&&n<=p+l+Df*2+gk)};ce();ue();Ve();z();Ye();import{jsx as Ek}from"react/jsx-runtime";var yc=B({name:"hyperlink",label:(e,t)=>Of(e,t),icon:cc,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},commitToHistory:!0},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.K,predicate:(e,t)=>me(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=me(e,t);return Ek(ae,{type:"button",icon:cc,"aria-label":b(Of(e,t)),title:`${vt(e[0])?b("labels.link.labelEmbed"):b("labels.link.label")} - ${R("CtrlOrCmd+K")}`,onClick:()=>r(null),selected:o.length===1&&!!o[0].link})}});f();We();ce();ue();Ve();z();Ye();var Bf=e=>e.every(t=>!t.locked),Ff=B({name:"toggleElementLock",label:(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return o.length===1&&!Q(o[0])?o[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":Bf(o)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,t)=>{let r=me(t,e);return Bf(r)?Tl:fa},trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Bf(n),a=$(n);return{elements:e.map(l=>a.has(l.id)?ne(l,{locked:i}):l),appState:{...t,selectedLinearElement:i?null:t.selectedLinearElement},commitToHistory:!0}},keyTest:(e,t,r,o)=>e.key.toLocaleLowerCase()===S.L&&e[S.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),Tv=B({name:"unlockAllElements",paletteName:"Unlock all elements",trackEvent:{category:"canvas"},viewMode:!1,icon:fa,predicate:(e,t)=>me(e,t).length===0&&e.some(o=>o.locked),perform:(e,t)=>{let r=e.filter(o=>o.locked);return{elements:e.map(o=>o.locked?ne(o,{locked:!1}):o),appState:{...t,selectedElementIds:Object.fromEntries(r.map(o=>[o.id,!0]))},commitToHistory:!0}},label:"labels.elementLock.unlockAll"});f();f();import{useEffect as Hp,useRef as AM,useState as Fp}from"react";ue();f();import JA from"clsx";import{useEffect as QA,useState as eM}from"react";f();import{useCallback as yk,useState as wk}from"react";var Sv=()=>{let[e,t]=wk(null),r=yk(o=>t(o),[]);return[e,r]};ue();f();import vk from"react";import Tk from"clsx";import{jsx as Sk}from"react/jsx-runtime";var $t=vk.forwardRef(({children:e,padding:t,className:r,style:o},n)=>Sk("div",{className:Tk("Island",r),style:{"--padding":t,...o},ref:n,children:e}));f();ue();import{createPortal as Ik}from"react-dom";import Ck from"clsx";import{useRef as kk}from"react";import{jsx as Iv,jsxs as Ak}from"react/jsx-runtime";var Cv=e=>{let{closeOnClickOutside:t=!0}=e,r=Qm({className:"excalidraw-modal-container"}),o=kk(document.body.classList.contains("excalidraw-animations-disabled"));if(!r)return null;let n=i=>{i.key===S.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return Ik(Ak("div",{className:Ck("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Iv("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),Iv("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),r)};z();import{useSetAtom as tM}from"jotai";f();import{useState as $A,useCallback as e1,useMemo as u3,useRef as Qf}from"react";f();Er();cl();import{atom as Dk}from"jotai";at();qn();G();import{useEffect as Mv,useRef as Lv}from"react";f();Zt();import{atom as Mk,useAtom as Lk}from"jotai";import{useEffect as Pk,useState as _k}from"react";da();var Hf=Mk(new Map),kv=async e=>await xl({elements:e,appState:{exportBackground:!1,viewBackgroundColor:se.white},files:null,renderEmbeddables:!1}),Av=(e,t,r)=>{let[o,n]=_k();return Pk(()=>{if(t)if(e){let i=r.get(e);i?n(i):(async()=>{let a=await kv(t);a.querySelector(".style-fonts")?.remove(),a&&(r.set(e,a),n(a))})()}else(async()=>{let i=await kv(t);n(i)})()},[e,t,r,n]),o},fp=()=>{let[e]=Lk(Hf,Be);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:o=>{o.forEach(n=>e.delete(n))},svgCache:e}};z();f();var lo=class{subscribers=[];on(...t){let r=t.flat().filter(o=>typeof o=="function");return this.subscribers.push(...r),()=>this.off(r)}once(...t){let r=t.flat().filter(n=>typeof n=="function");r.push(()=>o());let o=this.on(...r);return o}off(...t){let r=t.flat();this.subscribers=this.subscribers.filter(o=>!r.includes(o))}trigger(...t){for(let r of this.subscribers)r(...t);return this}clear(){this.subscribers=[]}};f();z();var bp=class{jobs=[];running=!1;tick(){if(this.running)return;let t=this.jobs.shift();t?(this.running=!0,t.promise.resolve(gs(t.jobFactory,...t.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(t,...r){let o=md();return this.jobs.push({jobFactory:t,promise:o,args:r}),this.tick(),o}};ge();var _v=new lo,Ca=Dk({status:"loaded",isInitialized:!1,libraryItems:[]}),wc=e=>Bo(e),Rk=(e,t)=>!e.find(r=>r.elements.length!==t.elements.length?!1:r.elements.every((o,n)=>o.id===t.elements[n].id&&o.versionNonce===t.elements[n].versionNonce)),Dv=(e,t)=>{let r=[];for(let o of t)Rk(e,o)&&r.push(o);return[...r,...e]},Rv=(e,t)=>{let r=$(t),o={deletedItems:new Map,addedItems:new Map};for(let i of e)r.has(i.id)||o.deletedItems.set(i.id,i);let n=$(e);for(let i of t)n.has(i.id)||o.addedItems.set(i.id,i);return o},zf=class{currLibraryItems=[];prevLibraryItems=wc(this.currLibraryItems);app;constructor(t){this.app=t}updateQueue=[];getLastUpdateTask=()=>this.updateQueue[this.updateQueue.length-1];notifyListeners=()=>{if(this.updateQueue.length>0)Xt.set(Ca,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{Xt.set(Ca,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=wc(this.currLibraryItems);let r=wc(this.currLibraryItems);this.app.props.onLibraryChange?.(r),_v.trigger(Rv(t,r),r)}catch(t){console.error(t)}}};destroy=()=>{this.updateQueue=[],this.currLibraryItems=[],Xt.set(Hf,new Map)};resetLibrary=()=>this.setLibrary([]);getLatestLibrary=()=>new Promise(async t=>{try{let r=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(wc(r))}catch{return t(this.currLibraryItems)}});updateLibrary=async({libraryItems:t,prompt:r=!1,merge:o=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:kr.name,tab:ms}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),c;s instanceof Blob?c=await Wh(s,i):c=aa(s,i),!r||window.confirm(b("alerts.confirmAddLibrary",{numShapes:c.length}))?(r&&this.app.focusContainer(),a(o?Dv(this.currLibraryItems,c):c)):l(new zo)}catch(s){l(s)}})));setLibrary=t=>{let r=new Promise(async(o,n)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=wc(await t),o(this.currLibraryItems)}catch(i){n(i)}}).catch(o=>{if(o.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw o}).finally(()=>{this.updateQueue=this.updateQueue.filter(o=>o!==r),this.notifyListeners()});return this.updateQueue.push(r),this.notifyListeners(),r}},Nv=zf,yp=e=>{let r=Math.ceil(Math.sqrt(e.length)),o=[],n=u=>e.slice(u*r,u*r+r).reduce((x,E)=>{let{height:v}=br(E.elements);return Math.max(x,v)},0),i=u=>{let h=0,x=0,E=0;for(let v of e){if(h%r===0&&(x=0),x===u){let{width:w}=br(v.elements);E=Math.max(E,w)}h++,x++}return E},a=0,l=0,s=0,c=0,d=0,m=0,p=0;for(let u of e){d&&d%r===0&&(l+=s+50,a=0,m=0,p++),m===0&&(s=n(p)),c=i(m);let{minX:h,minY:x,width:E,height:v}=br(u.elements),w=(c-E)/2,y=(s-v)/2;o.push(...u.elements.map(I=>({...I,x:I.x+a+w-h,y:I.y+l+y-x}))),a+=c+50,d++,m++}return o},Gf=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(rd.addLibrary)||new URLSearchParams(window.location.search).get(td.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},Ul=class e{static queue=new bp;static async getLibraryItems(t,r,o=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await t.load({source:r});i(aa(l?.libraryItems||[],"published"))}catch(l){a(l)}});return o?e.queue.push(n):n()}static run=async(t,r)=>{let o=new e(t);return e.queue.push(()=>r(o))};adapter;constructor(t){this.adapter=t}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}},vc=0,xp=0,Ep=e=>Tg(e.map(t=>`${t.id}:${vg(t.elements)}`).sort().join()),Pv=async(e,t)=>{try{return xp++,await Ul.run(e,async r=>{let o=$(await r.getLibraryItems("save"));for(let[l]of t.deletedItems)o.delete(l);let n=[];for(let[l,s]of t.addedItems)o.has(l)?o.set(l,s):n.push(s);let i=n.concat(Array.from(o.values())),a=Ep(i);return a!==vc&&await e.save({libraryItems:i}),vc=a,i})}finally{xp--}},Nk=e=>{let{excalidrawAPI:t}=e,r=Lv(e);r.current=e;let o=Lv(!1);Mv(()=>{if(!t)return;o.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(m,p)=>{try{let h=await(await fetch(decodeURIComponent(l))).blob();m(h)}catch(u){p(u)}}),d=s!==t.id;await(d&&document.hidden?new Promise(m=>{window.addEventListener("focus",()=>m(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(m){throw m}finally{if(window.location.hash.includes(rd.addLibrary)){let m=new URLSearchParams(window.location.hash.slice(1));m.delete(rd.addLibrary),window.history.replaceState({},is,`#${m.toString()}`)}else if(window.location.search.includes(td.addLibrary)){let m=new URLSearchParams(window.location.search);m.delete(td.addLibrary),window.history.replaceState({},is,`?${m.toString()}`)}}},i=l=>{l.preventDefault();let s=Gf();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Gf();if(a&&n(a),"getInitialLibraryItems"in r.current&&r.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(r.current.getInitialLibraryItems()).then(l=>{t.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in r.current&&r.current.adapter){let l=r.current.adapter,s=r.current.migrationAdapter,c=md();s?c.resolve(gs(s.load).then(async d=>{let m=null;try{if(!d)return Ul.getLibraryItems(l,"load");m=aa(d.libraryItems||[],"published");let p=await Pv(l,Rv([],m));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),m}}).catch(d=>(console.error(`error during library migration: ${d.message}`),Ul.getLibraryItems(l,"load")))):c.resolve(gs(Ul.getLibraryItems,l,"load")),t.updateLibrary({libraryItems:c.then(d=>{let m=d||[];return vc=Ep(m),m}),merge:!0}).finally(()=>{o.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[t]),Mv(()=>{let n=_v.on(async(a,l)=>{let s=o.current,c="adapter"in r.current&&r.current.adapter||null;try{c&&vc!==Ep(l)&&await Pv(c,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),s&&r.current.excalidrawAPI&&r.current.excalidrawAPI.updateScene({appState:{errorMessage:b("errors.saveLibraryError")}})}}),i=a=>{xp&&px(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),vc=0,xp=0}},[])};Eo();f();Pn();import{useCallback as Kl,useEffect as UA,useMemo as c3,useRef as WA,useState as VA}from"react";z();f();import{forwardRef as Ov}from"react";import Bv from"clsx";import{jsx as Fv}from"react/jsx-runtime";var Ok=Ov(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>Fv("div",{className:Bv("Stack Stack_horizontal",n),style:{"--gap":t,alignItems:r,justifyContent:o,...i},ref:a,children:e})),Bk=Ov(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>Fv("div",{className:Bv("Stack Stack_vertical",n),style:{"--gap":t,justifyItems:r,justifyContent:o,...i},ref:a,children:e})),Ft={Row:Ok,Col:Bk};G();In();f();f();G();import{jsx as Hk}from"react/jsx-runtime";var Fk=({theme:e,id:t,libraryReturnUrl:r})=>{let o=r||window.location.origin+window.location.pathname;return Hk("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${o}&useHash=true&token=${t}&theme=${e}&version=${Ui.excalidrawLibrary}`,target:"_excalidraw_libraries",children:b("labels.libraries")})},Hv=Fk;import zk from"clsx";import{jsx as Gk,jsxs as Uk}from"react/jsx-runtime";var wp=({libraryReturnUrl:e,theme:t,id:r,style:o,children:n,className:i})=>Uk("div",{className:zk("library-menu-control-buttons",i),style:o,children:[Gk(Hv,{id:r,libraryReturnUrl:e,theme:t}),n]});f();import{useCallback as wA,useState as Xf}from"react";f();import vp from"react";var Wk=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,Vk=/{{([\w-]+)}}/,Yk=/<([\w-]+)>/,Kk=/<\/([\w-]+)>/,$k=(e,t)=>{let r=[{name:"",children:[]}];return e.split(Wk).filter(Boolean).forEach(o=>{let n=o.match(Yk),i=o.match(Kk),a=o.match(Vk);if(n!==null){let l=n[1];t.hasOwnProperty(l)?r.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===r[r.length-1].name){let s=r.pop(),c=vp.createElement(vp.Fragment,{},...s.children),d=t[s.name];typeof d=="function"&&r[r.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let l=a[1];t.hasOwnProperty(l)?r[r.length-1].children.push(t[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else r[r.length-1].children.push(o)}),r.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),r[0].children},Xk=({i18nKey:e,children:t,...r})=>{let{t:o}=yt();return vp.createElement(vp.Fragment,{},...$k(o(e),r))},sr=Xk;Pn();An();z();import{useAtom as Zf}from"jotai";f();f();import Zk from"clsx";import{jsx as Tp,jsxs as qk}from"react/jsx-runtime";var jk=({label:e,onClick:t,className:r,children:o,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return qk("button",{className:Zk("Dialog__action-button",s,r),type:i,"aria-label":e,onClick:t,...l,children:[o&&Tp("div",{style:a?{visibility:"hidden"}:{},children:o}),Tp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Tp("div",{style:{position:"absolute",inset:0},children:Tp(Ut,{})})]})},Wl=jk;import{useSetAtom as Jk}from"jotai";import{jsx as zv,jsxs as Gv}from"react/jsx-runtime";var Qk=e=>{let{onConfirm:t,onCancel:r,children:o,confirmText:n=b("buttons.confirm"),cancelText:i=b("buttons.cancel"),className:a="",...l}=e,s=_e(),c=Jk(Vl,Be),{container:d}=Bt();return Gv(st,{onCloseRequest:r,size:"small",...l,className:`confirm-dialog ${a}`,children:[o,Gv("div",{className:"confirm-dialog-buttons",children:[zv(Wl,{label:i,onClick:()=>{s({openMenu:null}),c(!1),r(),d?.focus()}}),zv(Wl,{label:n,onClick:()=>{s({openMenu:null}),c(!1),t(),d?.focus()},actionType:"danger"})]})]})},Sp=Qk;f();import{useCallback as eA,useEffect as Wf,useRef as Uv,useState as Uf}from"react";import Ip from"open-color";da();G();Er();z();f();var Tr=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),!1}}static get(t){try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):null}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),null}}static set=(t,r)=>{try{return window.localStorage.setItem(t,JSON.stringify(r)),!0}catch(o){return console.warn(`localStorage.setItem error: ${o.message}`),!1}};static delete=t=>{try{window.localStorage.removeItem(t)}catch(r){console.warn(`localStorage.removeItem error: ${r.message}`)}}};import{jsx as ye,jsxs as tr}from"react/jsx-runtime";var tA=async e=>{let o=Math.round(8),n=Math.max(Math.round(128/64),2),i=cx(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(o*2)-o*2,a.height=i.length*128+(i.length+1)*(o*2)-o*2;let l=a.getContext("2d");l.fillStyle=Ip.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let d=await hi({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:m,height:p}=d,u=Math.floor(s/6)*(128+o*2),h=s%6*(128+o*2);l.drawImage(d,h+(128-m)/2+o,u+(128-p)/2+o),l.lineWidth=n,l.strokeStyle=Ip.gray[4],l.strokeRect(h+o/2,u+o/2,128+o,128+o)}return await Ks(new File([await Ln(a)],"preview",{type:J.png}),{outputType:J.jpg,maxWidthOrHeight:5e3})},rA=({libItem:e,appState:t,index:r,onChange:o,onRemove:n})=>{let i=Uv(null),a=Uv(null);return Wf(()=>{let l=i.current;l&&(async()=>{let s=await xl({elements:e.elements,appState:{...t,viewBackgroundColor:Ip.white,exportBackground:!0},files:null});l.innerHTML=s.outerHTML})()},[e.elements,t]),tr("div",{className:"single-library-item",children:[e.status==="published"&&ye("span",{className:"single-library-item-status",children:b("labels.statusPublished")}),ye("div",{ref:i,className:"single-library-item__svg"}),ye(ae,{"aria-label":b("buttons.remove"),type:"button",icon:ro,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:b("buttons.remove")}),tr("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[tr("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[tr("div",{style:{padding:"0.5em 0"},children:[ye("span",{style:{fontWeight:500,color:Ip.gray[6]},children:b("publishDialog.itemName")}),ye("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ye("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{o(l.target.value,r)}})]}),ye("span",{className:"error",children:e.error})]})]})},oA=({onClose:e,libraryItems:t,appState:r,onSuccess:o,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Uf({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=Uf(!1);Wf(()=>{let y=Tr.get($r.PUBLISH_LIBRARY);y&&s(y)},[]);let[m,p]=Uf(t.slice());Wf(()=>{p(t.slice())},[t]);let u=y=>{s({...l,[y.target.name]:y.target.value})},h=async y=>{y.preventDefault(),d(!0);let I=[],P=!1;if(m.forEach(M=>{let k="";M.name||(k=b("publishDialog.errors.required"),P=!0),I.push({...M,error:k})}),P){p(I),d(!1);return}let C=await tA(m),_={type:jt.excalidrawLibrary,version:Ui.excalidrawLibrary,source:ds,libraryItems:m},D=JSON.stringify(_,null,2),H=new Blob([D],{type:"application/json"}),A=new FormData;A.append("excalidrawLib",H),A.append("previewImage",C),A.append("previewImageType",C.type),A.append("title",l.name),A.append("authorName",l.authorName),A.append("githubHandle",l.githubHandle),A.append("name",l.name),A.append("description",l.description),A.append("twitterHandle",l.twitterHandle),A.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:A}).then(M=>M.ok?M.json().then(({url:k})=>{Tr.delete($r.PUBLISH_LIBRARY),o({url:k,authorName:l.authorName,items:m})}):M.json().catch(()=>{throw new Error(M.statusText||"something went wrong")}).then(k=>{throw new Error(k.message||M.statusText||"something went wrong")}),M=>{console.error(M),n(M),d(!1)}).catch(M=>{console.error(M),n(M),d(!1)})},x=()=>{let y=[];return m.forEach((I,P)=>{y.push(ye("div",{className:"single-library-item-wrapper",children:ye(rA,{libItem:I,appState:r,index:P,onChange:(C,_)=>{let D=m.slice();D[_].name=C,p(D)},onRemove:a})},P))}),ye("div",{className:"selected-library-items",children:y})},E=eA(()=>{i(m),Tr.set($r.PUBLISH_LIBRARY,l),e()},[m,e,i,l]),v=!!t.length,w=t.some(y=>y.status==="published");return ye(st,{onCloseRequest:E,title:b("publishDialog.title"),className:"publish-library",children:v?tr("form",{onSubmit:h,children:[ye("div",{className:"publish-library-note",children:ye(sr,{i18nKey:"publishDialog.noteDescription",link:y=>ye("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:y})})}),ye("span",{className:"publish-library-note",children:ye(sr,{i18nKey:"publishDialog.noteGuidelines",link:y=>ye("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),ye("div",{className:"publish-library-note",children:b("publishDialog.noteItems")}),w&&ye("span",{className:"publish-library-note publish-library-warning",children:b("publishDialog.republishWarning")}),x(),tr("div",{className:"publish-library__fields",children:[tr("label",{children:[tr("div",{children:[ye("span",{children:b("publishDialog.libraryName")}),ye("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ye("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:b("publishDialog.placeholder.libraryName")})]}),tr("label",{style:{alignItems:"flex-start"},children:[tr("div",{children:[ye("span",{children:b("publishDialog.libraryDesc")}),ye("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ye("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:b("publishDialog.placeholder.libraryDesc")})]}),tr("label",{children:[tr("div",{children:[ye("span",{children:b("publishDialog.authorName")}),ye("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ye("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:b("publishDialog.placeholder.authorName")})]}),tr("label",{children:[ye("span",{children:b("publishDialog.githubUsername")}),ye("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:b("publishDialog.placeholder.githubHandle")})]}),tr("label",{children:[ye("span",{children:b("publishDialog.twitterUsername")}),ye("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:b("publishDialog.placeholder.twitterHandle")})]}),tr("label",{children:[ye("span",{children:b("publishDialog.website")}),ye("input",{type:"text",name:"website",pattern:"https?://.+",title:b("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:b("publishDialog.placeholder.website")})]}),ye("span",{className:"publish-library-note",children:ye(sr,{i18nKey:"publishDialog.noteLicense",link:y=>ye("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),tr("div",{className:"publish-library__buttons",children:[ye(Wl,{label:b("buttons.cancel"),onClick:E,"data-testid":"cancel-clear-canvas-button"}),ye(Wl,{type:"submit",label:b("buttons.submit"),actionType:"primary",isLoading:c})]})]}):ye("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:b("publishDialog.atleastOneLibItem")})})},Wv=oA;f();f();import nA from"clsx";import{jsx as iA}from"react/jsx-runtime";var Vv=({className:e="",children:t,onToggle:r,title:o,...n})=>{let i=Ie(),a=nA(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return iA("button",{"data-prevent-outside-click":!0,className:a,onClick:r,type:"button","data-testid":"dropdown-menu-button",title:o,...n,children:t})},Yv=Vv;Vv.displayName="DropdownMenuTrigger";f();f();G();z();import aA,{useContext as lA}from"react";var Vf=aA.createContext({}),Cp=(e="",t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?"dropdown-menu-item--selected":""}`.trim(),kp=(e,t)=>{let r=lA(Vf);return Xn(e,o=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});t?.(n),n.defaultPrevented||r.onSelect?.(n)})};f();import{Fragment as cA,jsx as Yf,jsxs as dA}from"react/jsx-runtime";var sA=({icon:e,shortcut:t,children:r})=>{let o=Ie();return dA(cA,{children:[Yf("div",{className:"dropdown-menu-item__icon",children:e}),Yf("div",{className:"dropdown-menu-item__text",children:r}),t&&!o.editor.isMobile&&Yf("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Ap=sA;import{jsx as Kf}from"react/jsx-runtime";var $f=({icon:e,onSelect:t,children:r,shortcut:o,className:n,selected:i,...a})=>{let l=kp(a.onClick,t);return Kf("button",{...a,onClick:l,type:"button",className:Cp(n,i),title:a.title??a["aria-label"],children:Kf(Ap,{icon:e,shortcut:o,children:r})})};$f.displayName="DropdownMenuItem";var Kv=({children:e})=>Kf("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",background:"pink",borderRadius:6,fontSize:9,color:"black",fontFamily:"Cascadia, monospace"},children:e});Kv.displayName="DropdownMenuItemBadge";$f.Badge=Kv;var so=$f;f();import{jsx as mA}from"react/jsx-runtime";var $v=()=>mA("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Xv=$v;$v.displayName="DropdownMenuSeparator";f();import{jsx as pA,jsxs as uA}from"react/jsx-runtime";var Zv=({children:e,className:t="",style:r,title:o})=>uA("div",{className:`dropdown-menu-group ${t}`,style:r,children:[o&&pA("p",{className:"dropdown-menu-group-title",children:o}),e]}),jv=Zv;Zv.displayName="DropdownMenuGroup";f();import hA from"clsx";import{useEffect as gA,useRef as fA}from"react";ue();G();import{jsx as Mp}from"react/jsx-runtime";var qv=({children:e,onClickOutside:t,className:r="",onSelect:o,style:n})=>{let i=Ie(),a=fA(null),l=Dl({onClickOutside:t});_l(a,()=>{l.onClickOutside?.()}),gA(()=>{let c=m=>{m.key===S.ESCAPE&&(m.stopImmediatePropagation(),l.onClickOutside?.())},d={capture:!0};return document.addEventListener("keydown",c,d),()=>{document.removeEventListener("keydown",c,d)}},[l]);let s=hA(`dropdown-menu ${r}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Mp(Vf.Provider,{value:{onSelect:o},children:Mp("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Mp(Ft.Col,{className:"dropdown-menu-container",children:e}):Mp($t,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};qv.displayName="DropdownMenuContent";var Jv=qv;f();import{jsx as Qv}from"react/jsx-runtime";var e3=({icon:e,shortcut:t,href:r,children:o,onSelect:n,className:i="",selected:a,...l})=>{let s=kp(l.onClick,n);return Qv("a",{...l,href:r,target:"_blank",rel:"noreferrer",className:Cp(i,a),title:l.title??l["aria-label"],onClick:s,children:Qv(Ap,{icon:e,shortcut:t,children:o})})},Yl=e3;e3.displayName="DropdownMenuItemLink";f();import{jsx as xA}from"react/jsx-runtime";var bA=({children:e,className:t="",selected:r,...o})=>xA("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${r?"dropdown-menu-item--selected":""}`.trim(),children:e}),t3=bA;f();import Lp from"react";var r3=e=>{let t=Lp.Children.toArray(e).find(r=>Lp.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuTrigger");return t||null},o3=e=>{let t=Lp.Children.toArray(e).find(r=>Lp.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuContent");return t||null};import{Fragment as EA,jsxs as yA}from"react/jsx-runtime";var Fn=({children:e,open:t})=>{let r=r3(e),o=o3(e);return yA(EA,{children:[r,t&&o]})};Fn.Trigger=Yv;Fn.Content=Jv;Fn.Item=so;Fn.ItemLink=Yl;Fn.ItemCustom=t3;Fn.Group=jv;Fn.Separator=Xv;var Oe=Fn;Fn.displayName="DropdownMenu";import vA from"clsx";import{jsx as Sr,jsxs as Pp}from"react/jsx-runtime";var TA=(e,t)=>e.filter(r=>t.includes(r.id)),SA=({setAppState:e,selectedItems:t,library:r,onRemoveFromLibrary:o,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=Zf(Ca,Be),[c,d]=Zf(Vl,Be),m=()=>{let A=t.length?b("alerts.removeItemsFromsLibrary",{count:t.length}):b("alerts.resetLibrary"),M=t.length?b("confirmDialog.removeItemsFromLib"):b("confirmDialog.resetLibrary");return Sr(Sp,{onConfirm:()=>{t.length?o():n(),u(!1)},onCancel:()=>{u(!1)},title:M,children:Sr("p",{children:A})})},[p,u]=Xf(!1),h=!!t.length,x=h?s.libraryItems.filter(A=>t.includes(A.id)):s.libraryItems,E=h?b("buttons.remove"):b("buttons.resetLibrary"),[v,w]=Xf(!1),[y,I]=Xf(null),P=wA(()=>Pp(st,{onCloseRequest:()=>I(null),title:b("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Sr("p",{children:Sr(sr,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:A=>Sr("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:A})})}),Sr(ae,{type:"button",title:b("buttons.close"),"aria-label":b("buttons.close"),label:b("buttons.close"),onClick:()=>I(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[I,y]),C=(A,M)=>{w(!1),I({url:A.url,authorName:A.authorName});let k=M.slice();k.forEach(O=>{t.includes(O.id)&&(O.status="published")}),r.setLibrary(k)},_=async()=>{try{await r.updateLibrary({libraryItems:al({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(A){if(A?.name==="AbortError"){console.warn(A);return}e({errorMessage:b("errors.importLibraryError")})}},D=async()=>{let A=h?x:await r.getLatestLibrary();gE(A).catch(dd).catch(M=>{e({errorMessage:M.message})})},H=()=>Pp(Oe,{open:c,children:[Sr(Oe.Trigger,{onToggle:()=>d(!c),children:My}),Pp(Oe.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!h&&Sr(Oe.Item,{onSelect:_,icon:Cl,"data-testid":"lib-dropdown--load",children:b("buttons.load")}),!!x.length&&Sr(Oe.Item,{onSelect:D,icon:ba,"data-testid":"lib-dropdown--export",children:b("buttons.export")}),!!x.length&&Sr(Oe.Item,{onSelect:()=>u(!0),icon:Lo,children:E}),h&&Sr(Oe.Item,{icon:F2,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:b("buttons.publishLibrary")})]})]});return Pp("div",{className:vA("library-menu-dropdown-container",l),children:[H(),t.length>0&&Sr("div",{className:"library-actions-counter",children:t.length}),p&&m(),v&&Sr(Wv,{onClose:()=>w(!1),libraryItems:TA(s.libraryItems,t),appState:a,onSuccess:A=>C(A,s.libraryItems),onError:A=>window.alert(A),updateItemsInStorage:()=>r.setLibrary(s.libraryItems),onRemove:A=>i(t.filter(M=>M!==A))}),y&&P()]})},jf=({selectedItems:e,onSelectItems:t,className:r})=>{let{library:o}=wr(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=fp(),a=Me(),l=_e(),[s]=Zf(Ca,Be),c=async m=>{let p=m.filter(u=>!e.includes(u.id));o.setLibrary(p).catch(()=>{l({errorMessage:b("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return Sr(SA,{appState:a,setAppState:l,selectedItems:e,onSelectItems:t,library:o,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{o.resetLibrary(),n()},className:r})};f();import{memo as DA,useEffect as RA,useState as NA}from"react";f();import n3 from"clsx";import{memo as IA,useEffect as CA,useRef as kA,useState as AA}from"react";import{jsx as _p,jsxs as MA}from"react/jsx-runtime";var i3=IA(({id:e,elements:t,isPending:r,onClick:o,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=kA(null),c=Av(e,t,l);CA(()=>{let h=s.current;if(h)return c&&(h.innerHTML=c.outerHTML),()=>{h.innerHTML=""}},[c]);let[d,m]=AA(!1),p=Ie().editor.isMobile,u=r&&_p("div",{className:"library-unit__adder",children:Ay});return MA("div",{className:n3("library-unit",{"library-unit__active":t,"library-unit--hover":t&&d,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[_p("div",{className:n3("library-unit__dragger",{"library-unit__pulse":!!r}),ref:s,draggable:!!t,onClick:t||r?h=>{e&&h.shiftKey?i(e,h):o(e)}:void 0,onDragStart:h=>{if(!e){h.preventDefault();return}m(!1),a(e,h)}}),u,e&&t&&(d||p||n)&&_p(Ta,{checked:n,onChange:(h,x)=>i(e,x),className:"library-unit__checkbox"})]})}),a3=()=>_p("div",{className:"library-unit library-unit--skeleton"});f();import LA,{useCallback as PA}from"react";function _A(){return[!1,PA(t=>t(),[])]}var l3=LA.useTransition||_A;import{Fragment as OA,jsx as Dp}from"react/jsx-runtime";var qf=({children:e})=>Dp("div",{className:"library-menu-items-container__grid",children:e}),Rp=DA(({items:e,onItemSelectToggle:t,onItemDrag:r,isItemSelected:o,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=l3(),[s,c]=NA(0);return RA(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Dp(OA,{children:e.map((d,m)=>m<s?Dp(i3,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:n,svgCache:i,id:d?.id,selected:o(d.id),onToggle:t,onDrag:r},d?.id??m):Dp(a3,{},m))})});f();import{useEffect as BA}from"react";import{atom as FA,useAtom as HA}from"jotai";import zA from"lodash.throttle";var GA=FA(0),s3=e=>{let[t,r]=HA(GA);return BA(()=>{let{current:o}=e;if(!o)return;let n=zA(()=>{let{scrollTop:i}=o;r(i)},200);return o.addEventListener("scroll",n),()=>{n.cancel(),o.removeEventListener("scroll",n)}},[e,r]),t};import{Fragment as d3,jsx as Ir,jsxs as $l}from"react/jsx-runtime";var YA=17,KA=64;function Jf({isLoading:e,libraryItems:t,onAddToLibrary:r,onInsertLibraryItems:o,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let d=WA(null),m=s3(d);UA(()=>{m>0&&d.current?.scrollTo(0,m)},[]);let{svgCache:p}=fp(),u=c3(()=>t.filter(A=>A.status!=="published"),[t]),h=c3(()=>t.filter(A=>A.status==="published"),[t]),x=!t.length&&!n.length,E=!n.length&&!u.length&&!h.length,[v,w]=VA(null),y=Kl((A,M)=>{let k=!c.includes(A),O=[...u,...h];if(k){if(M.shiftKey&&v){let X=O.findIndex(le=>le.id===v),Y=O.findIndex(le=>le.id===A);if(X===-1||Y===-1){s([...c,A]);return}let ee=$(c),xe=O.reduce((le,V,ve)=>((ve>=X&&ve<=Y||ee.has(V.id))&&le.push(V.id),le),[]);s(xe)}else s([...c,A]);w(A)}else w(null),s(c.filter(X=>X!==A))},[v,s,h,c,u]),I=Kl(A=>{let M;return c.includes(A)?M=t.filter(k=>c.includes(k.id)):M=t.filter(k=>k.id===A),M.map(k=>({...k,elements:$d(k.elements,{randomizeSeed:!0})}))},[t,c]),P=Kl((A,M)=>{M.dataTransfer.setData(J.excalidrawlib,tm(I(A)))},[I]),C=Kl(A=>A?c.includes(A):!1,[c]),_=Kl(()=>{r(n)},[n,r]),D=Kl(A=>{A&&o(I(A))},[I,o]),H=p.size>=t.length?KA:YA;return $l("div",{className:"library-menu-items-container",style:n.length||u.length||h.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!E&&Ir(jf,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),$l(Ft.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:h.length>0?1:"0 1 auto",marginBottom:0},ref:d,children:[$l(d3,{children:[!E&&Ir("div",{className:"library-menu-items-container__header",children:b("labels.personalLib")}),e&&Ir("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Ir(Ut,{})}),!n.length&&!u.length?$l("div",{className:"library-menu-items__no-items",children:[Ir("div",{className:"library-menu-items__no-items__label",children:b("library.noItems")}),Ir("div",{className:"library-menu-items__no-items__hint",children:h.length>0?b("library.hint_emptyPrivateLibrary"):b("library.hint_emptyLibrary")})]}):$l(qf,{children:[n.length>0&&Ir(Rp,{itemsRenderedPerBatch:H,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:P,onClick:_,isItemSelected:C,svgCache:p}),Ir(Rp,{itemsRenderedPerBatch:H,items:u,onItemSelectToggle:y,onItemDrag:P,onClick:D,isItemSelected:C,svgCache:p})]})]}),$l(d3,{children:[(h.length>0||n.length>0||u.length>0)&&Ir("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:b("labels.excalidrawLib")}),h.length>0?Ir(qf,{children:Ir(Rp,{itemsRenderedPerBatch:H,items:h,onItemSelectToggle:y,onItemDrag:P,onClick:D,isItemSelected:C,svgCache:p})}):u.length>0?Ir("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:b("library.noItems")}):null]}),x&&Ir(wp,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:Ir(jf,{selectedItems:c,onSelectItems:s})})]})]})}import{atom as XA,useAtom as ZA}from"jotai";Ve();z();G();import{jsx as wi,jsxs as p3}from"react/jsx-runtime";var Vl=XA(!1),m3=({children:e})=>wi("div",{className:"layer-ui__library",children:e}),jA=({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:r,setAppState:o,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[d]=ZA(Ca,Be),m=e1(h=>{(async(E,v)=>{fe("element","addToLibrary","ui");for(let y of id)if(E.some(I=>I.type===y))return o({errorMessage:b(`errors.libraryElementTypeError.${y}`)});let w=[{status:"unpublished",elements:E,id:Pt(),created:Date.now()},...v];r(),i.setLibrary(w).catch(()=>{o({errorMessage:b("alerts.errorAddingToLibrary")})})})(h,d.libraryItems)},[r,i,o,d.libraryItems]),p=u3(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return wi(m3,{children:wi("div",{className:"layer-ui__library-message",children:p3("div",{children:[wi(Ut,{size:"2em"}),wi("span",{children:b("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||t.length>0;return p3(m3,{children:[wi(Jf,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:m,onInsertLibraryItems:e,pendingElements:t,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&wi(wp,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})},qA=(e,t)=>{let r=()=>me(t,e,{includeBoundTextElement:!0,includeElementsInFrames:!0}),o=Qf(r()),n=Qf(e),i=Qf(t);return(!wt(e.selectedElementIds,n.current.selectedElementIds)||!wt(t,i.current))&&(o.current=r(),n.current=e,i.current=t),o.current},h3=()=>{let{library:e,id:t,onInsertElements:r}=wr(),o=yi(),n=Me(),i=_e(),a=bi(),[l,s]=$A([]),c=u3(()=>e,[e]),d=qA(n,a),m=e1(u=>{r(yp(u))},[r]),p=e1(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return wi(jA,{pendingElements:d,onInsertLibraryItems:m,onAddToLibrary:p,setAppState:i,libraryReturnUrl:o.libraryReturnUrl,library:c,id:t,theme:n.theme,selectedItems:l,onSelectItems:s})};import{jsx as Tc,jsxs as oM}from"react/jsx-runtime";function rM(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var st=e=>{let[t,r]=Sv(),[o]=eM(document.activeElement),{id:n}=Bt(),i=Ie().viewport.isMobile;QA(()=>{if(!t)return;let c=us(t);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=m=>{if(m.key===S.TAB){let p=us(t),{activeElement:u}=document,h=p.findIndex(x=>x===u);h===0&&m.shiftKey?(p[p.length-1].focus(),m.preventDefault()):h===p.length-1&&!m.shiftKey&&(p[0].focus(),m.preventDefault())}};return t.addEventListener("keydown",d),()=>t.removeEventListener("keydown",d)},[t,e.autofocus]);let a=_e(),l=tM(Vl,Be),s=()=>{a({openMenu:null}),l(!1),o.focus(),e.onCloseRequest()};return Tc(Cv,{className:JA("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:rM(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:oM($t,{ref:r,children:[e.title&&Tc("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Tc("span",{className:"Dialog__titleContent",children:e.title})}),i&&Tc("button",{className:"Dialog__close",onClick:s,title:b("buttons.close"),"aria-label":b("buttons.close"),children:ro}),Tc("div",{className:"Dialog__content",children:e.children})]})})};f();import{forwardRef as aM,useRef as lM,useImperativeHandle as sM,useLayoutEffect as cM,useState as dM}from"react";import t1 from"clsx";f();z();import nM from"clsx";import{jsx as iM}from"react/jsx-runtime";var Jo=({type:e="button",onSelect:t,selected:r,children:o,className:n="",...i})=>iM("button",{onClick:Xn(i.onClick,a=>{t()}),type:e,className:nM("excalidraw-button",n,{selected:r}),...i,children:o});import{jsx as r1,jsxs as g3}from"react/jsx-runtime";var Np=aM(({onChange:e,label:t,fullWidth:r,placeholder:o,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,...s},c)=>{let d=lM(null);sM(c,()=>d.current),cM(()=>{i&&d.current?.select()},[i]);let[m,p]=dM(!1);return g3("div",{className:t1("ExcTextField",{"ExcTextField--fullWidth":r}),onClick:()=>{d.current?.focus()},children:[r1("div",{className:"ExcTextField__label",children:t}),g3("div",{className:t1("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[r1("input",{className:t1({"is-redacted":"value"in s&&s.value&&l&&!m}),readOnly:n,value:"value"in s?s.value:void 0,defaultValue:"defaultValue"in s?s.defaultValue:void 0,placeholder:o,ref:d,onChange:u=>e?.(u.target.value),onKeyDown:a}),l&&r1(Jo,{onSelect:()=>p(!m),style:{border:0,userSelect:"none"},children:m?Y2:Ml})]})]})});Ve();import S3 from"clsx";f();G();z();var mM={toggleTheme:[R("Shift+Alt+D")],saveScene:[R("CtrlOrCmd+S")],loadScene:[R("CtrlOrCmd+O")],clearCanvas:[R("CtrlOrCmd+Delete")],imageExport:[R("CtrlOrCmd+Shift+E")],commandPalette:[R("CtrlOrCmd+/"),R("CtrlOrCmd+Shift+P")],cut:[R("CtrlOrCmd+X")],copy:[R("CtrlOrCmd+C")],paste:[R("CtrlOrCmd+V")],copyStyles:[R("CtrlOrCmd+Alt+C")],pasteStyles:[R("CtrlOrCmd+Alt+V")],selectAll:[R("CtrlOrCmd+A")],deleteSelectedElements:[R("Delete")],duplicateSelection:[R("CtrlOrCmd+D"),R(`Alt+${b("helpDialog.drag")}`)],sendBackward:[R("CtrlOrCmd+[")],bringForward:[R("CtrlOrCmd+]")],sendToBack:[rr?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")],bringToFront:[rr?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")],copyAsPng:[R("Shift+Alt+C")],copyAsSvg:[],group:[R("CtrlOrCmd+G")],ungroup:[R("CtrlOrCmd+Shift+G")],gridMode:[R("CtrlOrCmd+'")],zenMode:[R("Alt+Z")],objectsSnapMode:[R("Alt+S")],stats:[R("Alt+/")],addToLibrary:[],flipHorizontal:[R("Shift+H")],flipVertical:[R("Shift+V")],viewMode:[R("Alt+R")],hyperlink:[R("CtrlOrCmd+K")],toggleElementLock:[R("CtrlOrCmd+Shift+L")],resetZoom:[R("CtrlOrCmd+0")],zoomOut:[R("CtrlOrCmd+-")],zoomIn:[R("CtrlOrCmd++")],zoomToFitSelection:[R("Shift+3")],zoomToFit:[R("Shift+1")],zoomToFitSelectionInViewport:[R("Shift+2")],toggleEraserTool:[R("E")],toggleHandTool:[R("H")],setFrameAsActiveTool:[R("F")],saveFileToDisk:[R("CtrlOrCmd+S")],saveToActiveFile:[R("CtrlOrCmd+S")],toggleShortcuts:[R("?")]},It=(e,t=0)=>{let r=mM[e];return r&&r.length>0?r[t]||r[0]:""};G();import MM from"fuzzy";z();import{atom as LM,useAtom as PM}from"jotai";f();var pM="\\u0300-\\u036f",uM="\\ufe20-\\ufe2f",hM="\\u20d0-\\u20ff",gM=pM+uM+hM,fM=`[${gM}]`,bM=RegExp(fM,"g"),xM=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,EM={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},o1=e=>e.replace(xM,t=>EM[t]||t).replace(bM,"");f();import{jsx as yM}from"react/jsx-runtime";var vi=({icon:e})=>yM("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});f();ue();var Sc=[{icon:Ry,value:"selection",key:S.V,numericKey:S[1],fillable:!0},{icon:Ny,value:"rectangle",key:S.R,numericKey:S[2],fillable:!0},{icon:Oy,value:"diamond",key:S.D,numericKey:S[3],fillable:!0},{icon:By,value:"ellipse",key:S.O,numericKey:S[4],fillable:!0},{icon:Fy,value:"arrow",key:S.A,numericKey:S[5],fillable:!0},{icon:Hy,value:"line",key:S.L,numericKey:S[6],fillable:!0},{icon:Sl,value:"freedraw",key:[S.P,S.X],numericKey:S[7],fillable:!1},{icon:Gy,value:"text",key:S.T,numericKey:S[8],fillable:!1},{icon:Uy,value:"image",key:null,numericKey:S[9],fillable:!1},{icon:Wy,value:"eraser",key:S.E,numericKey:S[0],fillable:!1}],f3=e=>Sc.find((r,o)=>r.numericKey!=null&&e===r.numericKey.toString()||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null;f();import{useState as wM}from"react";Ve();z();Cs();ce();import a1 from"clsx";ut();ue();f();import n1 from"react";import Qo from"tunnel-rat";var i1=n1.createContext(null),et=()=>n1.useContext(i1),b3=()=>n1.useMemo(()=>({MainMenuTunnel:Qo(),WelcomeScreenMenuHintTunnel:Qo(),WelcomeScreenToolbarHintTunnel:Qo(),WelcomeScreenHelpHintTunnel:Qo(),WelcomeScreenCenterTunnel:Qo(),FooterCenterTunnel:Qo(),DefaultSidebarTriggerTunnel:Qo(),DefaultSidebarTabTriggersTunnel:Qo(),OverwriteConfirmDialogTunnel:Qo(),TTDDialogTriggerTunnel:Qo(),jotaiScope:Symbol()}),[]);import{Fragment as Ti,jsx as ot,jsxs as Et}from"react/jsx-runtime";var l1=(e,t)=>{let r=t[0]?.type||null;for(let o of t)if(o.type!==r){r=null;break}return Is(e.activeTool.type)&&e.activeTool.type!=="image"&&r!=="image"&&r!=="frame"&&r!=="magicframe"||t.some(o=>Is(o.type))},s1=(e,t)=>fn(e.activeTool.type)||t.some(r=>fn(r.type)),Op=({appState:e,elementsMap:t,renderAction:r})=>{let o=ga(t,e),n=!1;o.length===2&&(gr(o[0])||gr(o[1]))&&(n=!0);let i=!!e.editingElement,a=Ie(),l=document.documentElement.getAttribute("dir")==="rtl",s=fn(e.activeTool.type)&&!or(e.currentItemBackgroundColor)||o.some(d=>fn(d.type)&&!or(d.backgroundColor)),c=o.length===1||n;return Et("div",{className:"panelColumn",children:[ot("div",{children:l1(e,o)&&r("changeStrokeColor")}),s1(e,o)&&ot("div",{children:r("changeBackgroundColor")}),s&&r("changeFillStyle"),(yd(e.activeTool.type)||o.some(d=>yd(d.type)))&&r("changeStrokeWidth"),(e.activeTool.type==="freedraw"||o.some(d=>d.type==="freedraw"))&&r("changeStrokeShape"),(wd(e.activeTool.type)||o.some(d=>wd(d.type)))&&Et(Ti,{children:[r("changeStrokeStyle"),r("changeSloppiness")]}),(Wa(e.activeTool.type)||o.some(d=>Wa(d.type)))&&ot(Ti,{children:r("changeRoundness")}),(e.activeTool.type==="text"||o.some(U))&&Et(Ti,{children:[r("changeFontSize"),r("changeFontFamily"),(e.activeTool.type==="text"||S0(o,t))&&r("changeTextAlign")]}),T0(o,t)&&r("changeVerticalAlign"),(Yi(e.activeTool.type)||o.some(d=>Yi(d.type)))&&ot(Ti,{children:r("changeArrowhead")}),r("changeOpacity"),Et("fieldset",{children:[ot("legend",{children:b("labels.layers")}),Et("div",{className:"buttonList",children:[r("sendToBack"),r("sendBackward"),r("bringToFront"),r("bringForward")]})]}),o.length>1&&!n&&Et("fieldset",{children:[ot("legend",{children:b("labels.align")}),Et("div",{className:"buttonList",children:[l?Et(Ti,{children:[r("alignRight"),r("alignHorizontallyCentered"),r("alignLeft")]}):Et(Ti,{children:[r("alignLeft"),r("alignHorizontallyCentered"),r("alignRight")]}),o.length>2&&r("distributeHorizontally"),ot("div",{style:{flexBasis:"100%",height:0}}),Et("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[r("alignTop"),r("alignVerticallyCentered"),r("alignBottom"),o.length>2&&r("distributeVertically")]})]})]}),!i&&o.length>0&&Et("fieldset",{children:[ot("legend",{children:b("labels.actions")}),Et("div",{className:"buttonList",children:[!a.editor.isMobile&&r("duplicateSelection"),!a.editor.isMobile&&r("deleteSelectedElements"),r("group"),r("ungroup"),c&&r("hyperlink")]})]})]})},Bp=({activeTool:e,appState:t,app:r,UIOptions:o})=>{let[n,i]=wM(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=et();return Et(Ti,{children:[Sc.map(({value:d,icon:m,key:p,numericKey:u,fillable:h},x)=>{if(o.tools?.[d]===!1)return null;let E=b(`toolBar.${d}`),v=p&&$n(typeof p=="string"?p:p[0]),w=v?`${v} ${b("helpDialog.or")} ${u}`:`${u}`;return ot(ae,{className:a1("Shape",{fillable:h}),type:"radio",icon:m,checked:e.type===d,name:"editor-current-shape",title:`${$n(E)} \u2014 ${w}`,keyBindingLabel:u||v,"aria-label":$n(E),"aria-keyshortcuts":w,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:y})=>{!t.penDetected&&y==="pen"&&r.togglePenMode(!0)},onChange:({pointerType:y})=>{t.activeTool.type!==d&&fe("toolbar",d,"ui"),d==="image"?r.setActiveTool({type:d,insertOnCanvasDirectly:y!=="mouse"}):r.setActiveTool({type:d})}},d)}),ot("div",{className:"App-toolbar__divider"}),Et(Oe,{open:n,children:[Et(Oe.Trigger,{className:a1("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||s||l&&!r.props.isCollaborating}),onToggle:()=>i(!n),title:b("toolBar.extraTools"),children:[W2,r.props.aiEnabled!==!1&&ot("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:8,fontFamily:"Cascadia, monospace",position:"absolute",background:"pink",color:"black",bottom:3,right:4},children:"AI"})]}),Et(Oe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[ot(Oe.Item,{onSelect:()=>r.setActiveTool({type:"frame"}),icon:Ym,shortcut:S.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:b("toolBar.frame")}),ot(Oe.Item,{onSelect:()=>r.setActiveTool({type:"embeddable"}),icon:Yy,"data-testid":"toolbar-embeddable",selected:s,children:b("toolBar.embeddable")}),ot(Oe.Item,{onSelect:()=>r.setActiveTool({type:"laser"}),icon:$m,"data-testid":"toolbar-laser",selected:l,shortcut:S.K.toLocaleUpperCase(),children:b("toolBar.laser")}),ot("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),r.props.aiEnabled!==!1&&ot(c.Out,{}),ot(Oe.Item,{onSelect:()=>r.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Km,"data-testid":"toolbar-embeddable",children:b("toolBar.mermaidToExcalidraw")}),r.props.aiEnabled!==!1&&Et(Ti,{children:[Et(Oe.Item,{onSelect:()=>r.onMagicframeToolSelect(),icon:Al,"data-testid":"toolbar-magicframe",children:[b("toolBar.magicframe"),ot(Oe.Item.Badge,{children:"AI"})]}),ot(Oe.Item,{onSelect:()=>{fe("ai","open-settings","d2c"),r.setOpenDialog({name:"settings",source:"settings",tab:"diagram-to-code"})},icon:dc,"data-testid":"toolbar-magicSettings",children:b("toolBar.magicSettings")})]})]})]})]})},x3=({renderAction:e,zoom:t})=>ot(Ft.Col,{gap:1,className:"zoom-actions",children:Et(Ft.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),E3=({renderAction:e,className:t})=>Et("div",{className:`undo-redo-buttons ${t}`,children:[ot("div",{className:"undo-button-container",children:ot(Ur,{label:b("buttons.undo"),children:e("undo")})}),ot("div",{className:"redo-button-container",children:Et(Ur,{label:b("buttons.redo"),children:[" ",e("redo")]})})]}),y3=({actionManager:e,showExitZenModeBtn:t})=>ot("button",{className:a1("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(zl),children:b("buttons.exitZenMode")}),w3=({renderAction:e,className:t})=>ot("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})});f();import{useRef as vM}from"react";var c1=e=>{let t=vM({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...r)=>t.current.userFn(...r)),t.current.stableFn};f();import{atom as TM,useAtom as SM}from"jotai";import{jsx as CM,jsxs as IM}from"react/jsx-runtime";var ka=TM(null),v3=()=>{let[e,t]=SM(ka,Be),r=_t();return e&&e==="clearCanvas"?CM(Sp,{onConfirm:()=>{r.executeAction(On),t(null)},onCancel:()=>t(null),title:b("clearCanvasDialog.title"),children:IM("p",{className:"clear-canvas__content",children:[" ",b("alerts.clearReset")]})}):null};var d1={};Mu(d1,{toggleTheme:()=>kM});f();var kM={...ya,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(ya,"commandPalette")}};import{jsx as cr,jsxs as en}from"react/jsx-runtime";var _M=LM(null),gt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},DM=e=>{switch(e){case gt.app:return 1;case gt.export:return 2;case gt.editor:return 3;case gt.tools:return 4;case gt.elements:return 5;case gt.links:return 6;default:return 10}},zp=({shortcut:e,className:t,children:r})=>{let o=e.replace("++","+$").split("+");return en("div",{className:S3("shortcut",t),children:[o.map((n,i)=>cr("div",{className:"shortcut-wrapper",children:cr("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),cr("div",{className:"shortcut-desc",children:r})]})},I3=e=>!e.altKey&&e[S.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===S.P||e.key===S.SLASH),Jne=Object.assign(e=>{let t=Me(),r=_e();return Hp(()=>{let o=n=>{I3(n)&&(n.preventDefault(),n.stopPropagation(),r(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&fe("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",o,{capture:!0}),()=>window.removeEventListener("keydown",o,{capture:!0})},[r]),t.openDialog?.name!=="commandPalette"?null:cr(RM,{...e})},{defaultItems:d1});function RM({customCommandPaletteItems:e}){let t=wr(),r=Me(),o=_e(),n=yi(),i=_t(),[a,l]=PM(_M),[s,c]=Fp(null),d=AM(null),m=Dl({uiAppState:r,customCommandPaletteItems:e,appProps:n});Hp(()=>{let{uiAppState:C,customCommandPaletteItems:_,appProps:D}=m,H=O=>{let X="";return O.label&&(typeof O.label=="function"?X=b(O.label(t.scene.getNonDeletedElements(),C,t)):X=b(O.label)),X},A=O=>typeof O.icon=="function"?O.icon(C,t.scene.getNonDeletedElements()):O.icon,M=[],k=(O,X,Y)=>{let ee={label:H(O),icon:A(O),category:X,shortcut:It(O.name),keywords:O.keywords,predicate:O.predicate,viewMode:O.viewMode,perform:()=>{i.executeAction(O,"commandPalette")}};return Y?Y(ee,O):ee};if(C&&t.scene&&i){let O=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.copyStyles,i.actions.pasteStyles,i.actions.sendBackward,i.actions.sendToBack,i.actions.bringForward,i.actions.bringToFront,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,yc].map(V=>k(V,gt.elements,(ve,Re)=>({...ve,predicate:Re.predicate?Re.predicate:(dt,Le,ur,ln)=>me(dt,Le).length>0}))),X=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool].map(V=>k(V,gt.tools)),Y=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(V=>k(V,gt.editor)),ee=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(V=>k(V,gt.export));M=[...O,...Y,{label:H(On),icon:A(On),shortcut:It(On.name),category:gt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Xt.set(ka,"clearCanvas")}},{label:b("buttons.exportImage"),category:gt.export,icon:Gm,shortcut:It("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{o({openDialog:{name:"imageExport"}})}},...ee];let xe=[{label:b("toolBar.library"),category:gt.app,icon:Bm,viewMode:!1,perform:()=>{C.openSidebar?o({openSidebar:null}):o({openSidebar:{name:kr.name,tab:kr.defaultTab}})}},{label:b("labels.changeStroke"),keywords:["color","outline"],category:gt.elements,icon:zm,viewMode:!1,predicate:(V,ve)=>{let Re=me(V,ve);return Re.length>0&&l1(ve,Re)},perform:()=>{o(V=>({openMenu:V.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:b("labels.changeBackground"),keywords:["color","fill"],icon:zm,category:gt.elements,viewMode:!1,predicate:(V,ve)=>{let Re=me(V,ve);return Re.length>0&&s1(ve,Re)},perform:()=>{o(V=>({openMenu:V.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:b("labels.canvasBackground"),keywords:["color"],icon:zm,category:gt.editor,viewMode:!1,perform:()=>{o(V=>({openMenu:V.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Sc.reduce((V,ve)=>{let{value:Re,icon:dt,key:Le,numericKey:ur}=ve;if(D.UIOptions.tools?.[Re]===!1)return V;let Gt=Le&&$n(typeof Le=="string"?Le:Le[0])||ur,Do={label:b(`toolBar.${Re}`),category:gt.tools,shortcut:Gt,icon:dt,keywords:["toolbar"],viewMode:!1,perform:({event:sn})=>{Re==="image"?t.setActiveTool({type:Re,insertOnCanvasDirectly:sn.type==="keydown"}):t.setActiveTool({type:Re})}};return V.push(Do),V},[]),...X,{label:b("toolBar.lock"),category:gt.tools,icon:C.activeTool.locked?Tl:fa,shortcut:S.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${b("labels.textToDiagram")}...`,category:gt.tools,icon:$2,viewMode:!1,predicate:D.aiEnabled,perform:()=>{o(V=>({...V,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${b("toolBar.mermaidToExcalidraw")}...`,category:gt.tools,icon:Km,viewMode:!1,predicate:D.aiEnabled,perform:()=>{o(V=>({...V,openDialog:{name:"ttd",tab:"mermaid"}}))}}],le=[...M,...xe,..._||[]].map(V=>({...V,icon:V.icon||Zm,order:V.order??DM(V.category),haystack:`${o1(V.label)} ${V.keywords?.join(" ")||""}`}));c(le),l(le.find(V=>V.label===a?.label)??null)}},[m,t,i,c,a?.label,l,o]);let[p,u]=Fp(""),[h,x]=Fp(null),[E,v]=Fp({}),w=C=>{o({openDialog:null},C),u("")},y=(C,_)=>{r.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{C.perform({actionManager:i,event:_}),l(C),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},I=c1(C=>C.viewMode===!1&&r.viewModeEnabled?!1:typeof C.predicate=="function"?C.predicate(t.scene.getNonDeletedElements(),r,n,t):C.predicate===void 0||C.predicate),P=c1(C=>{let _=Xr(C.target)||I3(C)||C.key===S.ESCAPE;if(_&&C.key!==S.ARROW_UP&&C.key!==S.ARROW_DOWN&&C.key!==S.ENTER)return;let D=Object.values(E).flat(),H=a&&!p&&I(a);if(C.key===S.ARROW_UP){C.preventDefault();let A=D.findIndex(O=>O.label===h?.label);if(H){if(A===0){x(a);return}if(h===a){let O=D[D.length-1];O&&x(O);return}}let M;A===-1?M=D.length-1:M=A===0?D.length-1:(A-1)%D.length;let k=D[M];k&&x(k);return}if(C.key===S.ARROW_DOWN){C.preventDefault();let A=D.findIndex(O=>O.label===h?.label);if(H){if(!h||A===D.length-1){x(a);return}if(h===a){let O=D[0];O&&x(O);return}}let M=(A+1)%D.length,k=D[M];k&&x(k);return}if(C.key===S.ENTER&&h&&setTimeout(()=>{y(h,C)}),!_){if(C.stopPropagation(),/^[a-zA-Z0-9]$/.test(C.key)){d?.current?.focus();return}C.preventDefault()}});return Hp(()=>(window.addEventListener("keydown",P,{capture:!0}),()=>window.removeEventListener("keydown",P,{capture:!0})),[P]),Hp(()=>{if(!s)return;let C=A=>{let M={};for(let k of A)M[k.category]?M[k.category].push(k):M[k.category]=[k];return M},_=s.filter(I).sort((A,M)=>A.order-M.order),D=!p&&a&&I(a);if(!p){v(C(D?_.filter(A=>A.label!==a?.label):_)),x(D?a:_[0]||null);return}let H=o1(p.replace(/[<>-_| ]/g,""));_=MM.filter(H,_,{extract:A=>A.haystack}).sort((A,M)=>M.score-A.score).map(A=>A.original),v(C(_)),x(_[0]??null)},[p,s,I,a]),en(st,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[cr(Np,{value:p,placeholder:b("commandPalette.search.placeholder"),onChange:C=>{u(C)},selectOnRender:!0,ref:d}),!t.device.viewport.isMobile&&en("div",{className:"shortcuts-wrapper",children:[cr(zp,{shortcut:"\u2191\u2193",children:b("commandPalette.shortcuts.select")}),cr(zp,{shortcut:"\u21B5",children:b("commandPalette.shortcuts.confirm")}),cr(zp,{shortcut:R("Esc"),children:b("commandPalette.shortcuts.close")})]}),en("div",{className:"commands",children:[a&&!p&&en("div",{className:"command-category",children:[en("div",{className:"command-category-title",children:[b("commandPalette.recents"),cr("div",{className:"icon",style:{marginLeft:"6px"},children:X2})]}),cr(T3,{command:a,isSelected:a.label===h?.label,onClick:C=>y(a,C),disabled:!I(a),onMouseMove:()=>x(a),showShortcut:!t.device.viewport.isMobile,appState:r})]}),Object.keys(E).length>0?Object.keys(E).map((C,_)=>en("div",{className:"command-category",children:[cr("div",{className:"command-category-title",children:C}),E[C].map(D=>cr(T3,{command:D,isSelected:D.label===h?.label,onClick:H=>y(D,H),onMouseMove:()=>x(D),showShortcut:!t.device.viewport.isMobile,appState:r},D.label))]},C)):s?en("div",{className:"no-match",children:[cr("div",{className:"icon",children:Xm})," ",b("commandPalette.search.noMatch")]}):null]})]})}var T3=({command:e,isSelected:t,disabled:r,onMouseMove:o,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return en("div",{className:S3("command-item",{"item-selected":t,"item-disabled":r}),ref:s=>{t&&!r&&s?.scrollIntoView?.({block:"nearest"})},onClick:r?l:n,onMouseMove:r?l:o,title:r?b("commandPalette.itemNotAvailable"):"",children:[en("div",{className:"name",children:[e.icon&&cr(vi,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&cr(zp,{shortcut:e.shortcut})]})};Qt();ce();Ye();var m1=B({name:"toggleLinearEditor",category:gt.elements,label:(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return t.editingLinearElement?.elementId===o?.id?"labels.lineEditor.exit":"labels.lineEditor.edit"},trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return!!(n.length===1&&re(n[0]))},perform(e,t,r,o){let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],i=t.editingLinearElement?.elementId===n.id?null:new K(n);return{appState:{...t,editingLinearElement:i},commitToHistory:!1}}});f();ue();We();Jr();z();G();wo();import{jsx as M3}from"react/jsx-runtime";var C3=(e,t,r)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingElement&&!t.draggingElement){let n=r();if(n===null)return{commitToHistory:!1};let i=$(e),a=n.elements,l=$(a),s=e.filter(d=>!l.has(d.id)),c=a.map(d=>ne(i.get(d.id)||d,d)).concat(s.map(d=>ne(d,{isDeleted:!0})));return Ja(c,s),Mr(c),{elements:c,appState:{...t,...n.appState},commitToHistory:!1,syncHistory:!0}}return{commitToHistory:!1}},k3=e=>({name:"undo",label:"buttons.undo",icon:_g,trackEvent:{category:"history"},viewMode:!1,perform:(t,r)=>C3(t,r,()=>e.undoOnce()),keyTest:t=>t[S.CTRL_OR_CMD]&&t.key.toLowerCase()===S.Z&&!t.shiftKey,PanelComponent:({updateData:t,data:r})=>M3(ae,{type:"button",icon:_g,"aria-label":b("buttons.undo"),onClick:t,size:r?.size||"medium"}),commitToHistory:()=>!1}),A3=e=>({name:"redo",label:"buttons.redo",icon:Dg,trackEvent:{category:"history"},viewMode:!1,perform:(t,r)=>C3(t,r,()=>e.redoOnce()),keyTest:t=>t[S.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===S.Z||jc&&t.ctrlKey&&!t.shiftKey&&t.key===S.Y,PanelComponent:({updateData:t,data:r})=>M3(ae,{type:"button",icon:Dg,"aria-label":b("buttons.redo"),onClick:t,size:r?.size||"medium"}),commitToHistory:()=>!1});f();z();import{jsx as NM}from"react/jsx-runtime";var p1=(e,t,r,o,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(r,o,i))&&fe(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Gp=class{actions={};updater;getAppState;getElementsIncludingDeleted;app;constructor(t,r,o,n){this.updater=i=>{if(Oo(i))i.then(a=>t(a));else return t(i)},this.getAppState=r,this.getElementsIncludingDeleted=o,this.app=n}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(r=>this.registerAction(r))}handleKeyDown(t){let r=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in r?r[s.name]:!0)&&s.keyTest&&s.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let n=o[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return p1(n,"keyboard",a,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(o[0].perform(i,a,l,this.app)),!0}executeAction(t,r="api",o=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();p1(t,r,i,n,this.app,o),this.updater(t.perform(n,i,o,this.app))}renderAction=(t,r)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in o)||o[t])){let n=this.actions[t],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{p1(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return NM(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:r})}return null};isActionEnabled=t=>{let r=this.getElementsIncludingDeleted(),o=this.getAppState();return!t.predicate||t.predicate(r,o,this.app.props,this.app)}};Ye();Rr();ui();G();cl();ge();Jr();Qt();We();In();ce();f();var u1=e=>{let t=Array.from(e.values());return{x:L3(t,r=>r.x)/t.length,y:L3(t,r=>r.y)/t.length}},h1=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),L3=(e,t)=>e.reduce((r,o)=>r+t(o),0);Nr();f();ce();In();var OM=e=>({selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,viewBackgroundColor:e.viewBackgroundColor,editingLinearElement:e.editingLinearElement,editingGroupId:e.editingGroupId,name:e.name}),g1=class{elementCache=new Map;recording=!0;stateHistory=[];redoStack=[];lastEntry=null;hydrateHistoryEntry({appState:t,elements:r}){return{appState:JSON.parse(t),elements:r.map(o=>{let n=this.elementCache.get(o.id)?.get(o.versionNonce);if(!n)throw new Error(`Element not found: ${o.id}:${o.versionNonce}`);return n})}}dehydrateHistoryEntry({appState:t,elements:r}){return{appState:JSON.stringify(t),elements:r.map(o=>{this.elementCache.has(o.id)||this.elementCache.set(o.id,new Map);let n=this.elementCache.get(o.id);return n.has(o.versionNonce)||n.set(o.versionNonce,Sn(o)),{id:o.id,versionNonce:o.versionNonce}})}}getSnapshotForTest(){return{recording:this.recording,stateHistory:this.stateHistory.map(t=>this.hydrateHistoryEntry(t)),redoStack:this.redoStack.map(t=>this.hydrateHistoryEntry(t))}}clear(){this.stateHistory.length=0,this.redoStack.length=0,this.lastEntry=null,this.elementCache.clear()}generateEntry=(t,r)=>this.dehydrateHistoryEntry({appState:OM(t),elements:r.reduce((o,n)=>{if(re(n)&&t.multiElement&&t.multiElement.id===n.id){if(t.multiElement&&t.multiElement.id===n.id&&n.points.length<2)return o;o.push({...n,points:n.lastCommittedPoint!==n.points[n.points.length-1]?n.points.slice(0,-1):n.points})}else o.push(n);return o},[])});shouldCreateEntry(t){let{lastEntry:r}=this;if(!r||t.elements.length!==r.elements.length)return!0;for(let n=t.elements.length-1;n>-1;n--){let i=t.elements[n],a=r.elements[n];if(!i||!a||i.id!==a.id||i.versionNonce!==a.versionNonce)return!0}let o;for(o in t.appState)if(!(o==="editingLinearElement"&&t.appState[o]?.elementId===r.appState[o]?.elementId)&&!(o==="selectedElementIds"||o==="selectedGroupIds")&&t.appState[o]!==r.appState[o])return!0;return!1}pushEntry(t,r){let o=this.generateEntry(t,r),n=this.hydrateHistoryEntry(o);if(n){if(!this.shouldCreateEntry(n))return;this.stateHistory.push(o),this.lastEntry=n,this.clearRedoStack()}}clearRedoStack(){this.redoStack.splice(0,this.redoStack.length)}redoOnce(){if(this.redoStack.length===0)return null;let t=this.redoStack.pop();return t!==void 0?(this.stateHistory.push(t),this.hydrateHistoryEntry(t)):null}undoOnce(){if(this.stateHistory.length===1)return null;let t=this.stateHistory.pop(),r=this.stateHistory[this.stateHistory.length-1];return t!==void 0?(this.redoStack.push(t),this.hydrateHistoryEntry(r)):null}setCurrentState(t,r){this.lastEntry=this.hydrateHistoryEntry(this.generateEntry(t,r))}resumeRecording(){this.recording=!0}record(t,r){this.recording&&(this.pushEntry(t,r),this.recording=!1)}},P3=g1;ue();pa();Rt();Ve();Jn();Om();Zh();Id();z();zs();f();import BM from"clsx";import FM from"react";import{jsx as Xl,jsxs as HM}from"react/jsx-runtime";var dr="separator",_3=FM.memo(({actionManager:e,items:t,top:r,left:o,onClose:n})=>{let i=Gl(),a=bi(),l=t.reduce((s,c)=>(c&&(c===dr||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return Xl(rp,{onCloseRequest:()=>{n()},top:r,left:o,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Xl("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===dr)return!l[c-1]||l[c-1]===dr?null:Xl("hr",{className:"context-menu-item-separator"},c);let d=s.name,m="";return s.label&&(typeof s.label=="function"?m=b(s.label(a,i,e.app)):m=b(s.label)),Xl("li",{"data-testid":d,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:HM("button",{className:BM("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Xl("div",{className:"context-menu-item__label",children:m}),Xl("kbd",{className:"context-menu-item__shortcut",children:d?It(d):""})]})},c)})})})});f();G();ge();import Rc from"clsx";import R8 from"react";Ve();z();f();import zM,{useState as GM}from"react";import{Fragment as UM,jsx as f1}from"react/jsx-runtime";var D3=({children:e,onClose:t})=>{let[r,o]=GM(!!e),{container:n}=Bt(),i=zM.useCallback(()=>{o(!1),t&&t(),n?.focus()},[t,n]);return f1(UM,{children:r&&f1(st,{size:"small",onCloseRequest:i,title:b("errorDialog.title"),children:f1("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};f();import{useEffect as jM,useRef as qM,useState as Si}from"react";ui();G();Er();An();Ve();da();f();import WM from"clsx";import{jsx as R3,jsxs as VM}from"react/jsx-runtime";var Up=function({onChange:e,value:t,choices:r,name:o}){return R3("div",{className:"RadioGroup",children:r.map(n=>VM("div",{className:WM("RadioGroup__choice",{active:n.value===t}),title:n.ariaLabel,children:[R3("input",{name:o,type:"radio",checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};f();import YM from"clsx";import{jsx as N3}from"react/jsx-runtime";var Ic=({title:e,name:t,checked:r,onChange:o,disabled:n=!1})=>N3("div",{className:YM("Switch",{toggled:r,disabled:n}),children:N3("input",{name:t,id:t,title:e,type:"checkbox",checked:r,disabled:n,onChange:()=>o(!r),onKeyDown:i=>{i.key===" "&&o(!r)}})});f();import{forwardRef as KM,useState as $M}from"react";import XM from"clsx";qn();z();import{jsx as b1,jsxs as ZM}from"react/jsx-runtime";var tn=KM(({children:e,icon:t,onClick:r,label:o,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s},c)=>{let[d,m]=$M(!1),p=async u=>{let h=r?.(u);if(Oo(h))try{m(!0),await h}catch(x){if(x instanceof zo)console.warn(x);else throw x}finally{m(!1)}};return b1("button",{className:XM("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,{"ExcButton--fullWidth":l},s),onClick:p,type:"button","aria-label":o,ref:c,disabled:d,children:ZM("div",{className:"ExcButton__contents",children:[d&&b1(Ut,{}),t&&b1("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),n!=="icon"&&(e??o)]})})});z();import{jsx as tt,jsxs as Ii}from"react/jsx-runtime";var JM="filter"in document.createElement("canvas").getContext("2d"),QM=()=>Ii("div",{children:[tt("h3",{children:b("canvasError.cannotShowPreview")}),tt("p",{children:tt("span",{children:b("canvasError.canvasTooBig")})}),Ii("em",{children:["(",b("canvasError.canvasTooBigTip"),")"]})]}),eL=({appStateSnapshot:e,elementsSnapshot:t,files:r,actionManager:o,onExportImage:n,name:i})=>{let a=ze(t,e),[l,s]=Si(i),[c,d]=Si(a),[m,p]=Si(e.exportBackground),[u,h]=Si(e.exportWithDarkMode),[x,E]=Si(e.exportEmbedScene),[v,w]=Si(e.exportScale),y=qM(null),[I,P]=Si(null),{exportedElements:C,exportingFrame:_}=wa(t,e,c);return jM(()=>{let D=y.current;if(!D)return;let H=D.offsetWidth,A=D.offsetHeight;H&&hi({elements:C,appState:{...e,name:l,exportBackground:m,exportWithDarkMode:u,exportScale:v,exportEmbedScene:x},files:r,exportPadding:fo,maxWidthOrHeight:Math.max(H,A),exportingFrame:_}).then(M=>(P(null),Ln(M).then(()=>{D.replaceChildren(M)}).catch(k=>{throw k.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):k}))).catch(M=>{console.error(M),P(M)})},[e,r,C,_,l,m,u,v,x]),Ii("div",{className:"ImageExportModal",children:[tt("h3",{children:b("imageExportDialog.header")}),Ii("div",{className:"ImageExportModal__preview",children:[tt("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&tt(QM,{})}),tt("div",{className:"ImageExportModal__preview__filename",children:!si&&tt("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:D=>{s(D.target.value),o.executeAction(Ef,"ui",D.target.value)}})})]}),Ii("div",{className:"ImageExportModal__settings",children:[tt("h3",{children:b("imageExportDialog.header")}),a&&tt(Cc,{label:b("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:tt(Ic,{name:"exportOnlySelected",checked:c,onChange:D=>{d(D)}})}),tt(Cc,{label:b("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:tt(Ic,{name:"exportBackgroundSwitch",checked:m,onChange:D=>{p(D),o.executeAction(yf,"ui",D)}})}),JM&&tt(Cc,{label:b("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:tt(Ic,{name:"exportDarkModeSwitch",checked:u,onChange:D=>{h(D),o.executeAction(rv,"ui",D)}})}),tt(Cc,{label:b("imageExportDialog.label.embedScene"),tooltip:b("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:tt(Ic,{name:"exportEmbedSwitch",checked:x,onChange:D=>{E(D),o.executeAction(ap,"ui",D)}})}),tt(Cc,{label:b("imageExportDialog.label.scale"),name:"exportScale",children:tt(Up,{name:"exportScale",value:v,onChange:D=>{w(D),o.executeAction(tv,"ui",D)},choices:Fa.map(D=>({value:D,label:`${D}\xD7`}))})}),Ii("div",{className:"ImageExportModal__settings__buttons",children:[tt(tn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.exportToPng"),onClick:()=>n(Qc.png,C,{exportingFrame:_}),icon:Zg,children:b("imageExportDialog.button.exportToPng")}),tt(tn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.exportToSvg"),onClick:()=>n(Qc.svg,C,{exportingFrame:_}),icon:Zg,children:b("imageExportDialog.button.exportToSvg")}),(bl||mn)&&tt(tn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.copyPngToClipboard"),onClick:()=>n(Qc.clipboard,C,{exportingFrame:_}),icon:Vm,children:b("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Cc=({label:e,children:t,tooltip:r,name:o})=>Ii("div",{className:"ImageExportModal__settings__setting",title:e,children:[Ii("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,r&&tt(Ur,{label:r,long:!0,children:z2})]}),tt("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),O3=({elements:e,appState:t,files:r,actionManager:o,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Si(()=>({appStateSnapshot:Bo(t),elementsSnapshot:Bo(e)}));return tt(st,{onCloseRequest:i,size:"wide",title:!1,children:tt(eL,{elementsSnapshot:s,appStateSnapshot:l,files:r,actionManager:o,onExportImage:n,name:a})})};f();import tL from"clsx";import{jsx as rL}from"react/jsx-runtime";var Wp=({children:e,side:t,className:r})=>rL("div",{className:tL("FixedSideContainer",`FixedSideContainer_side_${t}`,r),children:e});f();ce();z();Rr();import{jsx as B3}from"react/jsx-runtime";var oL=({appState:e,isMobile:t,device:r,app:o})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar&&!r.editor.canFitSidebar)return null;if(xr(e))return b("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?b("hints.linearElementMulti"):b("hints.linearElement");if(n.type==="freedraw")return b("hints.freeDraw");if(n.type==="text")return b("hints.text");if(n.type==="embeddable")return b("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return b("hints.placeImage");let c=o.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let d=c[0];return re(d)&&d.points.length===2?b("hints.lockAngle"):Zr(d)?b("hints.resizeImage"):b("hints.resize")}if(a&&l==="mouse")return b("hints.rotate");if(c.length===1&&U(c[0]))return b("hints.text_selected");if(e.editingElement&&U(e.editingElement))return b("hints.text_editing");if(n.type==="selection"){if(e.draggingElement?.type==="selection"&&!c.length&&!e.editingElement&&!e.editingLinearElement)return b("hints.deepBoxSelect");if(e.gridSize&&e.draggingElement)return b("hints.disableSnapping");if(!c.length&&!t)return b("hints.canvasPanning");if(c.length===1){if(re(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?b("hints.lineEditor_pointSelected"):b("hints.lineEditor_nothingSelected"):b("hints.lineEditor_info");if(!e.draggingElement&&Fo(c[0]))return b("hints.bindTextToElement")}}return null},Vp=({appState:e,isMobile:t,device:r,app:o})=>{let n=oL({appState:e,isMobile:t,device:r,app:o});return n?(n=R(n),B3("div",{className:"HintViewer",children:B3("span",{children:n})})):null};f();import nL from"clsx";import{jsx as H3,jsxs as aL}from"react/jsx-runtime";var iL="medium",F3={CHECKED:Tl,UNCHECKED:fa},Yp=e=>aL("label",{className:nL("ToolIcon ToolIcon__lock",`ToolIcon_size_${iL}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[H3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),H3("div",{className:"ToolIcon__icon",children:e.checked?F3.CHECKED:F3.UNCHECKED})]});f();ge();Ve();f();import{Fragment as lL,jsx as z3,jsxs as sL}from"react/jsx-runtime";var Ci=({heading:e,children:t,...r})=>{let{id:o}=Bt(),n=z3("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:b(`headings.${e}`)});return z3("section",{...r,"aria-labelledby":`${o}-${e}-title`,children:typeof t=="function"?t(n):sL(lL,{children:[n,t]})})};f();ge();z();var Po=4,rn=6,G3="rgba(0,0,0,0.3)",U3=(e,t,r,o)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,l]=we(e),s=t/o.zoom.value,c=r/o.zoom.value,d=t-s,m=r-c,p={top:parseInt(ps("sat"))||0,bottom:parseInt(ps("sab"))||0,left:parseInt(ps("sal"))||0,right:parseInt(ps("sar"))||0},u=dn().rtl,h=-o.scrollX+d/2+p.left,x=-o.scrollY+m/2+p.top,E=h+s-p.right,v=x+c-p.bottom,w=Math.min(n,h),y=Math.min(i,x),I=Math.max(a,E),P=Math.max(l,v);return{horizontal:h===w&&E===I?null:{x:Math.max(p.left,Po)+(h-w)/(I-w)*t,y:r-rn-Math.max(Po,p.bottom),width:(E-h)/(I-w)*t-Math.max(Po*2,p.left+p.right),height:rn},vertical:x===y&&v===P?null:{x:u?Math.max(p.left,Po):t-rn-Math.max(p.right,Po),y:(x-y)/(P-y)*r+Math.max(p.top,Po),width:rn,height:(v-x)/(P-y)*r-Math.max(Po*2,p.top+p.bottom)}}},x1=(e,t,r)=>{let[o,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=t&&t<=a.x+a.width&&a.y<=r&&r<=a.y+a.height);return{isOverEither:o||n,isOverHorizontal:o,isOverVertical:n}};f();import cL from"clsx";import{jsx as W3,jsxs as mL}from"react/jsx-runtime";var dL="medium",Kp=e=>e.penDetected?mL("label",{className:cL("ToolIcon ToolIcon__penMode",`ToolIcon_size_${dL}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[W3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),W3("div",{className:"ToolIcon__icon",children:zy})]}):null;f();at();Ve();import{Fragment as V3,jsx as qe,jsxs as Wr}from"react/jsx-runtime";var $p=e=>{let t=we(e.elements),r=ga(e.elements,e.appState),o=we(r);return qe("div",{className:"Stats",children:Wr($t,{padding:2,children:[qe("div",{className:"close",onClick:e.onClose,children:ro}),qe("h3",{children:b("stats.title")}),qe("table",{children:Wr("tbody",{children:[qe("tr",{children:qe("th",{colSpan:2,children:b("stats.scene")})}),Wr("tr",{children:[qe("td",{children:b("stats.elements")}),qe("td",{children:e.elements.length})]}),Wr("tr",{children:[qe("td",{children:b("stats.width")}),qe("td",{children:Math.round(t[2])-Math.round(t[0])})]}),Wr("tr",{children:[qe("td",{children:b("stats.height")}),qe("td",{children:Math.round(t[3])-Math.round(t[1])})]}),r.length===1&&qe("tr",{children:qe("th",{colSpan:2,children:b("stats.element")})}),r.length>1&&Wr(V3,{children:[qe("tr",{children:qe("th",{colSpan:2,children:b("stats.selected")})}),Wr("tr",{children:[qe("td",{children:b("stats.elements")}),qe("td",{children:r.length})]})]}),r.length>0&&Wr(V3,{children:[Wr("tr",{children:[qe("td",{children:"x"}),qe("td",{children:Math.round(o[0])})]}),Wr("tr",{children:[qe("td",{children:"y"}),qe("td",{children:Math.round(o[1])})]}),Wr("tr",{children:[qe("td",{children:b("stats.width")}),qe("td",{children:Math.round(o[2]-o[0])})]}),Wr("tr",{children:[qe("td",{children:b("stats.height")}),qe("td",{children:Math.round(o[3]-o[1])})]})]}),r.length===1&&Wr("tr",{children:[qe("td",{children:b("stats.angle")}),qe("td",{children:`${Math.round(r[0].angle*180/Math.PI)}\xB0`})]}),e.renderCustomStats?.(e.elements,e.appState)]})})]})})};f();import pL from"clsx";ue();import{jsx as uL}from"react/jsx-runtime";var Xp=e=>uL(ae,{className:pL("Shape",{fillable:!1}),type:"radio",icon:Wm,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:S.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":S.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});Rr();import{Fragment as hL,jsx as Ht,jsxs as ki}from"react/jsx-runtime";var Y3=({appState:e,elements:t,actionManager:r,setAppState:o,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:d,renderWelcomeScreen:m,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:h,MainMenuTunnel:x,DefaultSidebarTriggerTunnel:E}=et(),v=()=>ki(Wp,{side:"top",className:"App-top-bar",children:[m&&Ht(h.Out,{}),Ht(Ci,{heading:"shapes",children:y=>Ht(Ft.Col,{gap:4,align:"center",children:ki(Ft.Row,{gap:1,className:"App-toolbar-container",children:[ki($t,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,Ht(Ft.Row,{gap:1,children:Ht(Bp,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),ki("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&Ht(E.Out,{}),Ht(Kp,{checked:e.penMode,onChange:()=>a(null),title:b("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Ht(Yp,{checked:e.activeTool.locked,onChange:n,title:b("toolBar.lock"),isMobile:!0}),Ht(Xp,{checked:Co(e),onChange:()=>i(),title:b("toolBar.hand"),isMobile:!0})]})]})})}),Ht(Vp,{appState:e,isMobile:!0,device:d,app:u})]}),w=()=>e.viewModeEnabled?Ht("div",{className:"App-toolbar-content",children:Ht(x.Out,{})}):ki("div",{className:"App-toolbar-content",children:[Ht(x.Out,{}),r.renderAction("toggleEditMenu"),r.renderAction("undo"),r.renderAction("redo"),r.renderAction(e.multiElement?"finalize":"duplicateSelection"),r.renderAction("deleteSelectedElements")]});return ki(hL,{children:[c(),!e.viewModeEnabled&&v(),!e.openMenu&&e.showStats&&Ht($p,{appState:e,setAppState:o,elements:t,onClose:()=>{r.executeAction(Ei)},renderCustomStats:s}),Ht("div",{className:"App-bottom-bar",style:{marginBottom:rn+Po*2,marginLeft:rn+Po*2,marginRight:rn+Po*2},children:ki($t,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&ua(e,t)?Ht(Ci,{className:"App-mobile-menu",heading:"selectedShapeActions",children:Ht(Op,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:r.renderAction})}):null,ki("footer",{className:"App-toolbar",children:[w(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Ht("button",{className:"scroll-back-to-content",onClick:()=>{o(y=>({...Yo(t,y)}))},children:b("buttons.scrollBackToContent")})]})]})})]})};f();import gL from"open-color";import fL,{useLayoutEffect as bL,useRef as xL,useState as EL}from"react";og();qs();import{jsx as kc,jsxs as yL}from"react/jsx-runtime";var K3=e=>{let t=xL(null),[r,o]=EL(null);return bL(()=>{if(!e.spreadsheet)return;let n=FE(e.chartType,e.spreadsheet,0,0);o(n);let i,a=t.current;return(async()=>(i=await hl(n,{exportBackground:!1,viewBackgroundColor:gL.white},null),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),kc("button",{className:"ChartPreview",onClick:()=>{r&&e.onClick(e.chartType,r)},children:kc("div",{ref:t})})},$3=({setAppState:e,appState:t,onClose:r})=>{let{onInsertElements:o}=wr(),n=fL.useCallback(()=>{r&&r()},[r]),i=(a,l)=>{o(l),fe("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return kc(st,{size:"small",onCloseRequest:n,title:b("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:yL("div",{className:"container",children:[kc(K3,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:i}),kc(K3,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:i})]})})};f();import wL from"react";ue();z();ui();G();import{Fragment as Z3,jsx as W,jsxs as Vr}from"react/jsx-runtime";var vL=()=>Vr("div",{className:"HelpDialog__header",children:[Vr("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:Pg}),b("helpDialog.documentation")]}),Vr("a",{className:"HelpDialog__btn",href:"https://blog.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:Pg}),b("helpDialog.blog")]}),Vr("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:Hm}),b("helpDialog.github")]}),Vr("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:aw}),"YouTube"]})]}),TL=e=>Vr(Z3,{children:[W("h3",{children:e.title}),W("div",{className:"HelpDialog__islands-container",children:e.children})]}),E1=e=>Vr("div",{className:`HelpDialog__island ${e.className}`,children:[W("h4",{className:"HelpDialog__island-title",children:e.caption}),W("div",{className:"HelpDialog__island-content",children:e.children})]});function*SL(e,t){let r=!0;for(let o of e)r||(yield t),r=!1,yield o}var IL=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),Z=({label:e,shortcuts:t,isOr:r=!0})=>{let o=t.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>W(CL,{children:IL(a)},a)));return Vr("div",{className:"HelpDialog__shortcut",children:[W("div",{children:e}),W("div",{className:"HelpDialog__key-container",children:[...SL(o,r?b("helpDialog.or"):null)]})]})},CL=e=>W("kbd",{className:"HelpDialog__key",...e}),X3=({onClose:e})=>{let t=wL.useCallback(()=>{e&&e()},[e]);return W(Z3,{children:Vr(st,{onCloseRequest:t,title:b("helpDialog.title"),className:"HelpDialog",children:[W(vL,{}),Vr(TL,{title:b("helpDialog.shortcuts"),children:[Vr(E1,{className:"HelpDialog__island--tools",caption:b("helpDialog.tools"),children:[W(Z,{label:b("toolBar.hand"),shortcuts:[S.H]}),W(Z,{label:b("toolBar.selection"),shortcuts:[S.V,S[1]]}),W(Z,{label:b("toolBar.rectangle"),shortcuts:[S.R,S[2]]}),W(Z,{label:b("toolBar.diamond"),shortcuts:[S.D,S[3]]}),W(Z,{label:b("toolBar.ellipse"),shortcuts:[S.O,S[4]]}),W(Z,{label:b("toolBar.arrow"),shortcuts:[S.A,S[5]]}),W(Z,{label:b("toolBar.line"),shortcuts:[S.L,S[6]]}),W(Z,{label:b("toolBar.freedraw"),shortcuts:[S.P,S[7]]}),W(Z,{label:b("toolBar.text"),shortcuts:[S.T,S[8]]}),W(Z,{label:b("toolBar.image"),shortcuts:[S[9]]}),W(Z,{label:b("toolBar.eraser"),shortcuts:[S.E,S[0]]}),W(Z,{label:b("toolBar.frame"),shortcuts:[S.F]}),W(Z,{label:b("toolBar.laser"),shortcuts:[S.K]}),W(Z,{label:b("labels.eyeDropper"),shortcuts:[S.I,"Shift+S","Shift+G"]}),W(Z,{label:b("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),W(Z,{label:b("helpDialog.editText"),shortcuts:[R("Enter")]}),W(Z,{label:b("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),W(Z,{label:b("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),W(Z,{label:b("helpDialog.curvedArrow"),shortcuts:["A",b("helpDialog.click"),b("helpDialog.click"),b("helpDialog.click")],isOr:!1}),W(Z,{label:b("helpDialog.curvedLine"),shortcuts:["L",b("helpDialog.click"),b("helpDialog.click"),b("helpDialog.click")],isOr:!1}),W(Z,{label:b("toolBar.lock"),shortcuts:[S.Q]}),W(Z,{label:b("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),W(Z,{label:b("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]})]}),Vr(E1,{className:"HelpDialog__island--view",caption:b("helpDialog.view"),children:[W(Z,{label:b("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),W(Z,{label:b("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),W(Z,{label:b("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),W(Z,{label:b("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),W(Z,{label:b("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),W(Z,{label:b("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),W(Z,{label:b("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),W(Z,{label:b("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),W(Z,{label:b("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),W(Z,{label:b("labels.showGrid"),shortcuts:[R("CtrlOrCmd+'")]}),W(Z,{label:b("labels.viewMode"),shortcuts:[R("Alt+R")]}),W(Z,{label:b("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),W(Z,{label:b("stats.title"),shortcuts:[R("Alt+/")]}),W(Z,{label:b("commandPalette.title"),shortcuts:mn?[It("commandPalette")]:[It("commandPalette"),It("commandPalette",1)]})]}),Vr(E1,{className:"HelpDialog__island--editor",caption:b("helpDialog.editor"),children:[W(Z,{label:b("labels.moveCanvas"),shortcuts:[R(`Space+${b("helpDialog.drag")}`),R(`Wheel+${b("helpDialog.drag")}`)],isOr:!0}),W(Z,{label:b("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),W(Z,{label:b("labels.delete"),shortcuts:[R("Delete")]}),W(Z,{label:b("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),W(Z,{label:b("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),W(Z,{label:b("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),W(Z,{label:b("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),W(Z,{label:b("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),W(Z,{label:b("labels.multiSelect"),shortcuts:[R(`Shift+${b("helpDialog.click")}`)]}),W(Z,{label:b("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${b("helpDialog.click")}`)]}),W(Z,{label:b("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${b("helpDialog.drag")}`)]}),(bl||mn)&&W(Z,{label:b("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),W(Z,{label:b("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),W(Z,{label:b("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),W(Z,{label:b("labels.sendToBack"),shortcuts:[rr?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),W(Z,{label:b("labels.bringToFront"),shortcuts:[rr?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),W(Z,{label:b("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),W(Z,{label:b("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),W(Z,{label:b("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),W(Z,{label:b("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),W(Z,{label:b("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),W(Z,{label:b("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),W(Z,{label:b("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${b("helpDialog.drag")}`)]}),W(Z,{label:b("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),W(Z,{label:b("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),W(Z,{label:b("buttons.redo"),shortcuts:jc?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),W(Z,{label:b("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),W(Z,{label:b("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),W(Z,{label:b("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),W(Z,{label:b("labels.flipVertical"),shortcuts:[R("Shift+V")]}),W(Z,{label:b("labels.showStroke"),shortcuts:[R("S")]}),W(Z,{label:b("labels.showBackground"),shortcuts:[R("G")]}),W(Z,{label:b("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),W(Z,{label:b("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};f();import Ac,{useLayoutEffect as kL}from"react";import j3 from"clsx";import*as jl from"@radix-ui/react-popover";z();G();import{jsx as Hn,jsxs as Zl}from"react/jsx-runtime";var AL=4,ML=8,LL=({shouldWrap:e,children:t,username:r})=>e?Hn(Ur,{label:r||"Unknown user",children:t}):Hn(Ac.Fragment,{children:t}),y1=({actionManager:e,collaborator:t,socketId:r,withName:o=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:r,collaborator:t,withName:o,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Hn(LL,{username:t.username,shouldWrap:n,children:l},r)},PL=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Zp=Ac.memo(({className:e,mobile:t,collaborators:r,userToFollow:o})=>{let n=_t(),i=new Map;r.forEach((E,v)=>{let w=E.id||v;i.set(w,{...E,socketId:v})});let a=Array.from(i.values()).filter(E=>E.username?.trim()),[l,s]=Ac.useState(""),c=Ac.useRef(null);kL(()=>{if(c.current){let E=w=>{let y=Math.max(1,Math.min(8,Math.floor(w/38)));m(y)};if(E(c.current.clientWidth),!ns)return;let v=new ResizeObserver(w=>{for(let y of w){let{width:I}=y.contentRect;E(I)}});return v.observe(c.current),()=>{v.disconnect()}}},[]);let[d,m]=Ac.useState(AL),u=l.trim().toLowerCase()?a.filter(E=>E.username?.toLowerCase().includes(l)):a,x=a.slice(0,d-1).map(E=>y1({actionManager:n,collaborator:E,socketId:E.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:E.socketId===o}));return t?Hn("div",{className:j3("UserList UserList_mobile",e),children:a.map(E=>y1({actionManager:n,collaborator:E,socketId:E.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:E.socketId===o}))}):Hn("div",{className:"UserList-wrapper",ref:c,children:Zl("div",{className:j3("UserList",e),style:{"--max-avatars":d},children:[x,a.length>d-1&&Zl(jl.Root,{onOpenChange:E=>{E||s("")},children:[Zl(jl.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),Hn(jl.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Zl($t,{style:{overflow:"hidden"},children:[a.length>=ML&&Zl("div",{className:"UserList__search-wrapper",children:[Xm,Hn("input",{className:"UserList__search",type:"text",placeholder:b("userList.search.placeholder"),value:l,onChange:E=>{s(E.target.value)}})]}),Zl("div",{className:"dropdown-menu UserList__collaborators",children:[u.length===0&&Hn("div",{className:"UserList__collaborators__empty",children:b("userList.search.empty")}),Hn("div",{className:"UserList__hint",children:b("userList.hint.text")}),u.map(E=>y1({actionManager:n,collaborator:E,socketId:E.socketId,withName:!0,isBeingFollowed:E.socketId===o}))]})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let r=t.collaborators.keys();for(let[o,n]of e.collaborators){let i=t.collaborators.get(o);if(!i||o!==r.next().value||!wt(n,i,PL))return!1}return!0});f();import DL from"react";f();import w1 from"open-color";import{jsx as _L}from"react/jsx-runtime";var v1=({children:e,color:t})=>_L("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":w1[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":w1[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":w1[t][9]},children:e});An();z();import{Fragment as NL,jsx as _o,jsxs as jp}from"react/jsx-runtime";var RL=({elements:e,appState:t,setAppState:r,files:o,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return _o("div",{className:"ExportDialog ExportDialog--json",children:jp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&jp(v1,{color:"lime",children:[_o("div",{className:"Card-icon",children:Qy}),_o("h2",{children:b("exportDialog.disk_title")}),jp("div",{className:"Card-details",children:[b("exportDialog.disk_details"),!si&&n.renderAction("changeProjectName")]}),_o(ae,{className:"Card-button",type:"button",title:b("exportDialog.disk_button"),"aria-label":b("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(bc,"ui")}})]}),s&&jp(v1,{color:"pink",children:[_o("div",{className:"Card-icon",children:cc}),_o("h2",{children:b("exportDialog.link_title")}),_o("div",{className:"Card-details",children:b("exportDialog.link_details")}),_o(ae,{className:"Card-button",type:"button",title:b("exportDialog.link_button"),"aria-label":b("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{fe("export","link",`ui (${fx()})`),await s(e,t,o),l()}catch(c){r({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,o,a)]})})},q3=({elements:e,appState:t,files:r,actionManager:o,exportOpts:n,canvas:i,setAppState:a})=>{let l=DL.useCallback(()=>{a({openDialog:null})},[a]);return _o(NL,{children:t.openDialog?.name==="jsonExport"&&_o(st,{onCloseRequest:l,title:b("buttons.export"),children:_o(RL,{elements:e,appState:t,setAppState:a,files:r,actionManager:o,onCloseRequest:l,exportOpts:n,canvas:i})})})};f();import qp from"clsx";f();import{jsx as OL}from"react/jsx-runtime";var J3=e=>OL("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${b("helpDialog.title")} \u2014 ?`,"aria-label":b("helpDialog.title"),children:Il});import{jsx as on,jsxs as T1}from"react/jsx-runtime";var Q3=({appState:e,actionManager:t,showExitZenModeBtn:r,renderWelcomeScreen:o})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=et(),a=Ie(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return T1("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[on("div",{className:qp("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:on(Ft.Col,{gap:2,children:T1(Ci,{heading:"canvasActions",children:[on(x3,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&on(E3,{renderAction:t.renderAction,className:qp("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&on(w3,{renderAction:t.renderAction,className:qp("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),on(n.Out,{}),on("div",{className:qp("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:T1("div",{style:{position:"relative"},children:[o&&on(i.Out,{}),on(J3,{onClick:()=>t.executeAction(Sa)})]})}),on(y3,{actionManager:t,showExitZenModeBtn:r})]})},eT=Q3;Q3.displayName="Footer";f();import{useEffect as dT,useLayoutEffect as mT,useRef as _1,useState as VL,forwardRef as pT,useImperativeHandle as YL,useCallback as sT}from"react";import{atom as KL,useSetAtom as $L}from"jotai";f();import BL from"react";var Jp=BL.createContext({});f();import FL from"clsx";import{useContext as HL}from"react";import{jsx as S1,jsxs as tT}from"react/jsx-runtime";var I1=({children:e,className:t})=>{let r=Ie(),o=HL(Jp),n=!!(r.editor.canFitSidebar&&o.shouldRenderDockButton);return tT("div",{className:FL("sidebar__header",t),"data-testid":"sidebar-header",children:[e,tT("div",{className:"sidebar__header__buttons",children:[n&&S1(Ur,{label:b("labels.sidebarLock"),children:S1(Jo,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":b("labels.sidebarLock"),children:Ly})}),S1(Jo,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":b("buttons.close"),children:ro})]})]})};I1.displayName="SidebarHeader";import XL from"clsx";z();ue();G();f();import zL from"clsx";import{jsx as C1,jsxs as rT}from"react/jsx-runtime";var k1=({name:e,tab:t,icon:r,title:o,children:n,onToggle:i,className:a,style:l})=>{let s=_e(),c=Me();return rT("label",{title:o,className:"sidebar-trigger__label-element",children:[C1("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=d.target.checked;s({openSidebar:m?{name:e,tab:t}:null}),i?.(m)},checked:c.openSidebar?.name===e,"aria-label":o,"aria-keyshortcuts":"0"}),rT("div",{className:zL("sidebar-trigger",a),style:l,children:[r&&C1("div",{children:r}),n&&C1("div",{className:"sidebar-trigger__label",children:n})]})]})};k1.displayName="SidebarTrigger";f();import*as oT from"@radix-ui/react-tabs";import{jsx as GL}from"react/jsx-runtime";var A1=({children:e,...t})=>GL(oT.List,{className:"sidebar-triggers",...t,children:e});A1.displayName="SidebarTabTriggers";f();import*as iT from"@radix-ui/react-tabs";import{jsx as nT}from"react/jsx-runtime";var M1=({children:e,tab:t,onSelect:r,...o})=>nT(iT.Trigger,{value:t,asChild:!0,onSelect:r,children:nT("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});M1.displayName="SidebarTabTrigger";f();import*as aT from"@radix-ui/react-tabs";import{jsx as UL}from"react/jsx-runtime";var L1=({children:e,...t})=>{let r=Me(),o=_e();if(!r.openSidebar)return null;let{name:n}=r.openSidebar;return UL(aT.Root,{className:"sidebar-tabs-root",value:r.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...t,children:e})};L1.displayName="SidebarTabs";f();import*as lT from"@radix-ui/react-tabs";import{jsx as WL}from"react/jsx-runtime";var P1=({tab:e,children:t,...r})=>WL(lT.Content,{...r,value:e,"data-testid":e,children:t});P1.displayName="SidebarTab";import{jsx as cT}from"react/jsx-runtime";import{createElement as ZL}from"react";var Mc=KL(!1),uT=pT(({name:e,children:t,onDock:r,docked:o,className:n,...i},a)=>{T.DEV&&r&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=_e(),s=$L(Mc,Be);mT(()=>(s(!!o),()=>{s(!1)}),[s,o]);let c=_1({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>r?.(u),c.current=Ga(c.current,{docked:o,shouldRenderDockButton:!!r&&o!=null});let d=_1(null);YL(a,()=>d.current);let m=Ie(),p=sT(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return _l(d,sT(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.editor.canFitSidebar)&&p()},[p,o,m.editor.canFitSidebar])),dT(()=>{let u=h=>{h.key===S.ESCAPE&&(!o||!m.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,o,m.editor.canFitSidebar]),cT($t,{...i,className:XL("sidebar",{"sidebar--docked":o},n),ref:d,children:cT(Jp.Provider,{value:c.current,children:t})})});uT.displayName="SidebarInner";var zn=Object.assign(pT((e,t)=>{let r=Me(),{onStateChange:o}=e,n=_1(r.openSidebar);dT(()=>{(!r.openSidebar&&n?.current?.name===e.name||r.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&r.openSidebar!==n.current&&o?.(r.openSidebar?.name!==e.name?null:r.openSidebar),n.current=r.openSidebar},[r.openSidebar,o,e.name]);let[i,a]=VL(!1);return mT(()=>(a(!0),()=>a(!1)),[]),i&&r.openSidebar?.name===e.name?ZL(uT,{...e,ref:t,key:e.name}):null}),{Header:I1,TabTriggers:A1,TabTrigger:M1,Tabs:L1,Tab:P1,Trigger:k1});zn.displayName="Sidebar";import{Provider as N8,useAtom as O8,useAtomValue as B8}from"jotai";f();var N1={};Mu(N1,{ChangeCanvasBackground:()=>IT,ClearCanvas:()=>TT,CommandPalette:()=>wT,Export:()=>CT,Help:()=>vT,LiveCollaborationTrigger:()=>AT,LoadScene:()=>xT,SaveAsImage:()=>yT,SaveToActiveFile:()=>ET,Socials:()=>kT,ToggleTheme:()=>ST});f();import JL from"clsx";import{useSetAtom as QL}from"jotai";f();import{atom as jL}from"jotai";var D1=jL({active:!1});async function hT({title:e,description:t,actionLabel:r,color:o}){return new Promise(n=>{Xt.set(D1,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:t,actionLabel:r,color:o})})}f();import{Fragment as qL,jsx as R1,jsxs as gT}from"react/jsx-runtime";var fT=({value:e,shortcut:t,onChange:r,choices:o,children:n,name:i})=>{let a=Ie();return gT(qL,{children:[gT("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[R1("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),R1(Up,{name:i,value:e,onChange:r,choices:o})]}),t&&!a.editor.isMobile&&R1("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};fT.displayName="DropdownMenuItemContentRadio";var bT=fT;G();import{Fragment as e8,jsx as zt,jsxs as MT}from"react/jsx-runtime";var xT=()=>{let{t:e}=yt(),t=_t(),r=bi();return t.isActionEnabled(Nl)?zt(so,{icon:Cl,onSelect:async()=>{(!r.length||await hT({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:zt(sr,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>zt("strong",{children:n}),br:()=>zt("br",{})})}))&&t.executeAction(Nl)},"data-testid":"load-button",shortcut:It("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};xT.displayName="LoadScene";var ET=()=>{let{t:e}=yt(),t=_t();return t.isActionEnabled(lp)?zt(so,{shortcut:It("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(lp),icon:jy,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};ET.displayName="SaveToActiveFile";var yT=()=>{let e=_e(),{t}=yt();return zt(so,{icon:Gm,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:It("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};yT.displayName="SaveAsImage";var wT=e=>{let t=_e(),{t:r}=yt();return zt(so,{icon:Zm,"data-testid":"command-palette-button",onSelect:()=>{fe("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:It("commandPalette"),"aria-label":r("commandPalette.title"),className:e?.className,children:r("commandPalette.title")})};wT.displayName="CommandPalette";var vT=()=>{let{t:e}=yt(),t=_t();return zt(so,{"data-testid":"help-menu-item",icon:Il,onSelect:()=>t.executeAction(Sa),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};vT.displayName="Help";var TT=()=>{let{t:e}=yt(),t=QL(ka,Be);return _t().isActionEnabled(On)?zt(so,{icon:Lo,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};TT.displayName="ClearCanvas";var ST=e=>{let{t}=yt(),r=Me(),o=_t(),n=It("toggleTheme");return o.isActionEnabled(ya)?e?.allowSystemTheme?zt(bT,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:oe.LIGHT,label:sc,ariaLabel:`${t("buttons.lightMode")} - ${n}`},{value:oe.DARK,label:lc,ariaLabel:`${t("buttons.darkMode")} - ${n}`},{value:"system",label:iw,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):zt(so,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(r.theme===oe.DARK?oe.LIGHT:oe.DARK);else return o.executeAction(ya)},icon:r.theme===oe.DARK?sc:lc,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":r.theme===oe.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:r.theme===oe.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};ST.displayName="ToggleTheme";var IT=()=>{let{t:e}=yt(),t=Me(),r=_t(),o=yi();return t.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:MT("div",{style:{marginTop:"0.5rem"},children:[zt("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),zt("div",{style:{padding:"0 0.625rem"},children:r.renderAction("changeViewBackgroundColor")})]})};IT.displayName="ChangeCanvasBackground";var CT=()=>{let{t:e}=yt(),t=_e();return zt(so,{icon:ba,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};CT.displayName="Export";var kT=()=>{let{t:e}=yt();return MT(e8,{children:[zt(Yl,{icon:Hm,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),zt(Yl,{icon:Xy,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),zt(Yl,{icon:$y,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};kT.displayName="Socials";var AT=({onSelect:e,isCollaborating:t})=>{let{t:r}=yt();return zt(so,{"data-testid":"collab-button",icon:Um,className:JL({"active-collab":t}),onSelect:e,children:r("labels.liveCollaboration")})};AT.displayName="LiveCollaborationTrigger";f();import{atom as t8,useAtom as r8}from"jotai";import{useLayoutEffect as o8,useRef as n8}from"react";import{jsx as i8}from"react/jsx-runtime";var Gn=(e,t)=>{let r=t8(0),o=n=>{let{jotaiScope:i}=et(),[,a]=r8(r,i),l=n8({preferHost:!1,counter:0});return o8(()=>{let s=l.current;return a(c=>{let d=c+1;return s.counter=d,d}),()=>{a(c=>{let d=c-1;return s.counter=d,d||(s.preferHost=!1),d})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:i8(t,{...n})};return o.displayName=e,o};z();import{jsx as Qp,jsxs as O1}from"react/jsx-runtime";var a8=Object.assign(Gn("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:r}=et(),o=Ie(),n=Me(),i=_e(),a=o.editor.isMobile?void 0:()=>i({openMenu:null});return Qp(r.In,{children:O1(Oe,{open:n.openMenu==="canvas",children:[Qp(Oe.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Fm}),O1(Oe.Content,{onClickOutside:a,onSelect:Xn(t,()=>{i({openMenu:null})}),children:[e,o.editor.isMobile&&n.collaborators.size>0&&O1("fieldset",{className:"UserList-Wrapper",children:[Qp("legend",{children:b("labels.collaborators")}),Qp(Zp,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Oe.Trigger,Item:Oe.Item,ItemLink:Oe.ItemLink,ItemCustom:Oe.ItemCustom,Group:Oe.Group,Separator:Oe.Separator,DefaultItems:N1}),mr=a8;f();import{useAtom as d8}from"jotai";f();import{jsx as ql,jsxs as c8}from"react/jsx-runtime";var eu=({title:e,children:t,actionLabel:r,onClick:o})=>c8("div",{className:"OverwriteConfirm__Actions__Action",children:[ql("h4",{children:e}),ql("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),ql(tn,{variant:"outlined",color:"muted",label:r,size:"large",fullWidth:!0,onClick:o})]}),l8=()=>{let{t:e}=yt(),t=_t(),r=_e();return ql(eu,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(ap,"ui",!0),r({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},s8=()=>{let{t:e}=yt(),t=_t();return ql(eu,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(bc,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},B1=Object.assign(({children:e})=>ql("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:l8,SaveToDisk:s8});import{jsx as Ai,jsxs as LT}from"react/jsx-runtime";var tu=Object.assign(Gn("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=et(),[r,o]=d8(D1,Be);if(!r.active)return null;let n=()=>{r.onClose(),o(a=>({...a,active:!1}))},i=()=>{r.onConfirm(),o(a=>({...a,active:!1}))};return Ai(t.In,{children:Ai(st,{onCloseRequest:n,title:!1,size:916,children:LT("div",{className:"OverwriteConfirm",children:[Ai("h3",{children:r.title}),LT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${r.color}`,children:[Ai("div",{className:"OverwriteConfirm__Description__icon",children:G2}),Ai("div",{children:r.description}),Ai("div",{className:"OverwriteConfirm__Description__spacer"}),Ai(tn,{color:r.color,size:"large",label:r.actionLabel,onClick:i})]}),Ai(B1,{children:e})]})})})}),{Actions:B1,Action:eu});Rr();f();G();import m8 from"clsx";z();import{jsx as Mi,jsxs as PT}from"react/jsx-runtime";import{createElement as p8}from"react";var _T=Gn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=et();return Mi(t.In,{children:Mi(zn.Trigger,{...e,className:"default-sidebar-trigger",name:kr.name})})});_T.displayName="DefaultSidebarTrigger";var DT=({children:e,...t})=>{let{DefaultSidebarTabTriggersTunnel:r}=et();return Mi(r.In,{children:Mi(zn.TabTriggers,{...t,children:e})})};DT.displayName="DefaultTabTriggers";var ru=Object.assign(Gn("DefaultSidebar",({children:e,className:t,onDock:r,docked:o,...n})=>{let i=Me(),a=_e(),{DefaultSidebarTabTriggersTunnel:l}=et();return p8(zn,{...n,name:"default",key:"default",className:m8("default-sidebar",t),docked:o??i.defaultSidebarDockedPreference,onDock:r===!1||!r&&o!=null?void 0:Xn(r,s=>{a({defaultSidebarDockedPreference:s})})},PT(zn.Tabs,{children:[PT(zn.Header,{children:[n.__fallback&&Mi("div",{style:{color:"var(--color-primary)",fontSize:"1.2em",fontWeight:"bold",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",paddingRight:"1em"},children:b("toolBar.library")}),Mi(l.Out,{})]}),Mi(zn.Tab,{tab:ms,children:Mi(h3,{})}),e]}))}),{Trigger:_T,TabTriggers:DT});We();Go();Jn();f();import u8 from"clsx";import{jsx as RT,jsxs as g8}from"react/jsx-runtime";var h8="small",NT=e=>g8("label",{className:u8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${h8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[RT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),RT("div",{className:"ToolIcon__icon",children:$m})]});f();import{useState as zT}from"react";ue();f();import{jsx as f8}from"react/jsx-runtime";var Jl=e=>f8("p",{className:"excalidraw__paragraph",style:e.style,children:e.children});f();import*as BT from"@radix-ui/react-tabs";import{useRef as OT}from"react";z();import{jsx as b8}from"react/jsx-runtime";var FT=e=>{let t=_e(),r=OT(null),o=OT(0);return b8(BT.Root,{ref:r,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=r.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>o.current&&(o.current=a,i.style.minHeight=`min(${o.current}px, 100%)`)}e.dialog==="settings"&&hs(["text-to-diagram","diagram-to-code"],n)?t({openDialog:{name:e.dialog,tab:n,source:"settings"}}):e.dialog==="ttd"&&hs(["text-to-diagram","mermaid"],n)&&t({openDialog:{name:e.dialog,tab:n}})},children:e.children})};FT.displayName="TTDDialogTabs";var ou=FT;f();import*as HT from"@radix-ui/react-tabs";import{jsx as x8}from"react/jsx-runtime";var Ql=({tab:e,children:t,...r})=>x8(HT.Content,{...r,value:e,children:t});Ql.displayName="TTDDialogTab";import{jsx as Cr,jsxs as Lc}from"react/jsx-runtime";var GT=e=>{let[t,r]=zT(e.openAIKey||""),[o,n]=zT(e.isPersisted),i=Me(),a=()=>{e.onConfirm(t.trim(),o)};return i.openDialog?.name!=="settings"?null:Cr(st,{onCloseRequest:()=>{e.onClose(),e.onConfirm(t.trim(),o)},title:Lc("div",{style:{display:"flex"},children:["Wireframe to Code (AI)"," ",Cr("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.1rem 0.5rem",marginLeft:"1rem",fontSize:14,borderRadius:"12px",color:"#000",background:"pink"},children:"Experimental"})]}),className:"MagicSettings",autofocus:!1,children:Cr(ou,{dialog:"settings",tab:i.openDialog.tab,children:Lc(Ql,{tab:"diagram-to-code",children:[Lc(Jl,{children:["For the diagram-to-code feature we use"," ",Cr(vi,{icon:dc}),"OpenAI."]}),Lc(Jl,{children:["While the OpenAI API is in beta, its use is strictly limited \u2014 as such we require you use your own API key. You can create an"," ",Cr("a",{href:"https://platform.openai.com/login?launch",rel:"noopener noreferrer",target:"_blank",children:"OpenAI account"}),", add a small credit (5 USD minimum), and"," ",Cr("a",{href:"https://platform.openai.com/api-keys",rel:"noopener noreferrer",target:"_blank",children:"generate your own API key"}),"."]}),Cr(Jl,{children:"Your OpenAI key does not leave the browser, and you can also set your own limit in your OpenAI account dashboard if needed."}),Cr(Np,{isRedacted:!0,value:t,placeholder:"Paste your API key here",label:"OpenAI API key",onChange:l=>{r(l),e.onChange(l.trim(),o)},selectOnRender:!0,onKeyDown:l=>l.key===S.ENTER&&a()}),Cr(Jl,{children:"By default, your API token is not persisted anywhere so you'll need to insert it again after reload. But, you can persist locally in your browser below."}),Cr(Ta,{checked:o,onChange:n,children:"Persist API key in browser storage"}),Lc(Jl,{children:["Once API key is set, you can use the ",Cr(vi,{icon:Al})," ","tool to wrap your elements in a frame that will then allow you to turn it into code. This dialog can be accessed using the"," ",Cr("b",{children:"AI Settings"})," ",Cr(vi,{icon:dc}),"."]}),Cr(tn,{className:"MagicSettings__confirm",size:"large",label:"Confirm",onClick:a})]})})})};f();f();import{useState as KT,useRef as $T,useEffect as XT,useDeferredValue as I8}from"react";f();G();Er();var E8=({canvasRef:e,setError:t})=>{let r=e.current;if(!r)return;let o=r.parentElement;o&&(o.style.background="",t(null),r.replaceChildren())},nu=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:r,setError:o,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!r){E8({canvasRef:e,setError:o});return}try{let l=await t.api,s;try{s=await l.parseMermaidToExcalidraw(r,{fontSize:At})}catch{s=await l.parseMermaidToExcalidraw(r.replace(/"/g,"'"),{fontSize:At})}let{elements:c,files:d}=s;o(null),n.current={elements:_c(c,{regenerateIds:!0}),files:d};let m=await hi({elements:n.current.elements,files:n.current.files,exportPadding:fo,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Ln(m)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(m)}catch(l){throw a.style.background="var(--default-bg-color)",r&&o(l),l}}},Pc=e=>{Tr.set($r.MERMAID_TO_EXCALIDRAW,e)},iu=({app:e,data:t,text:r,shouldSaveMermaidDataToStorage:o})=>{let{elements:n,files:i}=t.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),o&&r&&Pc(r))};f();import{jsx as y8}from"react/jsx-runtime";var au=({children:e})=>y8("div",{className:"ttd-dialog-panels",children:e});f();import UT from"clsx";import{jsx as F1,jsxs as Dc}from"react/jsx-runtime";var es=({label:e,children:t,panelAction:r,panelActionDisabled:o=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>Dc("div",{className:"ttd-dialog-panel",children:[Dc("div",{className:"ttd-dialog-panel__header",children:[F1("label",{children:e}),i?.()]}),t,Dc("div",{className:UT("ttd-dialog-panel-button-container",{invisible:!r}),style:{display:"flex",alignItems:"center"},children:[Dc(Jo,{className:"ttd-dialog-panel-button",onSelect:r?r.action:()=>{},disabled:o||n,children:[Dc("div",{className:UT({invisible:n}),children:[r?.label,r?.icon&&F1("span",{children:r.icon})]}),n&&F1(Ut,{})]}),!o&&!n&&a?.(),l?.()]})]});f();G();ue();import{useEffect as w8,useRef as WT}from"react";import{jsx as v8}from"react/jsx-runtime";var lu=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:o})=>{let n=WT(null),i=WT(o);return i.current=o,w8(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[S.CTRL_OR_CMD]&&s.key===S.ENTER&&(s.preventDefault(),i.current?.())};return a.addEventListener("keydown",l),()=>{a.removeEventListener("keydown",l)}}},[]),v8("textarea",{className:"ttd-dialog-input",onChange:r,value:e,placeholder:t,autoFocus:!0,ref:n})};f();import{jsx as su,jsxs as VT}from"react/jsx-runtime";var T8=({error:e})=>VT("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",su("p",{children:e})]}),cu=({error:e,canvasRef:t,loaded:r})=>VT("div",{className:"ttd-dialog-output-wrapper",children:[e&&su(T8,{error:e.message}),r?su("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):su(Ut,{size:"2rem"})]});G();z();f();z();import{jsx as YT,jsxs as S8}from"react/jsx-runtime";var du=()=>S8("div",{className:"ttd-dialog-submit-shortcut",children:[YT("div",{className:"ttd-dialog-submit-shortcut__key",children:R("CtrlOrCmd")}),YT("div",{className:"ttd-dialog-submit-shortcut__key",children:R("Enter")})]});import{Fragment as A8,jsx as nn,jsxs as jT}from"react/jsx-runtime";var C8=`flowchart TD
59
+ `);try{Dn(i)}catch{throw new Error(b("errors.copyToSystemClipboardFailed"))}return{commitToHistory:!1}},predicate:(e,t,r,o)=>Em&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(G),keywords:["text","clipboard","copy"]});f();ue();Ye();U();var fp=B({name:"gridMode",label:"labels.showGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.gridSize},perform(e,t){return{appState:{...t,gridSize:this.checked(t)?null:un,objectsSnapModeEnabled:!1},commitToHistory:!1}},checked:e=>e.gridSize!==null,predicate:(e,t,r)=>typeof r.gridModeEnabled>"u",keyTest:e=>e[S.CTRL_OR_CMD]&&e.code===he.QUOTE});f();ue();Ye();var Gl=B({name:"zenMode",label:"buttons.zenMode",icon:lw,paletteName:"Toggle zen mode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},commitToHistory:!1}},checked:e=>e.zenModeEnabled,predicate:(e,t,r)=>typeof r.zenModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.Z});f();ue();Ye();var Pf=B({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:aw,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridSize:null},commitToHistory:!1}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,r)=>typeof r.objectsSnapModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.S});f();Ye();ue();var Ei=B({name:"stats",label:"stats.title",icon:tw,paletteName:"Toggle stats",viewMode:!0,trackEvent:{category:"menu"},perform(e,t){return{appState:{...t,showStats:!this.checked(t)},commitToHistory:!1}},checked:e=>e.showStats,keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.SLASH});f();U();ge();We();lt();Ld();ce();z();Ye();wo();var _f=B({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>o.scene.getSelectedElements(t).some(i=>gr(i)),perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=o.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=de(a,i);if(l){let{width:s,height:c}=Io(l.originalText,Ge(l),l.lineHeight),d=x0(a.id);Md(a.id);let{x:m,y:p}=rl(a,l,i);F(l,{containerId:null,width:s,height:c,text:l.originalText,x:m,y:p}),F(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:d||a.height})}}),{elements:e,appState:t,commitToHistory:!0}}}),Df=B({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);if(n.length===2){let i=G(n[0])||G(n[1]),a;if(Fo(n[0])?a=n[0]:Fo(n[1])&&(a=n[1]),i&&a&&de(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i,a;G(n[0])&&Fo(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),F(i,{containerId:a.id,verticalAlign:ft.MIDDLE,textAlign:Kn.CENTER}),F(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Yt(i,a,o.scene.getNonDeletedElementsMap()),ea(a.id,l),{elements:ck(e,a,i),appState:{...t,selectedElementIds:{[a.id]:!0}},commitToHistory:!0}}}),ck=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===r.id);o.splice(n,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i+1,0,r),qt(o,$([t,r])),o},dk=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===t.id);o.splice(n,1);let i=o.findIndex(a=>a.id===r.id);return o.splice(i,0,t),qt(o,$([t,r])),o},xv=B({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=n.every(a=>G(a));return n.length>0&&i},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=e.slice(),a={};for(let l of n)if(G(l)){let s=Fr({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:Ho("rectangle")?rt.ADAPTIVE_RADIUS:rt.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-ht,y:l.y-ht,width:yn(l.width,"rectangle"),height:yn(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&F(m,{startBinding:p,endBinding:u},!1)})}F(l,{containerId:s.id,verticalAlign:ft.MIDDLE,boundElements:null,textAlign:Kn.CENTER},!1),Yt(l,s,o.scene.getNonDeletedElementsMap()),i=dk([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...t,selectedElementIds:a},commitToHistory:!0}}});f();f();z();Gs();We();ue();U();at();import{useCallback as Ev,useEffect as mk,useLayoutEffect as pk,useRef as uk,useState as hk}from"react";import gk from"clsx";Ve();sm();ia();ce();dm();import{jsx as xc,jsxs as yv}from"react/jsx-runtime";var Of=320,wv=85,Rf=5,fk=42,bk=500,Nf=!1,bp=new Map,vv=({element:e,elementsMap:t,setAppState:r,onLinkOpen:o,setToast:n,updateEmbedValidationStatus:i})=>{let a=Ul(),l=yi(),s=e.link||"",[c,d]=hk(s),m=uk(null),p=a.showHyperlinkPopup==="editor",u=Ev(()=>{if(!m.current)return;let w=lr(m.current.value)||null;if(!e.link&&w&&fe("hyperlink","create"),vt(e)){if(a.activeEmbeddable?.element===e&&r({activeEmbeddable:null}),!w){F(e,{link:null}),i(e,!1);return}if(!il(w,l.validateEmbeddable))w&&n({message:b("toast.unableToEmbed"),closable:!0}),e.link&&bp.set(e.id,e.link),F(e,{link:w}),i(e,!1);else{let{width:y,height:I}=e,P=kn(w);P?.error instanceof URIError&&n({message:b("toast.unrecognizedLinkFormat"),closable:!0});let C=P?P.intrinsicSize.w/P.intrinsicSize.h:1,_=bp.get(e.id)!==e.link;F(e,{..._?{width:P?.type==="video"?y>I?y:I*C:y,height:P?.type==="video"&&y>I?y/C:I}:{},link:w}),i(e,!0),bp.has(e.id)&&bp.delete(e.id)}}else F(e,{link:w})},[e,n,l.validateEmbeddable,a.activeEmbeddable,r,i]);pk(()=>()=>{u()},[u]),mk(()=>{let w=null,y=I=>{if(p)return;w&&clearTimeout(w),Ek(e,t,a,[I.clientX,I.clientY])&&(w=window.setTimeout(()=>{r({showHyperlinkPopup:!1})},bk))};return window.addEventListener("pointermove",y,!1),()=>{window.removeEventListener("pointermove",y,!1),w&&clearTimeout(w)}},[a,e,p,r,t]);let h=Ev(()=>{fe("hyperlink","delete"),F(e,{link:null}),p&&(m.current.value=""),r({showHyperlinkPopup:!1})},[r,e,p]),x=()=>{fe("hyperlink","edit","popup-ui"),r({showHyperlinkPopup:"editor"})},{x:E,y:v}=Tv(e,a,t);return a.contextMenu||a.draggingElement||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:yv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${v}px`,left:`${E}px`,width:Of,padding:Rf},onClick:()=>{!e.link&&!p&&r({showHyperlinkPopup:"editor"})},children:[p?xc("input",{className:gk("excalidraw-hyperlinkContainer-input"),placeholder:"Type or paste your link here",ref:m,value:c,onChange:w=>d(w.target.value),autoFocus:!0,onKeyDown:w=>{w.stopPropagation(),w[S.CTRL_OR_CMD]&&w.key===S.K&&w.preventDefault(),(w.key===S.ENTER||w.key===S.ESCAPE)&&(u(),r({showHyperlinkPopup:"info"}))}}):e.link?xc("a",{href:lr(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Gd(e.link)?"_self":"_blank",onClick:w=>{if(e.link&&o){let y=pd("excalidraw-link",w.nativeEvent);o({...e,link:lr(e.link)},y),y.defaultPrevented&&w.preventDefault()}},rel:"noopener noreferrer",children:e.link}):xc("div",{className:"excalidraw-hyperlinkContainer-link",children:b("labels.link.empty")}),yv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!p&&xc(ae,{type:"button",title:b("buttons.edit"),"aria-label":b("buttons.edit"),label:b("buttons.edit"),onClick:x,className:"excalidraw-hyperlinkContainer--edit",icon:Il}),s&&!vt(e)&&xc(ae,{type:"button",title:b("buttons.remove"),"aria-label":b("buttons.remove"),label:b("buttons.remove"),onClick:h,className:"excalidraw-hyperlinkContainer--remove",icon:Lo})]})]})},Tv=(e,t,r)=>{let[o,n]=te(e,r),{x:i,y:a}=Dt({sceneX:o+e.width/2,sceneY:n},t),l=i-t.offsetLeft-Of/2,s=a-t.offsetTop-wv;return{x:l,y:s}},Bf=(e,t)=>{let r=pe(e,t);return r[0]?.link?vt(r[0])?"labels.link.editEmbed":"labels.link.edit":vt(r[0])?"labels.link.createEmbed":"labels.link.create"},Ec=null,Sv=(e,t,r)=>{Ec&&clearTimeout(Ec),Ec=window.setTimeout(()=>xk(e,t,r),Kb)},xk=(e,t,r)=>{if(!e.link)return;let o=Nl();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=e.link;let[n,i,a,l]=te(e,r),[s,c,d,m]=Zs([n,i,a,l],e.angle,t),p=Dt({sceneX:s,sceneY:c},t);Ef(o,{left:p.x,top:p.y,width:d,height:m},"top"),fe("hyperlink","tooltip","link-icon"),Nf=!0},Iv=()=>{Ec&&clearTimeout(Ec),Nf&&(Nf=!1,Nl().classList.remove("excalidraw-tooltip--visible"))},Ek=(e,t,r,[o,n])=>{let{x:i,y:a}=Ue({clientX:o,clientY:n},r),l=15/r.zoom.value;if(la(i,a,e,t))return!1;let[s,c,d]=te(e,t);if(i>=s&&i<=d&&a>=c-wv&&a<=c)return!1;let{x:m,y:p}=Tv(e,r,t);return!(o>=m-l&&o<=m+Of+Rf*2+l&&n>=p-l&&n<=p+l+Rf*2+fk)};ce();ue();Ve();z();Ye();import{jsx as yk}from"react/jsx-runtime";var yc=B({name:"hyperlink",label:(e,t)=>Bf(e,t),icon:cc,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},commitToHistory:!0},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.K,predicate:(e,t)=>pe(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=pe(e,t);return yk(ae,{type:"button",icon:cc,"aria-label":b(Bf(e,t)),title:`${vt(e[0])?b("labels.link.labelEmbed"):b("labels.link.label")} - ${R("CtrlOrCmd+K")}`,onClick:()=>r(null),selected:o.length===1&&!!o[0].link})}});f();We();ce();ue();Ve();z();Ye();var Ff=e=>e.every(t=>!t.locked),Hf=B({name:"toggleElementLock",label:(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return o.length===1&&!Q(o[0])?o[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":Ff(o)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,t)=>{let r=pe(t,e);return Ff(r)?Sl:fa},trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Ff(n),a=$(n);return{elements:e.map(l=>a.has(l.id)?ne(l,{locked:i}):l),appState:{...t,selectedLinearElement:i?null:t.selectedLinearElement},commitToHistory:!0}},keyTest:(e,t,r,o)=>e.key.toLocaleLowerCase()===S.L&&e[S.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),Cv=B({name:"unlockAllElements",paletteName:"Unlock all elements",trackEvent:{category:"canvas"},viewMode:!1,icon:fa,predicate:(e,t)=>pe(e,t).length===0&&e.some(o=>o.locked),perform:(e,t)=>{let r=e.filter(o=>o.locked);return{elements:e.map(o=>o.locked?ne(o,{locked:!1}):o),appState:{...t,selectedElementIds:Object.fromEntries(r.map(o=>[o.id,!0]))},commitToHistory:!0}},label:"labels.elementLock.unlockAll"});f();f();import{useEffect as Gp,useRef as MM,useState as zp}from"react";ue();f();import QA from"clsx";import{useEffect as eM,useState as tM}from"react";f();import{useCallback as wk,useState as vk}from"react";var kv=()=>{let[e,t]=vk(null),r=wk(o=>t(o),[]);return[e,r]};ue();f();import Tk from"react";import Sk from"clsx";import{jsx as Ik}from"react/jsx-runtime";var $t=Tk.forwardRef(({children:e,padding:t,className:r,style:o},n)=>Ik("div",{className:Sk("Island",r),style:{"--padding":t,...o},ref:n,children:e}));f();ue();import{createPortal as Ck}from"react-dom";import kk from"clsx";import{useRef as Ak}from"react";import{jsx as Av,jsxs as Mk}from"react/jsx-runtime";var Mv=e=>{let{closeOnClickOutside:t=!0}=e,r=tp({className:"excalidraw-modal-container"}),o=Ak(document.body.classList.contains("excalidraw-animations-disabled"));if(!r)return null;let n=i=>{i.key===S.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return Ck(Mk("div",{className:kk("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Av("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),Av("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),r)};z();import{useSetAtom as rM}from"jotai";f();import{useState as XA,useCallback as t1,useMemo as f3,useRef as e1}from"react";f();Er();cl();import{atom as Rk}from"jotai";at();qn();U();import{useEffect as _v,useRef as Dv}from"react";f();Zt();import{atom as Lk,useAtom as Pk}from"jotai";import{useEffect as _k,useState as Dk}from"react";da();var zf=Lk(new Map),Lv=async e=>await El({elements:e,appState:{exportBackground:!1,viewBackgroundColor:se.white},files:null,renderEmbeddables:!1}),Pv=(e,t,r)=>{let[o,n]=Dk();return _k(()=>{if(t)if(e){let i=r.get(e);i?n(i):(async()=>{let a=await Lv(t);a.querySelector(".style-fonts")?.remove(),a&&(r.set(e,a),n(a))})()}else(async()=>{let i=await Lv(t);n(i)})()},[e,t,r,n]),o},xp=()=>{let[e]=Pk(zf,Be);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:o=>{o.forEach(n=>e.delete(n))},svgCache:e}};z();f();var lo=class{subscribers=[];on(...t){let r=t.flat().filter(o=>typeof o=="function");return this.subscribers.push(...r),()=>this.off(r)}once(...t){let r=t.flat().filter(n=>typeof n=="function");r.push(()=>o());let o=this.on(...r);return o}off(...t){let r=t.flat();this.subscribers=this.subscribers.filter(o=>!r.includes(o))}trigger(...t){for(let r of this.subscribers)r(...t);return this}clear(){this.subscribers=[]}};f();z();var Ep=class{jobs=[];running=!1;tick(){if(this.running)return;let t=this.jobs.shift();t?(this.running=!0,t.promise.resolve(fs(t.jobFactory,...t.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(t,...r){let o=md();return this.jobs.push({jobFactory:t,promise:o,args:r}),this.tick(),o}};ge();var Nv=new lo,Ca=Rk({status:"loaded",isInitialized:!1,libraryItems:[]}),wc=e=>Bo(e),Nk=(e,t)=>!e.find(r=>r.elements.length!==t.elements.length?!1:r.elements.every((o,n)=>o.id===t.elements[n].id&&o.versionNonce===t.elements[n].versionNonce)),Ov=(e,t)=>{let r=[];for(let o of t)Nk(e,o)&&r.push(o);return[...r,...e]},Bv=(e,t)=>{let r=$(t),o={deletedItems:new Map,addedItems:new Map};for(let i of e)r.has(i.id)||o.deletedItems.set(i.id,i);let n=$(e);for(let i of t)n.has(i.id)||o.addedItems.set(i.id,i);return o},Gf=class{currLibraryItems=[];prevLibraryItems=wc(this.currLibraryItems);app;constructor(t){this.app=t}updateQueue=[];getLastUpdateTask=()=>this.updateQueue[this.updateQueue.length-1];notifyListeners=()=>{if(this.updateQueue.length>0)Xt.set(Ca,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{Xt.set(Ca,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=wc(this.currLibraryItems);let r=wc(this.currLibraryItems);this.app.props.onLibraryChange?.(r),Nv.trigger(Bv(t,r),r)}catch(t){console.error(t)}}};destroy=()=>{this.updateQueue=[],this.currLibraryItems=[],Xt.set(zf,new Map)};resetLibrary=()=>this.setLibrary([]);getLatestLibrary=()=>new Promise(async t=>{try{let r=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(wc(r))}catch{return t(this.currLibraryItems)}});updateLibrary=async({libraryItems:t,prompt:r=!1,merge:o=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:kr.name,tab:ps}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),c;s instanceof Blob?c=await Vh(s,i):c=aa(s,i),!r||window.confirm(b("alerts.confirmAddLibrary",{numShapes:c.length}))?(r&&this.app.focusContainer(),a(o?Ov(this.currLibraryItems,c):c)):l(new zo)}catch(s){l(s)}})));setLibrary=t=>{let r=new Promise(async(o,n)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=wc(await t),o(this.currLibraryItems)}catch(i){n(i)}}).catch(o=>{if(o.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw o}).finally(()=>{this.updateQueue=this.updateQueue.filter(o=>o!==r),this.notifyListeners()});return this.updateQueue.push(r),this.notifyListeners(),r}},Fv=Gf,vp=e=>{let r=Math.ceil(Math.sqrt(e.length)),o=[],n=u=>e.slice(u*r,u*r+r).reduce((x,E)=>{let{height:v}=br(E.elements);return Math.max(x,v)},0),i=u=>{let h=0,x=0,E=0;for(let v of e){if(h%r===0&&(x=0),x===u){let{width:w}=br(v.elements);E=Math.max(E,w)}h++,x++}return E},a=0,l=0,s=0,c=0,d=0,m=0,p=0;for(let u of e){d&&d%r===0&&(l+=s+50,a=0,m=0,p++),m===0&&(s=n(p)),c=i(m);let{minX:h,minY:x,width:E,height:v}=br(u.elements),w=(c-E)/2,y=(s-v)/2;o.push(...u.elements.map(I=>({...I,x:I.x+a+w-h,y:I.y+l+y-x}))),a+=c+50,d++,m++}return o},Uf=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(rd.addLibrary)||new URLSearchParams(window.location.search).get(td.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},Wl=class e{static queue=new Ep;static async getLibraryItems(t,r,o=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await t.load({source:r});i(aa(l?.libraryItems||[],"published"))}catch(l){a(l)}});return o?e.queue.push(n):n()}static run=async(t,r)=>{let o=new e(t);return e.queue.push(()=>r(o))};adapter;constructor(t){this.adapter=t}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}},vc=0,yp=0,wp=e=>Sg(e.map(t=>`${t.id}:${Tg(t.elements)}`).sort().join()),Rv=async(e,t)=>{try{return yp++,await Wl.run(e,async r=>{let o=$(await r.getLibraryItems("save"));for(let[l]of t.deletedItems)o.delete(l);let n=[];for(let[l,s]of t.addedItems)o.has(l)?o.set(l,s):n.push(s);let i=n.concat(Array.from(o.values())),a=wp(i);return a!==vc&&await e.save({libraryItems:i}),vc=a,i})}finally{yp--}},Ok=e=>{let{excalidrawAPI:t}=e,r=Dv(e);r.current=e;let o=Dv(!1);_v(()=>{if(!t)return;o.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(m,p)=>{try{let h=await(await fetch(decodeURIComponent(l))).blob();m(h)}catch(u){p(u)}}),d=s!==t.id;await(d&&document.hidden?new Promise(m=>{window.addEventListener("focus",()=>m(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(m){throw m}finally{if(window.location.hash.includes(rd.addLibrary)){let m=new URLSearchParams(window.location.hash.slice(1));m.delete(rd.addLibrary),window.history.replaceState({},as,`#${m.toString()}`)}else if(window.location.search.includes(td.addLibrary)){let m=new URLSearchParams(window.location.search);m.delete(td.addLibrary),window.history.replaceState({},as,`?${m.toString()}`)}}},i=l=>{l.preventDefault();let s=Uf();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Uf();if(a&&n(a),"getInitialLibraryItems"in r.current&&r.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(r.current.getInitialLibraryItems()).then(l=>{t.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in r.current&&r.current.adapter){let l=r.current.adapter,s=r.current.migrationAdapter,c=md();s?c.resolve(fs(s.load).then(async d=>{let m=null;try{if(!d)return Wl.getLibraryItems(l,"load");m=aa(d.libraryItems||[],"published");let p=await Rv(l,Bv([],m));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),m}}).catch(d=>(console.error(`error during library migration: ${d.message}`),Wl.getLibraryItems(l,"load")))):c.resolve(fs(Wl.getLibraryItems,l,"load")),t.updateLibrary({libraryItems:c.then(d=>{let m=d||[];return vc=wp(m),m}),merge:!0}).finally(()=>{o.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[t]),_v(()=>{let n=Nv.on(async(a,l)=>{let s=o.current,c="adapter"in r.current&&r.current.adapter||null;try{c&&vc!==wp(l)&&await Rv(c,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),s&&r.current.excalidrawAPI&&r.current.excalidrawAPI.updateScene({appState:{errorMessage:b("errors.saveLibraryError")}})}}),i=a=>{yp&&ux(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),vc=0,yp=0}},[])};Eo();f();Pn();import{useCallback as $l,useEffect as WA,useMemo as p3,useRef as VA,useState as YA}from"react";z();f();import{forwardRef as Hv}from"react";import zv from"clsx";import{jsx as Gv}from"react/jsx-runtime";var Bk=Hv(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>Gv("div",{className:zv("Stack Stack_horizontal",n),style:{"--gap":t,alignItems:r,justifyContent:o,...i},ref:a,children:e})),Fk=Hv(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>Gv("div",{className:zv("Stack Stack_vertical",n),style:{"--gap":t,justifyItems:r,justifyContent:o,...i},ref:a,children:e})),Ft={Row:Bk,Col:Fk};U();In();f();f();U();import{jsx as zk}from"react/jsx-runtime";var Hk=({theme:e,id:t,libraryReturnUrl:r})=>{let o=r||window.location.origin+window.location.pathname;return zk("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${o}&useHash=true&token=${t}&theme=${e}&version=${Ui.excalidrawLibrary}`,target:"_excalidraw_libraries",children:b("labels.libraries")})},Uv=Hk;import Gk from"clsx";import{jsx as Uk,jsxs as Wk}from"react/jsx-runtime";var Tp=({libraryReturnUrl:e,theme:t,id:r,style:o,children:n,className:i})=>Wk("div",{className:Gk("library-menu-control-buttons",i),style:o,children:[Uk(Uv,{id:r,libraryReturnUrl:e,theme:t}),n]});f();import{useCallback as vA,useState as Zf}from"react";f();import Sp from"react";var Vk=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,Yk=/{{([\w-]+)}}/,Kk=/<([\w-]+)>/,$k=/<\/([\w-]+)>/,Xk=(e,t)=>{let r=[{name:"",children:[]}];return e.split(Vk).filter(Boolean).forEach(o=>{let n=o.match(Kk),i=o.match($k),a=o.match(Yk);if(n!==null){let l=n[1];t.hasOwnProperty(l)?r.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===r[r.length-1].name){let s=r.pop(),c=Sp.createElement(Sp.Fragment,{},...s.children),d=t[s.name];typeof d=="function"&&r[r.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let l=a[1];t.hasOwnProperty(l)?r[r.length-1].children.push(t[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else r[r.length-1].children.push(o)}),r.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),r[0].children},Zk=({i18nKey:e,children:t,...r})=>{let{t:o}=yt();return Sp.createElement(Sp.Fragment,{},...Xk(o(e),r))},sr=Zk;Pn();An();z();import{useAtom as jf}from"jotai";f();f();import jk from"clsx";import{jsx as Ip,jsxs as Jk}from"react/jsx-runtime";var qk=({label:e,onClick:t,className:r,children:o,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return Jk("button",{className:jk("Dialog__action-button",s,r),type:i,"aria-label":e,onClick:t,...l,children:[o&&Ip("div",{style:a?{visibility:"hidden"}:{},children:o}),Ip("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Ip("div",{style:{position:"absolute",inset:0},children:Ip(Ut,{})})]})},Vl=qk;import{useSetAtom as Qk}from"jotai";import{jsx as Wv,jsxs as Vv}from"react/jsx-runtime";var eA=e=>{let{onConfirm:t,onCancel:r,children:o,confirmText:n=b("buttons.confirm"),cancelText:i=b("buttons.cancel"),className:a="",...l}=e,s=_e(),c=Qk(Yl,Be),{container:d}=Bt();return Vv(ct,{onCloseRequest:r,size:"small",...l,className:`confirm-dialog ${a}`,children:[o,Vv("div",{className:"confirm-dialog-buttons",children:[Wv(Vl,{label:i,onClick:()=>{s({openMenu:null}),c(!1),r(),d?.focus()}}),Wv(Vl,{label:n,onClick:()=>{s({openMenu:null}),c(!1),t(),d?.focus()},actionType:"danger"})]})]})},Cp=eA;f();import{useCallback as tA,useEffect as Vf,useRef as Yv,useState as Wf}from"react";import kp from"open-color";da();U();Er();z();f();var Tr=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),!1}}static get(t){try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):null}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),null}}static set=(t,r)=>{try{return window.localStorage.setItem(t,JSON.stringify(r)),!0}catch(o){return console.warn(`localStorage.setItem error: ${o.message}`),!1}};static delete=t=>{try{window.localStorage.removeItem(t)}catch(r){console.warn(`localStorage.removeItem error: ${r.message}`)}}};import{jsx as ye,jsxs as tr}from"react/jsx-runtime";var rA=async e=>{let o=Math.round(8),n=Math.max(Math.round(128/64),2),i=dx(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(o*2)-o*2,a.height=i.length*128+(i.length+1)*(o*2)-o*2;let l=a.getContext("2d");l.fillStyle=kp.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let d=await hi({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:m,height:p}=d,u=Math.floor(s/6)*(128+o*2),h=s%6*(128+o*2);l.drawImage(d,h+(128-m)/2+o,u+(128-p)/2+o),l.lineWidth=n,l.strokeStyle=kp.gray[4],l.strokeRect(h+o/2,u+o/2,128+o,128+o)}return await $s(new File([await Ln(a)],"preview",{type:J.png}),{outputType:J.jpg,maxWidthOrHeight:5e3})},oA=({libItem:e,appState:t,index:r,onChange:o,onRemove:n})=>{let i=Yv(null),a=Yv(null);return Vf(()=>{let l=i.current;l&&(async()=>{let s=await El({elements:e.elements,appState:{...t,viewBackgroundColor:kp.white,exportBackground:!0},files:null});l.innerHTML=s.outerHTML})()},[e.elements,t]),tr("div",{className:"single-library-item",children:[e.status==="published"&&ye("span",{className:"single-library-item-status",children:b("labels.statusPublished")}),ye("div",{ref:i,className:"single-library-item__svg"}),ye(ae,{"aria-label":b("buttons.remove"),type:"button",icon:ro,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:b("buttons.remove")}),tr("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[tr("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[tr("div",{style:{padding:"0.5em 0"},children:[ye("span",{style:{fontWeight:500,color:kp.gray[6]},children:b("publishDialog.itemName")}),ye("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ye("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{o(l.target.value,r)}})]}),ye("span",{className:"error",children:e.error})]})]})},nA=({onClose:e,libraryItems:t,appState:r,onSuccess:o,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Wf({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=Wf(!1);Vf(()=>{let y=Tr.get($r.PUBLISH_LIBRARY);y&&s(y)},[]);let[m,p]=Wf(t.slice());Vf(()=>{p(t.slice())},[t]);let u=y=>{s({...l,[y.target.name]:y.target.value})},h=async y=>{y.preventDefault(),d(!0);let I=[],P=!1;if(m.forEach(M=>{let k="";M.name||(k=b("publishDialog.errors.required"),P=!0),I.push({...M,error:k})}),P){p(I),d(!1);return}let C=await rA(m),_={type:jt.excalidrawLibrary,version:Ui.excalidrawLibrary,source:ms,libraryItems:m},D=JSON.stringify(_,null,2),H=new Blob([D],{type:"application/json"}),A=new FormData;A.append("excalidrawLib",H),A.append("previewImage",C),A.append("previewImageType",C.type),A.append("title",l.name),A.append("authorName",l.authorName),A.append("githubHandle",l.githubHandle),A.append("name",l.name),A.append("description",l.description),A.append("twitterHandle",l.twitterHandle),A.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:A}).then(M=>M.ok?M.json().then(({url:k})=>{Tr.delete($r.PUBLISH_LIBRARY),o({url:k,authorName:l.authorName,items:m})}):M.json().catch(()=>{throw new Error(M.statusText||"something went wrong")}).then(k=>{throw new Error(k.message||M.statusText||"something went wrong")}),M=>{console.error(M),n(M),d(!1)}).catch(M=>{console.error(M),n(M),d(!1)})},x=()=>{let y=[];return m.forEach((I,P)=>{y.push(ye("div",{className:"single-library-item-wrapper",children:ye(oA,{libItem:I,appState:r,index:P,onChange:(C,_)=>{let D=m.slice();D[_].name=C,p(D)},onRemove:a})},P))}),ye("div",{className:"selected-library-items",children:y})},E=tA(()=>{i(m),Tr.set($r.PUBLISH_LIBRARY,l),e()},[m,e,i,l]),v=!!t.length,w=t.some(y=>y.status==="published");return ye(ct,{onCloseRequest:E,title:b("publishDialog.title"),className:"publish-library",children:v?tr("form",{onSubmit:h,children:[ye("div",{className:"publish-library-note",children:ye(sr,{i18nKey:"publishDialog.noteDescription",link:y=>ye("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:y})})}),ye("span",{className:"publish-library-note",children:ye(sr,{i18nKey:"publishDialog.noteGuidelines",link:y=>ye("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),ye("div",{className:"publish-library-note",children:b("publishDialog.noteItems")}),w&&ye("span",{className:"publish-library-note publish-library-warning",children:b("publishDialog.republishWarning")}),x(),tr("div",{className:"publish-library__fields",children:[tr("label",{children:[tr("div",{children:[ye("span",{children:b("publishDialog.libraryName")}),ye("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ye("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:b("publishDialog.placeholder.libraryName")})]}),tr("label",{style:{alignItems:"flex-start"},children:[tr("div",{children:[ye("span",{children:b("publishDialog.libraryDesc")}),ye("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ye("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:b("publishDialog.placeholder.libraryDesc")})]}),tr("label",{children:[tr("div",{children:[ye("span",{children:b("publishDialog.authorName")}),ye("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ye("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:b("publishDialog.placeholder.authorName")})]}),tr("label",{children:[ye("span",{children:b("publishDialog.githubUsername")}),ye("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:b("publishDialog.placeholder.githubHandle")})]}),tr("label",{children:[ye("span",{children:b("publishDialog.twitterUsername")}),ye("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:b("publishDialog.placeholder.twitterHandle")})]}),tr("label",{children:[ye("span",{children:b("publishDialog.website")}),ye("input",{type:"text",name:"website",pattern:"https?://.+",title:b("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:b("publishDialog.placeholder.website")})]}),ye("span",{className:"publish-library-note",children:ye(sr,{i18nKey:"publishDialog.noteLicense",link:y=>ye("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),tr("div",{className:"publish-library__buttons",children:[ye(Vl,{label:b("buttons.cancel"),onClick:E,"data-testid":"cancel-clear-canvas-button"}),ye(Vl,{type:"submit",label:b("buttons.submit"),actionType:"primary",isLoading:c})]})]}):ye("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:b("publishDialog.atleastOneLibItem")})})},Kv=nA;f();f();import iA from"clsx";import{jsx as aA}from"react/jsx-runtime";var $v=({className:e="",children:t,onToggle:r,title:o,...n})=>{let i=Ie(),a=iA(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return aA("button",{"data-prevent-outside-click":!0,className:a,onClick:r,type:"button","data-testid":"dropdown-menu-button",title:o,...n,children:t})},Xv=$v;$v.displayName="DropdownMenuTrigger";f();f();U();z();import lA,{useContext as sA}from"react";var Yf=lA.createContext({}),Ap=(e="",t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?"dropdown-menu-item--selected":""}`.trim(),Mp=(e,t)=>{let r=sA(Yf);return Xn(e,o=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});t?.(n),n.defaultPrevented||r.onSelect?.(n)})};f();import{Fragment as dA,jsx as Kf,jsxs as mA}from"react/jsx-runtime";var cA=({icon:e,shortcut:t,children:r})=>{let o=Ie();return mA(dA,{children:[Kf("div",{className:"dropdown-menu-item__icon",children:e}),Kf("div",{className:"dropdown-menu-item__text",children:r}),t&&!o.editor.isMobile&&Kf("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Lp=cA;import{jsx as $f}from"react/jsx-runtime";var Xf=({icon:e,onSelect:t,children:r,shortcut:o,className:n,selected:i,...a})=>{let l=Mp(a.onClick,t);return $f("button",{...a,onClick:l,type:"button",className:Ap(n,i),title:a.title??a["aria-label"],children:$f(Lp,{icon:e,shortcut:o,children:r})})};Xf.displayName="DropdownMenuItem";var Zv=({children:e})=>$f("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",background:"pink",borderRadius:6,fontSize:9,color:"black",fontFamily:"Cascadia, monospace"},children:e});Zv.displayName="DropdownMenuItemBadge";Xf.Badge=Zv;var so=Xf;f();import{jsx as pA}from"react/jsx-runtime";var jv=()=>pA("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),qv=jv;jv.displayName="DropdownMenuSeparator";f();import{jsx as uA,jsxs as hA}from"react/jsx-runtime";var Jv=({children:e,className:t="",style:r,title:o})=>hA("div",{className:`dropdown-menu-group ${t}`,style:r,children:[o&&uA("p",{className:"dropdown-menu-group-title",children:o}),e]}),Qv=Jv;Jv.displayName="DropdownMenuGroup";f();import gA from"clsx";import{useEffect as fA,useRef as bA}from"react";ue();U();import{jsx as Pp}from"react/jsx-runtime";var e3=({children:e,onClickOutside:t,className:r="",onSelect:o,style:n})=>{let i=Ie(),a=bA(null),l=Rl({onClickOutside:t});Dl(a,()=>{l.onClickOutside?.()}),fA(()=>{let c=m=>{m.key===S.ESCAPE&&(m.stopImmediatePropagation(),l.onClickOutside?.())},d={capture:!0};return document.addEventListener("keydown",c,d),()=>{document.removeEventListener("keydown",c,d)}},[l]);let s=gA(`dropdown-menu ${r}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Pp(Yf.Provider,{value:{onSelect:o},children:Pp("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Pp(Ft.Col,{className:"dropdown-menu-container",children:e}):Pp($t,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};e3.displayName="DropdownMenuContent";var t3=e3;f();import{jsx as r3}from"react/jsx-runtime";var o3=({icon:e,shortcut:t,href:r,children:o,onSelect:n,className:i="",selected:a,...l})=>{let s=Mp(l.onClick,n);return r3("a",{...l,href:r,target:"_blank",rel:"noreferrer",className:Ap(i,a),title:l.title??l["aria-label"],onClick:s,children:r3(Lp,{icon:e,shortcut:t,children:o})})},Kl=o3;o3.displayName="DropdownMenuItemLink";f();import{jsx as EA}from"react/jsx-runtime";var xA=({children:e,className:t="",selected:r,...o})=>EA("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${r?"dropdown-menu-item--selected":""}`.trim(),children:e}),n3=xA;f();import _p from"react";var i3=e=>{let t=_p.Children.toArray(e).find(r=>_p.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuTrigger");return t||null},a3=e=>{let t=_p.Children.toArray(e).find(r=>_p.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuContent");return t||null};import{Fragment as yA,jsxs as wA}from"react/jsx-runtime";var Fn=({children:e,open:t})=>{let r=i3(e),o=a3(e);return wA(yA,{children:[r,t&&o]})};Fn.Trigger=Xv;Fn.Content=t3;Fn.Item=so;Fn.ItemLink=Kl;Fn.ItemCustom=n3;Fn.Group=Qv;Fn.Separator=qv;var Oe=Fn;Fn.displayName="DropdownMenu";import TA from"clsx";import{jsx as Sr,jsxs as Dp}from"react/jsx-runtime";var SA=(e,t)=>e.filter(r=>t.includes(r.id)),IA=({setAppState:e,selectedItems:t,library:r,onRemoveFromLibrary:o,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=jf(Ca,Be),[c,d]=jf(Yl,Be),m=()=>{let A=t.length?b("alerts.removeItemsFromsLibrary",{count:t.length}):b("alerts.resetLibrary"),M=t.length?b("confirmDialog.removeItemsFromLib"):b("confirmDialog.resetLibrary");return Sr(Cp,{onConfirm:()=>{t.length?o():n(),u(!1)},onCancel:()=>{u(!1)},title:M,children:Sr("p",{children:A})})},[p,u]=Zf(!1),h=!!t.length,x=h?s.libraryItems.filter(A=>t.includes(A.id)):s.libraryItems,E=h?b("buttons.remove"):b("buttons.resetLibrary"),[v,w]=Zf(!1),[y,I]=Zf(null),P=vA(()=>Dp(ct,{onCloseRequest:()=>I(null),title:b("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Sr("p",{children:Sr(sr,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:A=>Sr("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:A})})}),Sr(ae,{type:"button",title:b("buttons.close"),"aria-label":b("buttons.close"),label:b("buttons.close"),onClick:()=>I(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[I,y]),C=(A,M)=>{w(!1),I({url:A.url,authorName:A.authorName});let k=M.slice();k.forEach(O=>{t.includes(O.id)&&(O.status="published")}),r.setLibrary(k)},_=async()=>{try{await r.updateLibrary({libraryItems:al({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(A){if(A?.name==="AbortError"){console.warn(A);return}e({errorMessage:b("errors.importLibraryError")})}},D=async()=>{let A=h?x:await r.getLatestLibrary();xE(A).catch(dd).catch(M=>{e({errorMessage:M.message})})},H=()=>Dp(Oe,{open:c,children:[Sr(Oe.Trigger,{onToggle:()=>d(!c),children:_y}),Dp(Oe.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!h&&Sr(Oe.Item,{onSelect:_,icon:kl,"data-testid":"lib-dropdown--load",children:b("buttons.load")}),!!x.length&&Sr(Oe.Item,{onSelect:D,icon:ba,"data-testid":"lib-dropdown--export",children:b("buttons.export")}),!!x.length&&Sr(Oe.Item,{onSelect:()=>u(!0),icon:Lo,children:E}),h&&Sr(Oe.Item,{icon:G2,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:b("buttons.publishLibrary")})]})]});return Dp("div",{className:TA("library-menu-dropdown-container",l),children:[H(),t.length>0&&Sr("div",{className:"library-actions-counter",children:t.length}),p&&m(),v&&Sr(Kv,{onClose:()=>w(!1),libraryItems:SA(s.libraryItems,t),appState:a,onSuccess:A=>C(A,s.libraryItems),onError:A=>window.alert(A),updateItemsInStorage:()=>r.setLibrary(s.libraryItems),onRemove:A=>i(t.filter(M=>M!==A))}),y&&P()]})},qf=({selectedItems:e,onSelectItems:t,className:r})=>{let{library:o}=wr(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=xp(),a=Me(),l=_e(),[s]=jf(Ca,Be),c=async m=>{let p=m.filter(u=>!e.includes(u.id));o.setLibrary(p).catch(()=>{l({errorMessage:b("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return Sr(IA,{appState:a,setAppState:l,selectedItems:e,onSelectItems:t,library:o,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{o.resetLibrary(),n()},className:r})};f();import{memo as RA,useEffect as NA,useState as OA}from"react";f();import l3 from"clsx";import{memo as CA,useEffect as kA,useRef as AA,useState as MA}from"react";import{jsx as Rp,jsxs as LA}from"react/jsx-runtime";var s3=CA(({id:e,elements:t,isPending:r,onClick:o,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=AA(null),c=Pv(e,t,l);kA(()=>{let h=s.current;if(h)return c&&(h.innerHTML=c.outerHTML),()=>{h.innerHTML=""}},[c]);let[d,m]=MA(!1),p=Ie().editor.isMobile,u=r&&Rp("div",{className:"library-unit__adder",children:Py});return LA("div",{className:l3("library-unit",{"library-unit__active":t,"library-unit--hover":t&&d,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[Rp("div",{className:l3("library-unit__dragger",{"library-unit__pulse":!!r}),ref:s,draggable:!!t,onClick:t||r?h=>{e&&h.shiftKey?i(e,h):o(e)}:void 0,onDragStart:h=>{if(!e){h.preventDefault();return}m(!1),a(e,h)}}),u,e&&t&&(d||p||n)&&Rp(Ta,{checked:n,onChange:(h,x)=>i(e,x),className:"library-unit__checkbox"})]})}),c3=()=>Rp("div",{className:"library-unit library-unit--skeleton"});f();import PA,{useCallback as _A}from"react";function DA(){return[!1,_A(t=>t(),[])]}var d3=PA.useTransition||DA;import{Fragment as BA,jsx as Np}from"react/jsx-runtime";var Jf=({children:e})=>Np("div",{className:"library-menu-items-container__grid",children:e}),Op=RA(({items:e,onItemSelectToggle:t,onItemDrag:r,isItemSelected:o,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=d3(),[s,c]=OA(0);return NA(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Np(BA,{children:e.map((d,m)=>m<s?Np(s3,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:n,svgCache:i,id:d?.id,selected:o(d.id),onToggle:t,onDrag:r},d?.id??m):Np(c3,{},m))})});f();import{useEffect as FA}from"react";import{atom as HA,useAtom as zA}from"jotai";import GA from"lodash.throttle";var UA=HA(0),m3=e=>{let[t,r]=zA(UA);return FA(()=>{let{current:o}=e;if(!o)return;let n=GA(()=>{let{scrollTop:i}=o;r(i)},200);return o.addEventListener("scroll",n),()=>{n.cancel(),o.removeEventListener("scroll",n)}},[e,r]),t};import{Fragment as u3,jsx as Ir,jsxs as Xl}from"react/jsx-runtime";var KA=17,$A=64;function Qf({isLoading:e,libraryItems:t,onAddToLibrary:r,onInsertLibraryItems:o,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let d=VA(null),m=m3(d);WA(()=>{m>0&&d.current?.scrollTo(0,m)},[]);let{svgCache:p}=xp(),u=p3(()=>t.filter(A=>A.status!=="published"),[t]),h=p3(()=>t.filter(A=>A.status==="published"),[t]),x=!t.length&&!n.length,E=!n.length&&!u.length&&!h.length,[v,w]=YA(null),y=$l((A,M)=>{let k=!c.includes(A),O=[...u,...h];if(k){if(M.shiftKey&&v){let X=O.findIndex(le=>le.id===v),Y=O.findIndex(le=>le.id===A);if(X===-1||Y===-1){s([...c,A]);return}let ee=$(c),xe=O.reduce((le,V,ve)=>((ve>=X&&ve<=Y||ee.has(V.id))&&le.push(V.id),le),[]);s(xe)}else s([...c,A]);w(A)}else w(null),s(c.filter(X=>X!==A))},[v,s,h,c,u]),I=$l(A=>{let M;return c.includes(A)?M=t.filter(k=>c.includes(k.id)):M=t.filter(k=>k.id===A),M.map(k=>({...k,elements:Xd(k.elements,{randomizeSeed:!0})}))},[t,c]),P=$l((A,M)=>{M.dataTransfer.setData(J.excalidrawlib,om(I(A)))},[I]),C=$l(A=>A?c.includes(A):!1,[c]),_=$l(()=>{r(n)},[n,r]),D=$l(A=>{A&&o(I(A))},[I,o]),H=p.size>=t.length?$A:KA;return Xl("div",{className:"library-menu-items-container",style:n.length||u.length||h.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!E&&Ir(qf,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Xl(Ft.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:h.length>0?1:"0 1 auto",marginBottom:0},ref:d,children:[Xl(u3,{children:[!E&&Ir("div",{className:"library-menu-items-container__header",children:b("labels.personalLib")}),e&&Ir("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Ir(Ut,{})}),!n.length&&!u.length?Xl("div",{className:"library-menu-items__no-items",children:[Ir("div",{className:"library-menu-items__no-items__label",children:b("library.noItems")}),Ir("div",{className:"library-menu-items__no-items__hint",children:h.length>0?b("library.hint_emptyPrivateLibrary"):b("library.hint_emptyLibrary")})]}):Xl(Jf,{children:[n.length>0&&Ir(Op,{itemsRenderedPerBatch:H,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:P,onClick:_,isItemSelected:C,svgCache:p}),Ir(Op,{itemsRenderedPerBatch:H,items:u,onItemSelectToggle:y,onItemDrag:P,onClick:D,isItemSelected:C,svgCache:p})]})]}),Xl(u3,{children:[(h.length>0||n.length>0||u.length>0)&&Ir("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:b("labels.excalidrawLib")}),h.length>0?Ir(Jf,{children:Ir(Op,{itemsRenderedPerBatch:H,items:h,onItemSelectToggle:y,onItemDrag:P,onClick:D,isItemSelected:C,svgCache:p})}):u.length>0?Ir("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:b("library.noItems")}):null]}),x&&Ir(Tp,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:Ir(qf,{selectedItems:c,onSelectItems:s})})]})]})}import{atom as ZA,useAtom as jA}from"jotai";Ve();z();U();import{jsx as wi,jsxs as g3}from"react/jsx-runtime";var Yl=ZA(!1),h3=({children:e})=>wi("div",{className:"layer-ui__library",children:e}),qA=({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:r,setAppState:o,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[d]=jA(Ca,Be),m=t1(h=>{(async(E,v)=>{fe("element","addToLibrary","ui");for(let y of id)if(E.some(I=>I.type===y))return o({errorMessage:b(`errors.libraryElementTypeError.${y}`)});let w=[{status:"unpublished",elements:E,id:Pt(),created:Date.now()},...v];r(),i.setLibrary(w).catch(()=>{o({errorMessage:b("alerts.errorAddingToLibrary")})})})(h,d.libraryItems)},[r,i,o,d.libraryItems]),p=f3(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return wi(h3,{children:wi("div",{className:"layer-ui__library-message",children:g3("div",{children:[wi(Ut,{size:"2em"}),wi("span",{children:b("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||t.length>0;return g3(h3,{children:[wi(Qf,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:m,onInsertLibraryItems:e,pendingElements:t,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&wi(Tp,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})},JA=(e,t)=>{let r=()=>pe(t,e,{includeBoundTextElement:!0,includeElementsInFrames:!0}),o=e1(r()),n=e1(e),i=e1(t);return(!wt(e.selectedElementIds,n.current.selectedElementIds)||!wt(t,i.current))&&(o.current=r(),n.current=e,i.current=t),o.current},b3=()=>{let{library:e,id:t,onInsertElements:r}=wr(),o=yi(),n=Me(),i=_e(),a=bi(),[l,s]=XA([]),c=f3(()=>e,[e]),d=JA(n,a),m=t1(u=>{r(vp(u))},[r]),p=t1(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return wi(qA,{pendingElements:d,onInsertLibraryItems:m,onAddToLibrary:p,setAppState:i,libraryReturnUrl:o.libraryReturnUrl,library:c,id:t,theme:n.theme,selectedItems:l,onSelectItems:s})};import{jsx as Tc,jsxs as nM}from"react/jsx-runtime";function oM(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var ct=e=>{let[t,r]=kv(),[o]=tM(document.activeElement),{id:n}=Bt(),i=Ie().viewport.isMobile;eM(()=>{if(!t)return;let c=hs(t);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=m=>{if(m.key===S.TAB){let p=hs(t),{activeElement:u}=document,h=p.findIndex(x=>x===u);h===0&&m.shiftKey?(p[p.length-1].focus(),m.preventDefault()):h===p.length-1&&!m.shiftKey&&(p[0].focus(),m.preventDefault())}};return t.addEventListener("keydown",d),()=>t.removeEventListener("keydown",d)},[t,e.autofocus]);let a=_e(),l=rM(Yl,Be),s=()=>{a({openMenu:null}),l(!1),o.focus(),e.onCloseRequest()};return Tc(Mv,{className:QA("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:oM(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:nM($t,{ref:r,children:[e.title&&Tc("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Tc("span",{className:"Dialog__titleContent",children:e.title})}),i&&Tc("button",{className:"Dialog__close",onClick:s,title:b("buttons.close"),"aria-label":b("buttons.close"),children:ro}),Tc("div",{className:"Dialog__content",children:e.children})]})})};f();import{forwardRef as lM,useRef as sM,useImperativeHandle as cM,useLayoutEffect as dM,useState as mM}from"react";import r1 from"clsx";f();z();import iM from"clsx";import{jsx as aM}from"react/jsx-runtime";var Jo=({type:e="button",onSelect:t,selected:r,children:o,className:n="",...i})=>aM("button",{onClick:Xn(i.onClick,a=>{t()}),type:e,className:iM("excalidraw-button",n,{selected:r}),...i,children:o});import{jsx as o1,jsxs as x3}from"react/jsx-runtime";var Bp=lM(({onChange:e,label:t,fullWidth:r,placeholder:o,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,...s},c)=>{let d=sM(null);cM(c,()=>d.current),dM(()=>{i&&d.current?.select()},[i]);let[m,p]=mM(!1);return x3("div",{className:r1("ExcTextField",{"ExcTextField--fullWidth":r}),onClick:()=>{d.current?.focus()},children:[o1("div",{className:"ExcTextField__label",children:t}),x3("div",{className:r1("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[o1("input",{className:r1({"is-redacted":"value"in s&&s.value&&l&&!m}),readOnly:n,value:"value"in s?s.value:void 0,defaultValue:"defaultValue"in s?s.defaultValue:void 0,placeholder:o,ref:d,onChange:u=>e?.(u.target.value),onKeyDown:a}),l&&o1(Jo,{onSelect:()=>p(!m),style:{border:0,userSelect:"none"},children:m?X2:Ll})]})]})});Ve();import k3 from"clsx";f();U();z();var pM={toggleTheme:[R("Shift+Alt+D")],saveScene:[R("CtrlOrCmd+S")],loadScene:[R("CtrlOrCmd+O")],clearCanvas:[R("CtrlOrCmd+Delete")],imageExport:[R("CtrlOrCmd+Shift+E")],commandPalette:[R("CtrlOrCmd+/"),R("CtrlOrCmd+Shift+P")],cut:[R("CtrlOrCmd+X")],copy:[R("CtrlOrCmd+C")],paste:[R("CtrlOrCmd+V")],copyStyles:[R("CtrlOrCmd+Alt+C")],pasteStyles:[R("CtrlOrCmd+Alt+V")],selectAll:[R("CtrlOrCmd+A")],deleteSelectedElements:[R("Delete")],duplicateSelection:[R("CtrlOrCmd+D"),R(`Alt+${b("helpDialog.drag")}`)],sendBackward:[R("CtrlOrCmd+[")],bringForward:[R("CtrlOrCmd+]")],sendToBack:[rr?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")],bringToFront:[rr?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")],copyAsPng:[R("Shift+Alt+C")],copyAsSvg:[],group:[R("CtrlOrCmd+G")],ungroup:[R("CtrlOrCmd+Shift+G")],gridMode:[R("CtrlOrCmd+'")],zenMode:[R("Alt+Z")],objectsSnapMode:[R("Alt+S")],stats:[R("Alt+/")],addToLibrary:[],flipHorizontal:[R("Shift+H")],flipVertical:[R("Shift+V")],viewMode:[R("Alt+R")],hyperlink:[R("CtrlOrCmd+K")],toggleElementLock:[R("CtrlOrCmd+Shift+L")],resetZoom:[R("CtrlOrCmd+0")],zoomOut:[R("CtrlOrCmd+-")],zoomIn:[R("CtrlOrCmd++")],zoomToFitSelection:[R("Shift+3")],zoomToFit:[R("Shift+1")],zoomToFitSelectionInViewport:[R("Shift+2")],toggleEraserTool:[R("E")],toggleHandTool:[R("H")],setFrameAsActiveTool:[R("F")],saveFileToDisk:[R("CtrlOrCmd+S")],saveToActiveFile:[R("CtrlOrCmd+S")],toggleShortcuts:[R("?")]},It=(e,t=0)=>{let r=pM[e];return r&&r.length>0?r[t]||r[0]:""};U();import LM from"fuzzy";z();import{atom as PM,useAtom as _M}from"jotai";f();var uM="\\u0300-\\u036f",hM="\\ufe20-\\ufe2f",gM="\\u20d0-\\u20ff",fM=uM+hM+gM,bM=`[${fM}]`,xM=RegExp(bM,"g"),EM=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,yM={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},n1=e=>e.replace(EM,t=>yM[t]||t).replace(xM,"");f();import{jsx as wM}from"react/jsx-runtime";var vi=({icon:e})=>wM("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});f();ue();var Sc=[{icon:By,value:"selection",key:S.V,numericKey:S[1],fillable:!0},{icon:Fy,value:"rectangle",key:S.R,numericKey:S[2],fillable:!0},{icon:Hy,value:"diamond",key:S.D,numericKey:S[3],fillable:!0},{icon:zy,value:"ellipse",key:S.O,numericKey:S[4],fillable:!0},{icon:Gy,value:"arrow",key:S.A,numericKey:S[5],fillable:!0},{icon:Uy,value:"line",key:S.L,numericKey:S[6],fillable:!0},{icon:Il,value:"freedraw",key:[S.P,S.X],numericKey:S[7],fillable:!1},{icon:Vy,value:"text",key:S.T,numericKey:S[8],fillable:!1},{icon:Yy,value:"image",key:null,numericKey:S[9],fillable:!1},{icon:Ky,value:"eraser",key:S.E,numericKey:S[0],fillable:!1}],E3=e=>Sc.find((r,o)=>r.numericKey!=null&&e===r.numericKey.toString()||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null;f();import{useState as vM}from"react";Ve();z();ks();ce();import l1 from"clsx";lt();ue();f();import i1 from"react";import Qo from"tunnel-rat";var a1=i1.createContext(null),et=()=>i1.useContext(a1),y3=()=>i1.useMemo(()=>({MainMenuTunnel:Qo(),WelcomeScreenMenuHintTunnel:Qo(),WelcomeScreenToolbarHintTunnel:Qo(),WelcomeScreenHelpHintTunnel:Qo(),WelcomeScreenCenterTunnel:Qo(),FooterCenterTunnel:Qo(),DefaultSidebarTriggerTunnel:Qo(),DefaultSidebarTabTriggersTunnel:Qo(),OverwriteConfirmDialogTunnel:Qo(),TTDDialogTriggerTunnel:Qo(),jotaiScope:Symbol()}),[]);import{Fragment as Ti,jsx as ot,jsxs as Et}from"react/jsx-runtime";var s1=(e,t)=>{let r=t[0]?.type||null;for(let o of t)if(o.type!==r){r=null;break}return Cs(e.activeTool.type)&&e.activeTool.type!=="image"&&r!=="image"&&r!=="frame"&&r!=="magicframe"||t.some(o=>Cs(o.type))},c1=(e,t)=>fn(e.activeTool.type)||t.some(r=>fn(r.type)),Fp=({appState:e,elementsMap:t,renderAction:r})=>{let o=ga(t,e),n=!1;o.length===2&&(gr(o[0])||gr(o[1]))&&(n=!0);let i=!!e.editingElement,a=Ie(),l=document.documentElement.getAttribute("dir")==="rtl",s=fn(e.activeTool.type)&&!or(e.currentItemBackgroundColor)||o.some(d=>fn(d.type)&&!or(d.backgroundColor)),c=o.length===1||n;return Et("div",{className:"panelColumn",children:[ot("div",{children:s1(e,o)&&r("changeStrokeColor")}),c1(e,o)&&ot("div",{children:r("changeBackgroundColor")}),s&&r("changeFillStyle"),(yd(e.activeTool.type)||o.some(d=>yd(d.type)))&&r("changeStrokeWidth"),(e.activeTool.type==="freedraw"||o.some(d=>d.type==="freedraw"))&&r("changeStrokeShape"),(wd(e.activeTool.type)||o.some(d=>wd(d.type)))&&Et(Ti,{children:[r("changeStrokeStyle"),r("changeSloppiness")]}),(Wa(e.activeTool.type)||o.some(d=>Wa(d.type)))&&ot(Ti,{children:r("changeRoundness")}),(e.activeTool.type==="text"||o.some(G))&&Et(Ti,{children:[r("changeFontSize"),r("changeFontFamily"),(e.activeTool.type==="text"||I0(o,t))&&r("changeTextAlign")]}),S0(o,t)&&r("changeVerticalAlign"),(Yi(e.activeTool.type)||o.some(d=>Yi(d.type)))&&ot(Ti,{children:r("changeArrowhead")}),r("changeOpacity"),Et("fieldset",{children:[ot("legend",{children:b("labels.layers")}),Et("div",{className:"buttonList",children:[r("sendToBack"),r("sendBackward"),r("bringToFront"),r("bringForward")]})]}),o.length>1&&!n&&Et("fieldset",{children:[ot("legend",{children:b("labels.align")}),Et("div",{className:"buttonList",children:[l?Et(Ti,{children:[r("alignRight"),r("alignHorizontallyCentered"),r("alignLeft")]}):Et(Ti,{children:[r("alignLeft"),r("alignHorizontallyCentered"),r("alignRight")]}),o.length>2&&r("distributeHorizontally"),ot("div",{style:{flexBasis:"100%",height:0}}),Et("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[r("alignTop"),r("alignVerticallyCentered"),r("alignBottom"),o.length>2&&r("distributeVertically")]})]})]}),!i&&o.length>0&&Et("fieldset",{children:[ot("legend",{children:b("labels.actions")}),Et("div",{className:"buttonList",children:[!a.editor.isMobile&&r("duplicateSelection"),!a.editor.isMobile&&r("deleteSelectedElements"),r("group"),r("ungroup"),c&&r("hyperlink")]})]})]})},Hp=({activeTool:e,appState:t,app:r,UIOptions:o})=>{let[n,i]=vM(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=et();return Et(Ti,{children:[Sc.map(({value:d,icon:m,key:p,numericKey:u,fillable:h},x)=>{if(o.tools?.[d]===!1)return null;let E=b(`toolBar.${d}`),v=p&&$n(typeof p=="string"?p:p[0]),w=v?`${v} ${b("helpDialog.or")} ${u}`:`${u}`;return ot(ae,{className:l1("Shape",{fillable:h}),type:"radio",icon:m,checked:e.type===d,name:"editor-current-shape",title:`${$n(E)} \u2014 ${w}`,keyBindingLabel:u||v,"aria-label":$n(E),"aria-keyshortcuts":w,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:y})=>{!t.penDetected&&y==="pen"&&r.togglePenMode(!0)},onChange:({pointerType:y})=>{t.activeTool.type!==d&&fe("toolbar",d,"ui"),d==="image"?r.setActiveTool({type:d,insertOnCanvasDirectly:y!=="mouse"}):r.setActiveTool({type:d})}},d)}),ot("div",{className:"App-toolbar__divider"}),Et(Oe,{open:n,children:[Et(Oe.Trigger,{className:l1("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||s||l&&!r.props.isCollaborating}),onToggle:()=>i(!n),title:b("toolBar.extraTools"),children:[K2,r.props.aiEnabled!==!1&&ot("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:8,fontFamily:"Cascadia, monospace",position:"absolute",background:"pink",color:"black",bottom:3,right:4},children:"AI"})]}),Et(Oe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[ot(Oe.Item,{onSelect:()=>r.setActiveTool({type:"frame"}),icon:$m,shortcut:S.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:b("toolBar.frame")}),ot(Oe.Item,{onSelect:()=>r.setActiveTool({type:"embeddable"}),icon:Xy,"data-testid":"toolbar-embeddable",selected:s,children:b("toolBar.embeddable")}),ot(Oe.Item,{onSelect:()=>r.setActiveTool({type:"laser"}),icon:Zm,"data-testid":"toolbar-laser",selected:l,shortcut:S.K.toLocaleUpperCase(),children:b("toolBar.laser")}),ot("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),r.props.aiEnabled!==!1&&ot(c.Out,{}),ot(Oe.Item,{onSelect:()=>r.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Xm,"data-testid":"toolbar-embeddable",children:b("toolBar.mermaidToExcalidraw")}),r.props.aiEnabled!==!1&&Et(Ti,{children:[Et(Oe.Item,{onSelect:()=>r.onMagicframeToolSelect(),icon:Ml,"data-testid":"toolbar-magicframe",children:[b("toolBar.magicframe"),ot(Oe.Item.Badge,{children:"AI"})]}),ot(Oe.Item,{onSelect:()=>{fe("ai","open-settings","d2c"),r.setOpenDialog({name:"settings",source:"settings",tab:"diagram-to-code"})},icon:dc,"data-testid":"toolbar-magicSettings",children:b("toolBar.magicSettings")})]})]})]})]})},w3=({renderAction:e,zoom:t})=>ot(Ft.Col,{gap:1,className:"zoom-actions",children:Et(Ft.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),v3=({renderAction:e,className:t})=>Et("div",{className:`undo-redo-buttons ${t}`,children:[ot("div",{className:"undo-button-container",children:ot(Ur,{label:b("buttons.undo"),children:e("undo")})}),ot("div",{className:"redo-button-container",children:Et(Ur,{label:b("buttons.redo"),children:[" ",e("redo")]})})]}),T3=({actionManager:e,showExitZenModeBtn:t})=>ot("button",{className:l1("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(Gl),children:b("buttons.exitZenMode")}),S3=({renderAction:e,className:t})=>ot("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})});f();import{useRef as TM}from"react";var d1=e=>{let t=TM({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...r)=>t.current.userFn(...r)),t.current.stableFn};f();import{atom as SM,useAtom as IM}from"jotai";import{jsx as kM,jsxs as CM}from"react/jsx-runtime";var ka=SM(null),I3=()=>{let[e,t]=IM(ka,Be),r=_t();return e&&e==="clearCanvas"?kM(Cp,{onConfirm:()=>{r.executeAction(On),t(null)},onCancel:()=>t(null),title:b("clearCanvasDialog.title"),children:CM("p",{className:"clear-canvas__content",children:[" ",b("alerts.clearReset")]})}):null};var m1={};Pu(m1,{toggleTheme:()=>AM});f();var AM={...ya,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(ya,"commandPalette")}};import{jsx as cr,jsxs as en}from"react/jsx-runtime";var DM=PM(null),gt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},RM=e=>{switch(e){case gt.app:return 1;case gt.export:return 2;case gt.editor:return 3;case gt.tools:return 4;case gt.elements:return 5;case gt.links:return 6;default:return 10}},Up=({shortcut:e,className:t,children:r})=>{let o=e.replace("++","+$").split("+");return en("div",{className:k3("shortcut",t),children:[o.map((n,i)=>cr("div",{className:"shortcut-wrapper",children:cr("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),cr("div",{className:"shortcut-desc",children:r})]})},A3=e=>!e.altKey&&e[S.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===S.P||e.key===S.SLASH),tie=Object.assign(e=>{let t=Me(),r=_e();return Gp(()=>{let o=n=>{A3(n)&&(n.preventDefault(),n.stopPropagation(),r(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&fe("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",o,{capture:!0}),()=>window.removeEventListener("keydown",o,{capture:!0})},[r]),t.openDialog?.name!=="commandPalette"?null:cr(NM,{...e})},{defaultItems:m1});function NM({customCommandPaletteItems:e}){let t=wr(),r=Me(),o=_e(),n=yi(),i=_t(),[a,l]=_M(DM),[s,c]=zp(null),d=MM(null),m=Rl({uiAppState:r,customCommandPaletteItems:e,appProps:n});Gp(()=>{let{uiAppState:C,customCommandPaletteItems:_,appProps:D}=m,H=O=>{let X="";return O.label&&(typeof O.label=="function"?X=b(O.label(t.scene.getNonDeletedElements(),C,t)):X=b(O.label)),X},A=O=>typeof O.icon=="function"?O.icon(C,t.scene.getNonDeletedElements()):O.icon,M=[],k=(O,X,Y)=>{let ee={label:H(O),icon:A(O),category:X,shortcut:It(O.name),keywords:O.keywords,predicate:O.predicate,viewMode:O.viewMode,perform:()=>{i.executeAction(O,"commandPalette")}};return Y?Y(ee,O):ee};if(C&&t.scene&&i){let O=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.copyStyles,i.actions.pasteStyles,i.actions.sendBackward,i.actions.sendToBack,i.actions.bringForward,i.actions.bringToFront,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,yc].map(V=>k(V,gt.elements,(ve,Re)=>({...ve,predicate:Re.predicate?Re.predicate:(mt,Le,ur,ln)=>pe(mt,Le).length>0}))),X=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool].map(V=>k(V,gt.tools)),Y=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(V=>k(V,gt.editor)),ee=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(V=>k(V,gt.export));M=[...O,...Y,{label:H(On),icon:A(On),shortcut:It(On.name),category:gt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Xt.set(ka,"clearCanvas")}},{label:b("buttons.exportImage"),category:gt.export,icon:Wm,shortcut:It("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{o({openDialog:{name:"imageExport"}})}},...ee];let xe=[{label:b("toolBar.library"),category:gt.app,icon:Hm,viewMode:!1,perform:()=>{C.openSidebar?o({openSidebar:null}):o({openSidebar:{name:kr.name,tab:kr.defaultTab}})}},{label:b("labels.changeStroke"),keywords:["color","outline"],category:gt.elements,icon:Um,viewMode:!1,predicate:(V,ve)=>{let Re=pe(V,ve);return Re.length>0&&s1(ve,Re)},perform:()=>{o(V=>({openMenu:V.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:b("labels.changeBackground"),keywords:["color","fill"],icon:Um,category:gt.elements,viewMode:!1,predicate:(V,ve)=>{let Re=pe(V,ve);return Re.length>0&&c1(ve,Re)},perform:()=>{o(V=>({openMenu:V.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:b("labels.canvasBackground"),keywords:["color"],icon:Um,category:gt.editor,viewMode:!1,perform:()=>{o(V=>({openMenu:V.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Sc.reduce((V,ve)=>{let{value:Re,icon:mt,key:Le,numericKey:ur}=ve;if(D.UIOptions.tools?.[Re]===!1)return V;let Gt=Le&&$n(typeof Le=="string"?Le:Le[0])||ur,Do={label:b(`toolBar.${Re}`),category:gt.tools,shortcut:Gt,icon:mt,keywords:["toolbar"],viewMode:!1,perform:({event:sn})=>{Re==="image"?t.setActiveTool({type:Re,insertOnCanvasDirectly:sn.type==="keydown"}):t.setActiveTool({type:Re})}};return V.push(Do),V},[]),...X,{label:b("toolBar.lock"),category:gt.tools,icon:C.activeTool.locked?Sl:fa,shortcut:S.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${b("labels.textToDiagram")}...`,category:gt.tools,icon:j2,viewMode:!1,predicate:D.aiEnabled,perform:()=>{o(V=>({...V,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${b("toolBar.mermaidToExcalidraw")}...`,category:gt.tools,icon:Xm,viewMode:!1,predicate:D.aiEnabled,perform:()=>{o(V=>({...V,openDialog:{name:"ttd",tab:"mermaid"}}))}}],le=[...M,...xe,..._||[]].map(V=>({...V,icon:V.icon||qm,order:V.order??RM(V.category),haystack:`${n1(V.label)} ${V.keywords?.join(" ")||""}`}));c(le),l(le.find(V=>V.label===a?.label)??null)}},[m,t,i,c,a?.label,l,o]);let[p,u]=zp(""),[h,x]=zp(null),[E,v]=zp({}),w=C=>{o({openDialog:null},C),u("")},y=(C,_)=>{r.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{C.perform({actionManager:i,event:_}),l(C),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},I=d1(C=>C.viewMode===!1&&r.viewModeEnabled?!1:typeof C.predicate=="function"?C.predicate(t.scene.getNonDeletedElements(),r,n,t):C.predicate===void 0||C.predicate),P=d1(C=>{let _=Xr(C.target)||A3(C)||C.key===S.ESCAPE;if(_&&C.key!==S.ARROW_UP&&C.key!==S.ARROW_DOWN&&C.key!==S.ENTER)return;let D=Object.values(E).flat(),H=a&&!p&&I(a);if(C.key===S.ARROW_UP){C.preventDefault();let A=D.findIndex(O=>O.label===h?.label);if(H){if(A===0){x(a);return}if(h===a){let O=D[D.length-1];O&&x(O);return}}let M;A===-1?M=D.length-1:M=A===0?D.length-1:(A-1)%D.length;let k=D[M];k&&x(k);return}if(C.key===S.ARROW_DOWN){C.preventDefault();let A=D.findIndex(O=>O.label===h?.label);if(H){if(!h||A===D.length-1){x(a);return}if(h===a){let O=D[0];O&&x(O);return}}let M=(A+1)%D.length,k=D[M];k&&x(k);return}if(C.key===S.ENTER&&h&&setTimeout(()=>{y(h,C)}),!_){if(C.stopPropagation(),/^[a-zA-Z0-9]$/.test(C.key)){d?.current?.focus();return}C.preventDefault()}});return Gp(()=>(window.addEventListener("keydown",P,{capture:!0}),()=>window.removeEventListener("keydown",P,{capture:!0})),[P]),Gp(()=>{if(!s)return;let C=A=>{let M={};for(let k of A)M[k.category]?M[k.category].push(k):M[k.category]=[k];return M},_=s.filter(I).sort((A,M)=>A.order-M.order),D=!p&&a&&I(a);if(!p){v(C(D?_.filter(A=>A.label!==a?.label):_)),x(D?a:_[0]||null);return}let H=n1(p.replace(/[<>-_| ]/g,""));_=LM.filter(H,_,{extract:A=>A.haystack}).sort((A,M)=>M.score-A.score).map(A=>A.original),v(C(_)),x(_[0]??null)},[p,s,I,a]),en(ct,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[cr(Bp,{value:p,placeholder:b("commandPalette.search.placeholder"),onChange:C=>{u(C)},selectOnRender:!0,ref:d}),!t.device.viewport.isMobile&&en("div",{className:"shortcuts-wrapper",children:[cr(Up,{shortcut:"\u2191\u2193",children:b("commandPalette.shortcuts.select")}),cr(Up,{shortcut:"\u21B5",children:b("commandPalette.shortcuts.confirm")}),cr(Up,{shortcut:R("Esc"),children:b("commandPalette.shortcuts.close")})]}),en("div",{className:"commands",children:[a&&!p&&en("div",{className:"command-category",children:[en("div",{className:"command-category-title",children:[b("commandPalette.recents"),cr("div",{className:"icon",style:{marginLeft:"6px"},children:q2})]}),cr(C3,{command:a,isSelected:a.label===h?.label,onClick:C=>y(a,C),disabled:!I(a),onMouseMove:()=>x(a),showShortcut:!t.device.viewport.isMobile,appState:r})]}),Object.keys(E).length>0?Object.keys(E).map((C,_)=>en("div",{className:"command-category",children:[cr("div",{className:"command-category-title",children:C}),E[C].map(D=>cr(C3,{command:D,isSelected:D.label===h?.label,onClick:H=>y(D,H),onMouseMove:()=>x(D),showShortcut:!t.device.viewport.isMobile,appState:r},D.label))]},C)):s?en("div",{className:"no-match",children:[cr("div",{className:"icon",children:jm})," ",b("commandPalette.search.noMatch")]}):null]})]})}var C3=({command:e,isSelected:t,disabled:r,onMouseMove:o,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return en("div",{className:k3("command-item",{"item-selected":t,"item-disabled":r}),ref:s=>{t&&!r&&s?.scrollIntoView?.({block:"nearest"})},onClick:r?l:n,onMouseMove:r?l:o,title:r?b("commandPalette.itemNotAvailable"):"",children:[en("div",{className:"name",children:[e.icon&&cr(vi,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&cr(Up,{shortcut:e.shortcut})]})};Qt();ce();Ye();var p1=B({name:"toggleLinearEditor",category:gt.elements,label:(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return t.editingLinearElement?.elementId===o?.id?"labels.lineEditor.exit":"labels.lineEditor.edit"},trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return!!(n.length===1&&re(n[0]))},perform(e,t,r,o){let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],i=t.editingLinearElement?.elementId===n.id?null:new K(n);return{appState:{...t,editingLinearElement:i},commitToHistory:!1}}});f();ue();We();Jr();z();U();wo();import{jsx as _3}from"react/jsx-runtime";var M3=(e,t,r)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingElement&&!t.draggingElement){let n=r();if(n===null)return{commitToHistory:!1};let i=$(e),a=n.elements,l=$(a),s=e.filter(d=>!l.has(d.id)),c=a.map(d=>ne(i.get(d.id)||d,d)).concat(s.map(d=>ne(d,{isDeleted:!0})));return Qa(c,s),Mr(c),{elements:c,appState:{...t,...n.appState},commitToHistory:!1,syncHistory:!0}}return{commitToHistory:!1}},L3=e=>({name:"undo",label:"buttons.undo",icon:Dg,trackEvent:{category:"history"},viewMode:!1,perform:(t,r)=>M3(t,r,()=>e.undoOnce()),keyTest:t=>t[S.CTRL_OR_CMD]&&t.key.toLowerCase()===S.Z&&!t.shiftKey,PanelComponent:({updateData:t,data:r})=>_3(ae,{type:"button",icon:Dg,"aria-label":b("buttons.undo"),onClick:t,size:r?.size||"medium"}),commitToHistory:()=>!1}),P3=e=>({name:"redo",label:"buttons.redo",icon:Rg,trackEvent:{category:"history"},viewMode:!1,perform:(t,r)=>M3(t,r,()=>e.redoOnce()),keyTest:t=>t[S.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===S.Z||jc&&t.ctrlKey&&!t.shiftKey&&t.key===S.Y,PanelComponent:({updateData:t,data:r})=>_3(ae,{type:"button",icon:Rg,"aria-label":b("buttons.redo"),onClick:t,size:r?.size||"medium"}),commitToHistory:()=>!1});f();z();import{jsx as OM}from"react/jsx-runtime";var u1=(e,t,r,o,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(r,o,i))&&fe(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Wp=class{actions={};updater;getAppState;getElementsIncludingDeleted;app;constructor(t,r,o,n){this.updater=i=>{if(Oo(i))i.then(a=>t(a));else return t(i)},this.getAppState=r,this.getElementsIncludingDeleted=o,this.app=n}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(r=>this.registerAction(r))}handleKeyDown(t){let r=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in r?r[s.name]:!0)&&s.keyTest&&s.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let n=o[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return u1(n,"keyboard",a,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(o[0].perform(i,a,l,this.app)),!0}executeAction(t,r="api",o=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();u1(t,r,i,n,this.app,o),this.updater(t.perform(n,i,o,this.app))}renderAction=(t,r)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in o)||o[t])){let n=this.actions[t],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{u1(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return OM(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:r})}return null};isActionEnabled=t=>{let r=this.getElementsIncludingDeleted(),o=this.getAppState();return!t.predicate||t.predicate(r,o,this.app.props,this.app)}};Ye();Rr();ui();U();cl();ge();Jr();Qt();We();In();ce();f();var h1=e=>{let t=Array.from(e.values());return{x:D3(t,r=>r.x)/t.length,y:D3(t,r=>r.y)/t.length}},g1=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),D3=(e,t)=>e.reduce((r,o)=>r+t(o),0);Nr();f();ce();In();var BM=e=>({selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,viewBackgroundColor:e.viewBackgroundColor,editingLinearElement:e.editingLinearElement,editingGroupId:e.editingGroupId,name:e.name}),f1=class{elementCache=new Map;recording=!0;stateHistory=[];redoStack=[];lastEntry=null;hydrateHistoryEntry({appState:t,elements:r}){return{appState:JSON.parse(t),elements:r.map(o=>{let n=this.elementCache.get(o.id)?.get(o.versionNonce);if(!n)throw new Error(`Element not found: ${o.id}:${o.versionNonce}`);return n})}}dehydrateHistoryEntry({appState:t,elements:r}){return{appState:JSON.stringify(t),elements:r.map(o=>{this.elementCache.has(o.id)||this.elementCache.set(o.id,new Map);let n=this.elementCache.get(o.id);return n.has(o.versionNonce)||n.set(o.versionNonce,Sn(o)),{id:o.id,versionNonce:o.versionNonce}})}}getSnapshotForTest(){return{recording:this.recording,stateHistory:this.stateHistory.map(t=>this.hydrateHistoryEntry(t)),redoStack:this.redoStack.map(t=>this.hydrateHistoryEntry(t))}}clear(){this.stateHistory.length=0,this.redoStack.length=0,this.lastEntry=null,this.elementCache.clear()}generateEntry=(t,r)=>this.dehydrateHistoryEntry({appState:BM(t),elements:r.reduce((o,n)=>{if(re(n)&&t.multiElement&&t.multiElement.id===n.id){if(t.multiElement&&t.multiElement.id===n.id&&n.points.length<2)return o;o.push({...n,points:n.lastCommittedPoint!==n.points[n.points.length-1]?n.points.slice(0,-1):n.points})}else o.push(n);return o},[])});shouldCreateEntry(t){let{lastEntry:r}=this;if(!r||t.elements.length!==r.elements.length)return!0;for(let n=t.elements.length-1;n>-1;n--){let i=t.elements[n],a=r.elements[n];if(!i||!a||i.id!==a.id||i.versionNonce!==a.versionNonce)return!0}let o;for(o in t.appState)if(!(o==="editingLinearElement"&&t.appState[o]?.elementId===r.appState[o]?.elementId)&&!(o==="selectedElementIds"||o==="selectedGroupIds")&&t.appState[o]!==r.appState[o])return!0;return!1}pushEntry(t,r){let o=this.generateEntry(t,r),n=this.hydrateHistoryEntry(o);if(n){if(!this.shouldCreateEntry(n))return;this.stateHistory.push(o),this.lastEntry=n,this.clearRedoStack()}}clearRedoStack(){this.redoStack.splice(0,this.redoStack.length)}redoOnce(){if(this.redoStack.length===0)return null;let t=this.redoStack.pop();return t!==void 0?(this.stateHistory.push(t),this.hydrateHistoryEntry(t)):null}undoOnce(){if(this.stateHistory.length===1)return null;let t=this.stateHistory.pop(),r=this.stateHistory[this.stateHistory.length-1];return t!==void 0?(this.redoStack.push(t),this.hydrateHistoryEntry(r)):null}setCurrentState(t,r){this.lastEntry=this.hydrateHistoryEntry(this.generateEntry(t,r))}resumeRecording(){this.recording=!0}record(t,r){this.recording&&(this.pushEntry(t,r),this.recording=!1)}},R3=f1;ue();pa();Rt();Ve();Jn();Fm();jh();Id();z();Gs();f();import FM from"clsx";import HM from"react";import{jsx as Zl,jsxs as zM}from"react/jsx-runtime";var dr="separator",N3=HM.memo(({actionManager:e,items:t,top:r,left:o,onClose:n})=>{let i=Ul(),a=bi(),l=t.reduce((s,c)=>(c&&(c===dr||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return Zl(np,{onCloseRequest:()=>{n()},top:r,left:o,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Zl("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===dr)return!l[c-1]||l[c-1]===dr?null:Zl("hr",{className:"context-menu-item-separator"},c);let d=s.name,m="";return s.label&&(typeof s.label=="function"?m=b(s.label(a,i,e.app)):m=b(s.label)),Zl("li",{"data-testid":d,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:zM("button",{className:FM("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Zl("div",{className:"context-menu-item__label",children:m}),Zl("kbd",{className:"context-menu-item__shortcut",children:d?It(d):""})]})},c)})})})});f();U();ge();import Rc from"clsx";import N8 from"react";Ve();z();f();import GM,{useState as UM}from"react";import{Fragment as WM,jsx as b1}from"react/jsx-runtime";var O3=({children:e,onClose:t})=>{let[r,o]=UM(!!e),{container:n}=Bt(),i=GM.useCallback(()=>{o(!1),t&&t(),n?.focus()},[t,n]);return b1(WM,{children:r&&b1(ct,{size:"small",onCloseRequest:i,title:b("errorDialog.title"),children:b1("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};f();import{useEffect as qM,useRef as JM,useState as Si}from"react";ui();U();Er();An();Ve();da();f();import VM from"clsx";import{jsx as B3,jsxs as YM}from"react/jsx-runtime";var Vp=function({onChange:e,value:t,choices:r,name:o}){return B3("div",{className:"RadioGroup",children:r.map(n=>YM("div",{className:VM("RadioGroup__choice",{active:n.value===t}),title:n.ariaLabel,children:[B3("input",{name:o,type:"radio",checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};f();import KM from"clsx";import{jsx as F3}from"react/jsx-runtime";var Ic=({title:e,name:t,checked:r,onChange:o,disabled:n=!1})=>F3("div",{className:KM("Switch",{toggled:r,disabled:n}),children:F3("input",{name:t,id:t,title:e,type:"checkbox",checked:r,disabled:n,onChange:()=>o(!r),onKeyDown:i=>{i.key===" "&&o(!r)}})});f();import{forwardRef as $M,useState as XM}from"react";import ZM from"clsx";qn();z();import{jsx as x1,jsxs as jM}from"react/jsx-runtime";var tn=$M(({children:e,icon:t,onClick:r,label:o,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s},c)=>{let[d,m]=XM(!1),p=async u=>{let h=r?.(u);if(Oo(h))try{m(!0),await h}catch(x){if(x instanceof zo)console.warn(x);else throw x}finally{m(!1)}};return x1("button",{className:ZM("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,{"ExcButton--fullWidth":l},s),onClick:p,type:"button","aria-label":o,ref:c,disabled:d,children:jM("div",{className:"ExcButton__contents",children:[d&&x1(Ut,{}),t&&x1("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),n!=="icon"&&(e??o)]})})});z();import{jsx as tt,jsxs as Ii}from"react/jsx-runtime";var QM="filter"in document.createElement("canvas").getContext("2d"),eL=()=>Ii("div",{children:[tt("h3",{children:b("canvasError.cannotShowPreview")}),tt("p",{children:tt("span",{children:b("canvasError.canvasTooBig")})}),Ii("em",{children:["(",b("canvasError.canvasTooBigTip"),")"]})]}),tL=({appStateSnapshot:e,elementsSnapshot:t,files:r,actionManager:o,onExportImage:n,name:i})=>{let a=ze(t,e),[l,s]=Si(i),[c,d]=Si(a),[m,p]=Si(e.exportBackground),[u,h]=Si(e.exportWithDarkMode),[x,E]=Si(e.exportEmbedScene),[v,w]=Si(e.exportScale),y=JM(null),[I,P]=Si(null),{exportedElements:C,exportingFrame:_}=wa(t,e,c);return qM(()=>{let D=y.current;if(!D)return;let H=D.offsetWidth,A=D.offsetHeight;H&&hi({elements:C,appState:{...e,name:l,exportBackground:m,exportWithDarkMode:u,exportScale:v,exportEmbedScene:x},files:r,exportPadding:fo,maxWidthOrHeight:Math.max(H,A),exportingFrame:_}).then(M=>(P(null),Ln(M).then(()=>{D.replaceChildren(M)}).catch(k=>{throw k.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):k}))).catch(M=>{console.error(M),P(M)})},[e,r,C,_,l,m,u,v,x]),Ii("div",{className:"ImageExportModal",children:[tt("h3",{children:b("imageExportDialog.header")}),Ii("div",{className:"ImageExportModal__preview",children:[tt("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&tt(eL,{})}),tt("div",{className:"ImageExportModal__preview__filename",children:!si&&tt("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:D=>{s(D.target.value),o.executeAction(yf,"ui",D.target.value)}})})]}),Ii("div",{className:"ImageExportModal__settings",children:[tt("h3",{children:b("imageExportDialog.header")}),a&&tt(Cc,{label:b("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:tt(Ic,{name:"exportOnlySelected",checked:c,onChange:D=>{d(D)}})}),tt(Cc,{label:b("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:tt(Ic,{name:"exportBackgroundSwitch",checked:m,onChange:D=>{p(D),o.executeAction(wf,"ui",D)}})}),QM&&tt(Cc,{label:b("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:tt(Ic,{name:"exportDarkModeSwitch",checked:u,onChange:D=>{h(D),o.executeAction(iv,"ui",D)}})}),tt(Cc,{label:b("imageExportDialog.label.embedScene"),tooltip:b("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:tt(Ic,{name:"exportEmbedSwitch",checked:x,onChange:D=>{E(D),o.executeAction(sp,"ui",D)}})}),tt(Cc,{label:b("imageExportDialog.label.scale"),name:"exportScale",children:tt(Vp,{name:"exportScale",value:v,onChange:D=>{w(D),o.executeAction(nv,"ui",D)},choices:Fa.map(D=>({value:D,label:`${D}\xD7`}))})}),Ii("div",{className:"ImageExportModal__settings__buttons",children:[tt(tn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.exportToPng"),onClick:()=>n(Qc.png,C,{exportingFrame:_}),icon:jg,children:b("imageExportDialog.button.exportToPng")}),tt(tn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.exportToSvg"),onClick:()=>n(Qc.svg,C,{exportingFrame:_}),icon:jg,children:b("imageExportDialog.button.exportToSvg")}),(xl||mn)&&tt(tn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.copyPngToClipboard"),onClick:()=>n(Qc.clipboard,C,{exportingFrame:_}),icon:Km,children:b("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Cc=({label:e,children:t,tooltip:r,name:o})=>Ii("div",{className:"ImageExportModal__settings__setting",title:e,children:[Ii("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,r&&tt(Ur,{label:r,long:!0,children:W2})]}),tt("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),H3=({elements:e,appState:t,files:r,actionManager:o,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Si(()=>({appStateSnapshot:Bo(t),elementsSnapshot:Bo(e)}));return tt(ct,{onCloseRequest:i,size:"wide",title:!1,children:tt(tL,{elementsSnapshot:s,appStateSnapshot:l,files:r,actionManager:o,onExportImage:n,name:a})})};f();import rL from"clsx";import{jsx as oL}from"react/jsx-runtime";var Yp=({children:e,side:t,className:r})=>oL("div",{className:rL("FixedSideContainer",`FixedSideContainer_side_${t}`,r),children:e});f();ce();z();Rr();import{jsx as z3}from"react/jsx-runtime";var nL=({appState:e,isMobile:t,device:r,app:o})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar&&!r.editor.canFitSidebar)return null;if(xr(e))return b("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?b("hints.linearElementMulti"):b("hints.linearElement");if(n.type==="freedraw")return b("hints.freeDraw");if(n.type==="text")return b("hints.text");if(n.type==="embeddable")return b("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return b("hints.placeImage");let c=o.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let d=c[0];return re(d)&&d.points.length===2?b("hints.lockAngle"):Zr(d)?b("hints.resizeImage"):b("hints.resize")}if(a&&l==="mouse")return b("hints.rotate");if(c.length===1&&G(c[0]))return b("hints.text_selected");if(e.editingElement&&G(e.editingElement))return b("hints.text_editing");if(n.type==="selection"){if(e.draggingElement?.type==="selection"&&!c.length&&!e.editingElement&&!e.editingLinearElement)return b("hints.deepBoxSelect");if(e.gridSize&&e.draggingElement)return b("hints.disableSnapping");if(!c.length&&!t)return b("hints.canvasPanning");if(c.length===1){if(re(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?b("hints.lineEditor_pointSelected"):b("hints.lineEditor_nothingSelected"):b("hints.lineEditor_info");if(!e.draggingElement&&Fo(c[0]))return b("hints.bindTextToElement")}}return null},Kp=({appState:e,isMobile:t,device:r,app:o})=>{let n=nL({appState:e,isMobile:t,device:r,app:o});return n?(n=R(n),z3("div",{className:"HintViewer",children:z3("span",{children:n})})):null};f();import iL from"clsx";import{jsx as U3,jsxs as lL}from"react/jsx-runtime";var aL="medium",G3={CHECKED:Sl,UNCHECKED:fa},$p=e=>lL("label",{className:iL("ToolIcon ToolIcon__lock",`ToolIcon_size_${aL}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[U3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),U3("div",{className:"ToolIcon__icon",children:e.checked?G3.CHECKED:G3.UNCHECKED})]});f();ge();Ve();f();import{Fragment as sL,jsx as W3,jsxs as cL}from"react/jsx-runtime";var Ci=({heading:e,children:t,...r})=>{let{id:o}=Bt(),n=W3("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:b(`headings.${e}`)});return W3("section",{...r,"aria-labelledby":`${o}-${e}-title`,children:typeof t=="function"?t(n):cL(sL,{children:[n,t]})})};f();ge();z();var Po=4,rn=6,V3="rgba(0,0,0,0.3)",Y3=(e,t,r,o)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,l]=we(e),s=t/o.zoom.value,c=r/o.zoom.value,d=t-s,m=r-c,p={top:parseInt(us("sat"))||0,bottom:parseInt(us("sab"))||0,left:parseInt(us("sal"))||0,right:parseInt(us("sar"))||0},u=dn().rtl,h=-o.scrollX+d/2+p.left,x=-o.scrollY+m/2+p.top,E=h+s-p.right,v=x+c-p.bottom,w=Math.min(n,h),y=Math.min(i,x),I=Math.max(a,E),P=Math.max(l,v);return{horizontal:h===w&&E===I?null:{x:Math.max(p.left,Po)+(h-w)/(I-w)*t,y:r-rn-Math.max(Po,p.bottom),width:(E-h)/(I-w)*t-Math.max(Po*2,p.left+p.right),height:rn},vertical:x===y&&v===P?null:{x:u?Math.max(p.left,Po):t-rn-Math.max(p.right,Po),y:(x-y)/(P-y)*r+Math.max(p.top,Po),width:rn,height:(v-x)/(P-y)*r-Math.max(Po*2,p.top+p.bottom)}}},E1=(e,t,r)=>{let[o,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=t&&t<=a.x+a.width&&a.y<=r&&r<=a.y+a.height);return{isOverEither:o||n,isOverHorizontal:o,isOverVertical:n}};f();import dL from"clsx";import{jsx as K3,jsxs as pL}from"react/jsx-runtime";var mL="medium",Xp=e=>e.penDetected?pL("label",{className:dL("ToolIcon ToolIcon__penMode",`ToolIcon_size_${mL}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[K3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),K3("div",{className:"ToolIcon__icon",children:Wy})]}):null;f();at();Ve();import{Fragment as $3,jsx as qe,jsxs as Wr}from"react/jsx-runtime";var Zp=e=>{let t=we(e.elements),r=ga(e.elements,e.appState),o=we(r);return qe("div",{className:"Stats",children:Wr($t,{padding:2,children:[qe("div",{className:"close",onClick:e.onClose,children:ro}),qe("h3",{children:b("stats.title")}),qe("table",{children:Wr("tbody",{children:[qe("tr",{children:qe("th",{colSpan:2,children:b("stats.scene")})}),Wr("tr",{children:[qe("td",{children:b("stats.elements")}),qe("td",{children:e.elements.length})]}),Wr("tr",{children:[qe("td",{children:b("stats.width")}),qe("td",{children:Math.round(t[2])-Math.round(t[0])})]}),Wr("tr",{children:[qe("td",{children:b("stats.height")}),qe("td",{children:Math.round(t[3])-Math.round(t[1])})]}),r.length===1&&qe("tr",{children:qe("th",{colSpan:2,children:b("stats.element")})}),r.length>1&&Wr($3,{children:[qe("tr",{children:qe("th",{colSpan:2,children:b("stats.selected")})}),Wr("tr",{children:[qe("td",{children:b("stats.elements")}),qe("td",{children:r.length})]})]}),r.length>0&&Wr($3,{children:[Wr("tr",{children:[qe("td",{children:"x"}),qe("td",{children:Math.round(o[0])})]}),Wr("tr",{children:[qe("td",{children:"y"}),qe("td",{children:Math.round(o[1])})]}),Wr("tr",{children:[qe("td",{children:b("stats.width")}),qe("td",{children:Math.round(o[2]-o[0])})]}),Wr("tr",{children:[qe("td",{children:b("stats.height")}),qe("td",{children:Math.round(o[3]-o[1])})]})]}),r.length===1&&Wr("tr",{children:[qe("td",{children:b("stats.angle")}),qe("td",{children:`${Math.round(r[0].angle*180/Math.PI)}\xB0`})]}),e.renderCustomStats?.(e.elements,e.appState)]})})]})})};f();import uL from"clsx";ue();import{jsx as hL}from"react/jsx-runtime";var jp=e=>hL(ae,{className:uL("Shape",{fillable:!1}),type:"radio",icon:Ym,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:S.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":S.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});Rr();import{Fragment as gL,jsx as Ht,jsxs as ki}from"react/jsx-runtime";var X3=({appState:e,elements:t,actionManager:r,setAppState:o,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:d,renderWelcomeScreen:m,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:h,MainMenuTunnel:x,DefaultSidebarTriggerTunnel:E}=et(),v=()=>ki(Yp,{side:"top",className:"App-top-bar",children:[m&&Ht(h.Out,{}),Ht(Ci,{heading:"shapes",children:y=>Ht(Ft.Col,{gap:4,align:"center",children:ki(Ft.Row,{gap:1,className:"App-toolbar-container",children:[ki($t,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,Ht(Ft.Row,{gap:1,children:Ht(Hp,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),ki("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&Ht(E.Out,{}),Ht(Xp,{checked:e.penMode,onChange:()=>a(null),title:b("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Ht($p,{checked:e.activeTool.locked,onChange:n,title:b("toolBar.lock"),isMobile:!0}),Ht(jp,{checked:Co(e),onChange:()=>i(),title:b("toolBar.hand"),isMobile:!0})]})]})})}),Ht(Kp,{appState:e,isMobile:!0,device:d,app:u})]}),w=()=>e.viewModeEnabled?Ht("div",{className:"App-toolbar-content",children:Ht(x.Out,{})}):ki("div",{className:"App-toolbar-content",children:[Ht(x.Out,{}),r.renderAction("toggleEditMenu"),r.renderAction("undo"),r.renderAction("redo"),r.renderAction(e.multiElement?"finalize":"duplicateSelection"),r.renderAction("deleteSelectedElements")]});return ki(gL,{children:[c(),!e.viewModeEnabled&&v(),!e.openMenu&&e.showStats&&Ht(Zp,{appState:e,setAppState:o,elements:t,onClose:()=>{r.executeAction(Ei)},renderCustomStats:s}),Ht("div",{className:"App-bottom-bar",style:{marginBottom:rn+Po*2,marginLeft:rn+Po*2,marginRight:rn+Po*2},children:ki($t,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&ua(e,t)?Ht(Ci,{className:"App-mobile-menu",heading:"selectedShapeActions",children:Ht(Fp,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:r.renderAction})}):null,ki("footer",{className:"App-toolbar",children:[w(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Ht("button",{className:"scroll-back-to-content",onClick:()=>{o(y=>({...Yo(t,y)}))},children:b("buttons.scrollBackToContent")})]})]})})]})};f();import fL from"open-color";import bL,{useLayoutEffect as xL,useRef as EL,useState as yL}from"react";ng();qs();import{jsx as kc,jsxs as wL}from"react/jsx-runtime";var Z3=e=>{let t=EL(null),[r,o]=yL(null);return xL(()=>{if(!e.spreadsheet)return;let n=GE(e.chartType,e.spreadsheet,0,0);o(n);let i,a=t.current;return(async()=>(i=await gl(n,{exportBackground:!1,viewBackgroundColor:fL.white},null),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),kc("button",{className:"ChartPreview",onClick:()=>{r&&e.onClick(e.chartType,r)},children:kc("div",{ref:t})})},j3=({setAppState:e,appState:t,onClose:r})=>{let{onInsertElements:o}=wr(),n=bL.useCallback(()=>{r&&r()},[r]),i=(a,l)=>{o(l),fe("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return kc(ct,{size:"small",onCloseRequest:n,title:b("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:wL("div",{className:"container",children:[kc(Z3,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:i}),kc(Z3,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:i})]})})};f();import vL from"react";ue();z();ui();U();import{Fragment as J3,jsx as W,jsxs as Vr}from"react/jsx-runtime";var TL=()=>Vr("div",{className:"HelpDialog__header",children:[Vr("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:_g}),b("helpDialog.documentation")]}),Vr("a",{className:"HelpDialog__btn",href:"https://blog.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:_g}),b("helpDialog.blog")]}),Vr("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:Gm}),b("helpDialog.github")]}),Vr("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:cw}),"YouTube"]})]}),SL=e=>Vr(J3,{children:[W("h3",{children:e.title}),W("div",{className:"HelpDialog__islands-container",children:e.children})]}),y1=e=>Vr("div",{className:`HelpDialog__island ${e.className}`,children:[W("h4",{className:"HelpDialog__island-title",children:e.caption}),W("div",{className:"HelpDialog__island-content",children:e.children})]});function*IL(e,t){let r=!0;for(let o of e)r||(yield t),r=!1,yield o}var CL=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),Z=({label:e,shortcuts:t,isOr:r=!0})=>{let o=t.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>W(kL,{children:CL(a)},a)));return Vr("div",{className:"HelpDialog__shortcut",children:[W("div",{children:e}),W("div",{className:"HelpDialog__key-container",children:[...IL(o,r?b("helpDialog.or"):null)]})]})},kL=e=>W("kbd",{className:"HelpDialog__key",...e}),q3=({onClose:e})=>{let t=vL.useCallback(()=>{e&&e()},[e]);return W(J3,{children:Vr(ct,{onCloseRequest:t,title:b("helpDialog.title"),className:"HelpDialog",children:[W(TL,{}),Vr(SL,{title:b("helpDialog.shortcuts"),children:[Vr(y1,{className:"HelpDialog__island--tools",caption:b("helpDialog.tools"),children:[W(Z,{label:b("toolBar.hand"),shortcuts:[S.H]}),W(Z,{label:b("toolBar.selection"),shortcuts:[S.V,S[1]]}),W(Z,{label:b("toolBar.rectangle"),shortcuts:[S.R,S[2]]}),W(Z,{label:b("toolBar.diamond"),shortcuts:[S.D,S[3]]}),W(Z,{label:b("toolBar.ellipse"),shortcuts:[S.O,S[4]]}),W(Z,{label:b("toolBar.arrow"),shortcuts:[S.A,S[5]]}),W(Z,{label:b("toolBar.line"),shortcuts:[S.L,S[6]]}),W(Z,{label:b("toolBar.freedraw"),shortcuts:[S.P,S[7]]}),W(Z,{label:b("toolBar.text"),shortcuts:[S.T,S[8]]}),W(Z,{label:b("toolBar.image"),shortcuts:[S[9]]}),W(Z,{label:b("toolBar.eraser"),shortcuts:[S.E,S[0]]}),W(Z,{label:b("toolBar.frame"),shortcuts:[S.F]}),W(Z,{label:b("toolBar.laser"),shortcuts:[S.K]}),W(Z,{label:b("labels.eyeDropper"),shortcuts:[S.I,"Shift+S","Shift+G"]}),W(Z,{label:b("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),W(Z,{label:b("helpDialog.editText"),shortcuts:[R("Enter")]}),W(Z,{label:b("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),W(Z,{label:b("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),W(Z,{label:b("helpDialog.curvedArrow"),shortcuts:["A",b("helpDialog.click"),b("helpDialog.click"),b("helpDialog.click")],isOr:!1}),W(Z,{label:b("helpDialog.curvedLine"),shortcuts:["L",b("helpDialog.click"),b("helpDialog.click"),b("helpDialog.click")],isOr:!1}),W(Z,{label:b("toolBar.lock"),shortcuts:[S.Q]}),W(Z,{label:b("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),W(Z,{label:b("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]})]}),Vr(y1,{className:"HelpDialog__island--view",caption:b("helpDialog.view"),children:[W(Z,{label:b("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),W(Z,{label:b("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),W(Z,{label:b("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),W(Z,{label:b("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),W(Z,{label:b("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),W(Z,{label:b("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),W(Z,{label:b("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),W(Z,{label:b("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),W(Z,{label:b("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),W(Z,{label:b("labels.showGrid"),shortcuts:[R("CtrlOrCmd+'")]}),W(Z,{label:b("labels.viewMode"),shortcuts:[R("Alt+R")]}),W(Z,{label:b("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),W(Z,{label:b("stats.title"),shortcuts:[R("Alt+/")]}),W(Z,{label:b("commandPalette.title"),shortcuts:mn?[It("commandPalette")]:[It("commandPalette"),It("commandPalette",1)]})]}),Vr(y1,{className:"HelpDialog__island--editor",caption:b("helpDialog.editor"),children:[W(Z,{label:b("labels.moveCanvas"),shortcuts:[R(`Space+${b("helpDialog.drag")}`),R(`Wheel+${b("helpDialog.drag")}`)],isOr:!0}),W(Z,{label:b("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),W(Z,{label:b("labels.delete"),shortcuts:[R("Delete")]}),W(Z,{label:b("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),W(Z,{label:b("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),W(Z,{label:b("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),W(Z,{label:b("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),W(Z,{label:b("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),W(Z,{label:b("labels.multiSelect"),shortcuts:[R(`Shift+${b("helpDialog.click")}`)]}),W(Z,{label:b("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${b("helpDialog.click")}`)]}),W(Z,{label:b("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${b("helpDialog.drag")}`)]}),(xl||mn)&&W(Z,{label:b("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),W(Z,{label:b("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),W(Z,{label:b("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),W(Z,{label:b("labels.sendToBack"),shortcuts:[rr?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),W(Z,{label:b("labels.bringToFront"),shortcuts:[rr?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),W(Z,{label:b("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),W(Z,{label:b("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),W(Z,{label:b("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),W(Z,{label:b("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),W(Z,{label:b("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),W(Z,{label:b("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),W(Z,{label:b("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${b("helpDialog.drag")}`)]}),W(Z,{label:b("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),W(Z,{label:b("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),W(Z,{label:b("buttons.redo"),shortcuts:jc?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),W(Z,{label:b("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),W(Z,{label:b("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),W(Z,{label:b("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),W(Z,{label:b("labels.flipVertical"),shortcuts:[R("Shift+V")]}),W(Z,{label:b("labels.showStroke"),shortcuts:[R("S")]}),W(Z,{label:b("labels.showBackground"),shortcuts:[R("G")]}),W(Z,{label:b("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),W(Z,{label:b("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};f();import Ac,{useLayoutEffect as AL}from"react";import Q3 from"clsx";import*as ql from"@radix-ui/react-popover";z();U();import{jsx as Hn,jsxs as jl}from"react/jsx-runtime";var ML=4,LL=8,PL=({shouldWrap:e,children:t,username:r})=>e?Hn(Ur,{label:r||"Unknown user",children:t}):Hn(Ac.Fragment,{children:t}),w1=({actionManager:e,collaborator:t,socketId:r,withName:o=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:r,collaborator:t,withName:o,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Hn(PL,{username:t.username,shouldWrap:n,children:l},r)},_L=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],qp=Ac.memo(({className:e,mobile:t,collaborators:r,userToFollow:o})=>{let n=_t(),i=new Map;r.forEach((E,v)=>{let w=E.id||v;i.set(w,{...E,socketId:v})});let a=Array.from(i.values()).filter(E=>E.username?.trim()),[l,s]=Ac.useState(""),c=Ac.useRef(null);AL(()=>{if(c.current){let E=w=>{let y=Math.max(1,Math.min(8,Math.floor(w/38)));m(y)};if(E(c.current.clientWidth),!is)return;let v=new ResizeObserver(w=>{for(let y of w){let{width:I}=y.contentRect;E(I)}});return v.observe(c.current),()=>{v.disconnect()}}},[]);let[d,m]=Ac.useState(ML),u=l.trim().toLowerCase()?a.filter(E=>E.username?.toLowerCase().includes(l)):a,x=a.slice(0,d-1).map(E=>w1({actionManager:n,collaborator:E,socketId:E.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:E.socketId===o}));return t?Hn("div",{className:Q3("UserList UserList_mobile",e),children:a.map(E=>w1({actionManager:n,collaborator:E,socketId:E.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:E.socketId===o}))}):Hn("div",{className:"UserList-wrapper",ref:c,children:jl("div",{className:Q3("UserList",e),style:{"--max-avatars":d},children:[x,a.length>d-1&&jl(ql.Root,{onOpenChange:E=>{E||s("")},children:[jl(ql.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),Hn(ql.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:jl($t,{style:{overflow:"hidden"},children:[a.length>=LL&&jl("div",{className:"UserList__search-wrapper",children:[jm,Hn("input",{className:"UserList__search",type:"text",placeholder:b("userList.search.placeholder"),value:l,onChange:E=>{s(E.target.value)}})]}),jl("div",{className:"dropdown-menu UserList__collaborators",children:[u.length===0&&Hn("div",{className:"UserList__collaborators__empty",children:b("userList.search.empty")}),Hn("div",{className:"UserList__hint",children:b("userList.hint.text")}),u.map(E=>w1({actionManager:n,collaborator:E,socketId:E.socketId,withName:!0,isBeingFollowed:E.socketId===o}))]})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let r=t.collaborators.keys();for(let[o,n]of e.collaborators){let i=t.collaborators.get(o);if(!i||o!==r.next().value||!wt(n,i,_L))return!1}return!0});f();import RL from"react";f();import v1 from"open-color";import{jsx as DL}from"react/jsx-runtime";var T1=({children:e,color:t})=>DL("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":v1[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":v1[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":v1[t][9]},children:e});An();z();import{Fragment as OL,jsx as _o,jsxs as Jp}from"react/jsx-runtime";var NL=({elements:e,appState:t,setAppState:r,files:o,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return _o("div",{className:"ExportDialog ExportDialog--json",children:Jp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Jp(T1,{color:"lime",children:[_o("div",{className:"Card-icon",children:r2}),_o("h2",{children:b("exportDialog.disk_title")}),Jp("div",{className:"Card-details",children:[b("exportDialog.disk_details"),!si&&n.renderAction("changeProjectName")]}),_o(ae,{className:"Card-button",type:"button",title:b("exportDialog.disk_button"),"aria-label":b("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(bc,"ui")}})]}),s&&Jp(T1,{color:"pink",children:[_o("div",{className:"Card-icon",children:cc}),_o("h2",{children:b("exportDialog.link_title")}),_o("div",{className:"Card-details",children:b("exportDialog.link_details")}),_o(ae,{className:"Card-button",type:"button",title:b("exportDialog.link_button"),"aria-label":b("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{fe("export","link",`ui (${bx()})`),await s(e,t,o),l()}catch(c){r({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,o,a)]})})},eT=({elements:e,appState:t,files:r,actionManager:o,exportOpts:n,canvas:i,setAppState:a})=>{let l=RL.useCallback(()=>{a({openDialog:null})},[a]);return _o(OL,{children:t.openDialog?.name==="jsonExport"&&_o(ct,{onCloseRequest:l,title:b("buttons.export"),children:_o(NL,{elements:e,appState:t,setAppState:a,files:r,actionManager:o,onCloseRequest:l,exportOpts:n,canvas:i})})})};f();import Qp from"clsx";f();import{jsx as BL}from"react/jsx-runtime";var tT=e=>BL("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${b("helpDialog.title")} \u2014 ?`,"aria-label":b("helpDialog.title"),children:Cl});import{jsx as on,jsxs as S1}from"react/jsx-runtime";var rT=({appState:e,actionManager:t,showExitZenModeBtn:r,renderWelcomeScreen:o})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=et(),a=Ie(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return S1("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[on("div",{className:Qp("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:on(Ft.Col,{gap:2,children:S1(Ci,{heading:"canvasActions",children:[on(w3,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&on(v3,{renderAction:t.renderAction,className:Qp("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&on(S3,{renderAction:t.renderAction,className:Qp("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),on(n.Out,{}),on("div",{className:Qp("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:S1("div",{style:{position:"relative"},children:[o&&on(i.Out,{}),on(tT,{onClick:()=>t.executeAction(Sa)})]})}),on(T3,{actionManager:t,showExitZenModeBtn:r})]})},oT=rT;rT.displayName="Footer";f();import{useEffect as uT,useLayoutEffect as hT,useRef as D1,useState as YL,forwardRef as gT,useImperativeHandle as KL,useCallback as mT}from"react";import{atom as $L,useSetAtom as XL}from"jotai";f();import FL from"react";var eu=FL.createContext({});f();import HL from"clsx";import{useContext as zL}from"react";import{jsx as I1,jsxs as nT}from"react/jsx-runtime";var C1=({children:e,className:t})=>{let r=Ie(),o=zL(eu),n=!!(r.editor.canFitSidebar&&o.shouldRenderDockButton);return nT("div",{className:HL("sidebar__header",t),"data-testid":"sidebar-header",children:[e,nT("div",{className:"sidebar__header__buttons",children:[n&&I1(Ur,{label:b("labels.sidebarLock"),children:I1(Jo,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":b("labels.sidebarLock"),children:Dy})}),I1(Jo,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":b("buttons.close"),children:ro})]})]})};C1.displayName="SidebarHeader";import ZL from"clsx";z();ue();U();f();import GL from"clsx";import{jsx as k1,jsxs as iT}from"react/jsx-runtime";var A1=({name:e,tab:t,icon:r,title:o,children:n,onToggle:i,className:a,style:l})=>{let s=_e(),c=Me();return iT("label",{title:o,className:"sidebar-trigger__label-element",children:[k1("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=d.target.checked;s({openSidebar:m?{name:e,tab:t}:null}),i?.(m)},checked:c.openSidebar?.name===e,"aria-label":o,"aria-keyshortcuts":"0"}),iT("div",{className:GL("sidebar-trigger",a),style:l,children:[r&&k1("div",{children:r}),n&&k1("div",{className:"sidebar-trigger__label",children:n})]})]})};A1.displayName="SidebarTrigger";f();import*as aT from"@radix-ui/react-tabs";import{jsx as UL}from"react/jsx-runtime";var M1=({children:e,...t})=>UL(aT.List,{className:"sidebar-triggers",...t,children:e});M1.displayName="SidebarTabTriggers";f();import*as sT from"@radix-ui/react-tabs";import{jsx as lT}from"react/jsx-runtime";var L1=({children:e,tab:t,onSelect:r,...o})=>lT(sT.Trigger,{value:t,asChild:!0,onSelect:r,children:lT("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});L1.displayName="SidebarTabTrigger";f();import*as cT from"@radix-ui/react-tabs";import{jsx as WL}from"react/jsx-runtime";var P1=({children:e,...t})=>{let r=Me(),o=_e();if(!r.openSidebar)return null;let{name:n}=r.openSidebar;return WL(cT.Root,{className:"sidebar-tabs-root",value:r.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...t,children:e})};P1.displayName="SidebarTabs";f();import*as dT from"@radix-ui/react-tabs";import{jsx as VL}from"react/jsx-runtime";var _1=({tab:e,children:t,...r})=>VL(dT.Content,{...r,value:e,"data-testid":e,children:t});_1.displayName="SidebarTab";import{jsx as pT}from"react/jsx-runtime";import{createElement as jL}from"react";var Mc=$L(!1),fT=gT(({name:e,children:t,onDock:r,docked:o,className:n,...i},a)=>{T.DEV&&r&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=_e(),s=XL(Mc,Be);hT(()=>(s(!!o),()=>{s(!1)}),[s,o]);let c=D1({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>r?.(u),c.current=Ga(c.current,{docked:o,shouldRenderDockButton:!!r&&o!=null});let d=D1(null);KL(a,()=>d.current);let m=Ie(),p=mT(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Dl(d,mT(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.editor.canFitSidebar)&&p()},[p,o,m.editor.canFitSidebar])),uT(()=>{let u=h=>{h.key===S.ESCAPE&&(!o||!m.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,o,m.editor.canFitSidebar]),pT($t,{...i,className:ZL("sidebar",{"sidebar--docked":o},n),ref:d,children:pT(eu.Provider,{value:c.current,children:t})})});fT.displayName="SidebarInner";var zn=Object.assign(gT((e,t)=>{let r=Me(),{onStateChange:o}=e,n=D1(r.openSidebar);uT(()=>{(!r.openSidebar&&n?.current?.name===e.name||r.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&r.openSidebar!==n.current&&o?.(r.openSidebar?.name!==e.name?null:r.openSidebar),n.current=r.openSidebar},[r.openSidebar,o,e.name]);let[i,a]=YL(!1);return hT(()=>(a(!0),()=>a(!1)),[]),i&&r.openSidebar?.name===e.name?jL(fT,{...e,ref:t,key:e.name}):null}),{Header:C1,TabTriggers:M1,TabTrigger:L1,Tabs:P1,Tab:_1,Trigger:A1});zn.displayName="Sidebar";import{Provider as O8,useAtom as B8,useAtomValue as F8}from"jotai";f();var O1={};Pu(O1,{ChangeCanvasBackground:()=>AT,ClearCanvas:()=>CT,CommandPalette:()=>ST,Export:()=>MT,Help:()=>IT,LiveCollaborationTrigger:()=>PT,LoadScene:()=>wT,SaveAsImage:()=>TT,SaveToActiveFile:()=>vT,Socials:()=>LT,ToggleTheme:()=>kT});f();import QL from"clsx";import{useSetAtom as e8}from"jotai";f();import{atom as qL}from"jotai";var R1=qL({active:!1});async function bT({title:e,description:t,actionLabel:r,color:o}){return new Promise(n=>{Xt.set(R1,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:t,actionLabel:r,color:o})})}f();import{Fragment as JL,jsx as N1,jsxs as xT}from"react/jsx-runtime";var ET=({value:e,shortcut:t,onChange:r,choices:o,children:n,name:i})=>{let a=Ie();return xT(JL,{children:[xT("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[N1("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),N1(Vp,{name:i,value:e,onChange:r,choices:o})]}),t&&!a.editor.isMobile&&N1("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};ET.displayName="DropdownMenuItemContentRadio";var yT=ET;U();import{Fragment as t8,jsx as zt,jsxs as _T}from"react/jsx-runtime";var wT=()=>{let{t:e}=yt(),t=_t(),r=bi();return t.isActionEnabled(Ol)?zt(so,{icon:kl,onSelect:async()=>{(!r.length||await bT({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:zt(sr,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>zt("strong",{children:n}),br:()=>zt("br",{})})}))&&t.executeAction(Ol)},"data-testid":"load-button",shortcut:It("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};wT.displayName="LoadScene";var vT=()=>{let{t:e}=yt(),t=_t();return t.isActionEnabled(cp)?zt(so,{shortcut:It("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(cp),icon:Qy,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};vT.displayName="SaveToActiveFile";var TT=()=>{let e=_e(),{t}=yt();return zt(so,{icon:Wm,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:It("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};TT.displayName="SaveAsImage";var ST=e=>{let t=_e(),{t:r}=yt();return zt(so,{icon:qm,"data-testid":"command-palette-button",onSelect:()=>{fe("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:It("commandPalette"),"aria-label":r("commandPalette.title"),className:e?.className,children:r("commandPalette.title")})};ST.displayName="CommandPalette";var IT=()=>{let{t:e}=yt(),t=_t();return zt(so,{"data-testid":"help-menu-item",icon:Cl,onSelect:()=>t.executeAction(Sa),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};IT.displayName="Help";var CT=()=>{let{t:e}=yt(),t=e8(ka,Be);return _t().isActionEnabled(On)?zt(so,{icon:Lo,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};CT.displayName="ClearCanvas";var kT=e=>{let{t}=yt(),r=Me(),o=_t(),n=It("toggleTheme");return o.isActionEnabled(ya)?e?.allowSystemTheme?zt(yT,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:oe.LIGHT,label:sc,ariaLabel:`${t("buttons.lightMode")} - ${n}`},{value:oe.DARK,label:lc,ariaLabel:`${t("buttons.darkMode")} - ${n}`},{value:"system",label:sw,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):zt(so,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(r.theme===oe.DARK?oe.LIGHT:oe.DARK);else return o.executeAction(ya)},icon:r.theme===oe.DARK?sc:lc,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":r.theme===oe.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:r.theme===oe.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};kT.displayName="ToggleTheme";var AT=()=>{let{t:e}=yt(),t=Me(),r=_t(),o=yi();return t.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:_T("div",{style:{marginTop:"0.5rem"},children:[zt("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),zt("div",{style:{padding:"0 0.625rem"},children:r.renderAction("changeViewBackgroundColor")})]})};AT.displayName="ChangeCanvasBackground";var MT=()=>{let{t:e}=yt(),t=_e();return zt(so,{icon:ba,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};MT.displayName="Export";var LT=()=>{let{t:e}=yt();return _T(t8,{children:[zt(Kl,{icon:Gm,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),zt(Kl,{icon:qy,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),zt(Kl,{icon:jy,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};LT.displayName="Socials";var PT=({onSelect:e,isCollaborating:t})=>{let{t:r}=yt();return zt(so,{"data-testid":"collab-button",icon:Vm,className:QL({"active-collab":t}),onSelect:e,children:r("labels.liveCollaboration")})};PT.displayName="LiveCollaborationTrigger";f();import{atom as r8,useAtom as o8}from"jotai";import{useLayoutEffect as n8,useRef as i8}from"react";import{jsx as a8}from"react/jsx-runtime";var Gn=(e,t)=>{let r=r8(0),o=n=>{let{jotaiScope:i}=et(),[,a]=o8(r,i),l=i8({preferHost:!1,counter:0});return n8(()=>{let s=l.current;return a(c=>{let d=c+1;return s.counter=d,d}),()=>{a(c=>{let d=c-1;return s.counter=d,d||(s.preferHost=!1),d})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:a8(t,{...n})};return o.displayName=e,o};z();import{jsx as tu,jsxs as B1}from"react/jsx-runtime";var l8=Object.assign(Gn("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:r}=et(),o=Ie(),n=Me(),i=_e(),a=o.editor.isMobile?void 0:()=>i({openMenu:null});return tu(r.In,{children:B1(Oe,{open:n.openMenu==="canvas",children:[tu(Oe.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:zm}),B1(Oe.Content,{onClickOutside:a,onSelect:Xn(t,()=>{i({openMenu:null})}),children:[e,o.editor.isMobile&&n.collaborators.size>0&&B1("fieldset",{className:"UserList-Wrapper",children:[tu("legend",{children:b("labels.collaborators")}),tu(qp,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Oe.Trigger,Item:Oe.Item,ItemLink:Oe.ItemLink,ItemCustom:Oe.ItemCustom,Group:Oe.Group,Separator:Oe.Separator,DefaultItems:O1}),mr=l8;f();import{useAtom as m8}from"jotai";f();import{jsx as Jl,jsxs as d8}from"react/jsx-runtime";var ru=({title:e,children:t,actionLabel:r,onClick:o})=>d8("div",{className:"OverwriteConfirm__Actions__Action",children:[Jl("h4",{children:e}),Jl("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),Jl(tn,{variant:"outlined",color:"muted",label:r,size:"large",fullWidth:!0,onClick:o})]}),s8=()=>{let{t:e}=yt(),t=_t(),r=_e();return Jl(ru,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(sp,"ui",!0),r({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},c8=()=>{let{t:e}=yt(),t=_t();return Jl(ru,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(bc,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},F1=Object.assign(({children:e})=>Jl("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:s8,SaveToDisk:c8});import{jsx as Ai,jsxs as DT}from"react/jsx-runtime";var ou=Object.assign(Gn("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=et(),[r,o]=m8(R1,Be);if(!r.active)return null;let n=()=>{r.onClose(),o(a=>({...a,active:!1}))},i=()=>{r.onConfirm(),o(a=>({...a,active:!1}))};return Ai(t.In,{children:Ai(ct,{onCloseRequest:n,title:!1,size:916,children:DT("div",{className:"OverwriteConfirm",children:[Ai("h3",{children:r.title}),DT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${r.color}`,children:[Ai("div",{className:"OverwriteConfirm__Description__icon",children:V2}),Ai("div",{children:r.description}),Ai("div",{className:"OverwriteConfirm__Description__spacer"}),Ai(tn,{color:r.color,size:"large",label:r.actionLabel,onClick:i})]}),Ai(F1,{children:e})]})})})}),{Actions:F1,Action:ru});Rr();f();U();import p8 from"clsx";z();import{jsx as Mi,jsxs as RT}from"react/jsx-runtime";import{createElement as u8}from"react";var NT=Gn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=et();return Mi(t.In,{children:Mi(zn.Trigger,{...e,className:"default-sidebar-trigger",name:kr.name})})});NT.displayName="DefaultSidebarTrigger";var OT=({children:e,...t})=>{let{DefaultSidebarTabTriggersTunnel:r}=et();return Mi(r.In,{children:Mi(zn.TabTriggers,{...t,children:e})})};OT.displayName="DefaultTabTriggers";var nu=Object.assign(Gn("DefaultSidebar",({children:e,className:t,onDock:r,docked:o,...n})=>{let i=Me(),a=_e(),{DefaultSidebarTabTriggersTunnel:l}=et();return u8(zn,{...n,name:"default",key:"default",className:p8("default-sidebar",t),docked:o??i.defaultSidebarDockedPreference,onDock:r===!1||!r&&o!=null?void 0:Xn(r,s=>{a({defaultSidebarDockedPreference:s})})},RT(zn.Tabs,{children:[RT(zn.Header,{children:[n.__fallback&&Mi("div",{style:{color:"var(--color-primary)",fontSize:"1.2em",fontWeight:"bold",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",paddingRight:"1em"},children:b("toolBar.library")}),Mi(l.Out,{})]}),Mi(zn.Tab,{tab:ps,children:Mi(b3,{})}),e]}))}),{Trigger:NT,TabTriggers:OT});We();Go();Jn();f();import h8 from"clsx";import{jsx as BT,jsxs as f8}from"react/jsx-runtime";var g8="small",FT=e=>f8("label",{className:h8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${g8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[BT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),BT("div",{className:"ToolIcon__icon",children:Zm})]});f();import{useState as WT}from"react";ue();f();import{jsx as b8}from"react/jsx-runtime";var Ql=e=>b8("p",{className:"excalidraw__paragraph",style:e.style,children:e.children});f();import*as zT from"@radix-ui/react-tabs";import{useRef as HT}from"react";z();import{jsx as x8}from"react/jsx-runtime";var GT=e=>{let t=_e(),r=HT(null),o=HT(0);return x8(zT.Root,{ref:r,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=r.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>o.current&&(o.current=a,i.style.minHeight=`min(${o.current}px, 100%)`)}e.dialog==="settings"&&gs(["text-to-diagram","diagram-to-code"],n)?t({openDialog:{name:e.dialog,tab:n,source:"settings"}}):e.dialog==="ttd"&&gs(["text-to-diagram","mermaid"],n)&&t({openDialog:{name:e.dialog,tab:n}})},children:e.children})};GT.displayName="TTDDialogTabs";var iu=GT;f();import*as UT from"@radix-ui/react-tabs";import{jsx as E8}from"react/jsx-runtime";var es=({tab:e,children:t,...r})=>E8(UT.Content,{...r,value:e,children:t});es.displayName="TTDDialogTab";import{jsx as Cr,jsxs as Lc}from"react/jsx-runtime";var VT=e=>{let[t,r]=WT(e.openAIKey||""),[o,n]=WT(e.isPersisted),i=Me(),a=()=>{e.onConfirm(t.trim(),o)};return i.openDialog?.name!=="settings"?null:Cr(ct,{onCloseRequest:()=>{e.onClose(),e.onConfirm(t.trim(),o)},title:Lc("div",{style:{display:"flex"},children:["Wireframe to Code (AI)"," ",Cr("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.1rem 0.5rem",marginLeft:"1rem",fontSize:14,borderRadius:"12px",color:"#000",background:"pink"},children:"Experimental"})]}),className:"MagicSettings",autofocus:!1,children:Cr(iu,{dialog:"settings",tab:i.openDialog.tab,children:Lc(es,{tab:"diagram-to-code",children:[Lc(Ql,{children:["For the diagram-to-code feature we use"," ",Cr(vi,{icon:dc}),"OpenAI."]}),Lc(Ql,{children:["While the OpenAI API is in beta, its use is strictly limited \u2014 as such we require you use your own API key. You can create an"," ",Cr("a",{href:"https://platform.openai.com/login?launch",rel:"noopener noreferrer",target:"_blank",children:"OpenAI account"}),", add a small credit (5 USD minimum), and"," ",Cr("a",{href:"https://platform.openai.com/api-keys",rel:"noopener noreferrer",target:"_blank",children:"generate your own API key"}),"."]}),Cr(Ql,{children:"Your OpenAI key does not leave the browser, and you can also set your own limit in your OpenAI account dashboard if needed."}),Cr(Bp,{isRedacted:!0,value:t,placeholder:"Paste your API key here",label:"OpenAI API key",onChange:l=>{r(l),e.onChange(l.trim(),o)},selectOnRender:!0,onKeyDown:l=>l.key===S.ENTER&&a()}),Cr(Ql,{children:"By default, your API token is not persisted anywhere so you'll need to insert it again after reload. But, you can persist locally in your browser below."}),Cr(Ta,{checked:o,onChange:n,children:"Persist API key in browser storage"}),Lc(Ql,{children:["Once API key is set, you can use the ",Cr(vi,{icon:Ml})," ","tool to wrap your elements in a frame that will then allow you to turn it into code. This dialog can be accessed using the"," ",Cr("b",{children:"AI Settings"})," ",Cr(vi,{icon:dc}),"."]}),Cr(tn,{className:"MagicSettings__confirm",size:"large",label:"Confirm",onClick:a})]})})})};f();f();import{useState as ZT,useRef as jT,useEffect as qT,useDeferredValue as C8}from"react";f();U();Er();var y8=({canvasRef:e,setError:t})=>{let r=e.current;if(!r)return;let o=r.parentElement;o&&(o.style.background="",t(null),r.replaceChildren())},au=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:r,setError:o,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!r){y8({canvasRef:e,setError:o});return}try{let l=await t.api,s;try{s=await l.parseMermaidToExcalidraw(r,{fontSize:At})}catch{s=await l.parseMermaidToExcalidraw(r.replace(/"/g,"'"),{fontSize:At})}let{elements:c,files:d}=s;o(null),n.current={elements:_c(c,{regenerateIds:!0}),files:d};let m=await hi({elements:n.current.elements,files:n.current.files,exportPadding:fo,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Ln(m)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(m)}catch(l){throw a.style.background="var(--default-bg-color)",r&&o(l),l}}},Pc=e=>{Tr.set($r.MERMAID_TO_EXCALIDRAW,e)},lu=({app:e,data:t,text:r,shouldSaveMermaidDataToStorage:o})=>{let{elements:n,files:i}=t.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),o&&r&&Pc(r))};f();import{jsx as w8}from"react/jsx-runtime";var su=({children:e})=>w8("div",{className:"ttd-dialog-panels",children:e});f();import YT from"clsx";import{jsx as H1,jsxs as Dc}from"react/jsx-runtime";var ts=({label:e,children:t,panelAction:r,panelActionDisabled:o=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>Dc("div",{className:"ttd-dialog-panel",children:[Dc("div",{className:"ttd-dialog-panel__header",children:[H1("label",{children:e}),i?.()]}),t,Dc("div",{className:YT("ttd-dialog-panel-button-container",{invisible:!r}),style:{display:"flex",alignItems:"center"},children:[Dc(Jo,{className:"ttd-dialog-panel-button",onSelect:r?r.action:()=>{},disabled:o||n,children:[Dc("div",{className:YT({invisible:n}),children:[r?.label,r?.icon&&H1("span",{children:r.icon})]}),n&&H1(Ut,{})]}),!o&&!n&&a?.(),l?.()]})]});f();U();ue();import{useEffect as v8,useRef as KT}from"react";import{jsx as T8}from"react/jsx-runtime";var cu=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:o})=>{let n=KT(null),i=KT(o);return i.current=o,v8(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[S.CTRL_OR_CMD]&&s.key===S.ENTER&&(s.preventDefault(),i.current?.())};return a.addEventListener("keydown",l),()=>{a.removeEventListener("keydown",l)}}},[]),T8("textarea",{className:"ttd-dialog-input",onChange:r,value:e,placeholder:t,autoFocus:!0,ref:n})};f();import{jsx as du,jsxs as $T}from"react/jsx-runtime";var S8=({error:e})=>$T("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",du("p",{children:e})]}),mu=({error:e,canvasRef:t,loaded:r})=>$T("div",{className:"ttd-dialog-output-wrapper",children:[e&&du(S8,{error:e.message}),r?du("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):du(Ut,{size:"2rem"})]});U();z();f();z();import{jsx as XT,jsxs as I8}from"react/jsx-runtime";var pu=()=>I8("div",{className:"ttd-dialog-submit-shortcut",children:[XT("div",{className:"ttd-dialog-submit-shortcut__key",children:R("CtrlOrCmd")}),XT("div",{className:"ttd-dialog-submit-shortcut__key",children:R("Enter")})]});import{Fragment as M8,jsx as nn,jsxs as QT}from"react/jsx-runtime";var k8=`flowchart TD
60
60
  A[Christmas] -->|Get money| B(Go shopping)
61
61
  B --> C{Let me think}
62
62
  C -->|One| D[Laptop]
63
63
  C -->|Two| E[iPhone]
64
- C -->|Three| F[Car]`,ZT=Wi(Pc,300),k8=({mermaidToExcalidrawLib:e})=>{let[t,r]=KT(()=>Tr.get($r.MERMAID_TO_EXCALIDRAW)||C8),o=I8(t.trim()),[n,i]=KT(null),a=$T(null),l=$T({elements:[],files:null}),s=wr();XT(()=>{nu({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:o}).catch(d=>{gx()&&console.error("Failed to parse mermaid definition",d)}),ZT(o)},[o,e]),XT(()=>()=>{ZT.flush()},[]);let c=()=>{iu({app:s,data:l,text:t,shouldSaveMermaidDataToStorage:!0})};return jT(A8,{children:[nn("div",{className:"ttd-dialog-desc",children:nn(sr,{i18nKey:"mermaid.description",flowchartLink:d=>nn("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>nn("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>nn("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),jT(au,{children:[nn(es,{label:b("mermaid.syntax"),children:nn(lu,{input:t,placeholder:"Write Mermaid diagram defintion here...",onChange:d=>r(d.target.value),onKeyboardSubmit:()=>{c()}})}),nn(es,{label:b("mermaid.preview"),panelAction:{action:()=>{c()},label:b("mermaid.button"),icon:kl},renderSubmitShortcut:()=>nn(du,{}),children:nn(cu,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},qT=k8;import{useEffect as L8,useRef as z1,useState as pu}from"react";f();import*as JT from"@radix-ui/react-tabs";import{jsx as M8}from"react/jsx-runtime";var H1=({children:e,...t})=>M8(JT.List,{className:"ttd-dialog-triggers",...t,children:e});H1.displayName="TTDDialogTabTriggers";f();import*as e5 from"@radix-ui/react-tabs";import{jsx as QT}from"react/jsx-runtime";var mu=({children:e,tab:t,onSelect:r,...o})=>QT(e5.Trigger,{value:t,asChild:!0,onSelect:r,children:QT("button",{type:"button",className:"ttd-dialog-tab-trigger",...o,children:e})});mu.displayName="TTDDialogTabTrigger";z();import{atom as r5,useAtom as t5}from"jotai";import{jsx as pr,jsxs as Li}from"react/jsx-runtime";var G1=3,ts=1e3,P8=r5(null),_8=r5(null),U1=e=>{let t=Me();return t.openDialog?.name!=="ttd"?null:pr(D8,{...e,tab:t.openDialog.tab})},D8=Gn("TTDDialogBase",({tab:e,...t})=>{let r=wr(),o=_e(),n=z1(null),[i,a]=t5(_8),[l,s]=pu(i?.prompt??""),c=l.trim(),d=C=>{s(C.target.value),a(_=>({generatedResponse:_?.generatedResponse??null,prompt:C.target.value}))},[m,p]=pu(!1),[u,h]=t5(P8),x=async()=>{if(c.length>ts||c.length<G1||m||u?.rateLimitRemaining===0||"__fallback"in t){c.length<G1&&P(new Error(`Prompt is too short (min ${G1} characters)`)),c.length>ts&&P(new Error(`Prompt is too long (max ${ts} characters)`));return}try{p(!0),fe("ai","generate","ttd");let{generatedResponse:C,error:_,rateLimit:D,rateLimitRemaining:H}=await t.onTextSubmit(c);if(typeof C=="string"&&a(A=>({generatedResponse:C,prompt:A?.prompt??null})),Wu(D)&&Wu(H)&&h({rateLimit:D,rateLimitRemaining:H}),_){P(_);return}if(!C){P(new Error("Generation failed"));return}try{await nu({canvasRef:n,data:y,mermaidToExcalidrawLib:v,setError:P,mermaidDefinition:C}),fe("ai","mermaid parse success","ttd")}catch(A){console.info(`%cTTD mermaid render errror: ${A.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
65
- TTD mermaid definition render errror: ${A.message}`,"color: yellow"),fe("ai","mermaid parse failed","ttd"),P(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(C){let _=C.message;(!_||_==="Failed to fetch")&&(_="Request failed"),P(new Error(_))}finally{p(!1)}},E=z1(x);E.current=x;let[v,w]=pu({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});L8(()=>{(async()=>{await v.api,w(_=>({..._,loaded:!0}))})()},[v.api]);let y=z1({elements:[],files:null}),[I,P]=pu(null);return pr(st,{className:"ttd-dialog",onCloseRequest:()=>{r.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:Li(ou,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?pr("p",{className:"dialog-mermaid-title",children:b("mermaid.title")}):Li(H1,{children:[pr(mu,{tab:"text-to-diagram",children:Li("div",{style:{display:"flex",alignItems:"center"},children:[b("labels.textToDiagram"),pr("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"pink",color:"#000"},children:"AI Beta"})]})}),pr(mu,{tab:"mermaid",children:"Mermaid"})]}),pr(Ql,{className:"ttd-dialog-content",tab:"mermaid",children:pr(qT,{mermaidToExcalidrawLib:v})}),!("__fallback"in t)&&Li(Ql,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[pr("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),Li(au,{children:[pr(es,{label:b("labels.prompt"),panelAction:{action:x,label:"Generate",icon:kl},onTextSubmitInProgess:m,panelActionDisabled:c.length>ts||u?.rateLimitRemaining===0,renderTopRight:()=>u?Li("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>pr(du,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Li("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Pc(i.generatedResponse),o({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",pr(vi,{icon:kl})]});let C=c.length/ts;return C>.8?Li("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:C>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",ts]}):null},children:pr(lu,{onChange:d,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{E.current()}})}),pr(es,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),iu({app:r,data:y})},label:"Insert",icon:kl},children:pr(cu,{canvasRef:n,error:I,loaded:v.loaded})})]})]})]})})});import{Fragment as n5,jsx as ie,jsxs as Yr}from"react/jsx-runtime";var F8=({UIOptions:e})=>Yr(mr,{__fallback:!0,children:[ie(mr.DefaultItems.LoadScene,{}),ie(mr.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ie(mr.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ie(mr.DefaultItems.SaveAsImage,{}),ie(mr.DefaultItems.Help,{}),ie(mr.DefaultItems.ClearCanvas,{}),ie(mr.Separator,{}),ie(mr.Group,{title:"Excalidraw links",children:ie(mr.DefaultItems.Socials,{})}),ie(mr.Separator,{}),ie(mr.DefaultItems.ToggleTheme,{}),ie(mr.DefaultItems.ChangeCanvasBackground,{})]}),H8=()=>Yr(tu,{__fallback:!0,children:[ie(tu.Actions.SaveToDisk,{}),ie(tu.Actions.ExportToImage,{})]}),z8=({actionManager:e,appState:t,files:r,setAppState:o,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:h,children:x,app:E,isCollaborating:v,openAIKey:w,isOpenAIKeyPersisted:y,onOpenAIAPIKeyChange:I,onMagicSettingsConfirm:P})=>{let C=Ie(),_=b3(),[D,H]=O8(fi,Be),A=()=>p.canvasActions.export?ie(q3,{elements:n,appState:t,files:r,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,M=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:ie(O3,{elements:n,appState:t,files:r,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:E.getName()}),k=()=>Yr("div",{style:{position:"relative"},children:[ie(_.MainMenuTunnel.Out,{}),h&&ie(_.WelcomeScreenMenuHintTunnel.Out,{})]}),O=()=>ie(Ci,{heading:"selectedShapeActions",className:Rc("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:ie($t,{className:qc.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:ie(Op,{appState:t,elementsMap:E.scene.getNonDeletedElementsMap(),renderAction:e.renderAction})})}),X=()=>{let le=ua(t,n);return ie(Wp,{side:"top",children:Yr("div",{className:"App-menu App-menu_top",children:[Yr(Ft.Col,{gap:6,className:Rc("App-menu_top__left"),children:[k(),le&&O()]}),!t.viewModeEnabled&&ie(Ci,{heading:"shapes",className:"shapes-section",children:V=>Yr("div",{style:{position:"relative"},children:[h&&ie(_.WelcomeScreenToolbarHintTunnel.Out,{}),ie(Ft.Col,{gap:4,align:"start",children:Yr(Ft.Row,{gap:1,className:Rc("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[Yr($t,{padding:1,className:Rc("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[ie(Vp,{appState:t,isMobile:C.editor.isMobile,device:C,app:E}),V,Yr(Ft.Row,{gap:1,children:[ie(Kp,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>s(null),title:b("toolBar.penMode"),penDetected:t.penDetected}),ie(Yp,{checked:t.activeTool.locked,onChange:a,title:b("toolBar.lock")}),ie("div",{className:"App-toolbar__divider"}),ie(Xp,{checked:Co(t),onChange:()=>l(),title:b("toolBar.hand"),isMobile:!0}),ie(Bp,{appState:t,activeTool:t.activeTool,UIOptions:p,app:E})]})]}),v&&ie($t,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:ie(NT,{title:b("toolBar.laser"),checked:t.activeTool.type===bt.laser,onChange:()=>E.setActiveTool({type:bt.laser}),isMobile:!0})})]})})]})}),Yr("div",{className:Rc("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&ie(Zp,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),d?.(C.editor.isMobile,t),!t.viewModeEnabled&&(!ee||t.openSidebar?.name!==kr.name)&&ie(_.DefaultSidebarTriggerTunnel.Out,{})]})]})})},Y=()=>ie(ru,{__fallback:!0,onDock:le=>{fe("sidebar",`toggleDock (${le?"dock":"undock"})`,`(${C.editor.isMobile?"mobile":"desktop"})`)}}),ee=B8(Mc,Be),xe=Yr(n5,{children:[x,ie(F8,{UIOptions:p}),ie(ru.Trigger,{__fallback:!0,icon:Bm,title:$n(b("toolBar.library")),onToggle:le=>{le&&fe("sidebar",`${kr.name} (open)`,`button (${C.editor.isMobile?"mobile":"desktop"})`)},tab:kr.defaultTab,children:b("toolBar.library")}),ie(H8,{}),t.openDialog?.name==="ttd"&&ie(U1,{__fallback:!0}),t.isLoading&&ie(ld,{delay:250}),t.errorMessage&&ie(D3,{onClose:()=>o({errorMessage:null}),children:t.errorMessage}),D&&!C.editor.isMobile&&ie(Rw,{colorPickerType:D.colorPickerType,onCancel:()=>{H(null)},onChange:(le,V,ve,{altKey:Re})=>{if(!(le!=="elementBackground"&&le!=="elementStroke"))if(ve.length){for(let dt of ve)F(dt,{[Re&&D.swapPreviewOnAlt?le==="elementBackground"?"strokeColor":"backgroundColor":le==="elementBackground"?"backgroundColor":"strokeColor"]:V},!1),ke.delete(dt);pt.getScene(ve[0])?.informMutation()}else o(le==="elementBackground"?{currentItemBackgroundColor:V}:{currentItemStrokeColor:V})},onSelect:(le,V)=>{H(ve=>ve?.keepOpenOnAlt&&V.altKey?ve:null),D?.onSelect?.(le,V)}}),t.openDialog?.name==="help"&&ie(X3,{onClose:()=>{o({openDialog:null})}}),t.openDialog?.name==="settings"&&ie(GT,{openAIKey:w,isPersisted:y,onChange:I,onConfirm:(le,V)=>{let ve=t.openDialog?.name==="settings"?t.openDialog?.source:"settings";o({openDialog:null},()=>{P(le,V,ve)})},onClose:()=>{o({openDialog:null})}}),ie(v3,{}),ie(_.OverwriteConfirmDialogTunnel.Out,{}),M(),A(),t.pasteDialog.shown&&ie($3,{setAppState:o,appState:t,onClose:()=>o({pasteDialog:{shown:!1,data:null}})}),C.editor.isMobile&&ie(Y3,{app:E,appState:t,elements:n,actionManager:e,renderJSONExportDialog:A,renderImageExportDialog:M,setAppState:o,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:d,renderCustomStats:m,renderSidebars:Y,device:C,renderWelcomeScreen:h,UIOptions:p}),!C.editor.isMobile&&Yr(n5,{children:[Yr("div",{className:"layer-ui__wrapper",style:t.openSidebar&&ee&&C.editor.canFitSidebar?{width:`calc(100% - ${jb}px)`}:{},children:[h&&ie(_.WelcomeScreenCenterTunnel.Out,{}),X(),ie(eT,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:h}),t.showStats&&ie($p,{appState:t,setAppState:o,elements:n,onClose:()=>{e.executeAction(Ei)},renderCustomStats:m}),t.scrolledOutside&&ie("button",{className:"scroll-back-to-content",onClick:()=>{o(le=>({...Yo(n,le)}))},children:b("buttons.scrollBackToContent")})]}),Y()]})]});return ie(mf.Provider,{value:t,children:ie(N8,{scope:_.jotaiScope,children:ie(i1.Provider,{value:_,children:xe})})})},o5=e=>{let{suggestedBindings:t,startBoundElement:r,cursorButton:o,scrollX:n,scrollY:i,...a}=e;return a},G8=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:r,appState:o,...n}=e,{canvas:i,appState:a,...l}=t;return wt(o5(o),o5(a),{selectedElementIds:wt,selectedGroupIds:wt})&&wt(n,l)},i5=R8.memo(z8,G8);f();import{useCallback as U8,useEffect as W8,useRef as V8}from"react";import{jsx as a5,jsxs as K8}from"react/jsx-runtime";var Y8=5e3,l5=({message:e,onClose:t,closable:r=!1,duration:o=Y8,style:n})=>{let i=V8(0),a=o!==1/0,l=U8(()=>{a&&(i.current=window.setTimeout(()=>t(),o))},[t,o,a]);return W8(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,o,a]),K8("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[a5("p",{className:"Toast__message",children:e}),r&&a5(ae,{icon:ro,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})};f();ue();Ye();var W1=B({name:"viewMode",label:"labels.viewMode",paletteName:"Toggle view mode",icon:Ml,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},commitToHistory:!1}},checked:e=>e.viewModeEnabled,predicate:(e,t,r)=>typeof r.viewModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.R});Er();Xh();An();ut();import FP from"lodash.throttle";rl();oc();f();ge();We();ut();ce();z();Go();var uu=class e{scene;onSceneUpdated;constructor({scene:t,onSceneUpdated:r}){this.scene=t,this.onSceneUpdated=r}static loadedFontFaces=new Set;onFontsLoaded=t=>{if(t.every(o=>{let n=`${o.family}-${o.style}-${o.weight}`;return e.loadedFontFaces.has(n)?!0:(e.loadedFontFaces.add(n),!1)}))return!1;let r=!1;this.scene.mapElements(o=>U(o)&&!Ne(o)?(ke.delete(o),r=!0,ne(o,{...nl(o,lt(o,this.scene.getNonDeletedElementsMap()),this.scene.getNonDeletedElementsMap())})):o),r&&this.onSceneUpdated()};loadFontsForElements=async t=>{let r=await Promise.all([...new Set(t.filter(o=>U(o)).map(o=>o.fontFamily))].map(o=>{let n=Ge({fontFamily:o,fontSize:16});if(!document.fonts?.check?.(n))return document.fonts?.load?.(n)}));this.onFontsLoaded(r.flat().filter(Boolean))}};er();Qn();f();ge();er();er();ue();z();ol();Ye();ce();var s5=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length===1&&Q(r[0])},c5=B({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;if(Q(n)){let i=Hr(be(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},commitToHistory:!1}}return{elements:e,appState:t,commitToHistory:!1}},predicate:(e,t,r,o)=>s5(t,o)}),d5=B({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;return Q(n)?{elements:cg(e,n),appState:{...t,selectedElementIds:{[n.id]:!0}},commitToHistory:!0}:{elements:e,appState:t,commitToHistory:!1}},predicate:(e,t,r,o)=>s5(t,o)}),m1e=B({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},commitToHistory:!1}),checked:e=>e.frameRendering.enabled}),p1e=B({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Ym,viewMode:!1,perform:(e,t,r,o)=>{let n=Xe(t,{type:"frame"});return Br(o.interactiveCanvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:Xe(t,{type:"frame"})},commitToHistory:!1}},keyTest:e=>!e[S.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===S.F});qn();f();G();at();ce();Nr();ue();Rt();Qn();var $8=8,m5=99999,hu=e=>$8/e,co=class e{static referenceSnapPoints=null;static visibleGaps=null;static setReferenceSnapPoints=t=>{e.referenceSnapPoints=t};static getReferenceSnapPoints=()=>e.referenceSnapPoints;static setVisibleGaps=t=>{e.visibleGaps=t};static getVisibleGaps=()=>e.visibleGaps;static destroy=()=>{e.referenceSnapPoints=null,e.visibleGaps=null}},Un=({event:e,appState:t,selectedElements:r})=>e?t.objectsSnapModeEnabled&&!e[S.CTRL_OR_CMD]||!t.objectsSnapModeEnabled&&e[S.CTRL_OR_CMD]&&t.gridSize===null:r.length===1&&r[0].type==="arrow"?!1:t.objectsSnapModeEnabled,X8=(e,t,r=.01)=>Math.abs(e-t)<=r,Nc=(e,t,{omitCenter:r,boundingBoxCorners:o,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,d,m,p]=te(a,t);n&&(l+=n.x,c+=n.x,m+=n.x,s+=n.y,d+=n.y,p+=n.y);let u=(c-l)/2,h=(d-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let x=Ze([l,s+h],[m,p],a.angle),E=Ze([l+u,s],[m,p],a.angle),v=Ze([c,s+h],[m,p],a.angle),w=Ze([l+u,d],[m,p],a.angle);i=r?[x,E,v,w]:[x,E,v,w,[m,p]]}else{let x=Ze([l,s],[m,p],a.angle),E=Ze([c,s],[m,p],a.angle),v=Ze([l,d],[m,p],a.angle),w=Ze([c,d],[m,p],a.angle);i=r?[x,E,v,w]:[x,E,v,w,[m,p]]}}else if(e.length>1){let[a,l,s,c]=Od(e,n??{x:0,y:0}),d=s-a,m=c-l,p=[a,l],u=[s,l],h=[a,c],x=[s,c],E=[a+d/2,l+m/2];i=r?[p,u,h,x]:[p,u,h,x,E]}return i.map(a=>[ct(a[0]),ct(a[1])])},h5=(e,t,r,o)=>{let n=t.filter(i=>Q(i)).map(i=>i.id);return Sg(e,t,r,o).filter(i=>!(i.frameId&&n.includes(i.frameId)))},g5=(e,t,r,o)=>{let n=h5(e,t,r,o),i=na(n,o).filter(m=>!(m.length===1&&Ne(m[0]))).map(m=>we(m).map(p=>ct(p))),a=i.sort((m,p)=>m[0]-p[0]),l=[],s=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++s>m5)break e;let h=a[u],[,x,E,v]=p,[w,y,,I]=h;E<w&&vs([x,v],[y,I])&&l.push({startBounds:p,endBounds:h,startSide:[[E,x],[E,v]],endSide:[[w,y],[w,I]],length:w-E,overlap:Ts([x,v],[y,I])})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];s=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++s>m5)break e;let h=c[u],[x,,E,v]=p,[w,y,I]=h;v<y&&vs([x,E],[w,I])&&d.push({startBounds:p,endBounds:h,startSide:[[x,v],[E,v]],endSide:[[w,y],[I,y]],length:y-v,overlap:Ts([x,E],[w,I])})}}return{horizontalGaps:l,verticalGaps:d}},p5=(e,t,r,o,n,i,a)=>{if(!Un({appState:r,event:o,selectedElements:e}))return[];if(e.length===0)return[];let l=co.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[d,m,p,u]=Od(e,t).map(E=>ct(E)),h=(d+p)/2,x=(m+u)/2;for(let E of s){if(!vs([m,u],E.overlap))continue;let v=E.startSide[0][0]+E.length/2,w=ct(v-h);if(E.length>p-d&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(n.length=0),a.x=Math.abs(w);let A={type:"gap",direction:"center_horizontal",gap:E,offset:w};n.push(A);continue}let[,,I]=E.endBounds,P=d-I,C=ct(E.length-P);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(n.length=0),a.x=Math.abs(C);let A={type:"gap",direction:"side_right",gap:E,offset:C};n.push(A);continue}let[_,,,]=E.startBounds,D=_-p,H=ct(D-E.length);if(Math.abs(H)<=a.x){Math.abs(H)<a.x&&(n.length=0),a.x=Math.abs(H);let A={type:"gap",direction:"side_left",gap:E,offset:H};n.push(A);continue}}for(let E of c){if(!vs([d,p],E.overlap))continue;let v=E.startSide[0][1]+E.length/2,w=ct(v-x);if(E.length>u-m&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let A={type:"gap",direction:"center_vertical",gap:E,offset:w};i.push(A);continue}let[,I,,]=E.startBounds,P=I-u,C=ct(P-E.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let A={type:"gap",direction:"side_top",gap:E,offset:C};i.push(A);continue}let[,,,_]=E.endBounds,D=ct(m-_),H=E.length-D;if(Math.abs(H)<=a.y){Math.abs(H)<a.y&&(i.length=0),a.y=Math.abs(H);let A={type:"gap",direction:"side_bottom",gap:E,offset:H};i.push(A);continue}}}},f5=(e,t,r,o)=>{let n=h5(e,t,r,o);return na(n,o).filter(i=>!(i.length===1&&Ne(i[0]))).flatMap(i=>Nc(i,o))},rs=(e,t,r,o,n,i,a)=>{if(!Un({appState:r,event:o,selectedElements:e})||e.length===0&&t.length===0)return[];let l=co.getReferenceSnapPoints();if(l)for(let s of t)for(let c of l){let d=c[0]-s[0],m=c[1]-s[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:m}),a.y=Math.abs(m))}},b5=(e,t,r,o,n)=>{let i=me(e,r);if(!Un({appState:r,event:o,selectedElements:i})||i.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=ct(t.x),t.y=ct(t.y);let a=[],l=[],s=hu(r.zoom.value),c={x:s,y:s},d=Nc(i,n,{dragOffset:t});rs(i,d,r,o,a,l,c),p5(i,t,r,o,a,l,c);let m={x:a[0]?.offset??0,y:l[0]?.offset??0};c.x=0,c.y=0,a.length=0,l.length=0;let p={x:ct(t.x+m.x),y:ct(t.y+m.y)};rs(i,Nc(i,n,{dragOffset:p}),r,o,a,l,c),p5(i,p,r,o,a,l,c);let u=V1(a,l),h=j8(i,p,[...a,...l].filter(x=>x.type==="gap"));return{snapOffset:m,snapLines:[...u,...h]}},ct=e=>Math.round(e*10**6)/10**6,u5=e=>{let t=new Map;for(let r of e){let o=r.join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},V1=(e,t)=>{let r={},o={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=ct(n.points[0][0]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>[ct(a[0]),ct(a[1])]))}}if(t.length>0){for(let n of t)if(n.type==="point"){let i=ct(n.points[0][1]);o[i]||(o[i]=[]),o[i].push(...n.points.map(a=>[ct(a[0]),ct(a[1])]))}}return Object.entries(r).map(([n,i])=>({type:"points",points:u5(i.map(a=>[Number(n),a[1]]).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(o).map(([n,i])=>({type:"points",points:u5(i.map(a=>[a[0],Number(n)]).sort((a,l)=>a[0]-l[0]))})))},Z8=e=>{let t=new Map;for(let r of e){let o=r.points.flat().map(n=>[ct(n)]).join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},j8=(e,t,r)=>{let[o,n,i,a]=Od(e,t),l=[];for(let s of r){let[c,d,m,p]=s.gap.startBounds,[u,h,x,E]=s.gap.endBounds,v=Ts([n,a],s.gap.overlap),w=Ts([o,i],s.gap.overlap);switch(s.direction){case"center_horizontal":{if(v){let y=(v[0]+v[1])/2;l.push({type:"gap",direction:"horizontal",points:[[s.gap.startSide[0][0],y],[o,y]]},{type:"gap",direction:"horizontal",points:[[i,y],[s.gap.endSide[0][0],y]]})}break}case"center_vertical":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[[y,s.gap.startSide[0][1]],[y,n]]},{type:"gap",direction:"vertical",points:[[y,a],[y,s.gap.endSide[0][1]]]})}break}case"side_right":{if(v){let y=(v[0]+v[1])/2;l.push({type:"gap",direction:"horizontal",points:[[m,y],[u,y]]},{type:"gap",direction:"horizontal",points:[[x,y],[o,y]]})}break}case"side_left":{if(v){let y=(v[0]+v[1])/2;l.push({type:"gap",direction:"horizontal",points:[[i,y],[c,y]]},{type:"gap",direction:"horizontal",points:[[m,y],[u,y]]})}break}case"side_top":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[[y,a],[y,d]]},{type:"gap",direction:"vertical",points:[[y,p],[y,h]]})}break}case"side_bottom":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[[y,p],[y,h]]},{type:"gap",direction:"vertical",points:[[y,E],[y,n]]})}break}}}return Z8(l.map(s=>({...s,points:s.points.map(c=>[ct(c[0]),ct(c[1])])})))},x5=(e,t,r,o,n,i)=>{if(!Un({event:o,selectedElements:e,appState:r})||e.length===0||e.length===1&&!X8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=we(t);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(c+=n.y));let d=[];if(i)switch(i){case"e":{d.push([s,l],[s,c]);break}case"w":{d.push([a,l],[a,c]);break}case"n":{d.push([a,l],[s,l]);break}case"s":{d.push([a,c],[s,c]);break}case"ne":{d.push([s,l]);break}case"nw":{d.push([a,l]);break}case"se":{d.push([s,c]);break}case"sw":{d.push([a,c]);break}}let m=hu(r.zoom.value),p={x:m,y:m},u=[],h=[];rs(t,d,r,o,u,h,p);let x={x:u[0]?.offset??0,y:h[0]?.offset??0};p.x=0,p.y=0,u.length=0,h.length=0;let[E,v,w,y]=we(e).map(C=>ct(C));rs(e,[[E,v],[E,y],[w,v],[w,y]],r,o,u,h,p);let P=V1(u,h);return{snapOffset:x,snapLines:P}},E5=(e,t,r,o,n,i)=>{if(!Un({event:r,selectedElements:[e],appState:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[[o.x+n.x,o.y+n.y]],l=hu(t.zoom.value),s={x:l,y:l},c=[],d=[];rs([e],a,t,r,c,d,s);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};s.x=0,s.y=0,c.length=0,d.length=0;let p=Nc([e],i,{boundingBoxCorners:!0,omitCenter:!0});rs([e],p,t,r,c,d,s);let u=V1(c,d);return{snapOffset:m,snapLines:u}},y5=(e,t,r,o,n)=>{if(!Un({event:o,selectedElements:[],appState:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Sg(e,[],t,n),a=hu(t.zoom.value),l={x:a,y:a},s=[],c=[];for(let d of i){let m=Nc([d],n);for(let p of m){let u=p[0]-r.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,[p[0],r.y]],direction:"vertical"}),l.x=u);let h=p[1]-r.y;Math.abs(h)<=Math.abs(l.y)&&(Math.abs(h)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,[r.x,p[1]]],direction:"horizontal"}),l.y=h)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-r.x:0,y:s.length>0?s[0].points[0][1]-r.y:0},snapLines:[...c,...s]}},w5=e=>e===bt.rectangle||e===bt.ellipse||e===bt.diamond||e===bt.frame||e===bt.magicframe||e===bt.image;f();import{jsx as mo,jsxs as v5}from"react/jsx-runtime";var q8=()=>v5("div",{"data-testid":"brave-measure-text-error",children:[mo("p",{children:mo(sr,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>mo("span",{style:{fontWeight:600},children:e})})}),mo("p",{children:mo(sr,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>mo("span",{style:{fontWeight:600},children:e})})}),mo("p",{children:mo(sr,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>mo("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),mo("p",{children:mo(sr,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>mo("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>v5("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),T5=q8;f();G();ge();Jr();In();ut();z();ys();Eo();wo();var gu={width:100,height:0},Pi=100,J8=(e,t,r)=>{let o=Nt({x:0,y:0,textAlign:Kn.CENTER,verticalAlign:ft.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:o.id})}),Yt(o,e,r),[e,o]},S5=(e,t,r,o,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let d=t?.width??Pi,m=t?.height??Pi,p;t.id&&(p=o.getElement(t.id),p||console.error(`No element for start binding with id ${t.id} found`));let u=t.x||e.x-d,h=t.y||e.y-m/2,x=p?p.type:t.type;if(x){if(x==="text"){let E="";p&&p.type==="text"?E=p.text:t.type==="text"&&(E=t.text),E||console.error(`No text found for start binding text element for ${e.id}`),i=Nt({x:u,y:h,type:"text",...p,...t,text:E}),Object.assign(i,{x:t.x||e.x-i.width,y:t.y||e.y-i.height/2})}else switch(x){case"rectangle":case"ellipse":case"diamond":{i=Fr({x:u,y:h,width:d,height:m,...p,...t,type:x});break}default:Zn(e,`Unhandled element start type "${t.type}"`,!0)}qa(e,i,"start",n)}}if(r){let d=r?.height??Pi,m=r?.width??Pi,p;r.id&&(p=o.getElement(r.id),p||console.error(`No element for end binding with id ${r.id} found`));let u=r.x||e.x+e.width,h=r.y||e.y-d/2,x=p?p.type:r.type;if(x){if(x==="text"){let E="";p&&p.type==="text"?E=p.text:r.type==="text"&&(E=r.text),E||console.error(`No text found for end binding text element for ${e.id}`),a=Nt({x:u,y:h,type:"text",...p,...r,text:E}),Object.assign(a,{y:r.y||e.y-a.height/2})}else switch(x){case"rectangle":case"ellipse":case"diamond":{a=Fr({x:u,y:h,width:m,height:d,...p,...r,type:x});break}default:Zn(e,`Unhandled element end type "${x}"`,!0)}qa(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,c=Bo(e.points);return e.points[l][0]>e.points[l-1][0]&&(c[0][0]=s,c[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(c[0][0]=-s,c[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(c[0][1]=s,c[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(c[0][1]=-s,c[l][1]+=s),Object.assign(e,{points:c}),{linearElement:e,startBoundElement:i,endBoundElement:a}},Y1=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>Mr(Array.from(this.excalidrawElements.values()));getElementsMap=()=>xo($(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},_c=(e,t)=>{if(!e)return[];let r=Bo(e),o=new Y1,n=new Map,i=new Map;for(let l of r){let s,c=l.id;switch(t?.regenerateIds!==!1&&Object.assign(l,{id:Pt()}),l.type){case"rectangle":case"ellipse":case"diamond":{let m=l?.label?.text&&l.width===void 0?0:l?.width||Pi,p=l?.label?.text&&l.height===void 0?0:l?.height||Pi;s=Fr({...l,width:m,height:p});break}case"line":{let m=l.width||gu.width,p=l.height||gu.height;s=Qr({width:m,height:p,points:[[0,0],[m,p]],...l});break}case"arrow":{let m=l.width||gu.width,p=l.height||gu.height;s=Qr({width:m,height:p,endArrowhead:"arrow",points:[[0,0],[m,p]],...l}),Object.assign(s,bd(s.points));break}case"text":{let m=l?.fontFamily||Wt,p=l?.fontSize||At,u=l?.lineHeight||_r(m),h=l.text??"",x=ni(h),E=Io(x,Ge({fontFamily:m,fontSize:p}),u);s=Nt({width:E.width,height:E.height,fontFamily:m,fontSize:p,...l});break}case"image":{s=Fs({width:l?.width||Pi,height:l?.height||Pi,...l});break}case"frame":{s=Kd({x:0,y:0,...l});break}case"magicframe":{s=Bs({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{s=l;break}default:s=l,Zn(l,`Unhandled element type "${l.type}"`,!0)}o.getElement(s.id)?console.error(`Duplicate id found for ${s.id}`):(o.add(s),n.set(s.id,l),c&&i.set(c,s.id))}let a=o.getElementsMap();for(let[l,s]of n){let c=o.getElement(l);switch(s.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(s.label?.text){let[d,m]=J8(c,s?.label,a);if(o.add(d),o.add(m),d.type==="arrow"){let p=s.type==="arrow"?s?.start:void 0,u=s.type==="arrow"?s?.end:void 0;if(p&&p.id){let v=i.get(p.id);v&&Object.assign(p,{id:v})}if(u&&u.id){let v=i.get(u.id);v&&Object.assign(u,{id:v})}let{linearElement:h,startBoundElement:x,endBoundElement:E}=S5(d,p,u,o,a);d=h,o.add(h),o.add(x),o.add(E)}}else switch(s.type){case"arrow":{let{start:d,end:m}=s;if(d&&d.id){let x=i.get(d.id);Object.assign(d,{id:x})}if(m&&m.id){let x=i.get(m.id);Object.assign(m,{id:x})}let{linearElement:p,startBoundElement:u,endBoundElement:h}=S5(c,d,m,o,a);o.add(p),o.add(u),o.add(h);break}}break}}}for(let[l,s]of n){if(s.type!=="frame"&&s.type!=="magicframe")continue;let c=o.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let d=[];s.children.forEach(w=>{let y=i.get(w);if(!y)throw new Error(`Element with ${w} wasn't mapped correctly`);let I=o.getElement(y);if(!I)throw new Error(`Frame element with id ${y} doesn't exist`);Object.assign(I,{frameId:c.id}),I?.boundElements?.forEach(P=>{let C=o.getElement(P.id);if(!C)throw new Error(`Bound element with id ${P.id} doesn't exist`);Object.assign(C,{frameId:c.id}),d.push(C)}),d.push(I)});let[m,p,u,h]=we(d),x=10;m=m-x,p=p-x,u=u+x,h=h+x;let E=Math.max(c?.width,u-m),v=Math.max(c?.height,h-p);Object.assign(c,{x:m,y:p,width:E,height:v})}return o.getElements()};f();f();z();G();import uP,{useEffect as hP,useRef as gP}from"react";f();z();import{unstable_batchedUpdates as I5}from"react-dom";import{version as Q8}from"react";var nt=e=>t=>{I5(e,t)},fu=e=>za(t=>{I5(e,t)}),bu=(()=>{let e;try{let r=Q8.split(".");e=Number(r[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();f();ge();bn();Nr();oc();z();G();f();G();var eP="#ff6b6b",tP="#ff0000",C5=1,k5=2,A5=(e,t)=>{if(!t.snapLines.length)return;let r=t.theme===oe.LIGHT||t.zenModeEnabled?eP:tP,o=(t.zenModeEnabled?C5*1.5:C5)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let n of t.snapLines)n.type==="pointer"?(e.lineWidth=o,e.strokeStyle=r,oP(n,e,t)):n.type==="gap"?(e.lineWidth=o,e.strokeStyle=r,nP(n.points[0],n.points[1],n.direction,t,e)):n.type==="points"&&(e.lineWidth=o,e.strokeStyle=r,rP(n,e,t));e.restore()},rP=(e,t,r)=>{if(!r.zenModeEnabled){let o=e.points[0],n=e.points[e.points.length-1];po(o,n,t)}for(let o of e.points)M5(o,r,t)},oP=(e,t,r)=>{M5(e.points[0],r,t),r.zenModeEnabled||po(e.points[0],e.points[1],t)},M5=([e,t],r,o)=>{o.save();let n=(r.zenModeEnabled?k5*1.5:k5)/r.zoom.value;o.beginPath(),o.moveTo(e-n,t-n),o.lineTo(e+n,t+n),o.moveTo(e+n,t-n),o.lineTo(e-n,t+n),o.stroke(),o.restore()},po=(e,t,r)=>{r.beginPath(),r.lineTo(...e),r.lineTo(...t),r.stroke()},nP=(e,t,r,o,n)=>{let i=8/o.zoom.value,a=i/2,l=i/4;if(r==="horizontal"){let s=[(e[0]+t[0])/2,e[1]];o.zenModeEnabled||po([e[0],e[1]-i],[e[0],e[1]+i],n),po([s[0]-l,s[1]-a],[s[0]-l,s[1]+a],n),po([s[0]+l,s[1]-a],[s[0]+l,s[1]+a],n),o.zenModeEnabled||(po([t[0],t[1]-i],[t[0],t[1]+i],n),po(e,t,n))}else{let s=[e[0],(e[1]+t[1])/2];o.zenModeEnabled||po([e[0]-i,e[1]],[e[0]+i,e[1]],n),po([s[0]-a,s[1]-l],[s[0]+a,s[1]-l],n),po([s[0]-a,s[1]+l],[s[0]+a,s[1]+l],n),o.zenModeEnabled||(po([t[0]-i,t[1]],[t[0]+i,t[1]],n),po(e,t,n))}};Jr();Qt();Jh();ce();import xu from"open-color";var iP=(e,t,r)=>{let{elementId:o,hoverPointIndex:n}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=K.getElement(o,r);if(!i)return;let a=K.getPointAtIndexGlobalCoordinates(i,n,r);e.save(),e.translate(t.scrollX,t.scrollY),$1(a,e,t),e.restore()},$1=(e,t,r)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",Zs(t,e[0],e[1],K.POINT_HANDLE_SIZE/r.zoom.value,!1)},Oc=(e,t,r,o,n,i,a,l,s=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(l),s&&e.fillRect(t-i,r-a,o,n),c&&e.roundRect?(e.beginPath(),e.roundRect(t-i,r-a,o,n,c),e.stroke(),e.closePath()):e.strokeRect(t-i,r-a,o,n),e.restore()},aP=(e,t,r,o,n,i)=>{e.save(),e.translate(o,n),e.rotate(i),e.beginPath(),e.moveTo(0,r/2),e.lineTo(t/2,0),e.lineTo(0,-r/2),e.lineTo(-t/2,0),e.closePath(),e.stroke(),e.restore()},Eu=(e,t,r,o,n,i=!1)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Zs(e,r[0],r[1],o/t.zoom.value,!i)},lP=(e,t,r,o,n,i)=>{e.beginPath(),e.ellipse(o,n,t/2,r/2,i,0,Math.PI*2),e.stroke()},sP=(e,t,r)=>{let[o,n,i,a]=te(t,r),l=i-o,s=a-n,c=Ds(t,l,s),d=4;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=c-d;let m=d/2+c/2;switch(t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":Oc(e,o-m,n-m,l+m*2,s+m*2,o+l/2,n+s/2,t.angle);break;case"diamond":let p=Math.hypot(l,s),u=m*p/s,h=m*p/l;aP(e,l+u*2,s+h*2,o+l/2,n+s/2,t.angle);break;case"ellipse":lP(e,l+m*2,s+m*2,o+l/2,n+s/2,t.angle);break}},cP=(e,t,r)=>{let[o,n,i]=t,a=Ds(i,i.width,i.height);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(n==="both"?[0,-1]:n==="start"?[0]:[-1]).forEach(s=>{let[c,d]=K.getPointAtIndexGlobalCoordinates(o,s,r);Zs(e,c,d,a)})},P5=(e,t,r,o=zi*2)=>{let{angle:n,elementX1:i,elementY1:a,elementX2:l,elementY2:s,selectionColors:c,cx:d,cy:m,dashed:p,activeEmbeddable:u}=r,h=l-i,x=s-a,E=o/t.zoom.value,v=8/t.zoom.value,w=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(u?4:1)/t.zoom.value;let y=c.length;for(let I=0;I<y;++I)e.strokeStyle=c[I],p&&e.setLineDash([v,w+(v+w)*(y-1)]),e.lineDashOffset=(v+w)*I,Oc(e,i-E,a-E,h+E*2,x+E*2,d,m,n);e.restore()},dP=(e,t,r,o)=>{let n=Array.isArray(r)?cP:sP;e.save(),e.translate(t.scrollX,t.scrollY),n(e,r,o),e.restore()},mP=(e,t,r,o)=>{let[n,i,a,l]=te(r,o),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=$e.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),Oc(e,n,i,s,c,n+s/2,i+c/2,r.angle,!1,$e.radius/t.zoom.value),e.restore()},pP=(e,t,r)=>{let o=r.filter(l=>l.groupIds.length===0),n=r.filter(l=>l.groupIds.length>0),i=l=>{let[s,c,d,m]=we(l);return{angle:0,elementX1:s,elementX2:d,elementY1:c,elementY2:m,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:s+(d-s)/2,cy:c+(m-c)/2,activeEmbeddable:!1}},a=l=>{let s=Je(r,l);return i(s)};Object.entries(Hd(n,t)).filter(([l,s])=>s).map(([l,s])=>l).map(l=>a(l)).concat(o.map(l=>i([l]))).forEach(l=>P5(e,t,l))},K1=(e,t,r,o)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let n=K.getPointsGlobalCoordinates(r,o),{POINT_HANDLE_SIZE:i}=K,a=t.editingLinearElement?i:i/2;n.forEach((s,c)=>{let d=!!t.editingLinearElement?.selectedPointsIndices?.includes(c);Eu(e,t,s,a,d)}),K.getEditorMidPoints(r,o,t).filter(s=>s!==null).forEach(s=>{t?.selectedLinearElement?.segmentMidPointHoveredCoords&&K.arePointsEqual(s,t.selectedLinearElement.segmentMidPointHoveredCoords)?t.editingLinearElement?(Eu(e,t,s,a,!1),$1(s,e,t)):($1(s,e,t),Eu(e,t,s,a,!1)):(t.editingLinearElement||n.length===2)&&Eu(e,t,s,i/2,!1,!0)}),e.restore()},L5=(e,t,r,o,n)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[l,s,c,d]=a;e.save(),e.lineWidth=1/r.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?Zs(e,l+c/2,s+d/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,d,2/r.zoom.value),e.fill(),e.stroke()):Oc(e,l,s,c,d,l+c/2,s+d/2,n,!0),e.restore()}})},_5=({canvas:e,elementsMap:t,visibleElements:r,selectedElements:o,scale:n,appState:i,renderConfig:a})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[l,s]=cm(e,n),c=dm({canvas:e,scale:n,normalizedWidth:l,normalizedHeight:s});c.save(),c.scale(i.zoom.value,i.zoom.value);let d;if(r.forEach(u=>{i.editingLinearElement?.elementId===u.id&&u&&(d=u)}),d&&K1(c,i,d,t),i.selectionElement)try{uy(i.selectionElement,c,i)}catch(u){console.error(u)}i.isBindingEnabled&&i.suggestedBindings.filter(u=>u!=null).forEach(u=>{dP(c,i,u,t)}),i.frameToHighlight&&mP(c,i,i.frameToHighlight,t),i.elementsToHighlight&&pP(c,i,i.elementsToHighlight);let m=o.some(u=>Q(u));if(o.length===1&&i.editingLinearElement?.elementId===o[0].id&&K1(c,i,o[0],t),i.selectedLinearElement&&i.selectedLinearElement.hoverPointIndex>=0&&iP(c,i,t),!i.multiElement&&!i.editingLinearElement){let u=Lm(o,i);o.length===1&&re(o[0])&&i.selectedLinearElement?.elementId===o[0].id&&!o[0].locked&&K1(c,i,o[0],t);let x=a.selectionColor||xu.black;if(u){let E=$(o),v=[];for(let y of t.values()){let I=[];E.has(y.id)&&!Fd(i,y)&&I.push(x);let P=a.remoteSelectedElementIds.get(y.id);if(P&&I.push(...P.map(C=>Ia(C,i.collaborators.get(C)))),I.length){let[C,_,D,H,A,M]=te(y,t,!0);v.push({angle:y.angle,elementX1:C,elementY1:_,elementX2:D,elementY2:H,selectionColors:I,dashed:!!P,cx:A,cy:M,activeEmbeddable:i.activeEmbeddable?.element===y&&i.activeEmbeddable.state==="active"})}}let w=y=>{let I=Je(t,y),[P,C,_,D]=we(I);v.push({angle:0,elementX1:P,elementX2:_,elementY1:C,elementY2:D,selectionColors:[xu.black],dashed:!0,cx:P+(_-P)/2,cy:C+(D-C)/2,activeEmbeddable:!1})};for(let y of vn(i))w(y);i.editingGroupId&&w(i.editingGroupId),v.forEach(y=>P5(c,i,y))}if(c.save(),c.translate(i.scrollX,i.scrollY),o.length===1){c.fillStyle=xu.white;let E=rc(o[0],i.zoom,t,"mouse");!i.viewModeEnabled&&u&&L5(c,a,i,E,o[0].angle)}else if(o.length>1&&!i.isRotating){let E=zi*2/i.zoom.value;c.fillStyle=xu.white;let[v,w,y,I]=we(o),P=c.getLineDash();c.setLineDash([2/i.zoom.value]);let C=c.lineWidth;c.lineWidth=1/i.zoom.value,c.strokeStyle=x,Oc(c,v-E,w-E,y-v+E*2,I-w+E*2,(v+y)/2,(w+I)/2,0),c.lineWidth=C,c.setLineDash(P);let _=vl([v,w,y,I,(v+y)/2,(w+I)/2],0,i.zoom,"mouse",m?by:tc);o.some(D=>!D.locked)&&L5(c,a,i,_,0)}c.restore()}A5(c,i),c.restore(),lv({context:c,renderConfig:a,appState:i,normalizedWidth:l,normalizedHeight:s});let p;return a.renderScrollbars&&(p=U3(r,l,s,i),c.save(),c.fillStyle=G3,c.strokeStyle="rgba(255,255,255,0.8)",[p.horizontal,p.vertical].forEach(u=>{u&&sp(c,u.x,u.y,u.width,u.height,rn/2)}),c.restore()),{scrollBars:p,atLeastOneVisibleElement:r.length>0,elementsMap:t}},X1=za(e=>{let t=_5(e);e.callback?.(t)},{trailing:!0}),D5=(e,t)=>{if(t){X1(e);return}let r=_5(e);return e.callback(r),r};import{jsx as xP}from"react/jsx-runtime";var fP=e=>{let t=gP(!1);return hP(()=>{if(!t.current){t.current=!0;return}let r=new Map,o=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,c)=>{if(s.selectedElementIds)for(let d of Object.keys(s.selectedElementIds))n.has(d)||n.set(d,[]),n.get(d).push(c);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(c,s.username),s.userState&&a.set(c,s.userState),o.set(c,Dt({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),r.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";D5({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:o,remotePointerButton:r,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:!1},callback:e.renderInteractiveSceneCallback},bu())}),xP("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Ce.GRAB:Ce.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:b("labels.drawingCanvas")})},R5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled}),bP=(e,t)=>e.selectionNonce!==t.selectionNonce||e.versionNonce!==t.versionNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements?!1:wt(R5(e.appState),R5(t.appState)),Z1=uP.memo(fP,bP);f();um();z();import EP,{useEffect as yP,useRef as N5}from"react";import{jsx as TP}from"react/jsx-runtime";var wP=e=>{let t=N5(null),r=N5(!1);return yP(()=>{let o=t.current;if(!o)return;let n=e.canvas;r.current||(r.current=!0,o.replaceChildren(n),n.classList.add("excalidraw__canvas","static"));let i=`${e.appState.width}px`,a=`${e.appState.height}px`;n.style.width!==i&&(n.style.width=i),n.style.height!==a&&(n.style.height=a);let l=e.appState.width*e.scale,s=e.appState.height*e.scale;n.width!==l&&(n.width=l),n.height!==s&&(n.height=s),pm({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},bu())}),TP("div",{className:"excalidraw__canvas-wrapper",ref:t})},O5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId}),vP=(e,t)=>e.versionNonce!==t.versionNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:wt(O5(e.appState),O5(t.appState))&&wt(e.renderConfig,t.renderConfig),j1=EP.memo(wP,vP);f();pa();ce();um();z();var Bc=class{scene;constructor(t){this.scene=t}getRenderableElements=(()=>{let t=({elementsMap:o,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:d})=>{let m=[];for(let p of o.values())ma(p,d,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},o)&&m.push(p);return m},r=({elements:o,editingElement:n,pendingImageElementId:i})=>{let a=xo(new Map);for(let l of o)Zr(l)&&i===l.id||(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return bx(({zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingElement:d,pendingImageElementId:m,versionNonce:p})=>{let u=this.scene.getNonDeletedElements(),h=r({elements:u,editingElement:d,pendingImageElementId:m}),x=t({elementsMap:h,zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:h,visibleElements:x}})})();destroy(){X1.cancel(),Qh.cancel(),this.getRenderableElements.clear()}};Go();f();import{useEffect as SP,useRef as IP}from"react";import{jsx as B5}from"react/jsx-runtime";var F5=({trails:e})=>{let t=IP(null);return SP(()=>{if(t.current)for(let r of e)r.start(t.current);return()=>{for(let r of e)r.stop()}},e),B5("div",{className:"SVGLayer",children:B5("svg",{ref:t})})};ol();f();z();ge();import{jsx as AP}from"react/jsx-runtime";var CP=5,kP=(e,t,r)=>{let[o,n]=te(e,r),{x:i,y:a}=Dt({sceneX:o+e.width,sceneY:n},t),l=i-t.offsetLeft+10,s=a-t.offsetTop;return{x:l,y:s}},q1=({children:e,element:t,elementsMap:r})=>{let o=Gl();if(o.contextMenu||o.draggingElement||o.resizingElement||o.isRotating||o.openMenu||o.viewModeEnabled)return null;let{x:n,y:i}=kP(t,o,r);return AP("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:CP},children:e})};f();G();var MP=`You are a skilled front-end developer who builds interactive prototypes from wireframes, and is an expert at CSS Grid and Flex design.
64
+ C -->|Three| F[Car]`,JT=Wi(Pc,300),A8=({mermaidToExcalidrawLib:e})=>{let[t,r]=ZT(()=>Tr.get($r.MERMAID_TO_EXCALIDRAW)||k8),o=C8(t.trim()),[n,i]=ZT(null),a=jT(null),l=jT({elements:[],files:null}),s=wr();qT(()=>{au({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:o}).catch(d=>{fx()&&console.error("Failed to parse mermaid definition",d)}),JT(o)},[o,e]),qT(()=>()=>{JT.flush()},[]);let c=()=>{lu({app:s,data:l,text:t,shouldSaveMermaidDataToStorage:!0})};return QT(M8,{children:[nn("div",{className:"ttd-dialog-desc",children:nn(sr,{i18nKey:"mermaid.description",flowchartLink:d=>nn("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>nn("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>nn("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),QT(su,{children:[nn(ts,{label:b("mermaid.syntax"),children:nn(cu,{input:t,placeholder:"Write Mermaid diagram defintion here...",onChange:d=>r(d.target.value),onKeyboardSubmit:()=>{c()}})}),nn(ts,{label:b("mermaid.preview"),panelAction:{action:()=>{c()},label:b("mermaid.button"),icon:Al},renderSubmitShortcut:()=>nn(pu,{}),children:nn(mu,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},e5=A8;import{useEffect as P8,useRef as G1,useState as hu}from"react";f();import*as t5 from"@radix-ui/react-tabs";import{jsx as L8}from"react/jsx-runtime";var z1=({children:e,...t})=>L8(t5.List,{className:"ttd-dialog-triggers",...t,children:e});z1.displayName="TTDDialogTabTriggers";f();import*as o5 from"@radix-ui/react-tabs";import{jsx as r5}from"react/jsx-runtime";var uu=({children:e,tab:t,onSelect:r,...o})=>r5(o5.Trigger,{value:t,asChild:!0,onSelect:r,children:r5("button",{type:"button",className:"ttd-dialog-tab-trigger",...o,children:e})});uu.displayName="TTDDialogTabTrigger";z();import{atom as i5,useAtom as n5}from"jotai";import{jsx as pr,jsxs as Li}from"react/jsx-runtime";var U1=3,rs=1e3,_8=i5(null),D8=i5(null),W1=e=>{let t=Me();return t.openDialog?.name!=="ttd"?null:pr(R8,{...e,tab:t.openDialog.tab})},R8=Gn("TTDDialogBase",({tab:e,...t})=>{let r=wr(),o=_e(),n=G1(null),[i,a]=n5(D8),[l,s]=hu(i?.prompt??""),c=l.trim(),d=C=>{s(C.target.value),a(_=>({generatedResponse:_?.generatedResponse??null,prompt:C.target.value}))},[m,p]=hu(!1),[u,h]=n5(_8),x=async()=>{if(c.length>rs||c.length<U1||m||u?.rateLimitRemaining===0||"__fallback"in t){c.length<U1&&P(new Error(`Prompt is too short (min ${U1} characters)`)),c.length>rs&&P(new Error(`Prompt is too long (max ${rs} characters)`));return}try{p(!0),fe("ai","generate","ttd");let{generatedResponse:C,error:_,rateLimit:D,rateLimitRemaining:H}=await t.onTextSubmit(c);if(typeof C=="string"&&a(A=>({generatedResponse:C,prompt:A?.prompt??null})),Yu(D)&&Yu(H)&&h({rateLimit:D,rateLimitRemaining:H}),_){P(_);return}if(!C){P(new Error("Generation failed"));return}try{await au({canvasRef:n,data:y,mermaidToExcalidrawLib:v,setError:P,mermaidDefinition:C}),fe("ai","mermaid parse success","ttd")}catch(A){console.info(`%cTTD mermaid render errror: ${A.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
65
+ TTD mermaid definition render errror: ${A.message}`,"color: yellow"),fe("ai","mermaid parse failed","ttd"),P(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(C){let _=C.message;(!_||_==="Failed to fetch")&&(_="Request failed"),P(new Error(_))}finally{p(!1)}},E=G1(x);E.current=x;let[v,w]=hu({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});P8(()=>{(async()=>{await v.api,w(_=>({..._,loaded:!0}))})()},[v.api]);let y=G1({elements:[],files:null}),[I,P]=hu(null);return pr(ct,{className:"ttd-dialog",onCloseRequest:()=>{r.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:Li(iu,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?pr("p",{className:"dialog-mermaid-title",children:b("mermaid.title")}):Li(z1,{children:[pr(uu,{tab:"text-to-diagram",children:Li("div",{style:{display:"flex",alignItems:"center"},children:[b("labels.textToDiagram"),pr("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"pink",color:"#000"},children:"AI Beta"})]})}),pr(uu,{tab:"mermaid",children:"Mermaid"})]}),pr(es,{className:"ttd-dialog-content",tab:"mermaid",children:pr(e5,{mermaidToExcalidrawLib:v})}),!("__fallback"in t)&&Li(es,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[pr("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),Li(su,{children:[pr(ts,{label:b("labels.prompt"),panelAction:{action:x,label:"Generate",icon:Al},onTextSubmitInProgess:m,panelActionDisabled:c.length>rs||u?.rateLimitRemaining===0,renderTopRight:()=>u?Li("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>pr(pu,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Li("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Pc(i.generatedResponse),o({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",pr(vi,{icon:Al})]});let C=c.length/rs;return C>.8?Li("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:C>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",rs]}):null},children:pr(cu,{onChange:d,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{E.current()}})}),pr(ts,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),lu({app:r,data:y})},label:"Insert",icon:Al},children:pr(mu,{canvasRef:n,error:I,loaded:v.loaded})})]})]})]})})});import{Fragment as l5,jsx as ie,jsxs as Yr}from"react/jsx-runtime";var H8=({UIOptions:e})=>Yr(mr,{__fallback:!0,children:[ie(mr.DefaultItems.LoadScene,{}),ie(mr.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ie(mr.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ie(mr.DefaultItems.SaveAsImage,{}),ie(mr.DefaultItems.Help,{}),ie(mr.DefaultItems.ClearCanvas,{}),ie(mr.Separator,{}),ie(mr.Group,{title:"Excalidraw links",children:ie(mr.DefaultItems.Socials,{})}),ie(mr.Separator,{}),ie(mr.DefaultItems.ToggleTheme,{}),ie(mr.DefaultItems.ChangeCanvasBackground,{})]}),z8=()=>Yr(ou,{__fallback:!0,children:[ie(ou.Actions.SaveToDisk,{}),ie(ou.Actions.ExportToImage,{})]}),G8=({actionManager:e,appState:t,files:r,setAppState:o,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:h,children:x,app:E,isCollaborating:v,openAIKey:w,isOpenAIKeyPersisted:y,onOpenAIAPIKeyChange:I,onMagicSettingsConfirm:P})=>{let C=Ie(),_=y3(),[D,H]=B8(fi,Be),A=()=>p.canvasActions.export?ie(eT,{elements:n,appState:t,files:r,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,M=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:ie(H3,{elements:n,appState:t,files:r,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:E.getName()}),k=()=>Yr("div",{style:{position:"relative"},children:[ie(_.MainMenuTunnel.Out,{}),h&&ie(_.WelcomeScreenMenuHintTunnel.Out,{})]}),O=()=>ie(Ci,{heading:"selectedShapeActions",className:Rc("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:ie($t,{className:qc.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:ie(Fp,{appState:t,elementsMap:E.scene.getNonDeletedElementsMap(),renderAction:e.renderAction})})}),X=()=>{let le=ua(t,n);return ie(Yp,{side:"top",children:Yr("div",{className:"App-menu App-menu_top",children:[Yr(Ft.Col,{gap:6,className:Rc("App-menu_top__left"),children:[k(),le&&O()]}),!t.viewModeEnabled&&ie(Ci,{heading:"shapes",className:"shapes-section",children:V=>Yr("div",{style:{position:"relative"},children:[h&&ie(_.WelcomeScreenToolbarHintTunnel.Out,{}),ie(Ft.Col,{gap:4,align:"start",children:Yr(Ft.Row,{gap:1,className:Rc("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[Yr($t,{padding:1,className:Rc("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[ie(Kp,{appState:t,isMobile:C.editor.isMobile,device:C,app:E}),V,Yr(Ft.Row,{gap:1,children:[ie(Xp,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>s(null),title:b("toolBar.penMode"),penDetected:t.penDetected}),ie($p,{checked:t.activeTool.locked,onChange:a,title:b("toolBar.lock")}),ie("div",{className:"App-toolbar__divider"}),ie(jp,{checked:Co(t),onChange:()=>l(),title:b("toolBar.hand"),isMobile:!0}),ie(Hp,{appState:t,activeTool:t.activeTool,UIOptions:p,app:E})]})]}),v&&ie($t,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:ie(FT,{title:b("toolBar.laser"),checked:t.activeTool.type===bt.laser,onChange:()=>E.setActiveTool({type:bt.laser}),isMobile:!0})})]})})]})}),Yr("div",{className:Rc("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&ie(qp,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),d?.(C.editor.isMobile,t),!t.viewModeEnabled&&(!ee||t.openSidebar?.name!==kr.name)&&ie(_.DefaultSidebarTriggerTunnel.Out,{})]})]})})},Y=()=>ie(nu,{__fallback:!0,onDock:le=>{fe("sidebar",`toggleDock (${le?"dock":"undock"})`,`(${C.editor.isMobile?"mobile":"desktop"})`)}}),ee=F8(Mc,Be),xe=Yr(l5,{children:[x,ie(H8,{UIOptions:p}),ie(nu.Trigger,{__fallback:!0,icon:Hm,title:$n(b("toolBar.library")),onToggle:le=>{le&&fe("sidebar",`${kr.name} (open)`,`button (${C.editor.isMobile?"mobile":"desktop"})`)},tab:kr.defaultTab,children:b("toolBar.library")}),ie(z8,{}),t.openDialog?.name==="ttd"&&ie(W1,{__fallback:!0}),t.isLoading&&ie(ld,{delay:250}),t.errorMessage&&ie(O3,{onClose:()=>o({errorMessage:null}),children:t.errorMessage}),D&&!C.editor.isMobile&&ie(Bw,{colorPickerType:D.colorPickerType,onCancel:()=>{H(null)},onChange:(le,V,ve,{altKey:Re})=>{if(!(le!=="elementBackground"&&le!=="elementStroke"))if(ve.length){for(let mt of ve)F(mt,{[Re&&D.swapPreviewOnAlt?le==="elementBackground"?"strokeColor":"backgroundColor":le==="elementBackground"?"backgroundColor":"strokeColor"]:V},!1),ke.delete(mt);ut.getScene(ve[0])?.informMutation()}else o(le==="elementBackground"?{currentItemBackgroundColor:V}:{currentItemStrokeColor:V})},onSelect:(le,V)=>{H(ve=>ve?.keepOpenOnAlt&&V.altKey?ve:null),D?.onSelect?.(le,V)}}),t.openDialog?.name==="help"&&ie(q3,{onClose:()=>{o({openDialog:null})}}),t.openDialog?.name==="settings"&&ie(VT,{openAIKey:w,isPersisted:y,onChange:I,onConfirm:(le,V)=>{let ve=t.openDialog?.name==="settings"?t.openDialog?.source:"settings";o({openDialog:null},()=>{P(le,V,ve)})},onClose:()=>{o({openDialog:null})}}),ie(I3,{}),ie(_.OverwriteConfirmDialogTunnel.Out,{}),M(),A(),t.pasteDialog.shown&&ie(j3,{setAppState:o,appState:t,onClose:()=>o({pasteDialog:{shown:!1,data:null}})}),C.editor.isMobile&&ie(X3,{app:E,appState:t,elements:n,actionManager:e,renderJSONExportDialog:A,renderImageExportDialog:M,setAppState:o,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:d,renderCustomStats:m,renderSidebars:Y,device:C,renderWelcomeScreen:h,UIOptions:p}),!C.editor.isMobile&&Yr(l5,{children:[Yr("div",{className:"layer-ui__wrapper",style:t.openSidebar&&ee&&C.editor.canFitSidebar?{width:`calc(100% - ${qb}px)`}:{},children:[h&&ie(_.WelcomeScreenCenterTunnel.Out,{}),X(),ie(oT,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:h}),t.showStats&&ie(Zp,{appState:t,setAppState:o,elements:n,onClose:()=>{e.executeAction(Ei)},renderCustomStats:m}),t.scrolledOutside&&ie("button",{className:"scroll-back-to-content",onClick:()=>{o(le=>({...Yo(n,le)}))},children:b("buttons.scrollBackToContent")})]}),Y()]})]});return ie(pf.Provider,{value:t,children:ie(O8,{scope:_.jotaiScope,children:ie(a1.Provider,{value:_,children:xe})})})},a5=e=>{let{suggestedBindings:t,startBoundElement:r,cursorButton:o,scrollX:n,scrollY:i,...a}=e;return a},U8=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:r,appState:o,...n}=e,{canvas:i,appState:a,...l}=t;return wt(a5(o),a5(a),{selectedElementIds:wt,selectedGroupIds:wt})&&wt(n,l)},s5=N8.memo(G8,U8);f();import{useCallback as W8,useEffect as V8,useRef as Y8}from"react";import{jsx as c5,jsxs as $8}from"react/jsx-runtime";var K8=5e3,d5=({message:e,onClose:t,closable:r=!1,duration:o=K8,style:n})=>{let i=Y8(0),a=o!==1/0,l=W8(()=>{a&&(i.current=window.setTimeout(()=>t(),o))},[t,o,a]);return V8(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,o,a]),$8("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[c5("p",{className:"Toast__message",children:e}),r&&c5(ae,{icon:ro,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})};f();ue();Ye();var V1=B({name:"viewMode",label:"labels.viewMode",paletteName:"Toggle view mode",icon:Ll,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},commitToHistory:!1}},checked:e=>e.viewModeEnabled,predicate:(e,t,r)=>typeof r.viewModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===he.R});Er();Zh();An();lt();import HP from"lodash.throttle";ia();oc();f();ge();We();lt();ce();z();Go();var gu=class e{scene;onSceneUpdated;constructor({scene:t,onSceneUpdated:r}){this.scene=t,this.onSceneUpdated=r}static loadedFontFaces=new Set;onFontsLoaded=t=>{if(t.every(o=>{let n=`${o.family}-${o.style}-${o.weight}`;return e.loadedFontFaces.has(n)?!0:(e.loadedFontFaces.add(n),!1)}))return!1;let r=!1;this.scene.mapElements(o=>G(o)&&!Ne(o)?(ke.delete(o),r=!0,ne(o,{...nl(o,st(o,this.scene.getNonDeletedElementsMap()),this.scene.getNonDeletedElementsMap())})):o),r&&this.onSceneUpdated()};loadFontsForElements=async t=>{let r=await Promise.all([...new Set(t.filter(o=>G(o)).map(o=>o.fontFamily))].map(o=>{let n=Ge({fontFamily:o,fontSize:16});if(!document.fonts?.check?.(n))return document.fonts?.load?.(n)}));this.onFontsLoaded(r.flat().filter(Boolean))}};er();Qn();f();ge();er();er();ue();z();ol();Ye();ce();var m5=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length===1&&Q(r[0])},p5=B({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;if(Q(n)){let i=Hr(be(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},commitToHistory:!1}}return{elements:e,appState:t,commitToHistory:!1}},predicate:(e,t,r,o)=>m5(t,o)}),u5=B({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;return Q(n)?{elements:dg(e,n),appState:{...t,selectedElementIds:{[n.id]:!0}},commitToHistory:!0}:{elements:e,appState:t,commitToHistory:!1}},predicate:(e,t,r,o)=>m5(t,o)}),h1e=B({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},commitToHistory:!1}),checked:e=>e.frameRendering.enabled}),g1e=B({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:$m,viewMode:!1,perform:(e,t,r,o)=>{let n=Xe(t,{type:"frame"});return Br(o.interactiveCanvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:Xe(t,{type:"frame"})},commitToHistory:!1}},keyTest:e=>!e[S.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===S.F});qn();f();U();at();ce();Nr();ue();Rt();Qn();var X8=8,h5=99999,fu=e=>X8/e,co=class e{static referenceSnapPoints=null;static visibleGaps=null;static setReferenceSnapPoints=t=>{e.referenceSnapPoints=t};static getReferenceSnapPoints=()=>e.referenceSnapPoints;static setVisibleGaps=t=>{e.visibleGaps=t};static getVisibleGaps=()=>e.visibleGaps;static destroy=()=>{e.referenceSnapPoints=null,e.visibleGaps=null}},Un=({event:e,appState:t,selectedElements:r})=>e?t.objectsSnapModeEnabled&&!e[S.CTRL_OR_CMD]||!t.objectsSnapModeEnabled&&e[S.CTRL_OR_CMD]&&t.gridSize===null:r.length===1&&r[0].type==="arrow"?!1:t.objectsSnapModeEnabled,Z8=(e,t,r=.01)=>Math.abs(e-t)<=r,Nc=(e,t,{omitCenter:r,boundingBoxCorners:o,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,d,m,p]=te(a,t);n&&(l+=n.x,c+=n.x,m+=n.x,s+=n.y,d+=n.y,p+=n.y);let u=(c-l)/2,h=(d-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let x=Ze([l,s+h],[m,p],a.angle),E=Ze([l+u,s],[m,p],a.angle),v=Ze([c,s+h],[m,p],a.angle),w=Ze([l+u,d],[m,p],a.angle);i=r?[x,E,v,w]:[x,E,v,w,[m,p]]}else{let x=Ze([l,s],[m,p],a.angle),E=Ze([c,s],[m,p],a.angle),v=Ze([l,d],[m,p],a.angle),w=Ze([c,d],[m,p],a.angle);i=r?[x,E,v,w]:[x,E,v,w,[m,p]]}}else if(e.length>1){let[a,l,s,c]=Od(e,n??{x:0,y:0}),d=s-a,m=c-l,p=[a,l],u=[s,l],h=[a,c],x=[s,c],E=[a+d/2,l+m/2];i=r?[p,u,h,x]:[p,u,h,x,E]}return i.map(a=>[dt(a[0]),dt(a[1])])},b5=(e,t,r,o)=>{let n=t.filter(i=>Q(i)).map(i=>i.id);return Ig(e,t,r,o).filter(i=>!(i.frameId&&n.includes(i.frameId)))},x5=(e,t,r,o)=>{let n=b5(e,t,r,o),i=na(n,o).filter(m=>!(m.length===1&&Ne(m[0]))).map(m=>we(m).map(p=>dt(p))),a=i.sort((m,p)=>m[0]-p[0]),l=[],s=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++s>h5)break e;let h=a[u],[,x,E,v]=p,[w,y,,I]=h;E<w&&Ts([x,v],[y,I])&&l.push({startBounds:p,endBounds:h,startSide:[[E,x],[E,v]],endSide:[[w,y],[w,I]],length:w-E,overlap:Ss([x,v],[y,I])})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];s=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++s>h5)break e;let h=c[u],[x,,E,v]=p,[w,y,I]=h;v<y&&Ts([x,E],[w,I])&&d.push({startBounds:p,endBounds:h,startSide:[[x,v],[E,v]],endSide:[[w,y],[I,y]],length:y-v,overlap:Ss([x,E],[w,I])})}}return{horizontalGaps:l,verticalGaps:d}},g5=(e,t,r,o,n,i,a)=>{if(!Un({appState:r,event:o,selectedElements:e}))return[];if(e.length===0)return[];let l=co.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[d,m,p,u]=Od(e,t).map(E=>dt(E)),h=(d+p)/2,x=(m+u)/2;for(let E of s){if(!Ts([m,u],E.overlap))continue;let v=E.startSide[0][0]+E.length/2,w=dt(v-h);if(E.length>p-d&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(n.length=0),a.x=Math.abs(w);let A={type:"gap",direction:"center_horizontal",gap:E,offset:w};n.push(A);continue}let[,,I]=E.endBounds,P=d-I,C=dt(E.length-P);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(n.length=0),a.x=Math.abs(C);let A={type:"gap",direction:"side_right",gap:E,offset:C};n.push(A);continue}let[_,,,]=E.startBounds,D=_-p,H=dt(D-E.length);if(Math.abs(H)<=a.x){Math.abs(H)<a.x&&(n.length=0),a.x=Math.abs(H);let A={type:"gap",direction:"side_left",gap:E,offset:H};n.push(A);continue}}for(let E of c){if(!Ts([d,p],E.overlap))continue;let v=E.startSide[0][1]+E.length/2,w=dt(v-x);if(E.length>u-m&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let A={type:"gap",direction:"center_vertical",gap:E,offset:w};i.push(A);continue}let[,I,,]=E.startBounds,P=I-u,C=dt(P-E.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let A={type:"gap",direction:"side_top",gap:E,offset:C};i.push(A);continue}let[,,,_]=E.endBounds,D=dt(m-_),H=E.length-D;if(Math.abs(H)<=a.y){Math.abs(H)<a.y&&(i.length=0),a.y=Math.abs(H);let A={type:"gap",direction:"side_bottom",gap:E,offset:H};i.push(A);continue}}}},E5=(e,t,r,o)=>{let n=b5(e,t,r,o);return na(n,o).filter(i=>!(i.length===1&&Ne(i[0]))).flatMap(i=>Nc(i,o))},os=(e,t,r,o,n,i,a)=>{if(!Un({appState:r,event:o,selectedElements:e})||e.length===0&&t.length===0)return[];let l=co.getReferenceSnapPoints();if(l)for(let s of t)for(let c of l){let d=c[0]-s[0],m=c[1]-s[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:m}),a.y=Math.abs(m))}},y5=(e,t,r,o,n)=>{let i=pe(e,r);if(!Un({appState:r,event:o,selectedElements:i})||i.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=dt(t.x),t.y=dt(t.y);let a=[],l=[],s=fu(r.zoom.value),c={x:s,y:s},d=Nc(i,n,{dragOffset:t});os(i,d,r,o,a,l,c),g5(i,t,r,o,a,l,c);let m={x:a[0]?.offset??0,y:l[0]?.offset??0};c.x=0,c.y=0,a.length=0,l.length=0;let p={x:dt(t.x+m.x),y:dt(t.y+m.y)};os(i,Nc(i,n,{dragOffset:p}),r,o,a,l,c),g5(i,p,r,o,a,l,c);let u=Y1(a,l),h=q8(i,p,[...a,...l].filter(x=>x.type==="gap"));return{snapOffset:m,snapLines:[...u,...h]}},dt=e=>Math.round(e*10**6)/10**6,f5=e=>{let t=new Map;for(let r of e){let o=r.join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},Y1=(e,t)=>{let r={},o={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=dt(n.points[0][0]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>[dt(a[0]),dt(a[1])]))}}if(t.length>0){for(let n of t)if(n.type==="point"){let i=dt(n.points[0][1]);o[i]||(o[i]=[]),o[i].push(...n.points.map(a=>[dt(a[0]),dt(a[1])]))}}return Object.entries(r).map(([n,i])=>({type:"points",points:f5(i.map(a=>[Number(n),a[1]]).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(o).map(([n,i])=>({type:"points",points:f5(i.map(a=>[a[0],Number(n)]).sort((a,l)=>a[0]-l[0]))})))},j8=e=>{let t=new Map;for(let r of e){let o=r.points.flat().map(n=>[dt(n)]).join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},q8=(e,t,r)=>{let[o,n,i,a]=Od(e,t),l=[];for(let s of r){let[c,d,m,p]=s.gap.startBounds,[u,h,x,E]=s.gap.endBounds,v=Ss([n,a],s.gap.overlap),w=Ss([o,i],s.gap.overlap);switch(s.direction){case"center_horizontal":{if(v){let y=(v[0]+v[1])/2;l.push({type:"gap",direction:"horizontal",points:[[s.gap.startSide[0][0],y],[o,y]]},{type:"gap",direction:"horizontal",points:[[i,y],[s.gap.endSide[0][0],y]]})}break}case"center_vertical":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[[y,s.gap.startSide[0][1]],[y,n]]},{type:"gap",direction:"vertical",points:[[y,a],[y,s.gap.endSide[0][1]]]})}break}case"side_right":{if(v){let y=(v[0]+v[1])/2;l.push({type:"gap",direction:"horizontal",points:[[m,y],[u,y]]},{type:"gap",direction:"horizontal",points:[[x,y],[o,y]]})}break}case"side_left":{if(v){let y=(v[0]+v[1])/2;l.push({type:"gap",direction:"horizontal",points:[[i,y],[c,y]]},{type:"gap",direction:"horizontal",points:[[m,y],[u,y]]})}break}case"side_top":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[[y,a],[y,d]]},{type:"gap",direction:"vertical",points:[[y,p],[y,h]]})}break}case"side_bottom":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[[y,p],[y,h]]},{type:"gap",direction:"vertical",points:[[y,E],[y,n]]})}break}}}return j8(l.map(s=>({...s,points:s.points.map(c=>[dt(c[0]),dt(c[1])])})))},w5=(e,t,r,o,n,i)=>{if(!Un({event:o,selectedElements:e,appState:r})||e.length===0||e.length===1&&!Z8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=we(t);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(c+=n.y));let d=[];if(i)switch(i){case"e":{d.push([s,l],[s,c]);break}case"w":{d.push([a,l],[a,c]);break}case"n":{d.push([a,l],[s,l]);break}case"s":{d.push([a,c],[s,c]);break}case"ne":{d.push([s,l]);break}case"nw":{d.push([a,l]);break}case"se":{d.push([s,c]);break}case"sw":{d.push([a,c]);break}}let m=fu(r.zoom.value),p={x:m,y:m},u=[],h=[];os(t,d,r,o,u,h,p);let x={x:u[0]?.offset??0,y:h[0]?.offset??0};p.x=0,p.y=0,u.length=0,h.length=0;let[E,v,w,y]=we(e).map(C=>dt(C));os(e,[[E,v],[E,y],[w,v],[w,y]],r,o,u,h,p);let P=Y1(u,h);return{snapOffset:x,snapLines:P}},v5=(e,t,r,o,n,i)=>{if(!Un({event:r,selectedElements:[e],appState:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[[o.x+n.x,o.y+n.y]],l=fu(t.zoom.value),s={x:l,y:l},c=[],d=[];os([e],a,t,r,c,d,s);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};s.x=0,s.y=0,c.length=0,d.length=0;let p=Nc([e],i,{boundingBoxCorners:!0,omitCenter:!0});os([e],p,t,r,c,d,s);let u=Y1(c,d);return{snapOffset:m,snapLines:u}},T5=(e,t,r,o,n)=>{if(!Un({event:o,selectedElements:[],appState:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Ig(e,[],t,n),a=fu(t.zoom.value),l={x:a,y:a},s=[],c=[];for(let d of i){let m=Nc([d],n);for(let p of m){let u=p[0]-r.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,[p[0],r.y]],direction:"vertical"}),l.x=u);let h=p[1]-r.y;Math.abs(h)<=Math.abs(l.y)&&(Math.abs(h)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,[r.x,p[1]]],direction:"horizontal"}),l.y=h)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-r.x:0,y:s.length>0?s[0].points[0][1]-r.y:0},snapLines:[...c,...s]}},S5=e=>e===bt.rectangle||e===bt.ellipse||e===bt.diamond||e===bt.frame||e===bt.magicframe||e===bt.image;f();import{jsx as mo,jsxs as I5}from"react/jsx-runtime";var J8=()=>I5("div",{"data-testid":"brave-measure-text-error",children:[mo("p",{children:mo(sr,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>mo("span",{style:{fontWeight:600},children:e})})}),mo("p",{children:mo(sr,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>mo("span",{style:{fontWeight:600},children:e})})}),mo("p",{children:mo(sr,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>mo("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),mo("p",{children:mo(sr,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>mo("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>I5("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),C5=J8;f();U();ge();Jr();In();lt();z();ws();Eo();wo();var bu={width:100,height:0},Pi=100,Q8=(e,t,r)=>{let o=Nt({x:0,y:0,textAlign:Kn.CENTER,verticalAlign:ft.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:o.id})}),Yt(o,e,r),[e,o]},k5=(e,t,r,o,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let d=t?.width??Pi,m=t?.height??Pi,p;t.id&&(p=o.getElement(t.id),p||console.error(`No element for start binding with id ${t.id} found`));let u=t.x||e.x-d,h=t.y||e.y-m/2,x=p?p.type:t.type;if(x){if(x==="text"){let E="";p&&p.type==="text"?E=p.text:t.type==="text"&&(E=t.text),E||console.error(`No text found for start binding text element for ${e.id}`),i=Nt({x:u,y:h,type:"text",...p,...t,text:E}),Object.assign(i,{x:t.x||e.x-i.width,y:t.y||e.y-i.height/2})}else switch(x){case"rectangle":case"ellipse":case"diamond":{i=Fr({x:u,y:h,width:d,height:m,...p,...t,type:x});break}default:Zn(e,`Unhandled element start type "${t.type}"`,!0)}Ja(e,i,"start",n)}}if(r){let d=r?.height??Pi,m=r?.width??Pi,p;r.id&&(p=o.getElement(r.id),p||console.error(`No element for end binding with id ${r.id} found`));let u=r.x||e.x+e.width,h=r.y||e.y-d/2,x=p?p.type:r.type;if(x){if(x==="text"){let E="";p&&p.type==="text"?E=p.text:r.type==="text"&&(E=r.text),E||console.error(`No text found for end binding text element for ${e.id}`),a=Nt({x:u,y:h,type:"text",...p,...r,text:E}),Object.assign(a,{y:r.y||e.y-a.height/2})}else switch(x){case"rectangle":case"ellipse":case"diamond":{a=Fr({x:u,y:h,width:m,height:d,...p,...r,type:x});break}default:Zn(e,`Unhandled element end type "${x}"`,!0)}Ja(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,c=Bo(e.points);return e.points[l][0]>e.points[l-1][0]&&(c[0][0]=s,c[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(c[0][0]=-s,c[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(c[0][1]=s,c[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(c[0][1]=-s,c[l][1]+=s),Object.assign(e,{points:c}),{linearElement:e,startBoundElement:i,endBoundElement:a}},K1=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>Mr(Array.from(this.excalidrawElements.values()));getElementsMap=()=>xo($(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},_c=(e,t)=>{if(!e)return[];let r=Bo(e),o=new K1,n=new Map,i=new Map;for(let l of r){let s,c=l.id;switch(t?.regenerateIds!==!1&&Object.assign(l,{id:Pt()}),l.type){case"rectangle":case"ellipse":case"diamond":{let m=l?.label?.text&&l.width===void 0?0:l?.width||Pi,p=l?.label?.text&&l.height===void 0?0:l?.height||Pi;s=Fr({...l,width:m,height:p});break}case"line":{let m=l.width||bu.width,p=l.height||bu.height;s=Qr({width:m,height:p,points:[[0,0],[m,p]],...l});break}case"arrow":{let m=l.width||bu.width,p=l.height||bu.height;s=Qr({width:m,height:p,endArrowhead:"arrow",points:[[0,0],[m,p]],...l}),Object.assign(s,bd(s.points));break}case"text":{let m=l?.fontFamily||Wt,p=l?.fontSize||At,u=l?.lineHeight||_r(m),h=l.text??"",x=ni(h),E=Io(x,Ge({fontFamily:m,fontSize:p}),u);s=Nt({width:E.width,height:E.height,fontFamily:m,fontSize:p,...l});break}case"image":{s=Fs({width:l?.width||Pi,height:l?.height||Pi,...l});break}case"frame":{s=$d({x:0,y:0,...l});break}case"magicframe":{s=Bs({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{s=l;break}default:s=l,Zn(l,`Unhandled element type "${l.type}"`,!0)}o.getElement(s.id)?console.error(`Duplicate id found for ${s.id}`):(o.add(s),n.set(s.id,l),c&&i.set(c,s.id))}let a=o.getElementsMap();for(let[l,s]of n){let c=o.getElement(l);switch(s.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(s.label?.text){let[d,m]=Q8(c,s?.label,a);if(o.add(d),o.add(m),d.type==="arrow"){let p=s.type==="arrow"?s?.start:void 0,u=s.type==="arrow"?s?.end:void 0;if(p&&p.id){let v=i.get(p.id);v&&Object.assign(p,{id:v})}if(u&&u.id){let v=i.get(u.id);v&&Object.assign(u,{id:v})}let{linearElement:h,startBoundElement:x,endBoundElement:E}=k5(d,p,u,o,a);d=h,o.add(h),o.add(x),o.add(E)}}else switch(s.type){case"arrow":{let{start:d,end:m}=s;if(d&&d.id){let x=i.get(d.id);Object.assign(d,{id:x})}if(m&&m.id){let x=i.get(m.id);Object.assign(m,{id:x})}let{linearElement:p,startBoundElement:u,endBoundElement:h}=k5(c,d,m,o,a);o.add(p),o.add(u),o.add(h);break}}break}}}for(let[l,s]of n){if(s.type!=="frame"&&s.type!=="magicframe")continue;let c=o.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let d=[];s.children.forEach(w=>{let y=i.get(w);if(!y)throw new Error(`Element with ${w} wasn't mapped correctly`);let I=o.getElement(y);if(!I)throw new Error(`Frame element with id ${y} doesn't exist`);Object.assign(I,{frameId:c.id}),I?.boundElements?.forEach(P=>{let C=o.getElement(P.id);if(!C)throw new Error(`Bound element with id ${P.id} doesn't exist`);Object.assign(C,{frameId:c.id}),d.push(C)}),d.push(I)});let[m,p,u,h]=we(d),x=10;m=m-x,p=p-x,u=u+x,h=h+x;let E=Math.max(c?.width,u-m),v=Math.max(c?.height,h-p);Object.assign(c,{x:m,y:p,width:E,height:v})}return o.getElements()};f();f();z();U();import hP,{useEffect as gP,useRef as fP}from"react";f();z();import{unstable_batchedUpdates as A5}from"react-dom";import{version as eP}from"react";var nt=e=>t=>{A5(e,t)},xu=e=>za(t=>{A5(e,t)}),Eu=(()=>{let e;try{let r=eP.split(".");e=Number(r[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();f();ge();bn();Nr();oc();z();U();f();U();var tP="#ff6b6b",rP="#ff0000",M5=1,L5=2,P5=(e,t)=>{if(!t.snapLines.length)return;let r=t.theme===oe.LIGHT||t.zenModeEnabled?tP:rP,o=(t.zenModeEnabled?M5*1.5:M5)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let n of t.snapLines)n.type==="pointer"?(e.lineWidth=o,e.strokeStyle=r,nP(n,e,t)):n.type==="gap"?(e.lineWidth=o,e.strokeStyle=r,iP(n.points[0],n.points[1],n.direction,t,e)):n.type==="points"&&(e.lineWidth=o,e.strokeStyle=r,oP(n,e,t));e.restore()},oP=(e,t,r)=>{if(!r.zenModeEnabled){let o=e.points[0],n=e.points[e.points.length-1];po(o,n,t)}for(let o of e.points)_5(o,r,t)},nP=(e,t,r)=>{_5(e.points[0],r,t),r.zenModeEnabled||po(e.points[0],e.points[1],t)},_5=([e,t],r,o)=>{o.save();let n=(r.zenModeEnabled?L5*1.5:L5)/r.zoom.value;o.beginPath(),o.moveTo(e-n,t-n),o.lineTo(e+n,t+n),o.moveTo(e+n,t-n),o.lineTo(e-n,t+n),o.stroke(),o.restore()},po=(e,t,r)=>{r.beginPath(),r.lineTo(...e),r.lineTo(...t),r.stroke()},iP=(e,t,r,o,n)=>{let i=8/o.zoom.value,a=i/2,l=i/4;if(r==="horizontal"){let s=[(e[0]+t[0])/2,e[1]];o.zenModeEnabled||po([e[0],e[1]-i],[e[0],e[1]+i],n),po([s[0]-l,s[1]-a],[s[0]-l,s[1]+a],n),po([s[0]+l,s[1]-a],[s[0]+l,s[1]+a],n),o.zenModeEnabled||(po([t[0],t[1]-i],[t[0],t[1]+i],n),po(e,t,n))}else{let s=[e[0],(e[1]+t[1])/2];o.zenModeEnabled||po([e[0]-i,e[1]],[e[0]+i,e[1]],n),po([s[0]-a,s[1]-l],[s[0]+a,s[1]-l],n),po([s[0]-a,s[1]+l],[s[0]+a,s[1]+l],n),o.zenModeEnabled||(po([t[0]-i,t[1]],[t[0]+i,t[1]],n),po(e,t,n))}};Jr();Qt();Qh();ce();import yu from"open-color";var aP=(e,t,r)=>{let{elementId:o,hoverPointIndex:n}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=K.getElement(o,r);if(!i)return;let a=K.getPointAtIndexGlobalCoordinates(i,n,r);e.save(),e.translate(t.scrollX,t.scrollY),X1(a,e,t),e.restore()},X1=(e,t,r)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",js(t,e[0],e[1],K.POINT_HANDLE_SIZE/r.zoom.value,!1)},Oc=(e,t,r,o,n,i,a,l,s=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(l),s&&e.fillRect(t-i,r-a,o,n),c&&e.roundRect?(e.beginPath(),e.roundRect(t-i,r-a,o,n,c),e.stroke(),e.closePath()):e.strokeRect(t-i,r-a,o,n),e.restore()},lP=(e,t,r,o,n,i)=>{e.save(),e.translate(o,n),e.rotate(i),e.beginPath(),e.moveTo(0,r/2),e.lineTo(t/2,0),e.lineTo(0,-r/2),e.lineTo(-t/2,0),e.closePath(),e.stroke(),e.restore()},wu=(e,t,r,o,n,i=!1)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),js(e,r[0],r[1],o/t.zoom.value,!i)},sP=(e,t,r,o,n,i)=>{e.beginPath(),e.ellipse(o,n,t/2,r/2,i,0,Math.PI*2),e.stroke()},cP=(e,t,r)=>{let[o,n,i,a]=te(t,r),l=i-o,s=a-n,c=Ds(t,l,s),d=4;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=c-d;let m=d/2+c/2;switch(t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":Oc(e,o-m,n-m,l+m*2,s+m*2,o+l/2,n+s/2,t.angle);break;case"diamond":let p=Math.hypot(l,s),u=m*p/s,h=m*p/l;lP(e,l+u*2,s+h*2,o+l/2,n+s/2,t.angle);break;case"ellipse":sP(e,l+m*2,s+m*2,o+l/2,n+s/2,t.angle);break}},dP=(e,t,r)=>{let[o,n,i]=t,a=Ds(i,i.width,i.height);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(n==="both"?[0,-1]:n==="start"?[0]:[-1]).forEach(s=>{let[c,d]=K.getPointAtIndexGlobalCoordinates(o,s,r);js(e,c,d,a)})},R5=(e,t,r,o=zi*2)=>{let{angle:n,elementX1:i,elementY1:a,elementX2:l,elementY2:s,selectionColors:c,cx:d,cy:m,dashed:p,activeEmbeddable:u}=r,h=l-i,x=s-a,E=o/t.zoom.value,v=8/t.zoom.value,w=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(u?4:1)/t.zoom.value;let y=c.length;for(let I=0;I<y;++I)e.strokeStyle=c[I],p&&e.setLineDash([v,w+(v+w)*(y-1)]),e.lineDashOffset=(v+w)*I,Oc(e,i-E,a-E,h+E*2,x+E*2,d,m,n);e.restore()},mP=(e,t,r,o)=>{let n=Array.isArray(r)?dP:cP;e.save(),e.translate(t.scrollX,t.scrollY),n(e,r,o),e.restore()},pP=(e,t,r,o)=>{let[n,i,a,l]=te(r,o),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=$e.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),Oc(e,n,i,s,c,n+s/2,i+c/2,r.angle,!1,$e.radius/t.zoom.value),e.restore()},uP=(e,t,r)=>{let o=r.filter(l=>l.groupIds.length===0),n=r.filter(l=>l.groupIds.length>0),i=l=>{let[s,c,d,m]=we(l);return{angle:0,elementX1:s,elementX2:d,elementY1:c,elementY2:m,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:s+(d-s)/2,cy:c+(m-c)/2,activeEmbeddable:!1}},a=l=>{let s=Je(r,l);return i(s)};Object.entries(Hd(n,t)).filter(([l,s])=>s).map(([l,s])=>l).map(l=>a(l)).concat(o.map(l=>i([l]))).forEach(l=>R5(e,t,l))},$1=(e,t,r,o)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let n=K.getPointsGlobalCoordinates(r,o),{POINT_HANDLE_SIZE:i}=K,a=t.editingLinearElement?i:i/2;n.forEach((s,c)=>{let d=!!t.editingLinearElement?.selectedPointsIndices?.includes(c);wu(e,t,s,a,d)}),K.getEditorMidPoints(r,o,t).filter(s=>s!==null).forEach(s=>{t?.selectedLinearElement?.segmentMidPointHoveredCoords&&K.arePointsEqual(s,t.selectedLinearElement.segmentMidPointHoveredCoords)?t.editingLinearElement?(wu(e,t,s,a,!1),X1(s,e,t)):(X1(s,e,t),wu(e,t,s,a,!1)):(t.editingLinearElement||n.length===2)&&wu(e,t,s,i/2,!1,!0)}),e.restore()},D5=(e,t,r,o,n)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[l,s,c,d]=a;e.save(),e.lineWidth=1/r.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?js(e,l+c/2,s+d/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,d,2/r.zoom.value),e.fill(),e.stroke()):Oc(e,l,s,c,d,l+c/2,s+d/2,n,!0),e.restore()}})},N5=({canvas:e,elementsMap:t,visibleElements:r,selectedElements:o,scale:n,appState:i,renderConfig:a})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[l,s]=mm(e,n),c=pm({canvas:e,scale:n,normalizedWidth:l,normalizedHeight:s});c.save(),c.scale(i.zoom.value,i.zoom.value);let d;if(r.forEach(u=>{i.editingLinearElement?.elementId===u.id&&u&&(d=u)}),d&&$1(c,i,d,t),i.selectionElement)try{fy(i.selectionElement,c,i)}catch(u){console.error(u)}i.isBindingEnabled&&i.suggestedBindings.filter(u=>u!=null).forEach(u=>{mP(c,i,u,t)}),i.frameToHighlight&&pP(c,i,i.frameToHighlight,t),i.elementsToHighlight&&uP(c,i,i.elementsToHighlight);let m=o.some(u=>Q(u));if(o.length===1&&i.editingLinearElement?.elementId===o[0].id&&$1(c,i,o[0],t),i.selectedLinearElement&&i.selectedLinearElement.hoverPointIndex>=0&&aP(c,i,t),!i.multiElement&&!i.editingLinearElement){let u=_m(o,i);o.length===1&&re(o[0])&&i.selectedLinearElement?.elementId===o[0].id&&!o[0].locked&&$1(c,i,o[0],t);let x=a.selectionColor||yu.black;if(u){let E=$(o),v=[];for(let y of t.values()){let I=[];E.has(y.id)&&!Fd(i,y)&&I.push(x);let P=a.remoteSelectedElementIds.get(y.id);if(P&&I.push(...P.map(C=>Ia(C,i.collaborators.get(C)))),I.length){let[C,_,D,H,A,M]=te(y,t,!0);v.push({angle:y.angle,elementX1:C,elementY1:_,elementX2:D,elementY2:H,selectionColors:I,dashed:!!P,cx:A,cy:M,activeEmbeddable:i.activeEmbeddable?.element===y&&i.activeEmbeddable.state==="active"})}}let w=y=>{let I=Je(t,y),[P,C,_,D]=we(I);v.push({angle:0,elementX1:P,elementX2:_,elementY1:C,elementY2:D,selectionColors:[yu.black],dashed:!0,cx:P+(_-P)/2,cy:C+(D-C)/2,activeEmbeddable:!1})};for(let y of vn(i))w(y);i.editingGroupId&&w(i.editingGroupId),v.forEach(y=>R5(c,i,y))}if(c.save(),c.translate(i.scrollX,i.scrollY),o.length===1){c.fillStyle=yu.white;let E=rc(o[0],i.zoom,t,"mouse");!i.viewModeEnabled&&u&&D5(c,a,i,E,o[0].angle)}else if(o.length>1&&!i.isRotating){let E=zi*2/i.zoom.value;c.fillStyle=yu.white;let[v,w,y,I]=we(o),P=c.getLineDash();c.setLineDash([2/i.zoom.value]);let C=c.lineWidth;c.lineWidth=1/i.zoom.value,c.strokeStyle=x,Oc(c,v-E,w-E,y-v+E*2,I-w+E*2,(v+y)/2,(w+I)/2,0),c.lineWidth=C,c.setLineDash(P);let _=Tl([v,w,y,I,(v+y)/2,(w+I)/2],0,i.zoom,"mouse",m?yy:tc);o.some(D=>!D.locked)&&D5(c,a,i,_,0)}c.restore()}P5(c,i),c.restore(),dv({context:c,renderConfig:a,appState:i,normalizedWidth:l,normalizedHeight:s});let p;return a.renderScrollbars&&(p=Y3(r,l,s,i),c.save(),c.fillStyle=V3,c.strokeStyle="rgba(255,255,255,0.8)",[p.horizontal,p.vertical].forEach(u=>{u&&dp(c,u.x,u.y,u.width,u.height,rn/2)}),c.restore()),{scrollBars:p,atLeastOneVisibleElement:r.length>0,elementsMap:t}},Z1=za(e=>{let t=N5(e);e.callback?.(t)},{trailing:!0}),O5=(e,t)=>{if(t){Z1(e);return}let r=N5(e);return e.callback(r),r};import{jsx as EP}from"react/jsx-runtime";var bP=e=>{let t=fP(!1);return gP(()=>{if(!t.current){t.current=!0;return}let r=new Map,o=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,c)=>{if(s.selectedElementIds)for(let d of Object.keys(s.selectedElementIds))n.has(d)||n.set(d,[]),n.get(d).push(c);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(c,s.username),s.userState&&a.set(c,s.userState),o.set(c,Dt({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),r.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";O5({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:o,remotePointerButton:r,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:!1},callback:e.renderInteractiveSceneCallback},Eu())}),EP("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Ce.GRAB:Ce.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:b("labels.drawingCanvas")})},B5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled}),xP=(e,t)=>e.selectionNonce!==t.selectionNonce||e.versionNonce!==t.versionNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements?!1:wt(B5(e.appState),B5(t.appState)),j1=hP.memo(bP,xP);f();gm();z();import yP,{useEffect as wP,useRef as F5}from"react";import{jsx as SP}from"react/jsx-runtime";var vP=e=>{let t=F5(null),r=F5(!1);return wP(()=>{let o=t.current;if(!o)return;let n=e.canvas;r.current||(r.current=!0,o.replaceChildren(n),n.classList.add("excalidraw__canvas","static"));let i=`${e.appState.width}px`,a=`${e.appState.height}px`;n.style.width!==i&&(n.style.width=i),n.style.height!==a&&(n.style.height=a);let l=e.appState.width*e.scale,s=e.appState.height*e.scale;n.width!==l&&(n.width=l),n.height!==s&&(n.height=s),hm({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Eu())}),SP("div",{className:"excalidraw__canvas-wrapper",ref:t})},H5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId}),TP=(e,t)=>e.versionNonce!==t.versionNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:wt(H5(e.appState),H5(t.appState))&&wt(e.renderConfig,t.renderConfig),q1=yP.memo(vP,TP);f();pa();ce();gm();z();var Bc=class{scene;constructor(t){this.scene=t}getRenderableElements=(()=>{let t=({elementsMap:o,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:d})=>{let m=[];for(let p of o.values())ma(p,d,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},o)&&m.push(p);return m},r=({elements:o,editingElement:n,pendingImageElementId:i})=>{let a=xo(new Map);for(let l of o)Zr(l)&&i===l.id||(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return xx(({zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingElement:d,pendingImageElementId:m,versionNonce:p})=>{let u=this.scene.getNonDeletedElements(),h=r({elements:u,editingElement:d,pendingImageElementId:m}),x=t({elementsMap:h,zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:h,visibleElements:x}})})();destroy(){Z1.cancel(),eg.cancel(),this.getRenderableElements.clear()}};Go();f();import{useEffect as IP,useRef as CP}from"react";import{jsx as z5}from"react/jsx-runtime";var G5=({trails:e})=>{let t=CP(null);return IP(()=>{if(t.current)for(let r of e)r.start(t.current);return()=>{for(let r of e)r.stop()}},e),z5("div",{className:"SVGLayer",children:z5("svg",{ref:t})})};ol();f();z();ge();import{jsx as MP}from"react/jsx-runtime";var kP=5,AP=(e,t,r)=>{let[o,n]=te(e,r),{x:i,y:a}=Dt({sceneX:o+e.width,sceneY:n},t),l=i-t.offsetLeft+10,s=a-t.offsetTop;return{x:l,y:s}},J1=({children:e,element:t,elementsMap:r})=>{let o=Ul();if(o.contextMenu||o.draggingElement||o.resizingElement||o.isRotating||o.openMenu||o.viewModeEnabled)return null;let{x:n,y:i}=AP(t,o,r);return MP("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:kP},children:e})};f();U();var LP=`You are a skilled front-end developer who builds interactive prototypes from wireframes, and is an expert at CSS Grid and Flex design.
66
66
  Your role is to transform low-fidelity wireframes into working front-end HTML code.
67
67
 
68
68
  YOU MUST FOLLOW FOLLOWING RULES:
@@ -82,8 +82,8 @@ If the wireframes, diagrams, or text is unclear or unreadable, refer to provided
82
82
 
83
83
  Your goal is a production-ready prototype that brings the wireframes to life.
84
84
 
85
- Please output JUST THE HTML file containing your best attempt at implementing the provided wireframes.`;async function H5({image:e,apiKey:t,text:r,theme:o=oe.LIGHT}){let n={model:"gpt-4-vision-preview",max_tokens:4096,temperature:.1,messages:[{role:"system",content:MP},{role:"user",content:[{type:"image_url",image_url:{url:e,detail:"high"}},{type:"text",text:`Above is the reference wireframe. Please make a new website based on these and return just the HTML file. Also, please make it for the ${o} theme. What follows are the wireframe's text annotations (if any)...`},{type:"text",text:r}]}]},i,a=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)});return a.ok?i={...await a.json(),ok:!0}:i={...await a.json(),ok:!1},i}da();Zt();f();import LP from"clsx";import{jsx as z5,jsxs as _P}from"react/jsx-runtime";var PP="small",yu=e=>_P("label",{className:LP("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${PP}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[z5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),z5("div",{className:"ToolIcon__icon",children:e.icon})]});f();import{jsx as J1,jsxs as G5}from"react/jsx-runtime";var DP=({height:e,width:t,userToFollow:r,onDisconnect:o})=>J1("div",{className:"follow-mode",style:{width:t,height:e},children:G5("div",{className:"follow-mode__badge",children:[G5("div",{className:"follow-mode__badge__label",children:["Following"," ",J1("span",{className:"follow-mode__badge__username",title:r.username,children:r.username})]}),J1("button",{onClick:o,className:"follow-mode__disconnect-btn",children:ro})]})}),U5=DP;f();var wu=class{targets=new WeakMap;rafIds=new WeakMap;register(t,r){this.targets.set(t,{callback:r,stopped:!0})}start(t){let r=this.targets.get(t);r&&(this.rafIds.has(t)||(this.targets.set(t,{...r,stopped:!1}),this.scheduleFrame(t)))}stop(t){let r=this.targets.get(t);r&&!r.stopped&&this.targets.set(t,{...r,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return r=>{let o=this.targets.get(t);if(!o)return;let n=this.onFrame(o,r);!o.stopped&&!n?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){let r=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,r)}cancelFrame(t){if(this.rafIds.has(t)){let r=this.rafIds.get(t);cancelAnimationFrame(r)}this.rafIds.delete(t)}onFrame(t,r){return t.callback(r)??!1}};f();z();G();import{LaserPointer as RP}from"@excalidraw/laser-pointer";var Aa=class{constructor(t,r,o){this.animationFrameHandler=t;this.app=r;this.options=o;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Fe,"path")}currentTrail;pastTrails=[];container;trailElement;get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(t,r){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===t&&this.currentTrail.originalPoints[o-1][1]===r}return!1}start(t){t&&(this.container=t),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(t,r){this.currentTrail=new RP(this.options),this.currentTrail.addPoint([t,r,performance.now()]),this.update()}addPointToPath(t,r){this.currentTrail&&(this.currentTrail.addPoint([t,r,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}update(){this.start()}onFrame(){let t=[];for(let o of this.pastTrails)t.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);t.push(o)}this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline().length!==0),t.length===0&&this.stop();let r=t.join(" ").trim();this.trailElement.setAttribute("d",r),this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(t,r){let o=t.getStrokeOutline(t.options.size/r.zoom.value).map(([n,i])=>{let a=Dt({sceneX:n,sceneY:i},r);return[a.x,a.y]});return xx(o,!0)}};f();z();G();var vu=class{constructor(t,r){this.animationFrameHandler=t;this.app=r;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Aa(t,r,{...this.getTrailOptions(),fill:()=>Du})}localTrail;collabTrails=new Map;container;getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(hn(i),hn(n))}}}startPath(t,r){this.localTrail.startPath(t,r)}addPointToPath(t,r){this.localTrail.addPointToPath(t,r)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[t,r]of this.app.state.collaborators.entries()){let o;this.collabTrails.has(t)?o=this.collabTrails.get(t):(o=new Aa(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>r.pointer?.laserColor||Ia(t,r)}),o.start(this.container),this.collabTrails.set(t,o)),r.pointer&&r.pointer.tool==="laser"&&(r.button==="down"&&!o.hasCurrentTrail&&o.startPath(r.pointer.x,r.pointer.y),r.button==="down"&&o.hasCurrentTrail&&!o.hasLastPoint(r.pointer.x,r.pointer.y)&&o.addPointToPath(r.pointer.x,r.pointer.y),r.button==="up"&&o.hasCurrentTrail&&(o.addPointToPath(r.pointer.x,r.pointer.y),o.endPath()))}for(let t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}};bn();am();f();ue();z();Jn();ce();G();We();ut();Qt();ui();Ld();var NP=(e,t,r,o,n,i)=>{let{zoom:a}=o,l=180*r/Math.PI,s=e*(a.value-1)/2,c=t*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),t>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},W5=({id:e,onChange:t,onSubmit:r,getViewportCoords:o,element:n,canvas:i,excalidrawContainer:a,app:l})=>{let s=(k,O)=>{if(!O.style.fontFamily||!O.style.fontSize)return!1;let X=O.style.fontFamily.replace(/"/g,"");return Ha({fontFamily:k.fontFamily})!==X||`${k.fontSize}px`!==O.style.fontSize},c=()=>{let k=l.state,O=pt.getScene(n)?.getElement(e);if(!O)return;let{textAlign:X,verticalAlign:Y}=O,ee=l.scene.getNonDeletedElementsMap();if(O&&U(O)){let xe=O.x,le=O.y,V=lt(O,l.scene.getNonDeletedElementsMap()),ve=O.width,Re=O.height,dt=O.width,Le=O.height;if(V&&O.containerId){if(Te(V)){let kt=K.getBoundTextElementPosition(V,O,ee);xe=kt.x,le=kt.y}let Kr=s(O,d),cn;if(Kr?cn=ea(V.id,V.height):(cn=Qi[V.id],cn||(cn=ea(V.id,V.height))),ve=fr(V,O),Re=ta(V,O),!Te(V)&&Le>Re){let kt=yn(Le,V.type);F(V,{height:kt});return}else if(!Te(V)&&V.height>cn.height&&Le<Re){let kt=yn(Le,V.type);F(V,{height:kt})}else{let{y:kt}=tl(V,O,ee);le=kt}}let[ur,ln]=o(xe,le),Gt=d.selectionStart,Do=d.selectionEnd,sn=d.value.length;if(Gt===Do&&Do!==sn){let Kr=sn-Do;d.selectionStart=d.value.length-Kr,d.selectionEnd=d.value.length-Kr}V||(ve=(k.width-8-ur)/k.zoom.value,dt=Math.min(dt,ve));let Ni=(k.height-ln)/k.zoom.value;Object.assign(d.style,{font:Ge(O),lineHeight:O.lineHeight,width:`${dt}px`,height:`${Le}px`,left:`${ur}px`,top:`${ln}px`,transform:NP(dt,Le,v0(O,V),k,ve,Ni),textAlign:X,verticalAlign:Y,color:O.strokeColor,opacity:O.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Ni}px`}),d.scrollTop=0,Ar()&&(d.style.fontFamily=Ha(O)),F(O,{x:xe,y:le})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let m="pre",p="normal";Ne(n)&&(m="pre-wrap",p="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:p,whiteSpace:m,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,c(),t&&(d.onpaste=async k=>{let O=await Em(k,!0);if(!O.text)return;let X=ni(O.text);if(!X)return;let Y=lt(n,l.scene.getNonDeletedElementsMap()),ee=Ge({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Y){let xe=pe(Y,l.scene.getNonDeletedElementsMap()),le=ai(`${d.value}${X}`,ee,fr(Y,xe)),V=Os(le,ee);d.style.width=`${V}px`}},d.oninput=()=>{t(ni(d.value))}),d.onkeydown=k=>{if(!k.shiftKey&&op.keyTest(k))k.preventDefault(),l.actionManager.executeAction(op),c();else if(!k.shiftKey&&np.keyTest(k))k.preventDefault(),l.actionManager.executeAction(np),c();else if(ff.keyTest(k))l.actionManager.executeAction(ff);else if(bf.keyTest(k))l.actionManager.executeAction(bf);else if(k.key===S.ESCAPE)k.preventDefault(),I=!0,P();else if(k.key===S.ENTER&&k[S.CTRL_OR_CMD]){if(k.preventDefault(),k.isComposing||k.keyCode===229)return;I=!0,P()}else if(k.key===S.TAB||k[S.CTRL_OR_CMD]&&(k.code===he.BRACKET_LEFT||k.code===he.BRACKET_RIGHT)){if(k.preventDefault(),k.isComposing)return;k.shiftKey||k.code===he.BRACKET_LEFT?v():E(),d.dispatchEvent(new Event("input"))}};let u=4,h=" ".repeat(u),x=new RegExp(`^ {1,${u}}`),E=()=>{let{selectionStart:k,selectionEnd:O}=d,X=w(),Y=d.value;X.forEach(ee=>{let xe=Y.slice(0,ee),le=Y.slice(ee);Y=`${xe}${h}${le}`}),d.value=Y,d.selectionStart=k+u,d.selectionEnd=O+u*X.length},v=()=>{let{selectionStart:k,selectionEnd:O}=d,X=w(),Y=[],ee=d.value;X.forEach(xe=>{let le=ee.slice(xe,xe+u).match(x);if(le){let V=ee.slice(0,xe),ve=ee.slice(xe+le[0].length);ee=`${V}${ve}`,Y.push(xe)}}),d.value=ee,Y.length&&(k>Y[Y.length-1]?d.selectionStart=Math.max(k-u,Y[Y.length-1]):d.selectionStart=k,d.selectionEnd=Math.max(d.selectionStart,O-u*Y.length))},w=()=>{let{selectionStart:k,selectionEnd:O,value:X}=d,Y=X.slice(0,k).match(/[^\n]*$/)[0].length;return k=k-Y,X.slice(k,O).split(`
86
- `).reduce((xe,le,V,ve)=>xe.concat(V?xe[V-1]+ve[V-1].length+1:k),[]).reverse()},y=k=>{k.preventDefault(),k.stopPropagation()},I=!1,P=()=>{C();let k=pt.getScene(n)?.getElement(n.id);if(!k)return;let O=d.value,X=lt(k,l.scene.getNonDeletedElementsMap());if(X){if(O=k.text,d.value.trim()){let Y=wn(X);!Y||Y!==n.id?F(X,{boundElements:(X.boundElements||[]).concat({type:"text",id:n.id})}):Te(X)&&li(X)}else F(X,{boundElements:X.boundElements?.filter(Y=>!U(Y))});Yt(k,X,l.scene.getNonDeletedElementsMap())}r({text:O,viaKeyboard:I,originalText:d.value})},C=()=>{A||(A=!0,d.onblur=null,d.oninput=null,d.onkeydown=null,M&&M.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("wheel",y,!0),window.removeEventListener("pointerdown",D),window.removeEventListener("pointerup",_),window.removeEventListener("blur",P),window.removeEventListener("beforeunload",P),H(),d.remove())},_=k=>{window.removeEventListener("pointerup",_);let O=k?.target,X=O instanceof HTMLElement&&O.classList.contains("active-color");setTimeout(()=>{if(d.onblur=P,X){let Y=(xe,le)=>{xe.find(ve=>ve.removedNodes.length>0&&ve.removedNodes[0].dataset?.radixPopperContentWrapper!==void 0)&&(setTimeout(()=>{d.focus()}),le.disconnect())};new MutationObserver(Y).observe(document.querySelector(".excalidraw-container"),{childList:!0})}X||d.focus()})},D=k=>{let O=k.target instanceof HTMLElement&&k.target.classList.contains("active-color");((k.target instanceof HTMLElement||k.target instanceof SVGElement)&&k.target.closest(`.${qc.SHAPE_ACTIONS_MENU}`)&&!Xr(k.target)||O)&&(d.onblur=null,window.addEventListener("pointerup",_),window.addEventListener("blur",P))},H=pt.getScene(n).addCallback(()=>{c(),!!document.activeElement?.closest(".color-picker-content")||d.focus()}),A=!1;d.select(),_();let M=null;i&&"ResizeObserver"in window?(M=new window.ResizeObserver(()=>{c()}),M.observe(i)):window.addEventListener("resize",c),window.addEventListener("pointerdown",D),window.addEventListener("wheel",y,{passive:!1,capture:!0}),window.addEventListener("beforeunload",P),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d)};wo();sm();import{Fragment as zP,jsx as Ke,jsxs as Su}from"react/jsx-runtime";var $5=an.createContext(null),X5=an.createContext(null),Z5={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},ib=an.createContext(Z5);ib.displayName="DeviceContext";var ab=an.createContext({container:null,id:null});ab.displayName="ExcalidrawContainerContext";var lb=an.createContext([]);lb.displayName="ExcalidrawElementsContext";var sb=an.createContext({...ar(),width:0,height:0,offsetLeft:0,offsetTop:0});sb.displayName="ExcalidrawAppStateContext";var cb=an.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});cb.displayName="ExcalidrawSetAppStateContext";var db=an.createContext(null);db.displayName="ExcalidrawActionManagerContext";var wr=()=>Di($5),yi=()=>Di(X5),Ie=()=>Di(ib),Bt=()=>Di(ab),bi=()=>Di(lb),Gl=()=>Di(sb),_e=()=>Di(cb),_t=()=>Di(db),Fc=!1,eb=0,Ma=!1,Hc=!1,tb=!1,rb={horizontal:null,vertical:null},_i=0,zc=!1,ob=new Map,Tu=!1,Y5=0,K5=!1,Gc=null,De={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},nb=class e extends an.Component{canvas;interactiveCanvas=null;rc;unmounted=!1;actionManager;device=Z5;excalidrawContainerRef=an.createRef();scene;renderer;fonts;resizeObserver;nearestScrollableContainer;library;libraryItemsFromStorage;id;history;excalidrawContainerValue;files={};imageCache=new Map;iFrameRefs=new Map;embedsValidationStatus=new Map;initializedEmbeds=new Set;elementsPendingErasure=new Set;hitLinkElement;lastPointerDownEvent=null;lastPointerUpEvent=null;lastPointerMoveEvent=null;lastViewportPosition={x:0,y:0};animationFrameHandler=new wu;laserTrails=new vu(this.animationFrameHandler,this);eraserTrail=new Aa(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/200),i=(10-Math.min(10,t.totalLength-t.currentIndex))/10;return Math.min(hn(i),hn(n))},fill:()=>this.state.theme===oe.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});onChangeEmitter=new lo;onPointerDownEmitter=new lo;onPointerUpEmitter=new lo;onUserFollowEmitter=new lo;onScrollChangeEmitter=new lo;missingPointerEventCleanupEmitter=new lo;onRemoveEventListenersEmitter=new lo;constructor(t){super(t);let r=ar(),{excalidrawAPI:o,viewModeEnabled:n=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:l=!1,theme:s=r.theme,name:c=`${b("labels.untitled")}-${Hu()}`}=t;if(this.state={...r,theme:s,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:n,zenModeEnabled:i,objectsSnapModeEnabled:l,gridSize:a?un:null,name:c,width:window.innerWidth,height:window.innerHeight},this.id=BP(),this.library=new Nv(this),this.actionManager=new Gp(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new pt,this.canvas=document.createElement("canvas"),this.rc=OP.canvas(this.canvas),this.renderer=new Bc(this.scene),o){let d={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:m=>{this.actionManager.registerAction(m)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:m=>this.onChangeEmitter.on(m),onPointerDown:m=>this.onPointerDownEmitter.on(m),onPointerUp:m=>this.onPointerUpEmitter.on(m),onScrollChange:m=>this.onScrollChangeEmitter.on(m),onUserFollow:m=>this.onUserFollowEmitter.on(m)};typeof o=="function"?o(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new uu({scene:this.scene,onSceneUpdated:this.onSceneUpdated}),this.history=new P3,this.actionManager.registerAll(Ud),this.actionManager.registerAction(k3(this.history)),this.actionManager.registerAction(A3(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let o=null,n=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!n)break;for(let i of n)i.contentWindow===t.source&&(o=i.contentWindow);o?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let o=r.id,n=r.info.playerState;Object.values(as).includes(n)&&ob.set(o,n)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},draggingElement:null,selectionElement:null})},100),jr(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let o=ob.get(t.id);switch(o||(ob.set(t.id,as.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),o){case as.PLAYING:case as.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,o,n){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&o>=t.x+t.width/3&&o<=t.x+2*t.width/3&&n>=t.y+t.height/3&&n<=t.y+2*t.height/3}updateEmbedValidationStatus=(t,r)=>{this.embedsValidationStatus.set(t.id,r),ke.delete(t)};updateEmbeddables=()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(o=>{if(vt(o)){if(t.add(o.id),!this.embedsValidationStatus.has(o.id)){r=!0;let n=il(o.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(o,n)}}else jr(o)&&t.add(o.id);return!1}),r&&this.scene.informMutation(),this.iFrameRefs.forEach((o,n)=>{t.has(n)||this.iFrameRefs.delete(n)})};renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,o=this.state.height,n=this.scene.getNonDeletedElements().filter(i=>vt(i)&&this.embedsValidationStatus.get(i.id)===!0||jr(i));return Ke(zP,{children:n.map(i=>{let{x:a,y:l}=Dt({sceneX:i.x,sceneY:i.y},this.state),s=ma(i,r,o,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(i.id);if(s&&!c&&this.initializedEmbeds.add(i.id),!(s||c))return null;let m;if(jr(i)){m=null;let h=(i.customData?.generationData??this.magicGenerations.get(i.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(h.status==="done"){let x=h.html;m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>x}}else if(h.status==="pending")m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>ia(`
85
+ Please output JUST THE HTML file containing your best attempt at implementing the provided wireframes.`;async function U5({image:e,apiKey:t,text:r,theme:o=oe.LIGHT}){let n={model:"gpt-4-vision-preview",max_tokens:4096,temperature:.1,messages:[{role:"system",content:LP},{role:"user",content:[{type:"image_url",image_url:{url:e,detail:"high"}},{type:"text",text:`Above is the reference wireframe. Please make a new website based on these and return just the HTML file. Also, please make it for the ${o} theme. What follows are the wireframe's text annotations (if any)...`},{type:"text",text:r}]}]},i,a=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)});return a.ok?i={...await a.json(),ok:!0}:i={...await a.json(),ok:!1},i}da();Zt();f();import PP from"clsx";import{jsx as W5,jsxs as DP}from"react/jsx-runtime";var _P="small",vu=e=>DP("label",{className:PP("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${_P}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[W5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),W5("div",{className:"ToolIcon__icon",children:e.icon})]});f();import{jsx as Q1,jsxs as V5}from"react/jsx-runtime";var RP=({height:e,width:t,userToFollow:r,onDisconnect:o})=>Q1("div",{className:"follow-mode",style:{width:t,height:e},children:V5("div",{className:"follow-mode__badge",children:[V5("div",{className:"follow-mode__badge__label",children:["Following"," ",Q1("span",{className:"follow-mode__badge__username",title:r.username,children:r.username})]}),Q1("button",{onClick:o,className:"follow-mode__disconnect-btn",children:ro})]})}),Y5=RP;f();var Tu=class{targets=new WeakMap;rafIds=new WeakMap;register(t,r){this.targets.set(t,{callback:r,stopped:!0})}start(t){let r=this.targets.get(t);r&&(this.rafIds.has(t)||(this.targets.set(t,{...r,stopped:!1}),this.scheduleFrame(t)))}stop(t){let r=this.targets.get(t);r&&!r.stopped&&this.targets.set(t,{...r,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return r=>{let o=this.targets.get(t);if(!o)return;let n=this.onFrame(o,r);!o.stopped&&!n?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){let r=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,r)}cancelFrame(t){if(this.rafIds.has(t)){let r=this.rafIds.get(t);cancelAnimationFrame(r)}this.rafIds.delete(t)}onFrame(t,r){return t.callback(r)??!1}};f();z();U();import{LaserPointer as NP}from"@excalidraw/laser-pointer";var Aa=class{constructor(t,r,o){this.animationFrameHandler=t;this.app=r;this.options=o;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Fe,"path")}currentTrail;pastTrails=[];container;trailElement;get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(t,r){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===t&&this.currentTrail.originalPoints[o-1][1]===r}return!1}start(t){t&&(this.container=t),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(t,r){this.currentTrail=new NP(this.options),this.currentTrail.addPoint([t,r,performance.now()]),this.update()}addPointToPath(t,r){this.currentTrail&&(this.currentTrail.addPoint([t,r,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}update(){this.start()}onFrame(){let t=[];for(let o of this.pastTrails)t.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);t.push(o)}this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline().length!==0),t.length===0&&this.stop();let r=t.join(" ").trim();this.trailElement.setAttribute("d",r),this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(t,r){let o=t.getStrokeOutline(t.options.size/r.zoom.value).map(([n,i])=>{let a=Dt({sceneX:n,sceneY:i},r);return[a.x,a.y]});return Ex(o,!0)}};f();z();U();var Su=class{constructor(t,r){this.animationFrameHandler=t;this.app=r;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Aa(t,r,{...this.getTrailOptions(),fill:()=>Nu})}localTrail;collabTrails=new Map;container;getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(hn(i),hn(n))}}}startPath(t,r){this.localTrail.startPath(t,r)}addPointToPath(t,r){this.localTrail.addPointToPath(t,r)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[t,r]of this.app.state.collaborators.entries()){let o;this.collabTrails.has(t)?o=this.collabTrails.get(t):(o=new Aa(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>r.pointer?.laserColor||Ia(t,r)}),o.start(this.container),this.collabTrails.set(t,o)),r.pointer&&r.pointer.tool==="laser"&&(r.button==="down"&&!o.hasCurrentTrail&&o.startPath(r.pointer.x,r.pointer.y),r.button==="down"&&o.hasCurrentTrail&&!o.hasLastPoint(r.pointer.x,r.pointer.y)&&o.addPointToPath(r.pointer.x,r.pointer.y),r.button==="up"&&o.hasCurrentTrail&&(o.addPointToPath(r.pointer.x,r.pointer.y),o.endPath()))}for(let t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}};bn();sm();f();ue();z();Jn();ce();U();We();lt();Qt();ui();Ld();var OP=(e,t,r,o,n,i)=>{let{zoom:a}=o,l=180*r/Math.PI,s=e*(a.value-1)/2,c=t*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),t>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},K5=({id:e,onChange:t,onSubmit:r,getViewportCoords:o,element:n,canvas:i,excalidrawContainer:a,app:l})=>{let s=(k,O)=>{if(!O.style.fontFamily||!O.style.fontSize)return!1;let X=O.style.fontFamily.replace(/"/g,"");return Ha({fontFamily:k.fontFamily})!==X||`${k.fontSize}px`!==O.style.fontSize},c=()=>{let k=l.state,O=ut.getScene(n)?.getElement(e);if(!O)return;let{textAlign:X,verticalAlign:Y}=O,ee=l.scene.getNonDeletedElementsMap();if(O&&G(O)){let xe=O.x,le=O.y,V=st(O,l.scene.getNonDeletedElementsMap()),ve=O.width,Re=O.height,mt=O.width,Le=O.height;if(V&&O.containerId){if(Te(V)){let kt=K.getBoundTextElementPosition(V,O,ee);xe=kt.x,le=kt.y}let Kr=s(O,d),cn;if(Kr?cn=ea(V.id,V.height):(cn=Qi[V.id],cn||(cn=ea(V.id,V.height))),ve=fr(V,O),Re=ta(V,O),!Te(V)&&Le>Re){let kt=yn(Le,V.type);F(V,{height:kt});return}else if(!Te(V)&&V.height>cn.height&&Le<Re){let kt=yn(Le,V.type);F(V,{height:kt})}else{let{y:kt}=rl(V,O,ee);le=kt}}let[ur,ln]=o(xe,le),Gt=d.selectionStart,Do=d.selectionEnd,sn=d.value.length;if(Gt===Do&&Do!==sn){let Kr=sn-Do;d.selectionStart=d.value.length-Kr,d.selectionEnd=d.value.length-Kr}V||(ve=(k.width-8-ur)/k.zoom.value,mt=Math.min(mt,ve));let Ni=(k.height-ln)/k.zoom.value;Object.assign(d.style,{font:Ge(O),lineHeight:O.lineHeight,width:`${mt}px`,height:`${Le}px`,left:`${ur}px`,top:`${ln}px`,transform:OP(mt,Le,T0(O,V),k,ve,Ni),textAlign:X,verticalAlign:Y,color:O.strokeColor,opacity:O.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Ni}px`}),d.scrollTop=0,Ar()&&(d.style.fontFamily=Ha(O)),F(O,{x:xe,y:le})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let m="pre",p="normal";Ne(n)&&(m="pre-wrap",p="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:p,whiteSpace:m,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,c(),t&&(d.onpaste=async k=>{let O=await wm(k,!0);if(!O.text)return;let X=ni(O.text);if(!X)return;let Y=st(n,l.scene.getNonDeletedElementsMap()),ee=Ge({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Y){let xe=de(Y,l.scene.getNonDeletedElementsMap()),le=ai(`${d.value}${X}`,ee,fr(Y,xe)),V=Os(le,ee);d.style.width=`${V}px`}},d.oninput=()=>{t(ni(d.value))}),d.onkeydown=k=>{if(!k.shiftKey&&ip.keyTest(k))k.preventDefault(),l.actionManager.executeAction(ip),c();else if(!k.shiftKey&&ap.keyTest(k))k.preventDefault(),l.actionManager.executeAction(ap),c();else if(bf.keyTest(k))l.actionManager.executeAction(bf);else if(xf.keyTest(k))l.actionManager.executeAction(xf);else if(k.key===S.ESCAPE)k.preventDefault(),I=!0,P();else if(k.key===S.ENTER&&k[S.CTRL_OR_CMD]){if(k.preventDefault(),k.isComposing||k.keyCode===229)return;I=!0,P()}else if(k.key===S.TAB||k[S.CTRL_OR_CMD]&&(k.code===he.BRACKET_LEFT||k.code===he.BRACKET_RIGHT)){if(k.preventDefault(),k.isComposing)return;k.shiftKey||k.code===he.BRACKET_LEFT?v():E(),d.dispatchEvent(new Event("input"))}};let u=4,h=" ".repeat(u),x=new RegExp(`^ {1,${u}}`),E=()=>{let{selectionStart:k,selectionEnd:O}=d,X=w(),Y=d.value;X.forEach(ee=>{let xe=Y.slice(0,ee),le=Y.slice(ee);Y=`${xe}${h}${le}`}),d.value=Y,d.selectionStart=k+u,d.selectionEnd=O+u*X.length},v=()=>{let{selectionStart:k,selectionEnd:O}=d,X=w(),Y=[],ee=d.value;X.forEach(xe=>{let le=ee.slice(xe,xe+u).match(x);if(le){let V=ee.slice(0,xe),ve=ee.slice(xe+le[0].length);ee=`${V}${ve}`,Y.push(xe)}}),d.value=ee,Y.length&&(k>Y[Y.length-1]?d.selectionStart=Math.max(k-u,Y[Y.length-1]):d.selectionStart=k,d.selectionEnd=Math.max(d.selectionStart,O-u*Y.length))},w=()=>{let{selectionStart:k,selectionEnd:O,value:X}=d,Y=X.slice(0,k).match(/[^\n]*$/)[0].length;return k=k-Y,X.slice(k,O).split(`
86
+ `).reduce((xe,le,V,ve)=>xe.concat(V?xe[V-1]+ve[V-1].length+1:k),[]).reverse()},y=k=>{k.preventDefault(),k.stopPropagation()},I=!1,P=()=>{C();let k=ut.getScene(n)?.getElement(n.id);if(!k)return;let O=d.value,X=st(k,l.scene.getNonDeletedElementsMap());if(X){if(O=k.text,d.value.trim()){let Y=wn(X);!Y||Y!==n.id?F(X,{boundElements:(X.boundElements||[]).concat({type:"text",id:n.id})}):Te(X)&&li(X)}else F(X,{boundElements:X.boundElements?.filter(Y=>!G(Y))});Yt(k,X,l.scene.getNonDeletedElementsMap())}r({text:O,viaKeyboard:I,originalText:d.value})},C=()=>{A||(A=!0,d.onblur=null,d.oninput=null,d.onkeydown=null,M&&M.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("wheel",y,!0),window.removeEventListener("pointerdown",D),window.removeEventListener("pointerup",_),window.removeEventListener("blur",P),window.removeEventListener("beforeunload",P),H(),d.remove())},_=k=>{window.removeEventListener("pointerup",_);let O=k?.target,X=O instanceof HTMLElement&&O.classList.contains("active-color");setTimeout(()=>{if(d.onblur=P,X){let Y=(xe,le)=>{xe.find(ve=>ve.removedNodes.length>0&&ve.removedNodes[0].dataset?.radixPopperContentWrapper!==void 0)&&(setTimeout(()=>{d.focus()}),le.disconnect())};new MutationObserver(Y).observe(document.querySelector(".excalidraw-container"),{childList:!0})}X||d.focus()})},D=k=>{let O=k.target instanceof HTMLElement&&k.target.classList.contains("active-color");((k.target instanceof HTMLElement||k.target instanceof SVGElement)&&k.target.closest(`.${qc.SHAPE_ACTIONS_MENU}`)&&!Xr(k.target)||O)&&(d.onblur=null,window.addEventListener("pointerup",_),window.addEventListener("blur",P))},H=ut.getScene(n).addCallback(()=>{c(),!!document.activeElement?.closest(".color-picker-content")||d.focus()}),A=!1;d.select(),_();let M=null;i&&"ResizeObserver"in window?(M=new window.ResizeObserver(()=>{c()}),M.observe(i)):window.addEventListener("resize",c),window.addEventListener("pointerdown",D),window.addEventListener("wheel",y,{passive:!1,capture:!0}),window.addEventListener("beforeunload",P),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d)};wo();dm();import{Fragment as GP,jsx as Ke,jsxs as Cu}from"react/jsx-runtime";var j5=an.createContext(null),q5=an.createContext(null),J5={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},ab=an.createContext(J5);ab.displayName="DeviceContext";var lb=an.createContext({container:null,id:null});lb.displayName="ExcalidrawContainerContext";var sb=an.createContext([]);sb.displayName="ExcalidrawElementsContext";var cb=an.createContext({...ar(),width:0,height:0,offsetLeft:0,offsetTop:0});cb.displayName="ExcalidrawAppStateContext";var db=an.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});db.displayName="ExcalidrawSetAppStateContext";var mb=an.createContext(null);mb.displayName="ExcalidrawActionManagerContext";var wr=()=>Di(j5),yi=()=>Di(q5),Ie=()=>Di(ab),Bt=()=>Di(lb),bi=()=>Di(sb),Ul=()=>Di(cb),_e=()=>Di(db),_t=()=>Di(mb),Fc=!1,tb=0,Ma=!1,Hc=!1,rb=!1,ob={horizontal:null,vertical:null},_i=0,zc=!1,nb=new Map,Iu=!1,X5=0,Z5=!1,Gc=null,De={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},ib=class e extends an.Component{canvas;interactiveCanvas=null;rc;unmounted=!1;actionManager;device=J5;excalidrawContainerRef=an.createRef();scene;renderer;fonts;resizeObserver;nearestScrollableContainer;library;libraryItemsFromStorage;id;history;excalidrawContainerValue;files={};imageCache=new Map;iFrameRefs=new Map;embedsValidationStatus=new Map;initializedEmbeds=new Set;elementsPendingErasure=new Set;hitLinkElement;lastPointerDownEvent=null;lastPointerUpEvent=null;lastPointerMoveEvent=null;lastViewportPosition={x:0,y:0};animationFrameHandler=new Tu;laserTrails=new Su(this.animationFrameHandler,this);eraserTrail=new Aa(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/200),i=(10-Math.min(10,t.totalLength-t.currentIndex))/10;return Math.min(hn(i),hn(n))},fill:()=>this.state.theme===oe.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});onChangeEmitter=new lo;onPointerDownEmitter=new lo;onPointerUpEmitter=new lo;onUserFollowEmitter=new lo;onScrollChangeEmitter=new lo;missingPointerEventCleanupEmitter=new lo;onRemoveEventListenersEmitter=new lo;constructor(t){super(t);let r=ar(),{excalidrawAPI:o,viewModeEnabled:n=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:l=!1,theme:s=r.theme,name:c=`${b("labels.untitled")}-${Gu()}`}=t;if(this.state={...r,theme:s,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:n,zenModeEnabled:i,objectsSnapModeEnabled:l,gridSize:a?un:null,name:c,width:window.innerWidth,height:window.innerHeight},this.id=FP(),this.library=new Fv(this),this.actionManager=new Wp(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new ut,this.canvas=document.createElement("canvas"),this.rc=BP.canvas(this.canvas),this.renderer=new Bc(this.scene),o){let d={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:m=>{this.actionManager.registerAction(m)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:m=>this.onChangeEmitter.on(m),onPointerDown:m=>this.onPointerDownEmitter.on(m),onPointerUp:m=>this.onPointerUpEmitter.on(m),onScrollChange:m=>this.onScrollChangeEmitter.on(m),onUserFollow:m=>this.onUserFollowEmitter.on(m)};typeof o=="function"?o(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new gu({scene:this.scene,onSceneUpdated:this.onSceneUpdated}),this.history=new R3,this.actionManager.registerAll(Wd),this.actionManager.registerAction(L3(this.history)),this.actionManager.registerAction(P3(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let o=null,n=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!n)break;for(let i of n)i.contentWindow===t.source&&(o=i.contentWindow);o?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let o=r.id,n=r.info.playerState;Object.values(ls).includes(n)&&nb.set(o,n)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},draggingElement:null,selectionElement:null})},100),jr(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let o=nb.get(t.id);switch(o||(nb.set(t.id,ls.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),o){case ls.PLAYING:case ls.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,o,n){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&o>=t.x+t.width/3&&o<=t.x+2*t.width/3&&n>=t.y+t.height/3&&n<=t.y+2*t.height/3}updateEmbedValidationStatus=(t,r)=>{this.embedsValidationStatus.set(t.id,r),ke.delete(t)};updateEmbeddables=()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(o=>{if(vt(o)){if(t.add(o.id),!this.embedsValidationStatus.has(o.id)){r=!0;let n=il(o.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(o,n)}}else jr(o)&&t.add(o.id);return!1}),r&&this.scene.informMutation(),this.iFrameRefs.forEach((o,n)=>{t.has(n)||this.iFrameRefs.delete(n)})};renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,o=this.state.height,n=this.scene.getNonDeletedElements().filter(i=>vt(i)&&this.embedsValidationStatus.get(i.id)===!0||jr(i));return Ke(GP,{children:n.map(i=>{let{x:a,y:l}=Dt({sceneX:i.x,sceneY:i.y},this.state),s=ma(i,r,o,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(i.id);if(s&&!c&&this.initializedEmbeds.add(i.id),!(s||c))return null;let m;if(jr(i)){m=null;let h=(i.customData?.generationData??this.magicGenerations.get(i.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(h.status==="done"){let x=h.html;m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>x}}else if(h.status==="pending")m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>zs(`
87
87
  <style>
88
88
  html, body {
89
89
  width: 100%;
@@ -155,7 +155,7 @@ Please output JUST THE HTML file containing your best attempt at implementing th
155
155
  </svg>
156
156
  </div>
157
157
  <div>Generating...</div>
158
- `)};else{let x;h.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=h.message||"Generation failed",m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>ia(`
158
+ `)};else{let x;h.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=h.message||"Generation failed",m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>zs(`
159
159
  <style>
160
160
  html, body {
161
161
  height: 100%;
@@ -174,9 +174,9 @@ Please output JUST THE HTML file containing your best attempt at implementing th
174
174
  </style>
175
175
  <h1>Error!</h1>
176
176
  <h3>${x}</h3>
177
- `)}}}else m=kn(Gd(i.link||""));let p=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="active",u=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="hover";return Ke("div",{className:V5("excalidraw__embeddable-container",{"is-hovered":u}),style:{transform:s?`translate(${a-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t})`:"none",display:s?"block":"none",opacity:dg(i,Ot(i,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure),"--embeddable-radius":`${vo(Math.min(i.width,i.height),i)}px`},children:Su("div",{className:"excalidraw__embeddable-container__inner",style:{width:s?`${i.width}px`:0,height:s?`${i.height}px`:0,transform:s?`rotate(${i.angle}rad)`:"none",pointerEvents:p?Fi.enabled:Fi.disabled},children:[u&&Ke("div",{className:"excalidraw__embeddable-hint",children:b("buttons.embeddableInteractionButton")}),Ke("div",{className:"excalidraw__embeddable__outer",style:{padding:`${i.strokeWidth}px`},children:(vt(i)?this.props.renderEmbeddable?.(i,this.state):null)??Ke("iframe",{ref:h=>this.cacheEmbeddableRef(i,h),className:"excalidraw__embeddable",srcDoc:m?.type==="document"?m.srcdoc(this.state.theme):void 0,src:m?.type!=="document"?m?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:"allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads"})})]})},i.id)})})}getFrameNameDOMId=t=>`${this.id}-frame-name-${t.id}`;frameNameBoundsCache={get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let o=document.getElementById(this.getFrameNameDOMId(t));if(o){let n=o.getBoundingClientRect(),i=Ue({clientX:n.x,clientY:n.y},this.state),a=Ue({clientX:n.right,clientY:n.bottom},this.state);return r={x:i.x,y:i.y,width:a.x-i.x,height:a.y-i.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map};renderFrameNames=()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return null;let t=this.state.theme===oe.DARK,r=0,o=0;return this.scene.getNonDeletedFramesLikes().map(n=>{if(jn(n)?r++:o++,!ma(n,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return null;let{x:i,y:a}=Dt({sceneX:n.x,sceneY:n.y},this.state),l=6,s=()=>{F(n,{name:n.name?.trim()||null}),this.setState({editingFrame:null})},c,d=gm(n,jn(n)?r:o);if(n.id===this.state.editingFrame){let m=d;c=Ke("input",{autoFocus:!0,value:m,onChange:p=>{F(n,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>s(),onKeyDown:p=>{(p.key===S.ESCAPE||p.key===S.ENTER)&&s()},style:{background:this.state.viewBackgroundColor,filter:t?Oa:"none",zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${l}px, ${l}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-i-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Ke("div",{id:this.getFrameNameDOMId(n),style:{position:"absolute",bottom:`${this.state.height+$e.nameOffsetY-a+this.state.offsetTop}px`,left:`${i-this.state.offsetLeft}px`,zIndex:2,fontSize:$e.nameFontSize,color:t?$e.nameColorDarkTheme:$e.nameColorLightTheme,lineHeight:$e.nameLineHeight,width:"max-content",maxWidth:`${n.width}px`,overflow:n.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Ce.MOVE,pointerEvents:this.state.viewModeEnabled?Fi.disabled:Fi.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:n.id})},children:c},n.id)})};toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:o}=this.props,n=this.scene.getVersionNonce(),{elementsMap:i,visibleElements:a}=this.renderer.getRenderableElements({versionNonce:n,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingElement:this.state.editingElement,pendingImageElementId:this.state.pendingImageElementId}),l=this.scene.getNonDeletedElementsMap(),s=!(this.state.editingElement&&re(this.state.editingElement))&&(this.state.selectionElement||this.state.draggingElement||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down"||this.state.editingElement&&!U(this.state.editingElement)),c=t[0];return Ke("div",{className:V5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":s?Fi.disabled:Fi.enabled},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:Ke($5.Provider,{value:this,children:Ke(X5.Provider,{value:this.props,children:Ke(ab.Provider,{value:this.excalidrawContainerValue,children:Ke(ib.Provider,{value:this.device,children:Ke(cb.Provider,{value:this.setAppState,children:Ke(sb.Provider,{value:this.state,children:Su(lb.Provider,{value:this.scene.getNonDeletedElements(),children:[Su(db.Provider,{value:this.actionManager,children:[Ke(i5,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:dn().code,renderTopRightUI:r,renderCustomStats:o,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,openAIKey:this.OPENAI_KEY,isOpenAIKeyPersisted:this.OPENAI_KEY_IS_PERSISTED,onOpenAIAPIKeyChange:this.onOpenAIKeyChange,onMagicSettingsConfirm:this.onMagicSettingsConfirm,children:this.props.children}),Ke("div",{className:"excalidraw-textEditorContainer"}),Ke("div",{className:"excalidraw-contextMenuContainer"}),Ke("div",{className:"excalidraw-eye-dropper-container"}),Ke(F5,{trails:[this.laserTrails,this.eraserTrail]}),t.length===1&&this.state.showHyperlinkPopup&&Ke(Ev,{element:c,elementsMap:l,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&Vi(c)&&Ke(q1,{element:c,elementsMap:i,children:Ke(yu,{title:b("labels.convertToCode"),icon:Al,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&jr(c)&&c.customData?.generationData?.status==="done"&&Su(q1,{element:c,elementsMap:i,children:[Ke(yu,{title:b("labels.copySource"),icon:Vm,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),Ke(yu,{title:"Enter fullscreen",icon:V2,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(c);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},draggingElement:null,selectionElement:null})}catch(m){console.warn(m),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&Ke(l5,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&Ke(_3,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:d=>{this.setState({contextMenu:null},()=>{this.focusContainer(),d?.()})}}),Ke(j1,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:l,visibleElements:a,versionNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!0,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure}}),Ke(Z1,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,selectedElements:t,versionNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&Ke(U5,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}focusContainer=()=>{this.excalidrawContainerRef.current?.focus()};getSceneElementsIncludingDeleted=()=>this.scene.getElementsIncludingDeleted();getSceneElements=()=>this.scene.getNonDeletedElements();onInsertElements=t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})};onExportImage=async(t,r,o)=>{fe("export",t,"ui");let n=await va(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:o.exportingFrame}).catch(dd).catch(i=>{console.error(i),this.setState({errorMessage:i.message})});this.state.exportEmbedScene&&n&&ml(n)&&this.setState({fileHandle:n})};magicGenerations=new Map;updateMagicGeneration=({frameElement:t,data:r})=>{r.status==="pending"?F(t,{customData:{generationData:void 0}},!1):F(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.onSceneUpdated()};getTextFromElements(t){return t.reduce((o,n)=>(U(n)&&o.push(n.text),o),[]).join(`
177
+ `)}}}else m=kn(Ud(i.link||""));let p=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="active",u=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="hover";return Ke("div",{className:$5("excalidraw__embeddable-container",{"is-hovered":u}),style:{transform:s?`translate(${a-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t})`:"none",display:s?"block":"none",opacity:mg(i,Ot(i,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure),"--embeddable-radius":`${vo(Math.min(i.width,i.height),i)}px`},children:Cu("div",{className:"excalidraw__embeddable-container__inner",style:{width:s?`${i.width}px`:0,height:s?`${i.height}px`:0,transform:s?`rotate(${i.angle}rad)`:"none",pointerEvents:p?Fi.enabled:Fi.disabled},children:[u&&Ke("div",{className:"excalidraw__embeddable-hint",children:b("buttons.embeddableInteractionButton")}),Ke("div",{className:"excalidraw__embeddable__outer",style:{padding:`${i.strokeWidth}px`},children:(vt(i)?this.props.renderEmbeddable?.(i,this.state):null)??Ke("iframe",{ref:h=>this.cacheEmbeddableRef(i,h),className:"excalidraw__embeddable",srcDoc:m?.type==="document"?m.srcdoc(this.state.theme):void 0,src:m?.type!=="document"?m?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${m?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},i.id)})})}getFrameNameDOMId=t=>`${this.id}-frame-name-${t.id}`;frameNameBoundsCache={get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let o=document.getElementById(this.getFrameNameDOMId(t));if(o){let n=o.getBoundingClientRect(),i=Ue({clientX:n.x,clientY:n.y},this.state),a=Ue({clientX:n.right,clientY:n.bottom},this.state);return r={x:i.x,y:i.y,width:a.x-i.x,height:a.y-i.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map};renderFrameNames=()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return null;let t=this.state.theme===oe.DARK,r=0,o=0;return this.scene.getNonDeletedFramesLikes().map(n=>{if(jn(n)?r++:o++,!ma(n,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return null;let{x:i,y:a}=Dt({sceneX:n.x,sceneY:n.y},this.state),l=6,s=()=>{F(n,{name:n.name?.trim()||null}),this.setState({editingFrame:null})},c,d=bm(n,jn(n)?r:o);if(n.id===this.state.editingFrame){let m=d;c=Ke("input",{autoFocus:!0,value:m,onChange:p=>{F(n,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>s(),onKeyDown:p=>{(p.key===S.ESCAPE||p.key===S.ENTER)&&s()},style:{background:this.state.viewBackgroundColor,filter:t?Oa:"none",zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${l}px, ${l}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-i-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Ke("div",{id:this.getFrameNameDOMId(n),style:{position:"absolute",bottom:`${this.state.height+$e.nameOffsetY-a+this.state.offsetTop}px`,left:`${i-this.state.offsetLeft}px`,zIndex:2,fontSize:$e.nameFontSize,color:t?$e.nameColorDarkTheme:$e.nameColorLightTheme,lineHeight:$e.nameLineHeight,width:"max-content",maxWidth:`${n.width}px`,overflow:n.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Ce.MOVE,pointerEvents:this.state.viewModeEnabled?Fi.disabled:Fi.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:n.id})},children:c},n.id)})};toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:o}=this.props,n=this.scene.getVersionNonce(),{elementsMap:i,visibleElements:a}=this.renderer.getRenderableElements({versionNonce:n,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingElement:this.state.editingElement,pendingImageElementId:this.state.pendingImageElementId}),l=this.scene.getNonDeletedElementsMap(),s=!(this.state.editingElement&&re(this.state.editingElement))&&(this.state.selectionElement||this.state.draggingElement||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down"||this.state.editingElement&&!G(this.state.editingElement)),c=t[0];return Ke("div",{className:$5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":s?Fi.disabled:Fi.enabled},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:Ke(j5.Provider,{value:this,children:Ke(q5.Provider,{value:this.props,children:Ke(lb.Provider,{value:this.excalidrawContainerValue,children:Ke(ab.Provider,{value:this.device,children:Ke(db.Provider,{value:this.setAppState,children:Ke(cb.Provider,{value:this.state,children:Cu(sb.Provider,{value:this.scene.getNonDeletedElements(),children:[Cu(mb.Provider,{value:this.actionManager,children:[Ke(s5,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:dn().code,renderTopRightUI:r,renderCustomStats:o,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,openAIKey:this.OPENAI_KEY,isOpenAIKeyPersisted:this.OPENAI_KEY_IS_PERSISTED,onOpenAIAPIKeyChange:this.onOpenAIKeyChange,onMagicSettingsConfirm:this.onMagicSettingsConfirm,children:this.props.children}),Ke("div",{className:"excalidraw-textEditorContainer"}),Ke("div",{className:"excalidraw-contextMenuContainer"}),Ke("div",{className:"excalidraw-eye-dropper-container"}),Ke(G5,{trails:[this.laserTrails,this.eraserTrail]}),t.length===1&&this.state.showHyperlinkPopup&&Ke(vv,{element:c,elementsMap:l,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&Vi(c)&&Ke(J1,{element:c,elementsMap:i,children:Ke(vu,{title:b("labels.convertToCode"),icon:Ml,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&jr(c)&&c.customData?.generationData?.status==="done"&&Cu(J1,{element:c,elementsMap:i,children:[Ke(vu,{title:b("labels.copySource"),icon:Km,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),Ke(vu,{title:"Enter fullscreen",icon:$2,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(c);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},draggingElement:null,selectionElement:null})}catch(m){console.warn(m),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&Ke(d5,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&Ke(N3,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:d=>{this.setState({contextMenu:null},()=>{this.focusContainer(),d?.()})}}),Ke(q1,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:l,visibleElements:a,versionNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!0,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure}}),Ke(j1,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,selectedElements:t,versionNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&Ke(Y5,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}focusContainer=()=>{this.excalidrawContainerRef.current?.focus()};getSceneElementsIncludingDeleted=()=>this.scene.getElementsIncludingDeleted();getSceneElements=()=>this.scene.getNonDeletedElements();onInsertElements=t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})};onExportImage=async(t,r,o)=>{fe("export",t,"ui");let n=await va(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:o.exportingFrame}).catch(dd).catch(i=>{console.error(i),this.setState({errorMessage:i.message})});this.state.exportEmbedScene&&n&&ml(n)&&this.setState({fileHandle:n})};magicGenerations=new Map;updateMagicGeneration=({frameElement:t,data:r})=>{r.status==="pending"?F(t,{customData:{generationData:void 0}},!1):F(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.onSceneUpdated()};getTextFromElements(t){return t.reduce((o,n)=>(G(n)&&o.push(n.text),o),[]).join(`
178
178
 
179
- `)}async onMagicFrameGenerate(t,r){if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"generation"}}),fe("ai","generate (missing key)","d2c");return}let o=gl(this.scene.getNonDeletedElements(),t).filter(m=>!Vi(m));if(!o.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),fe("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let n=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(!n)return;this.updateMagicGeneration({frameElement:n,data:{status:"pending"}}),this.setState({selectedElementIds:{[n.id]:!0}});let i=await wm({elements:this.scene.getNonDeletedElements(),appState:{...this.state,exportBackground:!0,viewBackgroundColor:this.state.viewBackgroundColor},exportingFrame:t,files:this.files}),a=await Jd(i),l=this.getTextFromElements(o);fe("ai","generate (start)","d2c");let s=await H5({image:a,apiKey:this.OPENAI_KEY,text:l,theme:this.state.theme});if(!s.ok){fe("ai","generate (failed)","d2c"),console.error(s.error),this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:s.error?.message||"Unknown error during generation"}});return}if(fe("ai","generate (success)","d2c"),s.choices[0].message.content==null){this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let c=s.choices[0].message.content,d=c.slice(c.indexOf("<!DOCTYPE html>"),c.indexOf("</html>")+7);this.updateMagicGeneration({frameElement:n,data:{status:"done",html:d}})}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(Dn(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}OPENAI_KEY=Tr.get($r.OAI_API_KEY);OPENAI_KEY_IS_PERSISTED=Tr.has($r.OAI_API_KEY)||!1;onOpenAIKeyChange=(t,r)=>{if(this.OPENAI_KEY=t||null,r){let o=Tr.set($r.OAI_API_KEY,t);this.OPENAI_KEY_IS_PERSISTED=o}else this.OPENAI_KEY_IS_PERSISTED=!1};onMagicSettingsConfirm=(t,r,o)=>{if(this.OPENAI_KEY=t||null,this.onOpenAIKeyChange(this.OPENAI_KEY,r),o==="settings")return;let n=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});t?n.length?this.onMagicframeToolSelect():this.setActiveTool({type:"magicframe"}):Vi(n[0])||this.setActiveTool({type:"magicframe"})};onMagicframeToolSelect=()=>{if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"tool"}}),fe("ai","tool-select (missing key)","d2c");return}let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:bt.magicframe}),fe("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&Vi(t[0])&&t[0];if(!r&&t.some(n=>Q(n)||n.frameId)){this.setActiveTool({type:bt.magicframe});return}fe("ai","tool-select (existing selection)","d2c");let o;if(r)o=r;else{let[n,i,a,l]=we(t),s=50;o=Bs({...$e,x:n-s,y:i-s,width:a-n+s*2,height:l-i+s*2,opacity:100,locked:!1}),this.scene.insertElement(o);for(let c of t)F(c,{frameId:o.id});this.setState({selectedElementIds:{[o.id]:!0}})}this.onMagicFrameGenerate(o,"upstream")}};openEyeDropper=({type:t})=>{Xt.set(fi,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,o)=>{let n=t==="background"&&o.altKey||t==="stroke"&&!o.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?n?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},commitToHistory:!0}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},commitToHistory:!0}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?ne(a,{[n?"strokeColor":"backgroundColor"]:r}):a)})},keepOpenOnAlt:!1})};syncActionResult=nt(t=>{if(this.unmounted||t===!1)return;let r=null;if(t.elements&&(t.elements.forEach(o=>{this.state.editingElement?.id===o.id&&this.state.editingElement!==o&&Es(o)&&(r=o)}),this.scene.replaceAllElements(t.elements),t.commitToHistory&&this.history.resumeRecording()),t.files&&(this.files=t.replaceFiles?t.files:{...this.files,...t.files},this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){t.commitToHistory&&this.history.resumeRecording();let o=t?.appState?.viewModeEnabled||!1,n=t?.appState?.zenModeEnabled||!1,i=t?.appState?.gridSize||null,a=t?.appState?.theme||this.props.theme||oe.LIGHT,l=t?.appState?.name??this.state.name,s=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(o=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(n=this.props.zenModeEnabled),typeof this.props.gridModeEnabled<"u"&&(i=this.props.gridModeEnabled?un:null),r=r||t.appState?.editingElement||null,r?.isDeleted&&(r=null),this.setState(c=>Object.assign(t.appState||{},{contextMenu:null,editingElement:r,viewModeEnabled:o,zenModeEnabled:n,gridSize:i,theme:a,name:l,errorMessage:s}),()=>{t.syncHistory&&this.history.setCurrentState(this.state,this.scene.getElementsIncludingDeleted())})}});onBlur=nt(()=>{Ma=!1,this.setState({isBindingEnabled:!0})});onUnload=()=>{this.onBlur()};disableEvent=t=>{t.preventDefault()};resetHistory=()=>{this.history.clear()};resetScene=nt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...ar(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetHistory()});initializeScene=async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async o=>{if(!o.files.length)return;let n=o.files[0],i=await n.getFile();this.loadFileToCanvas(new File([i],i.name||"",{type:i.type}),n)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(o=>{console.error(o)})}catch(o){console.error(o),t={appState:{errorMessage:o.message||"Encountered an error during importing or restoring scene data"}}}let r=ci(t,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...Yo(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.fonts.loadFontsForElements(r.elements),this.resetHistory(),this.syncActionResult({...r,commitToHistory:!0})};isMobileBreakpoint=(t,r)=>t<Kb||r<Xb&&t<$b;refreshViewportBreakpoints=()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:o}=document.body,n=this.device.viewport,i=Ga(n,{isLandscape:r>o,isMobile:this.isMobileBreakpoint(r,o)});return n!==i?(this.device={...this.device,viewport:i},!0):!1};refreshEditorBreakpoints=()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:o}=t.getBoundingClientRect(),n=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:Zb,i=this.device.editor,a=Ga(i,{isMobile:this.isMobileBreakpoint(r,o),canFitSidebar:r>n});return i!==a?(this.device={...this.device,editor:a},!0):!1};async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,T.MODE===ls.TEST||T.DEV){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...o)=>this.setState(...o)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history}})}this.scene.addCallback(this.onSceneUpdated),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Ar()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),ns&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),Nb()&&!C0()&&this.setState({errorMessage:Ke(T5,{})})}componentWillUnmount(){this.renderer.destroy(),this.scene=new pt,this.renderer=new Bc(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.scene.destroy(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),ke.destroy(),co.destroy(),clearTimeout(_i),ze.clearCache(),Kt.clearCache(),_i=0,document.documentElement.style.overscrollBehaviorX=""}onResize=nt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>ke.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),ns||this.refreshEditorBreakpoints(),this.setState({})});onFullscreenChange=()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})};removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(mt(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(mt(this.excalidrawContainerRef.current,"wheel",this.onWheel,{passive:!1}),mt(window,"message",this.onWindowMessage,!1),mt(document,"pointerup",this.removePointer),mt(document,"copy",this.onCopy),mt(document,"keyup",this.onKeyUp,{passive:!0}),mt(document,"mousemove",this.updateCurrentCursorPosition),mt(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onFontsLoaded(r)}),mt(document,"gesturestart",this.onGestureStart,!1),mt(document,"gesturechange",this.onGestureChange,!1),mt(document,"gestureend",this.onGestureEnd,!1),mt(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null)})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(mt(document,"fullscreenchange",this.onFullscreenChange),mt(document,"paste",this.pasteFromClipboard),mt(document,"cut",this.onCut),mt(window,"resize",this.onResize,!1),mt(window,"unload",this.onUnload,!1),mt(window,"blur",this.onBlur,!1),mt(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),mt(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(mt(dx(this.excalidrawContainerRef.current),"scroll",this.onScroll)))}componentDidUpdate(t,r){this.updateEmbeddables();let o=this.scene.getElementsIncludingDeleted(),n=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!o.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&xr(this.state)&&this.setState({activeTool:Xe(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&Ph(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),xr(r)&&!xr(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),t.gridModeEnabled!==this.props.gridModeEnabled&&this.setState({gridSize:this.props.gridModeEnabled?un:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===oe.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(io)}),this.state.editingElement?.isDeleted&&this.setState({editingElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:a}=r;r.activeTool!==this.state.activeTool&&a!=null&&Uo(this.state)&&Tt(a,!1)&&Ps(a,this.state,bo(K.getPointAtIndexGlobalCoordinates(a,-1,n)),this),this.history.record(this.state,o),this.state.isLoading||(this.props.onChange?.(o,this.state,this.files),this.onChangeEmitter.trigger(o,this.state,this.files))}renderInteractiveSceneCallback=({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:o})=>{r&&(rb=r);let n=U(this.state.editingElement)?!1:!t&&o.size>0;this.state.scrolledOutside!==n&&this.setState({scrolledOutside:n}),this.scheduleImageRefresh()};onScroll=Wi(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(o=>o.offsetLeft===r&&o.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},Vb);onCut=nt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Xr(t.target)||(this.actionManager.executeAction(dp,"keyboard",t),t.preventDefault(),t.stopPropagation())});onCopy=nt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Xr(t.target)||(this.actionManager.executeAction(Hl,"keyboard",t),t.preventDefault(),t.stopPropagation())});static resetTapTwice(){Fc=!1}onTouchStart=t=>{if(Rb&&t.preventDefault(),!Fc){Fc=!0,clearTimeout(eb),eb=window.setTimeout(e.resetTapTwice,Ub);return}if(Fc&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),Fc=!1,clearTimeout(eb)}t.touches.length===2&&this.setState({selectedElementIds:Pe({},this.state),activeEmbeddable:null})};onTouchEnd=t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Pe(this.state.previousSelectedElementIds,this.state)}):De.pointers.clear()};pasteFromClipboard=nt(async t=>{let r=!!Tu,o=document.activeElement,n=this.excalidrawContainerRef.current?.contains(o);if(t&&!n)return;let i=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(i instanceof HTMLCanvasElement)||Xr(o)))return;let{x:a,y:l}=Ue({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),s=t?.clipboardData?.files[0],c=await Em(t,r);if(!s&&!r){if(c.mixedContent)return this.addElementsFromMixedContentPaste(c.mixedContent,{isPlainPaste:r,sceneX:a,sceneY:l});if(c.text){let d=c.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(s=Vh(d))}}if(di(s)&&!c.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:b("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:a,sceneY:l});this.insertImageElement(d,s),this.initializeImageDimensions(d),this.setState({selectedElementIds:Pe({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}if(c.errorMessage)this.setState({errorMessage:c.errorMessage});else if(c.spreadsheet&&!r)this.setState({pasteDialog:{data:c.spreadsheet,shown:!0}});else if(c.elements){let d=c.programmaticAPI?_c(c.elements):c.elements;this.addElementsFromPasteOrLibrary({elements:d,files:c.files||null,position:"cursor",retainSeed:r})}else if(c.text){let d=hd(c.text).split(/\n+/).map(p=>p.trim()).filter(Boolean),m=d.map(p=>V0(p)).filter(p=>il(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||kn(p)?.type==="video"));if(!Tu&&m.length>0&&m.length===d.length){let p=[];for(let u of m){let h=p[p.length-1],x=this.insertEmbeddableElement({sceneX:h?h.x+h.width+20:a,sceneY:l,link:lr(u)});x&&p.push(x)}p.length&&this.setState({selectedElementIds:Object.fromEntries(p.map(u=>[u.id,!0]))});return}this.addTextFromPaste(c.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()});addElementsFromPasteOrLibrary=t=>{let r=Ws(t.elements,null,void 0),[o,n,i,a]=we(r),l=Mt(o,i)/2,s=Mt(n,a)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:m,y:p}=Ue({clientX:c,clientY:d},this.state),u=m-l,h=p-s,[x,E]=St(u,h,this.state.gridSize),v=$d(r.map(C=>ne(C,{x:C.x+x-o,y:C.y+E-n})),{randomizeSeed:!t.retainSeed}),y=[...this.scene.getElementsIncludingDeleted(),...v];qt(y,$(v));let I=this.getTopLayerFrameAtSceneCoords({x:m,y:p});if(I){let C=ny(v,I);ec(y,C,I)}this.scene.replaceAllElements(y),v.forEach(C=>{if(U(C)&&Ne(C)){let _=lt(C,this.scene.getElementsMapIncludingDeleted());Yt(C,_,this.scene.getElementsMapIncludingDeleted())}}),t.files&&(this.files={...this.files,...t.files}),this.history.resumeRecording();let P=ha(v);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Xt.get(Mc)?this.state.openSidebar:null,...Kt({editingGroupId:null,selectedElementIds:P.reduce((C,_)=>(Ne(_)||(C[_.id]=!0),C),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(v,{fitToContent:!0})};async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:o,sceneY:n}){if(!r&&t.some(i=>i.type==="imageUrl")&&this.isToolSupported("image")){let i=t.filter(m=>m.type==="imageUrl").map(m=>m.value),a=await Promise.all(i.map(async m=>{try{return{file:await pE(m)}}catch(p){let u=p.message;return p.cause==="FETCH_ERROR"?u=b("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(u=b("errors.unsupportedFileType")),{errorMessage:u}}})),l=n,s=!1,c={};for(let m of a)if(m.file){let p=this.createImageElement({sceneX:o,sceneY:l}),u=await this.insertImageElement(p,m.file);u&&(s||(s=!0,l-=u.height/2),F(u,{y:l},!1),l=p.y+p.height+25,c[p.id]=!0)}this.setState({selectedElementIds:Pe(c,this.state)});let d=a.find(m=>!!m.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let i=t.filter(a=>a.type==="text");i.length&&this.addTextFromPaste(i.map(a=>a.value).join(`
179
+ `)}async onMagicFrameGenerate(t,r){if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"generation"}}),fe("ai","generate (missing key)","d2c");return}let o=fl(this.scene.getNonDeletedElements(),t).filter(m=>!Vi(m));if(!o.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),fe("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let n=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(!n)return;this.updateMagicGeneration({frameElement:n,data:{status:"pending"}}),this.setState({selectedElementIds:{[n.id]:!0}});let i=await Tm({elements:this.scene.getNonDeletedElements(),appState:{...this.state,exportBackground:!0,viewBackgroundColor:this.state.viewBackgroundColor},exportingFrame:t,files:this.files}),a=await em(i),l=this.getTextFromElements(o);fe("ai","generate (start)","d2c");let s=await U5({image:a,apiKey:this.OPENAI_KEY,text:l,theme:this.state.theme});if(!s.ok){fe("ai","generate (failed)","d2c"),console.error(s.error),this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:s.error?.message||"Unknown error during generation"}});return}if(fe("ai","generate (success)","d2c"),s.choices[0].message.content==null){this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let c=s.choices[0].message.content,d=c.slice(c.indexOf("<!DOCTYPE html>"),c.indexOf("</html>")+7);this.updateMagicGeneration({frameElement:n,data:{status:"done",html:d}})}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(Dn(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}OPENAI_KEY=Tr.get($r.OAI_API_KEY);OPENAI_KEY_IS_PERSISTED=Tr.has($r.OAI_API_KEY)||!1;onOpenAIKeyChange=(t,r)=>{if(this.OPENAI_KEY=t||null,r){let o=Tr.set($r.OAI_API_KEY,t);this.OPENAI_KEY_IS_PERSISTED=o}else this.OPENAI_KEY_IS_PERSISTED=!1};onMagicSettingsConfirm=(t,r,o)=>{if(this.OPENAI_KEY=t||null,this.onOpenAIKeyChange(this.OPENAI_KEY,r),o==="settings")return;let n=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});t?n.length?this.onMagicframeToolSelect():this.setActiveTool({type:"magicframe"}):Vi(n[0])||this.setActiveTool({type:"magicframe"})};onMagicframeToolSelect=()=>{if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"tool"}}),fe("ai","tool-select (missing key)","d2c");return}let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:bt.magicframe}),fe("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&Vi(t[0])&&t[0];if(!r&&t.some(n=>Q(n)||n.frameId)){this.setActiveTool({type:bt.magicframe});return}fe("ai","tool-select (existing selection)","d2c");let o;if(r)o=r;else{let[n,i,a,l]=we(t),s=50;o=Bs({...$e,x:n-s,y:i-s,width:a-n+s*2,height:l-i+s*2,opacity:100,locked:!1}),this.scene.insertElement(o);for(let c of t)F(c,{frameId:o.id});this.setState({selectedElementIds:{[o.id]:!0}})}this.onMagicFrameGenerate(o,"upstream")}};openEyeDropper=({type:t})=>{Xt.set(fi,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,o)=>{let n=t==="background"&&o.altKey||t==="stroke"&&!o.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?n?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},commitToHistory:!0}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},commitToHistory:!0}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?ne(a,{[n?"strokeColor":"backgroundColor"]:r}):a)})},keepOpenOnAlt:!1})};syncActionResult=nt(t=>{if(this.unmounted||t===!1)return;let r=null;if(t.elements&&(t.elements.forEach(o=>{this.state.editingElement?.id===o.id&&this.state.editingElement!==o&&ys(o)&&(r=o)}),this.scene.replaceAllElements(t.elements),t.commitToHistory&&this.history.resumeRecording()),t.files&&(this.files=t.replaceFiles?t.files:{...this.files,...t.files},this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){t.commitToHistory&&this.history.resumeRecording();let o=t?.appState?.viewModeEnabled||!1,n=t?.appState?.zenModeEnabled||!1,i=t?.appState?.gridSize||null,a=t?.appState?.theme||this.props.theme||oe.LIGHT,l=t?.appState?.name??this.state.name,s=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(o=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(n=this.props.zenModeEnabled),typeof this.props.gridModeEnabled<"u"&&(i=this.props.gridModeEnabled?un:null),r=r||t.appState?.editingElement||null,r?.isDeleted&&(r=null),this.setState(c=>Object.assign(t.appState||{},{contextMenu:null,editingElement:r,viewModeEnabled:o,zenModeEnabled:n,gridSize:i,theme:a,name:l,errorMessage:s}),()=>{t.syncHistory&&this.history.setCurrentState(this.state,this.scene.getElementsIncludingDeleted())})}});onBlur=nt(()=>{Ma=!1,this.setState({isBindingEnabled:!0})});onUnload=()=>{this.onBlur()};disableEvent=t=>{t.preventDefault()};resetHistory=()=>{this.history.clear()};resetScene=nt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...ar(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetHistory()});initializeScene=async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async o=>{if(!o.files.length)return;let n=o.files[0],i=await n.getFile();this.loadFileToCanvas(new File([i],i.name||"",{type:i.type}),n)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(o=>{console.error(o)})}catch(o){console.error(o),t={appState:{errorMessage:o.message||"Encountered an error during importing or restoring scene data"}}}let r=ci(t,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...Yo(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.fonts.loadFontsForElements(r.elements),this.resetHistory(),this.syncActionResult({...r,commitToHistory:!0})};isMobileBreakpoint=(t,r)=>t<$b||r<Zb&&t<Xb;refreshViewportBreakpoints=()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:o}=document.body,n=this.device.viewport,i=Ga(n,{isLandscape:r>o,isMobile:this.isMobileBreakpoint(r,o)});return n!==i?(this.device={...this.device,viewport:i},!0):!1};refreshEditorBreakpoints=()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:o}=t.getBoundingClientRect(),n=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:jb,i=this.device.editor,a=Ga(i,{isMobile:this.isMobileBreakpoint(r,o),canFitSidebar:r>n});return i!==a?(this.device={...this.device,editor:a},!0):!1};async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,T.MODE===ss.TEST||T.DEV){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...o)=>this.setState(...o)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history}})}this.scene.addCallback(this.onSceneUpdated),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Ar()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),is&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),Ob()&&!k0()&&this.setState({errorMessage:Ke(C5,{})})}componentWillUnmount(){this.renderer.destroy(),this.scene=new ut,this.renderer=new Bc(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.scene.destroy(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),ke.destroy(),co.destroy(),clearTimeout(_i),ze.clearCache(),Kt.clearCache(),_i=0,document.documentElement.style.overscrollBehaviorX=""}onResize=nt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>ke.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),is||this.refreshEditorBreakpoints(),this.setState({})});onFullscreenChange=()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})};removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(pt(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(pt(this.excalidrawContainerRef.current,"wheel",this.onWheel,{passive:!1}),pt(window,"message",this.onWindowMessage,!1),pt(document,"pointerup",this.removePointer),pt(document,"copy",this.onCopy),pt(document,"keyup",this.onKeyUp,{passive:!0}),pt(document,"mousemove",this.updateCurrentCursorPosition),pt(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onFontsLoaded(r)}),pt(document,"gesturestart",this.onGestureStart,!1),pt(document,"gesturechange",this.onGestureChange,!1),pt(document,"gestureend",this.onGestureEnd,!1),pt(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null)})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(pt(document,"fullscreenchange",this.onFullscreenChange),pt(document,"paste",this.pasteFromClipboard),pt(document,"cut",this.onCut),pt(window,"resize",this.onResize,!1),pt(window,"unload",this.onUnload,!1),pt(window,"blur",this.onBlur,!1),pt(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),pt(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(pt(mx(this.excalidrawContainerRef.current),"scroll",this.onScroll)))}componentDidUpdate(t,r){this.updateEmbeddables();let o=this.scene.getElementsIncludingDeleted(),n=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!o.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&xr(this.state)&&this.setState({activeTool:Xe(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&Dh(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),xr(r)&&!xr(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),t.gridModeEnabled!==this.props.gridModeEnabled&&this.setState({gridSize:this.props.gridModeEnabled?un:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===oe.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(io)}),this.state.editingElement?.isDeleted&&this.setState({editingElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:a}=r;r.activeTool!==this.state.activeTool&&a!=null&&Uo(this.state)&&Tt(a,!1)&&Ps(a,this.state,bo(K.getPointAtIndexGlobalCoordinates(a,-1,n)),this),this.history.record(this.state,o),this.state.isLoading||(this.props.onChange?.(o,this.state,this.files),this.onChangeEmitter.trigger(o,this.state,this.files))}renderInteractiveSceneCallback=({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:o})=>{r&&(ob=r);let n=G(this.state.editingElement)?!1:!t&&o.size>0;this.state.scrolledOutside!==n&&this.setState({scrolledOutside:n}),this.scheduleImageRefresh()};onScroll=Wi(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(o=>o.offsetLeft===r&&o.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},Yb);onCut=nt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Xr(t.target)||(this.actionManager.executeAction(pp,"keyboard",t),t.preventDefault(),t.stopPropagation())});onCopy=nt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Xr(t.target)||(this.actionManager.executeAction(zl,"keyboard",t),t.preventDefault(),t.stopPropagation())});static resetTapTwice(){Fc=!1}onTouchStart=t=>{if(Nb&&t.preventDefault(),!Fc){Fc=!0,clearTimeout(tb),tb=window.setTimeout(e.resetTapTwice,Wb);return}if(Fc&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),Fc=!1,clearTimeout(tb)}t.touches.length===2&&this.setState({selectedElementIds:Pe({},this.state),activeEmbeddable:null})};onTouchEnd=t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Pe(this.state.previousSelectedElementIds,this.state)}):De.pointers.clear()};pasteFromClipboard=nt(async t=>{let r=!!Iu,o=document.activeElement,n=this.excalidrawContainerRef.current?.contains(o);if(t&&!n)return;let i=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(i instanceof HTMLCanvasElement)||Xr(o)))return;let{x:a,y:l}=Ue({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),s=t?.clipboardData?.files[0],c=await wm(t,r);if(!s&&!r){if(c.mixedContent)return this.addElementsFromMixedContentPaste(c.mixedContent,{isPlainPaste:r,sceneX:a,sceneY:l});if(c.text){let d=c.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(s=Yh(d))}}if(di(s)&&!c.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:b("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:a,sceneY:l});this.insertImageElement(d,s),this.initializeImageDimensions(d),this.setState({selectedElementIds:Pe({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}if(c.errorMessage)this.setState({errorMessage:c.errorMessage});else if(c.spreadsheet&&!r)this.setState({pasteDialog:{data:c.spreadsheet,shown:!0}});else if(c.elements){let d=c.programmaticAPI?_c(c.elements):c.elements;this.addElementsFromPasteOrLibrary({elements:d,files:c.files||null,position:"cursor",retainSeed:r})}else if(c.text){let d=hd(c.text).split(/\n+/).map(p=>p.trim()).filter(Boolean),m=d.map(p=>$0(p)).filter(p=>il(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||kn(p)?.type==="video"));if(!Iu&&m.length>0&&m.length===d.length){let p=[];for(let u of m){let h=p[p.length-1],x=this.insertEmbeddableElement({sceneX:h?h.x+h.width+20:a,sceneY:l,link:lr(u)});x&&p.push(x)}p.length&&this.setState({selectedElementIds:Object.fromEntries(p.map(u=>[u.id,!0]))});return}this.addTextFromPaste(c.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()});addElementsFromPasteOrLibrary=t=>{let r=Vs(t.elements,null,void 0),[o,n,i,a]=we(r),l=Mt(o,i)/2,s=Mt(n,a)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:m,y:p}=Ue({clientX:c,clientY:d},this.state),u=m-l,h=p-s,[x,E]=St(u,h,this.state.gridSize),v=Xd(r.map(C=>ne(C,{x:C.x+x-o,y:C.y+E-n})),{randomizeSeed:!t.retainSeed}),y=[...this.scene.getElementsIncludingDeleted(),...v];qt(y,$(v));let I=this.getTopLayerFrameAtSceneCoords({x:m,y:p});if(I){let C=ly(v,I);ec(y,C,I)}this.scene.replaceAllElements(y),v.forEach(C=>{if(G(C)&&Ne(C)){let _=st(C,this.scene.getElementsMapIncludingDeleted());Yt(C,_,this.scene.getElementsMapIncludingDeleted())}}),t.files&&(this.files={...this.files,...t.files}),this.history.resumeRecording();let P=ha(v);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Xt.get(Mc)?this.state.openSidebar:null,...Kt({editingGroupId:null,selectedElementIds:P.reduce((C,_)=>(Ne(_)||(C[_.id]=!0),C),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(v,{fitToContent:!0})};async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:o,sceneY:n}){if(!r&&t.some(i=>i.type==="imageUrl")&&this.isToolSupported("image")){let i=t.filter(m=>m.type==="imageUrl").map(m=>m.value),a=await Promise.all(i.map(async m=>{try{return{file:await gE(m)}}catch(p){let u=p.message;return p.cause==="FETCH_ERROR"?u=b("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(u=b("errors.unsupportedFileType")),{errorMessage:u}}})),l=n,s=!1,c={};for(let m of a)if(m.file){let p=this.createImageElement({sceneX:o,sceneY:l}),u=await this.insertImageElement(p,m.file);u&&(s||(s=!0,l-=u.height/2),F(u,{y:l},!1),l=p.y+p.height+25,c[p.id]=!0)}this.setState({selectedElementIds:Pe(c,this.state)});let d=a.find(m=>!!m.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let i=t.filter(a=>a.type==="text");i.length&&this.addTextFromPaste(i.map(a=>a.value).join(`
180
180
 
181
181
  `),r)}}addTextFromPaste(t,r=!1){let{x:o,y:n}=Ue({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),i={x:o,y:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:this.state.currentItemTextAlign,verticalAlign:Hi,locked:!1},a=10,l=n,s=r?[t]:t.split(`
182
- `),c=s.reduce((d,m,p)=>{let u=m.trim(),h=_r(i.fontFamily);if(u.length){let x=this.getTopLayerFrameAtSceneCoords({x:o,y:l}),E=Nt({...i,x:o,y:l,text:u,lineHeight:h,frameId:x?x.id:null});d.push(E),l+=E.height+a}else s[p-1]?.trim()&&(l+=ii(i.fontSize,h)+a);return d},[]);c.length!==0&&(this.scene.insertElements(c),this.setState({selectedElementIds:Pe(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)}),!r&&c.length>1&&K5===!1&&!this.device.editor.isMobile&&(this.setToast({message:b("toast.pasteAsSingleElement",{shortcut:R("CtrlOrCmd+Shift+V")}),duration:5e3}),K5=!0),this.history.resumeRecording())}setAppState=(t,r)=>{this.setState(t,r)};removePointer=t=>{_i&&this.resetContextMenuTimer(),De.pointers.delete(t.pointerId)};toggleLock=(t="ui")=>{this.state.activeTool.locked||fe("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Xe(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))};updateFrameRendering=t=>{this.setState(r=>{let o=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:o?.enabled??r.frameRendering.enabled,clip:o?.clip??r.frameRendering.clip,name:o?.name??r.frameRendering.name,outline:o?.outline??r.frameRendering.outline}}})};togglePenMode=t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))};onHandToolToggle=()=>{this.actionManager.executeAction(Xw)};zoomCanvas=t=>{this.setState({...Nn({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Xo(t)},this.state)})};cancelInProgressAnimation=null;scrollToContent=(t=this.scene.getNonDeletedElements(),r)=>{this.cancelInProgressAnimation?.();let o=Array.isArray(t)?t:[t],n=this.state.zoom,i=this.state.scrollX,a=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:l}=gc({targetElements:o,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor});n=l.zoom,i=l.scrollX,a=l.scrollY}else{let l=Yo(o,this.state);i=l.scrollX,a=l.scrollY}if(r?.animate){let l=this.state.scrollX,s=this.state.scrollY,c=this.state.zoom.value,d=sx({fromValues:{scrollX:l,scrollY:s,zoom:c},toValues:{scrollX:i,scrollY:a,zoom:n.value},interpolateValue:(m,p,u,h)=>{if(h==="zoom")return m*Math.pow(p/m,hn(u))},onStep:({scrollX:m,scrollY:p,zoom:u})=>{this.setState({scrollX:m,scrollY:p,zoom:{value:u}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:i,scrollY:a,zoom:n})};maybeUnfollowRemoteUser=()=>{this.state.userToFollow&&this.setState({userToFollow:null})};translateCanvas=t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)};setToast=t=>{this.setState({toast:t})};restoreFileFromShare=async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let o=await r.blob(),n=new File([o],o.name||"",{type:o.type});this.loadFileToCanvas(n,null),await t.delete("shared-file"),window.history.replaceState(null,is,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}};addFiles=nt(t=>{let r=t.reduce((o,n)=>(o.set(n.id,n),o),new Map);this.files={...this.files,...Object.fromEntries(r)},this.scene.getNonDeletedElements().forEach(o=>{nr(o)&&r.has(o.fileId)&&(this.imageCache.delete(o.fileId),ke.delete(o))}),this.scene.informMutation(),this.addNewImagesToImageCache()});updateScene=nt(t=>{t.commitToHistory&&this.history.resumeRecording(),t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(t.elements),t.collaborators&&this.setState({collaborators:t.collaborators})});onSceneUpdated=()=>{this.setState({})};toggleSidebar=({name:t,tab:r,force:o})=>{let n;o===void 0?n=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:n=o?t:null;let i=n?{name:n}:null;return i&&r&&(i.tab=r),this.setState({openSidebar:i}),!!n};updateCurrentCursorPosition=nt(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY});onKeyDown=nt(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(i,a){let l=i[a];return typeof l=="function"?l.bind(i):a==="key"?t.shiftKey?i.key.toUpperCase():i.key.toLowerCase():l}})),t[S.CTRL_OR_CMD]&&t.key===S.P&&!t.shiftKey&&!t.altKey){this.setToast({message:b("commandPalette.shortcutHint",{shortcut:It("commandPalette")})}),t.preventDefault();return}if(t[S.CTRL_OR_CMD]&&t.key.toLowerCase()===S.V&&(Tu=t.shiftKey,clearTimeout(Y5),Y5=window.setTimeout(()=>{Tu=!1},100)),t[S.CTRL_OR_CMD]&&Xr(t.target)&&(t.code===he.MINUS||t.code===he.EQUAL)){t.preventDefault();return}if(Xr(t.target)&&t.key!==S.ESCAPE||Za(t.key)&&zu(t.target))return;if(t.key===S.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===S.E&&t.shiftKey&&t[S.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===S.PAGE_UP||t.key===S.PAGE_DOWN){let i=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===S.PAGE_DOWN&&(i=-i),t.shiftKey?this.translateCanvas(a=>({scrollX:a.scrollX+i})):this.translateCanvas(a=>({scrollY:a.scrollY+i}))}if(this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[S.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Za(t.key)){let i=this.state.gridSize&&(t.shiftKey?_u:this.state.gridSize)||(t.shiftKey?Ob:_u),a=0,l=0;t.key===S.ARROW_LEFT?a=-i:t.key===S.ARROW_RIGHT?a=i:t.key===S.ARROW_UP?l=-i:t.key===S.ARROW_DOWN&&(l=i);let s=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});s.forEach(c=>{F(c,{x:c.x+a,y:c.y+l}),So(c,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:s})}),this.maybeSuggestBindingForAll(s),t.preventDefault()}else if(t.key===S.ENTER){let i=this.scene.getSelectedElements(this.state);if(i.length===1){let a=i[0];if(t[S.CTRL_OR_CMD])re(a)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==i[0].id)&&(this.history.resumeRecording(),this.setState({editingLinearElement:new K(a)}));else if(U(a)||I0(a)){let l;U(a)||(l=a);let s=Nd(a,this.state,this.scene.getNonDeletedElementsMap()),c=s.x,d=s.y;this.startTextEditing({sceneX:c,sceneY:d,container:l}),t.preventDefault();return}else Q(a)&&this.setState({editingFrame:a.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&this.state.draggingElement===null){let i=f3(t.key);i?(this.state.activeTool.type!==i&&fe("toolbar",i,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setActiveTool({type:i}),t.stopPropagation()):t.key===S.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===S.SPACE&&De.pointers.size===0&&(Ma=!0,He(this.interactiveCanvas,Ce.GRAB),t.preventDefault()),(t.key===S.G||t.key===S.S)&&!t.altKey&&!t[S.CTRL_OR_CMD]){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;t.key===S.G&&(fn(this.state.activeTool.type)||i.some(a=>fn(a.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===S.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(t.key===S.K&&!t.altKey&&!t[S.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[S.CTRL_OR_CMD]&&(t.key===S.BACKSPACE||t.key===S.DELETE)&&Xt.set(ka,"clearCanvas");let r=t.key.toLocaleLowerCase(),o=r===S.S&&t.shiftKey,n=t.key===S.I||r===S.G&&t.shiftKey;(o||n)&&this.openEyeDropper({type:o?"stroke":"background"})});onWheel=nt(t=>{!(t.target instanceof HTMLCanvasElement)&&t.ctrlKey&&t.preventDefault()});onKeyUp=nt(t=>{if(t.key===S.SPACE&&(this.state.viewModeEnabled?He(this.interactiveCanvas,Ce.GRAB):this.state.activeTool.type==="selection"?Or(this.interactiveCanvas):(Br(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Ma=!1),!t[S.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Za(t.key)){let r=this.scene.getSelectedElements(this.state),o=this.scene.getNonDeletedElementsMap();Uo(this.state)?Ls(r,this):_s(r,o),this.setState({suggestedBindings:[]})}});isToolSupported=t=>this.props.UIOptions.tools?.[t]!==!1;setActiveTool=t=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=Xe(this.state,t);r.type==="hand"?He(this.interactiveCanvas,Ce.GRAB):Ma||Br(this.interactiveCanvas,this.state),ax(document.activeElement)&&this.focusContainer(),fs(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(t.type==="image"&&t.insertOnCanvasDirectly)??!1}),this.setState(o=>{let n={snapLines:o.snapLines.length?[]:o.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type!=="selection"?{...o,activeTool:r,selectedElementIds:Pe({},o),selectedGroupIds:Pe({},o),editingGroupId:null,multiElement:null,...n}:{...o,activeTool:r,...n}})};setOpenDialog=t=>{this.setState({openDialog:t})};setCursor=t=>{He(this.interactiveCanvas,t)};resetCursor=()=>{Or(this.interactiveCanvas)};isTouchScreenMultiTouchGesture=()=>De.pointers.size>=2;getName=()=>this.state.name||this.props.name||`${b("labels.untitled")}-${Hu()}`;onGestureStart=nt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Pe({},this.state),activeEmbeddable:null}),De.initialScale=this.state.zoom.value});onGestureChange=nt(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=De.initialScale;r&&this.setState(o=>({...Nn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Xo(r*t.scale)},o)}))});onGestureEnd=nt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Pe(this.state.previousSelectedElementIds,this.state)}),De.initialScale=null});handleTextWysiwyg(t,{isExistingElement:r=!1}){let o=this.scene.getElementsMapIncludingDeleted(),n=(i,a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&U(s)?Dh(s,lt(s,o),o,{text:i,isDeleted:l,originalText:a}):s)])};W5({id:t.id,canvas:this.canvas,getViewportCoords:(i,a)=>{let{x:l,y:s}=Dt({sceneX:i,sceneY:a},this.state);return[l-this.state.offsetLeft,s-this.state.offsetTop]},onChange:nt(i=>{n(i,i,!1),Es(t)&&So(t,o)}),onSubmit:nt(({text:i,viaKeyboard:a,originalText:l})=>{let s=!i.trim();if(n(i,l,s),!s&&a){let c=t.containerId?t.containerId:t.id;this.setState(d=>({selectedElementIds:Pe({...d.selectedElementIds,[c]:!0},d)}))}s&&Ja(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.history.resumeRecording(),this.setState({draggingElement:null,editingElement:null}),this.state.activeTool.locked&&Br(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this}),this.deselectElements(),n(t.text,t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let o=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return o&&U(o)&&!o.isDeleted?o:null}getElementShape(t){switch(t.type){case"rectangle":case"diamond":case"frame":case"magicframe":case"embeddable":case"image":case"iframe":case"text":case"selection":return nm(t);case"arrow":case"line":{let r=ke.get(t)?.[0]??ke.generateElementShape(t,null)[0],[,,,,o,n]=te(t,this.scene.getNonDeletedElementsMap());return im(t)?vE(r,[t.x,t.y],t.angle,[o,n]):yE(r,[t.x,t.y],t.angle,[o,n])}case"ellipse":return xE(t);case"freedraw":{let[,,,,r,o]=te(t,this.scene.getNonDeletedElementsMap());return wE(t,[r,o],im(t))}}}getBoundTextShape(t){let r=pe(t,this.scene.getNonDeletedElementsMap());return r?t.type==="arrow"?this.getElementShape({...r,...K.getBoundTextElementPosition(t,r,this.scene.getNonDeletedElementsMap())}):this.getElementShape(r):null}getElementAtPosition(t,r,o){let n=this.getElementsAtPosition(t,r,o?.includeBoundTextElement,o?.includeLockedElements);if(n.length>1){if(o?.preferSelected){for(let a=n.length-1;a>-1;a--)if(this.state.selectedElementIds[n[a].id])return n[a]}let i=n[n.length-1];return Xa([t,r],this.getElementShape(i))?i:n[n.length-2]}return n.length===1?n[0]:null}getElementsAtPosition(t,r,o=!1,n=!1){let i=[],a=this.scene.getNonDeletedElementsMap();return(o&&n?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n||!s.locked)&&(o||!(U(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let c=Ot(s,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?sg({x:t,y:r},c,a):!0}).filter(s=>jr(s)?(i.push(s),!1):!0).concat(i)}getHitThreshold(){return 10/this.state.zoom.value}hitElement(t,r,o,n=!0){return n&&this.state.selectedElementIds[o.id]&&Lm([o],this.state)?la(t,r,o,this.scene.getNonDeletedElementsMap(),this.getHitThreshold()):SE(t,r,this.getBoundTextShape(o))?!0:ul({x:t,y:r,element:o,shape:this.getElementShape(o),threshold:this.getHitThreshold(),frameNameBound:Q(o)?this.frameNameBoundsCache.get(o):null})}getTextBindableContainerAtPosition(t,r){let o=this.scene.getNonDeletedElements(),n=this.scene.getSelectedElements(this.state);if(n.length===1)return Fo(n[0],!1)?n[0]:null;let i=null;for(let a=o.length-1;a>=0;--a){if(o[a].isDeleted)continue;let[l,s,c,d]=te(o[a],this.scene.getNonDeletedElementsMap());if(Te(o[a])&&ul({x:t,y:r,element:o[a],shape:this.getElementShape(o[a]),threshold:this.getHitThreshold()})){i=o[a];break}else if(l<t&&t<c&&s<r&&r<d){i=o[a];break}}return Fo(i,!1)?i:null}startTextEditing=({sceneX:t,sceneY:r,insertAtParentCenter:o=!0,container:n})=>{let i=!1,a=o&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n);n&&a&&(pe(n,this.scene.getNonDeletedElementsMap())||(i=!0));let l=null,s=this.scene.getSelectedElements(this.state);s.length===1?U(s[0])?l=s[0]:n?l=pe(s[0],this.scene.getNonDeletedElementsMap()):l=this.getTextElementAtPosition(t,r):l=this.getTextElementAtPosition(t,r);let c=l?.fontFamily||this.state.currentItemFontFamily,d=l?.lineHeight||_r(c),m=this.state.currentItemFontSize;if(!l&&i&&n&&!Te(n)){let x=Rd(Ge({fontSize:m,fontFamily:c}),d),E=Dd(m,d),v=Math.max(n.height,E),w=Math.max(n.width,x);F(n,{height:v,width:w}),t=n.x+w/2,r=n.y+v/2,a&&(a=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n))}let p=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),u=l||Nt({x:a?a.elementCenterX:t,y:a?a.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:m,fontFamily:c,textAlign:a?"center":this.state.currentItemTextAlign,verticalAlign:a?ft.MIDDLE:Hi,containerId:i?n?.id:void 0,groupIds:n?.groupIds??[],lineHeight:d,angle:n?.angle??0,frameId:p?p.id:null});if(!l&&i&&n&&F(n,{boundElements:(n.boundElements||[]).concat({type:"text",id:u.id})}),this.setState({editingElement:u}),!l)if(n&&i){let h=this.scene.getElementIndex(n.id);this.scene.insertElementAtIndex(u,h+1)}else this.scene.insertElement(u);this.setState({editingElement:u}),this.handleTextWysiwyg(u,{isExistingElement:!!l})};handleCanvasDoubleClick=t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state);if(r.length===1&&re(r[0])&&t[S.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)){this.history.resumeRecording(),this.setState({editingLinearElement:new K(r[0])});return}Or(this.interactiveCanvas);let{x:o,y:n}=Ue(t,this.state);if(vn(this.state).length>0){let a=this.getElementAtPosition(o,n),l=a&&_0(a,this.state.selectedGroupIds);if(l){this.setState(s=>({...s,...Kt({editingGroupId:l,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),s,this)}));return}}if(Or(this.interactiveCanvas),!t[S.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let a=this.getElementAtPosition(o,n);if(Vt(a)){this.setState({activeEmbeddable:{element:a,state:"active"}});return}let l=this.getTextBindableContainerAtPosition(o,n);if(l&&(gr(l)||!or(l.backgroundColor)||ul({x:o,y:n,element:l,shape:this.getElementShape(l),threshold:this.getHitThreshold()}))){let s=Nd(l,this.state,this.scene.getNonDeletedElementsMap());o=s.x,n=s.y}this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:l})}};getElementLinkAtPosition=(t,r)=>{let o=this.scene.getNonDeletedElements().slice().reverse(),n=1/0;return o.find((i,a)=>(r&&i.id===r.id&&(n=a),i.link&&a<=n&&lm(i,this.scene.getNonDeletedElementsMap(),this.state,[t.x,t.y],this.device.editor.isMobile)))};redirectToLink=(t,r)=>{let o=xt(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY,this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY);if(!this.hitLinkElement||r&&o>pn||!r&&o!==0)return;let n=Ue(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=lm(this.hitLinkElement,i,this.state,[n.x,n.y],this.device.editor.isMobile),l=Ue(this.lastPointerUpEvent,this.state),s=lm(this.hitLinkElement,i,this.state,[l.x,l.y],this.device.editor.isMobile);if(a&&s){let c=this.hitLinkElement.link;if(c){c=lr(c);let d;if(this.props.onLinkOpen&&(d=pd("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let m=zd(c)?"_self":"_blank",p=window.open(void 0,m);p&&(p.opener=null,p.location=c)}}}};getTopLayerFrameAtSceneCoords=t=>{let r=this.scene.getNonDeletedElementsMap(),o=this.scene.getNonDeletedFramesLikes().filter(n=>sg(t,n,r));return o.length?o[o.length-1]:null};handleCanvasPointerMove=t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,De.pointers.has(t.pointerId)&&De.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=De.initialScale;if(De.pointers.size===2&&De.lastCenter&&r&&De.initialDistance){let p=u1(De.pointers),u=p.x-De.lastCenter.x,h=p.y-De.lastCenter.y;De.lastCenter=p;let x=h1(Array.from(De.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:x/De.initialDistance,v=E?Xo(r*E):this.state.zoom.value;this.setState(w=>{let y=Nn({viewportX:p.x,viewportY:p.y,nextZoom:v},w);this.translateCanvas({zoom:y.zoom,scrollX:y.scrollX+u/v,scrollY:y.scrollY+h/v,shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else De.lastCenter=De.initialDistance=De.initialScale=null;if(Ma||Hc||tb||Co(this.state))return;let n=x1(rb,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.draggingElement&&!this.state.multiElement&&(n?Or(this.interactiveCanvas):Br(this.interactiveCanvas,this.state));let i=Ue(t,this.state),{x:a,y:l}=i;if(!this.state.draggingElement&&w5(this.state.activeTool.type)){let{originOffset:p,snapLines:u}=y5(this.scene.getNonDeletedElements(),this.state,{x:a,y:l},t,this.scene.getNonDeletedElementsMap());this.setState(h=>{let x=ud(h.snapLines,u),E=h.originSnapOffset?ud(h.originSnapOffset,p):p;return h.snapLines===x&&h.originSnapOffset===E?null:{snapLines:x,originSnapOffset:E}})}else this.state.draggingElement||this.setState(p=>p.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let p=K.handlePointerMove(t,a,l,this.state,this.scene.getNonDeletedElementsMap());p&&p!==this.state.editingLinearElement&&Q1(()=>{this.setState({editingLinearElement:p})}),p?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(i):Q1(()=>{this.setState({suggestedBindings:[]})})}if(Vu(this.state.activeTool.type)){let{draggingElement:p}=this.state;Tt(p,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(p,[i],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(i)}if(this.state.multiElement){let{multiElement:p}=this.state,{x:u,y:h}=p,{points:x,lastCommittedPoint:E}=p,v=x[x.length-1];if(Br(this.interactiveCanvas,this.state),v===E)xt(a-u,l-h,v[0],v[1])>=Na?F(p,{points:[...x,[a-u,l-h]]}):He(this.interactiveCanvas,Ce.POINTER);else if(x.length>2&&E&&xt(a-u,l-h,E[0],E[1])<Na)He(this.interactiveCanvas,Ce.POINTER),F(p,{points:x.slice(0,-1)});else{let[w,y]=St(a,l,t[S.CTRL_OR_CMD]?null:this.state.gridSize),[I,P]=p?.lastCommittedPoint??[0,0],C=w-u-I,_=y-h-P;qi(t)&&({width:C,height:_}=el(I+u,P+h,w,y)),ir(x,this.state.zoom.value)&&He(this.interactiveCanvas,Ce.POINTER),F(p,{points:[...x.slice(0,-1),[I+C,P+_]]})}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!n&&!this.state.editingLinearElement){let p=Pm(c,this.state,a,l,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap());if(p&&p.transformHandleType){He(this.interactiveCanvas,Dm(p));return}}else if(d.length>1&&!n){let p=_m(we(d),a,l,this.state.zoom,t.pointerType);if(p){He(this.interactiveCanvas,Dm({transformHandleType:p}));return}}let m=this.getElementAtPosition(i.x,i.y);this.hitLinkElement=this.getElementLinkAtPosition(i,m),!xr(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(He(this.interactiveCanvas,Ce.POINTER),wv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(vv(),m&&(m.link||vt(m))&&this.state.selectedElementIds[m.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?He(this.interactiveCanvas,U(m)?Ce.TEXT:Ce.CROSSHAIR):this.state.viewModeEnabled?He(this.interactiveCanvas,Ce.GRAB):n?He(this.interactiveCanvas,Ce.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,l):t[S.CTRL_OR_CMD]?He(this.interactiveCanvas,Ce.AUTO):(m||this.isHittingCommonBoundingBoxOfSelectedElements(i,d))&&!m?.locked&&(m&&Vt(m)&&this.isIframeLikeElementCenter(m,t,a,l)?(He(this.interactiveCanvas,Ce.POINTER),this.setState({activeEmbeddable:{element:m,state:"hover"}})):(He(this.interactiveCanvas,Ce.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))))};handleEraser=(t,r,o)=>{this.eraserTrail.addPointToPath(o.x,o.y);let n=!1,i=new Set,a=this.scene.getNonDeletedElements(),l=p=>{for(let u of p){if(u.locked)return;if(t.altKey?this.elementsPendingErasure.delete(u.id)&&(n=!0):this.elementsPendingErasure.has(u.id)||(n=!0,this.elementsPendingErasure.add(u.id)),n&&u.groupIds?.length){let h=u.groupIds.at(-1);if(!i.has(h)){i.add(h);let x=Je(a,h);for(let E of x)t.altKey?this.elementsPendingErasure.delete(E.id):this.elementsPendingErasure.add(E.id)}}}},s=xt(r.lastCoords.x,r.lastCoords.y,o.x,o.y),c=this.getHitThreshold(),d={...r.lastCoords},m=0;for(;m<=s;){let p=this.getElementsAtPosition(d.x,d.y);if(l(p),m===s)break;m=Math.min(m+c,s);let u=m/s,h=(1-u)*d.x+u*o.x,x=(1-u)*d.y+u*o.y;d.x=h,d.y=x}if(r.lastCoords.x=o.x,r.lastCoords.y=o.y,n){for(let p of this.scene.getNonDeletedElements())Ne(p)&&(this.elementsPendingErasure.has(p.id)||this.elementsPendingErasure.has(p.containerId))&&(t.altKey?(this.elementsPendingErasure.delete(p.id),this.elementsPendingErasure.delete(p.containerId)):(this.elementsPendingErasure.add(p.id),this.elementsPendingErasure.add(p.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.onSceneUpdated()}};handleTouchMove=t=>{zc=!0};handleHoverSelectedLinearElement(t,r,o){let n=this.scene.getNonDeletedElementsMap(),i=K.getElement(t.elementId,n);if(i)if(this.state.selectedLinearElement){let a=-1,l=null;ul({x:r,y:o,element:i,shape:this.getElementShape(i)})?(a=K.getPointIndexUnderCursor(i,n,this.state.zoom,r,o),l=K.getSegmentMidpointHitCoords(t,{x:r,y:o},this.state,this.scene.getNonDeletedElementsMap()),a>=0||l?He(this.interactiveCanvas,Ce.POINTER):He(this.interactiveCanvas,Ce.MOVE)):this.hitElement(r,o,i)&&He(this.interactiveCanvas,Ce.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),K.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}})}else He(this.interactiveCanvas,Ce.AUTO)}handleCanvasPointerDown=t=>{if(this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.draggingElement&&this.state.draggingElement.type==="freedraw"){let c=this.state.draggingElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(d=>d.id!==c.id)}:{},appState:{draggingElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Pe(Object.keys(this.state.selectedElementIds).filter(d=>d!==c.id).reduce((d,m)=>(d[m]=this.state.selectedElementIds[m],d),{}),this.state)}});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Ga(this.device,{isTouchScreen:!0})),Hc||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Vn.ERASER&&this.state.activeTool.type!==bt.eraser){this.setState({activeTool:Xe(this.state,{type:bt.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{d(),m?.(),xr(this.state)&&this.setState({activeTool:Xe(this.state,{...this.state.activeTool.lastActiveTool||{type:bt.selection},lastActiveToolBeforeEraser:null})})},d=mt(window,"pointerup",c,{once:!0}),m;requestAnimationFrame(()=>{m=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==Vn.MAIN&&t.button!==Vn.TOUCH&&t.button!==Vn.ERASER||De.pointers.size>1)return;let o=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,o)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,o))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="text"){this.handleTextOnPointerDown(t,o);return}else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,o);else if(this.state.activeTool.type==="image"){He(this.interactiveCanvas,Ce.CROSSHAIR);let c=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!c)return;this.setState({draggingElement:c,editingElement:c,pendingImageElementId:null,multiElement:null});let{x:d,y:m}=Ue(t,this.state),p=this.getTopLayerFrameAtSceneCoords({x:d,y:m});F(c,{x:d,y:m,frameId:p?p.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,o):this.state.activeTool.type==="custom"?Br(this.interactiveCanvas,this.state):this.state.activeTool.type===bt.frame||this.state.activeTool.type===bt.magicframe?this.createFrameElementOnPointerDown(o,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(o.lastCoords.x,o.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,o);this.props?.onPointerDown?.(this.state.activeTool,o),this.onPointerDownEmitter.trigger(this.state.activeTool,o,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(o.lastCoords.x,o.lastCoords.y);let i=this.onPointerMoveFromPointerDownHandler(o),a=this.onPointerUpFromPointerDownHandler(o),l=this.onKeyDownFromPointerDownHandler(o),s=this.onKeyUpFromPointerDownHandler(o);this.missingPointerEventCleanupEmitter.once(c=>a(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",i),window.addEventListener("pointerup",a),window.addEventListener("keydown",l),window.addEventListener("keyup",s),o.eventListeners.onMove=i,o.eventListeners.onUp=a,o.eventListeners.onKeyUp=s,o.eventListeners.onKeyDown=l)};handleCanvasPointerUp=t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Ue({clientX:t.clientX,clientY:t.clientY},this.state),o=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&o<300){let n=this.getElementAtPosition(r.x,r.y);if(Vt(n)&&this.isIframeLikeElementCenter(n,t,r.x,r.y)){this.handleEmbeddableCenterClick(n);return}}if(this.device.isTouchScreen){let n=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,n)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?o<300&&Vt(this.hitLinkElement)&&!qh(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,[r.x,r.y])?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})};maybeOpenContextMenuAfterPointerDownOnTouchDevices=t=>{t.pointerType==="touch"&&(zc=!1,_i?zc=!0:_i=window.setTimeout(()=>{_i=0,zc||this.handleCanvasContextMenu(t)},Wb))};resetContextMenuTimer=()=>{clearTimeout(_i),_i=0,zc=!1};maybeCleanupAfterMissingPointerUp=t=>{Gc?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()};handleCanvasPanUsingWheelOrSpaceDrag=t=>{if(!(De.pointers.size<=1&&(t.button===Vn.WHEEL||t.button===Vn.MAIN&&Ma||Co(this.state)||this.state.viewModeEnabled))||U(this.state.editingElement))return!1;Hc=!0,t.preventDefault();let r=!1,o=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);He(this.interactiveCanvas,Ce.GRABBING);let{clientX:n,clientY:i}=t,a=fu(s=>{let c=n-s.clientX,d=i-s.clientY;if(n=s.clientX,i=s.clientY,o&&!r&&(Math.abs(c)>1||Math.abs(d)>1)){r=!0;let m=u=>{document.body.removeEventListener("paste",m),u.stopPropagation()},p=()=>{setTimeout(()=>{document.body.removeEventListener("paste",m),window.removeEventListener("pointerup",p)},100)};document.body.addEventListener("paste",m),window.addEventListener("pointerup",p)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),l=nt(Gc=()=>{Gc=null,Hc=!1,Ma||(this.state.viewModeEnabled?He(this.interactiveCanvas,Ce.GRAB):Br(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l),window.removeEventListener("blur",l),a.flush()});return window.addEventListener("blur",l),window.addEventListener("pointermove",a,{passive:!0}),window.addEventListener("pointerup",l),!0};updateGestureOnPointerDown(t){De.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),De.pointers.size===2&&(De.lastCenter=u1(De.pointers),De.initialScale=this.state.zoom.value,De.initialDistance=h1(Array.from(De.pointers.values())))}initialPointerDownState(t){let r=Ue(t,this.state),o=this.scene.getSelectedElements(this.state),[n,i,a,l]=we(o);return{origin:r,withCmdOrCtrl:t[S.CTRL_OR_CMD],originInGrid:bo(St(r.x,r.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize)),scrollbars:x1(rb,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((s,c)=>(s.set(c.id,Sn(c)),s),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+n)/2,y:(l+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,o)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;tb=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let o=fu(i=>{i.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(i,r)}),n=nt(()=>{Gc=null,tb=!1,Br(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",n),o.flush()});return Gc=n,window.addEventListener("pointermove",o),window.addEventListener("pointerup",n),!0}clearSelectionIfNotUsingSelection=()=>{this.state.activeTool.type!=="selection"&&this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})};handleSelectionOnPointerDown=(t,r)=>{if(this.state.activeTool.type==="selection"){let o=this.scene.getNonDeletedElements(),n=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.editingLinearElement){let a=Pm(o,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap());a!=null&&(this.setState({resizingElement:a.element}),r.resize.handleType=a.transformHandleType)}else i.length>1&&(r.resize.handleType=_m(we(i),r.origin.x,r.origin.y,this.state.zoom,t.pointerType));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=bo(bg(r.resize.handleType,i,n,r.origin.x,r.origin.y)),i.length===1&&re(i[0])&&i[0].points.length===2&&(r.resize.arrowDirection=xg(r.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let s=this.state.editingLinearElement||this.state.selectedLinearElement,c=K.handlePointerDown(t,this.state,this.history,r.origin,s,this);if(c.hitElement&&(r.hit.element=c.hitElement),c.linearElementEditor&&(this.setState({selectedLinearElement:c.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:c.linearElementEditor})),c.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=this.getElementsAtPosition(r.origin.x,r.origin.y);let a=r.hit.element,l=r.hit.allHitElements.some(s=>this.isASelectedElement(s));if((a===null||!l)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(a),this.state.editingLinearElement)this.setState({selectedElementIds:Pe({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(a!=null){if(t[S.CTRL_OR_CMD])return this.state.selectedElementIds[a.id]||(r.hit.wasAddedToSelection=!0),this.setState(s=>({...P0(s,a),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!oa(a,this.state.editingGroupId)&&this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!l&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(s=>{let c={...s.selectedElementIds,[a.id]:!0},d=[];if(Object.keys(s.selectedElementIds).forEach(m=>{let p=this.scene.getElement(m);p&&d.push(p)}),Q(a))Hr(d,a.id).forEach(m=>{delete c[m.id]});else if(a.frameId)c[a.frameId]&&delete c[a.id];else{let m=a.groupIds,p=new Set(m.flatMap(u=>Je(this.scene.getNonDeletedElements(),u)).filter(u=>Q(u)).map(u=>u.id));p.size>0&&d.forEach(u=>{u.frameId&&p.has(u.frameId)&&(delete c[u.id],u.groupIds.flatMap(h=>Je(this.scene.getNonDeletedElements(),h)).forEach(h=>{delete c[h.id]}))})}return{...Kt({editingGroupId:s.editingGroupId,selectedElementIds:c},this.scene.getNonDeletedElements(),s,this),showHyperlinkPopup:a.link||vt(a)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1};isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let o=this.getHitThreshold(),[n,i,a,l]=we(r);return t.x>n-o&&t.x<a+o&&t.y>i-o&&t.y<l+o}handleTextOnPointerDown=(t,r)=>{if(U(this.state.editingElement))return;let o=r.origin.x,n=r.origin.y,i=this.getElementAtPosition(o,n,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(o,n);gr(i)&&(a=i,o=i.x+i.width/2,n=i.y+i.height/2),this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:a}),Or(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Xe(this.state,{type:"selection"})})};handleFreeDrawElementOnPointerDown=(t,r,o)=>{let[n,i]=St(o.origin.x,o.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l=G0({type:r,x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:t.pressure===.5,locked:!1,frameId:a?a.id:null});this.setState(d=>{let m={...d.selectedElementIds};return delete m[l.id],{selectedElementIds:Pe(m,d)}});let s=l.simulatePressure?l.pressures:[...l.pressures,t.pressure];F(l,{points:[[0,0]],pressures:s});let c=Wo(o.origin,this);this.scene.insertElement(l),this.setState({draggingElement:l,editingElement:l,startBoundElement:c,suggestedBindings:[]})};insertIframeElement=({sceneX:t,sceneY:r,width:o,height:n})=>{let[i,a]=St(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),l=H0({type:"iframe",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:o,height:n});return this.scene.insertElement(l),l};insertEmbeddableElement=({sceneX:t,sceneY:r,link:o})=>{let[n,i]=St(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=kn(o);if(!a)return;a.error instanceof URIError&&this.setToast({message:b("toast.unrecognizedLinkFormat"),closable:!0});let l=_h({type:"embeddable",x:n,y:i,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:o});return this.scene.insertElement(l),l};createImageElement=({sceneX:t,sceneY:r,addToFrameUnderCursor:o=!0})=>{let[n,i]=St(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=o?this.getTopLayerFrameAtSceneCoords({x:n,y:i}):null;return Fs({type:"image",x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null})};handleLinearElementOnPointerDown=(t,r,o)=>{if(this.state.multiElement){let{multiElement:n}=this.state;if(n.type==="line"&&ir(n.points,this.state.zoom.value)){F(n,{lastCommittedPoint:n.points[n.points.length-1]}),this.actionManager.executeAction(io);return}let{x:i,y:a,lastCommittedPoint:l}=n;if(n.points.length>1&&l&&xt(o.origin.x-i,o.origin.y-a,l[0],l[1])<Na){this.actionManager.executeAction(io);return}this.setState(s=>({selectedElementIds:Pe({...s.selectedElementIds,[n.id]:!0},s)})),F(n,{lastCommittedPoint:n.points[n.points.length-1]}),He(this.interactiveCanvas,Ce.POINTER)}else{let[n,i]=St(o.origin.x,o.origin.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),{currentItemStartArrowhead:l,currentItemEndArrowhead:s}=this.state,[c,d]=r==="arrow"?[l,s]:[null,null],m=Qr({type:r,x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:rt.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:a?a.id:null});this.setState(u=>{let h={...u.selectedElementIds};return delete h[m.id],{selectedElementIds:Pe(h,u)}}),F(m,{points:[...m.points,[0,0]]});let p=Wo(o.origin,this);this.scene.insertElement(m),this.setState({draggingElement:m,editingElement:m,startBoundElement:p,suggestedBindings:[]})}};getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:Ho(t)?rt.ADAPTIVE_RADIUS:rt.PROPORTIONAL_RADIUS}:null}createGenericElementOnPointerDown=(t,r)=>{let[o,n]=St(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i=this.getTopLayerFrameAtSceneCoords({x:o,y:n}),a={x:o,y:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:i?i.id:null},l;t==="embeddable"?l=_h({type:"embeddable",...a}):l=Fr({type:t,...a}),l.type==="selection"?this.setState({selectionElement:l,draggingElement:l}):(this.scene.insertElement(l),this.setState({multiElement:null,draggingElement:l,editingElement:l}))};createFrameElementOnPointerDown=(t,r)=>{let[o,n]=St(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i={x:o,y:n,opacity:this.state.currentItemOpacity,locked:!1,...$e},a=r===bt.magicframe?Bs(i):Kd(i);this.scene.insertElement(a),this.setState({multiElement:null,draggingElement:a,editingElement:a})};maybeCacheReferenceSnapPoints(t,r,o=!1){Un({event:t,appState:this.state,selectedElements:r})&&(o||!co.getReferenceSnapPoints())&&co.setReferenceSnapPoints(f5(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,o=!1){Un({event:t,appState:this.state,selectedElements:r})&&(o||!co.getVisibleGaps())&&co.setVisibleGaps(g5(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return nt(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return nt(r=>{r.key===S.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return fu(r=>{if(t.drag.offset===null&&(t.drag.offset=bo(wg(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;let n=Ue(r,this.state);if(xr(this.state)){this.handleEraser(r,t,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[i,a]=St(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize);if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&xt(n.x,n.y,t.origin.x,t.origin.y)<pn)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleResize(t,r)))return!0;let l=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let m=this.state.editingLinearElement||this.state.selectedLinearElement;if(K.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,l)){let u=K.addMidpoint(this.state.selectedLinearElement,n,this.state,!r[S.CTRL_OR_CMD],l);if(!u)return;Q1(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}})});return}else if(m.pointerDownState.segmentMidpoint.value!==null&&!m.pointerDownState.segmentMidpoint.added)return;if(K.handlePointDragging(r,this.state,n.x,n.y,(u,h)=>{this.maybeSuggestBindingsForLinearElementAtCoords(u,h)},m,this.scene.getNonDeletedElementsMap())){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging&&this.setState({editingLinearElement:{...this.state.editingLinearElement,isDragging:!0}}),this.state.selectedLinearElement.isDragging||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0}});return}}let s=t.hit.allHitElements.some(m=>this.isASelectedElement(m)),c=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((s||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c){let m=this.scene.getSelectedElements(this.state);if(m.every(h=>h.locked))return;let p=m.find(h=>Q(h)),u=this.getTopLayerFrameAtSceneCoords(n);if(this.setState({frameToHighlight:u&&!p?u:null}),t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0}),m.length>0&&!t.withCmdOrCtrl&&!this.state.editingElement&&this.state.activeEmbeddable?.state!=="active"){let h={x:n.x-t.origin.x,y:n.y-t.origin.y},x=[...t.originalElements.values()],E=r.shiftKey;if(E){let y=Math.abs(h.x),I=Math.abs(h.y),P=E&&y<I,C=E&&y>I;P&&(h.x=0),C&&(h.y=0)}this.maybeCacheVisibleGaps(r,m),this.maybeCacheReferenceSnapPoints(r,m);let{snapOffset:v,snapLines:w}=b5(x,h,this.state,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:w}),!this.state.editingFrame&&yg(t,m,h,this.state,this.scene,v,r[S.CTRL_OR_CMD]?null:this.state.gridSize),this.maybeSuggestBindingForAll(m),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let y=[],I=[],P=new Map,C=new Map,_=t.hit.element,D=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(M=>M.id)),H=this.scene.getElementsIncludingDeleted();for(let M of H)if(D.has(M.id)||M.id===_?.id&&t.hit.wasAddedToSelection){let k=Hs(this.state.editingGroupId,P,M),O=t.originalElements.get(M.id);F(k,{x:O.x,y:O.y}),t.originalElements.set(k.id,k),y.push(k),I.push(M),C.set(M.id,k.id)}else y.push(M);let A=[...y,...I];qt(A,$(I)),Pd(y,I,C),Ad(A,I,C,"duplicatesServeAsOld"),Tm(A,I,C),this.scene.replaceAllElements(A),this.maybeCacheVisibleGaps(r,m,!0),this.maybeCacheReferenceSnapPoints(r,m,!0)}return}}let d=this.state.draggingElement;if(d){if(d.type==="freedraw"){let m=d.points,p=n.x-d.x,u=n.y-d.y,h=m.length>0&&m[m.length-1];if(!(h&&h[0]===p&&h[1]===u)){let E=d.simulatePressure?d.pressures:[...d.pressures,r.pressure];F(d,{points:[...m,[p,u]],pressures:E})}}else if(re(d)){t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0});let m=d.points,p=i-d.x,u=a-d.y;qi(r)&&m.length===2&&({width:p,height:u}=el(d.x,d.y,n.x,n.y)),m.length===1?F(d,{points:[...m,[p,u]]}):m.length===2&&F(d,{points:[...m.slice(0,-1),[p,u]]}),Tt(d,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(d,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r);if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let m=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)K.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let p=!0;!r.shiftKey&&ze(m,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(h=>Kt({...h,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),h,this)):p=!1);let u=wl(m,d,this.scene.getNonDeletedElementsMap());this.setState(h=>{let x={...p&&h.selectedElementIds,...u.reduce((E,v)=>(E[v.id]=!0,E),{})};return t.hit.element&&(u.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),h=p?h:{...h,selectedGroupIds:{},editingGroupId:null},{...Kt({editingGroupId:h.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),h,this),selectedLinearElement:u.length===1&&re(u[0])?new K(u[0]):null,showHyperlinkPopup:u.length===1&&(u[0].link||vt(u[0]))?"info":!1}})}}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let o=t.clientX,n=o-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-n/this.state.zoom.value}),r.lastCoords.x=o,!0}if(r.scrollbars.isOverVertical){let o=t.clientY,n=o-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-n/this.state.zoom.value}),r.lastCoords.y=o,!0}return!1}onPointerUpFromPointerDownHandler(t){return nt(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{draggingElement:o,resizingElement:n,multiElement:i,activeTool:a,isResizing:l,isRotating:s}=this.state;this.setState(u=>({isResizing:!1,isRotating:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",editingElement:i||U(this.state.editingElement)?this.state.editingElement:null,snapLines:ud(u.snapLines,[]),originSnapOffset:null})),co.setReferenceSnapPoints(null),co.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let c=this.scene.getNonDeletedElementsMap();if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(io);else{let u=K.handlePointerUp(r,this.state.editingLinearElement,this.state,this);u!==this.state.editingLinearElement&&this.setState({editingLinearElement:u,suggestedBindings:[]})}else if(this.state.selectedLinearElement)if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let u=K.handlePointerUp(r,this.state.selectedLinearElement,this.state,this),{startBindingElement:h,endBindingElement:x}=u,E=this.scene.getElement(u.elementId);Tt(E)&&xn(E,h,x,c),u!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(a,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),o?.type==="freedraw"){let u=Ue(r,this.state),h=o.points,x=u.x-o.x,E=u.y-o.y;x===h[0][0]&&E===h[0][1]&&(E+=1e-4,x+=1e-4);let v=o.simulatePressure?[]:[...o.pressures,r.pressure];F(o,{points:[...h,[x,E]],pressures:v,lastCommittedPoint:[x,E]}),this.actionManager.executeAction(io);return}if(Zr(o)){let u=o;try{this.initializeImageDimensions(u),this.setState({selectedElementIds:Pe({[u.id]:!0},this.state)},()=>{this.actionManager.executeAction(io)})}catch(h){console.error(h),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(x=>x.id!==u.id)),this.actionManager.executeAction(io)}return}if(re(o)){o.points.length>1&&this.history.resumeRecording();let u=Ue(r,this.state);!t.drag.hasOccurred&&o&&!i?(F(o,{points:[...o.points,[u.x-o.x,u.y-o.y]]}),this.setState({multiElement:o,editingElement:this.state.draggingElement})):t.drag.hasOccurred&&!i&&(Uo(this.state)&&Tt(o,!1)&&Ps(o,this.state,u,this),this.setState({suggestedBindings:[],startBoundElement:null}),a.locked?this.setState(h=>({draggingElement:null})):(Or(this.interactiveCanvas),this.setState(h=>({draggingElement:null,activeTool:Xe(this.state,{type:"selection"}),selectedElementIds:Pe({...h.selectedElementIds,[o.id]:!0},h),selectedLinearElement:new K(o)}))));return}if(a.type!=="selection"&&o&&eo(o)){this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(u=>u.id!==o.id)),this.setState({draggingElement:null});return}if(o){if(t.drag.hasOccurred){let u=Ue(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let h=this.scene.getElement(this.state.selectedLinearElement.elementId);if(h?.frameId){let x=Ot(h,c);x&&h&&(Ko(h,x,this.scene.getNonDeletedElementsMap())||(F(h,{groupIds:[]}),yl([h],this.scene.getNonDeletedElementsMap()),this.scene.informMutation()))}}else{let h=this.getTopLayerFrameAtSceneCoords(u),x=this.scene.getSelectedElements(this.state),E=this.scene.getElementsMapIncludingDeleted(),v=w=>{if(w.length>0){for(let y of w){let I=y.groupIds.indexOf(this.state.editingGroupId);F(y,{groupIds:y.groupIds.slice(0,I)},!1)}E.forEach(y=>{y.groupIds.length&&Je(E,y.groupIds[y.groupIds.length-1]).length<2&&F(y,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(h&&!this.state.selectedElementIds[h.id]){let w=x.filter(y=>y.frameId!==h.id&&sa(y,E,this.state));this.state.editingGroupId&&v(w),E=ec(E,w,h)}else if(!h&&this.state.editingGroupId){let w=x.filter(y=>y.frameId&&!sa(y,E,this.state));v(w)}E=$o(E,this.state,this),this.scene.replaceAllElements(E)}}if(Q(o)){let u=oy(this.scene.getElementsIncludingDeleted(),o,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(ec(this.scene.getElementsMapIncludingDeleted(),u,o))}F(o,Vs(o))}if(n&&this.history.resumeRecording(),n&&eo(n)&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(u=>u.id!==n.id)),t.resize.isResizing){let u=$o(this.scene.getElementsIncludingDeleted(),this.state,this),h=this.scene.getSelectedElements(this.state).filter(x=>Q(x));for(let x of h)u=Sm(u,El(this.scene.getElementsIncludingDeleted(),x,this.state,c),x,this);this.scene.replaceAllElements(u)}let d=t.hit.element;this.state.selectedLinearElement?.elementId!==d?.id&&re(d)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new K(d)});let m=this.lastPointerDownEvent,p=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(xr(this.state)&&m&&p){if(this.eraserTrail.endPath(),xt(m.clientX,m.clientY,p.clientX,p.clientY)===0){let h=Ue({clientX:p.clientX,clientY:p.clientY},this.state);this.getElementsAtPosition(h.x,h.y).forEach(E=>this.elementsPendingErasure.add(E.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(d&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[d.id]?Fd(this.state,d)?this.setState(u=>{let h={...u.selectedElementIds};for(let x of d.groupIds.flatMap(E=>Je(this.scene.getNonDeletedElements(),E)))delete h[x.id];return{selectedGroupIds:{...u.selectedElementIds,...d.groupIds.map(x=>({[x]:!1})).reduce((x,E)=>({...x,...E}),{})},selectedElementIds:Pe(h,u)}}):this.state.selectedLinearElement?.isDragging||this.setState(u=>{let h={...u.selectedElementIds};delete h[d.id];let x=me(this.scene.getNonDeletedElements(),{selectedElementIds:h});return{...Kt({editingGroupId:u.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:x.length===1&&re(x[0])?new K(x[0]):u.selectedLinearElement}}):d.frameId&&this.state.selectedElementIds[d.frameId]?this.setState(u=>{let h={...u.selectedElementIds,[d.id]:!0};return delete h[d.frameId],(this.scene.getElement(d.frameId)?.groupIds??[]).flatMap(x=>Je(this.scene.getNonDeletedElements(),x)).forEach(x=>{delete h[x.id]}),{...Kt({editingGroupId:u.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:d.link||vt(d)?"info":!1}}):this.setState(u=>({selectedElementIds:Pe({...u.selectedElementIds,[d.id]:!0},u)})):this.setState(u=>({...Kt({editingGroupId:u.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:re(d)&&u.selectedLinearElement?.elementId!==d.id?new K(d):u.selectedLinearElement}))),!t.drag.hasOccurred&&!this.state.isResizing&&(d&&TE({x:t.origin.x,y:t.origin.y,element:d,shape:this.getElementShape(d),threshold:this.getHitThreshold(),frameNameBound:Q(d)?this.frameNameBoundsCache.get(d):null},c)||!d&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),He(this.interactiveCanvas,Ce.AUTO);return}if(!a.locked&&a.type!=="freedraw"&&o&&o.type!=="selection"&&this.setState(u=>({selectedElementIds:Pe({...u.selectedElementIds,[o.id]:!0},u),showHyperlinkPopup:vt(o)&&!o.link?"editor":u.showHyperlinkPopup})),(a.type!=="selection"||ze(this.scene.getNonDeletedElements(),this.state))&&this.history.resumeRecording(),(t.drag.hasOccurred||l||s)&&(Uo(this.state)?Ls(this.scene.getSelectedElements(this.state),this):_s(this.scene.getNonDeletedElements(),c)),a.type==="laser"){this.laserTrails.endPath();return}!a.locked&&a.type!=="freedraw"?(Or(this.interactiveCanvas),this.setState({draggingElement:null,suggestedBindings:[],activeTool:Xe(this.state,{type:"selection"})})):this.setState({draggingElement:null,suggestedBindings:[]}),d&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&De.pointers.size<=1&&Vt(d)&&this.isIframeLikeElementCenter(d,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(d)})}restoreReadyToEraseElements=()=>{this.elementsPendingErasure=new Set,this.onSceneUpdated()};eraseElements=()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(o=>this.elementsPendingErasure.has(o.id)||o.frameId&&this.elementsPendingErasure.has(o.frameId)||Ne(o)&&this.elementsPendingErasure.has(o.containerId)?(t=!0,ne(o,{isDeleted:!0})):o);this.elementsPendingErasure=new Set,t&&(this.history.resumeRecording(),this.scene.replaceAllElements(r))};initializeImage=async({imageFile:t,imageElement:r,showCursorImagePreview:o=!1})=>{if(!di(t))throw new Error(b("errors.unsupportedFileType"));let n=t.type;if(He(this.interactiveCanvas,"wait"),n===J.svg)try{t=Vh(await bE(await t.text()),t.name)}catch(c){throw console.warn(c),new Error(b("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(t)||dE(t));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(b("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{t=await Ks(t,{maxWidthOrHeight:qb})}catch(c){console.error("Error trying to resizing image file on insertion",c)}if(t.size>Ou)throw new Error(b("errors.fileTooBig",{maxSize:`${Math.trunc(Ou/1024/1024)}MB`}))}if(o){let c=this.files[i]?.dataURL,d=c&&mE(c);this.setImagePreviewCursor(d||t)}let l=this.files[i]?.dataURL||await Jd(t),s=F(r,{fileId:i},!1);return new Promise(async(c,d)=>{try{this.files={...this.files,[i]:{mimeType:n,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}};let m=this.imageCache.get(i);m||(this.addNewImagesToImageCache(),await this.updateImageCache([s])),m?.image instanceof Promise&&await m.image,this.state.pendingImageElementId!==s.id&&this.state.draggingElement?.id!==s.id&&this.initializeImageDimensions(s,!0),c(s)}catch(m){console.error(m),d(new Error(b("errors.imageInsertError")))}finally{o||Or(this.interactiveCanvas)}})};insertImageElement=async(t,r,o)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:b("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:o})}catch(n){return F(t,{isDeleted:!0}),this.actionManager.executeAction(io),this.setState({errorMessage:n.message||b("errors.imageInsertError")}),null}};setImagePreviewCursor=async t=>{let o;try{o=await Ks(t,{maxWidthOrHeight:96})}catch(i){throw i.cause==="UNSUPPORTED"?new Error(b("errors.unsupportedFileType")):i}let n=await Jd(o);if(t.type===J.svg){let i=await $h(n),a=Math.min(i.height,96),l=a*(i.width/i.height);l>96&&(l=96,a=l*(i.height/i.width));let s=document.createElement("canvas");s.height=a,s.width=l,s.getContext("2d").drawImage(i,0,0,l,a),n=s.toDataURL(J.svg)}this.state.pendingImageElementId&&He(this.interactiveCanvas,`url(${n}) 4 4, auto`)};onImageAction=async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Ue({clientX:r,clientY:o},this.state),a=await al({description:"Image",extensions:Object.keys(cs)}),l=this.createImageElement({sceneX:n,sceneY:i,addToFrameUnderCursor:!1});t?(this.insertImageElement(l,a),this.initializeImageDimensions(l),this.setState({selectedElementIds:Pe({[l.id]:!0},this.state)},()=>{this.actionManager.executeAction(io)})):this.setState({pendingImageElementId:l.id},()=>{this.insertImageElement(l,a,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,editingElement:null,activeTool:Xe(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(io)})}};initializeImageDimensions=(t,r=!1)=>{let o=nr(t)&&this.imageCache.get(t.fileId)?.image;if(!o||o instanceof Promise){if(t.width<pn/this.state.zoom.value&&t.height<pn/this.state.zoom.value){let n=100/this.state.zoom.value;F(t,{x:t.x-n/2,y:t.y-n/2,width:n,height:n})}return}if(r||t.width<pn/this.state.zoom.value&&t.height<pn/this.state.zoom.value){let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),l=a*(o.naturalWidth/o.naturalHeight),s=t.x+t.width/2-l/2,c=t.y+t.height/2-a/2;F(t,{x:s,y:c,width:l,height:a})}};updateImageCache=async(t,r=this.files)=>{let{updatedFiles:o,erroredFiles:n}=await rm({imageCache:this.imageCache,fileIds:t.map(i=>i.fileId),files:r});if(o.size||n.size)for(let i of t)o.has(i.fileId)&&ke.delete(i);return n.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(i=>nr(i)&&n.has(i.fileId)?ne(i,{status:"error"}):i)),{updatedFiles:o,erroredFiles:n}};addNewImagesToImageCache=async(t=om(this.scene.getNonDeletedElements()),r=this.files)=>{let o=t.filter(n=>!n.isDeleted&&!this.imageCache.has(n.fileId));if(o.length){let{updatedFiles:n}=await this.updateImageCache(o,r);n.size&&this.scene.informMutation()}};scheduleImageRefresh=FP(()=>{this.addNewImagesToImageCache()},Gb);updateBindingEnabledOnPointerMove=t=>{let r=d0(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})};maybeSuggestBindingAtCursor=t=>{let r=Wo(t,this);this.setState({suggestedBindings:r!=null?[r]:[]})};maybeSuggestBindingsForLinearElementAtCoords=(t,r,o)=>{if(!r.length)return;let n=r.reduce((i,a)=>{let l=Wo(a,this);return l!=null&&!fh(t,o?.id,l)&&i.push(l),i},[]);this.setState({suggestedBindings:n})};maybeSuggestBindingForAll(t){if(t.length>50)return;let r=p0(t,this);this.setState({suggestedBindings:r})}clearSelection(t){this.setState(r=>({selectedElementIds:Pe({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&oa(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Pe({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}handleInteractiveCanvasRef=t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("wheel",this.handleWheel),this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("wheel",this.handleWheel),this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))};handleAppOnDrop=async t=>{let{file:r,fileHandle:o}=await uE(t),{x:n,y:i}=Ue(t,this.state);try{if(di(r)&&this.isToolSupported("image")){if(r?.type===J.png||r?.type===J.svg)try{let s=await pl(r,this.state,this.scene.getElementsIncludingDeleted(),o);this.syncActionResult({...s,appState:{...s.appState||this.state,isLoading:!1},replaceFiles:!0,commitToHistory:!0});return}catch(s){if(s.name!=="EncodingError")throw new Error(b("alerts.couldNotLoadInvalidFile"))}let l=this.createImageElement({sceneX:n,sceneY:i});this.insertImageElement(l,r),this.initializeImageDimensions(l),this.setState({selectedElementIds:Pe({[l.id]:!0},this.state)});return}}catch(l){return this.setState({isLoading:!1,errorMessage:l.message})}let a=t.dataTransfer.getData(J.excalidrawlib);if(a&&typeof a=="string"){try{let l=Uh(a);this.addElementsFromPasteOrLibrary({elements:yp(l),position:t,files:null})}catch(l){this.setState({errorMessage:l.message})}return}if(r&&await this.loadFileToCanvas(r,o),t.dataTransfer?.types?.includes("text/plain")){let l=t.dataTransfer?.getData("text");if(l&&il(l,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(l)||kn(l)?.type==="video")){let s=this.insertEmbeddableElement({sceneX:n,sceneY:i,link:lr(l)});s&&this.setState({selectedElementIds:{[s.id]:!0}})}}};loadFileToCanvas=async(t,r)=>{t=await $s(t);try{let o;try{o=await qd(t,this.state,this.scene.getElementsIncludingDeleted(),r)}catch(n){let i=n instanceof yo;if(i&&n.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:b("errors.imageToolNotSupported")});return}let a=i?b("alerts.cannotRestoreFromImage"):b("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:a})}if(!o)return;o.type===J.excalidraw?(this.setState({isLoading:!0}),this.syncActionResult({...o.data,appState:{...o.data.appState||this.state,isLoading:!1},replaceFiles:!0,commitToHistory:!0})):o.type===J.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(n=>{console.error(n),this.setState({errorMessage:b("errors.importLibraryError")})})}catch(o){this.setState({isLoading:!1,errorMessage:o.message})}};handleCanvasContextMenu=t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Vn.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:o}=Ue(t,this.state),n=this.getElementAtPosition(r,o,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:o},i),l=n||a?"element":"canvas",s=this.excalidrawContainerRef.current,{top:c,left:d}=s.getBoundingClientRect(),m=t.clientX-d,p=t.clientY-c;fe("contextMenu","openContextMenu",l),this.setState({...n&&!this.state.selectedElementIds[n.id]?{...this.state,...Kt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[n.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:re(n)?new K(n):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:p,left:m,items:this.getContextMenuItems(l)}})})};maybeDragNewGenericElement=(t,r)=>{let o=this.state.draggingElement,n=t.lastCoords;if(o)if(o.type==="selection"&&this.state.activeTool.type!=="eraser")Nm(o,this.state.activeTool.type,t.origin.x,t.origin.y,n.x,n.y,Mt(t.origin.x,n.x),Mt(t.origin.y,n.y),ja(r),Cd(r));else{let[i,a]=St(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),l=nr(o)&&this.imageCache.get(o.fileId)?.image,s=l&&!(l instanceof Promise)?l.width/l.height:null;this.maybeCacheReferenceSnapPoints(r,[o]);let{snapOffset:c,snapLines:d}=E5(o,this.state,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:i-t.originInGrid.x,y:a-t.originInGrid.y},this.scene.getNonDeletedElementsMap());i+=c.x,a+=c.y,this.setState({snapLines:d}),Nm(o,this.state.activeTool.type,t.originInGrid.x,t.originInGrid.y,i,a,Mt(t.originInGrid.x,i),Mt(t.originInGrid.y,a),Zr(o)?!ja(r):ja(r),Cd(r),s,this.state.originSnapOffset),this.maybeSuggestBindingForAll([o]),(this.state.activeTool.type===bt.frame||this.state.activeTool.type===bt.magicframe)&&this.setState({elementsToHighlight:El(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap())})}};maybeHandleResize=(t,r)=>{let o=this.scene.getSelectedElements(this.state),n=o.filter(d=>Q(d)),i=t.resize.handleType;if(n.length>0&&i==="rotation")return!1;this.setState({isResizing:i&&i!=="rotation",isRotating:i==="rotation",activeEmbeddable:null});let a=t.lastCoords,[l,s]=St(a.x-t.resize.offset.x,a.y-t.resize.offset.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),c=new Map;if(n.forEach(d=>{Hr(this.scene.getNonDeletedElements(),d.id).forEach(p=>{c.set(d.id+p.id,{x:p.x-d.x,y:p.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,m]=St(a.x,a.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),p={x:d-t.originInGrid.x,y:m-t.originInGrid.y},u=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,o);let{snapOffset:h,snapLines:x}=x5(o,me(u,this.state),this.state,r,p,i);l+=h.x,s+=h.y,this.setState({snapLines:x})}if(hg(t.originalElements,i,o,this.scene.getElementsMapIncludingDeleted(),qi(r),Cd(r),o.length===1&&Zr(o[0])?!ja(r):ja(r),l,s,t.resize.center.x,t.resize.center.y)){this.maybeSuggestBindingForAll(o);let d=new Set;return n.forEach(m=>{El(this.scene.getNonDeletedElements(),m,this.state,this.scene.getNonDeletedElementsMap()).forEach(p=>d.add(p))}),this.setState({elementsToHighlight:[...d]}),!0}return!1};getContextMenuItems=t=>{let r=[];return r.push(pp,mp),t==="canvas"?this.state.viewModeEnabled?[...r,hp,zl,W1,Ei]:[Mf,dr,pp,mp,up,dr,rf,Tv,dr,hp,Lf,zl,W1,Ei]:(r.push(up),this.state.viewModeEnabled?[Hl,...r]:[dp,Hl,Mf,c5,d5,dr,...r,dr,wf,vf,dr,Tf,Pf,_f,gv,Sf,dr,Cf,dr,Jg,Qg,ef,tf,dr,kf,Af,dr,m1,yc,of,Ff,dr,mc])};handleWheel=nt(t=>{if(t.preventDefault(),Hc)return;let{deltaX:r,deltaY:o}=t;if(t.metaKey||t.ctrlKey){let n=Math.sign(o),i=Gi*100,a=Math.abs(o),l=o;a>i&&(l=i*n);let s=this.state.zoom.value-l/100;s+=Math.log10(Math.max(1,this.state.zoom.value))*-n*Math.min(1,a/20),this.translateCanvas(c=>({...Nn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Xo(s)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:n,scrollX:i})=>({scrollX:i-(o||r)/n.value}));return}this.translateCanvas(({zoom:n,scrollX:i,scrollY:a})=>({scrollX:i-r/n.value,scrollY:a-o/n.value}))});getTextWysiwygSnappedToCenterPosition(t,r,o,n){if(n){let i=n.x+n.width/2,a=n.y+n.height/2,l=Nd(n,o,this.scene.getNonDeletedElementsMap());if(l&&(i=l.x,a=l.y),Math.hypot(t-i,r-a)<Bb){let{x:d,y:m}=Dt({sceneX:i,sceneY:a},o);return{viewportX:d,viewportY:m,elementCenterX:i,elementCenterY:a}}}}savePointer=(t,r,o)=>{if(!t||!r)return;let{x:n,y:i}=Ue({clientX:t,clientY:r},this.state);isNaN(n)||isNaN(i);let a={x:n,y:i,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:a,button:o,pointersMap:De.pointers})};resetShouldCacheIgnoreZoomDebounced=Wi(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300);updateDOMRect=t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:o,height:n,left:i,top:a}=r.getBoundingClientRect(),{width:l,height:s,offsetTop:c,offsetLeft:d}=this.state;if(o===l&&n===s&&i===d&&a===c){t&&t();return}this.setState({width:o,height:n,offsetLeft:i,offsetTop:a},()=>{t&&t()})}};refresh=()=>{this.setState({...this.getCanvasOffsets()})};getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:o}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:o}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=_a.find(r=>r.code===this.props.langCode)||Ro;await Kc(t),this.setAppState({})}},HP=()=>{(T.MODE===ls.TEST||T.DEV)&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(Mr(e))}}}))};HP();var j5=nb;z();f();var GP=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},q5=GP;G();import{Provider as t7}from"jotai";f();import UP from"clsx";import{jsx as J5}from"react/jsx-runtime";var Q5=({children:e})=>{let{FooterCenterTunnel:t}=et(),r=Me();return J5(t.In,{children:J5("div",{className:UP("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":r.zenModeEnabled}),children:e})})},WP=Q5;Q5.displayName="FooterCenter";f();f();f();import{jsx as Ri,jsxs as tS}from"react/jsx-runtime";var VP=()=>Ri("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Ri("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),YP=()=>tS("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Ri("path",{d:"M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z",transform:"translate(-144.023 -51.76)"}),Ri("path",{d:"M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z",transform:"translate(-144.023 -51.76)"}),Ri("path",{d:"M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z",transform:"translate(-144.023 -51.76)"}),Ri("path",{d:"m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z",fill:"currentColor",transform:"translate(-144.023 -51.76)"})]}),eS=({style:e,size:t="small",withText:r})=>tS("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Ri(VP,{}),r&&Ri(YP,{})]});import{Fragment as nS,jsx as Ct,jsxs as mb}from"react/jsx-runtime";var pb=({icon:e,shortcut:t,children:r})=>{let o=Ie();return mb(nS,{children:[Ct("div",{className:"welcome-screen-menu-item__icon",children:e}),Ct("div",{className:"welcome-screen-menu-item__text",children:r}),t&&!o.editor.isMobile&&Ct("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};pb.displayName="WelcomeScreenMenuItemContent";var Uc=({onSelect:e,children:t,icon:r,shortcut:o,className:n="",...i})=>Ct("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Ct(pb,{icon:r,shortcut:o,children:t})});Uc.displayName="WelcomeScreenMenuItem";var rS=({children:e,href:t,icon:r,shortcut:o,className:n="",...i})=>Ct("a",{...i,className:`welcome-screen-menu-item ${n}`,href:t,target:"_blank",rel:"noreferrer",children:Ct(pb,{icon:r,shortcut:o,children:e})});rS.displayName="WelcomeScreenMenuItemLink";var uo=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=et();return Ct(t.In,{children:Ct("div",{className:"welcome-screen-center",children:e||mb(nS,{children:[Ct(ub,{}),Ct(hb,{children:b("welcomeScreen.defaults.center_heading")}),mb(gb,{children:[Ct(bb,{}),Ct(fb,{})]})]})})})};uo.displayName="Center";var ub=({children:e})=>Ct("div",{className:"welcome-screen-center__logo virgil welcome-screen-decor",children:e||Ct(eS,{withText:!0})});ub.displayName="Logo";var hb=({children:e})=>Ct("div",{className:"welcome-screen-center__heading welcome-screen-decor virgil",children:e});hb.displayName="Heading";var gb=({children:e})=>Ct("div",{className:"welcome-screen-menu",children:e});gb.displayName="Menu";var fb=()=>{let e=_t();return Ct(Uc,{onSelect:()=>e.executeAction(Sa),shortcut:"?",icon:Il,children:b("helpDialog.title")})};fb.displayName="MenuItemHelp";var bb=()=>{let e=Me(),t=_t();return e.viewModeEnabled?null:Ct(Uc,{onSelect:()=>t.executeAction(Nl),shortcut:It("loadScene"),icon:Cl,children:b("buttons.load")})};bb.displayName="MenuItemLoadScene";var oS=({onSelect:e})=>{let{t}=yt();return Ct(Uc,{shortcut:null,onSelect:e,icon:Um,children:t("labels.liveCollaboration")})};oS.displayName="MenuItemLiveCollaborationTrigger";uo.Logo=ub;uo.Heading=hb;uo.Menu=gb;uo.MenuItem=Uc;uo.MenuItemLink=rS;uo.MenuItemHelp=fb;uo.MenuItemLoadScene=bb;uo.MenuItemLiveCollaborationTrigger=oS;f();import{jsx as os,jsxs as xb}from"react/jsx-runtime";var Iu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=et();return os(t.In,{children:xb("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Py,os("div",{className:"welcome-screen-decor-hint__label",children:e||b("welcomeScreen.defaults.menuHint")})]})})};Iu.displayName="MenuHint";var Cu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=et();return os(t.In,{children:xb("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[os("div",{className:"welcome-screen-decor-hint__label",children:e||b("welcomeScreen.defaults.toolbarHint")}),Dy]})})};Cu.displayName="ToolbarHint";var ku=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=et();return os(t.In,{children:xb("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[os("div",{children:e||b("welcomeScreen.defaults.helpHint")}),_y]})})};ku.displayName="HelpHint";import{Fragment as iS,jsx as Wc,jsxs as $P}from"react/jsx-runtime";var Au=e=>Wc(iS,{children:e.children||$P(iS,{children:[Wc(uo,{}),Wc(Iu,{}),Wc(Cu,{}),Wc(ku,{})]})});Au.displayName="WelcomeScreen";Au.Center=uo;Au.Hints={MenuHint:Iu,ToolbarHint:Cu,HelpHint:ku};var KP=Au;f();import XP from"clsx";import{jsx as jP,jsxs as qP}from"react/jsx-runtime";var aS=({isCollaborating:e,onSelect:t,...r})=>{let o=Me(),n=o.width<830;return qP(Jo,{...r,className:XP("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:n?void 0:"auto"},title:b("labels.liveCollaboration"),children:[n?r2:b("labels.share"),o.collaborators.size>0&&jP("div",{className:"CollabButton-collaborators",children:o.collaborators.size})]})},ZP=aS;aS.displayName="LiveCollaborationTrigger";ge();cl();da();Pn();Er();bn();ce();G();We();z();f();import{jsx as lS,jsxs as JP}from"react/jsx-runtime";var sS=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:r}=et(),o=_e();return lS(r.In,{children:JP(Oe.Item,{onSelect:()=>{fe("ai","dialog open","ttd"),o({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??K2,children:[e??b("labels.textToDiagram"),lS(Oe.Item.Badge,{children:"AI"})]})})};sS.displayName="TTDDialogTrigger";rl();at();ag();import{jsx as Eb}from"react/jsx-runtime";q5();var r7=e=>{let{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n=!1,onPointerUpdate:i,renderTopRightUI:a,langCode:l=Ro.code,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:h,onPaste:x,detectScroll:E=!0,handleKeyboardGlobally:v=!1,onLibraryChange:w,autoFocus:y=!1,generateIdForFile:I,onLinkOpen:P,onPointerDown:C,onPointerUp:_,onScrollChange:D,children:H,validateEmbeddable:A,renderEmbeddable:M,aiEnabled:k}=e,O=e.UIOptions?.canvasActions,X={...e.UIOptions,canvasActions:{...Nu.canvasActions,...O},tools:{image:e.UIOptions?.tools?.image??!0}};return O?.export&&(X.canvasActions.export.saveFileToDisk=O.export?.saveFileToDisk??Nu.canvasActions.export.saveFileToDisk),X.canvasActions.toggleTheme===null&&typeof p>"u"&&(X.canvasActions.toggleTheme=!0),e7(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ee=xe=>{typeof xe.scale=="number"&&xe.scale!==1&&xe.preventDefault()};return document.addEventListener("touchmove",ee,{passive:!1}),()=>{document.removeEventListener("touchmove",ee)}},[]),Eb(t7,{unstable_createStore:()=>Xt,scope:Be,children:Eb(rx,{langCode:l,theme:p,children:Eb(j5,{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n,onPointerUpdate:i,renderTopRightUI:a,langCode:l,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:h,UIOptions:X,onPaste:x,detectScroll:E,handleKeyboardGlobally:v,onLibraryChange:w,autoFocus:y,generateIdForFile:I,onLinkOpen:P,onPointerDown:C,onPointerUp:_,onScrollChange:D,validateEmbeddable:A,renderEmbeddable:M,aiEnabled:k!==!1,children:H})})})},o7=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:r,UIOptions:o={},...n}=e,{initialData:i,UIOptions:a={},...l}=t,s=Object.keys(o),c=Object.keys(a);return s.length!==c.length?!1:s.every(m=>m==="canvasActions"?Object.keys(o.canvasActions).every(u=>u==="export"&&o?.canvasActions?.export&&a?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:o?.canvasActions?.[u]===a?.canvasActions?.[u]):o[m]===a[m])&&wt(n,l)},n7=QP.memo(r7,o7);n7.displayName="Excalidraw";export{Jo as Button,Du as DEFAULT_LASER_COLOR,ru as DefaultSidebar,n7 as Excalidraw,it as FONT_FAMILY,WP as Footer,ZP as LiveCollaborationTrigger,J as MIME_TYPES,mr as MainMenu,rt as ROUNDNESS,zn as Sidebar,oe as THEME,U1 as TTDDialog,sS as TTDDialogTrigger,KP as WelcomeScreen,li as bumpVersion,_c as convertToExcalidrawElements,Ro as defaultLang,VE as elementPartiallyOverlapsWithOrContainsBBox,ig as elementsOverlappingBBox,wm as exportToBlob,hi as exportToCanvas,H6 as exportToClipboard,xl as exportToSvg,we as getCommonBounds,Zd as getFreeDrawSvgPath,Ep as getLibraryItemsHash,be as getNonDeletedElements,cC as getSceneVersion,HI as getVisibleSceneBounds,vg as hashElementsVersion,Tg as hashString,ng as isElementInsideBBox,eo as isInvisiblySmallElement,re as isLinearElement,_a as languages,pl as loadFromBlob,Wh as loadLibraryFromBlob,qd as loadSceneOrLibraryFromBlob,Dv as mergeLibraryItems,F as mutateElement,ne as newElementWith,lr as normalizeLink,Gf as parseLibraryTokensFromUrl,ci as restore,q0 as restoreAppState,Ws as restoreElements,aa as restoreLibraryItems,Dt as sceneCoordsToViewportCoords,mi as serializeAsJSON,tm as serializeLibraryAsJSON,Ie as useDevice,Nk as useHandleLibrary,yt as useI18n,Ue as viewportCoordsToSceneCoords,$w as zoomToFitBounds};
182
+ `),c=s.reduce((d,m,p)=>{let u=m.trim(),h=_r(i.fontFamily);if(u.length){let x=this.getTopLayerFrameAtSceneCoords({x:o,y:l}),E=Nt({...i,x:o,y:l,text:u,lineHeight:h,frameId:x?x.id:null});d.push(E),l+=E.height+a}else s[p-1]?.trim()&&(l+=ii(i.fontSize,h)+a);return d},[]);c.length!==0&&(this.scene.insertElements(c),this.setState({selectedElementIds:Pe(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)}),!r&&c.length>1&&Z5===!1&&!this.device.editor.isMobile&&(this.setToast({message:b("toast.pasteAsSingleElement",{shortcut:R("CtrlOrCmd+Shift+V")}),duration:5e3}),Z5=!0),this.history.resumeRecording())}setAppState=(t,r)=>{this.setState(t,r)};removePointer=t=>{_i&&this.resetContextMenuTimer(),De.pointers.delete(t.pointerId)};toggleLock=(t="ui")=>{this.state.activeTool.locked||fe("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Xe(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))};updateFrameRendering=t=>{this.setState(r=>{let o=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:o?.enabled??r.frameRendering.enabled,clip:o?.clip??r.frameRendering.clip,name:o?.name??r.frameRendering.name,outline:o?.outline??r.frameRendering.outline}}})};togglePenMode=t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))};onHandToolToggle=()=>{this.actionManager.executeAction(qw)};zoomCanvas=t=>{this.setState({...Nn({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Xo(t)},this.state)})};cancelInProgressAnimation=null;scrollToContent=(t=this.scene.getNonDeletedElements(),r)=>{this.cancelInProgressAnimation?.();let o=Array.isArray(t)?t:[t],n=this.state.zoom,i=this.state.scrollX,a=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:l}=gc({targetElements:o,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor});n=l.zoom,i=l.scrollX,a=l.scrollY}else{let l=Yo(o,this.state);i=l.scrollX,a=l.scrollY}if(r?.animate){let l=this.state.scrollX,s=this.state.scrollY,c=this.state.zoom.value,d=cx({fromValues:{scrollX:l,scrollY:s,zoom:c},toValues:{scrollX:i,scrollY:a,zoom:n.value},interpolateValue:(m,p,u,h)=>{if(h==="zoom")return m*Math.pow(p/m,hn(u))},onStep:({scrollX:m,scrollY:p,zoom:u})=>{this.setState({scrollX:m,scrollY:p,zoom:{value:u}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:i,scrollY:a,zoom:n})};maybeUnfollowRemoteUser=()=>{this.state.userToFollow&&this.setState({userToFollow:null})};translateCanvas=t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)};setToast=t=>{this.setState({toast:t})};restoreFileFromShare=async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let o=await r.blob(),n=new File([o],o.name||"",{type:o.type});this.loadFileToCanvas(n,null),await t.delete("shared-file"),window.history.replaceState(null,as,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}};addFiles=nt(t=>{let r=t.reduce((o,n)=>(o.set(n.id,n),o),new Map);this.files={...this.files,...Object.fromEntries(r)},this.scene.getNonDeletedElements().forEach(o=>{nr(o)&&r.has(o.fileId)&&(this.imageCache.delete(o.fileId),ke.delete(o))}),this.scene.informMutation(),this.addNewImagesToImageCache()});updateScene=nt(t=>{t.commitToHistory&&this.history.resumeRecording(),t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(t.elements),t.collaborators&&this.setState({collaborators:t.collaborators})});onSceneUpdated=()=>{this.setState({})};toggleSidebar=({name:t,tab:r,force:o})=>{let n;o===void 0?n=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:n=o?t:null;let i=n?{name:n}:null;return i&&r&&(i.tab=r),this.setState({openSidebar:i}),!!n};updateCurrentCursorPosition=nt(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY});onKeyDown=nt(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(i,a){let l=i[a];return typeof l=="function"?l.bind(i):a==="key"?t.shiftKey?i.key.toUpperCase():i.key.toLowerCase():l}})),t[S.CTRL_OR_CMD]&&t.key===S.P&&!t.shiftKey&&!t.altKey){this.setToast({message:b("commandPalette.shortcutHint",{shortcut:It("commandPalette")})}),t.preventDefault();return}if(t[S.CTRL_OR_CMD]&&t.key.toLowerCase()===S.V&&(Iu=t.shiftKey,clearTimeout(X5),X5=window.setTimeout(()=>{Iu=!1},100)),t[S.CTRL_OR_CMD]&&Xr(t.target)&&(t.code===he.MINUS||t.code===he.EQUAL)){t.preventDefault();return}if(Xr(t.target)&&t.key!==S.ESCAPE||ja(t.key)&&Uu(t.target))return;if(t.key===S.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===S.E&&t.shiftKey&&t[S.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===S.PAGE_UP||t.key===S.PAGE_DOWN){let i=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===S.PAGE_DOWN&&(i=-i),t.shiftKey?this.translateCanvas(a=>({scrollX:a.scrollX+i})):this.translateCanvas(a=>({scrollY:a.scrollY+i}))}if(this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[S.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),ja(t.key)){let i=this.state.gridSize&&(t.shiftKey?Ru:this.state.gridSize)||(t.shiftKey?Bb:Ru),a=0,l=0;t.key===S.ARROW_LEFT?a=-i:t.key===S.ARROW_RIGHT?a=i:t.key===S.ARROW_UP?l=-i:t.key===S.ARROW_DOWN&&(l=i);let s=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});s.forEach(c=>{F(c,{x:c.x+a,y:c.y+l}),So(c,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:s})}),this.maybeSuggestBindingForAll(s),t.preventDefault()}else if(t.key===S.ENTER){let i=this.scene.getSelectedElements(this.state);if(i.length===1){let a=i[0];if(t[S.CTRL_OR_CMD])re(a)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==i[0].id)&&(this.history.resumeRecording(),this.setState({editingLinearElement:new K(a)}));else if(G(a)||C0(a)){let l;G(a)||(l=a);let s=Nd(a,this.state,this.scene.getNonDeletedElementsMap()),c=s.x,d=s.y;this.startTextEditing({sceneX:c,sceneY:d,container:l}),t.preventDefault();return}else Q(a)&&this.setState({editingFrame:a.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&this.state.draggingElement===null){let i=E3(t.key);i?(this.state.activeTool.type!==i&&fe("toolbar",i,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setActiveTool({type:i}),t.stopPropagation()):t.key===S.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===S.SPACE&&De.pointers.size===0&&(Ma=!0,He(this.interactiveCanvas,Ce.GRAB),t.preventDefault()),(t.key===S.G||t.key===S.S)&&!t.altKey&&!t[S.CTRL_OR_CMD]){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;t.key===S.G&&(fn(this.state.activeTool.type)||i.some(a=>fn(a.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===S.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(t.key===S.K&&!t.altKey&&!t[S.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[S.CTRL_OR_CMD]&&(t.key===S.BACKSPACE||t.key===S.DELETE)&&Xt.set(ka,"clearCanvas");let r=t.key.toLocaleLowerCase(),o=r===S.S&&t.shiftKey,n=t.key===S.I||r===S.G&&t.shiftKey;(o||n)&&this.openEyeDropper({type:o?"stroke":"background"})});onWheel=nt(t=>{!(t.target instanceof HTMLCanvasElement)&&t.ctrlKey&&t.preventDefault()});onKeyUp=nt(t=>{if(t.key===S.SPACE&&(this.state.viewModeEnabled?He(this.interactiveCanvas,Ce.GRAB):this.state.activeTool.type==="selection"?Or(this.interactiveCanvas):(Br(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Ma=!1),!t[S.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),ja(t.key)){let r=this.scene.getSelectedElements(this.state),o=this.scene.getNonDeletedElementsMap();Uo(this.state)?Ls(r,this):_s(r,o),this.setState({suggestedBindings:[]})}});isToolSupported=t=>this.props.UIOptions.tools?.[t]!==!1;setActiveTool=t=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=Xe(this.state,t);r.type==="hand"?He(this.interactiveCanvas,Ce.GRAB):Ma||Br(this.interactiveCanvas,this.state),lx(document.activeElement)&&this.focusContainer(),bs(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(t.type==="image"&&t.insertOnCanvasDirectly)??!1}),this.setState(o=>{let n={snapLines:o.snapLines.length?[]:o.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type!=="selection"?{...o,activeTool:r,selectedElementIds:Pe({},o),selectedGroupIds:Pe({},o),editingGroupId:null,multiElement:null,...n}:{...o,activeTool:r,...n}})};setOpenDialog=t=>{this.setState({openDialog:t})};setCursor=t=>{He(this.interactiveCanvas,t)};resetCursor=()=>{Or(this.interactiveCanvas)};isTouchScreenMultiTouchGesture=()=>De.pointers.size>=2;getName=()=>this.state.name||this.props.name||`${b("labels.untitled")}-${Gu()}`;onGestureStart=nt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Pe({},this.state),activeEmbeddable:null}),De.initialScale=this.state.zoom.value});onGestureChange=nt(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=De.initialScale;r&&this.setState(o=>({...Nn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Xo(r*t.scale)},o)}))});onGestureEnd=nt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Pe(this.state.previousSelectedElementIds,this.state)}),De.initialScale=null});handleTextWysiwyg(t,{isExistingElement:r=!1}){let o=this.scene.getElementsMapIncludingDeleted(),n=(i,a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&G(s)?Nh(s,st(s,o),o,{text:i,isDeleted:l,originalText:a}):s)])};K5({id:t.id,canvas:this.canvas,getViewportCoords:(i,a)=>{let{x:l,y:s}=Dt({sceneX:i,sceneY:a},this.state);return[l-this.state.offsetLeft,s-this.state.offsetTop]},onChange:nt(i=>{n(i,i,!1),ys(t)&&So(t,o)}),onSubmit:nt(({text:i,viaKeyboard:a,originalText:l})=>{let s=!i.trim();if(n(i,l,s),!s&&a){let c=t.containerId?t.containerId:t.id;this.setState(d=>({selectedElementIds:Pe({...d.selectedElementIds,[c]:!0},d)}))}s&&Qa(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.history.resumeRecording(),this.setState({draggingElement:null,editingElement:null}),this.state.activeTool.locked&&Br(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this}),this.deselectElements(),n(t.text,t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let o=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return o&&G(o)&&!o.isDeleted?o:null}getElementShape(t){switch(t.type){case"rectangle":case"diamond":case"frame":case"magicframe":case"embeddable":case"image":case"iframe":case"text":case"selection":return am(t);case"arrow":case"line":{let r=ke.get(t)?.[0]??ke.generateElementShape(t,null)[0],[,,,,o,n]=te(t,this.scene.getNonDeletedElementsMap());return lm(t)?IE(t,r,[t.x,t.y],t.angle,[o,n]):TE(r,[t.x,t.y],t.angle,[o,n])}case"ellipse":return wE(t);case"freedraw":{let[,,,,r,o]=te(t,this.scene.getNonDeletedElementsMap());return SE(t,[r,o],lm(t))}}}getBoundTextShape(t){let r=de(t,this.scene.getNonDeletedElementsMap());return r?t.type==="arrow"?this.getElementShape({...r,...K.getBoundTextElementPosition(t,r,this.scene.getNonDeletedElementsMap())}):this.getElementShape(r):null}getElementAtPosition(t,r,o){let n=this.getElementsAtPosition(t,r,o?.includeBoundTextElement,o?.includeLockedElements);if(n.length>1){if(o?.preferSelected){for(let a=n.length-1;a>-1;a--)if(this.state.selectedElementIds[n[a].id])return n[a]}let i=n[n.length-1];return Za([t,r],this.getElementShape(i))?i:n[n.length-2]}return n.length===1?n[0]:null}getElementsAtPosition(t,r,o=!1,n=!1){let i=[],a=this.scene.getNonDeletedElementsMap();return(o&&n?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n||!s.locked)&&(o||!(G(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let c=Ot(s,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?cg({x:t,y:r},c,a):!0}).filter(s=>jr(s)?(i.push(s),!1):!0).concat(i)}getHitThreshold(){return 10/this.state.zoom.value}hitElement(t,r,o,n=!0){return n&&this.state.selectedElementIds[o.id]&&_m([o],this.state)?la(t,r,o,this.scene.getNonDeletedElementsMap(),this.getHitThreshold()):kE(t,r,this.getBoundTextShape(o))?!0:ul({x:t,y:r,element:o,shape:this.getElementShape(o),threshold:this.getHitThreshold(),frameNameBound:Q(o)?this.frameNameBoundsCache.get(o):null})}getTextBindableContainerAtPosition(t,r){let o=this.scene.getNonDeletedElements(),n=this.scene.getSelectedElements(this.state);if(n.length===1)return Fo(n[0],!1)?n[0]:null;let i=null;for(let a=o.length-1;a>=0;--a){if(o[a].isDeleted)continue;let[l,s,c,d]=te(o[a],this.scene.getNonDeletedElementsMap());if(Te(o[a])&&ul({x:t,y:r,element:o[a],shape:this.getElementShape(o[a]),threshold:this.getHitThreshold()})){i=o[a];break}else if(l<t&&t<c&&s<r&&r<d){i=o[a];break}}return Fo(i,!1)?i:null}startTextEditing=({sceneX:t,sceneY:r,insertAtParentCenter:o=!0,container:n})=>{let i=!1,a=o&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n);n&&a&&(de(n,this.scene.getNonDeletedElementsMap())||(i=!0));let l=null,s=this.scene.getSelectedElements(this.state);s.length===1?G(s[0])?l=s[0]:n?l=de(s[0],this.scene.getNonDeletedElementsMap()):l=this.getTextElementAtPosition(t,r):l=this.getTextElementAtPosition(t,r);let c=l?.fontFamily||this.state.currentItemFontFamily,d=l?.lineHeight||_r(c),m=this.state.currentItemFontSize;if(!l&&i&&n&&!Te(n)){let x=Rd(Ge({fontSize:m,fontFamily:c}),d),E=Dd(m,d),v=Math.max(n.height,E),w=Math.max(n.width,x);F(n,{height:v,width:w}),t=n.x+w/2,r=n.y+v/2,a&&(a=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n))}let p=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),u=l||Nt({x:a?a.elementCenterX:t,y:a?a.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:m,fontFamily:c,textAlign:a?"center":this.state.currentItemTextAlign,verticalAlign:a?ft.MIDDLE:Hi,containerId:i?n?.id:void 0,groupIds:n?.groupIds??[],lineHeight:d,angle:n?.angle??0,frameId:p?p.id:null});if(!l&&i&&n&&F(n,{boundElements:(n.boundElements||[]).concat({type:"text",id:u.id})}),this.setState({editingElement:u}),!l)if(n&&i){let h=this.scene.getElementIndex(n.id);this.scene.insertElementAtIndex(u,h+1)}else this.scene.insertElement(u);this.setState({editingElement:u}),this.handleTextWysiwyg(u,{isExistingElement:!!l})};handleCanvasDoubleClick=t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state);if(r.length===1&&re(r[0])&&t[S.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)){this.history.resumeRecording(),this.setState({editingLinearElement:new K(r[0])});return}Or(this.interactiveCanvas);let{x:o,y:n}=Ue(t,this.state);if(vn(this.state).length>0){let a=this.getElementAtPosition(o,n),l=a&&D0(a,this.state.selectedGroupIds);if(l){this.setState(s=>({...s,...Kt({editingGroupId:l,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),s,this)}));return}}if(Or(this.interactiveCanvas),!t[S.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let a=this.getElementAtPosition(o,n);if(Vt(a)){this.setState({activeEmbeddable:{element:a,state:"active"}});return}let l=this.getTextBindableContainerAtPosition(o,n);if(l&&(gr(l)||!or(l.backgroundColor)||ul({x:o,y:n,element:l,shape:this.getElementShape(l),threshold:this.getHitThreshold()}))){let s=Nd(l,this.state,this.scene.getNonDeletedElementsMap());o=s.x,n=s.y}this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:l})}};getElementLinkAtPosition=(t,r)=>{let o=this.scene.getNonDeletedElements().slice().reverse(),n=1/0;return o.find((i,a)=>(r&&i.id===r.id&&(n=a),i.link&&a<=n&&cm(i,this.scene.getNonDeletedElementsMap(),this.state,[t.x,t.y],this.device.editor.isMobile)))};redirectToLink=(t,r)=>{let o=xt(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY,this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY);if(!this.hitLinkElement||r&&o>pn||!r&&o!==0)return;let n=Ue(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=cm(this.hitLinkElement,i,this.state,[n.x,n.y],this.device.editor.isMobile),l=Ue(this.lastPointerUpEvent,this.state),s=cm(this.hitLinkElement,i,this.state,[l.x,l.y],this.device.editor.isMobile);if(a&&s){let c=this.hitLinkElement.link;if(c){c=lr(c);let d;if(this.props.onLinkOpen&&(d=pd("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let m=Gd(c)?"_self":"_blank",p=window.open(void 0,m);p&&(p.opener=null,p.location=c)}}}};getTopLayerFrameAtSceneCoords=t=>{let r=this.scene.getNonDeletedElementsMap(),o=this.scene.getNonDeletedFramesLikes().filter(n=>cg(t,n,r));return o.length?o[o.length-1]:null};handleCanvasPointerMove=t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,De.pointers.has(t.pointerId)&&De.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=De.initialScale;if(De.pointers.size===2&&De.lastCenter&&r&&De.initialDistance){let p=h1(De.pointers),u=p.x-De.lastCenter.x,h=p.y-De.lastCenter.y;De.lastCenter=p;let x=g1(Array.from(De.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:x/De.initialDistance,v=E?Xo(r*E):this.state.zoom.value;this.setState(w=>{let y=Nn({viewportX:p.x,viewportY:p.y,nextZoom:v},w);this.translateCanvas({zoom:y.zoom,scrollX:y.scrollX+u/v,scrollY:y.scrollY+h/v,shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else De.lastCenter=De.initialDistance=De.initialScale=null;if(Ma||Hc||rb||Co(this.state))return;let n=E1(ob,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.draggingElement&&!this.state.multiElement&&(n?Or(this.interactiveCanvas):Br(this.interactiveCanvas,this.state));let i=Ue(t,this.state),{x:a,y:l}=i;if(!this.state.draggingElement&&S5(this.state.activeTool.type)){let{originOffset:p,snapLines:u}=T5(this.scene.getNonDeletedElements(),this.state,{x:a,y:l},t,this.scene.getNonDeletedElementsMap());this.setState(h=>{let x=ud(h.snapLines,u),E=h.originSnapOffset?ud(h.originSnapOffset,p):p;return h.snapLines===x&&h.originSnapOffset===E?null:{snapLines:x,originSnapOffset:E}})}else this.state.draggingElement||this.setState(p=>p.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let p=K.handlePointerMove(t,a,l,this.state,this.scene.getNonDeletedElementsMap());p&&p!==this.state.editingLinearElement&&eb(()=>{this.setState({editingLinearElement:p})}),p?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(i):eb(()=>{this.setState({suggestedBindings:[]})})}if(Ku(this.state.activeTool.type)){let{draggingElement:p}=this.state;Tt(p,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(p,[i],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(i)}if(this.state.multiElement){let{multiElement:p}=this.state,{x:u,y:h}=p,{points:x,lastCommittedPoint:E}=p,v=x[x.length-1];if(Br(this.interactiveCanvas,this.state),v===E)xt(a-u,l-h,v[0],v[1])>=Na?F(p,{points:[...x,[a-u,l-h]]}):He(this.interactiveCanvas,Ce.POINTER);else if(x.length>2&&E&&xt(a-u,l-h,E[0],E[1])<Na)He(this.interactiveCanvas,Ce.POINTER),F(p,{points:x.slice(0,-1)});else{let[w,y]=St(a,l,t[S.CTRL_OR_CMD]?null:this.state.gridSize),[I,P]=p?.lastCommittedPoint??[0,0],C=w-u-I,_=y-h-P;qi(t)&&({width:C,height:_}=tl(I+u,P+h,w,y)),ir(x,this.state.zoom.value)&&He(this.interactiveCanvas,Ce.POINTER),F(p,{points:[...x.slice(0,-1),[I+C,P+_]]})}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!n&&!this.state.editingLinearElement){let p=Dm(c,this.state,a,l,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap());if(p&&p.transformHandleType){He(this.interactiveCanvas,Nm(p));return}}else if(d.length>1&&!n){let p=Rm(we(d),a,l,this.state.zoom,t.pointerType);if(p){He(this.interactiveCanvas,Nm({transformHandleType:p}));return}}let m=this.getElementAtPosition(i.x,i.y);this.hitLinkElement=this.getElementLinkAtPosition(i,m),!xr(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(He(this.interactiveCanvas,Ce.POINTER),Sv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Iv(),m&&(m.link||vt(m))&&this.state.selectedElementIds[m.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?He(this.interactiveCanvas,G(m)?Ce.TEXT:Ce.CROSSHAIR):this.state.viewModeEnabled?He(this.interactiveCanvas,Ce.GRAB):n?He(this.interactiveCanvas,Ce.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,l):t[S.CTRL_OR_CMD]?He(this.interactiveCanvas,Ce.AUTO):(m||this.isHittingCommonBoundingBoxOfSelectedElements(i,d))&&!m?.locked&&(m&&Vt(m)&&this.isIframeLikeElementCenter(m,t,a,l)?(He(this.interactiveCanvas,Ce.POINTER),this.setState({activeEmbeddable:{element:m,state:"hover"}})):(He(this.interactiveCanvas,Ce.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))))};handleEraser=(t,r,o)=>{this.eraserTrail.addPointToPath(o.x,o.y);let n=!1,i=new Set,a=this.scene.getNonDeletedElements(),l=p=>{for(let u of p){if(u.locked)return;if(t.altKey?this.elementsPendingErasure.delete(u.id)&&(n=!0):this.elementsPendingErasure.has(u.id)||(n=!0,this.elementsPendingErasure.add(u.id)),n&&u.groupIds?.length){let h=u.groupIds.at(-1);if(!i.has(h)){i.add(h);let x=Je(a,h);for(let E of x)t.altKey?this.elementsPendingErasure.delete(E.id):this.elementsPendingErasure.add(E.id)}}}},s=xt(r.lastCoords.x,r.lastCoords.y,o.x,o.y),c=this.getHitThreshold(),d={...r.lastCoords},m=0;for(;m<=s;){let p=this.getElementsAtPosition(d.x,d.y);if(l(p),m===s)break;m=Math.min(m+c,s);let u=m/s,h=(1-u)*d.x+u*o.x,x=(1-u)*d.y+u*o.y;d.x=h,d.y=x}if(r.lastCoords.x=o.x,r.lastCoords.y=o.y,n){for(let p of this.scene.getNonDeletedElements())Ne(p)&&(this.elementsPendingErasure.has(p.id)||this.elementsPendingErasure.has(p.containerId))&&(t.altKey?(this.elementsPendingErasure.delete(p.id),this.elementsPendingErasure.delete(p.containerId)):(this.elementsPendingErasure.add(p.id),this.elementsPendingErasure.add(p.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.onSceneUpdated()}};handleTouchMove=t=>{zc=!0};handleHoverSelectedLinearElement(t,r,o){let n=this.scene.getNonDeletedElementsMap(),i=K.getElement(t.elementId,n);if(i)if(this.state.selectedLinearElement){let a=-1,l=null;ul({x:r,y:o,element:i,shape:this.getElementShape(i)})?(a=K.getPointIndexUnderCursor(i,n,this.state.zoom,r,o),l=K.getSegmentMidpointHitCoords(t,{x:r,y:o},this.state,this.scene.getNonDeletedElementsMap()),a>=0||l?He(this.interactiveCanvas,Ce.POINTER):He(this.interactiveCanvas,Ce.MOVE)):this.hitElement(r,o,i)&&He(this.interactiveCanvas,Ce.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),K.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}})}else He(this.interactiveCanvas,Ce.AUTO)}handleCanvasPointerDown=t=>{if(this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.draggingElement&&this.state.draggingElement.type==="freedraw"){let c=this.state.draggingElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(d=>d.id!==c.id)}:{},appState:{draggingElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Pe(Object.keys(this.state.selectedElementIds).filter(d=>d!==c.id).reduce((d,m)=>(d[m]=this.state.selectedElementIds[m],d),{}),this.state)}});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Ga(this.device,{isTouchScreen:!0})),Hc||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Vn.ERASER&&this.state.activeTool.type!==bt.eraser){this.setState({activeTool:Xe(this.state,{type:bt.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{d(),m?.(),xr(this.state)&&this.setState({activeTool:Xe(this.state,{...this.state.activeTool.lastActiveTool||{type:bt.selection},lastActiveToolBeforeEraser:null})})},d=pt(window,"pointerup",c,{once:!0}),m;requestAnimationFrame(()=>{m=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==Vn.MAIN&&t.button!==Vn.TOUCH&&t.button!==Vn.ERASER||De.pointers.size>1)return;let o=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,o)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,o))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="text"){this.handleTextOnPointerDown(t,o);return}else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,o);else if(this.state.activeTool.type==="image"){He(this.interactiveCanvas,Ce.CROSSHAIR);let c=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!c)return;this.setState({draggingElement:c,editingElement:c,pendingImageElementId:null,multiElement:null});let{x:d,y:m}=Ue(t,this.state),p=this.getTopLayerFrameAtSceneCoords({x:d,y:m});F(c,{x:d,y:m,frameId:p?p.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,o):this.state.activeTool.type==="custom"?Br(this.interactiveCanvas,this.state):this.state.activeTool.type===bt.frame||this.state.activeTool.type===bt.magicframe?this.createFrameElementOnPointerDown(o,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(o.lastCoords.x,o.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,o);this.props?.onPointerDown?.(this.state.activeTool,o),this.onPointerDownEmitter.trigger(this.state.activeTool,o,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(o.lastCoords.x,o.lastCoords.y);let i=this.onPointerMoveFromPointerDownHandler(o),a=this.onPointerUpFromPointerDownHandler(o),l=this.onKeyDownFromPointerDownHandler(o),s=this.onKeyUpFromPointerDownHandler(o);this.missingPointerEventCleanupEmitter.once(c=>a(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",i),window.addEventListener("pointerup",a),window.addEventListener("keydown",l),window.addEventListener("keyup",s),o.eventListeners.onMove=i,o.eventListeners.onUp=a,o.eventListeners.onKeyUp=s,o.eventListeners.onKeyDown=l)};handleCanvasPointerUp=t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Ue({clientX:t.clientX,clientY:t.clientY},this.state),o=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&o<300){let n=this.getElementAtPosition(r.x,r.y);if(Vt(n)&&this.isIframeLikeElementCenter(n,t,r.x,r.y)){this.handleEmbeddableCenterClick(n);return}}if(this.device.isTouchScreen){let n=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,n)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?o<300&&Vt(this.hitLinkElement)&&!Jh(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,[r.x,r.y])?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})};maybeOpenContextMenuAfterPointerDownOnTouchDevices=t=>{t.pointerType==="touch"&&(zc=!1,_i?zc=!0:_i=window.setTimeout(()=>{_i=0,zc||this.handleCanvasContextMenu(t)},Vb))};resetContextMenuTimer=()=>{clearTimeout(_i),_i=0,zc=!1};maybeCleanupAfterMissingPointerUp=t=>{Gc?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()};handleCanvasPanUsingWheelOrSpaceDrag=t=>{if(!(De.pointers.size<=1&&(t.button===Vn.WHEEL||t.button===Vn.MAIN&&Ma||Co(this.state)||this.state.viewModeEnabled))||G(this.state.editingElement))return!1;Hc=!0,t.preventDefault();let r=!1,o=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);He(this.interactiveCanvas,Ce.GRABBING);let{clientX:n,clientY:i}=t,a=xu(s=>{let c=n-s.clientX,d=i-s.clientY;if(n=s.clientX,i=s.clientY,o&&!r&&(Math.abs(c)>1||Math.abs(d)>1)){r=!0;let m=u=>{document.body.removeEventListener("paste",m),u.stopPropagation()},p=()=>{setTimeout(()=>{document.body.removeEventListener("paste",m),window.removeEventListener("pointerup",p)},100)};document.body.addEventListener("paste",m),window.addEventListener("pointerup",p)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),l=nt(Gc=()=>{Gc=null,Hc=!1,Ma||(this.state.viewModeEnabled?He(this.interactiveCanvas,Ce.GRAB):Br(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l),window.removeEventListener("blur",l),a.flush()});return window.addEventListener("blur",l),window.addEventListener("pointermove",a,{passive:!0}),window.addEventListener("pointerup",l),!0};updateGestureOnPointerDown(t){De.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),De.pointers.size===2&&(De.lastCenter=h1(De.pointers),De.initialScale=this.state.zoom.value,De.initialDistance=g1(Array.from(De.pointers.values())))}initialPointerDownState(t){let r=Ue(t,this.state),o=this.scene.getSelectedElements(this.state),[n,i,a,l]=we(o);return{origin:r,withCmdOrCtrl:t[S.CTRL_OR_CMD],originInGrid:bo(St(r.x,r.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize)),scrollbars:E1(ob,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((s,c)=>(s.set(c.id,Sn(c)),s),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+n)/2,y:(l+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,o)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;rb=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let o=xu(i=>{i.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(i,r)}),n=nt(()=>{Gc=null,rb=!1,Br(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",n),o.flush()});return Gc=n,window.addEventListener("pointermove",o),window.addEventListener("pointerup",n),!0}clearSelectionIfNotUsingSelection=()=>{this.state.activeTool.type!=="selection"&&this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})};handleSelectionOnPointerDown=(t,r)=>{if(this.state.activeTool.type==="selection"){let o=this.scene.getNonDeletedElements(),n=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.editingLinearElement){let a=Dm(o,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap());a!=null&&(this.setState({resizingElement:a.element}),r.resize.handleType=a.transformHandleType)}else i.length>1&&(r.resize.handleType=Rm(we(i),r.origin.x,r.origin.y,this.state.zoom,t.pointerType));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=bo(xg(r.resize.handleType,i,n,r.origin.x,r.origin.y)),i.length===1&&re(i[0])&&i[0].points.length===2&&(r.resize.arrowDirection=Eg(r.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let s=this.state.editingLinearElement||this.state.selectedLinearElement,c=K.handlePointerDown(t,this.state,this.history,r.origin,s,this);if(c.hitElement&&(r.hit.element=c.hitElement),c.linearElementEditor&&(this.setState({selectedLinearElement:c.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:c.linearElementEditor})),c.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=this.getElementsAtPosition(r.origin.x,r.origin.y);let a=r.hit.element,l=r.hit.allHitElements.some(s=>this.isASelectedElement(s));if((a===null||!l)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(a),this.state.editingLinearElement)this.setState({selectedElementIds:Pe({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(a!=null){if(t[S.CTRL_OR_CMD])return this.state.selectedElementIds[a.id]||(r.hit.wasAddedToSelection=!0),this.setState(s=>({..._0(s,a),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!oa(a,this.state.editingGroupId)&&this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!l&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(s=>{let c={...s.selectedElementIds,[a.id]:!0},d=[];if(Object.keys(s.selectedElementIds).forEach(m=>{let p=this.scene.getElement(m);p&&d.push(p)}),Q(a))Hr(d,a.id).forEach(m=>{delete c[m.id]});else if(a.frameId)c[a.frameId]&&delete c[a.id];else{let m=a.groupIds,p=new Set(m.flatMap(u=>Je(this.scene.getNonDeletedElements(),u)).filter(u=>Q(u)).map(u=>u.id));p.size>0&&d.forEach(u=>{u.frameId&&p.has(u.frameId)&&(delete c[u.id],u.groupIds.flatMap(h=>Je(this.scene.getNonDeletedElements(),h)).forEach(h=>{delete c[h.id]}))})}return{...Kt({editingGroupId:s.editingGroupId,selectedElementIds:c},this.scene.getNonDeletedElements(),s,this),showHyperlinkPopup:a.link||vt(a)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1};isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let o=this.getHitThreshold(),[n,i,a,l]=we(r);return t.x>n-o&&t.x<a+o&&t.y>i-o&&t.y<l+o}handleTextOnPointerDown=(t,r)=>{if(G(this.state.editingElement))return;let o=r.origin.x,n=r.origin.y,i=this.getElementAtPosition(o,n,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(o,n);gr(i)&&(a=i,o=i.x+i.width/2,n=i.y+i.height/2),this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:a}),Or(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Xe(this.state,{type:"selection"})})};handleFreeDrawElementOnPointerDown=(t,r,o)=>{let[n,i]=St(o.origin.x,o.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l=U0({type:r,x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:t.pressure===.5,locked:!1,frameId:a?a.id:null});this.setState(d=>{let m={...d.selectedElementIds};return delete m[l.id],{selectedElementIds:Pe(m,d)}});let s=l.simulatePressure?l.pressures:[...l.pressures,t.pressure];F(l,{points:[[0,0]],pressures:s});let c=Wo(o.origin,this);this.scene.insertElement(l),this.setState({draggingElement:l,editingElement:l,startBoundElement:c,suggestedBindings:[]})};insertIframeElement=({sceneX:t,sceneY:r,width:o,height:n})=>{let[i,a]=St(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),l=z0({type:"iframe",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:o,height:n});return this.scene.insertElement(l),l};insertEmbeddableElement=({sceneX:t,sceneY:r,link:o})=>{let[n,i]=St(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=kn(o);if(!a)return;a.error instanceof URIError&&this.setToast({message:b("toast.unrecognizedLinkFormat"),closable:!0});let l=Rh({type:"embeddable",x:n,y:i,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:o});return this.scene.insertElement(l),l};createImageElement=({sceneX:t,sceneY:r,addToFrameUnderCursor:o=!0})=>{let[n,i]=St(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=o?this.getTopLayerFrameAtSceneCoords({x:n,y:i}):null;return Fs({type:"image",x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null})};handleLinearElementOnPointerDown=(t,r,o)=>{if(this.state.multiElement){let{multiElement:n}=this.state;if(n.type==="line"&&ir(n.points,this.state.zoom.value)){F(n,{lastCommittedPoint:n.points[n.points.length-1]}),this.actionManager.executeAction(io);return}let{x:i,y:a,lastCommittedPoint:l}=n;if(n.points.length>1&&l&&xt(o.origin.x-i,o.origin.y-a,l[0],l[1])<Na){this.actionManager.executeAction(io);return}this.setState(s=>({selectedElementIds:Pe({...s.selectedElementIds,[n.id]:!0},s)})),F(n,{lastCommittedPoint:n.points[n.points.length-1]}),He(this.interactiveCanvas,Ce.POINTER)}else{let[n,i]=St(o.origin.x,o.origin.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),{currentItemStartArrowhead:l,currentItemEndArrowhead:s}=this.state,[c,d]=r==="arrow"?[l,s]:[null,null],m=Qr({type:r,x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:rt.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:a?a.id:null});this.setState(u=>{let h={...u.selectedElementIds};return delete h[m.id],{selectedElementIds:Pe(h,u)}}),F(m,{points:[...m.points,[0,0]]});let p=Wo(o.origin,this);this.scene.insertElement(m),this.setState({draggingElement:m,editingElement:m,startBoundElement:p,suggestedBindings:[]})}};getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:Ho(t)?rt.ADAPTIVE_RADIUS:rt.PROPORTIONAL_RADIUS}:null}createGenericElementOnPointerDown=(t,r)=>{let[o,n]=St(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i=this.getTopLayerFrameAtSceneCoords({x:o,y:n}),a={x:o,y:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:i?i.id:null},l;t==="embeddable"?l=Rh({type:"embeddable",...a}):l=Fr({type:t,...a}),l.type==="selection"?this.setState({selectionElement:l,draggingElement:l}):(this.scene.insertElement(l),this.setState({multiElement:null,draggingElement:l,editingElement:l}))};createFrameElementOnPointerDown=(t,r)=>{let[o,n]=St(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i={x:o,y:n,opacity:this.state.currentItemOpacity,locked:!1,...$e},a=r===bt.magicframe?Bs(i):$d(i);this.scene.insertElement(a),this.setState({multiElement:null,draggingElement:a,editingElement:a})};maybeCacheReferenceSnapPoints(t,r,o=!1){Un({event:t,appState:this.state,selectedElements:r})&&(o||!co.getReferenceSnapPoints())&&co.setReferenceSnapPoints(E5(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,o=!1){Un({event:t,appState:this.state,selectedElements:r})&&(o||!co.getVisibleGaps())&&co.setVisibleGaps(x5(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return nt(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return nt(r=>{r.key===S.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return xu(r=>{if(t.drag.offset===null&&(t.drag.offset=bo(vg(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;let n=Ue(r,this.state);if(xr(this.state)){this.handleEraser(r,t,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[i,a]=St(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize);if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&xt(n.x,n.y,t.origin.x,t.origin.y)<pn)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleResize(t,r)))return!0;let l=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let m=this.state.editingLinearElement||this.state.selectedLinearElement;if(K.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,l)){let u=K.addMidpoint(this.state.selectedLinearElement,n,this.state,!r[S.CTRL_OR_CMD],l);if(!u)return;eb(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}})});return}else if(m.pointerDownState.segmentMidpoint.value!==null&&!m.pointerDownState.segmentMidpoint.added)return;if(K.handlePointDragging(r,this.state,n.x,n.y,(u,h)=>{this.maybeSuggestBindingsForLinearElementAtCoords(u,h)},m,this.scene.getNonDeletedElementsMap())){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging&&this.setState({editingLinearElement:{...this.state.editingLinearElement,isDragging:!0}}),this.state.selectedLinearElement.isDragging||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0}});return}}let s=t.hit.allHitElements.some(m=>this.isASelectedElement(m)),c=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((s||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c){let m=this.scene.getSelectedElements(this.state);if(m.every(h=>h.locked))return;let p=m.find(h=>Q(h)),u=this.getTopLayerFrameAtSceneCoords(n);if(this.setState({frameToHighlight:u&&!p?u:null}),t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0}),m.length>0&&!t.withCmdOrCtrl&&!this.state.editingElement&&this.state.activeEmbeddable?.state!=="active"){let h={x:n.x-t.origin.x,y:n.y-t.origin.y},x=[...t.originalElements.values()],E=r.shiftKey;if(E){let y=Math.abs(h.x),I=Math.abs(h.y),P=E&&y<I,C=E&&y>I;P&&(h.x=0),C&&(h.y=0)}this.maybeCacheVisibleGaps(r,m),this.maybeCacheReferenceSnapPoints(r,m);let{snapOffset:v,snapLines:w}=y5(x,h,this.state,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:w}),!this.state.editingFrame&&wg(t,m,h,this.state,this.scene,v,r[S.CTRL_OR_CMD]?null:this.state.gridSize),this.maybeSuggestBindingForAll(m),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let y=[],I=[],P=new Map,C=new Map,_=t.hit.element,D=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(M=>M.id)),H=this.scene.getElementsIncludingDeleted();for(let M of H)if(D.has(M.id)||M.id===_?.id&&t.hit.wasAddedToSelection){let k=Hs(this.state.editingGroupId,P,M),O=t.originalElements.get(M.id);F(k,{x:O.x,y:O.y}),t.originalElements.set(k.id,k),y.push(k),I.push(M),C.set(M.id,k.id)}else y.push(M);let A=[...y,...I];qt(A,$(I)),Pd(y,I,C),Ad(A,I,C,"duplicatesServeAsOld"),Im(A,I,C),this.scene.replaceAllElements(A),this.maybeCacheVisibleGaps(r,m,!0),this.maybeCacheReferenceSnapPoints(r,m,!0)}return}}let d=this.state.draggingElement;if(d){if(d.type==="freedraw"){let m=d.points,p=n.x-d.x,u=n.y-d.y,h=m.length>0&&m[m.length-1];if(!(h&&h[0]===p&&h[1]===u)){let E=d.simulatePressure?d.pressures:[...d.pressures,r.pressure];F(d,{points:[...m,[p,u]],pressures:E})}}else if(re(d)){t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0});let m=d.points,p=i-d.x,u=a-d.y;qi(r)&&m.length===2&&({width:p,height:u}=tl(d.x,d.y,n.x,n.y)),m.length===1?F(d,{points:[...m,[p,u]]}):m.length===2&&F(d,{points:[...m.slice(0,-1),[p,u]]}),Tt(d,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(d,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r);if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let m=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)K.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let p=!0;!r.shiftKey&&ze(m,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(h=>Kt({...h,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),h,this)):p=!1);let u=vl(m,d,this.scene.getNonDeletedElementsMap());this.setState(h=>{let x={...p&&h.selectedElementIds,...u.reduce((E,v)=>(E[v.id]=!0,E),{})};return t.hit.element&&(u.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),h=p?h:{...h,selectedGroupIds:{},editingGroupId:null},{...Kt({editingGroupId:h.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),h,this),selectedLinearElement:u.length===1&&re(u[0])?new K(u[0]):null,showHyperlinkPopup:u.length===1&&(u[0].link||vt(u[0]))?"info":!1}})}}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let o=t.clientX,n=o-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-n/this.state.zoom.value}),r.lastCoords.x=o,!0}if(r.scrollbars.isOverVertical){let o=t.clientY,n=o-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-n/this.state.zoom.value}),r.lastCoords.y=o,!0}return!1}onPointerUpFromPointerDownHandler(t){return nt(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{draggingElement:o,resizingElement:n,multiElement:i,activeTool:a,isResizing:l,isRotating:s}=this.state;this.setState(u=>({isResizing:!1,isRotating:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",editingElement:i||G(this.state.editingElement)?this.state.editingElement:null,snapLines:ud(u.snapLines,[]),originSnapOffset:null})),co.setReferenceSnapPoints(null),co.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let c=this.scene.getNonDeletedElementsMap();if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(io);else{let u=K.handlePointerUp(r,this.state.editingLinearElement,this.state,this);u!==this.state.editingLinearElement&&this.setState({editingLinearElement:u,suggestedBindings:[]})}else if(this.state.selectedLinearElement)if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let u=K.handlePointerUp(r,this.state.selectedLinearElement,this.state,this),{startBindingElement:h,endBindingElement:x}=u,E=this.scene.getElement(u.elementId);Tt(E)&&xn(E,h,x,c),u!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(a,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),o?.type==="freedraw"){let u=Ue(r,this.state),h=o.points,x=u.x-o.x,E=u.y-o.y;x===h[0][0]&&E===h[0][1]&&(E+=1e-4,x+=1e-4);let v=o.simulatePressure?[]:[...o.pressures,r.pressure];F(o,{points:[...h,[x,E]],pressures:v,lastCommittedPoint:[x,E]}),this.actionManager.executeAction(io);return}if(Zr(o)){let u=o;try{this.initializeImageDimensions(u),this.setState({selectedElementIds:Pe({[u.id]:!0},this.state)},()=>{this.actionManager.executeAction(io)})}catch(h){console.error(h),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(x=>x.id!==u.id)),this.actionManager.executeAction(io)}return}if(re(o)){o.points.length>1&&this.history.resumeRecording();let u=Ue(r,this.state);!t.drag.hasOccurred&&o&&!i?(F(o,{points:[...o.points,[u.x-o.x,u.y-o.y]]}),this.setState({multiElement:o,editingElement:this.state.draggingElement})):t.drag.hasOccurred&&!i&&(Uo(this.state)&&Tt(o,!1)&&Ps(o,this.state,u,this),this.setState({suggestedBindings:[],startBoundElement:null}),a.locked?this.setState(h=>({draggingElement:null})):(Or(this.interactiveCanvas),this.setState(h=>({draggingElement:null,activeTool:Xe(this.state,{type:"selection"}),selectedElementIds:Pe({...h.selectedElementIds,[o.id]:!0},h),selectedLinearElement:new K(o)}))));return}if(a.type!=="selection"&&o&&eo(o)){this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(u=>u.id!==o.id)),this.setState({draggingElement:null});return}if(o){if(t.drag.hasOccurred){let u=Ue(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let h=this.scene.getElement(this.state.selectedLinearElement.elementId);if(h?.frameId){let x=Ot(h,c);x&&h&&(Ko(h,x,this.scene.getNonDeletedElementsMap())||(F(h,{groupIds:[]}),wl([h],this.scene.getNonDeletedElementsMap()),this.scene.informMutation()))}}else{let h=this.getTopLayerFrameAtSceneCoords(u),x=this.scene.getSelectedElements(this.state),E=this.scene.getElementsMapIncludingDeleted(),v=w=>{if(w.length>0){for(let y of w){let I=y.groupIds.indexOf(this.state.editingGroupId);F(y,{groupIds:y.groupIds.slice(0,I)},!1)}E.forEach(y=>{y.groupIds.length&&Je(E,y.groupIds[y.groupIds.length-1]).length<2&&F(y,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(h&&!this.state.selectedElementIds[h.id]){let w=x.filter(y=>y.frameId!==h.id&&sa(y,E,this.state));this.state.editingGroupId&&v(w),E=ec(E,w,h)}else if(!h&&this.state.editingGroupId){let w=x.filter(y=>y.frameId&&!sa(y,E,this.state));v(w)}E=$o(E,this.state,this),this.scene.replaceAllElements(E)}}if(Q(o)){let u=ay(this.scene.getElementsIncludingDeleted(),o,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(ec(this.scene.getElementsMapIncludingDeleted(),u,o))}F(o,Ys(o))}if(n&&this.history.resumeRecording(),n&&eo(n)&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(u=>u.id!==n.id)),t.resize.isResizing){let u=$o(this.scene.getElementsIncludingDeleted(),this.state,this),h=this.scene.getSelectedElements(this.state).filter(x=>Q(x));for(let x of h)u=Cm(u,yl(this.scene.getElementsIncludingDeleted(),x,this.state,c),x,this);this.scene.replaceAllElements(u)}let d=t.hit.element;this.state.selectedLinearElement?.elementId!==d?.id&&re(d)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new K(d)});let m=this.lastPointerDownEvent,p=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(xr(this.state)&&m&&p){if(this.eraserTrail.endPath(),xt(m.clientX,m.clientY,p.clientX,p.clientY)===0){let h=Ue({clientX:p.clientX,clientY:p.clientY},this.state);this.getElementsAtPosition(h.x,h.y).forEach(E=>this.elementsPendingErasure.add(E.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(d&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[d.id]?Fd(this.state,d)?this.setState(u=>{let h={...u.selectedElementIds};for(let x of d.groupIds.flatMap(E=>Je(this.scene.getNonDeletedElements(),E)))delete h[x.id];return{selectedGroupIds:{...u.selectedElementIds,...d.groupIds.map(x=>({[x]:!1})).reduce((x,E)=>({...x,...E}),{})},selectedElementIds:Pe(h,u)}}):this.state.selectedLinearElement?.isDragging||this.setState(u=>{let h={...u.selectedElementIds};delete h[d.id];let x=pe(this.scene.getNonDeletedElements(),{selectedElementIds:h});return{...Kt({editingGroupId:u.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:x.length===1&&re(x[0])?new K(x[0]):u.selectedLinearElement}}):d.frameId&&this.state.selectedElementIds[d.frameId]?this.setState(u=>{let h={...u.selectedElementIds,[d.id]:!0};return delete h[d.frameId],(this.scene.getElement(d.frameId)?.groupIds??[]).flatMap(x=>Je(this.scene.getNonDeletedElements(),x)).forEach(x=>{delete h[x.id]}),{...Kt({editingGroupId:u.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:d.link||vt(d)?"info":!1}}):this.setState(u=>({selectedElementIds:Pe({...u.selectedElementIds,[d.id]:!0},u)})):this.setState(u=>({...Kt({editingGroupId:u.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:re(d)&&u.selectedLinearElement?.elementId!==d.id?new K(d):u.selectedLinearElement}))),!t.drag.hasOccurred&&!this.state.isResizing&&(d&&CE({x:t.origin.x,y:t.origin.y,element:d,shape:this.getElementShape(d),threshold:this.getHitThreshold(),frameNameBound:Q(d)?this.frameNameBoundsCache.get(d):null},c)||!d&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Pe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),He(this.interactiveCanvas,Ce.AUTO);return}if(!a.locked&&a.type!=="freedraw"&&o&&o.type!=="selection"&&this.setState(u=>({selectedElementIds:Pe({...u.selectedElementIds,[o.id]:!0},u),showHyperlinkPopup:vt(o)&&!o.link?"editor":u.showHyperlinkPopup})),(a.type!=="selection"||ze(this.scene.getNonDeletedElements(),this.state))&&this.history.resumeRecording(),(t.drag.hasOccurred||l||s)&&(Uo(this.state)?Ls(this.scene.getSelectedElements(this.state),this):_s(this.scene.getNonDeletedElements(),c)),a.type==="laser"){this.laserTrails.endPath();return}!a.locked&&a.type!=="freedraw"?(Or(this.interactiveCanvas),this.setState({draggingElement:null,suggestedBindings:[],activeTool:Xe(this.state,{type:"selection"})})):this.setState({draggingElement:null,suggestedBindings:[]}),d&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&De.pointers.size<=1&&Vt(d)&&this.isIframeLikeElementCenter(d,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(d)})}restoreReadyToEraseElements=()=>{this.elementsPendingErasure=new Set,this.onSceneUpdated()};eraseElements=()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(o=>this.elementsPendingErasure.has(o.id)||o.frameId&&this.elementsPendingErasure.has(o.frameId)||Ne(o)&&this.elementsPendingErasure.has(o.containerId)?(t=!0,ne(o,{isDeleted:!0})):o);this.elementsPendingErasure=new Set,t&&(this.history.resumeRecording(),this.scene.replaceAllElements(r))};initializeImage=async({imageFile:t,imageElement:r,showCursorImagePreview:o=!1})=>{if(!di(t))throw new Error(b("errors.unsupportedFileType"));let n=t.type;if(He(this.interactiveCanvas,"wait"),n===J.svg)try{t=Yh(await yE(await t.text()),t.name)}catch(c){throw console.warn(c),new Error(b("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(t)||uE(t));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(b("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{t=await $s(t,{maxWidthOrHeight:Jb})}catch(c){console.error("Error trying to resizing image file on insertion",c)}if(t.size>Fu)throw new Error(b("errors.fileTooBig",{maxSize:`${Math.trunc(Fu/1024/1024)}MB`}))}if(o){let c=this.files[i]?.dataURL,d=c&&hE(c);this.setImagePreviewCursor(d||t)}let l=this.files[i]?.dataURL||await em(t),s=F(r,{fileId:i},!1);return new Promise(async(c,d)=>{try{this.files={...this.files,[i]:{mimeType:n,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}};let m=this.imageCache.get(i);m||(this.addNewImagesToImageCache(),await this.updateImageCache([s])),m?.image instanceof Promise&&await m.image,this.state.pendingImageElementId!==s.id&&this.state.draggingElement?.id!==s.id&&this.initializeImageDimensions(s,!0),c(s)}catch(m){console.error(m),d(new Error(b("errors.imageInsertError")))}finally{o||Or(this.interactiveCanvas)}})};insertImageElement=async(t,r,o)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:b("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:o})}catch(n){return F(t,{isDeleted:!0}),this.actionManager.executeAction(io),this.setState({errorMessage:n.message||b("errors.imageInsertError")}),null}};setImagePreviewCursor=async t=>{let o;try{o=await $s(t,{maxWidthOrHeight:96})}catch(i){throw i.cause==="UNSUPPORTED"?new Error(b("errors.unsupportedFileType")):i}let n=await em(o);if(t.type===J.svg){let i=await Xh(n),a=Math.min(i.height,96),l=a*(i.width/i.height);l>96&&(l=96,a=l*(i.height/i.width));let s=document.createElement("canvas");s.height=a,s.width=l,s.getContext("2d").drawImage(i,0,0,l,a),n=s.toDataURL(J.svg)}this.state.pendingImageElementId&&He(this.interactiveCanvas,`url(${n}) 4 4, auto`)};onImageAction=async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Ue({clientX:r,clientY:o},this.state),a=await al({description:"Image",extensions:Object.keys(ds)}),l=this.createImageElement({sceneX:n,sceneY:i,addToFrameUnderCursor:!1});t?(this.insertImageElement(l,a),this.initializeImageDimensions(l),this.setState({selectedElementIds:Pe({[l.id]:!0},this.state)},()=>{this.actionManager.executeAction(io)})):this.setState({pendingImageElementId:l.id},()=>{this.insertImageElement(l,a,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,editingElement:null,activeTool:Xe(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(io)})}};initializeImageDimensions=(t,r=!1)=>{let o=nr(t)&&this.imageCache.get(t.fileId)?.image;if(!o||o instanceof Promise){if(t.width<pn/this.state.zoom.value&&t.height<pn/this.state.zoom.value){let n=100/this.state.zoom.value;F(t,{x:t.x-n/2,y:t.y-n/2,width:n,height:n})}return}if(r||t.width<pn/this.state.zoom.value&&t.height<pn/this.state.zoom.value){let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),l=a*(o.naturalWidth/o.naturalHeight),s=t.x+t.width/2-l/2,c=t.y+t.height/2-a/2;F(t,{x:s,y:c,width:l,height:a})}};updateImageCache=async(t,r=this.files)=>{let{updatedFiles:o,erroredFiles:n}=await nm({imageCache:this.imageCache,fileIds:t.map(i=>i.fileId),files:r});if(o.size||n.size)for(let i of t)o.has(i.fileId)&&ke.delete(i);return n.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(i=>nr(i)&&n.has(i.fileId)?ne(i,{status:"error"}):i)),{updatedFiles:o,erroredFiles:n}};addNewImagesToImageCache=async(t=im(this.scene.getNonDeletedElements()),r=this.files)=>{let o=t.filter(n=>!n.isDeleted&&!this.imageCache.has(n.fileId));if(o.length){let{updatedFiles:n}=await this.updateImageCache(o,r);n.size&&this.scene.informMutation()}};scheduleImageRefresh=HP(()=>{this.addNewImagesToImageCache()},Ub);updateBindingEnabledOnPointerMove=t=>{let r=m0(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})};maybeSuggestBindingAtCursor=t=>{let r=Wo(t,this);this.setState({suggestedBindings:r!=null?[r]:[]})};maybeSuggestBindingsForLinearElementAtCoords=(t,r,o)=>{if(!r.length)return;let n=r.reduce((i,a)=>{let l=Wo(a,this);return l!=null&&!xh(t,o?.id,l)&&i.push(l),i},[]);this.setState({suggestedBindings:n})};maybeSuggestBindingForAll(t){if(t.length>50)return;let r=u0(t,this);this.setState({suggestedBindings:r})}clearSelection(t){this.setState(r=>({selectedElementIds:Pe({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&oa(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Pe({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}handleInteractiveCanvasRef=t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("wheel",this.handleWheel),this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("wheel",this.handleWheel),this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))};handleAppOnDrop=async t=>{let{file:r,fileHandle:o}=await fE(t),{x:n,y:i}=Ue(t,this.state);try{if(di(r)&&this.isToolSupported("image")){if(r?.type===J.png||r?.type===J.svg)try{let s=await pl(r,this.state,this.scene.getElementsIncludingDeleted(),o);this.syncActionResult({...s,appState:{...s.appState||this.state,isLoading:!1},replaceFiles:!0,commitToHistory:!0});return}catch(s){if(s.name!=="EncodingError")throw new Error(b("alerts.couldNotLoadInvalidFile"))}let l=this.createImageElement({sceneX:n,sceneY:i});this.insertImageElement(l,r),this.initializeImageDimensions(l),this.setState({selectedElementIds:Pe({[l.id]:!0},this.state)});return}}catch(l){return this.setState({isLoading:!1,errorMessage:l.message})}let a=t.dataTransfer.getData(J.excalidrawlib);if(a&&typeof a=="string"){try{let l=Wh(a);this.addElementsFromPasteOrLibrary({elements:vp(l),position:t,files:null})}catch(l){this.setState({errorMessage:l.message})}return}if(r&&await this.loadFileToCanvas(r,o),t.dataTransfer?.types?.includes("text/plain")){let l=t.dataTransfer?.getData("text");if(l&&il(l,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(l)||kn(l)?.type==="video")){let s=this.insertEmbeddableElement({sceneX:n,sceneY:i,link:lr(l)});s&&this.setState({selectedElementIds:{[s.id]:!0}})}}};loadFileToCanvas=async(t,r)=>{t=await Xs(t);try{let o;try{o=await Qd(t,this.state,this.scene.getElementsIncludingDeleted(),r)}catch(n){let i=n instanceof yo;if(i&&n.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:b("errors.imageToolNotSupported")});return}let a=i?b("alerts.cannotRestoreFromImage"):b("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:a})}if(!o)return;o.type===J.excalidraw?(this.setState({isLoading:!0}),this.syncActionResult({...o.data,appState:{...o.data.appState||this.state,isLoading:!1},replaceFiles:!0,commitToHistory:!0})):o.type===J.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(n=>{console.error(n),this.setState({errorMessage:b("errors.importLibraryError")})})}catch(o){this.setState({isLoading:!1,errorMessage:o.message})}};handleCanvasContextMenu=t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Vn.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:o}=Ue(t,this.state),n=this.getElementAtPosition(r,o,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:o},i),l=n||a?"element":"canvas",s=this.excalidrawContainerRef.current,{top:c,left:d}=s.getBoundingClientRect(),m=t.clientX-d,p=t.clientY-c;fe("contextMenu","openContextMenu",l),this.setState({...n&&!this.state.selectedElementIds[n.id]?{...this.state,...Kt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[n.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:re(n)?new K(n):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:p,left:m,items:this.getContextMenuItems(l)}})})};maybeDragNewGenericElement=(t,r)=>{let o=this.state.draggingElement,n=t.lastCoords;if(o)if(o.type==="selection"&&this.state.activeTool.type!=="eraser")Bm(o,this.state.activeTool.type,t.origin.x,t.origin.y,n.x,n.y,Mt(t.origin.x,n.x),Mt(t.origin.y,n.y),qa(r),Cd(r));else{let[i,a]=St(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),l=nr(o)&&this.imageCache.get(o.fileId)?.image,s=l&&!(l instanceof Promise)?l.width/l.height:null;this.maybeCacheReferenceSnapPoints(r,[o]);let{snapOffset:c,snapLines:d}=v5(o,this.state,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:i-t.originInGrid.x,y:a-t.originInGrid.y},this.scene.getNonDeletedElementsMap());i+=c.x,a+=c.y,this.setState({snapLines:d}),Bm(o,this.state.activeTool.type,t.originInGrid.x,t.originInGrid.y,i,a,Mt(t.originInGrid.x,i),Mt(t.originInGrid.y,a),Zr(o)?!qa(r):qa(r),Cd(r),s,this.state.originSnapOffset),this.maybeSuggestBindingForAll([o]),(this.state.activeTool.type===bt.frame||this.state.activeTool.type===bt.magicframe)&&this.setState({elementsToHighlight:yl(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap())})}};maybeHandleResize=(t,r)=>{let o=this.scene.getSelectedElements(this.state),n=o.filter(d=>Q(d)),i=t.resize.handleType;if(n.length>0&&i==="rotation")return!1;this.setState({isResizing:i&&i!=="rotation",isRotating:i==="rotation",activeEmbeddable:null});let a=t.lastCoords,[l,s]=St(a.x-t.resize.offset.x,a.y-t.resize.offset.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),c=new Map;if(n.forEach(d=>{Hr(this.scene.getNonDeletedElements(),d.id).forEach(p=>{c.set(d.id+p.id,{x:p.x-d.x,y:p.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,m]=St(a.x,a.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),p={x:d-t.originInGrid.x,y:m-t.originInGrid.y},u=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,o);let{snapOffset:h,snapLines:x}=w5(o,pe(u,this.state),this.state,r,p,i);l+=h.x,s+=h.y,this.setState({snapLines:x})}if(gg(t.originalElements,i,o,this.scene.getElementsMapIncludingDeleted(),qi(r),Cd(r),o.length===1&&Zr(o[0])?!qa(r):qa(r),l,s,t.resize.center.x,t.resize.center.y)){this.maybeSuggestBindingForAll(o);let d=new Set;return n.forEach(m=>{yl(this.scene.getNonDeletedElements(),m,this.state,this.scene.getNonDeletedElementsMap()).forEach(p=>d.add(p))}),this.setState({elementsToHighlight:[...d]}),!0}return!1};getContextMenuItems=t=>{let r=[];return r.push(hp,up),t==="canvas"?this.state.viewModeEnabled?[...r,fp,Gl,V1,Ei]:[Lf,dr,hp,up,gp,dr,of,Cv,dr,fp,Pf,Gl,V1,Ei]:(r.push(gp),this.state.viewModeEnabled?[zl,...r]:[pp,zl,Lf,p5,u5,dr,...r,dr,vf,Tf,dr,Sf,_f,Df,xv,If,dr,kf,dr,Qg,ef,tf,rf,dr,Af,Mf,dr,p1,yc,nf,Hf,dr,mc])};handleWheel=nt(t=>{if(t.preventDefault(),Hc)return;let{deltaX:r,deltaY:o}=t;if(t.metaKey||t.ctrlKey){let n=Math.sign(o),i=Gi*100,a=Math.abs(o),l=o;a>i&&(l=i*n);let s=this.state.zoom.value-l/100;s+=Math.log10(Math.max(1,this.state.zoom.value))*-n*Math.min(1,a/20),this.translateCanvas(c=>({...Nn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Xo(s)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:n,scrollX:i})=>({scrollX:i-(o||r)/n.value}));return}this.translateCanvas(({zoom:n,scrollX:i,scrollY:a})=>({scrollX:i-r/n.value,scrollY:a-o/n.value}))});getTextWysiwygSnappedToCenterPosition(t,r,o,n){if(n){let i=n.x+n.width/2,a=n.y+n.height/2,l=Nd(n,o,this.scene.getNonDeletedElementsMap());if(l&&(i=l.x,a=l.y),Math.hypot(t-i,r-a)<Fb){let{x:d,y:m}=Dt({sceneX:i,sceneY:a},o);return{viewportX:d,viewportY:m,elementCenterX:i,elementCenterY:a}}}}savePointer=(t,r,o)=>{if(!t||!r)return;let{x:n,y:i}=Ue({clientX:t,clientY:r},this.state);isNaN(n)||isNaN(i);let a={x:n,y:i,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:a,button:o,pointersMap:De.pointers})};resetShouldCacheIgnoreZoomDebounced=Wi(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300);updateDOMRect=t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:o,height:n,left:i,top:a}=r.getBoundingClientRect(),{width:l,height:s,offsetTop:c,offsetLeft:d}=this.state;if(o===l&&n===s&&i===d&&a===c){t&&t();return}this.setState({width:o,height:n,offsetLeft:i,offsetTop:a},()=>{t&&t()})}};refresh=()=>{this.setState({...this.getCanvasOffsets()})};getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:o}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:o}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=_a.find(r=>r.code===this.props.langCode)||Ro;await Kc(t),this.setAppState({})}},zP=()=>{(T.MODE===ss.TEST||T.DEV)&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(Mr(e))}}}))};zP();var Q5=ib;z();f();var UP=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},eS=UP;U();import{Provider as r7}from"jotai";f();import WP from"clsx";import{jsx as tS}from"react/jsx-runtime";var rS=({children:e})=>{let{FooterCenterTunnel:t}=et(),r=Me();return tS(t.In,{children:tS("div",{className:WP("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":r.zenModeEnabled}),children:e})})},VP=rS;rS.displayName="FooterCenter";f();f();f();import{jsx as Ri,jsxs as nS}from"react/jsx-runtime";var YP=()=>Ri("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Ri("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),KP=()=>nS("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Ri("path",{d:"M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z",transform:"translate(-144.023 -51.76)"}),Ri("path",{d:"M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z",transform:"translate(-144.023 -51.76)"}),Ri("path",{d:"M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z",transform:"translate(-144.023 -51.76)"}),Ri("path",{d:"m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z",fill:"currentColor",transform:"translate(-144.023 -51.76)"})]}),oS=({style:e,size:t="small",withText:r})=>nS("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Ri(YP,{}),r&&Ri(KP,{})]});import{Fragment as lS,jsx as Ct,jsxs as pb}from"react/jsx-runtime";var ub=({icon:e,shortcut:t,children:r})=>{let o=Ie();return pb(lS,{children:[Ct("div",{className:"welcome-screen-menu-item__icon",children:e}),Ct("div",{className:"welcome-screen-menu-item__text",children:r}),t&&!o.editor.isMobile&&Ct("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};ub.displayName="WelcomeScreenMenuItemContent";var Uc=({onSelect:e,children:t,icon:r,shortcut:o,className:n="",...i})=>Ct("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Ct(ub,{icon:r,shortcut:o,children:t})});Uc.displayName="WelcomeScreenMenuItem";var iS=({children:e,href:t,icon:r,shortcut:o,className:n="",...i})=>Ct("a",{...i,className:`welcome-screen-menu-item ${n}`,href:t,target:"_blank",rel:"noreferrer",children:Ct(ub,{icon:r,shortcut:o,children:e})});iS.displayName="WelcomeScreenMenuItemLink";var uo=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=et();return Ct(t.In,{children:Ct("div",{className:"welcome-screen-center",children:e||pb(lS,{children:[Ct(hb,{}),Ct(gb,{children:b("welcomeScreen.defaults.center_heading")}),pb(fb,{children:[Ct(xb,{}),Ct(bb,{})]})]})})})};uo.displayName="Center";var hb=({children:e})=>Ct("div",{className:"welcome-screen-center__logo virgil welcome-screen-decor",children:e||Ct(oS,{withText:!0})});hb.displayName="Logo";var gb=({children:e})=>Ct("div",{className:"welcome-screen-center__heading welcome-screen-decor virgil",children:e});gb.displayName="Heading";var fb=({children:e})=>Ct("div",{className:"welcome-screen-menu",children:e});fb.displayName="Menu";var bb=()=>{let e=_t();return Ct(Uc,{onSelect:()=>e.executeAction(Sa),shortcut:"?",icon:Cl,children:b("helpDialog.title")})};bb.displayName="MenuItemHelp";var xb=()=>{let e=Me(),t=_t();return e.viewModeEnabled?null:Ct(Uc,{onSelect:()=>t.executeAction(Ol),shortcut:It("loadScene"),icon:kl,children:b("buttons.load")})};xb.displayName="MenuItemLoadScene";var aS=({onSelect:e})=>{let{t}=yt();return Ct(Uc,{shortcut:null,onSelect:e,icon:Vm,children:t("labels.liveCollaboration")})};aS.displayName="MenuItemLiveCollaborationTrigger";uo.Logo=hb;uo.Heading=gb;uo.Menu=fb;uo.MenuItem=Uc;uo.MenuItemLink=iS;uo.MenuItemHelp=bb;uo.MenuItemLoadScene=xb;uo.MenuItemLiveCollaborationTrigger=aS;f();import{jsx as ns,jsxs as Eb}from"react/jsx-runtime";var ku=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=et();return ns(t.In,{children:Eb("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Ry,ns("div",{className:"welcome-screen-decor-hint__label",children:e||b("welcomeScreen.defaults.menuHint")})]})})};ku.displayName="MenuHint";var Au=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=et();return ns(t.In,{children:Eb("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ns("div",{className:"welcome-screen-decor-hint__label",children:e||b("welcomeScreen.defaults.toolbarHint")}),Oy]})})};Au.displayName="ToolbarHint";var Mu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=et();return ns(t.In,{children:Eb("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ns("div",{children:e||b("welcomeScreen.defaults.helpHint")}),Ny]})})};Mu.displayName="HelpHint";import{Fragment as sS,jsx as Wc,jsxs as XP}from"react/jsx-runtime";var Lu=e=>Wc(sS,{children:e.children||XP(sS,{children:[Wc(uo,{}),Wc(ku,{}),Wc(Au,{}),Wc(Mu,{})]})});Lu.displayName="WelcomeScreen";Lu.Center=uo;Lu.Hints={MenuHint:ku,ToolbarHint:Au,HelpHint:Mu};var $P=Lu;f();import ZP from"clsx";import{jsx as qP,jsxs as JP}from"react/jsx-runtime";var cS=({isCollaborating:e,onSelect:t,...r})=>{let o=Me(),n=o.width<830;return JP(Jo,{...r,className:ZP("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:n?void 0:"auto"},title:b("labels.liveCollaboration"),children:[n?i2:b("labels.share"),o.collaborators.size>0&&qP("div",{className:"CollabButton-collaborators",children:o.collaborators.size})]})},jP=cS;cS.displayName="LiveCollaborationTrigger";ge();cl();da();Pn();Er();bn();ce();U();We();z();f();import{jsx as dS,jsxs as QP}from"react/jsx-runtime";var mS=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:r}=et(),o=_e();return dS(r.In,{children:QP(Oe.Item,{onSelect:()=>{fe("ai","dialog open","ttd"),o({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??Z2,children:[e??b("labels.textToDiagram"),dS(Oe.Item.Badge,{children:"AI"})]})})};mS.displayName="TTDDialogTrigger";ia();at();lg();import{jsx as yb}from"react/jsx-runtime";eS();var o7=e=>{let{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n=!1,onPointerUpdate:i,renderTopRightUI:a,langCode:l=Ro.code,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:h,onPaste:x,detectScroll:E=!0,handleKeyboardGlobally:v=!1,onLibraryChange:w,autoFocus:y=!1,generateIdForFile:I,onLinkOpen:P,onPointerDown:C,onPointerUp:_,onScrollChange:D,children:H,validateEmbeddable:A,renderEmbeddable:M,aiEnabled:k}=e,O=e.UIOptions?.canvasActions,X={...e.UIOptions,canvasActions:{...Bu.canvasActions,...O},tools:{image:e.UIOptions?.tools?.image??!0}};return O?.export&&(X.canvasActions.export.saveFileToDisk=O.export?.saveFileToDisk??Bu.canvasActions.export.saveFileToDisk),X.canvasActions.toggleTheme===null&&typeof p>"u"&&(X.canvasActions.toggleTheme=!0),t7(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ee=xe=>{typeof xe.scale=="number"&&xe.scale!==1&&xe.preventDefault()};return document.addEventListener("touchmove",ee,{passive:!1}),()=>{document.removeEventListener("touchmove",ee)}},[]),yb(r7,{unstable_createStore:()=>Xt,scope:Be,children:yb(ox,{langCode:l,theme:p,children:yb(Q5,{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n,onPointerUpdate:i,renderTopRightUI:a,langCode:l,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:h,UIOptions:X,onPaste:x,detectScroll:E,handleKeyboardGlobally:v,onLibraryChange:w,autoFocus:y,generateIdForFile:I,onLinkOpen:P,onPointerDown:C,onPointerUp:_,onScrollChange:D,validateEmbeddable:A,renderEmbeddable:M,aiEnabled:k!==!1,children:H})})})},n7=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:r,UIOptions:o={},...n}=e,{initialData:i,UIOptions:a={},...l}=t,s=Object.keys(o),c=Object.keys(a);return s.length!==c.length?!1:s.every(m=>m==="canvasActions"?Object.keys(o.canvasActions).every(u=>u==="export"&&o?.canvasActions?.export&&a?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:o?.canvasActions?.[u]===a?.canvasActions?.[u]):o[m]===a[m])&&wt(n,l)},i7=e7.memo(o7,n7);i7.displayName="Excalidraw";export{Jo as Button,Nu as DEFAULT_LASER_COLOR,nu as DefaultSidebar,i7 as Excalidraw,it as FONT_FAMILY,VP as Footer,jP as LiveCollaborationTrigger,J as MIME_TYPES,mr as MainMenu,rt as ROUNDNESS,zn as Sidebar,oe as THEME,W1 as TTDDialog,mS as TTDDialogTrigger,$P as WelcomeScreen,li as bumpVersion,_c as convertToExcalidrawElements,Ro as defaultLang,$E as elementPartiallyOverlapsWithOrContainsBBox,ag as elementsOverlappingBBox,Tm as exportToBlob,hi as exportToCanvas,z6 as exportToClipboard,El as exportToSvg,we as getCommonBounds,qd as getFreeDrawSvgPath,wp as getLibraryItemsHash,be as getNonDeletedElements,dC as getSceneVersion,UI as getVisibleSceneBounds,Tg as hashElementsVersion,Sg as hashString,ig as isElementInsideBBox,eo as isInvisiblySmallElement,re as isLinearElement,_a as languages,pl as loadFromBlob,Vh as loadLibraryFromBlob,Qd as loadSceneOrLibraryFromBlob,Ov as mergeLibraryItems,F as mutateElement,ne as newElementWith,lr as normalizeLink,Uf as parseLibraryTokensFromUrl,ci as restore,eE as restoreAppState,Vs as restoreElements,aa as restoreLibraryItems,Dt as sceneCoordsToViewportCoords,mi as serializeAsJSON,om as serializeLibraryAsJSON,Ie as useDevice,Ok as useHandleLibrary,yt as useI18n,Ue as viewportCoordsToSceneCoords,jw as zoomToFitBounds};