ultisuite-client/out/_next/static/chunks/5858bd96.f2258cadf39c5742.js
R3D347HR4Y d6d18f911b
Some checks failed
E2E / Playwright e2e (push) Has been cancelled
Lots of stuff and mobile app
2026-06-17 00:13:28 +02:00

108 lines
486 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3808],{3339:(e,t,n)=>{n.d(t,{Excalidraw:()=>rj,exportToSvg:()=>i.ri,restoreAppState:()=>i.kh,restoreElements:()=>i.jh,serializeAsJSON:()=>i.Jh});var i=n(71323),a=n(22450),l=n(67002),s=n(47739),r=n(847),o=n(91356),d=n(32777),c=n(9367),h=n(4208),m=n(20193),p=n(86669),u=n(88823),g=n(763),f=n(434),b=n(75208),x=n(53088),E=n(74239),y=n(1346),v=n(85668),w=n(67498),S=n(97591),k=(0,c.l)(),{useAtom:C,useSetAtom:j,useAtomValue:I,useStore:T}=k,M=k.Provider,D=(0,d.y$)(),L=(0,r.b)({"./locales/ar-SA.json":()=>n.e(3802).then(n.bind(n,83802)),"./locales/az-AZ.json":()=>n.e(4689).then(n.bind(n,4689)),"./locales/bg-BG.json":()=>n.e(8842).then(n.bind(n,28842)),"./locales/bn-BD.json":()=>n.e(7521).then(n.bind(n,47521)),"./locales/ca-ES.json":()=>n.e(1236).then(n.bind(n,81236)),"./locales/cs-CZ.json":()=>n.e(8698).then(n.bind(n,58698)),"./locales/da-DK.json":()=>n.e(2260).then(n.bind(n,62260)),"./locales/de-DE.json":()=>n.e(8142).then(n.bind(n,58142)),"./locales/el-GR.json":()=>n.e(2692).then(n.bind(n,82692)),"./locales/en.json":()=>n.e(3731).then(n.bind(n,36112)),"./locales/es-ES.json":()=>n.e(3624).then(n.bind(n,73624)),"./locales/eu-ES.json":()=>n.e(106).then(n.bind(n,90106)),"./locales/fa-IR.json":()=>n.e(7176).then(n.bind(n,87176)),"./locales/fi-FI.json":()=>n.e(9169).then(n.bind(n,99169)),"./locales/fr-FR.json":()=>n.e(4825).then(n.bind(n,24825)),"./locales/gl-ES.json":()=>n.e(8018).then(n.bind(n,65637)),"./locales/he-IL.json":()=>n.e(6379).then(n.bind(n,36379)),"./locales/hi-IN.json":()=>n.e(1778).then(n.bind(n,31778)),"./locales/hu-HU.json":()=>n.e(8441).then(n.bind(n,68441)),"./locales/id-ID.json":()=>n.e(7407).then(n.bind(n,47407)),"./locales/it-IT.json":()=>n.e(2458).then(n.bind(n,52458)),"./locales/ja-JP.json":()=>n.e(3705).then(n.bind(n,43705)),"./locales/kaa.json":()=>n.e(3305).then(n.bind(n,3305)),"./locales/kab-KAB.json":()=>n.e(2637).then(n.bind(n,2637)),"./locales/kk-KZ.json":()=>n.e(6673).then(n.bind(n,26673)),"./locales/km-KH.json":()=>n.e(8172).then(n.bind(n,48172)),"./locales/ko-KR.json":()=>n.e(8912).then(n.bind(n,48912)),"./locales/ku-TR.json":()=>n.e(3683).then(n.bind(n,83683)),"./locales/lt-LT.json":()=>n.e(9828).then(n.bind(n,39828)),"./locales/lv-LV.json":()=>n.e(920).then(n.bind(n,20920)),"./locales/mr-IN.json":()=>n.e(2460).then(n.bind(n,52460)),"./locales/my-MM.json":()=>n.e(2447).then(n.bind(n,92447)),"./locales/nb-NO.json":()=>n.e(1903).then(n.bind(n,61903)),"./locales/nl-NL.json":()=>n.e(2510).then(n.bind(n,82510)),"./locales/nn-NO.json":()=>n.e(9852).then(n.bind(n,79852)),"./locales/oc-FR.json":()=>n.e(5075).then(n.bind(n,25075)),"./locales/pa-IN.json":()=>n.e(9977).then(n.bind(n,19977)),"./locales/percentages.json":()=>n.e(5862).then(n.bind(n,95862)),"./locales/pl-PL.json":()=>n.e(7267).then(n.bind(n,77267)),"./locales/pt-BR.json":()=>n.e(9076).then(n.bind(n,79076)),"./locales/pt-PT.json":()=>n.e(7900).then(n.bind(n,37900)),"./locales/ro-RO.json":()=>n.e(2153).then(n.bind(n,12153)),"./locales/ru-RU.json":()=>n.e(4401).then(n.bind(n,14401)),"./locales/si-LK.json":()=>n.e(7048).then(n.bind(n,37048)),"./locales/sk-SK.json":()=>n.e(2689).then(n.bind(n,22689)),"./locales/sl-SI.json":()=>n.e(1816).then(n.bind(n,11816)),"./locales/sv-SE.json":()=>n.e(23).then(n.bind(n,60023)),"./locales/ta-IN.json":()=>n.e(7608).then(n.bind(n,7608)),"./locales/th-TH.json":()=>n.e(5637).then(n.bind(n,5637)),"./locales/tr-TR.json":()=>n.e(308).then(n.bind(n,40308)),"./locales/uk-UA.json":()=>n.e(6446).then(n.bind(n,26446)),"./locales/vi-VN.json":()=>n.e(3492).then(n.bind(n,43492)),"./locales/zh-CN.json":()=>n.e(1639).then(n.bind(n,31639)),"./locales/zh-HK.json":()=>n.e(6222).then(n.bind(n,6222)),"./locales/zh-TW.json":()=>n.e(7510).then(n.bind(n,97510))}),N={code:"en",label:"English"},A=[N,...[{code:"ar-SA",label:"العربية",rtl:!0},{code:"bg-BG",label:"Български"},{code:"ca-ES",label:"Catal\xe0"},{code:"cs-CZ",label:"Česky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"Ελληνικά"},{code:"es-ES",label:"Espa\xf1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"فارسی",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xe7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"עברית",rtl:!0},{code:"hi-IN",label:"हिन्दी"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"日本語"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"Қазақ тілі"},{code:"ko-KR",label:"한국어"},{code:"ku-TR",label:"Kurd\xee"},{code:"lt-LT",label:"Lietuvių"},{code:"lv-LV",label:"Latviešu"},{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:"ਪੰਜਾਬੀ"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xeas Brasileiro"},{code:"pt-PT",label:"Portugu\xeas"},{code:"ro-RO",label:"Rom\xe2nă"},{code:"ru-RU",label:"Русский"},{code:"sk-SK",label:"Slovenčina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Slovenščina"},{code:"tr-TR",label:"T\xfcrk\xe7e"},{code:"uk-UA",label:"Українська"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"},{code:"vi-VN",label:"Tiếng Việt"},{code:"mr-IN",label:"मराठी"}].filter(e=>s.c[e.code]>=85).sort((e,t)=>e.label>t.label?1:-1)],P="__test__";a.a.DEV&&A.unshift({code:P,label:"test language"},{code:`${P}.rtl`,label:"test language (rtl)",rtl:!0});var _=N,R={},O=async e=>{if(_=e,document.documentElement.dir=_.rtl?"rtl":"ltr",document.documentElement.lang=_.code,e.code.startsWith(P))R={};else try{R=await L(`./locales/${_.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),R=l.J}D.set(U,e.code)},F=(e,t)=>{for(let n=0;n<t.length;++n){let i=t[n];if(void 0===e[i])return;e=e[i]}if("string"==typeof e)return e},z=(e,t,n)=>{if(_.code.startsWith(P))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let i=e.split("."),s=F(R,i)||F(l.J,i)||n;if(void 0===s){let t=`Can't find translation for ${e}`;if(a.a.PROD)return console.warn(t),"";throw Error(t)}if(t)for(let e in t)s=s.replace(`{{${e}}}`,String(t[e]));return s},U=(0,d.eU)(N.code),B=()=>({t:z,langCode:I(U)}),W=({size:e="1em",circleWidth:t=8,synchronized:n=!1,className:i=""})=>{let a=-(o.useRef(Date.now()).current%1600);return(0,h.jsx)("div",{className:`Spinner ${i}`,children:(0,h.jsx)("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":n?`${a}ms`:0},children:(0,h.jsx)("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},H=({delay:e,theme:t})=>{let[n,a]=(0,o.useState)(!!e);return(0,o.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{a(!1)},e);return()=>clearTimeout(t)},[e]),n?null:(0,h.jsxs)("div",{className:(0,m.A)("LoadingMessage",{"LoadingMessage--dark":t===i.G.DARK}),children:[(0,h.jsx)("div",{children:(0,h.jsx)(W,{})}),(0,h.jsx)("div",{className:"LoadingMessage-text",children:z("labels.loadingScene")})]})},$=e=>{let[t,n]=(0,o.useState)(!0);return(0,o.useEffect)(()=>{let t=async()=>{await O(i),n(!1)},i=A.find(t=>t.code===e.langCode)||N;t()},[e.langCode]),t?(0,h.jsx)(H,{theme:e.theme}):e.children},Y=o.forwardRef(({size:e="medium",visible:t=!0,className:n="",...a},l)=>{let{id:s}=sJ(),r=o.useRef(null);o.useImperativeHandle(l,()=>r.current);let d=`ToolIcon_size_${e}`,[c,p]=(0,o.useState)(!1),u=(0,o.useRef)(!0),g=async e=>{let t="onClick"in a&&a.onClick?.(e);if((0,i.Fb)(t))try{p(!0),await t}catch(e){if(e instanceof i.tc)console.warn(e);else throw e}finally{u.current&&p(!1)}};(0,o.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let f=(0,o.useRef)(null);if("button"===a.type||"icon"===a.type||"submit"===a.type){let e="icon"===a.type?"button":a.type;return(0,h.jsxs)("button",{className:(0,m.A)("ToolIcon_type_button",d,n,t&&!a.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!a.hidden,"ToolIcon--selected":a.selected,"ToolIcon--plain":"icon"===a.type}),style:a.style,"data-testid":a["data-testid"],hidden:a.hidden,title:a.title,"aria-label":a["aria-label"],type:e,onClick:g,ref:r,disabled:c||a.isLoading||!!a.disabled,children:[(a.icon||a.label)&&(0,h.jsxs)("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!a.disabled,children:[a.icon||a.label,a.keyBindingLabel&&(0,h.jsx)("span",{className:"ToolIcon__keybinding",children:a.keyBindingLabel}),a.isLoading&&(0,h.jsx)(W,{})]}),a.showAriaLabel&&(0,h.jsxs)("div",{className:"ToolIcon__label",children:[a["aria-label"]," ",c&&(0,h.jsx)(W,{})]}),a.children]})}return(0,h.jsxs)("label",{className:(0,m.A)("ToolIcon",n),title:a.title,onPointerDown:e=>{f.current=e.pointerType||null,a.onPointerDown?.({pointerType:e.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{f.current=null})},children:[(0,h.jsx)("input",{className:`ToolIcon_type_radio ${d}`,type:"radio",name:a.name,"aria-label":a["aria-label"],"aria-keyshortcuts":a["aria-keyshortcuts"],"data-testid":a["data-testid"],id:`${s}-${a.id}`,onChange:()=>{a.onChange?.({pointerType:f.current})},checked:a.checked,ref:r}),(0,h.jsxs)("div",{className:"ToolIcon__icon",children:[a.icon,a.keyBindingLabel&&(0,h.jsx)("span",{className:"ToolIcon__keybinding",children:a.keyBindingLabel})]})]})});Y.displayName="ToolButton";var G=(e,t)=>{if(e.editingGroupId){let n=(0,i.Qc)((0,i.pk)(t),e.editingGroupId);if(n.length)return{...e,selectedElementIds:{[n[0].id]:!0}}}return e},V=(0,i.$c)({name:"deleteSelectedElements",label:"labels.delete",icon:i.ud,trackEvent:{category:"element",action:"delete"},perform:(e,t,n,a)=>{if(t.editingLinearElement){let{elementId:n,selectedPointsIndices:l,startBindingElement:s,endBindingElement:r}=t.editingLinearElement,o=a.scene.getNonDeletedElementsMap(),d=i.pj.getElement(n,o);if(!d||null==l)return!1;if(d.points.length<2){let n=e.map(e=>e.id===d.id?(0,i.Qj)(e,{isDeleted:!0}):e),a=G(t,n);return{elements:n,appState:{...a,editingLinearElement:null},captureUpdate:i.Wg.IMMEDIATELY}}let c={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:r};return i.pj.deletePoints(d,l),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...c,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:i.Wg.IMMEDIATELY}}let{elements:l,appState:s}=((e,t,n)=>{let a=new Set((0,i.vk)(e.filter(e=>(0,i.bc)(e)),t).map(e=>e.id)),l={},s=n.scene.getNonDeletedElementsMap(),r=new Set;for(let t of a)for(let n of(0,i.Bi)(e,t))if(!r.has(n.id)){if((0,i.nc)(n)){let e=(0,i.Aj)(n,s);e&&(l[e.id]=!0)}else l[n.id]=!0;r.add(n.id)}let o=!0,d=e.map(e=>{if(t.selectedElementIds[e.id]){let t=(0,i.nc)(e)?(0,i.Aj)(e,s):null;return e.frameId&&a.has(e.frameId)?(o=!1,l[e.id]=!0,e):t?.frameId&&a.has(t?.frameId)?e:(e.boundElements&&e.boundElements.forEach(t=>{let a=n.scene.getNonDeletedElementsMap().get(t.id);a&&(0,i.ec)(a)&&((0,i.Pj)(a,{startBinding:e.id===a.startBinding?.elementId?null:a.startBinding,endBinding:e.id===a.endBinding?.elementId?null:a.endBinding}),(0,i.Pj)(a,{points:a.points}))}),(0,i.Qj)(e,{isDeleted:!0}))}return e.frameId&&a.has(e.frameId)?(o=!1,(0,i.nc)(e)||(l[e.id]=!0),(0,i.Qj)(e,{frameId:null})):(0,i.nc)(e)&&t.selectedElementIds[e.containerId]?(0,i.Qj)(e,{isDeleted:!0}):e}),c=t.editingGroupId;if(o&&t.editingGroupId){let e=(0,i.Qc)(d,t.editingGroupId).filter(e=>!e.isDeleted);if(e.length>1)e[0]&&(l[e[0].id]=!0);else{c=null,e[0]&&(l[e[0].id]=!0);let n=e[0];if(n){let e=n.groupIds.findIndex(e=>e===t.editingGroupId),a=n.groupIds[e+1];if(a){let e=(0,i.Qc)(d,a).filter(e=>!e.isDeleted);e.length>1&&(c=a,e.forEach(e=>{l[e.id]=!0}))}}}}return{elements:d,appState:{...t,...(0,i.Jc)({selectedElementIds:l,editingGroupId:c},d,t,null)}}})(e,t,a);return(0,i.Tg)(l,l.filter(e=>e.isDeleted)),s=G(s,l),{elements:l,appState:{...s,activeTool:(0,i.jb)(t,{type:"selection"}),multiElement:null,activeEmbeddable:null},captureUpdate:(0,i.tk)((0,i.pk)(e),t)?i.Wg.IMMEDIATELY:i.Wg.EVENTUALLY}},keyTest:(e,t,n)=>(e.key===i.hg.BACKSPACE||e.key===i.hg.DELETE)&&!e[i.hg.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:n})=>(0,h.jsx)(Y,{type:"button",icon:i.ud,title:z("labels.delete"),"aria-label":z("labels.delete"),onClick:()=>n(null),visible:(0,i.tk)((0,i.pk)(e),t)})}),K=(e,t)=>e.frameId===t||e.id===t,Z=(e,t,n)=>{let a=[],l=[],s=null,r=-1,o=(0,i.xb)(n||(0,i.vk)(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++r<e.length;){let t=e[r];o.get(t.id)?(l.length&&(a=a.concat(l),l=[]),a.push(r),s=r+1):t.isDeleted&&s===r?(s=r+1,l.push(r)):l=[]}return a},X=(e,t,n)=>{if("containerId"in e&&e.containerId){let a=i.Oj.getScene(e).getElement(e.containerId);if(a)return"left"===n?Math.min(t.indexOf(a),t.indexOf(e)):Math.max(t.indexOf(a),t.indexOf(e))}else{let a=e.boundElements?.find(e=>"arrow"!==e.type)?.id;if(a){let l=i.Oj.getScene(e).getElement(a);if(l)return"left"===n?Math.min(t.indexOf(l),t.indexOf(e)):Math.max(t.indexOf(l),t.indexOf(e))}}},Q=(e,t)=>t.reduce((t,n)=>{let i=e[n];return t.set(i.id,i),t},new Map),q=(e,t,n)=>{let a,l=Z(e,t),s=Q(e,l),r=(a=0,l.reduce((e,t,n)=>(n>0&&l[n-1]!==t-1&&(a=++a),(e[a]||(e[a]=[])).push(t),e),[]));"right"===n&&(r=r.reverse());let o=new Set(l.filter(t=>(0,i.bc)(e[t])).map(t=>e[t].id));return r.forEach((a,l)=>{let s=a[0],r=a[a.length-1],d="left"===n?s:r,c=a.some(t=>{let n=e[t];return n.frameId&&o.has(n.frameId)})?null:e[d]?.frameId,h=((e,t,n,a,l)=>{let s=t[n],r=t=>!t.isDeleted&&(l?t.frameId===l:!e.editingGroupId||t.groupIds.includes(e.editingGroupId)),o="left"===a?(0,i.rb)(t,e=>r(e),Math.max(0,n-1)):(0,i.qb)(t,e=>r(e),n+1),d=t[o];if(!d)return -1;if(e.editingGroupId){if(s?.groupIds.join("")===d?.groupIds.join(""))return X(d,t,a)??o;if(!d?.groupIds.includes(e.editingGroupId))return -1}if(!l&&(d.frameId||(0,i.bc)(d))){var c;let e,n,i=(c=d.frameId||d.id,e=-1,n=-1,t.forEach((t,i)=>{K(t,c)&&(-1===e&&(e=i),n=i)}),-1===e?[]:t.slice(e,n+1));return"left"===a?t.indexOf(i[0]):t.indexOf(i[i.length-1])}if(!d.groupIds.length)return X(d,t,a)??o;let h=e.editingGroupId?d.groupIds[d.groupIds.indexOf(e.editingGroupId)-1]:d.groupIds[d.groupIds.length-1],m=(0,i.Qc)(t,h);return m.length?"left"===a?t.indexOf(m[0]):t.indexOf(m[m.length-1]):o})(t,e,d,n,c);if(-1===h||d===h)return;let m="left"===n?e.slice(0,h):e.slice(0,s),p=e.slice(s,r+1),u="left"===n?e.slice(h,s):e.slice(r+1,h+1),g="left"===n?e.slice(r+1):e.slice(h+1);e="left"===n?[...m,...p,...u,...g]:[...m,...u,...p,...g]}),(0,i.Mj)(e,s),e},J=(e,t,n,a,l)=>{let s=Z(e,t,l),r=Q(e,s),o=[],d,c;if("left"===n){if(a)d=(0,i.qb)(e,e=>K(e,a));else if(t.editingGroupId){let n=(0,i.Qc)(e,t.editingGroupId);if(!n.length)return e;d=e.indexOf(n[0])}else d=0;c=s[s.length-1]}else{if(a)c=(0,i.rb)(e,e=>K(e,a));else if(t.editingGroupId){let n=(0,i.Qc)(e,t.editingGroupId);if(!n.length)return e;c=e.indexOf(n[n.length-1])}else c=e.length-1;d=s[0]}-1===d&&(d=0);for(let t=d;t<c+1;t++)s.includes(t)||o.push(e[t]);let h=Array.from(r.values()),m=e.slice(0,d),p=e.slice(c+1),u="left"===n?[...m,...h,...o,...p]:[...m,...o,...h,...p];return(0,i.Mj)(u,r),u};function ee(e,t,n,a){let l=(0,i.xb)((0,i.vk)(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),s={regularElements:[],frameChildren:new Map},r=new Set;for(let t of e)l.has(t.id)&&(0,i.bc)(t)&&r.add(t.id);for(let t of e)if(l.has(t.id))if((0,i.bc)(t)||t.frameId&&r.has(t.frameId))s.regularElements.push(t);else if(t.frameId){let e=s.frameChildren.get(t.frameId)||[];e.push(t),s.frameChildren.set(t.frameId,e)}else s.regularElements.push(t);let o=e;for(let[i,l]of Array.from(s.frameChildren.entries()))o=a(e,t,n,i,l);return a(o,t,n,null,s.regularElements)}var et=(0,i.$c)({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:i.Wd,trackEvent:{category:"element"},perform:(e,t)=>({elements:q(e,t,"left"),appState:t,captureUpdate:i.Wg.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[i.hg.CTRL_OR_CMD]&&!e.shiftKey&&e.code===i.gg.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,h.jsx)("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${z("labels.sendBackward")} \u2014 ${(0,i.kb)("CtrlOrCmd+[")}`,children:i.Wd})}),en=(0,i.$c)({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:i.Vd,trackEvent:{category:"element"},perform:(e,t)=>({elements:q(e,t,"right"),appState:t,captureUpdate:i.Wg.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[i.hg.CTRL_OR_CMD]&&!e.shiftKey&&e.code===i.gg.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,h.jsx)("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${z("labels.bringForward")} \u2014 ${(0,i.kb)("CtrlOrCmd+]")}`,children:i.Vd})}),ei=(0,i.$c)({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:i.Yd,trackEvent:{category:"element"},perform:(e,t)=>({elements:ee(e,t,"left",J),appState:t,captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>i.l?e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.BRACKET_LEFT:e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&e.code===i.gg.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,h.jsx)("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${z("labels.sendToBack")} \u2014 ${i.l?(0,i.kb)("CtrlOrCmd+Alt+["):(0,i.kb)("CtrlOrCmd+Shift+[")}`,children:i.Yd})}),ea=(0,i.$c)({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:i.Xd,trackEvent:{category:"element"},perform:(e,t)=>({elements:ee(e,t,"right",J),appState:t,captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>i.l?e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.BRACKET_RIGHT:e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&e.code===i.gg.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,h.jsx)("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${z("labels.bringToFront")} \u2014 ${i.l?(0,i.kb)("CtrlOrCmd+Alt+]"):(0,i.kb)("CtrlOrCmd+Shift+]")}`,children:i.Xd})}),el=(0,i.$c)({name:"selectAll",label:"labels.selectAll",icon:i.uf,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,n,a)=>{if(t.editingLinearElement)return!1;let l=e.filter(e=>!e.isDeleted&&!((0,i._b)(e)&&e.containerId)&&!e.locked).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...(0,i.Jc)({editingGroupId:null,selectedElementIds:l},(0,i.pk)(e),t,a),selectedLinearElement:1===Object.keys(l).length&&(0,i.cc)(e[0])?new i.pj(e[0]):null},captureUpdate:i.Wg.IMMEDIATELY}},keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.A}),es=(0,i.$c)({name:"duplicateSelection",label:"labels.duplicateSelection",icon:i.wd,trackEvent:{category:"element"},perform:(e,t,n,a)=>{if(t.editingLinearElement)try{let n=i.pj.duplicateSelectedPoints(t,a.scene.getNonDeletedElementsMap());return{elements:e,appState:n,captureUpdate:i.Wg.IMMEDIATELY}}catch{return!1}let l=er(e,t);if(a.props.onDuplicate&&l.elements){let t=a.props.onDuplicate(l.elements,e);t&&(l.elements=t)}return{...l,captureUpdate:i.Wg.IMMEDIATELY}},keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.D,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,h.jsx)(Y,{type:"button",icon:i.wd,title:`${z("labels.duplicateSelection")} \u2014 ${(0,i.kb)("CtrlOrCmd+D")}`,"aria-label":z("labels.duplicateSelection"),onClick:()=>n(null),visible:(0,i.tk)((0,i.pk)(e),t)})}),er=(e,t)=>{var n,a;let l,s,r,o,d,c,h,m=new Map,p=[],u=[],g=new Map,f=new Map,b=(0,i.xb)(e),x=e=>{let n=(0,i.Ub)(e).reduce((e,n)=>{if(y.has(n.id))return e;y.set(n.id,!0);let a=(0,i.cg)(t.editingGroupId,m,n,{x:n.x+i.R/2,y:n.y+i.R/2});return y.set(a.id,!0),f.set(a.id,a),g.set(n.id,a.id),u.push(n),p.push(a),e.push(a),e},[]);return Array.isArray(e)?n:n[0]||null};l=(n=e).slice(),s=new Set,r=e=>{let t=e[0]?.groupIds?.join(""),n=[e[0]],i=[];for(let a of e.slice(1))a.groupIds?.join("")===t?n.push(a):i.push(a);return i.length?[...n,...r(i)]:n},o=new Map,l.forEach((e,t)=>{if(!o.has(e.id))if(e.groupIds?.length){let n=e.groupIds[e.groupIds.length-1];for(let e of r(l.slice(t).filter(e=>{let t=e?.groupIds?.some(e=>e===n);return t&&o.set(e.id,!0),t})))s.add(e)}else s.add(e)}),a=s.size!==n.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),n):[...s],d=(0,i.yb)(a),c=a.slice(),h=new Set,c.forEach((e,t)=>{e&&(e.boundElements?.length?(h.add(e),c[t]=null,e.boundElements.forEach(e=>{let t=d.get(e.id);t&&"text"===e.type&&(h.add(t[0]),c[t[1]]=null)})):"text"===e.type&&e.containerId&&d.get(e.containerId)?.[0].boundElements?.find(t=>t.id===e.id)||(h.add(e),c[t]=null))}),e=h.size!==a.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),a):[...h];let E=(0,i.xb)((0,i.vk)(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),y=new Map,v=e.slice(),w=(e,t)=>{(0,i.Kb)(-1!==e,"targetIndex === -1 "),(Array.isArray(t)||t)&&v.splice(e+1,0,...(0,i.Ub)(t))},S=new Set(e.filter(e=>E.has(e.id)&&(0,i.bc)(e)).map(e=>e.id));for(let n of e){if(y.has(n.id)||!E.has(n.id))continue;let a=(0,i.Lc)(t,n);if(a){let t=(0,i.Qc)(e,a).flatMap(t=>(0,i.bc)(t)?[...(0,i.Bi)(e,t.id),t]:[t]);w((0,i.rb)(v,e=>e.groupIds?.includes(a)),x(t));continue}if(!(n.frameId&&S.has(n.frameId))){if((0,i.bc)(n)){let t=n.id,a=(0,i.Bi)(e,t);w((0,i.rb)(v,e=>e.frameId===t||e.id===t),x([...a,n]));continue}if((0,i.mc)(n)){let e=(0,i.zj)(n,b);w((0,i.rb)(v,e=>e.id===n.id||"containerId"in e&&e.containerId===n.id),x(e?[n,e]:n));continue}if((0,i.nc)(n)){let e=(0,i.Aj)(n,b);w((0,i.rb)(v,t=>t.id===n.id||t.id===e?.id),x(e?[e,n]:n));continue}w((0,i.rb)(v,e=>e.id===n.id),x(n))}}(0,i.vj)(v,u,g),(0,i.Sg)(v,u,g),(0,i.wi)(v,u,g);let k=(0,i.rk)(p);return{elements:v,appState:{...t,...(0,i.Jc)({editingGroupId:t.editingGroupId,selectedElementIds:k.reduce((e,t)=>((0,i.nc)(t)||(e[t.id]=!0),e),{})},(0,i.pk)(v),t,null)}}},eo=new Set(["command_palette","export"]),ed=(e,t,n,i)=>{try{if(typeof window>"u"||a.a.VITE_WORKER_ID||"true"!==a.a.VITE_APP_ENABLE_TRACKING||!eo.has(e)||a.a.DEV)return;a.a.PROD||console.info("trackEvent",{category:e,action:t,label:n,value:i}),window.sa_event&&window.sa_event(t,{category:e,label:n,value:i})}catch(e){console.error("error during analytics",e)}},ec=(0,o.forwardRef)((e,t)=>{let{title:n,className:i,testId:a,active:l,standalone:s,icon:r,onClick:o}=e;return(0,h.jsx)("button",{type:"button",ref:t,title:n,"data-testid":a,className:(0,m.A)(i,{standalone:s,active:l}),onClick:o,children:r},n)}),eh=e=>(0,h.jsx)("div",{className:"buttonList",children:e.options.map(t=>"button"===e.type?(0,h.jsx)(ec,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:n=>e.onClick(t.value,n)},t.text):(0,h.jsxs)("label",{className:(0,m.A)({active:e.value===t.value}),title:t.text,children:[(0,h.jsx)("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))}),em=({onChange:e,type:t,activeColor:n,topPicks:a})=>{let l;return"elementStroke"===t&&(l=i.f),"elementBackground"===t&&(l=i.g),"canvasBackground"===t&&(l=i.h),a&&(l=a),l?(0,h.jsx)("div",{className:"color-picker__top-picks",children:l.map(t=>(0,h.jsx)("button",{className:(0,m.A)("color-picker__button",{active:t===n,"is-transparent":"transparent"===t||!t}),style:{"--swatch-color":t},type:"button",title:t,onClick:()=>e(t),"data-testid":`color-top-pick-${t}`,children:(0,h.jsx)("div",{className:"color-picker__button-outline"})},t))}):(console.error("Invalid type for TopPicks"),null)},ep=()=>(0,h.jsx)("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}}),eu=({palette:e,color:t})=>{for(let[n,i]of Object.entries(e))if(Array.isArray(i)){let e=i.indexOf(t);if(e>-1)return{colorName:n,shade:e}}else if(i===t)return{colorName:n,shade:null};return null},eg=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),ef=({color:e,palette:t})=>!Object.values(t).flat().includes(e),eb=(0,d.eU)(null),ex=(e,t,n)=>(299*e+587*t+114*n)/1e3>=160?"black":"white",eE=({color:e,keyLabel:t,isCustomColor:n=!1,isShade:i=!1})=>(0,h.jsxs)("div",{className:"color-picker__button__hotkey-label",style:{color:((e,t)=>{if(t){let t=new Option().style;if(t.color=e,t.color){let e=t.color.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(",");return ex(parseInt(e[0]),parseInt(e[1]),parseInt(e[2]))}}return"transparent"===e?"black":ex(parseInt(e.substring(1,3),16),parseInt(e.substring(3,5),16),parseInt(e.substring(5,7),16))})(e,n)},children:[i&&"⇧",t]}),ey=({hex:e,onChange:t,palette:n})=>{let i=eu({color:e||"transparent",palette:n}),[a,l]=C(eb),s=(0,o.useRef)(null);if((0,o.useEffect)(()=>{s.current&&"shades"===a&&s.current.focus()},[i,a]),i){let{colorName:e,shade:r}=i,o=n[e];if(Array.isArray(o))return(0,h.jsx)("div",{className:"color-picker-content--default shades",children:o.map((n,i)=>(0,h.jsxs)("button",{ref:i===r&&"shades"===a?s:void 0,tabIndex:-1,type:"button",className:(0,m.A)("color-picker__button color-picker__button--large",{active:i===r}),"aria-label":"Shade",title:`${e} - ${i+1}`,style:n?{"--swatch-color":n}:void 0,onClick:()=>{t(n),l("shades")},children:[(0,h.jsx)("div",{className:"color-picker__button-outline"}),(0,h.jsx)(eE,{color:n,keyLabel:i+1,isShade:!0})]},i))})}return(0,h.jsxs)("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[(0,h.jsx)("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),(0,h.jsx)("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:z("colorPicker.noShades")})]})},ev=({palette:e,color:t,onChange:n,label:i,activeShade:a})=>{let l=eu({color:t||"transparent",palette:e}),[s,r]=C(eb),d=(0,o.useRef)(null);return(0,o.useEffect)(()=>{d.current&&"baseColors"===s&&d.current.focus()},[l?.colorName,s]),(0,h.jsx)("div",{className:"color-picker-content--default",children:Object.entries(e).map(([e,t],i)=>{let s=(Array.isArray(t)?t[a]:t)||"transparent",o=eg[i],c=z(`colors.${e.replace(/\d+/,"")}`,null,"");return(0,h.jsxs)("button",{ref:l?.colorName===e?d:void 0,tabIndex:-1,type:"button",className:(0,m.A)("color-picker__button color-picker__button--large",{active:l?.colorName===e,"is-transparent":"transparent"===s||!s}),onClick:()=>{n(s),r("baseColors")},title:`${c}${s.startsWith("#")?` ${s}`:""} \u2014 ${o}`,"aria-label":`${c} \u2014 ${o}`,style:s?{"--swatch-color":s}:void 0,"data-testid":`color-${e}`,children:[(0,h.jsx)("div",{className:"color-picker__button-outline"}),(0,h.jsx)(eE,{color:s,keyLabel:o})]},e)})})},ew=({colors:e,color:t,onChange:n,label:i})=>{let[a,l]=C(eb),s=(0,o.useRef)(null);return(0,o.useEffect)(()=>{s.current&&s.current.focus()},[t,a]),(0,h.jsx)("div",{className:"color-picker-content--default",children:e.map((e,a)=>(0,h.jsxs)("button",{ref:t===e?s:void 0,tabIndex:-1,type:"button",className:(0,m.A)("color-picker__button color-picker__button--large",{active:t===e,"is-transparent":"transparent"===e||!e}),onClick:()=>{n(e),l("custom")},title:e,"aria-label":i,style:{"--swatch-color":e},children:[(0,h.jsx)("div",{className:"color-picker__button-outline"}),(0,h.jsx)(eE,{color:e,keyLabel:a+1,isCustomColor:!0})]},a))})},eS=(e,t,n)=>{let a=Math.ceil(n/i.b);switch(t=t??-1,e){case"ArrowLeft":{let e=t-1;return e<0?n-1:e}case"ArrowRight":return(t+1)%n;case"ArrowDown":{let e=t+i.b;return e>=n?t%i.b:e}case"ArrowUp":{let e=t-i.b,l=e<0?i.b*a+e:e;return l>=n?void 0:l}}},ek=({children:e})=>(0,h.jsx)("div",{className:"color-picker__heading",children:e}),eC=({color:e,onChange:t,label:n,type:a,elements:l,palette:s,updateData:r,children:d,onEyeDropperToggle:c,onEscape:m})=>{let[p]=o.useState(()=>{let e,t,n;return"canvasBackground"===a?[]:(e={elementBackground:"backgroundColor",elementStroke:"strokeColor"},t=l.filter(t=>!t.isDeleted&&ef({color:t[e[a]],palette:s})),n=new Map,t.forEach(t=>{let i=t[e[a]];n.has(i)?n.set(i,n.get(i)+1):n.set(i,1)}),[...n.entries()].sort((e,t)=>t[1]-e[1]).map(e=>e[0]).slice(0,i.a))}),[u,g]=C(eb),f=eu({color:e,palette:s});(0,o.useEffect)(()=>{if(!u){let t=ef({color:e,palette:s});g(t&&!p.includes(e)?"hex":t?"custom":f?.shade!=null?"shades":"baseColors")}},[u,e,s,g,f,p]);let[b,x]=(0,o.useState)(f?.shade??("elementBackground"===a?i.d:i.c));(0,o.useEffect)(()=>{f?.shade!=null&&x(f.shade);let e=e=>{e.key===i.hg.ALT&&c(!1)};return document.addEventListener("keyup",e,{capture:!0}),()=>{document.removeEventListener("keyup",e,{capture:!0})}},[f,c]);let E=o.useRef(null);return(0,h.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":z("labels.colorPicker"),children:(0,h.jsxs)("div",{ref:E,onKeyDown:n=>{(({event:e,activeColorPickerSection:t,palette:n,color:a,onChange:l,customColors:s,setActiveColorPickerSection:r,updateData:o,activeShade:d,onEyeDropperToggle:c,onEscape:h})=>{if(e[i.hg.CTRL_OR_CMD])return!1;if(e.key===i.hg.ESCAPE)return h(e),!0;if(e.key===i.hg.ALT)return c(!0),!0;if(e.key===i.hg.I)return c(),!0;let m=eu({color:a,palette:n});if(e.key===i.hg.TAB){let o=Object.entries({custom:!!s.length,baseColors:!0,shades:m?.shade!=null,hex:!0}).reduce((e,[t,n])=>(n&&e.push(t),e),[]),d=o.indexOf(t),c=e.shiftKey?-1:1,h=d+c>o.length-1?0:d+c<0?o.length-1:d+c,p=o[h];return p&&r(p),"custom"===p?l(s[0]):"baseColors"===p&&(Object.entries(n).find(([e,t])=>Array.isArray(t)?t.includes(a):t===a?e:null)||l(i.e.black)),e.preventDefault(),e.stopPropagation(),!0}if((({e,colorObj:t,onChange:n,palette:i,customColors:a,setActiveColorPickerSection:l,activeShade:s})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let a=Number(e.code.slice(-1))-1;return n(i[t.colorName][a]),l("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&a[Number(e.key)-1])return n(a[Number(e.key)-1]),l("custom"),!0;if(eg.includes(e.key)){let t=eg.indexOf(e.key),a=Object.keys(i)[t],r=i[a];return n(Array.isArray(r)?r[s]:r),l("baseColors"),!0}return!1})({e,colorObj:m,onChange:l,palette:n,customColors:s,setActiveColorPickerSection:r,activeShade:d}))return!0;if("shades"===t&&m){let{shade:t}=m,a=eS(e.key,t,i.b);if(void 0!==a)return l(n[m.colorName][a]),!0}if("baseColors"===t&&m){let{colorName:t}=m,i=Object.keys(n),a=i.indexOf(t),s=eS(e.key,a,i.length);if(void 0!==s){let e=n[i[s]];return l(Array.isArray(e)?e[d]:e),!0}}if("custom"===t){let t=s.indexOf(a),n=eS(e.key,t,s.length);if(void 0!==n)return l(s[n]),!0}return!1})({event:n,activeColorPickerSection:u,palette:s,color:e,onChange:t,onEyeDropperToggle:c,customColors:p,setActiveColorPickerSection:g,updateData:r,activeShade:b,onEscape:m})&&(n.preventDefault(),n.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!p.length&&(0,h.jsxs)("div",{children:[(0,h.jsx)(ek,{children:z("colorPicker.mostUsedCustomColors")}),(0,h.jsx)(ew,{colors:p,color:e,label:z("colorPicker.mostUsedCustomColors"),onChange:t})]}),(0,h.jsxs)("div",{children:[(0,h.jsx)(ek,{children:z("colorPicker.colors")}),(0,h.jsx)(ev,{color:e,label:n,palette:s,onChange:t,activeShade:b})]}),(0,h.jsxs)("div",{children:[(0,h.jsx)(ek,{children:z("colorPicker.shades")}),(0,h.jsx)(ey,{hex:e,onChange:t,palette:s})]}),d]})})},ej=o.createContext(null),eI=e=>{let[t,n]=(0,o.useState)(null),a=sq(),{theme:l}=o.useContext(ej),{container:s}=sJ();return(0,o.useLayoutEffect)(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",a.editor.isMobile),t.classList.toggle("theme--dark",l===i.G.DARK))},[t,l,a.editor.isMobile,e?.className]),(0,o.useLayoutEffect)(()=>{let t=e?.parentSelector?s?.querySelector(e.parentSelector):document.body;if(!t)return;let i=document.createElement("div");return t.appendChild(i),n(i),()=>{t.removeChild(i)}},[s,e?.parentSelector]),t};function eT(e,t,n){(0,o.useEffect)(()=>{function i(i){if(!e.current)return;let a=n?.(i,e.current);if(!0!==a){if(!1===a)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&"none"===document.body.style.pointerEvents||i.target.closest("[data-prevent-outside-click]")||t(i)}}return document.addEventListener("pointerdown",i),document.addEventListener("touchstart",i),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("touchstart",i)}},[e,t,n])}var eM=e=>{let t=(0,o.useRef)(e);return Object.assign(t.current,e),t.current},eD=(0,d.eU)(null),eL=({onCancel:e,onChange:t,onSelect:n,colorPickerType:a})=>{let l=eI({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),s=o.useContext(ej),r=s0(),d=sX(),c=eM({app:d,onCancel:e,onChange:t,onSelect:n,selectedElements:(0,i.vk)(r,s)}),{container:m}=sJ();(0,o.useEffect)(()=>{let e=u.current;if(!e||!d.canvas||!l)return;let t=!1,n=d.canvas.getContext("2d"),r=({clientX:e,clientY:t})=>{let a=n.getImageData((e-s.offsetLeft)*window.devicePixelRatio,(t-s.offsetTop)*window.devicePixelRatio,1,1).data;return(0,i.k)(a[0],a[1],a[2])},o=({clientX:n,clientY:i,altKey:l})=>{e.style.top=`${i+20}px`,e.style.left=`${n+20}px`;let s=r({clientX:n,clientY:i});t&&c.onChange(a,s,c.selectedElements,{altKey:l}),e.style.background=s},h=()=>{c.onCancel()},p=e=>{t=!0,e.stopImmediatePropagation()},g=e=>{var n;t=!1,m?.focus(),e.stopImmediatePropagation(),e.preventDefault(),n=r(e),c.onSelect(n,e)},f=e=>{e.key===i.hg.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),h())};return l.tabIndex=-1,l.focus(),o({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),l.addEventListener("keydown",f),l.addEventListener("pointerdown",p),l.addEventListener("pointerup",g),window.addEventListener("pointermove",o,{passive:!0}),window.addEventListener("blur",h),()=>{t=!1,l.removeEventListener("keydown",f),l.removeEventListener("pointerdown",p),l.removeEventListener("pointerup",g),window.removeEventListener("pointermove",o),window.removeEventListener("blur",h)}},[c,d.canvas,l,a,m,s.offsetLeft,s.offsetTop]);let u=(0,o.useRef)(null);return eT(u,()=>{e()},e=>!!e.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),l?(0,p.createPortal)((0,h.jsx)("div",{ref:u,className:"excalidraw-eye-dropper-preview"}),l):null},eN=({color:e,onChange:t,label:n,colorPickerType:a})=>{let l=sq(),[s,r]=(0,o.useState)(e),[d,c]=C(eb);(0,o.useEffect)(()=>{r(e)},[e]);let p=(0,o.useCallback)(e=>{let n=e.toLowerCase(),i=eR(n);i&&t(i),r(n)},[t]),u=(0,o.useRef)(null),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{u.current&&u.current.focus()},[d]);let[f,b]=C(eD);return(0,o.useEffect)(()=>()=>{b(null)},[b]),(0,h.jsxs)("div",{className:"color-picker__input-label",children:[(0,h.jsx)("div",{className:"color-picker__input-hash",children:"#"}),(0,h.jsx)("input",{ref:"hex"===d?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":n,onChange:e=>{p(e.target.value)},value:(s||"").replace(/^#/,""),onBlur:()=>{r(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:e=>{e.key!==i.hg.TAB&&(e.key===i.hg.ESCAPE&&g.current?.focus(),e.stopPropagation())}}),!l.editor.isMobile&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),(0,h.jsx)("div",{ref:g,className:(0,m.A)("excalidraw-eye-dropper-trigger",{selected:f}),onClick:()=>b(e=>e?null:{keepOpenOnAlt:!1,onSelect:e=>t(e),colorPickerType:a}),title:`${z("labels.eyeDropper")} \u2014 ${i.hg.I.toLocaleUpperCase()} or ${(0,i.kb)("Alt")} `,children:i.df})]})]})},eA=o.forwardRef(({children:e,padding:t,className:n,style:i},a)=>(0,h.jsx)("div",{className:(0,m.A)("Island",n),style:{"--padding":t,...i},ref:a,children:e})),eP=o.forwardRef(({className:e,container:t,children:n,style:a,onClose:l,onKeyDown:s,onFocusOutside:r,onPointerLeave:o,onPointerDownOutside:d},c)=>{let p=sq();return(0,h.jsx)(f.ZL,{container:t,children:(0,h.jsxs)(f.UC,{ref:c,className:(0,m.A)("focus-visible-none",e),"data-prevent-outside-click":!0,side:p.editor.isMobile&&!p.viewport.isLandscape?"bottom":"right",align:p.editor.isMobile&&!p.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:o,onKeyDown:s,onFocusOutside:r,onPointerDownOutside:d,onCloseAutoFocus:e=>{e.stopPropagation(),e.preventDefault(),t&&!(0,i.$a)(document.activeElement)&&t.focus(),l()},children:[(0,h.jsx)(eA,{padding:3,style:a,children:n}),(0,h.jsx)(f.i3,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})}),e_=e=>{let t=new Option().style;return t.color=e,!!t.color},eR=e=>(0,i.sb)(e)?e:e_(`#${e}`)?`#${e}`:e_(e)?e:null,eO=({type:e,color:t,onChange:n,label:a,elements:l,palette:s=i.e,updateData:r})=>{let{container:d}=sJ(),[,c]=C(eb),[m,p]=C(eD),u=(0,h.jsxs)("div",{children:[(0,h.jsx)(ek,{children:z("colorPicker.hexCode")}),(0,h.jsx)(eN,{color:t,label:a,onChange:e=>{n(e)},colorPickerType:e})]}),g=(0,o.useRef)(null);return(0,h.jsx)(eP,{container:d,style:{maxWidth:"13rem"},onFocusOutside:e=>{g.current?.querySelector(".color-picker-content")?.focus(),e.preventDefault()},onPointerDownOutside:e=>{m&&e.preventDefault()},onClose:()=>{r({openPopup:null}),c(null)},children:s?(0,h.jsx)(eC,{palette:s,color:t,onChange:e=>{n(e)},onEyeDropperToggle:t=>{p(i=>t?((i=i||{keepOpenOnAlt:!0,onSelect:n,colorPickerType:e}).keepOpenOnAlt=!0,i):!1===t||i?null:{keepOpenOnAlt:!1,onSelect:n,colorPickerType:e})},onEscape:e=>{m?p(null):r({openPopup:null})},label:a,type:e,elements:l,updateData:r,children:u}):u})},eF=({label:e,color:t,type:n})=>(0,h.jsx)(f.l9,{type:"button",className:(0,m.A)("color-picker__button active-color properties-trigger",{"is-transparent":"transparent"===t||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:"elementStroke"===n?z("labels.showStroke"):z("labels.showBackground"),children:(0,h.jsx)("div",{className:"color-picker__button-outline"})}),ez=({type:e,color:t,onChange:n,label:a,elements:l,palette:s=i.e,topPicks:r,updateData:o,appState:d})=>(0,h.jsx)("div",{children:(0,h.jsxs)("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[(0,h.jsx)(em,{activeColor:t,onChange:n,type:e,topPicks:r}),(0,h.jsx)(ep,{}),(0,h.jsxs)(f.bL,{open:d.openPopup===e,onOpenChange:t=>{o({openPopup:t?e:null})},children:[(0,h.jsx)(eF,{color:t,label:a,type:e}),d.openPopup===e&&(0,h.jsx)(eO,{type:e,color:t,onChange:n,label:a,elements:l,palette:s,updateData:o})]})]})}),eU=({icon:e})=>(0,h.jsx)("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e}),eB=({label:e,open:t,openTrigger:n,children:a,className:l})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:l,onClick:n,children:[e,(0,h.jsx)(eU,{icon:t?i.Mf:i.Lf})]}),t&&(0,h.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:a})]}),eW=(0,d.eU)(!1);function eH({options:e,value:t,label:n,onChange:a,onClose:l,numberOfOptionsToAlwaysShow:s=e.length}){let r=sq(),[d,c]=C(eW),p=o.useMemo(()=>e.slice(0,s),[e,s]),u=o.useMemo(()=>e.slice(s),[e,s]);(0,o.useEffect)(()=>{p.some(e=>e.value===t)||c(!0)},[t,p,c]);let g=e=>(0,h.jsx)("div",{className:"picker-content",children:e.map((e,n)=>(0,h.jsxs)("button",{type:"button",className:(0,m.A)("picker-option",{active:t===e.value}),onClick:t=>{a(e.value)},title:`${e.text} ${e.keyBinding&&`\u2014 ${e.keyBinding.toUpperCase()}`}`,"aria-label":e.text||"none","aria-keyshortcuts":e.keyBinding||void 0,ref:n=>{t===e.value&&setTimeout(()=>{n?.focus()},0)},children:[e.icon,e.keyBinding&&(0,h.jsx)("span",{className:"picker-keybinding",children:e.keyBinding})]},e.text))});return(0,h.jsx)(f.UC,{side:r.editor.isMobile&&!r.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:n=>{let r=e.find(e=>e.keyBinding===n.key.toLowerCase());if(!(n.metaKey||n.altKey||n.ctrlKey)&&r)a(r.value),n.preventDefault();else if(n.key===i.hg.TAB){let i=e.findIndex(e=>e.value===t),l=n.shiftKey?(e.length+i-1)%e.length:(i+1)%e.length;a(e[l].value)}else if((0,i.jg)(n.key)){let l=_.rtl,r=e.findIndex(e=>e.value===t);if(-1!==r){let t=e.length,o=r;switch(n.key){case l?i.hg.ARROW_LEFT:i.hg.ARROW_RIGHT:o=(r+1)%t;break;case l?i.hg.ARROW_RIGHT:i.hg.ARROW_LEFT:o=(t+r-1)%t;break;case i.hg.ARROW_DOWN:o=(r+(s??1))%t;break;case i.hg.ARROW_UP:o=(t+r-(s??1))%t}a(e[o].value)}n.preventDefault()}else(n.key===i.hg.ESCAPE||n.key===i.hg.ENTER)&&(n.preventDefault(),l());n.nativeEvent.stopImmediatePropagation(),n.stopPropagation()},children:(0,h.jsxs)("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":n,children:[g(p),u.length>0&&(0,h.jsx)(eB,{label:z("labels.more_options"),open:d,openTrigger:()=>{c(e=>!e)},className:"picker-collapsible",children:g(u)})]})})}function e$({value:e,label:t,options:n,onChange:i,group:a="",numberOfOptionsToAlwaysShow:l}){let[s,r]=o.useState(!1),d=o.useRef(null);return(0,h.jsx)("div",{children:(0,h.jsxs)(f.bL,{open:s,onOpenChange:e=>r(e),children:[(0,h.jsx)(f.l9,{name:a,type:"button","aria-label":t,onClick:()=>r(!s),ref:d,className:s?"active":"",children:n.find(t=>t.value===e)?.icon}),s&&(0,h.jsx)(eH,{options:n,value:e,label:t,onChange:i,onClose:()=>{r(!1)},numberOfOptionsToAlwaysShow:l})]})})}var eY=o.forwardRef(({className:e,placeholder:t,onChange:n},a)=>(0,h.jsxs)("div",{className:(0,m.A)("QuickSearch__wrapper",e),children:[i.pf,(0,h.jsx)("input",{ref:a,className:"QuickSearch__input",type:"text",placeholder:t,onChange:e=>n(e.target.value.trim().toLowerCase())})]})),eG=({className:e,placeholder:t,children:n})=>{let i=!o.Children.count(n);return(0,h.jsx)("div",{className:(0,m.A)("ScrollableList__wrapper",e),role:"menu",children:i?(0,h.jsx)("div",{className:"empty",children:t}):n})},eV=({children:e,className:t="",style:n,title:i})=>(0,h.jsxs)("div",{className:`dropdown-menu-group ${t}`,style:n,children:[i&&(0,h.jsx)("p",{className:"dropdown-menu-group-title",children:i}),e]});eV.displayName="DropdownMenuGroup";var eK=o.createContext({}),eZ=(e="",t=!1,n=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
${t?"dropdown-menu-item--selected":""} ${n?"dropdown-menu-item--hovered":""}`.trim(),eX=(e,t)=>{let n=(0,o.useContext)(eK);return(0,i.Ib)(e,e=>{let i=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});t?.(i),i.defaultPrevented||n.onSelect?.(i)})},eQ=({textStyle:e,icon:t,shortcut:n,children:i})=>{let a=sq();return(0,h.jsxs)(h.Fragment,{children:[t&&(0,h.jsx)("div",{className:"dropdown-menu-item__icon",children:t}),(0,h.jsx)("div",{style:e,className:"dropdown-menu-item__text",children:i}),n&&!a.editor.isMobile&&(0,h.jsx)("div",{className:"dropdown-menu-item__shortcut",children:n})]})},eq=({icon:e,value:t,order:n,children:i,shortcut:a,className:l,hovered:s,selected:r,textStyle:d,onSelect:c,onClick:m,...p})=>{let u=eX(m,c),g=(0,o.useRef)(null);return(0,o.useEffect)(()=>{s&&(0===n?g.current?.scrollIntoView({block:"end"}):g.current?.scrollIntoView({block:"nearest"}))},[s,n]),(0,h.jsx)("button",{...p,ref:g,value:t,onClick:u,className:eZ(l,r,s),title:p.title??p["aria-label"],children:(0,h.jsx)(eQ,{textStyle:d,icon:e,shortcut:a,children:i})})};eq.displayName="DropdownMenuItem";var eJ="blue",e0=({type:e=eJ,children:t})=>{let{theme:n}=s1(),a={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:n===i.G.LIGHT?"1.5px solid white":"none"};switch(e){case"green":Object.assign(a,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case"red":Object.assign(a,{backgroundColor:"pink",color:"darkred"});break;default:Object.assign(a,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return(0,h.jsx)("div",{className:"DropDownMenuItemBadge",style:a,children:t})};e0.displayName="DropdownMenuItemBadge",eq.Badge=e0;var e1=o.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:n,onHover:a,onLeave:l,onOpen:s,onClose:r})=>{let{container:d}=sJ(),{fonts:c}=sX(),{showDeprecatedFonts:m}=sQ(),[p,u]=(0,o.useState)(""),g=(0,o.useRef)(null),f=(0,o.useMemo)(()=>Array.from(i.Qf.registered.entries()).filter(([e,{metadata:t}])=>!t.serverSide&&!t.fallback).map(([e,{metadata:t,fontFaces:n}])=>{let a={value:e,icon:t.icon??i.Oe,text:n[0]?.fontFace?.family??"Unknown"};return t.deprecated&&Object.assign(a,{deprecated:t.deprecated,badge:{type:"red",placeholder:z("fontList.badge.old")}}),a}).sort((e,t)=>e.text.toLowerCase()>t.text.toLowerCase()?1:-1),[]),b=(0,o.useMemo)(()=>new Set(c.getSceneFamilies()),[e]),x=(0,o.useMemo)(()=>f.filter(e=>b.has(e.value)),[f,b]),E=(0,o.useMemo)(()=>f.filter(e=>!b.has(e.value)&&(m||!e.deprecated)),[f,b,m]),y=(0,o.useMemo)(()=>(0,i.zb)([...x,...E].filter(e=>e.text?.toLowerCase().includes(p))),[x,E,p]),v=(0,o.useMemo)(()=>{let n;return t?n=y.find(e=>e.value===t):e&&(n=y.find(t=>t.value===e)),!n&&p&&(y[0]?.value?a(y[0].value):l()),n},[t,e,p,y,a,l]),w=(0,o.useCallback)(e=>{(({event:e,inputRef:t,hoveredFont:n,filteredFonts:a,onClose:l,onSelect:s,onHover:r})=>!e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===i.hg.F?(t.current?.focus(),!0):e.key===i.hg.ESCAPE?(l(),!0):e.key===i.hg.ENTER?(n?.value&&s(n.value),!0):e.key===i.hg.ARROW_DOWN?(n?.next?r(n.next.value):a[0]?.value&&r(a[0].value),!0):e.key===i.hg.ARROW_UP?(n?.prev?r(n.prev.value):a[a.length-1]?.value&&r(a[a.length-1].value),!0):void 0)({event:e,inputRef:g,hoveredFont:v,filteredFonts:y,onSelect:n,onHover:a,onClose:r})&&(e.preventDefault(),e.stopPropagation())},[v,y,n,a,r]);(0,o.useEffect)(()=>(s(),()=>{r()}),[]);let S=(0,o.useMemo)(()=>y.filter(e=>b.has(e.value)),[y,b]),k=(0,o.useMemo)(()=>y.filter(e=>!b.has(e.value)),[y,b]),C=(t,l)=>(0,h.jsxs)(eq,{icon:t.icon,value:t.value,order:l,textStyle:{fontFamily:(0,i.bb)({fontFamily:t.value})},hovered:t.value===v?.value,selected:t.value===e,tabIndex:t.value===e?0:-1,onClick:e=>{n(Number(e.currentTarget.value))},onMouseMove:()=>{v?.value!==t.value&&a(t.value)},children:[t.text,t.badge&&(0,h.jsx)(e0,{type:t.badge.type,children:t.badge.placeholder})]},t.value),j=[];return S.length&&j.push((0,h.jsx)(eV,{title:z("fontList.sceneFonts"),children:S.map(C)},"group_1")),k.length&&j.push((0,h.jsx)(eV,{title:z("fontList.availableFonts"),children:k.map((e,t)=>C(e,t+S.length))},"group_2")),(0,h.jsxs)(eP,{className:"properties-content",container:d,style:{width:"15rem"},onClose:r,onPointerLeave:l,onKeyDown:w,children:[(0,h.jsx)(eY,{ref:g,placeholder:z("quickSearch.placeholder"),onChange:(0,i.db)(u,20)}),(0,h.jsx)(eG,{className:"dropdown-menu fonts manual-hover",placeholder:z("fontList.empty"),children:j.length?j:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),e2=({selectedFontFamily:e})=>{let t=(0,o.useMemo)(()=>!!(e&&!e4(e)),[e]);return(0,h.jsx)(f.l9,{asChild:!0,children:(0,h.jsx)("div",{children:(0,h.jsx)(ec,{standalone:!0,icon:i.qd,title:z("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:t,onClick:()=>{}})})})},e3=[{value:i.F.Excalifont,icon:i.pd,text:z("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:i.F.Nunito,icon:i.Oe,text:z("labels.normal"),testId:"font-family-normal"},{value:i.F["Comic Shanns"],icon:i.Pe,text:z("labels.code"),testId:"font-family-code"}],e5=new Set(e3.map(e=>e.value)),e4=e=>!!e&&e5.has(e),e6=o.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:n,onSelect:i,onHover:a,onLeave:l,onPopupChange:s})=>{let r=(0,o.useMemo)(()=>e3,[]),d=(0,o.useCallback)(e=>{e&&i(e)},[i]);return(0,h.jsxs)("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[(0,h.jsx)(eh,{type:"button",options:r,value:t,onClick:d}),(0,h.jsx)(ep,{}),(0,h.jsxs)(f.bL,{open:e,onOpenChange:s,children:[(0,h.jsx)(e2,{selectedFontFamily:t}),e&&(0,h.jsx)(e1,{selectedFontFamily:t,hoveredFontFamily:n,onSelect:d,onHover:a,onLeave:l,onOpen:()=>s(!0),onClose:()=>s(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),e8=({updateData:e,appState:t,elements:n,testId:i})=>{let a=o.useRef(null),l=o.useRef(null),s=e9(n,t,e=>e.opacity,!0,t.currentItemOpacity);return(0,o.useEffect)(()=>{if(a.current&&l.current){let e=a.current,t=l.current,n=s/100*(e.offsetWidth-15)+7.5;t.style.left=`${n}px`,e.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${s}%, var(--button-bg) ${s}%, var(--button-bg) 100%)`}},[s]),(0,h.jsxs)("label",{className:"control-label",children:[z("labels.opacity"),(0,h.jsxs)("div",{className:"range-wrapper",children:[(0,h.jsx)("input",{ref:a,type:"range",min:"0",max:"100",step:"10",onChange:t=>{e(+t.target.value)},value:s,className:"range-input","data-testid":i}),(0,h.jsx)("div",{className:"value-bubble",ref:l,children:0!==s?s:null}),(0,h.jsx)("div",{className:"zero-label",children:"0"})]})]})},e7=(e,t,n,a=!1)=>{let l=(0,i.xb)((0,i.vk)(e,t,{includeBoundTextElement:a}));return e.map(e=>l.get(e.id)||e.id===t.editingTextElement?.id?n(e):e)},e9=function(e,t,n,a,l){let s=t.editingTextElement,r=(0,i.pk)(e),o=null;return s&&(o=n(s)),o||(o=(0,i.tk)(r,t)?(0,i.uk)(!0===a?r:r.filter(e=>a(e)),t,n)??("function"==typeof l?l(!0):l):"function"==typeof l?l(!1):l),o},te=(e,t,n,a,l)=>{let s=new Set,r=e7(e,t,e=>{if((0,i._b)(e)){let t,l=a(e);s.add(l);let r=(0,i.Qj)(e,{fontSize:l});return(0,i.uj)(r,n.scene.getContainerElement(e),n.scene.getNonDeletedElementsMap()),t=r,r=(0,i.nc)(t)||!t.autoResize?t:(0,i.Pj)(t,{x:"left"===e.textAlign?e.x:e.x+(e.width-t.width)/("center"===e.textAlign?2:1),y:e.y+(e.height-t.height)/2},!1)}return e},!0),o=(0,i.xb)(r);return(0,i.vk)(e,t,{includeBoundTextElement:!0}).forEach(e=>{(0,i._b)(e)&&(0,i.Pg)(e,o)}),{elements:r,appState:{...t,currentItemFontSize:1===s.size?[...s][0]:l??t.currentItemFontSize},captureUpdate:i.Wg.IMMEDIATELY}},tt=((0,i.$c)({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,n)=>({...n.currentItemStrokeColor&&{elements:e7(e,t,e=>(0,i.Wi)(e.type)?(0,i.Qj)(e,{strokeColor:n.currentItemStrokeColor}):e,!0)},appState:{...t,...n},captureUpdate:n.currentItemStrokeColor?i.Wg.IMMEDIATELY:i.Wg.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:a})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("h3",{"aria-hidden":"true",children:z("labels.stroke")}),(0,h.jsx)(ez,{topPicks:i.f,palette:i.i,type:"elementStroke",label:z("labels.stroke"),color:e9(e,t,e=>e.strokeColor,!0,t.currentItemStrokeColor),onChange:e=>n({currentItemStrokeColor:e}),elements:e,appState:t,updateData:n})]})}),(0,i.$c)({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,n)=>({...n.currentItemBackgroundColor&&{elements:e7(e,t,e=>(0,i.Qj)(e,{backgroundColor:n.currentItemBackgroundColor}))},appState:{...t,...n},captureUpdate:n.currentItemBackgroundColor?i.Wg.IMMEDIATELY:i.Wg.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:a})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("h3",{"aria-hidden":"true",children:z("labels.background")}),(0,h.jsx)(ez,{topPicks:i.g,palette:i.j,type:"elementBackground",label:z("labels.background"),color:e9(e,t,e=>e.backgroundColor,!0,t.currentItemBackgroundColor),onChange:e=>n({currentItemBackgroundColor:e}),elements:e,appState:t,updateData:n})]})}),(0,i.$c)({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,n,a)=>(ed("element","changeFillStyle",`${n} (${a.device.editor.isMobile?"mobile":"desktop"})`),{elements:e7(e,t,e=>(0,i.Qj)(e,{fillStyle:n})),appState:{...t,currentItemFillStyle:n},captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let a=(0,i.vk)(e,t),l=a.length>0&&a.every(e=>"zigzag"===e.fillStyle);return(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.fill")}),(0,h.jsx)(eh,{type:"button",options:[{value:"hachure",text:`${l?z("labels.zigzag"):z("labels.hachure")} (${(0,i.kb)("Alt-Click")})`,icon:l?i.je:i.ke,active:!!l||void 0,testId:"fill-hachure"},{value:"cross-hatch",text:z("labels.crossHatch"),icon:i.le,testId:"fill-cross-hatch"},{value:"solid",text:z("labels.solid"),icon:i.me,testId:"fill-solid"}],value:e9(e,t,e=>e.fillStyle,e=>e.hasOwnProperty("fillStyle"),e=>e?null:t.currentItemFillStyle),onClick:(e,t)=>{n(t.altKey&&"hachure"===e&&a.every(e=>"hachure"===e.fillStyle)?"zigzag":e)}})]})}}),(0,i.$c)({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,n)=>({elements:e7(e,t,e=>(0,i.Qj)(e,{strokeWidth:n})),appState:{...t,currentItemStrokeWidth:n},captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.strokeWidth")}),(0,h.jsx)(eh,{group:"stroke-width",options:[{value:i.va.thin,text:z("labels.thin"),icon:i.ne,testId:"strokeWidth-thin"},{value:i.va.bold,text:z("labels.bold"),icon:i.oe,testId:"strokeWidth-bold"},{value:i.va.extraBold,text:z("labels.extraBold"),icon:i.pe,testId:"strokeWidth-extraBold"}],value:e9(e,t,e=>e.strokeWidth,e=>e.hasOwnProperty("strokeWidth"),e=>e?null:t.currentItemStrokeWidth),onChange:e=>n(e)})]})}),(0,i.$c)({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,n)=>({elements:e7(e,t,e=>(0,i.Qj)(e,{seed:(0,i.rc)(),roughness:n})),appState:{...t,currentItemRoughness:n},captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.sloppiness")}),(0,h.jsx)(eh,{group:"sloppiness",options:[{value:0,text:z("labels.architect"),icon:i.se},{value:1,text:z("labels.artist"),icon:i.te},{value:2,text:z("labels.cartoonist"),icon:i.ue}],value:e9(e,t,e=>e.roughness,e=>e.hasOwnProperty("roughness"),e=>e?null:t.currentItemRoughness),onChange:e=>n(e)})]})}),(0,i.$c)({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,n)=>({elements:e7(e,t,e=>(0,i.Qj)(e,{strokeStyle:n})),appState:{...t,currentItemStrokeStyle:n},captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.strokeStyle")}),(0,h.jsx)(eh,{group:"strokeStyle",options:[{value:"solid",text:z("labels.strokeStyle_solid"),icon:i.ne},{value:"dashed",text:z("labels.strokeStyle_dashed"),icon:i.qe},{value:"dotted",text:z("labels.strokeStyle_dotted"),icon:i.re}],value:e9(e,t,e=>e.strokeStyle,e=>e.hasOwnProperty("strokeStyle"),e=>e?null:t.currentItemStrokeStyle),onChange:e=>n(e)})]})}),(0,i.$c)({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,n)=>({elements:e7(e,t,e=>(0,i.Qj)(e,{opacity:n}),!0),appState:{...t,currentItemOpacity:n},captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,h.jsx)(e8,{updateData:n,elements:e,appState:t,testId:"opacity"})}),(0,i.$c)({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,n,i)=>te(e,t,i,()=>n,n),PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.fontSize")}),(0,h.jsx)(eh,{group:"font-size",options:[{value:16,text:z("labels.small"),icon:i.Je,testId:"fontSize-small"},{value:20,text:z("labels.medium"),icon:i.Ke,testId:"fontSize-medium"},{value:28,text:z("labels.large"),icon:i.Le,testId:"fontSize-large"},{value:36,text:z("labels.veryLarge"),icon:i.Me,testId:"fontSize-veryLarge"}],value:e9(e,t,e=>{if((0,i._b)(e))return e.fontSize;let t=(0,i.zj)(e,a.scene.getNonDeletedElementsMap());return t?t.fontSize:null},e=>(0,i._b)(e)||null!==(0,i.zj)(e,a.scene.getNonDeletedElementsMap()),e=>e?null:t.currentItemFontSize||i.I),onChange:e=>n(e)})]})}),(0,i.$c)({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:i.Ne,trackEvent:!1,perform:(e,t,n,i)=>te(e,t,i,e=>Math.round(1/1.1*e.fontSize)),keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&(e.key===i.hg.CHEVRON_LEFT||e.key===i.hg.COMMA)})),tn=(0,i.$c)({name:"increaseFontSize",label:"labels.increaseFontSize",icon:i.Ne,trackEvent:!1,perform:(e,t,n,i)=>te(e,t,i,e=>Math.round(1.1*e.fontSize)),keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&(e.key===i.hg.CHEVRON_RIGHT||e.key===i.hg.PERIOD)}),ti=((0,i.$c)({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,n,a)=>{let{cachedElements:l,resetAll:s,resetContainers:r,...o}=n;if(s)return{elements:e7(e,t,e=>{let t=l?.get(e.id);return t?(0,i.Qj)(e,{...t}):e},!0),appState:{...t,...o},captureUpdate:i.Wg.NEVER};let{currentItemFontFamily:d,currentHoveredFontFamily:c}=n,h=i.Wg.EVENTUALLY,m,p=!1;if(d)m=d,h=i.Wg.IMMEDIATELY;else if(c){m=c,h=i.Wg.EVENTUALLY;let n=(0,i.vk)(e,t,{includeBoundTextElement:!0}).filter(e=>(0,i._b)(e));if(n.length>200)p=!0;else{let e=0,t=0;for(;e<n.length&&t<5e3;){let i=n[e];t+=i?.originalText.length||0,e++}t>5e3&&(p=!0)}}let u={appState:{...t,...o},captureUpdate:h};if(m&&!p){let n=new Map,s=new Set,o=!1,h=Array.from(i.Qf.loadedFontsCache.values()),p=Object.entries(i.F).find(([e,t])=>t===m)?.[0];c&&p&&h.some(e=>e.startsWith(p))&&(o=!0),Object.assign(u,{elements:e7(e,t,e=>{if((0,i._b)(e)&&(e.fontFamily!==m||d)){let t=(0,i.Qj)(e,{fontFamily:m,lineHeight:(0,i.Rf)(m)}),d=l?.get(e.containerId||"")||{},c=a.scene.getContainerElement(e);return r&&c&&d&&(0,i.Pj)(c,{...d},!1),o||(s=new Set([...s,...Array.from(t.originalText)])),n.set(t,c),t}return e},!0)});let g=`10px ${(0,i.bb)({fontFamily:m})}`,f=Array.from(s.values()).join();if(o||window.document.fonts.check(g,f))for(let[e,t]of n)(0,i.uj)(e,t,a.scene.getNonDeletedElementsMap(),!1);else window.document.fonts.load(g,f).then(e=>{for(let[e,t]of n){let n=a.scene.getElement(e.id),l=t?a.scene.getElement(t.id):null;n&&(0,i.uj)(n,l,a.scene.getNonDeletedElementsMap(),!1)}a.fonts.onLoaded(e)})}return u},PanelComponent:({elements:e,appState:t,app:n,updateData:a})=>{let l=(0,o.useRef)(new Map),s=(0,o.useRef)(null),[r,d]=(0,o.useState)({}),c=(0,o.useRef)(!0),m=(0,o.useMemo)(()=>{let a=(e,n)=>e9(e,t,e=>{if((0,i._b)(e))return e.fontFamily;let t=(0,i.zj)(e,n);return t?t.fontFamily:null},e=>(0,i._b)(e)||null!==(0,i.zj)(e,n),e=>e?null:t.currentItemFontFamily||i.J);return"fontFamily"===r.openPopup&&"fontFamily"===t.openPopup?a(Array.from(l.current?.values()??[]),l.current):r.openPopup||"fontFamily"===t.openPopup?s.current:a(e,n.scene.getNonDeletedElementsMap())},[r.openPopup,t,e,n.scene]);return(0,o.useEffect)(()=>{s.current=m},[m]),(0,o.useEffect)(()=>{Object.keys(r).length&&(a(r),d({}))},[r]),(0,o.useEffect)(()=>(c.current=!1,()=>{c.current=!0}),[]),(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.fontFamily")}),(0,h.jsx)(e6,{isOpened:"fontFamily"===t.openPopup,selectedFontFamily:m,hoveredFontFamily:t.currentHoveredFontFamily,onSelect:e=>{d({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:e}),l.current.clear()},onHover:e=>{d({currentHoveredFontFamily:e,cachedElements:new Map(l.current),resetContainers:!0})},onLeave:()=>{d({currentHoveredFontFamily:null,cachedElements:new Map(l.current),resetAll:!0})},onPopupChange:s=>{if(s){l.current.clear();let{editingTextElement:a}=t;if(a?.type==="text"){let e=n.scene.getElement(a.id);l.current.set(a.id,(0,i.Qj)(e||a,{},!0))}else for(let n of(0,i.vk)(e,t,{includeBoundTextElement:!0}))l.current.set(n.id,(0,i.Qj)(n,{},!0));d({openPopup:"fontFamily"})}else{let e={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(l.current),resetAll:!0};c.current?a({...r,...e}):d(e),l.current.clear()}}})]})}}),(0,i.$c)({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,n,a)=>({elements:e7(e,t,e=>{if((0,i._b)(e)){let t=(0,i.Qj)(e,{textAlign:n});return(0,i.uj)(t,a.scene.getContainerElement(e),a.scene.getNonDeletedElementsMap()),t}return e},!0),appState:{...t,currentItemTextAlign:n},captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>{let l=a.scene.getNonDeletedElementsMap();return(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.textAlign")}),(0,h.jsx)(eh,{group:"text-align",options:[{value:"left",text:z("labels.left"),icon:i.Qe,testId:"align-left"},{value:"center",text:z("labels.center"),icon:i.Re,testId:"align-horizontal-center"},{value:"right",text:z("labels.right"),icon:i.Se,testId:"align-right"}],value:e9(e,t,e=>{if((0,i._b)(e))return e.textAlign;let t=(0,i.zj)(e,l);return t?t.textAlign:null},e=>(0,i._b)(e)||null!==(0,i.zj)(e,l),e=>e?null:t.currentItemTextAlign),onChange:e=>n(e)})]})}}),(0,i.$c)({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,n,a)=>({elements:e7(e,t,e=>{if((0,i._b)(e)){let t=(0,i.Qj)(e,{verticalAlign:n});return(0,i.uj)(t,a.scene.getContainerElement(e),a.scene.getNonDeletedElementsMap()),t}return e},!0),appState:{...t},captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)("fieldset",{children:(0,h.jsx)(eh,{group:"text-align",options:[{value:i.sa.TOP,text:z("labels.alignTop"),icon:(0,h.jsx)(i.Te,{theme:t.theme}),testId:"align-top"},{value:i.sa.MIDDLE,text:z("labels.centerVertically"),icon:(0,h.jsx)(i.Ve,{theme:t.theme}),testId:"align-middle"},{value:i.sa.BOTTOM,text:z("labels.alignBottom"),icon:(0,h.jsx)(i.Ue,{theme:t.theme}),testId:"align-bottom"}],value:e9(e,t,e=>{if((0,i._b)(e)&&e.containerId)return e.verticalAlign;let t=(0,i.zj)(e,a.scene.getNonDeletedElementsMap());return t?t.verticalAlign:null},e=>(0,i._b)(e)||null!==(0,i.zj)(e,a.scene.getNonDeletedElementsMap()),e=>e?null:i.sa.MIDDLE),onChange:e=>n(e)})})}),(0,i.$c)({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,n)=>({elements:e7(e,t,e=>(0,i.ec)(e)?e:(0,i.Qj)(e,{roundness:"round"===n?{type:(0,i.oc)(e.type)?i.ua.ADAPTIVE_RADIUS:i.ua.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:n},captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let a=(0,i.wk)((0,i.pk)(e),t).some(e=>e.roundness?.type===i.ua.LEGACY);return(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.edges")}),(0,h.jsx)(eh,{group:"edges",options:[{value:"sharp",text:z("labels.sharp"),icon:i.ve},{value:"round",text:z("labels.round"),icon:i.we}],value:e9(e,t,e=>a?null:e.roundness?"round":"sharp",e=>!(0,i.dc)(e)&&e.hasOwnProperty("roundness"),e=>e?null:t.currentItemRoundness),onChange:e=>n(e)})]})}}),e=>[{value:null,text:z("labels.arrowhead_none"),keyBinding:"q",icon:i.xe},{value:"arrow",text:z("labels.arrowhead_arrow"),keyBinding:"w",icon:(0,h.jsx)(i.ye,{flip:e})},{value:"triangle",text:z("labels.arrowhead_triangle"),icon:(0,h.jsx)(i.Ce,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:z("labels.arrowhead_triangle_outline"),icon:(0,h.jsx)(i.De,{flip:e}),keyBinding:"r"},{value:"circle",text:z("labels.arrowhead_circle"),keyBinding:"a",icon:(0,h.jsx)(i.ze,{flip:e})},{value:"circle_outline",text:z("labels.arrowhead_circle_outline"),keyBinding:"s",icon:(0,h.jsx)(i.Ae,{flip:e})},{value:"diamond",text:z("labels.arrowhead_diamond"),icon:(0,h.jsx)(i.Ee,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:z("labels.arrowhead_diamond_outline"),icon:(0,h.jsx)(i.Fe,{flip:e}),keyBinding:"f"},{value:"bar",text:z("labels.arrowhead_bar"),keyBinding:"z",icon:(0,h.jsx)(i.Be,{flip:e})},{value:"crowfoot_one",text:z("labels.arrowhead_crowfoot_one"),icon:(0,h.jsx)(i.He,{flip:e}),keyBinding:"c"},{value:"crowfoot_many",text:z("labels.arrowhead_crowfoot_many"),icon:(0,h.jsx)(i.Ge,{flip:e}),keyBinding:"x"},{value:"crowfoot_one_or_many",text:z("labels.arrowhead_crowfoot_one_or_many"),icon:(0,h.jsx)(i.Ie,{flip:e}),keyBinding:"v"}]);(0,i.$c)({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,n)=>({elements:e7(e,t,e=>{if((0,i.cc)(e)){let{position:t,type:a}=n;if("start"===t)return(0,i.Qj)(e,{startArrowhead:a});if("end"===t)return(0,i.Qj)(e,{endArrowhead:a})}return e}),appState:{...t,["start"===n.position?"currentItemStartArrowhead":"currentItemEndArrowhead"]:n.type},captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let a=_.rtl;return(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.arrowheads")}),(0,h.jsxs)("div",{className:"iconSelectList buttonList",children:[(0,h.jsx)(e$,{label:"arrowhead_start",options:ti(!a),value:e9(e,t,e=>(0,i.cc)(e)&&(0,i.$i)(e.type)?e.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:e=>n({position:"start",type:e}),numberOfOptionsToAlwaysShow:4}),(0,h.jsx)(e$,{label:"arrowhead_end",group:"arrowheads",options:ti(!!a),value:e9(e,t,e=>(0,i.cc)(e)&&(0,i.$i)(e.type)?e.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:e=>n({position:"end",type:e}),numberOfOptionsToAlwaysShow:4})]})]})}}),(0,i.$c)({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,t,n,a)=>{let l=e7(e,t,l=>{if(!(0,i.dc)(l))return l;let s=(0,i.Qj)(l,{roundness:n===i.Fa.round?{type:i.ua.PROPORTIONAL_RADIUS}:null,elbowed:n===i.Fa.elbow,points:n===i.Fa.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if((0,i.ec)(s)){let n=a.scene.getNonDeletedElementsMap();a.dismissLinearEditor();let l=i.pj.getPointAtIndexGlobalCoordinates(s,0,n),r=i.pj.getPointAtIndexGlobalCoordinates(s,-1,n),o=!s.startBinding&&(0,i.Og)((0,i.ob)(l),e,n,t.zoom,!1,!0),d=!s.endBinding&&(0,i.Og)((0,i.ob)(r),e,n,t.zoom,!1,!0),c=o||s.startBinding&&n.get(s.startBinding.elementId),h=d||s.endBinding&&n.get(s.endBinding.elementId),m=o?(0,i.Qg)(s,o,"start"):l,p=d?(0,i.Qg)(s,d,"end"):r;o&&(0,i.Mg)(s,o,"start",n),d&&(0,i.Mg)(s,d,"end",n),(0,i.Pj)(s,{points:[m,p].map(e=>(0,i.Ua)(e[0]-s.x,e[1]-s.y)),...c&&s.startBinding?{startBinding:{...s.startBinding,...(0,i.Rg)(s,c,"start",n)}}:{},...h&&s.endBinding?{endBinding:{...s.endBinding,...(0,i.Rg)(s,h,"end",n)}}:{}}),i.pj.updateEditorMidPointsCache(s,n,a.state)}return s}),s={...t,currentItemArrowType:n},r=t.selectedLinearElement?.elementId;if(r){let e=l.find(e=>e.id===r);e&&(s.selectedLinearElement=new i.pj(e))}return{elements:l,appState:s,captureUpdate:i.Wg.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n})=>(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.arrowtypes")}),(0,h.jsx)(eh,{group:"arrowtypes",options:[{value:i.Fa.sharp,text:z("labels.arrowtype_sharp"),icon:i.If,testId:"sharp-arrow"},{value:i.Fa.round,text:z("labels.arrowtype_round"),icon:i.Kf,testId:"round-arrow"},{value:i.Fa.elbow,text:z("labels.arrowtype_elbowed"),icon:i.Jf,testId:"elbow-arrow"}],value:e9(e,t,e=>(0,i.dc)(e)?e.elbowed?i.Fa.elbow:e.roundness?i.Fa.round:i.Fa.sharp:null,e=>(0,i.dc)(e),e=>e?null:t.currentItemArrowType),onChange:e=>n(e)})]})});var ta=({viewportX:e,viewportY:t,nextZoom:n},i)=>{let a=e-i.offsetLeft,l=t-i.offsetTop,s=i.zoom.value;return{scrollX:i.scrollX+(a-a/s)+-(a-a/n),scrollY:i.scrollY+(l-l/s)+-(l-l/n),zoom:{value:n}}},tl=()=>{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},ts=(e,t,n="bottom")=>{let i,a=e.getBoundingClientRect(),l=window.innerWidth,s=window.innerHeight,r=t.left+t.width/2-a.width/2;r<0?r=5:r+a.width>=l&&(r=l-a.width-5),"bottom"===n?(i=t.top+t.height+5)+a.height>=s&&(i=t.top-a.height-5):(i=t.top-a.height-5)<0&&(i=t.top+t.height+5),Object.assign(e.style,{top:`${i}px`,left:`${r}px`})},tr=({children:e,label:t,long:n=!1,style:i,disabled:a})=>((0,o.useEffect)(()=>()=>tl().classList.remove("excalidraw-tooltip--visible"),[]),a?null:(0,h.jsx)("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:e=>{var i,a;return i=e.currentTarget,a=tl(),void(a.classList.add("excalidraw-tooltip--visible"),a.style.minWidth=n?"50ch":"10ch",a.style.maxWidth=n?"50ch":"15ch",a.textContent=t,ts(a,i.getBoundingClientRect()))},onPointerLeave:()=>tl().classList.remove("excalidraw-tooltip--visible"),style:i,children:e}));(0,i.$c)({name:"changeViewBackgroundColor",label:"labels.canvasBackground",paletteName:"Change canvas background color",trackEvent:!1,predicate:(e,t,n,i)=>!!i.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,n)=>({appState:{...t,...n},captureUpdate:n.viewBackgroundColor?i.Wg.IMMEDIATELY:i.Wg.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:a})=>(0,h.jsx)(ez,{palette:null,topPicks:i.h,label:z("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:e=>n({viewBackgroundColor:e}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:n})});var to=(0,i.$c)({name:"clearCanvas",label:"labels.clearCanvas",paletteName:"Clear canvas",icon:i.ud,trackEvent:{category:"canvas"},predicate:(e,t,n,i)=>!!i.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector",perform:(e,t,n,a)=>(a.imageCache.clear(),{elements:e.map(e=>(0,i.Qj)(e,{isDeleted:!0})),appState:{...(0,i.Fc)(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,gridStep:t.gridStep,gridModeEnabled:t.gridModeEnabled,stats:t.stats,pasteDialog:t.pasteDialog,activeTool:"image"===t.activeTool.type?{...t.activeTool,type:"selection"}:t.activeTool},captureUpdate:i.Wg.IMMEDIATELY})}),td=(0,i.$c)({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:i.rd,trackEvent:{category:"canvas"},perform:(e,t,n,a)=>({appState:{...t,...ta({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:(0,i.Ak)(t.zoom.value+i.$)},t),userToFollow:null},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>(0,h.jsx)(Y,{type:"button",className:"zoom-in-button zoom-button",icon:i.rd,title:`${z("buttons.zoomIn")} \u2014 ${(0,i.kb)("CtrlOrCmd++")}`,"aria-label":z("buttons.zoomIn"),disabled:t.zoom.value>=i.ba,onClick:()=>{e(null)}}),keyTest:e=>(e.code===i.gg.EQUAL||e.code===i.gg.NUM_ADD)&&(e[i.hg.CTRL_OR_CMD]||e.shiftKey)}),tc=(0,i.$c)({name:"zoomOut",label:"buttons.zoomOut",icon:i.sd,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,n,a)=>({appState:{...t,...ta({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:(0,i.Ak)(t.zoom.value-i.$)},t),userToFollow:null},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>(0,h.jsx)(Y,{type:"button",className:"zoom-out-button zoom-button",icon:i.sd,title:`${z("buttons.zoomOut")} \u2014 ${(0,i.kb)("CtrlOrCmd+-")}`,"aria-label":z("buttons.zoomOut"),disabled:t.zoom.value<=i.aa,onClick:()=>{e(null)}}),keyTest:e=>(e.code===i.gg.MINUS||e.code===i.gg.NUM_SUBTRACT)&&(e[i.hg.CTRL_OR_CMD]||e.shiftKey)}),th=(0,i.$c)({name:"resetZoom",label:"buttons.resetZoom",icon:i.td,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,n,a)=>({appState:{...t,...ta({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:(0,i.Ak)(1)},t),userToFollow:null},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>(0,h.jsx)(tr,{label:z("buttons.resetZoom"),style:{height:"100%"},children:(0,h.jsxs)(Y,{type:"button",className:"reset-zoom-button zoom-button",title:z("buttons.resetZoom"),"aria-label":z("buttons.resetZoom"),onClick:()=>{e(null)},children:[(100*t.zoom.value).toFixed(0),"%"]})}),keyTest:e=>(e.code===i.gg.ZERO||e.code===i.gg.NUM_ZERO)&&(e[i.hg.CTRL_OR_CMD]||e.shiftKey)}),tm=({canvasOffsets:e,targetElements:t,appState:n,fitToViewport:a,viewportZoomFactor:l,minZoom:s,maxZoom:r})=>(({bounds:e,appState:t,canvasOffsets:n,fitToViewport:a=!1,viewportZoomFactor:l=1,minZoom:s=-1/0,maxZoom:r=1/0})=>{l=(0,i.Ia)(l,i.aa,i.ba);let[o,d,c,h]=e,m=n?.left??0,p=n?.top??0,u=n?.right??0,g=n?.bottom??0,f=t.width-m-u,b=t.height-p-g,x;x=a?Math.min(f/(c-o),b/(h-d))*l:((e,t,n=1)=>{let[a,l,s,r]=e;return Math.min(Math.min(t.width/(s-a),t.height/(r-l))*(0,i.Ia)(n,.1,1),1)})(e,{width:f,height:b},l);let E=(0,i.Ak)((0,i.Ia)((0,i.Ka)(x,i.$,"floor"),s,r)),y=(0,i.yk)({scenePoint:{x:(o+c)/2,y:(d+h)/2},viewportDimensions:{width:t.width,height:t.height},offsets:n,zoom:{value:E}});return{appState:{...t,scrollX:y.scrollX,scrollY:y.scrollY,zoom:{value:E}},captureUpdate:i.Wg.EVENTUALLY}})({canvasOffsets:e,bounds:(0,i.bj)((0,i.pk)(t)),appState:n,fitToViewport:a,viewportZoomFactor:l,minZoom:s,maxZoom:r}),tp=((0,i.$c)({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:i.zf,trackEvent:{category:"canvas"},perform:(e,t,n,i)=>{let a=i.scene.getSelectedElements(t);return tm({targetElements:a.length?a:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:i.getEditorUIOffsets()})},keyTest:e=>e.code===i.gg.TWO&&e.shiftKey&&!e.altKey&&!e[i.hg.CTRL_OR_CMD]}),(0,i.$c)({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:i.zf,trackEvent:{category:"canvas"},perform:(e,t,n,i)=>{let a=i.scene.getSelectedElements(t);return tm({targetElements:a.length?a:e,appState:{...t,userToFollow:null},fitToViewport:!0,canvasOffsets:i.getEditorUIOffsets()})},keyTest:e=>e.code===i.gg.THREE&&e.shiftKey&&!e.altKey&&!e[i.hg.CTRL_OR_CMD]}),(0,i.$c)({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:i.zf,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,n,i)=>tm({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:i.getEditorUIOffsets()}),keyTest:e=>e.code===i.gg.ONE&&e.shiftKey&&!e.altKey&&!e[i.hg.CTRL_OR_CMD]}),(0,i.$c)({name:"toggleTheme",label:(e,t)=>t.theme===i.G.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===i.G.LIGHT?i.xd:i.yd,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,n)=>({appState:{...t,theme:n||(t.theme===i.G.LIGHT?i.G.DARK:i.G.LIGHT)},captureUpdate:i.Wg.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===i.gg.D,predicate:(e,t,n,i)=>!!i.props.UIOptions.canvasActions.toggleTheme})),tu=((0,i.$c)({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t)=>{let n;return n=(0,i.Gc)(t)?(0,i.jb)(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(0,i.jb)(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:i.Wg.IMMEDIATELY}},keyTest:e=>e.key===i.hg.E}),(0,i.$c)({name:"toggleHandTool",label:"toolBar.hand",paletteName:"Toggle hand tool",trackEvent:{category:"toolbar"},icon:i.Ye,viewMode:!1,perform:(e,t,n,a)=>{let l;return(0,i.Hc)(t)?l=(0,i.jb)(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(l=(0,i.jb)(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),(0,i.bd)(a.interactiveCanvas,i.z.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:l},captureUpdate:i.Wg.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.H})),tg=(0,i.$c)({name:"finalize",label:"",trackEvent:!1,perform:(e,t,n,a)=>{let l,{interactiveCanvas:s,focusContainer:r,scene:o}=a,d=o.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:n,startBindingElement:a,endBindingElement:l}=t.editingLinearElement,s=i.pj.getElement(n,d);if(s)return(0,i.gc)(s)&&(0,i.Ig)(s,a,l,d,o),{elements:s.points.length<2||(0,i.Sj)(s)?e.filter(e=>e.id!==s.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null},captureUpdate:i.Wg.IMMEDIATELY}}let c=e,h=t.pendingImageElementId&&o.getElement(t.pendingImageElementId);h&&(0,i.Pj)(h,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&r();let m=t.multiElement?t.multiElement:t.newElement?.type==="freedraw"?t.newElement:null;if(m){if("freedraw"!==m.type&&"touch"!==t.lastPointerDownWith){let{points:e,lastCommittedPoint:t}=m;t&&e[e.length-1]===t||(0,i.Pj)(m,{points:m.points.slice(0,-1)})}(0,i.Sj)(m)&&(c=c.filter(e=>e.id!==m.id));let n=(0,i.xg)(m.points,t.zoom.value);if(("line"===m.type||"freedraw"===m.type)&&n){let e=m.points,t=e[0];(0,i.Pj)(m,{points:e.map((n,a)=>a===e.length-1?(0,i.Ua)(t[0],t[1]):n)})}if((0,i.gc)(m)&&!n&&m.points.length>1){let[n,a]=i.pj.getPointAtIndexGlobalCoordinates(m,-1,(0,i.xb)(e));(0,i.Lg)(m,t,{x:n,y:a},d,e)}}return(t.activeTool.locked||"freedraw"===t.activeTool.type)&&m||(0,i.ad)(s),l="eraser"===t.activeTool.type?(0,i.jb)(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(0,i.jb)(t,{type:"selection"}),{elements:c,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||"freedraw"===t.activeTool.type)&&m?t.activeTool:l,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:m&&!t.activeTool.locked&&"freedraw"!==t.activeTool.type?{...t.selectedElementIds,[m.id]:!0}:t.selectedElementIds,selectedLinearElement:m&&(0,i.cc)(m)?new i.pj(m):t.selectedLinearElement,pendingImageElementId:null},captureUpdate:i.Wg.IMMEDIATELY}},keyTest:(e,t)=>e.key===i.hg.ESCAPE&&(null!==t.editingLinearElement||!t.newElement&&null===t.multiElement)||(e.key===i.hg.ESCAPE||e.key===i.hg.ENTER)&&null!==t.multiElement,PanelComponent:({appState:e,updateData:t,data:n})=>(0,h.jsx)(Y,{type:"button",icon:i.Qd,title:z("buttons.done"),"aria-label":z("buttons.done"),onClick:t,visible:null!=e.multiElement,size:n?.size||"medium",style:{pointerEvents:"all"}})}),tf=e=>{let{id:t}=sJ(),[n,a]=(0,o.useState)(e.value);return(0,h.jsxs)("div",{className:"ProjectName",children:[(0,h.jsx)("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),(0,h.jsx)("input",{type:"text",className:"TextInput",onBlur:t=>{e.ignoreFocus||(0,i.vb)(t.target);let n=t.target.value;n!==e.value&&e.onChange(n)},onKeyDown:e=>{e.key===i.hg.ENTER&&(e.preventDefault(),e.nativeEvent.isComposing||229===e.keyCode||e.currentTarget.blur())},id:`${t}-filename`,value:n,onChange:e=>a(e.target.value)})]})},tb=e=>{let t=e.title||(e.value===i.G.DARK?z("buttons.lightMode"):z("buttons.darkMode"));return(0,h.jsx)(Y,{type:"icon",icon:e.value===i.G.LIGHT?tx.MOON:tx.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===i.G.DARK?i.G.LIGHT:i.G.DARK),"data-testid":"toggle-dark-mode"})},tx={SUN:(0,h.jsx)("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:(0,h.jsx)("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:(0,h.jsx)("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:(0,h.jsx)("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"})})},tE=(e,{selectedElementIds:t},n)=>{e=(0,i.pk)(e);let a=n&&(0,i.tk)(e,{selectedElementIds:t}),l=null,s=a?(0,i.vk)(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return a&&(1===s.length&&(0,i.bc)(s[0])?(l=s[0],s=(0,i.Pi)(e,l)):s.length>1&&(s=(0,i.vk)(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:l,exportedElements:(0,i.Nb)(s)}},ty=async(e,t,a,l,{exportBackground:s,exportPadding:r=i.ma,viewBackgroundColor:o,name:d=a.name||i.Ca,fileHandle:c=null,exportingFrame:h=null})=>{if(0===t.length)throw Error(z("alerts.cannotExportEmptyCanvas"));if("svg"===e||"clipboard-svg"===e){let n=(0,i.ei)(t,{exportBackground:s,exportWithDarkMode:a.exportWithDarkMode,viewBackgroundColor:o,exportPadding:r,exportScale:a.exportScale,exportEmbedScene:a.exportEmbedScene&&"svg"===e},l,{exportingFrame:h});if("svg"===e)return(0,i.gh)(n.then(e=>new Blob([e.outerHTML],{type:i.T.svg})),{description:"Export to SVG",name:d,extension:a.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[i.S.svg],fileHandle:c});if("clipboard-svg"===e){let e=await n.then(e=>e.outerHTML);try{await (0,i.oi)(e)}catch{throw Error(z("errors.copyToSystemClipboardFailed"))}return}}let m=(0,i.di)(t,a,l,{exportBackground:s,viewBackgroundColor:o,exportPadding:r,exportingFrame:h});if("png"===e){let e=(0,i.yh)(m);return a.exportEmbedScene&&(e=e.then(e=>n.e(7429).then(n.bind(n,7429)).then(({encodePngMetadata:n})=>n({blob:e,metadata:(0,i.Jh)(t,a,l,"local")})))),(0,i.gh)(e,{description:"Export to PNG",name:d,extension:a.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[i.S.png],fileHandle:c})}if("clipboard"===e)try{let e=(0,i.yh)(m);await (0,i.ni)(e)}catch(e){throw console.warn(e),"CANVAS_POSSIBLY_TOO_BIG"===e.name?Error(z("canvasError.canvasTooBig")):i.n&&"TypeError"===e.name?Error(`${z("alerts.couldNotCopyToClipboard")}
${z("hints.firefox_clipboard_write")}`):Error(z("alerts.couldNotCopyToClipboard"))}else throw Error("Unsupported export type")},tv=async(e,t,n,a)=>{let{exportBackground:l,viewBackgroundColor:s,fileHandle:r}=t,o=(0,i.qh)(r);if(!r||!(0,i.rh)(o))throw Error("fileHandle should exist and should be of type svg or png when resaving");let{exportedElements:d,exportingFrame:c}=tE(e,t={...t,exportEmbedScene:!0},!1);return await ty(o,d,t,n,{exportBackground:l,viewBackgroundColor:s,name:a,fileHandle:r,exportingFrame:c}),{fileHandle:r}},tw=({children:e,checked:t,onChange:n,className:a})=>(0,h.jsxs)("div",{className:(0,m.A)("Checkbox",a,{"is-checked":t}),onClick:e=>{n(!t,e),e.currentTarget.querySelector(".Checkbox-box").focus()},children:[(0,h.jsx)("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":t,children:i.Hd}),(0,h.jsx)("div",{className:"Checkbox-label",children:e})]}),tS=(0,i.$c)({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,n)=>({appState:{...t,name:n},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:n,data:i,app:a})=>(0,h.jsx)(tf,{label:z("labels.fileTitle"),value:a.getName(),onChange:e=>t(e),ignoreFocus:i?.ignoreFocus??!1})}),tk=(0,i.$c)({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,n)=>({appState:{...t,exportScale:n},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let a=(0,i.pk)(e),l=(0,i.tk)(a,t)?(0,i.vk)(a,t):a;return(0,h.jsx)(h.Fragment,{children:i.la.map(e=>{let[a,s]=(0,i.fi)(l,i.ma,e),r=`${z("imageExportDialog.label.scale")} ${e}x (${a}x${s})`;return(0,h.jsx)(Y,{size:"small",type:"radio",icon:`${e}x`,name:"export-canvas-scale",title:r,"aria-label":r,id:"export-canvas-scale",checked:e===t.exportScale,onChange:()=>n(e)},e)})})}}),tC=(0,i.$c)({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,n)=>({appState:{...t,exportBackground:n},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,h.jsx)(tw,{checked:e.exportBackground,onChange:e=>t(e),children:z("imageExportDialog.label.withBackground")})}),tj=(0,i.$c)({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,n)=>({appState:{...t,exportEmbedScene:n},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,h.jsxs)(tw,{checked:e.exportEmbedScene,onChange:e=>t(e),children:[z("imageExportDialog.label.embedScene"),(0,h.jsx)(tr,{label:z("imageExportDialog.tooltip.embedScene"),long:!0,children:(0,h.jsx)("div",{className:"excalidraw-tooltip-icon",children:i.Td})})]})}),tI=(0,i.$c)({name:"saveToActiveFile",label:"buttons.save",icon:i.Ad,trackEvent:{category:"export"},predicate:(e,t,n,i)=>!!i.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,n,a)=>{let l=!!t.fileHandle;try{let{fileHandle:n}=(0,i.sh)(t.fileHandle)?await tv(e,t,a.files,a.getName()):await (0,i.Kh)(e,t,a.files,a.getName());return{captureUpdate:i.Wg.EVENTUALLY,appState:{...t,fileHandle:n,toast:l?{message:n?.name?z("toast.fileSavedToFilename").replace("{filename}",`"${n.name}"`):z("toast.fileSaved")}:null}}}catch(e){return e?.name!=="AbortError"?console.error(e):console.warn(e),{captureUpdate:i.Wg.EVENTUALLY}}},keyTest:e=>e.key===i.hg.S&&e[i.hg.CTRL_OR_CMD]&&!e.shiftKey}),tT=(0,i.$c)({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:i.Ad,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,n,a)=>{try{let{fileHandle:n}=await (0,i.Kh)(e,{...t,fileHandle:null},a.files,a.getName());return{captureUpdate:i.Wg.EVENTUALLY,appState:{...t,openDialog:null,fileHandle:n,toast:{message:z("toast.fileSaved")}}}}catch(e){return e?.name!=="AbortError"?console.error(e):console.warn(e),{captureUpdate:i.Wg.EVENTUALLY}}},keyTest:e=>e.key===i.hg.S&&e.shiftKey&&e[i.hg.CTRL_OR_CMD],PanelComponent:({updateData:e})=>(0,h.jsx)(Y,{type:"button",icon:i.Kd,title:z("buttons.saveAs"),"aria-label":z("buttons.saveAs"),showAriaLabel:sq().editor.isMobile,hidden:!i.eh,onClick:()=>e(null),"data-testid":"save-as-button"})}),tM=(0,i.$c)({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,n,i)=>!!i.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,n,a)=>{try{let{elements:n,appState:a,files:l}=await (0,i.Lh)(t,e);return{elements:n,appState:a,files:l,captureUpdate:i.Wg.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:a.files,captureUpdate:i.Wg.EVENTUALLY}}},keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.O}),tD=(0,i.$c)({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,n)=>({appState:{...t,exportWithDarkMode:n},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,h.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:(0,h.jsx)(tb,{value:e.exportWithDarkMode?i.G.DARK:i.G.LIGHT,onChange:e=>{t(e===i.G.DARK)},title:z("imageExportDialog.label.darkMode")})})}),tL="{}",tN=(0,i.$c)({name:"copyStyles",label:"labels.copyStyles",icon:i.yf,trackEvent:{category:"element"},perform:(e,t,n,a)=>{let l=[],s=e.find(e=>t.selectedElementIds[e.id]);if(l.push(s),s&&(0,i.mc)(s)){let e=(0,i.zj)(s,a.scene.getNonDeletedElementsMap());l.push(e)}return s&&(tL=JSON.stringify(l)),{appState:{...t,toast:{message:z("toast.copyStyles")}},captureUpdate:i.Wg.EVENTUALLY}},keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.C}),tA=(0,i.$c)({name:"pasteStyles",label:"labels.pasteStyles",icon:i.yf,trackEvent:{category:"element"},perform:(e,t,n,a)=>{let l=JSON.parse(tL),s=l[0],r=l[1];if(!(0,i.kc)(s))return{elements:e,captureUpdate:i.Wg.EVENTUALLY};let o=(0,i.vk)(e,t,{includeBoundTextElement:!0}),d=o.map(e=>e.id);return{elements:e.map(e=>{if(d.includes(e.id)){let t=s;if((0,i._b)(e)&&e.containerId&&(t=r),!t)return e;let n=(0,i.Qj)(e,{backgroundColor:t?.backgroundColor,strokeWidth:t?.strokeWidth,strokeColor:t?.strokeColor,strokeStyle:t?.strokeStyle,fillStyle:t?.fillStyle,opacity:t?.opacity,roughness:t?.roughness,roundness:t.roundness?(0,i.pc)(t.roundness.type,e)?t.roundness:(0,i.qc)(e):null});if((0,i._b)(n)){let e=t.fontSize||i.I,l=t.fontFamily||i.J;n=(0,i.Qj)(n,{fontSize:e,fontFamily:l,textAlign:t.textAlign||i.K,lineHeight:t.lineHeight||(0,i.Rf)(l)});let s=null;n.containerId&&(s=o.find(e=>(0,i._b)(n)&&e.id===n.containerId)||null),(0,i.uj)(n,s,a.scene.getNonDeletedElementsMap())}return"arrow"===n.type&&(0,i.dc)(t)&&(n=(0,i.Qj)(n,{startArrowhead:t.startArrowhead,endArrowhead:t.endArrowhead})),(0,i.bc)(e)&&(n=(0,i.Qj)(n,{roundness:null,backgroundColor:"transparent"})),n}return e}),captureUpdate:i.Wg.IMMEDIATELY}},keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.V});(0,i.$c)({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:"canvas"===t.openMenu?null:"canvas"},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,h.jsx)(Y,{type:"button",icon:i.zd,"aria-label":z("buttons.menu"),onClick:t,selected:"canvas"===e.openMenu})}),(0,i.$c)({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:"shape"===t.openMenu?null:"shape"},captureUpdate:i.Wg.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,h.jsx)(Y,{visible:(0,i.lk)(t,(0,i.pk)(e)),type:"button",icon:i.Md,"aria-label":z("buttons.edit"),onClick:n,selected:"shape"===t.openMenu})});var tP=(0,i.$c)({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:i.Cd,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,n,{focusContainer:a})=>(t.openDialog?.name==="help"&&a(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:i.Wg.EVENTUALLY}),keyTest:e=>e.key===i.hg.QUESTION_MARK}),t_=(e,t,n)=>{let a=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return a.length>=2&&!(e=>{if(e.length>=2){for(let t of e[0].groupIds)if(e.reduce((e,n)=>e&&(0,i.Pc)(n,t),!0))return!0}return!1})(a)&&!(0,i.Qi)(a)},tR=(0,i.$c)({name:"group",label:"labels.group",icon:e=>(0,h.jsx)(i.he,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,n,a)=>{let l=(0,i.Di)(a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(l.length<2)return{appState:t,elements:e,captureUpdate:i.Wg.EVENTUALLY};let s=(0,i.Mc)(t);if(1===s.length){let n=s[0],a=new Set((0,i.Qc)(e,n).map(e=>e.id)),r=new Set(l.map(e=>e.id));if(new Set([...Array.from(a),...Array.from(r)]).size===a.size)return{appState:t,elements:e,captureUpdate:i.Wg.EVENTUALLY}}let r=[...e];new Set(l.map(e=>e.frameId)).size>1&&(0,i.Ai)(l).forEach((e,t)=>{(0,i.Ji)(e,a.scene.getNonDeletedElementsMap())});let o=(0,i.sc)(),d=(0,i.xb)(l);r=r.map(e=>d.get(e.id)?(0,i.Qj)(e,{groupIds:(0,i.Sc)(e.groupIds,o,t.editingGroupId)}):e);let c=(0,i.Qc)(r,o),h=c[c.length-1],m=r.lastIndexOf(h),p=r.slice(m+1),u=r.slice(0,m).filter(e=>!(0,i.Pc)(e,o)),g=(0,i.Mj)([...u,...c,...p],(0,i.xb)(c));return{appState:{...t,...(0,i.Ic)(o,{...t,selectedGroupIds:{}},(0,i.pk)(r))},elements:g,captureUpdate:i.Wg.IMMEDIATELY}},predicate:(e,t,n,i)=>t_(e,t,i),keyTest:e=>!e.shiftKey&&e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.G,PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)(Y,{hidden:!t_(e,t,a),type:"button",icon:(0,h.jsx)(i.he,{theme:t.theme}),onClick:()=>n(null),title:`${z("labels.group")} \u2014 ${(0,i.kb)("CtrlOrCmd+G")}`,"aria-label":z("labels.group"),visible:(0,i.tk)((0,i.pk)(e),t)})}),tO=(0,i.$c)({name:"ungroup",label:"labels.ungroup",icon:e=>(0,h.jsx)(i.ie,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,n,a)=>{let l=(0,i.Mc)(t),s=(0,i.xb)(e);if(0===l.length)return{appState:t,elements:e,captureUpdate:i.Wg.EVENTUALLY};let r=[...e],o=[];r=r.map(e=>{(0,i.nc)(e)&&o.push(e.id);let n=(0,i.Tc)(e.groupIds,t.selectedGroupIds);return n.length===e.groupIds.length?e:(0,i.Qj)(e,{groupIds:n})});let d=(0,i.Jc)(t,(0,i.pk)(r),t,null),c=new Set(a.scene.getSelectedElements(t).filter(e=>e.frameId).map(e=>e.frameId));return(0,i.Ci)(e).filter(e=>c.has(e.id)).forEach(e=>{e&&(r=(0,i.Li)(r,(0,i.Ei)(r,e,t,s),e,a))}),d.selectedElementIds=Object.entries(d.selectedElementIds).reduce((e,[t,n])=>(n&&!o.includes(t)&&(e[t]=!0),e),{}),{appState:{...t,...d},elements:r,captureUpdate:i.Wg.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.G.toUpperCase(),predicate:(e,t)=>(0,i.Mc)(t).length>0,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,h.jsx)(Y,{type:"button",hidden:0===(0,i.Mc)(t).length,icon:(0,h.jsx)(i.ie,{theme:t.theme}),onClick:()=>n(null),title:`${z("labels.ungroup")} \u2014 ${(0,i.kb)("CtrlOrCmd+Shift+G")}`,"aria-label":z("labels.ungroup"),visible:(0,i.tk)((0,i.pk)(e),t)})}),tF=(e,t,n,i,a,l,s)=>{e.beginPath(),e.moveTo(t+l,n),e.lineTo(t+i-l,n),e.quadraticCurveTo(t+i,n,t+i,n+l),e.lineTo(t+i,n+a-l),e.quadraticCurveTo(t+i,n+a,t+i-l,n+a),e.lineTo(t+l,n+a),e.quadraticCurveTo(t,n+a,t,n+a-l),e.lineTo(t,n+l),e.quadraticCurveTo(t,n,t+l,n),e.closePath(),e.fill(),s&&(e.strokeStyle=s),e.stroke()},tz=(e,t)=>`hsl(${Math.abs(function(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n);return t}(t?.id||e))%37*10}, 100%, 83%)`,tU=({color:e,onClick:t,name:n,src:i,className:a})=>{let l,s=((l=n?.trim()?.codePointAt(0))?String.fromCodePoint(l):"?").toUpperCase(),[r,d]=(0,o.useState)(!1),c=!r&&i;return(0,h.jsx)("div",{className:(0,m.A)("Avatar",a),style:c?void 0:{background:e},onClick:t,children:c?(0,h.jsx)("img",{className:"Avatar-img",src:i,alt:s,referrerPolicy:"no-referrer",onError:()=>d(!0)}):s})};(0,i.$c)({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,n)=>!n.socketId||t.userToFollow?.socketId===n.socketId||n.isCurrentUser?{appState:{...t,userToFollow:null},captureUpdate:i.Wg.EVENTUALLY}:{appState:{...t,userToFollow:{socketId:n.socketId,username:n.username||""},openMenu:"canvas"===t.openMenu?null:t.openMenu},captureUpdate:i.Wg.EVENTUALLY},PanelComponent:({updateData:e,data:t,appState:n})=>{let{socketId:a,collaborator:l,withName:s,isBeingFollowed:r}=t,o=tz(a,l),d=(0,m.A)({"is-followed":r,"is-current-user":!0===l.isCurrentUser,"is-speaking":l.isSpeaking,"is-in-call":l.isInCall,"is-muted":l.isMuted}),c=l.isInCall?l.isSpeaking?(0,h.jsxs)("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:z("userList.hint.isSpeaking"),children:[(0,h.jsx)("div",{}),(0,h.jsx)("div",{}),(0,h.jsx)("div",{})]}):l.isMuted?(0,h.jsx)("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:z("userList.hint.micMuted"),children:i.sf}):(0,h.jsx)("div",{title:z("userList.hint.inCall"),children:i.rf}):null;return s?(0,h.jsxs)("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${d}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(l),children:[(0,h.jsx)(tU,{color:o,onClick:()=>{},name:l.username||"",src:l.avatarUrl,className:d}),(0,h.jsx)("div",{className:"UserList__collaborator-name",children:l.username}),(0,h.jsxs)("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[r&&(0,h.jsx)("div",{className:"UserList__collaborator-status-icon-is-followed",title:z("userList.hint.followStatus"),children:i.lf}),c]})]}):(0,h.jsxs)("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${d}`,children:[(0,h.jsx)(tU,{color:o,onClick:()=>{e(l)},name:l.username||"",src:l.avatarUrl,className:d}),c&&(0,h.jsx)("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var tB=(0,i.$c)({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,n,a)=>{let l=a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let e of i.za)if(l.some(t=>t.type===e))return{captureUpdate:i.Wg.EVENTUALLY,appState:{...t,errorMessage:z(`errors.libraryElementTypeError.${e}`)}};return a.library.getLatestLibrary().then(e=>a.library.setLibrary([{id:(0,i.sc)(),status:"unpublished",elements:l.map(i.bg),created:Date.now()},...e])).then(()=>({captureUpdate:i.Wg.EVENTUALLY,appState:{...t,toast:{message:z("toast.addedToLibrary")}}})).catch(e=>({captureUpdate:i.Wg.EVENTUALLY,appState:{...t,errorMessage:e.message}}))},label:"labels.addToLibrary"}),tW=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length>1&&!n.some(e=>(0,i.bc)(e))},tH=(e,t,n,a)=>{var l;let s,r,o=n.scene.getSelectedElements(t),d=(0,i.xb)(e),c=(l=n.scene,s=(0,i.Uc)(o,d),r=(0,i.cj)(o),s.flatMap(e=>{let t=((e,t,{axis:n,position:a})=>{let l=(0,i.cj)(e),[s,r]="x"===n?["minX","maxX"]:["minY","maxY"],o={x:0,y:0};return"start"===a?{...o,[n]:t[s]-l[s]}:"end"===a?{...o,[n]:t[r]-l[r]}:{...o,[n]:(t[s]+t[r])/2-(l[s]+l[r])/2}})(e,r,a);return e.map(n=>{let a=(0,i.Pj)(n,{x:n.x+t.x,y:n.y+t.y});return(0,i.Pg)(n,l.getNonDeletedElementsMap(),{simultaneouslyUpdated:e}),a})})),h=(0,i.xb)(c);return(0,i.Mi)(e.map(e=>h.get(e.id)||e),t,n)};(0,i.$c)({name:"alignTop",label:"labels.alignTop",icon:i.Zd,trackEvent:{category:"element"},predicate:(e,t,n,i)=>tW(t,i),perform:(e,t,n,a)=>({appState:t,elements:tH(e,t,a,{position:"start",axis:"y"}),captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&e.key===i.hg.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)(Y,{hidden:!tW(t,a),type:"button",icon:i.Zd,onClick:()=>n(null),title:`${z("labels.alignTop")} \u2014 ${(0,i.kb)("CtrlOrCmd+Shift+Up")}`,"aria-label":z("labels.alignTop"),visible:(0,i.tk)((0,i.pk)(e),t)})}),(0,i.$c)({name:"alignBottom",label:"labels.alignBottom",icon:i._d,trackEvent:{category:"element"},predicate:(e,t,n,i)=>tW(t,i),perform:(e,t,n,a)=>({appState:t,elements:tH(e,t,a,{position:"end",axis:"y"}),captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&e.key===i.hg.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)(Y,{hidden:!tW(t,a),type:"button",icon:i._d,onClick:()=>n(null),title:`${z("labels.alignBottom")} \u2014 ${(0,i.kb)("CtrlOrCmd+Shift+Down")}`,"aria-label":z("labels.alignBottom"),visible:(0,i.tk)((0,i.pk)(e),t)})}),(0,i.$c)({name:"alignLeft",label:"labels.alignLeft",icon:i.$d,trackEvent:{category:"element"},predicate:(e,t,n,i)=>tW(t,i),perform:(e,t,n,a)=>({appState:t,elements:tH(e,t,a,{position:"start",axis:"x"}),captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&e.key===i.hg.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)(Y,{hidden:!tW(t,a),type:"button",icon:i.$d,onClick:()=>n(null),title:`${z("labels.alignLeft")} \u2014 ${(0,i.kb)("CtrlOrCmd+Shift+Left")}`,"aria-label":z("labels.alignLeft"),visible:(0,i.tk)((0,i.pk)(e),t)})}),(0,i.$c)({name:"alignRight",label:"labels.alignRight",icon:i.ae,trackEvent:{category:"element"},predicate:(e,t,n,i)=>tW(t,i),perform:(e,t,n,a)=>({appState:t,elements:tH(e,t,a,{position:"end",axis:"x"}),captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&e.key===i.hg.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)(Y,{hidden:!tW(t,a),type:"button",icon:i.ae,onClick:()=>n(null),title:`${z("labels.alignRight")} \u2014 ${(0,i.kb)("CtrlOrCmd+Shift+Right")}`,"aria-label":z("labels.alignRight"),visible:(0,i.tk)((0,i.pk)(e),t)})}),(0,i.$c)({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:i.de,trackEvent:{category:"element"},predicate:(e,t,n,i)=>tW(t,i),perform:(e,t,n,a)=>({appState:t,elements:tH(e,t,a,{position:"center",axis:"y"}),captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)(Y,{hidden:!tW(t,a),type:"button",icon:i.de,onClick:()=>n(null),title:z("labels.centerVertically"),"aria-label":z("labels.centerVertically"),visible:(0,i.tk)((0,i.pk)(e),t)})}),(0,i.$c)({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:i.ee,trackEvent:{category:"element"},predicate:(e,t,n,i)=>tW(t,i),perform:(e,t,n,a)=>({appState:t,elements:tH(e,t,a,{position:"center",axis:"x"}),captureUpdate:i.Wg.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)(Y,{hidden:!tW(t,a),type:"button",icon:i.ee,onClick:()=>n(null),title:z("labels.centerHorizontally"),"aria-label":z("labels.centerHorizontally"),visible:(0,i.tk)((0,i.pk)(e),t)})});var t$=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length>1&&!n.some(e=>(0,i.bc)(e))},tY=(e,t,n,a)=>{let l=((e,t,n)=>{let[a,l,s,r]="x"===n.axis?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],o=(0,i.cj)(e),d=(0,i.Uc)(e,t).map(e=>[e,(0,i.cj)(e)]).sort((e,t)=>e[1][l]-t[1][l]),c=0;for(let e of d)c+=e[1][r];let h=(o[r]-c)/(d.length-1);if(h<0){let e=d.findIndex(e=>e[1][a]===o[a]),t=d.findIndex(e=>e[1][s]===o[s]),r=(d[t][1][l]-d[e][1][l])/(d.length-1),c=d[e][1][l];return d.flatMap(([a,s],o)=>{let d={x:0,y:0};return o!==e&&o!==t&&(c+=r,d[n.axis]=c-s[l]),a.map(e=>(0,i.Qj)(e,{x:e.x+d.x,y:e.y+d.y}))})}let m=o[a];return d.flatMap(([e,t])=>{let l={x:0,y:0};return l[n.axis]=m-t[a],m+=h,m+=t[r],e.map(e=>(0,i.Qj)(e,{x:e.x+l.x,y:e.y+l.y}))})})(n.scene.getSelectedElements(t),n.scene.getNonDeletedElementsMap(),a),s=(0,i.xb)(l);return(0,i.Mi)(e.map(e=>s.get(e.id)||e),t,n)};(0,i.$c)({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,n,a)=>({appState:t,elements:tY(e,t,a,{space:"between",axis:"x"}),captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>!e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.H,PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)(Y,{hidden:!t$(t,a),type:"button",icon:i.be,onClick:()=>n(null),title:`${z("labels.distributeHorizontally")} \u2014 ${(0,i.kb)("Alt+H")}`,"aria-label":z("labels.distributeHorizontally"),visible:(0,i.tk)((0,i.pk)(e),t)})}),(0,i.$c)({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,n,a)=>({appState:t,elements:tY(e,t,a,{space:"between",axis:"y"}),captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>!e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.V,PanelComponent:({elements:e,appState:t,updateData:n,app:a})=>(0,h.jsx)(Y,{hidden:!t$(t,a),type:"button",icon:i.ce,onClick:()=>n(null),title:`${z("labels.distributeVertically")} \u2014 ${(0,i.kb)("Alt+V")}`,"aria-label":z("labels.distributeVertically"),visible:(0,i.tk)((0,i.pk)(e),t)})});var tG=(0,i.$c)({name:"flipHorizontal",label:"labels.flipHorizontal",icon:i.xf,trackEvent:{category:"element"},perform:(e,t,n,a)=>({elements:(0,i.Mi)(tK(e,a.scene.getNonDeletedElementsMap(),t,"horizontal",a),t,a),appState:t,captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===i.gg.H}),tV=(0,i.$c)({name:"flipVertical",label:"labels.flipVertical",icon:i.wf,trackEvent:{category:"element"},perform:(e,t,n,a)=>({elements:(0,i.Mi)(tK(e,a.scene.getNonDeletedElementsMap(),t,"vertical",a),t,a),appState:t,captureUpdate:i.Wg.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===i.gg.V&&!e[i.hg.CTRL_OR_CMD]}),tK=(e,t,n,a,l)=>{let s=tZ((0,i.vk)((0,i.pk)(e),n,{includeBoundTextElement:!0,includeElementsInFrames:!0}),t,n,a,l),r=(0,i.xb)(s);return e.map(e=>r.get(e.id)||e)},tZ=(e,t,n,a,l)=>{if(e.every(e=>(0,i.dc)(e)&&(e.startBinding||e.endBinding)))return e.map(e=>(0,i.Qj)(e,{startArrowhead:e.endArrowhead,endArrowhead:e.startArrowhead}));let{midX:s,midY:r}=(0,i.cj)(e);(0,i.hk)(e,t,"nw",l.scene,new Map(Array.from(t.values()).map(e=>[e.id,(0,i.bg)(e)])),{flipByX:"horizontal"===a,flipByY:"vertical"===a,shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),(0,i.Jg)(e.filter(i.cc),t,l.scene.getNonDeletedElements(),l.scene,(0,i.Fg)(n),[],n.zoom);let{elbowArrows:o,otherElements:d}=e.reduce((e,t)=>(0,i.ec)(t)?{...e,elbowArrows:e.elbowArrows.concat(t)}:{...e,otherElements:e.otherElements.concat(t)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:h}=(0,i.cj)(e),[m,p]=[s-c,r-h];return d.forEach(e=>(0,i.Pj)(e,{x:e.x+m,y:e.y+p})),o.forEach(e=>(0,i.Pj)(e,{x:e.x+m,y:e.y+p})),e},tX=(0,i.$c)({name:"copy",label:"labels.copy",icon:i.wd,trackEvent:{category:"element"},perform:async(e,t,n,a)=>{let l=a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await (0,i.ki)(l,a.files,n)}catch(e){return{captureUpdate:i.Wg.EVENTUALLY,appState:{...t,errorMessage:e.message}}}return{captureUpdate:i.Wg.EVENTUALLY}},keyTest:void 0}),tQ=(0,i.$c)({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,n,a)=>{let l;try{l=await (0,i.li)()}catch(e){return"AbortError"!==e.name&&"NotAllowedError"!==e.name&&(console.error(`actionPaste ${e.name}: ${e.message}`),i.n?{captureUpdate:i.Wg.EVENTUALLY,appState:{...t,errorMessage:z("hints.firefox_clipboard_write")}}:{captureUpdate:i.Wg.EVENTUALLY,appState:{...t,errorMessage:z("errors.asyncPasteFailedOnRead")}})}try{a.pasteFromClipboard((0,i.ji)({types:l}))}catch(e){return console.error(e),{captureUpdate:i.Wg.EVENTUALLY,appState:{...t,errorMessage:z("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:i.Wg.EVENTUALLY}},keyTest:void 0}),tq=(0,i.$c)({name:"cut",label:"labels.cut",icon:i.$e,trackEvent:{category:"element"},perform:(e,t,n,i)=>(tX.perform(e,t,n,i),V.perform(e,t,null,i)),keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.X}),tJ=(0,i.$c)({name:"copyAsSvg",label:"labels.copyAsSvg",icon:i.Af,trackEvent:{category:"element"},perform:async(e,t,n,a)=>{if(!a.canvas)return{captureUpdate:i.Wg.EVENTUALLY};let{exportedElements:l,exportingFrame:s}=tE(e,t,!0);try{await ty("clipboard-svg",l,t,a.files,{...t,exportingFrame:s,name:a.getName()});let e=a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:z("toast.copyToClipboardAsSvg",{exportSelection:e.length?z("toast.selection"):z("toast.canvas"),exportColorScheme:t.exportWithDarkMode?z("buttons.darkMode"):z("buttons.lightMode")})}},captureUpdate:i.Wg.EVENTUALLY}}catch(e){return console.error(e),{appState:{errorMessage:e.message},captureUpdate:i.Wg.EVENTUALLY}}},predicate:e=>i.hi&&e.length>0,keywords:["svg","clipboard","copy"]}),t0=(0,i.$c)({name:"copyAsPng",label:"labels.copyAsPng",icon:i.Bf,trackEvent:{category:"element"},perform:async(e,t,n,a)=>{if(!a.canvas)return{captureUpdate:i.Wg.EVENTUALLY};let l=a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:s,exportingFrame:r}=tE(e,t,!0);try{return await ty("clipboard",s,t,a.files,{...t,exportingFrame:r,name:a.getName()}),{appState:{...t,toast:{message:z("toast.copyToClipboardAsPng",{exportSelection:l.length?z("toast.selection"):z("toast.canvas"),exportColorScheme:t.exportWithDarkMode?z("buttons.darkMode"):z("buttons.lightMode")})}},captureUpdate:i.Wg.EVENTUALLY}}catch(e){return console.error(e),{appState:{...t,errorMessage:e.message},captureUpdate:i.Wg.EVENTUALLY}}},predicate:e=>i.ii&&e.length>0,keyTest:e=>e.code===i.gg.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),t1=(0,i.$c)({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,n,a)=>{let l=a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{(0,i.oi)((0,i.Jj)(l))}catch{throw Error(z("errors.copyToSystemClipboardFailed"))}return{captureUpdate:i.Wg.EVENTUALLY}},predicate:(e,t,n,a)=>i.hi&&a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(i._b),keywords:["text","clipboard","copy"]}),t2=(0,i.$c)({name:"gridMode",icon:i.Gf,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,t){return{appState:{...t,gridModeEnabled:!this.checked(t),objectsSnapModeEnabled:!1},captureUpdate:i.Wg.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>void 0===n.gridModeEnabled,keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.code===i.gg.QUOTE}),t3=(0,i.$c)({name:"zenMode",label:"buttons.zenMode",icon:i.Df,paletteName:"Toggle zen mode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:i.Wg.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,n)=>typeof n.zenModeEnabled>"u",keyTest:e=>!e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.Z}),t5=(0,i.$c)({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:i.Cf,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:i.Wg.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,n)=>typeof n.objectsSnapModeEnabled>"u",keyTest:e=>!e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.S}),t4=(0,i.$c)({name:"stats",label:"stats.fullTitle",icon:i.vf,paletteName:"Toggle stats",viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:i.Wg.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.SLASH}),t6=(0,i.$c)({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,n,a)=>a.scene.getSelectedElements(t).some(e=>(0,i.mc)(e)),perform:(e,t,n,a)=>{let l=a.scene.getSelectedElements(t),s=a.scene.getNonDeletedElementsMap();return l.forEach(e=>{let t=(0,i.zj)(e,s);if(t){let{width:n,height:a}=(0,i.vc)(t.originalText,(0,i.cb)(t),t.lineHeight),l=(0,i.tj)(e.id);(0,i.sj)(e.id);let{x:r,y:o}=(0,i.xj)(e,t,s);(0,i.Pj)(t,{containerId:null,width:n,height:a,text:t.originalText,x:r,y:o}),(0,i.Pj)(e,{boundElements:e.boundElements?.filter(e=>e.id!==t.id),height:l||e.height})}}),{elements:e,appState:t,captureUpdate:i.Wg.IMMEDIATELY}}}),t8=(0,i.$c)({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,n,a)=>{let l=a.scene.getSelectedElements(t);if(2===l.length){let e=(0,i._b)(l[0])||(0,i._b)(l[1]),t;if((0,i.jc)(l[0])?t=l[0]:(0,i.jc)(l[1])&&(t=l[1]),e&&t&&null===(0,i.zj)(t,a.scene.getNonDeletedElementsMap()))return!0}return!1},perform:(e,t,n,a)=>{let l=a.scene.getSelectedElements(t),s,r;(0,i._b)(l[0])&&(0,i.jc)(l[1])?(s=l[0],r=l[1]):(s=l[1],r=l[0]),(0,i.Pj)(s,{containerId:r.id,verticalAlign:i.sa.MIDDLE,textAlign:i.ta.CENTER,autoResize:!0}),(0,i.Pj)(r,{boundElements:(r.boundElements||[]).concat({type:"text",id:s.id})});let o=r.height;return(0,i.uj)(s,r,a.scene.getNonDeletedElementsMap()),(0,i.rj)(r.id,o),{elements:t7(e,r,s),appState:{...t,selectedElementIds:{[r.id]:!0}},captureUpdate:i.Wg.IMMEDIATELY}}}),t7=(e,t,n)=>{let a=e.slice(),l=a.findIndex(e=>e.id===n.id);a.splice(l,1);let s=a.findIndex(e=>e.id===t.id);return a.splice(s+1,0,n),(0,i.Mj)(a,(0,i.xb)([t,n])),a},t9=(e,t,n)=>{let a=e.slice(),l=a.findIndex(e=>e.id===t.id);a.splice(l,1);let s=a.findIndex(e=>e.id===n.id);return a.splice(s,0,t),(0,i.Mj)(a,(0,i.xb)([t,n])),a},ne=(0,i.$c)({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,n,a)=>{let l=a.scene.getSelectedElements(t),s=l.every(e=>(0,i._b)(e));return l.length>0&&s},perform:(e,t,n,a)=>{let l=a.scene.getSelectedElements(t),s=e.slice(),r={};for(let e of l)if((0,i._b)(e)){let n=(0,i.Sf)({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...e.boundElements||[],{id:e.id,type:"text"}],angle:e.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:"round"===t.currentItemRoundness?{type:(0,i.oc)("rectangle")?i.ua.ADAPTIVE_RADIUS:i.ua.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:e.x-i.ra,y:e.y-i.ra,width:(0,i.Gj)(e.width,"rectangle"),height:(0,i.Gj)(e.height,"rectangle"),groupIds:e.groupIds,frameId:e.frameId});if(e.boundElements?.length){let t=e.boundElements.filter(e=>"arrow"===e.type).map(e=>e.id);s.filter(e=>t.includes(e.id)).forEach(t=>{let a=t.startBinding,l=t.endBinding;a?.elementId===e.id&&(a={...a,elementId:n.id}),l?.elementId===e.id&&(l={...l,elementId:n.id}),(a||l)&&(0,i.Pj)(t,{startBinding:a,endBinding:l},!1)})}(0,i.Pj)(e,{containerId:n.id,verticalAlign:i.sa.MIDDLE,boundElements:null,textAlign:i.ta.CENTER,autoResize:!0},!1),(0,i.uj)(e,n,a.scene.getNonDeletedElementsMap()),s=t9([...s,n],n,e),r[n.id]=!0}return{elements:s,appState:{...t,selectedElementIds:r},captureUpdate:i.Wg.IMMEDIATELY}}}),nt=!1,nn=new Map,ni=({element:e,elementsMap:t,setAppState:n,onLinkOpen:a,setToast:l,updateEmbedValidationStatus:s})=>{let r=s1(),d=sQ(),c=sq(),p=e.link||"",[u,g]=(0,o.useState)(p),f=(0,o.useRef)(null),b="editor"===r.showHyperlinkPopup,x=(0,o.useCallback)(()=>{if(!f.current)return;let t=(0,i.Xc)(f.current.value)||null;if(!e.link&&t&&ed("hyperlink","create"),(0,i.Xb)(e)){if(r.activeEmbeddable?.element===e&&n({activeEmbeddable:null}),!t){(0,i.Pj)(e,{link:null}),s(e,!1);return}if((0,i.$g)(t,d.validateEmbeddable)){let{width:n,height:a}=e,r=(0,i.Zg)(t);r?.error instanceof URIError&&l({message:z("toast.unrecognizedLinkFormat"),closable:!0});let o=r?r.intrinsicSize.w/r.intrinsicSize.h:1,d=nn.get(e.id)!==e.link;(0,i.Pj)(e,{...d?{width:r?.type==="video"?n>a?n:a*o:n,height:r?.type==="video"&&n>a?n/o:a}:{},link:t}),s(e,!0),nn.has(e.id)&&nn.delete(e.id)}else t&&l({message:z("toast.unableToEmbed"),closable:!0}),e.link&&nn.set(e.id,e.link),(0,i.Pj)(e,{link:t}),s(e,!1)}else(0,i.Pj)(e,{link:t})},[e,l,d.validateEmbeddable,r.activeEmbeddable,n,s]);(0,o.useLayoutEffect)(()=>()=>{x()},[x]),(0,o.useEffect)(()=>{b&&f?.current&&!(c.viewport.isMobile||c.isTouchScreen)&&f.current.select()},[b,c.viewport.isMobile,c.isTouchScreen]),(0,o.useEffect)(()=>{let a=null,l=l=>{!b&&(a&&clearTimeout(a),no(e,t,r,(0,i.Ua)(l.clientX,l.clientY))&&(a=window.setTimeout(()=>{n({showHyperlinkPopup:!1})},500)))};return window.addEventListener("pointermove",l,!1),()=>{window.removeEventListener("pointermove",l,!1),a&&clearTimeout(a)}},[r,e,b,n,t]);let E=(0,o.useCallback)(()=>{ed("hyperlink","delete"),(0,i.Pj)(e,{link:null}),n({showHyperlinkPopup:!1})},[n,e]),{x:y,y:v}=na(e,r,t);return r.contextMenu||r.selectedElementsAreBeingDragged||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled?null:(0,h.jsxs)("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${v}px`,left:`${y}px`,width:380,padding:5},children:[b?(0,h.jsx)("input",{className:(0,m.A)("excalidraw-hyperlinkContainer-input"),placeholder:z("labels.link.hint"),ref:f,value:u,onChange:e=>g(e.target.value),autoFocus:!0,onKeyDown:e=>{e.stopPropagation(),e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.K&&e.preventDefault(),(e.key===i.hg.ENTER||e.key===i.hg.ESCAPE)&&(x(),n({showHyperlinkPopup:"info"}))}}):e.link?(0,h.jsx)("a",{href:(0,i.Xc)(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:(0,i.Yc)(e.link)?"_self":"_blank",onClick:t=>{if(e.link&&a){let n=(0,i.Cb)("excalidraw-link",t.nativeEvent);a({...e,link:(0,i.Xc)(e.link)},n),n.defaultPrevented&&t.preventDefault()}},rel:"noopener noreferrer",children:e.link}):(0,h.jsx)("div",{className:"excalidraw-hyperlinkContainer-link",children:z("labels.link.empty")}),(0,h.jsxs)("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!b&&(0,h.jsx)(Y,{type:"button",title:z("buttons.edit"),"aria-label":z("buttons.edit"),label:z("buttons.edit"),onClick:()=>{ed("hyperlink","edit","popup-ui"),n({showHyperlinkPopup:"editor"})},className:"excalidraw-hyperlinkContainer--edit",icon:i.pd}),(0,h.jsx)(Y,{type:"button",title:z("labels.linkToElement"),"aria-label":z("labels.linkToElement"),label:z("labels.linkToElement"),onClick:()=>{n({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:i.Pf}),p&&!(0,i.Xb)(e)&&(0,h.jsx)(Y,{type:"button",title:z("buttons.remove"),"aria-label":z("buttons.remove"),label:z("buttons.remove"),onClick:E,className:"excalidraw-hyperlinkContainer--remove",icon:i.ud})]})]})},na=(e,t,n)=>{let[a,l]=(0,i.aj)(e,n),{x:s,y:r}=(0,i.mb)({sceneX:a+e.width/2,sceneY:l},t);return{x:s-t.offsetLeft-190,y:r-t.offsetTop-85}},nl=(e,t)=>{let n=(0,i.vk)(e,t);return(0,i.Xb)(n[0])?"labels.link.editEmbed":n[0]?.link?"labels.link.edit":"labels.link.create"},ns=null,nr=()=>{ns&&clearTimeout(ns),nt&&(nt=!1,tl().classList.remove("excalidraw-tooltip--visible"))},no=(e,t,n,[a,l])=>{let{x:s,y:r}=(0,i.lb)({clientX:a,clientY:l},n),o=15/n.zoom.value;if((0,i.og)(s,r,e,t))return!1;let[d,c,h]=(0,i.aj)(e,t);if(s>=d&&s<=h&&r>=c-85&&r<=c)return!1;let{x:m,y:p}=na(e,n,t);return!(a>=m-o&&a<=m+380+10+o&&l>=p-o&&l<=p+o+10+42)},nd=(0,i.$c)({name:"hyperlink",label:(e,t)=>nl(e,t),icon:i.Id,perform:(e,t)=>"editor"!==t.showHyperlinkPopup&&{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:i.Wg.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.K,predicate:(e,t)=>1===(0,i.vk)(e,t).length,PanelComponent:({elements:e,appState:t,updateData:n})=>{let a=(0,i.vk)(e,t);return(0,h.jsx)(Y,{type:"button",icon:i.Id,"aria-label":z(nl(e,t)),title:`${(0,i.Xb)(e[0])?z("labels.link.labelEmbed"):z("labels.link.label")} - ${(0,i.kb)("CtrlOrCmd+K")}`,onClick:()=>n(null),selected:1===a.length&&!!a[0].link})}}),nc=e=>e.every(e=>!e.locked),nh=(0,i.$c)({name:"toggleElementLock",label:(e,t,n)=>{let a=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return 1!==a.length||(0,i.bc)(a[0])?nc(a)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll":a[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock"},icon:(e,t)=>nc((0,i.vk)(t,e))?i.kd:i.jd,trackEvent:{category:"element"},predicate:(e,t,n,i)=>{let a=i.scene.getSelectedElements(t);return a.length>0&&!a.some(e=>e.locked&&e.frameId)},perform:(e,t,n,a)=>{let l=a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!l.length)return!1;let s=nc(l),r=(0,i.xb)(l);return{elements:e.map(e=>r.has(e.id)?(0,i.Qj)(e,{locked:s}):e),appState:{...t,selectedLinearElement:s?null:t.selectedLinearElement},captureUpdate:i.Wg.IMMEDIATELY}},keyTest:(e,t,n,a)=>e.key.toLocaleLowerCase()===i.hg.L&&e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),nm=(0,i.$c)({name:"unlockAllElements",paletteName:"Unlock all elements",trackEvent:{category:"canvas"},viewMode:!1,icon:i.jd,predicate:(e,t)=>0===(0,i.vk)(e,t).length&&e.some(e=>e.locked),perform:(e,t)=>{let n=e.filter(e=>e.locked);return{elements:e.map(e=>e.locked?(0,i.Qj)(e,{locked:!1}):e),appState:{...t,selectedElementIds:Object.fromEntries(n.map(e=>[e.id,!0]))},captureUpdate:i.Wg.IMMEDIATELY}},label:"labels.elementLock.unlockAll"}),np=e=>{let{closeOnClickOutside:t=!0}=e,n=eI({className:"excalidraw-modal-container"}),a=(0,o.useRef)(document.body.classList.contains("excalidraw-animations-disabled"));return n?(0,p.createPortal)((0,h.jsxs)("div",{className:(0,m.A)("Modal",e.className,{"animations-disabled":a.current}),role:"dialog","aria-modal":"true",onKeyDown:t=>{t.key===i.hg.ESCAPE&&(t.nativeEvent.stopImmediatePropagation(),t.stopPropagation(),e.onCloseRequest())},"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[(0,h.jsx)("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),(0,h.jsx)("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),n):null},nu=(0,d.eU)(new Map),ng=async e=>await (0,i.ri)({elements:e,appState:{exportBackground:!1,viewBackgroundColor:i.e.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),nf=()=>{let[e]=C(nu);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:t=>{t.forEach(t=>e.delete(t))},svgCache:e}},nb=class{constructor(){(0,r.d)(this,"jobs",[]),(0,r.d)(this,"running",!1)}tick(){if(this.running)return;let e=this.jobs.shift();e?(this.running=!0,e.promise.resolve((0,i.Tb)(e.jobFactory,...e.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(e,...t){let n=(0,i.tb)();return this.jobs.push({jobFactory:e,promise:n,args:t}),this.tick(),n}},nx=new i.Vg,nE=(0,d.eU)({status:"loaded",isInitialized:!1,libraryItems:[]}),ny=e=>(0,i.Nb)(e),nv=(e,t)=>!e.find(e=>e.elements.length===t.elements.length&&e.elements.every((e,n)=>e.id===t.elements[n].id&&e.versionNonce===t.elements[n].versionNonce)),nw=class{constructor(e){(0,r.d)(this,"currLibraryItems",[]),(0,r.d)(this,"prevLibraryItems",ny(this.currLibraryItems)),(0,r.d)(this,"app"),(0,r.d)(this,"updateQueue",[]),(0,r.d)(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]),(0,r.d)(this,"notifyListeners",()=>{if(this.updateQueue.length>0)D.set(nE,e=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:e.isInitialized}));else{D.set(nE,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let e=this.prevLibraryItems;this.prevLibraryItems=ny(this.currLibraryItems);let t=ny(this.currLibraryItems);this.app.props.onLibraryChange?.(t),nx.trigger(((e,t)=>{let n=(0,i.xb)(t),a={deletedItems:new Map,addedItems:new Map};for(let t of e)n.has(t.id)||a.deletedItems.set(t.id,t);let l=(0,i.xb)(e);for(let e of t)l.has(e.id)||a.addedItems.set(e.id,e);return a})(e,t),t)}catch(e){console.error(e)}}}),(0,r.d)(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],D.set(nu,new Map)}),(0,r.d)(this,"resetLibrary",()=>this.setLibrary([])),(0,r.d)(this,"getLatestLibrary",()=>new Promise(async e=>{try{let t=await (this.getLastUpdateTask()||this.currLibraryItems);e(this.updateQueue.length>0?this.getLatestLibrary():ny(t))}catch{return e(this.currLibraryItems)}})),(0,r.d)(this,"updateLibrary",async({libraryItems:e,prompt:t=!1,merge:n=!1,openLibraryMenu:a=!1,defaultStatus:l="unpublished"})=>(a&&this.app.setState({openSidebar:{name:i.ya.name,tab:i.wa}}),this.setLibrary(()=>new Promise(async(a,s)=>{try{let r=await ("function"==typeof e&&!(e instanceof Blob)?e(this.currLibraryItems):e),o;o=r instanceof Blob?await (0,i.xh)(r,l):(0,i.mh)(r,l),!t||window.confirm(z("alerts.confirmAddLibrary",{numShapes:o.length}))?(t&&this.app.focusContainer(),a(n?((e,t)=>{let n=[];for(let i of t)nv(e,i)&&n.push(i);return[...n,...e]})(this.currLibraryItems,o):o)):s(new i.tc)}catch(e){s(e)}})))),(0,r.d)(this,"setLibrary",e=>{let t=new Promise(async(t,n)=>{try{await this.getLastUpdateTask(),"function"==typeof e&&(e=e(this.currLibraryItems)),this.currLibraryItems=ny(await e),t(this.currLibraryItems)}catch(e){n(e)}}).catch(e=>{if("AbortError"===e.name)return console.warn("Library update aborted by user"),this.currLibraryItems;throw e}).finally(()=>{this.updateQueue=this.updateQueue.filter(e=>e!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t}),this.app=e}},nS=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],a=n=>e.slice(n*t,n*t+t).reduce((e,t)=>{let{height:n}=(0,i.cj)(t.elements);return Math.max(e,n)},0),l=n=>{let a=0,l=0,s=0;for(let r of e){if(a%t==0&&(l=0),l===n){let{width:e}=(0,i.cj)(r.elements);s=Math.max(s,e)}a++,l++}return s},s=0,r=0,o=0,d=0,c=0,h=0,m=0;for(let p of e){c&&c%t==0&&(r+=o+50,s=0,h=0,m++),0===h&&(o=a(m)),d=l(h);let{minX:e,minY:u,width:g,height:f}=(0,i.cj)(p.elements),b=(d-g)/2,x=(o-f)/2;n.push(...p.elements.map(t=>({...t,x:t.x+s+b-e,y:t.y+r+x-u}))),s+=d+50,c++,h++}return n},nk=class e{constructor(e){(0,r.d)(this,"adapter"),this.adapter=e}static async getLibraryItems(t,n,a=!0){let l=()=>new Promise(async(e,a)=>{try{let a=await t.load({source:n});e((0,i.mh)(a?.libraryItems||[],"published"))}catch(e){a(e)}});return a?e.queue.push(l):l()}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}};(0,r.d)(nk,"queue",new nb),(0,r.d)(nk,"run",async(e,t)=>{let n=new nk(e);return nk.queue.push(()=>t(n))});var nC=(0,o.forwardRef)(({children:e,gap:t,align:n,justifyContent:i,className:a,style:l},s)=>(0,h.jsx)("div",{className:(0,m.A)("Stack Stack_horizontal",a),style:{"--gap":t,alignItems:n,justifyContent:i,...l},ref:s,children:e})),nj=(0,o.forwardRef)(({children:e,gap:t,align:n,justifyContent:i,className:a,style:l},s)=>(0,h.jsx)("div",{className:(0,m.A)("Stack Stack_vertical",a),style:{"--gap":t,justifyItems:n,justifyContent:i,...l},ref:s,children:e})),nI=({theme:e,id:t,libraryReturnUrl:n})=>{let l=n||window.location.origin+window.location.pathname;return(0,h.jsx)("a",{className:"library-menu-browse-button",href:`${a.a.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${l}&useHash=true&token=${t}&theme=${e}&version=${i.qa.excalidrawLibrary}`,target:"_excalidraw_libraries",children:z("labels.libraries")})},nT=({libraryReturnUrl:e,theme:t,id:n,style:i,children:a,className:l})=>(0,h.jsxs)("div",{className:(0,m.A)("library-menu-control-buttons",l),style:i,children:[(0,h.jsx)(nI,{id:n,libraryReturnUrl:e,theme:t}),a]}),nM=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,nD=/{{([\w-]+)}}/,nL=/<([\w-]+)>/,nN=/<\/([\w-]+)>/,nA=({i18nKey:e,children:t,...n})=>{var i;let a,{t:l}=B();return o.createElement(o.Fragment,{},...(i=l(e),a=[{name:"",children:[]}],i.split(nM).filter(Boolean).forEach(e=>{let t=e.match(nL),l=e.match(nN),s=e.match(nD);if(null!==t){let e=t[1];n.hasOwnProperty(e)?a.push({name:e,children:[]}):console.warn(`Trans: missed to pass in prop ${e} for interpolating ${i}`)}else if(null!==l)if(l[1]===a[a.length-1].name){let e=a.pop(),t=o.createElement(o.Fragment,{},...e.children),i=n[e.name];"function"==typeof i&&a[a.length-1].children.push(i(t))}else console.warn(`Trans: unexpected end tag ${e} for interpolating ${i}`);else if(null!==s){let e=s[1];n.hasOwnProperty(e)?a[a.length-1].children.push(n[e]):console.warn(`Trans: key ${e} not in props for interpolating ${i}`)}else a[a.length-1].children.push(e)}),1!==a.length&&console.warn(`Trans: stack not empty for interpolating ${i}`),a[0].children))},nP=({label:e,onClick:t,className:n,children:i,actionType:a,type:l="button",isLoading:s,...r})=>{let o=a?`Dialog__action-button--${a}`:"";return(0,h.jsxs)("button",{className:(0,m.A)("Dialog__action-button",o,n),type:l,"aria-label":e,onClick:t,...r,children:[i&&(0,h.jsx)("div",{style:s?{visibility:"hidden"}:{},children:i}),(0,h.jsx)("div",{style:s?{visibility:"hidden"}:{},children:e}),s&&(0,h.jsx)("div",{style:{position:"absolute",inset:0},children:(0,h.jsx)(W,{})})]})},n_=e=>{let{onConfirm:t,onCancel:n,children:i,confirmText:a=z("buttons.confirm"),cancelText:l=z("buttons.cancel"),className:s="",...r}=e,o=s2(),d=j(n0),{container:c}=sJ();return(0,h.jsxs)(n4,{onCloseRequest:n,size:"small",...r,className:`confirm-dialog ${s}`,children:[i,(0,h.jsxs)("div",{className:"confirm-dialog-buttons",children:[(0,h.jsx)(nP,{label:l,onClick:()=>{o({openMenu:null}),d(!1),(0,p.flushSync)(()=>{n()}),c?.focus()}}),(0,h.jsx)(nP,{label:a,onClick:()=>{o({openMenu:null}),d(!1),(0,p.flushSync)(()=>{t()}),c?.focus()},actionType:"danger"})]})]})},nR=class{static has(e){try{return!!window.localStorage.getItem(e)}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),!1}}static get(e){try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):null}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),null}}};(0,r.d)(nR,"set",(e,t)=>{try{return window.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return console.warn(`localStorage.setItem error: ${e.message}`),!1}}),(0,r.d)(nR,"delete",e=>{try{window.localStorage.removeItem(e)}catch(e){console.warn(`localStorage.removeItem error: ${e.message}`)}});var nO=async e=>{let t=Math.round(8),n=Math.max(Math.round(2),2),a=(0,i.hb)(e,6),l=document.createElement("canvas");l.width=128*a[0].length+(a[0].length+1)*(2*t)-2*t,l.height=128*a.length+(a.length+1)*(2*t)-2*t;let s=l.getContext("2d");for(let[a,r]of(s.fillStyle=b.white,s.fillRect(0,0,l.width,l.height),e.entries())){let e=await (0,i.pi)({elements:r.elements,files:null,maxWidthOrHeight:128}),{width:l,height:o}=e,d=Math.floor(a/6)*(128+2*t),c=a%6*(128+2*t);s.drawImage(e,c+(128-l)/2+t,d+(128-o)/2+t),s.lineWidth=n,s.strokeStyle=b.gray[4],s.strokeRect(c+t/2,d+t/2,128+t,128+t)}return await (0,i.Eh)(new File([await (0,i.yh)(l)],"preview",{type:i.T.png}),{outputType:i.T.jpg,maxWidthOrHeight:5e3})},nF=({libItem:e,appState:t,index:n,onChange:a,onRemove:l})=>{let s=(0,o.useRef)(null),r=(0,o.useRef)(null);return(0,o.useEffect)(()=>{let n=s.current;n&&(async()=>{n.innerHTML=(await (0,i.ri)({elements:e.elements,appState:{...t,viewBackgroundColor:b.white,exportBackground:!0},files:null,skipInliningFonts:!0})).outerHTML})()},[e.elements,t]),(0,h.jsxs)("div",{className:"single-library-item",children:["published"===e.status&&(0,h.jsx)("span",{className:"single-library-item-status",children:z("labels.statusPublished")}),(0,h.jsx)("div",{ref:s,className:"single-library-item__svg"}),(0,h.jsx)(Y,{"aria-label":z("buttons.remove"),type:"button",icon:i.ge,className:"single-library-item--remove",onClick:l.bind(null,e.id),title:z("buttons.remove")}),(0,h.jsxs)("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[(0,h.jsxs)("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[(0,h.jsxs)("div",{style:{padding:"0.5em 0"},children:[(0,h.jsx)("span",{style:{fontWeight:500,color:b.gray[6]},children:z("publishDialog.itemName")}),(0,h.jsx)("span",{"aria-hidden":"true",className:"required",children:"*"})]}),(0,h.jsx)("input",{type:"text",ref:r,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:e=>{a(e.target.value,n)}})]}),(0,h.jsx)("span",{className:"error",children:e.error})]})]})},nz=({onClose:e,libraryItems:t,appState:n,onSuccess:l,onError:s,updateItemsInStorage:r,onRemove:d})=>{let c,[m,p]=(0,o.useState)({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[u,g]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=nR.get(i.Ba.PUBLISH_LIBRARY);e&&p(e)},[]);let[f,b]=(0,o.useState)(t.slice());(0,o.useEffect)(()=>{b(t.slice())},[t]);let x=e=>{p({...m,[e.target.name]:e.target.value})},E=async e=>{e.preventDefault(),g(!0);let t=[],n=!1;if(f.forEach(e=>{let i="";e.name||(i=z("publishDialog.errors.required"),n=!0),t.push({...e,error:i})}),n){b(t),g(!1);return}let r=await nO(f),o=new Blob([JSON.stringify({type:i.V.excalidrawLibrary,version:i.qa.excalidrawLibrary,source:i.W,libraryItems:f},null,2)],{type:"application/json"}),d=new FormData;d.append("excalidrawLib",o),d.append("previewImage",r),d.append("previewImageType",r.type),d.append("title",m.name),d.append("authorName",m.authorName),d.append("githubHandle",m.githubHandle),d.append("name",m.name),d.append("description",m.description),d.append("twitterHandle",m.twitterHandle),d.append("website",m.website),fetch(`${a.a.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:d}).then(e=>e.ok?e.json().then(({url:e})=>{nR.delete(i.Ba.PUBLISH_LIBRARY),l({url:e,authorName:m.authorName,items:f})}):e.json().catch(()=>{throw Error(e.statusText||"something went wrong")}).then(t=>{throw Error(t.message||e.statusText||"something went wrong")}),e=>{console.error(e),s(e),g(!1)}).catch(e=>{console.error(e),s(e),g(!1)})},y=(0,o.useCallback)(()=>{r(f),nR.set(i.Ba.PUBLISH_LIBRARY,m),e()},[f,e,r,m]),v=!!t.length,w=t.some(e=>"published"===e.status);return(0,h.jsx)(n4,{onCloseRequest:y,title:z("publishDialog.title"),className:"publish-library",children:v?(0,h.jsxs)("form",{onSubmit:E,children:[(0,h.jsx)("div",{className:"publish-library-note",children:(0,h.jsx)(nA,{i18nKey:"publishDialog.noteDescription",link:e=>(0,h.jsx)("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:e})})}),(0,h.jsx)("span",{className:"publish-library-note",children:(0,h.jsx)(nA,{i18nKey:"publishDialog.noteGuidelines",link:e=>(0,h.jsx)("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:e})})}),(0,h.jsx)("div",{className:"publish-library-note",children:z("publishDialog.noteItems")}),w&&(0,h.jsx)("span",{className:"publish-library-note publish-library-warning",children:z("publishDialog.republishWarning")}),(c=[],f.forEach((e,t)=>{c.push((0,h.jsx)("div",{className:"single-library-item-wrapper",children:(0,h.jsx)(nF,{libItem:e,appState:n,index:t,onChange:(e,t)=>{let n=f.slice();n[t].name=e,b(n)},onRemove:d})},t))}),(0,h.jsx)("div",{className:"selected-library-items",children:c})),(0,h.jsxs)("div",{className:"publish-library__fields",children:[(0,h.jsxs)("label",{children:[(0,h.jsxs)("div",{children:[(0,h.jsx)("span",{children:z("publishDialog.libraryName")}),(0,h.jsx)("span",{"aria-hidden":"true",className:"required",children:"*"})]}),(0,h.jsx)("input",{type:"text",name:"name",required:!0,value:m.name,onChange:x,placeholder:z("publishDialog.placeholder.libraryName")})]}),(0,h.jsxs)("label",{style:{alignItems:"flex-start"},children:[(0,h.jsxs)("div",{children:[(0,h.jsx)("span",{children:z("publishDialog.libraryDesc")}),(0,h.jsx)("span",{"aria-hidden":"true",className:"required",children:"*"})]}),(0,h.jsx)("textarea",{name:"description",rows:4,required:!0,value:m.description,onChange:x,placeholder:z("publishDialog.placeholder.libraryDesc")})]}),(0,h.jsxs)("label",{children:[(0,h.jsxs)("div",{children:[(0,h.jsx)("span",{children:z("publishDialog.authorName")}),(0,h.jsx)("span",{"aria-hidden":"true",className:"required",children:"*"})]}),(0,h.jsx)("input",{type:"text",name:"authorName",required:!0,value:m.authorName,onChange:x,placeholder:z("publishDialog.placeholder.authorName")})]}),(0,h.jsxs)("label",{children:[(0,h.jsx)("span",{children:z("publishDialog.githubUsername")}),(0,h.jsx)("input",{type:"text",name:"githubHandle",value:m.githubHandle,onChange:x,placeholder:z("publishDialog.placeholder.githubHandle")})]}),(0,h.jsxs)("label",{children:[(0,h.jsx)("span",{children:z("publishDialog.twitterUsername")}),(0,h.jsx)("input",{type:"text",name:"twitterHandle",value:m.twitterHandle,onChange:x,placeholder:z("publishDialog.placeholder.twitterHandle")})]}),(0,h.jsxs)("label",{children:[(0,h.jsx)("span",{children:z("publishDialog.website")}),(0,h.jsx)("input",{type:"text",name:"website",pattern:"https?://.+",title:z("publishDialog.errors.website"),value:m.website,onChange:x,placeholder:z("publishDialog.placeholder.website")})]}),(0,h.jsx)("span",{className:"publish-library-note",children:(0,h.jsx)(nA,{i18nKey:"publishDialog.noteLicense",link:e=>(0,h.jsx)("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:e})})})]}),(0,h.jsxs)("div",{className:"publish-library__buttons",children:[(0,h.jsx)(nP,{label:z("buttons.cancel"),onClick:y,"data-testid":"cancel-clear-canvas-button"}),(0,h.jsx)(nP,{type:"submit",label:z("buttons.submit"),actionType:"primary",isLoading:u})]})]}):(0,h.jsx)("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:z("publishDialog.atleastOneLibItem")})})},nU=({className:e="",children:t,onToggle:n,title:i,...a})=>{let l=sq(),s=(0,m.A)(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":l.editor.isMobile}).trim();return(0,h.jsx)("button",{"data-prevent-outside-click":!0,className:s,onClick:n,type:"button","data-testid":"dropdown-menu-button",title:i,...a,children:t})};nU.displayName="DropdownMenuTrigger";var nB=()=>(0,h.jsx)("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}});nB.displayName="DropdownMenuSeparator";var nW=({children:e,onClickOutside:t,className:n="",onSelect:a,style:l})=>{let s=sq(),r=(0,o.useRef)(null),d=eM({onClickOutside:t});eT(r,()=>{d.onClickOutside?.()}),(0,o.useEffect)(()=>{let e=e=>{e.key===i.hg.ESCAPE&&(e.stopImmediatePropagation(),d.onClickOutside?.())},t={capture:!0};return document.addEventListener("keydown",e,t),()=>{document.removeEventListener("keydown",e,t)}},[d]);let c=(0,m.A)(`dropdown-menu ${n}`,{"dropdown-menu--mobile":s.editor.isMobile}).trim();return(0,h.jsx)(eK.Provider,{value:{onSelect:a},children:(0,h.jsx)("div",{ref:r,className:c,style:l,"data-testid":"dropdown-menu",children:s.editor.isMobile?(0,h.jsx)(nj,{className:"dropdown-menu-container",children:e}):(0,h.jsx)(eA,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};nW.displayName="DropdownMenuContent";var nH=({icon:e,shortcut:t,href:n,children:i,onSelect:a,className:l="",selected:s,rel:r="noreferrer",...o})=>{let d=eX(o.onClick,a);return(0,h.jsx)("a",{...o,href:n,target:"_blank",rel:"noreferrer",className:eZ(l,s),title:o.title??o["aria-label"],onClick:d,children:(0,h.jsx)(eQ,{icon:e,shortcut:t,children:i})})};nH.displayName="DropdownMenuItemLink";var n$=({children:e,open:t})=>{let n=o.Children.toArray(e).find(e=>o.isValidElement(e)&&"string"!=typeof e.type&&e?.type.displayName&&"DropdownMenuTrigger"===e.type.displayName)||null,i=o.Children.toArray(e).find(e=>o.isValidElement(e)&&"string"!=typeof e.type&&e?.type.displayName&&"DropdownMenuContent"===e.type.displayName)||null;return(0,h.jsxs)(h.Fragment,{children:[n,t&&i]})};n$.Trigger=nU,n$.Content=nW,n$.Item=eq,n$.ItemLink=nH,n$.ItemCustom=({children:e,className:t="",selected:n,...i})=>(0,h.jsx)("div",{...i,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${n?"dropdown-menu-item--selected":""}`.trim(),children:e}),n$.Group=eV,n$.Separator=nB,n$.displayName="DropdownMenu";var nY=({setAppState:e,selectedItems:t,library:n,onRemoveFromLibrary:a,resetLibrary:l,onSelectItems:s,appState:r,className:d})=>{let c,p,u,[g]=C(nE),[f,b]=C(n0),[x,E]=(0,o.useState)(!1),y=!!t.length,v=y?g.libraryItems.filter(e=>t.includes(e.id)):g.libraryItems,w=y?z("buttons.remove"):z("buttons.resetLibrary"),[S,k]=(0,o.useState)(!1),[j,I]=(0,o.useState)(null),T=(0,o.useCallback)(()=>(0,h.jsxs)(n4,{onCloseRequest:()=>I(null),title:z("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[(0,h.jsx)("p",{children:(0,h.jsx)(nA,{i18nKey:"publishSuccessDialog.content",authorName:j.authorName,link:e=>(0,h.jsx)("a",{href:j?.url,target:"_blank",rel:"noopener noreferrer",children:e})})}),(0,h.jsx)(Y,{type:"button",title:z("buttons.close"),"aria-label":z("buttons.close"),label:z("buttons.close"),onClick:()=>I(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[I,j]),M=async()=>{try{await n.updateLibrary({libraryItems:(0,i.fh)({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(t){if(t?.name==="AbortError")return void console.warn(t);e({errorMessage:z("errors.importLibraryError")})}},D=async()=>{let t=y?v:await n.getLatestLibrary();(0,i.Nh)(t).catch(i.pb).catch(t=>{e({errorMessage:t.message})})};return(0,h.jsxs)("div",{className:(0,m.A)("library-menu-dropdown-container",d),children:[(0,h.jsxs)(n$,{open:f,children:[(0,h.jsx)(n$.Trigger,{onToggle:()=>b(!f),children:i.hd}),(0,h.jsxs)(n$.Content,{onClickOutside:()=>b(!1),onSelect:()=>b(!1),className:"library-menu",children:[!y&&(0,h.jsx)(n$.Item,{onSelect:M,icon:i.Ld,"data-testid":"lib-dropdown--load",children:z("buttons.load")}),!!v.length&&(0,h.jsx)(n$.Item,{onSelect:D,icon:i.Ad,"data-testid":"lib-dropdown--export",children:z("buttons.export")}),!!v.length&&(0,h.jsx)(n$.Item,{onSelect:()=>E(!0),icon:i.ud,children:w}),y&&(0,h.jsx)(n$.Item,{icon:i.Xe,onSelect:()=>k(!0),"data-testid":"lib-dropdown--remove",children:z("buttons.publishLibrary")})]})]}),t.length>0&&(0,h.jsx)("div",{className:"library-actions-counter",children:t.length}),x&&(c=t.length?z("alerts.removeItemsFromsLibrary",{count:t.length}):z("alerts.resetLibrary"),p=t.length?z("confirmDialog.removeItemsFromLib"):z("confirmDialog.resetLibrary"),(0,h.jsx)(n_,{onConfirm:()=>{t.length?a():l(),E(!1)},onCancel:()=>{E(!1)},title:p,children:(0,h.jsx)("p",{children:c})})),S&&(0,h.jsx)(nz,{onClose:()=>k(!1),libraryItems:(u=g.libraryItems,u.filter(e=>t.includes(e.id))),appState:r,onSuccess:e=>{var i;let a;return i=g.libraryItems,k(!1),I({url:e.url,authorName:e.authorName}),void((a=i.slice()).forEach(e=>{t.includes(e.id)&&(e.status="published")}),n.setLibrary(a))},onError:e=>window.alert(e),updateItemsInStorage:()=>n.setLibrary(g.libraryItems),onRemove:e=>s(t.filter(t=>t!==e))}),j&&T()]})},nG=({selectedItems:e,onSelectItems:t,className:n})=>{let{library:i}=sX(),{clearLibraryCache:a,deleteItemsFromLibraryCache:l}=nf(),s=o.useContext(ej),r=s2(),[d]=C(nE),c=async n=>{let a=n.filter(t=>!e.includes(t.id));i.setLibrary(a).catch(()=>{r({errorMessage:z("alerts.errorRemovingFromLibrary")})}),l(e),t([])};return(0,h.jsx)(nY,{appState:s,setAppState:r,selectedItems:e,onSelectItems:t,library:i,onRemoveFromLibrary:()=>c(d.libraryItems),resetLibrary:()=>{i.resetLibrary(),a()},className:n})},nV=(0,o.memo)(({id:e,elements:t,isPending:n,onClick:a,selected:l,onToggle:s,onDrag:r,svgCache:d})=>{let c=(0,o.useRef)(null),p=((e,t,n)=>{let[i,a]=(0,o.useState)();return(0,o.useEffect)(()=>{if(t)if(e){let i=n.get(e);i?a(i):(async()=>{let i=await ng(t);i.querySelector(".style-fonts")?.remove(),i&&(n.set(e,i),a(i))})()}else(async()=>{a(await ng(t))})()},[e,t,n,a]),i})(e,t,d);(0,o.useEffect)(()=>{let e=c.current;if(e)return p&&(e.innerHTML=p.outerHTML),()=>{e.innerHTML=""}},[p]);let[u,g]=(0,o.useState)(!1),f=sq().editor.isMobile,b=n&&(0,h.jsx)("div",{className:"library-unit__adder",children:i.gd});return(0,h.jsxs)("div",{className:(0,m.A)("library-unit",{"library-unit__active":t,"library-unit--hover":t&&u,"library-unit--selected":l,"library-unit--skeleton":!p}),onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[(0,h.jsx)("div",{className:(0,m.A)("library-unit__dragger",{"library-unit__pulse":!!n}),ref:c,draggable:!!t,onClick:t||n?t=>{e&&t.shiftKey?s(e,t):a(e)}:void 0,onDragStart:t=>{e?(g(!1),r(e,t)):t.preventDefault()}}),b,e&&t&&(u||f||l)&&(0,h.jsx)(tw,{checked:l,onChange:(t,n)=>s(e,n),className:"library-unit__checkbox"})]})}),nK=()=>(0,h.jsx)("div",{className:"library-unit library-unit--skeleton"}),nZ=o.useTransition||function(){return[!1,(0,o.useCallback)(e=>e(),[])]},nX=({children:e})=>(0,h.jsx)("div",{className:"library-menu-items-container__grid",children:e}),nQ=(0,o.memo)(({items:e,onItemSelectToggle:t,onItemDrag:n,isItemSelected:i,onClick:a,svgCache:l,itemsRenderedPerBatch:s})=>{let[,r]=nZ(),[d,c]=(0,o.useState)(0);return(0,o.useEffect)(()=>{d<e.length&&r(()=>{c(d+s)})},[d,e.length,r,s]),(0,h.jsx)(h.Fragment,{children:e.map((e,s)=>s<d?(0,h.jsx)(nV,{elements:e?.elements,isPending:!e?.id&&!!e?.elements,onClick:a,svgCache:l,id:e?.id,selected:i(e.id),onToggle:t,onDrag:n},e?.id??s):(0,h.jsx)(nK,{},s))})}),nq=(0,d.eU)(0);function nJ({isLoading:e,libraryItems:t,onAddToLibrary:n,onInsertLibraryItems:a,pendingElements:l,theme:s,id:r,libraryReturnUrl:d,onSelectItems:c,selectedItems:m}){let p=(0,o.useRef)(null),u=(e=>{let[t,n]=C(nq);return(0,o.useEffect)(()=>{let{current:t}=e;if(!t)return;let i=x(()=>{let{scrollTop:e}=t;n(e)},200);return t.addEventListener("scroll",i),()=>{i.cancel(),t.removeEventListener("scroll",i)}},[e,n]),t})(p);(0,o.useEffect)(()=>{u>0&&p.current?.scrollTo(0,u)},[]);let{svgCache:g}=nf(),f=(0,o.useMemo)(()=>t.filter(e=>"published"!==e.status),[t]),b=(0,o.useMemo)(()=>t.filter(e=>"published"===e.status),[t]),E=!t.length&&!l.length,y=!l.length&&!f.length&&!b.length,[v,w]=(0,o.useState)(null),S=(0,o.useCallback)((e,t)=>{let n=!m.includes(e),a=[...f,...b];if(n){if(t.shiftKey&&v){let t=a.findIndex(e=>e.id===v),n=a.findIndex(t=>t.id===e);if(-1===t||-1===n)return void c([...m,e]);let l=(0,i.xb)(m);c(a.reduce((e,i,a)=>((a>=t&&a<=n||l.has(i.id))&&e.push(i.id),e),[]))}else c([...m,e]);w(e)}else w(null),c(m.filter(t=>t!==e))},[v,c,b,m,f]),k=(0,o.useCallback)(e=>(m.includes(e)?t.filter(e=>m.includes(e.id)):t.filter(t=>t.id===e)).map(e=>({...e,elements:(0,i.dg)(e.elements,{randomizeSeed:!0})})),[t,m]),j=(0,o.useCallback)((e,t)=>{t.dataTransfer.setData(i.T.excalidrawlib,(0,i.Mh)(k(e)))},[k]),I=(0,o.useCallback)(e=>!!e&&m.includes(e),[m]),T=(0,o.useCallback)(()=>{n(l)},[l,n]),M=(0,o.useCallback)(e=>{e&&a(k(e))},[k,a]),D=g.size>=t.length?64:17;return(0,h.jsxs)("div",{className:"library-menu-items-container",style:l.length||f.length||b.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!y&&(0,h.jsx)(nG,{selectedItems:m,onSelectItems:c,className:"library-menu-dropdown-container--in-heading"}),(0,h.jsxs)(nj,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:b.length>0?1:"0 1 auto",marginBottom:0},ref:p,children:[(0,h.jsxs)(h.Fragment,{children:[!y&&(0,h.jsx)("div",{className:"library-menu-items-container__header",children:z("labels.personalLib")}),e&&(0,h.jsx)("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:(0,h.jsx)(W,{})}),l.length||f.length?(0,h.jsxs)(nX,{children:[l.length>0&&(0,h.jsx)(nQ,{itemsRenderedPerBatch:D,items:[{id:null,elements:l}],onItemSelectToggle:S,onItemDrag:j,onClick:T,isItemSelected:I,svgCache:g}),(0,h.jsx)(nQ,{itemsRenderedPerBatch:D,items:f,onItemSelectToggle:S,onItemDrag:j,onClick:M,isItemSelected:I,svgCache:g})]}):(0,h.jsxs)("div",{className:"library-menu-items__no-items",children:[(0,h.jsx)("div",{className:"library-menu-items__no-items__label",children:z("library.noItems")}),(0,h.jsx)("div",{className:"library-menu-items__no-items__hint",children:b.length>0?z("library.hint_emptyPrivateLibrary"):z("library.hint_emptyLibrary")})]})]}),(0,h.jsxs)(h.Fragment,{children:[(b.length>0||l.length>0||f.length>0)&&(0,h.jsx)("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:z("labels.excalidrawLib")}),b.length>0?(0,h.jsx)(nX,{children:(0,h.jsx)(nQ,{itemsRenderedPerBatch:D,items:b,onItemSelectToggle:S,onItemDrag:j,onClick:M,isItemSelected:I,svgCache:g})}):f.length>0?(0,h.jsx)("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:z("library.noItems")}):null]}),E&&(0,h.jsx)(nT,{style:{padding:"16px 0",width:"100%"},id:r,libraryReturnUrl:d,theme:s,children:(0,h.jsx)(nG,{selectedItems:m,onSelectItems:c})})]})]})}var n0=(0,d.eU)(!1),n1=({children:e})=>(0,h.jsx)("div",{className:"layer-ui__library",children:e}),n2=(0,o.memo)(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:n,setAppState:a,libraryReturnUrl:l,library:s,id:r,theme:d,selectedItems:c,onSelectItems:m})=>{let[p]=C(nE),u=(0,o.useCallback)(e=>{(async(e,t)=>{for(let t of(ed("element","addToLibrary","ui"),i.za))if(e.some(e=>e.type===t))return a({errorMessage:z(`errors.libraryElementTypeError.${t}`)});let l=[{status:"unpublished",elements:e,id:(0,i.sc)(),created:Date.now()},...t];n(),s.setLibrary(l).catch(()=>{a({errorMessage:z("alerts.errorAddingToLibrary")})})})(e,p.libraryItems)},[n,s,a,p.libraryItems]),g=(0,o.useMemo)(()=>p.libraryItems,[p]);if("loading"===p.status&&!p.isInitialized)return(0,h.jsx)(n1,{children:(0,h.jsx)("div",{className:"layer-ui__library-message",children:(0,h.jsxs)("div",{children:[(0,h.jsx)(W,{size:"2em"}),(0,h.jsx)("span",{children:z("labels.libraryLoadingMessage")})]})})});let f=p.libraryItems.length>0||t.length>0;return(0,h.jsxs)(n1,{children:[(0,h.jsx)(nJ,{isLoading:"loading"===p.status,libraryItems:g,onAddToLibrary:u,onInsertLibraryItems:e,pendingElements:t,id:r,libraryReturnUrl:l,theme:d,onSelectItems:m,selectedItems:c}),f&&(0,h.jsx)(nT,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:r,libraryReturnUrl:l,theme:d})]})}),n3=(e,t)=>({elements:e,pending:(0,i.vk)(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),n5=(0,o.memo)(()=>{let e=sX(),{onInsertElements:t}=e,n=sQ(),a=o.useContext(ej),l=s2(),[s,r]=(0,o.useState)([]),d=(0,o.useMemo)(()=>e.library,[e.library]),c=((e,t)=>{let n=s0(),[a,l]=(0,o.useState)(()=>n3(n,e.selectedElementIds)),s=(0,o.useRef)(new Map);return(0,o.useEffect)(()=>{for(let e of a.pending)s.current.set(e.id,e.version)},[a.pending]),(0,o.useEffect)(()=>{"up"===t.state.cursorButton&&"selection"===t.state.activeTool.type&&l(a=>{if(!(0,i.Hb)(a.selectedElementIds,e.selectedElementIds))return s.current.clear(),n3(n,e.selectedElementIds);let l=t.scene.getNonDeletedElementsMap();for(let t of Object.keys(e.selectedElementIds)){let i=l.get(t)?.version;if(i&&i!==s.current.get(t))return n3(n,e.selectedElementIds)}return a})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,n]),a.pending})(a,e),m=(0,o.useCallback)(e=>{t(nS(e))},[t]),p=(0,o.useCallback)(()=>{l({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[l]);return(0,h.jsx)(n2,{pendingElements:c,onInsertLibraryItems:m,onAddToLibrary:p,setAppState:l,libraryReturnUrl:n.libraryReturnUrl,library:d,id:e.id,theme:a.theme,selectedItems:s,onSelectItems:r})}),n4=e=>{let[t,n]=(()=>{let[e,t]=(0,o.useState)(null);return[e,(0,o.useCallback)(e=>t(e),[])]})(),[a]=(0,o.useState)(document.activeElement),{id:l}=sJ(),s=sq().viewport.isMobile;(0,o.useEffect)(()=>{if(!t)return;let n=(0,i.Gb)(t);setTimeout(()=>{n.length>0&&!1!==e.autofocus&&(n[1]||n[0]).focus()});let a=e=>{if(e.key===i.hg.TAB){let n=(0,i.Gb)(t),{activeElement:a}=document,l=n.findIndex(e=>e===a);0===l&&e.shiftKey?(n[n.length-1].focus(),e.preventDefault()):l!==n.length-1||e.shiftKey||(n[0].focus(),e.preventDefault())}};return t.addEventListener("keydown",a),()=>t.removeEventListener("keydown",a)},[t,e.autofocus]);let r=s2(),d=j(n0),c=()=>{r({openMenu:null}),d(!1),a.focus(),e.onCloseRequest()};return(0,h.jsx)(np,{className:(0,m.A)("Dialog",e.className,{"Dialog--fullscreen":s}),labelledBy:"dialog-title",maxWidth:function(e){if(e&&"number"==typeof e)return e;switch(e){case"small":return 550;case"wide":return 1024;default:return 800}}(e.size),onCloseRequest:c,closeOnClickOutside:e.closeOnClickOutside,children:(0,h.jsxs)(eA,{ref:n,children:[e.title&&(0,h.jsx)("h2",{id:`${l}-dialog-title`,className:"Dialog__title",children:(0,h.jsx)("span",{className:"Dialog__titleContent",children:e.title})}),s&&(0,h.jsx)("button",{className:"Dialog__close",onClick:c,title:z("buttons.close"),"aria-label":z("buttons.close"),type:"button",children:i.ge}),(0,h.jsx)("div",{className:"Dialog__content",children:e.children})]})})},n6=({type:e="button",onSelect:t,selected:n,children:a,className:l="",...s})=>(0,h.jsx)("button",{onClick:(0,i.Ib)(s.onClick,e=>{t()}),type:e,className:(0,m.A)("excalidraw-button",l,{selected:n}),...s,children:a}),n8=(0,o.forwardRef)(({onChange:e,label:t,fullWidth:n,placeholder:a,readonly:l,selectOnRender:s,onKeyDown:r,isRedacted:d=!1,icon:c,className:p,...u},g)=>{let f=(0,o.useRef)(null);(0,o.useImperativeHandle)(g,()=>f.current),(0,o.useLayoutEffect)(()=>{s&&(f.current?.focus(),f.current?.select())},[s]);let[b,x]=(0,o.useState)(!1);return(0,h.jsxs)("div",{className:(0,m.A)("ExcTextField",p,{"ExcTextField--fullWidth":n,"ExcTextField--hasIcon":!!c}),onClick:()=>{f.current?.focus()},children:[c,t&&(0,h.jsx)("div",{className:"ExcTextField__label",children:t}),(0,h.jsxs)("div",{className:(0,m.A)("ExcTextField__input",{"ExcTextField__input--readonly":l}),children:[(0,h.jsx)("input",{className:(0,m.A)({"is-redacted":"value"in u&&u.value&&d&&!b}),readOnly:l,value:"value"in u?u.value:void 0,defaultValue:"defaultValue"in u?u.defaultValue:void 0,placeholder:a,ref:f,onChange:t=>e?.(t.target.value),onKeyDown:r}),d&&(0,h.jsx)(n6,{onSelect:()=>x(!b),style:{border:0,userSelect:"none"},children:b?i.mf:i.lf})]})]})}),n7={toggleTheme:[(0,i.kb)("Shift+Alt+D")],saveScene:[(0,i.kb)("CtrlOrCmd+S")],loadScene:[(0,i.kb)("CtrlOrCmd+O")],clearCanvas:[(0,i.kb)("CtrlOrCmd+Delete")],imageExport:[(0,i.kb)("CtrlOrCmd+Shift+E")],commandPalette:[(0,i.kb)("CtrlOrCmd+/"),(0,i.kb)("CtrlOrCmd+Shift+P")],cut:[(0,i.kb)("CtrlOrCmd+X")],copy:[(0,i.kb)("CtrlOrCmd+C")],paste:[(0,i.kb)("CtrlOrCmd+V")],copyStyles:[(0,i.kb)("CtrlOrCmd+Alt+C")],pasteStyles:[(0,i.kb)("CtrlOrCmd+Alt+V")],selectAll:[(0,i.kb)("CtrlOrCmd+A")],deleteSelectedElements:[(0,i.kb)("Delete")],duplicateSelection:[(0,i.kb)("CtrlOrCmd+D"),(0,i.kb)(`Alt+${z("helpDialog.drag")}`)],sendBackward:[(0,i.kb)("CtrlOrCmd+[")],bringForward:[(0,i.kb)("CtrlOrCmd+]")],sendToBack:[i.l?(0,i.kb)("CtrlOrCmd+Alt+["):(0,i.kb)("CtrlOrCmd+Shift+[")],bringToFront:[i.l?(0,i.kb)("CtrlOrCmd+Alt+]"):(0,i.kb)("CtrlOrCmd+Shift+]")],copyAsPng:[(0,i.kb)("Shift+Alt+C")],group:[(0,i.kb)("CtrlOrCmd+G")],ungroup:[(0,i.kb)("CtrlOrCmd+Shift+G")],gridMode:[(0,i.kb)("CtrlOrCmd+'")],zenMode:[(0,i.kb)("Alt+Z")],objectsSnapMode:[(0,i.kb)("Alt+S")],stats:[(0,i.kb)("Alt+/")],addToLibrary:[],flipHorizontal:[(0,i.kb)("Shift+H")],flipVertical:[(0,i.kb)("Shift+V")],viewMode:[(0,i.kb)("Alt+R")],hyperlink:[(0,i.kb)("CtrlOrCmd+K")],toggleElementLock:[(0,i.kb)("CtrlOrCmd+Shift+L")],resetZoom:[(0,i.kb)("CtrlOrCmd+0")],zoomOut:[(0,i.kb)("CtrlOrCmd+-")],zoomIn:[(0,i.kb)("CtrlOrCmd++")],zoomToFitSelection:[(0,i.kb)("Shift+3")],zoomToFit:[(0,i.kb)("Shift+1")],zoomToFitSelectionInViewport:[(0,i.kb)("Shift+2")],toggleEraserTool:[(0,i.kb)("E")],toggleHandTool:[(0,i.kb)("H")],setFrameAsActiveTool:[(0,i.kb)("F")],saveFileToDisk:[(0,i.kb)("CtrlOrCmd+S")],saveToActiveFile:[(0,i.kb)("CtrlOrCmd+S")],toggleShortcuts:[(0,i.kb)("?")],searchMenu:[(0,i.kb)("CtrlOrCmd+F")],wrapSelectionInFrame:[]},n9=(e,t=0)=>{let n=n7[e];return n&&n.length>0?n[t]||n[0]:""},ie=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g"),it=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ii={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"E",æ:"e",Þ:"T",þ:"t",ß:"s",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"I",ij:"i",Œ:"E",œ:"e",ʼn:"n",ſ:"s"},ia=e=>e.replace(it,e=>ii[e]||e).replace(ie,""),il=o.createContext(null),is=(0,c.l)(),ir=(e,t)=>{let n=t[0]?.type||null;for(let e of t)if(e.type!==n){n=null;break}return(0,i.Wi)(e.activeTool.type)&&"image"!==e.activeTool.type&&"image"!==n&&"frame"!==n&&"magicframe"!==n||t.some(e=>(0,i.Wi)(e.type))},io=(e,t)=>(0,i.Vi)(e.activeTool.type)||t.some(e=>(0,i.Vi)(e.type)),id=({appState:e,elementsMap:t,renderAction:n,app:a})=>{let l=(0,i.wk)(t,e),s=!1;2===l.length&&((0,i.mc)(l[0])||(0,i.mc)(l[1]))&&(s=!0);let r=!!(e.editingTextElement||e.newElement),o=sq(),d="rtl"===document.documentElement.getAttribute("dir"),c=(0,i.Vi)(e.activeTool.type)&&!(0,i.sb)(e.currentItemBackgroundColor)||l.some(e=>(0,i.Vi)(e.type)&&!(0,i.sb)(e.backgroundColor)),m=1===l.length||s,p=!e.editingLinearElement&&1===l.length&&(0,i.cc)(l[0])&&!(0,i.ec)(l[0]),u=!e.croppingElementId&&1===l.length&&(0,i.Wb)(l[0]),g=!s&&tW(e,a);return(0,h.jsxs)("div",{className:"panelColumn",children:[(0,h.jsx)("div",{children:ir(e,l)&&n("changeStrokeColor")}),io(e,l)&&(0,h.jsx)("div",{children:n("changeBackgroundColor")}),c&&n("changeFillStyle"),((0,i.Xi)(e.activeTool.type)||l.some(e=>(0,i.Xi)(e.type)))&&n("changeStrokeWidth"),("freedraw"===e.activeTool.type||l.some(e=>"freedraw"===e.type))&&n("changeStrokeShape"),((0,i.Yi)(e.activeTool.type)||l.some(e=>(0,i.Yi)(e.type)))&&(0,h.jsxs)(h.Fragment,{children:[n("changeStrokeStyle"),n("changeSloppiness")]}),((0,i.Zi)(e.activeTool.type)||l.some(e=>(0,i.Zi)(e.type)))&&(0,h.jsx)(h.Fragment,{children:n("changeRoundness")}),((0,i._i)(e.activeTool.type)||l.some(e=>(0,i._i)(e.type)))&&(0,h.jsx)(h.Fragment,{children:n("changeArrowType")}),("text"===e.activeTool.type||l.some(i._b))&&(0,h.jsxs)(h.Fragment,{children:[n("changeFontFamily"),n("changeFontSize"),("text"===e.activeTool.type||(0,i.Ej)(l,t))&&n("changeTextAlign")]}),(0,i.Dj)(l,t)&&n("changeVerticalAlign"),((0,i.$i)(e.activeTool.type)||l.some(e=>(0,i.$i)(e.type)))&&(0,h.jsx)(h.Fragment,{children:n("changeArrowhead")}),n("changeOpacity"),(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.layers")}),(0,h.jsxs)("div",{className:"buttonList",children:[n("sendToBack"),n("sendBackward"),n("bringForward"),n("bringToFront")]})]}),g&&!s&&(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.align")}),(0,h.jsxs)("div",{className:"buttonList",children:[d?(0,h.jsxs)(h.Fragment,{children:[n("alignRight"),n("alignHorizontallyCentered"),n("alignLeft")]}):(0,h.jsxs)(h.Fragment,{children:[n("alignLeft"),n("alignHorizontallyCentered"),n("alignRight")]}),l.length>2&&n("distributeHorizontally"),(0,h.jsx)("div",{style:{flexBasis:"100%",height:0}}),(0,h.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[n("alignTop"),n("alignVerticallyCentered"),n("alignBottom"),l.length>2&&n("distributeVertically")]})]})]}),!r&&l.length>0&&(0,h.jsxs)("fieldset",{children:[(0,h.jsx)("legend",{children:z("labels.actions")}),(0,h.jsxs)("div",{className:"buttonList",children:[!o.editor.isMobile&&n("duplicateSelection"),!o.editor.isMobile&&n("deleteSelectedElements"),n("group"),n("ungroup"),m&&n("hyperlink"),u&&n("cropEditor"),p&&n("toggleLinearEditor")]})]})]})},ic=({activeTool:e,appState:t,app:n,UIOptions:a})=>{let[l,s]=(0,o.useState)(!1),r="frame"===e.type,d="laser"===e.type,c="embeddable"===e.type,{TTDDialogTriggerTunnel:p}=o.useContext(il);return(0,h.jsxs)(h.Fragment,{children:[i.rg.map(({value:l,icon:s,key:r,numericKey:o,fillable:d},c)=>{if(a.tools?.[l]===!1)return null;let p=z(`toolBar.${l}`),u=r&&(0,i.Ya)("string"==typeof r?r:r[0]),g=u?`${u} ${z("helpDialog.or")} ${o}`:`${o}`;return(0,h.jsx)(Y,{className:(0,m.A)("Shape",{fillable:d}),type:"radio",icon:s,checked:e.type===l,name:"editor-current-shape",title:`${(0,i.Ya)(p)} \u2014 ${g}`,keyBindingLabel:o||u,"aria-label":(0,i.Ya)(p),"aria-keyshortcuts":g,"data-testid":`toolbar-${l}`,onPointerDown:({pointerType:e})=>{t.penDetected||"pen"!==e||n.togglePenMode(!0)},onChange:({pointerType:e})=>{t.activeTool.type!==l&&ed("toolbar",l,"ui"),"image"===l?n.setActiveTool({type:l,insertOnCanvasDirectly:"mouse"!==e}):n.setActiveTool({type:l})}},l)}),(0,h.jsx)("div",{className:"App-toolbar__divider"}),(0,h.jsxs)(n$,{open:l,children:[(0,h.jsx)(n$.Trigger,{className:(0,m.A)("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":r||c||d&&!n.props.isCollaborating}),onToggle:()=>s(!l),title:z("toolBar.extraTools"),children:i.ef}),(0,h.jsxs)(n$.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:[(0,h.jsx)(n$.Item,{onSelect:()=>n.setActiveTool({type:"frame"}),icon:i.ff,shortcut:i.hg.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:r,children:z("toolBar.frame")}),(0,h.jsx)(n$.Item,{onSelect:()=>n.setActiveTool({type:"embeddable"}),icon:i.vd,"data-testid":"toolbar-embeddable",selected:c,children:z("toolBar.embeddable")}),(0,h.jsx)(n$.Item,{onSelect:()=>n.setActiveTool({type:"laser"}),icon:i.if,"data-testid":"toolbar-laser",selected:d,shortcut:i.hg.K.toLocaleUpperCase(),children:z("toolBar.laser")}),(0,h.jsx)("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),!1!==n.props.aiEnabled&&(0,h.jsx)(p.Out,{}),(0,h.jsx)(n$.Item,{onSelect:()=>n.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:i.gf,"data-testid":"toolbar-embeddable",children:z("toolBar.mermaidToExcalidraw")}),!1!==n.props.aiEnabled&&n.plugins.diagramToCode&&(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(n$.Item,{onSelect:()=>n.onMagicframeToolSelect(),icon:i.jf,"data-testid":"toolbar-magicframe",children:[z("toolBar.magicframe"),(0,h.jsx)(n$.Item.Badge,{children:"AI"})]})})]})]})]})},ih=({renderAction:e,zoom:t})=>(0,h.jsx)(nj,{gap:1,className:i.E.ZOOM_ACTIONS,children:(0,h.jsxs)(nC,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),im=({renderAction:e,className:t})=>(0,h.jsxs)("div",{className:`undo-redo-buttons ${t}`,children:[(0,h.jsx)("div",{className:"undo-button-container",children:(0,h.jsx)(tr,{label:z("buttons.undo"),children:e("undo")})}),(0,h.jsx)("div",{className:"redo-button-container",children:(0,h.jsxs)(tr,{label:z("buttons.redo"),children:[" ",e("redo")]})})]}),ip=({actionManager:e,showExitZenModeBtn:t})=>(0,h.jsx)("button",{type:"button",className:(0,m.A)("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(t3),children:z("buttons.exitZenMode")}),iu=({renderAction:e,className:t})=>(0,h.jsx)("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})}),ig=e=>{let t=(0,o.useRef)({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...e)=>t.current.userFn(...e)),t.current.stableFn},ib=(0,d.eU)(null),ix=()=>{let[e,t]=C(ib),n=s3();return e&&"clearCanvas"===e?(0,h.jsx)(n_,{onConfirm:()=>{n.executeAction(to),t(null)},onCancel:()=>t(null),title:z("clearCanvasDialog.title"),children:(0,h.jsxs)("p",{className:"clear-canvas__content",children:[" ",z("alerts.clearReset")]})}):null},iE={};(0,r.c)(iE,{toggleTheme:()=>iy});var iy={...tp,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(tp,"commandPalette")}},iv=(0,i.$c)({name:"copyElementLink",label:"labels.copyElementLink",icon:i._e,trackEvent:{category:"element"},perform:async(e,t,n,a)=>{let l=(0,i.vk)(e,t);try{if(window.location){let n=(0,i.Zh)(l,t);return n?(await (0,i.oi)(a.props.generateLinkForSelection?a.props.generateLinkForSelection(n.id,n.type):(0,i.Yh)(n.id,n.type)),{appState:{toast:{message:z("toast.elementLinkCopied"),closable:!0}},captureUpdate:i.Wg.EVENTUALLY}):{appState:t,elements:e,app:a,captureUpdate:i.Wg.EVENTUALLY}}}catch(e){console.error(e)}return{appState:t,elements:e,app:a,captureUpdate:i.Wg.EVENTUALLY}},predicate:(e,t)=>(0,i._h)((0,i.vk)(e,t))}),iw=(0,i.$c)({name:"linkToElement",label:"labels.linkToElement",icon:i.Pf,perform:(e,t,n,a)=>{let l=(0,i.vk)(e,t);return 1===l.length&&(0,i._h)(l)?{appState:{...t,openDialog:{name:"elementLinkSelector",sourceElementId:(0,i.vk)(e,t)[0].id}},captureUpdate:i.Wg.IMMEDIATELY}:{elements:e,appState:t,app:a,captureUpdate:i.Wg.EVENTUALLY}},predicate:(e,t,n,a)=>{let l=(0,i.vk)(e,t);return t.openDialog?.name!=="elementLinkSelector"&&1===l.length&&(0,i._h)(l)},trackEvent:!1}),iS=(0,d.eU)(null),ik="Export",iC="Tools",ij="Editor",iI="Elements",iT=({shortcut:e,className:t,children:n})=>{let i=e.replace("++","+$").split("+");return(0,h.jsxs)("div",{className:(0,m.A)("shortcut",t),children:[i.map((e,t)=>(0,h.jsx)("div",{className:"shortcut-wrapper",children:(0,h.jsx)("div",{className:"shortcut-key",children:"$"===e?"+":e})},e)),(0,h.jsx)("div",{className:"shortcut-desc",children:n})]})},iM=e=>!e.altKey&&e[i.hg.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===i.hg.P||e.key===i.hg.SLASH);function iD({customCommandPaletteItems:e}){let t=sX(),n=o.useContext(ej),a=s2(),l=sQ(),s=s3(),[r,d]=C(iS),[c,m]=(0,o.useState)(null),p=(0,o.useRef)(null),u=eM({uiAppState:n,customCommandPaletteItems:e,appProps:l});(0,o.useEffect)(()=>{let{uiAppState:e,customCommandPaletteItems:n,appProps:l}=u,o=n=>{let i="";return n.label&&(i="function"==typeof n.label?z(n.label(t.scene.getNonDeletedElements(),e,t)):z(n.label)),i},c=n=>"function"==typeof n.icon?n.icon(e,t.scene.getNonDeletedElements()):n.icon,h=(e,t,n)=>{let i={label:o(e),icon:c(e),category:t,shortcut:n9(e.name),keywords:e.keywords,predicate:e.predicate,viewMode:e.viewMode,perform:()=>{s.executeAction(e,"commandPalette")}};return n?n(i,e):i};if(e&&t.scene&&s){let p=[s.actions.group,s.actions.ungroup,s.actions.cut,s.actions.copy,s.actions.deleteSelectedElements,s.actions.wrapSelectionInFrame,s.actions.copyStyles,s.actions.pasteStyles,s.actions.bringToFront,s.actions.bringForward,s.actions.sendBackward,s.actions.sendToBack,s.actions.alignTop,s.actions.alignBottom,s.actions.alignLeft,s.actions.alignRight,s.actions.alignVerticallyCentered,s.actions.alignHorizontallyCentered,s.actions.duplicateSelection,s.actions.flipHorizontal,s.actions.flipVertical,s.actions.zoomToFitSelection,s.actions.zoomToFitSelectionInViewport,s.actions.increaseFontSize,s.actions.decreaseFontSize,s.actions.toggleLinearEditor,s.actions.cropEditor,nd,iv,iw].map(e=>h(e,iI,(e,t)=>({...e,predicate:t.predicate?t.predicate:(e,t,n,a)=>(0,i.vk)(e,t).length>0}))),u=[s.actions.toggleHandTool,s.actions.setFrameAsActiveTool].map(e=>h(e,iC)),g=[s.actions.undo,s.actions.redo,s.actions.zoomIn,s.actions.zoomOut,s.actions.resetZoom,s.actions.zoomToFit,s.actions.zenMode,s.actions.viewMode,s.actions.gridMode,s.actions.objectsSnapMode,s.actions.toggleShortcuts,s.actions.selectAll,s.actions.toggleElementLock,s.actions.unlockAllElements,s.actions.stats].map(e=>h(e,ij)),f=[s.actions.saveToActiveFile,s.actions.saveFileToDisk,s.actions.copyAsPng,s.actions.copyAsSvg].map(e=>h(e,ik)),b=[...p,...g,{label:o(to),icon:c(to),shortcut:n9(to.name),category:ij,keywords:["delete","destroy"],viewMode:!1,perform:()=>{D.set(ib,"clearCanvas")}},{label:z("buttons.exportImage"),category:ik,icon:i.Od,shortcut:n9("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{a({openDialog:{name:"imageExport"}})}},...f,{label:z("toolBar.library"),category:"App",icon:i.fd,viewMode:!1,perform:()=>{e.openSidebar?a({openSidebar:null}):a({openSidebar:{name:i.ya.name,tab:i.ya.defaultTab}})}},{label:z("search.title"),category:"App",icon:i.pf,viewMode:!0,perform:()=>{s.executeAction(iA)}},{label:z("labels.changeStroke"),keywords:["color","outline"],category:iI,icon:i.Nd,viewMode:!1,predicate:(e,t)=>{let n=(0,i.vk)(e,t);return n.length>0&&ir(t,n)},perform:()=>{a(e=>({openMenu:"shape"===e.openMenu?null:"shape",openPopup:"elementStroke"}))}},{label:z("labels.changeBackground"),keywords:["color","fill"],icon:i.Nd,category:iI,viewMode:!1,predicate:(e,t)=>{let n=(0,i.vk)(e,t);return n.length>0&&io(t,n)},perform:()=>{a(e=>({openMenu:"shape"===e.openMenu?null:"shape",openPopup:"elementBackground"}))}},{label:z("labels.canvasBackground"),keywords:["color"],icon:i.Nd,category:ij,viewMode:!1,perform:()=>{a(e=>({openMenu:"canvas"===e.openMenu?null:"canvas",openPopup:"canvasBackground"}))}},...i.rg.reduce((e,n)=>{let{value:a,icon:s,key:r,numericKey:o}=n;if(l.UIOptions.tools?.[a]===!1)return e;let d=r&&(0,i.Ya)("string"==typeof r?r:r[0])||o,c={label:z(`toolBar.${a}`),category:iC,shortcut:d,icon:s,keywords:["toolbar"],viewMode:!1,perform:({event:e})=>{"image"===a?t.setActiveTool({type:a,insertOnCanvasDirectly:"keydown"===e.type}):t.setActiveTool({type:a})}};return e.push(c),e},[]),...u,{label:z("toolBar.lock"),category:iC,icon:e.activeTool.locked?i.kd:i.jd,shortcut:i.hg.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${z("labels.textToDiagram")}...`,category:iC,icon:i.of,viewMode:!1,predicate:l.aiEnabled,perform:()=>{a(e=>({...e,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${z("toolBar.mermaidToExcalidraw")}...`,category:iC,icon:i.gf,viewMode:!1,predicate:l.aiEnabled,perform:()=>{a(e=>({...e,openDialog:{name:"ttd",tab:"mermaid"}}))}},...n||[]].map(e=>({...e,icon:e.icon||i.tf,order:e.order??(e=>{switch(e){case"App":return 1;case ik:return 2;case ij:return 3;case iC:return 4;case iI:return 5;case"Links":return 6;default:return 10}})(e.category),haystack:`${ia(e.label.toLocaleLowerCase())} ${e.keywords?.join(" ")||""}`}));m(b),d(b.find(e=>e.label===r?.label)??null)}},[u,t,s,m,r?.label,d,a]);let[g,f]=(0,o.useState)(""),[b,x]=(0,o.useState)(null),[y,v]=(0,o.useState)({}),w=e=>{a({openDialog:null},e),f("")},S=(e,t)=>{n.openDialog?.name==="commandPalette"&&(t.stopPropagation(),t.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{e.perform({actionManager:s,event:t}),d(e),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},k=ig(e=>(!1!==e.viewMode||!n.viewModeEnabled)&&("function"==typeof e.predicate?e.predicate(t.scene.getNonDeletedElements(),n,l,t):void 0===e.predicate||e.predicate)),j=ig(e=>{let t=(0,i.ab)(e.target)||iM(e)||e.key===i.hg.ESCAPE;if(t&&e.key!==i.hg.ARROW_UP&&e.key!==i.hg.ARROW_DOWN&&e.key!==i.hg.ENTER)return;let n=Object.values(y).flat(),a=r&&!g&&k(r);if(e.key===i.hg.ARROW_UP){let t;e.preventDefault();let i=n.findIndex(e=>e.label===b?.label);if(a){if(0===i)return void x(r);if(b===r){let e=n[n.length-1];e&&x(e);return}}t=-1===i||0===i?n.length-1:(i-1)%n.length;let l=n[t];l&&x(l);return}if(e.key===i.hg.ARROW_DOWN){e.preventDefault();let t=n.findIndex(e=>e.label===b?.label);if(a){if(!b||t===n.length-1)return void x(r);if(b===r){let e=n[0];e&&x(e);return}}let i=(t+1)%n.length,l=n[i];l&&x(l);return}if(e.key===i.hg.ENTER&&b&&setTimeout(()=>{S(b,e)}),!t){if(e.stopPropagation(),/^[a-zA-Z0-9]$/.test(e.key))return void p?.current?.focus();e.preventDefault()}});return(0,o.useEffect)(()=>(window.addEventListener("keydown",j,{capture:!0}),()=>window.removeEventListener("keydown",j,{capture:!0})),[j]),(0,o.useEffect)(()=>{if(!c)return;let e=e=>{let t={};for(let n of e)t[n.category]?t[n.category].push(n):t[n.category]=[n];return t},t=c.filter(k).sort((e,t)=>e.order-t.order),n=!g&&r&&k(r);if(!g){v(e(n?t.filter(e=>e.label!==r?.label):t)),x(n?r:t[0]||null);return}let i=ia(g.toLocaleLowerCase().replace(/[<>_| -]/g,""));v(e(t=E.filter(i,t,{extract:e=>e.haystack}).sort((e,t)=>t.score-e.score).map(e=>e.original))),x(t[0]??null)},[g,c,k,r]),(0,h.jsxs)(n4,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[(0,h.jsx)(n8,{value:g,placeholder:z("commandPalette.search.placeholder"),onChange:e=>{f(e)},selectOnRender:!0,ref:p}),!t.device.viewport.isMobile&&(0,h.jsxs)("div",{className:"shortcuts-wrapper",children:[(0,h.jsx)(iT,{shortcut:"↑↓",children:z("commandPalette.shortcuts.select")}),(0,h.jsx)(iT,{shortcut:"↵",children:z("commandPalette.shortcuts.confirm")}),(0,h.jsx)(iT,{shortcut:(0,i.kb)("Esc"),children:z("commandPalette.shortcuts.close")})]}),(0,h.jsxs)("div",{className:"commands",children:[r&&!g&&(0,h.jsxs)("div",{className:"command-category",children:[(0,h.jsxs)("div",{className:"command-category-title",children:[z("commandPalette.recents"),(0,h.jsx)("div",{className:"icon",style:{marginLeft:"6px"},children:i.qf})]}),(0,h.jsx)(iL,{command:r,isSelected:r.label===b?.label,onClick:e=>S(r,e),disabled:!k(r),onMouseMove:()=>x(r),showShortcut:!t.device.viewport.isMobile,appState:n})]}),Object.keys(y).length>0?Object.keys(y).map((e,i)=>(0,h.jsxs)("div",{className:"command-category",children:[(0,h.jsx)("div",{className:"command-category-title",children:e}),y[e].map(e=>(0,h.jsx)(iL,{command:e,isSelected:e.label===b?.label,onClick:t=>S(e,t),onMouseMove:()=>x(e),showShortcut:!t.device.viewport.isMobile,appState:n},e.label))]},e)):c?(0,h.jsxs)("div",{className:"no-match",children:[(0,h.jsx)("div",{className:"icon",children:i.pf})," ",z("commandPalette.search.noMatch")]}):null]})]})}Object.assign(e=>{let t=o.useContext(ej),n=s2();return(0,o.useEffect)(()=>{let e=e=>{iM(e)&&(e.preventDefault(),e.stopPropagation(),n(e=>{let t=e.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return t&&ed("command_palette","open","shortcut"),{openDialog:t}}))};return window.addEventListener("keydown",e,{capture:!0}),()=>window.removeEventListener("keydown",e,{capture:!0})},[n]),t.openDialog?.name!=="commandPalette"?null:(0,h.jsx)(iD,{...e})},{defaultItems:iE});var iL=({command:e,isSelected:t,disabled:n,onMouseMove:i,onClick:a,showShortcut:l,appState:s})=>{let r=()=>{};return(0,h.jsxs)("div",{className:(0,m.A)("command-item",{"item-selected":t,"item-disabled":n}),ref:e=>{t&&!n&&e?.scrollIntoView?.({block:"nearest"})},onClick:n?r:a,onMouseMove:n?r:i,title:n?z("commandPalette.itemNotAvailable"):"",children:[(0,h.jsxs)("div",{className:"name",children:[e.icon&&(0,h.jsx)(eU,{icon:"function"==typeof e.icon?e.icon(s):e.icon}),e.label]}),l&&e.shortcut&&(0,h.jsx)(iT,{shortcut:e.shortcut})]})},iN=(0,i.$c)({name:"toggleLinearEditor",category:iI,label:(e,t,n)=>n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,t,n,a)=>{let l=a.scene.getSelectedElements(t);return!!(!t.editingLinearElement&&1===l.length&&(0,i.cc)(l[0])&&!(0,i.ec)(l[0]))},perform(e,t,n,a){let l=a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],s=t.editingLinearElement?.elementId===l.id?null:new i.pj(l);return{appState:{...t,editingLinearElement:s},captureUpdate:i.Wg.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let a=z("arrow"===n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0].type?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return(0,h.jsx)(Y,{type:"button",icon:i.Hf,title:a,"aria-label":a,onClick:()=>t(null)})}}),iA=(0,i.$c)({name:"searchMenu",icon:i.pf,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,t,n,a){if(t.openSidebar?.name===i.ya.name&&t.openSidebar.tab===i.xa){let e=a.excalidrawContainerValue.container?.querySelector(`.${i.E.SEARCH_MENU_INPUT_WRAPPER} input`);return e?.matches(":focus")?{appState:{...t,openSidebar:null},captureUpdate:i.Wg.EVENTUALLY}:(e?.focus(),e?.select(),!1)}return{appState:{...t,openSidebar:{name:i.ya.name,tab:i.xa},openDialog:null},captureUpdate:i.Wg.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>void 0===n.gridModeEnabled,keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.F}),iP=(0,i.$c)({name:"cropEditor",label:"helpDialog.cropStart",icon:i.Of,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,t,n,a){let l=a.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...t,isCropping:!1,croppingElementId:l.id},captureUpdate:i.Wg.IMMEDIATELY}},predicate:(e,t,n,a)=>{let l=a.scene.getSelectedElements(t);return!!(!t.croppingElementId&&1===l.length&&(0,i.Wb)(l[0]))},PanelComponent:({appState:e,updateData:t,app:n})=>{let a=z("helpDialog.cropStart");return(0,h.jsx)(Y,{type:"button",icon:i.Of,title:a,"aria-label":a,onClick:()=>t(null)})}}),i_=class{constructor(e=!0,t=!0){this.isUndoStackEmpty=e,this.isRedoStackEmpty=t}},iR=class e{constructor(){(0,r.d)(this,"onHistoryChangedEmitter",new i.Vg),(0,r.d)(this,"undoStack",[]),(0,r.d)(this,"redoStack",[])}get isUndoStackEmpty(){return 0===this.undoStack.length}get isRedoStackEmpty(){return 0===this.redoStack.length}clear(){this.undoStack.length=0,this.redoStack.length=0}record(e,t){let n=iO.create(t,e);n.isEmpty()||(this.undoStack.push(n.inverse()),n.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new i_(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(t,n,i){return this.perform(t,n,i,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n,t))}redo(t,n,i){return this.perform(t,n,i,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n,t))}perform(e,t,n,i,a){try{let l=i();if(null===l)return;let s=e,r=t,o=!1;for(;l;){try{[s,r,o]=l.applyTo(s,r,n)}finally{a(l)}if(o)break;l=i()}return[s,r]}finally{this.onHistoryChangedEmitter.trigger(new i_(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(e){if(!e.length)return null;let t=e.pop();return void 0!==t?t:null}static push(e,t,n){let i=t.inverse().applyLatestChanges(n);return e.push(i)}},iO=class e{constructor(e,t){this.appStateChange=e,this.elementsChange=t}static create(t,n){return new e(t,n)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(e,t,n){let[i,a]=this.elementsChange.applyTo(e,n.elements),[l,s]=this.appStateChange.applyTo(t,i);return[i,l,a||s]}applyLatestChanges(t){let n=this.elementsChange.applyLatestChanges(t);return e.create(this.appStateChange,n)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}},iF=(e,t)=>{let[n,i]=(0,o.useState)(t);return(0,o.useEffect)(()=>{let t=e.on(e=>{i(e)});return()=>{t()}},[e]),n},iz=(e,t,n)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowChartCreator.isCreatingChart){let e=n();if(!e)return{captureUpdate:i.Wg.EVENTUALLY};let[t,a]=e;return{appState:a,elements:Array.from(t.values()),captureUpdate:i.Wg.NEVER}}return{captureUpdate:i.Wg.EVENTUALLY}},iU=(e,t,n,i,a,l)=>{if(e.trackEvent)try{"object"==typeof e.trackEvent&&(!e.trackEvent.predicate||e.trackEvent.predicate(n,i,l))&&ed(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${a.device.editor.isMobile?"mobile":"desktop"})`)}catch(e){console.error("error while logging action:",e)}},iB=class{constructor(e,t,n,a){(0,r.d)(this,"actions",{}),(0,r.d)(this,"updater"),(0,r.d)(this,"getAppState"),(0,r.d)(this,"getElementsIncludingDeleted"),(0,r.d)(this,"app"),(0,r.d)(this,"renderAction",(e,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[e]&&"PanelComponent"in this.actions[e]&&(!(e in n)||n[e])){let n=this.actions[e],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=e=>{iU(n,"ui",l,a,this.app,e),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),e,this.app))};return(0,h.jsx)(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t})}return null}),(0,r.d)(this,"isActionEnabled",e=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!e.predicate||e.predicate(t,n,this.app.props,this.app)}),this.updater=t=>{if(!(0,i.Fb)(t))return e(t);t.then(t=>e(t))},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=a}registerAction(e){this.actions[e.name]=e}registerAll(e){e.forEach(e=>this.registerAction(e))}handleKeyDown(e){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((e,t)=>(t.keyPriority||0)-(e.keyPriority||0)).filter(n=>(!(n.name in t)||t[n.name])&&n.keyTest&&n.keyTest(e,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(1!==n.length)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let i=n[0];if(this.getAppState().viewModeEnabled&&!0!==i.viewMode)return!1;let a=this.getElementsIncludingDeleted(),l=this.getAppState();return iU(i,"keyboard",l,a,this.app,null),e.preventDefault(),e.stopPropagation(),this.updater(n[0].perform(a,l,null,this.app)),!0}executeAction(e,t="api",n=null){let i=this.getElementsIncludingDeleted(),a=this.getAppState();iU(e,t,a,i,this.app,n),this.updater(e.perform(i,a,n,this.app))}},iW=e=>{let t=Array.from(e.values());return{x:i$(t,e=>e.x)/t.length,y:i$(t,e=>e.y)/t.length}},iH=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),i$=(e,t)=>e.reduce((e,n)=>e+t(n),0),iY=({children:e,left:t,top:n,onCloseRequest:a,fitInViewport:l=!1,offsetLeft:s=0,offsetTop:r=0,viewportWidth:d=window.innerWidth,viewportHeight:c=window.innerHeight})=>{let m=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=m.current;if(!e)return;e.contains(document.activeElement)||e.focus();let t=t=>{if(t.key===i.hg.TAB){let n=(0,i.Gb)(e),{activeElement:a}=document,l=n.findIndex(e=>e===a);a===e?(t.shiftKey?n[n.length-1]?.focus():n[0].focus(),t.preventDefault(),t.stopImmediatePropagation()):0===l&&t.shiftKey?(n[n.length-1]?.focus(),t.preventDefault(),t.stopImmediatePropagation()):l!==n.length-1||t.shiftKey||(n[0]?.focus(),t.preventDefault(),t.stopImmediatePropagation())}};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)},[]);let u=(0,o.useRef)(null);return(0,o.useLayoutEffect)(()=>{if(l&&m.current&&null!=n&&null!=t){let e=m.current,{width:i,height:a}=e.getBoundingClientRect();(u.current?.top!==n||u.current?.left!==t)&&(u.current={top:n,left:t},i>=d?(e.style.width=`${d}px`,e.style.left="0px",e.style.overflowX="scroll"):t+i-s>d?e.style.left=`${d-i-10}px`:e.style.left=`${t}px`,a>=c?(e.style.height=`${c-20}px`,e.style.top="10px",e.style.overflowY="scroll"):n+a-r>c?e.style.top=`${c-a}px`:e.style.top=`${n}px`)}},[n,t,l,d,c,s,r]),(0,o.useEffect)(()=>{if(a){let e=e=>{m.current?.contains(e.target)||(0,p.unstable_batchedUpdates)(()=>a(e))};return document.addEventListener("pointerdown",e,!1),()=>document.removeEventListener("pointerdown",e,!1)}},[a]),(0,h.jsx)("div",{className:"popover",ref:m,tabIndex:-1,children:e})},iG="separator",iV=o.memo(({actionManager:e,items:t,top:n,left:i,onClose:a})=>{let l=s1(),s=s0(),r=t.reduce((t,n)=>(n&&(n===iG||!n.predicate||n.predicate(s,l,e.app.props,e.app))&&t.push(n),t),[]);return(0,h.jsx)(iY,{onCloseRequest:()=>{a()},top:n,left:i,fitInViewport:!0,offsetLeft:l.offsetLeft,offsetTop:l.offsetTop,viewportWidth:l.width,viewportHeight:l.height,children:(0,h.jsx)("ul",{className:"context-menu",onContextMenu:e=>e.preventDefault(),children:r.map((t,n)=>{if(t===iG)return r[n-1]&&r[n-1]!==iG?(0,h.jsx)("hr",{className:"context-menu-item-separator"},n):null;let i=t.name,o="";return t.label&&(o="function"==typeof t.label?z(t.label(s,l,e.app)):z(t.label)),(0,h.jsx)("li",{"data-testid":i,onClick:()=>{a(()=>{e.executeAction(t,"contextMenu")})},children:(0,h.jsxs)("button",{type:"button",className:(0,m.A)("context-menu-item",{dangerous:"deleteSelectedElements"===i,checkmark:t.checked?.(l)}),children:[(0,h.jsx)("div",{className:"context-menu-item__label",children:o}),(0,h.jsx)("kbd",{className:"context-menu-item__shortcut",children:i?n9(i):""})]})},n)})})})}),iK=({children:e,onClose:t})=>{let[n,i]=(0,o.useState)(!!e),{container:a}=sJ(),l=o.useCallback(()=>{i(!1),t&&t(),a?.focus()},[t,a]);return(0,h.jsx)(h.Fragment,{children:n&&(0,h.jsx)(n4,{size:"small",onCloseRequest:l,title:z("errorDialog.title"),children:(0,h.jsx)("div",{style:{whiteSpace:"pre-wrap"},children:e})})})},iZ=function({onChange:e,value:t,choices:n,name:i}){return(0,h.jsx)("div",{className:"RadioGroup",children:n.map(n=>(0,h.jsxs)("div",{className:(0,m.A)("RadioGroup__choice",{active:n.value===t}),title:n.ariaLabel,children:[(0,h.jsx)("input",{name:i,type:"radio",checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})},iX=({title:e,name:t,checked:n,onChange:i,disabled:a=!1})=>(0,h.jsx)("div",{className:(0,m.A)("Switch",{toggled:n,disabled:a}),children:(0,h.jsx)("input",{name:t,id:t,title:e,type:"checkbox",checked:n,disabled:a,onChange:()=>i(!n),onKeyDown:e=>{" "===e.key&&i(!n)}})}),iQ=(0,o.forwardRef)(({children:e,icon:t,onClick:n,label:a,variant:l="filled",color:s="primary",size:r="medium",fullWidth:d,className:c,status:p},u)=>{let[g,f]=(0,o.useState)(!1),b=async e=>{let t=n?.(e);if((0,i.Fb)(t)){let e=window.setTimeout(()=>{f(!0)},50);try{await t}catch(e){if(e instanceof i.tc)console.warn(e);else throw e}finally{clearTimeout(e),f(!1)}}},x=g?"loading":p;return s="success"===x?"success":s,(0,h.jsx)("button",{className:(0,m.A)("ExcButton",`ExcButton--color-${s}`,`ExcButton--variant-${l}`,`ExcButton--size-${r}`,`ExcButton--status-${x}`,{"ExcButton--fullWidth":d},c),onClick:b,type:"button","aria-label":a,ref:u,disabled:"loading"===x||"success"===x,children:(0,h.jsxs)("div",{className:"ExcButton__contents",children:["loading"===x?(0,h.jsx)(W,{className:"ExcButton__statusIcon"}):"success"===x&&(0,h.jsx)("div",{className:"ExcButton__statusIcon",children:i.bf}),t&&(0,h.jsx)("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),"icon"!==l&&(e??a)]})})}),iq="filter"in document.createElement("canvas").getContext("2d"),iJ=()=>(0,h.jsxs)("div",{children:[(0,h.jsx)("h3",{children:z("canvasError.cannotShowPreview")}),(0,h.jsx)("p",{children:(0,h.jsx)("span",{children:z("canvasError.canvasTooBig")})}),(0,h.jsxs)("em",{children:["(",z("canvasError.canvasTooBigTip"),")"]})]}),i0=({appStateSnapshot:e,elementsSnapshot:t,files:n,actionManager:a,onExportImage:l,name:s})=>{let r=(0,i.tk)(t,e),[d,c]=(0,o.useState)(s),[m,p]=(0,o.useState)(r),[u,g]=(0,o.useState)(e.exportBackground),[f,b]=(0,o.useState)(e.exportWithDarkMode),[x,E]=(0,o.useState)(e.exportEmbedScene),[y,v]=(0,o.useState)(e.exportScale),w=(0,o.useRef)(null),[S,k]=(0,o.useState)(null),{onCopy:C,copyStatus:j,resetCopyStatus:I}=(()=>{let[e,t]=(0,o.useState)(null),n=(0,o.useRef)(0);return{copyStatus:e,resetCopyStatus:(0,o.useCallback)(()=>{t(null)},[]),onCopy:()=>{clearTimeout(n.current),t("success"),n.current=window.setTimeout(()=>{t(null)},2e3)}}})();(0,o.useEffect)(()=>{I()},[d,u,f,y,x,I]);let{exportedElements:T,exportingFrame:M}=tE(t,e,m);return(0,o.useEffect)(()=>{let t=w.current;if(!t)return;let a=t.offsetWidth,l=t.offsetHeight;a&&(0,i.pi)({elements:T,appState:{...e,name:d,exportBackground:u,exportWithDarkMode:f,exportScale:y,exportEmbedScene:x},files:n,exportPadding:i.ma,maxWidthOrHeight:Math.max(a,l),exportingFrame:M}).then(e=>(k(null),(0,i.yh)(e).then(()=>{t.replaceChildren(e)}).catch(e=>{throw"CANVAS_POSSIBLY_TOO_BIG"===e.name?Error(z("canvasError.canvasTooBig")):e}))).catch(e=>{console.error(e),k(e)})},[e,n,T,M,d,u,f,y,x]),(0,h.jsxs)("div",{className:"ImageExportModal",children:[(0,h.jsx)("h3",{children:z("imageExportDialog.header")}),(0,h.jsxs)("div",{className:"ImageExportModal__preview",children:[(0,h.jsx)("div",{className:"ImageExportModal__preview__canvas",ref:w,children:S&&(0,h.jsx)(iJ,{})}),(0,h.jsx)("div",{className:"ImageExportModal__preview__filename",children:!i.eh&&(0,h.jsx)("input",{type:"text",className:"TextInput",value:d,style:{width:"30ch"},onChange:e=>{c(e.target.value),a.executeAction(tS,"ui",e.target.value)}})})]}),(0,h.jsxs)("div",{className:"ImageExportModal__settings",children:[(0,h.jsx)("h3",{children:z("imageExportDialog.header")}),r&&(0,h.jsx)(i1,{label:z("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:(0,h.jsx)(iX,{name:"exportOnlySelected",checked:m,onChange:e=>{p(e)}})}),(0,h.jsx)(i1,{label:z("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:(0,h.jsx)(iX,{name:"exportBackgroundSwitch",checked:u,onChange:e=>{g(e),a.executeAction(tC,"ui",e)}})}),iq&&(0,h.jsx)(i1,{label:z("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:(0,h.jsx)(iX,{name:"exportDarkModeSwitch",checked:f,onChange:e=>{b(e),a.executeAction(tD,"ui",e)}})}),(0,h.jsx)(i1,{label:z("imageExportDialog.label.embedScene"),tooltip:z("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:(0,h.jsx)(iX,{name:"exportEmbedSwitch",checked:x,onChange:e=>{E(e),a.executeAction(tj,"ui",e)}})}),(0,h.jsx)(i1,{label:z("imageExportDialog.label.scale"),name:"exportScale",children:(0,h.jsx)(iZ,{name:"exportScale",value:y,onChange:e=>{v(e),a.executeAction(tk,"ui",e)},choices:i.la.map(e=>({value:e,label:`${e}\xd7`}))})}),(0,h.jsxs)("div",{className:"ImageExportModal__settings__buttons",children:[(0,h.jsx)(iQ,{className:"ImageExportModal__settings__buttons__button",label:z("imageExportDialog.title.exportToPng"),onClick:()=>l(i.U.png,T,{exportingFrame:M}),icon:i.Ze,children:z("imageExportDialog.button.exportToPng")}),(0,h.jsx)(iQ,{className:"ImageExportModal__settings__buttons__button",label:z("imageExportDialog.title.exportToSvg"),onClick:()=>l(i.U.svg,T,{exportingFrame:M}),icon:i.Ze,children:z("imageExportDialog.button.exportToSvg")}),(i.ii||i.n)&&(0,h.jsx)(iQ,{className:"ImageExportModal__settings__buttons__button",label:z("imageExportDialog.title.copyPngToClipboard"),status:j,onClick:async()=>{await l(i.U.clipboard,T,{exportingFrame:M}),C()},icon:i._e,children:z("imageExportDialog.button.copyPngToClipboard")})]})]})]})},i1=({label:e,children:t,tooltip:n,name:a})=>(0,h.jsxs)("div",{className:"ImageExportModal__settings__setting",title:e,children:[(0,h.jsxs)("label",{htmlFor:a,className:"ImageExportModal__settings__setting__label",children:[e,n&&(0,h.jsx)(tr,{label:n,long:!0,children:i.af})]}),(0,h.jsx)("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),i2=({elements:e,appState:t,files:n,actionManager:a,onExportImage:l,onCloseRequest:s,name:r})=>{let[{appStateSnapshot:d,elementsSnapshot:c}]=(0,o.useState)(()=>({appStateSnapshot:(0,i.Nb)(t),elementsSnapshot:(0,i.Nb)(e)}));return(0,h.jsx)(n4,{onCloseRequest:s,size:"wide",title:!1,children:(0,h.jsx)(i0,{elementsSnapshot:c,appStateSnapshot:d,files:n,actionManager:a,onExportImage:l,name:r})})},i3=({children:e,side:t,className:n})=>(0,h.jsx)("div",{className:(0,m.A)("FixedSideContainer",`FixedSideContainer_side_${t}`,n),children:e}),i5=e=>{switch(e){case i.hg.ARROW_UP:return"up";case i.hg.ARROW_DOWN:return"down";case i.hg.ARROW_RIGHT:return"right";case i.hg.ARROW_LEFT:return"left";default:return"right"}},i4=(e,t,n,a)=>{let l=[...n.values()].reduce((a,l)=>{let s;if((0,i.ec)(l)&&(s=l["predecessors"===e?"startBinding":"endBinding"])&&l["predecessors"===e?"endBinding":"startBinding"]?.elementId===t.id){let r=n.get(s.elementId);if(!r)return a;(0,i.Kb)((0,i.ic)(r),"not an ExcalidrawBindableElement");let o="predecessors"===e?l.points[l.points.length-1]:[0,0],d=(0,i.Dg)(t,(0,i.vg)(t),[o[0]+l.x,o[1]+l.y]);a.push({relative:r,heading:d})}return a},[]);switch(a){case"up":return l.filter(e=>(0,i.Cg)(e.heading,i.Bg)).map(e=>e.relative);case"down":return l.filter(e=>(0,i.Cg)(e.heading,i.zg)).map(e=>e.relative);case"right":return l.filter(e=>(0,i.Cg)(e.heading,i.yg)).map(e=>e.relative);case"left":return l.filter(e=>(0,i.Cg)(e.heading,i.Ag)).map(e=>e.relative)}},i6=(e,t,n,a,l)=>{let s,r,o,d;switch(a){case"up":s=e.x+e.width/2,r=e.y-6;break;case"down":s=e.x+e.width/2,r=e.y+e.height+6;break;case"right":s=e.x+e.width+6,r=e.y+e.height/2;break;case"left":s=e.x-6,r=e.y+e.height/2}switch(a){case"up":o=t.x+t.width/2-s,d=t.y+t.height-r+6;break;case"down":o=t.x+t.width/2-s,d=t.y-r-6;break;case"right":o=t.x-s-6,d=t.y-r+t.height/2;break;case"left":o=t.x+t.width-s+6,d=t.y-r+t.height/2}let c=(0,i.$f)({type:"arrow",x:s,y:r,startArrowhead:null,endArrowhead:l.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[(0,i.Ua)(0,0),(0,i.Ua)(o,d)],elbowed:!0});(0,i.Mg)(c,e,"start",n),(0,i.Mg)(c,t,"end",n);let h=new Map;h.set(e.id,e),h.set(t.id,t),h.set(c.id,c),i.pj.movePoints(c,[{index:1,point:c.points[1]}]);let m=(0,i.ih)(c,(0,i.Sb)(new Map([...n.entries(),[e.id,e],[t.id,t],[c.id,c]])),{points:c.points});return{...c,...m}},i8=class{constructor(){(0,r.d)(this,"isExploring",!1),(0,r.d)(this,"sameLevelNodes",[]),(0,r.d)(this,"sameLevelIndex",0),(0,r.d)(this,"direction",null),(0,r.d)(this,"visitedNodes",new Set)}clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(e,t,n){if(!(0,i.ic)(e))return null;if(n!==this.direction&&this.clear(),this.visitedNodes.has(e.id)||this.visitedNodes.add(e.id),this.isExploring&&n===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let a=[...i4("successors",e,t,n),...i4("predecessors",e,t,n)];if(a.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=a,this.direction=n,this.visitedNodes.add(a[0].id),a[0].id;if(n===this.direction||!this.isExploring){for(let i of(this.isExploring||this.visitedNodes.add(e.id),["up","right","down","left"].filter(e=>e!==n).map(n=>[...i4("successors",e,t,n),...i4("predecessors",e,t,n)]).flat().filter(e=>!this.visitedNodes.has(e.id))))if(!this.visitedNodes.has(i.id))return this.visitedNodes.add(i.id),this.isExploring=!0,this.direction=n,i.id}return null}},i7=class{constructor(){(0,r.d)(this,"isCreatingChart",!1),(0,r.d)(this,"numberOfNodes",0),(0,r.d)(this,"direction","right"),(0,r.d)(this,"pendingNodes",null)}createNodes(e,t,n,a){if(a!==this.direction){var l,s,r,o;let d,c,h,m,p,{nextNode:u,bindingArrow:g}=(l=e,s=t,r=n,d=i4("successors",l,s,o=a),c=i4("predecessors",l,s,o),h=((e,t,n)=>{let i=100+e.width;if("up"===n||"down"===n){let i=100+e.height,a=e.x,l=e.x+e.width;if(t.every(e=>e.x+e.width<a||e.x>l))return{x:0,y:i*("up"===n?-1:1)}}else if("right"===n||"left"===n){let i=e.y,a=e.y+e.height;if(t.every(e=>e.y+e.height<i||e.y>a))return{x:(100+e.width)*("left"===n?-1:1),y:0}}if("up"===n||"down"===n){let a=(t.length,100+e.height),l=0===t.length?0:(t.length+1)%2==0?(t.length+1)/2*i:-(t.length/2*i*1);return"up"===n?{x:l,y:-1*a}:{x:l,y:a}}let a=100+e.height,l=(t.length,100+e.width),s=0===t.length?0:(t.length+1)%2==0?(t.length+1)/2*a:-(t.length/2*a*1);return"left"===n?{x:-1*l,y:s}:{x:l,y:s}})(l,[...d,...c],o),m=(0,i.Sf)({type:l.type,x:l.x+h.x,y:l.y+h.y,width:l.width,height:l.height,roundness:l.roundness,roughness:l.roughness,backgroundColor:l.backgroundColor,strokeColor:l.strokeColor,strokeWidth:l.strokeWidth,opacity:l.opacity,fillStyle:l.fillStyle,strokeStyle:l.strokeStyle}),(0,i.Kb)((0,i.lc)(m),"not an ExcalidrawFlowchartNodeElement"),p=i6(l,m,s,o,r),{nextNode:m,bindingArrow:p});this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=a,this.pendingNodes=[u,g]}else{this.numberOfNodes+=1;let l=((e,t,n,a,l)=>{let s=[];for(let r=0;r<l;r++){let o,d;if("left"===a||"right"===a){let t=100*(l-1)+l*e.height,n=e.y+e.height/2-t/2,i=100+e.width;"left"===a&&(i*=-1),o=e.x+i,d=n+(100+e.height)*r}else{let t=100*(l-1)+l*e.width,n=e.x+e.width/2-t/2,i=100+e.height;"up"===a&&(i*=-1),d=e.y+i,o=n+(100+e.width)*r}let c=(0,i.Sf)({type:e.type,x:o,y:d,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});(0,i.Kb)((0,i.lc)(c),"not an ExcalidrawFlowchartNodeElement");let h=i6(e,c,t,a,n);s.push(c),s.push(h)}return s})(e,t,n,a,this.numberOfNodes);this.isCreatingChart=!0,this.direction=a,this.pendingNodes=l}if(e.frameId){let n=t.get(e.frameId);(0,i.Kb)(n&&(0,i.$b)(n),"not an ExcalidrawFrameElement"),n&&this.pendingNodes.every(e=>(0,i.xi)([e],n,t)||(0,i.yi)(e,n,t))&&(this.pendingNodes=this.pendingNodes.map(t=>(0,i.Pj)(t,{frameId:e.frameId},!1)))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},i9=({appState:e,isMobile:t,device:n,app:a})=>{let l=(({appState:e,isMobile:t,device:n,app:a})=>{let{activeTool:l,isResizing:s,isRotating:r,lastPointerDownWith:o}=e,d=null!==e.multiElement;if(e.openSidebar?.name===i.ya.name&&e.openSidebar.tab===i.xa&&e.searchMatches?.length)return z("hints.dismissSearch");if(e.openSidebar&&!n.editor.canFitSidebar)return null;if((0,i.Gc)(e))return z("hints.eraserRevert");if("arrow"===l.type||"line"===l.type)return d?z("hints.linearElementMulti"):"arrow"===l.type?z("hints.arrowTool",{arrowShortcut:(0,i.kb)("A")}):z("hints.linearElement");if("freedraw"===l.type)return z("hints.freeDraw");if("text"===l.type)return z("hints.text");if("embeddable"===l.type)return z("hints.embeddable");if("image"===e.activeTool.type&&e.pendingImageElementId)return z("hints.placeImage");let c=a.scene.getSelectedElements(e);if(s&&"mouse"===o&&1===c.length){let e=c[0];return(0,i.cc)(e)&&2===e.points.length?z("hints.lockAngle"):(0,i.Wb)(e)?z("hints.resizeImage"):z("hints.resize")}if(r&&"mouse"===o)return z("hints.rotate");if(1===c.length&&(0,i._b)(c[0]))return z("hints.text_selected");if(e.editingTextElement)return z("hints.text_editing");if(e.croppingElementId)return z("hints.leaveCropEditor");if(1===c.length&&(0,i.Wb)(c[0]))return z("hints.enterCropEditor");if("selection"===l.type){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.editingLinearElement)return z("hints.deepBoxSelect");if((0,i.fj)(a)&&e.selectedElementsAreBeingDragged)return z("hints.disableSnapping");if(!c.length&&!t)return z("hints.canvasPanning");if(1===c.length){if((0,i.cc)(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?z("hints.lineEditor_pointSelected"):z("hints.lineEditor_nothingSelected"):z("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&(0,i.jc)(c[0]))return(0,i.lc)(c[0])?(((e,t)=>{for(let[,n]of t)if("arrow"===n.type&&(n.startBinding?.elementId===e.id||n.endBinding?.elementId===e.id))return!0})(c[0],a.scene.getNonDeletedElementsMap()),[z("hints.bindTextToElement"),z("hints.createFlowchart")]):z("hints.bindTextToElement")}}return null})({appState:e,isMobile:t,device:n,app:a});if(!l)return null;let s=Array.isArray(l)?l.map(e=>(0,i.kb)(e).replace(/\. ?$/,"")).join(". "):(0,i.kb)(l);return(0,h.jsx)("div",{className:"HintViewer",children:(0,h.jsx)("span",{children:s})})},ae={CHECKED:i.kd,UNCHECKED:i.jd},at=e=>(0,h.jsxs)("label",{className:(0,m.A)("ToolIcon ToolIcon__lock","ToolIcon_size_medium",{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[(0,h.jsx)("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),(0,h.jsx)("div",{className:"ToolIcon__icon",children:e.checked?ae.CHECKED:ae.UNCHECKED})]}),an=({heading:e,children:t,...n})=>{let{id:i}=sJ(),a=(0,h.jsx)("h2",{className:"visually-hidden",id:`${i}-${e}-title`,children:z(`headings.${e}`)});return(0,h.jsx)("section",{...n,"aria-labelledby":`${i}-${e}-title`,children:"function"==typeof t?t(a):(0,h.jsxs)(h.Fragment,{children:[a,t]})})},ai=(e,t,n)=>{let[i,a]=[e.horizontal,e.vertical].map(e=>null!=e&&e.x<=t&&t<=e.x+e.width&&e.y<=n&&n<=e.y+e.height);return{isOverEither:i||a,isOverHorizontal:i,isOverVertical:a}},aa=e=>e.penDetected?(0,h.jsxs)("label",{className:(0,m.A)("ToolIcon ToolIcon__penMode","ToolIcon_size_medium",{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,h.jsx)("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),(0,h.jsx)("div",{className:"ToolIcon__icon",children:i.od})]}):null,al=e=>(0,h.jsx)(Y,{className:(0,m.A)("Shape",{fillable:!1}),type:"radio",icon:i.Ye,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:i.hg.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":i.hg.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()}),as=({appState:e,elements:t,actionManager:n,setAppState:a,onLockToggle:l,onHandToolToggle:s,onPenModeToggle:r,renderTopRightUI:d,renderCustomStats:c,renderSidebars:m,device:p,renderWelcomeScreen:u,UIOptions:g,app:f})=>{let{WelcomeScreenCenterTunnel:b,MainMenuTunnel:x,DefaultSidebarTriggerTunnel:E}=o.useContext(il);return(0,h.jsxs)(h.Fragment,{children:[m(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(0,h.jsxs)(i3,{side:"top",className:"App-top-bar",children:[u&&(0,h.jsx)(b.Out,{}),(0,h.jsx)(an,{heading:"shapes",children:t=>(0,h.jsx)(nj,{gap:4,align:"center",children:(0,h.jsxs)(nC,{gap:1,className:"App-toolbar-container",children:[(0,h.jsxs)(eA,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[t,(0,h.jsx)(nC,{gap:1,children:(0,h.jsx)(ic,{appState:e,activeTool:e.activeTool,UIOptions:g,app:f})})]}),d&&d(!0,e),(0,h.jsxs)("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(0,h.jsx)(E.Out,{}),(0,h.jsx)(aa,{checked:e.penMode,onChange:()=>r(null),title:z("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),(0,h.jsx)(at,{checked:e.activeTool.locked,onChange:l,title:z("toolBar.lock"),isMobile:!0}),(0,h.jsx)(al,{checked:(0,i.Hc)(e),onChange:()=>s(),title:z("toolBar.hand"),isMobile:!0})]})]})})}),(0,h.jsx)(i9,{appState:e,isMobile:!0,device:p,app:f})]}),(0,h.jsx)("div",{className:"App-bottom-bar",style:{marginBottom:14,marginLeft:14,marginRight:14},children:(0,h.jsxs)(eA,{padding:0,children:["shape"===e.openMenu&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(0,i.lk)(e,t)?(0,h.jsx)(an,{className:"App-mobile-menu",heading:"selectedShapeActions",children:(0,h.jsx)(id,{appState:e,elementsMap:f.scene.getNonDeletedElementsMap(),renderAction:n.renderAction,app:f})}):null,(0,h.jsxs)("footer",{className:"App-toolbar",children:[e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?(0,h.jsx)("div",{className:"App-toolbar-content",children:(0,h.jsx)(x.Out,{})}):(0,h.jsxs)("div",{className:"App-toolbar-content",children:[(0,h.jsx)(x.Out,{}),n.renderAction("toggleEditMenu"),n.renderAction(e.multiElement?"finalize":"duplicateSelection"),n.renderAction("deleteSelectedElements"),(0,h.jsxs)("div",{children:[n.renderAction("undo"),n.renderAction("redo")]})]}),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&(0,h.jsx)("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{a(e=>({...(0,i.zk)(t,e)}))},children:z("buttons.scrollBackToContent")})]})]})})]})},ar=e=>{let t=(0,o.useRef)(null),[n,a]=(0,o.useState)(null);return(0,o.useLayoutEffect)(()=>{if(!e.spreadsheet)return;let n=(0,i.gi)(e.chartType,e.spreadsheet,0,0);a(n);let l,s=t.current;return(async()=>(l=await (0,i.ei)(n,{exportBackground:!1,viewBackgroundColor:b.white},null,{skipInliningFonts:!0}),l.querySelector(".style-fonts")?.remove(),s.replaceChildren(),s.appendChild(l),e.selected&&s.parentNode.focus()))(),()=>{s.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),(0,h.jsx)("button",{type:"button",className:"ChartPreview",onClick:()=>{n&&e.onClick(e.chartType,n)},children:(0,h.jsx)("div",{ref:t})})},ao=({setAppState:e,appState:t,onClose:n})=>{let{onInsertElements:i}=sX(),a=o.useCallback(()=>{n&&n()},[n]),l=(t,n)=>{i(n),ed("paste","chart",t),e({currentChartType:t,pasteDialog:{shown:!1,data:null}})};return(0,h.jsx)(n4,{size:"small",onCloseRequest:a,title:z("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:(0,h.jsxs)("div",{className:"container",children:[(0,h.jsx)(ar,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:"bar"===t.currentChartType,onClick:l}),(0,h.jsx)(ar,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:"line"===t.currentChartType,onClick:l})]})})},ad=()=>(0,h.jsxs)("div",{className:"HelpDialog__header",children:[(0,h.jsxs)("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[(0,h.jsx)("div",{className:"HelpDialog__link-icon",children:i.Dd}),z("helpDialog.documentation")]}),(0,h.jsxs)("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener noreferrer",children:[(0,h.jsx)("div",{className:"HelpDialog__link-icon",children:i.Dd}),z("helpDialog.blog")]}),(0,h.jsxs)("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[(0,h.jsx)("div",{className:"HelpDialog__link-icon",children:i.Ed}),z("helpDialog.github")]}),(0,h.jsxs)("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[(0,h.jsx)("div",{className:"HelpDialog__link-icon",children:i.Ff}),"YouTube"]})]}),ac=e=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("h3",{children:e.title}),(0,h.jsx)("div",{className:"HelpDialog__islands-container",children:e.children})]}),ah=e=>(0,h.jsxs)("div",{className:`HelpDialog__island ${e.className}`,children:[(0,h.jsx)("h4",{className:"HelpDialog__island-title",children:e.caption}),(0,h.jsx)("div",{className:"HelpDialog__island-content",children:e.children})]}),am=({label:e,shortcuts:t,isOr:n=!0})=>{let i=t.map(e=>(e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+")).map(e=>(0,h.jsx)(ap,{children:e.replace(/\b[a-z]\b/,e=>e.toUpperCase())},e)));return(0,h.jsxs)("div",{className:"HelpDialog__shortcut",children:[(0,h.jsx)("div",{children:e}),(0,h.jsx)("div",{className:"HelpDialog__key-container",children:[...function*(e,t){let n=!0;for(let i of e)n||(yield t),n=!1,yield i}(i,n?z("helpDialog.or"):null)]})]})},ap=e=>(0,h.jsx)("kbd",{className:"HelpDialog__key",...e}),au=({onClose:e})=>{let t=o.useCallback(()=>{e&&e()},[e]);return(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(n4,{onCloseRequest:t,title:z("helpDialog.title"),className:"HelpDialog",children:[(0,h.jsx)(ad,{}),(0,h.jsxs)(ac,{title:z("helpDialog.shortcuts"),children:[(0,h.jsxs)(ah,{className:"HelpDialog__island--tools",caption:z("helpDialog.tools"),children:[(0,h.jsx)(am,{label:z("toolBar.hand"),shortcuts:[i.hg.H]}),(0,h.jsx)(am,{label:z("toolBar.selection"),shortcuts:[i.hg.V,i.hg[1]]}),(0,h.jsx)(am,{label:z("toolBar.rectangle"),shortcuts:[i.hg.R,i.hg[2]]}),(0,h.jsx)(am,{label:z("toolBar.diamond"),shortcuts:[i.hg.D,i.hg[3]]}),(0,h.jsx)(am,{label:z("toolBar.ellipse"),shortcuts:[i.hg.O,i.hg[4]]}),(0,h.jsx)(am,{label:z("toolBar.arrow"),shortcuts:[i.hg.A,i.hg[5]]}),(0,h.jsx)(am,{label:z("toolBar.line"),shortcuts:[i.hg.L,i.hg[6]]}),(0,h.jsx)(am,{label:z("toolBar.freedraw"),shortcuts:[i.hg.P,i.hg[7]]}),(0,h.jsx)(am,{label:z("toolBar.text"),shortcuts:[i.hg.T,i.hg[8]]}),(0,h.jsx)(am,{label:z("toolBar.image"),shortcuts:[i.hg[9]]}),(0,h.jsx)(am,{label:z("toolBar.eraser"),shortcuts:[i.hg.E,i.hg[0]]}),(0,h.jsx)(am,{label:z("toolBar.frame"),shortcuts:[i.hg.F]}),(0,h.jsx)(am,{label:z("toolBar.laser"),shortcuts:[i.hg.K]}),(0,h.jsx)(am,{label:z("labels.eyeDropper"),shortcuts:[i.hg.I,"Shift+S","Shift+G"]}),(0,h.jsx)(am,{label:z("helpDialog.editLineArrowPoints"),shortcuts:[(0,i.kb)("CtrlOrCmd+Enter")]}),(0,h.jsx)(am,{label:z("helpDialog.editText"),shortcuts:[(0,i.kb)("Enter")]}),(0,h.jsx)(am,{label:z("helpDialog.textNewLine"),shortcuts:[(0,i.kb)("Enter"),(0,i.kb)("Shift+Enter")]}),(0,h.jsx)(am,{label:z("helpDialog.textFinish"),shortcuts:[(0,i.kb)("Esc"),(0,i.kb)("CtrlOrCmd+Enter")]}),(0,h.jsx)(am,{label:z("helpDialog.curvedArrow"),shortcuts:["A",z("helpDialog.click"),z("helpDialog.click"),z("helpDialog.click")],isOr:!1}),(0,h.jsx)(am,{label:z("helpDialog.curvedLine"),shortcuts:["L",z("helpDialog.click"),z("helpDialog.click"),z("helpDialog.click")],isOr:!1}),(0,h.jsx)(am,{label:z("helpDialog.cropStart"),shortcuts:[z("helpDialog.doubleClick"),(0,i.kb)("Enter")],isOr:!0}),(0,h.jsx)(am,{label:z("helpDialog.cropFinish"),shortcuts:[(0,i.kb)("Enter"),(0,i.kb)("Escape")],isOr:!0}),(0,h.jsx)(am,{label:z("toolBar.lock"),shortcuts:[i.hg.Q]}),(0,h.jsx)(am,{label:z("helpDialog.preventBinding"),shortcuts:[(0,i.kb)("CtrlOrCmd")]}),(0,h.jsx)(am,{label:z("toolBar.link"),shortcuts:[(0,i.kb)("CtrlOrCmd+K")]})]}),(0,h.jsxs)(ah,{className:"HelpDialog__island--view",caption:z("helpDialog.view"),children:[(0,h.jsx)(am,{label:z("buttons.zoomIn"),shortcuts:[(0,i.kb)("CtrlOrCmd++")]}),(0,h.jsx)(am,{label:z("buttons.zoomOut"),shortcuts:[(0,i.kb)("CtrlOrCmd+-")]}),(0,h.jsx)(am,{label:z("buttons.resetZoom"),shortcuts:[(0,i.kb)("CtrlOrCmd+0")]}),(0,h.jsx)(am,{label:z("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),(0,h.jsx)(am,{label:z("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),(0,h.jsx)(am,{label:z("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),(0,h.jsx)(am,{label:z("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),(0,h.jsx)(am,{label:z("buttons.zenMode"),shortcuts:[(0,i.kb)("Alt+Z")]}),(0,h.jsx)(am,{label:z("buttons.objectsSnapMode"),shortcuts:[(0,i.kb)("Alt+S")]}),(0,h.jsx)(am,{label:z("labels.toggleGrid"),shortcuts:[(0,i.kb)("CtrlOrCmd+'")]}),(0,h.jsx)(am,{label:z("labels.viewMode"),shortcuts:[(0,i.kb)("Alt+R")]}),(0,h.jsx)(am,{label:z("labels.toggleTheme"),shortcuts:[(0,i.kb)("Alt+Shift+D")]}),(0,h.jsx)(am,{label:z("stats.fullTitle"),shortcuts:[(0,i.kb)("Alt+/")]}),(0,h.jsx)(am,{label:z("search.title"),shortcuts:[n9("searchMenu")]}),(0,h.jsx)(am,{label:z("commandPalette.title"),shortcuts:i.n?[n9("commandPalette")]:[n9("commandPalette"),n9("commandPalette",1)]})]}),(0,h.jsxs)(ah,{className:"HelpDialog__island--editor",caption:z("helpDialog.editor"),children:[(0,h.jsx)(am,{label:z("helpDialog.createFlowchart"),shortcuts:[(0,i.kb)("CtrlOrCmd+Arrow Key")],isOr:!0}),(0,h.jsx)(am,{label:z("helpDialog.navigateFlowchart"),shortcuts:[(0,i.kb)("Alt+Arrow Key")],isOr:!0}),(0,h.jsx)(am,{label:z("labels.moveCanvas"),shortcuts:[(0,i.kb)(`Space+${z("helpDialog.drag")}`),(0,i.kb)(`Wheel+${z("helpDialog.drag")}`)],isOr:!0}),(0,h.jsx)(am,{label:z("buttons.clearReset"),shortcuts:[(0,i.kb)("CtrlOrCmd+Delete")]}),(0,h.jsx)(am,{label:z("labels.delete"),shortcuts:[(0,i.kb)("Delete")]}),(0,h.jsx)(am,{label:z("labels.cut"),shortcuts:[(0,i.kb)("CtrlOrCmd+X")]}),(0,h.jsx)(am,{label:z("labels.copy"),shortcuts:[(0,i.kb)("CtrlOrCmd+C")]}),(0,h.jsx)(am,{label:z("labels.paste"),shortcuts:[(0,i.kb)("CtrlOrCmd+V")]}),(0,h.jsx)(am,{label:z("labels.pasteAsPlaintext"),shortcuts:[(0,i.kb)("CtrlOrCmd+Shift+V")]}),(0,h.jsx)(am,{label:z("labels.selectAll"),shortcuts:[(0,i.kb)("CtrlOrCmd+A")]}),(0,h.jsx)(am,{label:z("labels.multiSelect"),shortcuts:[(0,i.kb)(`Shift+${z("helpDialog.click")}`)]}),(0,h.jsx)(am,{label:z("helpDialog.deepSelect"),shortcuts:[(0,i.kb)(`CtrlOrCmd+${z("helpDialog.click")}`)]}),(0,h.jsx)(am,{label:z("helpDialog.deepBoxSelect"),shortcuts:[(0,i.kb)(`CtrlOrCmd+${z("helpDialog.drag")}`)]}),(i.ii||i.n)&&(0,h.jsx)(am,{label:z("labels.copyAsPng"),shortcuts:[(0,i.kb)("Shift+Alt+C")]}),(0,h.jsx)(am,{label:z("labels.copyStyles"),shortcuts:[(0,i.kb)("CtrlOrCmd+Alt+C")]}),(0,h.jsx)(am,{label:z("labels.pasteStyles"),shortcuts:[(0,i.kb)("CtrlOrCmd+Alt+V")]}),(0,h.jsx)(am,{label:z("labels.sendToBack"),shortcuts:[i.l?(0,i.kb)("CtrlOrCmd+Alt+["):(0,i.kb)("CtrlOrCmd+Shift+[")]}),(0,h.jsx)(am,{label:z("labels.bringToFront"),shortcuts:[i.l?(0,i.kb)("CtrlOrCmd+Alt+]"):(0,i.kb)("CtrlOrCmd+Shift+]")]}),(0,h.jsx)(am,{label:z("labels.sendBackward"),shortcuts:[(0,i.kb)("CtrlOrCmd+[")]}),(0,h.jsx)(am,{label:z("labels.bringForward"),shortcuts:[(0,i.kb)("CtrlOrCmd+]")]}),(0,h.jsx)(am,{label:z("labels.alignTop"),shortcuts:[(0,i.kb)("CtrlOrCmd+Shift+Up")]}),(0,h.jsx)(am,{label:z("labels.alignBottom"),shortcuts:[(0,i.kb)("CtrlOrCmd+Shift+Down")]}),(0,h.jsx)(am,{label:z("labels.alignLeft"),shortcuts:[(0,i.kb)("CtrlOrCmd+Shift+Left")]}),(0,h.jsx)(am,{label:z("labels.alignRight"),shortcuts:[(0,i.kb)("CtrlOrCmd+Shift+Right")]}),(0,h.jsx)(am,{label:z("labels.duplicateSelection"),shortcuts:[(0,i.kb)("CtrlOrCmd+D"),(0,i.kb)(`Alt+${z("helpDialog.drag")}`)]}),(0,h.jsx)(am,{label:z("helpDialog.toggleElementLock"),shortcuts:[(0,i.kb)("CtrlOrCmd+Shift+L")]}),(0,h.jsx)(am,{label:z("buttons.undo"),shortcuts:[(0,i.kb)("CtrlOrCmd+Z")]}),(0,h.jsx)(am,{label:z("buttons.redo"),shortcuts:i.m?[(0,i.kb)("CtrlOrCmd+Y"),(0,i.kb)("CtrlOrCmd+Shift+Z")]:[(0,i.kb)("CtrlOrCmd+Shift+Z")]}),(0,h.jsx)(am,{label:z("labels.group"),shortcuts:[(0,i.kb)("CtrlOrCmd+G")]}),(0,h.jsx)(am,{label:z("labels.ungroup"),shortcuts:[(0,i.kb)("CtrlOrCmd+Shift+G")]}),(0,h.jsx)(am,{label:z("labels.flipHorizontal"),shortcuts:[(0,i.kb)("Shift+H")]}),(0,h.jsx)(am,{label:z("labels.flipVertical"),shortcuts:[(0,i.kb)("Shift+V")]}),(0,h.jsx)(am,{label:z("labels.showStroke"),shortcuts:[(0,i.kb)("S")]}),(0,h.jsx)(am,{label:z("labels.showBackground"),shortcuts:[(0,i.kb)("G")]}),(0,h.jsx)(am,{label:z("labels.showFonts"),shortcuts:[(0,i.kb)("Shift+F")]}),(0,h.jsx)(am,{label:z("labels.decreaseFontSize"),shortcuts:[(0,i.kb)("CtrlOrCmd+Shift+<")]}),(0,h.jsx)(am,{label:z("labels.increaseFontSize"),shortcuts:[(0,i.kb)("CtrlOrCmd+Shift+>")]})]})]})]})})},ag=({shouldWrap:e,children:t,username:n})=>e?(0,h.jsx)(tr,{label:n||"Unknown user",children:t}):(0,h.jsx)(h.Fragment,{children:t}),af=({actionManager:e,collaborator:t,socketId:n,withName:i=!1,shouldWrapWithTooltip:a=!1,isBeingFollowed:l})=>{let s=e.renderAction("goToCollaborator",{socketId:n,collaborator:t,withName:i,isBeingFollowed:l});return(0,h.jsx)(ag,{username:t.username,shouldWrap:a,children:s},n)},ab=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],ax=o.memo(({className:e,mobile:t,collaborators:n,userToFollow:a})=>{let l=s3(),s=new Map;n.forEach((e,t)=>{let n=e.id||t;s.set(n,{...e,socketId:t})});let r=Array.from(s.values()).filter(e=>e.username?.trim()),[d,c]=o.useState(""),p=r.filter(e=>e.username?.toLowerCase().includes(d)),u=o.useRef(null);(0,o.useLayoutEffect)(()=>{if(u.current){let e=e=>{b(Math.max(1,Math.min(8,Math.floor(e/38))))};if(e(u.current.clientWidth),!i.r)return;let t=new ResizeObserver(t=>{for(let n of t){let{width:t}=n.contentRect;e(t)}});return t.observe(u.current),()=>{t.disconnect()}}},[]);let[g,b]=o.useState(4),x=r.slice(0,g-1).map(e=>af({actionManager:l,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===a}));return t?(0,h.jsx)("div",{className:(0,m.A)("UserList UserList_mobile",e),children:r.map(e=>af({actionManager:l,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===a}))}):(0,h.jsx)("div",{className:"UserList__wrapper",ref:u,children:(0,h.jsxs)("div",{className:(0,m.A)("UserList",e),style:{"--max-avatars":g},children:[x,r.length>g-1&&(0,h.jsxs)(f.bL,{children:[(0,h.jsxs)(f.l9,{className:"UserList__more",children:["+",r.length-g+1]}),(0,h.jsx)(f.UC,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:(0,h.jsxs)(eA,{padding:2,children:[r.length>=8&&(0,h.jsx)(eY,{placeholder:z("quickSearch.placeholder"),onChange:c}),(0,h.jsx)(eG,{className:"dropdown-menu UserList__collaborators",placeholder:z("userList.empty"),children:p.length>0?[(0,h.jsx)("div",{className:"hint",children:z("userList.hint.text")}),p.map(e=>af({actionManager:l,collaborator:e,socketId:e.socketId,withName:!0,isBeingFollowed:e.socketId===a}))]:[]}),(0,h.jsx)(f.i3,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let n=t.collaborators.keys();for(let[a,l]of e.collaborators){let e=t.collaborators.get(a);if(!e||a!==n.next().value||!(0,i.Hb)(l,e,ab))return!1}return!0}),aE=({children:e,color:t})=>(0,h.jsx)("div",{className:"Card",style:{"--card-color":"primary"===t?"var(--color-primary)":b[t][7],"--card-color-darker":"primary"===t?"var(--color-primary-darker)":b[t][8],"--card-color-darkest":"primary"===t?"var(--color-primary-darkest)":b[t][9]},children:e}),ay=({elements:e,appState:t,setAppState:n,files:a,actionManager:l,exportOpts:s,canvas:r,onCloseRequest:o})=>{let{onExportToBackend:d}=s;return(0,h.jsx)("div",{className:"ExportDialog ExportDialog--json",children:(0,h.jsxs)("div",{className:"ExportDialog-cards",children:[s.saveFileToDisk&&(0,h.jsxs)(aE,{color:"lime",children:[(0,h.jsx)("div",{className:"Card-icon",children:i.Pd}),(0,h.jsx)("h2",{children:z("exportDialog.disk_title")}),(0,h.jsxs)("div",{className:"Card-details",children:[z("exportDialog.disk_details"),!i.eh&&l.renderAction("changeProjectName")]}),(0,h.jsx)(Y,{className:"Card-button",type:"button",title:z("exportDialog.disk_button"),"aria-label":z("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{l.executeAction(tT,"ui")}})]}),d&&(0,h.jsxs)(aE,{color:"pink",children:[(0,h.jsx)("div",{className:"Card-icon",children:i.Id}),(0,h.jsx)("h2",{children:z("exportDialog.link_title")}),(0,h.jsx)("div",{className:"Card-details",children:z("exportDialog.link_details")}),(0,h.jsx)(Y,{className:"Card-button",type:"button",title:z("exportDialog.link_button"),"aria-label":z("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ed("export","link",`ui (${(0,i.Eb)()})`),await d(e,t,a),o()}catch(e){n({errorMessage:e.message})}}})]}),s.renderCustomUI&&s.renderCustomUI(e,t,a,r)]})})},av=({elements:e,appState:t,files:n,actionManager:i,exportOpts:a,canvas:l,setAppState:s})=>{let r=o.useCallback(()=>{s({openDialog:null})},[s]);return(0,h.jsx)(h.Fragment,{children:t.openDialog?.name==="jsonExport"&&(0,h.jsx)(n4,{onCloseRequest:r,title:z("buttons.export"),children:(0,h.jsx)(ay,{elements:e,appState:t,setAppState:s,files:n,actionManager:i,onCloseRequest:r,exportOpts:a,canvas:l})})})},aw=e=>(0,h.jsx)("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${z("helpDialog.title")} \u2014 ?`,"aria-label":z("helpDialog.title"),children:i.Bd}),aS=({appState:e,actionManager:t,showExitZenModeBtn:n,renderWelcomeScreen:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:l}=o.useContext(il),s=sq(),r=!e.viewModeEnabled&&e.multiElement&&s.isTouchScreen;return(0,h.jsxs)("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(0,h.jsx)("div",{className:(0,m.A)("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:(0,h.jsx)(nj,{gap:2,children:(0,h.jsxs)(an,{heading:"canvasActions",children:[(0,h.jsx)(ih,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&(0,h.jsx)(im,{renderAction:t.renderAction,className:(0,m.A)("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),r&&(0,h.jsx)(iu,{renderAction:t.renderAction,className:(0,m.A)("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),(0,h.jsx)(a.Out,{}),(0,h.jsx)("div",{className:(0,m.A)("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:(0,h.jsxs)("div",{style:{position:"relative"},children:[i&&(0,h.jsx)(l.Out,{}),(0,h.jsx)(aw,{onClick:()=>t.executeAction(tP)})]})}),(0,h.jsx)(ip,{actionManager:t,showExitZenModeBtn:n})]})};aS.displayName="Footer";var ak=o.createContext({}),aC=({children:e,className:t})=>{let n=sq(),a=(0,o.useContext)(ak),l=!!(n.editor.canFitSidebar&&a.shouldRenderDockButton);return(0,h.jsxs)("div",{className:(0,m.A)("sidebar__header",t),"data-testid":"sidebar-header",children:[e,(0,h.jsxs)("div",{className:"sidebar__header__buttons",children:[l&&(0,h.jsx)(tr,{label:z("labels.sidebarLock"),children:(0,h.jsx)(n6,{onSelect:()=>a.onDock?.(!a.docked),selected:!!a.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":z("labels.sidebarLock"),children:i.id})}),(0,h.jsx)(n6,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:a.onCloseRequest,"aria-label":z("buttons.close"),children:i.ge})]})]})};aC.displayName="SidebarHeader";var aj=({name:e,tab:t,icon:n,title:i,children:a,onToggle:l,className:s,style:r})=>{let d=s2(),c=o.useContext(ej);return(0,h.jsxs)("label",{title:i,className:"sidebar-trigger__label-element",children:[(0,h.jsx)("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:n=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let i=n.target.checked;d({openSidebar:i?{name:e,tab:t}:null}),l?.(i)},checked:c.openSidebar?.name===e,"aria-label":i,"aria-keyshortcuts":"0"}),(0,h.jsxs)("div",{className:(0,m.A)("sidebar-trigger",s),style:r,children:[n&&(0,h.jsx)("div",{children:n}),a&&(0,h.jsx)("div",{className:"sidebar-trigger__label",children:a})]})]})};aj.displayName="SidebarTrigger";var aI=({children:e,...t})=>(0,h.jsx)(v.B8,{className:"sidebar-triggers",...t,children:e});aI.displayName="SidebarTabTriggers";var aT=({children:e,tab:t,onSelect:n,...i})=>(0,h.jsx)(v.l9,{value:t,asChild:!0,onSelect:n,children:(0,h.jsx)("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...i,children:e})});aT.displayName="SidebarTabTrigger";var aM=({children:e,...t})=>{let n=o.useContext(ej),i=s2();if(!n.openSidebar)return null;let{name:a}=n.openSidebar;return(0,h.jsx)(v.bL,{className:"sidebar-tabs-root",value:n.openSidebar.tab,onValueChange:e=>i(t=>({...t,openSidebar:{...t.openSidebar,name:a,tab:e}})),...t,children:e})};aM.displayName="SidebarTabs";var aD=({tab:e,children:t,...n})=>(0,h.jsx)(v.UC,{...n,value:e,"data-testid":e,children:t});aD.displayName="SidebarTab";var aL=(0,d.eU)(!1),aN=(0,o.forwardRef)(({name:e,children:t,onDock:n,docked:l,className:s,...r},d)=>{a.a.DEV&&n&&null==l&&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 c=s2(),p=j(aL);(0,o.useLayoutEffect)(()=>(p(!!l),()=>{p(!1)}),[p,l]);let u=(0,o.useRef)({});u.current.onCloseRequest=()=>{c({openSidebar:null})},u.current.onDock=e=>n?.(e),u.current=(0,i.Db)(u.current,{docked:l,shouldRenderDockButton:!!n&&null!=l});let g=(0,o.useRef)(null);(0,o.useImperativeHandle)(d,()=>g.current);let f=sq(),b=(0,o.useCallback)(()=>{document.querySelector(".Dialog")||c({openSidebar:null})},[c]);return eT(g,(0,o.useCallback)(e=>{e.target.closest(".sidebar-trigger")||l&&f.editor.canFitSidebar||b()},[b,l,f.editor.canFitSidebar])),(0,o.useEffect)(()=>{let e=e=>{e.key!==i.hg.ESCAPE||l&&f.editor.canFitSidebar||b()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[b,l,f.editor.canFitSidebar]),(0,h.jsx)(eA,{...r,className:(0,m.A)("sidebar",{"sidebar--docked":l},s),ref:g,children:(0,h.jsx)(ak.Provider,{value:u.current,children:t})})});aN.displayName="SidebarInner";var aA=Object.assign((0,o.forwardRef)((e,t)=>{let n=o.useContext(ej),{onStateChange:i}=e,a=(0,o.useRef)(n.openSidebar);(0,o.useEffect)(()=>{(n.openSidebar||a?.current?.name!==e.name)&&(n.openSidebar?.name!==e.name||a?.current?.name===e.name)&&a.current?.name!==e.name||n.openSidebar===a.current||i?.(n.openSidebar?.name!==e.name?null:n.openSidebar),a.current=n.openSidebar},[n.openSidebar,i,e.name]);let[l,s]=(0,o.useState)(!1);return(0,o.useLayoutEffect)(()=>(s(!0),()=>s(!1)),[]),l&&n.openSidebar?.name===e.name?(0,o.createElement)(aN,{...e,ref:t,key:e.name}):null}),{Header:aC,TabTriggers:aI,TabTrigger:aT,Tabs:aM,Tab:aD,Trigger:aj});aA.displayName="Sidebar";var aP={};(0,r.c)(aP,{ChangeCanvasBackground:()=>aG,ClearCanvas:()=>a$,CommandPalette:()=>aB,Export:()=>aV,Help:()=>aH,LiveCollaborationTrigger:()=>aZ,LoadScene:()=>aF,SaveAsImage:()=>aU,SaveToActiveFile:()=>az,SearchMenu:()=>aW,Socials:()=>aK,ToggleTheme:()=>aY});var a_=(0,d.eU)({active:!1});async function aR({title:e,description:t,actionLabel:n,color:i}){return new Promise(a=>{D.set(a_,{active:!0,onConfirm:()=>a(!0),onClose:()=>a(!1),onReject:()=>a(!1),title:e,description:t,actionLabel:n,color:i})})}var aO=({value:e,shortcut:t,onChange:n,choices:i,children:a,name:l})=>{let s=sq();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[(0,h.jsx)("label",{className:"dropdown-menu-item__text",htmlFor:l,children:a}),(0,h.jsx)(iZ,{name:l,value:e,onChange:n,choices:i})]}),t&&!s.editor.isMobile&&(0,h.jsx)("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};aO.displayName="DropdownMenuItemContentRadio";var aF=()=>{let{t:e}=B(),t=s3(),n=s0();return t.isActionEnabled(tM)?(0,h.jsx)(eq,{icon:i.Ld,onSelect:async()=>{(!n.length||await aR({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:(0,h.jsx)(nA,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:e=>(0,h.jsx)("strong",{children:e}),br:()=>(0,h.jsx)("br",{})})}))&&t.executeAction(tM)},"data-testid":"load-button",shortcut:n9("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};aF.displayName="LoadScene";var az=()=>{let{t:e}=B(),t=s3();return t.isActionEnabled(tI)?(0,h.jsx)(eq,{shortcut:n9("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(tI),icon:i.Jd,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};az.displayName="SaveToActiveFile";var aU=()=>{let e=s2(),{t:t}=B();return(0,h.jsx)(eq,{icon:i.Od,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:n9("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};aU.displayName="SaveAsImage";var aB=e=>{let t=s2(),{t:n}=B();return(0,h.jsx)(eq,{icon:i.tf,"data-testid":"command-palette-button",onSelect:()=>{ed("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:n9("commandPalette"),"aria-label":n("commandPalette.title"),className:e?.className,children:n("commandPalette.title")})};aB.displayName="CommandPalette";var aW=e=>{let{t:t}=B(),n=s3();return(0,h.jsx)(eq,{icon:i.pf,"data-testid":"search-menu-button",onSelect:()=>{n.executeAction(iA)},shortcut:n9("searchMenu"),"aria-label":t("search.title"),className:e?.className,children:t("search.title")})};aW.displayName="SearchMenu";var aH=()=>{let{t:e}=B(),t=s3();return(0,h.jsx)(eq,{"data-testid":"help-menu-item",icon:i.Bd,onSelect:()=>t.executeAction(tP),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};aH.displayName="Help";var a$=()=>{let{t:e}=B(),t=j(ib);return s3().isActionEnabled(to)?(0,h.jsx)(eq,{icon:i.ud,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};a$.displayName="ClearCanvas";var aY=e=>{let{t:t}=B(),n=o.useContext(ej),a=s3(),l=n9("toggleTheme");return a.isActionEnabled(tp)?e?.allowSystemTheme?(0,h.jsx)(aO,{name:"theme",value:e.theme,onChange:t=>e.onSelect(t),choices:[{value:i.G.LIGHT,label:i.yd,ariaLabel:`${t("buttons.lightMode")} - ${l}`},{value:i.G.DARK,label:i.xd,ariaLabel:`${t("buttons.darkMode")} - ${l}`},{value:"system",label:i.Ef,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):(0,h.jsx)(eq,{onSelect:t=>{if(t.preventDefault(),!e?.onSelect)return a.executeAction(tp);e.onSelect(n.theme===i.G.DARK?i.G.LIGHT:i.G.DARK)},icon:n.theme===i.G.DARK?i.yd:i.xd,"data-testid":"toggle-dark-mode",shortcut:l,"aria-label":t(n.theme===i.G.DARK?"buttons.lightMode":"buttons.darkMode"),children:t(n.theme===i.G.DARK?"buttons.lightMode":"buttons.darkMode")}):null};aY.displayName="ToggleTheme";var aG=()=>{let{t:e}=B(),t=o.useContext(ej),n=s3(),i=sQ();return t.viewModeEnabled||!i.UIOptions.canvasActions.changeViewBackgroundColor?null:(0,h.jsxs)("div",{style:{marginTop:"0.5rem"},children:[(0,h.jsx)("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),(0,h.jsx)("div",{style:{padding:"0 0.625rem"},children:n.renderAction("changeViewBackgroundColor")})]})};aG.displayName="ChangeCanvasBackground";var aV=()=>{let{t:e}=B(),t=s2();return(0,h.jsx)(eq,{icon:i.Ad,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};aV.displayName="Export";var aK=()=>{let{t:e}=B();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(nH,{icon:i.Ed,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),(0,h.jsx)(nH,{icon:i.Gd,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),(0,h.jsx)(nH,{icon:i.Fd,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};aK.displayName="Socials";var aZ=({onSelect:e,isCollaborating:t})=>{let{t:n}=B();return(0,h.jsx)(eq,{"data-testid":"collab-button",icon:i.fe,className:(0,m.A)({"active-collab":t}),onSelect:e,children:n("labels.liveCollaboration")})};aZ.displayName="LiveCollaborationTrigger";var aX=(e,t)=>{let n=(0,d.eU)(0),i=e=>{let{tunnelsJotai:{useAtom:i}}=o.useContext(il),[,a]=i(n),l=(0,o.useRef)({preferHost:!1,counter:0});return(0,o.useLayoutEffect)(()=>{let e=l.current;return a(t=>{let n=t+1;return e.counter=n,n}),()=>{a(t=>{let n=t-1;return e.counter=n,n||(e.preferHost=!1),n})}},[a]),e.__fallback||(l.current.preferHost=!0),!l.current.counter&&e.__fallback&&l.current.preferHost||l.current.counter>1&&e.__fallback?null:(0,h.jsx)(t,{...e})};return i.displayName=e,i},aQ=Object.assign(aX("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:n}=o.useContext(il),a=sq(),l=o.useContext(ej),s=s2(),r=a.editor.isMobile?void 0:()=>s({openMenu:null});return(0,h.jsx)(n.In,{children:(0,h.jsxs)(n$,{open:"canvas"===l.openMenu,children:[(0,h.jsx)(n$.Trigger,{onToggle:()=>{s({openMenu:"canvas"===l.openMenu?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:i.zd}),(0,h.jsxs)(n$.Content,{onClickOutside:r,onSelect:(0,i.Ib)(t,()=>{s({openMenu:null})}),children:[e,a.editor.isMobile&&l.collaborators.size>0&&(0,h.jsxs)("fieldset",{className:"UserList-Wrapper",children:[(0,h.jsx)("legend",{children:z("labels.collaborators")}),(0,h.jsx)(ax,{mobile:!0,collaborators:l.collaborators,userToFollow:l.userToFollow?.socketId||null})]})]})]})})}),{Trigger:n$.Trigger,Item:n$.Item,ItemLink:n$.ItemLink,ItemCustom:n$.ItemCustom,Group:n$.Group,Separator:n$.Separator,DefaultItems:aP}),aq=({title:e,children:t,actionLabel:n,onClick:i})=>(0,h.jsxs)("div",{className:"OverwriteConfirm__Actions__Action",children:[(0,h.jsx)("h4",{children:e}),(0,h.jsx)("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),(0,h.jsx)(iQ,{variant:"outlined",color:"muted",label:n,size:"large",fullWidth:!0,onClick:i})]}),aJ=Object.assign(({children:e})=>(0,h.jsx)("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:()=>{let{t:e}=B(),t=s3(),n=s2();return(0,h.jsx)(aq,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(tj,"ui",!0),n({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},SaveToDisk:()=>{let{t:e}=B(),t=s3();return(0,h.jsx)(aq,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(tT,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})}}),a0=Object.assign(aX("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=o.useContext(il),[n,a]=C(a_);return n.active?(0,h.jsx)(t.In,{children:(0,h.jsx)(n4,{onCloseRequest:()=>{n.onClose(),a(e=>({...e,active:!1}))},title:!1,size:916,children:(0,h.jsxs)("div",{className:"OverwriteConfirm",children:[(0,h.jsx)("h3",{children:n.title}),(0,h.jsxs)("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${n.color}`,children:[(0,h.jsx)("div",{className:"OverwriteConfirm__Description__icon",children:i.cf}),(0,h.jsx)("div",{children:n.description}),(0,h.jsx)("div",{className:"OverwriteConfirm__Description__spacer"}),(0,h.jsx)(iQ,{color:n.color,size:"large",label:n.actionLabel,onClick:()=>{n.onConfirm(),a(e=>({...e,active:!1}))}})]}),(0,h.jsx)(aJ,{children:e})]})})}):null}),{Actions:aJ,Action:aq}),a1=(0,d.eU)(""),a2=(0,d.eU)(null),a3=()=>{let e=sX(),t=s2(),n=(0,o.useRef)(null),[a,l]=C(a1),s=a.trim(),[r,d]=(0,o.useState)(!1),[c,m]=(0,o.useState)({nonce:null,items:[]}),p=(0,o.useRef)(null),u=(0,o.useRef)(void 0),[g,f]=C(a2),b=e.scene.getNonDeletedElementsMap();(0,o.useEffect)(()=>{r||(s!==p.current||e.scene.getSceneNonce()!==u.current)&&(p.current=null,a7(s,e,(n,a)=>{m({nonce:(0,i.rc)(),items:n}),p.current=s,u.current=e.scene.getSceneNonce(),t({searchMatches:n.map(e=>({id:e.textElement.id,focus:!1,matchedLines:e.matchedLines}))})}))},[r,s,b,e,t,f,u]);let x=()=>{c.items.length>0&&f(e=>null===e?0:(e+1)%c.items.length)},E=()=>{c.items.length>0&&f(e=>null===e?0:e-1<0?c.items.length-1:e-1)};(0,o.useEffect)(()=>{t(e=>({searchMatches:e.searchMatches.map((e,t)=>t===g?{...e,focus:!0}:{...e,focus:!1})}))},[g,t]),(0,o.useEffect)(()=>{if(c.items.length>0&&null!==g){let t=c.items[g];if(t){let n=e.state.zoom.value,a=(0,i.Xf)({text:t.searchQuery,x:t.textElement.x+(t.matchedLines[0]?.offsetX??0),y:t.textElement.y+(t.matchedLines[0]?.offsetY??0),width:t.matchedLines[0]?.width,height:t.matchedLines[0]?.height,fontSize:t.textElement.fontSize,fontFamily:t.textElement.fontFamily}),l=t.textElement.fontSize,s=l*n<14;if(!(0,i.Uj)([a],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||s){let t;t=s?l>=14?{fitToContent:!0}:{fitToViewport:!0,maxZoom:(0,i.Ja)(14/l,1)}:{fitToContent:!0},e.scrollToContent(a,{animate:!0,duration:300,...t,canvasOffsets:e.getEditorUIOffsets()})}}}},[g,c,e]),(0,o.useEffect)(()=>()=>{f(null),p.current=null,u.current=void 0,t({searchMatches:[]}),d(!1)},[t,f]);let y=eM({goToNextItem:x,goToPreviousItem:E,searchMatches:c});(0,o.useEffect)(()=>(0,i.Pb)(window,"keydown",a=>{if(a.key===i.hg.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){a.preventDefault(),a.stopPropagation(),t({openSidebar:null});return}a[i.hg.CTRL_OR_CMD]&&a.key===i.hg.F&&(a.preventDefault(),a.stopPropagation(),n.current?.matches(":focus")?t({openSidebar:null}):(e.state.openDialog&&t({openDialog:null}),n.current?.focus(),n.current?.select())),a.target instanceof HTMLElement&&a.target.closest(".layer-ui__search")&&y.searchMatches.items.length&&(a.key===i.hg.ENTER&&(a.stopPropagation(),y.goToNextItem()),a.key===i.hg.ARROW_UP?(a.stopPropagation(),y.goToPreviousItem()):a.key===i.hg.ARROW_DOWN&&(a.stopPropagation(),y.goToNextItem()))},{capture:!0,passive:!1}),[t,y,e]);let v=`${c.items.length} ${1===c.items.length?z("search.singleResult"):z("search.multipleResults")}`;return(0,h.jsxs)("div",{className:"layer-ui__search",children:[(0,h.jsx)("div",{className:"layer-ui__search-header",children:(0,h.jsx)(n8,{className:i.E.SEARCH_MENU_INPUT_WRAPPER,value:a,ref:n,placeholder:z("search.placeholder"),icon:i.pf,onChange:n=>{l(n),d(!0);let a=n.trim();a7(a,e,(n,l)=>{m({nonce:(0,i.rc)(),items:n}),f(l),p.current=a,u.current=e.scene.getSceneNonce(),t({searchMatches:n.map(e=>({id:e.textElement.id,focus:!1,matchedLines:e.matchedLines}))}),d(!1)})},selectOnRender:!0})}),(0,h.jsxs)("div",{className:"layer-ui__search-count",children:[c.items.length>0&&(0,h.jsxs)(h.Fragment,{children:[null!==g&&g>-1?(0,h.jsxs)("div",{children:[g+1," / ",v]}):(0,h.jsx)("div",{children:v}),(0,h.jsxs)("div",{className:"result-nav",children:[(0,h.jsx)(n6,{onSelect:()=>{x()},className:"result-nav-btn",children:i.Lf}),(0,h.jsx)(n6,{onSelect:()=>{E()},className:"result-nav-btn",children:i.Nf})]})]}),0===c.items.length&&s&&p.current&&(0,h.jsx)("div",{style:{margin:"1rem auto"},children:z("search.noMatch")})]}),(0,h.jsx)(a4,{matches:c,onItemClick:f,focusIndex:g,searchQuery:s})]})},a5=e=>{let t=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return(0,h.jsx)("div",{tabIndex:-1,className:(0,m.A)("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:(0,h.jsx)("div",{className:"preview-text",children:t.flatMap((e,t)=>(0,h.jsx)(o.Fragment,{children:2===t?(0,h.jsx)("b",{children:e}):e},t))})})},a4=(0,o.memo)(e=>(0,h.jsx)("div",{className:"layer-ui__search-result-container",children:e.matches.items.map((t,n)=>(0,h.jsx)(a5,{searchQuery:e.searchQuery,preview:t.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},t.textElement.id+t.index))}),(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex),a6=(e,t,n)=>{let i=e.slice(0,t),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-!l,r=a.slice(s<=0?0:s).join(" ")+(l?" ":"");r=r.length>20?r.slice(-20):r;let o=e.slice(t+n.length),d=o.split(/\s+/),c=!o.startsWith(" "),h=c?6:5,m=(c?"":" ")+d.slice(0,h).join(" ");return{indexInSearchQuery:r.length,previewText:r+n+m,moreBefore:s>0,moreAfter:d.length>h}},a8=(e,t,n)=>{let a=((e,t)=>{let n=e.split(`
`),i=[],a=0;for(let e=0;e<n.length;e++){let l=n[e],s=n[e+1];if(s){let e=t.indexOf(s,a);if(e>l.length+a){let t=e-(l.length+a);for(;t>0;)l+=" ",t--}}i.push(l),a+=l.length}return i.join(`
`)})(e.text,e.originalText).split(`
`),l=[],s=0,r=0;for(let e of a){let t=s,n=t+e.length-1;l.push({line:e,startIndex:t,endIndex:n,lineNumber:r}),s=n+1,r++}let o=n,d=e.originalText.slice(n,n+t.length),c=[];for(let t of l){if(""===d)break;if(o>=t.startIndex&&o<=t.endIndex){let n=t.endIndex+1-o,a=t.line.slice(0,o-t.startIndex),l=d.slice(0,n);d=d.slice(n);let s=(0,i.vc)(a,(0,i.cb)(e),e.lineHeight);if(""===a&&(s.width=0),"left"!==e.textAlign&&t.line.length>0){let n=(0,i.vc)(t.line,(0,i.cb)(e),e.lineHeight),a="center"===e.textAlign?(e.width-n.width)/2:e.width-n.width;s.width+=a}let{width:r,height:h}=(0,i.vc)(l,(0,i.cb)(e),e.lineHeight),m=s.width,p=t.lineNumber*s.height;c.push({offsetX:m,offsetY:p,width:r,height:h}),o+=n}}return c},a7=w((e,t,n)=>{if(!e||""===e)return void n([],null);let a=t.scene.getNonDeletedElements().filter(e=>(0,i._b)(e));a.sort((e,t)=>e.y-t.y);let l=[],s=RegExp(e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),"gi");for(let t of a){let n=null,i=t.originalText;for(;null!==(n=s.exec(i));){let a=a6(i,n.index,e),s=a8(t,e,n.index);s.length>0&&l.push({textElement:t,searchQuery:e,preview:a,index:n.index,matchedLines:s})}}let r=new Set(t.visibleElements.map(e=>e.id)),o=l.findIndex(e=>r.has(e.textElement.id))??null;n(l,o)},350),a9=aX("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=o.useContext(il);return(0,h.jsx)(t.In,{children:(0,h.jsx)(aA.Trigger,{...e,className:"default-sidebar-trigger",name:i.ya.name})})});a9.displayName="DefaultSidebarTrigger";var le=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=o.useContext(il);return(0,h.jsx)(t.In,{children:e})};le.displayName="DefaultTabTriggers";var lt=Object.assign(aX("DefaultSidebar",({children:e,className:t,onDock:n,docked:a,...l})=>{let s=o.useContext(ej),r=s2(),{DefaultSidebarTabTriggersTunnel:d}=o.useContext(il),c=s.openSidebar?.tab===i.xa;return(0,o.createElement)(aA,{...l,name:"default",key:"default",className:(0,m.A)("default-sidebar",t),docked:c||(a??s.defaultSidebarDockedPreference),onDock:c||!1===n||!n&&null!=a?void 0:(0,i.Ib)(n,e=>{r({defaultSidebarDockedPreference:e})})},(0,h.jsxs)(aA.Tabs,{children:[(0,h.jsx)(aA.Header,{children:(0,h.jsxs)(aA.TabTriggers,{children:[(0,h.jsx)(aA.TabTrigger,{tab:i.xa,children:i.pf}),(0,h.jsx)(aA.TabTrigger,{tab:i.wa,children:i.fd}),(0,h.jsx)(d.Out,{})]})}),(0,h.jsx)(aA.Tab,{tab:i.wa,children:(0,h.jsx)(n5,{})}),(0,h.jsx)(aA.Tab,{tab:i.xa,children:(0,h.jsx)(a3,{})}),e]}))}),{Trigger:a9,TabTriggers:le}),ln=e=>(0,h.jsxs)("label",{className:(0,m.A)("ToolIcon ToolIcon__LaserPointer","ToolIcon_size_small",{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,h.jsx)("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),(0,h.jsx)("div",{className:"ToolIcon__icon",children:i.if})]}),li=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:n,setError:a,data:l})=>{let s=e.current,r=s?.parentElement;if(!(!s||!r)){if(!n)return void(({canvasRef:e,setError:t})=>{let n=e.current;if(!n)return;let i=n.parentElement;i&&(i.style.background="",t(null),n.replaceChildren())})({canvasRef:e,setError:a});try{let e=await t.api,o;try{o=await e.parseMermaidToExcalidraw(n)}catch{o=await e.parseMermaidToExcalidraw(n.replace(/"/g,"'"))}let{elements:d,files:c={}}=o;a(null),l.current={elements:ss(d,{regenerateIds:!0}),files:c};let h=await (0,i.pi)({elements:l.current.elements,files:l.current.files,exportPadding:i.ma,maxWidthOrHeight:Math.max(r.offsetWidth,r.offsetHeight)*window.devicePixelRatio});try{await (0,i.yh)(h)}catch(e){throw"CANVAS_POSSIBLY_TOO_BIG"===e.name?Error(z("canvasError.canvasTooBig")):e}r.style.background="var(--default-bg-color)",s.replaceChildren(h)}catch(e){throw r.style.background="var(--default-bg-color)",n&&a(e),e}}},la=e=>{nR.set(i.Ba.MERMAID_TO_EXCALIDRAW,e)},ll=({app:e,data:t,text:n,shouldSaveMermaidDataToStorage:i})=>{let{elements:a,files:l}=t.current;a.length&&(e.addElementsFromPasteOrLibrary({elements:a,files:l,position:"center",fitToContent:!0}),e.setOpenDialog(null),i&&n&&la(n))},ls=({children:e})=>(0,h.jsx)("div",{className:"ttd-dialog-panels",children:e}),lr=({label:e,children:t,panelAction:n,panelActionDisabled:i=!1,onTextSubmitInProgess:a,renderTopRight:l,renderSubmitShortcut:s,renderBottomRight:r})=>(0,h.jsxs)("div",{className:"ttd-dialog-panel",children:[(0,h.jsxs)("div",{className:"ttd-dialog-panel__header",children:[(0,h.jsx)("label",{children:e}),l?.()]}),t,(0,h.jsxs)("div",{className:(0,m.A)("ttd-dialog-panel-button-container",{invisible:!n}),style:{display:"flex",alignItems:"center"},children:[(0,h.jsxs)(n6,{className:"ttd-dialog-panel-button",onSelect:n?n.action:()=>{},disabled:i||a,children:[(0,h.jsxs)("div",{className:(0,m.A)({invisible:a}),children:[n?.label,n?.icon&&(0,h.jsx)("span",{children:n.icon})]}),a&&(0,h.jsx)(W,{})]}),!i&&!a&&s?.(),r?.()]})]}),lo=({input:e,placeholder:t,onChange:n,onKeyboardSubmit:a})=>{let l=(0,o.useRef)(null),s=(0,o.useRef)(a);return s.current=a,(0,o.useEffect)(()=>{if(!s.current)return;let e=l.current;if(e){let t=e=>{e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.ENTER&&(e.preventDefault(),s.current?.())};return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}}},[]),(0,h.jsx)("textarea",{className:"ttd-dialog-input",onChange:n,value:e,placeholder:t,autoFocus:!0,ref:l})},ld=({error:e})=>(0,h.jsxs)("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",(0,h.jsx)("p",{children:e})]}),lc=({error:e,canvasRef:t,loaded:n})=>(0,h.jsxs)("div",{className:"ttd-dialog-output-wrapper",children:[e&&(0,h.jsx)(ld,{error:e.message}),n?(0,h.jsx)("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):(0,h.jsx)(W,{size:"2rem"})]}),lh=()=>(0,h.jsxs)("div",{className:"ttd-dialog-submit-shortcut",children:[(0,h.jsx)("div",{className:"ttd-dialog-submit-shortcut__key",children:(0,i.kb)("CtrlOrCmd")}),(0,h.jsx)("div",{className:"ttd-dialog-submit-shortcut__key",children:(0,i.kb)("Enter")})]}),lm=`flowchart TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[Car]`,lp=(0,i.db)(la,300),lu=({mermaidToExcalidrawLib:e})=>{let[t,n]=(0,o.useState)(()=>nR.get(i.Ba.MERMAID_TO_EXCALIDRAW)||lm),a=(0,o.useDeferredValue)(t.trim()),[l,s]=(0,o.useState)(null),r=(0,o.useRef)(null),d=(0,o.useRef)({elements:[],files:null}),c=sX();(0,o.useEffect)(()=>{li({canvasRef:r,data:d,mermaidToExcalidrawLib:e,setError:s,mermaidDefinition:a}).catch(e=>{(0,i.Bb)()&&console.error("Failed to parse mermaid definition",e)}),lp(a)},[a,e]),(0,o.useEffect)(()=>()=>{lp.flush()},[]);let m=()=>{ll({app:c,data:d,text:t,shouldSaveMermaidDataToStorage:!0})};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"ttd-dialog-desc",children:(0,h.jsx)(nA,{i18nKey:"mermaid.description",flowchartLink:e=>(0,h.jsx)("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:e}),sequenceLink:e=>(0,h.jsx)("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:e}),classLink:e=>(0,h.jsx)("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:e})})}),(0,h.jsxs)(ls,{children:[(0,h.jsx)(lr,{label:z("mermaid.syntax"),children:(0,h.jsx)(lo,{input:t,placeholder:"Write Mermaid diagram defintion here...",onChange:e=>n(e.target.value),onKeyboardSubmit:()=>{m()}})}),(0,h.jsx)(lr,{label:z("mermaid.preview"),panelAction:{action:()=>{m()},label:z("mermaid.button"),icon:i.hf},renderSubmitShortcut:()=>(0,h.jsx)(lh,{}),children:(0,h.jsx)(lc,{canvasRef:r,loaded:e.loaded,error:l})})]})]})},lg=e=>{let t=s2(),n=(0,o.useRef)(null),a=(0,o.useRef)(0);return(0,h.jsx)(v.bL,{ref:n,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:l=>{if(!l)return;let s=n.current?.closest(".Modal__content");if(s){let e=s.offsetHeight||0;e>a.current&&(a.current=e,s.style.minHeight=`min(${a.current}px, 100%)`)}"ttd"===e.dialog&&(0,i.Mb)(["text-to-diagram","mermaid"],l)&&t({openDialog:{name:e.dialog,tab:l}})},children:e.children})};lg.displayName="TTDDialogTabs";var lf=({children:e,...t})=>(0,h.jsx)(v.B8,{className:"ttd-dialog-triggers",...t,children:e});lf.displayName="TTDDialogTabTriggers";var lb=({children:e,tab:t,onSelect:n,...i})=>(0,h.jsx)(v.l9,{value:t,asChild:!0,onSelect:n,children:(0,h.jsx)("button",{type:"button",className:"ttd-dialog-tab-trigger",...i,children:e})});lb.displayName="TTDDialogTabTrigger";var lx=({tab:e,children:t,...n})=>(0,h.jsx)(v.UC,{...n,value:e,children:t});lx.displayName="TTDDialogTab";var lE=(0,d.eU)(null),ly=(0,d.eU)(null),lv=e=>{let t=o.useContext(ej);return t.openDialog?.name!=="ttd"?null:(0,h.jsx)(lw,{...e,tab:t.openDialog.tab})},lw=aX("TTDDialogBase",({tab:e,...t})=>{let a=sX(),l=s2(),s=(0,o.useRef)(null),[r,d]=C(ly),[c,m]=(0,o.useState)(r?.prompt??""),p=c.trim(),[u,g]=(0,o.useState)(!1),[f,b]=C(lE),x=async()=>{if(p.length>1e3||p.length<3||u||f?.rateLimitRemaining===0||"__fallback"in t){p.length<3&&k(Error("Prompt is too short (min 3 characters)")),p.length>1e3&&k(Error("Prompt is too long (max 1000 characters)"));return}try{g(!0),ed("ai","generate","ttd");let{generatedResponse:e,error:n,rateLimit:a,rateLimitRemaining:l}=await t.onTextSubmit(p);if("string"==typeof e&&d(t=>({generatedResponse:e,prompt:t?.prompt??null})),(0,i.La)(a)&&(0,i.La)(l)&&b({rateLimit:a,rateLimitRemaining:l}),n)return void k(n);if(!e)return void k(Error("Generation failed"));try{await li({canvasRef:s,data:w,mermaidToExcalidrawLib:y,setError:k,mermaidDefinition:e}),ed("ai","mermaid parse success","ttd")}catch(e){console.info(`%cTTD mermaid render errror: ${e.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
TTD mermaid definition render errror: ${e.message}`,"color: yellow"),ed("ai","mermaid parse failed","ttd"),k(Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(t){let e=t.message;e&&"Failed to fetch"!==e||(e="Request failed"),k(Error(e))}finally{g(!1)}},E=(0,o.useRef)(x);E.current=x;let[y,v]=(0,o.useState)({loaded:!1,api:Promise.all([n.e(159),n.e(2425),n.e(8356),n.e(709),n.e(9838),n.e(1845)]).then(n.bind(n,38134))});(0,o.useEffect)(()=>{(async()=>{await y.api,v(e=>({...e,loaded:!0}))})()},[y.api]);let w=(0,o.useRef)({elements:[],files:null}),[S,k]=(0,o.useState)(null);return(0,h.jsx)(n4,{className:"ttd-dialog",onCloseRequest:()=>{a.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:(0,h.jsxs)(lg,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?(0,h.jsx)("p",{className:"dialog-mermaid-title",children:z("mermaid.title")}):(0,h.jsxs)(lf,{children:[(0,h.jsx)(lb,{tab:"text-to-diagram",children:(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[z("labels.textToDiagram"),(0,h.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"AI Beta"})]})}),(0,h.jsx)(lb,{tab:"mermaid",children:"Mermaid"})]}),(0,h.jsx)(lx,{className:"ttd-dialog-content",tab:"mermaid",children:(0,h.jsx)(lu,{mermaidToExcalidrawLib:y})}),!("__fallback"in t)&&(0,h.jsxs)(lx,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[(0,h.jsx)("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."}),(0,h.jsxs)(ls,{children:[(0,h.jsx)(lr,{label:z("labels.prompt"),panelAction:{action:x,label:"Generate",icon:i.hf},onTextSubmitInProgess:u,panelActionDisabled:p.length>1e3||f?.rateLimitRemaining===0,renderTopRight:()=>f?(0,h.jsxs)("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:0===f.rateLimitRemaining?"var(--color-danger)":void 0},children:[f.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>(0,h.jsx)(lh,{}),renderBottomRight:()=>{if("string"==typeof r?.generatedResponse)return(0,h.jsxs)("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{"string"==typeof r?.generatedResponse&&(la(r.generatedResponse),l({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",(0,h.jsx)(eU,{icon:i.hf})]});let e=p.length/1e3;return e>.8?(0,h.jsxs)("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:e>1?"var(--color-danger)":void 0},children:["Length: ",p.length,"/",1e3]}):null},children:(0,h.jsx)(lo,{onChange:e=>{m(e.target.value),d(t=>({generatedResponse:t?.generatedResponse??null,prompt:e.target.value}))},input:c,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{E.current()}})}),(0,h.jsx)(lr,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),ll({app:a,data:w})},label:"Insert",icon:i.hf},children:(0,h.jsx)(lc,{canvasRef:s,error:S,loaded:y.loaded})})]})]})]})})}),lS=(e,t)=>!("height"===t&&(0,i._b)(e)||"width"===t&&(0,i._b)(e)||"angle"===t&&(0,i.bc)(e)),lk=(e,t)=>{let n=e+t/2;return n-n%t},lC=(e,t,n)=>Object.keys(e).map(e=>({original:(n??t).get(e),latest:t.get(e)})).filter(e=>void 0!==e.original&&void 0!==e.latest),lj=(e,t,n,a,l,s,r,o=!0)=>{let d=a.get(n.id);if(!d)return;let[c,h]=[n.x+n.width/2,n.y+n.height/2],[m,p]=(0,i.Va)((0,i.Ua)(n.x,n.y),(0,i.Ua)(c,h),n.angle),u=e-m,g=t-p,[f,b]=(0,i.Va)((0,i.Ua)(e,t),(0,i.Ua)(c+u,h+g),-n.angle);(0,i.Pj)(d,{x:f,y:b},o),lT(d,a,l,s);let x=(0,i.zj)(n,r);if(x){let e=a.get(x.id);e&&(0,i.Pj)(e,{x:x.x+u,y:x.y+g},o)}},lI=(e,t)=>{let n=(0,i.Mc)(t).map(t=>(0,i.Qc)(e,t).reduce((e,t)=>(e[t.id]=!0,e),{}));return e.filter(e=>!(0,i.Wc)(e)).forEach(e=>{n.push({[e.id]:!0})}),n},lT=(e,t,n,a,l)=>{(0,i.cc)(e)?(0,i.Jg)([e],t,n,a,!0,[],l?.zoom):(0,i.Pg)(e,t,l)},lM=({label:e,icon:t,dragInputCallback:n,value:a,elements:l,editable:s=!0,shouldKeepAspectRatio:r,property:d,scene:c,appState:p,sensitivity:u=1})=>{let g=sX(),f=(0,o.useRef)(null),b=(0,o.useRef)(null),[x,E]=(0,o.useState)(a.toString()),y=(0,o.useRef)(null);y.current||(y.current={originalAppState:(0,i.Nb)(p),originalElements:l,lastUpdatedValue:x,updatePending:!1}),(0,o.useEffect)(()=>{let e=a.toString();E(e),y.current.lastUpdatedValue=e},[a]);let v=(e,t,l)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let s=Number(e);if(isNaN(s))return void E(a.toString());let o=Number(s.toFixed(2)),h=Number(a);(isNaN(h)||Math.abs(o-h)>=.01)&&(y.current.lastUpdatedValue=e,n({accumulatedChange:0,instantChange:0,originalElements:t,originalElementsMap:g.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:r,shouldChangeByStepSize:!1,scene:c,nextValue:o,property:d,originalAppState:l,setInputValue:e=>E(String(e))}),g.syncActionResult({captureUpdate:i.Wg.IMMEDIATELY}))},w=(0,o.useRef)({});return w.current.handleInputValue=v,(0,o.useEffect)(()=>{let e=f.current,t=w.current;return()=>{let n=e?.value;n&&t.handleInputValue?.(n,y.current.originalElements,y.current.originalAppState),window.removeEventListener("pointermove",t.onPointerMove,!1),window.removeEventListener("pointerup",t.onPointerUp,!1)}},[s]),s?(0,h.jsxs)("div",{className:(0,m.A)("drag-input-container",!s&&"disabled"),"data-testid":e,children:[(0,h.jsx)("div",{className:"drag-input-label",ref:b,onPointerDown:e=>{if(f.current&&s){document.body.classList.add("excalidraw-cursor-resize");let e=Number(f.current.value);isNaN(e)&&(e=0);let t=null,a=g.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,(0,i.bg)(t)),e),new Map),s=l.map(e=>a.get(e.id)),o=(0,i.Nb)(p),h=0,m=0,b=e=>{if(t&&null!==a&&null!==s){let i=e.clientX-t.x;0!==i&&Math.abs(m+=i)>=u&&(n({accumulatedChange:h+=m=Math.sign(m)*Math.floor(Math.abs(m)/u),instantChange:m,originalElements:s,originalElementsMap:a,shouldKeepAspectRatio:r,shouldChangeByStepSize:e.shiftKey,property:d,scene:c,originalAppState:o,setInputValue:e=>E(String(e))}),m=0)}t={x:e.clientX,y:e.clientY}},x=()=>{window.removeEventListener("pointermove",b,!1),g.syncActionResult({captureUpdate:i.Wg.IMMEDIATELY}),t=null,h=0,m=0,s=null,a=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",x,!1)};w.current.onPointerMove=b,w.current.onPointerUp=x,window.addEventListener("pointermove",b,!1),window.addEventListener("pointerup",x,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:t?(0,h.jsx)(eU,{icon:t}):e}),(0,h.jsx)("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:e=>{if(s){let t=e.target;t instanceof HTMLInputElement&&e.key===i.hg.ENTER&&(v(t.value,l,p),g.focusContainer())}},ref:f,value:x,onChange:e=>{y.current.updatePending=!0,E(e.target.value)},onFocus:e=>{e.target.select(),y.current.originalElements=l,y.current.originalAppState=(0,i.Nb)(p)},onBlur:e=>{x?s&&v(e.target.value,y.current.originalElements,y.current.originalAppState):E(a.toString())},disabled:!s})]}):null},lD=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldKeepAspectRatio:a,shouldChangeByStepSize:l,nextValue:s,property:r,originalAppState:o,instantChange:d,scene:c})=>{let h=c.getNonDeletedElementsMap(),m=t[0],p=h.get(m.id);if(m&&p){let t=a||"image"===m.type,c=m.width/m.height;if(o.croppingElementId===m.id){let e=h.get(m.id);if(!e||!(0,i.Wb)(e)||!e.crop)return;let t=e.crop,n={...t},a=-1===e.scale[0],l=-1===e.scale[1],{width:o,height:c}=(0,i.ch)(e),p=t.naturalWidth/o,u=t.naturalHeight/c,g=a?t.width+t.x:t.naturalWidth-t.x,f=l?t.height+t.y:t.naturalHeight-t.y,b=i.ah*p,x=i.ah*u;if(void 0!==s){if("width"===r){let e=s*p,l=(0,i.Ia)(e,b,g);n={...n,width:l,x:a?t.x+t.width-l:t.x}}else if("height"===r){let e=s*u,a=(0,i.Ia)(e,x,f);n={...n,height:a,y:l?t.y+t.height-a:t.y}}(0,i.Pj)(e,{crop:n,width:n.width/(t.naturalWidth/o),height:n.height/(t.naturalHeight/c)});return}let E=(0,i.Ia)(t.width+("width"===r?d:0),b,g),y=(0,i.Ia)(t.height+("height"===r?d:0),b,f);n={...t,x:a?t.x+t.width-E:t.x,y:l?t.y+t.height-y:t.y,width:E,height:y},(0,i.Pj)(e,{crop:n,width:n.width/(t.naturalWidth/o),height:n.height/(t.naturalHeight/c)});return}if(void 0!==s){let e=Math.max("width"===r?s:t?s*c:m.width,i.Ea),a=Math.max("height"===r?s:t?s/c:m.height,i.Ea);(0,i.gk)(e,a,p,m,h,n,"width"===r?"e":"s",{shouldMaintainAspectRatio:t});return}let u=Math.max(0,m.width+("width"===r?e:0));"width"===r&&(u=l?lk(u,10):Math.round(u));let g=Math.max(0,m.height+("height"===r?e:0));"height"===r&&(g=l?lk(g,10):Math.round(g)),t&&("width"===r?g=Math.round(u/c*100)/100:u=Math.round(g*c*100)/100),g=Math.max(i.Ea,g),u=Math.max(i.Ea,u),(0,i.gk)(u,g,p,m,h,n,"width"===r?"e":"s",{shouldMaintainAspectRatio:t})}},lL=({property:e,element:t,scene:n,appState:a})=>{let l=(0,i.Ja)("width"===e?t.width:t.height,2);if(a.croppingElementId&&a.croppingElementId===t.id&&(0,i.Wb)(t)&&t.crop){let{width:n,height:a}=(0,i.ch)(t);if("width"===e){let e=n/t.crop.naturalWidth;l=(0,i.Ja)(t.crop.width*e,2)}if("height"===e){let e=a/t.crop.naturalHeight;l=(0,i.Ja)(t.crop.height*e,2)}}return(0,h.jsx)(lM,{label:"width"===e?"W":"H",elements:[t],dragInputCallback:lD,value:l,editable:lS(t,e),scene:n,appState:a,property:e})},lN=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:a,scene:l})=>{let s=l.getNonDeletedElementsMap(),r=l.getNonDeletedElements(),o=t[0];if(o&&!(0,i.ec)(o)){let t=s.get(o.id);if(!t)return;if(void 0!==a){let e=(0,i.Ma)(a);(0,i.Pj)(t,{angle:e}),lT(t,s,r,l);let n=(0,i.zj)(t,s);n&&!(0,i.dc)(t)&&(0,i.Pj)(n,{angle:e});return}let d=(Math.round(100*(0,i.Na)(o.angle))/100+Math.round(e))%360;n&&(d=lk(d,15)),d=d<0?d+360:d;let c=(0,i.Ma)(d);(0,i.Pj)(t,{angle:c}),lT(t,s,r,l);let h=(0,i.zj)(t,s);h&&!(0,i.dc)(t)&&(0,i.Pj)(h,{angle:c})}},lA=({element:e,scene:t,appState:n,property:a})=>(0,h.jsx)(lM,{label:"A",icon:i.We,value:Math.round((0,i.Na)(e.angle)%360*100)/100,elements:[e],dragInputCallback:lN,editable:lS(e,"angle"),scene:t,appState:n,property:a}),lP=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:a,scene:l})=>{let s=l.getNonDeletedElementsMap(),r=t[0];if(r){let t,o=s.get(r.id);if(!o||!(0,i._b)(o))return;void 0!==a?t=Math.max(Math.round(a),4):"text"===r.type&&(t=Math.max(Math.round(r.fontSize)+Math.round(e),4),n&&(t=lk(t,4))),t&&((0,i.Pj)(o,{fontSize:t}),(0,i.uj)(o,l.getContainerElement(o),l.getNonDeletedElementsMap()))}},l_=({element:e,scene:t,appState:n,property:a})=>{let l=(0,i._b)(e)?e:(0,i.mc)(e)?(0,i.zj)(e,t.getNonDeletedElementsMap()):null;return l?(0,h.jsx)(lM,{label:"F",value:Math.round(10*l.fontSize)/10,elements:[l],dragInputCallback:lP,icon:i.Ne,appState:n,scene:t,property:a}):null},lR=(e,t,n,a,l,s,r,o)=>{let d,c,h,m,p=(d=s.x-e,c=s.y-t,{width:h=s.width*a,height:m=s.height*a,x:e+d*a,y:t+c*a,...(0,i.dk)(s,h,m,!1),...(0,i._b)(s)?{fontSize:s.fontSize*a}:{}});(0,i.Pj)(l,p,!1);let u=(0,i.zj)(s,o);if(u){let e=u.fontSize*a;(0,i.Pg)(l,r,{newSize:{width:p.width,height:p.height}});let t=r.get(u.id);t&&(0,i._b)(t)&&((0,i.Pj)(t,{fontSize:e},!1),(0,i.wj)(l,r,"width"===n?"e":"s",!0))}},lO=(e,t,n,i,a,l,s,r,o,d)=>{"width"===l?t=Math.round(e/i*100)/100:e=Math.round(t*i*100)/100;let c=t/n;for(let e=0;e<r.length;e++){let t=r[e],n=s[e];lR(a[0],a[1],l,c,n,t,o,d)}},lF=({accumulatedChange:e,originalElements:t,originalElementsMap:n,originalAppState:a,shouldChangeByStepSize:l,nextValue:s,scene:r,property:o})=>{let d=r.getNonDeletedElementsMap(),c=lI(t,a);if(void 0!==s){for(let e of c){let t=lC(e,d,n);if(t.length>1){let e=t.map(e=>e.latest),a=t.map(e=>e.original),[l,r,c,h]=(0,i.bj)(a),m=c-l,p=h-r,u=m/p;lO(Math.max(i.Ea,"width"===o?Math.max(0,s):m),Math.max(i.Ea,"height"===o?Math.max(0,s):p),p,u,(0,i.Ua)(l,r),o,e,a,d,n)}else{let[e]=t,a=e?.latest,r=e?.original;if(a&&r&&lS(a,o)){let e="width"===o?Math.max(0,s):a.width;"width"===o&&(e=l?lk(e,10):Math.round(e));let t="height"===o?Math.max(0,s):a.height;"height"===o&&(t=l?lk(t,10):Math.round(t)),e=Math.max(i.Ea,e),t=Math.max(i.Ea,t),(0,i.gk)(e,t,a,r,d,n,"width"===o?"e":"s",{shouldInformMutation:!1})}}}r.triggerUpdate();return}let h="width"===o?e:0,m="height"===o?e:0;for(let e of c){let t=lC(e,d,n);if(t.length>1){let e=t.map(e=>e.latest),a=t.map(e=>e.original),[s,r,c,p]=(0,i.bj)(a),u=c-s,g=p-r,f=u/g,b=Math.max(0,u+h);"width"===o&&(b=l?lk(b,10):Math.round(b));let x=Math.max(0,g+m);"height"===o&&(x=l?lk(x,10):Math.round(x)),lO(b=Math.max(i.Ea,b),x=Math.max(i.Ea,x),g,f,(0,i.Ua)(s,r),o,e,a,d,n)}else{let[e]=t,a=e?.latest,s=e?.original;if(a&&s&&lS(a,o)){let e=Math.max(0,s.width+h);"width"===o&&(e=l?lk(e,10):Math.round(e));let t=Math.max(0,s.height+m);"height"===o&&(t=l?lk(t,10):Math.round(t)),e=Math.max(i.Ea,e),t=Math.max(i.Ea,t),(0,i.gk)(e,t,a,s,d,n,"width"===o?"e":"s",{shouldInformMutation:!1})}}}r.triggerUpdate()},lz=({property:e,elements:t,elementsMap:n,atomicUnits:a,scene:l,appState:s})=>{let r=(0,o.useMemo)(()=>a.map(t=>{let a=lC(t,n);if(a.length>1){let[t,n,l,s]=(0,i.bj)(a.map(e=>e.latest));return Math.round(("width"===e?l-t:s-n)*100)/100}let[l]=a;return Math.round(("width"===e?l.latest.width:l.latest.height)*100)/100}),[n,a,e]),d=1===new Set(r).size?Math.round(100*r[0])/100:"Mixed",c=r.length>0;return(0,h.jsx)(lM,{label:"width"===e?"W":"H",elements:t,dragInputCallback:lF,value:d,editable:c,appState:s,property:e,scene:l})},lU=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:a,property:l,scene:s})=>{let r=s.getNonDeletedElementsMap(),o=t.map(e=>r.get(e.id)).filter(e=>e&&!(0,i.Wc)(e)&&lS(e,l)),d=t.filter(e=>!(0,i.Wc)(e)&&lS(e,l));if(void 0!==a){let e=(0,i.Ma)(a);for(let t of o){if(!t)continue;(0,i.Pj)(t,{angle:e},!1);let n=(0,i.zj)(t,r);n&&!(0,i.dc)(t)&&(0,i.Pj)(n,{angle:e},!1)}s.triggerUpdate();return}for(let t=0;t<o.length;t++){let a=o[t];if(!a)continue;let l=d[t],s=(Math.round(100*(0,i.Na)(l.angle))/100+Math.round(e))%360;n&&(s=lk(s,15)),s=s<0?s+360:s;let c=(0,i.Ma)(s);(0,i.Pj)(a,{angle:c},!1);let h=(0,i.zj)(a,r);h&&!(0,i.dc)(a)&&(0,i.Pj)(h,{angle:c},!1)}s.triggerUpdate()},lB=({elements:e,scene:t,appState:n,property:a})=>{let l=e.filter(e=>!(0,i.Wc)(e)&&lS(e,"angle")),s=l.map(e=>Math.round((0,i.Na)(e.angle)%360*100)/100),r=1===new Set(s).size?s[0]:"Mixed",o=l.some(e=>lS(e,"angle"));return(0,h.jsx)(lM,{label:"A",icon:i.We,value:r,elements:e,dragInputCallback:lU,editable:o,appState:n,scene:t,property:a})},lW=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:a,scene:l})=>{let s=l.getNonDeletedElementsMap(),r=t.map(e=>s.get(e.id)),o;if(a){for(let e of(o=Math.max(Math.round(a),4),r))(0,i.Pj)(e,{fontSize:o},!1),(0,i.uj)(e,l.getContainerElement(e),s,!1);l.triggerUpdate()}else{for(let a=0;a<r.length;a++){let o=r[a],d=Math.max(Math.round(t[a].fontSize)+Math.round(e),4);n&&(d=lk(d,4)),(0,i.Pj)(o,{fontSize:d},!1),(0,i.uj)(o,l.getContainerElement(o),s,!1)}l.triggerUpdate()}},lH=({elements:e,scene:t,appState:n,property:a,elementsMap:l})=>{let s=e.reduce((e,t)=>{if(!t||(0,i.Wc)(t))return e;if((0,i._b)(t))return e.push(t),e;if((0,i.mc)(t)){let n=(0,i.zj)(t,l);if(n)return e.push(n),e}return e},[]);if(!s.length)return null;let r=s.map(e=>Math.round(10*e.fontSize)/10),o=1===new Set(r).size?r[0]:"Mixed",d=r.length>0;return(0,h.jsx)(lM,{label:"F",icon:i.Ne,elements:s,dragInputCallback:lW,value:o,editable:d,scene:t,property:a,appState:n})},l$=({accumulatedChange:e,instantChange:t,originalElements:n,originalElementsMap:a,shouldChangeByStepSize:l,nextValue:s,property:r,scene:o,originalAppState:d})=>{let c=o.getNonDeletedElementsMap(),h=o.getNonDeletedElements(),m=n[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[g,f]=(0,i.Va)((0,i.Ua)(m.x,m.y),(0,i.Ua)(p,u),m.angle);if(d.croppingElementId===m.id){let e=c.get(m.id);if(!e||!(0,i.Wb)(e)||!e.crop)return;let n=e.crop,a=n,l=-1===e.scale[0],o=-1===e.scale[1],{width:d,height:h}=(0,i.ch)(e);if(void 0!==s){if("x"===r){let e=s*(n.naturalWidth/d);a=l?{...n,x:(0,i.Ia)(n.naturalWidth-e-n.width,0,n.naturalWidth-n.width)}:{...n,x:(0,i.Ia)(s*(n.naturalWidth/d),0,n.naturalWidth-n.width)}}"y"===r&&(a={...n,y:(0,i.Ia)(s*(n.naturalHeight/h),0,n.naturalHeight-n.height)}),(0,i.Pj)(e,{crop:a});return}a={...n,x:(0,i.Ia)(n.x+("x"===r?t:0)*(l?-1:1),0,n.naturalWidth-n.width),y:(0,i.Ia)(n.y+("y"===r?t:0)*(o?-1:1),0,n.naturalHeight-n.height)},(0,i.Pj)(e,{crop:a});return}if(void 0!==s)return void lj("x"===r?s:g,"y"===r?s:f,m,c,h,o,a);let b="x"===r?e:0,x="y"===r?e:0;lj("x"===r?Math.round(l?lk(m.x+b,10):g+b):g,"y"===r?Math.round(l?lk(m.y+x,10):f+x):f,m,c,h,o,a)},lY=({property:e,element:t,elementsMap:n,scene:a,appState:l})=>{let[s,r]=(0,i.Va)((0,i.Ua)(t.x,t.y),(0,i.Ua)(t.x+t.width/2,t.y+t.height/2),t.angle),o=(0,i.Ja)("x"===e?s:r,2);if(l.croppingElementId===t.id&&(0,i.Wb)(t)&&t.crop){let n=(0,i.dh)(t);n&&(o=(0,i.Ja)("x"===e?n.x:n.y,2))}return(0,h.jsx)(lM,{label:"x"===e?"X":"Y",elements:[t],dragInputCallback:l$,scene:a,value:o,property:e,appState:l})},lG=(e,t,n,a,l,s,r)=>{let[o,d,,]=(0,i.bj)(n),c=e-o,h=t-d;for(let e=0;e<n.length;e++){let t=n[e],o=a.get(t.id);if(o&&(!(0,i._b)(o)||!o.containerId)){let[e,n]=[o.x+o.width/2,o.y+o.height/2],[d,m]=(0,i.Va)((0,i.Ua)(o.x,o.y),(0,i.Ua)(e,n),o.angle);lj(d+c,m+h,t,a,l,r,s,!1)}}},lV=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:a,nextValue:l,property:s,scene:r,originalAppState:o})=>{let d=r.getNonDeletedElementsMap(),c=r.getNonDeletedElements();if(void 0!==l){for(let e of lI(t,o)){let t=lC(e,d,n);if(t.length>1){let[e,a,,]=(0,i.bj)(t.map(e=>e.latest));lG("x"===s?l:e,"y"===s?l:a,t.map(e=>e.original),d,c,n,r)}else{let e=t[0]?.original,a=t[0]?.latest;if(e&&a&&lS(a,s)){let[t,a]=[e.x+e.width/2,e.y+e.height/2],[o,h]=(0,i.Va)((0,i.Ua)(e.x,e.y),(0,i.Ua)(t,a),e.angle);lj("x"===s?l:o,"y"===s?l:h,e,d,c,r,n,!1)}}}r.triggerUpdate();return}let h=a?lk(e,10):e;((e,t,n,a,l,s,r,o)=>{for(let d=0;d<a.length;d++){let c=l[d],[h,m]=[c.x+c.width/2,c.y+c.height/2],[p,u]=(0,i.Va)((0,i.Ua)(c.x,c.y),(0,i.Ua)(h,m),c.angle);lj("x"===e?Math.round(p+t):p,"y"===e?Math.round(u+n):u,c,s,a,o,r,!1)}})(s,"x"===s?h:0,"y"===s?h:0,t,t,d,n,r),r.triggerUpdate()},lK=({property:e,elements:t,elementsMap:n,atomicUnits:a,scene:l,appState:s})=>{let r=(0,o.useMemo)(()=>a.map(t=>{let a=Object.keys(t).map(e=>n.get(e)).filter(e=>void 0!==e);if(a.length>1){let[t,n]=(0,i.bj)(a);return Math.round(("x"===e?t:n)*100)/100}let[l]=a,[s,r]=[l.x+l.width/2,l.y+l.height/2],[o,d]=(0,i.Va)((0,i.Ua)(l.x,l.y),(0,i.Ua)(s,r),l.angle);return Math.round(("x"===e?o:d)*100)/100}),[a,n,e]),d=1===new Set(r).size?r[0]:"Mixed";return(0,h.jsx)(lM,{label:"x"===e?"X":"Y",elements:t,dragInputCallback:lV,value:d,property:e,scene:l,appState:s})},lZ=({property:e,scene:t,appState:n,setAppState:a})=>(0,h.jsx)(lM,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:e,instantChange:t,shouldChangeByStepSize:n,setInputValue:l})=>{a(a=>{let s;return e?s=e:t&&(s=n?lk(a.gridStep+5*Math.sign(t),5):a.gridStep+t),s?(l(s=(0,i.Bk)(s)),{gridStep:s}):(l(a.gridStep),null)})},scene:t,value:n.gridStep,property:e,appState:n}),lX=e=>{let t=s1(),n=e.app.scene.getSceneNonce()||1,a=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),l=(0,i.fj)(e.app);return(0,h.jsx)(lJ,{...e,appState:t,sceneNonce:n,selectedElements:a,gridModeEnabled:l})},lQ=({children:e,columns:t=1,heading:n,style:i,...a})=>(0,h.jsx)("div",{className:(0,m.A)("exc-stats__row",{"exc-stats__row--heading":n}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...i},...a,children:e});lQ.displayName="StatsRow";var lq=({children:e,order:t,style:n,...i})=>(0,h.jsx)("div",{className:"exc-stats__rows",style:{order:t,...n},...i,children:e});lq.displayName="StatsRows",lX.StatsRow=lQ,lX.StatsRows=lq;var lJ=(0,o.memo)(({app:e,onClose:t,renderCustomStats:n,selectedElements:a,appState:l,sceneNonce:s,gridModeEnabled:r})=>{let d=e.scene,c=d.getNonDeletedElements(),m=d.getNonDeletedElementsMap(),p=s2(),u=1===a.length?a[0]:null,g=a.length>1?a:null,f=l.croppingElementId&&(0,i.Wb)(u),b=f?(0,i.ch)(u):null,[E,y]=(0,o.useState)({width:0,height:0}),v=(0,o.useMemo)(()=>x(e=>{let t=(0,i.bj)(e);y({width:Math.round(t[2])-Math.round(t[0]),height:Math.round(t[3])-Math.round(t[1])})},50),[]);(0,o.useEffect)(()=>{v(c)},[s,c,v]),(0,o.useEffect)(()=>()=>v.cancel(),[v]);let w=(0,o.useMemo)(()=>lI(a,l),[a,l]),S=(0,o.useMemo)(()=>(0,i.Qi)(a),[a]);return(0,h.jsx)("div",{className:"exc-stats",children:(0,h.jsxs)(eA,{padding:3,children:[(0,h.jsxs)("div",{className:"title",children:[(0,h.jsx)("h2",{children:z("stats.title")}),(0,h.jsx)("div",{className:"close",onClick:t,children:i.ge})]}),(0,h.jsxs)(eB,{label:(0,h.jsx)("h3",{children:z("stats.generalStats")}),open:!!(l.stats.panels&i.Da.generalStats),openTrigger:()=>p(e=>({stats:{open:!0,panels:e.stats.panels^i.Da.generalStats}})),children:[(0,h.jsxs)(lq,{children:[(0,h.jsx)(lQ,{heading:!0,children:z("stats.scene")}),(0,h.jsxs)(lQ,{columns:2,children:[(0,h.jsx)("div",{children:z("stats.shapes")}),(0,h.jsx)("div",{children:c.length})]}),(0,h.jsxs)(lQ,{columns:2,children:[(0,h.jsx)("div",{children:z("stats.width")}),(0,h.jsx)("div",{children:E.width})]}),(0,h.jsxs)(lQ,{columns:2,children:[(0,h.jsx)("div",{children:z("stats.height")}),(0,h.jsx)("div",{children:E.height})]}),r&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(lQ,{heading:!0,children:"Canvas"}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lZ,{property:"gridStep",scene:d,appState:l,setAppState:p})})]})]}),n?.(c,l)]}),!S&&a.length>0&&(0,h.jsx)("div",{id:"elementStats",style:{marginTop:12},children:(0,h.jsx)(eB,{label:(0,h.jsx)("h3",{children:z("stats.elementProperties")}),open:!!(l.stats.panels&i.Da.elementProperties),openTrigger:()=>p(e=>({stats:{open:!0,panels:e.stats.panels^i.Da.elementProperties}})),children:(0,h.jsxs)(lq,{children:[u&&(0,h.jsxs)(h.Fragment,{children:[f&&(0,h.jsx)(lQ,{heading:!0,children:z("labels.unCroppedDimension")}),l.croppingElementId&&(0,i.Wb)(u)&&b&&(0,h.jsxs)(lQ,{columns:2,children:[(0,h.jsx)("div",{children:z("stats.width")}),(0,h.jsx)("div",{children:(0,i.Ja)(b.width,2)})]}),l.croppingElementId&&(0,i.Wb)(u)&&b&&(0,h.jsxs)(lQ,{columns:2,children:[(0,h.jsx)("div",{children:z("stats.height")}),(0,h.jsx)("div",{children:(0,i.Ja)(b.height,2)})]}),(0,h.jsx)(lQ,{heading:!0,"data-testid":"stats-element-type",children:l.croppingElementId?z("labels.imageCropping"):z(`element.${u.type}`)}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lY,{element:u,property:"x",elementsMap:m,scene:d,appState:l})}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lY,{element:u,property:"y",elementsMap:m,scene:d,appState:l})}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lL,{property:"width",element:u,scene:d,appState:l})}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lL,{property:"height",element:u,scene:d,appState:l})}),!(0,i.ec)(u)&&(0,h.jsx)(lQ,{children:(0,h.jsx)(lA,{property:"angle",element:u,scene:d,appState:l})}),(0,h.jsx)(lQ,{children:(0,h.jsx)(l_,{property:"fontSize",element:u,scene:d,appState:l})})]}),g&&(0,h.jsxs)(h.Fragment,{children:[(0,i.Vc)(g)&&(0,h.jsx)(lQ,{heading:!0,children:z("element.group")}),(0,h.jsxs)(lQ,{columns:2,style:{margin:"0.3125rem 0"},children:[(0,h.jsx)("div",{children:z("stats.shapes")}),(0,h.jsx)("div",{children:a.length})]}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lK,{property:"x",elements:g,elementsMap:m,atomicUnits:w,scene:d,appState:l})}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lK,{property:"y",elements:g,elementsMap:m,atomicUnits:w,scene:d,appState:l})}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lz,{property:"width",elements:g,elementsMap:m,atomicUnits:w,scene:d,appState:l})}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lz,{property:"height",elements:g,elementsMap:m,atomicUnits:w,scene:d,appState:l})}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lB,{property:"angle",elements:g,scene:d,appState:l})}),(0,h.jsx)(lQ,{children:(0,h.jsx)(lH,{property:"fontSize",elements:g,scene:d,appState:l,elementsMap:m})})]})]})})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels&&e.gridModeEnabled===t.gridModeEnabled&&e.appState.gridStep===t.appState.gridStep&&e.appState.croppingElementId===t.appState.croppingElementId),l0=({sourceElementId:e,onClose:t,elementsMap:n,appState:a,generateLinkForSelection:l=i.Yh})=>{let s=n.get(e)?.link??null,[r,d]=(0,o.useState)(s),[c,m]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=(0,i.vk)(n,a),t=s;if(e.length>0&&l){let n=(0,i.Zh)(e,a);n&&(t=(0,i.Xc)(l(n.id,n.type)))}d(t)},[n,a,a.selectedElementIds,s,l]);let p=(0,o.useCallback)(()=>{if(r&&r!==n.get(e)?.link){let t=n.get(e);t&&(0,i.Pj)(t,{link:r})}if(!r&&c&&e){let t=n.get(e);t&&(0,i.Pj)(t,{link:null})}t?.()},[e,r,n,c,t]);return(0,o.useEffect)(()=>{let e=e=>{a.openDialog?.name==="elementLinkSelector"&&e.key===i.hg.ENTER&&p(),a.openDialog?.name==="elementLinkSelector"&&e.key===i.hg.ESCAPE&&t?.()};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[a,t,p]),(0,h.jsxs)("div",{className:"ElementLinkDialog",children:[(0,h.jsxs)("div",{className:"ElementLinkDialog__header",children:[(0,h.jsx)("h2",{children:z("elementLink.title")}),(0,h.jsx)("p",{children:z("elementLink.desc")})]}),(0,h.jsxs)("div",{className:"ElementLinkDialog__input",children:[(0,h.jsx)(n8,{value:r??"",onChange:e=>{c||m(!0),d(e)},onKeyDown:e=>{e.key===i.hg.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),s&&r&&(0,h.jsx)(Y,{type:"button",title:z("buttons.remove"),"aria-label":z("buttons.remove"),label:z("buttons.remove"),onClick:()=>{d(null),m(!0)},className:"ElementLinkDialog__remove",icon:i.ud})]}),(0,h.jsxs)("div",{className:"ElementLinkDialog__actions",children:[(0,h.jsx)(nP,{label:z("buttons.cancel"),onClick:()=>{t?.()},style:{marginRight:10}}),(0,h.jsx)(nP,{label:z("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},l1=({UIOptions:e})=>(0,h.jsxs)(aQ,{__fallback:!0,children:[(0,h.jsx)(aQ.DefaultItems.LoadScene,{}),(0,h.jsx)(aQ.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&(0,h.jsx)(aQ.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&(0,h.jsx)(aQ.DefaultItems.SaveAsImage,{}),(0,h.jsx)(aQ.DefaultItems.SearchMenu,{}),(0,h.jsx)(aQ.DefaultItems.Help,{}),(0,h.jsx)(aQ.DefaultItems.ClearCanvas,{}),(0,h.jsx)(aQ.Separator,{}),(0,h.jsx)(aQ.Group,{title:"Excalidraw links",children:(0,h.jsx)(aQ.DefaultItems.Socials,{})}),(0,h.jsx)(aQ.Separator,{}),(0,h.jsx)(aQ.DefaultItems.ToggleTheme,{}),(0,h.jsx)(aQ.DefaultItems.ChangeCanvasBackground,{})]}),l2=()=>(0,h.jsxs)(a0,{__fallback:!0,children:[(0,h.jsx)(a0.Actions.SaveToDisk,{}),(0,h.jsx)(a0.Actions.ExportToImage,{})]}),l3=e=>{let{suggestedBindings:t,startBoundElement:n,cursorButton:i,scrollX:a,scrollY:l,...s}=e;return s},l5=o.memo(({actionManager:e,appState:t,files:n,setAppState:a,elements:l,canvas:s,onLockToggle:r,onHandToolToggle:d,onPenModeToggle:c,showExitZenModeBtn:p,renderTopRightUI:u,renderCustomStats:g,UIOptions:f,onExportImage:b,renderWelcomeScreen:x,children:E,app:v,isCollaborating:w,generateLinkForSelection:S})=>{let k,j,T=sq(),M=o.useMemo(()=>({MainMenuTunnel:(0,y.A)(),WelcomeScreenMenuHintTunnel:(0,y.A)(),WelcomeScreenToolbarHintTunnel:(0,y.A)(),WelcomeScreenHelpHintTunnel:(0,y.A)(),WelcomeScreenCenterTunnel:(0,y.A)(),FooterCenterTunnel:(0,y.A)(),DefaultSidebarTriggerTunnel:(0,y.A)(),DefaultSidebarTabTriggersTunnel:(0,y.A)(),OverwriteConfirmDialogTunnel:(0,y.A)(),TTDDialogTriggerTunnel:(0,y.A)(),tunnelsJotai:is}),[]),D=M.tunnelsJotai.Provider,[L,N]=C(eD),A=()=>f.canvasActions.export?(0,h.jsx)(av,{elements:l,appState:t,files:n,actionManager:e,exportOpts:f.canvasActions.export,canvas:s,setAppState:a}):null,P=()=>f.canvasActions.saveAsImage&&t.openDialog?.name==="imageExport"?(0,h.jsx)(i2,{elements:l,appState:t,files:n,actionManager:e,onExportImage:b,onCloseRequest:()=>a({openDialog:null}),name:v.getName()}):null,_=()=>(0,h.jsx)(lt,{__fallback:!0,onDock:e=>{ed("sidebar",`toggleDock (${e?"dock":"undock"})`,`(${T.editor.isMobile?"mobile":"desktop"})`)}}),R=I(aL),O=(0,h.jsxs)(h.Fragment,{children:[E,(0,h.jsx)(l1,{UIOptions:f}),(0,h.jsx)(lt.Trigger,{__fallback:!0,icon:i.fd,title:(0,i.Ya)(z("toolBar.library")),onToggle:e=>{e&&ed("sidebar",`${i.ya.name} (open)`,`button (${T.editor.isMobile?"mobile":"desktop"})`)},tab:i.ya.defaultTab,children:z("toolBar.library")}),(0,h.jsx)(l2,{}),t.openDialog?.name==="ttd"&&(0,h.jsx)(lv,{__fallback:!0}),t.isLoading&&(0,h.jsx)(H,{delay:250}),t.errorMessage&&(0,h.jsx)(iK,{onClose:()=>a({errorMessage:null}),children:t.errorMessage}),L&&!T.editor.isMobile&&(0,h.jsx)(eL,{colorPickerType:L.colorPickerType,onCancel:()=>{N(null)},onChange:(e,t,n,{altKey:l})=>{if("elementBackground"===e||"elementStroke"===e)if(n.length){for(let a of n)(0,i.Pj)(a,{[l&&L.swapPreviewOnAlt?"elementBackground"===e?"strokeColor":"backgroundColor":"elementBackground"===e?"backgroundColor":"strokeColor"]:t},!1),i.ed.delete(a);i.Oj.getScene(n[0])?.triggerUpdate()}else a("elementBackground"===e?{currentItemBackgroundColor:t}:{currentItemStrokeColor:t})},onSelect:(e,t)=>{N(e=>e?.keepOpenOnAlt&&t.altKey?e:null),L?.onSelect?.(e,t)}}),t.openDialog?.name==="help"&&(0,h.jsx)(au,{onClose:()=>{a({openDialog:null})}}),(0,h.jsx)(ix,{}),t.openDialog?.name==="elementLinkSelector"&&(0,h.jsx)(l0,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{a({openDialog:null})},elementsMap:v.scene.getNonDeletedElementsMap(),appState:t,generateLinkForSelection:S}),(0,h.jsx)(M.OverwriteConfirmDialogTunnel.Out,{}),P(),A(),t.pasteDialog.shown&&(0,h.jsx)(ao,{setAppState:a,appState:t,onClose:()=>a({pasteDialog:{shown:!1,data:null}})}),T.editor.isMobile&&(0,h.jsx)(as,{app:v,appState:t,elements:l,actionManager:e,renderJSONExportDialog:A,renderImageExportDialog:P,setAppState:a,onLockToggle:r,onHandToolToggle:d,onPenModeToggle:c,renderTopRightUI:u,renderCustomStats:g,renderSidebars:_,device:T,renderWelcomeScreen:x,UIOptions:f}),!T.editor.isMobile&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"layer-ui__wrapper",style:t.openSidebar&&R&&T.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[x&&(0,h.jsx)(M.WelcomeScreenCenterTunnel.Out,{}),(k=(0,i.lk)(t,l),j=t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector",(0,h.jsx)(i3,{side:"top",children:(0,h.jsxs)("div",{className:"App-menu App-menu_top",children:[(0,h.jsxs)(nj,{gap:6,className:(0,m.A)("App-menu_top__left"),children:[(0,h.jsxs)("div",{style:{position:"relative"},children:[(0,h.jsx)(M.MainMenuTunnel.Out,{}),x&&(0,h.jsx)(M.WelcomeScreenMenuHintTunnel.Out,{})]}),k&&(0,h.jsx)(an,{heading:"selectedShapeActions",className:(0,m.A)("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:(0,h.jsx)(eA,{className:i.E.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:(0,h.jsx)(id,{appState:t,elementsMap:v.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:v})})})]}),!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&(0,h.jsx)(an,{heading:"shapes",className:"shapes-section",children:e=>(0,h.jsxs)("div",{style:{position:"relative"},children:[x&&(0,h.jsx)(M.WelcomeScreenToolbarHintTunnel.Out,{}),(0,h.jsx)(nj,{gap:4,align:"start",children:(0,h.jsxs)(nC,{gap:1,className:(0,m.A)("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[(0,h.jsxs)(eA,{padding:1,className:(0,m.A)("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[(0,h.jsx)(i9,{appState:t,isMobile:T.editor.isMobile,device:T,app:v}),e,(0,h.jsxs)(nC,{gap:1,children:[(0,h.jsx)(aa,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>c(null),title:z("toolBar.penMode"),penDetected:t.penDetected}),(0,h.jsx)(at,{checked:t.activeTool.locked,onChange:r,title:z("toolBar.lock")}),(0,h.jsx)("div",{className:"App-toolbar__divider"}),(0,h.jsx)(al,{checked:(0,i.Hc)(t),onChange:()=>d(),title:z("toolBar.hand"),isMobile:!0}),(0,h.jsx)(ic,{appState:t,activeTool:t.activeTool,UIOptions:f,app:v})]})]}),w&&(0,h.jsx)(eA,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:(0,h.jsx)(ln,{title:z("toolBar.laser"),checked:t.activeTool.type===i.Aa.laser,onChange:()=>v.setActiveTool({type:i.Aa.laser}),isMobile:!0})})]})})]})}),(0,h.jsxs)("div",{className:(0,m.A)("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&(0,h.jsx)(ax,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),u?.(T.editor.isMobile,t),!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&(!R||t.openSidebar?.name!==i.ya.name)&&(0,h.jsx)(M.DefaultSidebarTriggerTunnel.Out,{}),j&&(0,h.jsx)(lX,{app:v,onClose:()=>{e.executeAction(t4)},renderCustomStats:g})]})]})})),(0,h.jsx)(aS,{appState:t,actionManager:e,showExitZenModeBtn:p,renderWelcomeScreen:x}),t.scrolledOutside&&(0,h.jsx)("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{a(e=>({...(0,i.zk)(l,e)}))},children:z("buttons.scrollBackToContent")})]}),_()]})]});return(0,h.jsx)(ej.Provider,{value:t,children:(0,h.jsx)(D,{children:(0,h.jsx)(il.Provider,{value:M,children:O})})})},(e,t)=>{if(e.children!==t.children)return!1;let{canvas:n,appState:a,...l}=e,{canvas:s,appState:r,...o}=t;return(0,i.Hb)(l3(a),l3(r),{selectedElementIds:i.Hb,selectedGroupIds:i.Hb})&&(0,i.Hb)(l,o)}),l4=5e3,l6=({message:e,onClose:t,closable:n=!1,duration:a=l4,style:l})=>{let s=(0,o.useRef)(0),r=a!==1/0,d=(0,o.useCallback)(()=>{r&&(s.current=window.setTimeout(()=>t(),a))},[t,a,r]);return(0,o.useEffect)(()=>{if(r)return d(),()=>clearTimeout(s.current)},[d,e,a,r]),(0,h.jsxs)("div",{className:"Toast",onMouseEnter:r?()=>clearTimeout(s?.current):void 0,onMouseLeave:r?d:void 0,style:l,children:[(0,h.jsx)("p",{className:"Toast__message",children:e}),n&&(0,h.jsx)(Y,{icon:i.ge,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})},l8=(0,i.$c)({name:"viewMode",label:"labels.viewMode",paletteName:"Toggle view mode",icon:i.lf,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:i.Wg.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,n)=>typeof n.viewModeEnabled>"u",keyTest:e=>!e[i.hg.CTRL_OR_CMD]&&e.altKey&&e.code===i.gg.R}),l7=(e,t)=>{let n=t.scene.getSelectedElements(e);return 1===n.length&&(0,i.bc)(n[0])},l9=(0,i.$c)({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,n,a)=>{let l=a.scene.getSelectedElements(t).at(0)||null;if((0,i.bc)(l)){let n=(0,i.Bi)((0,i.pk)(e),l.id).filter(e=>!("text"===e.type&&e.containerId));return{elements:e,appState:{...t,selectedElementIds:n.reduce((e,t)=>(e[t.id]=!0,e),{})},captureUpdate:i.Wg.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:i.Wg.EVENTUALLY}},predicate:(e,t,n,i)=>l7(t,i)}),se=(0,i.$c)({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,n,a)=>{let l=a.scene.getSelectedElements(t).at(0)||null;return(0,i.bc)(l)?{elements:(0,i.Ki)(e,l),appState:{...t,selectedElementIds:{[l.id]:!0}},captureUpdate:i.Wg.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:i.Wg.EVENTUALLY}},predicate:(e,t,n,i)=>l7(t,i)}),st=((0,i.$c)({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},captureUpdate:i.Wg.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),(0,i.$c)({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:i.ff,viewMode:!1,perform:(e,t,n,a)=>{let l=(0,i.jb)(t,{type:"frame"});return(0,i.dd)(a.interactiveCanvas,{...t,activeTool:l}),{elements:e,appState:{...t,activeTool:(0,i.jb)(t,{type:"frame"})},captureUpdate:i.Wg.EVENTUALLY}},keyTest:e=>!e[i.hg.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===i.hg.F}),(0,i.$c)({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,t,n,a)=>{let l=(0,i.vk)(e,t);return l.length>0&&!l.some(e=>(0,i.bc)(e))},perform:(e,t,n,a)=>{let l=(0,i.vk)(e,t),[s,r,o,d]=(0,i.bj)(l,a.scene.getNonDeletedElementsMap()),c=(0,i.Vf)({x:s-16,y:r-16,width:o-s+32,height:d-r+32});if(t.editingGroupId)for(let e of(0,i.Qc)(l,t.editingGroupId)){let n=e.groupIds.indexOf(t.editingGroupId);(0,i.Pj)(e,{groupIds:e.groupIds.slice(0,n)},!1)}return{elements:(0,i.Ii)([...a.scene.getElementsIncludingDeleted(),c],l,c,t),appState:{selectedElementIds:{[c.id]:!0}},captureUpdate:i.Wg.IMMEDIATELY}}})),sn=()=>(0,h.jsxs)("div",{"data-testid":"brave-measure-text-error",children:[(0,h.jsx)("p",{children:(0,h.jsx)(nA,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>(0,h.jsx)("span",{style:{fontWeight:600},children:e})})}),(0,h.jsx)("p",{children:(0,h.jsx)(nA,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>(0,h.jsx)("span",{style:{fontWeight:600},children:e})})}),(0,h.jsx)("p",{children:(0,h.jsx)(nA,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>(0,h.jsx)("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),(0,h.jsx)("p",{children:(0,h.jsx)(nA,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>(0,h.jsx)("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>(0,h.jsxs)("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),si=(e,t,n)=>{let a=(0,i.Xf)({x:0,y:0,textAlign:i.ta.CENTER,verticalAlign:i.sa.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:a.id})}),(0,i.uj)(a,e,n),[e,a]},sa=(e,t,n,a,l)=>{let s,r;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let n=t?.width??100,r=t?.height??100,o;t.id&&((o=a.getElement(t.id))||console.error(`No element for start binding with id ${t.id} found`));let d=t.x||e.x-n,c=t.y||e.y-r/2,h=o?o.type:t.type;if(h){if("text"===h){let n="";o&&"text"===o.type?n=o.text:"text"===t.type&&(n=t.text),n||console.error(`No text found for start binding text element for ${e.id}`),Object.assign(s=(0,i.Xf)({x:d,y:c,type:"text",...o,...t,text:n}),{x:t.x||e.x-s.width,y:t.y||e.y-s.height/2})}else switch(h){case"rectangle":case"ellipse":case"diamond":s=(0,i.Sf)({x:d,y:c,width:n,height:r,...o,...t,type:h});break;default:(0,i.Jb)(e,`Unhandled element start type "${t.type}"`,!0)}(0,i.Mg)(e,s,"start",l)}}if(n){let t=n?.height??100,s=n?.width??100,o;n.id&&((o=a.getElement(n.id))||console.error(`No element for end binding with id ${n.id} found`));let d=n.x||e.x+e.width,c=n.y||e.y-t/2,h=o?o.type:n.type;if(h){if("text"===h){let t="";o&&"text"===o.type?t=o.text:"text"===n.type&&(t=n.text),t||console.error(`No text found for end binding text element for ${e.id}`),Object.assign(r=(0,i.Xf)({x:d,y:c,type:"text",...o,...n,text:t}),{y:n.y||e.y-r.height/2})}else switch(h){case"rectangle":case"ellipse":case"diamond":r=(0,i.Sf)({x:d,y:c,width:s,height:t,...o,...n,type:h});break;default:(0,i.Jb)(e,`Unhandled element end type "${h}"`,!0)}(0,i.Mg)(e,r,"end",l)}}if(e.points.length<2)return{linearElement:e,startBoundElement:s,endBoundElement:r};let o=e.points.length-1,d=(0,i.Nb)(e.points);return e.points[o][0]>e.points[o-1][0]&&(d[0][0]=.5,d[o][0]-=.5),e.points[o][0]<e.points[o-1][0]&&(d[0][0]=-.5,d[o][0]+=.5),e.points[o][1]>e.points[o-1][1]&&(d[0][1]=.5,d[o][1]-=.5),e.points[o][1]<e.points[o-1][1]&&(d[0][1]=-.5,d[o][1]+=.5),Object.assign(e,{points:d}),{linearElement:e,startBoundElement:s,endBoundElement:r}},sl=class{constructor(){(0,r.d)(this,"excalidrawElements",new Map),(0,r.d)(this,"add",e=>{e&&this.excalidrawElements.set(e.id,e)}),(0,r.d)(this,"getElements",()=>(0,i.Nj)(Array.from(this.excalidrawElements.values()))),(0,r.d)(this,"getElementsMap",()=>(0,i.Sb)((0,i.xb)(this.getElements()))),(0,r.d)(this,"getElement",e=>this.excalidrawElements.get(e))}},ss=(e,t)=>{if(!e)return[];let n=(0,i.Nb)(e),a=new sl,l=new Map,s=new Map;for(let e of n){let n,r=e.id;switch(t?.regenerateIds!==!1&&Object.assign(e,{id:(0,i.sc)()}),e.type){case"rectangle":case"ellipse":case"diamond":{let t=e?.label?.text&&void 0===e.width?0:e?.width||100,a=e?.label?.text&&void 0===e.height?0:e?.height||100;n=(0,i.Sf)({...e,width:t,height:a});break}case"line":{let t=e.width||100,a=e.height||0;n=(0,i._f)({width:t,height:a,points:[(0,i.Ua)(0,0),(0,i.Ua)(t,a)],...e});break}case"arrow":{let t=e.width||100,a=e.height||0;Object.assign(n=(0,i.$f)({width:t,height:a,endArrowhead:"arrow",points:[(0,i.Ua)(0,0),(0,i.Ua)(t,a)],...e,type:"arrow"}),(0,i.hh)(n.points));break}case"text":{let t=e?.fontFamily||i.J,a=e?.fontSize||i.I,l=e?.lineHeight||(0,i.Rf)(t),s=e.text??"",r=(0,i.zc)(s),o=(0,i.vc)(r,(0,i.cb)({fontFamily:t,fontSize:a}),l);n=(0,i.Xf)({width:o.width,height:o.height,fontFamily:t,fontSize:a,...e});break}case"image":n=(0,i.ag)({width:e?.width||100,height:e?.height||100,...e});break;case"frame":n=(0,i.Vf)({x:0,y:0,...e});break;case"magicframe":n=(0,i.Wf)({x:0,y:0,...e});break;case"freedraw":case"iframe":case"embeddable":n=e;break;default:n=e,(0,i.Jb)(e,`Unhandled element type "${e.type}"`,!0)}a.getElement(n.id)?console.error(`Duplicate id found for ${n.id}`):(a.add(n),l.set(n.id,e),r&&s.set(r,n.id))}let r=a.getElementsMap();for(let[e,t]of l){let n=a.getElement(e);switch(t.type){case"rectangle":case"ellipse":case"diamond":case"arrow":if(t.label?.text){let[e,l]=si(n,t?.label,r);if(a.add(e),a.add(l),(0,i.dc)(e)){let n="arrow"===t.type?t?.start:void 0,i="arrow"===t.type?t?.end:void 0;if(n&&n.id){let e=s.get(n.id);e&&Object.assign(n,{id:e})}if(i&&i.id){let e=s.get(i.id);e&&Object.assign(i,{id:e})}let{linearElement:l,startBoundElement:o,endBoundElement:d}=sa(e,n,i,a,r);e=l,a.add(l),a.add(o),a.add(d)}}else if("arrow"===t.type){let{start:e,end:i}=t;if(e&&e.id){let t=s.get(e.id);Object.assign(e,{id:t})}if(i&&i.id){let e=s.get(i.id);Object.assign(i,{id:e})}let{linearElement:l,startBoundElement:o,endBoundElement:d}=sa(n,e,i,a,r);a.add(l),a.add(o),a.add(d)}}}for(let[e,t]of l){if("frame"!==t.type&&"magicframe"!==t.type)continue;let n=a.getElement(e);if(!n)throw Error(`Excalidraw element with id ${e} doesn't exist`);let l=[];t.children.forEach(e=>{let t=s.get(e);if(!t)throw Error(`Element with ${e} wasn't mapped correctly`);let i=a.getElement(t);if(!i)throw Error(`Frame element with id ${t} doesn't exist`);Object.assign(i,{frameId:n.id}),i?.boundElements?.forEach(e=>{let t=a.getElement(e.id);if(!t)throw Error(`Bound element with id ${e.id} doesn't exist`);Object.assign(t,{frameId:n.id}),l.push(t)}),l.push(i)});let[r,o,d,c]=(0,i.bj)(l);r-=10,o-=10,d+=10,c+=10;let h=n?.x||r,m=n?.y||o,p=n?.width||d-r,u=n?.height||c-o;Object.assign(n,{x:h,y:m,width:p,height:u}),(0,i.Bb)()&&t.children.length&&(n?.x||n?.y||n?.width||n?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return a.getElements()},sr=e=>t=>{(0,p.unstable_batchedUpdates)(e,t)},so=e=>(0,i.eb)(t=>{(0,p.unstable_batchedUpdates)(e,t)}),sd=(()=>{let e;try{let t=o.version.split(".");e=Number(t[0])>17}catch{e=!1}let t=!1;return()=>!0===window.EXCALIDRAW_THROTTLE_RENDER&&(!!e||(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1))})(),sc=(e,t,n)=>{for(let i of(n.zenModeEnabled||sp(e.points[0],e.points[e.points.length-1],t),e.points))sm(i,n,t)},sh=(e,t,n)=>{sm(e.points[0],n,t),n.zenModeEnabled||sp(e.points[0],e.points[1],t)},sm=([e,t],n,i)=>{i.save();let a=(n.zenModeEnabled?3:2)/n.zoom.value;i.beginPath(),i.moveTo(e-a,t-a),i.lineTo(e+a,t+a),i.moveTo(e+a,t-a),i.lineTo(e-a,t+a),i.stroke(),i.restore()},sp=(e,t,n)=>{n.beginPath(),n.lineTo(e[0],e[1]),n.lineTo(t[0],t[1]),n.stroke()},su=(e,t,n,a,l)=>{let s=8/a.zoom.value,r=s/2,o=s/4;if("horizontal"===n){let n=[(e[0]+t[0])/2,e[1]];a.zenModeEnabled||sp((0,i.Ua)(e[0],e[1]-s),(0,i.Ua)(e[0],e[1]+s),l),sp((0,i.Ua)(n[0]-o,n[1]-r),(0,i.Ua)(n[0]-o,n[1]+r),l),sp((0,i.Ua)(n[0]+o,n[1]-r),(0,i.Ua)(n[0]+o,n[1]+r),l),a.zenModeEnabled||(sp((0,i.Ua)(t[0],t[1]-s),(0,i.Ua)(t[0],t[1]+s),l),sp(e,t,l))}else{let n=[e[0],(e[1]+t[1])/2];a.zenModeEnabled||sp((0,i.Ua)(e[0]-s,e[1]),(0,i.Ua)(e[0]+s,e[1]),l),sp((0,i.Ua)(n[0]-r,n[1]-o),(0,i.Ua)(n[0]+r,n[1]-o),l),sp((0,i.Ua)(n[0]-r,n[1]+o),(0,i.Ua)(n[0]+r,n[1]+o),l),a.zenModeEnabled||(sp((0,i.Ua)(t[0]-s,t[1]),(0,i.Ua)(t[0]+s,t[1]),l),sp(e,t,l))}},sg=(e,t,n)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",(0,i.Vh)(t,e[0],e[1],i.pj.POINT_HANDLE_SIZE/n.zoom.value,!1)},sf=(e,t,n,i,a,l,s,r,o=!1,d=0)=>{e.save(),e.translate(l,s),e.rotate(r),o&&e.fillRect(t-l,n-s,i,a),d&&e.roundRect?(e.beginPath(),e.roundRect(t-l,n-s,i,a,d),e.stroke(),e.closePath()):e.strokeRect(t-l,n-s,i,a),e.restore()},sb=(e,t,n,a,l,s=!1)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",l?e.fillStyle="rgba(134, 131, 226, 0.9)":s&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),(0,i.Vh)(e,n[0],n[1],a/t.zoom.value,!s)},sx=(e,t,n,a)=>{var l,s,r,o;let[d,c,h,m]=(0,i.aj)(t,n),p=h-d,u=m-c;e.strokeStyle="rgba(0,0,0,.05)";let g=a.value<1?a.value:1;e.lineWidth=i.Gg/g;let f=e.lineWidth/2+i.Hg,b=(0,i.wg)(Math.min(t.width,t.height),t);switch(t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":sf(e,d-f,c-f,p+2*f,u+2*f,d+p/2,c+u/2,t.angle,void 0,b);break;case"diamond":let x=Math.hypot(p,u);l=p+f*x/u*2,s=u+f*x/p*2,r=t.angle,e.save(),e.translate(d+p/2,c+u/2),e.rotate(r),e.beginPath(),e.moveTo(0,s/2),e.lineTo(l/2,0),e.lineTo(0,-s/2),e.lineTo(-l/2,0),e.closePath(),e.stroke(),e.restore();break;case"ellipse":o=t.angle,e.beginPath(),e.ellipse(d+p/2,c+u/2,(p+2*f)/2,(u+2*f)/2,o,0,2*Math.PI),e.stroke()}},sE=(e,t,n,a)=>{let[l,s,r]=t,o=(0,i.Ug)(r,r.width,r.height,a);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",("both"===s?[0,-1]:"start"===s?[0]:[-1]).forEach(t=>{let[a,s]=i.pj.getPointAtIndexGlobalCoordinates(l,t,n);(0,i.Vh)(e,a,s,o)})},sy=(e,t,n)=>{let{angle:a,x1:l,y1:s,x2:r,y2:o,selectionColors:d,cx:c,cy:h,dashed:m,activeEmbeddable:p}=n,u=r-l,g=o-s,f=(n.padding??2*i.M)/t.zoom.value,b=8/t.zoom.value,x=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(p?4:1)/t.zoom.value;let E=d.length;for(let t=0;t<E;++t)e.strokeStyle=d[t],m&&e.setLineDash([b,x+(b+x)*(E-1)]),e.lineDashOffset=(b+x)*t,sf(e,l-f,s-f,u+2*f,g+2*f,c,h,a);e.restore()},sv=(e,t,n,a)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let l=i.pj.getPointsGlobalCoordinates(n,a),{POINT_HANDLE_SIZE:s}=i.pj,r=t.editingLinearElement?s:s/2;if(l.forEach((a,s)=>{if((0,i.ec)(n)&&0!==s&&s!==l.length-1)return;let o=!!t.editingLinearElement?.selectedPointsIndices?.includes(s);sb(e,t,a,r,o)}),(0,i.ec)(n)){let a=n.fixedSegments?.map(e=>e.index)||[];l.slice(0,-1).forEach((r,o)=>{i.pj.isSegmentTooShort(n,l[o+1],l[o],o,t.zoom)||sb(e,t,(0,i.Ua)((r[0]+l[o+1][0])/2,(r[1]+l[o+1][1])/2),s/2,!1,!a.includes(o+1))})}else i.pj.getEditorMidPoints(n,a,t).filter((e,t,a)=>null!==e&&!((0,i.ec)(n)&&(0===t||t===a.length-1))).forEach(n=>{(t.editingLinearElement||2===l.length)&&sb(e,t,n,s/2,!1,!0)});e.restore()},sw=(e,t,n,a,l)=>{Object.keys(a).forEach(s=>{let r=a[s];if(void 0!==r){let[a,o,d,c]=r;e.save(),e.lineWidth=1/n.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),"rotation"===s?(0,i.Vh)(e,a+d/2,o+c/2,d/2):e.roundRect?(e.beginPath(),e.roundRect(a,o,d,c,2/n.zoom.value),e.fill(),e.stroke()):sf(e,a,o,d,c,a+d/2,o+c/2,l,!0),e.restore()}})},sS=({canvas:e,elementsMap:t,visibleElements:n,selectedElements:a,allElementsMap:l,scale:s,appState:r,renderConfig:o,device:d})=>{var c,h;let m,p,u,g,f;if(null===e)return{atLeastOneVisibleElement:!1,elementsMap:t};let[x,E]=(0,i.Wh)(e,s),y=(0,i.Xh)({canvas:e,scale:s,normalizedWidth:x,normalizedHeight:E});if(y.save(),y.scale(r.zoom.value,r.zoom.value),n.forEach(e=>{r.editingLinearElement?.elementId===e.id&&e&&(m=e)}),m&&sv(y,r,m,t),r.selectionElement&&!r.isCropping)try{(0,i.Si)(r.selectionElement,y,r,o.selectionColor)}catch(e){console.error(e)}if(r.editingTextElement&&(0,i._b)(r.editingTextElement)){let e,t,n,a,s,d=l.get(r.editingTextElement.id);d&&!d.autoResize&&(c=o.selectionColor,y.save(),e=2*i.M/r.zoom.value,t=d.width+2*e,n=d.height+2*e,a=d.x+t/2,s=d.y+n/2,y.translate(a+r.scrollX,s+r.scrollY),y.rotate(d.angle),y.lineWidth=1/r.zoom.value,y.strokeStyle=c,y.strokeRect(-(t/2+e),-(n/2+e),t,n),y.restore())}r.isBindingEnabled&&r.suggestedBindings.filter(e=>null!=e).forEach(e=>{let n;n=Array.isArray(e)?sE:sx,y.save(),y.translate(r.scrollX,r.scrollY),n(y,e,t,r.zoom),y.restore()}),r.frameToHighlight&&((e,t,n,a)=>{let[l,s,r,o]=(0,i.aj)(n,a),d=r-l,c=o-s;e.strokeStyle="rgb(0,118,255)",e.lineWidth=i.H.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),sf(e,l,s,d,c,l+d/2,s+c/2,n.angle,!1,i.H.radius/t.zoom.value),e.restore()})(y,r,r.frameToHighlight,t),r.elementsToHighlight&&(u=(h=r.elementsToHighlight).filter(e=>0===e.groupIds.length),g=h.filter(e=>e.groupIds.length>0),f=e=>{let[t,n,a,l]=(0,i.bj)(e);return{angle:0,x1:t,x2:a,y1:n,y2:l,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:t+(a-t)/2,cy:n+(l-n)/2,activeEmbeddable:!1}},Object.entries((0,i.Nc)(g,r)).filter(([e,t])=>t).map(([e,t])=>e).map(e=>f((0,i.Qc)(h,e))).concat(u.map(e=>f([e]))).forEach(e=>sy(y,r,e)));let v=a.some(e=>(0,i.bc)(e));if(1===a.length&&r.editingLinearElement?.elementId===a[0].id&&sv(y,r,a[0],t),(0,i.ec)(a[0])&&r.selectedLinearElement&&r.selectedLinearElement.segmentMidPointHoveredCoords?((e,t)=>{(0,i.Kb)(t.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:n}=t.selectedLinearElement;(0,i.Kb)(n,"midPointCoords is null"),e.save(),e.translate(t.scrollX,t.scrollY),sg(n,e,t),e.restore()})(y,r):r.selectedLinearElement&&r.selectedLinearElement.hoverPointIndex>=0&&!((0,i.ec)(a[0])&&r.selectedLinearElement.hoverPointIndex>0&&r.selectedLinearElement.hoverPointIndex<a[0].points.length-1)&&((e,t,n)=>{let{elementId:a,hoverPointIndex:l}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(l))return;let s=i.pj.getElement(a,n);if(!s)return;let r=i.pj.getPointAtIndexGlobalCoordinates(s,l,n);e.save(),e.translate(t.scrollX,t.scrollY),sg(r,e,t),e.restore()})(y,r,t),!r.multiElement&&!r.editingLinearElement){let e=(0,i._j)(a,r),n=1===a.length&&(0,i.cc)(a[0]);n&&r.selectedLinearElement?.elementId===a[0].id&&!a[0].locked&&sv(y,r,a[0],t);let l=o.selectionColor||b.black;if(e){let e=(0,i.xb)(a),s=[];for(let a of t.values()){let d=[],c=o.remoteSelectedElementIds.get(a.id);if(n&&(0,i.ec)(a)&&(a.startBinding||a.endBinding)||(e.has(a.id)&&!(0,i.Kc)(r,a)&&d.push(l),c&&d.push(...c.map(e=>tz(e,r.collaborators.get(e))))),d.length){let[e,n,l,o,h,m]=(0,i.aj)(a,t,!0);s.push({angle:a.angle,x1:e,y1:n,x2:l,y2:o,selectionColors:d,dashed:!!c,cx:h,cy:m,activeEmbeddable:r.activeEmbeddable?.element===a&&"active"===r.activeEmbeddable.state,padding:a.id===r.croppingElementId||(0,i.Wb)(a)?0:void 0})}}let d=e=>{let n=(0,i.Qc)(t,e),[a,l,r,o]=(0,i.bj)(n);s.push({angle:0,x1:a,x2:r,y1:l,y2:o,selectionColors:[b.black],dashed:!0,cx:a+(r-a)/2,cy:l+(o-l)/2,activeEmbeddable:!1})};for(let e of(0,i.Mc)(r))d(e);r.editingGroupId&&d(r.editingGroupId),s.forEach(e=>sy(y,r,e))}if(y.save(),y.translate(r.scrollX,r.scrollY),1===a.length){y.fillStyle=b.white;let n=(0,i.Zj)(a[0],r.zoom,t,"mouse",(0,i.Xj)(d));if(r.viewModeEnabled||!e||(0,i._b)(r.editingTextElement)||r.croppingElementId||sw(y,o,r,n,a[0].angle),r.croppingElementId&&!r.isCropping){let e=t.get(r.croppingElementId);e&&(0,i.Wb)(e)&&((e,t,n,a,l)=>{let[s,r,,,o,d]=(0,i.aj)(a,l),c=3/n.zoom.value,h=c/2,m=o-s+c,p=d-r+c,u=Math.min(20/n.zoom.value,m),g=Math.min(20/n.zoom.value,p);e.save(),e.fillStyle=t.selectionColor,e.strokeStyle=t.selectionColor,e.lineWidth=c,[[[-m,-p],[0,h],[u,h],[h,0],[h,g]],[[m-h,-p],[h,h],[-u+h,h],[0,0],[0,g]],[[-m,p],[0,-h],[u,-h],[h,0],[h,-g]],[[m-h,p],[h,-h],[-u+h,-h],[0,0],[0,-g]]].forEach(t=>{let[[n,i],[l,s],[r,c],[h,m],[p,u]]=t;e.save(),e.translate(o,d),e.rotate(a.angle),e.beginPath(),e.moveTo(n+l,i+s),e.lineTo(n+r,i+c),e.stroke(),e.beginPath(),e.moveTo(n+h,i+m),e.lineTo(n+p,i+u),e.stroke(),e.restore()}),e.restore()})(y,o,r,e,t)}}else if(a.length>1&&!r.isRotating){let e=2*i.M/r.zoom.value;y.fillStyle=b.white;let[t,n,s,c]=(0,i.bj)(a),h=y.getLineDash();y.setLineDash([2/r.zoom.value]);let m=y.lineWidth;y.lineWidth=1/r.zoom.value,y.strokeStyle=l,sf(y,t-e,n-e,s-t+2*e,c-n+2*e,(t+s)/2,(n+c)/2,0),y.lineWidth=m,y.setLineDash(h);let p=(0,i.Yj)([t,n,s,c,(t+s)/2,(n+c)/2],0,r.zoom,"mouse",v?{...(0,i.Xj)(d),rotation:!0}:(0,i.Xj)(d));a.some(e=>!e.locked)&&sw(y,o,r,p,0)}y.restore()}return r.searchMatches.forEach(({id:e,focus:n,matchedLines:a})=>{let l=t.get(e);if(l&&(0,i._b)(l)){let[e,s,,,o,d]=(0,i.aj)(l,t,!0);y.save(),r.theme===i.G.LIGHT?n?y.fillStyle="rgba(255, 124, 0, 0.4)":y.fillStyle="rgba(255, 226, 0, 0.4)":n?y.fillStyle="rgba(229, 82, 0, 0.4)":y.fillStyle="rgba(99, 52, 0, 0.4)",y.translate(r.scrollX,r.scrollY),y.translate(o,d),y.rotate(l.angle),a.forEach(t=>{y.fillRect(e+t.offsetX-o,s+t.offsetY-d,t.width,t.height)}),y.restore()}}),((e,t)=>{if(!t.snapLines.length)return;let n=t.theme===i.G.LIGHT||t.zenModeEnabled?"#ff6b6b":"#ff0000",a=(t.zenModeEnabled?1.5:1)/t.zoom.value;for(let i of(e.save(),e.translate(t.scrollX,t.scrollY),t.snapLines))"pointer"===i.type?(e.lineWidth=a,e.strokeStyle=n,sh(i,e,t)):"gap"===i.type?(e.lineWidth=a,e.strokeStyle=n,su(i.points[0],i.points[1],i.direction,t,e)):"points"===i.type&&(e.lineWidth=a,e.strokeStyle=n,sc(i,e,t));e.restore()})(y,r),y.restore(),(({context:e,renderConfig:t,appState:n,normalizedWidth:a,normalizedHeight:l})=>{for(let[s,r]of t.remotePointerViewportCoords){let{x:o,y:d}=r,c=n.collaborators.get(s);o-=n.offsetLeft,d-=n.offsetTop;let h=o<0||o>a-11||d<0||d>l-14;o=Math.min(o=Math.max(o,0),a-11),d=Math.min(d=Math.max(d,0),l-14);let m=tz(s,c);e.save(),e.strokeStyle=m,e.fillStyle=m;let p=t.remotePointerUserStates.get(s),u=h||"idle"===p||"away"===p;u&&(e.globalAlpha=.3),"down"===t.remotePointerButton.get(s)&&(e.beginPath(),e.arc(o,d,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(o,d,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=m,e.stroke(),e.closePath());let g=n.theme===i.G.DARK?"#2f6330":i.Q,f=c?.isSpeaking;f&&(e.fillStyle=g,e.strokeStyle=g,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(o,d),e.lineTo(o+0,d+14),e.lineTo(o+4,d+9),e.lineTo(o+11,d+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=i.O,e.strokeStyle=i.O,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(o,d),e.lineTo(o+0,d+14),e.lineTo(o+4,d+9),e.lineTo(o+11,d+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=m,e.strokeStyle=m,e.lineWidth=2,e.lineJoin="round",e.beginPath(),u?(e.moveTo(o-1,d-1),e.lineTo(o-1,d+15),e.lineTo(o+5,d+10),e.lineTo(o+12,d+9),e.closePath(),e.fill()):(e.moveTo(o,d),e.lineTo(o+0,d+14),e.lineTo(o+4,d+9),e.lineTo(o+11,d+8),e.closePath(),e.fill(),e.stroke());let b=t.remotePointerUsernames.get(s)||"";if(!h&&b){e.font="600 12px sans-serif";let t=(f?o+0:o)+5.5,n=(f?d+0:d)+14+2,a=e.measureText(b),l=a.actualBoundingBoxDescent+a.actualBoundingBoxAscent,s=Math.max(l,12),r=t-1,c=n-1,h=a.width+2+10+2,p=s+2+6+2;e.roundRect?(e.beginPath(),e.roundRect(r,c,h,p,8),e.fillStyle=m,e.fill(),e.strokeStyle=i.O,e.stroke(),f&&(e.beginPath(),e.roundRect(r-2,c-2,h+4,p+4,8),e.strokeStyle=g,e.stroke())):tF(e,r,c,h,p,8,i.O),e.fillStyle=i.P,e.fillText(b,t+5+1,n+3+a.actualBoundingBoxAscent+Math.floor((s-l)/2)+2),f&&(e.fillStyle=g,e.fillRect(r+h+8,c+(p/2-4),2,8),e.fillRect(r+h+8+5,c+(p/2-8),2,16),e.fillRect(r+h+8+10,c+(p/2-4),2,8))}e.restore(),e.closePath()}})({context:y,renderConfig:o,appState:r,normalizedWidth:x,normalizedHeight:E}),o.renderScrollbars&&(p=((e,t,n,a)=>{if(!e.length)return{horizontal:null,vertical:null};let[l,s,r,o]=(0,i.bj)(e),d=t/a.zoom.value,c=n/a.zoom.value,h={top:parseInt((0,i.nb)("sat"))||0,bottom:parseInt((0,i.nb)("sab"))||0,left:parseInt((0,i.nb)("sal"))||0,right:parseInt((0,i.nb)("sar"))||0},m=_.rtl,p=-a.scrollX+(t-d)/2+h.left,u=-a.scrollY+(n-c)/2+h.top,g=p+d-h.right,f=u+c-h.bottom,b=Math.min(l,p),x=Math.min(s,u),E=Math.max(r,g),y=Math.max(o,f);return{horizontal:p===b&&g===E?null:{x:Math.max(h.left,4)+(p-b)/(E-b)*t,y:n-6-Math.max(4,h.bottom),width:(g-p)/(E-b)*t-Math.max(8,h.left+h.right),height:6},vertical:u===x&&f===y?null:{x:m?Math.max(h.left,4):t-6-Math.max(h.right,4),y:(u-x)/(y-x)*n+Math.max(h.top,4),width:6,height:(f-u)/(y-x)*n-Math.max(8,h.top+h.bottom)}}})(n,x,E,r),y.save(),y.fillStyle="rgba(0,0,0,0.3)",y.strokeStyle="rgba(255,255,255,0.8)",[p.horizontal,p.vertical].forEach(e=>{e&&tF(y,e.x,e.y,e.width,e.height,3)}),y.restore()),{scrollBars:p,atLeastOneVisibleElement:n.length>0,elementsMap:t}},sk=(0,i.eb)(e=>{let t=sS(e);e.callback?.(t)},{trailing:!0}),sC=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,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,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches}),sj=o.memo(e=>{let t=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{if(!t.current){t.current=!0;return}let n=new Map,a=new Map,l=new Map,s=new Map,r=new Map;e.appState.collaborators.forEach((t,o)=>{if(t.selectedElementIds)for(let e of Object.keys(t.selectedElementIds))l.has(e)||l.set(e,[]),l.get(e).push(o);t.pointer&&!1!==t.pointer.renderCursor&&(t.username&&s.set(o,t.username),t.userState&&r.set(o,t.userState),a.set(o,(0,i.mb)({sceneX:t.pointer.x,sceneY:t.pointer.y},e.appState)),n.set(o,t.button))});let o=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";((e,t)=>{if(t)return sk(e);let n=sS(e);return e.callback(n)})({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:a,remotePointerButton:n,remoteSelectedElementIds:l,remotePointerUsernames:s,remotePointerUserStates:r,selectionColor:o,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},sd())}),(0,h.jsx)("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?i.z.GRAB:i.z.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:z("labels.drawingCanvas")})},(e,t)=>e.selectionNonce===t.selectionNonce&&e.sceneNonce===t.sceneNonce&&e.scale===t.scale&&e.elementsMap===t.elementsMap&&e.visibleElements===t.visibleElements&&e.selectedElements===t.selectedElements&&(0,i.Hb)(sC(e.appState),sC(t.appState))),sI=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,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,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId}),sT=o.memo(e=>{let t=(0,o.useRef)(null),n=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{let a=t.current;if(!a)return;let l=e.canvas;n.current||(n.current=!0,a.replaceChildren(l),l.classList.add("excalidraw__canvas","static"));let s=`${e.appState.width}px`,r=`${e.appState.height}px`;l.style.width!==s&&(l.style.width=s),l.style.height!==r&&(l.style.height=r);let o=e.appState.width*e.scale,d=e.appState.height*e.scale;l.width!==o&&(l.width=o),l.height!==d&&(l.height=d),(0,i.ci)({canvas:l,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},sd())}),(0,h.jsx)("div",{className:"excalidraw__canvas-wrapper",ref:t})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.scale===t.scale&&e.elementsMap===t.elementsMap&&e.visibleElements===t.visibleElements&&(0,i.Hb)(sI(e.appState),sI(t.appState))&&(0,i.Hb)(e.renderConfig,t.renderConfig)),sM=class{constructor(e){(0,r.d)(this,"scene"),(0,r.d)(this,"getRenderableElements",(0,i.Lb)(({zoom:e,offsetLeft:t,offsetTop:n,scrollX:a,scrollY:l,height:s,width:r,editingTextElement:o,newElementId:d,pendingImageElementId:c,sceneNonce:h})=>{let m=(({elements:e,editingTextElement:t,newElementId:n,pendingImageElementId:a})=>{let l=(0,i.Sb)(new Map);for(let s of e)(0,i.Wb)(s)&&a===s.id||n===s.id||t&&"text"===t.type&&s.id===t.id||l.set(s.id,s);return l})({elements:this.scene.getNonDeletedElements(),editingTextElement:o,newElementId:d,pendingImageElementId:c}),p=(({elementsMap:e,zoom:t,offsetLeft:n,offsetTop:a,scrollX:l,scrollY:s,height:r,width:o})=>{let d=[];for(let c of e.values())(0,i.Tj)(c,o,r,{zoom:t,offsetLeft:n,offsetTop:a,scrollX:l,scrollY:s},e)&&d.push(c);return d})({elementsMap:m,zoom:e,offsetLeft:t,offsetTop:n,scrollX:a,scrollY:l,height:s,width:r});return{elementsMap:m,visibleElements:p}})),this.scene=e}destroy(){sk.cancel(),i.bi.cancel(),this.getRenderableElements.clear()}},sD=({trails:e})=>{let t=(0,o.useRef)(null);return(0,o.useEffect)(()=>{if(t.current)for(let n of e)n.start(t.current);return()=>{for(let t of e)t.stop()}},e),(0,h.jsx)("div",{className:"SVGLayer",children:(0,h.jsx)("svg",{ref:t})})},sL=({children:e,element:t,elementsMap:n})=>{let a=s1();if(a.contextMenu||a.newElement||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled)return null;let{x:l,y:s}=((e,t,n)=>{let[a,l]=(0,i.aj)(e,n),{x:s,y:r}=(0,i.mb)({sceneX:a+e.width,sceneY:l},t);return{x:s-t.offsetLeft+10,y:r-t.offsetTop}})(t,a,n);return(0,h.jsx)("div",{className:"excalidraw-canvas-buttons",style:{top:`${s}px`,left:`${l}px`,padding:5},children:e})},sN=e=>(0,h.jsxs)("label",{className:(0,m.A)("ToolIcon ToolIcon__MagicButton","ToolIcon_size_small",{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,h.jsx)("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),(0,h.jsx)("div",{className:"ToolIcon__icon",children:e.icon})]}),sA=({height:e,width:t,userToFollow:n,onDisconnect:a})=>(0,h.jsx)("div",{className:"follow-mode",style:{width:t,height:e},children:(0,h.jsxs)("div",{className:"follow-mode__badge",children:[(0,h.jsxs)("div",{className:"follow-mode__badge__label",children:["Following"," ",(0,h.jsx)("span",{className:"follow-mode__badge__username",title:n.username,children:n.username})]}),(0,h.jsx)("button",{type:"button",onClick:a,className:"follow-mode__disconnect-btn",children:i.ge})]})}),sP=class{constructor(){(0,r.d)(this,"targets",new WeakMap),(0,r.d)(this,"rafIds",new WeakMap)}register(e,t){this.targets.set(e,{callback:t,stopped:!0})}start(e){let t=this.targets.get(e);t&&(this.rafIds.has(e)||(this.targets.set(e,{...t,stopped:!1}),this.scheduleFrame(e)))}stop(e){let t=this.targets.get(e);t&&!t.stopped&&this.targets.set(e,{...t,stopped:!0}),this.cancelFrame(e)}constructFrame(e){return t=>{let n=this.targets.get(e);if(!n)return;let i=this.onFrame(n,t);n.stopped||i?this.cancelFrame(e):this.scheduleFrame(e)}}scheduleFrame(e){let t=requestAnimationFrame(this.constructFrame(e));this.rafIds.set(e,t)}cancelFrame(e){this.rafIds.has(e)&&cancelAnimationFrame(this.rafIds.get(e)),this.rafIds.delete(e)}onFrame(e,t){return e.callback(t)??!1}},s_=class{constructor(e,t,n){this.animationFrameHandler=e,this.app=t,this.options=n,(0,r.d)(this,"currentTrail"),(0,r.d)(this,"pastTrails",[]),(0,r.d)(this,"container"),(0,r.d)(this,"trailElement"),this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(i.pa,"path")}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(e,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===e&&this.currentTrail.originalPoints[n-1][1]===t}return!1}start(e){e&&(this.container=e),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(e,t){this.currentTrail=new S.z(this.options),this.currentTrail.addPoint([e,t,performance.now()]),this.update()}addPointToPath(e,t){this.currentTrail&&(this.currentTrail.addPoint([e,t,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 e=[];for(let t of this.pastTrails)e.push(this.drawTrail(t,this.app.state));if(this.currentTrail){let t=this.drawTrail(this.currentTrail,this.app.state);e.push(t)}this.pastTrails=this.pastTrails.filter(e=>0!==e.getStrokeOutline().length),0===e.length&&this.stop();let t=e.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(e,t){let n=e.getStrokeOutline(e.options.size/t.zoom.value).map(([e,n])=>{let a=(0,i.mb)({sceneX:e,sceneY:n},t);return[a.x,a.y]});return(0,i.Qb)(n,!0)}},sR=class{constructor(e,t){this.animationFrameHandler=e,this.app=t,(0,r.d)(this,"localTrail"),(0,r.d)(this,"collabTrails",new Map),(0,r.d)(this,"container"),this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new s_(e,t,{...this.getTrailOptions(),fill:()=>i.y})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/1e3),n=(50-Math.min(50,e.totalLength-e.currentIndex))/50;return Math.min((0,i.fb)(n),(0,i.fb)(t))}}}startPath(e,t){this.localTrail.startPath(e,t)}addPointToPath(e,t){this.localTrail.addPointToPath(e,t)}endPath(){this.localTrail.endPath()}start(e){this.container=e,this.animationFrameHandler.start(this),this.localTrail.start(e)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||0===this.app.state.collaborators.size)){for(let[e,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(e)?n=this.collabTrails.get(e):((n=new s_(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||tz(e,t)})).start(this.container),this.collabTrails.set(e,n)),t.pointer&&"laser"===t.pointer.tool&&("down"!==t.button||n.hasCurrentTrail||n.startPath(t.pointer.x,t.pointer.y),"down"===t.button&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),"up"===t.button&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let e of this.collabTrails.keys())this.app.state.collaborators.has(e)||(this.collabTrails.get(e).stop(),this.collabTrails.delete(e))}}},sO=(0,i.$c)({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,t,n,a)=>{let l=(0,i.vk)(e,t);return 1===l.length&&(0,i._b)(l[0])&&!l[0].autoResize},perform:(e,t,n,a)=>{let l=(0,i.vk)(e,t);return{appState:t,elements:e.map(e=>{if(e.id===l[0].id&&(0,i._b)(e)){let t=(0,i.vc)(e.originalText,(0,i.cb)(e),e.lineHeight);return(0,i.Qj)(e,{autoResize:!0,width:t.width,height:t.height,text:e.originalText})}return e}),captureUpdate:i.Wg.IMMEDIATELY}}}),sF=({canvas:e,rc:t,newElement:n,elementsMap:a,allElementsMap:l,scale:s,appState:r,renderConfig:o})=>{if(e){let[d,c]=(0,i.Wh)(e,s),h=(0,i.Xh)({canvas:e,scale:s,normalizedWidth:d,normalizedHeight:c});h.save(),h.scale(r.zoom.value,r.zoom.value),n&&"selection"!==n.type?(0,i.Ti)(n,a,l,t,h,o,r):h.clearRect(0,0,d,c)}},sz=(0,i.eb)(e=>{sF(e)},{trailing:!0}),sU=e=>{let t=(0,o.useRef)(null);return(0,o.useEffect)(()=>{var n;t.current&&(n={canvas:t.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},sd()?sz(n):sF(n))}),(0,h.jsx)("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:t})},sB=o.createContext(null),sW=o.createContext(null),sH={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},s$=o.createContext(sH);s$.displayName="DeviceContext";var sY=o.createContext({container:null,id:null});sY.displayName="ExcalidrawContainerContext";var sG=o.createContext([]);sG.displayName="ExcalidrawElementsContext";var sV=o.createContext({...(0,i.Fc)(),width:0,height:0,offsetLeft:0,offsetTop:0});sV.displayName="ExcalidrawAppStateContext";var sK=o.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});sK.displayName="ExcalidrawSetAppStateContext";var sZ=o.createContext(null);sZ.displayName="ExcalidrawActionManagerContext";var sX=()=>(0,o.useContext)(sB),sQ=()=>(0,o.useContext)(sW),sq=()=>(0,o.useContext)(s$),sJ=()=>(0,o.useContext)(sY),s0=()=>(0,o.useContext)(sG),s1=()=>(0,o.useContext)(sV),s2=()=>(0,o.useContext)(sK),s3=()=>(0,o.useContext)(sZ),s5=!1,s4=0,s6=!1,s8=!1,s7=!1,s9={horizontal:null,vertical:null},re=0,rt=!1,rn=new Map,ri=!1,ra=0,rl=!1,rs=null,rr={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},ro=class e extends o.Component{constructor(t){super(t),(0,r.d)(this,"canvas"),(0,r.d)(this,"interactiveCanvas",null),(0,r.d)(this,"rc"),(0,r.d)(this,"unmounted",!1),(0,r.d)(this,"actionManager"),(0,r.d)(this,"device",sH),(0,r.d)(this,"excalidrawContainerRef",o.createRef()),(0,r.d)(this,"scene"),(0,r.d)(this,"fonts"),(0,r.d)(this,"renderer"),(0,r.d)(this,"visibleElements"),(0,r.d)(this,"resizeObserver"),(0,r.d)(this,"nearestScrollableContainer"),(0,r.d)(this,"library"),(0,r.d)(this,"libraryItemsFromStorage"),(0,r.d)(this,"id"),(0,r.d)(this,"store"),(0,r.d)(this,"history"),(0,r.d)(this,"excalidrawContainerValue"),(0,r.d)(this,"files",{}),(0,r.d)(this,"imageCache",new Map),(0,r.d)(this,"iFrameRefs",new Map),(0,r.d)(this,"embedsValidationStatus",new Map),(0,r.d)(this,"initializedEmbeds",new Set),(0,r.d)(this,"elementsPendingErasure",new Set),(0,r.d)(this,"flowChartCreator",new i7),(0,r.d)(this,"flowChartNavigator",new i8),(0,r.d)(this,"hitLinkElement"),(0,r.d)(this,"lastPointerDownEvent",null),(0,r.d)(this,"lastPointerUpEvent",null),(0,r.d)(this,"lastPointerMoveEvent",null),(0,r.d)(this,"lastPointerMoveCoords",null),(0,r.d)(this,"lastViewportPosition",{x:0,y:0}),(0,r.d)(this,"animationFrameHandler",new sP),(0,r.d)(this,"laserTrails",new sR(this.animationFrameHandler,this)),(0,r.d)(this,"eraserTrail",new s_(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/200),n=(10-Math.min(10,e.totalLength-e.currentIndex))/10;return Math.min((0,i.fb)(n),(0,i.fb)(t))},fill:()=>this.state.theme===i.G.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"})),(0,r.d)(this,"onChangeEmitter",new i.Vg),(0,r.d)(this,"onPointerDownEmitter",new i.Vg),(0,r.d)(this,"onPointerUpEmitter",new i.Vg),(0,r.d)(this,"onUserFollowEmitter",new i.Vg),(0,r.d)(this,"onScrollChangeEmitter",new i.Vg),(0,r.d)(this,"missingPointerEventCleanupEmitter",new i.Vg),(0,r.d)(this,"onRemoveEventListenersEmitter",new i.Vg),(0,r.d)(this,"getEffectiveGridSize",()=>(0,i.fj)(this)?this.state.gridSize:null),(0,r.d)(this,"updateEmbedValidationStatus",(e,t)=>{this.embedsValidationStatus.set(e.id,t),i.ed.delete(e)}),(0,r.d)(this,"updateEmbeddables",()=>{let e=new Set,t=!1;this.scene.getNonDeletedElements().filter(n=>{if((0,i.Xb)(n)){if(e.add(n.id),!this.embedsValidationStatus.has(n.id)){t=!0;let e=(0,i.$g)(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,e)}}else(0,i.Yb)(n)&&e.add(n.id);return!1}),t&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((t,n)=>{e.has(n)||this.iFrameRefs.delete(n)})}),(0,r.d)(this,"getFrameNameDOMId",e=>`${this.id}-frame-name-${e.id}`),(0,r.d)(this,"frameNameBoundsCache",{get:e=>{let t=this.frameNameBoundsCache._cache.get(e.id);if(!t||t.zoom!==this.state.zoom.value||t.versionNonce!==e.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(e));if(n){let a=n.getBoundingClientRect(),l=(0,i.lb)({clientX:a.x,clientY:a.y},this.state),s=(0,i.lb)({clientX:a.right,clientY:a.bottom},this.state);return t={x:l.x,y:l.y,width:s.x-l.x,height:s.y-l.y,angle:0,zoom:this.state.zoom.value,versionNonce:e.versionNonce},this.frameNameBoundsCache._cache.set(e.id,t),t}return null}return t},_cache:new Map}),(0,r.d)(this,"resetEditingFrame",e=>{e&&(0,i.Pj)(e,{name:e.name?.trim()||null}),this.setState({editingFrame:null})}),(0,r.d)(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let e=this.state.theme===i.G.DARK;return this.scene.getNonDeletedFramesLikes().map(t=>{if(!(0,i.Tj)(t,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 this.state.editingFrame===t.id&&this.resetEditingFrame(t),null;let{x:n,y:a}=(0,i.mb)({sceneX:t.x,sceneY:t.y},this.state),l,s=(0,i.Oi)(t);return l=t.id===this.state.editingFrame?(0,h.jsx)("input",{autoFocus:!0,value:s,onChange:e=>{(0,i.Pj)(t,{name:e.target.value})},onFocus:e=>e.target.select(),onBlur:()=>this.resetEditingFrame(t),onKeyDown:e=>{(e.key===i.hg.ESCAPE||e.key===i.hg.ENTER)&&this.resetEditingFrame(t)},style:{background:this.state.viewBackgroundColor,filter:e?i.da:"none",zIndex:2,border:"none",display:"block",padding:"6px",borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:"translate(-6px, 6px)",color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-n-6}px`},size:s.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"}):s,(0,h.jsx)("div",{id:this.getFrameNameDOMId(t),style:{position:"absolute",bottom:`${this.state.height+i.H.nameOffsetY-a+this.state.offsetTop}px`,left:`${n-this.state.offsetLeft}px`,zIndex:2,fontSize:i.H.nameFontSize,color:e?i.H.nameColorDarkTheme:i.H.nameColorLightTheme,lineHeight:i.H.nameLineHeight,width:"max-content",maxWidth:`${t.width}px`,overflow:t.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:i.z.MOVE,pointerEvents:this.state.viewModeEnabled?i.B.disabled:i.B.enabled},onPointerDown:e=>this.handleCanvasPointerDown(e),onWheel:e=>this.handleWheel(e),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:t.id})},children:l},t.id)})}),(0,r.d)(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()}),(0,r.d)(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted()),(0,r.d)(this,"getSceneElements",()=>this.scene.getNonDeletedElements()),(0,r.d)(this,"onInsertElements",e=>{this.addElementsFromPasteOrLibrary({elements:e,position:"center",files:null})}),(0,r.d)(this,"onExportImage",async(e,t,n)=>{ed("export",e,"ui");let a=await ty(e,t,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(i.pb).catch(e=>{console.error(e),this.setState({errorMessage:e.message})});this.state.exportEmbedScene&&a&&(0,i.sh)(a)&&this.setState({fileHandle:a})}),(0,r.d)(this,"magicGenerations",new Map),(0,r.d)(this,"updateMagicGeneration",({frameElement:e,data:t})=>{"pending"===t.status?(0,i.Pj)(e,{customData:{generationData:void 0}},!1):(0,i.Pj)(e,{customData:{generationData:t}},!1),this.magicGenerations.set(e.id,t),this.triggerRender()}),(0,r.d)(this,"plugins",{}),(0,r.d)(this,"onMagicframeToolSelect",()=>{let e=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(0===e.length)this.setActiveTool({type:i.Aa.magicframe}),ed("ai","tool-select (empty-selection)","d2c");else{let t,n=1===e.length&&(0,i.ac)(e[0])&&e[0];if(!n&&e.some(e=>(0,i.bc)(e)||e.frameId))return void this.setActiveTool({type:i.Aa.magicframe});if(ed("ai","tool-select (existing selection)","d2c"),n)t=n;else{let[n,a,l,s]=(0,i.bj)(e);for(let r of(t=(0,i.Wf)({...i.H,x:n-50,y:a-50,width:l-n+100,height:s-a+100,opacity:100,locked:!1}),this.scene.insertElement(t),e))(0,i.Pj)(r,{frameId:t.id});this.setState({selectedElementIds:{[t.id]:!0}})}this.onMagicFrameGenerate(t,"upstream")}}),(0,r.d)(this,"openEyeDropper",({type:e})=>{D.set(eD,{swapPreviewOnAlt:!0,colorPickerType:"stroke"===e?"elementStroke":"elementBackground",onSelect:(t,n)=>{let a="background"===e&&n.altKey||"stroke"===e&&!n.altKey;this.scene.getSelectedElements(this.state).length&&"selection"===this.state.activeTool.type?this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(e=>this.state.selectedElementIds[e.id]?(0,i.Qj)(e,{[a?"strokeColor":"backgroundColor"]:t}):e),captureUpdate:i.Wg.IMMEDIATELY}):a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:t},captureUpdate:i.Wg.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:t},captureUpdate:i.Wg.IMMEDIATELY})},keepOpenOnAlt:!1})}),(0,r.d)(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})}),(0,r.d)(this,"syncActionResult",sr(e=>{if(this.unmounted||!1===e)return;e.captureUpdate===i.Wg.NEVER?this.store.shouldUpdateSnapshot():e.captureUpdate===i.Wg.IMMEDIATELY&&this.store.shouldCaptureIncrement();let t=!1,n=null;if(e.elements&&(this.scene.replaceAllElements(e.elements),t=!0),e.files&&(this.addMissingFiles(e.files,e.replaceFiles),this.addNewImagesToImageCache()),e.appState||n||this.state.contextMenu){let a=e?.appState?.viewModeEnabled||!1,l=e?.appState?.zenModeEnabled||!1,s=e?.appState?.theme||this.props.theme||i.G.LIGHT,r=e?.appState?.name??this.state.name,o=e?.appState?.errorMessage??this.state.errorMessage;"u">typeof this.props.viewModeEnabled&&(a=this.props.viewModeEnabled),"u">typeof this.props.zenModeEnabled&&(l=this.props.zenModeEnabled),n=e.appState?.editingTextElement||null,e.elements&&n&&e.elements.forEach(e=>{n?.id===e.id&&n!==e&&(0,i.qk)(e)&&(0,i._b)(e)&&(n=e)}),n?.isDeleted&&(n=null),this.setState(t=>{let i=e.appState||{};return{...t,...i,contextMenu:null,editingTextElement:n,viewModeEnabled:a,zenModeEnabled:l,theme:s,name:r,errorMessage:o}}),t=!0}t||e.captureUpdate===i.Wg.EVENTUALLY||this.scene.triggerUpdate()})),(0,r.d)(this,"onBlur",sr(()=>{s6=!1,this.setState({isBindingEnabled:!0})})),(0,r.d)(this,"onUnload",()=>{this.onBlur()}),(0,r.d)(this,"disableEvent",e=>{e.preventDefault()}),(0,r.d)(this,"resetHistory",()=>{this.history.clear()}),(0,r.d)(this,"resetStore",()=>{this.store.clear()}),(0,r.d)(this,"resetScene",sr(e=>{this.scene.replaceAllElements([]),this.setState(t=>({...(0,i.Fc)(),isLoading:!e?.resetLoadingState&&t.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()})),(0,r.d)(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async e=>{if(!e.files.length)return;let t=e.files[0],n=await t.getFile();this.loadFileToCanvas(new File([n],n.name||"",{type:n.type}),t)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let e=null;try{e="function"==typeof this.props.initialData?await this.props.initialData()||null:await this.props.initialData||null,e?.libraryItems&&this.library.updateLibrary({libraryItems:e.libraryItems,merge:!0}).catch(e=>{console.error(e)})}catch(t){console.error(t),e={appState:{errorMessage:t.message||"Encountered an error during importing or restoring scene data"}}}let t=(0,i.lh)(e,null,null,{repairBindings:!0});t.appState={...t.appState,theme:this.props.theme||t.appState.theme,openSidebar:t.appState?.openSidebar||this.state.openSidebar,activeTool:"image"===t.appState.activeTool.type?{...t.appState.activeTool,type:"selection"}:t.appState.activeTool,isLoading:!1,toast:this.state.toast},e?.scrollToContent&&(t.appState={...t.appState,...(0,i.zk)(t.elements,{...t.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...t,captureUpdate:i.Wg.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(e=>{this.fonts.onLoaded(e)}),(0,i.$h)(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})}),(0,r.d)(this,"isMobileBreakpoint",(e,t)=>e<i.ha||t<i.ja&&e<i.ia),(0,r.d)(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:e,clientHeight:t}=document.body,n=this.device.viewport,a=(0,i.Db)(n,{isLandscape:e>t,isMobile:this.isMobileBreakpoint(e,t)});return n!==a&&(this.device={...this.device,viewport:a},!0)}),(0,r.d)(this,"refreshEditorBreakpoints",()=>{let e=this.excalidrawContainerRef.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect(),a=null!=this.props.UIOptions.dockedSidebarBreakpoint?this.props.UIOptions.dockedSidebarBreakpoint:i.ka,l=this.device.editor,s=(0,i.Db)(l,{isMobile:this.isMobileBreakpoint(t,n),canFitSidebar:t>a});return l!==s&&(this.device={...this.device,editor:s},!0)}),(0,r.d)(this,"onResize",sr(()=>{this.scene.getElementsIncludingDeleted().forEach(e=>i.ed.delete(e)),this.refreshViewportBreakpoints(),this.updateDOMRect(),i.r||this.refreshEditorBreakpoints(),this.setState({})})),(0,r.d)(this,"onFullscreenChange",()=>{document.fullscreenElement||this.state.activeEmbeddable?.state!=="active"||this.setState({activeEmbeddable:null})}),(0,r.d)(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:e,scrollBars:t,elementsMap:n})=>{t&&(s9=t);let i=!this.state.editingTextElement&&!e&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()}),(0,r.d)(this,"onScroll",(0,i.db)(()=>{let{offsetTop:e,offsetLeft:t}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===t&&n.offsetTop===e?null:{offsetTop:e,offsetLeft:t})},i._)),(0,r.d)(this,"onCut",sr(e=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||(0,i.ab)(e.target)||(this.actionManager.executeAction(tq,"keyboard",e),e.preventDefault(),e.stopPropagation())})),(0,r.d)(this,"onCopy",sr(e=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||(0,i.ab)(e.target)||(this.actionManager.executeAction(tX,"keyboard",e),e.preventDefault(),e.stopPropagation())})),(0,r.d)(this,"onTouchStart",t=>{if(i.p&&t.preventDefault(),!s5){s5=!0,clearTimeout(s4),s4=window.setTimeout(e.resetTapTwice,i.Y);return}if(s5&&1===t.touches.length){let e=t.touches[0];this.handleCanvasDoubleClick({clientX:e.clientX,clientY:e.clientY}),s5=!1,clearTimeout(s4)}2===t.touches.length&&this.setState({selectedElementIds:(0,i.xk)({},this.state),activeEmbeddable:null})}),(0,r.d)(this,"onTouchEnd",e=>{this.resetContextMenuTimer(),e.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:(0,i.xk)(this.state.previousSelectedElementIds,this.state)}):rr.pointers.clear()}),(0,r.d)(this,"pasteFromClipboard",sr(async e=>{let t=!!ri,a=document.activeElement,l=this.excalidrawContainerRef.current?.contains(a);if(e&&!l)return;let s=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(e&&(!(s instanceof HTMLCanvasElement)||(0,i.ab)(a)))return;let{x:r,y:o}=(0,i.lb)({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),d=e?.clipboardData?.files[0],c=await (0,i.mi)(e,t);if(!d&&!t){if(c.mixedContent)return this.addElementsFromMixedContentPaste(c.mixedContent,{isPlainPaste:t,sceneX:r,sceneY:o});if(c.text){let e=c.text.trim();e.startsWith("<svg")&&e.endsWith("</svg>")&&(d=(0,i.Fh)(e))}}if((0,i.th)(d)&&!c.spreadsheet){if(!this.isToolSupported("image"))return void this.setState({errorMessage:z("errors.imageToolNotSupported")});let e=this.createImageElement({sceneX:r,sceneY:o});return this.insertImageElement(e,d),this.initializeImageDimensions(e),void this.setState({selectedElementIds:(0,i.xk)({[e.id]:!0},this.state)})}if(this.props.onPaste)try{if(await this.props.onPaste(c,e)===!1)return}catch(e){console.error(e)}if(c.errorMessage)this.setState({errorMessage:c.errorMessage});else if(c.spreadsheet&&!t)this.setState({pasteDialog:{data:c.spreadsheet,shown:!0}});else if(c.elements){let e=c.programmaticAPI?ss(c.elements):c.elements;this.addElementsFromPasteOrLibrary({elements:e,files:c.files||null,position:"cursor",retainSeed:t})}else if(c.text){var h;if(c.text&&(h=c.text,RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"].map(e=>`\\s*${e}(-beta)?`).join("|")})\\b`).test(h.trim()))){let e=await Promise.all([n.e(159),n.e(2425),n.e(8356),n.e(709),n.e(9838),n.e(1845)]).then(n.bind(n,38134));try{let{elements:t,files:n={}}=await e.parseMermaidToExcalidraw(c.text),i=ss(t,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:i,files:n,position:"cursor"});return}catch(e){console.warn(`parsing pasted text as mermaid definition failed: ${e.message}`)}}let e=(0,i.Rb)(c.text).split(/\n+/).map(e=>e.trim()).filter(Boolean),a=e.map(e=>(0,i._g)(e)).filter(e=>(0,i.$g)(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||(0,i.Zg)(e)?.type==="video"));if(!ri&&a.length>0&&a.length===e.length){let e=[];for(let t of a){let n=e[e.length-1],a=this.insertEmbeddableElement({sceneX:n?n.x+n.width+20:r,sceneY:o,link:(0,i.Xc)(t)});a&&e.push(a)}e.length&&this.setState({selectedElementIds:Object.fromEntries(e.map(e=>[e.id,!0]))});return}this.addTextFromPaste(c.text,t)}this.setActiveTool({type:"selection"}),e?.preventDefault()})),(0,r.d)(this,"addElementsFromPasteOrLibrary",e=>{let t=(0,i.jh)(e.elements,null,void 0),[n,a,l,s]=(0,i.bj)(t),r=(0,i.ib)(n,l)/2,o=(0,i.ib)(a,s)/2,d="object"==typeof e.position?e.position.clientX:"cursor"===e.position?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,c="object"==typeof e.position?e.position.clientY:"cursor"===e.position?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:h,y:m}=(0,i.lb)({clientX:d,clientY:c},this.state),[p,u]=(0,i.oj)(h-r,m-o,this.getEffectiveGridSize()),g=(0,i.dg)(t.map(e=>(0,i.Qj)(e,{x:e.x+p-n,y:e.y+u-a})),{randomizeSeed:!e.retainSeed}),f=this.scene.getElementsIncludingDeleted(),b=[...f,...g];b=this.props.onDuplicate?.(b,f)||b,(0,i.Mj)(b,(0,i.xb)(g));let x=this.getTopLayerFrameAtSceneCoords({x:h,y:m});if(x){let e=(0,i.Hi)(g,x);(0,i.Ii)(b,e,x,this.state)}this.scene.replaceAllElements(b),g.forEach(e=>{if((0,i._b)(e)&&(0,i.nc)(e)){let t=(0,i.Aj)(e,this.scene.getElementsMapIncludingDeleted());(0,i.uj)(e,t,this.scene.getElementsMapIncludingDeleted())}}),i.o&&i.Qf.loadElementsFonts(g).then(e=>{this.fonts.onLoaded(e)}),e.files&&this.addMissingFiles(e.files),this.store.shouldCaptureIncrement();let E=(0,i.rk)(g);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&D.get(aL)?this.state.openSidebar:null,...(0,i.Jc)({editingGroupId:null,selectedElementIds:E.reduce((e,t)=>((0,i.nc)(t)||(e[t.id]=!0),e),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{e.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),e.fitToContent&&this.scrollToContent(g,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})}),(0,r.d)(this,"setAppState",(e,t)=>{this.setState(e,t)}),(0,r.d)(this,"removePointer",e=>{re&&this.resetContextMenuTimer(),rr.pointers.delete(e.pointerId)}),(0,r.d)(this,"toggleLock",(e="ui")=>{this.state.activeTool.locked||ed("toolbar","toggleLock",`${e} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(e=>({activeTool:{...e.activeTool,...(0,i.jb)(this.state,e.activeTool.locked?{type:"selection"}:e.activeTool),locked:!e.activeTool.locked}}))}),(0,r.d)(this,"updateFrameRendering",e=>{this.setState(t=>{let n="function"==typeof e?e(t.frameRendering):e;return{frameRendering:{enabled:n?.enabled??t.frameRendering.enabled,clip:n?.clip??t.frameRendering.clip,name:n?.name??t.frameRendering.name,outline:n?.outline??t.frameRendering.outline}}})}),(0,r.d)(this,"togglePenMode",e=>{this.setState(t=>({penMode:e??!t.penMode,penDetected:!0}))}),(0,r.d)(this,"onHandToolToggle",()=>{this.actionManager.executeAction(tu)}),(0,r.d)(this,"zoomCanvas",e=>{this.setState({...ta({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:(0,i.Ak)(e)},this.state)})}),(0,r.d)(this,"cancelInProgressAnimation",null),(0,r.d)(this,"scrollToContent",(e=this.scene.getNonDeletedElements(),t)=>{if("string"==typeof e){let n;if(n=(0,i.$h)(e)?(0,i.ai)(e):e){let a=this.scene.getElementsFromId(n);a?.length?this.scrollToContent(a,{fitToContent:t?.fitToContent??!0,animate:t?.animate??!0}):(0,i.$h)(e)&&this.setState({toast:{message:z("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(e)?e:[e],a=this.state.zoom,l=this.state.scrollX,s=this.state.scrollY;if(t?.fitToContent||t?.fitToViewport){let{appState:e}=tm({canvasOffsets:t.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!t?.fitToViewport,viewportZoomFactor:t?.viewportZoomFactor,minZoom:t?.minZoom,maxZoom:t?.maxZoom});a=e.zoom,l=e.scrollX,s=e.scrollY}else{let e=(0,i.zk)(n,this.state);l=e.scrollX,s=e.scrollY}if(t?.animate){let e=this.state.scrollX,n=this.state.scrollY,r=this.state.zoom.value,o=(0,i.gb)({fromValues:{scrollX:e,scrollY:n,zoom:r},toValues:{scrollX:l,scrollY:s,zoom:a.value},interpolateValue:(e,t,n,a)=>{if("zoom"===a)return e*Math.pow(t/e,(0,i.fb)(n))},onStep:({scrollX:e,scrollY:t,zoom:n})=>{this.setState({scrollX:e,scrollY:t,zoom:{value:n}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:t?.duration??500});this.cancelInProgressAnimation=()=>{o(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:l,scrollY:s,zoom:a})}),(0,r.d)(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})}),(0,r.d)(this,"translateCanvas",e=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(e)}),(0,r.d)(this,"setToast",e=>{this.setState({toast:e})}),(0,r.d)(this,"restoreFileFromShare",async()=>{try{let e=await caches.open("web-share-target"),t=await e.match("shared-file");if(t){let n=await t.blob(),a=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(a,null),await e.delete("shared-file"),window.history.replaceState(null,i.s,window.location.pathname)}}catch(e){this.setState({errorMessage:e.message})}}),(0,r.d)(this,"addFiles",sr(e=>{let{addedFiles:t}=this.addMissingFiles(e);this.clearImageShapeCache(t),this.scene.triggerUpdate(),this.addNewImagesToImageCache()})),(0,r.d)(this,"addMissingFiles",(e,t=!1)=>{let n=t?{}:{...this.files},a={};for(let t of Array.isArray(e)?e:Object.values(e))if(!n[t.id]&&(a[t.id]=t,n[t.id]=t,t.mimeType===i.T.svg))try{let e=(0,i.Bh)((0,i.Rh)((0,i.Dh)(t.dataURL)),i.T.svg);t.dataURL!==e&&(t.version=(t.version??1)+1,t.dataURL=e)}catch(e){console.error(e)}return this.files=n,{addedFiles:a}}),(0,r.d)(this,"updateScene",sr(e=>{let t=(0,i.Nj)(e.elements??[]);if(e.captureUpdate&&e.captureUpdate!==i.Wg.EVENTUALLY){let n=this.store.snapshot.appState,a=this.store.snapshot.elements,l=e.appState?Object.assign({},n,e.appState):n,s=e.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),(0,i.xb)(t)):a;e.captureUpdate===i.Wg.IMMEDIATELY?this.store.captureIncrement(s,l):e.captureUpdate===i.Wg.NEVER&&this.store.updateSnapshot(s,l)}e.appState&&this.setState(e.appState),e.elements&&this.scene.replaceAllElements(t),e.collaborators&&this.setState({collaborators:e.collaborators})})),(0,r.d)(this,"triggerRender",e=>{!0===e?this.scene.triggerUpdate():this.setState({})}),(0,r.d)(this,"toggleSidebar",({name:e,tab:t,force:n})=>{let i,a=(i=void 0===n?this.state.openSidebar?.name===e&&this.state.openSidebar?.tab===t?null:e:n?e:null)?{name:i}:null;return a&&t&&(a.tab=t),this.setState({openSidebar:a}),!!i}),(0,r.d)(this,"updateCurrentCursorPosition",sr(e=>{this.lastViewportPosition.x=e.clientX,this.lastViewportPosition.y=e.clientY})),(0,r.d)(this,"getEditorUIOffsets",()=>{let e=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,t=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect();return _.rtl?{top:e+16,right:Math.max(this.state.width-(n?.left??this.state.width),0)+16,bottom:16,left:Math.max(t?.right??0,0)+16}:{top:e+16,right:Math.max(this.state.width-(t?.left??this.state.width)+16,0),bottom:16,left:Math.max(n?.right??0,0)+16}}),(0,r.d)(this,"onKeyDown",sr(e=>{if("Proxy"in window&&(!e.shiftKey&&/^[A-Z]$/.test(e.key)||e.shiftKey&&/^[a-z]$/.test(e.key))&&(e=new Proxy(e,{get(t,n){let i=t[n];return"function"==typeof i?i.bind(t):"key"===n?e.shiftKey?t.key.toUpperCase():t.key.toLowerCase():i}})),!(0,i._a)(e.target)){if((e.key===i.hg.ESCAPE||e.key===i.hg.ENTER)&&this.state.croppingElementId)return void this.finishImageCropping();let t=(0,i.vk)(this.scene.getNonDeletedElementsMap(),this.state);if(1===t.length&&(0,i.Wb)(t[0])&&e.key===i.hg.ENTER)return void this.startImageCropping(t[0]);if(e.key===i.hg.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let n=(0,i.jg)(e.key);if(e[i.hg.CTRL_OR_CMD]&&n&&!e.shiftKey){e.preventDefault();let t=(0,i.vk)(this.scene.getNonDeletedElementsMap(),this.state);1===t.length&&(0,i.lc)(t[0])&&this.flowChartCreator.createNodes(t[0],this.scene.getNonDeletedElementsMap(),this.state,i5(e.key)),this.flowChartCreator.pendingNodes?.length&&!(0,i.Uj)(this.flowChartCreator.pendingNodes,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(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(e.altKey){let t=(0,i.vk)(this.scene.getNonDeletedElementsMap(),this.state);if(1===t.length&&n){e.preventDefault();let n=this.flowChartNavigator.exploreByDirection(t[0],this.scene.getNonDeletedElementsMap(),i5(e.key));if(n){this.setState(e=>({selectedElementIds:(0,i.xk)({[n]:!0},e)}));let e=this.scene.getNonDeletedElementsMap().get(n);e&&!(0,i.Uj)([e],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(),this.getEditorUIOffsets())&&this.scrollToContent(e,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(e[i.hg.CTRL_OR_CMD]&&e.key===i.hg.P&&!e.shiftKey&&!e.altKey){this.setToast({message:z("commandPalette.shortcutHint",{shortcut:n9("commandPalette")})}),e.preventDefault();return}if(e[i.hg.CTRL_OR_CMD]&&e.key.toLowerCase()===i.hg.V&&(ri=e.shiftKey,clearTimeout(ra),ra=window.setTimeout(()=>{ri=!1},100)),e[i.hg.CTRL_OR_CMD]&&(0,i.ab)(e.target)&&(e.code===i.gg.MINUS||e.code===i.gg.EQUAL))return void e.preventDefault();if((0,i.ab)(e.target)&&e.key!==i.hg.ESCAPE||(0,i.jg)(e.key)&&(0,i._a)(e.target))return;if(e.key===i.hg.QUESTION_MARK)return void this.setState({openDialog:{name:"help"}});if(e.key.toLowerCase()===i.hg.E&&e.shiftKey&&e[i.hg.CTRL_OR_CMD]){e.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(e.key===i.hg.PAGE_UP||e.key===i.hg.PAGE_DOWN){let t=(e.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;e.key===i.hg.PAGE_DOWN&&(t=-t),e.shiftKey?this.translateCanvas(e=>({scrollX:e.scrollX+t})):this.translateCanvas(e=>({scrollY:e.scrollY+t}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(e)||this.state.viewModeEnabled)return;if(e[i.hg.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),(0,i.jg)(e.key)){let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),n=t.find(i.ec),a=new Set;t.filter(i.ec).filter(e=>{let n=e.startBinding&&!t.some(t=>t.id===e.startBinding?.elementId),i=e.endBinding&&!t.some(t=>t.id===e.endBinding?.elementId);return n||i}).forEach(e=>a.add(e.id)),t=t.filter(e=>!a.has(e.id));let l=this.getEffectiveGridSize()&&(e.shiftKey?i.w:this.getEffectiveGridSize())||(e.shiftKey?i.v:i.w),s=0,r=0;e.key===i.hg.ARROW_LEFT?s=-l:e.key===i.hg.ARROW_RIGHT?s=l:e.key===i.hg.ARROW_UP?r=-l:e.key===i.hg.ARROW_DOWN&&(r=l),t.forEach(e=>{(0,i.Pj)(e,{x:e.x+s,y:e.y+r},!1),(0,i.Pg)(e,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:t})}),this.setState({suggestedBindings:(0,i.Kg)(t.filter(e=>e.id!==n?.id||0!==l),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),e.preventDefault()}else if(e.key===i.hg.ENTER){let t=this.scene.getSelectedElements(this.state);if(1===t.length){let n=t[0];if(e[i.hg.CTRL_OR_CMD])(0,i.cc)(n)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==t[0].id)&&(this.store.shouldCaptureIncrement(),(0,i.ec)(n)||this.setState({editingLinearElement:new i.pj(n)}));else if((0,i._b)(n)||(0,i.Fj)(n)){let t;(0,i._b)(n)||(t=n);let a=(0,i.Bj)(n,this.state,this.scene.getNonDeletedElementsMap()),l=a.x,s=a.y;this.startTextEditing({sceneX:l,sceneY:s,container:t}),e.preventDefault();return}else(0,i.bc)(n)&&this.setState({editingFrame:n.id})}}else if(!e.ctrlKey&&!e.altKey&&!e.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let t=(0,i.sg)(e.key);t?(this.state.activeTool.type!==t&&ed("toolbar",t,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),"arrow"===t&&"arrow"===this.state.activeTool.type&&this.setState(e=>({currentItemArrowType:e.currentItemArrowType===i.Fa.sharp?i.Fa.round:e.currentItemArrowType===i.Fa.round?i.Fa.elbow:i.Fa.sharp})),this.setActiveTool({type:t}),e.stopPropagation()):e.key===i.hg.Q&&(this.toggleLock("keyboard"),e.stopPropagation())}if(e.key===i.hg.SPACE&&0===rr.pointers.size&&(s6=!0,(0,i.bd)(this.interactiveCanvas,i.z.GRAB),e.preventDefault()),(e.key===i.hg.G||e.key===i.hg.S)&&!e.altKey&&!e[i.hg.CTRL_OR_CMD]){let t=this.scene.getSelectedElements(this.state);if("selection"===this.state.activeTool.type&&!t.length)return;e.key===i.hg.G&&((0,i.Vi)(this.state.activeTool.type)||t.some(e=>(0,i.Vi)(e.type)))&&(this.setState({openPopup:"elementBackground"}),e.stopPropagation()),e.key===i.hg.S&&(this.setState({openPopup:"elementStroke"}),e.stopPropagation())}if(!e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===i.hg.F){let t=this.scene.getSelectedElements(this.state);if("selection"===this.state.activeTool.type&&!t.length)return;("text"===this.state.activeTool.type||t.find(e=>(0,i._b)(e)||(0,i.zj)(e,this.scene.getNonDeletedElementsMap())))&&(e.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(e.key===i.hg.K&&!e.altKey&&!e[i.hg.CTRL_OR_CMD])return void("laser"===this.state.activeTool.type?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"}));e[i.hg.CTRL_OR_CMD]&&(e.key===i.hg.BACKSPACE||e.key===i.hg.DELETE)&&D.set(ib,"clearCanvas");let t=e.key.toLocaleLowerCase(),n=t===i.hg.S&&e.shiftKey,a=e.key===i.hg.I||t===i.hg.G&&e.shiftKey;(n||a)&&this.openEyeDropper({type:n?"stroke":"background"})})),(0,r.d)(this,"onKeyUp",sr(e=>{if(e.key===i.hg.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?(0,i.bd)(this.interactiveCanvas,i.z.GRAB):"selection"===this.state.activeTool.type?(0,i.ad)(this.interactiveCanvas):((0,i.dd)(this.interactiveCanvas,this.state),this.setState({selectedElementIds:(0,i.xk)({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),s6=!1),e[i.hg.CTRL_OR_CMD]||this.state.isBindingEnabled||this.setState({isBindingEnabled:!0}),(0,i.jg)(e.key)&&((0,i.Jg)(this.scene.getSelectedElements(this.state).filter(i.cc),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,(0,i.Fg)(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom),this.setState({suggestedBindings:[]})),e.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:i.Wg.IMMEDIATELY})),!e[i.hg.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let e=this.flowChartCreator.pendingNodes?.[0];e&&(this.setState(t=>({selectedElementIds:(0,i.xk)({[e.id]:!0},t)})),(0,i.Uj)([e],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(),this.getEditorUIOffsets())||this.scrollToContent(e,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:i.Wg.IMMEDIATELY})}})),(0,r.d)(this,"isToolSupported",e=>this.props.UIOptions.tools?.[e]!==!1),(0,r.d)(this,"setActiveTool",e=>{if(!this.isToolSupported(e.type))return void console.warn(`"${e.type}" tool is disabled via "UIOptions.canvasActions.tools.${e.type}"`);let t=(0,i.jb)(this.state,e);"hand"===t.type?(0,i.bd)(this.interactiveCanvas,i.z.GRAB):s6||(0,i.dd)(this.interactiveCanvas,{...this.state,activeTool:t}),(0,i.Za)(document.activeElement)&&this.focusContainer(),(0,i.fc)(t.type)||this.setState({suggestedBindings:[]}),"image"===t.type&&this.onImageAction({insertOnCanvasDirectly:("image"===e.type&&e.insertOnCanvasDirectly)??!1}),this.setState(e=>{let n={snapLines:e.snapLines.length?[]:e.snapLines,originSnapOffset:null,activeEmbeddable:null};return"freedraw"===t.type&&this.store.shouldCaptureIncrement(),"selection"!==t.type?{...e,activeTool:t,selectedElementIds:(0,i.xk)({},e),selectedGroupIds:(0,i.xk)({},e),editingGroupId:null,multiElement:null,...n}:{...e,activeTool:t,...n}})}),(0,r.d)(this,"setOpenDialog",e=>{this.setState({openDialog:e})}),(0,r.d)(this,"setCursor",e=>{(0,i.bd)(this.interactiveCanvas,e)}),(0,r.d)(this,"resetCursor",()=>{(0,i.ad)(this.interactiveCanvas)}),(0,r.d)(this,"isTouchScreenMultiTouchGesture",()=>rr.pointers.size>=2),(0,r.d)(this,"getName",()=>this.state.name||this.props.name||`${z("labels.untitled")}-${(0,i.Xa)()}`),(0,r.d)(this,"onGestureStart",sr(e=>{e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:(0,i.xk)({},this.state),activeEmbeddable:null}),rr.initialScale=this.state.zoom.value})),(0,r.d)(this,"onGestureChange",sr(e=>{if(e.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let t=rr.initialScale;t&&this.setState(n=>({...ta({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:(0,i.Ak)(t*e.scale)},n)}))})),(0,r.d)(this,"onGestureEnd",sr(e=>{e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:(0,i.xk)(this.state.previousSelectedElementIds,this.state)}),rr.initialScale=null})),(0,r.d)(this,"startTextEditing",({sceneX:e,sceneY:t,insertAtParentCenter:n=!0,container:a,autoEdit:l=!0})=>{let s=!1,r=n&&this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,a);a&&r&&((0,i.zj)(a,this.scene.getNonDeletedElementsMap())||(s=!0));let o=null,d=this.scene.getSelectedElements(this.state);o=1===d.length?(0,i._b)(d[0])?d[0]:a?(0,i.zj)(d[0],this.scene.getNonDeletedElementsMap()):this.getTextElementAtPosition(e,t):this.getTextElementAtPosition(e,t);let c=o?.fontFamily||this.state.currentItemFontFamily,h=o?.lineHeight||(0,i.Rf)(c),m=this.state.currentItemFontSize;if(!o&&s&&a&&!(0,i.dc)(a)){let n=(0,i.wc)((0,i.cb)({fontSize:m,fontFamily:c}),h),l=(0,i.Bc)(m,h),s=Math.max(a.height,l),o=Math.max(a.width,n);(0,i.Pj)(a,{height:s,width:o}),e=a.x+o/2,t=a.y+s/2,r&&(r=this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,a))}let p=this.getTopLayerFrameAtSceneCoords({x:e,y:t}),u=o||(0,i.Xf)({x:r?r.elementCenterX:e,y:r?r.elementCenterY:t,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:r?"center":this.state.currentItemTextAlign,verticalAlign:r?i.sa.MIDDLE:i.L,containerId:s?a?.id:void 0,groupIds:a?.groupIds??[],lineHeight:h,angle:a?.angle??0,frameId:p?p.id:null});if(!o&&s&&a&&(0,i.Pj)(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:u.id})}),this.setState({editingTextElement:u}),!o)if(a&&s){let e=this.scene.getElementIndex(a.id);this.scene.insertElementAtIndex(u,e+1)}else this.scene.insertElement(u);l||o||a?this.handleTextWysiwyg(u,{isExistingElement:!!o}):this.setState({newElement:u,multiElement:null})}),(0,r.d)(this,"startImageCropping",e=>{this.store.shouldCaptureIncrement(),this.setState({croppingElementId:e.id})}),(0,r.d)(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.shouldCaptureIncrement(),this.setState({croppingElementId:null}))}),(0,r.d)(this,"handleCanvasDoubleClick",e=>{if(this.state.multiElement||"selection"!==this.state.activeTool.type)return;let t=this.scene.getSelectedElements(this.state),{x:n,y:a}=(0,i.lb)(e,this.state);if(1===t.length&&(0,i.cc)(t[0]))if(!e[i.hg.CTRL_OR_CMD]||this.state.editingLinearElement&&this.state.editingLinearElement.elementId===t[0].id||(0,i.ec)(t[0])){if(this.state.selectedLinearElement&&(0,i.ec)(t[0])){let e=i.pj.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:a},this.state,this.scene.getNonDeletedElementsMap()),l=e?i.pj.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,e,this.scene.getNonDeletedElementsMap()):-1;if(l&&l>-1){this.store.shouldCaptureIncrement(),i.pj.deleteFixedSegment(t[0],l);let s=i.pj.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:a},this.state,this.scene.getNonDeletedElementsMap()),r=s?i.pj.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:r,value:e,added:!1}},segmentMidPointHoveredCoords:s}});return}}}else{this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new i.pj(t[0])});return}if(1===t.length&&(0,i.Wb)(t[0]))return void this.startImageCropping(t[0]);if((0,i.ad)(this.interactiveCanvas),(0,i.Mc)(this.state).length>0){let e=this.getElementAtPosition(n,a),t=e&&(0,i.Rc)(e,this.state.selectedGroupIds);if(t){this.store.shouldCaptureIncrement(),this.setState(n=>({...n,...(0,i.Jc)({editingGroupId:t,selectedElementIds:{[e.id]:!0}},this.scene.getNonDeletedElements(),n,this)}));return}}if((0,i.ad)(this.interactiveCanvas),!e[i.hg.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let t=this.getElementAtPosition(n,a);if((0,i.Zb)(t))return void this.setState({activeEmbeddable:{element:t,state:"active"}});let l=this.getTextBindableContainerAtPosition(n,a);if(l&&((0,i.mc)(l)||!(0,i.sb)(l.backgroundColor)||(0,i.ng)({x:n,y:a,element:l,shape:(0,i.tg)(l,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let e=(0,i.Bj)(l,this.state,this.scene.getNonDeletedElementsMap());n=e.x,a=e.y}this.startTextEditing({sceneX:n,sceneY:a,insertAtParentCenter:!e.altKey,container:l})}}),(0,r.d)(this,"getElementLinkAtPosition",(e,t)=>{let n=this.scene.getNonDeletedElements(),a=-1;for(let l=n.length-1;l>=0;l--){let s=n[l];if(t&&s.id===t.id&&(a=l),s.link&&l>=a&&(0,i.Uh)(s,this.scene.getNonDeletedElementsMap(),this.state,(0,i.Ua)(e.x,e.y),this.device.editor.isMobile))return s}}),(0,r.d)(this,"redirectToLink",(e,t)=>{let n=(0,i.Wa)((0,i.Ua)(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),(0,i.Ua)(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>i.t)return;let a=(0,i.lb)(this.lastPointerDownEvent,this.state),l=this.scene.getNonDeletedElementsMap(),s=(0,i.Uh)(this.hitLinkElement,l,this.state,(0,i.Ua)(a.x,a.y),this.device.editor.isMobile),r=(0,i.lb)(this.lastPointerUpEvent,this.state),o=(0,i.Uh)(this.hitLinkElement,l,this.state,(0,i.Ua)(r.x,r.y),this.device.editor.isMobile);if(s&&o){nr();let t=this.hitLinkElement.link;if(t){let n;if(t=(0,i.Xc)(t),this.props.onLinkOpen&&(n=(0,i.Cb)("excalidraw-link",e.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:t},n)),!n?.defaultPrevented){let e=(0,i.Yc)(t)?"_self":"_blank",n=window.open(void 0,e);n&&(n.opener=null,n.location=t)}}}}),(0,r.d)(this,"getTopLayerFrameAtSceneCoords",e=>{let t=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(n=>(0,i.zi)(e,n,t));return n.length?n[n.length-1]:null}),(0,r.d)(this,"handleCanvasPointerMove",e=>{var t,n,a;this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.lastPointerMoveEvent=e.nativeEvent,rr.pointers.has(e.pointerId)&&rr.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});let l=rr.initialScale;if(2===rr.pointers.size&&rr.lastCenter&&l&&rr.initialDistance){let e=iW(rr.pointers),t=e.x-rr.lastCenter.x,n=e.y-rr.lastCenter.y;rr.lastCenter=e;let a=iH(Array.from(rr.pointers.values())),s="freedraw"===this.state.activeTool.type&&this.state.penMode?1:a/rr.initialDistance,r=s?(0,i.Ak)(l*s):this.state.zoom.value;this.setState(i=>{let a=ta({viewportX:e.x,viewportY:e.y,nextZoom:r},i);this.translateCanvas({zoom:a.zoom,scrollX:a.scrollX+t/r*2,scrollY:a.scrollY+n/r*2,shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else rr.lastCenter=rr.initialDistance=rr.initialScale=null;if(s6||s8||s7||(0,i.Hc)(this.state))return;let s=ai(s9,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop).isOverEither;this.state.newElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.state.multiElement||(s?(0,i.ad)(this.interactiveCanvas):(0,i.dd)(this.interactiveCanvas,this.state));let r=(0,i.lb)(e,this.state),{x:o,y:d}=r;if(!this.state.newElement&&(0,i.nj)(this.state.activeTool.type)){let{originOffset:t,snapLines:n}=(0,i.mj)(this.scene.getNonDeletedElements(),this,{x:o,y:d},e,this.scene.getNonDeletedElementsMap());this.setState(e=>{let a=(0,i.Ob)(e.snapLines,n),l=e.originSnapOffset?(0,i.Ob)(e.originSnapOffset,t):t;return e.snapLines===a&&e.originSnapOffset===l?null:{snapLines:a,originSnapOffset:l}})}else this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.selectionElement||this.setState(e=>e.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let t=i.pj.handlePointerMove(e,o,d,this,this.scene.getNonDeletedElementsMap());t&&t!==this.state.editingLinearElement&&(0,p.flushSync)(()=>{this.setState({editingLinearElement:t})}),t?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(r,t.elbowed):(0,p.flushSync)(()=>{this.setState({suggestedBindings:[]})})}if((0,i.hc)(this.state.activeTool.type)){let{newElement:e}=this.state;(0,i.gc)(e,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(e,[r],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(r,!1)}if(this.state.multiElement){let{multiElement:t}=this.state,{x:n,y:a}=t,{points:l,lastCommittedPoint:s}=t,r=l[l.length-1];if((0,i.dd)(this.interactiveCanvas,this.state),r===s)(0,i.Wa)((0,i.Ua)(o-n,d-a),r)>=i.u?(0,i.Pj)(t,{points:[...l,(0,i.Ua)(o-n,d-a)]},!1):(0,i.bd)(this.interactiveCanvas,i.z.POINTER);else if(l.length>2&&s&&(0,i.Wa)((0,i.Ua)(o-n,d-a),s)<i.u)(0,i.bd)(this.interactiveCanvas,i.z.POINTER),(0,i.Pj)(t,{points:l.slice(0,-1)},!1);else{let[s,r]=(0,i.oj)(o,d,e[i.hg.CTRL_OR_CMD]||(0,i.ec)(t)?null:this.getEffectiveGridSize()),[c,h]=t?.lastCommittedPoint??[0,0],m=s-n-c,p=r-a-h;(0,i.mg)(e)&&({width:m,height:p}=(0,i.Vj)(c+n,h+a,s,r)),(0,i.xg)(l,this.state.zoom.value)&&(0,i.bd)(this.interactiveCanvas,i.z.POINTER),(0,i.Pj)(t,{points:[...l.slice(0,-1),(0,i.Ua)(c+m,h+p)]},!1,{isDragging:!0}),this.triggerRender(!1)}return}if(e.buttons||"selection"!==this.state.activeTool.type&&"text"!==this.state.activeTool.type&&"eraser"!==this.state.activeTool.type)return;let c=this.scene.getNonDeletedElements(),h=this.scene.getSelectedElements(this.state);if(1!==h.length||s||this.state.editingLinearElement){if(h.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let t=(0,i.ak)((0,i.bj)(h),o,d,this.state.zoom,e.pointerType,this.device);if(t)return void(0,i.bd)(this.interactiveCanvas,(0,i.bk)({transformHandleType:t}))}}else if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,o,d),(!this.state.selectedLinearElement||-1===this.state.selectedLinearElement.hoverPointIndex)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(1===h.length&&(0,i.ec)(h[0]))){let t=(0,i.$j)(c,this.state,o,d,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(t&&t.transformHandleType)return void(0,i.bd)(this.interactiveCanvas,(0,i.bk)(t))}let m=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,m),!(0,i.Gc)(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?((0,i.bd)(this.interactiveCanvas,i.z.POINTER),t=this.hitLinkElement,n=this.state,a=this.scene.getNonDeletedElementsMap(),ns&&clearTimeout(ns),ns=window.setTimeout(()=>((e,t,n)=>{if(!e.link)return;let a=tl();a.classList.add("excalidraw-tooltip--visible"),a.style.maxWidth="20rem",a.textContent=(0,i.$h)(e.link)?z("labels.link.goToElement"):e.link;let[l,s,r,o]=(0,i.aj)(e,n),[d,c,h,m]=(0,i.Sh)([l,s,r,o],e.angle,t),p=(0,i.mb)({sceneX:d,sceneY:c},t);ts(a,{left:p.x,top:p.y,width:h,height:m},"top"),ed("hyperlink","tooltip","link-icon"),nt=!0})(t,n,a),i.ca)):(nr(),m&&(m.link||(0,i.Xb)(m))&&this.state.selectedElementIds[m.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):"text"===this.state.activeTool.type?(0,i.bd)(this.interactiveCanvas,(0,i._b)(m)?i.z.TEXT:i.z.CROSSHAIR):this.state.viewModeEnabled?(0,i.bd)(this.interactiveCanvas,i.z.GRAB):this.state.openDialog?.name==="elementLinkSelector"||s?(0,i.bd)(this.interactiveCanvas,i.z.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,o,d):e[i.hg.CTRL_OR_CMD]?(0,i.bd)(this.interactiveCanvas,i.z.AUTO):(m||this.isHittingCommonBoundingBoxOfSelectedElements(r,h))&&!m?.locked&&(m&&(0,i.Zb)(m)&&this.isIframeLikeElementCenter(m,e,o,d)?((0,i.bd)(this.interactiveCanvas,i.z.POINTER),this.setState({activeEmbeddable:{element:m,state:"hover"}})):m&&(0,i.ec)(m)||((0,i.bd)(this.interactiveCanvas,i.z.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name==="elementLinkSelector"&&m?this.setState(e=>({hoveredElementIds:(0,i.Ob)(e.hoveredElementIds,(0,i.Jc)({editingGroupId:e.editingGroupId,selectedElementIds:{[m.id]:!0}},this.scene.getNonDeletedElements(),e,this).selectedElementIds)})):this.state.openDialog?.name!=="elementLinkSelector"||m||this.setState(e=>({hoveredElementIds:(0,i.Ob)(e.hoveredElementIds,{})})))}),(0,r.d)(this,"handleEraser",(e,t,n)=>{this.eraserTrail.addPointToPath(n.x,n.y);let a=!1,l=new Set,s=this.scene.getNonDeletedElements(),r=t=>{for(let n of t){if(n.locked)return;if(e.altKey?this.elementsPendingErasure.delete(n.id)&&(a=!0):this.elementsPendingErasure.has(n.id)||(a=!0,this.elementsPendingErasure.add(n.id)),a&&n.groupIds?.length){let t=n.groupIds.at(-1);if(!l.has(t))for(let n of(l.add(t),(0,i.Qc)(s,t)))e.altKey?this.elementsPendingErasure.delete(n.id):this.elementsPendingErasure.add(n.id)}}},o=(0,i.Wa)((0,i.Ua)(t.lastCoords.x,t.lastCoords.y),(0,i.Ua)(n.x,n.y)),d=this.getElementHitThreshold(),c={...t.lastCoords},h=0;for(;h<=o&&(r(this.getElementsAtPosition(c.x,c.y)),h!==o);){let e=(h=Math.min(h+d,o))/o,t=(1-e)*c.x+e*n.x,i=(1-e)*c.y+e*n.y;c.x=t,c.y=i}if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,a){for(let t of this.scene.getNonDeletedElements())(0,i.nc)(t)&&(this.elementsPendingErasure.has(t.id)||this.elementsPendingErasure.has(t.containerId))&&(e.altKey?(this.elementsPendingErasure.delete(t.id),this.elementsPendingErasure.delete(t.containerId)):(this.elementsPendingErasure.add(t.id),this.elementsPendingErasure.add(t.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.triggerRender()}}),(0,r.d)(this,"handleTouchMove",e=>{rt=!0}),(0,r.d)(this,"handleCanvasPointerDown",e=>{let t=e.target;if(t.setPointerCapture&&t.setPointerCapture(e.pointerId),this.maybeCleanupAfterMissingPointerUp(e.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(e=>({searchMatches:e.searchMatches.map(e=>({...e,focus:!1}))})),D.set(a2,null)),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(e),"touch"===e.pointerType&&this.state.newElement&&"freedraw"===this.state.newElement.type){let e=this.state.newElement;this.updateScene({...e.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(t=>t.id!==e.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:(0,i.xk)(Object.keys(this.state.selectedElementIds).filter(t=>t!==e.id).reduce((e,t)=>(e[t]=this.state.selectedElementIds[t],e),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?i.Wg.EVENTUALLY:i.Wg.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(e),this.state.penDetected||"pen"!==e.pointerType||this.setState(e=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(e.pointerType)&&(this.device=(0,i.Db)(this.device,{isTouchScreen:!0})),s8||(this.lastPointerDownEvent=e,this.handleCanvasPanUsingWheelOrSpaceDrag(e)))return;if(this.setState({lastPointerDownWith:e.pointerType,cursorButton:"down"}),this.savePointer(e.clientX,e.clientY,"down"),e.button===i.A.ERASER&&this.state.activeTool.type!==i.Aa.eraser)return void this.setState({activeTool:(0,i.jb)(this.state,{type:i.Aa.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(e);let t=()=>{n(),a?.(),(0,i.Gc)(this.state)&&this.setState({activeTool:(0,i.jb)(this.state,{...this.state.activeTool.lastActiveTool||{type:i.Aa.selection},lastActiveToolBeforeEraser:null})})},n=(0,i.Pb)(window,"pointerup",t,{once:!0}),a;requestAnimationFrame(()=>{a=this.missingPointerEventCleanupEmitter.once(t)})});if(e.button!==i.A.MAIN&&e.button!==i.A.TOUCH&&e.button!==i.A.ERASER||rr.pointers.size>1)return;let a=this.initialPointerDownState(e);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(e,a)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(e),this.handleSelectionOnPointerDown(e,a))||!(!this.state.penMode||"touch"!==e.pointerType||"selection"===this.state.activeTool.type||"text"===this.state.activeTool.type||"image"===this.state.activeTool.type))return;if("text"===this.state.activeTool.type)this.handleTextOnPointerDown(e,a);else if("arrow"===this.state.activeTool.type||"line"===this.state.activeTool.type)this.handleLinearElementOnPointerDown(e,this.state.activeTool.type,a);else if("image"===this.state.activeTool.type){(0,i.bd)(this.interactiveCanvas,i.z.CROSSHAIR);let t=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!t)return;this.setState({newElement:t,pendingImageElementId:null,multiElement:null});let{x:n,y:a}=(0,i.lb)(e,this.state),l=this.getTopLayerFrameAtSceneCoords({x:n,y:a});(0,i.Pj)(t,{x:n,y:a,frameId:l?l.id:null})}else"freedraw"===this.state.activeTool.type?this.handleFreeDrawElementOnPointerDown(e,this.state.activeTool.type,a):"custom"===this.state.activeTool.type?(0,i.dd)(this.interactiveCanvas,this.state):this.state.activeTool.type===i.Aa.frame||this.state.activeTool.type===i.Aa.magicframe?this.createFrameElementOnPointerDown(a,this.state.activeTool.type):"laser"===this.state.activeTool.type?this.laserTrails.startPath(a.lastCoords.x,a.lastCoords.y):"eraser"!==this.state.activeTool.type&&"hand"!==this.state.activeTool.type&&this.createGenericElementOnPointerDown(this.state.activeTool.type,a);this.props?.onPointerDown?.(this.state.activeTool,a),this.onPointerDownEmitter.trigger(this.state.activeTool,a,e),"eraser"===this.state.activeTool.type&&this.eraserTrail.startPath(a.lastCoords.x,a.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(a),s=this.onPointerUpFromPointerDownHandler(a),r=this.onKeyDownFromPointerDownHandler(a),o=this.onKeyUpFromPointerDownHandler(a);this.missingPointerEventCleanupEmitter.once(t=>s(t||e.nativeEvent)),this.state.viewModeEnabled&&"laser"!==this.state.activeTool.type||(window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("keydown",r),window.addEventListener("keyup",o),a.eventListeners.onMove=l,a.eventListeners.onUp=s,a.eventListeners.onKeyUp=o,a.eventListeners.onKeyDown=r)}),(0,r.d)(this,"handleCanvasPointerUp",e=>{this.removePointer(e),this.lastPointerUpEvent=e;let t=(0,i.lb)({clientX:e.clientX,clientY:e.clientY},this.state),n=e.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let n=this.getElementAtPosition(t.x,t.y);if((0,i.Zb)(n)&&this.isIframeLikeElementCenter(n,e,t.x,t.y))return void this.handleEmbeddableCenterClick(n)}if(this.device.isTouchScreen){let e=this.getElementAtPosition(t.x,t.y);this.hitLinkElement=this.getElementLinkAtPosition(t,e)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&(0,i.Zb)(this.hitLinkElement)&&!(0,i.Th)(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,(0,i.Ua)(t.x,t.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(e,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}),(0,r.d)(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",e=>{"touch"===e.pointerType&&(rt=!1,re?rt=!0:re=window.setTimeout(()=>{re=0,rt||this.handleCanvasContextMenu(e)},i.Z))}),(0,r.d)(this,"resetContextMenuTimer",()=>{clearTimeout(re),re=0,rt=!1}),(0,r.d)(this,"maybeCleanupAfterMissingPointerUp",e=>{rs?.(),this.missingPointerEventCleanupEmitter.trigger(e).clear()}),(0,r.d)(this,"handleCanvasPanUsingWheelOrSpaceDrag",e=>{if(!(rr.pointers.size<=1&&(e.button===i.A.WHEEL||e.button===i.A.MAIN&&s6||(0,i.Hc)(this.state)||this.state.viewModeEnabled)))return!1;s8=!0,this.focusContainer(),this.state.editingTextElement||e.preventDefault();let t=!1,n=/Linux/.test(window.navigator.platform);(0,i.bd)(this.interactiveCanvas,i.z.GRABBING);let{clientX:a,clientY:l}=e,s=so(e=>{let i=a-e.clientX,s=l-e.clientY;if(a=e.clientX,l=e.clientY,n&&!t&&(Math.abs(i)>1||Math.abs(s)>1)){t=!0;let e=t=>{document.body.removeEventListener("paste",e),t.stopPropagation()},n=()=>{setTimeout(()=>{document.body.removeEventListener("paste",e),window.removeEventListener("pointerup",n)},100)};document.body.addEventListener("paste",e),window.addEventListener("pointerup",n)}this.translateCanvas({scrollX:this.state.scrollX-i/this.state.zoom.value,scrollY:this.state.scrollY-s/this.state.zoom.value})}),r=sr(rs=()=>{rs=null,s8=!1,s6||(this.state.viewModeEnabled?(0,i.bd)(this.interactiveCanvas,i.z.GRAB):(0,i.dd)(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(e.clientX,e.clientY,"up"),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),s.flush()});return window.addEventListener("blur",r),window.addEventListener("pointermove",s,{passive:!0}),window.addEventListener("pointerup",r),!0}),(0,r.d)(this,"clearSelectionIfNotUsingSelection",()=>{"selection"!==this.state.activeTool.type&&this.setState({selectedElementIds:(0,i.xk)({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}),(0,r.d)(this,"handleSelectionOnPointerDown",(e,t)=>{if("selection"===this.state.activeTool.type){let n=this.scene.getNonDeletedElements(),a=this.scene.getNonDeletedElementsMap(),l=this.scene.getSelectedElements(this.state);if(1!==l.length||this.state.editingLinearElement||(0,i.ec)(l[0])||this.state.selectedLinearElement&&-1!==this.state.selectedLinearElement.hoverPointIndex)l.length>1&&(t.resize.handleType=(0,i.ak)((0,i.bj)(l),t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.device));else{let a=(0,i.$j)(n,this.state,t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.device);null!=a&&("rotation"===a.transformHandleType?this.setState({resizingElement:a.element}):this.state.croppingElementId||this.setState({resizingElement:a.element}),t.resize.handleType=a.transformHandleType)}if(t.resize.handleType)t.resize.isResizing=!0,t.resize.offset=(0,i.ob)((0,i.ek)(t.resize.handleType,l,a,t.origin.x,t.origin.y)),1===l.length&&(0,i.cc)(l[0])&&2===l[0].points.length&&(t.resize.arrowDirection=(0,i.fk)(t.resize.handleType,l[0]));else{if(this.state.selectedLinearElement){let n=this.state.editingLinearElement||this.state.selectedLinearElement,a=i.pj.handlePointerDown(e,this,this.store,t.origin,n,this.scene);if(a.hitElement&&(t.hit.element=a.hitElement),a.linearElementEditor&&(this.setState({selectedLinearElement:a.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:a.linearElementEditor})),a.didAddPoint)return!0}if(t.hit.element=t.hit.element??this.getElementAtPosition(t.origin.x,t.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(t.origin,t.hit.element),this.hitLinkElement)return!0;if(this.state.croppingElementId&&t.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),t.hit.element&&this.getElementLinkAtPosition({x:t.origin.x,y:t.origin.y},t.hit.element))return!1;t.hit.allHitElements=this.getElementsAtPosition(t.origin.x,t.origin.y);let n=t.hit.element,a=t.hit.allHitElements.some(e=>this.isASelectedElement(e));if(null!==n&&a||e.shiftKey||t.hit.hasHitCommonBoundingBoxOfSelectedElements||this.clearSelection(n),this.state.editingLinearElement)this.setState({selectedElementIds:(0,i.xk)({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(null!=n){if(e[i.hg.CTRL_OR_CMD])return this.state.selectedElementIds[n.id]||(t.hit.wasAddedToSelection=!0),this.setState(e=>({...(0,i.Oc)(e,n),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[n.id]||(this.state.editingGroupId&&!(0,i.Pc)(n,this.state.editingGroupId)&&this.setState({selectedElementIds:(0,i.xk)({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),a||t.hit.hasHitCommonBoundingBoxOfSelectedElements||(this.setState(e=>{let t={...e.selectedElementIds,[n.id]:!0},a=[];if(Object.keys(e.selectedElementIds).forEach(e=>{let t=this.scene.getElement(e);t&&a.push(t)}),(0,i.bc)(n))(0,i.Bi)(a,n.id).forEach(e=>{delete t[e.id]});else if(n.frameId)t[n.frameId]&&delete t[n.id];else{let e=new Set(n.groupIds.flatMap(e=>(0,i.Qc)(this.scene.getNonDeletedElements(),e)).filter(e=>(0,i.bc)(e)).map(e=>e.id));e.size>0&&a.forEach(n=>{n.frameId&&e.has(n.frameId)&&(delete t[n.id],n.groupIds.flatMap(e=>(0,i.Qc)(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return e.openDialog?.name==="elementLinkSelector"&&(n.groupIds.some(t=>e.selectedGroupIds[t])||(t={[n.id]:!0})),{...(0,i.Jc)({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:!!(n.link||(0,i.Xb)(n))&&"info"}}),t.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1}),(0,r.d)(this,"handleTextOnPointerDown",(e,t)=>{if(this.state.editingTextElement)return;let n=t.origin.x,a=t.origin.y,l=this.getElementAtPosition(n,a,{includeBoundTextElement:!0}),s=this.getTextBindableContainerAtPosition(n,a);(0,i.mc)(l)&&(s=l,n=l.x+l.width/2,a=l.y+l.height/2),this.startTextEditing({sceneX:n,sceneY:a,insertAtParentCenter:!e.altKey,container:s,autoEdit:!1}),(0,i.ad)(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:(0,i.jb)(this.state,{type:"selection"})})}),(0,r.d)(this,"handleFreeDrawElementOnPointerDown",(e,t,n)=>{let[a,l]=(0,i.oj)(n.origin.x,n.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:a,y:l}),r=.5===e.pressure,o=(0,i.Zf)({type:t,x:a,y:l,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:r,locked:!1,frameId:s?s.id:null,points:[(0,i.Ua)(0,0)],pressures:r?[]:[e.pressure]});this.scene.insertElement(o),this.setState(e=>{let t={...e.selectedElementIds};return delete t[o.id],{selectedElementIds:(0,i.xk)(t,e)}});let d=(0,i.Og)(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:o,startBoundElement:d,suggestedBindings:[]})}),(0,r.d)(this,"insertIframeElement",({sceneX:e,sceneY:t,width:n,height:a})=>{let[l,s]=(0,i.oj)(e,t,this.lastPointerDownEvent?.[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),r=(0,i.Uf)({type:"iframe",x:l,y:s,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:n,height:a});return this.scene.insertElement(r),r}),(0,r.d)(this,"insertEmbeddableElement",({sceneX:e,sceneY:t,link:n})=>{let[a,l]=(0,i.oj)(e,t,this.lastPointerDownEvent?.[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=(0,i.Zg)(n);if(!s)return;s.error instanceof URIError&&this.setToast({message:z("toast.unrecognizedLinkFormat"),closable:!0});let r=(0,i.Tf)({type:"embeddable",x:a,y:l,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:s.intrinsicSize.w,height:s.intrinsicSize.h,link:n});return this.scene.insertElement(r),r}),(0,r.d)(this,"createImageElement",({sceneX:e,sceneY:t,addToFrameUnderCursor:n=!0})=>{let[a,l]=(0,i.oj)(e,t,this.lastPointerDownEvent?.[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=n?this.getTopLayerFrameAtSceneCoords({x:a,y:l}):null;return(0,i.ag)({type:"image",x:a,y:l,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:s?s.id:null})}),(0,r.d)(this,"handleLinearElementOnPointerDown",(e,t,n)=>{if(this.state.multiElement){let{multiElement:e}=this.state;if("line"===e.type&&(0,i.xg)(e.points,this.state.zoom.value)||(0,i.ec)(e)&&e.points.length>1){(0,i.Pj)(e,{lastCommittedPoint:e.points[e.points.length-1]}),this.actionManager.executeAction(tg);return}let{x:t,y:a,lastCommittedPoint:l}=e;if(e.points.length>1&&l&&(0,i.Wa)((0,i.Ua)(n.origin.x-t,n.origin.y-a),l)<i.u)return void this.actionManager.executeAction(tg);this.setState(t=>({selectedElementIds:(0,i.xk)({...t.selectedElementIds,[e.id]:!0},t)})),(0,i.Pj)(e,{lastCommittedPoint:e.points[e.points.length-1]}),(0,i.bd)(this.interactiveCanvas,i.z.POINTER)}else{let[a,l]=(0,i.oj)(n.origin.x,n.origin.y,e[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:a,y:l}),{currentItemStartArrowhead:r,currentItemEndArrowhead:o}=this.state,[d,c]="arrow"===t?[r,o]:[null,null],h="arrow"===t?(0,i.$f)({type:t,x:a,y:l,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.currentItemArrowType===i.Fa.round?{type:i.ua.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:c,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===i.Fa.elbow,fixedSegments:this.state.currentItemArrowType===i.Fa.elbow?[]:null}):(0,i._f)({type:t,x:a,y:l,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:"round"===this.state.currentItemRoundness?{type:i.ua.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null});this.setState(e=>{let t={...e.selectedElementIds};return delete t[h.id],{selectedElementIds:(0,i.xk)(t,e)}}),(0,i.Pj)(h,{points:[...h.points,(0,i.Ua)(0,0)]});let m=(0,i.Og)(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,(0,i.ec)(h),(0,i.ec)(h));this.scene.insertElement(h),this.setState({newElement:h,startBoundElement:m,suggestedBindings:[]})}}),(0,r.d)(this,"createGenericElementOnPointerDown",(e,t)=>{let[n,a]=(0,i.oj)(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:n,y:a}),s={x:n,y:a,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(e),locked:!1,frameId:l?l.id:null},r;"selection"===(r="embeddable"===e?(0,i.Tf)({type:"embeddable",...s}):(0,i.Sf)({type:e,...s})).type?this.setState({selectionElement:r}):(this.scene.insertElement(r),this.setState({multiElement:null,newElement:r}))}),(0,r.d)(this,"createFrameElementOnPointerDown",(e,t)=>{let[n,a]=(0,i.oj)(e.origin.x,e.origin.y,this.lastPointerDownEvent?.[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l={x:n,y:a,opacity:this.state.currentItemOpacity,locked:!1,...i.H},s=t===i.Aa.magicframe?(0,i.Wf)(l):(0,i.Vf)(l);this.scene.insertElement(s),this.setState({multiElement:null,newElement:s})}),(0,r.d)(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()}),(0,r.d)(this,"eraseElements",()=>{let e=!1,t=this.scene.getElementsIncludingDeleted().map(t=>this.elementsPendingErasure.has(t.id)||t.frameId&&this.elementsPendingErasure.has(t.frameId)||(0,i.nc)(t)&&this.elementsPendingErasure.has(t.containerId)?(e=!0,(0,i.Qj)(t,{isDeleted:!0})):t);this.elementsPendingErasure=new Set,e&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(t))}),(0,r.d)(this,"initializeImage",async({imageFile:e,imageElement:t,showCursorImagePreview:n=!1})=>{if(!(0,i.th)(e))throw Error(z("errors.unsupportedFileType"));let a=e.type;if((0,i.bd)(this.interactiveCanvas,"wait"),a===i.T.svg)try{e=(0,i.Fh)((0,i.Rh)(await e.text()),e.name)}catch(e){throw console.warn(e),Error(z("errors.svgImageInsertError"))}let l=await (this.props.generateIdForFile?.(e)||(0,i.zh)(e));if(!l)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),Error(z("errors.imageInsertError"));if(!this.files[l]?.dataURL){try{e=await (0,i.Eh)(e,{maxWidthOrHeight:i.na})}catch(e){console.error("Error trying to resizing image file on insertion",e)}if(e.size>i.oa)throw Error(z("errors.fileTooBig",{maxSize:`${Math.trunc(i.oa/1024/1024)}MB`}))}if(n){let t=this.files[l]?.dataURL,n=t&&(0,i.Ch)(t);this.setImagePreviewCursor(n||e)}let s=this.files[l]?.dataURL||await (0,i.Ah)(e),r=(0,i.Pj)(t,{fileId:l},!1);return new Promise(async(e,t)=>{try{this.addMissingFiles([{mimeType:a,id:l,dataURL:s,created:Date.now(),lastRetrieved:Date.now()}]);let t=this.imageCache.get(l);t||(this.addNewImagesToImageCache(),await this.updateImageCache([r])),t?.image instanceof Promise&&await t.image,this.state.pendingImageElementId!==r.id&&this.state.newElement?.id!==r.id&&this.initializeImageDimensions(r,!0),e(r)}catch(e){console.error(e),t(Error(z("errors.imageInsertError")))}finally{n||(0,i.ad)(this.interactiveCanvas)}})}),(0,r.d)(this,"insertImageElement",async(e,t,n)=>{if(!this.isToolSupported("image"))return void this.setState({errorMessage:z("errors.imageToolNotSupported")});this.scene.insertElement(e);try{return await this.initializeImage({imageFile:t,imageElement:e,showCursorImagePreview:n})}catch(t){return(0,i.Pj)(e,{isDeleted:!0}),this.actionManager.executeAction(tg),this.setState({errorMessage:t.message||z("errors.imageInsertError")}),null}}),(0,r.d)(this,"setImagePreviewCursor",async e=>{let t;try{t=await (0,i.Eh)(e,{maxWidthOrHeight:96})}catch(e){throw"UNSUPPORTED"===e.cause?Error(z("errors.unsupportedFileType")):e}let n=await (0,i.Ah)(t);if(e.type===i.T.svg){let e=await (0,i.Oh)(n),t=Math.min(e.height,96),a=t*(e.width/e.height);a>96&&(t=(a=96)*(e.height/e.width));let l=document.createElement("canvas");l.height=t,l.width=a,l.getContext("2d").drawImage(e,0,0,a,t),n=l.toDataURL(i.T.svg)}this.state.pendingImageElementId&&(0,i.bd)(this.interactiveCanvas,`url(${n}) 4 4, auto`)}),(0,r.d)(this,"onImageAction",async({insertOnCanvasDirectly:e})=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:a,y:l}=(0,i.lb)({clientX:t,clientY:n},this.state),s=await (0,i.fh)({description:"Image",extensions:Object.keys(i.S)}),r=this.createImageElement({sceneX:a,sceneY:l,addToFrameUnderCursor:!1});e?(this.insertImageElement(r,s),this.initializeImageDimensions(r),this.setState({selectedElementIds:(0,i.xk)({[r.id]:!0},this.state)},()=>{this.actionManager.executeAction(tg)})):this.setState({pendingImageElementId:r.id},()=>{this.insertImageElement(r,s,!0)})}catch(e){"AbortError"!==e.name?console.error(e):console.warn(e),this.setState({pendingImageElementId:null,newElement:null,activeTool:(0,i.jb)(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(tg)})}}),(0,r.d)(this,"initializeImageDimensions",(e,t=!1)=>{let n=(0,i.Vb)(e)&&this.imageCache.get(e.fileId)?.image;if(!n||n instanceof Promise){if(e.width<i.t/this.state.zoom.value&&e.height<i.t/this.state.zoom.value){let t=100/this.state.zoom.value;(0,i.Pj)(e,{x:e.x-t/2,y:e.y-t/2,width:t,height:t})}return}if(t||e.width<i.t/this.state.zoom.value&&e.height<i.t/this.state.zoom.value){let t=Math.min(Math.max(this.state.height-120,160),Math.floor(.5*this.state.height)/this.state.zoom.value),a=Math.min(n.naturalHeight,t),l=a*(n.naturalWidth/n.naturalHeight),s=e.x+e.width/2-l/2,r=e.y+e.height/2-a/2;(0,i.Pj)(e,{x:s,y:r,width:l,height:a,crop:null})}}),(0,r.d)(this,"updateImageCache",async(e,t=this.files)=>{let{updatedFiles:n,erroredFiles:a}=await (0,i.Ph)({imageCache:this.imageCache,fileIds:e.map(e=>e.fileId),files:t});if(n.size||a.size)for(let t of e)n.has(t.fileId)&&i.ed.delete(t);return a.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(e=>(0,i.Vb)(e)&&a.has(e.fileId)?(0,i.Qj)(e,{status:"error"}):e)),{updatedFiles:n,erroredFiles:a}}),(0,r.d)(this,"addNewImagesToImageCache",async(e=(0,i.Qh)(this.scene.getNonDeletedElements()),t=this.files)=>{let n=e.filter(e=>!e.isDeleted&&!this.imageCache.has(e.fileId));if(n.length){let{updatedFiles:e}=await this.updateImageCache(n,t);e.size&&this.scene.triggerUpdate()}}),(0,r.d)(this,"scheduleImageRefresh",x(()=>{this.addNewImagesToImageCache()},i.X)),(0,r.d)(this,"updateBindingEnabledOnPointerMove",e=>{let t=(0,i.Eg)(e);this.state.isBindingEnabled!==t&&this.setState({isBindingEnabled:t})}),(0,r.d)(this,"maybeSuggestBindingAtCursor",(e,t)=>{let n=(0,i.Og)(e,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,t);this.setState({suggestedBindings:null!=n?[n]:[]})}),(0,r.d)(this,"maybeSuggestBindingsForLinearElementAtCoords",(e,t,n)=>{if(!t.length)return;let a=t.reduce((t,a)=>{let l=(0,i.Og)(a,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,(0,i.ec)(e),(0,i.ec)(e));return null==l||(0,i.Ng)(e,n?.id,l)||t.push(l),t},[]);this.setState({suggestedBindings:a})}),(0,r.d)(this,"handleInteractiveCanvasRef",e=>{null!==e?(this.interactiveCanvas=e,this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))}),(0,r.d)(this,"handleAppOnDrop",async e=>{let{file:t,fileHandle:n}=await (0,i.Hh)(e),{x:a,y:l}=(0,i.lb)(e,this.state);try{if((0,i.th)(t)&&this.isToolSupported("image")){if(t?.type===i.T.png||t?.type===i.T.svg)try{let e=await (0,i.vh)(t,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...e,appState:{...e.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:i.Wg.IMMEDIATELY});return}catch(e){if("EncodingError"!==e.name)throw Error(z("alerts.couldNotLoadInvalidFile"))}let e=this.createImageElement({sceneX:a,sceneY:l});this.insertImageElement(e,t),this.initializeImageDimensions(e),this.setState({selectedElementIds:(0,i.xk)({[e.id]:!0},this.state)});return}}catch(e){return this.setState({isLoading:!1,errorMessage:e.message})}let s=e.dataTransfer.getData(i.T.excalidrawlib);if(s&&"string"==typeof s){try{let t=(0,i.wh)(s);this.addElementsFromPasteOrLibrary({elements:nS(t),position:e,files:null})}catch(e){this.setState({errorMessage:e.message})}return}if(t&&await this.loadFileToCanvas(t,n),e.dataTransfer?.types?.includes("text/plain")){let t=e.dataTransfer?.getData("text");if(t&&(0,i.$g)(t,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(t)||(0,i.Zg)(t)?.type==="video")){let e=this.insertEmbeddableElement({sceneX:a,sceneY:l,link:(0,i.Xc)(t)});e&&this.setState({selectedElementIds:{[e.id]:!0}})}}}),(0,r.d)(this,"loadFileToCanvas",async(e,t)=>{e=await (0,i.Ih)(e);try{let n=this.scene.getElementsIncludingDeleted(),a;try{a=await (0,i.uh)(e,this.state,n,t)}catch(n){let e=n instanceof i.uc;if(e&&"IMAGE_NOT_CONTAINS_SCENE_DATA"===n.code&&!this.isToolSupported("image"))return void this.setState({isLoading:!1,errorMessage:z("errors.imageToolNotSupported")});let t=e?z("alerts.cannotRestoreFromImage"):z("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:t})}if(!a)return;a.type===i.T.excalidraw?((0,i.Nj)(n.concat(a.data.elements)),this.store.updateSnapshot((0,i.xb)(n),this.state),this.setState({isLoading:!0}),this.syncActionResult({...a.data,appState:{...a.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:i.Wg.IMMEDIATELY})):a.type===i.T.excalidrawlib&&await this.library.updateLibrary({libraryItems:e,merge:!0,openLibraryMenu:!0}).catch(e=>{console.error(e),this.setState({errorMessage:z("errors.importLibraryError")})})}catch(e){this.setState({isLoading:!1,errorMessage:e.message})}}),(0,r.d)(this,"handleCanvasContextMenu",e=>{if(e.preventDefault(),("pointerType"in e.nativeEvent&&"touch"===e.nativeEvent.pointerType||"pointerType"in e.nativeEvent&&"pen"===e.nativeEvent.pointerType&&e.button!==i.A.SECONDARY)&&"selection"!==this.state.activeTool.type)return;let{x:t,y:n}=(0,i.lb)(e,this.state),a=this.getElementAtPosition(t,n,{preferSelected:!0,includeLockedElements:!0}),l=this.scene.getSelectedElements(this.state),s=this.isHittingCommonBoundingBoxOfSelectedElements({x:t,y:n},l),r=a||s?"element":"canvas",{top:o,left:d}=this.excalidrawContainerRef.current.getBoundingClientRect(),c=e.clientX-d,h=e.clientY-o;ed("contextMenu","openContextMenu",r),this.setState({...a&&!this.state.selectedElementIds[a.id]?{...this.state,...(0,i.Jc)({editingGroupId:this.state.editingGroupId,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:(0,i.cc)(a)?new i.pj(a):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:h,left:c,items:this.getContextMenuItems(r)}})})}),(0,r.d)(this,"maybeDragNewGenericElement",(e,t,n=!0)=>{let a=this.state.selectionElement,l=e.lastCoords;if(a&&"eraser"!==this.state.activeTool.type)return void(0,i.kk)({newElement:a,elementType:this.state.activeTool.type,originX:e.origin.x,originY:e.origin.y,x:l.x,y:l.y,width:(0,i.ib)(e.origin.x,l.x),height:(0,i.ib)(e.origin.y,l.y),shouldMaintainAspectRatio:(0,i.lg)(t),shouldResizeFromCenter:(0,i.kg)(t),zoom:this.state.zoom.value,informMutation:n});let s=this.state.newElement;if(!s)return;let[r,o]=(0,i.oj)(l.x,l.y,t[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=(0,i.Vb)(s)&&this.imageCache.get(s.fileId)?.image,c=!d||d instanceof Promise?null:d.width/d.height;this.maybeCacheReferenceSnapPoints(t,[s]);let{snapOffset:h,snapLines:m}=(0,i.lj)(s,this,t,{x:e.originInGrid.x+(this.state.originSnapOffset?.x??0),y:e.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:r-e.originInGrid.x,y:o-e.originInGrid.y},this.scene.getNonDeletedElementsMap());r+=h.x,o+=h.y,this.setState({snapLines:m}),(0,i.kk)({newElement:s,elementType:this.state.activeTool.type,originX:e.originInGrid.x,originY:e.originInGrid.y,x:r,y:o,width:(0,i.ib)(e.originInGrid.x,r),height:(0,i.ib)(e.originInGrid.y,o),shouldMaintainAspectRatio:(0,i.Wb)(s)?!(0,i.lg)(t):(0,i.lg)(t),shouldResizeFromCenter:(0,i.kg)(t),zoom:this.state.zoom.value,widthAspectRatio:c,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:s}),(this.state.activeTool.type===i.Aa.frame||this.state.activeTool.type===i.Aa.magicframe)&&this.setState({elementsToHighlight:(0,i.Ei)(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})}),(0,r.d)(this,"maybeHandleCrop",(e,t)=>{if(!this.state.croppingElementId)return!1;let n=e.resize.handleType,a=e.lastCoords,[l,s]=(0,i.oj)(a.x-e.resize.offset.x,a.y-e.resize.offset.y,t[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),r=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&r&&(0,i.Wb)(r)){let o=e.originalElements.get(r.id),d=(0,i.Vb)(r)&&this.imageCache.get(r.fileId)?.image;if(o&&(0,i.Wb)(o)&&d&&!(d instanceof Promise)){let[c,h]=(0,i.oj)(a.x,a.y,t[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m={x:c-e.originInGrid.x,y:h-e.originInGrid.y};this.maybeCacheReferenceSnapPoints(t,[r]);let{snapOffset:p,snapLines:u}=(0,i.kj)([r],[o],this,t,m,n);(0,i.Pj)(r,(0,i.bh)(r,n,d.naturalWidth,d.naturalHeight,l+p.x,s+p.y,t.shiftKey?o.width/o.height:void 0)),(0,i.Pg)(r,this.scene.getNonDeletedElementsMap(),{newSize:{width:r.width,height:r.height}}),this.setState({isCropping:n&&"rotation"!==n,snapLines:u})}return!0}return!1}),(0,r.d)(this,"maybeHandleResize",(e,t)=>{let n=this.scene.getSelectedElements(this.state),a=n.filter(e=>(0,i.bc)(e)),l=e.resize.handleType;if(a.length>0&&"rotation"===l||1===n.length&&(0,i.ec)(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:l&&"rotation"!==l,isRotating:"rotation"===l,activeEmbeddable:null});let s=e.lastCoords,[r,o]=(0,i.oj)(s.x-e.resize.offset.x,s.y-e.resize.offset.y,t[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(a.forEach(e=>{(0,i.Bi)(this.scene.getNonDeletedElements(),e.id).forEach(t=>{d.set(e.id+t.id,{x:t.x-e.x,y:t.y-e.y})})}),!this.state.selectedElementsAreBeingDragged){let[a,d]=(0,i.oj)(s.x,s.y,t[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c={x:a-e.originInGrid.x,y:d-e.originInGrid.y},h=[...e.originalElements.values()];this.maybeCacheReferenceSnapPoints(t,n);let{snapOffset:m,snapLines:p}=(0,i.kj)(n,(0,i.vk)(h,this.state),this,t,c,l);r+=m.x,o+=m.y,this.setState({snapLines:p})}if((0,i.ck)(e.originalElements,l,n,this.scene.getElementsMapIncludingDeleted(),this.scene,(0,i.mg)(t),(0,i.kg)(t),n.some(e=>(0,i.Wb)(e))?!(0,i.lg)(t):(0,i.lg)(t),r,o,e.resize.center.x,e.resize.center.y)){let e=(0,i.Kg)(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),t=new Set;return a.forEach(e=>{(0,i.Ei)(this.scene.getNonDeletedElements(),e,this.state,this.scene.getNonDeletedElementsMap()).forEach(e=>t.add(e))}),this.setState({elementsToHighlight:[...t],suggestedBindings:e}),!0}return!1}),(0,r.d)(this,"getContextMenuItems",e=>{let t=[];return t.push(t0,tJ),"canvas"===e?this.state.viewModeEnabled?[...t,t2,t3,l8,t4]:[tQ,iG,t0,tJ,t1,iG,el,nm,iG,t2,t5,t3,l8,t4]:(t.push(t1),this.state.viewModeEnabled?[tX,...t]:[iG,tq,tX,tQ,iG,l9,se,st,iG,iP,iG,...t,iG,tN,tA,iG,tR,sO,t6,t8,ne,tO,iG,tB,iG,et,en,ei,ea,iG,tG,tV,iG,iN,iG,nd,iv,iG,es,nh,iG,V])}),(0,r.d)(this,"handleWheel",sr(e=>{if(!(e.target instanceof HTMLCanvasElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLIFrameElement)){e[i.hg.CTRL_OR_CMD]&&e.preventDefault();return}if(e.preventDefault(),s8)return;let{deltaX:t,deltaY:n}=e;if(e.metaKey||e.ctrlKey){let e=Math.sign(n),t=100*i.$,a=Math.abs(n),l=n;a>t&&(l=t*e);let s=this.state.zoom.value-l/100;s+=-(Math.log10(Math.max(1,this.state.zoom.value))*e)*Math.min(1,a/20),this.translateCanvas(e=>({...ta({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:(0,i.Ak)(s)},e),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}e.shiftKey?this.translateCanvas(({zoom:e,scrollX:i})=>({scrollX:i-(n||t)/e.value})):this.translateCanvas(({zoom:e,scrollX:i,scrollY:a})=>({scrollX:i-t/e.value,scrollY:a-n/e.value}))})),(0,r.d)(this,"savePointer",(e,t,n)=>{if(!e||!t)return;let{x:a,y:l}=(0,i.lb)({clientX:e,clientY:t},this.state);isNaN(a)||isNaN(l);let s={x:a,y:l,tool:"laser"===this.state.activeTool.type?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:n,pointersMap:rr.pointers})}),(0,r.d)(this,"resetShouldCacheIgnoreZoomDebounced",(0,i.db)(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300)),(0,r.d)(this,"updateDOMRect",e=>{if(this.excalidrawContainerRef?.current){let{width:t,height:n,left:i,top:a}=this.excalidrawContainerRef.current.getBoundingClientRect(),{width:l,height:s,offsetTop:r,offsetLeft:o}=this.state;if(t===l&&n===s&&i===o&&a===r){e&&e();return}this.setState({width:t,height:n,offsetLeft:i,offsetTop:a},()=>{e&&e()})}}),(0,r.d)(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let a=(0,i.Fc)(),{excalidrawAPI:l,viewModeEnabled:s=!1,zenModeEnabled:d=!1,gridModeEnabled:c=!1,objectsSnapModeEnabled:m=!1,theme:f=a.theme,name:b=`${z("labels.untitled")}-${(0,i.Xa)()}`}=t;if(this.state={...a,theme:f,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:s,zenModeEnabled:d,objectsSnapModeEnabled:m,gridModeEnabled:c??a.gridModeEnabled,name:b,width:window.innerWidth,height:window.innerHeight},this.id=(0,g.Ak)(),this.library=new nw(this),this.actionManager=new iB(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new i.Oj,this.canvas=document.createElement("canvas"),this.rc=u.A.canvas(this.canvas),this.renderer=new sM(this.scene),this.visibleElements=[],this.store=new i.Xg,this.history=new iR,l){let e={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:e=>{this.actionManager.registerAction(e)},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:e=>this.onChangeEmitter.on(e),onPointerDown:e=>this.onPointerDownEmitter.on(e),onPointerUp:e=>this.onPointerUpEmitter.on(e),onScrollChange:e=>this.onScrollChangeEmitter.on(e),onUserFollow:e=>this.onUserFollowEmitter.on(e)};"function"==typeof l?l(e):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new i.Qf(this.scene),this.history=new iR,this.actionManager.registerAll(i._c),this.actionManager.registerAction(((e,t)=>({name:"undo",label:"buttons.undo",icon:i.Rd,trackEvent:{category:"history"},viewMode:!1,perform:(n,a,l,s)=>iz(s,a,()=>e.undo((0,i.xb)(n),a,t.snapshot)),keyTest:e=>e[i.hg.CTRL_OR_CMD]&&(0,i.ig)(e,i.hg.Z)&&!e.shiftKey,PanelComponent:({updateData:t,data:n})=>{let{isUndoStackEmpty:a}=iF(e.onHistoryChangedEmitter,new i_(e.isUndoStackEmpty,e.isRedoStackEmpty));return(0,h.jsx)(Y,{type:"button",icon:i.Rd,"aria-label":z("buttons.undo"),onClick:t,size:n?.size||"medium",disabled:a,"data-testid":"button-undo"})}}))(this.history,this.store)),this.actionManager.registerAction(((e,t)=>({name:"redo",label:"buttons.redo",icon:i.Sd,trackEvent:{category:"history"},viewMode:!1,perform:(n,a,l,s)=>iz(s,a,()=>e.redo((0,i.xb)(n),a,t.snapshot)),keyTest:e=>e[i.hg.CTRL_OR_CMD]&&e.shiftKey&&(0,i.ig)(e,i.hg.Z)||i.m&&e.ctrlKey&&!e.shiftKey&&(0,i.ig)(e,i.hg.Y),PanelComponent:({updateData:t,data:n})=>{let{isRedoStackEmpty:a}=iF(e.onHistoryChangedEmitter,new i_(e.isUndoStackEmpty,e.isRedoStackEmpty));return(0,h.jsx)(Y,{type:"button",icon:i.Sd,"aria-label":z("buttons.redo"),onClick:t,size:n?.size||"medium",disabled:a,"data-testid":"button-redo"})}}))(this.history,this.store))}onWindowMessage(e){if("https://player.vimeo.com"!==e.origin&&"https://www.youtube.com"!==e.origin)return;let t=null;try{t=JSON.parse(e.data)}catch{}if(t)switch(e.origin){case"https://player.vimeo.com":if("paused"===t.method){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let t of i)t.contentWindow===e.source&&(n=t.contentWindow);n?.postMessage(JSON.stringify({method:t.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if("infoDelivery"===t.event&&t.info&&t.id&&"number"==typeof t.info.playerState){let e=t.id,n=t.info.playerState;Object.values(i.C).includes(n)&&rn.set(e,n)}}}cacheEmbeddableRef(e,t){t&&this.iFrameRefs.set(e.id,t)}getHTMLIFrameElement(e){return this.iFrameRefs.get(e.id)}handleEmbeddableCenterClick(e){if(this.state.activeEmbeddable?.element===e&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:e,state:"active"},selectedElementIds:{[e.id]:!0},newElement:null,selectionElement:null})},100),(0,i.Yb)(e)))return;let t=this.getHTMLIFrameElement(e);if(t?.contentWindow){if(t.src.includes("youtube")){let n=rn.get(e.id);switch(n||(rn.set(e.id,i.C.UNSTARTED),t.contentWindow.postMessage(JSON.stringify({event:"listening",id:e.id}),"*")),n){case i.C.PLAYING:case i.C.BUFFERING:t.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:t.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}t.src.includes("player.vimeo.com")&&t.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(e,t,n,i){return e&&!t.altKey&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&(this.state.activeEmbeddable?.element!==e||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=e.x+e.width/3&&n<=e.x+2*e.width/3&&i>=e.y+e.height/3&&i<=e.y+2*e.height/3}renderEmbeddables(){let e=this.state.zoom.value,t=this.state.width,n=this.state.height,a=this.scene.getNonDeletedElements().filter(e=>(0,i.Xb)(e)&&!0===this.embedsValidationStatus.get(e.id)||(0,i.Yb)(e));return(0,h.jsx)(h.Fragment,{children:a.map(a=>{let l,{x:s,y:r}=(0,i.mb)({sceneX:a.x,sceneY:a.y},this.state),o=(0,i.Tj)(a,t,n,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(o&&!d&&this.initializedEmbeds.add(a.id),!(o||d))return null;if((0,i.Yb)(a)){l=null;let e=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if("done"===e.status){let t=e.html;l={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>t}}else if("pending"===e.status)l={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>(0,i.Yg)(`
<style>
html, body {
width: 100%;
height: 100%;
color: ${this.state.theme===i.G.DARK?"white":"black"};
}
body {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 1rem;
}
.Spinner {
display: flex;
align-items: center;
justify-content: center;
margin-left: auto;
margin-right: auto;
}
.Spinner svg {
animation: rotate 1.6s linear infinite;
transform-origin: center center;
width: 40px;
height: 40px;
}
.Spinner circle {
stroke: currentColor;
animation: dash 1.6s linear 0s infinite;
stroke-linecap: round;
}
@keyframes rotate {
100% {
transform: rotate(360deg);
}
}
@keyframes dash {
0% {
stroke-dasharray: 1, 300;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 150, 300;
stroke-dashoffset: -200;
}
100% {
stroke-dasharray: 1, 300;
stroke-dashoffset: -280;
}
}
</style>
<div class="Spinner">
<svg
viewBox="0 0 100 100"
>
<circle
cx="50"
cy="50"
r="46"
stroke-width="8"
fill="none"
stroke-miter-limit="10"
/>
</svg>
</div>
<div>Generating...</div>
`)};else{let t;t="ERR_GENERATION_INTERRUPTED"===e.code?"Generation was interrupted...":e.message||"Generation failed",l={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>(0,i.Yg)(`
<style>
html, body {
height: 100%;
}
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: ${i.e.red[3]};
}
h1, h3 {
margin-top: 0;
margin-bottom: 0.5rem;
}
</style>
<h1>Error!</h1>
<h3>${t}</h3>
`)}}}else l=(0,i.Zg)((0,i.Zc)(a.link||""));let c=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",p=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return(0,h.jsx)("div",{className:(0,m.A)("excalidraw__embeddable-container",{"is-hovered":p}),style:{transform:o?`translate(${s-this.state.offsetLeft}px, ${r-this.state.offsetTop}px) scale(${e})`:"none",display:o?"block":"none",opacity:(0,i.Ri)(a,(0,i.Gi)(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?i.Ga:1),"--embeddable-radius":`${(0,i.wg)(Math.min(a.width,a.height),a)}px`},children:(0,h.jsxs)("div",{className:"excalidraw__embeddable-container__inner",style:{width:o?`${a.width}px`:0,height:o?`${a.height}px`:0,transform:o?`rotate(${a.angle}rad)`:"none",pointerEvents:c?i.B.enabled:i.B.disabled},children:[p&&(0,h.jsx)("div",{className:"excalidraw__embeddable-hint",children:z("buttons.embeddableInteractionButton")}),(0,h.jsx)("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:((0,i.Xb)(a)?this.props.renderEmbeddable?.(a,this.state):null)??(0,h.jsx)("iframe",{ref:e=>this.cacheEmbeddableRef(a,e),className:"excalidraw__embeddable",srcDoc:l?.type==="document"?l.srcdoc(this.state.theme):void 0,src:l?.type!=="document"?l?.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:`${l?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(e){document.documentElement.style.overscrollBehaviorX="pointerenter"===e.type?"none":"auto"}render(){let e=this.scene.getSelectedElements(this.state),{renderTopRightUI:t,renderCustomStats:n}=this.props,a=this.scene.getSceneNonce(),{elementsMap:l,visibleElements:s}=this.renderer.getRenderableElements({sceneNonce:a,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,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id,pendingImageElementId:this.state.pendingImageElementId});this.visibleElements=s;let r=this.scene.getNonDeletedElementsMap(),o=!("setPointerCapture"in HTMLElement.prototype)&&(this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||"laser"===this.state.activeTool.type&&"down"===this.state.cursorButton),d=e[0];return(0,h.jsx)("div",{className:(0,m.A)("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":o?i.B.disabled:i.B.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:(0,h.jsx)(sB.Provider,{value:this,children:(0,h.jsx)(sW.Provider,{value:this.props,children:(0,h.jsx)(sY.Provider,{value:this.excalidrawContainerValue,children:(0,h.jsx)(s$.Provider,{value:this.device,children:(0,h.jsx)(sK.Provider,{value:this.setAppState,children:(0,h.jsx)(sV.Provider,{value:this.state,children:(0,h.jsxs)(sG.Provider,{value:this.scene.getNonDeletedElements(),children:[(0,h.jsxs)(sZ.Provider,{value:this.actionManager,children:[(0,h.jsx)(l5,{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:_.code,renderTopRightUI:t,renderCustomStats:n,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&"selection"===this.state.activeTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),(0,h.jsx)("div",{className:"excalidraw-textEditorContainer"}),(0,h.jsx)("div",{className:"excalidraw-contextMenuContainer"}),(0,h.jsx)("div",{className:"excalidraw-eye-dropper-container"}),(0,h.jsx)(sD,{trails:[this.laserTrails,this.eraserTrail]}),1===e.length&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&(0,h.jsx)(ni,{element:d,elementsMap:r,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},d.id),!1!==this.props.aiEnabled&&1===e.length&&(0,i.ac)(d)&&(0,h.jsx)(sL,{element:d,elementsMap:l,children:(0,h.jsx)(sN,{title:z("labels.convertToCode"),icon:i.jf,checked:!1,onChange:()=>this.onMagicFrameGenerate(d,"button")})}),1===e.length&&(0,i.Yb)(d)&&d.customData?.generationData?.status==="done"&&(0,h.jsxs)(sL,{element:d,elementsMap:l,children:[(0,h.jsx)(sN,{title:z("labels.copySource"),icon:i._e,checked:!1,onChange:()=>this.onIframeSrcCopy(d)}),(0,h.jsx)(sN,{title:"Enter fullscreen",icon:i.kf,checked:!1,onChange:()=>{let e=this.getHTMLIFrameElement(d);if(e)try{e.requestFullscreen(),this.setState({activeEmbeddable:{element:d,state:"active"},selectedElementIds:{[d.id]:!0},newElement:null,selectionElement:null})}catch(e){console.warn(e),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),null!==this.state.toast&&(0,h.jsx)(l6,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&(0,h.jsx)(iV,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:e=>{this.setState({contextMenu:null},()=>{this.focusContainer(),e?.()})}}),(0,h.jsx)(sT,{canvas:this.canvas,rc:this.rc,elementsMap:l,allElementsMap:r,visibleElements:s,sceneNonce:a,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:(0,i.fj)(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&(0,h.jsx)(sU,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:l,allElementsMap:r,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),(0,h.jsx)(sj,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:l,visibleElements:s,allElementsMap:r,selectedElements:e,sceneNonce:a,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,device:this.device,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&&(0,h.jsx)(sA,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(e){Object.assign(this.plugins,e)}async onMagicFrameGenerate(e,t){let n=this.plugins.diagramToCode?.generate;if(!n)return void this.setState({errorMessage:"No diagram to code plugin found"});let a=(0,i.Pi)(this.scene.getNonDeletedElements(),e).filter(e=>!(0,i.ac)(e));if(!a.length)return void("button"===t?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ed("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"}));let l=this.insertIframeElement({sceneX:e.x+e.width+30,sceneY:e.y,width:e.width,height:e.height});if(l){this.updateMagicGeneration({frameElement:l,data:{status:"pending"}}),this.setState({selectedElementIds:{[l.id]:!0}}),ed("ai","generate (start)","d2c");try{let{html:t}=await n({frame:e,children:a});if(ed("ai","generate (success)","d2c"),!t.trim())return void this.updateMagicGeneration({frameElement:l,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});let i=t.includes("<!DOCTYPE html>")&&t.includes("</html>")?t.slice(t.indexOf("<!DOCTYPE html>"),t.indexOf("</html>")+7):t;this.updateMagicGeneration({frameElement:l,data:{status:"done",html:i}})}catch(e){ed("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:l,data:{status:"error",code:"ERR_OAI",message:e.message||"Unknown error during generation"}})}}}onIframeSrcCopy(e){e.customData?.generationData?.status==="done"&&((0,i.oi)(e.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(e){let t=e??this.files;this.scene.getNonDeletedElements().forEach(e=>{(0,i.Vb)(e)&&t[e.fileId]&&(this.imageCache.delete(e.fileId),i.ed.delete(e))})}async componentDidMount(){this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,(a.a.MODE===i.D.TEST||a.a.DEV)&&(this.setState.bind(this),Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...e)=>this.setState(...e)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})),this.store.onStoreIncrementEmitter.on(e=>{this.history.record(e.elementsChange,e.appStateChange)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),(0,i.Ab)()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),i.r&&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),(0,i.q)()&&!(0,i.yc)()&&this.setState({errorMessage:(0,h.jsx)(sn,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new i.Oj,this.fonts=new i.Qf(this.scene),this.renderer=new sM(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),i.ed.destroy(),i.ej.destroy(),clearTimeout(re),i.tk.clearCache(),i.Jc.clearCache(),re=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once((0,i.Pb)(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once((0,i.Pb)(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),(0,i.Pb)(window,"message",this.onWindowMessage,!1),(0,i.Pb)(document,"pointerup",this.removePointer,{passive:!1}),(0,i.Pb)(document,"copy",this.onCopy,{passive:!1}),(0,i.Pb)(document,"keyup",this.onKeyUp,{passive:!0}),(0,i.Pb)(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),(0,i.Pb)(document.fonts,"loadingdone",e=>{let t=e.fontfaces;this.fonts.onLoaded(t)},{passive:!1}),(0,i.Pb)(document,"gesturestart",this.onGestureStart,!1),(0,i.Pb)(document,"gesturechange",this.onGestureChange,!1),(0,i.Pb)(document,"gestureend",this.onGestureEnd,!1),(0,i.Pb)(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once((0,i.Pb)(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),(0,i.Pb)(document,"paste",this.pasteFromClipboard,{passive:!1}),(0,i.Pb)(document,"cut",this.onCut,{passive:!1}),(0,i.Pb)(window,"resize",this.onResize,!1),(0,i.Pb)(window,"unload",this.onUnload,!1),(0,i.Pb)(window,"blur",this.onBlur,!1),(0,i.Pb)(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),(0,i.Pb)(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),(0,i.Pb)(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once((0,i.Pb)((0,i.ub)(this.excalidrawContainerRef.current),"scroll",this.onScroll,{passive:!1})))}componentDidUpdate(e,t){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),a=this.scene.getElementsMapIncludingDeleted(),l=this.scene.getNonDeletedElementsMap();this.state.showWelcomeScreen||n.length||this.setState({showWelcomeScreen:!0}),e.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),t.userToFollow&&!this.state.collaborators.has(t.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(t.zoom.value!==this.state.zoom.value||t.scrollX!==this.state.scrollX||t.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)),t.userToFollow!==this.state.userToFollow&&(t.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:t.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&(0,i.Gc)(this.state)&&this.setState({activeTool:(0,i.jb)(this.state,{type:"selection"})}),"eraser"===this.state.activeTool.type&&t.theme!==this.state.theme&&(0,i.cd)(this.interactiveCanvas,this.state.theme),"selection"===t.activeTool.type&&"selection"!==this.state.activeTool.type&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),e.langCode!==this.props.langCode&&this.updateLanguage(),(0,i.Gc)(t)&&!(0,i.Gc)(this.state)&&this.eraserTrail.endPath(),e.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),t.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(t.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&t.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),e.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),e.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===i.G.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(tg)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:s}=t;t.activeTool!==this.state.activeTool&&null!=s&&(0,i.Fg)(this.state)&&(0,i.gc)(s,!1)&&(0,i.Lg)(s,this.state,(0,i.ob)(i.pj.getPointAtIndexGlobalCoordinates(s,-1,l)),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.store.commit(a,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){s5=!1}async addElementsFromMixedContentPaste(e,{isPlainPaste:t,sceneX:n,sceneY:a}){if(!t&&e.some(e=>"imageUrl"===e.type)&&this.isToolSupported("image")){let t=e.filter(e=>"imageUrl"===e.type).map(e=>e.value),l=await Promise.all(t.map(async e=>{try{return{file:await (0,i.Gh)(e)}}catch(t){let e=t.message;return"FETCH_ERROR"===t.cause?e=z("errors.failedToFetchImage"):"UNSUPPORTED"===t.cause&&(e=z("errors.unsupportedFileType")),{errorMessage:e}}})),s=a,r=!1,o={};for(let e of l)if(e.file){let t=this.createImageElement({sceneX:n,sceneY:s}),a=await this.insertImageElement(t,e.file);a&&(r||(r=!0,s-=a.height/2),(0,i.Pj)(a,{y:s},!1),s=t.y+t.height+25,o[t.id]=!0)}this.setState({selectedElementIds:(0,i.xk)(o,this.state)});let d=l.find(e=>!!e.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let n=e.filter(e=>"text"===e.type);n.length&&this.addTextFromPaste(n.map(e=>e.value).join(`
`),t)}}addTextFromPaste(e,t=!1){let{x:n,y:a}=(0,i.lb)({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),l={x:n,y:a,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:e,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:i.K,verticalAlign:i.L,locked:!1},s=(0,i.cb)({fontSize:l.fontSize,fontFamily:l.fontFamily}),r=(0,i.Rf)(l.fontFamily),[o,,d]=(0,i.dj)(this.state),c=Math.max(Math.min((d-o)*.5,800),200),h=a,m=t?[e]:e.split(`
`),p=m.reduce((e,t,a)=>{let o=(0,i.zc)(t).trim();if(o.length){let t=this.getTopLayerFrameAtSceneCoords({x:n,y:h}),a=(0,i.vc)(o,s,r),d=a.width>c,m=d?(0,i.Ec)(o,s,c):o,p=n-(a=d?(0,i.vc)(m,s,r):a).width/2,u=h-a.height/2,g=(0,i.Xf)({...l,x:p,y:u,text:m,originalText:o,lineHeight:r,autoResize:!d,frameId:t?t.id:null});e.push(g),h+=g.height+10}else m[a-1]?.trim()&&(h+=(0,i.Ac)(l.fontSize,r)+10);return e},[]);0!==p.length&&(this.scene.insertElements(p),this.setState({selectedElementIds:(0,i.xk)(Object.fromEntries(p.map(e=>[e.id,!0])),this.state)}),t||!(p.length>1)||!1!==rl||this.device.editor.isMobile||(this.setToast({message:z("toast.pasteAsSingleElement",{shortcut:(0,i.kb)("CtrlOrCmd+Shift+V")}),duration:5e3}),rl=!0),this.store.shouldCaptureIncrement())}handleTextWysiwyg(e,{isExistingElement:t=!1}){let n=this.scene.getElementsMapIncludingDeleted(),a=(t,a)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(l=>l.id===e.id&&(0,i._b)(l)?(0,i.Qj)(l,{originalText:t,isDeleted:a??l.isDeleted,...(0,i.Yf)(l,(0,i.Aj)(l,n),n,t)}):l)])};(({id:e,onChange:t,onSubmit:n,getViewportCoords:a,element:l,canvas:s,excalidrawContainer:r,app:o,autoSelect:d=!0})=>{let c=()=>{let t=o.state,n=i.Oj.getScene(l)?.getElement(e);if(!n)return;let{textAlign:s,verticalAlign:r}=n,d=o.scene.getNonDeletedElementsMap();if(n&&(0,i._b)(n)){let e=n.x,l=n.y,c=(0,i.Aj)(n,o.scene.getNonDeletedElementsMap()),m=n.width,p=n.height,u=n.width,g=n.height;if(c&&n.containerId){let t;if((0,i.dc)(c)){let t=i.pj.getBoundTextElementPosition(c,n,d);e=t.x,l=t.y}if(((e,t)=>{if(!t.style.fontFamily||!t.style.fontSize)return!1;let n=t.style.fontFamily.replace(/"/g,"");return(0,i.bb)({fontFamily:e.fontFamily})!==n||`${e.fontSize}px`!==t.style.fontSize})(n,h)?t=(0,i.rj)(c.id,c.height):(t=i.qj[c.id])||(t=(0,i.rj)(c.id,c.height)),u=(0,i.Hj)(c,n),g=(0,i.Ij)(c,n),!(0,i.dc)(c)&&p>g){let e=(0,i.Gj)(p,c.type);(0,i.Pj)(c,{height:e});return}if(!(0,i.dc)(c)&&c.height>t.height&&p<g){let e=(0,i.Gj)(p,c.type);(0,i.Pj)(c,{height:e})}else{let{y:e}=(0,i.xj)(c,n,d);l=e}}let[f,b]=a(e,l),x=h.selectionStart,E=h.selectionEnd,y=h.value.length;if(x===E&&E!==y){let e=y-E;h.selectionStart=h.value.length-e,h.selectionEnd=h.value.length-e}c?m+=.5:m=Math.min(m,u=(t.width-8-f)/t.zoom.value),p*=1.05;let v=(0,i.cb)(n),w=(t.height-b)/t.zoom.value;Object.assign(h.style,{font:v,lineHeight:n.lineHeight,width:`${m}px`,height:`${p}px`,left:`${f}px`,top:`${b}px`,transform:((e,t,n,i,a,l)=>{let{zoom:s}=i,r=180*n/Math.PI,o=e*(s.value-1)/2,d=t*(s.value-1)/2;return e>a&&1!==s.value&&(o=a*(s.value-1)/2),t>l&&1!==s.value&&(d=l*(s.value-1)/2),`translate(${o}px, ${d}px) scale(${s.value}) rotate(${r}deg)`})(m,p,(0,i.Cj)(n,c),t,u,w),textAlign:s,verticalAlign:r,color:n.strokeColor,opacity:n.opacity/100,filter:"var(--theme-filter)",maxHeight:`${w}px`}),h.scrollTop=0,(0,i.Ab)()&&(h.style.fontFamily=(0,i.bb)(n)),(0,i.Pj)(n,{x:e,y:l})}},h=document.createElement("textarea");h.dir="auto",h.tabIndex=0,h.dataset.type="wysiwyg",h.wrap="off",h.classList.add("excalidraw-wysiwyg");let m="pre",p="normal";((0,i.nc)(l)||!l.autoResize)&&(m="pre-wrap",p="break-word"),Object.assign(h.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"}),h.value=l.originalText,c(),t&&(h.onpaste=async e=>{let t=await (0,i.mi)(e,!0);if(!t.text)return;let n=(0,i.zc)(t.text);if(!n)return;let a=(0,i.Aj)(l,o.scene.getNonDeletedElementsMap()),s=(0,i.cb)({fontSize:o.state.currentItemFontSize,fontFamily:o.state.currentItemFontFamily});if(a){let e=(0,i.zj)(a,o.scene.getNonDeletedElementsMap()),t=(0,i.Ec)(`${h.value}${n}`,s,(0,i.Hj)(a,e)),l=(0,i.Dc)(t,s);h.style.width=`${l}px`}},h.oninput=()=>{let e=(0,i.zc)(h.value);if(h.value!==e){let t=h.selectionStart;h.value=e,h.selectionStart=t,h.selectionEnd=t}t(h.value)}),h.onkeydown=e=>{if(!e.shiftKey&&td.keyTest(e))e.preventDefault(),o.actionManager.executeAction(td),c();else if(!e.shiftKey&&tc.keyTest(e))e.preventDefault(),o.actionManager.executeAction(tc),c();else if(!e.shiftKey&&th.keyTest(e))e.preventDefault(),o.actionManager.executeAction(th),c();else if(tt.keyTest(e))o.actionManager.executeAction(tt);else if(tn.keyTest(e))o.actionManager.executeAction(tn);else if(e.key===i.hg.ESCAPE)e.preventDefault(),y=!0,v();else if(e.key===i.hg.ENTER&&e[i.hg.CTRL_OR_CMD]){if(e.preventDefault(),e.isComposing||229===e.keyCode)return;y=!0,v()}else if(e.key===i.hg.TAB||e[i.hg.CTRL_OR_CMD]&&(e.code===i.gg.BRACKET_LEFT||e.code===i.gg.BRACKET_RIGHT)){if(e.preventDefault(),e.isComposing)return;e.shiftKey||e.code===i.gg.BRACKET_LEFT?b():f(),h.dispatchEvent(new Event("input"))}};let u=" ".repeat(4),g=RegExp("^ {1,4}"),f=()=>{let{selectionStart:e,selectionEnd:t}=h,n=x(),i=h.value;n.forEach(e=>{let t=i.slice(0,e),n=i.slice(e);i=`${t}${u}${n}`}),h.value=i,h.selectionStart=e+4,h.selectionEnd=t+4*n.length},b=()=>{let{selectionStart:e,selectionEnd:t}=h,n=x(),i=[],a=h.value;n.forEach(e=>{let t=a.slice(e,e+4).match(g);if(t){let n=a.slice(0,e),l=a.slice(e+t[0].length);a=`${n}${l}`,i.push(e)}}),h.value=a,i.length&&(e>i[i.length-1]?h.selectionStart=Math.max(e-4,i[i.length-1]):h.selectionStart=e,h.selectionEnd=Math.max(h.selectionStart,t-4*i.length))},x=()=>{let{selectionStart:e,selectionEnd:t,value:n}=h,i=n.slice(0,e).match(/[^\n]*$/)[0].length;return e-=i,n.slice(e,t).split(`
`).reduce((t,n,i,a)=>t.concat(i?t[i-1]+a[i-1].length+1:e),[]).reverse()},E=e=>{e.target instanceof HTMLCanvasElement&&(e.preventDefault(),e.stopPropagation())},y=!1,v=()=>{if(T)return;T=!0,w();let e=i.Oj.getScene(l)?.getElement(l.id);if(!e)return;let t=(0,i.Aj)(e,o.scene.getNonDeletedElementsMap());if(t){if(h.value.trim()){let e=(0,i.yj)(t);e&&e===l.id?(0,i.dc)(t)&&(0,i.Rj)(t):(0,i.Pj)(t,{boundElements:(t.boundElements||[]).concat({type:"text",id:l.id})})}else(0,i.Pj)(t,{boundElements:t.boundElements?.filter(e=>!(0,i._b)(e))});(0,i.uj)(e,t,o.scene.getNonDeletedElementsMap())}n({viaKeyboard:y,nextOriginalText:h.value})},w=()=>{h.onblur=null,h.oninput=null,h.onkeydown=null,M&&M.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("wheel",E,!0),window.removeEventListener("pointerdown",C),window.removeEventListener("pointerup",S),window.removeEventListener("blur",v),window.removeEventListener("beforeunload",v),j(),I(),h.remove()},S=e=>{window.removeEventListener("pointerup",S);let t=e?.target,n=t instanceof HTMLElement&&t.classList.contains("properties-trigger");setTimeout(()=>{h.onblur=v,n||h.focus()})},k=()=>{h.onblur=null,window.addEventListener("pointerup",S),window.addEventListener("blur",v)},C=e=>{let t=e?.target;if(e.button===i.A.WHEEL){t instanceof HTMLTextAreaElement&&(e.preventDefault(),o.handleCanvasPanUsingWheelOrSpaceDrag(e)),k();return}let n=t instanceof HTMLElement&&t.classList.contains("properties-trigger");(e.target instanceof HTMLElement||e.target instanceof SVGElement)&&e.target.closest(`.${i.E.SHAPE_ACTIONS_MENU}, .${i.E.ZOOM_ACTIONS}`)&&!(0,i.ab)(e.target)||n?k():e.target instanceof HTMLCanvasElement&&!(0,i.Ab)()&&requestAnimationFrame(()=>{v()})},j=o.scene.onUpdate(()=>{c(),document.activeElement?.closest(".properties-content")||h.focus()}),I=o.onScrollChangeEmitter.on(()=>{c()}),T=!1;d&&h.select(),S();let M=null;s&&"ResizeObserver"in window?(M=new window.ResizeObserver(()=>{c()})).observe(s):window.addEventListener("resize",c),h.onpointerdown=e=>e.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",C,{capture:!0})}),window.addEventListener("beforeunload",v),r?.querySelector(".excalidraw-textEditorContainer").appendChild(h)})({id:e.id,canvas:this.canvas,getViewportCoords:(e,t)=>{let{x:n,y:a}=(0,i.mb)({sceneX:e,sceneY:t},this.state);return[n-this.state.offsetLeft,a-this.state.offsetTop]},onChange:sr(t=>{a(t,!1),(0,i.qk)(e)&&(0,i.Pg)(e,this.scene.getNonDeletedElementsMap())}),onSubmit:sr(({viaKeyboard:n,nextOriginalText:l})=>{let s=!l.trim();if(a(l,s),!s&&n){let t=e.containerId?e.containerId:e.id;(0,p.flushSync)(()=>{this.setState(e=>({selectedElementIds:(0,i.xk)({...e.selectedElementIds,[t]:!0},e)}))})}s&&(0,i.Tg)(this.scene.getNonDeletedElements(),[e]),(!s||t)&&this.store.shouldCaptureIncrement(),(0,p.flushSync)(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&(0,i.dd)(this.interactiveCanvas,this.state),this.focusContainer()}),element:e,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),a(e.originalText,!1)}deselectElements(){this.setState({selectedElementIds:(0,i.xk)({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(e,t){let n=this.getElementAtPosition(e,t,{includeBoundTextElement:!0});return n&&(0,i._b)(n)&&!n.isDeleted?n:null}getElementAtPosition(e,t,n){let a=this.getElementsAtPosition(e,t,n?.includeBoundTextElement,n?.includeLockedElements);if(a.length>1){if(n?.preferSelected){for(let e=a.length-1;e>-1;e--)if(this.state.selectedElementIds[a[e].id])return a[e]}let l=a[a.length-1];return(0,i.ng)({x:e,y:t,element:l,shape:(0,i.tg)(l,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:(0,i.bc)(l)?this.frameNameBoundsCache.get(l):null})?l:a[a.length-2]}return 1===a.length?a[0]:null}getElementsAtPosition(e,t,n=!1,a=!1){let l=[],s=this.scene.getNonDeletedElementsMap();return(n&&a?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(e=>(a||!e.locked)&&(n||!((0,i._b)(e)&&e.containerId)))).filter(n=>this.hitElement(e,t,n)).filter(n=>{let a=(0,i.Gi)(n,s);return!a||!this.state.frameRendering.enabled||!this.state.frameRendering.clip||(0,i.zi)({x:e,y:t},a,s)}).filter(e=>!(0,i.Yb)(e)||(l.push(e),!1)).concat(l)}getElementHitThreshold(){return i.N/this.state.zoom.value}hitElement(e,t,n,a=!0){if(a&&this.state.selectedElementIds[n.id]&&(0,i._j)([n],this.state)){let a=(0,i.eg)(n,this.scene.getNonDeletedElementsMap(),(0,i.Wb)(n)?0:this.getElementHitThreshold());if((0,i.fg)((0,i.Ua)(e,t),a))return!0}return!!(0,i.qg)(e,t,(0,i.ug)(n,this.scene.getNonDeletedElementsMap()))||(0,i.ng)({x:e,y:t,element:n,shape:(0,i.tg)(n,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:(0,i.bc)(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(e,t){let n=this.scene.getNonDeletedElements(),a=this.scene.getSelectedElements(this.state);if(1===a.length)return(0,i.jc)(a[0],!1)?a[0]:null;let l=null;for(let a=n.length-1;a>=0;--a){if(n[a].isDeleted)continue;let[s,r,o,d]=(0,i.aj)(n[a],this.scene.getNonDeletedElementsMap());if((0,i.dc)(n[a])&&(0,i.ng)({x:e,y:t,element:n[a],shape:(0,i.tg)(n[a],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})||s<e&&e<o&&r<t&&t<d){l=n[a];break}}return(0,i.jc)(l,!1)?l:null}handleHoverSelectedLinearElement(e,t,n){let a=this.scene.getNonDeletedElementsMap(),l=i.pj.getElement(e.elementId,a);if(l)if(this.state.selectedLinearElement){let s=-1,r=null;(0,i.ng)({x:t,y:n,element:l,shape:(0,i.tg)(l,this.scene.getNonDeletedElementsMap())})?(s=i.pj.getPointIndexUnderCursor(l,a,this.state.zoom,t,n),r=i.pj.getSegmentMidpointHitCoords(e,{x:t,y:n},this.state,this.scene.getNonDeletedElementsMap()),((0,i.ec)(l)?0===s||s===l.points.length-1:s>=0)||r?(0,i.bd)(this.interactiveCanvas,i.z.POINTER):this.hitElement(t,n,l)&&(0,i.bd)(this.interactiveCanvas,i.z.MOVE)):!this.hitElement(t,n,l)||(0,i.ec)(l)&&(l.startBinding||l.endBinding)||(0,i.bd)(this.interactiveCanvas,i.z.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),i.pj.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,r)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:r}})}else(0,i.bd)(this.interactiveCanvas,i.z.AUTO)}updateGestureOnPointerDown(e){rr.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),2===rr.pointers.size&&(rr.lastCenter=iW(rr.pointers),rr.initialScale=this.state.zoom.value,rr.initialDistance=iH(Array.from(rr.pointers.values())))}initialPointerDownState(e){let t=(0,i.lb)(e,this.state),n=this.scene.getSelectedElements(this.state),[a,l,s,r]=(0,i.bj)(n),o=0===n.findIndex(i.ec);return{origin:t,withCmdOrCtrl:e[i.hg.CTRL_OR_CMD],originInGrid:(0,i.ob)((0,i.oj)(t.x,t.y,e[i.hg.CTRL_OR_CMD]||o?null:this.getEffectiveGridSize())),scrollbars:ai(s9,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop),lastCoords:{...t},originalElements:this.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,(0,i.bg)(t)),e),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(s+a)/2,y:(r+l)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(t,n)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(e,t){if(!(t.scrollbars.isOverEither&&!this.state.multiElement))return!1;s7=!0,t.lastCoords.x=e.clientX,t.lastCoords.y=e.clientY;let n=so(e=>{e.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(e,t)}),a=sr(()=>{rs=null,s7=!1,(0,i.dd)(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(e.clientX,e.clientY,"up"),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",a),n.flush()});return rs=a,window.addEventListener("pointermove",n),window.addEventListener("pointerup",a),!0}isASelectedElement(e){return null!=e&&this.state.selectedElementIds[e.id]}isHittingCommonBoundingBoxOfSelectedElements(e,t){if(t.length<2)return!1;let n=this.getElementHitThreshold(),[a,l,s,r]=(0,i.bj)(t);return e.x>a-n&&e.x<s+n&&e.y>l-n&&e.y<r+n}getCurrentItemRoundness(e){return"round"===this.state.currentItemRoundness?{type:(0,i.oc)(e)?i.ua.ADAPTIVE_RADIUS:i.ua.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(e,t,n=!1){(0,i.gj)({event:e,app:this,selectedElements:t})&&(n||!i.ej.getReferenceSnapPoints())&&i.ej.setReferenceSnapPoints((0,i.ij)(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(e,t,n=!1){(0,i.gj)({event:e,app:this,selectedElements:t})&&(n||!i.ej.getVisibleGaps())&&i.ej.setVisibleGaps((0,i.hj)(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(e){return sr(t=>{this.maybeHandleResize(e,t)||this.maybeDragNewGenericElement(e,t)})}onKeyUpFromPointerDownHandler(e){return sr(t=>{t.key===i.hg.ALT&&t.preventDefault(),this.maybeHandleResize(e,t)||this.maybeDragNewGenericElement(e,t)})}onPointerMoveFromPointerDownHandler(e){return so(t=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=(0,i.lb)(t,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[e,a]=(0,i.oj)(n.x,n.y,t[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(l<0){let t=i.pj.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:e,y:a},this.state,this.scene.getNonDeletedElementsMap());l=t?i.pj.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,t,this.scene.getNonDeletedElementsMap()):-1}let s=i.pj.moveFixedSegment(this.state.selectedLinearElement,l,e,a,this.scene.getNonDeletedElementsMap());(0,p.flushSync)(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s.segmentMidPointHoveredCoords,pointerDownState:s.pointerDownState}})});return}let a=this.lastPointerMoveCoords??e.origin;if(this.lastPointerMoveCoords=n,null===e.drag.offset&&(e.drag.offset=(0,i.ob)((0,i.jk)(this.scene.getSelectedElements(this.state),e.origin.x,e.origin.y))),!(t.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(t,e))return;if((0,i.Gc)(this.state))return void this.handleEraser(t,e,n);"laser"===this.state.activeTool.type&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=(0,i.oj)(n.x,n.y,t[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!e.drag.hasOccurred&&("arrow"===this.state.activeTool.type||"line"===this.state.activeTool.type)&&(0,i.Wa)((0,i.Ua)(n.x,n.y),(0,i.Ua)(e.origin.x,e.origin.y))<i.t)return;if(e.resize.isResizing&&(e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeHandleCrop(e,t)||this.maybeHandleResize(e,t)))return!0;let r=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let a=this.state.editingLinearElement||this.state.selectedLinearElement;if(i.pj.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,r)){let e=i.pj.addMidpoint(this.state.selectedLinearElement,n,this,!t[i.hg.CTRL_OR_CMD],r);if(!e)return;(0,p.flushSync)(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:e.pointerDownState,selectedPointsIndices:e.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:e.pointerDownState,selectedPointsIndices:e.selectedPointsIndices}})});return}if(null!==a.pointerDownState.segmentMidpoint.value&&!a.pointerDownState.segmentMidpoint.added)return;if(i.pj.handlePointDragging(t,this,n.x,n.y,(e,t)=>{this.maybeSuggestBindingsForLinearElementAtCoords(e,t)},a,this.scene)){e.lastCoords.x=n.x,e.lastCoords.y=n.y,e.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 o=e.hit.allHitElements.some(e=>this.isASelectedElement(e)),d=this.state.editingLinearElement&&t.shiftKey&&this.state.editingLinearElement.elementId===e.hit.element?.id;if((o||e.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d){let l=this.scene.getSelectedElements(this.state);if(l.every(e=>e.locked))return;let s=l.find(e=>(0,i.bc)(e)),o=this.getTopLayerFrameAtSceneCoords(n),d=o&&!s?o:null;if(this.state.frameToHighlight!==d&&(0,p.flushSync)(()=>{this.setState({frameToHighlight:d})}),e.drag.hasOccurred=!0,l.length>0&&!e.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let s={x:n.x-e.origin.x,y:n.y-e.origin.y},o=[...e.originalElements.values()],d=t.shiftKey;if(d){let e=Math.abs(s.x),t=Math.abs(s.y);d&&e<t&&(s.x=0),d&&e>t&&(s.y=0)}if(this.state.croppingElementId){let t=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(t&&(0,i.Wb)(t)&&null!==t.crop&&e.hit.element===t){let e=t.crop,l=(0,i.Vb)(t)&&this.imageCache.get(t.fileId)?.image;if(l&&!(l instanceof Promise)){let s=(0,i.Sa)((0,i.Oa)(n.x-a.x,n.y-a.y),Math.max(this.state.zoom.value,2)),[o,d,c,h,m,p]=(0,i.aj)(t,r),u=(0,i.Pa)((0,i.Va)((0,i.Ua)(o,d),(0,i.Ua)(m,p),t.angle)),g=(0,i.Pa)((0,i.Va)((0,i.Ua)(c,d),(0,i.Ua)(m,p),t.angle)),f=(0,i.Pa)((0,i.Va)((0,i.Ua)(o,h),(0,i.Ua)(m,p),t.angle)),b=(0,i.Ta)((0,i.Ra)(g,u)),x=(0,i.Ta)((0,i.Ra)(f,u)),E=(0,i.Oa)((0,i.Qa)(s,b),(0,i.Qa)(s,x)),y={...e,x:(0,i.Ia)(e.x-E[0]*Math.sign(t.scale[0]),0,l.naturalWidth-e.width),y:(0,i.Ia)(e.y-E[1]*Math.sign(t.scale[1]),0,l.naturalHeight-e.height)};(0,i.Pj)(t,{crop:y});return}}}this.maybeCacheVisibleGaps(t,l),this.maybeCacheReferenceSnapPoints(t,l);let{snapOffset:c,snapLines:h}=(0,i.jj)(o,s,this,t,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:h}),this.state.editingFrame||(0,i.ik)(e,l,s,this.scene,c,t[i.hg.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),1===l.length&&(0,i.ec)(l[0])||this.setState({suggestedBindings:(0,i.Kg)(l,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),t.altKey&&!e.hit.hasBeenDuplicated){e.hit.hasBeenDuplicated=!0;let n=[],a=[],s=new Map,r=new Map,o=e.hit.element,d=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(e=>e.id)),c=this.scene.getElementsIncludingDeleted();for(let t of c){let l=d.has(t.id)||t.id===o?.id&&e.hit.wasAddedToSelection;if(Math.abs(t.x)>1e7||Math.abs(t.x)>1e7||Math.abs(t.width)>1e7||Math.abs(t.height)>1e7)return void console.error("Alt+dragging element in scene with invalid dimensions",t.x,t.y,t.width,t.height,l);if(l){let l=(0,i.cg)(this.state.editingGroupId,s,t);if(Math.abs(l.x)>1e7||Math.abs(l.x)>1e7||Math.abs(l.width)>1e7||Math.abs(l.height)>1e7)return void console.error("Alt+dragging duplicated element with invalid dimensions",l.x,l.y,l.width,l.height);let o=e.originalElements.get(t.id);if(Math.abs(o.x)>1e7||Math.abs(o.x)>1e7||Math.abs(o.width)>1e7||Math.abs(o.height)>1e7)return void console.error("Alt+dragging duplicated element with invalid dimensions",o.x,o.y,o.width,o.height);(0,i.Pj)(l,{x:o.x,y:o.y}),e.originalElements.set(l.id,l),n.push(l),a.push(t),r.set(t.id,l.id)}else n.push(t)}let h=[...n,...a];h=this.props.onDuplicate?.(h,c)||h,(0,i.Mj)(h,(0,i.xb)(a)),(0,i.vj)(n,a,r),(0,i.Sg)(h,a,r,"duplicatesServeAsOld"),(0,i.wi)(h,a,r),this.scene.replaceAllElements(h),this.maybeCacheVisibleGaps(t,l,!0),this.maybeCacheReferenceSnapPoints(t,l,!0)}return}}if(this.state.selectionElement)e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t);else{let a=this.state.newElement;if(!a)return;if("freedraw"===a.type){let e=a.points,l=n.x-a.x,s=n.y-a.y,r=e.length>0&&e[e.length-1];if(!(r&&r[0]===l&&r[1]===s)){let n=a.simulatePressure?a.pressures:[...a.pressures,t.pressure];(0,i.Pj)(a,{points:[...e,(0,i.Ua)(l,s)],pressures:n},!1),this.setState({newElement:a})}}else if((0,i.cc)(a)){e.drag.hasOccurred=!0;let r=a.points,o=l-a.x,d=s-a.y;(0,i.mg)(t)&&2===r.length&&({width:o,height:d}=(0,i.Vj)(a.x,a.y,n.x,n.y)),1===r.length?(0,i.Pj)(a,{points:[...r,(0,i.Ua)(o,d)]},!1):(2===r.length||r.length>1&&(0,i.ec)(a))&&(0,i.Pj)(a,{points:[...r.slice(0,-1),(0,i.Ua)(o,d)]},!1,{isDragging:!0}),this.setState({newElement:a}),(0,i.gc)(a,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(a,[n],this.state.startBoundElement)}else e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t,!1)}if("selection"===this.state.activeTool.type){e.boxSelection.hasOccurred=!0;let n=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)i.pj.handleBoxSelection(t,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let a=!0;!t.shiftKey&&(0,i.tk)(n,this.state)&&(e.withCmdOrCtrl&&e.hit.element?this.setState(t=>(0,i.Jc)({...t,selectedElementIds:{[e.hit.element.id]:!0}},this.scene.getNonDeletedElements(),t,this)):a=!1);let l=this.state.selectionElement?(0,i.sk)(n,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(t=>{let n={...a&&t.selectedElementIds,...l.reduce((e,t)=>(e[t.id]=!0,e),{})};return e.hit.element&&(l.length?delete n[e.hit.element.id]:n[e.hit.element.id]=!0),t=a?t:{...t,selectedGroupIds:{},editingGroupId:null},{...(0,i.Jc)({editingGroupId:t.editingGroupId,selectedElementIds:n},this.scene.getNonDeletedElements(),t,this),selectedLinearElement:1===l.length&&(0,i.cc)(l[0])?new i.pj(l[0]):null,showHyperlinkPopup:!!(1===l.length&&(l[0].link||(0,i.Xb)(l[0])))&&"info"}})}}})}handlePointerMoveOverScrollbars(e,t){if(t.scrollbars.isOverHorizontal){let n=e.clientX,i=n-t.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i/this.state.zoom.value}),t.lastCoords.x=n,!0}if(t.scrollbars.isOverVertical){let n=e.clientY,i=n-t.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i/this.state.zoom.value}),t.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(e){return sr(t=>{this.removePointer(t),e.eventListeners.onMove&&e.eventListeners.onMove.flush();let{newElement:n,resizingElement:a,croppingElementId:l,multiElement:s,activeTool:r,isResizing:o,isRotating:d,isCropping:c}=this.state;this.setState(e=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:(0,i.Ob)(e.snapLines,[]),originSnapOffset:null})),this.lastPointerMoveCoords=null,i.ej.setReferenceSnapPoints(null),i.ej.setVisibleGaps(null),this.savePointer(t.clientX,t.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let h=this.scene.getNonDeletedElementsMap();if(e.drag.hasOccurred&&e.hit?.element?.id){let t=h.get(e.hit.element.id);(0,i.ic)(t)&&t.boundElements?.filter(e=>"arrow"===e.type).map(e=>h.get(e.id)).filter(e=>(0,i.ec)(e)).forEach(e=>{e&&(0,i.Pj)(e,{},!0)})}if(this.state.editingLinearElement)if(e.boxSelection.hasOccurred||e.hit?.element?.id===this.state.editingLinearElement.elementId){let e=i.pj.handlePointerUp(t,this.state.editingLinearElement,this.state,this.scene);e!==this.state.editingLinearElement&&this.setState({editingLinearElement:e,suggestedBindings:[]})}else this.actionManager.executeAction(tg);else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let e=i.pj.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());e&&(0,i.Pj)(e,{},!0)}if(e.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let e=i.pj.handlePointerUp(t,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:n,endBindingElement:a}=e,l=this.scene.getElement(e.elementId);(0,i.gc)(l)&&(0,i.Ig)(l,n,a,h,this.scene),e!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...e,selectedPointsIndices:null},suggestedBindings:[]})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",e.eventListeners.onMove),window.removeEventListener("pointerup",e.eventListeners.onUp),window.removeEventListener("keydown",e.eventListeners.onKeyDown),window.removeEventListener("keyup",e.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(r,e),this.onPointerUpEmitter.trigger(this.state.activeTool,e,t),n?.type==="freedraw"){let e=(0,i.lb)(t,this.state),a=n.points,l=e.x-n.x,s=e.y-n.y;l===a[0][0]&&s===a[0][1]&&(s+=1e-4,l+=1e-4);let r=n.simulatePressure?[]:[...n.pressures,t.pressure];(0,i.Pj)(n,{points:[...a,(0,i.Ua)(l,s)],pressures:r,lastCommittedPoint:(0,i.Ua)(l,s)}),this.actionManager.executeAction(tg);return}if((0,i.Wb)(n)){try{this.initializeImageDimensions(n),this.setState({selectedElementIds:(0,i.xk)({[n.id]:!0},this.state)},()=>{this.actionManager.executeAction(tg)})}catch(e){console.error(e),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(e=>e.id!==n.id)),this.actionManager.executeAction(tg)}return}if((0,i.cc)(n)){n.points.length>1&&this.store.shouldCaptureIncrement();let a=(0,i.lb)(t,this.state);e.drag.hasOccurred||!n||s?e.drag.hasOccurred&&!s&&((0,i.Fg)(this.state)&&(0,i.gc)(n,!1)&&(0,i.Lg)(n,this.state,a,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.setState({suggestedBindings:[],startBoundElement:null}),r.locked?this.setState(e=>({newElement:null})):((0,i.ad)(this.interactiveCanvas),this.setState(e=>({newElement:null,activeTool:(0,i.jb)(this.state,{type:"selection"}),selectedElementIds:(0,i.xk)({...e.selectedElementIds,[n.id]:!0},e),selectedLinearElement:new i.pj(n)}))),this.scene.triggerUpdate()):((0,i.Pj)(n,{points:[...n.points,(0,i.Ua)(a.x-n.x,a.y-n.y)]}),this.setState({multiElement:n,newElement:n}));return}if((0,i._b)(n)){let e=(0,i.xc)((0,i.cb)({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<e&&(0,i.Pj)(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if("selection"!==r.type&&n&&(0,i.Sj)(n))return void this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==n.id),appState:{newElement:null},captureUpdate:i.Wg.NEVER});if((0,i.bc)(n)){let e=(0,i.Fi)(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements((0,i.Ii)(this.scene.getElementsMapIncludingDeleted(),e,n,this.state))}if(n&&((0,i.Pj)(n,(0,i.Wj)(n)),this.scene.triggerUpdate()),e.drag.hasOccurred){let e=(0,i.lb)(t,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let e=this.scene.getElement(this.state.selectedLinearElement.elementId);if(e?.frameId){let t=(0,i.Gi)(e,h);t&&e&&((0,i.yi)(e,t,this.scene.getNonDeletedElementsMap())||((0,i.Pj)(e,{groupIds:[]}),(0,i.Ji)([e],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let t=this.getTopLayerFrameAtSceneCoords(e),n=this.scene.getSelectedElements(this.state),a=this.scene.getElementsMapIncludingDeleted(),l=e=>{if(e.length>0){for(let t of e){let e=t.groupIds.indexOf(this.state.editingGroupId);(0,i.Pj)(t,{groupIds:t.groupIds.slice(0,e)},!1)}a.forEach(e=>{e.groupIds.length&&(0,i.Qc)(a,e.groupIds[e.groupIds.length-1]).length<2&&(0,i.Pj)(e,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(t&&!this.state.selectedElementIds[t.id]){let e=n.filter(e=>e.frameId!==t.id&&(0,i.Ni)(e,a,this.state));this.state.editingGroupId&&l(e),a=(0,i.Ii)(a,e,t,this.state)}else!t&&this.state.editingGroupId&&l(n.filter(e=>e.frameId&&!(0,i.Ni)(e,a,this.state)));a=(0,i.Mi)(a,this.state,this),this.scene.replaceAllElements(a)}}if(a&&this.store.shouldCaptureIncrement(),a&&(0,i.Sj)(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==a.id),captureUpdate:i.Wg.NEVER}),e.resize.isResizing){let e=(0,i.Mi)(this.scene.getElementsIncludingDeleted(),this.state,this);for(let t of this.scene.getSelectedElements(this.state).filter(e=>(0,i.bc)(e)))e=(0,i.Li)(e,(0,i.Ei)(this.scene.getElementsIncludingDeleted(),t,this.state,h),t,this);this.scene.replaceAllElements(e)}let m=e.hit.element;this.state.selectedLinearElement?.elementId!==m?.id&&(0,i.cc)(m)&&1===this.scene.getSelectedElements(this.state).length&&this.setState({selectedLinearElement:new i.pj(m)}),l&&(!l||(m||c)&&(!m||m.id===l))||this.finishImageCropping();let p=this.lastPointerDownEvent,u=this.lastPointerUpEvent||this.lastPointerMoveEvent;if((0,i.Gc)(this.state)&&p&&u){if(this.eraserTrail.endPath(),0===(0,i.Wa)((0,i.Ua)(p.clientX,p.clientY),(0,i.Ua)(u.clientX,u.clientY))){let e=(0,i.lb)({clientX:u.clientX,clientY:u.clientY},this.state);this.getElementsAtPosition(e.x,e.y).forEach(e=>this.elementsPendingErasure.add(e.id))}this.eraseElements();return}if(this.elementsPendingErasure.size&&this.restoreReadyToEraseElements(),!m||e.drag.hasOccurred||e.hit.wasAddedToSelection||this.state.editingLinearElement&&e.boxSelection.hasOccurred||(t.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[m.id]?(0,i.Kc)(this.state,m)?this.setState(e=>{let t={...e.selectedElementIds};for(let e of m.groupIds.flatMap(e=>(0,i.Qc)(this.scene.getNonDeletedElements(),e)))delete t[e.id];return{selectedGroupIds:{...e.selectedElementIds,...m.groupIds.map(e=>({[e]:!1})).reduce((e,t)=>({...e,...t}),{})},selectedElementIds:(0,i.xk)(t,e)}}):this.state.selectedLinearElement?.isDragging||this.setState(e=>{let t={...e.selectedElementIds};delete t[m.id];let n=(0,i.vk)(this.scene.getNonDeletedElements(),{selectedElementIds:t});return{...(0,i.Jc)({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:1===n.length&&(0,i.cc)(n[0])?new i.pj(n[0]):e.selectedLinearElement}}):m.frameId&&this.state.selectedElementIds[m.frameId]?this.setState(e=>{let t={...e.selectedElementIds,[m.id]:!0};return delete t[m.frameId],(this.scene.getElement(m.frameId)?.groupIds??[]).flatMap(e=>(0,i.Qc)(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}),{...(0,i.Jc)({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:!!(m.link||(0,i.Xb)(m))&&"info"}}):this.setState(e=>({selectedElementIds:(0,i.xk)({...e.selectedElementIds,[m.id]:!0},e)})):this.setState(e=>({...(0,i.Jc)({editingGroupId:e.editingGroupId,selectedElementIds:{[m.id]:!0}},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:(0,i.cc)(m)&&e.selectedLinearElement?.elementId!==m.id?new i.pj(m):e.selectedLinearElement}))),!(m&&(0,i.ec)(m))&&!e.drag.hasOccurred&&!this.state.isResizing&&(m&&(0,i.pg)({x:e.origin.x,y:e.origin.y,element:m,shape:(0,i.tg)(m,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:(0,i.bc)(m)?this.frameNameBoundsCache.get(m):null},h)||!m&&e.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:(0,i.xk)({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),(0,i.bd)(this.interactiveCanvas,i.z.AUTO);return}if(!r.locked&&"freedraw"!==r.type&&n&&this.setState(e=>({selectedElementIds:(0,i.xk)({...e.selectedElementIds,[n.id]:!0},e),showHyperlinkPopup:(0,i.Xb)(n)&&!n.link?"editor":e.showHyperlinkPopup})),("selection"!==r.type||(0,i.tk)(this.scene.getNonDeletedElements(),this.state)||!(0,i.Hb)(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),e.drag.hasOccurred||o||d||c){let e=this.scene.getSelectedElements(this.state).filter(i.cc);(0,i.Jg)(e,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,(0,i.Fg)(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom)}"laser"===r.type?this.laserTrails.endPath():(r.locked||"freedraw"===r.type?this.setState({newElement:null,suggestedBindings:[]}):((0,i.ad)(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:(0,i.jb)(this.state,{type:"selection"})})),m&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&rr.pointers.size<=1&&(0,i.Zb)(m)&&this.isIframeLikeElementCenter(m,this.lastPointerUpEvent,e.origin.x,e.origin.y)&&this.handleEmbeddableCenterClick(m))})}clearSelection(e){this.setState(t=>({selectedElementIds:(0,i.xk)({},t),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:t.editingGroupId&&null!=e&&(0,i.Pc)(e,t.editingGroupId)?t.editingGroupId:null})),this.setState({selectedElementIds:(0,i.xk)({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(e,t,n,a){if(a){let l=a.x+a.width/2,s=a.y+a.height/2,r=(0,i.Bj)(a,n,this.scene.getNonDeletedElementsMap());if(r&&(l=r.x,s=r.y),Math.hypot(e-l,t-s)<i.x){let{x:e,y:t}=(0,i.mb)({sceneX:l,sceneY:s},n);return{viewportX:e,viewportY:t,elementCenterX:l,elementCenterY:s}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let{left:e,top:t}=this.excalidrawContainerRef.current.getBoundingClientRect();return{offsetLeft:e,offsetTop:t}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let e=A.find(e=>e.code===this.props.langCode)||N;await O(e),this.setAppState({})}};(a.a.MODE===i.D.TEST||a.a.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((0,i.Nj)(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}));var rd=()=>(0,h.jsx)("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:(0,h.jsx)("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"})}),rc=()=>(0,h.jsxs)("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[(0,h.jsx)("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)"}),(0,h.jsx)("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)"}),(0,h.jsx)("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)"}),(0,h.jsx)("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)"})]}),rh=({style:e,size:t="small",withText:n})=>(0,h.jsxs)("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[(0,h.jsx)(rd,{}),n&&(0,h.jsx)(rc,{})]}),rm=({icon:e,shortcut:t,children:n})=>{let i=sq();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"welcome-screen-menu-item__icon",children:e}),(0,h.jsx)("div",{className:"welcome-screen-menu-item__text",children:n}),t&&!i.editor.isMobile&&(0,h.jsx)("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};rm.displayName="WelcomeScreenMenuItemContent";var rp=({onSelect:e,children:t,icon:n,shortcut:i,className:a="",...l})=>(0,h.jsx)("button",{...l,type:"button",className:`welcome-screen-menu-item ${a}`,onClick:e,children:(0,h.jsx)(rm,{icon:n,shortcut:i,children:t})});rp.displayName="WelcomeScreenMenuItem";var ru=({children:e,href:t,icon:n,shortcut:i,className:a="",...l})=>(0,h.jsx)("a",{...l,className:`welcome-screen-menu-item ${a}`,href:t,target:"_blank",rel:"noreferrer",children:(0,h.jsx)(rm,{icon:n,shortcut:i,children:e})});ru.displayName="WelcomeScreenMenuItemLink";var rg=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=o.useContext(il);return(0,h.jsx)(t.In,{children:(0,h.jsx)("div",{className:"welcome-screen-center",children:e||(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(rf,{}),(0,h.jsx)(rb,{children:z("welcomeScreen.defaults.center_heading")}),(0,h.jsxs)(rx,{children:[(0,h.jsx)(ry,{}),(0,h.jsx)(rE,{})]})]})})})};rg.displayName="Center";var rf=({children:e})=>(0,h.jsx)("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||(0,h.jsx)(rh,{withText:!0})});rf.displayName="Logo";var rb=({children:e})=>(0,h.jsx)("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});rb.displayName="Heading";var rx=({children:e})=>(0,h.jsx)("div",{className:"welcome-screen-menu",children:e});rx.displayName="Menu";var rE=()=>{let e=s3();return(0,h.jsx)(rp,{onSelect:()=>e.executeAction(tP),shortcut:"?",icon:i.Bd,children:z("helpDialog.title")})};rE.displayName="MenuItemHelp";var ry=()=>{let e=o.useContext(ej),t=s3();return e.viewModeEnabled?null:(0,h.jsx)(rp,{onSelect:()=>t.executeAction(tM),shortcut:n9("loadScene"),icon:i.Ld,children:z("buttons.load")})};ry.displayName="MenuItemLoadScene";var rv=({onSelect:e})=>{let{t:t}=B();return(0,h.jsx)(rp,{shortcut:null,onSelect:e,icon:i.fe,children:t("labels.liveCollaboration")})};rv.displayName="MenuItemLiveCollaborationTrigger",rg.Logo=rf,rg.Heading=rb,rg.Menu=rx,rg.MenuItem=rp,rg.MenuItemLink=ru,rg.MenuItemHelp=rE,rg.MenuItemLoadScene=ry,rg.MenuItemLiveCollaborationTrigger=rv;var rw=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=o.useContext(il);return(0,h.jsx)(t.In,{children:(0,h.jsxs)("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[i.ld,(0,h.jsx)("div",{className:"welcome-screen-decor-hint__label",children:e||z("welcomeScreen.defaults.menuHint")})]})})};rw.displayName="MenuHint";var rS=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=o.useContext(il);return(0,h.jsx)(t.In,{children:(0,h.jsxs)("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[(0,h.jsx)("div",{className:"welcome-screen-decor-hint__label",children:e||z("welcomeScreen.defaults.toolbarHint")}),i.nd]})})};rS.displayName="ToolbarHint";var rk=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=o.useContext(il);return(0,h.jsx)(t.In,{children:(0,h.jsxs)("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[(0,h.jsx)("div",{children:e||z("welcomeScreen.defaults.helpHint")}),i.md]})})};rk.displayName="HelpHint";var rC=e=>(0,h.jsx)(h.Fragment,{children:e.children||(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(rg,{}),(0,h.jsx)(rw,{}),(0,h.jsx)(rS,{}),(0,h.jsx)(rk,{})]})});rC.displayName="WelcomeScreen",rC.Center=rg,rC.Hints={MenuHint:rw,ToolbarHint:rS,HelpHint:rk},x((e,t,n)=>{if(a.a.DEV||a.a.MODE===i.D.TEST||window?.DEBUG_FRACTIONAL_INDICES){let l=(0,i.Nj)(e.map(e=>({...e})));(0,i.Kj)(l,{shouldThrow:a.a.DEV||a.a.MODE===i.D.TEST,includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:n}})}},6e4,{leading:!0,trailing:!1}),Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if((e=Math.trunc(e)||0)<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)});var rj=o.memo(e=>{let{onChange:t,initialData:a,excalidrawAPI:l,isCollaborating:s=!1,onPointerUpdate:r,renderTopRightUI:d,langCode:c=N.code,viewModeEnabled:m,zenModeEnabled:p,gridModeEnabled:u,libraryReturnUrl:g,theme:f,name:b,renderCustomStats:x,onPaste:E,detectScroll:y=!0,handleKeyboardGlobally:v=!1,onLibraryChange:w,autoFocus:S=!1,generateIdForFile:k,onLinkOpen:C,generateLinkForSelection:j,onPointerDown:I,onPointerUp:T,onScrollChange:L,onDuplicate:A,children:P,validateEmbeddable:_,renderEmbeddable:R,aiEnabled:O,showDeprecatedFonts:F}=e,z=e.UIOptions?.canvasActions,U={...e.UIOptions,canvasActions:{...i.ga.canvasActions,...z},tools:{image:e.UIOptions?.tools?.image??!0}};return z?.export&&(U.canvasActions.export.saveFileToDisk=z.export?.saveFileToDisk??i.ga.canvasActions.export.saveFileToDisk),null===U.canvasActions.toggleTheme&&typeof f>"u"&&(U.canvasActions.toggleTheme=!0),(0,o.useEffect)(()=>{(async()=>{await n.e(4591).then(n.t.bind(n,84591,19))})();let e=e=>{"number"==typeof e.scale&&1!==e.scale&&e.preventDefault()};return document.addEventListener("touchmove",e,{passive:!1}),()=>{document.removeEventListener("touchmove",e)}},[]),(0,h.jsx)(M,{store:D,children:(0,h.jsx)($,{langCode:c,theme:f,children:(0,h.jsx)(ro,{onChange:t,initialData:a,excalidrawAPI:l,isCollaborating:s,onPointerUpdate:r,renderTopRightUI:d,langCode:c,viewModeEnabled:m,zenModeEnabled:p,gridModeEnabled:u,libraryReturnUrl:g,theme:f,name:b,renderCustomStats:x,UIOptions:U,onPaste:E,detectScroll:y,handleKeyboardGlobally:v,onLibraryChange:w,autoFocus:S,generateIdForFile:k,onLinkOpen:C,generateLinkForSelection:j,onPointerDown:I,onPointerUp:T,onScrollChange:L,onDuplicate:A,validateEmbeddable:_,renderEmbeddable:R,aiEnabled:!1!==O,showDeprecatedFonts:F,children:P})})})},(e,t)=>{if(e.children!==t.children)return!1;let{initialData:n,UIOptions:a={},...l}=e,{initialData:s,UIOptions:r={},...o}=t,d=Object.keys(a),c=Object.keys(r);return d.length===c.length&&d.every(e=>"canvasActions"===e?Object.keys(a.canvasActions).every(e=>"export"===e&&a?.canvasActions?.export&&r?.canvasActions?.export?a.canvasActions.export.saveFileToDisk===r.canvasActions.export.saveFileToDisk:a?.canvasActions?.[e]===r?.canvasActions?.[e]):a[e]===r[e])&&(0,i.Hb)(l,o)});rj.displayName="Excalidraw"}}]);