@excalidraw/excalidraw 0.18.0-3bdaafe → 0.18.0-414182f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,30 +1,33 @@
1
- import{$ as Tl,A as Gf,B as Uf,C as Yf,D as El,E as Fi,F as yl,G as wl,H as Wf,I as Vf,J as Oi,K as Xf,L as Kf,M as Zf,N as $f,O as vl,P as dr,Q as jf,R as vI,S as em,T as TI,U as mr,V as zi,X as qf,Z as Jf,_ as Qf,a as Ff,aa as Il,b as Dn,ba as tm,c as lo,ca as Cl,d as Of,da as e1,e as Ee,ea as om,f as zf,fa as To,g as j,ga as t1,h as fl,ha as nm,i as Wo,ia as o1,j as Zd,ja as n1,k as $d,ka as Sl,l as lr,la as rm,m as jd,ma as r1,n as sr,na as im,o as Hf,oa as i1,p as Vo,pa as a1,q as Xo,qa as am,r as ft,ra as pr,s as $t,sa as l1,t as cr,ta as kl,u as bl,ua as s1,v as qd,va as Ml,w as Bi,wa as Ll,x as xl,xa as so,y as Jd,z as Qd}from"./chunk-K6SESUPD.js";import{a as T}from"./chunk-A66AFZZU.js";import{J as Kd}from"./chunk-I4UNSFV6.js";import{c as Bf}from"./chunk-Z3N5DIM6.js";import{b as Rf,c as Nf,d as I}from"./chunk-SRAX5OIU.js";import HH,{useEffect as GH}from"react";import{DEFAULT_UI_OPTIONS as xI,isShallowEqual as UH}from"@excalidraw/common";import q5 from"clsx";import yO from"lodash.throttle";import vo,{useContext as Pn}from"react";import{flushSync as Li}from"react-dom";import wO from"roughjs/bin/rough";import{nanoid as vO}from"nanoid";import{clamp as J5,pointFrom as re,pointDistance as In,vector as Q5,pointRotateRads as Og,vectorScale as TO,vectorFromPoint as zg,vectorSubtract as eT,vectorDot as tT,vectorNormalize as oT}from"@excalidraw/math";import{COLOR_PALETTE as IO,CODES as nT,shouldResizeFromCenter as rT,shouldMaintainAspectRatio as Qa,shouldRotateWithDiscreteAngle as Hg,isArrowKey as _d,KEYS as Y,APP_NAME as CO,CURSOR_TYPE as Ae,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as SO,DEFAULT_VERTICAL_ALIGN as iT,DRAGGING_THRESHOLD as kO,ELEMENT_SHIFT_TRANSLATE_AMOUNT as MO,ELEMENT_TRANSLATE_AMOUNT as aT,EVENT as ee,FRAME_STYLE as Cn,IMAGE_MIME_TYPES as LO,IMAGE_RENDER_TIMEOUT as PO,isBrave as AO,LINE_CONFIRM_THRESHOLD as Gg,MAX_ALLOWED_FILE_BYTES as lT,MIME_TYPES as Sn,MQ_MAX_HEIGHT_LANDSCAPE as DO,MQ_MAX_WIDTH_LANDSCAPE as _O,MQ_MAX_WIDTH_PORTRAIT as RO,MQ_RIGHT_SIDEBAR_MIN_WIDTH as NO,POINTER_BUTTON as er,ROUNDNESS as Rd,SCROLL_TIMEOUT as BO,TAP_TWICE_TIMEOUT as FO,TEXT_TO_CENTER_SNAP_THRESHOLD as OO,THEME as Nd,THEME_FILTER as zO,TOUCH_CTX_MENU_TIMEOUT as HO,VERTICAL_ALIGN as GO,YOUTUBE_STATES as Bd,ZOOM_STEP as UO,POINTER_EVENTS as Pi,TOOL_TYPE as wo,isIOS as YO,supportsResizeObserver as sT,DEFAULT_COLLISION_THRESHOLD as cT,DEFAULT_TEXT_ALIGN as WO,ARROW_TYPE as kn,DEFAULT_REDUCED_GLOBAL_ALPHA as VO,isSafari as XO,isLocalLink as KO,normalizeLink as Ug,toValidURL as ZO,getGridPoint as nt,getLineHeight as dT,debounce as mT,distance as Ai,getFontString as Yg,getNearestScrollableContainer as $O,isInputLike as pT,isToolIcon as jO,isWritableElement as el,sceneCoordsToViewportCoords as Fd,tupleToCoors as Wg,viewportCoordsToSceneCoords as Fe,wrapEvent as qO,updateObject as Vg,updateActiveTool as Go,getShortcutKey as JO,isTransparent as QO,easeToValuesRAF as ez,muteFSAbortError as tz,isTestEnv as gf,isDevEnv as jT,easeOut as oz,updateStable as tl,addEventListener as De,normalizeEOL as nz,getDateTime as uT,isShallowEqual as rz,arrayToMap as Od,randomInteger as iz,CLASSES as az,Emitter as tr,isMobile as lz,MINIMUM_ARROW_SIZE as hT,DOUBLE_TAP_POSITION_THRESHOLD as sz}from"@excalidraw/common";import{getObservedAppState as cz,getCommonBounds as Di,maybeSuggestBindingsForLinearElementAtCoords as gT,getElementAbsoluteCoords as fT,bindOrUnbindLinearElements as bT,fixBindingsAfterDeletion as dz,getHoveredElementForBinding as Xg,isBindingEnabled as Kg,shouldEnableBindingForPointerEvent as mz,updateBoundElements as Zg,getSuggestedBindingsForArrows as $g,LinearElementEditor as Ce,newElementWith as Mn,newFrameElement as pz,newFreeDrawElement as uz,newEmbeddableElement as xT,newMagicFrameElement as ET,newIframeElement as hz,newArrowElement as gz,newElement as fz,newImageElement as bz,newLinearElement as xz,newTextElement as yT,refreshTextDimensions as Ez,deepCopyElement as wT,duplicateElements as vT,hasBoundTextElement as TT,isArrowElement as jg,isBindingElement as qg,isBindingElementType as IT,isBoundToContainer as Jg,isFrameLikeElement as St,isImageElement as or,isEmbeddableElement as Uo,isInitializedImageElement as ol,isLinearElement as Xt,isLinearElementType as yz,isUsingAdaptiveRadius as wz,isIframeElement as _i,isIframeLikeElement as nl,isMagicFrameElement as Qg,isTextBindableContainer as CT,isElbowArrow as Ye,isFlowchartNodeElement as vz,isBindableElement as Tz,isTextElement as io,getLockedLinearCursorAlignSize as ST,getNormalizedDimensions as Iz,isElementCompletelyInViewport as ef,isElementInViewport as kT,isInvisiblySmallElement as MT,getCornerRadius as Cz,isPathALoop as LT,createSrcDoc as PT,embeddableURLValidator as tf,maybeParseEmbedSrc as Sz,getEmbedLink as zd,getInitializedImageElements as kz,normalizeSVG as AT,updateImageCache as Mz,getBoundTextElement as of,getContainerCenter as nf,getContainerElement as DT,isValidTextContainer as Lz,redrawTextBoundingBox as Pz,shouldShowBoundingBox as Az,getFrameChildren as rf,isCursorInFrame as _T,addElementsToFrame as af,replaceAllElementsInFrame as Dz,removeElementsFromFrame as _z,getElementsInResizingFrame as lf,getElementsInNewFrame as Rz,getContainingFrame as sf,elementOverlapsWithFrame as Nz,updateFrameMembershipOfSelectedElements as RT,isElementInFrame as NT,getFrameLikeTitle as Bz,getElementsOverlappingFrame as Fz,filterElementsEligibleAsFrameChildren as Oz,hitElementBoundText as zz,hitElementBoundingBoxOnly as Hz,hitElementItself as rl,getVisibleSceneBounds as Gz,FlowChartCreator as Uz,FlowChartNavigator as Yz,getLinkDirectionFromKey as BT,cropElement as Wz,wrapText as Vz,isElementLink as cf,parseElementLinkFromURL as Xz,isMeasureTextSupported as Kz,normalizeText as Zz,measureText as FT,getLineHeightInPx as $z,getApproxMinLineWidth as jz,getApproxMinLineHeight as qz,getMinTextElementWidth as Jz,ShapeCache as il,getRenderOpacity as Qz,editGroupForSelectedElement as eH,getElementsInGroup as nr,getSelectedGroupIdForElement as tH,getSelectedGroupIds as oH,isElementInGroup as OT,isSelectedViaGroup as nH,selectGroupsForSelectedElements as Kt,syncInvalidIndices as qT,syncMovedIndices as zT,excludeElementsInFramesFromSelection as rH,getSelectionStateForElements as iH,makeNextSelectedElementIds as ye,getResizeOffsetXY as aH,getResizeArrowDirection as lH,transformElements as sH,getCursorForResizingElement as HT,getElementWithTransformHandleType as GT,getTransformHandleTypeFromCoords as UT,dragNewElement as YT,dragSelectedElements as cH,getDragOffsetXY as dH,isNonDeletedElement as WT,Scene as VT,Store as mH,CaptureUpdateAction as gt,hitElementBoundingBox as pH,isLineElement as df,isSimpleArrow as uH,StoreDelta as XT,positionElementsOnGrid as KT}from"@excalidraw/element";import{KEYS as _m,updateActiveTool as FI}from"@excalidraw/common";import{getNonDeletedElements as Rm}from"@excalidraw/element";import{fixBindingsAfterDeletion as OI}from"@excalidraw/element";import{LinearElementEditor as eb}from"@excalidraw/element";import{newElementWith as ns}from"@excalidraw/element";import{getContainerElement as tb}from"@excalidraw/element";import{isBoundToContainer as ts,isElbowArrow as zI,isFrameLikeElement as HI}from"@excalidraw/element";import{getFrameChildren as GI}from"@excalidraw/element";import{getElementsInGroup as Nm,selectGroupsForSelectedElements as UI}from"@excalidraw/element";import{CaptureUpdateAction as os}from"@excalidraw/element";import{isDevEnv as kI}from"@excalidraw/common";import{atom as me,createStore as II}from"jotai";import{createIsolation as CI}from"jotai-scope";var c1=CI();var{useAtom:ie,useSetAtom:Ko,useAtomValue:Pl,useStore:ZH}=c1,d1=c1.Provider,ze=II();var SI=Rf({"./locales/ar-SA.json":()=>import("./locales/ar-SA-G6X2FPQ2.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-76LH7QW2.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-XCXSNQG7.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-2XOGV67Q.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-6MX7JW3Y.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-2BRQDIVT.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5WZEPLOC.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-XR44H4JA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-BZB4AONW.js"),"./locales/en.json":()=>import("./locales/en-TYY6KWIJ.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-U4NZUMDT.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-A7QVB2H4.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-HGAKTJCU.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-Z5N7JZ37.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-RHASNOE6.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-HMX3MZ6V.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-6SHJWFNN.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-IWLTKZ5I.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-A5ZG7DT2.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-SAP4L64H.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-JPQ66NNP.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-DBVTYXUO.js"),"./locales/kaa.json":()=>import("./locales/kaa-6HZHGXH3.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-ZGHBKWFO.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5N5QNE5.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-HSX4SM5Z.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-MTYHY66A.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-6OUDTVRD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-XHIRWOB4.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-5QDEKY6T.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-CRQNXWMA.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5M5IBNSE.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-T6EIAALU.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-IS3SIHDZ.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-6E72VCQL.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-POXYY2M6.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-N4M65BXN.js"),"./locales/percentages.json":()=>import("./locales/percentages-BXMCSKIN.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-T2D74RX3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5N22H2LF.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-UZXXM6DQ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-JPDTUUEW.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-B4JR7IUQ.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-N5RQ5JYF.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-C5VTKIMK.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-NN7IZMDC.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XGPEYMSR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-2NMHFXQM.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HPSO5L25.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-DEFEU3FU.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-QMV73CPH.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-M7AON7JQ.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-LNUGB5OW.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var MI=85,co={code:"en",label:"English"},hr=[co,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>Bf[e.code]>=MI).sort((e,o)=>e.label>o.label?1:-1)],Dl="__test__";kI()&&hr.unshift({code:Dl,label:"test language"},{code:`${Dl}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var ur=co,Al={},_l=async e=>{if(ur=e,document.documentElement.dir=ur.rtl?"rtl":"ltr",document.documentElement.lang=ur.code,e.code.startsWith(Dl))Al={};else try{Al=await SI(`./locales/${ur.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Al=Kd}ze.set(p1,e.code)},Io=()=>ur,m1=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},g=(e,o,t)=>{if(ur.code.startsWith(Dl))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=m1(Al,n)||m1(Kd,n)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)r=r.replace(`{{${i}}}`,String(o[i]));return r},p1=me(co.code),Oe=()=>{let e=Pl(p1);return{t:g,langCode:e}};import LI from"clsx";import PI from"open-color";import Qe from"react";import{THEME as AI}from"@excalidraw/common";import{Fragment as be,jsx as h,jsxs as D}from"react/jsx-runtime";var jt=e=>"var(--icon-fill-color)",u1=e=>e===AI.LIGHT?PI.white:"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:LI({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},z={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},te={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},dG=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),z),gr=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),h("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),h("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),z),h1=M(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),z),g1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),z),f1=M(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),z),lm=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),z),_n=M(D("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),te),fr=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),te),b1=M(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),x1=M(D(be,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),E1=M(D(be,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),y1=M(D(be,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),mG=M(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),sm=M(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Hi=M(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Rl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),z),Nl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),z),Bl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),z),w1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),z),Fl=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),te),v1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),z),Zo=M(D("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),te),br=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),z),T1=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),te),I1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),z),cm=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),te),dm=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),te),C1=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),z),kt=M(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),te),mm=M(D("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),te),Gi=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),te),Ui=M(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),te),Yi=M(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...te,strokeWidth:1.5}),Ol=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),z),Rn=M(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),te),xr=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),S1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),pm=M(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),te),zl=M(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),te),k1=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),te),M1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),z),L1=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Wi=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),te),P1=M("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),A1=M("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Er=M(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),te),pG=M("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),D1=M("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Hl=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),h("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),h("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),z),_1=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),z),Gl=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),z),R1=M("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),uG=M("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),hG=M("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),N1=M("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),gG=M("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),um=M(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),te),hm=M(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),te),B1=M("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),F1=M(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),te),fG=M("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),bG=M("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),xG=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),z),EG=M(D(be,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),yG=M(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),O1=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),z1=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),gm=M(z1,z),fm=M(z1,{...z,style:{transform:"rotate(180deg)"}}),bm=M(O1,z),xm=M(O1,{...z,style:{transform:"rotate(180deg)"}}),Em=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),ym=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),wm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),vm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),H1=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),G1=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Tm=M(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),te),Im=M(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),te),Ul=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),z),wG=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),vG=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Bt=M(D(be,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),TG=M("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),IG=M("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),CG=M("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Cm=Qe.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:jt(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:jt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:jt(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:jt(e),strokeWidth:"2"}),D("g",{fill:u1(e),stroke:jt(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Sm=Qe.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:jt(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:jt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:jt(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:jt(e),strokeWidth:"2"}),D("g",{fill:u1(e),stroke:jt(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),U1=M(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),te),Y1=M(D(be,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),te),W1=M(D(be,{children:[D("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),V1=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...te,fill:"currentColor"}),km=M(h(be,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),te),X1=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),te),K1=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),te),SG=Qe.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:jt(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Z1=M(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),z),$1=M(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),z),j1=M(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),te),q1=M(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),te),J1=M(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),te),Q1=M(D("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),te),e0=M(D("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),z),t0=M(D("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[h("path",{d:"M12 12l9 0"}),h("path",{d:"M3 9l6 6"}),h("path",{d:"M3 15l6 -6"})]}),z),o0=Qe.memo(({flip:e=!1})=>M(D("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[h("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),h("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),n0=Qe.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),r0=Qe.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M26 10L6 10"}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),i0=Qe.memo(({flip:e=!1})=>M(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:h("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),a0=Qe.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),l0=Qe.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[h("path",{d:"M6,9.5H27"}),h("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),s0=Qe.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),c0=Qe.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),d0=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),m0=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),p0=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),u0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),h0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),g0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),f0=M(h(be,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),te),Nn=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),z),b0=M(h(be,{children:D("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),z),Vi=M(h(be,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),te),Yl=M(D(be,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),x0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),z),E0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),z),y0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),z),w0=Qe.memo(({theme:e})=>M(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),z)),v0=Qe.memo(({theme:e})=>M(D("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),z)),T0=Qe.memo(({theme:e})=>M(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),z)),Wl=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),z),I0=M(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),kG=M(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Vl=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),z),Mm=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),z),yr=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),z),C0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),z),S0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),MG=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),z),LG=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),z),k0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),z),M0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),z),L0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l6 6"}),h("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),z),P0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l-4 7h8z"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),z),Bn=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),z),Xl=M(h("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),wr=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),te),Xi=M(D("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),h("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),Kl=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),PG=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),AG=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),z),A0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),z),vr=M(D("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),z),D0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),z),_0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),R0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),Mt=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),z),N0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),z),B0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),z),F0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),z),Ki=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),z),O0=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),z),z0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),z),H0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),z),G0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),z),Lm=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),z),Zl=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),z),U0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),z),Y0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),z),W0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),z),V0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),z),X0=M(D("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...z,strokeWidth:1.5}),DG=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),z),K0=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),z),Z0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),z),$0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),z),$l=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),z),jl=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),z),ql=M(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),Jl=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),z),j0=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),q0=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),Pm=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),z),Ql=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),z);import J0 from"clsx";import Dm,{useEffect as RI,useRef as Q0,useState as NI}from"react";import{isPromiseLike as BI}from"@excalidraw/common";import DI from"react";import{jsx as Am}from"react/jsx-runtime";var _I=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(DI.useRef(Date.now()).current%1600);return Am("div",{className:`Spinner ${n}`,children:Am("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Am("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},et=_I;import{jsx as Zi,jsxs as $i}from"react/jsx-runtime";var K=Dm.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=He(),a=Dm.useRef(null);Dm.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,m]=NI(!1),c=Q0(!0),d=async u=>{let f="onClick"in n&&n.onClick?.(u);if(BI(f))try{m(!0),await f}catch(b){if(b instanceof sr)console.warn(b);else throw b}finally{c.current&&m(!1)}};RI(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=Q0(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return $i("button",{className:J0("ToolIcon_type_button",l,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:u,onClick:d,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&$i("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&Zi("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&Zi(et,{})]}),n.showAriaLabel&&$i("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&Zi(et,{})]}),n.children]})}return $i("label",{className:J0("ToolIcon",t),title:n.title,onPointerDown:u=>{p.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[Zi("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:p.current})},checked:n.checked,ref:a}),$i("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&Zi("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});K.displayName="ToolButton";var es=[],B=e=>(es=es.concat(e),e);import{jsx as WI}from"react/jsx-runtime";var YI=(e,o,t)=>{let n=new Set(j(e.filter(c=>HI(c)),o).map(c=>c.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let c of n){let d=GI(e,c);for(let p of d)if(!a.has(p.id)){if(ts(p)){let u=tb(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(c=>{if(o.selectedElementIds[c.id]){let d=ts(c)?tb(c,i):null;return c.frameId&&n.has(c.frameId)?(l=!1,r[c.id]=!0,c):d?.frameId&&n.has(d?.frameId)?c:(c.boundElements&&c.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&zI(u)&&t.scene.mutateElement(u,{startBinding:c.id===u.startBinding?.elementId?null:u.startBinding,endBinding:c.id===u.endBinding?.elementId?null:u.endBinding})}),ns(c,{isDeleted:!0}))}return c.frameId&&n.has(c.frameId)?(l=!1,ts(c)||(r[c.id]=!0),ns(c,{frameId:null})):ts(c)&&o.selectedElementIds[c.containerId]?ns(c,{isDeleted:!0}):c}),m=o.editingGroupId;if(l&&o.editingGroupId){let c=Nm(s,o.editingGroupId).filter(d=>!d.isDeleted);if(c.length>1)c[0]&&(r[c[0].id]=!0);else{m=null,c[0]&&(r[c[0].id]=!0);let d=c[0];if(d){let p=d.groupIds.findIndex(f=>f===o.editingGroupId),u=d.groupIds[p+1];if(u){let f=Nm(s,u).filter(b=>!b.isDeleted);f.length>1&&(m=u,f.forEach(b=>{r[b.id]=!0}))}}}}return{elements:s,appState:{...o,...UI({selectedElementIds:r,editingGroupId:m},s,o,null)}}},ob=(e,o)=>{if(e.editingGroupId){let t=Nm(Rm(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},ji=B({name:"deleteSelectedElements",label:"labels.delete",icon:kt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:m}=o.selectedLinearElement,c=n.scene.getNonDeletedElementsMap(),d=eb.getElement(a,c);if(!d||l==null)return!1;if(l.length>=d.points.length){let u=e.map(b=>b.id===d.id?ns(b,{isDeleted:!0}):b),f=ob(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:os.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:m};return eb.deletePoints(d,n,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:os.IMMEDIATELY}}let{elements:r,appState:i}=YI(e,o,n);return OI(r,r.filter(a=>a.isDeleted)),i=ob(i,r),{elements:r,appState:{...i,activeTool:FI(o,{type:n.defaultSelectionTool}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ee(Rm(e),o)?os.IMMEDIATELY:os.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===_m.BACKSPACE||e.key===_m.DELETE)&&!e[_m.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>WI(K,{type:"button",icon:kt,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:Ee(Rm(e),o)})});import{KEYS as Tr,CODES as Ir,getShortcutKey as Cr,isDarwin as rs}from"@excalidraw/common";import{moveOneLeft as VI,moveOneRight as XI,moveAllLeft as KI,moveAllRight as ZI}from"@excalidraw/element";import{CaptureUpdateAction as is}from"@excalidraw/element";import{jsx as as}from"react/jsx-runtime";var Bm=B({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:fm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:VI(e,o,n.scene),appState:o,captureUpdate:is.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Tr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ir.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>as("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${Cr("CtrlOrCmd+[")}`,children:fm})}),Fm=B({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:gm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:XI(e,o,n.scene),appState:o,captureUpdate:is.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Tr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ir.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>as("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${Cr("CtrlOrCmd+]")}`,children:gm})}),Om=B({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:xm,trackEvent:{category:"element"},perform:(e,o)=>({elements:KI(e,o),appState:o,captureUpdate:is.IMMEDIATELY}),keyTest:e=>rs?e[Tr.CTRL_OR_CMD]&&e.altKey&&e.code===Ir.BRACKET_LEFT:e[Tr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ir.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>as("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${rs?Cr("CtrlOrCmd+Alt+["):Cr("CtrlOrCmd+Shift+[")}`,children:xm})}),zm=B({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:bm,trackEvent:{category:"element"},perform:(e,o)=>({elements:ZI(e,o),appState:o,captureUpdate:is.IMMEDIATELY}),keyTest:e=>rs?e[Tr.CTRL_OR_CMD]&&e.altKey&&e.code===Ir.BRACKET_RIGHT:e[Tr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ir.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>as("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${rs?Cr("CtrlOrCmd+Alt+]"):Cr("CtrlOrCmd+Shift+]")}`,children:bm})});import{getNonDeletedElements as $I}from"@excalidraw/element";import{LinearElementEditor as jI}from"@excalidraw/element";import{isLinearElement as qI,isTextElement as JI}from"@excalidraw/element";import{arrayToMap as QI,KEYS as nb}from"@excalidraw/common";import{selectGroupsForSelectedElements as eC}from"@excalidraw/element";import{CaptureUpdateAction as tC}from"@excalidraw/element";var Hm=B({name:"selectAll",label:"labels.selectAll",icon:O0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(JI(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...eC({editingGroupId:null,selectedElementIds:r},$I(e),o,n),selectedLinearElement:Object.keys(r).length===1&&qI(e[0])?new jI(e[0],QI(e)):null},captureUpdate:tC.IMMEDIATELY}},keyTest:e=>e[nb.CTRL_OR_CMD]&&e.key===nb.A});import{DEFAULT_GRID_SIZE as rb,KEYS as ib,arrayToMap as ab,getShortcutKey as oC}from"@excalidraw/common";import{getNonDeletedElements as lb}from"@excalidraw/element";import{LinearElementEditor as nC}from"@excalidraw/element";import{getSelectedElements as rC,getSelectionStateForElements as iC}from"@excalidraw/element";import{syncMovedIndices as aC}from"@excalidraw/element";import{duplicateElements as lC}from"@excalidraw/element";import{CaptureUpdateAction as sb}from"@excalidraw/element";import{jsx as sC}from"react/jsx-runtime";var Gm=B({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Gi,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=nC.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:sb.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=lC({type:"in-place",elements:e,idsOfElementsToDuplicate:ab(rC(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+rb/2,y:a.y+rb/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:aC(i,ab(r)),appState:{...o,...iC(r,lb(i),o)},captureUpdate:sb.IMMEDIATELY}},keyTest:e=>e[ib.CTRL_OR_CMD]&&e.key===ib.D,PanelComponent:({elements:e,appState:o,updateData:t})=>sC(K,{type:"button",icon:Gi,title:`${g("labels.duplicateSelection")} \u2014 ${oC("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:Ee(lb(e),o)})});import{pointFrom as cS}from"@excalidraw/math";import{useEffect as cp,useMemo as dS,useRef as dp,useState as mS}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as pS,DEFAULT_ELEMENT_BACKGROUND_PICKS as uS,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as hS,DEFAULT_ELEMENT_STROKE_PICKS as gS,ARROW_TYPE as So,DEFAULT_FONT_FAMILY as fS,DEFAULT_FONT_SIZE as bS,FONT_FAMILY as xS,ROUNDNESS as Ts,STROKE_WIDTH as mp,VERTICAL_ALIGN as vs,KEYS as Br,randomInteger as ES,arrayToMap as hp,getFontFamilyString as yS,getShortcutKey as wS,getLineHeight as vS,isTransparent as TS,reduceToCommonValue as IS}from"@excalidraw/common";import{canBecomePolygon as CS,getNonDeletedElements as $b}from"@excalidraw/element";import{bindLinearElement as Vb,calculateFixedPointForElbowArrowBinding as Xb,updateBoundElements as SS}from"@excalidraw/element";import{LinearElementEditor as pp}from"@excalidraw/element";import{newElementWith as Xe}from"@excalidraw/element";import{getBoundTextElement as on,redrawTextBoundingBox as aa}from"@excalidraw/element";import{isArrowElement as Is,isBoundToContainer as kS,isElbowArrow as jb,isLinearElement as up,isLineElement as Kb,isTextElement as bt,isUsingAdaptiveRadius as MS}from"@excalidraw/element";import{hasStrokeColor as LS}from"@excalidraw/element";import{updateElbowArrowPoints as PS,CaptureUpdateAction as Ke,toggleLinePolygonState as AS}from"@excalidraw/element";import{isDevEnv as cC}from"@excalidraw/common";var dC=new Set(["command_palette","export"]),ne=(e,o,t,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!dC.has(e)||cC())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import hC from"clsx";import mC from"clsx";import{forwardRef as pC}from"react";import{jsx as uC}from"react/jsx-runtime";var Sr=pC((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return uC("button",{type:"button",ref:o,title:t,"data-testid":r,className:mC(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as fC,jsx as Um,jsxs as gC}from"react/jsx-runtime";var Ft=e=>Um(fC,{children:e.options.map(o=>e.type==="button"?Um(Sr,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):gC("label",{className:hC({active:e.value===o.value}),title:o.text,children:[Um("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as us from"@radix-ui/react-popover";import g6 from"clsx";import{useRef as f6}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as b6,COLOR_PALETTE as kb,isTransparent as x6}from"@excalidraw/common";import{jsx as bC}from"react/jsx-runtime";var ls=()=>bC("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as vC,useRef as TC}from"react";import{createPortal as IC}from"react-dom";import{EVENT as jo,KEYS as CC,rgbToHex as SC}from"@excalidraw/common";import cb from"react";var Ym=cb.createContext(null),ge=()=>cb.useContext(Ym);import{useState as xC,useLayoutEffect as db}from"react";import{THEME as EC}from"@excalidraw/common";var ss=e=>{let[o,t]=xC(null),n=ce(),{theme:r}=ge(),{container:i}=He();return db(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.editor.isMobile),o.classList.toggle("theme--dark",r===EC.DARK))},[o,r,n.editor.isMobile,e?.className]),db(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as yC}from"react";import{EVENT as cs}from"@excalidraw/common";function kr(e,o,t){yC(()=>{function n(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(cs.POINTER_DOWN,n),document.addEventListener(cs.TOUCH_START,n),()=>{document.removeEventListener(cs.POINTER_DOWN,n),document.removeEventListener(cs.TOUCH_START,n)}},[e,o,t])}import{useRef as wC}from"react";var $o=e=>{let o=wC(e);return Object.assign(o.current,e),o.current};import{jsx as kC}from"react/jsx-runtime";var qo=me(null),mb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=ss({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ge(),a=Jo(),l=_e(),s=j(a,i),m=$o({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:c}=He();vC(()=>{let p=d.current;if(!p||!l.canvas||!r)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:L})=>{let k=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(L-i.offsetTop)*window.devicePixelRatio,1,1).data;return SC(k[0],k[1],k[2])},x=({clientX:S,clientY:L,altKey:k})=>{p.style.top=`${L+20}px`,p.style.left=`${S+20}px`;let A=b({clientX:S,clientY:L});u&&m.onChange(n,A,m.selectedElements,{altKey:k}),p.style.background=A},w=()=>{m.onCancel()},E=(S,L)=>{m.onSelect(S,L)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,c?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},C=S=>{S.key===CC.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),x({clientX:m.app.lastViewportPosition.x,clientY:m.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(jo.KEYDOWN,C),r.addEventListener(jo.POINTER_DOWN,y),r.addEventListener(jo.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(jo.BLUR,w),()=>{u=!1,r.removeEventListener(jo.KEYDOWN,C),r.removeEventListener(jo.POINTER_DOWN,y),r.removeEventListener(jo.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(jo.BLUR,w)}},[m,l.canvas,r,n,c,i.offsetLeft,i.offsetTop]);let d=TC(null);return kr(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?IC(kC("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),r):null};import*as Mr from"@radix-ui/react-popover";import AC from"clsx";import DC from"react";import{isInteractive as _C}from"@excalidraw/common";import MC from"react";import LC from"clsx";import{jsx as PC}from"react/jsx-runtime";var Ve=MC.forwardRef(({children:e,padding:o,className:t,style:n},r)=>PC("div",{className:LC("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as Wm,jsxs as RC}from"react/jsx-runtime";var ds=DC.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},m)=>{let c=ce();return Wm(Mr.Portal,{container:o,children:RC(Mr.Content,{ref:m,className:AC("focus-visible-none",e),"data-prevent-outside-click":!0,side:c.editor.isMobile&&!c.viewport.isLandscape?"bottom":"right",align:c.editor.isMobile&&!c.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:d=>{d.stopPropagation(),d.preventDefault(),o&&!_C(document.activeElement)&&o.focus(),r()},children:[Wm(Ve,{padding:3,style:n,children:t}),Wm(Mr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import BC from"clsx";import{useCallback as FC,useEffect as Xm,useRef as hb,useState as OC}from"react";import{KEYS as Km,getShortcutKey as zC}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as NC}from"@excalidraw/common";var Qo=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},qi=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Vm=({color:e,palette:o})=>!Object.values(o).flat().includes(e),ub=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[o]];return Vm({color:l,palette:t})}),i=new Map;return r.forEach(a=>{let l=a[n[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,NC)},Ot=me(null),pb=(e,o,t)=>(e*299+o*587+t*114)/1e3,Lr=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),m=parseInt(l[1]),c=parseInt(l[2]);return pb(s,m,c)<o}return!0}let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return pb(t,n,r)<o};import{Fragment as HC,jsx as ms,jsxs as gb}from"react/jsx-runtime";var fb=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=ce(),[a,l]=OC(e),[s,m]=ie(Ot);Xm(()=>{l(e)},[e]);let c=FC(b=>{let x=b.toLowerCase(),w=bb(x);w&&o(w),l(x)},[o]),d=hb(null),p=hb(null);Xm(()=>{d.current&&d.current.focus()},[s]);let[u,f]=ie(qo);return Xm(()=>()=>{f(null)},[f]),gb("div",{className:"color-picker__input-label",children:[ms("div",{className:"color-picker__input-hash",children:"#"}),ms("input",{ref:s==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{c(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:b=>{b.key!==Km.TAB&&(b.key===Km.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:r}),!i.editor.isMobile&&gb(HC,{children:[ms("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),ms("div",{ref:p,className:BC("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${Km.I.toLocaleUpperCase()} or ${zC("Alt")} `,children:L0})]})]})};import qm,{useEffect as Jm,useImperativeHandle as i6,useState as a6}from"react";import{EVENT as Tb}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as l6,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as s6,KEYS as c6}from"@excalidraw/common";import YC from"clsx";import{useEffect as WC,useRef as VC}from"react";import{jsxs as UC}from"react/jsx-runtime";var GC=({color:e,keyLabel:o,isShade:t=!1})=>UC("div",{className:"color-picker__button__hotkey-label",style:{color:Lr(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Pr=GC;import{jsx as Zm,jsxs as XC}from"react/jsx-runtime";var xb=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=ie(Ot),a=VC(null);return WC(()=>{a.current&&a.current.focus()},[o,r]),Zm("div",{className:"color-picker-content--default",children:e.map((l,s)=>XC("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:YC("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":n,style:{"--swatch-color":l},children:[Zm("div",{className:"color-picker__button-outline"}),Zm(Pr,{color:l,keyLabel:s+1})]},s))})};import KC from"clsx";import{useEffect as ZC,useRef as $C}from"react";import{jsx as $m,jsxs as qC}from"react/jsx-runtime";var jC=({palette:e,color:o,onChange:t,activeShade:n})=>{let r=Qo({color:o,palette:e}),[i,a]=ie(Ot),l=$C(null);return ZC(()=>{l.current&&i==="baseColors"&&l.current.focus()},[r?.colorName,i]),$m("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,m],c)=>{let d=(Array.isArray(m)?m[n]:m)||"transparent",p=qi[c],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return qC("button",{ref:r?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:KC("color-picker__button color-picker__button--large has-outline",{active:r?.colorName===s,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),a("baseColors")},title:`${u}${d.startsWith("#")?` ${d}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${s}`,children:[$m("div",{className:"color-picker__button-outline"}),$m(Pr,{color:d,keyLabel:p})]},s)})})},Eb=jC;import{jsx as QC}from"react/jsx-runtime";var JC=({children:e})=>QC("div",{className:"color-picker__heading",children:e}),Ar=JC;import e6 from"clsx";import{useEffect as t6,useRef as o6}from"react";import{jsx as Ji,jsxs as yb}from"react/jsx-runtime";var wb=({color:e,onChange:o,palette:t})=>{let n=Qo({color:e||"transparent",palette:t}),[r,i]=ie(Ot),a=o6(null);if(t6(()=>{a.current&&r==="shades"&&a.current.focus()},[n,r]),n){let{colorName:l,shade:s}=n,m=t[l];if(Array.isArray(m))return Ji("div",{className:"color-picker-content--default shades",children:m.map((c,d)=>yb("button",{ref:d===s&&r==="shades"?a:void 0,tabIndex:-1,type:"button",className:e6("color-picker__button color-picker__button--large has-outline",{active:d===s}),"aria-label":"Shade",title:`${l} - ${d+1}`,style:c?{"--swatch-color":c}:void 0,onClick:()=>{o(c),i("shades")},children:[Ji("div",{className:"color-picker__button-outline"}),Ji(Pr,{color:c,keyLabel:d+1,isShade:!0})]},d))})}return yb("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Ji("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Ji("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:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Dr,COLOR_PALETTE as n6,KEYS as Qi}from"@excalidraw/common";var jm=(e,o,t)=>{let n=Math.ceil(t/Dr);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+Dr;return r>=t?o%Dr:r}case"ArrowUp":{let r=o-Dr,i=r<0?Dr*n+r:r;return i>=t?void 0:i}}},r6=({e,colorObj:o,onChange:t,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(n[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return t(r[Number(e.key)-1]),i("custom"),!0;if(qi.includes(e.key)){let l=qi.indexOf(e.key),s=Object.keys(n)[l],m=n[s],c=Array.isArray(m)?m[a]:m;return t(c),i("baseColors"),!0}return!1},vb=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:m,onEscape:c})=>{if(e[Qi.CTRL_OR_CMD])return!1;if(e.key===Qi.ESCAPE)return c(e),!0;if(e.key===Qi.ALT)return m(!0),!0;if(e.key===Qi.I)return m(),!0;let d=Qo({color:n,palette:t});if(e.key===Qi.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,v])=>(v&&E.push(y),E),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,w=u[x];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(n):v===n?y:null)||r(n6.black)),e.preventDefault(),e.stopPropagation(),!0}if(r6({e,colorObj:d,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=jm(e.key,p,Dr);if(u!==void 0)return r(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),f=u.indexOf(p),b=jm(e.key,f,u.length);if(b!==void 0){let x=u[b],w=t[x];return r(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let p=n!=null?i.indexOf(n):0,u=jm(e.key,p,i.length);if(u!==void 0){let f=i[u];return r(f),!0}}return!1};import{jsx as Fn,jsxs as ps}from"react/jsx-runtime";var Ib=qm.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},m)=>{let[c]=qm.useState(()=>t==="canvasBackground"?[]:ub(n,t,r)),[d,p]=ie(Ot),u=Qo({color:e,palette:r});Jm(()=>{if(!d){let w=!!e&&Vm({color:e,palette:r}),E=w&&!c.includes(e);p(E?null:w?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,r,p,u,c]);let[f,b]=a6(u?.shade??(t==="elementBackground"?l6:s6));Jm(()=>{u?.shade!=null&&b(u.shade);let w=E=>{E.key===c6.ALT&&l(!1)};return document.addEventListener(Tb.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(Tb.KEYUP,w,{capture:!0})}},[u,l]);let x=qm.useRef(null);return i6(m,()=>x.current),Jm(()=>{x?.current?.focus()},[]),Fn("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:ps("div",{ref:x,onKeyDown:w=>{vb({event:w,activeColorPickerSection:d,palette:r,color:e,onChange:o,onEyeDropperToggle:l,customColors:c,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!c.length&&ps("div",{children:[Fn(Ar,{children:g("colorPicker.mostUsedCustomColors")}),Fn(xb,{colors:c,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),ps("div",{children:[Fn(Ar,{children:g("colorPicker.colors")}),Fn(Eb,{color:e,palette:r,onChange:o,activeShade:f})]}),ps("div",{children:[Fn(Ar,{children:g("colorPicker.shades")}),Fn(wb,{color:e,onChange:o,palette:r})]}),a]})})});import d6 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as m6,DEFAULT_CANVAS_BACKGROUND_PICKS as p6,DEFAULT_ELEMENT_BACKGROUND_PICKS as u6,DEFAULT_ELEMENT_STROKE_PICKS as h6}from"@excalidraw/common";import{jsx as Qm}from"react/jsx-runtime";var Cb=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=h6),o==="elementBackground"&&(r=u6),o==="canvasBackground"&&(r=p6),n&&(r=n),r?Qm("div",{className:"color-picker__top-picks",children:r.map(i=>Qm("button",{className:d6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!Lr(i,m6)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Qm("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as qt,jsxs as ep}from"react/jsx-runtime";var Sb=e=>{let o=new Option().style;return o.color=e,!!o.color},bb=e=>x6(e)?e:Sb(`#${e}`)?`#${e}`:Sb(e)?e:null,E6=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=kb,updateData:a})=>{let{container:l}=He(),[,s]=ie(Ot),[m,c]=ie(qo),d=ep("div",{children:[qt(Ar,{children:g("colorPicker.hexCode")}),qt(fb,{color:o||"",label:n,onChange:f=>{t(f)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),p=f6(null),u=()=>{p.current?.focus()};return qt(ds,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{m&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?qt(Ib,{ref:p,palette:i,color:o,onChange:f=>{t(f)},onEyeDropperToggle:f=>{c(b=>f?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):f===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:f=>{m?c(null):a({openPopup:null})},type:e,elements:r,updateData:a,children:d}):d})},y6=({label:e,color:o,type:t})=>qt(us.Trigger,{type:"button",className:g6("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Lr(o,b6)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),children:qt("div",{className:"color-picker__button-outline",children:!o&&_1})}),ea=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=kb,topPicks:a,updateData:l,appState:s})=>qt("div",{children:ep("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[qt(Cb,{activeColor:o,onChange:t,type:e,topPicks:a}),qt(ls,{}),ep(us.Root,{open:s.openPopup===e,onOpenChange:m=>{l({openPopup:m?e:null})},children:[qt(y6,{color:o,label:n,type:e}),s.openPopup===e&&qt(E6,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:l})]})]})});import*as Fb from"@radix-ui/react-popover";import j6,{useCallback as q6,useMemo as J6}from"react";import{FONT_FAMILY as ip}from"@excalidraw/common";import H6,{useMemo as en,useState as G6,useRef as U6,useEffect as Y6,useCallback as W6}from"react";import{arrayToList as V6,debounce as X6,FONT_FAMILY as On,getFontFamilyString as K6}from"@excalidraw/common";import w6 from"clsx";import v6 from"react";import{jsx as T6,jsxs as I6}from"react/jsx-runtime";var hs=v6.forwardRef(({className:e,placeholder:o,onChange:t},n)=>I6("div",{className:w6("QuickSearch__wrapper",e),children:[Mt,T6("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import C6 from"clsx";import{Children as S6}from"react";import{jsx as Mb}from"react/jsx-runtime";var gs=({className:e,placeholder:o,children:t})=>{let n=!S6.count(t);return Mb("div",{className:C6("ScrollableList__wrapper",e),role:"menu",children:n?Mb("div",{className:"empty",children:o}):t})};import{jsx as k6,jsxs as M6}from"react/jsx-runtime";var Lb=({children:e,className:o="",style:t,title:n})=>M6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&k6("p",{className:"dropdown-menu-group-title",children:n}),e]}),ta=Lb;Lb.displayName="DropdownMenuGroup";import{useEffect as F6,useRef as O6}from"react";import{THEME as z6}from"@excalidraw/common";import{jsx as L6}from"react/jsx-runtime";var oa=({children:e,...o})=>L6("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as A6,jsx as fs,jsxs as D6}from"react/jsx-runtime";var P6=({textStyle:e,icon:o,shortcut:t,children:n})=>{let r=ce();return D6(A6,{children:[o&&fs("div",{className:"dropdown-menu-item__icon",children:o}),fs("div",{style:e,className:"dropdown-menu-item__text",children:fs(oa,{children:n})}),t&&!r.editor.isMobile&&fs("div",{className:"dropdown-menu-item__shortcut",children:t})]})},bs=P6;import _6,{useContext as R6}from"react";import{EVENT as N6,composeEventHandlers as B6}from"@excalidraw/common";var tp=_6.createContext({}),xs=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
2
- ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),Es=(e,o)=>{let t=R6(tp);return B6(e,n=>{let r=new CustomEvent(N6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(r),r.defaultPrevented||t.onSelect?.(r)})};import{jsx as op}from"react/jsx-runtime";var np=({icon:e,value:o,order:t,children:n,shortcut:r,className:i,hovered:a,selected:l,textStyle:s,onSelect:m,onClick:c,...d})=>{let p=Es(c,m),u=O6(null);return F6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),op("button",{...d,ref:u,value:o,onClick:p,className:xs(i,l,a),title:d.title??d["aria-label"],children:op(bs,{textStyle:s,icon:e,shortcut:r,children:n})})};np.displayName="DropdownMenuItem";var _r={GREEN:"green",RED:"red",BLUE:"blue"},ys=({type:e=_r.BLUE,children:o})=>{let{theme:t}=mo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===z6.LIGHT?"1.5px solid white":"none"};switch(e){case _r.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case _r.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case _r.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return op("div",{className:"DropDownMenuItemBadge",style:n,children:o})};ys.displayName="DropdownMenuItemBadge";np.Badge=ys;var dt=np;import{KEYS as Rr}from"@excalidraw/common";var Pb=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[Rr.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Rr.F)return o.current?.focus(),!0;if(e.key===Rr.ESCAPE)return r(),!0;if(e.key===Rr.ENTER)return t?.value&&i(t.value),!0;if(e.key===Rr.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===Rr.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as na,jsxs as Ab}from"react/jsx-runtime";var Z6=e=>{switch(e){case On.Excalifont:case On.Virgil:return Zo;case On.Nunito:case On.Helvetica:return Vi;case On["Lilita One"]:return b0;case On["Comic Shanns"]:case On.Cascadia:return Yl;default:return Vi}},Db=H6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=He(),{fonts:s}=_e(),{showDeprecatedFonts:m}=po(),[c,d]=G6(""),p=U6(null),u=en(()=>Array.from(Vo.registered.entries()).filter(([k,{metadata:A}])=>!A.private&&!A.fallback).map(([k,{metadata:A,fontFaces:P}])=>{let N={value:k,icon:Z6(k),text:P[0]?.fontFace?.family??"Unknown"};return A.deprecated&&Object.assign(N,{deprecated:A.deprecated,badge:{type:_r.RED,placeholder:g("fontList.badge.old")}}),N}).sort((k,A)=>k.text.toLowerCase()>A.text.toLowerCase()?1:-1),[]),f=en(()=>new Set(s.getSceneFamilies()),[e]),b=en(()=>u.filter(k=>f.has(k.value)),[u,f]),x=en(()=>u.filter(k=>!f.has(k.value)&&(m||!k.deprecated)),[u,f,m]),w=en(()=>V6([...b,...x].filter(k=>k.text?.toLowerCase().includes(c))),[b,x,c]),E=en(()=>{let k;return o?k=w.find(A=>A.value===o):e&&(k=w.find(A=>A.value===e)),!k&&c&&(w[0]?.value?n(w[0].value):r()),k},[o,e,c,w,n,r]),y=W6(k=>{Pb({event:k,inputRef:p,hoveredFont:E,filteredFonts:w,onSelect:t,onHover:n,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[E,w,t,n,a]);Y6(()=>(i(),()=>{a()}),[]);let v=en(()=>w.filter(k=>f.has(k.value)),[w,f]),C=en(()=>w.filter(k=>!f.has(k.value)),[w,f]),S=(k,A)=>Ab(dt,{icon:k.icon,value:k.value,order:A,textStyle:{fontFamily:K6({fontFamily:k.value})},hovered:k.value===E?.value,selected:k.value===e,tabIndex:k.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{E?.value!==k.value&&n(k.value)},children:[k.text,k.badge&&na(ys,{type:k.badge.type,children:k.badge.placeholder})]},k.value),L=[];return v.length&&L.push(na(ta,{title:g("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&L.push(na(ta,{title:g("fontList.availableFonts"),children:C.map((k,A)=>S(k,A+v.length))},"group_2")),Ab(ds,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:r,onKeyDown:y,children:[na(hs,{ref:p,placeholder:g("quickSearch.placeholder"),onChange:X6(d,20)}),na(gs,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:L.length?L:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as _b from"@radix-ui/react-popover";import{useMemo as $6}from"react";import{jsx as rp}from"react/jsx-runtime";var Rb=({selectedFontFamily:e})=>{let o=$6(()=>!!(e&&!Nb(e)),[e]);return rp(_b.Trigger,{asChild:!0,children:rp("div",{children:rp(Sr,{standalone:!0,icon:br,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as ra,jsxs as Bb}from"react/jsx-runtime";var Ob=[{value:ip.Excalifont,icon:Zo,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:ip.Nunito,icon:Vi,text:g("labels.normal"),testId:"font-family-normal"},{value:ip["Comic Shanns"],icon:Yl,text:g("labels.code"),testId:"font-family-code"}],Q6=new Set(Ob.map(e=>e.value)),Nb=e=>e?Q6.has(e):!1,zb=j6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a})=>{let l=J6(()=>Ob,[]),s=q6(m=>{m&&n(m)},[n]);return Bb("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[ra("div",{className:"buttonList",children:ra(Ft,{type:"button",options:l,value:o,onClick:s})}),ra(ls,{}),Bb(Fb.Root,{open:e,onOpenChange:a,children:[ra(Rb,{selectedFontFamily:o}),e&&ra(Db,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Nr from"@radix-ui/react-popover";import nS from"clsx";import ws,{useEffect as rS}from"react";import{isArrowKey as iS,KEYS as Co}from"@excalidraw/common";import{jsx as eS}from"react/jsx-runtime";var tn=({icon:e})=>eS("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:e});import{Fragment as oS,jsx as Hb,jsxs as Gb}from"react/jsx-runtime";var tS=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>Gb(oS,{children:[Gb("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Hb(tn,{icon:o?j0:Jl})]}),o&&Hb("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),ia=tS;import{jsx as zn,jsxs as ap}from"react/jsx-runtime";var aS=me(!1);function lS({options:e,value:o,label:t,onChange:n,onClose:r,numberOfOptionsToAlwaysShow:i=e.length}){let a=ce(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)n(f.value),u.preventDefault();else if(u.key===Co.TAB){let b=e.findIndex(w=>w.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;n(e[x].value)}else if(iS(u.key)){let b=Io().rtl,x=e.findIndex(w=>w.value===o);if(x!==-1){let w=e.length,E=x;switch(u.key){case(b?Co.ARROW_LEFT:Co.ARROW_RIGHT):E=(x+1)%w;break;case(b?Co.ARROW_RIGHT:Co.ARROW_LEFT):E=(w+x-1)%w;break;case Co.ARROW_DOWN:{E=(x+(i??1))%w;break}case Co.ARROW_UP:{E=(w+x-(i??1))%w;break}}n(e[E].value)}u.preventDefault()}else(u.key===Co.ESCAPE||u.key===Co.ENTER)&&(u.preventDefault(),r());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,m]=ie(aS),c=ws.useMemo(()=>e.slice(0,i),[e,i]),d=ws.useMemo(()=>e.slice(i),[e,i]);rS(()=>{c.some(u=>u.value===o)||m(!0)},[o,c,m]);let p=u=>zn("div",{className:"picker-content",children:u.map((f,b)=>ap("button",{type:"button",className:nS("picker-option",{active:o===f.value}),onClick:x=>{n(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&zn("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return zn(Nr.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:ap("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(c),d.length>0&&zn(ia,{label:g("labels.more_options"),open:s,openTrigger:()=>{m(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function lp({value:e,label:o,options:t,onChange:n,group:r="",numberOfOptionsToAlwaysShow:i}){let[a,l]=ws.useState(!1),s=ws.useRef(null);return zn("div",{children:ap(Nr.Root,{open:a,onOpenChange:m=>l(m),children:[zn(Nr.Trigger,{name:r,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(m=>m.value===e)?.icon}),a&&zn(lS,{options:t,value:e,label:o,onChange:n,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Ub,{useEffect as sS}from"react";import{jsx as sp,jsxs as Yb}from"react/jsx-runtime";var Wb=({updateData:e,app:o,testId:t})=>{let n=Ub.useRef(null),r=Ub.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),m=i.reduce((c,d)=>(c!=null&&c!==d.opacity&&(a=!1),c==null||c>d.opacity?d.opacity:c),l?.opacity??null)??o.state.currentItemOpacity;return sS(()=>{if(n.current&&r.current){let c=n.current,d=r.current,p=c.offsetWidth,u=15,f=m/100*(p-u)+u/2;d.style.left=`${f}px`,c.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${m}%, var(--button-bg) ${m}%, var(--button-bg) 100%)`}},[m]),Yb("label",{className:"control-label",children:[g("labels.opacity"),Yb("div",{className:"range-wrapper",children:[sp("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:c=>{e(+c.target.value)},value:m,className:"range-input","data-testid":t}),sp("div",{className:"value-bubble",ref:r,children:m!==0?m:null}),sp("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Jb,jsx as Q,jsxs as Et}from"react/jsx-runtime";var qb=.1,mt=(e,o,t,n=!1)=>{let r=hp(j(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},xt=function(e,o,t,n,r){let i=o.state.editingTextElement,a=$b(e),l=null;if(i&&(l=t(i)),!l)if(Ee(a,o.state)){let m=o.scene.getSelectedElements(o.state),c=n===!0?m:m.filter(d=>n(d));l=IS(c,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},DS=(e,o,t)=>kS(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),gp=(e,o,t,n,r)=>{let i=new Set,a=mt(e,o,l=>{if(bt(l)){let s=n(l);i.add(s);let m=Xe(l,{fontSize:s});return aa(m,t.scene.getContainerElement(l),t.scene),m=DS(l,m,t.scene),m}return l},!0);return j(e,o,{includeBoundTextElement:!0}).forEach(l=>{bt(l)&&SS(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:Ke.IMMEDIATELY}},_S=B({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:mt(e,o,n=>LS(n.type)?Xe(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?Ke.IMMEDIATELY:Ke.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Et(Jb,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.stroke")}),Q(ea,{topPicks:gS,palette:hS,type:"elementStroke",label:g("labels.stroke"),color:xt(e,n,r=>r.strokeColor,!0,r=>r?null:o.currentItemStrokeColor),onChange:r=>t({currentItemStrokeColor:r}),elements:e,appState:o,updateData:t})]})}),RS=B({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:Ke.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!TS(t.currentItemBackgroundColor)&&i.every(l=>Kb(l)&&CS(l.points))){let l=hp(i);r=e.map(s=>l.has(s.id)&&Kb(s)?Xe(s,{backgroundColor:t.currentItemBackgroundColor,...AS(s,!0)}):s)}else r=mt(e,o,l=>Xe(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:Ke.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Et(Jb,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.background")}),Q(ea,{topPicks:uS,palette:pS,type:"elementBackground",label:g("labels.background"),color:xt(e,n,r=>r.backgroundColor,!0,r=>r?null:o.currentItemBackgroundColor),onChange:r=>t({currentItemBackgroundColor:r}),elements:e,appState:o,updateData:t})]})}),NS=B({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(ne("element","changeFillStyle",`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`),{elements:mt(e,o,r=>Xe(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=j(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return Et("fieldset",{children:[Q("legend",{children:g("labels.fill")}),Q("div",{className:"buttonList",children:Q(Ft,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${wS("Alt-Click")})`,icon:i?U1:Y1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:W1,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:V1,testId:"fill-solid"}],value:xt(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(m=>m.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),BS=B({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:mt(e,o,n=>Xe(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Et("fieldset",{children:[Q("legend",{children:g("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"stroke-width",options:[{value:mp.thin,text:g("labels.thin"),icon:km,testId:"strokeWidth-thin"},{value:mp.bold,text:g("labels.bold"),icon:X1,testId:"strokeWidth-bold"},{value:mp.extraBold,text:g("labels.extraBold"),icon:K1,testId:"strokeWidth-extraBold"}],value:xt(e,n,r=>r.strokeWidth,r=>r.hasOwnProperty("strokeWidth"),r=>r?null:o.currentItemStrokeWidth),onChange:r=>t(r)})})]})}),FS=B({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:mt(e,o,n=>Xe(n,{seed:ES(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Et("fieldset",{children:[Q("legend",{children:g("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:j1},{value:1,text:g("labels.artist"),icon:q1},{value:2,text:g("labels.cartoonist"),icon:J1}],value:xt(e,n,r=>r.roughness,r=>r.hasOwnProperty("roughness"),r=>r?null:o.currentItemRoughness),onChange:r=>t(r)})})]})}),CZ=B({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:mt(e,o,n=>Xe(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Et("fieldset",{children:[Q("legend",{children:g("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:km},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:Z1},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:$1}],value:xt(e,n,r=>r.strokeStyle,r=>r.hasOwnProperty("strokeStyle"),r=>r?null:o.currentItemStrokeStyle),onChange:r=>t(r)})})]})}),OS=B({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:mt(e,o,n=>Xe(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>Q(Wb,{updateData:o,app:e,testId:"opacity"})}),zS=B({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>gp(e,o,n,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Et("fieldset",{children:[Q("legend",{children:g("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:u0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:h0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:g0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:f0,testId:"fontSize-veryLarge"}],value:xt(e,n,r=>{if(bt(r))return r.fontSize;let i=on(r,n.scene.getNonDeletedElementsMap());return i?i.fontSize:null},r=>bt(r)||on(r,n.scene.getNonDeletedElementsMap())!==null,r=>r?null:o.currentItemFontSize||bS),onChange:r=>t(r)})})]})}),fp=B({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Nn,trackEvent:!1,perform:(e,o,t,n)=>gp(e,o,n,r=>Math.round(1/(1+qb)*r.fontSize)),keyTest:e=>e[Br.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Br.CHEVRON_LEFT||e.key===Br.COMMA)}),bp=B({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Nn,trackEvent:!1,perform:(e,o,t,n)=>gp(e,o,n,r=>Math.round(r.fontSize*(1+qb))),keyTest:e=>e[Br.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Br.CHEVRON_RIGHT||e.key===Br.PERIOD)}),HS=B({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:mt(e,o,b=>{let x=r?.get(b.id);return x?Xe(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:Ke.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:m}=t,c=Ke.EVENTUALLY,d,p=!1;if(s)d=s,c=Ke.IMMEDIATELY;else if(m){d=m,c=Ke.EVENTUALLY;let f=j(e,o,{includeBoundTextElement:!0}).filter(b=>bt(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let w=f[b];x+=w?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:c};if(d&&!p){let f=new Map,b=new Set,x=!1,w=Array.from(Vo.loadedFontsCache.values()),E=Object.entries(xS).find(([C,S])=>S===d)?.[0];m&&E&&w.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:mt(e,o,C=>{if(bt(C)&&(C.fontFamily!==d||s)){let S=Xe(C,{fontFamily:d,lineHeight:vS(d)}),L=r?.get(C.containerId||"")||{},k=n.scene.getContainerElement(C);return a&&k&&L&&n.scene.mutateElement(k,{...L}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,k),S}return C},!0)});let y=`10px ${yS({fontFamily:d})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of f)aa(C,S,n.scene);else window.document.fonts.load(y,v).then(C=>{for(let[S,L]of f){let k=n.scene.getElement(S.id),A=L?n.scene.getElement(L.id):null;k&&aa(k,A,n.scene)}n.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=dp(new Map),i=dp(null),[a,l]=mS({}),s=dp(!0),m=dS(()=>{let c=(d,p)=>xt(d,t,u=>{if(bt(u))return u.fontFamily;let f=on(u,p);return f?f.fontFamily:null},u=>bt(u)||on(u,p)!==null,u=>u?null:o.currentItemFontFamily||fS);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?c(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&o.openPopup!=="fontFamily"?c(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return cp(()=>{i.current=m},[m]),cp(()=>{Object.keys(a).length&&(n(a),l({}))},[a]),cp(()=>(s.current=!1,()=>{s.current=!0}),[]),Et("fieldset",{children:[Q("legend",{children:g("labels.fontFamily")}),Q(zb,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:c=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:c}),r.current.clear()},onHover:c=>{l({currentHoveredFontFamily:c,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:c=>{if(c){r.current.clear();let{editingTextElement:d}=o;if(d?.type==="text"){let p=t.scene.getElement(d.id);r.current.set(d.id,Xe(p||d,{},!0))}else{let p=j(e,o,{includeBoundTextElement:!0});for(let u of p)r.current.set(u.id,Xe(u,{},!0))}l({openPopup:"fontFamily"})}else{let d={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s.current?n({...a,...d}):l(d),r.current.clear()}}})]})}}),GS=B({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:mt(e,o,r=>{if(bt(r)){let i=Xe(r,{textAlign:t});return aa(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=n.scene.getNonDeletedElementsMap();return Et("fieldset",{children:[Q("legend",{children:g("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:x0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:E0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:y0,testId:"align-right"}],value:xt(e,n,i=>{if(bt(i))return i.textAlign;let a=on(i,r);return a?a.textAlign:null},i=>bt(i)||on(i,r)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})})]})}}),US=B({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:mt(e,o,r=>{if(bt(r)){let i=Xe(r,{verticalAlign:t});return aa(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Ft,{group:"text-align",options:[{value:vs.TOP,text:g("labels.alignTop"),icon:Q(w0,{theme:o.theme}),testId:"align-top"},{value:vs.MIDDLE,text:g("labels.centerVertically"),icon:Q(T0,{theme:o.theme}),testId:"align-middle"},{value:vs.BOTTOM,text:g("labels.alignBottom"),icon:Q(v0,{theme:o.theme}),testId:"align-bottom"}],value:xt(e,n,r=>{if(bt(r)&&r.containerId)return r.verticalAlign;let i=on(r,n.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},r=>bt(r)||on(r,n.scene.getNonDeletedElementsMap())!==null,r=>r?null:vs.MIDDLE),onChange:r=>t(r)})})})}),SZ=B({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:mt(e,o,n=>jb(n)?n:Xe(n,{roundness:t==="round"?{type:MS(n.type)?Ts.ADAPTIVE_RADIUS:Ts.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=fl($b(e),o).some(l=>l.roundness?.type===Ts.LEGACY);return Et("fieldset",{children:[Q("legend",{children:g("labels.edges")}),Et("div",{className:"buttonList",children:[Q(Ft,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:Q1},{value:"round",text:g("labels.round"),icon:e0}],value:xt(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!Is(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),Zb=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:t0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(o0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:Q(a0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:Q(l0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:Q(n0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(r0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:Q(s0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:Q(c0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:Q(i0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:Q(m0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:Q(d0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:Q(p0,{flip:e}),keyBinding:"v"}],kZ=B({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:mt(e,o,n=>{if(up(n)){let{position:r,type:i}=t;if(r==="start")return Xe(n,{startArrowhead:i});if(r==="end")return Xe(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=Io().rtl;return Et("fieldset",{children:[Q("legend",{children:g("labels.arrowheads")}),Et("div",{className:"iconSelectList buttonList",children:[Q(lp,{label:"arrowhead_start",options:Zb(!r),value:xt(e,n,i=>up(i)&&lr(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),Q(lp,{label:"arrowhead_end",group:"arrowheads",options:Zb(!!r),value:xt(e,n,i=>up(i)&&lr(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),MZ=B({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=mt(e,o,l=>{if(!Is(l))return l;let s=Xe(l,{roundness:t===So.round?{type:Ts.PROPORTIONAL_RADIUS}:null,elbowed:t===So.elbow,points:t===So.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(jb(s)){s.fixedSegments=null;let m=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let c=pp.getPointAtIndexGlobalCoordinates(s,0,m),d=pp.getPointAtIndexGlobalCoordinates(s,-1,m),p=s.startBinding&&m.get(s.startBinding.elementId),u=s.endBinding&&m.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...Xb(s,p,"start",m)}:null,b=u&&s.endBinding?{...s.endBinding,...Xb(s,u,"end",m)}:null;s={...s,startBinding:f,endBinding:b,...PS(s,m,{points:[c,d].map(x=>cS(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let m=n.scene.getNonDeletedElementsMap();if(s.startBinding){let c=m.get(s.startBinding.elementId);c&&Vb(s,c,"start",n.scene)}if(s.endBinding){let c=m.get(s.endBinding.elementId);c&&Vb(s,c,"end",n.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new pp(l,hp(e)))}return{elements:r,appState:i,captureUpdate:Ke.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Et("fieldset",{children:[Q("legend",{children:g("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"arrowtypes",options:[{value:So.sharp,text:g("labels.arrowtype_sharp"),icon:$l,testId:"sharp-arrow"},{value:So.round,text:g("labels.arrowtype_round"),icon:ql,testId:"round-arrow"},{value:So.elbow,text:g("labels.arrowtype_elbowed"),icon:jl,testId:"elbow-arrow"}],value:xt(e,n,r=>Is(r)?r.elbowed?So.elbow:r.roundness?So.round:So.sharp:null,r=>Is(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as vp,roundToStep as $S}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as jS,CURSOR_TYPE as nx,MAX_ZOOM as rx,MIN_ZOOM as ix,THEME as la,ZOOM_STEP as Tp,getShortcutKey as ax,updateActiveTool as Or,CODES as ho,KEYS as Mo}from"@excalidraw/common";import{getNonDeletedElements as qS}from"@excalidraw/element";import{newElementWith as JS}from"@excalidraw/element";import{getCommonBounds as QS}from"@excalidraw/element";import{CaptureUpdateAction as Jt}from"@excalidraw/element";import{useEffect as YS}from"react";import{jsx as VS}from"react/jsx-runtime";var Fr=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},xp=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-n.width/2;l<0?l=a:l+n.width>=r&&(l=r-n.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+n.height>=i&&(s=o.top-n.height-a)):(s=o.top-n.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},WS=(e,o,t,n)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();xp(o,r)},Lt=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(YS(()=>()=>Fr().classList.remove("excalidraw-tooltip--visible"),[]),r?null:VS("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>WS(i.currentTarget,Fr(),o,t),onPointerLeave:()=>Fr().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import Cs from"open-color";import{CURSOR_TYPE as Ep,MIME_TYPES as yp,THEME as ex}from"@excalidraw/common";var tx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',XS='<path d="M6.164 11.755a5.314 5.314 0 0 1-4.932-5.298 5.314 5.314 0 0 1 5.311-5.311 5.314 5.314 0 0 1 5.307 5.113l8.773 8.773a3.322 3.322 0 0 1 0 4.696l-.895.895a3.322 3.322 0 0 1-4.696 0l-8.868-8.868Z" style="fill:#fff"/>',ox='<path stroke="#1b1b1f" fill="#fff" d="m7.868 11.113 7.773 7.774a2.359 2.359 0 0 0 1.667.691 2.368 2.368 0 0 0 2.357-2.358c0-.625-.248-1.225-.69-1.667L11.201 7.78 9.558 9.469l-1.69 1.643v.001Zm10.273 3.606-3.333 3.333m-3.25-6.583 2 2m-7-7 3 3M3.664 3.625l1 1M2.529 6.922l1.407-.144m5.735-2.932-1.118.866M4.285 9.823l.758-1.194m1.863-6.207-.13 1.408"/>',KS=`data:${yp.svg},${encodeURIComponent(`${tx}${ox}</svg>`)}`,ZS=`data:${yp.svg},${encodeURIComponent(`${tx}${XS}${ox}</svg>`)}`,zt=e=>{e&&(e.style.cursor="")},xe=(e,o)=>{e&&(e.style.cursor=o)},uo,Qb,wp=(e,o)=>{let n=()=>{let r=o===ex.DARK;uo=document.createElement("canvas"),uo.theme=o,uo.height=20,uo.width=20;let i=uo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(uo.width/2,uo.height/2,5,0,2*Math.PI),i.fillStyle=r?Cs.black:Cs.white,i.fill(),i.strokeStyle=r?Cs.white:Cs.black,i.stroke(),Qb=uo.toDataURL(yp.svg)};(!uo||uo.theme!==o)&&n(),xe(e,`url(${Qb}) ${20/2} ${20/2}, auto`)},Pt=(e,o)=>{if(e)if(o.activeTool.type==="selection")zt(e);else if($t(o))e.style.cursor=Ep.GRAB;else if(ft(o))wp(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===ex.LIGHT?KS:ZS;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Ep.AUTO):e.style.cursor=Ep.CROSSHAIR};var ko=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,a=n.zoom.value,l=n.scrollX+(r-r/a),s=n.scrollY+(i-i/a),m=-(r-r/t),c=-(i-i/t);return{scrollX:l+m,scrollY:s+c,zoom:{value:t}}};import{jsx as Ls,jsxs as n4}from"react/jsx-runtime";var e4=B({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?Jt.IMMEDIATELY:Jt.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n})=>Ls(ea,{palette:null,topPicks:jS,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:r=>t({viewBackgroundColor:r}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),Lo=B({name:"clearCanvas",label:"labels.clearCanvas",icon:kt,trackEvent:{category:"canvas"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,n)=>(n.imageCache.clear(),{elements:e.map(r=>JS(r,{isDeleted:!0})),appState:{...Xo(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:n.defaultSelectionTool}:o.activeTool},captureUpdate:Jt.IMMEDIATELY})}),Ss=B({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:cm,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...ko({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:lo(o.zoom.value+Tp)},o),userToFollow:null},captureUpdate:Jt.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Ls(K,{type:"button",className:"zoom-in-button zoom-button",icon:cm,title:`${g("buttons.zoomIn")} \u2014 ${ax("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=rx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===ho.EQUAL||e.code===ho.NUM_ADD)&&(e[Mo.CTRL_OR_CMD]||e.shiftKey)}),ks=B({name:"zoomOut",label:"buttons.zoomOut",icon:dm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...ko({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:lo(o.zoom.value-Tp)},o),userToFollow:null},captureUpdate:Jt.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Ls(K,{type:"button",className:"zoom-out-button zoom-button",icon:dm,title:`${g("buttons.zoomOut")} \u2014 ${ax("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=ix,onClick:()=>{e(null)}}),keyTest:e=>(e.code===ho.MINUS||e.code===ho.NUM_SUBTRACT)&&(e[Mo.CTRL_OR_CMD]||e.shiftKey)}),Ms=B({name:"resetZoom",label:"buttons.resetZoom",icon:C1,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...ko({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:lo(1)},o),userToFollow:null},captureUpdate:Jt.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Ls(Lt,{label:g("buttons.resetZoom"),style:{height:"100%"},children:n4(K,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===ho.ZERO||e.code===ho.NUM_ZERO)&&(e[Mo.CTRL_OR_CMD]||e.shiftKey)}),t4=(e,o,t=1)=>{let[n,r,i,a]=e,l=i-n,s=o.width/l,m=a-r,c=o.height/m,p=Math.min(s,c)*vp(t,.1,1);return Math.min(p,1)},lx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=vp(r,ix,rx);let[l,s,m,c]=e,d=(l+m)/2,p=(s+c)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,w=o.width-u-b,E=o.height-f-x,y;if(n){let S=m-l,L=c-s;y=Math.min(w/S,E/L)*r}else y=t4(e,{width:w,height:E},r);let v=lo(vp($S(y,Tp,"floor"),i,a)),C=Ff({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:Jt.EVENTUALLY}},sa=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=QS(qS(o));return lx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},d$=B({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Zl,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return sa({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===ho.TWO&&e.shiftKey&&!e.altKey&&!e[Mo.CTRL_OR_CMD]}),m$=B({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Zl,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return sa({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===ho.THREE&&e.shiftKey&&!e.altKey&&!e[Mo.CTRL_OR_CMD]}),o4=B({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Zl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>sa({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===ho.ONE&&e.shiftKey&&!e.altKey&&!e[Mo.CTRL_OR_CMD]}),Hn=B({name:"toggleTheme",label:(e,o)=>o.theme===la.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===la.LIGHT?Ui:Yi,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===la.LIGHT?la.DARK:la.LIGHT)},captureUpdate:Jt.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===ho.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),p$=B({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return ft(o)?r=Or(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):r=Or(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Jt.IMMEDIATELY}},keyTest:e=>e.key===Mo.E}),u$=B({name:"toggleLassoTool",label:"toolBar.lasso",icon:Hi,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.defaultSelectionTool!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=Or(o,{type:"lasso",fromSelection:!1}),xe(n.interactiveCanvas,nx.CROSSHAIR)):r=Or(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Jt.NEVER}}}),sx=B({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Vl,viewMode:!1,perform:(e,o,t,n)=>{let r;return $t(o)?r=Or(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=Or(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),xe(n.interactiveCanvas,nx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Jt.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Mo.CTRL_OR_CMD]&&e.key===Mo.H});import{updateActiveTool as cx}from"@excalidraw/common";import{CaptureUpdateAction as r4}from"@excalidraw/element";var i4=B({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=cx(o,{type:"embeddable"});return Pt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:cx(o,{type:"embeddable"})},captureUpdate:r4.EVENTUALLY}}});import{pointFrom as a4}from"@excalidraw/math";import{maybeBindLinearElement as l4,bindOrUnbindLinearElement as dx,isBindingEnabled as s4}from"@excalidraw/element/binding";import{isValidPolygon as mx,LinearElementEditor as ca,newElementWith as Ip}from"@excalidraw/element";import{isBindingElement as Ps,isFreeDrawElement as px,isLinearElement as ux,isLineElement as As}from"@excalidraw/element";import{KEYS as Cp,arrayToMap as Sp,tupleToCoors as c4,updateActiveTool as hx}from"@excalidraw/common";import{isPathALoop as d4}from"@excalidraw/element";import{isInvisiblySmallElement as kp}from"@excalidraw/element";import{CaptureUpdateAction as Mp}from"@excalidraw/element";import{jsx as m4}from"react/jsx-runtime";var At=B({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let{interactiveCanvas:r,focusContainer:i,scene:a}=n,{event:l,sceneCoords:s}=t??{},m=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=ca.handlePointerUp(l,o.selectedLinearElement,o,n.scene),{startBindingElement:f,endBindingElement:b}=u,x=n.scene.getElement(u.elementId);if(Ps(x)&&dx(x,f,b,n.scene),u!==o.selectedLinearElement){let w=e;return x&&kp(x)&&(w=w.map(E=>E.id===x.id?Ip(E,{isDeleted:!0}):E)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:Mp.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=ca.getElement(u,m);if(x)return Ps(x)&&dx(x,f,b,a),As(x)&&!mx(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||kp(x)?e.map(w=>w.id===x.id?Ip(w,{isDeleted:!0}):w):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new ca(x,Sp(m),!1)},captureUpdate:Mp.IMMEDIATELY}}let c=e;window.document.activeElement instanceof HTMLElement&&i();let d=null;if(o.multiElement)d=o.multiElement;else if(o.newElement?.type==="freedraw"||Ps(o.newElement))d=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=m.get(Object.keys(o.selectedElementIds)[0]);u&&(d=u)}if(d){if(o.multiElement&&d.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=d;(!f||u[u.length-1]!==f)&&a.mutateElement(d,{points:d.points.slice(0,-1)})}if(d&&kp(d)&&(c=c.map(u=>u.id===d?.id?Ip(u,{isDeleted:!0}):u)),ux(d)||px(d)){let u=d4(d.points,o.zoom.value);if(u&&(As(d)||px(d))){let f=d.points,b=f[0],x=f.map((w,E)=>E===f.length-1?a4(b[0],b[1]):w);As(d)?a.mutateElement(d,{points:x,polygon:!0}):a.mutateElement(d,{points:x})}if(As(d)&&!mx(d.points)&&a.mutateElement(d,{polygon:!1}),Ps(d)&&!u&&d.points.length>1&&s4(o)){let f=s??c4(ca.getPointAtIndexGlobalCoordinates(d,-1,Sp(e)));l4(d,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!d)&&zt(r);let p;return o.activeTool.type==="eraser"?p=hx(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):p=hx(o,{type:n.defaultSelectionTool}),{elements:c,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&d?o.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[d.id]:!0}:o.selectedElementIds,selectedLinearElement:d&&ux(d)?new ca(d,Sp(c)):o.selectedLinearElement},captureUpdate:Mp.IMMEDIATELY}},keyTest:(e,o)=>e.key===Cp.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===Cp.ESCAPE||e.key===Cp.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>m4(K,{type:"button",icon:N1,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as zr,DEFAULT_EXPORT_PADDING as k4,EXPORT_SCALES as M4,THEME as Lp}from"@excalidraw/common";import{getNonDeletedElements as L4}from"@excalidraw/element";import{CaptureUpdateAction as Qt}from"@excalidraw/element";import p4 from"clsx";import{jsx as gx,jsxs as u4}from"react/jsx-runtime";var da=({children:e,checked:o,onChange:t,className:n})=>u4("div",{className:p4("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[gx("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:L1}),gx("div",{className:"Checkbox-label",children:e})]});import{THEME as ma}from"@excalidraw/common";import{jsx as pa}from"react/jsx-runtime";var bx=e=>{let o=e.title||(e.value===ma.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return pa(K,{type:"icon",icon:e.value===ma.LIGHT?fx.MOON:fx.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===ma.DARK?ma.LIGHT:ma.DARK),"data-testid":"toggle-dark-mode"})},fx={SUN:pa("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:pa("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:pa("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:pa("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"})})};import{useState as h4}from"react";import{focusNearestParent as g4,KEYS as f4}from"@excalidraw/common";import{jsx as xx,jsxs as b4}from"react/jsx-runtime";var Ex=e=>{let{id:o}=He(),[t,n]=h4(e.value),r=a=>{e.ignoreFocus||g4(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===f4.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return b4("div",{className:"ProjectName",children:[xx("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),xx("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as x4,DEFAULT_FILENAME as E4,IMAGE_MIME_TYPES as yx,isFirefox as y4,MIME_TYPES as w4,cloneJSON as v4,SVG_DOCUMENT_PREAMBLE as T4}from"@excalidraw/common";import{getNonDeletedElements as I4}from"@excalidraw/element";import{isFrameLikeElement as C4}from"@excalidraw/element";import{getElementsOverlappingFrame as S4}from"@excalidraw/element";var Gn=(e,{selectedElementIds:o},t)=>{e=I4(e);let n=t&&Ee(e,{selectedElementIds:o}),r=null,i=n?j(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return n&&(i.length===1&&C4(i[0])?(r=i[0],i=S4(e,r)):i.length>1&&(i=j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:r,exportedElements:v4(i)}},Un=async(e,o,t,n,{exportBackground:r,exportPadding:i=x4,viewBackgroundColor:a,name:l=t.name||E4,fileHandle:s=null,exportingFrame:m=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let d=dr(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:m});if(e==="svg")return qd(d.then(p=>new Blob([T4+p.outerHTML],{type:w4.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[yx.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await d.then(u=>u.outerHTML);try{await so(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let c=vl(o,t,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:m});if(e==="png"){let d=To(c);return t.exportEmbedScene&&(d=d.then(p=>import("./data/image-I65E4LM3.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Bi(o,t,n,"local")})))),qd(d,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[yx.png],fileHandle:s})}else if(e==="clipboard")try{let d=To(c);await Ll(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):y4&&d.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
1
+ import{$ as f1,A as gm,B as n1,C as i1,D as a1,E as Al,F as Vi,G as Dl,H as _l,I as l1,J as s1,K as Xi,L as c1,M as d1,N as m1,O as p1,P as Rl,Q as bn,R as u1,S as QI,T as fm,U as eC,V as xn,W as Ki,Y as h1,_ as g1,a as e1,aa as Nl,b as Fr,ba as b1,c as uo,ca as bm,d as t1,da as xm,e as Ee,ea as Bl,f as o1,fa as x1,g as j,ga as Em,h as Ml,ha as ko,i as $o,ia as E1,j as cm,ja as ym,k as dm,ka as y1,l as hn,la as w1,m as mm,ma as Fl,n as gn,na as wm,o as r1,oa as v1,p as pm,pa as T1,q as jo,qa as I1,r as qo,ra as Ol,s as bt,t as qt,u as fn,v as Ll,w as um,x as Wi,y as Pl,z as hm}from"./chunk-VTWWEYSQ.js";import{a as T}from"./chunk-A66AFZZU.js";import{J as sm}from"./chunk-I4UNSFV6.js";import{c as Qf}from"./chunk-Z3N5DIM6.js";import{b as qf,c as Jf,d as I}from"./chunk-SRAX5OIU.js";import XG,{useEffect as KG}from"react";import{DEFAULT_UI_OPTIONS as $I,isShallowEqual as ZG}from"@excalidraw/common";import M5 from"clsx";import Sz from"lodash.throttle";import So,{useContext as Nr}from"react";import{flushSync as Fi}from"react-dom";import kz from"roughjs/bin/rough";import{nanoid as Mz}from"nanoid";import{clamp as L5,pointFrom as ne,pointDistance as Pr,vector as P5,pointRotateRads as tf,vectorScale as Lz,vectorFromPoint as of,vectorSubtract as A5,vectorDot as D5,vectorNormalize as _5}from"@excalidraw/math";import{COLOR_PALETTE as Pz,CODES as R5,shouldResizeFromCenter as N5,shouldMaintainAspectRatio as ml,shouldRotateWithDiscreteAngle as rf,isArrowKey as Zd,KEYS as Y,APP_NAME as Az,CURSOR_TYPE as De,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as Dz,DEFAULT_VERTICAL_ALIGN as B5,DRAGGING_THRESHOLD as _z,ELEMENT_SHIFT_TRANSLATE_AMOUNT as Rz,ELEMENT_TRANSLATE_AMOUNT as F5,EVENT as ee,FRAME_STYLE as Ar,IMAGE_MIME_TYPES as Nz,IMAGE_RENDER_TIMEOUT as Bz,isBrave as Fz,LINE_CONFIRM_THRESHOLD as nf,MAX_ALLOWED_FILE_BYTES as O5,MIME_TYPES as Vo,MQ_MAX_HEIGHT_LANDSCAPE as Oz,MQ_MAX_WIDTH_LANDSCAPE as zz,MQ_MAX_WIDTH_PORTRAIT as Hz,MQ_RIGHT_SIDEBAR_MIN_WIDTH as Gz,POINTER_BUTTON as ln,ROUNDNESS as $d,SCROLL_TIMEOUT as Uz,TAP_TWICE_TIMEOUT as Yz,TEXT_TO_CENTER_SNAP_THRESHOLD as Wz,THEME as jd,THEME_FILTER as Vz,TOUCH_CTX_MENU_TIMEOUT as Xz,VERTICAL_ALIGN as Kz,YOUTUBE_STATES as qd,ZOOM_STEP as Zz,POINTER_EVENTS as Oi,TOOL_TYPE as Co,isIOS as $z,supportsResizeObserver as z5,DEFAULT_COLLISION_THRESHOLD as H5,DEFAULT_TEXT_ALIGN as jz,ARROW_TYPE as Dr,DEFAULT_REDUCED_GLOBAL_ALPHA as qz,isSafari as Jz,isLocalLink as Qz,normalizeLink as af,toValidURL as eH,getGridPoint as nt,getLineHeight as G5,debounce as U5,distance as zi,getFontString as lf,getNearestScrollableContainer as tH,isInputLike as Y5,isToolIcon as oH,isWritableElement as pl,sceneCoordsToViewportCoords as Jd,tupleToCoors as sf,viewportCoordsToSceneCoords as Oe,wrapEvent as rH,updateObject as cf,updateActiveTool as Xo,getShortcutKey as nH,isTransparent as iH,easeToValuesRAF as aH,muteFSAbortError as lH,isTestEnv as Df,isDevEnv as kI,easeOut as sH,updateStable as ul,addEventListener as _e,normalizeEOL as cH,getDateTime as W5,isShallowEqual as dH,arrayToMap as Qd,randomInteger as mH,CLASSES as pH,Emitter as sn,isMobile as uH,MINIMUM_ARROW_SIZE as V5,DOUBLE_TAP_POSITION_THRESHOLD as hH}from"@excalidraw/common";import{getObservedAppState as gH,getCommonBounds as Hi,maybeSuggestBindingsForLinearElementAtCoords as X5,getElementAbsoluteCoords as K5,bindOrUnbindLinearElements as Z5,fixBindingsAfterDeletion as fH,getHoveredElementForBinding as df,isBindingEnabled as mf,shouldEnableBindingForPointerEvent as bH,updateBoundElements as pf,getSuggestedBindingsForArrows as uf,LinearElementEditor as Se,newElementWith as _r,newFrameElement as xH,newFreeDrawElement as EH,newEmbeddableElement as $5,newMagicFrameElement as j5,newIframeElement as yH,newArrowElement as wH,newElement as vH,newImageElement as TH,newLinearElement as IH,newTextElement as q5,refreshTextDimensions as CH,deepCopyElement as J5,duplicateElements as Q5,hasBoundTextElement as eI,isArrowElement as hf,isBindingElement as gf,isBindingElementType as tI,isBoundToContainer as ff,isFrameLikeElement as kt,isImageElement as cn,isEmbeddableElement as Ko,isInitializedImageElement as hl,isLinearElement as Zt,isLinearElementType as SH,isUsingAdaptiveRadius as kH,isIframeElement as Gi,isIframeLikeElement as gl,isMagicFrameElement as bf,isTextBindableContainer as oI,isElbowArrow as We,isFlowchartNodeElement as MH,isBindableElement as LH,isTextElement as mo,getLockedLinearCursorAlignSize as rI,getNormalizedDimensions as PH,isElementCompletelyInViewport as xf,isElementInViewport as nI,isInvisiblySmallElement as iI,getCornerRadius as AH,isPathALoop as aI,createSrcDoc as lI,embeddableURLValidator as Ef,maybeParseEmbedSrc as DH,getEmbedLink as em,getInitializedImageElements as _H,normalizeSVG as sI,updateImageCache as RH,getBoundTextElement as yf,getContainerCenter as wf,getContainerElement as cI,isValidTextContainer as NH,redrawTextBoundingBox as BH,shouldShowBoundingBox as FH,getFrameChildren as vf,isCursorInFrame as dI,addElementsToFrame as Tf,replaceAllElementsInFrame as OH,removeElementsFromFrame as zH,getElementsInResizingFrame as If,getElementsInNewFrame as HH,getContainingFrame as Cf,elementOverlapsWithFrame as GH,updateFrameMembershipOfSelectedElements as mI,isElementInFrame as pI,getFrameLikeTitle as UH,getElementsOverlappingFrame as YH,filterElementsEligibleAsFrameChildren as WH,hitElementBoundText as VH,hitElementBoundingBoxOnly as XH,hitElementItself as fl,getVisibleSceneBounds as KH,FlowChartCreator as ZH,FlowChartNavigator as $H,getLinkDirectionFromKey as uI,cropElement as jH,wrapText as qH,isElementLink as Sf,parseElementLinkFromURL as JH,isMeasureTextSupported as QH,normalizeText as eG,measureText as hI,getLineHeightInPx as tG,getApproxMinLineWidth as oG,getApproxMinLineHeight as rG,getMinTextElementWidth as nG,ShapeCache as bl,getRenderOpacity as iG,editGroupForSelectedElement as aG,getElementsInGroup as dn,getSelectedGroupIdForElement as lG,getSelectedGroupIds as sG,isElementInGroup as gI,isSelectedViaGroup as cG,selectGroupsForSelectedElements as $t,syncInvalidIndices as MI,syncMovedIndices as fI,excludeElementsInFramesFromSelection as dG,getSelectionStateForElements as mG,makeNextSelectedElementIds as ye,getResizeOffsetXY as pG,getResizeArrowDirection as uG,transformElements as hG,getCursorForResizingElement as bI,getElementWithTransformHandleType as xI,getTransformHandleTypeFromCoords as EI,dragNewElement as yI,dragSelectedElements as gG,getDragOffsetXY as fG,isNonDeletedElement as wI,Scene as vI,Store as bG,CaptureUpdateAction as ft,hitElementBoundingBox as xG,isLineElement as kf,isSimpleArrow as EG,StoreDelta as TI,positionElementsOnGrid as II}from"@excalidraw/element";import{KEYS as Zm,updateActiveTool as hC}from"@excalidraw/common";import{getNonDeletedElements as $m}from"@excalidraw/element";import{fixBindingsAfterDeletion as gC}from"@excalidraw/element";import{LinearElementEditor as fb}from"@excalidraw/element";import{newElementWith as ps}from"@excalidraw/element";import{getContainerElement as bb}from"@excalidraw/element";import{isBoundToContainer as ds,isElbowArrow as fC,isFrameLikeElement as bC}from"@excalidraw/element";import{getFrameChildren as xC}from"@excalidraw/element";import{getElementsInGroup as jm,selectGroupsForSelectedElements as EC}from"@excalidraw/element";import{CaptureUpdateAction as ms}from"@excalidraw/element";import{isDevEnv as nC}from"@excalidraw/common";import{atom as me,createStore as tC}from"jotai";import{createIsolation as oC}from"jotai-scope";var C1=oC();var{useAtom:ie,useSetAtom:Jo,useAtomValue:zl,useStore:eU}=C1,S1=C1.Provider,He=tC();var rC=qf({"./locales/ar-SA.json":()=>import("./locales/ar-SA-G6X2FPQ2.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-76LH7QW2.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-XCXSNQG7.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-2XOGV67Q.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-6MX7JW3Y.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-2BRQDIVT.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5WZEPLOC.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-XR44H4JA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-BZB4AONW.js"),"./locales/en.json":()=>import("./locales/en-TYY6KWIJ.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-U4NZUMDT.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-A7QVB2H4.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-HGAKTJCU.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-Z5N7JZ37.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-RHASNOE6.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-HMX3MZ6V.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-6SHJWFNN.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-IWLTKZ5I.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-A5ZG7DT2.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-SAP4L64H.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-JPQ66NNP.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-DBVTYXUO.js"),"./locales/kaa.json":()=>import("./locales/kaa-6HZHGXH3.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-ZGHBKWFO.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5N5QNE5.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-HSX4SM5Z.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-MTYHY66A.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-6OUDTVRD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-XHIRWOB4.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-5QDEKY6T.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-CRQNXWMA.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5M5IBNSE.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-T6EIAALU.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-IS3SIHDZ.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-6E72VCQL.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-POXYY2M6.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-N4M65BXN.js"),"./locales/percentages.json":()=>import("./locales/percentages-BXMCSKIN.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-T2D74RX3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5N22H2LF.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-UZXXM6DQ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-JPDTUUEW.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-B4JR7IUQ.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-N5RQ5JYF.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-C5VTKIMK.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-NN7IZMDC.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XGPEYMSR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-2NMHFXQM.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HPSO5L25.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-DEFEU3FU.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-QMV73CPH.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-M7AON7JQ.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-LNUGB5OW.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var iC=85,ho={code:"en",label:"English"},yn=[ho,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>Qf[e.code]>=iC).sort((e,o)=>e.label>o.label?1:-1)],Gl="__test__";nC()&&yn.unshift({code:Gl,label:"test language"},{code:`${Gl}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var En=ho,Hl={},Ul=async e=>{if(En=e,document.documentElement.dir=En.rtl?"rtl":"ltr",document.documentElement.lang=En.code,e.code.startsWith(Gl))Hl={};else try{Hl=await rC(`./locales/${En.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Hl=sm}He.set(M1,e.code)},Mo=()=>En,k1=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},g=(e,o,t)=>{if(En.code.startsWith(Gl))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=k1(Hl,r)||k1(sm,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},M1=me(ho.code),ze=()=>{let e=zl(M1);return{t:g,langCode:e}};import aC from"clsx";import lC from"open-color";import et from"react";import{THEME as sC}from"@excalidraw/common";import{Fragment as be,jsx as h,jsxs as D}from"react/jsx-runtime";var Jt=e=>"var(--icon-fill-color)",L1=e=>e===sC.LIGHT?lC.white:"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:aC({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},z={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},te={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},fU=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),z),wn=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),h("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),h("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),z),P1=M(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),z),A1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),z),D1=M(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),z),vm=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),z),Or=M(D("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),te),vn=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),te),_1=M(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),R1=M(D(be,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),N1=M(D(be,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),B1=M(D(be,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),bU=M(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),Tm=M(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Zi=M(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Yl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),z),Wl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),z),Vl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),z),F1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),z),Xl=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),te),O1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),z),Qo=M(D("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),te),Tn=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),z),z1=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),te),H1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),z),Im=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),te),Cm=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),te),G1=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),z),Mt=M(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),te),Sm=M(D("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),te),$i=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),te),ji=M(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),te),qi=M(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...te,strokeWidth:1.5}),Kl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),z),zr=M(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),te),In=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),U1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),km=M(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),te),Zl=M(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),te),Y1=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),te),W1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),z),V1=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ji=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),te),X1=M("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),K1=M("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Cn=M(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),te),xU=M("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),Z1=M("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),$l=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),h("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),h("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),z),$1=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),z),jl=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),z),j1=M("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),EU=M("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),yU=M("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),q1=M("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),wU=M("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Mm=M(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),te),Lm=M(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),te),J1=M("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),Q1=M(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),te),vU=M("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),TU=M("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),IU=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),z),CU=M(D(be,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),SU=M(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),e0=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),t0=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Pm=M(t0,z),Am=M(t0,{...z,style:{transform:"rotate(180deg)"}}),Dm=M(e0,z),_m=M(e0,{...z,style:{transform:"rotate(180deg)"}}),Rm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Nm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Bm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Fm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),o0=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),r0=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Om=M(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),te),zm=M(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),te),ql=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),z),kU=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),MU=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Ft=M(D(be,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),LU=M("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),PU=M("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),AU=M("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Hm=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:Jt(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Jt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Jt(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Jt(e),strokeWidth:"2"}),D("g",{fill:L1(e),stroke:Jt(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Gm=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:Jt(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Jt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Jt(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Jt(e),strokeWidth:"2"}),D("g",{fill:L1(e),stroke:Jt(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),n0=M(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),te),i0=M(D(be,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),te),a0=M(D(be,{children:[D("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),l0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...te,fill:"currentColor"}),Um=M(h(be,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),te),s0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),te),c0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),te),DU=et.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:Jt(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),d0=M(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),z),m0=M(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),z),p0=M(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),te),u0=M(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),te),h0=M(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),te),g0=M(D("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),te),f0=M(D("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),z),b0=M(D("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[h("path",{d:"M12 12l9 0"}),h("path",{d:"M3 9l6 6"}),h("path",{d:"M3 15l6 -6"})]}),z),x0=et.memo(({flip:e=!1})=>M(D("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[h("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),h("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),E0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),y0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M26 10L6 10"}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),w0=et.memo(({flip:e=!1})=>M(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:h("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),v0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),T0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[h("path",{d:"M6,9.5H27"}),h("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),I0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),C0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),S0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),k0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),M0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),L0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),P0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),A0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),D0=M(h(be,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),te),Hr=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),z),_0=M(h(be,{children:D("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),z),Qi=M(h(be,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),te),Jl=M(D(be,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),R0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),z),N0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),z),B0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),z),F0=et.memo(({theme:e})=>M(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),z)),O0=et.memo(({theme:e})=>M(D("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),z)),z0=et.memo(({theme:e})=>M(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),z)),Ql=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),z),H0=M(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),_U=M(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),es=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),z),Ym=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),z),Sn=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),z),G0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),z),U0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),RU=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),z),NU=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),z),Y0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),z),W0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),z),V0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l6 6"}),h("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),z),X0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l-4 7h8z"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),z),Gr=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),z),ts=M(h("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),kn=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),te),ea=M(D("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),h("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),os=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),BU=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),FU=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),z),K0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),z),Mn=M(D("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),z),Z0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),z),$0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),j0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),Lt=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),z),q0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),z),J0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),z),Q0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),z),ta=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),z),eb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),z),tb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),z),ob=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),z),rb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),z),Wm=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),z),rs=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),z),nb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),z),ib=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),z),ab=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),z),lb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),z),sb=M(D("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...z,strokeWidth:1.5}),OU=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),z),cb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),z),db=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),z),mb=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),z),ns=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),z),is=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),z),as=M(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),ls=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),z),pb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),ub=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),Vm=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),z),ss=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),z);import hb from"clsx";import Km,{useEffect as mC,useRef as gb,useState as pC}from"react";import{isPromiseLike as uC}from"@excalidraw/common";import cC from"react";import{jsx as Xm}from"react/jsx-runtime";var dC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(cC.useRef(Date.now()).current%1600);return Xm("div",{className:`Spinner ${r}`,children:Xm("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Xm("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},tt=dC;import{jsx as oa,jsxs as ra}from"react/jsx-runtime";var K=Km.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=Ge(),a=Km.useRef(null);Km.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,m]=pC(!1),c=gb(!0),d=async u=>{let f="onClick"in r&&r.onClick?.(u);if(uC(f))try{m(!0),await f}catch(b){if(b instanceof gn)console.warn(b);else throw b}finally{c.current&&m(!1)}};mC(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=gb(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return ra("button",{className:hb("ToolIcon_type_button",l,t,o&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"ToolIcon--plain":r.type==="icon"}),style:r.style,"data-testid":r["data-testid"],hidden:r.hidden,title:r.title,"aria-label":r["aria-label"],type:u,onClick:d,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&ra("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&oa("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&oa(tt,{})]}),r.showAriaLabel&&ra("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&oa(tt,{})]}),r.children]})}return ra("label",{className:hb("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[oa("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:r.name,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"data-testid":r["data-testid"],id:`${i}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:p.current})},checked:r.checked,ref:a}),ra("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&oa("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});K.displayName="ToolButton";var cs=[],B=e=>(cs=cs.concat(e),e);import{jsx as wC}from"react/jsx-runtime";var yC=(e,o,t)=>{let r=new Set(j(e.filter(c=>bC(c)),o).map(c=>c.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let c of r){let d=xC(e,c);for(let p of d)if(!a.has(p.id)){if(ds(p)){let u=bb(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(c=>{if(o.selectedElementIds[c.id]){let d=ds(c)?bb(c,i):null;return c.frameId&&r.has(c.frameId)?(l=!1,n[c.id]=!0,c):d?.frameId&&r.has(d?.frameId)?c:(c.boundElements&&c.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&fC(u)&&t.scene.mutateElement(u,{startBinding:c.id===u.startBinding?.elementId?null:u.startBinding,endBinding:c.id===u.endBinding?.elementId?null:u.endBinding})}),ps(c,{isDeleted:!0}))}return c.frameId&&r.has(c.frameId)?(l=!1,ds(c)||(n[c.id]=!0),ps(c,{frameId:null})):ds(c)&&o.selectedElementIds[c.containerId]?ps(c,{isDeleted:!0}):c}),m=o.editingGroupId;if(l&&o.editingGroupId){let c=jm(s,o.editingGroupId).filter(d=>!d.isDeleted);if(c.length>1)c[0]&&(n[c[0].id]=!0);else{m=null,c[0]&&(n[c[0].id]=!0);let d=c[0];if(d){let p=d.groupIds.findIndex(f=>f===o.editingGroupId),u=d.groupIds[p+1];if(u){let f=jm(s,u).filter(b=>!b.isDeleted);f.length>1&&(m=u,f.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...EC({selectedElementIds:n,editingGroupId:m},s,o,null)}}},xb=(e,o)=>{if(e.editingGroupId){let t=jm($m(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},na=B({name:"deleteSelectedElements",label:"labels.delete",icon:Mt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:m}=o.selectedLinearElement,c=r.scene.getNonDeletedElementsMap(),d=fb.getElement(a,c);if(!d||l==null)return!1;if(l.length>=d.points.length){let u=e.map(b=>b.id===d.id?ps(b,{isDeleted:!0}):b),f=xb(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:ms.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:m};return fb.deletePoints(d,r,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:ms.IMMEDIATELY}}let{elements:n,appState:i}=yC(e,o,r);return gC(n,n.filter(a=>a.isDeleted)),i=xb(i,n),{elements:n,appState:{...i,activeTool:hC(o,{type:r.defaultSelectionTool}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ee($m(e),o)?ms.IMMEDIATELY:ms.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===Zm.BACKSPACE||e.key===Zm.DELETE)&&!e[Zm.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>wC(K,{type:"button",icon:Mt,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:Ee($m(e),o)})});import{KEYS as Ln,CODES as Pn,getShortcutKey as An,isDarwin as us}from"@excalidraw/common";import{moveOneLeft as vC,moveOneRight as TC,moveAllLeft as IC,moveAllRight as CC}from"@excalidraw/element";import{CaptureUpdateAction as hs}from"@excalidraw/element";import{jsx as gs}from"react/jsx-runtime";var qm=B({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Am,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:vC(e,o,r.scene),appState:o,captureUpdate:hs.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Ln.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Pn.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>gs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${An("CtrlOrCmd+[")}`,children:Am})}),Jm=B({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Pm,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:TC(e,o,r.scene),appState:o,captureUpdate:hs.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Ln.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Pn.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>gs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${An("CtrlOrCmd+]")}`,children:Pm})}),Qm=B({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:_m,trackEvent:{category:"element"},perform:(e,o)=>({elements:IC(e,o),appState:o,captureUpdate:hs.IMMEDIATELY}),keyTest:e=>us?e[Ln.CTRL_OR_CMD]&&e.altKey&&e.code===Pn.BRACKET_LEFT:e[Ln.CTRL_OR_CMD]&&e.shiftKey&&e.code===Pn.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>gs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${us?An("CtrlOrCmd+Alt+["):An("CtrlOrCmd+Shift+[")}`,children:_m})}),ep=B({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Dm,trackEvent:{category:"element"},perform:(e,o)=>({elements:CC(e,o),appState:o,captureUpdate:hs.IMMEDIATELY}),keyTest:e=>us?e[Ln.CTRL_OR_CMD]&&e.altKey&&e.code===Pn.BRACKET_RIGHT:e[Ln.CTRL_OR_CMD]&&e.shiftKey&&e.code===Pn.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>gs("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${us?An("CtrlOrCmd+Alt+]"):An("CtrlOrCmd+Shift+]")}`,children:Dm})});import{getNonDeletedElements as SC}from"@excalidraw/element";import{LinearElementEditor as kC}from"@excalidraw/element";import{isLinearElement as MC,isTextElement as LC}from"@excalidraw/element";import{arrayToMap as PC,KEYS as Eb}from"@excalidraw/common";import{selectGroupsForSelectedElements as AC}from"@excalidraw/element";import{CaptureUpdateAction as DC}from"@excalidraw/element";var tp=B({name:"selectAll",label:"labels.selectAll",icon:eb,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing)return!1;let n=e.filter(i=>!i.isDeleted&&!(LC(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...AC({editingGroupId:null,selectedElementIds:n},SC(e),o,r),selectedLinearElement:Object.keys(n).length===1&&MC(e[0])?new kC(e[0],PC(e)):null},captureUpdate:DC.IMMEDIATELY}},keyTest:e=>e[Eb.CTRL_OR_CMD]&&e.key===Eb.A});import{DEFAULT_GRID_SIZE as yb,KEYS as wb,arrayToMap as vb,getShortcutKey as _C}from"@excalidraw/common";import{getNonDeletedElements as Tb}from"@excalidraw/element";import{LinearElementEditor as RC}from"@excalidraw/element";import{getSelectedElements as NC,getSelectionStateForElements as BC}from"@excalidraw/element";import{syncMovedIndices as FC}from"@excalidraw/element";import{duplicateElements as OC}from"@excalidraw/element";import{CaptureUpdateAction as Ib}from"@excalidraw/element";import{jsx as zC}from"react/jsx-runtime";var op=B({name:"duplicateSelection",label:"labels.duplicateSelection",icon:$i,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=RC.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:a,captureUpdate:Ib.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=OC({type:"in-place",elements:e,idsOfElementsToDuplicate:vb(NC(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+yb/2,y:a.y+yb/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:FC(i,vb(n)),appState:{...o,...BC(n,Tb(i),o)},captureUpdate:Ib.IMMEDIATELY}},keyTest:e=>e[wb.CTRL_OR_CMD]&&e.key===wb.D,PanelComponent:({elements:e,appState:o,updateData:t})=>zC(K,{type:"button",icon:$i,title:`${g("labels.duplicateSelection")} \u2014 ${_C("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:Ee(Tb(e),o)})});import{pointFrom as H6}from"@excalidraw/math";import{useEffect as Ip,useMemo as G6,useRef as Cp,useState as U6}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Y6,DEFAULT_ELEMENT_BACKGROUND_PICKS as W6,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as V6,DEFAULT_ELEMENT_STROKE_PICKS as X6,ARROW_TYPE as Po,DEFAULT_FONT_FAMILY as K6,DEFAULT_FONT_SIZE as Z6,FONT_FAMILY as $6,ROUNDNESS as Ds,STROKE_WIDTH as Sp,VERTICAL_ALIGN as As,KEYS as Un,randomInteger as j6,arrayToMap as Lp,getFontFamilyString as q6,getShortcutKey as J6,getLineHeight as Q6,isTransparent as e4,reduceToCommonValue as t4}from"@excalidraw/common";import{canBecomePolygon as o4,getNonDeletedElements as mx}from"@excalidraw/element";import{bindLinearElement as lx,calculateFixedPointForElbowArrowBinding as sx,updateBoundElements as r4}from"@excalidraw/element";import{LinearElementEditor as kp}from"@excalidraw/element";import{newElementWith as Ke}from"@excalidraw/element";import{getBoundTextElement as lr,redrawTextBoundingBox as ha}from"@excalidraw/element";import{isArrowElement as _s,isBoundToContainer as n4,isElbowArrow as px,isLinearElement as Mp,isLineElement as cx,isTextElement as xt,isUsingAdaptiveRadius as i4}from"@excalidraw/element";import{hasStrokeColor as a4}from"@excalidraw/element";import{updateElbowArrowPoints as l4,CaptureUpdateAction as Ze,toggleLinePolygonState as s4}from"@excalidraw/element";import{isDevEnv as HC}from"@excalidraw/common";var GC=new Set(["command_palette","export"]),re=(e,o,t,r)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!GC.has(e)||HC())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import VC from"clsx";import UC from"clsx";import{forwardRef as YC}from"react";import{jsx as WC}from"react/jsx-runtime";var Dn=YC((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return WC("button",{type:"button",ref:o,title:t,"data-testid":n,className:UC(r,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as KC,jsx as rp,jsxs as XC}from"react/jsx-runtime";var Ot=e=>rp(KC,{children:e.options.map(o=>e.type==="button"?rp(Dn,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):XC("label",{className:VC({active:e.value===o.value}),title:o.text,children:[rp("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as vs from"@radix-ui/react-popover";import XS from"clsx";import{useRef as KS}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as ZS,COLOR_PALETTE as Yb,isTransparent as $S}from"@excalidraw/common";import{jsx as ZC}from"react/jsx-runtime";var fs=()=>ZC("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as QC,useRef as eS}from"react";import{createPortal as tS}from"react-dom";import{EVENT as tr,KEYS as oS,rgbToHex as rS}from"@excalidraw/common";import Cb from"react";var np=Cb.createContext(null),ge=()=>Cb.useContext(np);import{useState as $C,useLayoutEffect as Sb}from"react";import{THEME as jC}from"@excalidraw/common";var bs=e=>{let[o,t]=$C(null),r=ce(),{theme:n}=ge(),{container:i}=Ge();return Sb(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.editor.isMobile),o.classList.toggle("theme--dark",n===jC.DARK))},[o,n,r.editor.isMobile,e?.className]),Sb(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as qC}from"react";import{EVENT as xs}from"@excalidraw/common";function _n(e,o,t){qC(()=>{function r(n){let i=n;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(xs.POINTER_DOWN,r),document.addEventListener(xs.TOUCH_START,r),()=>{document.removeEventListener(xs.POINTER_DOWN,r),document.removeEventListener(xs.TOUCH_START,r)}},[e,o,t])}import{useRef as JC}from"react";var er=e=>{let o=JC(e);return Object.assign(o.current,e),o.current};import{jsx as nS}from"react/jsx-runtime";var or=me(null),kb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=bs({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ge(),a=rr(),l=Re(),s=j(a,i),m=er({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:c}=Ge();QC(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:L})=>{let k=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(L-i.offsetTop)*window.devicePixelRatio,1,1).data;return rS(k[0],k[1],k[2])},x=({clientX:S,clientY:L,altKey:k})=>{p.style.top=`${L+20}px`,p.style.left=`${S+20}px`;let A=b({clientX:S,clientY:L});u&&m.onChange(r,A,m.selectedElements,{altKey:k}),p.style.background=A},w=()=>{m.onCancel()},E=(S,L)=>{m.onSelect(S,L)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,c?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},C=S=>{S.key===oS.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),w())};return n.tabIndex=-1,n.focus(),x({clientX:m.app.lastViewportPosition.x,clientY:m.app.lastViewportPosition.y,altKey:!1}),n.addEventListener(tr.KEYDOWN,C),n.addEventListener(tr.POINTER_DOWN,y),n.addEventListener(tr.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(tr.BLUR,w),()=>{u=!1,n.removeEventListener(tr.KEYDOWN,C),n.removeEventListener(tr.POINTER_DOWN,y),n.removeEventListener(tr.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(tr.BLUR,w)}},[m,l.canvas,n,r,c,i.offsetLeft,i.offsetTop]);let d=eS(null);return _n(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?tS(nS("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as Rn from"@radix-ui/react-popover";import sS from"clsx";import cS from"react";import{isInteractive as dS}from"@excalidraw/common";import iS from"react";import aS from"clsx";import{jsx as lS}from"react/jsx-runtime";var Xe=iS.forwardRef(({children:e,padding:o,className:t,style:r},n)=>lS("div",{className:aS("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as ip,jsxs as mS}from"react/jsx-runtime";var Es=cS.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},m)=>{let c=ce();return ip(Rn.Portal,{container:o,children:mS(Rn.Content,{ref:m,className:sS("focus-visible-none",e),"data-prevent-outside-click":!0,side:c.editor.isMobile&&!c.viewport.isLandscape?"bottom":"right",align:c.editor.isMobile&&!c.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:d=>{d.stopPropagation(),d.preventDefault(),o&&!dS(document.activeElement)&&o.focus(),n()},children:[ip(Xe,{padding:3,style:r,children:t}),ip(Rn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import uS from"clsx";import{useCallback as hS,useEffect as lp,useRef as Pb,useState as gS}from"react";import{KEYS as sp,getShortcutKey as fS}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as pS}from"@excalidraw/common";var nr=({palette:e,color:o})=>{if(!o)return null;for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},ia=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),ap=({color:e,palette:o})=>!Object.values(o).flat().includes(e),Lb=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return ap({color:l,palette:t})}),i=new Map;return n.forEach(a=>{let l=a[r[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,pS)},zt=me(null),Mb=(e,o,t)=>(e*299+o*587+t*114)/1e3,Nn=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),m=parseInt(l[1]),c=parseInt(l[2]);return Mb(s,m,c)<o}return!0}let t=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return Mb(t,r,n)<o};import{Fragment as bS,jsx as ys,jsxs as Ab}from"react/jsx-runtime";var Db=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let i=ce(),[a,l]=gS(e),[s,m]=ie(zt);lp(()=>{l(e)},[e]);let c=hS(b=>{let x=b.toLowerCase(),w=_b(x);w&&o(w),l(x)},[o]),d=Pb(null),p=Pb(null);lp(()=>{d.current&&d.current.focus()},[s]);let[u,f]=ie(or);return lp(()=>()=>{f(null)},[f]),Ab("div",{className:"color-picker__input-label",children:[ys("div",{className:"color-picker__input-hash",children:"#"}),ys("input",{ref:s==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{c(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:b=>{b.key!==sp.TAB&&(b.key===sp.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:n}),!i.editor.isMobile&&Ab(bS,{children:[ys("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),ys("div",{ref:p,className:uS("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:r}),title:`${g("labels.eyeDropper")} \u2014 ${sp.I.toLocaleUpperCase()} or ${fS("Alt")} `,children:V0})]})]})};import pp,{useEffect as up,useImperativeHandle as BS,useState as FS}from"react";import{EVENT as zb}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as OS,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as zS,KEYS as HS}from"@excalidraw/common";import yS from"clsx";import{useEffect as wS,useRef as vS}from"react";import{jsxs as ES}from"react/jsx-runtime";var xS=({color:e,keyLabel:o,isShade:t=!1})=>ES("div",{className:"color-picker__button__hotkey-label",style:{color:Nn(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Bn=xS;import{jsx as cp,jsxs as TS}from"react/jsx-runtime";var Rb=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ie(zt),a=vS(null);return wS(()=>{a.current&&a.current.focus()},[o,n]),cp("div",{className:"color-picker-content--default",children:e.map((l,s)=>TS("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:yS("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[cp("div",{className:"color-picker__button-outline"}),cp(Bn,{color:l,keyLabel:s+1})]},s))})};import IS from"clsx";import{useEffect as CS,useRef as SS}from"react";import{jsx as dp,jsxs as MS}from"react/jsx-runtime";var kS=({palette:e,color:o,onChange:t,activeShade:r})=>{let n=nr({color:o,palette:e}),[i,a]=ie(zt),l=SS(null);return CS(()=>{l.current&&i==="baseColors"&&l.current.focus()},[n?.colorName,i]),dp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,m],c)=>{let d=(Array.isArray(m)?m[r]:m)||"transparent",p=ia[c],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return MS("button",{ref:n?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:IS("color-picker__button color-picker__button--large has-outline",{active:n?.colorName===s,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),a("baseColors")},title:`${u}${d.startsWith("#")?` ${d}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${s}`,children:[dp("div",{className:"color-picker__button-outline"}),dp(Bn,{color:d,keyLabel:p})]},s)})})},Nb=kS;import{jsx as PS}from"react/jsx-runtime";var LS=({children:e})=>PS("div",{className:"color-picker__heading",children:e}),Fn=LS;import AS from"clsx";import{useEffect as DS,useRef as _S}from"react";import{jsx as aa,jsxs as Bb}from"react/jsx-runtime";var Fb=({color:e,onChange:o,palette:t})=>{let r=nr({color:e||"transparent",palette:t}),[n,i]=ie(zt),a=_S(null);if(DS(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,m=t[l];if(Array.isArray(m))return aa("div",{className:"color-picker-content--default shades",children:m.map((c,d)=>Bb("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:AS("color-picker__button color-picker__button--large has-outline",{active:d===s}),"aria-label":"Shade",title:`${l} - ${d+1}`,style:c?{"--swatch-color":c}:void 0,onClick:()=>{o(c),i("shades")},children:[aa("div",{className:"color-picker__button-outline"}),aa(Bn,{color:c,keyLabel:d+1,isShade:!0})]},d))})}return Bb("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[aa("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),aa("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:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as On,COLOR_PALETTE as RS,KEYS as la}from"@excalidraw/common";var mp=(e,o,t)=>{let r=Math.ceil(t/On);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+On;return n>=t?o%On:n}case"ArrowUp":{let n=o-On,i=n<0?On*r+n:n;return i>=t?void 0:i}}},NS=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),i("custom"),!0;if(ia.includes(e.key)){let l=ia.indexOf(e.key),s=Object.keys(r)[l],m=r[s],c=Array.isArray(m)?m[a]:m;return t(c),i("baseColors"),!0}return!1},Ob=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:m,onEscape:c})=>{if(e[la.CTRL_OR_CMD])return!1;if(e.key===la.ESCAPE)return c(e),!0;if(e.key===la.ALT)return m(!0),!0;if(e.key===la.I)return m(),!0;let d=nr({color:r,palette:t});if(e.key===la.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,v])=>(v&&E.push(y),E),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,w=u[x];return w&&a(w),w==="custom"?n(i[0]):w==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(RS.black)),e.preventDefault(),e.stopPropagation(),!0}if(NS({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=mp(e.key,p,On);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),f=u.indexOf(p),b=mp(e.key,f,u.length);if(b!==void 0){let x=u[b],w=t[x];return n(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let p=r!=null?i.indexOf(r):0,u=mp(e.key,p,i.length);if(u!==void 0){let f=i[u];return n(f),!0}}return!1};import{jsx as Ur,jsxs as ws}from"react/jsx-runtime";var Hb=pp.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},m)=>{let[c]=pp.useState(()=>t==="canvasBackground"?[]:Lb(r,t,n)),[d,p]=ie(zt),u=nr({color:e,palette:n});up(()=>{if(!d){let w=!!e&&ap({color:e,palette:n}),E=w&&!c.includes(e);p(E?null:w?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,n,p,u,c]);let[f,b]=FS(u?.shade??(t==="elementBackground"?OS:zS));up(()=>{u?.shade!=null&&b(u.shade);let w=E=>{E.key===HS.ALT&&l(!1)};return document.addEventListener(zb.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(zb.KEYUP,w,{capture:!0})}},[u,l]);let x=pp.useRef(null);return BS(m,()=>x.current),up(()=>{x?.current?.focus()},[]),Ur("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:ws("div",{ref:x,onKeyDown:w=>{Ob({event:w,activeColorPickerSection:d,palette:n,color:e,onChange:o,onEyeDropperToggle:l,customColors:c,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!c.length&&ws("div",{children:[Ur(Fn,{children:g("colorPicker.mostUsedCustomColors")}),Ur(Rb,{colors:c,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),ws("div",{children:[Ur(Fn,{children:g("colorPicker.colors")}),Ur(Nb,{color:e,palette:n,onChange:o,activeShade:f})]}),ws("div",{children:[Ur(Fn,{children:g("colorPicker.shades")}),Ur(Fb,{color:e,onChange:o,palette:n})]}),a]})})});import GS from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as US,DEFAULT_CANVAS_BACKGROUND_PICKS as YS,DEFAULT_ELEMENT_BACKGROUND_PICKS as WS,DEFAULT_ELEMENT_STROKE_PICKS as VS}from"@excalidraw/common";import{jsx as hp}from"react/jsx-runtime";var Gb=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=VS),o==="elementBackground"&&(n=WS),o==="canvasBackground"&&(n=YS),r&&(n=r),n?hp("div",{className:"color-picker__top-picks",children:n.map(i=>hp("button",{className:GS("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!Nn(i,US)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:hp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Qt,jsxs as gp}from"react/jsx-runtime";var Ub=e=>{let o=new Option().style;return o.color=e,!!o.color},_b=e=>$S(e)?e:Ub(`#${e}`)?`#${e}`:Ub(e)?e:null,jS=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Yb,updateData:a})=>{let{container:l}=Ge(),[,s]=ie(zt),[m,c]=ie(or),d=gp("div",{children:[Qt(Fn,{children:g("colorPicker.hexCode")}),Qt(Db,{color:o||"",label:r,onChange:f=>{t(f)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),p=KS(null),u=()=>{p.current?.focus()};return Qt(Es,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{m&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Qt(Hb,{ref:p,palette:i,color:o,onChange:f=>{t(f)},onEyeDropperToggle:f=>{c(b=>f?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):f===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:f=>{m?c(null):a({openPopup:null})},type:e,elements:n,updateData:a,children:d}):d})},qS=({label:e,color:o,type:t})=>Qt(vs.Trigger,{type:"button",className:XS("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Nn(o,ZS)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),children:Qt("div",{className:"color-picker__button-outline",children:!o&&$1})}),sa=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Yb,topPicks:a,updateData:l,appState:s})=>Qt("div",{children:gp("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Qt(Gb,{activeColor:o,onChange:t,type:e,topPicks:a}),Qt(fs,{}),gp(vs.Root,{open:s.openPopup===e,onOpenChange:m=>{l({openPopup:m?e:null})},children:[Qt(qS,{color:o,label:r,type:e}),s.openPopup===e&&Qt(jS,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as Qb from"@radix-ui/react-popover";import k6,{useCallback as M6,useMemo as L6}from"react";import{FONT_FAMILY as yp}from"@excalidraw/common";import b6,{useMemo as ir,useState as x6,useRef as E6,useEffect as y6,useCallback as w6}from"react";import{arrayToList as v6,debounce as T6,FONT_FAMILY as Yr,getFontFamilyString as I6}from"@excalidraw/common";import JS from"clsx";import QS from"react";import{jsx as e6,jsxs as t6}from"react/jsx-runtime";var Ts=QS.forwardRef(({className:e,placeholder:o,onChange:t},r)=>t6("div",{className:JS("QuickSearch__wrapper",e),children:[Lt,e6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import o6 from"clsx";import{Children as r6}from"react";import{jsx as Wb}from"react/jsx-runtime";var Is=({className:e,placeholder:o,children:t})=>{let r=!r6.count(t);return Wb("div",{className:o6("ScrollableList__wrapper",e),role:"menu",children:r?Wb("div",{className:"empty",children:o}):t})};import{jsx as n6,jsxs as i6}from"react/jsx-runtime";var Vb=({children:e,className:o="",style:t,title:r})=>i6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&n6("p",{className:"dropdown-menu-group-title",children:r}),e]}),ca=Vb;Vb.displayName="DropdownMenuGroup";import{useEffect as h6,useRef as g6}from"react";import{THEME as f6}from"@excalidraw/common";import{jsx as a6}from"react/jsx-runtime";var da=({children:e,...o})=>a6("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as s6,jsx as Cs,jsxs as c6}from"react/jsx-runtime";var l6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=ce();return c6(s6,{children:[o&&Cs("div",{className:"dropdown-menu-item__icon",children:o}),Cs("div",{style:e,className:"dropdown-menu-item__text",children:Cs(da,{children:r})}),t&&!n.editor.isMobile&&Cs("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Ss=l6;import d6,{useContext as m6}from"react";import{EVENT as p6,composeEventHandlers as u6}from"@excalidraw/common";var fp=d6.createContext({}),ks=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
2
+ ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),Ms=(e,o)=>{let t=m6(fp);return u6(e,r=>{let n=new CustomEvent(p6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as bp}from"react/jsx-runtime";var xp=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:m,onClick:c,...d})=>{let p=Ms(c,m),u=g6(null);return h6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),bp("button",{...d,ref:u,value:o,onClick:p,className:ks(i,l,a),title:d.title??d["aria-label"],children:bp(Ss,{textStyle:s,icon:e,shortcut:n,children:r})})};xp.displayName="DropdownMenuItem";var zn={GREEN:"green",RED:"red",BLUE:"blue"},Ls=({type:e=zn.BLUE,children:o})=>{let{theme:t}=go(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===f6.LIGHT?"1.5px solid white":"none"};switch(e){case zn.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case zn.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case zn.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return bp("div",{className:"DropDownMenuItemBadge",style:r,children:o})};Ls.displayName="DropdownMenuItemBadge";xp.Badge=Ls;var mt=xp;import{KEYS as Hn}from"@excalidraw/common";var Xb=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[Hn.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Hn.F)return o.current?.focus(),!0;if(e.key===Hn.ESCAPE)return n(),!0;if(e.key===Hn.ENTER)return t?.value&&i(t.value),!0;if(e.key===Hn.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===Hn.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as ma,jsxs as Kb}from"react/jsx-runtime";var C6=e=>{switch(e){case Yr.Excalifont:case Yr.Virgil:return Qo;case Yr.Nunito:case Yr.Helvetica:return Qi;case Yr["Lilita One"]:return _0;case Yr["Comic Shanns"]:case Yr.Cascadia:return Jl;default:return Qi}},Zb=b6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=Ge(),{fonts:s}=Re(),{showDeprecatedFonts:m}=fo(),[c,d]=x6(""),p=E6(null),u=ir(()=>Array.from(jo.registered.entries()).filter(([k,{metadata:A}])=>!A.private&&!A.fallback).map(([k,{metadata:A,fontFaces:P}])=>{let N={value:k,icon:C6(k),text:P[0]?.fontFace?.family??"Unknown"};return A.deprecated&&Object.assign(N,{deprecated:A.deprecated,badge:{type:zn.RED,placeholder:g("fontList.badge.old")}}),N}).sort((k,A)=>k.text.toLowerCase()>A.text.toLowerCase()?1:-1),[]),f=ir(()=>new Set(s.getSceneFamilies()),[e]),b=ir(()=>u.filter(k=>f.has(k.value)),[u,f]),x=ir(()=>u.filter(k=>!f.has(k.value)&&(m||!k.deprecated)),[u,f,m]),w=ir(()=>v6([...b,...x].filter(k=>k.text?.toLowerCase().includes(c))),[b,x,c]),E=ir(()=>{let k;return o?k=w.find(A=>A.value===o):e&&(k=w.find(A=>A.value===e)),!k&&c&&(w[0]?.value?r(w[0].value):n()),k},[o,e,c,w,r,n]),y=w6(k=>{Xb({event:k,inputRef:p,hoveredFont:E,filteredFonts:w,onSelect:t,onHover:r,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[E,w,t,r,a]);y6(()=>(i(),()=>{a()}),[]);let v=ir(()=>w.filter(k=>f.has(k.value)),[w,f]),C=ir(()=>w.filter(k=>!f.has(k.value)),[w,f]),S=(k,A)=>Kb(mt,{icon:k.icon,value:k.value,order:A,textStyle:{fontFamily:I6({fontFamily:k.value})},hovered:k.value===E?.value,selected:k.value===e,tabIndex:k.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{E?.value!==k.value&&r(k.value)},children:[k.text,k.badge&&ma(Ls,{type:k.badge.type,children:k.badge.placeholder})]},k.value),L=[];return v.length&&L.push(ma(ca,{title:g("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&L.push(ma(ca,{title:g("fontList.availableFonts"),children:C.map((k,A)=>S(k,A+v.length))},"group_2")),Kb(Es,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[ma(Ts,{ref:p,placeholder:g("quickSearch.placeholder"),onChange:T6(d,20)}),ma(Is,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:L.length?L:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as $b from"@radix-ui/react-popover";import{useMemo as S6}from"react";import{jsx as Ep}from"react/jsx-runtime";var jb=({selectedFontFamily:e})=>{let o=S6(()=>!!(e&&!qb(e)),[e]);return Ep($b.Trigger,{asChild:!0,children:Ep("div",{children:Ep(Dn,{standalone:!0,icon:Tn,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as pa,jsxs as Jb}from"react/jsx-runtime";var ex=[{value:yp.Excalifont,icon:Qo,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:yp.Nunito,icon:Qi,text:g("labels.normal"),testId:"font-family-normal"},{value:yp["Comic Shanns"],icon:Jl,text:g("labels.code"),testId:"font-family-code"}],P6=new Set(ex.map(e=>e.value)),qb=e=>e?P6.has(e):!1,tx=k6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=L6(()=>ex,[]),s=M6(m=>{m&&r(m)},[r]);return Jb("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[pa("div",{className:"buttonList",children:pa(Ot,{type:"button",options:l,value:o,onClick:s})}),pa(fs,{}),Jb(Qb.Root,{open:e,onOpenChange:a,children:[pa(jb,{selectedFontFamily:o}),e&&pa(Zb,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Gn from"@radix-ui/react-popover";import R6 from"clsx";import Ps,{useEffect as N6}from"react";import{isArrowKey as B6,KEYS as Lo}from"@excalidraw/common";import{jsx as A6}from"react/jsx-runtime";var ar=({icon:e})=>A6("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:e});import{Fragment as _6,jsx as ox,jsxs as rx}from"react/jsx-runtime";var D6=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:i=!0})=>rx(_6,{children:[rx("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,i&&ox(ar,{icon:o?pb:ls})]}),o&&ox("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),ua=D6;import{jsx as Wr,jsxs as wp}from"react/jsx-runtime";var F6=me(!1);function O6({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=ce(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)r(f.value),u.preventDefault();else if(u.key===Lo.TAB){let b=e.findIndex(w=>w.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(B6(u.key)){let b=Mo().rtl,x=e.findIndex(w=>w.value===o);if(x!==-1){let w=e.length,E=x;switch(u.key){case(b?Lo.ARROW_LEFT:Lo.ARROW_RIGHT):E=(x+1)%w;break;case(b?Lo.ARROW_RIGHT:Lo.ARROW_LEFT):E=(w+x-1)%w;break;case Lo.ARROW_DOWN:{E=(x+(i??1))%w;break}case Lo.ARROW_UP:{E=(w+x-(i??1))%w;break}}r(e[E].value)}u.preventDefault()}else(u.key===Lo.ESCAPE||u.key===Lo.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,m]=ie(F6),c=Ps.useMemo(()=>e.slice(0,i),[e,i]),d=Ps.useMemo(()=>e.slice(i),[e,i]);N6(()=>{c.some(u=>u.value===o)||m(!0)},[o,c,m]);let p=u=>Wr("div",{className:"picker-content",children:u.map((f,b)=>wp("button",{type:"button",className:R6("picker-option",{active:o===f.value}),onClick:x=>{r(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&Wr("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return Wr(Gn.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:wp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(c),d.length>0&&Wr(ua,{label:g("labels.more_options"),open:s,openTrigger:()=>{m(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function vp({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Ps.useState(!1),s=Ps.useRef(null);return Wr("div",{children:wp(Gn.Root,{open:a,onOpenChange:m=>l(m),children:[Wr(Gn.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(m=>m.value===e)?.icon}),a&&Wr(O6,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import nx,{useEffect as z6}from"react";import{jsx as Tp,jsxs as ix}from"react/jsx-runtime";var ax=({updateData:e,app:o,testId:t})=>{let r=nx.useRef(null),n=nx.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),m=i.reduce((c,d)=>(c!=null&&c!==d.opacity&&(a=!1),c==null||c>d.opacity?d.opacity:c),l?.opacity??null)??o.state.currentItemOpacity;return z6(()=>{if(r.current&&n.current){let c=r.current,d=n.current,p=c.offsetWidth,u=15,f=m/100*(p-u)+u/2;d.style.left=`${f}px`,c.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${m}%, var(--button-bg) ${m}%, var(--button-bg) 100%)`}},[m]),ix("label",{className:"control-label",children:[g("labels.opacity"),ix("div",{className:"range-wrapper",children:[Tp("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:r,type:"range",min:"0",max:"100",step:"10",onChange:c=>{e(+c.target.value)},value:m,className:"range-input","data-testid":t}),Tp("div",{className:"value-bubble",ref:n,children:m!==0?m:null}),Tp("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as hx,jsx as Q,jsxs as yt}from"react/jsx-runtime";var ux=.1,pt=(e,o,t,r=!1)=>{let n=Lp(j(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},Et=function(e,o,t,r,n){let i=o.state.editingTextElement,a=mx(e),l=null;if(i&&(l=t(i)),!l)if(Ee(a,o.state)){let m=o.scene.getSelectedElements(o.state),c=r===!0?m:m.filter(d=>r(d));l=t4(c,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},c4=(e,o,t)=>n4(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),Pp=(e,o,t,r,n)=>{let i=new Set,a=pt(e,o,l=>{if(xt(l)){let s=r(l);i.add(s);let m=Ke(l,{fontSize:s});return ha(m,t.scene.getContainerElement(l),t.scene),m=c4(l,m,t.scene),m}return l},!0);return j(e,o,{includeBoundTextElement:!0}).forEach(l=>{xt(l)&&r4(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:Ze.IMMEDIATELY}},d4=B({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:pt(e,o,r=>a4(r.type)?Ke(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?Ze.IMMEDIATELY:Ze.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt(hx,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.stroke")}),Q(sa,{topPicks:X6,palette:V6,type:"elementStroke",label:g("labels.stroke"),color:Et(e,r,n=>n.strokeColor,!0,n=>n?null:o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),m4=B({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,r)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:Ze.EVENTUALLY};let n,i=r.scene.getSelectedElements(o);if(!e4(t.currentItemBackgroundColor)&&i.every(l=>cx(l)&&o4(l.points))){let l=Lp(i);n=e.map(s=>l.has(s.id)&&cx(s)?Ke(s,{backgroundColor:t.currentItemBackgroundColor,...s4(s,!0)}):s)}else n=pt(e,o,l=>Ke(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:n,appState:{...o,...t},captureUpdate:Ze.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt(hx,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.background")}),Q(sa,{topPicks:W6,palette:Y6,type:"elementBackground",label:g("labels.background"),color:Et(e,r,n=>n.backgroundColor,!0,n=>n?null:o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),p4=B({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(re("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:pt(e,o,n=>Ke(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=j(e,o),i=n.length>0&&n.every(a=>a.fillStyle==="zigzag");return yt("fieldset",{children:[Q("legend",{children:g("labels.fill")}),Q("div",{className:"buttonList",children:Q(Ot,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${J6("Alt-Click")})`,icon:i?n0:i0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:a0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:l0,testId:"fill-solid"}],value:Et(e,r,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&n.every(m=>m.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),u4=B({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>Ke(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"stroke-width",options:[{value:Sp.thin,text:g("labels.thin"),icon:Um,testId:"strokeWidth-thin"},{value:Sp.bold,text:g("labels.bold"),icon:s0,testId:"strokeWidth-bold"},{value:Sp.extraBold,text:g("labels.extraBold"),icon:c0,testId:"strokeWidth-extraBold"}],value:Et(e,r,n=>n.strokeWidth,n=>n.hasOwnProperty("strokeWidth"),n=>n?null:o.currentItemStrokeWidth),onChange:n=>t(n)})})]})}),h4=B({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>Ke(r,{seed:j6(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:p0},{value:1,text:g("labels.artist"),icon:u0},{value:2,text:g("labels.cartoonist"),icon:h0}],value:Et(e,r,n=>n.roughness,n=>n.hasOwnProperty("roughness"),n=>n?null:o.currentItemRoughness),onChange:n=>t(n)})})]})}),A$=B({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>Ke(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:Um},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:d0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:m0}],value:Et(e,r,n=>n.strokeStyle,n=>n.hasOwnProperty("strokeStyle"),n=>n?null:o.currentItemStrokeStyle),onChange:n=>t(n)})})]})}),g4=B({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>Ke(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>Q(ax,{updateData:o,app:e,testId:"opacity"})}),f4=B({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>Pp(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:L0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:P0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:A0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:D0,testId:"fontSize-veryLarge"}],value:Et(e,r,n=>{if(xt(n))return n.fontSize;let i=lr(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>xt(n)||lr(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||Z6),onChange:n=>t(n)})})]})}),Ap=B({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Hr,trackEvent:!1,perform:(e,o,t,r)=>Pp(e,o,r,n=>Math.round(1/(1+ux)*n.fontSize)),keyTest:e=>e[Un.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Un.CHEVRON_LEFT||e.key===Un.COMMA)}),Dp=B({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Hr,trackEvent:!1,perform:(e,o,t,r)=>Pp(e,o,r,n=>Math.round(n.fontSize*(1+ux))),keyTest:e=>e[Un.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Un.CHEVRON_RIGHT||e.key===Un.PERIOD)}),b4=B({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:pt(e,o,b=>{let x=n?.get(b.id);return x?Ke(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:Ze.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:m}=t,c=Ze.EVENTUALLY,d,p=!1;if(s)d=s,c=Ze.IMMEDIATELY;else if(m){d=m,c=Ze.EVENTUALLY;let f=j(e,o,{includeBoundTextElement:!0}).filter(b=>xt(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let w=f[b];x+=w?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:c};if(d&&!p){let f=new Map,b=new Set,x=!1,w=Array.from(jo.loadedFontsCache.values()),E=Object.entries($6).find(([C,S])=>S===d)?.[0];m&&E&&w.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:pt(e,o,C=>{if(xt(C)&&(C.fontFamily!==d||s)){let S=Ke(C,{fontFamily:d,lineHeight:Q6(d)}),L=n?.get(C.containerId||"")||{},k=r.scene.getContainerElement(C);return a&&k&&L&&r.scene.mutateElement(k,{...L}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,k),S}return C},!0)});let y=`10px ${q6({fontFamily:d})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of f)ha(C,S,r.scene);else window.document.fonts.load(y,v).then(C=>{for(let[S,L]of f){let k=r.scene.getElement(S.id),A=L?r.scene.getElement(L.id):null;k&&ha(k,A,r.scene)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=Cp(new Map),i=Cp(null),[a,l]=U6({}),s=Cp(!0),m=G6(()=>{let c=(d,p)=>Et(d,t,u=>{if(xt(u))return u.fontFamily;let f=lr(u,p);return f?f.fontFamily:null},u=>xt(u)||lr(u,p)!==null,u=>u?null:o.currentItemFontFamily||K6);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?c(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?c(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return Ip(()=>{i.current=m},[m]),Ip(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),Ip(()=>(s.current=!1,()=>{s.current=!0}),[]),yt("fieldset",{children:[Q("legend",{children:g("labels.fontFamily")}),Q(tx,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:c=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:c}),n.current.clear()},onHover:c=>{l({currentHoveredFontFamily:c,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:c=>{if(c){n.current.clear();let{editingTextElement:d}=o;if(d?.type==="text"){let p=t.scene.getElement(d.id);n.current.set(d.id,Ke(p||d,{},!0))}else{let p=j(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,Ke(u,{},!0))}l({openPopup:"fontFamily"})}else{let d={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};s.current?r({...a,...d}):l(d),n.current.clear()}}})]})}}),x4=B({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:pt(e,o,n=>{if(xt(n)){let i=Ke(n,{textAlign:t});return ha(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return yt("fieldset",{children:[Q("legend",{children:g("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:R0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:N0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:B0,testId:"align-right"}],value:Et(e,r,i=>{if(xt(i))return i.textAlign;let a=lr(i,n);return a?a.textAlign:null},i=>xt(i)||lr(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})})]})}}),E4=B({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:pt(e,o,n=>{if(xt(n)){let i=Ke(n,{verticalAlign:t});return ha(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Ot,{group:"text-align",options:[{value:As.TOP,text:g("labels.alignTop"),icon:Q(F0,{theme:o.theme}),testId:"align-top"},{value:As.MIDDLE,text:g("labels.centerVertically"),icon:Q(z0,{theme:o.theme}),testId:"align-middle"},{value:As.BOTTOM,text:g("labels.alignBottom"),icon:Q(O0,{theme:o.theme}),testId:"align-bottom"}],value:Et(e,r,n=>{if(xt(n)&&n.containerId)return n.verticalAlign;let i=lr(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>xt(n)||lr(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:As.MIDDLE),onChange:n=>t(n)})})})}),D$=B({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>px(r)?r:Ke(r,{roundness:t==="round"?{type:i4(r.type)?Ds.ADAPTIVE_RADIUS:Ds.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>{let a=Ml(mx(e),o).some(l=>l.roundness?.type===Ds.LEGACY);return yt("fieldset",{children:[Q("legend",{children:g("labels.edges")}),yt("div",{className:"buttonList",children:[Q(Ot,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:g0},{value:"round",text:g("labels.round"),icon:f0}],value:Et(e,r,l=>a?null:l.roundness?"round":"sharp",l=>!_s(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),n("togglePolygon")]})]})}}),dx=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:b0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(x0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:Q(v0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:Q(T0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:Q(E0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(y0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:Q(I0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:Q(C0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:Q(w0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:Q(k0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:Q(S0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:Q(M0,{flip:e}),keyBinding:"v"}],_$=B({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>{if(Mp(r)){let{position:n,type:i}=t;if(n==="start")return Ke(r,{startArrowhead:i});if(n==="end")return Ke(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Mo().rtl;return yt("fieldset",{children:[Q("legend",{children:g("labels.arrowheads")}),yt("div",{className:"iconSelectList buttonList",children:[Q(vp,{label:"arrowhead_start",options:dx(!n),value:Et(e,r,i=>Mp(i)&&hn(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),Q(vp,{label:"arrowhead_end",group:"arrowheads",options:dx(!!n),value:Et(e,r,i=>Mp(i)&&hn(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),R$=B({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=pt(e,o,l=>{if(!_s(l))return l;let s=Ke(l,{roundness:t===Po.round?{type:Ds.PROPORTIONAL_RADIUS}:null,elbowed:t===Po.elbow,points:t===Po.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(px(s)){s.fixedSegments=null;let m=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let c=kp.getPointAtIndexGlobalCoordinates(s,0,m),d=kp.getPointAtIndexGlobalCoordinates(s,-1,m),p=s.startBinding&&m.get(s.startBinding.elementId),u=s.endBinding&&m.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...sx(s,p,"start",m)}:null,b=u&&s.endBinding?{...s.endBinding,...sx(s,u,"end",m)}:null;s={...s,startBinding:f,endBinding:b,...l4(s,m,{points:[c,d].map(x=>H6(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let m=r.scene.getNonDeletedElementsMap();if(s.startBinding){let c=m.get(s.startBinding.elementId);c&&lx(s,c,"start",r.scene)}if(s.endBinding){let c=m.get(s.endBinding.elementId);c&&lx(s,c,"end",r.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new kp(l,Lp(e)))}return{elements:n,appState:i,captureUpdate:Ze.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"arrowtypes",options:[{value:Po.sharp,text:g("labels.arrowtype_sharp"),icon:ns,testId:"sharp-arrow"},{value:Po.round,text:g("labels.arrowtype_round"),icon:as,testId:"round-arrow"},{value:Po.elbow,text:g("labels.arrowtype_elbowed"),icon:is,testId:"elbow-arrow"}],value:Et(e,r,n=>_s(n)?n.elbowed?Po.elbow:n.roundness?Po.round:Po.sharp:null,n=>_s(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})})]})});import{clamp as Fp,roundToStep as S4}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as k4,CURSOR_TYPE as Ex,MAX_ZOOM as yx,MIN_ZOOM as wx,THEME as ga,ZOOM_STEP as Op,getShortcutKey as vx,updateActiveTool as Wn,CODES as xo,KEYS as Do}from"@excalidraw/common";import{getNonDeletedElements as M4}from"@excalidraw/element";import{newElementWith as L4}from"@excalidraw/element";import{getCommonBounds as P4}from"@excalidraw/element";import{CaptureUpdateAction as eo}from"@excalidraw/element";import{useEffect as y4}from"react";import{jsx as v4}from"react/jsx-runtime";var Yn=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},_p=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+r.height>=i&&(s=o.top-r.height-a)):(s=o.top-r.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},w4=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();_p(o,n)},Pt=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(y4(()=>()=>Yn().classList.remove("excalidraw-tooltip--visible"),[]),n?null:v4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>w4(i.currentTarget,Yn(),o,t),onPointerLeave:()=>Yn().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import Rs from"open-color";import{CURSOR_TYPE as Rp,MIME_TYPES as Np,THEME as fx}from"@excalidraw/common";var bx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',T4='<path d="M6.164 11.755a5.314 5.314 0 0 1-4.932-5.298 5.314 5.314 0 0 1 5.311-5.311 5.314 5.314 0 0 1 5.307 5.113l8.773 8.773a3.322 3.322 0 0 1 0 4.696l-.895.895a3.322 3.322 0 0 1-4.696 0l-8.868-8.868Z" style="fill:#fff"/>',xx='<path stroke="#1b1b1f" fill="#fff" d="m7.868 11.113 7.773 7.774a2.359 2.359 0 0 0 1.667.691 2.368 2.368 0 0 0 2.357-2.358c0-.625-.248-1.225-.69-1.667L11.201 7.78 9.558 9.469l-1.69 1.643v.001Zm10.273 3.606-3.333 3.333m-3.25-6.583 2 2m-7-7 3 3M3.664 3.625l1 1M2.529 6.922l1.407-.144m5.735-2.932-1.118.866M4.285 9.823l.758-1.194m1.863-6.207-.13 1.408"/>',I4=`data:${Np.svg},${encodeURIComponent(`${bx}${xx}</svg>`)}`,C4=`data:${Np.svg},${encodeURIComponent(`${bx}${T4}${xx}</svg>`)}`,Ht=e=>{e&&(e.style.cursor="")},xe=(e,o)=>{e&&(e.style.cursor=o)},bo,gx,Bp=(e,o)=>{let r=()=>{let n=o===fx.DARK;bo=document.createElement("canvas"),bo.theme=o,bo.height=20,bo.width=20;let i=bo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(bo.width/2,bo.height/2,5,0,2*Math.PI),i.fillStyle=n?Rs.black:Rs.white,i.fill(),i.strokeStyle=n?Rs.white:Rs.black,i.stroke(),gx=bo.toDataURL(Np.svg)};(!bo||bo.theme!==o)&&r(),xe(e,`url(${gx}) ${20/2} ${20/2}, auto`)},At=(e,o)=>{if(e)if(o.activeTool.type==="selection")Ht(e);else if(qt(o))e.style.cursor=Rp.GRAB;else if(bt(o))Bp(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===fx.LIGHT?I4:C4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Rp.AUTO):e.style.cursor=Rp.CROSSHAIR};var Ao=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,i=o-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),m=-(n-n/t),c=-(i-i/t);return{scrollX:l+m,scrollY:s+c,zoom:{value:t}}};import{jsx as Os,jsxs as R4}from"react/jsx-runtime";var A4=B({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?eo.IMMEDIATELY:eo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>Os(sa,{palette:null,topPicks:k4,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),_o=B({name:"clearCanvas",label:"labels.clearCanvas",icon:Mt,trackEvent:{category:"canvas"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,r)=>(r.imageCache.clear(),{elements:e.map(n=>L4(n,{isDeleted:!0})),appState:{...qo(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:r.defaultSelectionTool}:o.activeTool},captureUpdate:eo.IMMEDIATELY})}),Ns=B({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Im,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value+Op)},o),userToFollow:null},captureUpdate:eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Os(K,{type:"button",className:"zoom-in-button zoom-button",icon:Im,title:`${g("buttons.zoomIn")} \u2014 ${vx("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=yx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===xo.EQUAL||e.code===xo.NUM_ADD)&&(e[Do.CTRL_OR_CMD]||e.shiftKey)}),Bs=B({name:"zoomOut",label:"buttons.zoomOut",icon:Cm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value-Op)},o),userToFollow:null},captureUpdate:eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Os(K,{type:"button",className:"zoom-out-button zoom-button",icon:Cm,title:`${g("buttons.zoomOut")} \u2014 ${vx("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=wx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===xo.MINUS||e.code===xo.NUM_SUBTRACT)&&(e[Do.CTRL_OR_CMD]||e.shiftKey)}),Fs=B({name:"resetZoom",label:"buttons.resetZoom",icon:G1,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(1)},o),userToFollow:null},captureUpdate:eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Os(Pt,{label:g("buttons.resetZoom"),style:{height:"100%"},children:R4(K,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===xo.ZERO||e.code===xo.NUM_ZERO)&&(e[Do.CTRL_OR_CMD]||e.shiftKey)}),D4=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,m=a-n,c=o.height/m,p=Math.min(s,c)*Fp(t,.1,1);return Math.min(p,1)},Tx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=Fp(n,wx,yx);let[l,s,m,c]=e,d=(l+m)/2,p=(s+c)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,w=o.width-u-b,E=o.height-f-x,y;if(r){let S=m-l,L=c-s;y=Math.min(w/S,E/L)*n}else y=D4(e,{width:w,height:E},n);let v=uo(Fp(S4(y,Op,"floor"),i,a)),C=e1({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:eo.EVENTUALLY}},fa=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=P4(M4(o));return Tx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},fj=B({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:rs,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return fa({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===xo.TWO&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),bj=B({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:rs,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return fa({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===xo.THREE&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),_4=B({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:rs,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>fa({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===xo.ONE&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),Vr=B({name:"toggleTheme",label:(e,o)=>o.theme===ga.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ga.LIGHT?ji:qi,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===ga.LIGHT?ga.DARK:ga.LIGHT)},captureUpdate:eo.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===xo.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),xj=B({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return bt(o)?n=Wn(o,{...o.activeTool.lastActiveTool||{type:r.defaultSelectionTool},lastActiveToolBeforeEraser:null}):n=Wn(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:eo.IMMEDIATELY}},keyTest:e=>e.key===Do.E}),Ej=B({name:"toggleLassoTool",label:"toolBar.lasso",icon:Zi,trackEvent:{category:"toolbar"},predicate:(e,o,t,r)=>r.defaultSelectionTool!=="lasso",perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=Wn(o,{type:"lasso",fromSelection:!1}),xe(r.interactiveCanvas,Ex.CROSSHAIR)):n=Wn(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:eo.NEVER}}}),Ix=B({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:es,viewMode:!1,perform:(e,o,t,r)=>{let n;return qt(o)?n=Wn(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Wn(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),xe(r.interactiveCanvas,Ex.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:eo.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Do.CTRL_OR_CMD]&&e.key===Do.H});import{updateActiveTool as Cx}from"@excalidraw/common";import{CaptureUpdateAction as N4}from"@excalidraw/element";var B4=B({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Cx(o,{type:"embeddable"});return At(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Cx(o,{type:"embeddable"})},captureUpdate:N4.EVENTUALLY}}});import{pointFrom as F4}from"@excalidraw/math";import{maybeBindLinearElement as O4,bindOrUnbindLinearElement as Sx,isBindingEnabled as z4}from"@excalidraw/element/binding";import{isValidPolygon as kx,LinearElementEditor as ba,newElementWith as zp}from"@excalidraw/element";import{isBindingElement as zs,isFreeDrawElement as Mx,isLinearElement as Lx,isLineElement as Hs}from"@excalidraw/element";import{KEYS as Hp,arrayToMap as Gp,tupleToCoors as H4,updateActiveTool as Px}from"@excalidraw/common";import{isPathALoop as G4}from"@excalidraw/element";import{isInvisiblySmallElement as Up}from"@excalidraw/element";import{CaptureUpdateAction as Yp}from"@excalidraw/element";import{jsx as U4}from"react/jsx-runtime";var Dt=B({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,{event:l,sceneCoords:s}=t??{},m=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=ba.handlePointerUp(l,o.selectedLinearElement,o,r.scene),{startBindingElement:f,endBindingElement:b}=u,x=r.scene.getElement(u.elementId);if(zs(x)&&Sx(x,f,b,r.scene),u!==o.selectedLinearElement){let w=e;return x&&Up(x)&&(w=w.map(E=>E.id===x.id?zp(E,{isDeleted:!0}):E)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:Yp.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=ba.getElement(u,m);if(x)return zs(x)&&Sx(x,f,b,a),Hs(x)&&!kx(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||Up(x)?e.map(w=>w.id===x.id?zp(w,{isDeleted:!0}):w):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new ba(x,Gp(m),!1)},captureUpdate:Yp.IMMEDIATELY}}let c=e;window.document.activeElement instanceof HTMLElement&&i();let d=null;if(o.multiElement)d=o.multiElement;else if(o.newElement?.type==="freedraw"||zs(o.newElement))d=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=m.get(Object.keys(o.selectedElementIds)[0]);u&&(d=u)}if(d){if(o.multiElement&&d.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=d;(!f||u[u.length-1]!==f)&&a.mutateElement(d,{points:d.points.slice(0,-1)})}if(d&&Up(d)&&(c=c.map(u=>u.id===d?.id?zp(u,{isDeleted:!0}):u)),Lx(d)||Mx(d)){let u=G4(d.points,o.zoom.value);if(u&&(Hs(d)||Mx(d))){let f=d.points,b=f[0],x=f.map((w,E)=>E===f.length-1?F4(b[0],b[1]):w);Hs(d)?a.mutateElement(d,{points:x,polygon:!0}):a.mutateElement(d,{points:x})}if(Hs(d)&&!kx(d.points)&&a.mutateElement(d,{polygon:!1}),zs(d)&&!u&&d.points.length>1&&z4(o)){let f=s??H4(ba.getPointAtIndexGlobalCoordinates(d,-1,Gp(e)));O4(d,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!d)&&Ht(n);let p;return o.activeTool.type==="eraser"?p=Px(o,{...o.activeTool.lastActiveTool||{type:r.defaultSelectionTool},lastActiveToolBeforeEraser:null}):p=Px(o,{type:r.defaultSelectionTool}),{elements:c,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&d?o.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[d.id]:!0}:o.selectedElementIds,selectedLinearElement:d&&Lx(d)?new ba(d,Gp(c)):o.selectedLinearElement},captureUpdate:Yp.IMMEDIATELY}},keyTest:(e,o)=>e.key===Hp.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===Hp.ESCAPE||e.key===Hp.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>U4(K,{type:"button",icon:q1,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as Kn,DEFAULT_EXPORT_PADDING as Dk,EXPORT_SCALES as _k,THEME as Xp}from"@excalidraw/common";import{getNonDeletedElements as Rk}from"@excalidraw/element";import{CaptureUpdateAction as no}from"@excalidraw/element";import Y4 from"clsx";import{jsx as Ax,jsxs as W4}from"react/jsx-runtime";var xa=({children:e,checked:o,onChange:t,className:r})=>W4("div",{className:Y4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Ax("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:V1}),Ax("div",{className:"Checkbox-label",children:e})]});import{THEME as Ea}from"@excalidraw/common";import{jsx as ya}from"react/jsx-runtime";var _x=e=>{let o=e.title||(e.value===Ea.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return ya(K,{type:"icon",icon:e.value===Ea.LIGHT?Dx.MOON:Dx.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===Ea.DARK?Ea.LIGHT:Ea.DARK),"data-testid":"toggle-dark-mode"})},Dx={SUN:ya("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ya("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:ya("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ya("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"})})};import{useState as V4}from"react";import{focusNearestParent as X4,KEYS as K4}from"@excalidraw/common";import{jsx as Rx,jsxs as Z4}from"react/jsx-runtime";var Nx=e=>{let{id:o}=Ge(),[t,r]=V4(e.value),n=a=>{e.ignoreFocus||X4(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===K4.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return Z4("div",{className:"ProjectName",children:[Rx("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Rx("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as Tk,DEFAULT_FILENAME as Ik,IMAGE_MIME_TYPES as qx,isFirefox as Ck,MIME_TYPES as Sk,cloneJSON as kk,SVG_DOCUMENT_PREAMBLE as Mk}from"@excalidraw/common";import{getNonDeletedElements as Lk}from"@excalidraw/element";import{isFrameLikeElement as Pk}from"@excalidraw/element";import{getElementsOverlappingFrame as Ak}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as ik,EXPORT_DATA_TYPES as Ta,MIME_TYPES as oo,arrayToMap as ak,isMemberOf as lk,isPromiseLike as sk,EVENT as Ys}from"@excalidraw/common";import{mutateElement as ck}from"@excalidraw/element";import{deepCopyElement as dk}from"@excalidraw/element";import{isFrameLikeElement as mk,isInitializedImageElement as pk}from"@excalidraw/element";import{getContainingFrame as Xx}from"@excalidraw/element";import{pointFrom as sr}from"@excalidraw/math";import{COLOR_PALETTE as Fx,DEFAULT_CHART_COLOR_INDEX as $4,getAllColorsSpecificShade as j4,DEFAULT_FONT_FAMILY as q4,DEFAULT_FONT_SIZE as Ox,VERTICAL_ALIGN as J4,randomId as zx,isDevEnv as Hx}from"@excalidraw/common";import{newTextElement as Gs,newLinearElement as va,newElement as Vp}from"@excalidraw/element";var to=32,we=12,cr=256,Gx=50,Xr="NOT_SPREADSHEET",Vn="VALID_SPREADSHEET",wa=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},Wp=(e,o)=>e.slice(1).every(t=>wa(t[o])!==null),Bx=e=>{let o=e[0].length;if(o>2)return{type:Xr,reason:"More than 2 columns"};if(o===1){if(!Wp(e,0))return{type:Xr,reason:"Value is not numeric"};let s=wa(e[0][0])===null,m=(s?e.slice(1):e).map(c=>wa(c[0]));return m.length<2?{type:Xr,reason:"Less than two rows"}:{type:Vn,spreadsheet:{title:s?e[0][0]:null,labels:null,values:m}}}let t=Wp(e,0),r=Wp(e,1);if(!t&&!r)return{type:Xr,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=wa(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:Xr,reason:"Less than 2 rows"}:{type:Vn,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>wa(s[i]))}}},Q4=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},Ux=e=>{let o=e.trim().split(`
3
+ `).map(i=>i.trim().split(" "));if(o.length&&o[0].length!==2&&(o=e.trim().split(`
4
+ `).map(i=>i.trim().split(","))),o.length===0)return{type:Xr,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:Xr,reason:"All rows don't have same number of columns"};let n=Bx(o);if(n.type!==Vn){let i=Bx(Q4(o));if(i.type===Vn)return i}return n},Us=j4($4),Gt={fillStyle:"hachure",fontFamily:q4,fontSize:Ox,opacity:100,roughness:1,strokeColor:Fx.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:J4.MIDDLE,locked:!1},Yx=e=>{let o=(to+we)*e.values.length+we,t=cr+we*2;return{chartWidth:o,chartHeight:t}},ek=(e,o,t,r,n)=>e.labels?.map((i,a)=>Gs({groupIds:[r],backgroundColor:n,...Gt,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(to+we)+we*2,y:t+we/2,width:to,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],tk=(e,o,t,r,n)=>{let i=Gs({groupIds:[r],backgroundColor:n,...Gt,x:o-we,y:t-we,text:"0",textAlign:"right"}),a=Gs({groupIds:[r],backgroundColor:n,...Gt,x:o-we,y:t-cr-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},ok=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=Yx(e),l=va({backgroundColor:n,groupIds:[r],...Gt,type:"line",x:o,y:t,width:i,points:[sr(0,0),sr(i,0)]}),s=va({backgroundColor:n,groupIds:[r],...Gt,type:"line",x:o,y:t,height:a,points:[sr(0,0),sr(0,-a)]}),m=va({backgroundColor:n,groupIds:[r],...Gt,type:"line",x:o,y:t-cr-we,strokeStyle:"dotted",width:i,opacity:Gx,points:[sr(0,0),sr(i,0)]});return[l,s,m]},Wx=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=Yx(e),s=e.title?Gs({backgroundColor:n,groupIds:[r],...Gt,text:e.title,x:o+a/2,y:t-cr-we*2-Ox,roundness:null,textAlign:"center"}):null,m=i?Vp({backgroundColor:n,groupIds:[r],...Gt,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:Fx.black,fillStyle:"solid",opacity:6}):null;return[...m?[m]:[],...s?[s]:[],...ek(e,o,t,r,n),...tk(e,o,t,r,n),...ok(e,o,t,r,n)]},rk=(e,o,t)=>{let r=Math.max(...e.values),n=zx(),i=Us[Math.floor(Math.random()*Us.length)];return[...e.values.map((l,s)=>{let m=l/r*cr;return Vp({backgroundColor:i,groupIds:[n],...Gt,type:"rectangle",x:o+s*(to+we)+we,y:t-m-we,width:to,height:m})}),...Wx(e,o,t,n,i,Hx())]},nk=(e,o,t)=>{let r=Math.max(...e.values),n=zx(),i=Us[Math.floor(Math.random()*Us.length)],a=0,l=[];for(let b of e.values){let x=a*(to+we),w=-(b/r)*cr;l.push([x,w]),a++}let s=Math.max(...l.map(b=>b[0])),m=Math.max(...l.map(b=>b[1])),c=Math.min(...l.map(b=>b[0])),d=Math.min(...l.map(b=>b[1])),p=va({backgroundColor:i,groupIds:[n],...Gt,type:"line",x:o+we+to/2,y:t-we,height:m-d,width:s-c,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let w=x*(to+we)+we/2,E=-(b/r)*cr+we/2;return Vp({backgroundColor:i,groupIds:[n],...Gt,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+w+to/2,y:t+E-we*2,width:we,height:we})}),f=e.values.map((b,x)=>{let w=x*(to+we)+we/2,E=b/r*cr+we/2+we;return va({backgroundColor:i,groupIds:[n],...Gt,type:"line",x:o+w+to/2+we/2,y:t-E,height:E,strokeStyle:"dotted",opacity:Gx,points:[sr(0,0),sr(0,E)]})});return[...Wx(e,o,t,n,i,Hx()),p,...f,...u]},Vx=(e,o,t,r)=>e==="line"?nk(o,t,r):rk(o,t,r);var Dq="clipboard"in navigator&&"readText"in navigator.clipboard,Ws="clipboard"in navigator&&"writeText"in navigator.clipboard,Xn="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,uk=e=>!!([Ta.excalidraw,Ta.excalidrawClipboard,Ta.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Kx=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Ys.PASTE,{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){o=o||[],o.push(n),t.clipboardData?.items.add(n);continue}try{if(t.clipboardData?.items.add(n,r),t.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let r=-1;for(let n of o){r++;try{if(t.clipboardData?.items.add(n),t.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},hk=({elements:e,files:o})=>{let t=ak(e),r=new Set(e.filter(l=>mk(l))),n=!1,i=e.reduce((l,s)=>(pk(s)&&(n=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});n&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Ta.excalidrawClipboard,elements:e.map(l=>{if(Xx(l,t)&&!r.has(Xx(l,t))){let s=dk(l);return ck(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},Vs=async(e,o,t)=>{await ro(hk({elements:e,files:o}),t)},gk=e=>{let o=Ux(e);return o.type===Vn?{spreadsheet:o.spreadsheet}:null};function Zx(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let r=t.textContent?.trim();r&&o.push({type:"text",value:r})}else if(t instanceof HTMLImageElement){let r=t.getAttribute("src");r&&r.startsWith("http")&&o.push({type:"imageUrl",value:r})}else o=o.concat(Zx(t));return o}var fk=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,oo.html),r=Zx(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},$x=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let r=await navigator.clipboard?.readText();if(r)return{[oo.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw t}for(let t of o)for(let r of t.types)if(lk(ik,r))try{if(r===oo.text||r===oo.html)e[r]=await(await t.getType(r)).text();else if(b1(r)){let n=await t.getType(r),i=I1(n,r,void 0);e[r]=i}else throw new pm(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof pm?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},bk=async(e,o=!1)=>{try{let t=e.findByType(oo.html),r=!o&&t&&fk(t);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.getData(oo.text)??r.value.map(n=>n.value).join(`
5
+ `).trim()}:r:{type:"text",value:(e.getData(oo.text)||"").trim()}}catch{return{type:"text",value:""}}},xk=function(e){return this.find(o=>o.type===e)||null},Ek=function(e){return this.find(t=>t.type===e)?.value??null},yk=function(){return this.filter(e=>e.kind==="file")},Ia=async e=>{let o;vk(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async r=>{if(r.kind==="file"){let n=r.getAsFile();if(n){let i=await T1(r);return{type:n.type,kind:"file",file:await Ol(n),fileHandle:i}}}else if(r.kind==="string"){let{type:n}=r,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(n):i=await new Promise(a=>{r.getAsString(l=>a(l))}),{type:n,kind:"string",value:i}}return null}))).filter(r=>r!=null);return Object.assign(t,{findByType:xk,getData:Ek,getFiles:yk})},jx=async(e,o=!1)=>{let t=await bk(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&gk(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===Ta.excalidrawClipboardWithAPI;if(uk(r))return{elements:r.elements,files:r.files,text:o?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:t.value}},Xs=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[oo.png]:e})])}catch(o){if(sk(e))await navigator.clipboard.write([new window.ClipboardItem({[oo.png]:await e})]);else throw o}},ro=async(e,o)=>{if(Ws)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(oo.text,e||""),o.clipboardData?.getData(oo.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!wk(e))throw new Error("Error copying to clipboard.")},wk=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${r}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let n=!1;try{t.select(),t.setSelectionRange(0,t.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),n},vk=e=>e.type===Ys.PASTE||e.type===Ys.COPY||e.type===Ys.CUT;var Kr=(e,{selectedElementIds:o},t)=>{e=Lk(e);let r=t&&Ee(e,{selectedElementIds:o}),n=null,i=r?j(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&Pk(i[0])?(n=i[0],i=Ak(e,n)):i.length>1&&(i=j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:kk(i)}},Zr=async(e,o,t,r,{exportBackground:n,exportPadding:i=Tk,viewBackgroundColor:a,name:l=t.name||Ik,fileHandle:s=null,exportingFrame:m=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let d=bn(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:m});if(e==="svg")return um(d.then(p=>new Blob([Mk+p.outerHTML],{type:Sk.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[qx.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await d.then(u=>u.outerHTML);try{await ro(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let c=Rl(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:m});if(e==="png"){let d=ko(c);return t.exportEmbedScene&&(d=d.then(p=>import("./data/image-YQ6UXXDA.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Wi(o,t,r,"local")})))),um(d,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[qx.png],fileHandle:s})}else if(e==="clipboard")try{let d=ko(c);await Xs(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):Ck&&d.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
3
6
 
4
- ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var wx=async(e,o,t,n)=>{let{exportBackground:r,viewBackgroundColor:i,fileHandle:a}=o,l=Jf(a);if(!a||!Qf(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:m}=Gn(e,o,!1);return await Un(l,s,o,t,{exportBackground:r,viewBackgroundColor:i,name:n,fileHandle:a,exportingFrame:m}),{fileHandle:a}};import{Fragment as P4,jsx as Po,jsxs as A4}from"react/jsx-runtime";var Pp=B({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>Po(Ex,{label:g("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),vx=B({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=L4(e),i=Ee(n,o)?j(n,o):n;return Po(P4,{children:M4.map(a=>{let[l,s]=jf(i,k4,a),m=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Po(K,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:m,"aria-label":m,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),Ap=B({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Po(da,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),Ds=B({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>A4(da,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Po(Lt,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Po("div",{className:"excalidraw-tooltip-icon",children:B1})})]})}),Yn=B({name:"saveToActiveFile",label:"buttons.save",icon:Rn,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{let r=!!o.fileHandle;try{let{fileHandle:i}=Tl(o.fileHandle)?await wx(e,o,n.files,n.getName()):await xl(e,o,n.files,n.getName());return{captureUpdate:Qt.EVENTUALLY,appState:{...o,fileHandle:i,toast:r?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:Qt.EVENTUALLY}}},keyTest:e=>e.key===zr.S&&e[zr.CTRL_OR_CMD]&&!e.shiftKey}),ua=B({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Rn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{try{let{fileHandle:r}=await xl(e,{...o,fileHandle:null},n.files,n.getName());return{captureUpdate:Qt.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:r,toast:{message:g("toast.fileSaved")}}}}catch(r){return r?.name!=="AbortError"?console.error(r):console.warn(r),{captureUpdate:Qt.EVENTUALLY}}},keyTest:e=>e.key===zr.S&&e.shiftKey&&e[zr.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Po(K,{type:"button",icon:A1,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:ce().editor.isMobile,hidden:!cr,onClick:()=>e(null),"data-testid":"save-as-button"})}),Hr=B({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{try{let{elements:r,appState:i,files:a}=await Jd(o,e);return{elements:r,appState:i,files:a,captureUpdate:Qt.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:Qt.EVENTUALLY}}},keyTest:e=>e[zr.CTRL_OR_CMD]&&e.key===zr.O}),Tx=B({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Po("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Po(bx,{value:e.exportWithDarkMode?Lp.DARK:Lp.LIGHT,onChange:t=>{o(t===Lp.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as D4,DEFAULT_FONT_FAMILY as _4,DEFAULT_TEXT_ALIGN as R4,CODES as Ix,KEYS as Cx,getLineHeight as N4}from"@excalidraw/common";import{newElementWith as _s}from"@excalidraw/element";import{hasBoundTextElement as B4,canApplyRoundnessTypeToElement as F4,getDefaultRoundnessTypeForElement as O4,isFrameLikeElement as z4,isArrowElement as H4,isExcalidrawElement as G4,isTextElement as Dp}from"@excalidraw/element";import{getBoundTextElement as U4,redrawTextBoundingBox as Y4}from"@excalidraw/element";import{CaptureUpdateAction as _p}from"@excalidraw/element";var Sx="{}",Rp=B({name:"copyStyles",label:"labels.copyStyles",icon:Lm,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(a=>o.selectedElementIds[a.id]);if(r.push(i),i&&B4(i)){let a=U4(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Sx=JSON.stringify(r)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:_p.EVENTUALLY}},keyTest:e=>e[Cx.CTRL_OR_CMD]&&e.altKey&&e.code===Ix.C}),Np=B({name:"pasteStyles",label:"labels.pasteStyles",icon:Lm,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(Sx),i=r[0],a=r[1];if(!G4(i))return{elements:e,captureUpdate:_p.EVENTUALLY};let l=j(e,o,{includeBoundTextElement:!0}),s=l.map(m=>m.id);return{elements:e.map(m=>{if(s.includes(m.id)){let c=i;if(Dp(m)&&m.containerId&&(c=a),!c)return m;let d=_s(m,{backgroundColor:c?.backgroundColor,strokeWidth:c?.strokeWidth,strokeColor:c?.strokeColor,strokeStyle:c?.strokeStyle,fillStyle:c?.fillStyle,opacity:c?.opacity,roughness:c?.roughness,roundness:c.roundness?F4(c.roundness.type,m)?c.roundness:O4(m):null});if(Dp(d)){let p=c.fontSize||D4,u=c.fontFamily||_4;d=_s(d,{fontSize:p,fontFamily:u,textAlign:c.textAlign||R4,lineHeight:c.lineHeight||N4(u)});let f=null;d.containerId&&(f=l.find(b=>Dp(d)&&b.id===d.containerId)||null),Y4(d,f,n.scene)}return d.type==="arrow"&&H4(c)&&(d=_s(d,{startArrowhead:c.startArrowhead,endArrowhead:c.endArrowhead})),z4(m)&&(d=_s(d,{roundness:null,backgroundColor:"transparent"})),d}return m}),captureUpdate:_p.IMMEDIATELY}},keyTest:e=>e[Cx.CTRL_OR_CMD]&&e.altKey&&e.code===Ix.V});import{KEYS as W4}from"@excalidraw/common";import{getNonDeletedElements as V4}from"@excalidraw/element";import{showSelectedShapeActions as X4}from"@excalidraw/element";import{CaptureUpdateAction as Bp}from"@excalidraw/element";import{jsx as kx}from"react/jsx-runtime";var K4=B({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:Bp.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>kx(K,{type:"button",icon:Ol,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),Z4=B({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:Bp.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>kx(K,{visible:X4(o,V4(e)),type:"button",icon:D1,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),Wn=B({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:S1,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:n})=>(o.openDialog?.name==="help"&&n(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:Bp.EVENTUALLY}),keyTest:e=>e.key===W4.QUESTION_MARK});import{getNonDeletedElements as Ns}from"@excalidraw/element";import{newElementWith as Px}from"@excalidraw/element";import{isBoundToContainer as $4}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as j4,getElementsInResizingFrame as q4,getFrameLikeElements as J4,getRootElements as Q4,groupByFrameLikes as ek,removeElementsFromFrame as tk,replaceAllElementsInFrame as ok}from"@excalidraw/element";import{KEYS as Bs,randomId as nk,arrayToMap as Fp,getShortcutKey as Ax}from"@excalidraw/common";import{getSelectedGroupIds as Rs,selectGroup as rk,selectGroupsForSelectedElements as ik,getElementsInGroup as Mx,addToGroup as ak,removeFromSelectedGroups as lk,isElementInGroup as Dx}from"@excalidraw/element";import{syncMovedIndices as sk}from"@excalidraw/element";import{CaptureUpdateAction as ha}from"@excalidraw/element";import{jsx as Gr}from"react/jsx-runtime";var ck=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&Dx(r,t),!0))return!0}return!1},Lx=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!ck(n)&&!j4(n)},Op=B({name:"group",label:"labels.group",icon:e=>Gr(Cm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=Q4(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:ha.EVENTUALLY};let i=Rs(o);if(i.length===1){let x=i[0],w=new Set(Mx(e,x).map(v=>v.id)),E=new Set(r.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:o,elements:e,captureUpdate:ha.EVENTUALLY}}let a=[...e];new Set(r.map(x=>x.frameId)).size>1&&ek(r).forEach((w,E)=>{tk(w,n.scene.getNonDeletedElementsMap())});let s=nk(),m=Fp(r);a=a.map(x=>m.get(x.id)?Px(x,{groupIds:ak(x.groupIds,s,o.editingGroupId)}):x);let c=Mx(a,s),d=c[c.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!Dx(x,s)),b=sk([...f,...c,...u],Fp(c));return{appState:{...o,...rk(s,{...o,selectedGroupIds:{}},Ns(a))},elements:b,captureUpdate:ha.IMMEDIATELY}},predicate:(e,o,t,n)=>Lx(e,o,n),keyTest:e=>!e.shiftKey&&e[Bs.CTRL_OR_CMD]&&e.key===Bs.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Gr(K,{hidden:!Lx(e,o,n),type:"button",icon:Gr(Cm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${Ax("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:Ee(Ns(e),o)})}),zp=B({name:"ungroup",label:"labels.ungroup",icon:e=>Gr(Sm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=Rs(o),i=Fp(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:ha.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{$4(p)&&l.push(p.id);let u=lk(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:Px(p,{groupIds:u})});let s=ik(o,Ns(a),o,null),m=n.scene.getSelectedElements(o),c=new Set(m.filter(p=>p.frameId).map(p=>p.frameId));return J4(e).filter(p=>c.has(p.id)).forEach(p=>{p&&(a=ok(a,q4(a,p,o,i),p,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:ha.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Bs.CTRL_OR_CMD]&&e.key===Bs.G.toUpperCase(),predicate:(e,o)=>Rs(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Gr(K,{type:"button",hidden:Rs(o).length===0,icon:Gr(Sm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${Ax("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:Ee(Ns(e),o)})});import fk from"clsx";import{CaptureUpdateAction as Fx}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as dk,COLOR_VOICE_CALL as mk,COLOR_WHITE as Os,THEME as pk,UserIdleState as _x}from"@excalidraw/common";var Fs=(e,o,t,n,r,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+n-i,t),e.quadraticCurveTo(o+n,t,o+n,t+i),e.lineTo(o+n,t+r-i),e.quadraticCurveTo(o+n,t+r,o+n-i,t+r),e.lineTo(o+i,t+r),e.quadraticCurveTo(o,t+r,o,t+r-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function uk(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);o=(o<<5)-o+n}return o}var Vn=(e,o)=>`hsl(${Math.abs(uk(o?.id||e))%37*10}, 100%, 83%)`,Rx=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},Nx=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,m=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let c=11,d=14,p=l<0||l>n-c||s<0||s>r-d;l=Math.max(l,0),l=Math.min(l,n-c),s=Math.max(s,0),s=Math.min(s,r-d);let u=Vn(i,m);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===_x.IDLE||f===_x.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===pk.DARK?"#2f6330":mk,w=m?.isSpeaking;w&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Os,e.strokeStyle=Os,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let E=o.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+c/2,v=(w?s+0:s)+d+2,C=5,S=3,L=e.measureText(E),k=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,A=Math.max(k,12),P=y-1,N=v-1,O=L.width+2+C*2+2,U=A+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,N,O,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=Os,e.stroke(),w&&(e.beginPath(),e.roundRect(P-2,N-2,O+4,U+4,8),e.strokeStyle=x,e.stroke())):Fs(e,P,N,O,U,8,Os),e.fillStyle=dk,e.fillText(E,y+C+1,v+S+L.actualBoundingBoxAscent+Math.floor((A-k)/2)+2),w){e.fillStyle=x;let J=8,_=8,R=5;e.fillRect(P+O+_,N+(U/2-J/2),2,J),e.fillRect(P+O+_+R,N+(U/2-J*2/2),2,J*2),e.fillRect(P+O+_+R*2,N+(U/2-J/2),2,J)}}e.restore(),e.closePath()}};import hk from"clsx";import{useState as gk}from"react";import{jsx as Bx}from"react/jsx-runtime";var Hp=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=Rx(t),[a,l]=gk(!1),s=!a&&n,m=s?void 0:{background:e};return Bx("div",{className:hk("Avatar",r),style:m,onClick:o,children:s?Bx("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as go,jsxs as zs}from"react/jsx-runtime";var bk=B({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:Fx.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:Fx.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=o,l=Vn(n,r),s=fk({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),m=r.isInCall?r.isSpeaking?zs("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[go("div",{}),go("div",{}),go("div",{})]}):r.isMuted?go("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:F0}):go("div",{title:g("userList.hint.inCall"),children:B0}):null;return i?zs("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[go(Hp,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),go("div",{className:"UserList__collaborator-name",children:r.username}),zs("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&go("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:vr}),m]})]}):zs("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[go(Hp,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),m&&go("div",{className:"UserList__collaborator-status-icon",children:m})]})}});import{LIBRARY_DISABLED_TYPES as xk,randomId as Ek}from"@excalidraw/common";import{deepCopyElement as yk}from"@excalidraw/element";import{CaptureUpdateAction as Gp}from"@excalidraw/element";var Up=B({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of xk)if(r.some(a=>a.type===i))return{captureUpdate:Gp.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:Ek(),status:"unpublished",elements:r.map(yk),created:Date.now()},...i])).then(()=>({captureUpdate:Gp.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:Gp.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as Ur}from"@excalidraw/element";import{isFrameLikeElement as wk}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as vk}from"@excalidraw/element";import{KEYS as nn,arrayToMap as Tk,getShortcutKey as Hs}from"@excalidraw/common";import{alignElements as Ik}from"@excalidraw/element";import{CaptureUpdateAction as Yr}from"@excalidraw/element";import{getSelectedElementsByGroup as Ck}from"@excalidraw/element";import{jsx as Vr}from"react/jsx-runtime";var yt=(e,o)=>{let t=o.scene.getSelectedElements(e);return Ck(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>wk(n))},Wr=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=Ik(r,n,t.scene,o),a=Tk(i);return vk(e.map(l=>a.get(l.id)||l),o,t)},Sk=B({name:"alignTop",label:"labels.alignTop",icon:Em,trackEvent:{category:"element"},predicate:(e,o,t,n)=>yt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Wr(e,o,n,{position:"start",axis:"y"}),captureUpdate:Yr.IMMEDIATELY}),keyTest:e=>e[nn.CTRL_OR_CMD]&&e.shiftKey&&e.key===nn.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Vr(K,{hidden:!yt(o,n),type:"button",icon:Em,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${Hs("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:Ee(Ur(e),o)})}),kk=B({name:"alignBottom",label:"labels.alignBottom",icon:ym,trackEvent:{category:"element"},predicate:(e,o,t,n)=>yt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Wr(e,o,n,{position:"end",axis:"y"}),captureUpdate:Yr.IMMEDIATELY}),keyTest:e=>e[nn.CTRL_OR_CMD]&&e.shiftKey&&e.key===nn.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Vr(K,{hidden:!yt(o,n),type:"button",icon:ym,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${Hs("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:Ee(Ur(e),o)})}),Mk=B({name:"alignLeft",label:"labels.alignLeft",icon:wm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>yt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Wr(e,o,n,{position:"start",axis:"x"}),captureUpdate:Yr.IMMEDIATELY}),keyTest:e=>e[nn.CTRL_OR_CMD]&&e.shiftKey&&e.key===nn.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Vr(K,{hidden:!yt(o,n),type:"button",icon:wm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${Hs("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:Ee(Ur(e),o)})}),Lk=B({name:"alignRight",label:"labels.alignRight",icon:vm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>yt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Wr(e,o,n,{position:"end",axis:"x"}),captureUpdate:Yr.IMMEDIATELY}),keyTest:e=>e[nn.CTRL_OR_CMD]&&e.shiftKey&&e.key===nn.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Vr(K,{hidden:!yt(o,n),type:"button",icon:vm,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${Hs("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:Ee(Ur(e),o)})}),Pk=B({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Tm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>yt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Wr(e,o,n,{position:"center",axis:"y"}),captureUpdate:Yr.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Vr(K,{hidden:!yt(o,n),type:"button",icon:Tm,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:Ee(Ur(e),o)})}),Ak=B({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Im,trackEvent:{category:"element"},predicate:(e,o,t,n)=>yt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Wr(e,o,n,{position:"center",axis:"x"}),captureUpdate:Yr.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Vr(K,{hidden:!yt(o,n),type:"button",icon:Im,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:Ee(Ur(e),o)})});import{getNonDeletedElements as Ox}from"@excalidraw/element";import{isFrameLikeElement as Dk}from"@excalidraw/element";import{CODES as zx,KEYS as Hx,arrayToMap as _k,getShortcutKey as Gx}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as Rk}from"@excalidraw/element";import{distributeElements as Nk}from"@excalidraw/element";import{CaptureUpdateAction as Ux}from"@excalidraw/element";import{getSelectedElementsByGroup as Bk}from"@excalidraw/element";import{jsx as Vx}from"react/jsx-runtime";var Yx=(e,o)=>{let t=o.scene.getSelectedElements(e);return Bk(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>Dk(n))},Wx=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=Nk(r,t.scene.getNonDeletedElementsMap(),n,o),a=_k(i);return Rk(e.map(l=>a.get(l.id)||l),o,t)},Fk=B({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:Wx(e,o,n,{space:"between",axis:"x"}),captureUpdate:Ux.IMMEDIATELY}),keyTest:e=>!e[Hx.CTRL_OR_CMD]&&e.altKey&&e.code===zx.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Vx(K,{hidden:!Yx(o,n),type:"button",icon:H1,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${Gx("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:Ee(Ox(e),o)})}),Ok=B({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:Wx(e,o,n,{space:"between",axis:"y"}),captureUpdate:Ux.IMMEDIATELY}),keyTest:e=>!e[Hx.CTRL_OR_CMD]&&e.altKey&&e.code===zx.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Vx(K,{hidden:!Yx(o,n),type:"button",icon:G1,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${Gx("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:Ee(Ox(e),o)})});import{getNonDeletedElements as zk}from"@excalidraw/element";import{bindOrUnbindLinearElements as Hk,isBindingEnabled as Gk}from"@excalidraw/element";import{getCommonBoundingBox as Xx}from"@excalidraw/element";import{newElementWith as Uk}from"@excalidraw/element";import{deepCopyElement as Yk}from"@excalidraw/element";import{resizeMultipleElements as Wk}from"@excalidraw/element";import{isArrowElement as Vk,isElbowArrow as Xk,isLinearElement as Kk}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Kx}from"@excalidraw/element";import{CODES as Zx,KEYS as Zk,arrayToMap as $k}from"@excalidraw/common";import{CaptureUpdateAction as $x}from"@excalidraw/element";var Yp=B({name:"flipHorizontal",label:"labels.flipHorizontal",icon:G0,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:Kx(jx(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:$x.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Zx.H}),Wp=B({name:"flipVertical",label:"labels.flipVertical",icon:H0,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:Kx(jx(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:$x.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Zx.V&&!e[Zk.CTRL_OR_CMD]}),jx=(e,o,t,n,r)=>{let i=j(zk(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=jk(i,o,t,n,r),l=$k(a);return e.map(s=>l.get(s.id)||s)},jk=(e,o,t,n,r)=>{if(e.every(u=>Vk(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return Uk(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=Xx(e);Wk(e,o,"nw",r.scene,new Map(Array.from(o.values()).map(u=>[u.id,Yk(u)])),{flipByX:n==="horizontal",flipByY:n==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),Hk(e.filter(Kk),Gk(t),[],r.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>Xk(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:m,midY:c}=Xx(e),[d,p]=[i-m,a-c];return s.forEach(u=>r.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>r.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),e};import{isTextElement as qk}from"@excalidraw/element";import{getTextFromElements as Jk}from"@excalidraw/element";import{CODES as Qk,KEYS as qx,isFirefox as eM}from"@excalidraw/common";import{CaptureUpdateAction as Dt}from"@excalidraw/element";var Xr=B({name:"copy",label:"labels.copy",icon:Gi,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await kl(r,n.files,t)}catch(i){return{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Dt.EVENTUALLY}},keyTest:void 0}),Vp=B({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await s1()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),eM?{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(l1({types:r}))}catch(i){return console.error(i),{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Dt.EVENTUALLY}},keyTest:void 0}),Gs=B({name:"cut",label:"labels.cut",icon:C0,trackEvent:{category:"element"},perform:(e,o,t,n)=>(Xr.perform(e,o,t,n),ji.perform(e,o,null,n)),keyTest:e=>e[qx.CTRL_OR_CMD]&&e.key===qx.X}),Us=B({name:"copyAsSvg",label:"labels.copyAsSvg",icon:U0,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Dt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Gn(e,o,!0);try{await Un("clipboard-svg",r,o,n.files,{...o,exportingFrame:i,name:n.getName()});let a=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Dt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Dt.EVENTUALLY}}},predicate:e=>am&&e.length>0,keywords:["svg","clipboard","copy"]}),Ys=B({name:"copyAsPng",label:"labels.copyAsPng",icon:Y0,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Dt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Gn(e,o,!0);try{return await Un("clipboard",i,o,n.files,{...o,exportingFrame:a,name:n.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:r.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Dt.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Dt.EVENTUALLY}}},predicate:e=>pr&&e.length>0,keyTest:e=>e.code===Qk.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Ws=B({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{so(Jk(r))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Dt.EVENTUALLY}},predicate:(e,o,t,n)=>am&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(qk),keywords:["text","clipboard","copy"]});import{CODES as tM,KEYS as oM}from"@excalidraw/common";import{CaptureUpdateAction as nM}from"@excalidraw/element";var Vs=B({name:"gridMode",icon:Z0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:nM.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[oM.CTRL_OR_CMD]&&e.code===tM.QUOTE});import{CODES as rM,KEYS as iM}from"@excalidraw/common";import{CaptureUpdateAction as aM}from"@excalidraw/element";var Kr=B({name:"zenMode",label:"buttons.zenMode",icon:V0,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:aM.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[iM.CTRL_OR_CMD]&&e.altKey&&e.code===rM.Z});import{CODES as lM,KEYS as sM}from"@excalidraw/common";import{CaptureUpdateAction as cM}from"@excalidraw/element";var Xp=B({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:W0,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:cM.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[sM.CTRL_OR_CMD]&&e.altKey&&e.code===lM.S});import{CODES as dM,KEYS as mM}from"@excalidraw/common";import{CaptureUpdateAction as pM}from"@excalidraw/element";var Zr=B({name:"stats",label:"stats.fullTitle",icon:z0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:pM.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[mM.CTRL_OR_CMD]&&e.altKey&&e.code===dM.SLASH});import{BOUND_TEXT_PADDING as Jx,ROUNDNESS as Qx,TEXT_ALIGN as tE,VERTICAL_ALIGN as oE,arrayToMap as nE,getFontString as uM}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as hM,resetOriginalContainerCache as gM,updateOriginalContainerCache as fM}from"@excalidraw/element";import{computeBoundTextPosition as bM,computeContainerDimensionForBoundText as eE,getBoundTextElement as rE,redrawTextBoundingBox as iE}from"@excalidraw/element";import{hasBoundTextElement as xM,isArrowElement as EM,isTextBindableContainer as Kp,isTextElement as ga,isUsingAdaptiveRadius as yM}from"@excalidraw/element";import{measureText as wM}from"@excalidraw/element";import{syncMovedIndices as aE}from"@excalidraw/element";import{newElement as vM}from"@excalidraw/element";import{CaptureUpdateAction as Zp}from"@excalidraw/element";var $p=B({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>xM(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=rE(a,i);if(l){let{width:s,height:m}=wM(l.originalText,uM(l),l.lineHeight),c=hM(a.id);gM(a.id);let{x:d,y:p}=bM(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:m,text:l.originalText,x:d,y:p}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:c||a.height})}}),{elements:e,appState:o,captureUpdate:Zp.IMMEDIATELY}}}),jp=B({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);if(r.length===2){let i=ga(r[0])||ga(r[1]),a;if(Kp(r[0])?a=r[0]:Kp(r[1])&&(a=r[1]),i&&a&&rE(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,a;ga(r[0])&&Kp(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:oE.MIDDLE,textAlign:tE.CENTER,autoResize:!0,angle:EM(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return iE(i,a,n.scene),fM(a.id,l),{elements:TM(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:Zp.IMMEDIATELY}}}),TM=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===t.id);n.splice(r,1);let i=n.findIndex(a=>a.id===o.id);return n.splice(i+1,0,t),aE(n,nE([o,t])),n},IM=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===o.id);n.splice(r,1);let i=n.findIndex(a=>a.id===t.id);return n.splice(i,0,o),aE(n,nE([o,t])),n},lE=B({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(a=>ga(a));return r.length>0&&i},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of r)if(ga(l)){let s=vM({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:yM("rectangle")?Qx.ADAPTIVE_RADIUS:Qx.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-Jx,y:l.y-Jx,width:eE(l.width,"rectangle"),height:eE(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let m=l.boundElements.filter(d=>d.type==="arrow").map(d=>d.id);i.filter(d=>m.includes(d.id)).forEach(d=>{let p=d.startBinding,u=d.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&n.scene.mutateElement(d,{startBinding:p,endBinding:u})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:oE.MIDDLE,boundElements:null,textAlign:tE.CENTER,autoResize:!0}),iE(l,s,n.scene),i=IM([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:Zp.IMMEDIATELY}}});import{isEmbeddableElement as GM}from"@excalidraw/element";import{KEYS as bE,getShortcutKey as UM}from"@excalidraw/common";import{CaptureUpdateAction as YM}from"@excalidraw/element";import{pointFrom as mE}from"@excalidraw/math";import CM from"clsx";import{useCallback as sE,useEffect as cE,useLayoutEffect as SM,useRef as kM,useState as MM}from"react";import{EVENT as qp,HYPERLINK_TOOLTIP_DELAY as LM,KEYS as Xs}from"@excalidraw/common";import{getElementAbsoluteCoords as ou}from"@excalidraw/element";import{hitElementBoundingBox as PM}from"@excalidraw/element";import{isElementLink as AM}from"@excalidraw/element";import{getEmbedLink as DM,embeddableURLValidator as _M}from"@excalidraw/element";import{sceneCoordsToViewportCoords as pE,viewportCoordsToSceneCoords as RM,wrapEvent as NM,isLocalLink as BM,normalizeLink as Jp}from"@excalidraw/common";import{isEmbeddableElement as Qp}from"@excalidraw/element";import{jsx as $r,jsxs as dE}from"react/jsx-runtime";var nu=380,FM=42,eu=5,uE=85,OM=500,tu=!1,Ks=new Map,hE=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=mo(),s=po(),m=ce(),c=e.link||"",[d,p]=MM(c),u=kM(null),f=l.showHyperlinkPopup==="editor",b=sE(()=>{if(!u.current)return;let v=Jp(u.current.value)||null;if(!e.link&&v&&ne("hyperlink","create"),Qp(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!_M(v,s.validateEmbeddable))v&&r({message:g("toast.unableToEmbed"),closable:!0}),e.link&&Ks.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:S}=e,L=DM(v);L?.error instanceof URIError&&r({message:g("toast.unrecognizedLinkFormat"),closable:!0});let k=L?L.intrinsicSize.w/L.intrinsicSize.h:1,A=Ks.get(e.id)!==e.link;o.mutateElement(e,{...A?{width:L?.type==="video"?C>S?C:S*k:C,height:L?.type==="video"&&C>S?C/k:S}:{},link:v}),i(e,!0),Ks.has(e.id)&&Ks.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);SM(()=>()=>{b()},[b]),cE(()=>{f&&u?.current&&!(m.viewport.isMobile||m.isTouchScreen)&&u.current.select()},[f,m.viewport.isMobile,m.isTouchScreen]),cE(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),HM(e,a,l,mE(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},OM))};return window.addEventListener(qp.POINTER_MOVE,C,!1),()=>{window.removeEventListener(qp.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=sE(()=>{ne("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{ne("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y}=gE(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:dE("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:nu,padding:eu},children:[f?$r("input",{className:CM("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:d,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Xs.CTRL_OR_CMD]&&v.key===Xs.K&&v.preventDefault(),(v.key===Xs.ENTER||v.key===Xs.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?$r("a",{href:Jp(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:BM(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&n){let C=NM(qp.EXCALIDRAW_LINK,v.nativeEvent);n({...e,link:Jp(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):$r("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),dE("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&$r(K,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:Zo}),$r(K,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Ql}),c&&!Qp(e)&&$r(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:kt})]})]})},gE=(e,o,t)=>{let[n,r]=ou(e,t),{x:i,y:a}=pE({sceneX:n+e.width/2,sceneY:r},o),l=i-o.offsetLeft-nu/2,s=a-o.offsetTop-uE;return{x:l,y:s}},ru=(e,o)=>{let t=j(e,o);return Qp(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},fa=null,fE=(e,o,t)=>{fa&&clearTimeout(fa),fa=window.setTimeout(()=>zM(e,o,t),LM)},zM=(e,o,t)=>{if(!e.link)return;let n=Fr();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=AM(e.link)?g("labels.link.goToElement"):e.link;let[r,i,a,l]=ou(e,t),[s,m,c,d]=Uf([r,i,a,l],e.angle,o),p=pE({sceneX:s,sceneY:m},o);xp(n,{left:p.x,top:p.y,width:c,height:d},"top"),ne("hyperlink","tooltip","link-icon"),tu=!0},iu=()=>{fa&&clearTimeout(fa),tu&&(tu=!1,Fr().classList.remove("excalidraw-tooltip--visible"))},HM=(e,o,t,[n,r])=>{let{x:i,y:a}=RM({clientX:n,clientY:r},t),l=15/t.zoom.value;if(PM(mE(i,a),e,o))return!1;let[s,m,c]=ou(e,o);if(i>=s&&i<=c&&a>=m-uE&&a<=m)return!1;let{x:d,y:p}=gE(e,t,o);return!(n>=d-l&&n<=d+nu+eu*2+l&&r>=p-l&&r<=p+l+eu*2+FM)};import{jsx as WM}from"react/jsx-runtime";var ba=B({name:"hyperlink",label:(e,o)=>ru(e,o),icon:Wi,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:YM.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[bE.CTRL_OR_CMD]&&e.key===bE.K,predicate:(e,o)=>j(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=j(e,o);return WM(K,{type:"button",icon:Wi,"aria-label":g(ru(e,o)),title:`${GM(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${UM("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as xE,arrayToMap as lu,randomId as VM}from"@excalidraw/common";import{elementsAreInSameGroup as XM,newElementWith as EE,selectGroupsFromGivenElements as yE}from"@excalidraw/element";import{CaptureUpdateAction as wE}from"@excalidraw/element";var au=e=>e.every(o=>!o.locked),xa=B({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return au(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=j(o,e);return au(t)?fr:_n},trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=au(r),a=lu(r),l=r.length>1&&XM(r),m=r.length===1||l?null:VM(),c={...o.lockedMultiSelections};if(i)c={...o.lockedMultiSelections,...m?{[m]:!0}:{}};else if(l){let w=r[0].groupIds.at(-1);delete c[w]}let d=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?m&&(E=[...E,m]):E=E.filter(y=>!o.lockedMultiSelections[y]),EE(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=lu(d),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),f=r.map(w=>p.get(w.id)||w),b=i?{}:yE(f,o),x=i?m||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:d,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:c,activeLockedId:x},captureUpdate:wE.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===xE.L&&e[xE.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),vE=B({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:_n,predicate:(e,o)=>j(e,o).length===0&&e.some(n=>n.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),n=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return EE(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=lu(n),i=t.map(a=>r.get(a.id)||a);return{elements:n,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:yE(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:wE.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as l7,isLinearElement as s7,isLineElement as ui}from"@excalidraw/element";import{arrayToMap as c7,invariant as ch}from"@excalidraw/common";import{toggleLinePolygonState as d7,CaptureUpdateAction as v2}from"@excalidraw/element";import Zy from"clsx";import o8 from"fuzzy";import{useEffect as yc,useRef as n8,useState as Ec}from"react";import{DEFAULT_SIDEBAR as Xy,EVENT as vc,KEYS as to,capitalizeString as r8,getShortcutKey as i8,isWritableElement as a8}from"@excalidraw/common";import{CaptureUpdateAction as ML}from"@excalidraw/element";import{useEffect as wa,useMemo as TE,useRef as mu,useState as KM}from"react";import{getLinearElementSubType as Jr,updateElbowArrowPoints as ZM}from"@excalidraw/element";import{pointFrom as $s,pointRotateRads as $M}from"@excalidraw/math";import{hasBoundTextElement as jM,isArrowBoundToElement as qM,isArrowElement as JM,isElbowArrow as QM,isLinearElement as gu,isUsingAdaptiveRadius as eL}from"@excalidraw/element";import{getCommonBoundingBox as tL,getElementAbsoluteCoords as oL}from"@excalidraw/element";import{getBoundTextElement as ME,getBoundTextMaxHeight as nL,getBoundTextMaxWidth as rL,redrawTextBoundingBox as iL}from"@excalidraw/element";import{wrapText as aL}from"@excalidraw/element";import{assertNever as lL,CLASSES as sL,getFontString as su,isProdEnv as cL,mapFind as dL,reduceToCommonValue as mL,updateActiveTool as IE}from"@excalidraw/common";import{measureText as CE}from"@excalidraw/element";import{LinearElementEditor as pL}from"@excalidraw/element";import{newArrowElement as cu,newElement as uL,newLinearElement as hL}from"@excalidraw/element";import{ShapeCache as gL}from"@excalidraw/element";import{updateBindings as fL}from"@excalidraw/element";import{jsx as hu}from"react/jsx-runtime";var bL=8,xL=10,Ea=["rectangle","diamond","ellipse"],ya=["line","sharpArrow","curvedArrow","elbowArrow"],EL=new Set(Ea),yL=new Set(ya),Qr=e=>EL.has(e),qs=e=>e==="arrow"||yL.has(e),eo=me(null),va=new Map,Ta=new Map,wL=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=mu(null);return wa(()=>{if(o.length===0){e.updateEditorAtom(eo,null);return}let n=ei(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(eo,null),t.current=null)},[o,e]),wa(()=>()=>{va.clear(),Ta.clear()},[]),hu(vL,{app:e,elements:o})},vL=({app:e,elements:o})=>{let t=ei(o),n=TE(()=>t==="generic"?PE(o):[],[t,o]),r=TE(()=>t==="linear"?uu(o):[],[t,o]),i=t==="generic"?n.every(d=>d.type===n[0].type):t==="linear"?r.every(d=>Jr(d)===Jr(r[0])):!1,[a,l]=KM({x:0,y:0}),s=mu(""),m=mu(null);wa(()=>{let d=[...n,...r].sort((x,w)=>x.id.localeCompare(w.id)),p=`
5
- ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${d.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(d.length===1){let[x,,,w,E,y]=oL(d[0],e.scene.getNonDeletedElementsMap());u=$M($s(x,w),$s(E,y),d[0].angle)}else{let{minX:x,maxY:w}=tL(d);u=$s(x,w)}let{x:f,y:b}=DE({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[n,r,e.scene,e.state]),wa(()=>{for(let d of r){let p=pu(d.id,kL(d));Ta.has(p)||Ta.set(p,d)}},[r]),wa(()=>{for(let d of n)if(!va.has(d.id)){let p=ME(d,e.scene.getNonDeletedElementsMap());p&&va.set(d.id,{fontSize:p.fontSize})}},[n,e.scene]);let c=t==="linear"?[["line",Fl],["sharpArrow",$l],["curvedArrow",ql],["elbowArrow",jl]]:t==="generic"?[["rectangle",Rl],["diamond",Nl],["ellipse",Bl]]:[];return hu("div",{ref:m,tabIndex:-1,style:{position:"absolute",top:`${a.y+(xL+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-bL}px`,zIndex:2},className:sL.CONVERT_ELEMENT_TYPE_POPUP,children:c.map(([d,p])=>{let u=i&&(t==="generic"&&n[0].type===d||t==="linear"&&Jr(r[0])===d);return hu(K,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:d,keyBindingLabel:"","aria-label":d,"data-testid":`toolbar-${d}`,onChange:()=>{e.state.activeTool.type!==d&&ne("convertElementType",d,"ui"),fu(e,{conversionType:t,nextType:d}),m.current?.focus()}},`${o[0].id}${o[0].version}_${d}`)})})},TL=(e,o,t)=>{let n=rL(e,o),r=nL(e,o),i=aL(o.text,su(o),n),a=CE(i,su(o),o.lineHeight),l=o.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...o,fontSize:l};a=CE(o.text,su(s),o.lineHeight)}Js(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),iL(o,e,t)},fu=(e,{conversionType:o,nextType:t,direction:n="right"})=>{if(!o)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=n==="right"?1:-1;if(o==="generic"){let l=PE(r),m=l.every(c=>c.type===l[0].type)?Ea.indexOf(l[0].type):-1;if(t=t??Ea[(m+Ea.length+a)%Ea.length],t&&Qr(t)){let c={};for(let p of l){let u=kE(p,t,e);c[u.id]=u}let d=[];for(let p of e.scene.getElementsIncludingDeleted())c[p.id]?d.push(c[p.id]):d.push(p);e.scene.replaceAllElements(d);for(let p of Object.values(c)){let u=ME(p,e.scene.getNonDeletedElementsMap());u&&(va.get(p.id)&&Js(u,e.scene.getNonDeletedElementsMap(),{fontSize:va.get(p.id)?.fontSize??u.fontSize}),TL(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:IE(p,{type:"selection"})}))}}if(o==="linear"){let l=uu(r);if(!t){let m=mL(l,Jr),c=m?ya.indexOf(m):-1;t=ya[(c+ya.length+a)%ya.length]}if(qs(t)){let m=[],c=e.scene.getElementsMapIncludingDeleted();for(let d of l){let p=Ta.get(pu(d.id,t));if(p&&Jr(p)===t)c.set(p.id,p),m.push(p);else{let u=kE(d,t,e);c.set(u.id,u),m.push(u)}}e.scene.replaceAllElements(c);for(let d of m)if(gu(d))if(QM(d)){let p=IL(d);if(p.length<2)continue;let u=[];for(let b=1;b<p.length-2;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=ZM(d,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Js(d,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=dL(["line","sharpArrow","curvedArrow"],u=>Ta.get(pu(d.id,u)));if(p){let u=p.points;e.scene.mutateElement(d,{points:u})}}}let s=uu(e.scene.getSelectedElements(e.state));e.setState(m=>({selectedElementIds:i,selectedLinearElement:s.length===1?new pL(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:IE(m,{type:"selection"})}))}return!0},ei=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(Qr(t.type))return"generic";LE(t)&&(o=!0)}return o?"linear":null},LE=e=>gu(e)&&(!JM(e)||!qM(e)&&!jM(e)),pu=(e,o)=>`${e}:${o}`,PE=e=>e.filter(o=>Qr(o.type)),uu=e=>e.filter(o=>LE(o)),Zs=20,jr=(e,o)=>e[0]===o[0],du=(e,o)=>e[1]===o[1],SE=(e,o)=>jr(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),IL=e=>{let o=[e.points[0]],t=CL(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<Zs?l[0]=a[0]:Math.abs(l[1]-a[1])<Zs&&(l[1]=a[1]),jr(a,l)||du(a,l)||o.push($s(a[0],l[1])),o.push(l)}let n=[o[0]];for(let i=1;i<o.length-1;++i)jr(o[i-1],o[i])&&jr(o[i],o[i+1])||du(o[i-1],o[i])&&du(o[i],o[i+1])||n.push(o[i]);n.push(o[o.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let a=r[r.length-1],l=n[i],s=n[i+1],m=jr(a,l),c=jr(l,s);if(m!==c){let d=SE(a,l),p=SE(l,s);if(d<Zs||p<Zs){if(p<d)m?s[0]=a[0]:s[1]=a[1];else if(c)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=l[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=l[1];continue}}r.push(l)}return r.push(n[n.length-1]),r},CL=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[n,r]=o[o.length-1],[i,a]=e[t];(n!==i||r!==a)&&o.push(e[t])}return o},kE=(e,o,t)=>{if(!SL(e.type,o)){if(!cL())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(gL.delete(e),Qr(o)){let n=qr(uL({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:eL(o)?js.ADAPTIVE_RADIUS:js.PROPORTIONAL_RADIUS}:e.roundness}));return fL(n,t.scene),n}if(qs(o))switch(o){case"line":return qr(hL({...e,type:"line"}));case"sharpArrow":return qr(cu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return qr(cu({...e,type:"arrow",elbowed:!1,roundness:{type:js.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return qr(cu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return lL(o,`unhandled conversion type: ${o}`),e},SL=(e,o)=>!!(Qr(e)&&Qr(o)||qs(e)&&qs(o)),kL=e=>gu(e)?Jr(e):e.type,AE=wL;var _E=B({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,n){return ze.set(eo,{type:"panel"}),{captureUpdate:ML.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>ei(e)!==null});import{canCreateLinkFromElements as bu,defaultGetElementLinkFromSelection as LL,getLinkIdAndTypeFromSelection as PL}from"@excalidraw/element";import{CaptureUpdateAction as Ia}from"@excalidraw/element";var Qs=B({name:"copyElementLink",label:"labels.copyElementLink",icon:yr,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=j(e,o);try{if(window.location){let i=PL(r,o);return i?(await so(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):LL(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:Ia.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:Ia.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:Ia.EVENTUALLY}},predicate:(e,o)=>bu(j(e,o))}),RE=B({name:"linkToElement",label:"labels.linkToElement",icon:Ql,perform:(e,o,t,n)=>{let r=j(e,o);return r.length!==1||!bu(r)?{elements:e,appState:o,app:n,captureUpdate:Ia.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:j(e,o)[0].id}},captureUpdate:Ia.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=j(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&bu(r)},trackEvent:!1});import{isDarwin as NE,getShortcutKey as oe}from"@excalidraw/common";var AL={toggleTheme:[oe("Shift+Alt+D")],saveScene:[oe("CtrlOrCmd+S")],loadScene:[oe("CtrlOrCmd+O")],clearCanvas:[oe("CtrlOrCmd+Delete")],imageExport:[oe("CtrlOrCmd+Shift+E")],commandPalette:[oe("CtrlOrCmd+/"),oe("CtrlOrCmd+Shift+P")],cut:[oe("CtrlOrCmd+X")],copy:[oe("CtrlOrCmd+C")],paste:[oe("CtrlOrCmd+V")],copyStyles:[oe("CtrlOrCmd+Alt+C")],pasteStyles:[oe("CtrlOrCmd+Alt+V")],selectAll:[oe("CtrlOrCmd+A")],deleteSelectedElements:[oe("Delete")],duplicateSelection:[oe("CtrlOrCmd+D"),oe(`Alt+${g("helpDialog.drag")}`)],sendBackward:[oe("CtrlOrCmd+[")],bringForward:[oe("CtrlOrCmd+]")],sendToBack:[NE?oe("CtrlOrCmd+Alt+["):oe("CtrlOrCmd+Shift+[")],bringToFront:[NE?oe("CtrlOrCmd+Alt+]"):oe("CtrlOrCmd+Shift+]")],copyAsPng:[oe("Shift+Alt+C")],group:[oe("CtrlOrCmd+G")],ungroup:[oe("CtrlOrCmd+Shift+G")],gridMode:[oe("CtrlOrCmd+'")],zenMode:[oe("Alt+Z")],objectsSnapMode:[oe("Alt+S")],stats:[oe("Alt+/")],addToLibrary:[],flipHorizontal:[oe("Shift+H")],flipVertical:[oe("Shift+V")],viewMode:[oe("Alt+R")],hyperlink:[oe("CtrlOrCmd+K")],toggleElementLock:[oe("CtrlOrCmd+Shift+L")],resetZoom:[oe("CtrlOrCmd+0")],zoomOut:[oe("CtrlOrCmd+-")],zoomIn:[oe("CtrlOrCmd++")],zoomToFitSelection:[oe("Shift+3")],zoomToFit:[oe("Shift+1")],zoomToFitSelectionInViewport:[oe("Shift+2")],toggleEraserTool:[oe("E")],toggleHandTool:[oe("H")],setFrameAsActiveTool:[oe("F")],saveFileToDisk:[oe("CtrlOrCmd+S")],saveToActiveFile:[oe("CtrlOrCmd+S")],toggleShortcuts:[oe("?")],searchMenu:[oe("CtrlOrCmd+F")],wrapSelectionInFrame:[]},Re=(e,o=0)=>{let t=AL[e];return t&&t.length>0?t[o]||t[0]:""};var DL="\\u0300-\\u036f",_L="\\ufe20-\\ufe2f",RL="\\u20d0-\\u20ff",NL=DL+_L+RL,BL=`[${NL}]`,FL=RegExp(BL,"g"),OL=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,zL={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},xu=e=>e.replace(OL,o=>zL[o]||o).replace(FL,"");import MA from"clsx";import{useEffect as LA,useState as PA}from"react";import{KEYS as AA,queryFocusableElements as _y}from"@excalidraw/common";import{useCallback as HL,useState as GL}from"react";var BE=()=>{let[e,o]=GL(null),t=HL(n=>o(n),[]);return[e,t]};import{useState as ky,useCallback as Ru,useMemo as My,useEffect as Iy,memo as Ly,useRef as bA}from"react";import{LIBRARY_DISABLED_TYPES as xA,randomId as EA,isShallowEqual as yA}from"@excalidraw/common";import{useEffect as HE,useRef as GE}from"react";import{URL_HASH_KEYS as wu,URL_QUERY_KEYS as vu,APP_NAME as UE,EVENT as tc,DEFAULT_SIDEBAR as XL,LIBRARY_SIDEBAR_TAB as KL,arrayToMap as Tu,cloneJSON as ZL,preventUnload as $L,promiseTry as YE,resolvablePromise as jL,toValidURL as qL,Queue as JL,Emitter as QL}from"@excalidraw/common";import{hashElementsVersion as eP,hashString as tP}from"@excalidraw/element";import{getCommonBoundingBox as yu}from"@excalidraw/element";import{MIME_TYPES as Xn}from"@excalidraw/common";var rn=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=mr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:m,viewBackgroundColor:c}=s;return vl(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:m,exportPadding:i,viewBackgroundColor:c,exportingFrame:a},(d,p)=>{let u=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(d,p),x=n<b?n/b:o?.exportScale??1;return u.width=d*x,u.height=p*x,{canvas:u,scale:x}}let f=r?.(d,p)||{width:d,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},FE=async e=>{let{mimeType:o=Xn.png,quality:t}=e;o===Xn.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${Xn.png}" mimeType`),o==="image/jpg"&&(o=Xn.jpg),o===Xn.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${Xn.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await rn(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((r,i)=>{n.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===Xn.png&&e.appState?.exportEmbedScene&&(a=await qf({blob:a,metadata:Bi(e.elements,e.appState,e.files||{},"local")})),r(a)},o,t)})},ti=async({elements:e,appState:o=Xo(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:m}=mr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),c={...m,exportPadding:n};return dr(s,c,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},UL=async e=>{if(e.type==="svg"){let o=await ti(e);await so(o.outerHTML)}else if(e.type==="png")await Ll(FE(e));else if(e.type==="json")await kl(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as YL,useState as WL}from"react";import{COLOR_PALETTE as VL}from"@excalidraw/common";var Eu=me(new Map),OE=async e=>await ti({elements:e,appState:{exportBackground:!1,viewBackgroundColor:VL.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),zE=(e,o,t)=>{let[n,r]=WL();return YL(()=>{if(o)if(e){let i=t.get(e);i?r(i):(async()=>{let a=await OE(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),r(a))})()}else(async()=>{let i=await OE(o);r(i)})()},[e,o,t,r]),n},ec=()=>{let[e]=ie(Eu);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var oP=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],VE=new QL,Kn=me({status:"loaded",isInitialized:!1,libraryItems:[]}),Ca=e=>ZL(e),nP=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((n,r)=>n.id===o.elements[r].id&&n.versionNonce===o.elements[r].versionNonce)),XE=(e,o)=>{let t=[];for(let n of o)nP(e,n)&&t.push(n);return[...t,...e]},KE=(e,o)=>{let t=Tu(o),n={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=Tu(e);for(let i of o)r.has(i.id)||n.addedItems.set(i.id,i);return n},Iu=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",Ca(this.currLibraryItems));I(this,"app");I(this,"updateQueue",[]);I(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);I(this,"notifyListeners",()=>{if(this.updateQueue.length>0)ze.set(Kn,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{ze.set(Kn,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Ca(this.currLibraryItems);let t=Ca(this.currLibraryItems);this.app.props.onLibraryChange?.(t),VE.trigger(KE(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],ze.set(Eu,new Map)});I(this,"resetLibrary",()=>this.setLibrary([]));I(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(Ca(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:XL.name,tab:KL}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),m;s instanceof Blob?m=await om(s,i):m=zi(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:m.length}))?(t&&this.app.focusContainer(),a(n?XE(this.currLibraryItems,m):m)):l(new sr)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Ca(await o),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},ZE=Iu,rc=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:w}=yu(x.elements);return Math.max(b,w)},0),i=u=>{let f=0,b=0,x=0;for(let w of e){if(f%t===0&&(b=0),b===u){let{width:E}=yu(w.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,m=0,c=0,d=0,p=0;for(let u of e){c&&c%t===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=r(p)),m=i(d);let{minX:f,minY:b,width:x,height:w}=yu(u.elements),E=(m-x)/2,y=(s-w)/2;n.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+y-b}))),a+=m+50,c++,d++}return n},rP=(e,o=oP)=>{if(typeof o=="function"?o(e):o.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Cu=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(wu.addLibrary)||new URLSearchParams(window.location.search).get(vu.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},an=class an{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,n=!0){let r=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(zi(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?an.queue.push(r):r()}getLibraryItems(o){return an.getLibraryItems(this.adapter,o,!1)}};I(an,"queue",new JL),I(an,"run",async(o,t)=>{let n=new an(o);return an.queue.push(()=>t(n))});var oi=an,Sa=0,oc=0,nc=e=>tP(e.map(o=>`${o.id}:${eP(o.elements)}`).sort().join()),WE=async(e,o)=>{try{return oc++,await oi.run(e,async t=>{let n=Tu(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)n.delete(l);let r=[];for(let[l,s]of o.addedItems)n.has(l)?n.set(l,s):r.push(s);let i=r.concat(Array.from(n.values())),a=nc(i);return a!==Sa&&await e.save({libraryItems:i}),Sa=a,i})}finally{oc--}},iP=e=>{let{excalidrawAPI:o}=e,t=GE(e);t.current=e;let n=GE(!1);HE(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let m=new Promise(async(d,p)=>{try{l=decodeURIComponent(l),l=qL(l),rP(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();d(f)}catch(u){p(u)}}),c=s!==o.id;await(c&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:m,prompt:c,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw o.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(wu.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(wu.addLibrary),window.history.replaceState({},UE,`#${d.toString()}`)}else if(window.location.search.includes(vu.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(vu.addLibrary),window.history.replaceState({},UE,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=Cu();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=Cu();if(a&&r(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,m=jL();s?m.resolve(YE(s.load).then(async c=>{let d=null;try{if(!c)return oi.getLibraryItems(l,"load");d=zi(c.libraryItems||[],"published");let p=await WE(l,KE([],d));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),d}}).catch(c=>(console.error(`error during library migration: ${c.message}`),oi.getLibraryItems(l,"load")))):m.resolve(YE(oi.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:m.then(c=>{let d=c||[];return Sa=nc(d),d}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(tc.HASHCHANGE,i),()=>{window.removeEventListener(tc.HASHCHANGE,i)}},[o]),HE(()=>{let r=VE.on(async(a,l)=>{let s=n.current,m="adapter"in t.current&&t.current.adapter||null;try{m&&Sa!==nc(l)&&await WE(m,a)}catch(c){console.error(`couldn't persist library update: ${c.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{oc&&$L(a)};return window.addEventListener(tc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(tc.BEFORE_UNLOAD,i),r(),Sa=0,oc=0}},[])};import cP from"clsx";import{VERSIONS as aP}from"@excalidraw/common";import{jsx as sP}from"react/jsx-runtime";var lP=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return sP("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${n}&useHash=true&token=${o}&theme=${e}&version=${aP.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},$E=lP;import{jsx as dP,jsxs as mP}from"react/jsx-runtime";var ic=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>mP("div",{className:cP("library-menu-control-buttons",i),style:n,children:[dP($E,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as ii,useEffect as cA,useMemo as vy,useRef as dA,useState as mA}from"react";import{MIME_TYPES as pA,arrayToMap as uA}from"@excalidraw/common";import{duplicateElements as hA}from"@excalidraw/element";import pP from"lodash.throttle";import{useEffect as uP}from"react";var hP=me(0),jE=e=>{let[o,t]=ie(hP);return uP(()=>{let{current:n}=e;if(!n)return;let r=pP(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import XP from"clsx";import{useCallback as KP,useState as Lu}from"react";import{muteFSAbortError as ZP}from"@excalidraw/common";import{flushSync as qE}from"react-dom";import gP from"clsx";import{jsx as ac,jsxs as bP}from"react/jsx-runtime";var fP=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return bP("button",{className:gP("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[n&&ac("div",{style:a?{visibility:"hidden"}:{},children:n}),ac("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&ac("div",{style:{position:"absolute",inset:0},children:ac(et,{})})]})},Ao=fP;import{jsx as JE,jsxs as QE}from"react/jsx-runtime";var xP=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=le(),m=Ko(ni),{container:c}=He();return QE(Ne,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,QE("div",{className:"confirm-dialog-buttons",children:[JE(Ao,{label:i,onClick:()=>{s({openMenu:null}),m(!1),qE(()=>{t()}),c?.focus()}}),JE(Ao,{label:r,onClick:()=>{s({openMenu:null}),m(!1),qE(()=>{o()}),c?.focus()},actionType:"danger"})]})]})},lc=xP;import cc from"open-color";import{useCallback as CP,useEffect as Mu,useRef as ey,useState as Su}from"react";import{EDITOR_LS_KEYS as ku,EXPORT_DATA_TYPES as SP,MIME_TYPES as ty,VERSIONS as kP,chunk as MP,getExportSource as LP}from"@excalidraw/common";var Ht=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};I(Ht,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),I(Ht,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import sc from"react";var EP=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,yP=/{{([\w-]+)}}/,wP=/<([\w-]+)>/,vP=/<\/([\w-]+)>/,TP=(e,o)=>{let t=[{name:"",children:[]}];return e.split(EP).filter(Boolean).forEach(n=>{let r=n.match(wP),i=n.match(vP),a=n.match(yP);if(r!==null){let l=r[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),m=sc.createElement(sc.Fragment,{},...s.children),c=o[s.name];typeof c=="function"&&t[t.length-1].children.push(c(m))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(n)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},IP=({i18nKey:e,children:o,...t})=>{let{t:n}=Oe();return sc.createElement(sc.Fragment,{},...TP(n(e),t))},pt=IP;import{jsx as ae,jsxs as it}from"react/jsx-runtime";var PP=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=MP(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(n*2)-n*2,a.height=i.length*128+(i.length+1)*(n*2)-n*2;let l=a.getContext("2d");l.fillStyle=cc.white,l.fillRect(0,0,a.width,a.height);for(let[s,m]of e.entries()){let c=await rn({elements:m.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=c,u=Math.floor(s/6)*(128+n*2),f=s%6*(128+n*2);l.drawImage(c,f+(128-d)/2+n,u+(128-p)/2+n),l.lineWidth=r,l.strokeStyle=cc.gray[4],l.strokeRect(f+n/2,u+n/2,128+n,128+n)}return await Sl(new File([await To(a)],"preview",{type:ty.png}),{outputType:ty.jpg,maxWidthOrHeight:5e3})},AP=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=ey(null),a=ey(null);return Mu(()=>{let l=i.current;l&&(async()=>{let s=await ti({elements:e.elements,appState:{...o,viewBackgroundColor:cc.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),it("div",{className:"single-library-item",children:[e.status==="published"&&ae("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),ae("div",{ref:i,className:"single-library-item__svg"}),ae(K,{"aria-label":g("buttons.remove"),type:"button",icon:Bt,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:g("buttons.remove")}),it("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[it("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[it("div",{style:{padding:"0.5em 0"},children:[ae("span",{style:{fontWeight:500,color:cc.gray[6]},children:g("publishDialog.itemName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{n(l.target.value,t)}})]}),ae("span",{className:"error",children:e.error})]})]})},DP=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Su({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[m,c]=Su(!1);Mu(()=>{let y=Ht.get(ku.PUBLISH_LIBRARY);y&&s(y)},[]);let[d,p]=Su(o.slice());Mu(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),c(!0);let v=[],C=!1;if(d.forEach(N=>{let O="";N.name||(O=g("publishDialog.errors.required"),C=!0),v.push({...N,error:O})}),C){p(v),c(!1);return}let S=await PP(d),L={type:SP.excalidrawLibrary,version:kP.excalidrawLibrary,source:LP(),libraryItems:d},k=JSON.stringify(L,null,2),A=new Blob([k],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",A),P.append("previewImage",S),P.append("previewImageType",S.type),P.append("title",l.name),P.append("authorName",l.authorName),P.append("githubHandle",l.githubHandle),P.append("name",l.name),P.append("description",l.description),P.append("twitterHandle",l.twitterHandle),P.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(N=>N.ok?N.json().then(({url:O})=>{Ht.delete(ku.PUBLISH_LIBRARY),n({url:O,authorName:l.authorName,items:d})}):N.json().catch(()=>{throw new Error(N.statusText||"something went wrong")}).then(O=>{throw new Error(O.message||N.statusText||"something went wrong")}),N=>{console.error(N),r(N),c(!1)}).catch(N=>{console.error(N),r(N),c(!1)})},b=()=>{let y=[];return d.forEach((v,C)=>{y.push(ae("div",{className:"single-library-item-wrapper",children:ae(AP,{libItem:v,appState:t,index:C,onChange:(S,L)=>{let k=d.slice();k[L].name=S,p(k)},onRemove:a})},C))}),ae("div",{className:"selected-library-items",children:y})},x=CP(()=>{i(d),Ht.set(ku.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),w=!!o.length,E=o.some(y=>y.status==="published");return ae(Ne,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:w?it("form",{onSubmit:f,children:[ae("div",{className:"publish-library-note",children:ae(pt,{i18nKey:"publishDialog.noteDescription",link:y=>ae("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),ae("span",{className:"publish-library-note",children:ae(pt,{i18nKey:"publishDialog.noteGuidelines",link:y=>ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),ae("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&ae("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),it("div",{className:"publish-library__fields",children:[it("label",{children:[it("div",{children:[ae("span",{children:g("publishDialog.libraryName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),it("label",{style:{alignItems:"flex-start"},children:[it("div",{children:[ae("span",{children:g("publishDialog.libraryDesc")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),it("label",{children:[it("div",{children:[ae("span",{children:g("publishDialog.authorName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),it("label",{children:[ae("span",{children:g("publishDialog.githubUsername")}),ae("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),it("label",{children:[ae("span",{children:g("publishDialog.twitterUsername")}),ae("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),it("label",{children:[ae("span",{children:g("publishDialog.website")}),ae("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),ae("span",{className:"publish-library-note",children:ae(pt,{i18nKey:"publishDialog.noteLicense",link:y=>ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),it("div",{className:"publish-library__buttons",children:[ae(Ao,{label:g("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),ae(Ao,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:m})]})]}):ae("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},oy=DP;import NP from"clsx";import{useEffect as BP,useRef as FP}from"react";import{EVENT as ay,KEYS as OP}from"@excalidraw/common";import{forwardRef as ny}from"react";import ry from"clsx";import{jsx as iy}from"react/jsx-runtime";var _P=ny(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>iy("div",{className:ry("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:a,children:e})),RP=ny(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>iy("div",{className:ry("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:a,children:e})),je={Row:_P,Col:RP};import{jsx as dc}from"react/jsx-runtime";var ly=({children:e,onClickOutside:o,className:t="",onSelect:n,style:r})=>{let i=ce(),a=FP(null),l=$o({onClickOutside:o});kr(a,()=>{l.onClickOutside?.()}),BP(()=>{let m=d=>{d.key===OP.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},c={capture:!0};return document.addEventListener(ay.KEYDOWN,m,c),()=>{document.removeEventListener(ay.KEYDOWN,m,c)}},[l]);let s=NP(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return dc(tp.Provider,{value:{onSelect:n},children:dc("div",{ref:a,className:s,style:r,"data-testid":"dropdown-menu",children:i.editor.isMobile?dc(je.Col,{className:"dropdown-menu-container",children:e}):dc(Ve,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};ly.displayName="DropdownMenuContent";var sy=ly;import{jsx as HP}from"react/jsx-runtime";var zP=({children:e,className:o="",selected:t,...n})=>HP("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),cy=zP;import{jsx as dy}from"react/jsx-runtime";var my=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let m=Es(s.onClick,r);return dy("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:xs(i,a),title:s.title??s["aria-label"],onClick:m,children:dy(bs,{icon:e,shortcut:o,children:n})})},ri=my;my.displayName="DropdownMenuItemLink";import{jsx as GP}from"react/jsx-runtime";var py=()=>GP("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),uy=py;py.displayName="DropdownMenuSeparator";import UP from"clsx";import{jsx as YP}from"react/jsx-runtime";var hy=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=ce(),a=UP(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return YP("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},gy=hy;hy.displayName="DropdownMenuTrigger";import mc from"react";var fy=e=>{let o=mc.Children.toArray(e).find(t=>mc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},by=e=>{let o=mc.Children.toArray(e).find(t=>mc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as WP,jsxs as VP}from"react/jsx-runtime";var Do=({children:e,open:o})=>{let t=fy(e),n=by(e);return VP(WP,{children:[t,o&&n]})};Do.Trigger=gy;Do.Content=sy;Do.Item=dt;Do.ItemLink=ri;Do.ItemCustom=cy;Do.Group=ta;Do.Separator=uy;var fe=Do;Do.displayName="DropdownMenu";import{jsx as wt,jsxs as pc}from"react/jsx-runtime";var $P=(e,o)=>e.filter(t=>o.includes(t.id)),jP=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=ie(Kn),[m,c]=ie(ni),d=()=>{let P=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),N=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return wt(lc,{onConfirm:()=>{o.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:N,children:wt("p",{children:P})})},[p,u]=Lu(!1),f=!!o.length,b=f?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[w,E]=Lu(!1),[y,v]=Lu(null),C=KP(()=>pc(Ne,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[wt("p",{children:wt(pt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>wt("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),wt(K,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(P,N)=>{E(!1),v({url:P.url,authorName:P.authorName});let O=N.slice();O.forEach(U=>{o.includes(U.id)&&(U.status="published")}),t.setLibrary(O)},L=async()=>{try{await t.updateLibrary({libraryItems:bl({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:g("errors.importLibraryError")})}},k=async()=>{let P=f?b:await t.getLatestLibrary();Gf(P).catch(ZP).catch(N=>{e({errorMessage:N.message})})},A=()=>pc(fe,{open:m,children:[wt(fe.Trigger,{onToggle:()=>c(!m),children:g1}),pc(fe.Content,{onClickOutside:()=>c(!1),onSelect:()=>c(!1),className:"library-menu",children:[!f&&wt(fe.Item,{onSelect:L,icon:Er,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&wt(fe.Item,{onSelect:k,icon:Rn,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&wt(fe.Item,{onSelect:()=>u(!0),icon:kt,children:x}),f&&wt(fe.Item,{icon:I0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return pc("div",{className:XP("library-menu-dropdown-container",l),children:[A(),o.length>0&&wt("div",{className:"library-actions-counter",children:o.length}),p&&d(),w&&wt(oy,{onClose:()=>E(!1),libraryItems:$P(s.libraryItems,o),appState:a,onSuccess:P=>S(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(N=>N!==P))}),y&&C()]})},Pu=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=_e(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=ec(),a=ge(),l=le(),[s]=ie(Kn),m=async d=>{let p=d.filter(u=>!e.includes(u.id));n.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return wt(jP,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>m(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as iA,useEffect as aA,useState as lA}from"react";import qP,{useCallback as JP}from"react";function QP(){return[!1,JP(o=>o(),[])]}var xy=qP.useTransition||QP;import Ey from"clsx";import{memo as eA,useEffect as tA,useRef as oA,useState as nA}from"react";import{jsx as uc,jsxs as rA}from"react/jsx-runtime";var yy=eA(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=oA(null),m=zE(e,o,l);tA(()=>{let f=s.current;if(f)return m&&(f.innerHTML=m.outerHTML),()=>{f.innerHTML=""}},[m]);let[c,d]=nA(!1),p=ce().editor.isMobile,u=t&&uc("div",{className:"library-unit__adder",children:h1});return rA("div",{className:Ey("library-unit",{"library-unit__active":o,"library-unit--hover":o&&c,"library-unit--selected":r,"library-unit--skeleton":!m}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[uc("div",{className:Ey("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):n(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}d(!1),a(e,f)}}),u,e&&o&&(c||p||r)&&uc(da,{checked:r,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),wy=()=>uc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as sA,jsx as hc}from"react/jsx-runtime";var Au=({children:e})=>hc("div",{className:"library-menu-items-container__grid",children:e}),gc=iA(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=xy(),[s,m]=lA(0);return aA(()=>{s<e.length&&l(()=>{m(s+a)})},[s,e.length,l,a]),hc(sA,{children:e.map((c,d)=>d<s?hc(yy,{elements:c?.elements,isPending:!c?.id&&!!c?.elements,onClick:r,svgCache:i,id:c?.id,selected:n(c.id),onToggle:o,onDrag:t},c?.id??d):hc(wy,{},d))})});import{Fragment as Ty,jsx as vt,jsxs as ai}from"react/jsx-runtime";var gA=17,fA=64;function Du({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:m}){let c=dA(null),d=jE(c);cA(()=>{d>0&&c.current?.scrollTo(0,d)},[]);let{svgCache:p}=ec(),u=vy(()=>o.filter(P=>P.status!=="published"),[o]),f=vy(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!r.length,x=!r.length&&!u.length&&!f.length,[w,E]=mA(null),y=ii((P,N)=>{let O=!m.includes(P),U=[...u,...f];if(O){if(N.shiftKey&&w){let J=U.findIndex(Z=>Z.id===w),_=U.findIndex(Z=>Z.id===P);if(J===-1||_===-1){s([...m,P]);return}let R=uA(m),V=U.reduce((Z,W,se)=>((se>=J&&se<=_||R.has(W.id))&&Z.push(W.id),Z),[]);s(V)}else s([...m,P]);E(P)}else E(null),s(m.filter(J=>J!==P))},[w,s,f,m,u]),v=ii(P=>{let N;return m.includes(P)?N=o.filter(O=>m.includes(O.id)):N=o.filter(O=>O.id===P),N.map(O=>({...O,elements:hA({type:"everything",elements:O.elements,randomizeSeed:!0}).duplicatedElements}))},[o,m]),C=ii((P,N)=>{N.dataTransfer.setData(pA.excalidrawlib,Qd(v(P)))},[v]),S=ii(P=>P?m.includes(P):!1,[m]),L=ii(()=>{t(r)},[r,t]),k=ii(P=>{P&&n(v(P))},[v,n]),A=p.size>=o.length?fA:gA;return ai("div",{className:"library-menu-items-container",style:r.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&vt(Pu,{selectedItems:m,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),ai(je.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:c,children:[ai(Ty,{children:[!x&&vt("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),e&&vt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:vt(et,{})}),!r.length&&!u.length?ai("div",{className:"library-menu-items__no-items",children:[vt("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),vt("div",{className:"library-menu-items__no-items__hint",children:f.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):ai(Au,{children:[r.length>0&&vt(gc,{itemsRenderedPerBatch:A,items:[{id:null,elements:r}],onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p}),vt(gc,{itemsRenderedPerBatch:A,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})]})]}),ai(Ty,{children:[(f.length>0||r.length>0||u.length>0)&&vt("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:g("labels.excalidrawLib")}),f.length>0?vt(Au,{children:vt(gc,{itemsRenderedPerBatch:A,items:f,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})}):u.length>0?vt("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:g("library.noItems")}):null]}),b&&vt(ic,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:vt(Pu,{selectedItems:m,onSelectItems:s})})]})]})}import{jsx as ln,jsxs as Sy}from"react/jsx-runtime";var ni=me(!1),Cy=({children:e})=>ln("div",{className:"layer-ui__library",children:e}),wA=Ly(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:m})=>{let[c]=ie(Kn),d=Ru(f=>{(async(x,w)=>{ne("element","addToLibrary","ui");for(let y of xA)if(x.some(v=>v.type===y))return n({errorMessage:g(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:EA(),created:Date.now()},...w];t(),i.setLibrary(E).catch(()=>{n({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,c.libraryItems)},[t,i,n,c.libraryItems]),p=My(()=>c.libraryItems,[c]);if(c.status==="loading"&&!c.isInitialized)return ln(Cy,{children:ln("div",{className:"layer-ui__library-message",children:Sy("div",{children:[ln(et,{size:"2em"}),ln("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=c.libraryItems.length>0||o.length>0;return Sy(Cy,{children:[ln(Du,{isLoading:c.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:r,theme:l,onSelectItems:m,selectedItems:s}),u&&ln(ic,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),_u=(e,o)=>({elements:e,pending:j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),vA=(e,o)=>{let t=Jo(),[n,r]=ky(()=>_u(t,e.selectedElementIds)),i=bA(new Map);return Iy(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),Iy(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(a=>{if(!yA(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),_u(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let m=l.get(s)?.version;if(m&&m!==i.current.get(s))return _u(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},Py=Ly(()=>{let e=_e(),{onInsertElements:o}=e,t=po(),n=ge(),r=le(),[i,a]=ky([]),l=My(()=>e.library,[e.library]),s=vA(n,e),m=Ru(d=>{o(rc(d))},[o]),c=Ru(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return ln(wA,{pendingElements:s,onInsertLibraryItems:m,onAddToLibrary:c,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import TA from"clsx";import{useRef as IA}from"react";import{createPortal as CA}from"react-dom";import{KEYS as SA}from"@excalidraw/common";import{jsx as Ay,jsxs as kA}from"react/jsx-runtime";var Dy=e=>{let{closeOnClickOutside:o=!0}=e,t=ss({className:"excalidraw-modal-container"}),n=IA(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===SA.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return CA(kA("div",{className:TA("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Ay("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),Ay("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as ka,jsxs as _A}from"react/jsx-runtime";function DA(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Ne=e=>{let[o,t]=BE(),[n]=PA(document.activeElement),{id:r}=He(),i=ce().viewport.isMobile;LA(()=>{if(!o)return;let m=_y(o);setTimeout(()=>{m.length>0&&e.autofocus!==!1&&(m[1]||m[0]).focus()});let c=d=>{if(d.key===AA.TAB){let p=_y(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):f===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",c),()=>o.removeEventListener("keydown",c)},[o,e.autofocus]);let a=le(),l=Ko(ni),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return ka(Dy,{className:MA("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:DA(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:_A(Ve,{ref:t,children:[e.title&&ka("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:ka("span",{className:"Dialog__titleContent",children:e.title})}),i&&ka("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Bt}),ka("div",{className:"Dialog__content",children:e.children})]})})};import Nu from"clsx";import{forwardRef as FA,useRef as OA,useImperativeHandle as zA,useLayoutEffect as HA,useState as GA}from"react";import RA from"clsx";import{composeEventHandlers as NA}from"@excalidraw/common";import{jsx as BA}from"react/jsx-runtime";var _t=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>BA("button",{onClick:NA(i.onClick,a=>{o()}),type:e,className:RA("excalidraw-button",r,{selected:t}),...i,children:n});import{jsx as Bu,jsxs as Ry}from"react/jsx-runtime";var li=FA(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:m,...c},d)=>{let p=OA(null);zA(d,()=>p.current),HA(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=GA(!1);return Ry("div",{className:Nu("ExcTextField",m,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&Bu("div",{className:"ExcTextField__label",children:o}),Ry("div",{className:Nu("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[Bu("input",{className:Nu({"is-redacted":"value"in c&&c.value&&l&&!u}),readOnly:r,value:"value"in c?c.value:void 0,defaultValue:"defaultValue"in c?c.defaultValue:void 0,placeholder:n,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&Bu(_t,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?D0:vr})]})]})});import{KEYS as Be}from"@excalidraw/common";var fc=[{icon:sm,value:"selection",key:Be.V,numericKey:Be[1],fillable:!0},{icon:Rl,value:"rectangle",key:Be.R,numericKey:Be[2],fillable:!0},{icon:Nl,value:"diamond",key:Be.D,numericKey:Be[3],fillable:!0},{icon:Bl,value:"ellipse",key:Be.O,numericKey:Be[4],fillable:!0},{icon:w1,value:"arrow",key:Be.A,numericKey:Be[5],fillable:!0},{icon:Fl,value:"line",key:Be.L,numericKey:Be[6],fillable:!0},{icon:Zo,value:"freedraw",key:[Be.P,Be.X],numericKey:Be[7],fillable:!1},{icon:br,value:"text",key:Be.T,numericKey:Be[8],fillable:!1},{icon:T1,value:"image",key:null,numericKey:Be[9],fillable:!1},{icon:I1,value:"eraser",key:Be.E,numericKey:Be[0],fillable:!1}],Fu=e=>e.defaultSelectionTool==="lasso"?[{value:"lasso",icon:sm,key:Be.V,numericKey:Be[1],fillable:!0},...fc.slice(1)]:fc,Ny=(e,o)=>Fu(o).find((n,r)=>n.numericKey!=null&&e===n.numericKey.toString()||n.key&&(typeof n.key=="string"?n.key===e:n.key.includes(e)))?.value||null;import Gu from"clsx";import{useState as WA}from"react";import{CLASSES as VA,KEYS as Fy,capitalizeString as Hu,isTransparent as Oy}from"@excalidraw/common";import{shouldAllowVerticalAlign as XA,suppportsHorizontalAlign as KA}from"@excalidraw/element";import{hasBoundTextElement as zy,isElbowArrow as ZA,isImageElement as $A,isLinearElement as jA,isTextElement as qA}from"@excalidraw/element";import{hasStrokeColor as Hy,toolIsArrow as Gy}from"@excalidraw/element";import{createIsolation as UA}from"jotai-scope";import Ou from"react";import fo from"tunnel-rat";var zu=Ou.createContext(null),we=()=>Ou.useContext(zu),YA=UA(),By=()=>Ou.useMemo(()=>({MainMenuTunnel:fo(),WelcomeScreenMenuHintTunnel:fo(),WelcomeScreenToolbarHintTunnel:fo(),WelcomeScreenHelpHintTunnel:fo(),WelcomeScreenCenterTunnel:fo(),FooterCenterTunnel:fo(),DefaultSidebarTriggerTunnel:fo(),DefaultSidebarTabTriggersTunnel:fo(),OverwriteConfirmDialogTunnel:fo(),TTDDialogTriggerTunnel:fo(),tunnelsJotai:YA}),[]);import{Fragment as _o,jsx as ve,jsxs as Ze}from"react/jsx-runtime";var Uu=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return Hy(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>Hy(n.type))},Yu=(e,o)=>Wo(e.activeTool.type)||o.some(t=>Wo(t.type)),bc=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=fl(o,e),i=!1;r.length===2&&(zy(r[0])||zy(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=ce(),s=document.documentElement.getAttribute("dir")==="rtl",m=Wo(e.activeTool.type)&&!Oy(e.currentItemBackgroundColor)||r.some(f=>Wo(f.type)&&!Oy(f.backgroundColor)),c=r.length===1||i,d=!e.selectedLinearElement?.isEditing&&r.length===1&&jA(r[0])&&!ZA(r[0]),p=!e.croppingElementId&&r.length===1&&$A(r[0]),u=!i&&yt(e,n);return Ze("div",{className:"selected-shape-actions",children:[ve("div",{children:Uu(e,r)&&t("changeStrokeColor")}),Yu(e,r)&&ve("div",{children:t("changeBackgroundColor")}),m&&t("changeFillStyle"),(Zd(e.activeTool.type)||r.some(f=>Zd(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),($d(e.activeTool.type)||r.some(f=>$d(f.type)))&&Ze(_o,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(jd(e.activeTool.type)||r.some(f=>jd(f.type)))&&ve(_o,{children:t("changeRoundness")}),(Gy(e.activeTool.type)||r.some(f=>Gy(f.type)))&&ve(_o,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(qA))&&Ze(_o,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||KA(r,o))&&t("changeTextAlign")]}),XA(r,o)&&t("changeVerticalAlign"),(lr(e.activeTool.type)||r.some(f=>lr(f.type)))&&ve(_o,{children:t("changeArrowhead")}),t("changeOpacity"),Ze("fieldset",{children:[ve("legend",{children:g("labels.layers")}),Ze("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&Ze("fieldset",{children:[ve("legend",{children:g("labels.align")}),Ze("div",{className:"buttonList",children:[s?Ze(_o,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):Ze(_o,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),ve("div",{style:{flexBasis:"100%",height:0}}),Ze("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically")]})]})]}),!a&&r.length>0&&Ze("fieldset",{children:[ve("legend",{children:g("labels.actions")}),Ze("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),c&&t("hyperlink"),p&&t("cropEditor"),d&&t("toggleLinearEditor")]})]})]})},xc=({activeTool:e,appState:o,app:t,UIOptions:n})=>{let[r,i]=WA(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso"&&t.defaultSelectionTool!=="lasso",m=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=we();return Ze(_o,{children:[Fu(t).map(({value:d,icon:p,key:u,numericKey:f,fillable:b},x)=>{if(n.tools?.[d]===!1)return null;let w=g(`toolBar.${d}`),E=u&&Hu(typeof u=="string"?u:u[0]),y=E?`${E} ${g("helpDialog.or")} ${f}`:`${f}`;return ve(K,{className:Gu("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===d,name:"editor-current-shape",title:`${Hu(w)} \u2014 ${y}`,keyBindingLabel:f||E,"aria-label":Hu(w),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),d==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==d&&ne("toolbar",d,"ui"),d==="image"?t.setActiveTool({type:d}):t.setActiveTool({type:d})}},d)}),ve("div",{className:"App-toolbar__divider"}),Ze(fe,{open:r,children:[ve(fe.Trigger,{className:Gu("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||m||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!r),title:g("toolBar.extraTools"),children:a?Bn:m?mm:l&&!t.props.isCollaborating?Xi:s?Hi:P0}),Ze(fe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[ve(fe.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:Bn,shortcut:Fy.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:g("toolBar.frame")}),ve(fe.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:mm,"data-testid":"toolbar-embeddable",selected:m,children:g("toolBar.embeddable")}),ve(fe.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Xi,"data-testid":"toolbar-laser",selected:l,shortcut:Fy.K.toLocaleUpperCase(),children:g("toolBar.laser")}),t.defaultSelectionTool!=="lasso"&&ve(fe.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:Hi,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),ve("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&ve(c.Out,{}),ve(fe.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Xl,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&ve(_o,{children:Ze(fe.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:Kl,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),ve(fe.Item.Badge,{children:"AI"})]})})]})]})]})},Uy=({renderAction:e,zoom:o})=>ve(je.Col,{gap:1,className:VA.ZOOM_ACTIONS,children:Ze(je.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),Yy=({renderAction:e,className:o})=>Ze("div",{className:`undo-redo-buttons ${o}`,children:[ve("div",{className:"undo-button-container",children:ve(Lt,{label:g("buttons.undo"),children:e("undo")})}),ve("div",{className:"redo-button-container",children:Ze(Lt,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),Wy=({actionManager:e,showExitZenModeBtn:o})=>ve("button",{type:"button",className:Gu("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(Kr),children:g("buttons.exitZenMode")});import{useRef as JA}from"react";var Wu=e=>{let o=JA({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as e8,jsxs as QA}from"react/jsx-runtime";var Zn=me(null),Vy=()=>{let[e,o]=ie(Zn),t=Ge();return e&&e==="clearCanvas"?e8(lc,{onConfirm:()=>{t.executeAction(Lo),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:QA("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var Vu={};Nf(Vu,{toggleTheme:()=>t8});var t8={...Hn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Hn,"commandPalette")}};import{jsx as at,jsxs as bo}from"react/jsx-runtime";var l8=me(null),Se={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},s8=e=>{switch(e){case Se.app:return 1;case Se.export:return 2;case Se.editor:return 3;case Se.tools:return 4;case Se.elements:return 5;case Se.links:return 6;default:return 10}},wc=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return bo("div",{className:Zy("shortcut",o),children:[n.map((r,i)=>at("div",{className:"shortcut-wrapper",children:at("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),at("div",{className:"shortcut-desc",children:t})]})},$y=e=>!e.altKey&&e[to.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===to.P||e.key===to.SLASH),cse=Object.assign(e=>{let o=ge(),t=le();return yc(()=>{let n=r=>{$y(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ne("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(vc.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(vc.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:at(c8,{...e})},{defaultItems:Vu});function c8({customCommandPaletteItems:e}){let o=_e(),t=ge(),n=le(),r=po(),i=Ge(),[a,l]=ie(l8),[s,m]=Ec(null),c=n8(null),d=$o({uiAppState:t,customCommandPaletteItems:e,appProps:r});yc(()=>{let{uiAppState:S,customCommandPaletteItems:L,appProps:k}=d,A=U=>{let J="";return U.label&&(typeof U.label=="function"?J=g(U.label(o.scene.getNonDeletedElements(),S,o)):J=g(U.label)),J},P=U=>typeof U.icon=="function"?U.icon(S,o.scene.getNonDeletedElements()):U.icon,N=[],O=(U,J,_)=>{let R={label:A(U),icon:P(U),category:J,shortcut:Re(U.name),keywords:U.keywords,predicate:U.predicate,viewMode:U.viewMode,perform:()=>{i.executeAction(U,"commandPalette")}};return _?_(R,U):R};if(S&&o.scene&&i){let U=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,ba,Qs,RE].map(W=>O(W,Se.elements,(se,he)=>({...se,predicate:he.predicate?he.predicate:(de,rt,ao,ir)=>j(de,rt).length>0}))),J=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(W=>O(W,Se.tools)),_=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(W=>O(W,Se.editor)),R=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(W=>O(W,Se.export));N=[...U,..._,{label:A(Lo),icon:P(Lo),shortcut:Re(Lo.name),category:Se.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{ze.set(Zn,"clearCanvas")}},{label:g("buttons.exportImage"),category:Se.export,icon:Gl,shortcut:Re("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...R];let V=[{label:g("toolBar.library"),category:Se.app,icon:gr,viewMode:!1,perform:()=>{S.openSidebar?n({openSidebar:null}):n({openSidebar:{name:Xy.name,tab:Xy.defaultTab}})}},{label:g("search.title"),category:Se.app,icon:Mt,viewMode:!0,perform:()=>{i.executeAction(Ma)}},{label:g("labels.shapeSwitch"),category:Se.elements,icon:Ki,perform:()=>{i.executeAction(_E)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Se.elements,icon:Hl,viewMode:!1,predicate:(W,se)=>{let he=j(W,se);return he.length>0&&Uu(se,he)},perform:()=>{n(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:Hl,category:Se.elements,viewMode:!1,predicate:(W,se)=>{let he=j(W,se);return he.length>0&&Yu(se,he)},perform:()=>{n(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:Hl,category:Se.editor,viewMode:!1,perform:()=>{n(W=>({openMenu:W.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...fc.reduce((W,se)=>{let{value:he,icon:de,key:rt,numericKey:ao}=se;if(k.UIOptions.tools?.[he]===!1)return W;let ar=rt&&r8(typeof rt=="string"?rt:rt[0])||ao,hl={label:g(`toolBar.${he}`),category:Se.tools,shortcut:ar,icon:de,keywords:["toolbar"],viewMode:!1,perform:({event:Vd})=>{he==="image"?o.setActiveTool({type:he}):o.setActiveTool({type:he})}};return W.push(hl),W},[]),...J,{label:g("toolBar.lock"),category:Se.tools,icon:S.activeTool.locked?fr:_n,shortcut:to.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Se.tools,icon:R0,viewMode:!1,predicate:k.aiEnabled,perform:()=>{n(W=>({...W,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Se.tools,icon:Xl,viewMode:!1,predicate:k.aiEnabled,perform:()=>{n(W=>({...W,openDialog:{name:"ttd",tab:"mermaid"}}))}}],Z=[...N,...V,...L||[]].map(W=>({...W,icon:W.icon||Ki,order:W.order??s8(W.category),haystack:`${xu(W.label.toLocaleLowerCase())} ${W.keywords?.join(" ")||""}`}));m(Z),l(Z.find(W=>W.label===a?.label)??null)}},[d,o,i,m,a?.label,l,n]);let[p,u]=Ec(""),[f,b]=Ec(null),[x,w]=Ec({}),E=S=>{n({openDialog:null},S),u("")},y=(S,L)=>{t.openDialog?.name==="commandPalette"&&(L.stopPropagation(),L.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),E(()=>{S.perform({actionManager:i,event:L}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=Wu(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,r,o):S.predicate===void 0||S.predicate),C=Wu(S=>{let L=a8(S.target)||$y(S)||S.key===to.ESCAPE;if(L&&S.key!==to.ARROW_UP&&S.key!==to.ARROW_DOWN&&S.key!==to.ENTER)return;let k=Object.values(x).flat(),A=a&&!p&&v(a);if(S.key===to.ARROW_UP){S.preventDefault();let P=k.findIndex(U=>U.label===f?.label);if(A){if(P===0){b(a);return}if(f===a){let U=k[k.length-1];U&&b(U);return}}let N;P===-1?N=k.length-1:N=P===0?k.length-1:(P-1)%k.length;let O=k[N];O&&b(O);return}if(S.key===to.ARROW_DOWN){S.preventDefault();let P=k.findIndex(U=>U.label===f?.label);if(A){if(!f||P===k.length-1){b(a);return}if(f===a){let U=k[0];U&&b(U);return}}let N=(P+1)%k.length,O=k[N];O&&b(O);return}if(S.key===to.ENTER&&f&&setTimeout(()=>{y(f,S)}),!L){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){c?.current?.focus();return}S.preventDefault()}});return yc(()=>(window.addEventListener(vc.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(vc.KEYDOWN,C,{capture:!0})),[C]),yc(()=>{if(!s)return;let S=P=>{let N={};for(let O of P)N[O.category]?N[O.category].push(O):N[O.category]=[O];return N},L=s.filter(v).sort((P,N)=>P.order-N.order),k=!p&&a&&v(a);if(!p){w(S(k?L.filter(P=>P.label!==a?.label):L)),b(k?a:L[0]||null);return}let A=xu(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=o8.filter(A,L,{extract:P=>P.haystack}).sort((P,N)=>N.score-P.score).map(P=>P.original),w(S(L)),b(L[0]??null)},[p,s,v,a]),bo(Ne,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[at(li,{value:p,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:c}),!o.device.viewport.isMobile&&bo("div",{className:"shortcuts-wrapper",children:[at(wc,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),at(wc,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),at(wc,{shortcut:i8("Esc"),children:g("commandPalette.shortcuts.close")})]}),bo("div",{className:"commands",children:[a&&!p&&bo("div",{className:"command-category",children:[bo("div",{className:"command-category-title",children:[g("commandPalette.recents"),at("div",{className:"icon",style:{marginLeft:"6px"},children:N0})]}),at(Ky,{command:a,isSelected:a.label===f?.label,onClick:S=>y(a,S),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,L)=>bo("div",{className:"command-category",children:[at("div",{className:"command-category-title",children:S}),x[S].map(k=>at(Ky,{command:k,isSelected:k.label===f?.label,onClick:A=>y(k,A),onMouseMove:()=>b(k),showShortcut:!o.device.viewport.isMobile,appState:t},k.label))]},S)):s?bo("div",{className:"no-match",children:[at("div",{className:"icon",children:Mt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var Ky=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:a})=>{let l=()=>{};return bo("div",{className:Zy("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:r,onMouseMove:t?l:n,title:t?g("commandPalette.itemNotAvailable"):"",children:[bo("div",{className:"name",children:[e.icon&&at(tn,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),at(oa,{children:e.label})]}),i&&e.shortcut&&at(wc,{shortcut:e.shortcut})]})};import{getSizeFromPoints as tfe,randomInteger as i7,getUpdatedTimestamp as a7}from"@excalidraw/common";import{simplify as $8}from"points-on-curve";import{pointsOnBezierCurves as hse}from"points-on-curve";import{invariant as fse}from"@excalidraw/common";import{curve as xse,lineSegment as Ese,pointFrom as yse,pointDistance as wse,pointFromArray as vse,pointFromVector as Tse,pointRotateRads as Ise,polygon as Cse,polygonFromPoints as Sse,PRECISION as kse,segmentsIntersectAt as Mse,vector as Lse,vectorAdd as Pse,vectorFromPoint as Ase,vectorScale as Dse}from"@excalidraw/math";import{getElementAbsoluteCoords as Rse}from"@excalidraw/element";var Xu=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as j8,pointDistance as b2,pointRotateRads as zge}from"@excalidraw/math";import{ROUGHNESS as q8,isTransparent as _a,assertNever as J8,COLOR_PALETTE as Q8,LINE_POLYGON_POINT_MERGE_DISTANCE as Gge}from"@excalidraw/common";import{RoughGenerator as e7}from"roughjs/bin/generator";import oge from"roughjs/bin/rough";import{getStroke as U8}from"perfect-freehand";import{isRightAngleRads as ige}from"@excalidraw/math";import{BOUND_TEXT_PADDING as lge,DEFAULT_REDUCED_GLOBAL_ALPHA as sge,ELEMENT_READY_TO_ERASE_OPACITY as cge,FRAME_STYLE as dge,MIME_TYPES as u2,THEME as mge,distance as pge,getFontString as uge,isRTL as hge,getVerticalOffset as gge}from"@excalidraw/common";import hue from"roughjs/bin/rough";import{arrayToMap as fue,invariant as i2,rescalePoints as bue,sizeOf as xue}from"@excalidraw/common";import{degreesToRadians as rh,lineSegment as yue,pointDistance as wue,pointFrom as tt,pointFromArray as S8,pointRotateRads as pi}from"@excalidraw/math";import{pointsOnBezierCurves as Iue}from"points-on-curve";import{pointCenter as Dpe,pointFrom as _pe,pointRotateRads as Rpe,pointsEqual as Npe,pointDistance as Bpe,vectorFromPoint as Fpe,curveLength as Ope,curvePointAtLength as zpe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Upe,KEYS as Ype,shouldRotateWithDiscreteAngle as Wpe,getGridPoint as Vpe,invariant as Xpe,tupleToCoors as Kpe,viewportCoordsToSceneCoords as Zpe}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as jpe,isPathALoop as qpe}from"@excalidraw/element";import{KEYS as Ame,arrayToMap as Dme,isBindingFallthroughEnabled as _me,tupleToCoors as Rme,invariant as Nme,isDevEnv as Bme,isTestEnv as Fme}from"@excalidraw/common";import{lineSegment as zme,pointFrom as Hme,pointRotateRads as Gme,vectorFromPoint as Ume,pointDistanceSq as Yme,clamp as Wme,pointDistance as Vme,pointFromVector as Xme,vectorScale as Kme,vectorNormalize as Zme,vectorCross as $me,pointsEqual as jme,lineSegmentIntersectionPoints as qme,PRECISION as Jme}from"@excalidraw/math";import{isTransparent as lde}from"@excalidraw/common";import{curveIntersectLineSegment as cde,isPointWithinBounds as dde,lineSegment as mde,lineSegmentIntersectionPoints as pde,pointFrom as ude,pointFromVector as hde,pointRotateRads as gde,pointsEqual as fde,vectorFromPoint as bde,vectorNormalize as xde,vectorScale as Ede}from"@excalidraw/math";import{ellipse as wde,ellipseSegmentInterceptPoints as vde}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as d8,DEFAULT_PROPORTIONAL_RADIUS as Ku,LINE_CONFIRM_THRESHOLD as m8,ROUNDNESS as Zu}from"@excalidraw/common";import{curve as zse,curveCatmullRomCubicApproxPoints as Hse,curveOffsetPoints as Gse,lineSegment as Use,pointDistance as p8,pointFrom as Yse,pointFromArray as Wse,rectangle as Vse}from"@excalidraw/math";var Tc=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return p8(t,n)<=m8/o}return!1},La=(e,o)=>{if(o.roundness?.type===Zu.PROPORTIONAL_RADIUS||o.roundness?.type===Zu.LEGACY)return e*Ku;if(o.roundness?.type===Zu.ADAPTIVE_RADIUS){let t=o.roundness?.value??d8,n=t/Ku;return e<=n?e*Ku:t}return 0};import{ROUNDNESS as Jse,assertNever as Qse}from"@excalidraw/common";import{pointsEqual as tce}from"@excalidraw/math";var jy=e=>!!e&&e.type==="embeddable",qy=e=>!!e&&e.type==="iframe",ju=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),$n=e=>e!=null&&e.type==="text";var Ic=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var sn=e=>e!=null&&u8(e.type);var si=e=>e!=null&&e.type==="arrow",Pa=e=>si(e)&&e.elbowed;var u8=e=>e==="arrow"||e==="line";var ci=e=>e!==null&&"containerId"in e&&e.containerId!==null&&$n(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Pce,ARROW_LABEL_WIDTH_FRACTION as Ace,BOUND_TEXT_PADDING as Dce,DEFAULT_FONT_SIZE as _ce,TEXT_ALIGN as Rce,VERTICAL_ALIGN as Nce,getFontString as Bce,isProdEnv as Fce,invariant as Oce}from"@excalidraw/common";import{pointFrom as Hce,pointRotateRads as Gce}from"@excalidraw/math";import{BOUND_TEXT_PADDING as lce,DEFAULT_FONT_SIZE as sce,DEFAULT_FONT_FAMILY as cce,getFontString as dce,isTestEnv as mce,normalizeEOL as pce}from"@excalidraw/common";var uce="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as yce,isTestEnv as wce}from"@excalidraw/common";import{curvePointDistance as jce,distanceToLineSegment as qce,pointRotateRads as Jce}from"@excalidraw/math";import{ellipse as ede,ellipseDistanceFromPoint as tde}from"@excalidraw/math/ellipse";import{invariant as Rde,isDevEnv as Nde,isTestEnv as Bde}from"@excalidraw/common";import{pointFrom as Ode,pointFromVector as zde,pointRotateRads as Hde,pointScaleFromOrigin as Gde,pointsEqual as Ude,triangleIncludesPoint as Yde,vectorCross as Wde,vectorFromPoint as x8,vectorScale as Vde}from"@excalidraw/math";var oh=[1,0],t2=[0,1],nh=[-1,0],o2=[0,-1],Cc=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?oh:o<=-r?nh:t>n?t2:o2},n2=(e,o)=>Cc(x8(e,o)),Sc=(e,o)=>kc(n2(e,o)),th=(e,o)=>e[0]===o[0]&&e[1]===o[1],kc=e=>th(e,oh)||th(e,nh);import{clamp as qde,pointDistance as Jde,pointFrom as Qde,pointScaleFromOrigin as eme,pointsEqual as tme,pointTranslate as ome,vector as nme,vectorCross as rme,vectorFromPoint as ime,vectorScale as ame}from"@excalidraw/math";import{BinaryHeap as sme,invariant as cme,isAnyTrue as dme,tupleToCoors as mme,getSizeFromPoints as pme,isDevEnv as ume,arrayToMap as hme}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as upe,viewportCoordsToSceneCoords as hpe}from"@excalidraw/common";import{normalizeRadians as fpe,radiansBetweenAngles as bpe,radiansDifference as xpe}from"@excalidraw/math";import{pointsEqual as ype}from"@excalidraw/math";var $u=e=>{let o=Math.floor(e.width/2)+1,t=0,n=e.width,r=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,n,r,i,a,0,r]};var k8=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},M8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},ih=(e,o,t,n)=>{if(o.length<1)return null;let r=Xu(o[0]);if(r.length<1)return null;let i=t==="start"?1:r.length-1,a=r[i].data;i2(a.length===6,"Op data length is not 6");let l=tt(a[4],a[5]),s=tt(a[2],a[3]),m=tt(a[0],a[1]),c=r[i-1],d=tt(0,0);if(c.op==="move"){let _=S8(c.data);i2(_!=null,"Op data is not a point"),d=_}else c.op==="bcurveTo"&&(d=tt(c.data[4],c.data[5]));let p=(_,R)=>Math.pow(1-_,3)*l[R]+3*_*Math.pow(1-_,2)*s[R]+3*Math.pow(_,2)*(1-_)*m[R]+d[R]*Math.pow(_,3),[u,f]=t==="start"?d:l,[b,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-b,f-x),E=(u-b)/w,y=(f-x)/w,v=k8(n),C=0;{let[_,R]=t==="end"?e.points[e.points.length-1]:e.points[0],[V,Z]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(_-V,R-Z)}let L=Math.min(v,C*(n==="diamond"||n==="diamond_outline"?.25:.5)),k=u-E*L,A=f-y*L;if(n==="dot"||n==="circle"||n==="circle_outline"){let _=Math.hypot(A-f,k-u)+e.strokeWidth-2;return[u,f,_]}let P=M8(n);if(n==="crowfoot_many"||n==="crowfoot_one_or_many"){let[_,R]=pi(tt(u,f),tt(k,A),rh(-P)),[V,Z]=pi(tt(u,f),tt(k,A),rh(P));return[k,A,_,R,V,Z]}let[N,O]=pi(tt(k,A),tt(u,f),-P*Math.PI/180),[U,J]=pi(tt(k,A),tt(u,f),rh(P));if(n==="diamond"||n==="diamond_outline"){let _,R;if(t==="start"){let[V,Z]=e.points.length>1?e.points[1]:[0,0];[_,R]=pi(tt(u+L*2,f),tt(u,f),Math.atan2(Z-f,V-u))}else{let[V,Z]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,R]=pi(tt(u-L*2,f),tt(u,f),Math.atan2(f-Z,u-V))}return[u,f,N,O,_,R,U,J]}return[u,f,N,O,U,J]};import{pointFrom as Oue,pointCenter as zue,pointRotateRads as Hue,vectorFromPoint as Gue,vectorNormalize as Uue,vectorSubtract as Yue,vectorAdd as Wue,vectorScale as Vue,pointFromVector as Xue,clamp as Kue,isCloseTo as Zue}from"@excalidraw/math";import{arrayToMap as Rhe}from"@excalidraw/common";import{isPointWithinBounds as Bhe,pointFrom as Fhe}from"@excalidraw/math";import{vectorCross as Que,vectorFromPoint as ehe}from"@excalidraw/math";import{arrayToMap as L8}from"@excalidraw/common";import{getElementBounds as P8}from"@excalidraw/element";import{isArrowElement as A8,isExcalidrawElement as D8,isFreeDrawElement as _8,isLinearElement as R8,isTextElement as N8}from"@excalidraw/element";import{rangeIncludesValue as Mc,pointFrom as No,pointRotateRads as B8,rangeInclusive as Lc}from"@excalidraw/math";var F8=e=>e.type==="diamond"?[No(e.width/2,0),No(e.width,e.height/2),No(e.width/2,e.height),No(0,e.height/2)]:[No(0,0),No(0+e.width,0),No(0+e.width,e.height),No(0,e.height)],O8=e=>R8(e)||_8(e)?e.points:F8(e),l2=e=>{let o=e.reduce((t,[n,r])=>(t.minY=Math.min(t.minY,r),t.minX=Math.min(t.minX,n),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,r),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},s2=e=>{let o=O8(e),{cx:t,cy:n}=l2(o),r=No(t,n),i=o.map(c=>B8(c,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:m}=l2(i);return[a+e.x,l+e.y,s+e.x,m+e.y]},ah=(e,o,t=!1)=>{let n=s2(e),r=o[0]<=n[0]&&o[2]>=n[2]&&o[1]<=n[1]&&o[3]>=n[3];return t?r?!0:n[0]<=o[0]&&n[2]>=o[2]&&n[1]<=o[1]&&n[3]>=o[3]:r},c2=(e,o)=>{let t=s2(e);return(Mc(t[0],Lc(o[0],o[2]))||Mc(o[0],Lc(t[0],t[2])))&&(Mc(t[1],Lc(o[1],o[3]))||Mc(o[1],Lc(t[1],t[3])))},d2=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{D8(o)&&(o=P8(o,L8(e)));let r=[o[0]-n,o[1]-n,o[2]+n,o[3]+n],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?c2(a,r):t==="inside"?ah(a,r):ah(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);N8(a)&&a.containerId&&i.add(a.containerId),A8(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{arrayToMap as fhe,isShallowEqual as H8}from"@excalidraw/common";var z8=function(){let e=null,o=null,t=null,n=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let m={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let f=u.indexOf(l.editingGroupId);f>-1&&(u=u.slice(0,f))}if(u.length>0){let f=u[u.length-1];m[f]=!0}}let c={},d=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>m[b]);return f&&(p[u.id]=!0,Array.isArray(c[f])?c[f].push(u.id):c[f]=[u.id]),p},{});for(let p of Object.keys(c))c[p].length<2&&m[p]&&(m[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:m,selectedElementIds:lh({...l.selectedElementIds,...d},s)},t},r=(i,a,l,s)=>{let m=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):sh(a,i);return m.length?n(m,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:lh(i.selectedElementIds,l)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var The=function(){let e=null,o=null,t=null,n=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===o||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,o=i.selectedElementIds),t);return n.clearCache=()=>{e=null,o=null,t=null},n}(),sh=(e,o,t)=>{let n=new Set,r=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(t?.includeBoundTextElement&&ci(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{Ic(a)&&m2(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var lh=(e,o)=>H8(o.selectedElementIds,e)?o.selectedElementIds:e;var m2=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var Y8=typeof document<"u"?document.createElement("img"):{src:""};Y8.src=`data:${u2.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var W8=typeof document<"u"?document.createElement("img"):{src:""};W8.src=`data:${u2.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;var h2=new WeakMap;var V8=new WeakMap([]);function g2(e){let o=X8(e),t=new Path2D(o);return V8.set(e,t),t}function X8(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([n,r],i)=>[n,r,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:n=>Math.sin(n*Math.PI/2),last:!!e.lastCommittedPoint};return Z8(U8(o,t))}function p2(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var K8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function Z8(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,n,r,i)=>(r===o?t.push(n,p2(n,i[0]),"L",i[0],"Z"):t.push(n,p2(n,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(K8,"$1")}var f2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var lt=class lt{};I(lt,"rg",new e7),I(lt,"cache",new WeakMap),I(lt,"get",o=>lt.cache.get(o)),I(lt,"set",(o,t)=>lt.cache.set(o,t)),I(lt,"delete",o=>lt.cache.delete(o)),I(lt,"destroy",()=>{lt.cache=new WeakMap}),I(lt,"generateElementShape",(o,t)=>{let n=t?.isExporting?void 0:lt.get(o);if(n!==void 0)return n;h2.delete(o);let r=n7(o,lt.rg,t||{isExporting:!1,canvasBackgroundColor:Q8.white,embedsValidationStatus:null});return lt.cache.set(o,r),r});var mi=lt,t7=e=>[8,8+e],y2=e=>[1.5,6+e];function o7(e){let o=e.roughness,t=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&t>=50||n>=15&&e.roundness&&f2(e.type)||sn(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Ro=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?t7(e.strokeWidth):e.strokeStyle==="dotted"?y2(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:o7(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<q8.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=_a(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"line":case"freedraw":return Tc(e.points)&&(t.fillStyle=e.fillStyle,t.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),t;case"arrow":return t;default:throw new Error(`Unimplemented type ${e.type}`)}},x2=(e,o,t)=>ju(e)&&(o||jy(e)&&t?.get(e.id)!==!0)&&_a(e.backgroundColor)&&_a(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:qy(e)?{...e,strokeColor:_a(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:_a(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,E2=(e,o,t,n,r,i,a)=>{let l=ih(e,o,t,n);if(l===null)return[];let s=(m,c)=>{if(m===null)return[];let[,,d,p,u,f]=m;return[r.line(d,p,u,f,c)]};switch(n){case"dot":case"circle":case"circle_outline":{let[m,c,d]=l;return delete i.strokeLineDash,[r.circle(m,c,d,{...i,fill:n==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[m,c,d,p,u,f]=l;return delete i.strokeLineDash,[r.polygon([[m,c],[d,p],[u,f],[m,c]],{...i,fill:n==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[m,c,d,p,u,f,b,x]=l;return delete i.strokeLineDash,[r.polygon([[m,c],[d,p],[u,f],[b,x],[m,c]],{...i,fill:n==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return s(l,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[m,c,d,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=y2(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[r.line(d,p,m,c,i),r.line(u,f,m,c,i),...n==="crowfoot_one_or_many"?s(ih(e,o,t,"crowfoot_one"),i):[]]}}};var n7=(e,o,{isExporting:t,canvasBackgroundColor:n,embedsValidationStatus:r})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=La(Math.min(a,l),e);i=o.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,Ro(x2(e,t,r),!0))}else i=o.rectangle(0,0,e.width,e.height,Ro(x2(e,t,r),!1));return i}case"diamond":{let i,[a,l,s,m,c,d,p,u]=$u(e);if(e.roundness){let f=La(Math.abs(a-p),e),b=La(Math.abs(m-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${m-b}
7
+ ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Jx=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=g1(a);if(!a||!f1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:m}=Kr(e,o,!1);return await Zr(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:m}),{fileHandle:a}};import{Fragment as Nk,jsx as Ro,jsxs as Bk}from"react/jsx-runtime";var Kp=B({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:no.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>Ro(Nx,{label:g("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),Qx=B({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:no.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Rk(e),i=Ee(r,o)?j(r,o):r;return Ro(Nk,{children:_k.map(a=>{let[l,s]=u1(i,Dk,a),m=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Ro(K,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:m,"aria-label":m,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),Zp=B({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:no.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Ro(xa,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),Ks=B({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:no.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Bk(xa,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Ro(Pt,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Ro("div",{className:"excalidraw-tooltip-icon",children:J1})})]})}),$r=B({name:"saveToActiveFile",label:"buttons.save",icon:zr,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:i}=Nl(o.fileHandle)?await Jx(e,o,r.files,r.getName()):await Pl(e,o,r.files,r.getName());return{captureUpdate:no.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:no.EVENTUALLY}}},keyTest:e=>e.key===Kn.S&&e[Kn.CTRL_OR_CMD]&&!e.shiftKey}),Ca=B({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:zr,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await Pl(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:no.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:g("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:no.EVENTUALLY}}},keyTest:e=>e.key===Kn.S&&e.shiftKey&&e[Kn.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Ro(K,{type:"button",icon:K1,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:ce().editor.isMobile,hidden:!fn,onClick:()=>e(null),"data-testid":"save-as-button"})}),Zn=B({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:i,files:a}=await hm(o,e);return{elements:n,appState:i,files:a,captureUpdate:no.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:no.EVENTUALLY}}},keyTest:e=>e[Kn.CTRL_OR_CMD]&&e.key===Kn.O}),eE=B({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:no.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Ro("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Ro(_x,{value:e.exportWithDarkMode?Xp.DARK:Xp.LIGHT,onChange:t=>{o(t===Xp.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as Fk,DEFAULT_FONT_FAMILY as Ok,DEFAULT_TEXT_ALIGN as zk,CODES as tE,KEYS as oE,getLineHeight as Hk}from"@excalidraw/common";import{newElementWith as Zs}from"@excalidraw/element";import{hasBoundTextElement as Gk,canApplyRoundnessTypeToElement as Uk,getDefaultRoundnessTypeForElement as Yk,isFrameLikeElement as Wk,isArrowElement as Vk,isExcalidrawElement as Xk,isTextElement as $p}from"@excalidraw/element";import{getBoundTextElement as Kk,redrawTextBoundingBox as Zk}from"@excalidraw/element";import{CaptureUpdateAction as jp}from"@excalidraw/element";var rE="{}",qp=B({name:"copyStyles",label:"labels.copyStyles",icon:Wm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&Gk(i)){let a=Kk(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(rE=JSON.stringify(n)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:jp.EVENTUALLY}},keyTest:e=>e[oE.CTRL_OR_CMD]&&e.altKey&&e.code===tE.C}),Jp=B({name:"pasteStyles",label:"labels.pasteStyles",icon:Wm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(rE),i=n[0],a=n[1];if(!Xk(i))return{elements:e,captureUpdate:jp.EVENTUALLY};let l=j(e,o,{includeBoundTextElement:!0}),s=l.map(m=>m.id);return{elements:e.map(m=>{if(s.includes(m.id)){let c=i;if($p(m)&&m.containerId&&(c=a),!c)return m;let d=Zs(m,{backgroundColor:c?.backgroundColor,strokeWidth:c?.strokeWidth,strokeColor:c?.strokeColor,strokeStyle:c?.strokeStyle,fillStyle:c?.fillStyle,opacity:c?.opacity,roughness:c?.roughness,roundness:c.roundness?Uk(c.roundness.type,m)?c.roundness:Yk(m):null});if($p(d)){let p=c.fontSize||Fk,u=c.fontFamily||Ok;d=Zs(d,{fontSize:p,fontFamily:u,textAlign:c.textAlign||zk,lineHeight:c.lineHeight||Hk(u)});let f=null;d.containerId&&(f=l.find(b=>$p(d)&&b.id===d.containerId)||null),Zk(d,f,r.scene)}return d.type==="arrow"&&Vk(c)&&(d=Zs(d,{startArrowhead:c.startArrowhead,endArrowhead:c.endArrowhead})),Wk(m)&&(d=Zs(d,{roundness:null,backgroundColor:"transparent"})),d}return m}),captureUpdate:jp.IMMEDIATELY}},keyTest:e=>e[oE.CTRL_OR_CMD]&&e.altKey&&e.code===tE.V});import{KEYS as $k}from"@excalidraw/common";import{getNonDeletedElements as jk}from"@excalidraw/element";import{showSelectedShapeActions as qk}from"@excalidraw/element";import{CaptureUpdateAction as Qp}from"@excalidraw/element";import{jsx as nE}from"react/jsx-runtime";var Jk=B({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:Qp.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>nE(K,{type:"button",icon:Kl,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),Qk=B({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:Qp.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>nE(K,{visible:qk(o,jk(e)),type:"button",icon:Z1,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),jr=B({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:U1,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:Qp.EVENTUALLY}),keyTest:e=>e.key===$k.QUESTION_MARK});import{getNonDeletedElements as js}from"@excalidraw/element";import{newElementWith as lE}from"@excalidraw/element";import{isBoundToContainer as eM}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as tM,getElementsInResizingFrame as oM,getFrameLikeElements as rM,getRootElements as nM,groupByFrameLikes as iM,removeElementsFromFrame as aM,replaceAllElementsInFrame as lM}from"@excalidraw/element";import{KEYS as qs,randomId as sM,arrayToMap as eu,getShortcutKey as sE}from"@excalidraw/common";import{getSelectedGroupIds as $s,selectGroup as cM,selectGroupsForSelectedElements as dM,getElementsInGroup as iE,addToGroup as mM,removeFromSelectedGroups as pM,isElementInGroup as cE}from"@excalidraw/element";import{syncMovedIndices as uM}from"@excalidraw/element";import{CaptureUpdateAction as Sa}from"@excalidraw/element";import{jsx as $n}from"react/jsx-runtime";var hM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&cE(n,t),!0))return!0}return!1},aE=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!hM(r)&&!tM(r)},tu=B({name:"group",label:"labels.group",icon:e=>$n(Hm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=nM(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:Sa.EVENTUALLY};let i=$s(o);if(i.length===1){let x=i[0],w=new Set(iE(e,x).map(v=>v.id)),E=new Set(n.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:o,elements:e,captureUpdate:Sa.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&iM(n).forEach((w,E)=>{aM(w,r.scene.getNonDeletedElementsMap())});let s=sM(),m=eu(n);a=a.map(x=>m.get(x.id)?lE(x,{groupIds:mM(x.groupIds,s,o.editingGroupId)}):x);let c=iE(a,s),d=c[c.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!cE(x,s)),b=uM([...f,...c,...u],eu(c));return{appState:{...o,...cM(s,{...o,selectedGroupIds:{}},js(a))},elements:b,captureUpdate:Sa.IMMEDIATELY}},predicate:(e,o,t,r)=>aE(e,o,r),keyTest:e=>!e.shiftKey&&e[qs.CTRL_OR_CMD]&&e.key===qs.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>$n(K,{hidden:!aE(e,o,r),type:"button",icon:$n(Hm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${sE("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:Ee(js(e),o)})}),ou=B({name:"ungroup",label:"labels.ungroup",icon:e=>$n(Gm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=$s(o),i=eu(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:Sa.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{eM(p)&&l.push(p.id);let u=pM(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:lE(p,{groupIds:u})});let s=dM(o,js(a),o,null),m=r.scene.getSelectedElements(o),c=new Set(m.filter(p=>p.frameId).map(p=>p.frameId));return rM(e).filter(p=>c.has(p.id)).forEach(p=>{p&&(a=lM(a,oM(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:Sa.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[qs.CTRL_OR_CMD]&&e.key===qs.G.toUpperCase(),predicate:(e,o)=>$s(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>$n(K,{type:"button",hidden:$s(o).length===0,icon:$n(Gm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${sE("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:Ee(js(e),o)})});import wM from"clsx";import{CaptureUpdateAction as hE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as gM,COLOR_VOICE_CALL as fM,COLOR_WHITE as Qs,THEME as bM,UserIdleState as dE}from"@excalidraw/common";var Js=(e,o,t,r,n,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+r-i,t),e.quadraticCurveTo(o+r,t,o+r,t+i),e.lineTo(o+r,t+n-i),e.quadraticCurveTo(o+r,t+n,o+r-i,t+n),e.lineTo(o+i,t+n),e.quadraticCurveTo(o,t+n,o,t+n-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function xM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var qr=(e,o)=>`hsl(${Math.abs(xM(o?.id||e))%37*10}, 100%, 83%)`,mE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},pE=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,m=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let c=11,d=14,p=l<0||l>r-c||s<0||s>n-d;l=Math.max(l,0),l=Math.min(l,r-c),s=Math.max(s,0),s=Math.min(s,n-d);let u=qr(i,m);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===dE.IDLE||f===dE.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===bM.DARK?"#2f6330":fM,w=m?.isSpeaking;w&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Qs,e.strokeStyle=Qs,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let E=o.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+c/2,v=(w?s+0:s)+d+2,C=5,S=3,L=e.measureText(E),k=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,A=Math.max(k,12),P=y-1,N=v-1,O=L.width+2+C*2+2,U=A+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,N,O,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=Qs,e.stroke(),w&&(e.beginPath(),e.roundRect(P-2,N-2,O+4,U+4,8),e.strokeStyle=x,e.stroke())):Js(e,P,N,O,U,8,Qs),e.fillStyle=gM,e.fillText(E,y+C+1,v+S+L.actualBoundingBoxAscent+Math.floor((A-k)/2)+2),w){e.fillStyle=x;let J=8,_=8,R=5;e.fillRect(P+O+_,N+(U/2-J/2),2,J),e.fillRect(P+O+_+R,N+(U/2-J*2/2),2,J*2),e.fillRect(P+O+_+R*2,N+(U/2-J/2),2,J)}}e.restore(),e.closePath()}};import EM from"clsx";import{useState as yM}from"react";import{jsx as uE}from"react/jsx-runtime";var ru=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=mE(t),[a,l]=yM(!1),s=!a&&r,m=s?void 0:{background:e};return uE("div",{className:EM("Avatar",n),style:m,onClick:o,children:s?uE("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as Eo,jsxs as ec}from"react/jsx-runtime";var vM=B({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:hE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:hE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=qr(r,n),s=wM({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),m=n.isInCall?n.isSpeaking?ec("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[Eo("div",{}),Eo("div",{}),Eo("div",{})]}):n.isMuted?Eo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:Q0}):Eo("div",{title:g("userList.hint.inCall"),children:J0}):null;return i?ec("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[Eo(ru,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),Eo("div",{className:"UserList__collaborator-name",children:n.username}),ec("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Eo("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:Mn}),m]})]}):ec("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Eo(ru,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),m&&Eo("div",{className:"UserList__collaborator-status-icon",children:m})]})}});import{LIBRARY_DISABLED_TYPES as TM,randomId as IM}from"@excalidraw/common";import{deepCopyElement as CM}from"@excalidraw/element";import{CaptureUpdateAction as nu}from"@excalidraw/element";var iu=B({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of TM)if(n.some(a=>a.type===i))return{captureUpdate:nu.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:IM(),status:"unpublished",elements:n.map(CM),created:Date.now()},...i])).then(()=>({captureUpdate:nu.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:nu.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as jn}from"@excalidraw/element";import{isFrameLikeElement as SM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as kM}from"@excalidraw/element";import{KEYS as dr,arrayToMap as MM,getShortcutKey as tc}from"@excalidraw/common";import{alignElements as LM}from"@excalidraw/element";import{CaptureUpdateAction as qn}from"@excalidraw/element";import{getSelectedElementsByGroup as PM}from"@excalidraw/element";import{jsx as Qn}from"react/jsx-runtime";var wt=(e,o)=>{let t=o.scene.getSelectedElements(e);return PM(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(r=>SM(r))},Jn=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=LM(n,r,t.scene,o),a=MM(i);return kM(e.map(l=>a.get(l.id)||l),o,t)},AM=B({name:"alignTop",label:"labels.alignTop",icon:Rm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>wt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Jn(e,o,r,{position:"start",axis:"y"}),captureUpdate:qn.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Qn(K,{hidden:!wt(o,r),type:"button",icon:Rm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${tc("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:Ee(jn(e),o)})}),DM=B({name:"alignBottom",label:"labels.alignBottom",icon:Nm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>wt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Jn(e,o,r,{position:"end",axis:"y"}),captureUpdate:qn.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Qn(K,{hidden:!wt(o,r),type:"button",icon:Nm,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${tc("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:Ee(jn(e),o)})}),_M=B({name:"alignLeft",label:"labels.alignLeft",icon:Bm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>wt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Jn(e,o,r,{position:"start",axis:"x"}),captureUpdate:qn.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Qn(K,{hidden:!wt(o,r),type:"button",icon:Bm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${tc("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:Ee(jn(e),o)})}),RM=B({name:"alignRight",label:"labels.alignRight",icon:Fm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>wt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Jn(e,o,r,{position:"end",axis:"x"}),captureUpdate:qn.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Qn(K,{hidden:!wt(o,r),type:"button",icon:Fm,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${tc("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:Ee(jn(e),o)})}),NM=B({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Om,trackEvent:{category:"element"},predicate:(e,o,t,r)=>wt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Jn(e,o,r,{position:"center",axis:"y"}),captureUpdate:qn.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Qn(K,{hidden:!wt(o,r),type:"button",icon:Om,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:Ee(jn(e),o)})}),BM=B({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:zm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>wt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Jn(e,o,r,{position:"center",axis:"x"}),captureUpdate:qn.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Qn(K,{hidden:!wt(o,r),type:"button",icon:zm,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:Ee(jn(e),o)})});import{getNonDeletedElements as gE}from"@excalidraw/element";import{isFrameLikeElement as FM}from"@excalidraw/element";import{CODES as fE,KEYS as bE,arrayToMap as OM,getShortcutKey as xE}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as zM}from"@excalidraw/element";import{distributeElements as HM}from"@excalidraw/element";import{CaptureUpdateAction as EE}from"@excalidraw/element";import{getSelectedElementsByGroup as GM}from"@excalidraw/element";import{jsx as vE}from"react/jsx-runtime";var yE=(e,o)=>{let t=o.scene.getSelectedElements(e);return GM(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(r=>FM(r))},wE=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=HM(n,t.scene.getNonDeletedElementsMap(),r,o),a=OM(i);return zM(e.map(l=>a.get(l.id)||l),o,t)},UM=B({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:wE(e,o,r,{space:"between",axis:"x"}),captureUpdate:EE.IMMEDIATELY}),keyTest:e=>!e[bE.CTRL_OR_CMD]&&e.altKey&&e.code===fE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>vE(K,{hidden:!yE(o,r),type:"button",icon:o0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${xE("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:Ee(gE(e),o)})}),YM=B({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:wE(e,o,r,{space:"between",axis:"y"}),captureUpdate:EE.IMMEDIATELY}),keyTest:e=>!e[bE.CTRL_OR_CMD]&&e.altKey&&e.code===fE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>vE(K,{hidden:!yE(o,r),type:"button",icon:r0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${xE("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:Ee(gE(e),o)})});import{getNonDeletedElements as WM}from"@excalidraw/element";import{bindOrUnbindLinearElements as VM,isBindingEnabled as XM}from"@excalidraw/element";import{getCommonBoundingBox as TE}from"@excalidraw/element";import{newElementWith as KM}from"@excalidraw/element";import{deepCopyElement as ZM}from"@excalidraw/element";import{resizeMultipleElements as $M}from"@excalidraw/element";import{isArrowElement as jM,isElbowArrow as qM,isLinearElement as JM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as IE}from"@excalidraw/element";import{CODES as CE,KEYS as QM,arrayToMap as eL}from"@excalidraw/common";import{CaptureUpdateAction as SE}from"@excalidraw/element";var au=B({name:"flipHorizontal",label:"labels.flipHorizontal",icon:rb,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:IE(kE(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:SE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===CE.H}),lu=B({name:"flipVertical",label:"labels.flipVertical",icon:ob,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:IE(kE(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:SE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===CE.V&&!e[QM.CTRL_OR_CMD]}),kE=(e,o,t,r,n)=>{let i=j(WM(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=tL(i,o,t,r,n),l=eL(a);return e.map(s=>l.get(s.id)||s)},tL=(e,o,t,r,n)=>{if(e.every(u=>jM(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return KM(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=TE(e);$M(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,ZM(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),VM(e.filter(JM),XM(t),[],n.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>qM(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:m,midY:c}=TE(e),[d,p]=[i-m,a-c];return s.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),e};import{isTextElement as oL}from"@excalidraw/element";import{getTextFromElements as rL}from"@excalidraw/element";import{CODES as nL,KEYS as ME,isFirefox as iL}from"@excalidraw/common";import{CaptureUpdateAction as _t}from"@excalidraw/element";var ei=B({name:"copy",label:"labels.copy",icon:$i,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Vs(n,r.files,t)}catch(i){return{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:_t.EVENTUALLY}},keyTest:void 0}),su=B({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await $x()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),iL?{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(Kx({types:n}))}catch(i){return console.error(i),{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:_t.EVENTUALLY}},keyTest:void 0}),oc=B({name:"cut",label:"labels.cut",icon:G0,trackEvent:{category:"element"},perform:(e,o,t,r)=>(ei.perform(e,o,t,r),na.perform(e,o,null,r)),keyTest:e=>e[ME.CTRL_OR_CMD]&&e.key===ME.X}),rc=B({name:"copyAsSvg",label:"labels.copyAsSvg",icon:nb,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:_t.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=Kr(e,o,!0);try{await Zr("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:_t.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:_t.EVENTUALLY}}},predicate:e=>Ws&&e.length>0,keywords:["svg","clipboard","copy"]}),nc=B({name:"copyAsPng",label:"labels.copyAsPng",icon:ib,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:_t.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Kr(e,o,!0);try{return await Zr("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:n.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:_t.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:_t.EVENTUALLY}}},predicate:e=>Xn&&e.length>0,keyTest:e=>e.code===nL.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),ic=B({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{ro(rL(n))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:_t.EVENTUALLY}},predicate:(e,o,t,r)=>Ws&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(oL),keywords:["text","clipboard","copy"]});import{CODES as aL,KEYS as lL}from"@excalidraw/common";import{CaptureUpdateAction as sL}from"@excalidraw/element";var ac=B({name:"gridMode",icon:db,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:sL.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[lL.CTRL_OR_CMD]&&e.code===aL.QUOTE});import{CODES as cL,KEYS as dL}from"@excalidraw/common";import{CaptureUpdateAction as mL}from"@excalidraw/element";var ti=B({name:"zenMode",label:"buttons.zenMode",icon:lb,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:mL.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[dL.CTRL_OR_CMD]&&e.altKey&&e.code===cL.Z});import{CODES as pL,KEYS as uL}from"@excalidraw/common";import{CaptureUpdateAction as hL}from"@excalidraw/element";var cu=B({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:ab,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:hL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[uL.CTRL_OR_CMD]&&e.altKey&&e.code===pL.S});import{CODES as gL,KEYS as fL}from"@excalidraw/common";import{CaptureUpdateAction as bL}from"@excalidraw/element";var oi=B({name:"stats",label:"stats.fullTitle",icon:tb,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:bL.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[fL.CTRL_OR_CMD]&&e.altKey&&e.code===gL.SLASH});import{BOUND_TEXT_PADDING as LE,ROUNDNESS as PE,TEXT_ALIGN as DE,VERTICAL_ALIGN as _E,arrayToMap as RE,getFontString as xL}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as EL,resetOriginalContainerCache as yL,updateOriginalContainerCache as wL}from"@excalidraw/element";import{computeBoundTextPosition as vL,computeContainerDimensionForBoundText as AE,getBoundTextElement as NE,redrawTextBoundingBox as BE}from"@excalidraw/element";import{hasBoundTextElement as TL,isArrowElement as IL,isTextBindableContainer as du,isTextElement as ka,isUsingAdaptiveRadius as CL}from"@excalidraw/element";import{measureText as SL}from"@excalidraw/element";import{syncMovedIndices as FE}from"@excalidraw/element";import{newElement as kL}from"@excalidraw/element";import{CaptureUpdateAction as mu}from"@excalidraw/element";var pu=B({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>TL(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=NE(a,i);if(l){let{width:s,height:m}=SL(l.originalText,xL(l),l.lineHeight),c=EL(a.id);yL(a.id);let{x:d,y:p}=vL(a,l,i);r.scene.mutateElement(l,{containerId:null,width:s,height:m,text:l.originalText,x:d,y:p}),r.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:c||a.height})}}),{elements:e,appState:o,captureUpdate:mu.IMMEDIATELY}}}),uu=B({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let i=ka(n[0])||ka(n[1]),a;if(du(n[0])?a=n[0]:du(n[1])&&(a=n[1]),i&&a&&NE(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;ka(n[0])&&du(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:_E.MIDDLE,textAlign:DE.CENTER,autoResize:!0,angle:IL(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return BE(i,a,r.scene),wL(a.id,l),{elements:ML(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:mu.IMMEDIATELY}}}),ML=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===t.id);r.splice(n,1);let i=r.findIndex(a=>a.id===o.id);return r.splice(i+1,0,t),FE(r,RE([o,t])),r},LL=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===o.id);r.splice(n,1);let i=r.findIndex(a=>a.id===t.id);return r.splice(i,0,o),FE(r,RE([o,t])),r},OE=B({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>ka(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(ka(l)){let s=kL({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:CL("rectangle")?PE.ADAPTIVE_RADIUS:PE.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-LE,y:l.y-LE,width:AE(l.width,"rectangle"),height:AE(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let m=l.boundElements.filter(d=>d.type==="arrow").map(d=>d.id);i.filter(d=>m.includes(d.id)).forEach(d=>{let p=d.startBinding,u=d.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&r.scene.mutateElement(d,{startBinding:p,endBinding:u})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:_E.MIDDLE,boundElements:null,textAlign:DE.CENTER,autoResize:!0}),BE(l,s,r.scene),i=LL([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:mu.IMMEDIATELY}}});import{isEmbeddableElement as XL}from"@excalidraw/element";import{KEYS as ZE,getShortcutKey as KL}from"@excalidraw/common";import{CaptureUpdateAction as ZL}from"@excalidraw/element";import{pointFrom as UE}from"@excalidraw/math";import PL from"clsx";import{useCallback as zE,useEffect as HE,useLayoutEffect as AL,useRef as DL,useState as _L}from"react";import{EVENT as hu,HYPERLINK_TOOLTIP_DELAY as RL,KEYS as lc}from"@excalidraw/common";import{getElementAbsoluteCoords as Eu}from"@excalidraw/element";import{hitElementBoundingBox as NL}from"@excalidraw/element";import{isElementLink as BL}from"@excalidraw/element";import{getEmbedLink as FL,embeddableURLValidator as OL}from"@excalidraw/element";import{sceneCoordsToViewportCoords as YE,viewportCoordsToSceneCoords as zL,wrapEvent as HL,isLocalLink as GL,normalizeLink as gu}from"@excalidraw/common";import{isEmbeddableElement as fu}from"@excalidraw/element";import{jsx as ri,jsxs as GE}from"react/jsx-runtime";var yu=380,UL=42,bu=5,WE=85,YL=500,xu=!1,sc=new Map,VE=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=go(),s=fo(),m=ce(),c=e.link||"",[d,p]=_L(c),u=DL(null),f=l.showHyperlinkPopup==="editor",b=zE(()=>{if(!u.current)return;let v=gu(u.current.value)||null;if(!e.link&&v&&re("hyperlink","create"),fu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!OL(v,s.validateEmbeddable))v&&n({message:g("toast.unableToEmbed"),closable:!0}),e.link&&sc.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:S}=e,L=FL(v);L?.error instanceof URIError&&n({message:g("toast.unrecognizedLinkFormat"),closable:!0});let k=L?L.intrinsicSize.w/L.intrinsicSize.h:1,A=sc.get(e.id)!==e.link;o.mutateElement(e,{...A?{width:L?.type==="video"?C>S?C:S*k:C,height:L?.type==="video"&&C>S?C/k:S}:{},link:v}),i(e,!0),sc.has(e.id)&&sc.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,n,s.validateEmbeddable,l.activeEmbeddable,t,i]);AL(()=>()=>{b()},[b]),HE(()=>{f&&u?.current&&!(m.viewport.isMobile||m.isTouchScreen)&&u.current.select()},[f,m.viewport.isMobile,m.isTouchScreen]),HE(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),VL(e,a,l,UE(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},YL))};return window.addEventListener(hu.POINTER_MOVE,C,!1),()=>{window.removeEventListener(hu.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=zE(()=>{re("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{re("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y}=XE(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:GE("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:yu,padding:bu},children:[f?ri("input",{className:PL("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:d,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[lc.CTRL_OR_CMD]&&v.key===lc.K&&v.preventDefault(),(v.key===lc.ENTER||v.key===lc.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?ri("a",{href:gu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:GL(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&r){let C=HL(hu.EXCALIDRAW_LINK,v.nativeEvent);r({...e,link:gu(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ri("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),GE("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&ri(K,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:Qo}),ri(K,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:ss}),c&&!fu(e)&&ri(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Mt})]})]})},XE=(e,o,t)=>{let[r,n]=Eu(e,t),{x:i,y:a}=YE({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-yu/2,s=a-o.offsetTop-WE;return{x:l,y:s}},wu=(e,o)=>{let t=j(e,o);return fu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Ma=null,KE=(e,o,t)=>{Ma&&clearTimeout(Ma),Ma=window.setTimeout(()=>WL(e,o,t),RL)},WL=(e,o,t)=>{if(!e.link)return;let r=Yn();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=BL(e.link)?g("labels.link.goToElement"):e.link;let[n,i,a,l]=Eu(e,t),[s,m,c,d]=i1([n,i,a,l],e.angle,o),p=YE({sceneX:s,sceneY:m},o);_p(r,{left:p.x,top:p.y,width:c,height:d},"top"),re("hyperlink","tooltip","link-icon"),xu=!0},vu=()=>{Ma&&clearTimeout(Ma),xu&&(xu=!1,Yn().classList.remove("excalidraw-tooltip--visible"))},VL=(e,o,t,[r,n])=>{let{x:i,y:a}=zL({clientX:r,clientY:n},t),l=15/t.zoom.value;if(NL(UE(i,a),e,o))return!1;let[s,m,c]=Eu(e,o);if(i>=s&&i<=c&&a>=m-WE&&a<=m)return!1;let{x:d,y:p}=XE(e,t,o);return!(r>=d-l&&r<=d+yu+bu*2+l&&n>=p-l&&n<=p+l+bu*2+UL)};import{jsx as $L}from"react/jsx-runtime";var La=B({name:"hyperlink",label:(e,o)=>wu(e,o),icon:Ji,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:ZL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[ZE.CTRL_OR_CMD]&&e.key===ZE.K,predicate:(e,o)=>j(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=j(e,o);return $L(K,{type:"button",icon:Ji,"aria-label":g(wu(e,o)),title:`${XL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${KL("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});import{KEYS as $E,arrayToMap as Iu,randomId as jL}from"@excalidraw/common";import{elementsAreInSameGroup as qL,newElementWith as jE,selectGroupsFromGivenElements as qE}from"@excalidraw/element";import{CaptureUpdateAction as JE}from"@excalidraw/element";var Tu=e=>e.every(o=>!o.locked),Pa=B({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Tu(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=j(o,e);return Tu(t)?vn:Or},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Tu(n),a=Iu(n),l=n.length>1&&qL(n),m=n.length===1||l?null:jL(),c={...o.lockedMultiSelections};if(i)c={...o.lockedMultiSelections,...m?{[m]:!0}:{}};else if(l){let w=n[0].groupIds.at(-1);delete c[w]}let d=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?m&&(E=[...E,m]):E=E.filter(y=>!o.lockedMultiSelections[y]),jE(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=Iu(d),u=i?{}:Object.fromEntries(n.map(w=>[w.id,!0])),f=n.map(w=>p.get(w.id)||w),b=i?{}:qE(f,o),x=i?m||(l?n[0].groupIds.at(-1):n[0].id):null;return{elements:d,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:c,activeLockedId:x},captureUpdate:JE.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===$E.L&&e[$E.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),QE=B({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Or,predicate:(e,o)=>j(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),r=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return jE(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),n=Iu(r),i=t.map(a=>n.get(a.id)||a);return{elements:r,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:qE(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:JE.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as pD,isLinearElement as uD,isLineElement as wi}from"@excalidraw/element";import{arrayToMap as hD,invariant as Sh}from"@excalidraw/common";import{toggleLinePolygonState as gD,CaptureUpdateAction as Q2}from"@excalidraw/element";import C2 from"clsx";import l7 from"fuzzy";import{useEffect as Nc,useRef as s7,useState as Rc}from"react";import{DEFAULT_SIDEBAR as T2,EVENT as Fc,KEYS as ao,capitalizeString as c7,getShortcutKey as d7,isWritableElement as m7}from"@excalidraw/common";import{CaptureUpdateAction as _P}from"@excalidraw/element";import{useEffect as _a,useMemo as ey,useRef as Mu,useState as JL}from"react";import{getLinearElementSubType as ai,updateElbowArrowPoints as QL}from"@excalidraw/element";import{pointFrom as dc,pointRotateRads as eP}from"@excalidraw/math";import{hasBoundTextElement as tP,isArrowBoundToElement as oP,isArrowElement as rP,isElbowArrow as nP,isLinearElement as Du,isUsingAdaptiveRadius as iP}from"@excalidraw/element";import{getCommonBoundingBox as aP,getElementAbsoluteCoords as lP}from"@excalidraw/element";import{getBoundTextElement as iy,getBoundTextMaxHeight as sP,getBoundTextMaxWidth as cP,redrawTextBoundingBox as dP}from"@excalidraw/element";import{wrapText as mP}from"@excalidraw/element";import{assertNever as pP,CLASSES as uP,getFontString as Cu,isProdEnv as hP,mapFind as gP,reduceToCommonValue as fP,updateActiveTool as ty}from"@excalidraw/common";import{measureText as oy}from"@excalidraw/element";import{LinearElementEditor as bP}from"@excalidraw/element";import{newArrowElement as Su,newElement as xP,newLinearElement as EP}from"@excalidraw/element";import{ShapeCache as yP}from"@excalidraw/element";import{updateBindings as wP}from"@excalidraw/element";import{jsx as Au}from"react/jsx-runtime";var vP=8,TP=10,Aa=["rectangle","diamond","ellipse"],Da=["line","sharpArrow","curvedArrow","elbowArrow"],IP=new Set(Aa),CP=new Set(Da),li=e=>IP.has(e),pc=e=>e==="arrow"||CP.has(e),io=me(null),Ra=new Map,Na=new Map,SP=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Mu(null);return _a(()=>{if(o.length===0){e.updateEditorAtom(io,null);return}let r=si(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(io,null),t.current=null)},[o,e]),_a(()=>()=>{Ra.clear(),Na.clear()},[]),Au(kP,{app:e,elements:o})},kP=({app:e,elements:o})=>{let t=si(o),r=ey(()=>t==="generic"?ly(o):[],[t,o]),n=ey(()=>t==="linear"?Pu(o):[],[t,o]),i=t==="generic"?r.every(d=>d.type===r[0].type):t==="linear"?n.every(d=>ai(d)===ai(n[0])):!1,[a,l]=JL({x:0,y:0}),s=Mu(""),m=Mu(null);_a(()=>{let d=[...r,...n].sort((x,w)=>x.id.localeCompare(w.id)),p=`
8
+ ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${d.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(d.length===1){let[x,,,w,E,y]=lP(d[0],e.scene.getNonDeletedElementsMap());u=eP(dc(x,w),dc(E,y),d[0].angle)}else{let{minX:x,maxY:w}=aP(d);u=dc(x,w)}let{x:f,y:b}=cy({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[r,n,e.scene,e.state]),_a(()=>{for(let d of n){let p=Lu(d.id,DP(d));Na.has(p)||Na.set(p,d)}},[n]),_a(()=>{for(let d of r)if(!Ra.has(d.id)){let p=iy(d,e.scene.getNonDeletedElementsMap());p&&Ra.set(d.id,{fontSize:p.fontSize})}},[r,e.scene]);let c=t==="linear"?[["line",Xl],["sharpArrow",ns],["curvedArrow",as],["elbowArrow",is]]:t==="generic"?[["rectangle",Yl],["diamond",Wl],["ellipse",Vl]]:[];return Au("div",{ref:m,tabIndex:-1,style:{position:"absolute",top:`${a.y+(TP+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-vP}px`,zIndex:2},className:uP.CONVERT_ELEMENT_TYPE_POPUP,children:c.map(([d,p])=>{let u=i&&(t==="generic"&&r[0].type===d||t==="linear"&&ai(n[0])===d);return Au(K,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:d,keyBindingLabel:"","aria-label":d,"data-testid":`toolbar-${d}`,onChange:()=>{e.state.activeTool.type!==d&&re("convertElementType",d,"ui"),_u(e,{conversionType:t,nextType:d}),m.current?.focus()}},`${o[0].id}${o[0].version}_${d}`)})})},MP=(e,o,t)=>{let r=cP(e,o),n=sP(e,o),i=mP(o.text,Cu(o),r),a=oy(i,Cu(o),o.lineHeight),l=o.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};a=oy(o.text,Cu(s),o.lineHeight)}uc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),dP(o,e,t)},_u=(e,{conversionType:o,nextType:t,direction:r="right"})=>{if(!o)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=r==="right"?1:-1;if(o==="generic"){let l=ly(n),m=l.every(c=>c.type===l[0].type)?Aa.indexOf(l[0].type):-1;if(t=t??Aa[(m+Aa.length+a)%Aa.length],t&&li(t)){let c={};for(let p of l){let u=ny(p,t,e);c[u.id]=u}let d=[];for(let p of e.scene.getElementsIncludingDeleted())c[p.id]?d.push(c[p.id]):d.push(p);e.scene.replaceAllElements(d);for(let p of Object.values(c)){let u=iy(p,e.scene.getNonDeletedElementsMap());u&&(Ra.get(p.id)&&uc(u,e.scene.getNonDeletedElementsMap(),{fontSize:Ra.get(p.id)?.fontSize??u.fontSize}),MP(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:ty(p,{type:"selection"})}))}}if(o==="linear"){let l=Pu(n);if(!t){let m=fP(l,ai),c=m?Da.indexOf(m):-1;t=Da[(c+Da.length+a)%Da.length]}if(pc(t)){let m=[],c=e.scene.getElementsMapIncludingDeleted();for(let d of l){let p=Na.get(Lu(d.id,t));if(p&&ai(p)===t)c.set(p.id,p),m.push(p);else{let u=ny(d,t,e);c.set(u.id,u),m.push(u)}}e.scene.replaceAllElements(c);for(let d of m)if(Du(d))if(nP(d)){let p=LP(d);if(p.length<2)continue;let u=[];for(let b=1;b<p.length-2;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=QL(d,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});uc(d,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=gP(["line","sharpArrow","curvedArrow"],u=>Na.get(Lu(d.id,u)));if(p){let u=p.points;e.scene.mutateElement(d,{points:u})}}}let s=Pu(e.scene.getSelectedElements(e.state));e.setState(m=>({selectedElementIds:i,selectedLinearElement:s.length===1?new bP(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:ty(m,{type:"selection"})}))}return!0},si=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(li(t.type))return"generic";ay(t)&&(o=!0)}return o?"linear":null},ay=e=>Du(e)&&(!rP(e)||!oP(e)&&!tP(e)),Lu=(e,o)=>`${e}:${o}`,ly=e=>e.filter(o=>li(o.type)),Pu=e=>e.filter(o=>ay(o)),cc=20,ni=(e,o)=>e[0]===o[0],ku=(e,o)=>e[1]===o[1],ry=(e,o)=>ni(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),LP=e=>{let o=[e.points[0]],t=PP(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<cc?l[0]=a[0]:Math.abs(l[1]-a[1])<cc&&(l[1]=a[1]),ni(a,l)||ku(a,l)||o.push(dc(a[0],l[1])),o.push(l)}let r=[o[0]];for(let i=1;i<o.length-1;++i)ni(o[i-1],o[i])&&ni(o[i],o[i+1])||ku(o[i-1],o[i])&&ku(o[i],o[i+1])||r.push(o[i]);r.push(o[o.length-1]);let n=[r[0]];for(let i=1;i<r.length-1;++i){let a=n[n.length-1],l=r[i],s=r[i+1],m=ni(a,l),c=ni(l,s);if(m!==c){let d=ry(a,l),p=ry(l,s);if(d<cc||p<cc){if(p<d)m?s[0]=a[0]:s[1]=a[1];else if(c)for(let u=n.length-1;u>=0&&n[u][0]===a[0];--u)n[u][0]=l[0];else for(let u=n.length-1;u>=0&&n[u][1]===a[1];--u)n[u][1]=l[1];continue}}n.push(l)}return n.push(r[r.length-1]),n},PP=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[r,n]=o[o.length-1],[i,a]=e[t];(r!==i||n!==a)&&o.push(e[t])}return o},ny=(e,o,t)=>{if(!AP(e.type,o)){if(!hP())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(yP.delete(e),li(o)){let r=ii(xP({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:iP(o)?mc.ADAPTIVE_RADIUS:mc.PROPORTIONAL_RADIUS}:e.roundness}));return wP(r,t.scene),r}if(pc(o))switch(o){case"line":return ii(EP({...e,type:"line"}));case"sharpArrow":return ii(Su({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return ii(Su({...e,type:"arrow",elbowed:!1,roundness:{type:mc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return ii(Su({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return pP(o,`unhandled conversion type: ${o}`),e},AP=(e,o)=>!!(li(e)&&li(o)||pc(e)&&pc(o)),DP=e=>Du(e)?ai(e):e.type,sy=SP;var dy=B({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,r){return He.set(io,{type:"panel"}),{captureUpdate:_P.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>si(e)!==null});import{canCreateLinkFromElements as Ru,defaultGetElementLinkFromSelection as RP,getLinkIdAndTypeFromSelection as NP}from"@excalidraw/element";import{CaptureUpdateAction as Ba}from"@excalidraw/element";var hc=B({name:"copyElementLink",label:"labels.copyElementLink",icon:Sn,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=j(e,o);try{if(window.location){let i=NP(n,o);return i?(await ro(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):RP(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:Ba.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:Ba.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:Ba.EVENTUALLY}},predicate:(e,o)=>Ru(j(e,o))}),my=B({name:"linkToElement",label:"labels.linkToElement",icon:ss,perform:(e,o,t,r)=>{let n=j(e,o);return n.length!==1||!Ru(n)?{elements:e,appState:o,app:r,captureUpdate:Ba.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:j(e,o)[0].id}},captureUpdate:Ba.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=j(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&Ru(n)},trackEvent:!1});import{isDarwin as py,getShortcutKey as oe}from"@excalidraw/common";var BP={toggleTheme:[oe("Shift+Alt+D")],saveScene:[oe("CtrlOrCmd+S")],loadScene:[oe("CtrlOrCmd+O")],clearCanvas:[oe("CtrlOrCmd+Delete")],imageExport:[oe("CtrlOrCmd+Shift+E")],commandPalette:[oe("CtrlOrCmd+/"),oe("CtrlOrCmd+Shift+P")],cut:[oe("CtrlOrCmd+X")],copy:[oe("CtrlOrCmd+C")],paste:[oe("CtrlOrCmd+V")],copyStyles:[oe("CtrlOrCmd+Alt+C")],pasteStyles:[oe("CtrlOrCmd+Alt+V")],selectAll:[oe("CtrlOrCmd+A")],deleteSelectedElements:[oe("Delete")],duplicateSelection:[oe("CtrlOrCmd+D"),oe(`Alt+${g("helpDialog.drag")}`)],sendBackward:[oe("CtrlOrCmd+[")],bringForward:[oe("CtrlOrCmd+]")],sendToBack:[py?oe("CtrlOrCmd+Alt+["):oe("CtrlOrCmd+Shift+[")],bringToFront:[py?oe("CtrlOrCmd+Alt+]"):oe("CtrlOrCmd+Shift+]")],copyAsPng:[oe("Shift+Alt+C")],group:[oe("CtrlOrCmd+G")],ungroup:[oe("CtrlOrCmd+Shift+G")],gridMode:[oe("CtrlOrCmd+'")],zenMode:[oe("Alt+Z")],objectsSnapMode:[oe("Alt+S")],stats:[oe("Alt+/")],addToLibrary:[],flipHorizontal:[oe("Shift+H")],flipVertical:[oe("Shift+V")],viewMode:[oe("Alt+R")],hyperlink:[oe("CtrlOrCmd+K")],toggleElementLock:[oe("CtrlOrCmd+Shift+L")],resetZoom:[oe("CtrlOrCmd+0")],zoomOut:[oe("CtrlOrCmd+-")],zoomIn:[oe("CtrlOrCmd++")],zoomToFitSelection:[oe("Shift+3")],zoomToFit:[oe("Shift+1")],zoomToFitSelectionInViewport:[oe("Shift+2")],toggleEraserTool:[oe("E")],toggleHandTool:[oe("H")],setFrameAsActiveTool:[oe("F")],saveFileToDisk:[oe("CtrlOrCmd+S")],saveToActiveFile:[oe("CtrlOrCmd+S")],toggleShortcuts:[oe("?")],searchMenu:[oe("CtrlOrCmd+F")],wrapSelectionInFrame:[]},Ne=(e,o=0)=>{let t=BP[e];return t&&t.length>0?t[o]||t[0]:""};var FP="\\u0300-\\u036f",OP="\\ufe20-\\ufe2f",zP="\\u20d0-\\u20ff",HP=FP+OP+zP,GP=`[${HP}]`,UP=RegExp(GP,"g"),YP=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,WP={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},Nu=e=>e.replace(YP,o=>WP[o]||o).replace(UP,"");import _8 from"clsx";import{useEffect as R8,useState as N8}from"react";import{KEYS as B8,queryFocusableElements as d2}from"@excalidraw/common";import{useCallback as VP,useState as XP}from"react";var uy=()=>{let[e,o]=XP(null),t=VP(r=>o(r),[]);return[e,t]};import{useState as n2,useCallback as qu,useMemo as i2,useEffect as t2,memo as a2,useRef as v8}from"react";import{LIBRARY_DISABLED_TYPES as T8,randomId as I8,isShallowEqual as C8}from"@excalidraw/common";import{useEffect as by,useRef as xy}from"react";import{URL_HASH_KEYS as Ou,URL_QUERY_KEYS as zu,APP_NAME as Ey,EVENT as fc,DEFAULT_SIDEBAR as qP,LIBRARY_SIDEBAR_TAB as JP,arrayToMap as Hu,cloneJSON as QP,preventUnload as eA,promiseTry as yy,resolvablePromise as tA,toValidURL as oA,Queue as rA,Emitter as nA}from"@excalidraw/common";import{hashElementsVersion as iA,hashString as aA}from"@excalidraw/element";import{getCommonBoundingBox as Fu}from"@excalidraw/element";import{MIME_TYPES as Jr}from"@excalidraw/common";var mr=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=xn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:m,viewBackgroundColor:c}=s;return Rl(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:m,exportPadding:i,viewBackgroundColor:c,exportingFrame:a},(d,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(d,p),x=r<b?r/b:o?.exportScale??1;return u.width=d*x,u.height=p*x,{canvas:u,scale:x}}let f=n?.(d,p)||{width:d,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},hy=async e=>{let{mimeType:o=Jr.png,quality:t}=e;o===Jr.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${Jr.png}" mimeType`),o==="image/jpg"&&(o=Jr.jpg),o===Jr.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${Jr.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await mr(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===Jr.png&&e.appState?.exportEmbedScene&&(a=await h1({blob:a,metadata:Wi(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},ci=async({elements:e,appState:o=qo(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:m}=xn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),c={...m,exportPadding:r};return bn(s,c,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},KP=async e=>{if(e.type==="svg"){let o=await ci(e);await ro(o.outerHTML)}else if(e.type==="png")await Xs(hy(e));else if(e.type==="json")await Vs(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as ZP,useState as $P}from"react";import{COLOR_PALETTE as jP}from"@excalidraw/common";var Bu=me(new Map),gy=async e=>await ci({elements:e,appState:{exportBackground:!1,viewBackgroundColor:jP.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),fy=(e,o,t)=>{let[r,n]=$P();return ZP(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await gy(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await gy(o);n(i)})()},[e,o,t,n]),r},gc=()=>{let[e]=ie(Bu);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var lA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],vy=new nA,Qr=me({status:"loaded",isInitialized:!1,libraryItems:[]}),Fa=e=>QP(e),sA=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),Ty=(e,o)=>{let t=[];for(let r of o)sA(e,r)&&t.push(r);return[...t,...e]},Iy=(e,o)=>{let t=Hu(o),r={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||r.deletedItems.set(i.id,i);let n=Hu(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},Gu=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",Fa(this.currLibraryItems));I(this,"app");I(this,"updateQueue",[]);I(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);I(this,"notifyListeners",()=>{if(this.updateQueue.length>0)He.set(Qr,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{He.set(Qr,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Fa(this.currLibraryItems);let t=Fa(this.currLibraryItems);this.app.props.onLibraryChange?.(t),vy.trigger(Iy(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],He.set(Bu,new Map)});I(this,"resetLibrary",()=>this.setLibrary([]));I(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(Fa(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:qP.name,tab:JP}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),m;s instanceof Blob?m=await Em(s,i):m=Ki(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:m.length}))?(t&&this.app.focusContainer(),a(r?Ty(this.currLibraryItems,m):m)):l(new gn)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Fa(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},Cy=Gu,Ec=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:w}=Fu(x.elements);return Math.max(b,w)},0),i=u=>{let f=0,b=0,x=0;for(let w of e){if(f%t===0&&(b=0),b===u){let{width:E}=Fu(w.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,m=0,c=0,d=0,p=0;for(let u of e){c&&c%t===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=n(p)),m=i(d);let{minX:f,minY:b,width:x,height:w}=Fu(u.elements),E=(m-x)/2,y=(s-w)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+y-b}))),a+=m+50,c++,d++}return r},cA=(e,o=lA)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Uu=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Ou.addLibrary)||new URLSearchParams(window.location.search).get(zu.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},pr=class pr{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(Ki(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?pr.queue.push(n):n()}getLibraryItems(o){return pr.getLibraryItems(this.adapter,o,!1)}};I(pr,"queue",new rA),I(pr,"run",async(o,t)=>{let r=new pr(o);return pr.queue.push(()=>t(r))});var di=pr,Oa=0,bc=0,xc=e=>aA(e.map(o=>`${o.id}:${iA(o.elements)}`).sort().join()),wy=async(e,o)=>{try{return bc++,await di.run(e,async t=>{let r=Hu(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);let i=n.concat(Array.from(r.values())),a=xc(i);return a!==Oa&&await e.save({libraryItems:i}),Oa=a,i})}finally{bc--}},dA=e=>{let{excalidrawAPI:o}=e,t=xy(e);t.current=e;let r=xy(!1);by(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let m=new Promise(async(d,p)=>{try{l=decodeURIComponent(l),l=oA(l),cA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();d(f)}catch(u){p(u)}}),c=s!==o.id;await(c&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:m,prompt:c,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw o.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(Ou.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(Ou.addLibrary),window.history.replaceState({},Ey,`#${d.toString()}`)}else if(window.location.search.includes(zu.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(zu.addLibrary),window.history.replaceState({},Ey,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=Uu();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Uu();if(a&&n(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,m=tA();s?m.resolve(yy(s.load).then(async c=>{let d=null;try{if(!c)return di.getLibraryItems(l,"load");d=Ki(c.libraryItems||[],"published");let p=await wy(l,Iy([],d));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),d}}).catch(c=>(console.error(`error during library migration: ${c.message}`),di.getLibraryItems(l,"load")))):m.resolve(yy(di.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:m.then(c=>{let d=c||[];return Oa=xc(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(fc.HASHCHANGE,i),()=>{window.removeEventListener(fc.HASHCHANGE,i)}},[o]),by(()=>{let n=vy.on(async(a,l)=>{let s=r.current,m="adapter"in t.current&&t.current.adapter||null;try{m&&Oa!==xc(l)&&await wy(m,a)}catch(c){console.error(`couldn't persist library update: ${c.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{bc&&eA(a)};return window.addEventListener(fc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(fc.BEFORE_UNLOAD,i),n(),Oa=0,bc=0}},[])};import hA from"clsx";import{VERSIONS as mA}from"@excalidraw/common";import{jsx as uA}from"react/jsx-runtime";var pA=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return uA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${mA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},Sy=pA;import{jsx as gA,jsxs as fA}from"react/jsx-runtime";var yc=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>fA("div",{className:hA("library-menu-control-buttons",i),style:r,children:[gA(Sy,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as ui,useEffect as h8,useMemo as Qy,useRef as g8,useState as f8}from"react";import{MIME_TYPES as b8,arrayToMap as x8}from"@excalidraw/common";import{duplicateElements as E8}from"@excalidraw/element";import bA from"lodash.throttle";import{useEffect as xA}from"react";var EA=me(0),ky=e=>{let[o,t]=ie(EA);return xA(()=>{let{current:r}=e;if(!r)return;let n=bA(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import qA from"clsx";import{useCallback as JA,useState as Xu}from"react";import{muteFSAbortError as QA}from"@excalidraw/common";import{flushSync as My}from"react-dom";import yA from"clsx";import{jsx as wc,jsxs as vA}from"react/jsx-runtime";var wA=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return vA("button",{className:yA("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&wc("div",{style:a?{visibility:"hidden"}:{},children:r}),wc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&wc("div",{style:{position:"absolute",inset:0},children:wc(tt,{})})]})},No=wA;import{jsx as Ly,jsxs as Py}from"react/jsx-runtime";var TA=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=le(),m=Jo(mi),{container:c}=Ge();return Py(Be,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,Py("div",{className:"confirm-dialog-buttons",children:[Ly(No,{label:i,onClick:()=>{s({openMenu:null}),m(!1),My(()=>{t()}),c?.focus()}}),Ly(No,{label:n,onClick:()=>{s({openMenu:null}),m(!1),My(()=>{o()}),c?.focus()},actionType:"danger"})]})]})},vc=TA;import Ic from"open-color";import{useCallback as PA,useEffect as Vu,useRef as Ay,useState as Yu}from"react";import{EDITOR_LS_KEYS as Wu,EXPORT_DATA_TYPES as AA,MIME_TYPES as Dy,VERSIONS as DA,chunk as _A,getExportSource as RA}from"@excalidraw/common";var Ut=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};I(Ut,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),I(Ut,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Tc from"react";var IA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,CA=/{{([\w-]+)}}/,SA=/<([\w-]+)>/,kA=/<\/([\w-]+)>/,MA=(e,o)=>{let t=[{name:"",children:[]}];return e.split(IA).filter(Boolean).forEach(r=>{let n=r.match(SA),i=r.match(kA),a=r.match(CA);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),m=Tc.createElement(Tc.Fragment,{},...s.children),c=o[s.name];typeof c=="function"&&t[t.length-1].children.push(c(m))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},LA=({i18nKey:e,children:o,...t})=>{let{t:r}=ze();return Tc.createElement(Tc.Fragment,{},...MA(r(e),t))},ut=LA;import{jsx as ae,jsxs as at}from"react/jsx-runtime";var NA=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=_A(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,a.height=i.length*128+(i.length+1)*(r*2)-r*2;let l=a.getContext("2d");l.fillStyle=Ic.white,l.fillRect(0,0,a.width,a.height);for(let[s,m]of e.entries()){let c=await mr({elements:m.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=c,u=Math.floor(s/6)*(128+r*2),f=s%6*(128+r*2);l.drawImage(c,f+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=Ic.gray[4],l.strokeRect(f+r/2,u+r/2,128+r,128+r)}return await Fl(new File([await ko(a)],"preview",{type:Dy.png}),{outputType:Dy.jpg,maxWidthOrHeight:5e3})},BA=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=Ay(null),a=Ay(null);return Vu(()=>{let l=i.current;l&&(async()=>{let s=await ci({elements:e.elements,appState:{...o,viewBackgroundColor:Ic.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),at("div",{className:"single-library-item",children:[e.status==="published"&&ae("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),ae("div",{ref:i,className:"single-library-item__svg"}),ae(K,{"aria-label":g("buttons.remove"),type:"button",icon:Ft,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:g("buttons.remove")}),at("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[at("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[at("div",{style:{padding:"0.5em 0"},children:[ae("span",{style:{fontWeight:500,color:Ic.gray[6]},children:g("publishDialog.itemName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),ae("span",{className:"error",children:e.error})]})]})},FA=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Yu({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[m,c]=Yu(!1);Vu(()=>{let y=Ut.get(Wu.PUBLISH_LIBRARY);y&&s(y)},[]);let[d,p]=Yu(o.slice());Vu(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),c(!0);let v=[],C=!1;if(d.forEach(N=>{let O="";N.name||(O=g("publishDialog.errors.required"),C=!0),v.push({...N,error:O})}),C){p(v),c(!1);return}let S=await NA(d),L={type:AA.excalidrawLibrary,version:DA.excalidrawLibrary,source:RA(),libraryItems:d},k=JSON.stringify(L,null,2),A=new Blob([k],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",A),P.append("previewImage",S),P.append("previewImageType",S.type),P.append("title",l.name),P.append("authorName",l.authorName),P.append("githubHandle",l.githubHandle),P.append("name",l.name),P.append("description",l.description),P.append("twitterHandle",l.twitterHandle),P.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(N=>N.ok?N.json().then(({url:O})=>{Ut.delete(Wu.PUBLISH_LIBRARY),r({url:O,authorName:l.authorName,items:d})}):N.json().catch(()=>{throw new Error(N.statusText||"something went wrong")}).then(O=>{throw new Error(O.message||N.statusText||"something went wrong")}),N=>{console.error(N),n(N),c(!1)}).catch(N=>{console.error(N),n(N),c(!1)})},b=()=>{let y=[];return d.forEach((v,C)=>{y.push(ae("div",{className:"single-library-item-wrapper",children:ae(BA,{libItem:v,appState:t,index:C,onChange:(S,L)=>{let k=d.slice();k[L].name=S,p(k)},onRemove:a})},C))}),ae("div",{className:"selected-library-items",children:y})},x=PA(()=>{i(d),Ut.set(Wu.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),w=!!o.length,E=o.some(y=>y.status==="published");return ae(Be,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:w?at("form",{onSubmit:f,children:[ae("div",{className:"publish-library-note",children:ae(ut,{i18nKey:"publishDialog.noteDescription",link:y=>ae("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),ae("span",{className:"publish-library-note",children:ae(ut,{i18nKey:"publishDialog.noteGuidelines",link:y=>ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),ae("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&ae("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),at("div",{className:"publish-library__fields",children:[at("label",{children:[at("div",{children:[ae("span",{children:g("publishDialog.libraryName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),at("label",{style:{alignItems:"flex-start"},children:[at("div",{children:[ae("span",{children:g("publishDialog.libraryDesc")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),at("label",{children:[at("div",{children:[ae("span",{children:g("publishDialog.authorName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),at("label",{children:[ae("span",{children:g("publishDialog.githubUsername")}),ae("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),at("label",{children:[ae("span",{children:g("publishDialog.twitterUsername")}),ae("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),at("label",{children:[ae("span",{children:g("publishDialog.website")}),ae("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),ae("span",{className:"publish-library-note",children:ae(ut,{i18nKey:"publishDialog.noteLicense",link:y=>ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),at("div",{className:"publish-library__buttons",children:[ae(No,{label:g("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),ae(No,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:m})]})]}):ae("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},_y=FA;import HA from"clsx";import{useEffect as GA,useRef as UA}from"react";import{EVENT as Fy,KEYS as YA}from"@excalidraw/common";import{forwardRef as Ry}from"react";import Ny from"clsx";import{jsx as By}from"react/jsx-runtime";var OA=Ry(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>By("div",{className:Ny("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),zA=Ry(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>By("div",{className:Ny("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),qe={Row:OA,Col:zA};import{jsx as Cc}from"react/jsx-runtime";var Oy=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=ce(),a=UA(null),l=er({onClickOutside:o});_n(a,()=>{l.onClickOutside?.()}),GA(()=>{let m=d=>{d.key===YA.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},c={capture:!0};return document.addEventListener(Fy.KEYDOWN,m,c),()=>{document.removeEventListener(Fy.KEYDOWN,m,c)}},[l]);let s=HA(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Cc(fp.Provider,{value:{onSelect:r},children:Cc("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Cc(qe.Col,{className:"dropdown-menu-container",children:e}):Cc(Xe,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};Oy.displayName="DropdownMenuContent";var zy=Oy;import{jsx as VA}from"react/jsx-runtime";var WA=({children:e,className:o="",selected:t,...r})=>VA("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Hy=WA;import{jsx as Gy}from"react/jsx-runtime";var Uy=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let m=Ms(s.onClick,n);return Gy("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:ks(i,a),title:s.title??s["aria-label"],onClick:m,children:Gy(Ss,{icon:e,shortcut:o,children:r})})},pi=Uy;Uy.displayName="DropdownMenuItemLink";import{jsx as XA}from"react/jsx-runtime";var Yy=()=>XA("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Wy=Yy;Yy.displayName="DropdownMenuSeparator";import KA from"clsx";import{jsx as ZA}from"react/jsx-runtime";var Vy=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=ce(),a=KA(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return ZA("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},Xy=Vy;Vy.displayName="DropdownMenuTrigger";import Sc from"react";var Ky=e=>{let o=Sc.Children.toArray(e).find(t=>Sc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},Zy=e=>{let o=Sc.Children.toArray(e).find(t=>Sc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as $A,jsxs as jA}from"react/jsx-runtime";var Bo=({children:e,open:o})=>{let t=Ky(e),r=Zy(e);return jA($A,{children:[t,o&&r]})};Bo.Trigger=Xy;Bo.Content=zy;Bo.Item=mt;Bo.ItemLink=pi;Bo.ItemCustom=Hy;Bo.Group=ca;Bo.Separator=Wy;var fe=Bo;Bo.displayName="DropdownMenu";import{jsx as vt,jsxs as kc}from"react/jsx-runtime";var e8=(e,o)=>e.filter(t=>o.includes(t.id)),t8=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ie(Qr),[m,c]=ie(mi),d=()=>{let P=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),N=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return vt(vc,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:N,children:vt("p",{children:P})})},[p,u]=Xu(!1),f=!!o.length,b=f?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[w,E]=Xu(!1),[y,v]=Xu(null),C=JA(()=>kc(Be,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[vt("p",{children:vt(ut,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>vt("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),vt(K,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(P,N)=>{E(!1),v({url:P.url,authorName:P.authorName});let O=N.slice();O.forEach(U=>{o.includes(U.id)&&(U.status="published")}),t.setLibrary(O)},L=async()=>{try{await t.updateLibrary({libraryItems:Ll({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:g("errors.importLibraryError")})}},k=async()=>{let P=f?b:await t.getLatestLibrary();n1(P).catch(QA).catch(N=>{e({errorMessage:N.message})})},A=()=>kc(fe,{open:m,children:[vt(fe.Trigger,{onToggle:()=>c(!m),children:A1}),kc(fe.Content,{onClickOutside:()=>c(!1),onSelect:()=>c(!1),className:"library-menu",children:[!f&&vt(fe.Item,{onSelect:L,icon:Cn,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&vt(fe.Item,{onSelect:k,icon:zr,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&vt(fe.Item,{onSelect:()=>u(!0),icon:Mt,children:x}),f&&vt(fe.Item,{icon:H0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return kc("div",{className:qA("library-menu-dropdown-container",l),children:[A(),o.length>0&&vt("div",{className:"library-actions-counter",children:o.length}),p&&d(),w&&vt(_y,{onClose:()=>E(!1),libraryItems:e8(s.libraryItems,o),appState:a,onSuccess:P=>S(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(N=>N!==P))}),y&&C()]})},Ku=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=Re(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=gc(),a=ge(),l=le(),[s]=ie(Qr),m=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return vt(t8,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>m(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as d8,useEffect as m8,useState as p8}from"react";import o8,{useCallback as r8}from"react";function n8(){return[!1,r8(o=>o(),[])]}var $y=o8.useTransition||n8;import jy from"clsx";import{memo as i8,useEffect as a8,useRef as l8,useState as s8}from"react";import{jsx as Mc,jsxs as c8}from"react/jsx-runtime";var qy=i8(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=l8(null),m=fy(e,o,l);a8(()=>{let f=s.current;if(f)return m&&(f.innerHTML=m.outerHTML),()=>{f.innerHTML=""}},[m]);let[c,d]=s8(!1),p=ce().editor.isMobile,u=t&&Mc("div",{className:"library-unit__adder",children:P1});return c8("div",{className:jy("library-unit",{"library-unit__active":o,"library-unit--hover":o&&c,"library-unit--selected":n,"library-unit--skeleton":!m}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[Mc("div",{className:jy("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):r(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}d(!1),a(e,f)}}),u,e&&o&&(c||p||n)&&Mc(xa,{checked:n,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),Jy=()=>Mc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as u8,jsx as Lc}from"react/jsx-runtime";var Zu=({children:e})=>Lc("div",{className:"library-menu-items-container__grid",children:e}),Pc=d8(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=$y(),[s,m]=p8(0);return m8(()=>{s<e.length&&l(()=>{m(s+a)})},[s,e.length,l,a]),Lc(u8,{children:e.map((c,d)=>d<s?Lc(qy,{elements:c?.elements,isPending:!c?.id&&!!c?.elements,onClick:n,svgCache:i,id:c?.id,selected:r(c.id),onToggle:o,onDrag:t},c?.id??d):Lc(Jy,{},d))})});import{Fragment as e2,jsx as Tt,jsxs as hi}from"react/jsx-runtime";var y8=17,w8=64;function $u({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:m}){let c=g8(null),d=ky(c);h8(()=>{d>0&&c.current?.scrollTo(0,d)},[]);let{svgCache:p}=gc(),u=Qy(()=>o.filter(P=>P.status!=="published"),[o]),f=Qy(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!f.length,[w,E]=f8(null),y=ui((P,N)=>{let O=!m.includes(P),U=[...u,...f];if(O){if(N.shiftKey&&w){let J=U.findIndex(Z=>Z.id===w),_=U.findIndex(Z=>Z.id===P);if(J===-1||_===-1){s([...m,P]);return}let R=x8(m),V=U.reduce((Z,W,se)=>((se>=J&&se<=_||R.has(W.id))&&Z.push(W.id),Z),[]);s(V)}else s([...m,P]);E(P)}else E(null),s(m.filter(J=>J!==P))},[w,s,f,m,u]),v=ui(P=>{let N;return m.includes(P)?N=o.filter(O=>m.includes(O.id)):N=o.filter(O=>O.id===P),N.map(O=>({...O,elements:E8({type:"everything",elements:O.elements,randomizeSeed:!0}).duplicatedElements}))},[o,m]),C=ui((P,N)=>{N.dataTransfer.setData(b8.excalidrawlib,gm(v(P)))},[v]),S=ui(P=>P?m.includes(P):!1,[m]),L=ui(()=>{t(n)},[n,t]),k=ui(P=>{P&&r(v(P))},[v,r]),A=p.size>=o.length?w8:y8;return hi("div",{className:"library-menu-items-container",style:n.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&Tt(Ku,{selectedItems:m,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),hi(qe.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:c,children:[hi(e2,{children:[!x&&Tt("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),e&&Tt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Tt(tt,{})}),!n.length&&!u.length?hi("div",{className:"library-menu-items__no-items",children:[Tt("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),Tt("div",{className:"library-menu-items__no-items__hint",children:f.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):hi(Zu,{children:[n.length>0&&Tt(Pc,{itemsRenderedPerBatch:A,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p}),Tt(Pc,{itemsRenderedPerBatch:A,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})]})]}),hi(e2,{children:[(f.length>0||n.length>0||u.length>0)&&Tt("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:g("labels.excalidrawLib")}),f.length>0?Tt(Zu,{children:Tt(Pc,{itemsRenderedPerBatch:A,items:f,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})}):u.length>0?Tt("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:g("library.noItems")}):null]}),b&&Tt(yc,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:Tt(Ku,{selectedItems:m,onSelectItems:s})})]})]})}import{jsx as ur,jsxs as r2}from"react/jsx-runtime";var mi=me(!1),o2=({children:e})=>ur("div",{className:"layer-ui__library",children:e}),S8=a2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:m})=>{let[c]=ie(Qr),d=qu(f=>{(async(x,w)=>{re("element","addToLibrary","ui");for(let y of T8)if(x.some(v=>v.type===y))return r({errorMessage:g(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:I8(),created:Date.now()},...w];t(),i.setLibrary(E).catch(()=>{r({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,c.libraryItems)},[t,i,r,c.libraryItems]),p=i2(()=>c.libraryItems,[c]);if(c.status==="loading"&&!c.isInitialized)return ur(o2,{children:ur("div",{className:"layer-ui__library-message",children:r2("div",{children:[ur(tt,{size:"2em"}),ur("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=c.libraryItems.length>0||o.length>0;return r2(o2,{children:[ur($u,{isLoading:c.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:m,selectedItems:s}),u&&ur(yc,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),ju=(e,o)=>({elements:e,pending:j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),k8=(e,o)=>{let t=rr(),[r,n]=n2(()=>ju(t,e.selectedElementIds)),i=v8(new Map);return t2(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),t2(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!C8(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),ju(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let m=l.get(s)?.version;if(m&&m!==i.current.get(s))return ju(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},l2=a2(()=>{let e=Re(),{onInsertElements:o}=e,t=fo(),r=ge(),n=le(),[i,a]=n2([]),l=i2(()=>e.library,[e.library]),s=k8(r,e),m=qu(d=>{o(Ec(d))},[o]),c=qu(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return ur(S8,{pendingElements:s,onInsertLibraryItems:m,onAddToLibrary:c,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import M8 from"clsx";import{useRef as L8}from"react";import{createPortal as P8}from"react-dom";import{KEYS as A8}from"@excalidraw/common";import{jsx as s2,jsxs as D8}from"react/jsx-runtime";var c2=e=>{let{closeOnClickOutside:o=!0}=e,t=bs({className:"excalidraw-modal-container"}),r=L8(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===A8.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return P8(D8("div",{className:M8("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[s2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),s2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as za,jsxs as O8}from"react/jsx-runtime";function F8(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Be=e=>{let[o,t]=uy(),[r]=N8(document.activeElement),{id:n}=Ge(),i=ce().viewport.isMobile;R8(()=>{if(!o)return;let m=d2(o);setTimeout(()=>{m.length>0&&e.autofocus!==!1&&(m[1]||m[0]).focus()});let c=d=>{if(d.key===B8.TAB){let p=d2(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):f===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",c),()=>o.removeEventListener("keydown",c)},[o,e.autofocus]);let a=le(),l=Jo(mi),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return za(c2,{className:_8("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:F8(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:O8(Xe,{ref:t,children:[e.title&&za("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:za("span",{className:"Dialog__titleContent",children:e.title})}),i&&za("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Ft}),za("div",{className:"Dialog__content",children:e.children})]})})};import Ju from"clsx";import{forwardRef as U8,useRef as Y8,useImperativeHandle as W8,useLayoutEffect as V8,useState as X8}from"react";import z8 from"clsx";import{composeEventHandlers as H8}from"@excalidraw/common";import{jsx as G8}from"react/jsx-runtime";var Rt=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>G8("button",{onClick:H8(i.onClick,a=>{o()}),type:e,className:z8("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as Qu,jsxs as m2}from"react/jsx-runtime";var gi=U8(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:m,...c},d)=>{let p=Y8(null);W8(d,()=>p.current),V8(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=X8(!1);return m2("div",{className:Ju("ExcTextField",m,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&Qu("div",{className:"ExcTextField__label",children:o}),m2("div",{className:Ju("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[Qu("input",{className:Ju({"is-redacted":"value"in c&&c.value&&l&&!u}),readOnly:n,value:"value"in c?c.value:void 0,defaultValue:"defaultValue"in c?c.defaultValue:void 0,placeholder:r,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&Qu(Rt,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?Z0:Mn})]})]})});import{KEYS as Fe}from"@excalidraw/common";var Ac=[{icon:Tm,value:"selection",key:Fe.V,numericKey:Fe[1],fillable:!0},{icon:Yl,value:"rectangle",key:Fe.R,numericKey:Fe[2],fillable:!0},{icon:Wl,value:"diamond",key:Fe.D,numericKey:Fe[3],fillable:!0},{icon:Vl,value:"ellipse",key:Fe.O,numericKey:Fe[4],fillable:!0},{icon:F1,value:"arrow",key:Fe.A,numericKey:Fe[5],fillable:!0},{icon:Xl,value:"line",key:Fe.L,numericKey:Fe[6],fillable:!0},{icon:Qo,value:"freedraw",key:[Fe.P,Fe.X],numericKey:Fe[7],fillable:!1},{icon:Tn,value:"text",key:Fe.T,numericKey:Fe[8],fillable:!1},{icon:z1,value:"image",key:null,numericKey:Fe[9],fillable:!1},{icon:H1,value:"eraser",key:Fe.E,numericKey:Fe[0],fillable:!1}],eh=e=>e.defaultSelectionTool==="lasso"?[{value:"lasso",icon:Tm,key:Fe.V,numericKey:Fe[1],fillable:!0},...Ac.slice(1)]:Ac,p2=(e,o)=>eh(o).find((r,n)=>r.numericKey!=null&&e===r.numericKey.toString()||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null;import nh from"clsx";import{useState as $8}from"react";import{CLASSES as j8,KEYS as h2,capitalizeString as rh,isTransparent as g2}from"@excalidraw/common";import{shouldAllowVerticalAlign as q8,suppportsHorizontalAlign as J8}from"@excalidraw/element";import{hasBoundTextElement as f2,isElbowArrow as Q8,isImageElement as e7,isLinearElement as t7,isTextElement as o7}from"@excalidraw/element";import{hasStrokeColor as b2,toolIsArrow as x2}from"@excalidraw/element";import{createIsolation as K8}from"jotai-scope";import th from"react";import yo from"tunnel-rat";var oh=th.createContext(null),ve=()=>th.useContext(oh),Z8=K8(),u2=()=>th.useMemo(()=>({MainMenuTunnel:yo(),WelcomeScreenMenuHintTunnel:yo(),WelcomeScreenToolbarHintTunnel:yo(),WelcomeScreenHelpHintTunnel:yo(),WelcomeScreenCenterTunnel:yo(),FooterCenterTunnel:yo(),DefaultSidebarTriggerTunnel:yo(),DefaultSidebarTabTriggersTunnel:yo(),OverwriteConfirmDialogTunnel:yo(),TTDDialogTriggerTunnel:yo(),tunnelsJotai:Z8}),[]);import{Fragment as Fo,jsx as Te,jsxs as $e}from"react/jsx-runtime";var ih=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return b2(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>b2(r.type))},ah=(e,o)=>$o(e.activeTool.type)||o.some(t=>$o(t.type)),Dc=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=Ml(o,e),i=!1;n.length===2&&(f2(n[0])||f2(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=ce(),s=document.documentElement.getAttribute("dir")==="rtl",m=$o(e.activeTool.type)&&!g2(e.currentItemBackgroundColor)||n.some(f=>$o(f.type)&&!g2(f.backgroundColor)),c=n.length===1||i,d=!e.selectedLinearElement?.isEditing&&n.length===1&&t7(n[0])&&!Q8(n[0]),p=!e.croppingElementId&&n.length===1&&e7(n[0]),u=!i&&wt(e,r);return $e("div",{className:"selected-shape-actions",children:[Te("div",{children:ih(e,n)&&t("changeStrokeColor")}),ah(e,n)&&Te("div",{children:t("changeBackgroundColor")}),m&&t("changeFillStyle"),(cm(e.activeTool.type)||n.some(f=>cm(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(dm(e.activeTool.type)||n.some(f=>dm(f.type)))&&$e(Fo,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(mm(e.activeTool.type)||n.some(f=>mm(f.type)))&&Te(Fo,{children:t("changeRoundness")}),(x2(e.activeTool.type)||n.some(f=>x2(f.type)))&&Te(Fo,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(o7))&&$e(Fo,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||J8(n,o))&&t("changeTextAlign")]}),q8(n,o)&&t("changeVerticalAlign"),(hn(e.activeTool.type)||n.some(f=>hn(f.type)))&&Te(Fo,{children:t("changeArrowhead")}),t("changeOpacity"),$e("fieldset",{children:[Te("legend",{children:g("labels.layers")}),$e("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&$e("fieldset",{children:[Te("legend",{children:g("labels.align")}),$e("div",{className:"buttonList",children:[s?$e(Fo,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):$e(Fo,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),Te("div",{style:{flexBasis:"100%",height:0}}),$e("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically")]})]})]}),!a&&n.length>0&&$e("fieldset",{children:[Te("legend",{children:g("labels.actions")}),$e("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),c&&t("hyperlink"),p&&t("cropEditor"),d&&t("toggleLinearEditor")]})]})]})},_c=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=$8(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso"&&t.defaultSelectionTool!=="lasso",m=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=ve();return $e(Fo,{children:[eh(t).map(({value:d,icon:p,key:u,numericKey:f,fillable:b},x)=>{if(r.tools?.[d]===!1)return null;let w=g(`toolBar.${d}`),E=u&&rh(typeof u=="string"?u:u[0]),y=E?`${E} ${g("helpDialog.or")} ${f}`:`${f}`;return Te(K,{className:nh("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===d,name:"editor-current-shape",title:`${rh(w)} \u2014 ${y}`,keyBindingLabel:f||E,"aria-label":rh(w),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),d==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==d&&re("toolbar",d,"ui"),d==="image"?t.setActiveTool({type:d}):t.setActiveTool({type:d})}},d)}),Te("div",{className:"App-toolbar__divider"}),$e(fe,{open:n,children:[Te(fe.Trigger,{className:nh("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||m||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:g("toolBar.extraTools"),children:a?Gr:m?Sm:l&&!t.props.isCollaborating?ea:s?Zi:X0}),$e(fe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:Gr,shortcut:h2.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:g("toolBar.frame")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:Sm,"data-testid":"toolbar-embeddable",selected:m,children:g("toolBar.embeddable")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:ea,"data-testid":"toolbar-laser",selected:l,shortcut:h2.K.toLocaleUpperCase(),children:g("toolBar.laser")}),t.defaultSelectionTool!=="lasso"&&Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:Zi,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),Te("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&Te(c.Out,{}),Te(fe.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:ts,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&Te(Fo,{children:$e(fe.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:os,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),Te(fe.Item.Badge,{children:"AI"})]})})]})]})]})},E2=({renderAction:e,zoom:o})=>Te(qe.Col,{gap:1,className:j8.ZOOM_ACTIONS,children:$e(qe.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),y2=({renderAction:e,className:o})=>$e("div",{className:`undo-redo-buttons ${o}`,children:[Te("div",{className:"undo-button-container",children:Te(Pt,{label:g("buttons.undo"),children:e("undo")})}),Te("div",{className:"redo-button-container",children:$e(Pt,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),w2=({actionManager:e,showExitZenModeBtn:o})=>Te("button",{type:"button",className:nh("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(ti),children:g("buttons.exitZenMode")});import{useRef as r7}from"react";var lh=e=>{let o=r7({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as i7,jsxs as n7}from"react/jsx-runtime";var en=me(null),v2=()=>{let[e,o]=ie(en),t=Ue();return e&&e==="clearCanvas"?i7(vc,{onConfirm:()=>{t.executeAction(_o),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:n7("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var sh={};Jf(sh,{toggleTheme:()=>a7});var a7={...Vr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Vr,"commandPalette")}};import{jsx as lt,jsxs as wo}from"react/jsx-runtime";var p7=me(null),ke={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},u7=e=>{switch(e){case ke.app:return 1;case ke.export:return 2;case ke.editor:return 3;case ke.tools:return 4;case ke.elements:return 5;case ke.links:return 6;default:return 10}},Bc=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return wo("div",{className:C2("shortcut",o),children:[r.map((n,i)=>lt("div",{className:"shortcut-wrapper",children:lt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),lt("div",{className:"shortcut-desc",children:t})]})},S2=e=>!e.altKey&&e[ao.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===ao.P||e.key===ao.SLASH),Ace=Object.assign(e=>{let o=ge(),t=le();return Nc(()=>{let r=n=>{S2(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&re("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(Fc.KEYDOWN,r,{capture:!0}),()=>window.removeEventListener(Fc.KEYDOWN,r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:lt(h7,{...e})},{defaultItems:sh});function h7({customCommandPaletteItems:e}){let o=Re(),t=ge(),r=le(),n=fo(),i=Ue(),[a,l]=ie(p7),[s,m]=Rc(null),c=s7(null),d=er({uiAppState:t,customCommandPaletteItems:e,appProps:n});Nc(()=>{let{uiAppState:S,customCommandPaletteItems:L,appProps:k}=d,A=U=>{let J="";return U.label&&(typeof U.label=="function"?J=g(U.label(o.scene.getNonDeletedElements(),S,o)):J=g(U.label)),J},P=U=>typeof U.icon=="function"?U.icon(S,o.scene.getNonDeletedElements()):U.icon,N=[],O=(U,J,_)=>{let R={label:A(U),icon:P(U),category:J,shortcut:Ne(U.name),keywords:U.keywords,predicate:U.predicate,viewMode:U.viewMode,perform:()=>{i.executeAction(U,"commandPalette")}};return _?_(R,U):R};if(S&&o.scene&&i){let U=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,La,hc,my].map(W=>O(W,ke.elements,(se,he)=>({...se,predicate:he.predicate?he.predicate:(de,it,po,pn)=>j(de,it).length>0}))),J=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(W=>O(W,ke.tools)),_=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(W=>O(W,ke.editor)),R=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(W=>O(W,ke.export));N=[...U,..._,{label:A(_o),icon:P(_o),shortcut:Ne(_o.name),category:ke.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{He.set(en,"clearCanvas")}},{label:g("buttons.exportImage"),category:ke.export,icon:jl,shortcut:Ne("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...R];let V=[{label:g("toolBar.library"),category:ke.app,icon:wn,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:T2.name,tab:T2.defaultTab}})}},{label:g("search.title"),category:ke.app,icon:Lt,viewMode:!0,perform:()=>{i.executeAction(Ha)}},{label:g("labels.shapeSwitch"),category:ke.elements,icon:ta,perform:()=>{i.executeAction(dy)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:ke.elements,icon:$l,viewMode:!1,predicate:(W,se)=>{let he=j(W,se);return he.length>0&&ih(se,he)},perform:()=>{r(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:$l,category:ke.elements,viewMode:!1,predicate:(W,se)=>{let he=j(W,se);return he.length>0&&ah(se,he)},perform:()=>{r(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:$l,category:ke.editor,viewMode:!1,perform:()=>{r(W=>({openMenu:W.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Ac.reduce((W,se)=>{let{value:he,icon:de,key:it,numericKey:po}=se;if(k.UIOptions.tools?.[he]===!1)return W;let un=it&&c7(typeof it=="string"?it:it[0])||po,Sl={label:g(`toolBar.${he}`),category:ke.tools,shortcut:un,icon:de,keywords:["toolbar"],viewMode:!1,perform:({event:am})=>{he==="image"?o.setActiveTool({type:he}):o.setActiveTool({type:he})}};return W.push(Sl),W},[]),...J,{label:g("toolBar.lock"),category:ke.tools,icon:S.activeTool.locked?vn:Or,shortcut:ao.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:ke.tools,icon:j0,viewMode:!1,predicate:k.aiEnabled,perform:()=>{r(W=>({...W,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:ke.tools,icon:ts,viewMode:!1,predicate:k.aiEnabled,perform:()=>{r(W=>({...W,openDialog:{name:"ttd",tab:"mermaid"}}))}}],Z=[...N,...V,...L||[]].map(W=>({...W,icon:W.icon||ta,order:W.order??u7(W.category),haystack:`${Nu(W.label.toLocaleLowerCase())} ${W.keywords?.join(" ")||""}`}));m(Z),l(Z.find(W=>W.label===a?.label)??null)}},[d,o,i,m,a?.label,l,r]);let[p,u]=Rc(""),[f,b]=Rc(null),[x,w]=Rc({}),E=S=>{r({openDialog:null},S),u("")},y=(S,L)=>{t.openDialog?.name==="commandPalette"&&(L.stopPropagation(),L.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),E(()=>{S.perform({actionManager:i,event:L}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=lh(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),C=lh(S=>{let L=m7(S.target)||S2(S)||S.key===ao.ESCAPE;if(L&&S.key!==ao.ARROW_UP&&S.key!==ao.ARROW_DOWN&&S.key!==ao.ENTER)return;let k=Object.values(x).flat(),A=a&&!p&&v(a);if(S.key===ao.ARROW_UP){S.preventDefault();let P=k.findIndex(U=>U.label===f?.label);if(A){if(P===0){b(a);return}if(f===a){let U=k[k.length-1];U&&b(U);return}}let N;P===-1?N=k.length-1:N=P===0?k.length-1:(P-1)%k.length;let O=k[N];O&&b(O);return}if(S.key===ao.ARROW_DOWN){S.preventDefault();let P=k.findIndex(U=>U.label===f?.label);if(A){if(!f||P===k.length-1){b(a);return}if(f===a){let U=k[0];U&&b(U);return}}let N=(P+1)%k.length,O=k[N];O&&b(O);return}if(S.key===ao.ENTER&&f&&setTimeout(()=>{y(f,S)}),!L){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){c?.current?.focus();return}S.preventDefault()}});return Nc(()=>(window.addEventListener(Fc.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(Fc.KEYDOWN,C,{capture:!0})),[C]),Nc(()=>{if(!s)return;let S=P=>{let N={};for(let O of P)N[O.category]?N[O.category].push(O):N[O.category]=[O];return N},L=s.filter(v).sort((P,N)=>P.order-N.order),k=!p&&a&&v(a);if(!p){w(S(k?L.filter(P=>P.label!==a?.label):L)),b(k?a:L[0]||null);return}let A=Nu(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=l7.filter(A,L,{extract:P=>P.haystack}).sort((P,N)=>N.score-P.score).map(P=>P.original),w(S(L)),b(L[0]??null)},[p,s,v,a]),wo(Be,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[lt(gi,{value:p,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:c}),!o.device.viewport.isMobile&&wo("div",{className:"shortcuts-wrapper",children:[lt(Bc,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),lt(Bc,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),lt(Bc,{shortcut:d7("Esc"),children:g("commandPalette.shortcuts.close")})]}),wo("div",{className:"commands",children:[a&&!p&&wo("div",{className:"command-category",children:[wo("div",{className:"command-category-title",children:[g("commandPalette.recents"),lt("div",{className:"icon",style:{marginLeft:"6px"},children:q0})]}),lt(I2,{command:a,isSelected:a.label===f?.label,onClick:S=>y(a,S),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,L)=>wo("div",{className:"command-category",children:[lt("div",{className:"command-category-title",children:S}),x[S].map(k=>lt(I2,{command:k,isSelected:k.label===f?.label,onClick:A=>y(k,A),onMouseMove:()=>b(k),showShortcut:!o.device.viewport.isMobile,appState:t},k.label))]},S)):s?wo("div",{className:"no-match",children:[lt("div",{className:"icon",children:Lt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var I2=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return wo("div",{className:C2("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:n,onMouseMove:t?l:r,title:t?g("commandPalette.itemNotAvailable"):"",children:[wo("div",{className:"name",children:[e.icon&&lt(ar,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),lt(da,{children:e.label})]}),i&&e.shortcut&&lt(Bc,{shortcut:e.shortcut})]})};import{getSizeFromPoints as T1e,randomInteger as dD,getUpdatedTimestamp as mD}from"@excalidraw/common";import{simplify as eD}from"points-on-curve";import{pointsOnBezierCurves as Bce}from"points-on-curve";import{invariant as Oce}from"@excalidraw/common";import{curve as Hce,lineSegment as Gce,pointFrom as Uce,pointDistance as Yce,pointFromArray as Wce,pointFromVector as Vce,pointRotateRads as Xce,polygon as Kce,polygonFromPoints as Zce,PRECISION as $ce,segmentsIntersectAt as jce,vector as qce,vectorAdd as Jce,vectorFromPoint as Qce,vectorScale as ede}from"@excalidraw/math";import{getElementAbsoluteCoords as ode}from"@excalidraw/element";var ch=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as tD,pointDistance as Z2,pointRotateRads as l1e}from"@excalidraw/math";import{ROUGHNESS as oD,isTransparent as Va,assertNever as rD,COLOR_PALETTE as nD,LINE_POLYGON_POINT_MERGE_DISTANCE as c1e}from"@excalidraw/common";import{RoughGenerator as iD}from"roughjs/bin/generator";import Ife from"roughjs/bin/rough";import{getStroke as K7}from"perfect-freehand";import{isRightAngleRads as kfe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Lfe,DEFAULT_REDUCED_GLOBAL_ALPHA as Pfe,ELEMENT_READY_TO_ERASE_OPACITY as Afe,FRAME_STYLE as Dfe,MIME_TYPES as W2,THEME as _fe,distance as Rfe,getFontString as Nfe,isRTL as Bfe,getVerticalOffset as Ffe}from"@excalidraw/common";import Bhe from"roughjs/bin/rough";import{arrayToMap as Ohe,invariant as B2,rescalePoints as zhe,sizeOf as Hhe}from"@excalidraw/common";import{degreesToRadians as wh,lineSegment as Uhe,pointDistance as Yhe,pointFrom as ot,pointFromArray as A7,pointRotateRads as yi}from"@excalidraw/math";import{pointsOnBezierCurves as Xhe}from"points-on-curve";import{pointCenter as ehe,pointFrom as the,pointRotateRads as ohe,pointsEqual as rhe,pointDistance as nhe,vectorFromPoint as ihe,curveLength as ahe,curvePointAtLength as lhe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as dhe,KEYS as mhe,shouldRotateWithDiscreteAngle as phe,getGridPoint as uhe,invariant as hhe,tupleToCoors as ghe,viewportCoordsToSceneCoords as fhe}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as xhe,isPathALoop as Ehe}from"@excalidraw/element";import{KEYS as Qpe,arrayToMap as eue,isBindingFallthroughEnabled as tue,tupleToCoors as oue,invariant as rue,isDevEnv as nue,isTestEnv as iue}from"@excalidraw/common";import{lineSegment as lue,pointFrom as sue,pointRotateRads as cue,vectorFromPoint as due,pointDistanceSq as mue,clamp as pue,pointDistance as uue,pointFromVector as hue,vectorScale as gue,vectorNormalize as fue,vectorCross as bue,pointsEqual as xue,lineSegmentIntersectionPoints as Eue,PRECISION as yue}from"@excalidraw/math";import{isTransparent as Lme}from"@excalidraw/common";import{curveIntersectLineSegment as Ame,isPointWithinBounds as Dme,lineSegment as _me,lineSegmentIntersectionPoints as Rme,pointFrom as Nme,pointFromVector as Bme,pointRotateRads as Fme,pointsEqual as Ome,vectorFromPoint as zme,vectorNormalize as Hme,vectorScale as Gme}from"@excalidraw/math";import{ellipse as Yme,ellipseSegmentInterceptPoints as Wme}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as g7,DEFAULT_PROPORTIONAL_RADIUS as dh,LINE_CONFIRM_THRESHOLD as f7,ROUNDNESS as mh}from"@excalidraw/common";import{curve as lde,curveCatmullRomCubicApproxPoints as sde,curveOffsetPoints as cde,lineSegment as dde,pointDistance as b7,pointFrom as mde,pointFromArray as pde,rectangle as ude}from"@excalidraw/math";var Oc=(e,o=1)=>{if(e.length>=3){let[t,r]=[e[0],e[e.length-1]];return b7(t,r)<=f7/o}return!1},Ga=(e,o)=>{if(o.roundness?.type===mh.PROPORTIONAL_RADIUS||o.roundness?.type===mh.LEGACY)return e*dh;if(o.roundness?.type===mh.ADAPTIVE_RADIUS){let t=o.roundness?.value??g7,r=t/dh;return e<=r?e*dh:t}return 0};import{ROUNDNESS as yde,assertNever as wde}from"@excalidraw/common";import{pointsEqual as Tde}from"@excalidraw/math";var k2=e=>!!e&&e.type==="embeddable",M2=e=>!!e&&e.type==="iframe",uh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),tn=e=>e!=null&&e.type==="text";var zc=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var hr=e=>e!=null&&x7(e.type);var fi=e=>e!=null&&e.type==="arrow",Ua=e=>fi(e)&&e.elbowed;var x7=e=>e==="arrow"||e==="line";var bi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&tn(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Jde,ARROW_LABEL_WIDTH_FRACTION as Qde,BOUND_TEXT_PADDING as eme,DEFAULT_FONT_SIZE as tme,TEXT_ALIGN as ome,VERTICAL_ALIGN as rme,getFontString as nme,isProdEnv as ime,invariant as ame}from"@excalidraw/common";import{pointFrom as sme,pointRotateRads as cme}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Lde,DEFAULT_FONT_SIZE as Pde,DEFAULT_FONT_FAMILY as Ade,getFontString as Dde,isTestEnv as _de,normalizeEOL as Rde}from"@excalidraw/common";var Nde="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Ude,isTestEnv as Yde}from"@excalidraw/common";import{curvePointDistance as xme,distanceToLineSegment as Eme,pointRotateRads as yme}from"@excalidraw/math";import{ellipse as vme,ellipseDistanceFromPoint as Tme}from"@excalidraw/math/ellipse";import{invariant as ope,isDevEnv as rpe,isTestEnv as npe}from"@excalidraw/common";import{pointFrom as ape,pointFromVector as lpe,pointRotateRads as spe,pointScaleFromOrigin as cpe,pointsEqual as dpe,triangleIncludesPoint as mpe,vectorCross as ppe,vectorFromPoint as T7,vectorScale as upe}from"@excalidraw/math";var Eh=[1,0],D2=[0,1],yh=[-1,0],_2=[0,-1],Hc=e=>{let[o,t]=e,r=Math.abs(o),n=Math.abs(t);return o>n?Eh:o<=-n?yh:t>r?D2:_2},R2=(e,o)=>Hc(T7(e,o)),Gc=(e,o)=>Uc(R2(e,o)),xh=(e,o)=>e[0]===o[0]&&e[1]===o[1],Uc=e=>xh(e,Eh)||xh(e,yh);import{clamp as Epe,pointDistance as ype,pointFrom as wpe,pointScaleFromOrigin as vpe,pointsEqual as Tpe,pointTranslate as Ipe,vector as Cpe,vectorCross as Spe,vectorFromPoint as kpe,vectorScale as Mpe}from"@excalidraw/math";import{BinaryHeap as Ppe,invariant as Ape,isAnyTrue as Dpe,tupleToCoors as _pe,getSizeFromPoints as Rpe,isDevEnv as Npe,arrayToMap as Bpe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Nue,viewportCoordsToSceneCoords as Bue}from"@excalidraw/common";import{normalizeRadians as Oue,radiansBetweenAngles as zue,radiansDifference as Hue}from"@excalidraw/math";import{pointsEqual as Uue}from"@excalidraw/math";var ph=e=>{let o=Math.floor(e.width/2)+1,t=0,r=e.width,n=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,r,n,i,a,0,n]};var D7=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},_7=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},vh=(e,o,t,r)=>{if(o.length<1)return null;let n=ch(o[0]);if(n.length<1)return null;let i=t==="start"?1:n.length-1,a=n[i].data;B2(a.length===6,"Op data length is not 6");let l=ot(a[4],a[5]),s=ot(a[2],a[3]),m=ot(a[0],a[1]),c=n[i-1],d=ot(0,0);if(c.op==="move"){let _=A7(c.data);B2(_!=null,"Op data is not a point"),d=_}else c.op==="bcurveTo"&&(d=ot(c.data[4],c.data[5]));let p=(_,R)=>Math.pow(1-_,3)*l[R]+3*_*Math.pow(1-_,2)*s[R]+3*Math.pow(_,2)*(1-_)*m[R]+d[R]*Math.pow(_,3),[u,f]=t==="start"?d:l,[b,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-b,f-x),E=(u-b)/w,y=(f-x)/w,v=D7(r),C=0;{let[_,R]=t==="end"?e.points[e.points.length-1]:e.points[0],[V,Z]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(_-V,R-Z)}let L=Math.min(v,C*(r==="diamond"||r==="diamond_outline"?.25:.5)),k=u-E*L,A=f-y*L;if(r==="dot"||r==="circle"||r==="circle_outline"){let _=Math.hypot(A-f,k-u)+e.strokeWidth-2;return[u,f,_]}let P=_7(r);if(r==="crowfoot_many"||r==="crowfoot_one_or_many"){let[_,R]=yi(ot(u,f),ot(k,A),wh(-P)),[V,Z]=yi(ot(u,f),ot(k,A),wh(P));return[k,A,_,R,V,Z]}let[N,O]=yi(ot(k,A),ot(u,f),-P*Math.PI/180),[U,J]=yi(ot(k,A),ot(u,f),wh(P));if(r==="diamond"||r==="diamond_outline"){let _,R;if(t==="start"){let[V,Z]=e.points.length>1?e.points[1]:[0,0];[_,R]=yi(ot(u+L*2,f),ot(u,f),Math.atan2(Z-f,V-u))}else{let[V,Z]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,R]=yi(ot(u-L*2,f),ot(u,f),Math.atan2(f-Z,u-V))}return[u,f,N,O,_,R,U,J]}return[u,f,N,O,U,J]};import{pointFrom as age,pointCenter as lge,pointRotateRads as sge,vectorFromPoint as cge,vectorNormalize as dge,vectorSubtract as mge,vectorAdd as pge,vectorScale as uge,pointFromVector as hge,clamp as gge,isCloseTo as fge}from"@excalidraw/math";import{arrayToMap as ofe}from"@excalidraw/common";import{isPointWithinBounds as nfe,pointFrom as ife}from"@excalidraw/math";import{vectorCross as wge,vectorFromPoint as vge}from"@excalidraw/math";import{arrayToMap as R7}from"@excalidraw/common";import{getElementBounds as N7}from"@excalidraw/element";import{isArrowElement as B7,isExcalidrawElement as F7,isFreeDrawElement as O7,isLinearElement as z7,isTextElement as H7}from"@excalidraw/element";import{rangeIncludesValue as Yc,pointFrom as zo,pointRotateRads as G7,rangeInclusive as Wc}from"@excalidraw/math";var U7=e=>e.type==="diamond"?[zo(e.width/2,0),zo(e.width,e.height/2),zo(e.width/2,e.height),zo(0,e.height/2)]:[zo(0,0),zo(0+e.width,0),zo(0+e.width,e.height),zo(0,e.height)],Y7=e=>z7(e)||O7(e)?e.points:U7(e),O2=e=>{let o=e.reduce((t,[r,n])=>(t.minY=Math.min(t.minY,n),t.minX=Math.min(t.minX,r),t.maxX=Math.max(t.maxX,r),t.maxY=Math.max(t.maxY,n),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},z2=e=>{let o=Y7(e),{cx:t,cy:r}=O2(o),n=zo(t,r),i=o.map(c=>G7(c,n,e.angle)),{minX:a,minY:l,maxX:s,maxY:m}=O2(i);return[a+e.x,l+e.y,s+e.x,m+e.y]},Th=(e,o,t=!1)=>{let r=z2(e),n=o[0]<=r[0]&&o[2]>=r[2]&&o[1]<=r[1]&&o[3]>=r[3];return t?n?!0:r[0]<=o[0]&&r[2]>=o[2]&&r[1]<=o[1]&&r[3]>=o[3]:n},H2=(e,o)=>{let t=z2(e);return(Yc(t[0],Wc(o[0],o[2]))||Yc(o[0],Wc(t[0],t[2])))&&(Yc(t[1],Wc(o[1],o[3]))||Yc(o[1],Wc(t[1],t[3])))},G2=({elements:e,bounds:o,type:t,errorMargin:r=0})=>{F7(o)&&(o=N7(o,R7(e)));let n=[o[0]-r,o[1]-r,o[2]+r,o[3]+r],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?H2(a,n):t==="inside"?Th(a,n):Th(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);H7(a)&&a.containerId&&i.add(a.containerId),B7(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{arrayToMap as Oge,isShallowEqual as V7}from"@excalidraw/common";var W7=function(){let e=null,o=null,t=null,r=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let m={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let f=u.indexOf(l.editingGroupId);f>-1&&(u=u.slice(0,f))}if(u.length>0){let f=u[u.length-1];m[f]=!0}}let c={},d=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>m[b]);return f&&(p[u.id]=!0,Array.isArray(c[f])?c[f].push(u.id):c[f]=[u.id]),p},{});for(let p of Object.keys(c))c[p].length<2&&m[p]&&(m[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:m,selectedElementIds:Ih({...l.selectedElementIds,...d},s)},t},n=(i,a,l,s)=>{let m=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Ch(a,i);return m.length?r(m,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Ih(i.selectedElementIds,l)}};return n.clearCache=()=>{o=null,e=null,t=null},n}();var Vge=function(){let e=null,o=null,t=null,r=(n,i)=>(t!=null&&n===e&&i.selectedElementIds===o||(t=n.some(a=>i.selectedElementIds[a.id]),e=n,o=i.selectedElementIds),t);return r.clearCache=()=>{e=null,o=null,t=null},r}(),Ch=(e,o,t)=>{let r=new Set,n=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){n.push(i),r.add(i.id);continue}if(t?.includeBoundTextElement&&bi(i)&&o.selectedElementIds[i?.containerId]){n.push(i),r.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return n.forEach(a=>{zc(a)&&U2(e,a.id).forEach(l=>!r.has(l.id)&&i.push(l)),i.push(a)}),i}return n};var Ih=(e,o)=>V7(o.selectedElementIds,e)?o.selectedElementIds:e;var U2=(e,o)=>{let t=[];for(let r of e.values())r.frameId===o&&t.push(r);return t};var Z7=typeof document<"u"?document.createElement("img"):{src:""};Z7.src=`data:${W2.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var $7=typeof document<"u"?document.createElement("img"):{src:""};$7.src=`data:${W2.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;var V2=new WeakMap;var j7=new WeakMap([]);function X2(e){let o=q7(e),t=new Path2D(o);return j7.set(e,t),t}function q7(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([r,n],i)=>[r,n,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:r=>Math.sin(r*Math.PI/2),last:!!e.lastCommittedPoint};return Q7(K7(o,t))}function Y2(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var J7=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function Q7(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,r,n,i)=>(n===o?t.push(r,Y2(r,i[0]),"L",i[0],"Z"):t.push(r,Y2(r,i[n+1])),t),["M",e[0],"Q"]).join(" ").replace(J7,"$1")}var K2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var st=class st{};I(st,"rg",new iD),I(st,"cache",new WeakMap),I(st,"get",o=>st.cache.get(o)),I(st,"set",(o,t)=>st.cache.set(o,t)),I(st,"delete",o=>st.cache.delete(o)),I(st,"destroy",()=>{st.cache=new WeakMap}),I(st,"generateElementShape",(o,t)=>{let r=t?.isExporting?void 0:st.get(o);if(r!==void 0)return r;V2.delete(o);let n=sD(o,st.rg,t||{isExporting:!1,canvasBackgroundColor:nD.white,embedsValidationStatus:null});return st.cache.set(o,n),n});var Ei=st,aD=e=>[8,8+e],q2=e=>[1.5,6+e];function lD(e){let o=e.roughness,t=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&t>=50||r>=15&&e.roundness&&K2(e.type)||hr(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Oo=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?aD(e.strokeWidth):e.strokeStyle==="dotted"?q2(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:lD(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<oD.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=Va(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"line":case"freedraw":return Oc(e.points)&&(t.fillStyle=e.fillStyle,t.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),t;case"arrow":return t;default:throw new Error(`Unimplemented type ${e.type}`)}},$2=(e,o,t)=>uh(e)&&(o||k2(e)&&t?.get(e.id)!==!0)&&Va(e.backgroundColor)&&Va(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:M2(e)?{...e,strokeColor:Va(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Va(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,j2=(e,o,t,r,n,i,a)=>{let l=vh(e,o,t,r);if(l===null)return[];let s=(m,c)=>{if(m===null)return[];let[,,d,p,u,f]=m;return[n.line(d,p,u,f,c)]};switch(r){case"dot":case"circle":case"circle_outline":{let[m,c,d]=l;return delete i.strokeLineDash,[n.circle(m,c,d,{...i,fill:r==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[m,c,d,p,u,f]=l;return delete i.strokeLineDash,[n.polygon([[m,c],[d,p],[u,f],[m,c]],{...i,fill:r==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[m,c,d,p,u,f,b,x]=l;return delete i.strokeLineDash,[n.polygon([[m,c],[d,p],[u,f],[b,x],[m,c]],{...i,fill:r==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return s(l,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[m,c,d,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=q2(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(d,p,m,c,i),n.line(u,f,m,c,i),...r==="crowfoot_one_or_many"?s(vh(e,o,t,"crowfoot_one"),i):[]]}}};var sD=(e,o,{isExporting:t,canvasBackgroundColor:r,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=Ga(Math.min(a,l),e);i=o.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,Oo($2(e,t,n),!0))}else i=o.rectangle(0,0,e.width,e.height,Oo($2(e,t,n),!1));return i}case"diamond":{let i,[a,l,s,m,c,d,p,u]=ph(e);if(e.roundness){let f=Ga(Math.abs(a-p),e),b=Ga(Math.abs(m-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${m-b}
6
9
  C ${s} ${m}, ${s} ${m}, ${s-f} ${m+b}
7
10
  L ${c+f} ${d-b}
8
11
  C ${c} ${d}, ${c} ${d}, ${c-f} ${d-b}
9
12
  L ${p+f} ${u+b}
10
13
  C ${p} ${u}, ${p} ${u}, ${p+f} ${u-b}
11
14
  L ${a-f} ${l+b}
12
- C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,Ro(e,!0))}else i=o.polygon([[a,l],[s,m],[c,d],[p,u]],Ro(e));return i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Ro(e));case"line":case"arrow":{let i,a=Ro(e),l=e.points.length?e.points:[j8(0,0)];if(Pa(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(r7(l,16),Ro(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[o.curve(l,a)]:a.fill?i=[o.polygon(l,a)]:i=[o.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:m="arrow"}=e;if(s!==null){let c=E2(e,i,"start",s,o,a,n);i.push(...c)}if(m!==null){let c=E2(e,i,"end",m,o,a,n);i.push(...c)}}return i}case"freedraw":{let i;if(g2(e),Tc(e.points)){let a=$8(e.points,.75);i=o.curve(a,{...Ro(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return J8(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},r7=(e,o)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=Sc(l,i),m=Sc(a,l),c=Math.min(o,b2(e[r],a)/2,b2(e[r],i)/2);s?i[0]<l[0]?t.push([e[r][0]-c,e[r][1]]):t.push([e[r][0]+c,e[r][1]]):i[1]<l[1]?t.push([e[r][0],e[r][1]-c]):t.push([e[r][0],e[r][1]+c]),t.push(e[r]),m?a[0]<l[0]?t.push([e[r][0]-c,e[r][1]]):t.push([e[r][0]+c,e[r][1]]):a[1]<l[1]?t.push([e[r][0],e[r][1]-c]):t.push([e[r][0],e[r][1]+c])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)n.push(`L ${t[r][0]} ${t[r][1]}`),n.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var w2=(e,o,t=!1)=>{let n=!1;for(let r in o){let i=o[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??i7(),updated:a7()}};import{jsx as T2}from"react/jsx-runtime";var hi=B({name:"toggleLinearEditor",category:Se.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&r.length===1&&s7(r[0])&&!l7(r[0]))},perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];ch(r,"No selected element found"),ch(o.selectedLinearElement,"No selected linear element found"),ch(r.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:v2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],r=g(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return T2(K,{type:"button",icon:$0,title:r,"aria-label":r,onClick:()=>o(null)})}}),bfe=B({name:"togglePolygon",category:Se.elements,icon:lm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!ui(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return r.length>0&&r.every(i=>ui(i)&&i.points.length>=4)},perform(e,o,t,n){let r=n.scene.getSelectedElements(o);if(r.some(s=>!ui(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=c7(i);return{elements:e.map(s=>!l.has(s.id)||!ui(s)?s:w2(s,{backgroundColor:a?s.backgroundColor:"transparent",...d7(s,a)})),appState:o,captureUpdate:v2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(a=>!ui(a)||!a.polygon||a.points.length<3))return null;let r=n.every(a=>ui(a)&&a.polygon),i=g(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return T2(Sr,{icon:lm,title:i,"aria-label":i,active:r,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as I2,CANVAS_SEARCH_TAB as C2,CLASSES as m7,DEFAULT_SIDEBAR as S2}from"@excalidraw/common";import{CaptureUpdateAction as p7}from"@excalidraw/element";var Ma=B({name:"searchMenu",icon:Mt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,n){if(o.openDialog)return!1;if(o.openSidebar?.name===S2.name&&o.openSidebar.tab===C2){let r=n.excalidrawContainerValue.container?.querySelector(`.${m7.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...o,openSidebar:{name:S2.name,tab:C2},openDialog:null},captureUpdate:p7.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[I2.CTRL_OR_CMD]&&e.key===I2.F});import{isImageElement as u7}from"@excalidraw/element";import{CaptureUpdateAction as h7}from"@excalidraw/element";import{jsx as g7}from"react/jsx-runtime";var dh=B({name:"cropEditor",label:"helpDialog.cropStart",icon:Pm,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:r.id},captureUpdate:h7.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.croppingElementId&&r.length===1&&u7(r[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=g("helpDialog.cropStart");return g7(K,{type:"button",icon:Pm,title:n,"aria-label":n,onClick:()=>o(null)})}});import{getNonDeletedElements as f7}from"@excalidraw/element";import{mutateElement as b7}from"@excalidraw/element";import{newFrameElement as x7}from"@excalidraw/element";import{isFrameLikeElement as Pc}from"@excalidraw/element";import{addElementsToFrame as E7,removeAllElementsFromFrame as y7}from"@excalidraw/element";import{getFrameChildren as w7}from"@excalidraw/element";import{KEYS as k2,updateActiveTool as M2}from"@excalidraw/common";import{getElementsInGroup as v7}from"@excalidraw/element";import{getCommonBounds as T7}from"@excalidraw/element";import{CaptureUpdateAction as jn}from"@excalidraw/element";var L2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Pc(t[0])},P2=B({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;if(Pc(r)){let i=w7(f7(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:jn.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:jn.EVENTUALLY}},predicate:(e,o,t,n)=>L2(o,n)}),A2=B({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;return Pc(r)?{elements:y7(e,r),appState:{...o,selectedElementIds:{[r.id]:!0}},captureUpdate:jn.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:jn.EVENTUALLY}},predicate:(e,o,t,n)=>L2(o,n)}),S1e=B({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:jn.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),k1e=B({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Bn,viewMode:!1,perform:(e,o,t,n)=>{let r=M2(o,{type:"frame"});return Pt(n.interactiveCanvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:M2(o,{type:"frame"})},captureUpdate:jn.EVENTUALLY}},keyTest:e=>!e[k2.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===k2.F}),D2=B({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=j(e,o);return r.length>0&&!r.some(i=>Pc(i))},perform:(e,o,t,n)=>{let r=j(e,o),i=n.scene.getNonDeletedElementsMap(),[a,l,s,m]=T7(r,i),c=16,d=x7({x:a-c,y:l-c,width:s-a+c*2,height:m-l+c*2});if(o.editingGroupId){let u=v7(r,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);b7(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:E7([...n.scene.getElementsIncludingDeleted(),d],r,d,o),appState:{selectedElementIds:{[d.id]:!0}},captureUpdate:jn.IMMEDIATELY}}});import{isWindows as P7,KEYS as Na,matchKey as uh,arrayToMap as _2}from"@excalidraw/common";import{CaptureUpdateAction as ph}from"@excalidraw/element";import{orderByFractionalIndex as A7}from"@excalidraw/element";import{Emitter as I7}from"@excalidraw/common";import{CaptureUpdateAction as C7,StoreChange as S7,StoreDelta as k7}from"@excalidraw/element";var gi=class extends k7{applyTo(o,t,n){let[r,i]=this.elements.applyTo(o,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,r);return[r,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,n,r){return super.applyLatestChanges(o,t,n,r)}},qn=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Ra=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new I7);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof gi)return;let t=gi.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new qn(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(o,t,n,r){try{let i=n();if(i===null)return;let a=C7.IMMEDIATELY,l=this.store.snapshot,s=o,m=t,c=!1;for(;i;){try{[s,m,c]=i.applyTo(s,m,l);let d=l.elements,p=l.maybeClone(a,s,m),u=S7.create(l,p),f=gi.applyLatestChanges(i,d,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{r(i)}if(c)break;i=n()}return[s,m]}finally{this.onHistoryChangedEmitter.trigger(new qn(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let n=gi.inverse(t);return o.push(n)}};import{useEffect as M7,useState as L7}from"react";var mh=(e,o)=>{let[t,n]=L7(o);return M7(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),t};import{jsx as F2}from"react/jsx-runtime";var R2=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=t();if(!n)return{captureUpdate:ph.EVENTUALLY};let[r,i]=n,a=A7(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:ph.NEVER}}return{captureUpdate:ph.EVENTUALLY}},N2=e=>({name:"undo",label:"buttons.undo",icon:um,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>R2(r,t,()=>e.undo(_2(o),t)),keyTest:o=>o[Na.CTRL_OR_CMD]&&uh(o,Na.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:n}=mh(e.onHistoryChangedEmitter,new qn(e.isUndoStackEmpty,e.isRedoStackEmpty));return F2(K,{type:"button",icon:um,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),B2=e=>({name:"redo",label:"buttons.redo",icon:hm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>R2(r,t,()=>e.redo(_2(o),t)),keyTest:o=>o[Na.CTRL_OR_CMD]&&o.shiftKey&&uh(o,Na.Z)||P7&&o.ctrlKey&&!o.shiftKey&&uh(o,Na.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:n}=mh(e.onHistoryChangedEmitter,new qn(e.isUndoStackEmpty,e.isRedoStackEmpty));return F2(K,{type:"button",icon:hm,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-redo"})}});import{getFontString as D7}from"@excalidraw/common";import{newElementWith as _7}from"@excalidraw/element";import{measureText as R7}from"@excalidraw/element";import{isTextElement as O2}from"@excalidraw/element";import{CaptureUpdateAction as N7}from"@excalidraw/element";var z2=B({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=j(e,o);return r.length===1&&O2(r[0])&&!r[0].autoResize},perform:(e,o,t,n)=>{let r=j(e,o);return{appState:o,elements:e.map(i=>{if(i.id===r[0].id&&O2(i)){let a=R7(i.originalText,D7(i),i.lineHeight);return _7(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:N7.IMMEDIATELY}}});import{CODES as B7,KEYS as F7}from"@excalidraw/common";import{CaptureUpdateAction as O7}from"@excalidraw/element";var hh=B({name:"viewMode",label:"labels.viewMode",icon:vr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:O7.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[F7.CTRL_OR_CMD]&&e.altKey&&e.code===B7.R});import{isPromiseLike as z7}from"@excalidraw/common";import{jsx as H7}from"react/jsx-runtime";var gh=(e,o,t,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,n,i))&&ne(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${r.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Ac=class{constructor(o,t,n,r){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in n)||n[o])){let r=this.actions[o],i=r.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=m=>{gh(r,"ui",l,a,this.app,m),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),m,this.app))};return H7(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!o.predicate||o.predicate(t,n,this.app.props,this.app)});this.updater=i=>{if(z7(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,m)=>(m.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return gh(r,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(n[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();gh(o,t,i,r,this.app,n),this.updater(o.perform(r,i,n,this.app))}};var Dc=class{constructor(){I(this,"targets",new WeakMap);I(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let n=this.targets.get(o);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var fh=e=>{let o=Array.from(e.values());return{x:H2(o,t=>t.x)/o.length,y:H2(o,t=>t.y)/o.length}},bh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),H2=(e,o)=>e.reduce((t,n)=>t+o(n),0);import{pointFrom as H,pointRotateRads as cn,rangeInclusive as Gt,rangeIntersection as _c,rangesOverlap as Rc}from"@excalidraw/math";import{TOOL_TYPE as Jn,KEYS as G2}from"@excalidraw/common";import{getCommonBounds as xh,getDraggedElementsBounds as Eh,getElementAbsoluteCoords as G7}from"@excalidraw/element";import{isBoundToContainer as V2}from"@excalidraw/element";import{getMaximumGroups as X2}from"@excalidraw/element";import{getSelectedElements as U7,getVisibleAndNonSelectedElements as K2}from"@excalidraw/element";var Y7=8,U2=99999,Nc=e=>Y7/e,ut=class ut{};I(ut,"referenceSnapPoints",null),I(ut,"visibleGaps",null),I(ut,"setReferenceSnapPoints",o=>{ut.referenceSnapPoints=o}),I(ut,"getReferenceSnapPoints",()=>ut.referenceSnapPoints),I(ut,"setVisibleGaps",o=>{ut.visibleGaps=o}),I(ut,"getVisibleGaps",()=>ut.visibleGaps),I(ut,"destroy",()=>{ut.referenceSnapPoints=null,ut.visibleGaps=null});var Ut=ut,dn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Bo=({event:e,app:o,selectedElements:t})=>{if(e){let n=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||n)&&(o.state.objectsSnapModeEnabled&&!e[G2.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[G2.CTRL_OR_CMD]&&!dn(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},W7=(e,o,t=.01)=>Math.abs(e-o)<=t,Ba=(e,o,{omitCenter:t,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,m,c,d,p]=G7(a,o);r&&(l+=r.x,m+=r.x,d+=r.x,s+=r.y,c+=r.y,p+=r.y);let u=(m-l)/2,f=(c-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!n){let b=cn(H(l,s+f),H(d,p),a.angle),x=cn(H(l+u,s),H(d,p),a.angle),w=cn(H(m,s+f),H(d,p),a.angle),E=cn(H(l+u,c),H(d,p),a.angle),y=H(d,p);i=t?[b,x,w,E]:[b,x,w,E,y]}else{let b=cn(H(l,s),H(d,p),a.angle),x=cn(H(m,s),H(d,p),a.angle),w=cn(H(l,c),H(d,p),a.angle),E=cn(H(m,c),H(d,p),a.angle),y=H(d,p);i=t?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,m]=Eh(e,r??{x:0,y:0}),c=s-a,d=m-l,p=H(a,l),u=H(s,l),f=H(a,m),b=H(s,m),x=H(a+c/2,l+d/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>H(Me(a[0]),Me(a[1])))},Z2=(e,o,t,n)=>K2(e,o,t,n),$2=(e,o,t,n)=>{let r=Z2(e,o,t,n),i=X2(r,n).filter(d=>!(d.length===1&&V2(d[0]))).map(d=>xh(d).map(p=>Me(p))),a=i.sort((d,p)=>d[0]-p[0]),l=[],s=0;e:for(let d=0;d<a.length;d++){let p=a[d];for(let u=d+1;u<a.length;u++){if(++s>U2)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&Rc(Gt(b,w),Gt(y,v))&&l.push({startBounds:p,endBounds:f,startSide:[H(x,b),H(x,w)],endSide:[H(E,y),H(E,v)],length:E-x,overlap:_c(Gt(b,w),Gt(y,v))})}}let m=i.sort((d,p)=>d[1]-p[1]),c=[];s=0;e:for(let d=0;d<m.length;d++){let p=m[d];for(let u=d+1;u<m.length;u++){if(++s>U2)break e;let f=m[u],[b,,x,w]=p,[E,y,v]=f;w<y&&Rc(Gt(b,x),Gt(E,v))&&c.push({startBounds:p,endBounds:f,startSide:[H(b,w),H(x,w)],endSide:[H(E,y),H(v,y)],length:y-w,overlap:_c(Gt(b,x),Gt(E,v))})}}return{horizontalGaps:l,verticalGaps:c}},Y2=(e,o,t,n,r,i,a)=>{if(!Bo({app:t,event:n,selectedElements:e}))return[];if(e.length===0)return[];let l=Ut.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:m}=l,[c,d,p,u]=Eh(e,o).map(x=>Me(x)),f=(c+p)/2,b=(d+u)/2;for(let x of s){if(!Rc(Gt(d,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=Me(w-f);if(x.length>p-c&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(r.length=0),a.x=Math.abs(E);let P={type:"gap",direction:"center_horizontal",gap:x,offset:E};r.push(P);continue}let[,,v]=x.endBounds,C=c-v,S=Me(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(r.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};r.push(P);continue}let[L,,,]=x.startBounds,k=L-p,A=Me(k-x.length);if(Math.abs(A)<=a.x){Math.abs(A)<a.x&&(r.length=0),a.x=Math.abs(A);let P={type:"gap",direction:"side_left",gap:x,offset:A};r.push(P);continue}}for(let x of m){if(!Rc(Gt(c,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=Me(w-b);if(x.length>u-d&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let P={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(P);continue}let[,v,,]=x.startBounds,C=v-u,S=Me(C-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,L]=x.endBounds,k=Me(d-L),A=x.length-k;if(Math.abs(A)<=a.y){Math.abs(A)<a.y&&(i.length=0),a.y=Math.abs(A);let P={type:"gap",direction:"side_bottom",gap:x,offset:A};i.push(P);continue}}}},j2=(e,o,t,n)=>{let r=Z2(e,o,t,n);return X2(r,n).filter(i=>!(i.length===1&&V2(i[0]))).flatMap(i=>Ba(i,n))},fi=(e,o,t,n,r,i,a)=>{if(!Bo({app:t,event:n,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Ut.getReferenceSnapPoints();if(l)for(let s of o)for(let m of l){let c=m[0]-s[0],d=m[1]-s[1];Math.abs(c)<=a.x&&(Math.abs(c)<a.x&&(r.length=0),r.push({type:"point",points:[s,m],offset:c}),a.x=Math.abs(c)),Math.abs(d)<=a.y&&(Math.abs(d)<a.y&&(i.length=0),i.push({type:"point",points:[s,m],offset:d}),a.y=Math.abs(d))}},q2=(e,o,t,n,r)=>{let i=t.state,a=U7(e,i);if(!Bo({app:t,event:n,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Me(o.x),o.y=Me(o.y);let l=[],s=[],m=Nc(i.zoom.value),c={x:m,y:m},d=Ba(a,r,{dragOffset:o});fi(a,d,t,n,l,s,c),Y2(a,o,t,n,l,s,c);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};c.x=0,c.y=0,l.length=0,s.length=0;let u={x:Me(o.x+p.x),y:Me(o.y+p.y)};fi(a,Ba(a,r,{dragOffset:u}),t,n,l,s,c),Y2(a,u,t,n,l,s,c);let f=yh(l,s),b=X7(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Me=e=>Math.round(e*10**6)/10**6,W2=e=>{let o=new Map;for(let t of e){let n=t.join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},yh=(e,o)=>{let t={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Me(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>H(Me(a[0]),Me(a[1]))))}}if(o.length>0){for(let r of o)if(r.type==="point"){let i=Me(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(a=>H(Me(a[0]),Me(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:W2(i.map(a=>H(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:W2(i.map(a=>H(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},V7=e=>{let o=new Map;for(let t of e){let n=t.points.flat().map(r=>[Me(r)]).join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},X7=(e,o,t)=>{let[n,r,i,a]=Eh(e,o),l=[];for(let s of t){let[m,c,d,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=_c(Gt(r,a),s.gap.overlap),E=_c(Gt(n,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(s.gap.startSide[0][0],y),H(n,y)]},{type:"gap",direction:"horizontal",points:[H(i,y),H(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,s.gap.startSide[0][1]),H(y,r)]},{type:"gap",direction:"vertical",points:[H(y,a),H(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(d,y),H(u,y)]},{type:"gap",direction:"horizontal",points:[H(b,y),H(n,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(i,y),H(m,y)]},{type:"gap",direction:"horizontal",points:[H(d,y),H(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,a),H(y,c)]},{type:"gap",direction:"vertical",points:[H(y,p),H(y,f)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,p),H(y,f)]},{type:"gap",direction:"vertical",points:[H(y,x),H(y,r)]})}break}}}return V7(l.map(s=>({...s,points:s.points.map(m=>H(Me(m[0]),Me(m[1])))})))},wh=(e,o,t,n,r,i)=>{if(!Bo({event:n,selectedElements:e,app:t})||e.length===0||e.length===1&&!W7(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,m]=xh(o);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(m+=r.y));let c=[];if(i)switch(i){case"e":{c.push(H(s,l),H(s,m));break}case"w":{c.push(H(a,l),H(a,m));break}case"n":{c.push(H(a,l),H(s,l));break}case"s":{c.push(H(a,m),H(s,m));break}case"ne":{c.push(H(s,l));break}case"nw":{c.push(H(a,l));break}case"se":{c.push(H(s,m));break}case"sw":{c.push(H(a,m));break}}let d=Nc(t.state.zoom.value),p={x:d,y:d},u=[],f=[];fi(o,c,t,n,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,w,E,y]=xh(e).map(S=>Me(S)),v=[H(x,w),H(x,y),H(E,w),H(E,y)];fi(e,v,t,n,u,f,p);let C=yh(u,f);return{snapOffset:b,snapLines:C}},J2=(e,o,t,n,r,i)=>{if(!Bo({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[H(n.x+r.x,n.y+r.y)],l=Nc(o.state.zoom.value),s={x:l,y:l},m=[],c=[];fi([e],a,o,t,m,c,s);let d={x:m[0]?.offset??0,y:c[0]?.offset??0};s.x=0,s.y=0,m.length=0,c.length=0;let p=Ba([e],i,{boundingBoxCorners:!0,omitCenter:!0});fi([e],p,o,t,m,c,s);let u=yh(m,c);return{snapOffset:d,snapLines:u}},Q2=(e,o,t,n,r)=>{if(!Bo({event:n,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=K2(e,[],o.state,r),a=Nc(o.state.zoom.value),l={x:a,y:a},s=[],m=[];for(let c of i){let d=Ba([c],r);for(let p of d){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(m.length=0),m.push({type:"pointer",points:[p,H(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,H(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:m.length>0?m[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...m,...s]}},ew=e=>e===Jn.rectangle||e===Jn.ellipse||e===Jn.diamond||e===Jn.frame||e===Jn.magicframe||e===Jn.image||e===Jn.text;import{pointFrom as Bc}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as K7,DEFAULT_FONT_SIZE as Z7,TEXT_ALIGN as $7,VERTICAL_ALIGN as j7,getSizeFromPoints as q7,randomId as J7,arrayToMap as Q7,assertNever as vh,cloneJSON as nw,getFontString as eD,isDevEnv as tD,toBrandedType as oD,getLineHeight as nD}from"@excalidraw/common";import{bindLinearElement as tw}from"@excalidraw/element";import{newArrowElement as rD,newElement as Th,newFrameElement as iD,newImageElement as aD,newLinearElement as lD,newMagicFrameElement as sD,newTextElement as Oc}from"@excalidraw/element";import{measureText as cD,normalizeText as dD}from"@excalidraw/element";import{isArrowElement as mD}from"@excalidraw/element";import{syncInvalidIndices as pD}from"@excalidraw/element";import{redrawTextBoundingBox as uD}from"@excalidraw/element";import{LinearElementEditor as hD}from"@excalidraw/element";import{getCommonBounds as gD}from"@excalidraw/element";import{Scene as fD}from"@excalidraw/element";var Fc={width:100,height:0},mn=100,bD=(e,o,t)=>{let n=Oc({x:0,y:0,textAlign:$7.CENTER,verticalAlign:j7.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:n.id})}),uD(n,e,t),[e,n]},ow=(e,o,t,n,r)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let c=o?.width??mn,d=o?.height??mn,p;o.id&&(p=n.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-c,f=o.y||e.y-d/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Oc({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=Th({x:u,y:f,width:c,height:d,...p,...o,type:b});break}default:vh(e,`Unhandled element start type "${o.type}"`,!0)}tw(e,i,"start",r)}}if(t){let c=t?.height??mn,d=t?.width??mn,p;t.id&&(p=n.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-c/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Oc({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=Th({x:u,y:f,width:d,height:c,...p,...t,type:b});break}default:vh(e,`Unhandled element end type "${b}"`,!0)}tw(e,a,"end",r)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,m=nw(e.points);return e.points[l][0]>e.points[l-1][0]&&(m[0][0]=s,m[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(m[0][0]=-s,m[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(m[0][1]=s,m[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(m[0][1]=-s,m[l][1]+=s),Object.assign(e,hD.getNormalizeElementPointsAndCoords({...e,points:m})),{linearElement:e,startBoundElement:i,endBoundElement:a}},Ih=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>pD(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>oD(Q7(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},bi=(e,o)=>{if(!e)return[];let t=nw(e),n=new Ih,r=new Map,i=new Map;for(let s of t){let m,c=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:J7()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||mn,u=s?.label?.text&&s.height===void 0?0:s?.height||mn;m=Th({...s,width:p,height:u});break}case"line":{let p=s.width||Fc.width,u=s.height||Fc.height;m=lD({width:p,height:u,points:[Bc(0,0),Bc(p,u)],...s});break}case"arrow":{let p=s.width||Fc.width,u=s.height||Fc.height;m=rD({width:p,height:u,endArrowhead:"arrow",points:[Bc(0,0),Bc(p,u)],...s,type:"arrow"}),Object.assign(m,q7(m.points));break}case"text":{let p=s?.fontFamily||K7,u=s?.fontSize||Z7,f=s?.lineHeight||nD(p),b=s.text??"",x=dD(b),w=cD(x,eD({fontFamily:p,fontSize:u}),f);m=Oc({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{m=aD({width:s?.width||mn,height:s?.height||mn,...s});break}case"frame":{m=iD({x:0,y:0,...s});break}case"magicframe":{m=sD({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{m=s;break}default:m=s,vh(s,`Unhandled element type "${s.type}"`,!0)}n.getElement(m.id)?console.error(`Duplicate id found for ${m.id}`):(n.add(m),r.set(m.id,s),c&&i.set(c,m.id))}let a=n.getElementsMap(),l=new fD(a);for(let[s,m]of r){let c=n.getElement(s);switch(m.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(m.label?.text){let[d,p]=bD(c,m?.label,l);if(n.add(d),n.add(p),mD(d)){let u=m.type==="arrow"?m?.start:void 0,f=m.type==="arrow"?m?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(f&&f.id){let E=i.get(f.id);E&&Object.assign(f,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:w}=ow(d,u,f,n,l);d=b,n.add(b),n.add(x),n.add(w)}}else switch(m.type){case"arrow":{let{start:d,end:p}=m;if(d&&d.id){let x=i.get(d.id);Object.assign(d,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=ow(c,d,p,n,l);n.add(u),n.add(f),n.add(b);break}}break}}}for(let[s,m]of r){if(m.type!=="frame"&&m.type!=="magicframe")continue;let c=n.getElement(s);if(!c)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let d=[];m.children.forEach(C=>{let S=i.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);let L=n.getElement(S);if(!L)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(L,{frameId:c.id}),L?.boundElements?.forEach(k=>{let A=n.getElement(k.id);if(!A)throw new Error(`Bound element with id ${k.id} doesn't exist`);Object.assign(A,{frameId:c.id}),d.push(A)}),d.push(L)});let[p,u,f,b]=gD(d),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let w=c?.x||p,E=c?.y||u,y=c?.width||f-p,v=c?.height||b-u;Object.assign(c,{x:w,y:E,width:y,height:v}),tD()&&m.children.length&&(c?.x||c?.y||c?.width||c?.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 n.getElements()};import{isElementInViewport as KD}from"@excalidraw/element";import{memoize as ZD,toBrandedType as $D}from"@excalidraw/common";import{pointFrom as CD,pointsEqual as SD}from"@excalidraw/math";import Hc from"open-color";import{arrayToMap as kD,DEFAULT_TRANSFORM_HANDLE_SPACING as Dh,FRAME_STYLE as dw,invariant as mw,THEME as MD,throttleRAF as LD}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as Sh,maxBindingGap as bw}from"@excalidraw/element";import{LinearElementEditor as pn}from"@excalidraw/element";import{getOmitSidesForDevice as kh,getTransformHandles as PD,getTransformHandlesFromCoords as AD,shouldShowBoundingBox as DD}from"@excalidraw/element";import{isElbowArrow as Fa,isFrameLikeElement as pw,isImageElement as uw,isLinearElement as _D,isLineElement as RD,isTextElement as hw}from"@excalidraw/element";import{renderSelectionElement as ND}from"@excalidraw/element";import{getElementsInGroup as Ph,getSelectedGroupIds as BD,isSelectedViaGroup as FD,selectGroupsFromGivenElements as OD}from"@excalidraw/element";import{getCommonBounds as Ah,getElementAbsoluteCoords as Oa}from"@excalidraw/element";import{pointFrom as st}from"@excalidraw/math";import{THEME as xD}from"@excalidraw/common";var ED="#ff6b6b",yD="#ff0000",rw=1,iw=2,aw=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===xD.LIGHT||o.zenModeEnabled?ED:yD,n=(o.zenModeEnabled?rw*1.5:rw)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let r of o.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=t,vD(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,TD(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,wD(r,e,o));e.restore()},wD=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];Yt(n,r,o)}for(let n of e.points)lw(n,t,o)},vD=(e,o,t)=>{lw(e.points[0],t,o),t.zenModeEnabled||Yt(e.points[0],e.points[1],o)},lw=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?iw*1.5:iw)/t.zoom.value;n.beginPath(),n.moveTo(e-r,o-r),n.lineTo(e+r,o+r),n.moveTo(e+r,o-r),n.lineTo(e-r,o+r),n.stroke(),n.restore()},Yt=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},TD=(e,o,t,n,r)=>{let i=8/n.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];n.zenModeEnabled||Yt(st(e[0],e[1]-i),st(e[0],e[1]+i),r),Yt(st(s[0]-l,s[1]-a),st(s[0]-l,s[1]+a),r),Yt(st(s[0]+l,s[1]-a),st(s[0]+l,s[1]+a),r),n.zenModeEnabled||(Yt(st(o[0],o[1]-i),st(o[0],o[1]+i),r),Yt(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||Yt(st(e[0]-i,e[1]),st(e[0]+i,e[1]),r),Yt(st(s[0]-a,s[1]-l),st(s[0]+a,s[1]-l),r),Yt(st(s[0]-a,s[1]+l),st(s[0]+a,s[1]+l),r),n.zenModeEnabled||(Yt(st(o[0]-i,o[1]),st(o[0]+i,o[1]),r),Yt(e,o,r))}};import{getGlobalCSSVariable as zc}from"@excalidraw/common";import{getCommonBounds as ID}from"@excalidraw/element";var oo=4,Tt=6,sw="rgba(0,0,0,0.3)",cw=(e,o,t,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=ID(e),s=o/n.zoom.value,m=t/n.zoom.value,c={top:parseInt(zc("sat"))||0,bottom:parseInt(zc("sab"))||0,left:parseInt(zc("sal"))||0,right:parseInt(zc("sar"))||0},d=Io().rtl,p=-n.scrollX+c.left,u=-n.scrollY+c.top,f=p+s-c.right,b=u+m-c.bottom,x=Math.min(r,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-r,C=l-i,S=E-x,L=y-w,k=Math.max(oo*2,c.left+c.right)+Tt*2,A=o*(s/S)-k,P=Math.max(oo*2,c.top+c.bottom)+Tt*2,N=t*(m/L)-P,O=S>v?S*n.zoom.value/(A+k):o/(A+k),U=L>C?L*n.zoom.value/(N+P):t/(N+P);return{horizontal:p===x&&f===E?null:{x:Math.max(c.left,oo)+Tt+(p-x)/S*o,y:t-Tt-Math.max(oo,c.bottom),width:A,height:Tt,deltaMultiplier:O},vertical:u===w&&b===y?null:{x:d?Math.max(c.left,oo):o-Tt-Math.max(c.right,oo),y:Math.max(c.top,oo)+Tt+(u-w)/L*t,width:Tt,height:N,deltaMultiplier:U}}},Ch=(e,o,t)=>{let[n,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:n||r,isOverHorizontal:n,isOverVertical:r}};var zD=(e,o)=>{mw(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;mw(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),xw(t,e,o),e.restore()},HD=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r))return;let i=pn.getElement(n,t);if(!i)return;let a=pn.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),xw(a,e,o),e.restore()},xw=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Fi(o,e[0],e[1],pn.POINT_HANDLE_SIZE/t.zoom.value,!1)},Mh=(e,o,t,n,r,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Fi(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},GD=(e,o,t,n)=>{let r=bw(o,o.width,o.height,n);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":Wf(e,o,t,r);break;case"diamond":Xf(e,r,o,t);break;case"ellipse":{let[i,a,l,s]=Oa(o,t),m=l-i,c=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=r-Sh,Vf(e,m+r+Sh,c+r+Sh,i+m/2,a+c/2,o.angle);break}}},UD=(e,o,t,n)=>{let[r,i,a]=o,l=bw(a,a.width,a.height,n);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(m=>{let[c,d]=pn.getPointAtIndexGlobalCoordinates(r,m,t);Fi(e,c,d,l,!0)})},Ew=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:m,cy:c,dashed:d,activeEmbeddable:p}=t,u=a-r,f=l-i,x=(t.padding??Dh*2)/o.zoom.value,w=8/o.zoom.value,E=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],d&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*v,Oi(e,r-x,i-x,u+x*2,f+x*2,m,c,n);e.restore()},YD=(e,o,t,n)=>{let r=Array.isArray(t)?UD:GD;e.save(),e.translate(o.scrollX,o.scrollY),r(e,t,n,o.zoom),e.restore()},WD=(e,o,t,n)=>{let[r,i,a,l]=Oa(t,n),s=a-r,m=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=dw.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Oi(e,r,i,s,m,r+s/2,i+m/2,t.angle,!1,dw.radius/o.zoom.value),e.restore()},gw=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=t.filter(c=>c.groupIds.length===0),l=t.filter(c=>c.groupIds.length>0),s=c=>{let[d,p,u,f]=Ah(c);return{angle:0,x1:d,x2:u,y1:p,y2:f,selectionColors:r,dashed:i,cx:d+(u-d)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},m=c=>{let d=Ph(t,c);return s(d)};Object.entries(OD(l,o)).filter(([c,d])=>d).map(([c,d])=>c).map(c=>m(c)).concat(a.map(c=>s([c]))).forEach(c=>Ew(e,o,c))},Lh=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=pn.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=pn,a=o.selectedLinearElement?.isEditing?i:i/2,l=Fa(t),s=RD(t);if(r.forEach((m,c)=>{if(l&&c!==0&&c!==r.length-1)return;let d=c>0&&(c!==r.length-1||!s||!t.polygon)&&SD(m,c===r.length-1?r[0]:r[c-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(c);s&&t.polygon&&!p&&c===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Mh(e,o,m,a,p,!1,d)}),Fa(t)){let m=t.fixedSegments?.map(c=>c.index)||[];r.slice(0,-1).forEach((c,d)=>{pn.isSegmentTooShort(t,r[d+1],r[d],d,o.zoom)||Mh(e,o,CD((c[0]+r[d+1][0])/2,(c[1]+r[d+1][1])/2),i/2,!1,!m.includes(d+1),!1)})}else pn.getEditorMidPoints(t,n,o).filter((c,d,p)=>c!==null&&!(Fa(t)&&(d===0||d===p.length-1))).forEach(c=>{(o.selectedLinearElement?.isEditing||r.length===2)&&Mh(e,o,c,i/2,!1,!0,!1)});e.restore()},fw=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,m,c]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Fi(e,l+m/2,s+c/2,m/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,m,c,2/t.zoom.value),e.fill(),e.stroke()):Oi(e,l,s,m,c,l+m/2,s+c/2,r,!0),e.restore()}})},VD=(e,o,t,n,r)=>{let[i,a,,,l,s]=Oa(n,r),m=3,c=20,d=m/t.zoom.value,p=d/2,u=l-i+d,f=s-a+d,b=Math.min(c/t.zoom.value,u),x=Math.min(c/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(E=>{let[[y,v],[C,S],[L,k],[A,P],[N,O]]=E;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+L,v+k),e.stroke(),e.beginPath(),e.moveTo(y+A,v+P),e.lineTo(y+N,v+O),e.stroke(),e.restore()}),e.restore()},XD=(e,o,t,n)=>{o.save();let r=Dh*2/t.zoom.value,i=e.width+r*2,a=e.height+r*2,l=e.x+i/2,s=e.y+a/2,m=-(i/2+r),c=-(a/2+r);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.strokeRect(m,c,i,a),o.restore()},yw=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:n,allElementsMap:r,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[m,c]=yl(e,i),d=wl({canvas:e,scale:i,normalizedWidth:m,normalizedHeight:c});d.save(),d.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===b.id&&b&&(p=b)}),p&&Lh(d,a,p,o),a.selectionElement&&!a.isCropping)try{ND(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&hw(a.editingTextElement)){let b=r.get(a.editingTextElement.id);b&&!b.autoResize&&XD(b,d,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{YD(d,a,b,o)}),a.frameToHighlight&&WD(d,a,a.frameToHighlight,o),a.elementsToHighlight&&gw(d,a,a.elementsToHighlight),a.activeLockedId){let b=r.get(a.activeLockedId),x=b?[b]:Ph(r,a.activeLockedId);gw(d,a,x,{colors:["#ced4da"],dashed:!0})}let u=n.some(b=>pw(b));if(n.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===n[0].id&&Lh(d,a,n[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=n.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?zD(d,a):(Fa(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&HD(d,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=DD(n,a),x=n.length===1&&_D(n[0]);x&&a.selectedLinearElement?.elementId===n[0].id&&!n[0].locked&&Lh(d,a,n[0],o);let w=l.selectionColor||Hc.black;if(b){let E=kD(n),y=[];for(let C of o.values()){let S=[],L=l.remoteSelectedElementIds.get(C.id);if(x&&Fa(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!FD(a,C)&&S.push(w),L&&S.push(...L.map(k=>Vn(k,a.collaborators.get(k))))),S.length){let[k,A,P,N,O,U]=Oa(C,o,!0);y.push({angle:C.angle,x1:k,y1:A,x2:P,y2:N,selectionColors:C.locked?["#ced4da"]:S,dashed:!!L||C.locked,cx:O,cy:U,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||uw(C)?0:void 0})}}let v=C=>{let S=Ph(o,C),[L,k,A,P]=Ah(S);y.push({angle:0,x1:L,x2:A,y1:k,y2:P,selectionColors:S.some(N=>N.locked)?["#ced4da"]:[Hc.black],dashed:!0,cx:L+(A-L)/2,cy:k+(P-k)/2,activeEmbeddable:!1})};for(let C of BD(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>Ew(d,a,C))}if(d.save(),d.translate(a.scrollX,a.scrollY),n.length===1){d.fillStyle=Hc.white;let E=PD(n[0],a.zoom,o,"mouse",kh(s));if(!a.viewModeEnabled&&b&&!hw(a.editingTextElement)&&!a.croppingElementId&&fw(d,l,a,E,n[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&uw(y)&&VD(d,l,a,y,o)}}else if(n.length>1&&!a.isRotating&&!n.some(E=>E.locked)){let E=Dh*2/a.zoom.value;d.fillStyle=Hc.white;let[y,v,C,S]=Ah(n,o),L=d.getLineDash();d.setLineDash([2/a.zoom.value]);let k=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=w,Oi(d,y-E,v-E,C-y+E*2,S-v+E*2,(y+C)/2,(v+S)/2,0),d.lineWidth=k,d.setLineDash(L);let A=AD([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...kh(s),rotation:!0}:kh(s));n.some(P=>!P.locked)&&fw(d,l,a,A,0)}d.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=o.get(b);if(E){let[y,v,,,C,S]=Oa(E,o,!0);d.save(),a.theme===MD.LIGHT?x?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":x?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)";let L=pw(E)?a.zoom.value:1;d.translate(a.scrollX,a.scrollY),d.translate(C,S),d.rotate(E.angle),w.forEach(k=>{(k.showOnCanvas||x)&&d.fillRect(y+k.offsetX/L-C,v+k.offsetY/L-S,k.width/L,k.height/L)}),d.restore()}}),aw(d,a),d.restore(),Nx({context:d,renderConfig:l,appState:a,normalizedWidth:m,normalizedHeight:c});let f;return l.renderScrollbars&&(f=cw(o,m,c,a),d.save(),d.fillStyle=sw,d.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&Fs(d,b.x,b.y,b.width,b.height,Tt/2)}),d.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},_h=LD(e=>{let o=yw(e);e.callback?.(o)},{trailing:!0}),ww=(e,o)=>{if(o){_h(e);return}let t=yw(e);return e.callback(t),t};var za=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:m,width:c})=>{let d=[];for(let p of n.values())KD(p,c,m,{zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},n)&&d.push(p);return d},t=({elements:n,editingTextElement:r,newElementId:i})=>{let a=$D(new Map);for(let l of n)i!==l.id&&(!r||r.type!=="text"||l.id!==r.id)&&a.set(l.id,l);return a};return ZD(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m,editingTextElement:c,newElementId:d,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:c,newElementId:d}),b=o({elementsMap:f,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){_h.cancel(),Zf.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as jD}from"@excalidraw/common";import{getElementAbsoluteCoords as qD}from"@excalidraw/element";import{jsx as e_}from"react/jsx-runtime";var JD=5,QD=(e,o,t)=>{let[n,r]=qD(e,t),{x:i,y:a}=jD({sceneX:n+e.width,sceneY:r},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},Rh=({children:e,element:o,elementsMap:t})=>{let n=mo();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=QD(o,n,t);return e_("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:JD},children:e})};import{DEFAULT_LASER_COLOR as r_,easeOut as Tw}from"@excalidraw/common";import{LaserPointer as t_}from"@excalidraw/laser-pointer";import{SVG_NS as vw,getSvgPathFromStroke as o_,sceneCoordsToViewportCoords as n_}from"@excalidraw/common";var Fo=class{constructor(o,t,n){this.animationFrameHandler=o;this.app=t;this.options=n;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(vw,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(vw,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===o&&this.currentTrail.originalPoints[n-1][1]===t}return!1}start(o){o&&(this.container=o),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(o,t){this.currentTrail=new t_(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,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())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let n of this.pastTrails)o.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);o.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let n=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=n_({sceneX:i,sceneY:a},t);return[l.x,l.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return o_(r,!0)}};var Gc=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Fo(o,t,{...this.getTrailOptions(),fill:()=>r_})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let r=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Tw(i),Tw(r))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(o)?n=this.collabTrails.get(o):(n=new Fo(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||Vn(o,t)}),n.start(this.container),this.collabTrails.set(o,n)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as i_}from"react";import{unstable_batchedUpdates as Iw}from"react-dom";import{throttleRAF as a_}from"@excalidraw/common";var Le=e=>o=>{Iw(e,o)},Uc=e=>a_(o=>{Iw(e,o)}),xi=(()=>{let e;try{let t=i_.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Nh,KEYS as Ha,CLASSES as Cw,POINTER_BUTTON as l_,isWritableElement as s_,getFontString as Sw,getFontFamilyString as kw,isTestEnv as Mw}from"@excalidraw/common";import{originalContainerCache as c_,updateOriginalContainerCache as Lw}from"@excalidraw/element";import{LinearElementEditor as d_}from"@excalidraw/element";import{bumpVersion as m_}from"@excalidraw/element";import{getBoundTextElementId as p_,getContainerElement as Bh,getTextElementAngle as u_,redrawTextBoundingBox as h_,getBoundTextMaxHeight as g_,getBoundTextMaxWidth as Pw,computeContainerDimensionForBoundText as Aw,computeBoundTextPosition as f_,getBoundTextElement as b_}from"@excalidraw/element";import{getTextWidth as x_}from"@excalidraw/element";import{normalizeText as Dw}from"@excalidraw/element";import{wrapText as E_}from"@excalidraw/element";import{isArrowElement as Yc,isBoundToContainer as y_,isTextElement as _w}from"@excalidraw/element";var w_=(e,o,t,n,r,i)=>{let{zoom:a}=n,l=180*t/Math.PI,s=e*(a.value-1)/2,m=o*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),o>i&&a.value!==1&&(m=i*(a.value-1)/2),`translate(${s}px, ${m}px) scale(${a.value}) rotate(${l}deg)`},Rw=({id:e,onChange:o,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let m=(_,R)=>{if(!R.style.fontFamily||!R.style.fontSize)return!1;let V=R.style.fontFamily.replace(/"/g,"");return kw({fontFamily:_.fontFamily})!==V||`${_.fontSize}px`!==R.style.fontSize},c=()=>{let _=l.state,R=l.scene.getElement(e);if(!R)return;let{textAlign:V,verticalAlign:Z}=R,W=l.scene.getNonDeletedElementsMap();if(R&&_w(R)){let se=R.x,he=R.y,de=Bh(R,l.scene.getNonDeletedElementsMap()),rt=R.width,ao=R.height,ir=R.width,ar=R.height;if(de&&R.containerId){if(Yc(de)){let Yo=d_.getBoundTextElementPosition(de,R,W);se=Yo.x,he=Yo.y}let gl=m(R,d),Ni;if(gl?Ni=Lw(de.id,de.height):(Ni=c_[de.id],Ni||(Ni=Lw(de.id,de.height))),ir=Pw(de,R),ar=g_(de,R),!Yc(de)&&ao>ar){let Yo=Aw(ao,de.type);l.scene.mutateElement(de,{height:Yo});return}else if(!Yc(de)&&de.height>Ni.height&&ao<ar){let Yo=Aw(ao,de.type);l.scene.mutateElement(de,{height:Yo})}else{let{x:Yo,y:wI}=f_(de,R,W);se=Yo,he=wI}}let[hl,Vd]=n(se,he),EI=d.selectionStart,Xd=d.selectionEnd,Df=d.value.length;if(EI===Xd&&Xd!==Df){let gl=Df-Xd;d.selectionStart=d.value.length-gl,d.selectionEnd=d.value.length-gl}de?rt+=.5:(ir=(_.width-8-hl)/_.zoom.value,rt=Math.min(rt,ir)),ao*=1.05;let yI=Sw(R),_f=(_.height-Vd)/_.zoom.value;Object.assign(d.style,{font:yI,lineHeight:R.lineHeight,width:`${rt}px`,height:`${ao}px`,left:`${hl}px`,top:`${Vd}px`,transform:w_(rt,ao,u_(R,de),_,ir,_f),textAlign:V,verticalAlign:Z,color:R.strokeColor,opacity:R.opacity/100,filter:"var(--theme-filter)",maxHeight:`${_f}px`}),d.scrollTop=0,Mw()&&(d.style.fontFamily=kw(R)),l.scene.mutateElement(R,{x:se,y:he})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(y_(r)||!r.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=r.originalText,c(),o&&(d.onpaste=async _=>{let R=await Ml(_,!0);if(!R.text)return;let V=Dw(R.text);if(!V)return;let Z=Bh(r,l.scene.getNonDeletedElementsMap()),W=Sw({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Z){let se=b_(Z,l.scene.getNonDeletedElementsMap()),he=E_(`${d.value}${V}`,W,Pw(Z,se)),de=x_(he,W);d.style.width=`${de}px`}},d.oninput=()=>{let _=Dw(d.value);if(d.value!==_){let R=d.selectionStart;d.value=_,d.selectionStart=R,d.selectionEnd=R}o(d.value)}),d.onkeydown=_=>{if(!_.shiftKey&&Ss.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Ss),c();else if(!_.shiftKey&&ks.keyTest(_))_.preventDefault(),l.actionManager.executeAction(ks),c();else if(!_.shiftKey&&Ms.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Ms),c();else if(fp.keyTest(_))l.actionManager.executeAction(fp);else if(bp.keyTest(_))l.actionManager.executeAction(bp);else if(_.key===Ha.ESCAPE)_.preventDefault(),C=!0,S();else if(Yn.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction(Yn);else if(_.key===Ha.ENTER&&_[Ha.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;C=!0,S()}else if(_.key===Ha.TAB||_[Ha.CTRL_OR_CMD]&&(_.code===Nh.BRACKET_LEFT||_.code===Nh.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===Nh.BRACKET_LEFT?E():w(),d.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),w=()=>{let{selectionStart:_,selectionEnd:R}=d,V=y(),Z=d.value;V.forEach(W=>{let se=Z.slice(0,W),he=Z.slice(W);Z=`${se}${b}${he}`}),d.value=Z,d.selectionStart=_+f,d.selectionEnd=R+f*V.length},E=()=>{let{selectionStart:_,selectionEnd:R}=d,V=y(),Z=[],W=d.value;V.forEach(se=>{let he=W.slice(se,se+f).match(x);if(he){let de=W.slice(0,se),rt=W.slice(se+he[0].length);W=`${de}${rt}`,Z.push(se)}}),d.value=W,Z.length&&(_>Z[Z.length-1]?d.selectionStart=Math.max(_-f,Z[Z.length-1]):d.selectionStart=_,d.selectionEnd=Math.max(d.selectionStart,R-f*Z.length))},y=()=>{let{selectionStart:_,selectionEnd:R,value:V}=d,Z=V.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-Z,V.slice(_,R).split(`
13
- `).reduce((se,he,de,rt)=>se.concat(de?se[de-1]+rt[de-1].length+1:_),[]).reverse()},v=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},C=!1,S=()=>{if(U)return;U=!0,L();let _=l.scene.getElement(r.id);if(!_)return;let R=Bh(_,l.scene.getNonDeletedElementsMap());if(R){if(d.value.trim()){let V=p_(R);!V||V!==r.id?l.scene.mutateElement(R,{boundElements:(R.boundElements||[]).concat({type:"text",id:r.id})}):Yc(R)&&m_(R)}else l.scene.mutateElement(R,{boundElements:R.boundElements?.filter(V=>!_w(V))});h_(_,R,l.scene)}t({viaKeyboard:C,nextOriginalText:d.value})},L=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,J&&J.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",k),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),N(),O(),d.remove()},k=_=>{window.removeEventListener("pointerup",k);let R=_?.target,V=R instanceof HTMLElement&&R.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=S,V||d.focus()})},A=()=>{d.onblur=null,window.addEventListener("pointerup",k),window.addEventListener("blur",S)},P=_=>{let R=_?.target;if(_.button===l_.WHEEL){R instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),A();return}let V=R instanceof HTMLElement&&R.classList.contains("properties-trigger");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&_.target.closest(`.${Cw.SHAPE_ACTIONS_MENU}, .${Cw.ZOOM_ACTIONS}`)&&!s_(_.target)||V?A():_.target instanceof HTMLCanvasElement&&!Mw()&&requestAnimationFrame(()=>{S()})},N=l.scene.onUpdate(()=>{c(),!!document.activeElement?.closest(".properties-content")||d.focus()}),O=l.onScrollChangeEmitter.on(()=>{c()}),U=!1;s&&d.select(),k();let J=null;return i&&"ResizeObserver"in window?(J=new window.ResizeObserver(()=>{c()}),J.observe(i)):window.addEventListener("resize",c),d.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d),S};var Nw=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(n=>`\\s*${n}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as A_}from"@excalidraw/math";import{getElementLineSegments as D_}from"@excalidraw/element";import{LinearElementEditor as __}from"@excalidraw/element";import{isFrameLikeElement as R_,isLinearElement as N_,isTextElement as B_}from"@excalidraw/element";import{getFrameChildren as F_}from"@excalidraw/element";import{selectGroupsForSelectedElements as O_}from"@excalidraw/element";import{getContainerElement as z_}from"@excalidraw/element";import{arrayToMap as H_,easeOut as zw,isShallowEqual as G_}from"@excalidraw/common";import{simplify as v_}from"points-on-curve";import{polygonFromPoints as T_,lineSegment as Bw,polygonIncludesPointNonZero as I_}from"@excalidraw/math";import{computeBoundTextPosition as C_,doBoundsIntersect as S_,getBoundTextElement as k_,getElementBounds as M_,intersectElementWithLineSegment as Fw}from"@excalidraw/element";var Ow=e=>{let{lassoPath:o,elements:t,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=v_(o,l));let m=t.filter(p=>!p.locked);a.clear(),i.clear();let c=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of m){let u=M_(p,n);S_(c,u)&&!i.has(p.id)&&!a.has(p.id)&&(L_(s,p,r)?a.add(p.id):P_(s,p,n)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},L_=(e,o,t)=>{let n=T_(e),r=t.get(o.id);return r?r.some(i=>i.some(a=>I_(a,n))):!1},P_=(e,o,t)=>{let n=e.slice(1).map((i,a)=>Bw(e[a],i)).concat([Bw(e[e.length-1],e[0])]),r=k_(o,t);return n.some(i=>Fw(o,t,i,0,!0).length>0||!!r&&Fw({...r,...C_(o,r,t)},t,i,0,!0).length>0)};var Wc=class extends Fo{constructor(t,n){super(t,n,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),s=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(zw(s),zw(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(n=>{let r=t.reduce((s,m)=>(s[m]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let m=this.app.scene.getNonDeletedElement(s);if(m&&B_(m)){let c=z_(m,this.app.scene.getNonDeletedElementsMap());c&&(r[c.id]=!0,delete r[m.id])}}for(let[s]of Object.entries(r)){let m=this.app.scene.getNonDeletedElement(s);if(m&&R_(m)){let c=F_(this.app.scene.getNonDeletedElementsMap(),m.id);for(let d of c)delete r[d.id]}}let i=O_({editingGroupId:n.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),n,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&N_(this.app.scene.getNonDeletedElement(a[0]))?new __(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,n,r=!1)=>{super.addPointToPath(t,n),this.keepPreviousSelection=r,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>A_(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!G_(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=H_(this.app.visibleElements);for(let i of this.app.visibleElements){let a=D_(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=Ow({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(t,n,r=!1){this.endPath(),super.startPath(t,n),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as U_,easeOut as Hw,THEME as Y_}from"@excalidraw/common";import{computeBoundTextPosition as W_,getBoundTextElement as V_,intersectElementWithLineSegment as Gw,isPointInElement as X_}from"@excalidraw/element";import{lineSegment as K_,pointFrom as Z_}from"@excalidraw/math";import{getElementsInGroup as Uw}from"@excalidraw/element";import{shouldTestInside as $_}from"@excalidraw/element";import{hasBoundTextElement as Yw,isBoundToContainer as Ww}from"@excalidraw/element";import{getBoundTextElementId as Vw}from"@excalidraw/element";var Vc=class extends Fo{constructor(t,n){super(t,n,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/200),s=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(Hw(s),Hw(l))},fill:()=>n.state.theme===Y_.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,n){this.endPath(),super.startPath(t,n),this.elementsToErase.clear()}addPointToPath(t,n,r=!1){return super.addPointToPath(t,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let n=super.getCurrentTrail()?.originalPoints?.map(l=>Z_(l[0],l[1]))||[];if(n.length<2)return[];let r=K_(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=U_(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(Xw(r,l,a)){let m=l.groupIds.at(-1);if(this.groupsToErase.has(m)){let c=Uw(this.app.scene.getNonDeletedElementsMap(),m);for(let d of c)this.elementsToErase.delete(d.id);this.groupsToErase.delete(m)}if(Ww(l)&&this.elementsToErase.delete(l.containerId),Yw(l)){let c=Vw(l);c&&this.elementsToErase.delete(c)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&Xw(r,l,a)){let m=l.groupIds.at(-1);if(!this.groupsToErase.has(m)){let c=Uw(this.app.scene.getNonDeletedElementsMap(),m);for(let d of c)this.elementsToErase.add(d.id);this.groupsToErase.add(m)}if(Yw(l)){let c=Vw(l);c&&this.elementsToErase.add(c)}Ww(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},Xw=(e,o,t)=>{let n=e[1];if($_(o)&&X_(n,o,t))return!0;let r=V_(o,t);return Gw(o,t,e,0,!0).length>0||!!r&&Gw({...r,...W_(o,r,t)},t,e,0,!0).length>0};import{jsx as Wt,jsxs as Kw}from"react/jsx-runtime";var j_=()=>Kw("div",{"data-testid":"brave-measure-text-error",children:[Wt("p",{children:Wt(pt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Wt("span",{style:{fontWeight:600},children:e})})}),Wt("p",{children:Wt(pt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Wt("span",{style:{fontWeight:600},children:e})})}),Wt("p",{children:Wt(pt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Wt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Wt("p",{children:Wt(pt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Wt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>Kw("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Zw=j_;import oR from"clsx";import nR from"react";import{useLayoutEffect as q_,useRef as $w,useEffect as jw}from"react";import{unstable_batchedUpdates as J_}from"react-dom";import{KEYS as Q_,queryFocusableElements as eR}from"@excalidraw/common";import{jsx as tR}from"react/jsx-runtime";var qw=({children:e,left:o,top:t,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let m=$w(null);jw(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===Q_.TAB){let f=eR(d),{activeElement:b}=document,x=f.findIndex(w=>w===b);b===d?(u.shiftKey?f[f.length-1]?.focus():f[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(f[f.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===f.length-1&&!u.shiftKey&&(f[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let c=$w(null);return q_(()=>{if(r&&m.current&&t!=null&&o!=null){let d=m.current,{width:p,height:u}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===o)return;c.current={top:t,left:o},p>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+p-i>l?d.style.left=`${l-p-10}px`:d.style.left=`${o}px`,u>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+u-a>s?d.style.top=`${s-u}px`:d.style.top=`${t}px`}},[t,o,r,l,s,i,a]),jw(()=>{if(n){let d=p=>{m.current?.contains(p.target)||J_(()=>n(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[n]),tR("div",{className:"popover",ref:m,tabIndex:-1,children:e})};import{jsx as Ei,jsxs as rR}from"react/jsx-runtime";var Ue="separator",Jw=nR.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=mo(),a=Jo(),l=o.reduce((s,m)=>(m&&(m===Ue||!m.predicate||m.predicate(a,i,e.app.props,e.app))&&s.push(m),s),[]);return Ei(qw,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Ei("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,m)=>{if(s===Ue)return!l[m-1]||l[m-1]===Ue?null:Ei("hr",{className:"context-menu-item-separator"},m);let c=s.name,d="";return s.label&&(typeof s.label=="function"?d=g(s.label(a,i,e.app)):d=g(s.label)),Ei("li",{"data-testid":c,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:rR("button",{type:"button",className:oR("context-menu-item",{dangerous:c==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Ei("div",{className:"context-menu-item__label",children:d}),Ei("kbd",{className:"context-menu-item__shortcut",children:c?Re(c):""})]})},m)})})})});import{jsx as Fh,jsxs as Qw}from"react/jsx-runtime";var iR=({height:e,width:o,userToFollow:t,onDisconnect:n})=>Fh("div",{className:"follow-mode",style:{width:o,height:e},children:Qw("div",{className:"follow-mode__badge",children:[Qw("div",{className:"follow-mode__badge__label",children:["Following"," ",Fh("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),Fh("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:Bt})]})}),ev=iR;import Ja from"clsx";import IF from"react";import{CLASSES as CF,DEFAULT_SIDEBAR as Ng,TOOL_TYPE as D5,arrayToMap as SF,capitalizeString as kF,isShallowEqual as Ad}from"@excalidraw/common";import{mutateElement as MF}from"@excalidraw/element";import{showSelectedShapeActions as LF}from"@excalidraw/element";import{ShapeCache as PF}from"@excalidraw/element";import aR from"clsx";import{useState as lR,useEffect as sR}from"react";import{THEME as cR}from"@excalidraw/common";import{jsx as Oh,jsxs as dR}from"react/jsx-runtime";var Xc=({delay:e,theme:o})=>{let[t,n]=lR(!!e);return sR(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:dR("div",{className:aR("LoadingMessage",{"LoadingMessage--dark":o===cR.DARK}),children:[Oh("div",{children:Oh(et,{})}),Oh("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import mR from"clsx";import{jsx as ov,jsxs as uR}from"react/jsx-runtime";var pR="medium",tv={CHECKED:fr,UNCHECKED:_n},Kc=e=>uR("label",{className:mR("ToolIcon ToolIcon__lock",`ToolIcon_size_${pR}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[ov("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),ov("div",{className:"ToolIcon__icon",children:e.checked?tv.CHECKED:tv.UNCHECKED})]});import{showSelectedShapeActions as AR}from"@excalidraw/element";import hR from"clsx";import{jsx as gR}from"react/jsx-runtime";var Zc=({children:e,side:o,className:t})=>gR("div",{className:hR("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import fR from"clsx";import{KEYS as nv}from"@excalidraw/common";import{jsx as bR}from"react/jsx-runtime";var $c=e=>bR(K,{className:fR("Shape",{fillable:!1}),type:"radio",icon:Vl,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:nv.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":nv.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as xR,DEFAULT_SIDEBAR as ER}from"@excalidraw/common";import{isFlowchartNodeElement as yR,isImageElement as rv,isLinearElement as iv,isLineElement as wR,isTextBindableContainer as vR,isTextElement as TR}from"@excalidraw/element";import{getShortcutKey as zh}from"@excalidraw/common";import{isNodeInFlowchart as IR}from"@excalidraw/element";import{jsx as av}from"react/jsx-runtime";var CR=({appState:e,isMobile:o,device:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===ER.name&&e.openSidebar.tab===xR&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(ft(e))return g("hints.eraserRevert");if(r.type==="arrow"||r.type==="line")return s?g("hints.linearElementMulti"):r.type==="arrow"?g("hints.arrowTool",{arrowShortcut:zh("A")}):g("hints.linearElement");if(r.type==="freedraw")return g("hints.freeDraw");if(r.type==="text")return g("hints.text");if(r.type==="embeddable")return g("hints.embeddable");let m=n.scene.getSelectedElements(e);if(i&&l==="mouse"&&m.length===1){let c=m[0];return iv(c)&&c.points.length===2?g("hints.lockAngle"):rv(c)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(m.length===1&&TR(m[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(m.length===1&&rv(m[0]))return g("hints.enterCropEditor");if(r.type==="selection"){if(e.selectionElement&&!m.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(dn(n)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!m.length&&!o)return[g("hints.canvasPanning")];if(m.length===1){if(iv(m[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):wR(m[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&vR(m[0]))return yR(m[0])?IR(m[0],n.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},jc=({appState:e,isMobile:o,device:t,app:n})=>{let r=CR({appState:e,isMobile:o,device:t,app:n});if(!r)return null;let i=Array.isArray(r)?r.map(a=>zh(a).replace(/\. ?$/,"")).join(". "):zh(r);return av("div",{className:"HintViewer",children:av("span",{children:i})})};import SR from"clsx";import{jsx as lv,jsxs as MR}from"react/jsx-runtime";var kR="medium",qc=e=>e.penDetected?MR("label",{className:SR("ToolIcon ToolIcon__penMode",`ToolIcon_size_${kR}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[lv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),lv("div",{className:"ToolIcon__icon",children:v1})]}):null;import{Fragment as LR,jsx as sv,jsxs as PR}from"react/jsx-runtime";var un=({heading:e,children:o,...t})=>{let{id:n}=He(),r=sv("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:g(`headings.${e}`)});return sv("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):PR(LR,{children:[r,o]})})};import{Fragment as DR,jsx as ot,jsxs as Oo}from"react/jsx-runtime";var cv=({appState:e,elements:o,actionManager:t,setAppState:n,onLockToggle:r,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:m,device:c,renderWelcomeScreen:d,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=we(),w=()=>Oo(Zc,{side:"top",className:"App-top-bar",children:[d&&ot(f.Out,{}),ot(un,{heading:"shapes",children:y=>ot(je.Col,{gap:4,align:"center",children:Oo(je.Row,{gap:1,className:"App-toolbar-container",children:[Oo(Ve,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,ot(je.Row,{gap:1,children:ot(xc,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Oo("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&ot(x.Out,{}),ot(qc,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),ot(Kc,{checked:e.activeTool.locked,onChange:r,title:g("toolBar.lock"),isMobile:!0}),ot($c,{checked:$t(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),ot(jc,{appState:e,isMobile:!0,device:c,app:u})]}),E=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?ot("div",{className:"App-toolbar-content",children:ot(b.Out,{})}):Oo("div",{className:"App-toolbar-content",children:[ot(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Oo("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Oo(DR,{children:[m(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&w(),ot("div",{className:"App-bottom-bar",style:{marginBottom:Tt+oo*2,marginLeft:Tt+oo*2,marginRight:Tt+oo*2},children:Oo(Ve,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&AR(e,o)?ot(un,{className:"App-mobile-menu",heading:"selectedShapeActions",children:ot(bc,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Oo("footer",{className:"App-toolbar",children:[E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&ot("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(y=>({...Dn(o,y)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import _R from"open-color";import RR,{useLayoutEffect as NR,useRef as BR,useState as FR}from"react";import{jsx as Ga,jsxs as OR}from"react/jsx-runtime";var dv=e=>{let o=BR(null),[t,n]=FR(null);return NR(()=>{if(!e.spreadsheet)return;let r=a1(e.chartType,e.spreadsheet,0,0);n(r);let i,a=o.current;return(async()=>(i=await dr(r,{exportBackground:!1,viewBackgroundColor:_R.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Ga("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Ga("div",{ref:o})})},mv=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:n}=_e(),r=RR.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{n(l),ne("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Ga(Ne,{size:"small",onCloseRequest:r,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:OR("div",{className:"container",children:[Ga(dv,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Ga(dv,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as hn from"@radix-ui/react-popover";import pv from"clsx";import Jc,{useLayoutEffect as zR}from"react";import{supportsResizeObserver as HR,isShallowEqual as GR}from"@excalidraw/common";import{Fragment as XR,jsx as xo,jsxs as Qc}from"react/jsx-runtime";var UR=4,YR=8,WR=({shouldWrap:e,children:o,username:t})=>e?xo(Lt,{label:t||"Unknown user",children:o}):xo(XR,{children:o}),Hh=({actionManager:e,collaborator:o,socketId:t,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:n,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return xo(WR,{username:o.username,shouldWrap:r,children:l},t)},VR=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],ed=Jc.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=Ge(),i=new Map;t.forEach((b,x)=>{let w=b.id||x;i.set(w,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Jc.useState(""),m=a.filter(b=>b.username?.toLowerCase().includes(l)),c=Jc.useRef(null);zR(()=>{if(c.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(c.current.clientWidth),!HR)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(c.current),()=>{x.disconnect()}}},[]);let[d,p]=Jc.useState(UR),f=a.slice(0,d-1).map(b=>Hh({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}));return o?xo("div",{className:pv("UserList UserList_mobile",e),children:a.map(b=>Hh({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}))}):xo("div",{className:"UserList__wrapper",ref:c,children:Qc("div",{className:pv("UserList",e),style:{"--max-avatars":d},children:[f,a.length>d-1&&Qc(hn.Root,{children:[Qc(hn.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),xo(hn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Qc(Ve,{padding:2,children:[a.length>=YR&&xo(hs,{placeholder:g("quickSearch.placeholder"),onChange:s}),xo(gs,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:m.length>0?[xo("div",{className:"hint",children:g("userList.hint.text")}),m.map(b=>Hh({actionManager:r,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===n}))]:[]}),xo(hn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[n,r]of e.collaborators){let i=o.collaborators.get(n);if(!i||n!==t.next().value||!GR(r,i,VR))return!1}return!0});import Gh from"clsx";import{jsx as KR}from"react/jsx-runtime";var uv=e=>KR("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:xr});import{jsx as zo,jsxs as Uh}from"react/jsx-runtime";var hv=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=we();return Uh("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[zo("div",{className:Gh("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:zo(je.Col,{gap:2,children:Uh(un,{heading:"canvasActions",children:[zo(Uy,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&zo(Yy,{renderAction:o.renderAction,className:Gh("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),zo(r.Out,{}),zo("div",{className:Gh("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Uh("div",{style:{position:"relative"},children:[n&&zo(i.Out,{}),zo(uv,{onClick:()=>o.executeAction(Wn)})]})}),zo(Wy,{actionManager:o,showExitZenModeBtn:t})]})},gv=hv;hv.displayName="Footer";import t9 from"clsx";import{useEffect as Sv,useLayoutEffect as kv,useRef as qh,useState as o9,forwardRef as Mv,useImperativeHandle as n9,useCallback as Tv}from"react";import{EVENT as Iv,isDevEnv as r9,KEYS as i9,updateObject as a9}from"@excalidraw/common";import $R from"clsx";import{useContext as jR}from"react";import ZR from"react";var td=ZR.createContext({});import{jsx as Yh,jsxs as fv}from"react/jsx-runtime";var Wh=({children:e,className:o})=>{let t=ce(),n=jR(td),r=!!(t.editor.canFitSidebar&&n.shouldRenderDockButton);return fv("div",{className:$R("sidebar__header",o),"data-testid":"sidebar-header",children:[e,fv("div",{className:"sidebar__header__buttons",children:[r&&Yh(Lt,{label:g("labels.sidebarLock"),children:Yh(_t,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:f1})}),Yh(_t,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":g("buttons.close"),children:Bt})]})]})};Wh.displayName="SidebarHeader";import*as xv from"@radix-ui/react-tabs";import{jsx as bv}from"react/jsx-runtime";var Vh=({children:e,tab:o,onSelect:t,...n})=>bv(xv.Trigger,{value:o,asChild:!0,onSelect:t,children:bv("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});Vh.displayName="SidebarTabTrigger";import*as Ev from"@radix-ui/react-tabs";import{jsx as qR}from"react/jsx-runtime";var Xh=({children:e,...o})=>qR(Ev.List,{className:"sidebar-triggers",...o,children:e});Xh.displayName="SidebarTabTriggers";import JR from"clsx";import{jsx as Kh,jsxs as yv}from"react/jsx-runtime";var Zh=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=le(),m=ge();return yv("label",{title:n,className:"sidebar-trigger__label-element",children:[Kh("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:c=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let d=c.target.checked;s({openSidebar:d?{name:e,tab:o}:null}),i?.(d)},checked:m.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),yv("div",{className:JR("sidebar-trigger",a),style:l,children:[t&&Kh("div",{children:t}),r&&Kh("div",{className:"sidebar-trigger__label",children:r})]})]})};Zh.displayName="SidebarTrigger";import*as wv from"@radix-ui/react-tabs";import{jsx as QR}from"react/jsx-runtime";var $h=({children:e,...o})=>{let t=ge(),n=le();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return QR(wv.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...o,children:e})};$h.displayName="SidebarTabs";import*as vv from"@radix-ui/react-tabs";import{jsx as e9}from"react/jsx-runtime";var jh=({tab:e,children:o,...t})=>e9(vv.Content,{...t,value:e,"data-testid":e,children:o});jh.displayName="SidebarTab";import{jsx as Cv}from"react/jsx-runtime";import{createElement as l9}from"react";var Ua=me(!1),Lv=Mv(({name:e,children:o,onDock:t,docked:n,className:r,...i},a)=>{r9()&&t&&n==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=le(),s=Ko(Ua);kv(()=>(s(!!n),()=>{s(!1)}),[s,n]);let m=qh({});m.current.onCloseRequest=()=>{l({openSidebar:null})},m.current.onDock=u=>t?.(u),m.current=a9(m.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let c=qh(null);n9(a,()=>c.current);let d=ce(),p=Tv(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return kr(c,Tv(u=>{u.target.closest(".sidebar-trigger")||(!n||!d.editor.canFitSidebar)&&p()},[p,n,d.editor.canFitSidebar])),Sv(()=>{let u=f=>{f.key===i9.ESCAPE&&(!n||!d.editor.canFitSidebar)&&p()};return document.addEventListener(Iv.KEYDOWN,u),()=>{document.removeEventListener(Iv.KEYDOWN,u)}},[p,n,d.editor.canFitSidebar]),Cv(Ve,{...i,className:t9("sidebar",{"sidebar--docked":n},r),ref:c,children:Cv(td.Provider,{value:m.current,children:o})})});Lv.displayName="SidebarInner";var Vt=Object.assign(Mv((e,o)=>{let t=ge(),{onStateChange:n}=e,r=qh(t.openSidebar);Sv(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&n?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,n,e.name]);let[i,a]=o9(!1);return kv(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?l9(Lv,{...e,ref:o,key:e.name}):null}),{Header:Wh,TabTriggers:Xh,TabTrigger:Vh,Tabs:$h,Tab:jh,Trigger:Zh});Vt.displayName="Sidebar";import{composeEventHandlers as f9}from"@excalidraw/common";import{useLayoutEffect as s9,useRef as c9}from"react";import{jsx as d9}from"react/jsx-runtime";var Ho=(e,o)=>{let t=me(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=we(),[,a]=i(t),l=c9({preferHost:!1,counter:0});return s9(()=>{let s=l.current;return a(m=>{let c=m+1;return s.counter=c,c}),()=>{a(m=>{let c=m-1;return s.counter=c,c||(s.preferHost=!1),c})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:d9(o,{...r})};return n.displayName=e,n};var eg={};Nf(eg,{ChangeCanvasBackground:()=>Yv,ClearCanvas:()=>Gv,CommandPalette:()=>Ov,Export:()=>Wv,Help:()=>Hv,LiveCollaborationTrigger:()=>Xv,LoadScene:()=>Nv,SaveAsImage:()=>Fv,SaveToActiveFile:()=>Bv,SearchMenu:()=>zv,Socials:()=>Vv,ToggleTheme:()=>Uv});import h9 from"clsx";import{THEME as gn}from"@excalidraw/common";var Jh=me({active:!1});async function Pv({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{ze.set(Jh,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}import m9 from"clsx";import{jsx as Av,jsxs as p9}from"react/jsx-runtime";var od=function({onChange:e,value:o,choices:t,name:n}){return Av("div",{className:"RadioGroup",children:t.map(r=>p9("div",{className:m9("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[Av("input",{name:n,type:"radio",checked:r.value===o,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as u9,jsx as Qh,jsxs as Dv}from"react/jsx-runtime";var _v=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i})=>{let a=ce();return Dv(u9,{children:[Dv("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Qh("label",{className:"dropdown-menu-item__text",htmlFor:i,children:r}),Qh(od,{name:i,value:e,onChange:t,choices:n})]}),o&&!a.editor.isMobile&&Qh("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};_v.displayName="DropdownMenuItemContentRadio";var Rv=_v;import{Fragment as g9,jsx as $e,jsxs as Kv}from"react/jsx-runtime";var Nv=()=>{let{t:e}=Oe(),o=Ge(),t=Jo();return o.isActionEnabled(Hr)?$e(dt,{icon:Er,onSelect:async()=>{(!t.length||await Pv({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:$e(pt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>$e("strong",{children:r}),br:()=>$e("br",{})})}))&&o.executeAction(Hr)},"data-testid":"load-button",shortcut:Re("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};Nv.displayName="LoadScene";var Bv=()=>{let{t:e}=Oe(),o=Ge();return o.isActionEnabled(Yn)?$e(dt,{shortcut:Re("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(Yn),icon:P1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};Bv.displayName="SaveToActiveFile";var Fv=()=>{let e=le(),{t:o}=Oe();return $e(dt,{icon:Gl,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Re("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};Fv.displayName="SaveAsImage";var Ov=e=>{let o=le(),{t}=Oe();return $e(dt,{icon:Ki,"data-testid":"command-palette-button",onSelect:()=>{ne("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Re("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};Ov.displayName="CommandPalette";var zv=e=>{let{t:o}=Oe(),t=Ge();return $e(dt,{icon:Mt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Ma)},shortcut:Re("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};zv.displayName="SearchMenu";var Hv=()=>{let{t:e}=Oe(),o=Ge();return $e(dt,{"data-testid":"help-menu-item",icon:xr,onSelect:()=>o.executeAction(Wn),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};Hv.displayName="Help";var Gv=()=>{let{t:e}=Oe(),o=Ko(Zn);return Ge().isActionEnabled(Lo)?$e(dt,{icon:kt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};Gv.displayName="ClearCanvas";var Uv=e=>{let{t:o}=Oe(),t=ge(),n=Ge(),r=Re("toggleTheme");return n.isActionEnabled(Hn)?e?.allowSystemTheme?$e(Rv,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:gn.LIGHT,label:Yi,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:gn.DARK,label:Ui,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:X0,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):$e(dt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===gn.DARK?gn.LIGHT:gn.DARK);else return n.executeAction(Hn)},icon:t.theme===gn.DARK?Yi:Ui,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===gn.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===gn.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};Uv.displayName="ToggleTheme";var Yv=()=>{let{t:e}=Oe(),o=ge(),t=Ge(),n=po();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:Kv("div",{style:{marginTop:"0.5rem"},children:[$e("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),$e("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};Yv.displayName="ChangeCanvasBackground";var Wv=()=>{let{t:e}=Oe(),o=le();return $e(dt,{icon:Rn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};Wv.displayName="Export";var Vv=()=>{let{t:e}=Oe();return Kv(g9,{children:[$e(ri,{icon:zl,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),$e(ri,{icon:M1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),$e(ri,{icon:k1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};Vv.displayName="Socials";var Xv=({onSelect:e,isCollaborating:o})=>{let{t}=Oe();return $e(dt,{"data-testid":"collab-button",icon:Ul,className:h9({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};Xv.displayName="LiveCollaborationTrigger";import{jsx as nd,jsxs as tg}from"react/jsx-runtime";var b9=Object.assign(Ho("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=we(),n=ce(),r=ge(),i=le(),a=n.editor.isMobile?void 0:()=>i({openMenu:null});return nd(t.In,{children:tg(fe,{open:r.openMenu==="canvas",children:[nd(fe.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Ol}),tg(fe.Content,{onClickOutside:a,onSelect:f9(o,()=>{i({openMenu:null})}),children:[e,n.editor.isMobile&&r.collaborators.size>0&&tg("fieldset",{className:"UserList-Wrapper",children:[nd("legend",{children:g("labels.collaborators")}),nd(ed,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:fe.Trigger,Item:fe.Item,ItemLink:fe.ItemLink,ItemCustom:fe.ItemCustom,Group:fe.Group,Separator:fe.Separator,DefaultItems:eg}),ct=b9;import x9 from"clsx";import{forwardRef as E9,useState as y9}from"react";import{isPromiseLike as w9}from"@excalidraw/common";import{jsx as rd,jsxs as v9}from"react/jsx-runtime";var fn=E9(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:m},c)=>{let[d,p]=y9(!1),u=async b=>{let x=t?.(b);if(w9(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof sr)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=d?"loading":m;return i=f==="success"?"success":i,rd("button",{className:x9("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":n,ref:c,disabled:f==="loading"||f==="success",children:v9("div",{className:"ExcButton__contents",children:[f==="loading"?rd(et,{className:"ExcButton__statusIcon"}):f==="success"&&rd("div",{className:"ExcButton__statusIcon",children:k0}),o&&rd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as yi,jsxs as C9}from"react/jsx-runtime";var id=({title:e,children:o,actionLabel:t,onClick:n})=>C9("div",{className:"OverwriteConfirm__Actions__Action",children:[yi("h4",{children:e}),yi("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),yi(fn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),T9=()=>{let{t:e}=Oe(),o=Ge(),t=le();return yi(id,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Ds,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},I9=()=>{let{t:e}=Oe(),o=Ge();return yi(id,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(ua,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},og=Object.assign(({children:e})=>yi("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:T9,SaveToDisk:I9});import{jsx as bn,jsxs as Zv}from"react/jsx-runtime";var ad=Object.assign(Ho("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=we(),[t,n]=ie(Jh);if(!t.active)return null;let r=()=>{t.onClose(),n(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),n(a=>({...a,active:!1}))};return bn(o.In,{children:bn(Ne,{onCloseRequest:r,title:!1,size:916,children:Zv("div",{className:"OverwriteConfirm",children:[bn("h3",{children:t.title}),Zv("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[bn("div",{className:"OverwriteConfirm__Description__icon",children:M0}),bn("div",{children:t.description}),bn("div",{className:"OverwriteConfirm__Description__spacer"}),bn(fn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),bn(og,{children:e})]})})})}),{Actions:og,Action:id});import K9 from"clsx";import{CANVAS_SEARCH_TAB as lg,DEFAULT_SIDEBAR as Z9,LIBRARY_SIDEBAR_TAB as r3,composeEventHandlers as $9}from"@excalidraw/common";import{round as S9}from"@excalidraw/math";import k9 from"clsx";import M9 from"lodash.debounce";import{Fragment as L9,memo as P9,useEffect as Ya,useMemo as $v,useRef as ng,useState as jv}from"react";import{CLASSES as A9,EVENT as D9,FONT_FAMILY as rg,FRAME_STYLE as ig,getLineHeight as _9}from"@excalidraw/common";import{isElementCompletelyInViewport as R9}from"@excalidraw/element";import{measureText as Wa}from"@excalidraw/element";import{KEYS as wi,randomInteger as qv,addEventListener as N9,getFontString as ld}from"@excalidraw/common";import{newTextElement as B9}from"@excalidraw/element";import{isTextElement as t3,isFrameLikeElement as sd}from"@excalidraw/element";import{getDefaultFrameName as o3}from"@excalidraw/element/frame";import{Fragment as X9,jsx as qe,jsxs as Eo}from"react/jsx-runtime";var F9=me(""),ag=me(null),O9=350,n3=()=>{let e=_e(),o=le(),t=ng(null),[n,r]=ie(F9),i=n.trim(),[a,l]=jv(!1),[s,m]=jv({nonce:null,items:[]}),c=ng(null),d=ng(void 0),[p,u]=ie(ag),f=e.scene.getNonDeletedElementsMap();Ya(()=>{a||(i!==c.current||e.scene.getSceneNonce()!==d.current)&&(c.current=null,e3(i,e,(y,v)=>{m({nonce:qv(),items:y}),c.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,f,e,o,u,d]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};Ya(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((C,S)=>S===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),Ya(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=B9({text:y.searchQuery,x:y.element.x+(y.matchedLines[0]?.offsetX??0),y:y.element.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:sd(y.element)?ig.nameFontSize:y.element.fontSize,fontFamily:sd(y.element)?rg.Assistant:y.element.fontFamily}),S=14,L=C.fontSize,k=L*v<S;if(!R9([C],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())||k){let A;k?L>=S?A={fitToContent:!0}:A={fitToViewport:!0,maxZoom:S9(S/L,1)}:A={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...A,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Ya(()=>()=>{u(null),c.current=null,d.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let w=$o({goToNextItem:b,goToPreviousItem:x,searchMatches:s});Ya(()=>{let y=v=>{if(v.key===wi.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[wi.CTRL_OR_CMD]&&v.key===wi.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===wi.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===wi.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===wi.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return N9(window,D9.KEYDOWN,y,{capture:!0,passive:!1})},[o,w,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return Eo("div",{className:"layer-ui__search",children:[qe("div",{className:"layer-ui__search-header",children:qe(li,{className:A9.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:g("search.placeholder"),icon:Mt,onChange:y=>{r(y),l(!0);let v=y.trim();e3(v,e,(C,S)=>{m({nonce:qv(),items:C}),u(S),c.current=v,d.current=e.scene.getSceneNonce(),o({searchMatches:C.length?{focusedId:null,matches:C.map(L=>({id:L.element.id,focus:!1,matchedLines:L.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Eo("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Eo(X9,{children:[p!==null&&p>-1?Eo("div",{children:[p+1," / ",E]}):qe("div",{children:E}),Eo("div",{className:"result-nav",children:[qe(_t,{onSelect:()=>{b()},className:"result-nav-btn",children:Jl}),qe(_t,{onSelect:()=>{x()},className:"result-nav-btn",children:q0})]})]}),s.items.length===0&&i&&c.current&&qe("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),qe(G9,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},Jv=e=>{let o=[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 qe("div",{tabIndex:-1,className:k9("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:qe("div",{className:"preview-text",children:o.flatMap((t,n)=>qe(L9,{children:n===2?qe("b",{children:t}):t},n))})})},z9=e=>{let o=$v(()=>e.matches.items.filter(n=>sd(n.element)),[e.matches]),t=$v(()=>e.matches.items.filter(n=>t3(n.element)),[e.matches]);return Eo("div",{children:[o.length>0&&Eo("div",{className:"layer-ui__search-result-container",children:[Eo("div",{className:"layer-ui__search-result-title",children:[qe("div",{className:"title-icon",children:Bn}),qe("div",{children:g("search.frames")})]}),o.map((n,r)=>qe(Jv,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&qe("div",{className:"layer-ui__divider"})]}),t.length>0&&Eo("div",{className:"layer-ui__search-result-container",children:[Eo("div",{className:"layer-ui__search-result-title",children:[qe("div",{className:"title-icon",children:br}),qe("div",{children:g("search.texts")})]}),t.map((n,r)=>qe(Jv,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},H9=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,G9=P9(z9,H9),Qv=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),m=a.slice(s<=0?0:s).join(" ")+(l?" ":""),c=20;m=m.length>c?m.slice(-c):m;let d=e.slice(o+t.length),p=d.split(/\s+/),u=!d.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:m.length,previewText:m+t+b,moreBefore:s>0,moreAfter:p.length>f}},U9=(e,o)=>{let t=e.split(`
14
- `),n=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,r);if(s>a.length+r){let m=s-(a.length+r);for(;m>0;)a+=" ",m--}}n.push(a),r=r+a.length}return n.join(`
15
- `)},Y9=(e,o,t)=>{let r=U9(e.text,e.originalText).split(`
16
- `),i=[],a=0,l=0;for(let d of r){let p=a,u=p+d.length-1;i.push({line:d,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,m=e.originalText.slice(t,t+o.length),c=[];for(let d of i){if(m==="")break;if(s>=d.startIndex&&s<=d.endIndex){let p=d.endIndex+1-s,u=d.line.slice(0,s-d.startIndex),f=m.slice(0,p);m=m.slice(p);let b=Wa(u,ld(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&d.line.length>0){let v=Wa(d.line,ld(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:w}=Wa(f,ld(e),e.lineHeight),E=b.width,y=d.lineNumber*b.height;c.push({offsetX:E,offsetY:y,width:x,height:w,showOnCanvas:!0}),s+=p}}return c},W9=(e,o,t,n)=>{let r=e.name??o3(e),i=r.slice(t,t+o.length),a=r.slice(0,t),l=ld({fontSize:ig.nameFontSize,fontFamily:rg.Assistant}),s=_9(rg.Assistant),m=Wa(a,l,s);a===""&&(m.width=0);let c=Wa(i,l,s),d=m.width,p=-m.height-ig.strokeWidth,u=c.width;return[{offsetX:d,offsetY:p,width:u,height:c.height,showOnCanvas:d+u<=e.width*n}]},V9=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),e3=M9((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(p=>t3(p)),i=n.filter(p=>sd(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(V9(e),"gi");for(let p of r){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=Qv(f,u.index,e),x=Y9(p,e,u.index);x.length>0&&a.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,f=p.name??o3(p);for(;(u=l.exec(f))!==null;){let b=Qv(f,u.index,e),x=W9(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let m=new Set(o.visibleElements.map(p=>p.id)),c=[...s,...a],d=c.findIndex(p=>m.has(p.element.id))??null;t(c,d)},O9);import{jsx as no,jsxs as i3}from"react/jsx-runtime";import{createElement as j9}from"react";var a3=Ho("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=we();return no(o.In,{children:no(Vt.Trigger,{...e,className:"default-sidebar-trigger",name:Z9.name})})});a3.displayName="DefaultSidebarTrigger";var l3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=we();return no(o.In,{children:e})};l3.displayName="DefaultTabTriggers";var cd=Object.assign(Ho("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=ge(),a=le(),{DefaultSidebarTabTriggersTunnel:l}=we(),s=i.openSidebar?.tab===lg;return j9(Vt,{...r,name:"default",key:"default",className:K9("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:$9(t,m=>{a({defaultSidebarDockedPreference:m})})},i3(Vt.Tabs,{children:[no(Vt.Header,{children:i3(Vt.TabTriggers,{children:[no(Vt.TabTrigger,{tab:lg,children:Mt}),no(Vt.TabTrigger,{tab:r3,children:gr}),no(l.Out,{})]})}),no(Vt.Tab,{tab:r3,children:no(Py,{})}),no(Vt.Tab,{tab:lg,children:no(n3,{})}),e]}))}),{Trigger:a3,TabTriggers:l3});import{useEffect as fN,useRef as dg,useState as Ed}from"react";import{isFiniteNumber as L3}from"@excalidraw/math";import{useState as g3,useRef as f3,useEffect as b3,useDeferredValue as iN}from"react";import{EDITOR_LS_KEYS as aN,debounce as lN,isDevEnv as sN}from"@excalidraw/common";import{useEffect as q9,useRef as s3}from"react";import{EVENT as c3,KEYS as d3}from"@excalidraw/common";import{jsx as J9}from"react/jsx-runtime";var dd=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:n})=>{let r=s3(null),i=s3(n);return i.current=n,q9(()=>{if(!i.current)return;let a=r.current;if(a){let l=s=>{s[d3.CTRL_OR_CMD]&&s.key===d3.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(c3.KEYDOWN,l),()=>{a.removeEventListener(c3.KEYDOWN,l)}}},[]),J9("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:r})};import{jsx as md,jsxs as m3}from"react/jsx-runtime";var Q9=({error:e})=>m3("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",md("p",{children:e})]}),pd=({error:e,canvasRef:o,loaded:t})=>m3("div",{className:"ttd-dialog-output-wrapper",children:[e&&md(Q9,{error:e.message}),t?md("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):md(et,{size:"2rem"})]});import p3 from"clsx";import{jsx as sg,jsxs as Va}from"react/jsx-runtime";var vi=({label:e,children:o,panelAction:t,panelActionDisabled:n=!1,onTextSubmitInProgess:r,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>Va("div",{className:"ttd-dialog-panel",children:[Va("div",{className:"ttd-dialog-panel__header",children:[sg("label",{children:e}),i?.()]}),o,Va("div",{className:p3("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[Va(_t,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:n||r,children:[Va("div",{className:p3({invisible:r}),children:[t?.label,t?.icon&&sg("span",{children:t.icon})]}),r&&sg(et,{})]}),!n&&!r&&a?.(),l?.()]})]});import{jsx as eN}from"react/jsx-runtime";var ud=({children:e})=>eN("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as u3}from"@excalidraw/common";import{jsx as h3,jsxs as tN}from"react/jsx-runtime";var hd=()=>tN("div",{className:"ttd-dialog-submit-shortcut",children:[h3("div",{className:"ttd-dialog-submit-shortcut__key",children:u3("CtrlOrCmd")}),h3("div",{className:"ttd-dialog-submit-shortcut__key",children:u3("Enter")})]});import{DEFAULT_EXPORT_PADDING as oN,EDITOR_LS_KEYS as nN}from"@excalidraw/common";var rN=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let n=t.parentElement;n&&(n.style.background="",o(null),t.replaceChildren())},gd=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:n,data:r})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){rN({canvasRef:e,setError:n});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:m,files:c}=s;n(null),r.current={elements:bi(m,{regenerateIds:!0}),files:c};let d=await rn({elements:r.current.elements,files:r.current.files,exportPadding:oN,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await To(d)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(d)}catch(l){throw a.style.background="var(--default-bg-color)",t&&n(l),l}}},Xa=e=>{Ht.set(nN.MERMAID_TO_EXCALIDRAW,e)},fd=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:n})=>{let{elements:r,files:i}=o.current;r.length&&(e.addElementsFromPasteOrLibrary({elements:r,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),n&&t&&Xa(t))};import{Fragment as mN,jsx as yo,jsxs as E3}from"react/jsx-runtime";var cN=`flowchart TD
15
+ C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,Oo(e,!0))}else i=o.polygon([[a,l],[s,m],[c,d],[p,u]],Oo(e));return i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Oo(e));case"line":case"arrow":{let i,a=Oo(e),l=e.points.length?e.points:[tD(0,0)];if(Ua(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(cD(l,16),Oo(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[o.curve(l,a)]:a.fill?i=[o.polygon(l,a)]:i=[o.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:m="arrow"}=e;if(s!==null){let c=j2(e,i,"start",s,o,a,r);i.push(...c)}if(m!==null){let c=j2(e,i,"end",m,o,a,r);i.push(...c)}}return i}case"freedraw":{let i;if(X2(e),Oc(e.points)){let a=eD(e.points,.75);i=o.curve(a,{...Oo(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return rD(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},cD=(e,o)=>{let t=[];for(let n=1;n<e.length-1;n+=1){let i=e[n-1],a=e[n+1],l=e[n],s=Gc(l,i),m=Gc(a,l),c=Math.min(o,Z2(e[n],a)/2,Z2(e[n],i)/2);s?i[0]<l[0]?t.push([e[n][0]-c,e[n][1]]):t.push([e[n][0]+c,e[n][1]]):i[1]<l[1]?t.push([e[n][0],e[n][1]-c]):t.push([e[n][0],e[n][1]+c]),t.push(e[n]),m?a[0]<l[0]?t.push([e[n][0]-c,e[n][1]]):t.push([e[n][0]+c,e[n][1]]):a[1]<l[1]?t.push([e[n][0],e[n][1]-c]):t.push([e[n][0],e[n][1]+c])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let n=0;n<t.length;n+=3)r.push(`L ${t[n][0]} ${t[n][1]}`),r.push(`Q ${t[n+1][0]} ${t[n+1][1]}, ${t[n+2][0]} ${t[n+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(" ")};var J2=(e,o,t=!1)=>{let r=!1;for(let n in o){let i=o[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;r=!0}}return!r&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??dD(),updated:mD()}};import{jsx as ew}from"react/jsx-runtime";var vi=B({name:"toggleLinearEditor",category:ke.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&n.length===1&&uD(n[0])&&!pD(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];Sh(n,"No selected element found"),Sh(o.selectedLinearElement,"No selected linear element found"),Sh(n.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:Q2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=g(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return ew(K,{type:"button",icon:mb,title:n,"aria-label":n,onClick:()=>o(null)})}}),z1e=B({name:"togglePolygon",category:ke.elements,icon:vm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!wi(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return n.length>0&&n.every(i=>wi(i)&&i.points.length>=4)},perform(e,o,t,r){let n=r.scene.getSelectedElements(o);if(n.some(s=>!wi(s)))return!1;let i=n,a=i.some(s=>!s.polygon),l=hD(i);return{elements:e.map(s=>!l.has(s.id)||!wi(s)?s:J2(s,{backgroundColor:a?s.backgroundColor:"transparent",...gD(s,a)})),appState:o,captureUpdate:Q2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(a=>!wi(a)||!a.polygon||a.points.length<3))return null;let n=r.every(a=>wi(a)&&a.polygon),i=g(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return ew(Dn,{icon:vm,title:i,"aria-label":i,active:n,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as tw,CANVAS_SEARCH_TAB as ow,CLASSES as fD,DEFAULT_SIDEBAR as rw}from"@excalidraw/common";import{CaptureUpdateAction as bD}from"@excalidraw/element";var Ha=B({name:"searchMenu",icon:Lt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openDialog)return!1;if(o.openSidebar?.name===rw.name&&o.openSidebar.tab===ow){let n=r.excalidrawContainerValue.container?.querySelector(`.${fD.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:rw.name,tab:ow},openDialog:null},captureUpdate:bD.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[tw.CTRL_OR_CMD]&&e.key===tw.F});import{isImageElement as xD}from"@excalidraw/element";import{CaptureUpdateAction as ED}from"@excalidraw/element";import{jsx as yD}from"react/jsx-runtime";var kh=B({name:"cropEditor",label:"helpDialog.cropStart",icon:Vm,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:ED.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&xD(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=g("helpDialog.cropStart");return yD(K,{type:"button",icon:Vm,title:r,"aria-label":r,onClick:()=>o(null)})}});import{getNonDeletedElements as wD}from"@excalidraw/element";import{mutateElement as vD}from"@excalidraw/element";import{newFrameElement as TD}from"@excalidraw/element";import{isFrameLikeElement as Vc}from"@excalidraw/element";import{addElementsToFrame as ID,removeAllElementsFromFrame as CD}from"@excalidraw/element";import{getFrameChildren as SD}from"@excalidraw/element";import{KEYS as nw,updateActiveTool as iw}from"@excalidraw/common";import{getElementsInGroup as kD}from"@excalidraw/element";import{getCommonBounds as MD}from"@excalidraw/element";import{CaptureUpdateAction as on}from"@excalidraw/element";var aw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Vc(t[0])},lw=B({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(Vc(n)){let i=SD(wD(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:on.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:on.EVENTUALLY}},predicate:(e,o,t,r)=>aw(o,r)}),sw=B({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return Vc(n)?{elements:CD(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:on.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:on.EVENTUALLY}},predicate:(e,o,t,r)=>aw(o,r)}),Z0e=B({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:on.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),$0e=B({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Gr,viewMode:!1,perform:(e,o,t,r)=>{let n=iw(o,{type:"frame"});return At(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:iw(o,{type:"frame"})},captureUpdate:on.EVENTUALLY}},keyTest:e=>!e[nw.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===nw.F}),cw=B({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=j(e,o);return n.length>0&&!n.some(i=>Vc(i))},perform:(e,o,t,r)=>{let n=j(e,o),i=r.scene.getNonDeletedElementsMap(),[a,l,s,m]=MD(n,i),c=16,d=TD({x:a-c,y:l-c,width:s-a+c*2,height:m-l+c*2});if(o.editingGroupId){let u=kD(n,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);vD(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:ID([...r.scene.getElementsIncludingDeleted(),d],n,d,o),appState:{selectedElementIds:{[d.id]:!0}},captureUpdate:on.IMMEDIATELY}}});import{isWindows as ND,KEYS as Ka,matchKey as Ph,arrayToMap as dw}from"@excalidraw/common";import{CaptureUpdateAction as Lh}from"@excalidraw/element";import{orderByFractionalIndex as BD}from"@excalidraw/element";import{Emitter as LD}from"@excalidraw/common";import{CaptureUpdateAction as PD,StoreChange as AD,StoreDelta as DD}from"@excalidraw/element";var Ti=class extends DD{applyTo(o,t,r){let[n,i]=this.elements.applyTo(o,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,n);return[n,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,r,n){return super.applyLatestChanges(o,t,r,n)}},rn=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Xa=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new LD);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof Ti)return;let t=Ti.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new rn(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(o,t,r,n){try{let i=r();if(i===null)return;let a=PD.IMMEDIATELY,l=this.store.snapshot,s=o,m=t,c=!1;for(;i;){try{[s,m,c]=i.applyTo(s,m,l);let d=l.elements,p=l.maybeClone(a,s,m),u=AD.create(l,p),f=Ti.applyLatestChanges(i,d,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{n(i)}if(c)break;i=r()}return[s,m]}finally{this.onHistoryChangedEmitter.trigger(new rn(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let r=Ti.inverse(t);return o.push(r)}};import{useEffect as _D,useState as RD}from"react";var Mh=(e,o)=>{let[t,r]=RD(o);return _D(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as hw}from"react/jsx-runtime";var mw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:Lh.EVENTUALLY};let[n,i]=r,a=BD(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:Lh.NEVER}}return{captureUpdate:Lh.EVENTUALLY}},pw=e=>({name:"undo",label:"buttons.undo",icon:Mm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>mw(n,t,()=>e.undo(dw(o),t)),keyTest:o=>o[Ka.CTRL_OR_CMD]&&Ph(o,Ka.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:r}=Mh(e.onHistoryChangedEmitter,new rn(e.isUndoStackEmpty,e.isRedoStackEmpty));return hw(K,{type:"button",icon:Mm,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-undo"})}}),uw=e=>({name:"redo",label:"buttons.redo",icon:Lm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>mw(n,t,()=>e.redo(dw(o),t)),keyTest:o=>o[Ka.CTRL_OR_CMD]&&o.shiftKey&&Ph(o,Ka.Z)||ND&&o.ctrlKey&&!o.shiftKey&&Ph(o,Ka.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:r}=Mh(e.onHistoryChangedEmitter,new rn(e.isUndoStackEmpty,e.isRedoStackEmpty));return hw(K,{type:"button",icon:Lm,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-redo"})}});import{getFontString as FD}from"@excalidraw/common";import{newElementWith as OD}from"@excalidraw/element";import{measureText as zD}from"@excalidraw/element";import{isTextElement as gw}from"@excalidraw/element";import{CaptureUpdateAction as HD}from"@excalidraw/element";var fw=B({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=j(e,o);return n.length===1&&gw(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=j(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&gw(i)){let a=zD(i.originalText,FD(i),i.lineHeight);return OD(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:HD.IMMEDIATELY}}});import{CODES as GD,KEYS as UD}from"@excalidraw/common";import{CaptureUpdateAction as YD}from"@excalidraw/element";var Ah=B({name:"viewMode",label:"labels.viewMode",icon:Mn,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:YD.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[UD.CTRL_OR_CMD]&&e.altKey&&e.code===GD.R});import{isPromiseLike as WD}from"@excalidraw/common";import{jsx as VD}from"react/jsx-runtime";var Dh=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&re(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Xc=class{constructor(o,t,r,n){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=m=>{Dh(n,"ui",l,a,this.app,m),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),m,this.app))};return VD(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(WD(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,m)=>(m.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return Dh(n,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(r[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();Dh(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var Kc=class{constructor(){I(this,"targets",new WeakMap);I(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var _h=e=>{let o=Array.from(e.values());return{x:bw(o,t=>t.x)/o.length,y:bw(o,t=>t.y)/o.length}},Rh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),bw=(e,o)=>e.reduce((t,r)=>t+o(r),0);import{pointFrom as H,pointRotateRads as gr,rangeInclusive as Yt,rangeIntersection as Zc,rangesOverlap as $c}from"@excalidraw/math";import{TOOL_TYPE as nn,KEYS as xw}from"@excalidraw/common";import{getCommonBounds as Nh,getDraggedElementsBounds as Bh,getElementAbsoluteCoords as XD}from"@excalidraw/element";import{isBoundToContainer as vw}from"@excalidraw/element";import{getMaximumGroups as Tw}from"@excalidraw/element";import{getSelectedElements as KD,getVisibleAndNonSelectedElements as Iw}from"@excalidraw/element";var ZD=8,Ew=99999,jc=e=>ZD/e,ht=class ht{};I(ht,"referenceSnapPoints",null),I(ht,"visibleGaps",null),I(ht,"setReferenceSnapPoints",o=>{ht.referenceSnapPoints=o}),I(ht,"getReferenceSnapPoints",()=>ht.referenceSnapPoints),I(ht,"setVisibleGaps",o=>{ht.visibleGaps=o}),I(ht,"getVisibleGaps",()=>ht.visibleGaps),I(ht,"destroy",()=>{ht.referenceSnapPoints=null,ht.visibleGaps=null});var Wt=ht,fr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Ho=({event:e,app:o,selectedElements:t})=>{if(e){let r=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||r)&&(o.state.objectsSnapModeEnabled&&!e[xw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[xw.CTRL_OR_CMD]&&!fr(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},$D=(e,o,t=.01)=>Math.abs(e-o)<=t,Za=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,m,c,d,p]=XD(a,o);n&&(l+=n.x,m+=n.x,d+=n.x,s+=n.y,c+=n.y,p+=n.y);let u=(m-l)/2,f=(c-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=gr(H(l,s+f),H(d,p),a.angle),x=gr(H(l+u,s),H(d,p),a.angle),w=gr(H(m,s+f),H(d,p),a.angle),E=gr(H(l+u,c),H(d,p),a.angle),y=H(d,p);i=t?[b,x,w,E]:[b,x,w,E,y]}else{let b=gr(H(l,s),H(d,p),a.angle),x=gr(H(m,s),H(d,p),a.angle),w=gr(H(l,c),H(d,p),a.angle),E=gr(H(m,c),H(d,p),a.angle),y=H(d,p);i=t?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,m]=Bh(e,n??{x:0,y:0}),c=s-a,d=m-l,p=H(a,l),u=H(s,l),f=H(a,m),b=H(s,m),x=H(a+c/2,l+d/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>H(Le(a[0]),Le(a[1])))},Cw=(e,o,t,r)=>Iw(e,o,t,r),Sw=(e,o,t,r)=>{let n=Cw(e,o,t,r),i=Tw(n,r).filter(d=>!(d.length===1&&vw(d[0]))).map(d=>Nh(d).map(p=>Le(p))),a=i.sort((d,p)=>d[0]-p[0]),l=[],s=0;e:for(let d=0;d<a.length;d++){let p=a[d];for(let u=d+1;u<a.length;u++){if(++s>Ew)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&$c(Yt(b,w),Yt(y,v))&&l.push({startBounds:p,endBounds:f,startSide:[H(x,b),H(x,w)],endSide:[H(E,y),H(E,v)],length:E-x,overlap:Zc(Yt(b,w),Yt(y,v))})}}let m=i.sort((d,p)=>d[1]-p[1]),c=[];s=0;e:for(let d=0;d<m.length;d++){let p=m[d];for(let u=d+1;u<m.length;u++){if(++s>Ew)break e;let f=m[u],[b,,x,w]=p,[E,y,v]=f;w<y&&$c(Yt(b,x),Yt(E,v))&&c.push({startBounds:p,endBounds:f,startSide:[H(b,w),H(x,w)],endSide:[H(E,y),H(v,y)],length:y-w,overlap:Zc(Yt(b,x),Yt(E,v))})}}return{horizontalGaps:l,verticalGaps:c}},yw=(e,o,t,r,n,i,a)=>{if(!Ho({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Wt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:m}=l,[c,d,p,u]=Bh(e,o).map(x=>Le(x)),f=(c+p)/2,b=(d+u)/2;for(let x of s){if(!$c(Yt(d,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=Le(w-f);if(x.length>p-c&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(n.length=0),a.x=Math.abs(E);let P={type:"gap",direction:"center_horizontal",gap:x,offset:E};n.push(P);continue}let[,,v]=x.endBounds,C=c-v,S=Le(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};n.push(P);continue}let[L,,,]=x.startBounds,k=L-p,A=Le(k-x.length);if(Math.abs(A)<=a.x){Math.abs(A)<a.x&&(n.length=0),a.x=Math.abs(A);let P={type:"gap",direction:"side_left",gap:x,offset:A};n.push(P);continue}}for(let x of m){if(!$c(Yt(c,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=Le(w-b);if(x.length>u-d&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let P={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(P);continue}let[,v,,]=x.startBounds,C=v-u,S=Le(C-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,L]=x.endBounds,k=Le(d-L),A=x.length-k;if(Math.abs(A)<=a.y){Math.abs(A)<a.y&&(i.length=0),a.y=Math.abs(A);let P={type:"gap",direction:"side_bottom",gap:x,offset:A};i.push(P);continue}}}},kw=(e,o,t,r)=>{let n=Cw(e,o,t,r);return Tw(n,r).filter(i=>!(i.length===1&&vw(i[0]))).flatMap(i=>Za(i,r))},Ii=(e,o,t,r,n,i,a)=>{if(!Ho({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Wt.getReferenceSnapPoints();if(l)for(let s of o)for(let m of l){let c=m[0]-s[0],d=m[1]-s[1];Math.abs(c)<=a.x&&(Math.abs(c)<a.x&&(n.length=0),n.push({type:"point",points:[s,m],offset:c}),a.x=Math.abs(c)),Math.abs(d)<=a.y&&(Math.abs(d)<a.y&&(i.length=0),i.push({type:"point",points:[s,m],offset:d}),a.y=Math.abs(d))}},Mw=(e,o,t,r,n)=>{let i=t.state,a=KD(e,i);if(!Ho({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Le(o.x),o.y=Le(o.y);let l=[],s=[],m=jc(i.zoom.value),c={x:m,y:m},d=Za(a,n,{dragOffset:o});Ii(a,d,t,r,l,s,c),yw(a,o,t,r,l,s,c);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};c.x=0,c.y=0,l.length=0,s.length=0;let u={x:Le(o.x+p.x),y:Le(o.y+p.y)};Ii(a,Za(a,n,{dragOffset:u}),t,r,l,s,c),yw(a,u,t,r,l,s,c);let f=Fh(l,s),b=qD(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Le=e=>Math.round(e*10**6)/10**6,ww=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},Fh=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=Le(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>H(Le(a[0]),Le(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=Le(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>H(Le(a[0]),Le(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:ww(i.map(a=>H(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:ww(i.map(a=>H(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},jD=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[Le(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},qD=(e,o,t)=>{let[r,n,i,a]=Bh(e,o),l=[];for(let s of t){let[m,c,d,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=Zc(Yt(n,a),s.gap.overlap),E=Zc(Yt(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(s.gap.startSide[0][0],y),H(r,y)]},{type:"gap",direction:"horizontal",points:[H(i,y),H(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,s.gap.startSide[0][1]),H(y,n)]},{type:"gap",direction:"vertical",points:[H(y,a),H(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(d,y),H(u,y)]},{type:"gap",direction:"horizontal",points:[H(b,y),H(r,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(i,y),H(m,y)]},{type:"gap",direction:"horizontal",points:[H(d,y),H(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,a),H(y,c)]},{type:"gap",direction:"vertical",points:[H(y,p),H(y,f)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,p),H(y,f)]},{type:"gap",direction:"vertical",points:[H(y,x),H(y,n)]})}break}}}return jD(l.map(s=>({...s,points:s.points.map(m=>H(Le(m[0]),Le(m[1])))})))},Oh=(e,o,t,r,n,i)=>{if(!Ho({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!$D(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,m]=Nh(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(m+=n.y));let c=[];if(i)switch(i){case"e":{c.push(H(s,l),H(s,m));break}case"w":{c.push(H(a,l),H(a,m));break}case"n":{c.push(H(a,l),H(s,l));break}case"s":{c.push(H(a,m),H(s,m));break}case"ne":{c.push(H(s,l));break}case"nw":{c.push(H(a,l));break}case"se":{c.push(H(s,m));break}case"sw":{c.push(H(a,m));break}}let d=jc(t.state.zoom.value),p={x:d,y:d},u=[],f=[];Ii(o,c,t,r,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,w,E,y]=Nh(e).map(S=>Le(S)),v=[H(x,w),H(x,y),H(E,w),H(E,y)];Ii(e,v,t,r,u,f,p);let C=Fh(u,f);return{snapOffset:b,snapLines:C}},Lw=(e,o,t,r,n,i)=>{if(!Ho({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[H(r.x+n.x,r.y+n.y)],l=jc(o.state.zoom.value),s={x:l,y:l},m=[],c=[];Ii([e],a,o,t,m,c,s);let d={x:m[0]?.offset??0,y:c[0]?.offset??0};s.x=0,s.y=0,m.length=0,c.length=0;let p=Za([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ii([e],p,o,t,m,c,s);let u=Fh(m,c);return{snapOffset:d,snapLines:u}},Pw=(e,o,t,r,n)=>{if(!Ho({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Iw(e,[],o.state,n),a=jc(o.state.zoom.value),l={x:a,y:a},s=[],m=[];for(let c of i){let d=Za([c],n);for(let p of d){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(m.length=0),m.push({type:"pointer",points:[p,H(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,H(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:m.length>0?m[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...m,...s]}},Aw=e=>e===nn.rectangle||e===nn.ellipse||e===nn.diamond||e===nn.frame||e===nn.magicframe||e===nn.image||e===nn.text;import{pointFrom as qc}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as JD,DEFAULT_FONT_SIZE as QD,TEXT_ALIGN as e_,VERTICAL_ALIGN as t_,getSizeFromPoints as o_,randomId as r_,arrayToMap as n_,assertNever as zh,cloneJSON as Rw,getFontString as i_,isDevEnv as a_,toBrandedType as l_,getLineHeight as s_}from"@excalidraw/common";import{bindLinearElement as Dw}from"@excalidraw/element";import{newArrowElement as c_,newElement as Hh,newFrameElement as d_,newImageElement as m_,newLinearElement as p_,newMagicFrameElement as u_,newTextElement as Qc}from"@excalidraw/element";import{measureText as h_,normalizeText as g_}from"@excalidraw/element";import{isArrowElement as f_}from"@excalidraw/element";import{syncInvalidIndices as b_}from"@excalidraw/element";import{redrawTextBoundingBox as x_}from"@excalidraw/element";import{LinearElementEditor as E_}from"@excalidraw/element";import{getCommonBounds as y_}from"@excalidraw/element";import{Scene as w_}from"@excalidraw/element";var Jc={width:100,height:0},br=100,v_=(e,o,t)=>{let r=Qc({x:0,y:0,textAlign:e_.CENTER,verticalAlign:t_.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),x_(r,e,t),[e,r]},_w=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let c=o?.width??br,d=o?.height??br,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-c,f=o.y||e.y-d/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Qc({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=Hh({x:u,y:f,width:c,height:d,...p,...o,type:b});break}default:zh(e,`Unhandled element start type "${o.type}"`,!0)}Dw(e,i,"start",n)}}if(t){let c=t?.height??br,d=t?.width??br,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-c/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Qc({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=Hh({x:u,y:f,width:d,height:c,...p,...t,type:b});break}default:zh(e,`Unhandled element end type "${b}"`,!0)}Dw(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,m=Rw(e.points);return e.points[l][0]>e.points[l-1][0]&&(m[0][0]=s,m[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(m[0][0]=-s,m[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(m[0][1]=s,m[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(m[0][1]=-s,m[l][1]+=s),Object.assign(e,E_.getNormalizeElementPointsAndCoords({...e,points:m})),{linearElement:e,startBoundElement:i,endBoundElement:a}},Gh=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>b_(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>l_(n_(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Ci=(e,o)=>{if(!e)return[];let t=Rw(e),r=new Gh,n=new Map,i=new Map;for(let s of t){let m,c=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:r_()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||br,u=s?.label?.text&&s.height===void 0?0:s?.height||br;m=Hh({...s,width:p,height:u});break}case"line":{let p=s.width||Jc.width,u=s.height||Jc.height;m=p_({width:p,height:u,points:[qc(0,0),qc(p,u)],...s});break}case"arrow":{let p=s.width||Jc.width,u=s.height||Jc.height;m=c_({width:p,height:u,endArrowhead:"arrow",points:[qc(0,0),qc(p,u)],...s,type:"arrow"}),Object.assign(m,o_(m.points));break}case"text":{let p=s?.fontFamily||JD,u=s?.fontSize||QD,f=s?.lineHeight||s_(p),b=s.text??"",x=g_(b),w=h_(x,i_({fontFamily:p,fontSize:u}),f);m=Qc({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{m=m_({width:s?.width||br,height:s?.height||br,...s});break}case"frame":{m=d_({x:0,y:0,...s});break}case"magicframe":{m=u_({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{m=s;break}default:m=s,zh(s,`Unhandled element type "${s.type}"`,!0)}r.getElement(m.id)?console.error(`Duplicate id found for ${m.id}`):(r.add(m),n.set(m.id,s),c&&i.set(c,m.id))}let a=r.getElementsMap(),l=new w_(a);for(let[s,m]of n){let c=r.getElement(s);switch(m.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(m.label?.text){let[d,p]=v_(c,m?.label,l);if(r.add(d),r.add(p),f_(d)){let u=m.type==="arrow"?m?.start:void 0,f=m.type==="arrow"?m?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(f&&f.id){let E=i.get(f.id);E&&Object.assign(f,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:w}=_w(d,u,f,r,l);d=b,r.add(b),r.add(x),r.add(w)}}else switch(m.type){case"arrow":{let{start:d,end:p}=m;if(d&&d.id){let x=i.get(d.id);Object.assign(d,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=_w(c,d,p,r,l);r.add(u),r.add(f),r.add(b);break}}break}}}for(let[s,m]of n){if(m.type!=="frame"&&m.type!=="magicframe")continue;let c=r.getElement(s);if(!c)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let d=[];m.children.forEach(C=>{let S=i.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);let L=r.getElement(S);if(!L)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(L,{frameId:c.id}),L?.boundElements?.forEach(k=>{let A=r.getElement(k.id);if(!A)throw new Error(`Bound element with id ${k.id} doesn't exist`);Object.assign(A,{frameId:c.id}),d.push(A)}),d.push(L)});let[p,u,f,b]=y_(d),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let w=c?.x||p,E=c?.y||u,y=c?.width||f-p,v=c?.height||b-u;Object.assign(c,{x:w,y:E,width:y,height:v}),a_()&&m.children.length&&(c?.x||c?.y||c?.width||c?.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 r.getElements()};import{isElementInViewport as J_}from"@excalidraw/element";import{memoize as Q_,toBrandedType as eR}from"@excalidraw/common";import{pointFrom as P_,pointsEqual as A_}from"@excalidraw/math";import td from"open-color";import{arrayToMap as D_,DEFAULT_TRANSFORM_HANDLE_SPACING as $h,FRAME_STYLE as Gw,invariant as Uw,THEME as __,throttleRAF as R_}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as Yh,maxBindingGap as Zw}from"@excalidraw/element";import{LinearElementEditor as xr}from"@excalidraw/element";import{getOmitSidesForDevice as Wh,getTransformHandles as N_,getTransformHandlesFromCoords as B_,shouldShowBoundingBox as F_}from"@excalidraw/element";import{isElbowArrow as $a,isFrameLikeElement as Yw,isImageElement as Ww,isLinearElement as O_,isLineElement as z_,isTextElement as Vw}from"@excalidraw/element";import{renderSelectionElement as H_}from"@excalidraw/element";import{getElementsInGroup as Kh,getSelectedGroupIds as G_,isSelectedViaGroup as U_,selectGroupsFromGivenElements as Y_}from"@excalidraw/element";import{getCommonBounds as Zh,getElementAbsoluteCoords as ja}from"@excalidraw/element";import{pointFrom as ct}from"@excalidraw/math";import{THEME as T_}from"@excalidraw/common";var I_="#ff6b6b",C_="#ff0000",Nw=1,Bw=2,Fw=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===T_.LIGHT||o.zenModeEnabled?I_:C_,r=(o.zenModeEnabled?Nw*1.5:Nw)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,k_(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,M_(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,S_(n,e,o));e.restore()},S_=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Vt(r,n,o)}for(let r of e.points)Ow(r,t,o)},k_=(e,o,t)=>{Ow(e.points[0],t,o),t.zenModeEnabled||Vt(e.points[0],e.points[1],o)},Ow=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?Bw*1.5:Bw)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},Vt=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},M_=(e,o,t,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||Vt(ct(e[0],e[1]-i),ct(e[0],e[1]+i),n),Vt(ct(s[0]-l,s[1]-a),ct(s[0]-l,s[1]+a),n),Vt(ct(s[0]+l,s[1]-a),ct(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Vt(ct(o[0],o[1]-i),ct(o[0],o[1]+i),n),Vt(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||Vt(ct(e[0]-i,e[1]),ct(e[0]+i,e[1]),n),Vt(ct(s[0]-a,s[1]-l),ct(s[0]+a,s[1]-l),n),Vt(ct(s[0]-a,s[1]+l),ct(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Vt(ct(o[0]-i,o[1]),ct(o[0]+i,o[1]),n),Vt(e,o,n))}};import{getGlobalCSSVariable as ed}from"@excalidraw/common";import{getCommonBounds as L_}from"@excalidraw/element";var lo=4,It=6,zw="rgba(0,0,0,0.3)",Hw=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=L_(e),s=o/r.zoom.value,m=t/r.zoom.value,c={top:parseInt(ed("sat"))||0,bottom:parseInt(ed("sab"))||0,left:parseInt(ed("sal"))||0,right:parseInt(ed("sar"))||0},d=Mo().rtl,p=-r.scrollX+c.left,u=-r.scrollY+c.top,f=p+s-c.right,b=u+m-c.bottom,x=Math.min(n,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-n,C=l-i,S=E-x,L=y-w,k=Math.max(lo*2,c.left+c.right)+It*2,A=o*(s/S)-k,P=Math.max(lo*2,c.top+c.bottom)+It*2,N=t*(m/L)-P,O=S>v?S*r.zoom.value/(A+k):o/(A+k),U=L>C?L*r.zoom.value/(N+P):t/(N+P);return{horizontal:p===x&&f===E?null:{x:Math.max(c.left,lo)+It+(p-x)/S*o,y:t-It-Math.max(lo,c.bottom),width:A,height:It,deltaMultiplier:O},vertical:u===w&&b===y?null:{x:d?Math.max(c.left,lo):o-It-Math.max(c.right,lo),y:Math.max(c.top,lo)+It+(u-w)/L*t,width:It,height:N,deltaMultiplier:U}}},Uh=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var W_=(e,o)=>{Uw(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;Uw(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),$w(t,e,o),e.restore()},V_=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(n))return;let i=xr.getElement(r,t);if(!i)return;let a=xr.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),$w(a,e,o),e.restore()},$w=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Vi(o,e[0],e[1],xr.POINT_HANDLE_SIZE/t.zoom.value,!1)},Vh=(e,o,t,r,n,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Vi(e,t[0],t[1],(a?r*(o.selectedLinearElement?.isEditing?1.5:2):r)/o.zoom.value,!i,!a||n)},X_=(e,o,t,r)=>{let n=Zw(o,o.width,o.height,r);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":l1(e,o,t,n);break;case"diamond":c1(e,n,o,t);break;case"ellipse":{let[i,a,l,s]=ja(o,t),m=l-i,c=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=n-Yh,s1(e,m+n+Yh,c+n+Yh,i+m/2,a+c/2,o.angle);break}}},K_=(e,o,t,r)=>{let[n,i,a]=o,l=Zw(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(m=>{let[c,d]=xr.getPointAtIndexGlobalCoordinates(n,m,t);Vi(e,c,d,l,!0)})},jw=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:m,cy:c,dashed:d,activeEmbeddable:p}=t,u=a-n,f=l-i,x=(t.padding??$h*2)/o.zoom.value,w=8/o.zoom.value,E=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],d&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*v,Xi(e,n-x,i-x,u+x*2,f+x*2,m,c,r);e.restore()},Z_=(e,o,t,r)=>{let n=Array.isArray(t)?K_:X_;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},$_=(e,o,t,r)=>{let[n,i,a,l]=ja(t,r),s=a-n,m=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Gw.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Xi(e,n,i,s,m,n+s/2,i+m/2,t.angle,!1,Gw.radius/o.zoom.value),e.restore()},Xw=(e,o,t,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:i=!1}=r||{},a=t.filter(c=>c.groupIds.length===0),l=t.filter(c=>c.groupIds.length>0),s=c=>{let[d,p,u,f]=Zh(c);return{angle:0,x1:d,x2:u,y1:p,y2:f,selectionColors:n,dashed:i,cx:d+(u-d)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},m=c=>{let d=Kh(t,c);return s(d)};Object.entries(Y_(l,o)).filter(([c,d])=>d).map(([c,d])=>c).map(c=>m(c)).concat(a.map(c=>s([c]))).forEach(c=>jw(e,o,c))},Xh=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=xr.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=xr,a=o.selectedLinearElement?.isEditing?i:i/2,l=$a(t),s=z_(t);if(n.forEach((m,c)=>{if(l&&c!==0&&c!==n.length-1)return;let d=c>0&&(c!==n.length-1||!s||!t.polygon)&&A_(m,c===n.length-1?n[0]:n[c-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(c);s&&t.polygon&&!p&&c===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Vh(e,o,m,a,p,!1,d)}),$a(t)){let m=t.fixedSegments?.map(c=>c.index)||[];n.slice(0,-1).forEach((c,d)=>{xr.isSegmentTooShort(t,n[d+1],n[d],d,o.zoom)||Vh(e,o,P_((c[0]+n[d+1][0])/2,(c[1]+n[d+1][1])/2),i/2,!1,!m.includes(d+1),!1)})}else xr.getEditorMidPoints(t,r,o).filter((c,d,p)=>c!==null&&!($a(t)&&(d===0||d===p.length-1))).forEach(c=>{(o.selectedLinearElement?.isEditing||n.length===2)&&Vh(e,o,c,i/2,!1,!0,!1)});e.restore()},Kw=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,m,c]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Vi(e,l+m/2,s+c/2,m/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,m,c,2/t.zoom.value),e.fill(),e.stroke()):Xi(e,l,s,m,c,l+m/2,s+c/2,n,!0),e.restore()}})},j_=(e,o,t,r,n)=>{let[i,a,,,l,s]=ja(r,n),m=3,c=20,d=m/t.zoom.value,p=d/2,u=l-i+d,f=s-a+d,b=Math.min(c/t.zoom.value,u),x=Math.min(c/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(E=>{let[[y,v],[C,S],[L,k],[A,P],[N,O]]=E;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+L,v+k),e.stroke(),e.beginPath(),e.moveTo(y+A,v+P),e.lineTo(y+N,v+O),e.stroke(),e.restore()}),e.restore()},q_=(e,o,t,r)=>{o.save();let n=$h*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,m=-(i/2+n),c=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(m,c,i,a),o.restore()},qw=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[m,c]=Dl(e,i),d=_l({canvas:e,scale:i,normalizedWidth:m,normalizedHeight:c});d.save(),d.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===b.id&&b&&(p=b)}),p&&Xh(d,a,p,o),a.selectionElement&&!a.isCropping)try{H_(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Vw(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&q_(b,d,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{Z_(d,a,b,o)}),a.frameToHighlight&&$_(d,a,a.frameToHighlight,o),a.elementsToHighlight&&Xw(d,a,a.elementsToHighlight),a.activeLockedId){let b=n.get(a.activeLockedId),x=b?[b]:Kh(n,a.activeLockedId);Xw(d,a,x,{colors:["#ced4da"],dashed:!0})}let u=r.some(b=>Yw(b));if(r.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===r[0].id&&Xh(d,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?W_(d,a):($a(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&V_(d,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=F_(r,a),x=r.length===1&&O_(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Xh(d,a,r[0],o);let w=l.selectionColor||td.black;if(b){let E=D_(r),y=[];for(let C of o.values()){let S=[],L=l.remoteSelectedElementIds.get(C.id);if(x&&$a(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!U_(a,C)&&S.push(w),L&&S.push(...L.map(k=>qr(k,a.collaborators.get(k))))),S.length){let[k,A,P,N,O,U]=ja(C,o,!0);y.push({angle:C.angle,x1:k,y1:A,x2:P,y2:N,selectionColors:C.locked?["#ced4da"]:S,dashed:!!L||C.locked,cx:O,cy:U,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||Ww(C)?0:void 0})}}let v=C=>{let S=Kh(o,C),[L,k,A,P]=Zh(S);y.push({angle:0,x1:L,x2:A,y1:k,y2:P,selectionColors:S.some(N=>N.locked)?["#ced4da"]:[td.black],dashed:!0,cx:L+(A-L)/2,cy:k+(P-k)/2,activeEmbeddable:!1})};for(let C of G_(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>jw(d,a,C))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=td.white;let E=N_(r[0],a.zoom,o,"mouse",Wh(s));if(!a.viewModeEnabled&&b&&!Vw(a.editingTextElement)&&!a.croppingElementId&&Kw(d,l,a,E,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&Ww(y)&&j_(d,l,a,y,o)}}else if(r.length>1&&!a.isRotating&&!r.some(E=>E.locked)){let E=$h*2/a.zoom.value;d.fillStyle=td.white;let[y,v,C,S]=Zh(r,o),L=d.getLineDash();d.setLineDash([2/a.zoom.value]);let k=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=w,Xi(d,y-E,v-E,C-y+E*2,S-v+E*2,(y+C)/2,(v+S)/2,0),d.lineWidth=k,d.setLineDash(L);let A=B_([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...Wh(s),rotation:!0}:Wh(s));r.some(P=>!P.locked)&&Kw(d,l,a,A,0)}d.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=o.get(b);if(E){let[y,v,,,C,S]=ja(E,o,!0);d.save(),a.theme===__.LIGHT?x?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":x?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)";let L=Yw(E)?a.zoom.value:1;d.translate(a.scrollX,a.scrollY),d.translate(C,S),d.rotate(E.angle),w.forEach(k=>{(k.showOnCanvas||x)&&d.fillRect(y+k.offsetX/L-C,v+k.offsetY/L-S,k.width/L,k.height/L)}),d.restore()}}),Fw(d,a),d.restore(),pE({context:d,renderConfig:l,appState:a,normalizedWidth:m,normalizedHeight:c});let f;return l.renderScrollbars&&(f=Hw(o,m,c,a),d.save(),d.fillStyle=zw,d.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&Js(d,b.x,b.y,b.width,b.height,It/2)}),d.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},jh=R_(e=>{let o=qw(e);e.callback?.(o)},{trailing:!0}),Jw=(e,o)=>{if(o){jh(e);return}let t=qw(e);return e.callback(t),t};var qa=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:m,width:c})=>{let d=[];for(let p of r.values())J_(p,c,m,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&d.push(p);return d},t=({elements:r,editingTextElement:n,newElementId:i})=>{let a=eR(new Map);for(let l of r)i!==l.id&&(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return Q_(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m,editingTextElement:c,newElementId:d,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:c,newElementId:d}),b=o({elementsMap:f,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){jh.cancel(),m1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as tR}from"@excalidraw/common";import{getElementAbsoluteCoords as oR}from"@excalidraw/element";import{jsx as iR}from"react/jsx-runtime";var rR=5,nR=(e,o,t)=>{let[r,n]=oR(e,t),{x:i,y:a}=tR({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},qh=({children:e,element:o,elementsMap:t})=>{let r=go();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=nR(o,r,t);return iR("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:rR},children:e})};import{DEFAULT_LASER_COLOR as cR,easeOut as ev}from"@excalidraw/common";import{LaserPointer as aR}from"@excalidraw/laser-pointer";import{SVG_NS as Qw,getSvgPathFromStroke as lR,sceneCoordsToViewportCoords as sR}from"@excalidraw/common";var Go=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Qw,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Qw,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),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(o,t){this.currentTrail=new aR(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,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())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=sR({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return lR(n,!0)}};var od=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Go(o,t,{...this.getTrailOptions(),fill:()=>cR})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(ev(i),ev(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new Go(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||qr(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as dR}from"react";import{unstable_batchedUpdates as tv}from"react-dom";import{throttleRAF as mR}from"@excalidraw/common";var Pe=e=>o=>{tv(e,o)},rd=e=>mR(o=>{tv(e,o)}),Si=(()=>{let e;try{let t=dR.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Jh,KEYS as Ja,CLASSES as ov,POINTER_BUTTON as pR,isWritableElement as uR,getFontString as rv,getFontFamilyString as nv,isTestEnv as iv,MIME_TYPES as hR}from"@excalidraw/common";import{originalContainerCache as gR,updateOriginalContainerCache as av}from"@excalidraw/element";import{LinearElementEditor as fR}from"@excalidraw/element";import{bumpVersion as bR}from"@excalidraw/element";import{getBoundTextElementId as xR,getContainerElement as Qh,getTextElementAngle as ER,redrawTextBoundingBox as yR,getBoundTextMaxHeight as wR,getBoundTextMaxWidth as lv,computeContainerDimensionForBoundText as sv,computeBoundTextPosition as vR,getBoundTextElement as TR}from"@excalidraw/element";import{getTextWidth as IR}from"@excalidraw/element";import{normalizeText as cv}from"@excalidraw/element";import{wrapText as CR}from"@excalidraw/element";import{isArrowElement as nd,isBoundToContainer as SR,isTextElement as dv}from"@excalidraw/element";var kR=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,m=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(m=i*(a.value-1)/2),`translate(${s}px, ${m}px) scale(${a.value}) rotate(${l}deg)`},mv=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let m=(_,R)=>{if(!R.style.fontFamily||!R.style.fontSize)return!1;let V=R.style.fontFamily.replace(/"/g,"");return nv({fontFamily:_.fontFamily})!==V||`${_.fontSize}px`!==R.style.fontSize},c=()=>{let _=l.state,R=l.scene.getElement(e);if(!R)return;let{textAlign:V,verticalAlign:Z}=R,W=l.scene.getNonDeletedElementsMap();if(R&&dv(R)){let se=R.x,he=R.y,de=Qh(R,l.scene.getNonDeletedElementsMap()),it=R.width,po=R.height,pn=R.width,un=R.height;if(de&&R.containerId){if(nd(de)){let Zo=fR.getBoundTextElementPosition(de,R,W);se=Zo.x,he=Zo.y}let kl=m(R,d),Yi;if(kl?Yi=av(de.id,de.height):(Yi=gR[de.id],Yi||(Yi=av(de.id,de.height))),pn=lv(de,R),un=wR(de,R),!nd(de)&&po>un){let Zo=sv(po,de.type);l.scene.mutateElement(de,{height:Zo});return}else if(!nd(de)&&de.height>Yi.height&&po<un){let Zo=sv(po,de.type);l.scene.mutateElement(de,{height:Zo})}else{let{x:Zo,y:JI}=vR(de,R,W);se=Zo,he=JI}}let[Sl,am]=r(se,he),jI=d.selectionStart,lm=d.selectionEnd,$f=d.value.length;if(jI===lm&&lm!==$f){let kl=$f-lm;d.selectionStart=d.value.length-kl,d.selectionEnd=d.value.length-kl}de?it+=.5:(pn=(_.width-8-Sl)/_.zoom.value,it=Math.min(it,pn)),po*=1.05;let qI=rv(R),jf=(_.height-am)/_.zoom.value;Object.assign(d.style,{font:qI,lineHeight:R.lineHeight,width:`${it}px`,height:`${po}px`,left:`${Sl}px`,top:`${am}px`,transform:kR(it,po,ER(R,de),_,pn,jf),textAlign:V,verticalAlign:Z,color:R.strokeColor,opacity:R.opacity/100,filter:"var(--theme-filter)",maxHeight:`${jf}px`}),d.scrollTop=0,iv()&&(d.style.fontFamily=nv(R)),l.scene.mutateElement(R,{x:se,y:he})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(SR(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,c(),o&&(d.onpaste=async _=>{let R=(await Ia(_)).findByType(hR.text);if(!R)return;let V=cv(R.value);if(!V)return;let Z=Qh(n,l.scene.getNonDeletedElementsMap()),W=rv({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Z){let se=TR(Z,l.scene.getNonDeletedElementsMap()),he=CR(`${d.value}${V}`,W,lv(Z,se)),de=IR(he,W);d.style.width=`${de}px`}},d.oninput=()=>{let _=cv(d.value);if(d.value!==_){let R=d.selectionStart;d.value=_,d.selectionStart=R,d.selectionEnd=R}o(d.value)}),d.onkeydown=_=>{if(!_.shiftKey&&Ns.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Ns),c();else if(!_.shiftKey&&Bs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Bs),c();else if(!_.shiftKey&&Fs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Fs),c();else if(Ap.keyTest(_))l.actionManager.executeAction(Ap);else if(Dp.keyTest(_))l.actionManager.executeAction(Dp);else if(_.key===Ja.ESCAPE)_.preventDefault(),C=!0,S();else if($r.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction($r);else if(_.key===Ja.ENTER&&_[Ja.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;C=!0,S()}else if(_.key===Ja.TAB||_[Ja.CTRL_OR_CMD]&&(_.code===Jh.BRACKET_LEFT||_.code===Jh.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===Jh.BRACKET_LEFT?E():w(),d.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),w=()=>{let{selectionStart:_,selectionEnd:R}=d,V=y(),Z=d.value;V.forEach(W=>{let se=Z.slice(0,W),he=Z.slice(W);Z=`${se}${b}${he}`}),d.value=Z,d.selectionStart=_+f,d.selectionEnd=R+f*V.length},E=()=>{let{selectionStart:_,selectionEnd:R}=d,V=y(),Z=[],W=d.value;V.forEach(se=>{let he=W.slice(se,se+f).match(x);if(he){let de=W.slice(0,se),it=W.slice(se+he[0].length);W=`${de}${it}`,Z.push(se)}}),d.value=W,Z.length&&(_>Z[Z.length-1]?d.selectionStart=Math.max(_-f,Z[Z.length-1]):d.selectionStart=_,d.selectionEnd=Math.max(d.selectionStart,R-f*Z.length))},y=()=>{let{selectionStart:_,selectionEnd:R,value:V}=d,Z=V.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-Z,V.slice(_,R).split(`
16
+ `).reduce((se,he,de,it)=>se.concat(de?se[de-1]+it[de-1].length+1:_),[]).reverse()},v=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},C=!1,S=()=>{if(U)return;U=!0,L();let _=l.scene.getElement(n.id);if(!_)return;let R=Qh(_,l.scene.getNonDeletedElementsMap());if(R){if(d.value.trim()){let V=xR(R);!V||V!==n.id?l.scene.mutateElement(R,{boundElements:(R.boundElements||[]).concat({type:"text",id:n.id})}):nd(R)&&bR(R)}else l.scene.mutateElement(R,{boundElements:R.boundElements?.filter(V=>!dv(V))});yR(_,R,l.scene)}t({viaKeyboard:C,nextOriginalText:d.value})},L=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,J&&J.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",k),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),N(),O(),d.remove()},k=_=>{window.removeEventListener("pointerup",k);let R=_?.target,V=R instanceof HTMLElement&&R.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=S,V||d.focus()})},A=()=>{d.onblur=null,window.addEventListener("pointerup",k),window.addEventListener("blur",S)},P=_=>{let R=_?.target;if(_.button===pR.WHEEL){R instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),A();return}let V=R instanceof HTMLElement&&R.classList.contains("properties-trigger");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&_.target.closest(`.${ov.SHAPE_ACTIONS_MENU}, .${ov.ZOOM_ACTIONS}`)&&!uR(_.target)||V?A():_.target instanceof HTMLCanvasElement&&!iv()&&requestAnimationFrame(()=>{S()})},N=l.scene.onUpdate(()=>{c(),!!document.activeElement?.closest(".properties-content")||d.focus()}),O=l.onScrollChangeEmitter.on(()=>{c()}),U=!1;s&&d.select(),k();let J=null;return i&&"ResizeObserver"in window?(J=new window.ResizeObserver(()=>{c()}),J.observe(i)):window.addEventListener("resize",c),d.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d),S};var pv=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as FR}from"@excalidraw/math";import{getElementLineSegments as OR}from"@excalidraw/element";import{LinearElementEditor as zR}from"@excalidraw/element";import{isFrameLikeElement as HR,isLinearElement as GR,isTextElement as UR}from"@excalidraw/element";import{getFrameChildren as YR}from"@excalidraw/element";import{selectGroupsForSelectedElements as WR}from"@excalidraw/element";import{getContainerElement as VR}from"@excalidraw/element";import{arrayToMap as XR,easeOut as fv,isShallowEqual as KR}from"@excalidraw/common";import{simplify as MR}from"points-on-curve";import{polygonFromPoints as LR,lineSegment as uv,polygonIncludesPointNonZero as PR}from"@excalidraw/math";import{computeBoundTextPosition as AR,doBoundsIntersect as DR,getBoundTextElement as _R,getElementBounds as RR,intersectElementWithLineSegment as hv}from"@excalidraw/element";var gv=e=>{let{lassoPath:o,elements:t,elementsMap:r,elementsSegments:n,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=MR(o,l));let m=t.filter(p=>!p.locked);a.clear(),i.clear();let c=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of m){let u=RR(p,r);DR(c,u)&&!i.has(p.id)&&!a.has(p.id)&&(NR(s,p,n)?a.add(p.id):BR(s,p,r)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},NR=(e,o,t)=>{let r=LR(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>PR(a,r))):!1},BR=(e,o,t)=>{let r=e.slice(1).map((i,a)=>uv(e[a],i)).concat([uv(e[e.length-1],e[0])]),n=_R(o,t);return r.some(i=>hv(o,t,i,0,!0).length>0||!!n&&hv({...n,...AR(o,n,t)},t,i,0,!0).length>0)};var id=class extends Go{constructor(t,r){super(t,r,{animateTrail:!0,streamline:.4,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/(1/0)),s=(5e3-Math.min(5e3,n.totalLength-n.currentIndex))/5e3;return Math.min(fv(s),fv(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,m)=>(s[m]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let m=this.app.scene.getNonDeletedElement(s);if(m&&UR(m)){let c=VR(m,this.app.scene.getNonDeletedElementsMap());c&&(n[c.id]=!0,delete n[m.id])}}for(let[s]of Object.entries(n)){let m=this.app.scene.getNonDeletedElement(s);if(m&&HR(m)){let c=YR(this.app.scene.getNonDeletedElementsMap(),m.id);for(let d of c)delete n[d.id]}}let i=WR({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&GR(this.app.scene.getNonDeletedElement(a[0]))?new zR(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(n=>FR(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!KR(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=XR(this.app.visibleElements);for(let i of this.app.visibleElements){let a=OR(i,n);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:n}=gv({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as ZR,easeOut as bv,THEME as $R}from"@excalidraw/common";import{computeBoundTextPosition as jR,getBoundTextElement as qR,intersectElementWithLineSegment as xv,isPointInElement as JR}from"@excalidraw/element";import{lineSegment as QR,pointFrom as e9}from"@excalidraw/math";import{getElementsInGroup as Ev}from"@excalidraw/element";import{shouldTestInside as t9}from"@excalidraw/element";import{hasBoundTextElement as yv,isBoundToContainer as wv}from"@excalidraw/element";import{getBoundTextElementId as vv}from"@excalidraw/element";var ad=class extends Go{constructor(t,r){super(t,r,{streamline:.2,size:5,keepHead:!0,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/200),s=(10-Math.min(10,n.totalLength-n.currentIndex))/10;return Math.min(bv(s),bv(l))},fill:()=>r.state.theme===$R.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>e9(l[0],l[1]))||[];if(r.length<2)return[];let n=QR(r[r.length-1],r[r.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=ZR(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(Tv(n,l,a)){let m=l.groupIds.at(-1);if(this.groupsToErase.has(m)){let c=Ev(this.app.scene.getNonDeletedElementsMap(),m);for(let d of c)this.elementsToErase.delete(d.id);this.groupsToErase.delete(m)}if(wv(l)&&this.elementsToErase.delete(l.containerId),yv(l)){let c=vv(l);c&&this.elementsToErase.delete(c)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&Tv(n,l,a)){let m=l.groupIds.at(-1);if(!this.groupsToErase.has(m)){let c=Ev(this.app.scene.getNonDeletedElementsMap(),m);for(let d of c)this.elementsToErase.add(d.id);this.groupsToErase.add(m)}if(yv(l)){let c=vv(l);c&&this.elementsToErase.add(c)}wv(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},Tv=(e,o,t)=>{let r=e[1];if(t9(o)&&JR(r,o,t))return!0;let n=qR(o,t);return xv(o,t,e,0,!0).length>0||!!n&&xv({...n,...jR(o,n,t)},t,e,0,!0).length>0};import{jsx as Xt,jsxs as Iv}from"react/jsx-runtime";var o9=()=>Iv("div",{"data-testid":"brave-measure-text-error",children:[Xt("p",{children:Xt(ut,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Xt("span",{style:{fontWeight:600},children:e})})}),Xt("p",{children:Xt(ut,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Xt("span",{style:{fontWeight:600},children:e})})}),Xt("p",{children:Xt(ut,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Xt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Xt("p",{children:Xt(ut,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Xt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>Iv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Cv=o9;import s9 from"clsx";import c9 from"react";import{useLayoutEffect as r9,useRef as Sv,useEffect as kv}from"react";import{unstable_batchedUpdates as n9}from"react-dom";import{KEYS as i9,queryFocusableElements as a9}from"@excalidraw/common";import{jsx as l9}from"react/jsx-runtime";var Mv=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let m=Sv(null);kv(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===i9.TAB){let f=a9(d),{activeElement:b}=document,x=f.findIndex(w=>w===b);b===d?(u.shiftKey?f[f.length-1]?.focus():f[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(f[f.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===f.length-1&&!u.shiftKey&&(f[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let c=Sv(null);return r9(()=>{if(n&&m.current&&t!=null&&o!=null){let d=m.current,{width:p,height:u}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===o)return;c.current={top:t,left:o},p>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+p-i>l?d.style.left=`${l-p-10}px`:d.style.left=`${o}px`,u>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+u-a>s?d.style.top=`${s-u}px`:d.style.top=`${t}px`}},[t,o,n,l,s,i,a]),kv(()=>{if(r){let d=p=>{m.current?.contains(p.target)||n9(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),l9("div",{className:"popover",ref:m,tabIndex:-1,children:e})};import{jsx as ki,jsxs as d9}from"react/jsx-runtime";var Ye="separator",Lv=c9.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=go(),a=rr(),l=o.reduce((s,m)=>(m&&(m===Ye||!m.predicate||m.predicate(a,i,e.app.props,e.app))&&s.push(m),s),[]);return ki(Mv,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:ki("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,m)=>{if(s===Ye)return!l[m-1]||l[m-1]===Ye?null:ki("hr",{className:"context-menu-item-separator"},m);let c=s.name,d="";return s.label&&(typeof s.label=="function"?d=g(s.label(a,i,e.app)):d=g(s.label)),ki("li",{"data-testid":c,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:d9("button",{type:"button",className:s9("context-menu-item",{dangerous:c==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[ki("div",{className:"context-menu-item__label",children:d}),ki("kbd",{className:"context-menu-item__shortcut",children:c?Ne(c):""})]})},m)})})})});import{jsx as eg,jsxs as Pv}from"react/jsx-runtime";var m9=({height:e,width:o,userToFollow:t,onDisconnect:r})=>eg("div",{className:"follow-mode",style:{width:o,height:e},children:Pv("div",{className:"follow-mode__badge",children:[Pv("div",{className:"follow-mode__badge__label",children:["Following"," ",eg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),eg("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Ft})]})}),Av=m9;import dl from"clsx";import PO from"react";import{CLASSES as AO,DEFAULT_SIDEBAR as Jg,TOOL_TYPE as c5,arrayToMap as DO,capitalizeString as _O,isShallowEqual as Xd}from"@excalidraw/common";import{mutateElement as RO}from"@excalidraw/element";import{showSelectedShapeActions as NO}from"@excalidraw/element";import{ShapeCache as BO}from"@excalidraw/element";import p9 from"clsx";import{useState as u9,useEffect as h9}from"react";import{THEME as g9}from"@excalidraw/common";import{jsx as tg,jsxs as f9}from"react/jsx-runtime";var ld=({delay:e,theme:o})=>{let[t,r]=u9(!!e);return h9(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:f9("div",{className:p9("LoadingMessage",{"LoadingMessage--dark":o===g9.DARK}),children:[tg("div",{children:tg(tt,{})}),tg("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import b9 from"clsx";import{jsx as _v,jsxs as E9}from"react/jsx-runtime";var x9="medium",Dv={CHECKED:vn,UNCHECKED:Or},sd=e=>E9("label",{className:b9("ToolIcon ToolIcon__lock",`ToolIcon_size_${x9}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[_v("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),_v("div",{className:"ToolIcon__icon",children:e.checked?Dv.CHECKED:Dv.UNCHECKED})]});import{showSelectedShapeActions as F9}from"@excalidraw/element";import y9 from"clsx";import{jsx as w9}from"react/jsx-runtime";var cd=({children:e,side:o,className:t})=>w9("div",{className:y9("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import v9 from"clsx";import{KEYS as Rv}from"@excalidraw/common";import{jsx as T9}from"react/jsx-runtime";var dd=e=>T9(K,{className:v9("Shape",{fillable:!1}),type:"radio",icon:es,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:Rv.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":Rv.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as I9,DEFAULT_SIDEBAR as C9}from"@excalidraw/common";import{isFlowchartNodeElement as S9,isImageElement as Nv,isLinearElement as Bv,isLineElement as k9,isTextBindableContainer as M9,isTextElement as L9}from"@excalidraw/element";import{getShortcutKey as og}from"@excalidraw/common";import{isNodeInFlowchart as P9}from"@excalidraw/element";import{jsx as Fv}from"react/jsx-runtime";var A9=({appState:e,isMobile:o,device:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===C9.name&&e.openSidebar.tab===I9&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(bt(e))return g("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?g("hints.linearElementMulti"):n.type==="arrow"?g("hints.arrowTool",{arrowShortcut:og("A")}):g("hints.linearElement");if(n.type==="freedraw")return g("hints.freeDraw");if(n.type==="text")return g("hints.text");if(n.type==="embeddable")return g("hints.embeddable");let m=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&m.length===1){let c=m[0];return Bv(c)&&c.points.length===2?g("hints.lockAngle"):Nv(c)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(m.length===1&&L9(m[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(m.length===1&&Nv(m[0]))return g("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!m.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(fr(r)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!m.length&&!o)return[g("hints.canvasPanning")];if(m.length===1){if(Bv(m[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):k9(m[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&M9(m[0]))return S9(m[0])?P9(m[0],r.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},md=({appState:e,isMobile:o,device:t,app:r})=>{let n=A9({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>og(a).replace(/\. ?$/,"")).join(". "):og(n);return Fv("div",{className:"HintViewer",children:Fv("span",{children:i})})};import D9 from"clsx";import{jsx as Ov,jsxs as R9}from"react/jsx-runtime";var _9="medium",pd=e=>e.penDetected?R9("label",{className:D9("ToolIcon ToolIcon__penMode",`ToolIcon_size_${_9}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Ov("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Ov("div",{className:"ToolIcon__icon",children:O1})]}):null;import{Fragment as N9,jsx as zv,jsxs as B9}from"react/jsx-runtime";var Er=({heading:e,children:o,...t})=>{let{id:r}=Ge(),n=zv("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:g(`headings.${e}`)});return zv("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):B9(N9,{children:[n,o]})})};import{Fragment as O9,jsx as rt,jsxs as Uo}from"react/jsx-runtime";var Hv=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:m,device:c,renderWelcomeScreen:d,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=ve(),w=()=>Uo(cd,{side:"top",className:"App-top-bar",children:[d&&rt(f.Out,{}),rt(Er,{heading:"shapes",children:y=>rt(qe.Col,{gap:4,align:"center",children:Uo(qe.Row,{gap:1,className:"App-toolbar-container",children:[Uo(Xe,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,rt(qe.Row,{gap:1,children:rt(_c,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Uo("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&rt(x.Out,{}),rt(pd,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),rt(sd,{checked:e.activeTool.locked,onChange:n,title:g("toolBar.lock"),isMobile:!0}),rt(dd,{checked:qt(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),rt(md,{appState:e,isMobile:!0,device:c,app:u})]}),E=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?rt("div",{className:"App-toolbar-content",children:rt(b.Out,{})}):Uo("div",{className:"App-toolbar-content",children:[rt(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Uo("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Uo(O9,{children:[m(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&w(),rt("div",{className:"App-bottom-bar",style:{marginBottom:It+lo*2,marginLeft:It+lo*2,marginRight:It+lo*2},children:Uo(Xe,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&F9(e,o)?rt(Er,{className:"App-mobile-menu",heading:"selectedShapeActions",children:rt(Dc,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Uo("footer",{className:"App-toolbar",children:[E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&rt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(y=>({...Fr(o,y)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import z9 from"open-color";import H9,{useLayoutEffect as G9,useRef as U9,useState as Y9}from"react";import{jsx as Qa,jsxs as W9}from"react/jsx-runtime";var Gv=e=>{let o=U9(null),[t,r]=Y9(null);return G9(()=>{if(!e.spreadsheet)return;let n=Vx(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await bn(n,{exportBackground:!1,viewBackgroundColor:z9.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Qa("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Qa("div",{ref:o})})},Uv=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=Re(),n=H9.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),re("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Qa(Be,{size:"small",onCloseRequest:n,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:W9("div",{className:"container",children:[Qa(Gv,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Qa(Gv,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as yr from"@radix-ui/react-popover";import Yv from"clsx";import ud,{useLayoutEffect as V9}from"react";import{supportsResizeObserver as X9,isShallowEqual as K9}from"@excalidraw/common";import{Fragment as J9,jsx as vo,jsxs as hd}from"react/jsx-runtime";var Z9=4,$9=8,j9=({shouldWrap:e,children:o,username:t})=>e?vo(Pt,{label:t||"Unknown user",children:o}):vo(J9,{children:o}),rg=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return vo(j9,{username:o.username,shouldWrap:n,children:l},t)},q9=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],gd=ud.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=Ue(),i=new Map;t.forEach((b,x)=>{let w=b.id||x;i.set(w,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=ud.useState(""),m=a.filter(b=>b.username?.toLowerCase().includes(l)),c=ud.useRef(null);V9(()=>{if(c.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(c.current.clientWidth),!X9)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(c.current),()=>{x.disconnect()}}},[]);let[d,p]=ud.useState(Z9),f=a.slice(0,d-1).map(b=>rg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?vo("div",{className:Yv("UserList UserList_mobile",e),children:a.map(b=>rg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):vo("div",{className:"UserList__wrapper",ref:c,children:hd("div",{className:Yv("UserList",e),style:{"--max-avatars":d},children:[f,a.length>d-1&&hd(yr.Root,{children:[hd(yr.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),vo(yr.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:hd(Xe,{padding:2,children:[a.length>=$9&&vo(Ts,{placeholder:g("quickSearch.placeholder"),onChange:s}),vo(Is,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:m.length>0?[vo("div",{className:"hint",children:g("userList.hint.text")}),m.map(b=>rg({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),vo(yr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let i=o.collaborators.get(r);if(!i||r!==t.next().value||!K9(n,i,q9))return!1}return!0});import ng from"clsx";import{jsx as Q9}from"react/jsx-runtime";var Wv=e=>Q9("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:In});import{jsx as Yo,jsxs as ig}from"react/jsx-runtime";var Vv=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=ve();return ig("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Yo("div",{className:ng("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Yo(qe.Col,{gap:2,children:ig(Er,{heading:"canvasActions",children:[Yo(E2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Yo(y2,{renderAction:o.renderAction,className:ng("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Yo(n.Out,{}),Yo("div",{className:ng("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:ig("div",{style:{position:"relative"},children:[r&&Yo(i.Out,{}),Yo(Wv,{onClick:()=>o.executeAction(jr)})]})}),Yo(w2,{actionManager:o,showExitZenModeBtn:t})]})},Xv=Vv;Vv.displayName="Footer";import lN from"clsx";import{useEffect as r3,useLayoutEffect as n3,useRef as hg,useState as sN,forwardRef as i3,useImperativeHandle as cN,useCallback as e3}from"react";import{EVENT as t3,isDevEnv as dN,KEYS as mN,updateObject as pN}from"@excalidraw/common";import tN from"clsx";import{useContext as oN}from"react";import eN from"react";var fd=eN.createContext({});import{jsx as ag,jsxs as Kv}from"react/jsx-runtime";var lg=({children:e,className:o})=>{let t=ce(),r=oN(fd),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return Kv("div",{className:tN("sidebar__header",o),"data-testid":"sidebar-header",children:[e,Kv("div",{className:"sidebar__header__buttons",children:[n&&ag(Pt,{label:g("labels.sidebarLock"),children:ag(Rt,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:D1})}),ag(Rt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":g("buttons.close"),children:Ft})]})]})};lg.displayName="SidebarHeader";import*as $v from"@radix-ui/react-tabs";import{jsx as Zv}from"react/jsx-runtime";var sg=({children:e,tab:o,onSelect:t,...r})=>Zv($v.Trigger,{value:o,asChild:!0,onSelect:t,children:Zv("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});sg.displayName="SidebarTabTrigger";import*as jv from"@radix-ui/react-tabs";import{jsx as rN}from"react/jsx-runtime";var cg=({children:e,...o})=>rN(jv.List,{className:"sidebar-triggers",...o,children:e});cg.displayName="SidebarTabTriggers";import nN from"clsx";import{jsx as dg,jsxs as qv}from"react/jsx-runtime";var mg=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=le(),m=ge();return qv("label",{title:r,className:"sidebar-trigger__label-element",children:[dg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:c=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let d=c.target.checked;s({openSidebar:d?{name:e,tab:o}:null}),i?.(d)},checked:m.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),qv("div",{className:nN("sidebar-trigger",a),style:l,children:[t&&dg("div",{children:t}),n&&dg("div",{className:"sidebar-trigger__label",children:n})]})]})};mg.displayName="SidebarTrigger";import*as Jv from"@radix-ui/react-tabs";import{jsx as iN}from"react/jsx-runtime";var pg=({children:e,...o})=>{let t=ge(),r=le();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return iN(Jv.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};pg.displayName="SidebarTabs";import*as Qv from"@radix-ui/react-tabs";import{jsx as aN}from"react/jsx-runtime";var ug=({tab:e,children:o,...t})=>aN(Qv.Content,{...t,value:e,"data-testid":e,children:o});ug.displayName="SidebarTab";import{jsx as o3}from"react/jsx-runtime";import{createElement as uN}from"react";var el=me(!1),a3=i3(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{dN()&&t&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=le(),s=Jo(el);n3(()=>(s(!!r),()=>{s(!1)}),[s,r]);let m=hg({});m.current.onCloseRequest=()=>{l({openSidebar:null})},m.current.onDock=u=>t?.(u),m.current=pN(m.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let c=hg(null);cN(a,()=>c.current);let d=ce(),p=e3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return _n(c,e3(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),r3(()=>{let u=f=>{f.key===mN.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener(t3.KEYDOWN,u),()=>{document.removeEventListener(t3.KEYDOWN,u)}},[p,r,d.editor.canFitSidebar]),o3(Xe,{...i,className:lN("sidebar",{"sidebar--docked":r},n),ref:c,children:o3(fd.Provider,{value:m.current,children:o})})});a3.displayName="SidebarInner";var Kt=Object.assign(i3((e,o)=>{let t=ge(),{onStateChange:r}=e,n=hg(t.openSidebar);r3(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[i,a]=sN(!1);return n3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?uN(a3,{...e,ref:o,key:e.name}):null}),{Header:lg,TabTriggers:cg,TabTrigger:sg,Tabs:pg,Tab:ug,Trigger:mg});Kt.displayName="Sidebar";import{composeEventHandlers as vN}from"@excalidraw/common";import{useLayoutEffect as hN,useRef as gN}from"react";import{jsx as fN}from"react/jsx-runtime";var Wo=(e,o)=>{let t=me(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=ve(),[,a]=i(t),l=gN({preferHost:!1,counter:0});return hN(()=>{let s=l.current;return a(m=>{let c=m+1;return s.counter=c,c}),()=>{a(m=>{let c=m-1;return s.counter=c,c||(s.preferHost=!1),c})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:fN(o,{...n})};return r.displayName=e,r};var bg={};Jf(bg,{ChangeCanvasBackground:()=>y3,ClearCanvas:()=>x3,CommandPalette:()=>g3,Export:()=>w3,Help:()=>b3,LiveCollaborationTrigger:()=>T3,LoadScene:()=>p3,SaveAsImage:()=>h3,SaveToActiveFile:()=>u3,SearchMenu:()=>f3,Socials:()=>v3,ToggleTheme:()=>E3});import yN from"clsx";import{THEME as wr}from"@excalidraw/common";var gg=me({active:!1});async function l3({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{He.set(gg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import bN from"clsx";import{jsx as s3,jsxs as xN}from"react/jsx-runtime";var bd=function({onChange:e,value:o,choices:t,name:r}){return s3("div",{className:"RadioGroup",children:t.map(n=>xN("div",{className:bN("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[s3("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as EN,jsx as fg,jsxs as c3}from"react/jsx-runtime";var d3=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=ce();return c3(EN,{children:[c3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[fg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),fg(bd,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&fg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};d3.displayName="DropdownMenuItemContentRadio";var m3=d3;import{Fragment as wN,jsx as je,jsxs as I3}from"react/jsx-runtime";var p3=()=>{let{t:e}=ze(),o=Ue(),t=rr();return o.isActionEnabled(Zn)?je(mt,{icon:Cn,onSelect:async()=>{(!t.length||await l3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:je(ut,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>je("strong",{children:n}),br:()=>je("br",{})})}))&&o.executeAction(Zn)},"data-testid":"load-button",shortcut:Ne("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};p3.displayName="LoadScene";var u3=()=>{let{t:e}=ze(),o=Ue();return o.isActionEnabled($r)?je(mt,{shortcut:Ne("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction($r),icon:X1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};u3.displayName="SaveToActiveFile";var h3=()=>{let e=le(),{t:o}=ze();return je(mt,{icon:jl,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ne("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};h3.displayName="SaveAsImage";var g3=e=>{let o=le(),{t}=ze();return je(mt,{icon:ta,"data-testid":"command-palette-button",onSelect:()=>{re("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Ne("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};g3.displayName="CommandPalette";var f3=e=>{let{t:o}=ze(),t=Ue();return je(mt,{icon:Lt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Ha)},shortcut:Ne("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};f3.displayName="SearchMenu";var b3=()=>{let{t:e}=ze(),o=Ue();return je(mt,{"data-testid":"help-menu-item",icon:In,onSelect:()=>o.executeAction(jr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};b3.displayName="Help";var x3=()=>{let{t:e}=ze(),o=Jo(en);return Ue().isActionEnabled(_o)?je(mt,{icon:Mt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};x3.displayName="ClearCanvas";var E3=e=>{let{t:o}=ze(),t=ge(),r=Ue(),n=Ne("toggleTheme");return r.isActionEnabled(Vr)?e?.allowSystemTheme?je(m3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:wr.LIGHT,label:qi,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:wr.DARK,label:ji,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:sb,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):je(mt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===wr.DARK?wr.LIGHT:wr.DARK);else return r.executeAction(Vr)},icon:t.theme===wr.DARK?qi:ji,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===wr.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===wr.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};E3.displayName="ToggleTheme";var y3=()=>{let{t:e}=ze(),o=ge(),t=Ue(),r=fo();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:I3("div",{style:{marginTop:"0.5rem"},children:[je("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),je("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};y3.displayName="ChangeCanvasBackground";var w3=()=>{let{t:e}=ze(),o=le();return je(mt,{icon:zr,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};w3.displayName="Export";var v3=()=>{let{t:e}=ze();return I3(wN,{children:[je(pi,{icon:Zl,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),je(pi,{icon:W1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),je(pi,{icon:Y1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};v3.displayName="Socials";var T3=({onSelect:e,isCollaborating:o})=>{let{t}=ze();return je(mt,{"data-testid":"collab-button",icon:ql,className:yN({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};T3.displayName="LiveCollaborationTrigger";import{jsx as xd,jsxs as xg}from"react/jsx-runtime";var TN=Object.assign(Wo("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=ve(),r=ce(),n=ge(),i=le(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return xd(t.In,{children:xg(fe,{open:n.openMenu==="canvas",children:[xd(fe.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Kl}),xg(fe.Content,{onClickOutside:a,onSelect:vN(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&xg("fieldset",{className:"UserList-Wrapper",children:[xd("legend",{children:g("labels.collaborators")}),xd(gd,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:fe.Trigger,Item:fe.Item,ItemLink:fe.ItemLink,ItemCustom:fe.ItemCustom,Group:fe.Group,Separator:fe.Separator,DefaultItems:bg}),dt=TN;import IN from"clsx";import{forwardRef as CN,useState as SN}from"react";import{isPromiseLike as kN}from"@excalidraw/common";import{jsx as Ed,jsxs as MN}from"react/jsx-runtime";var vr=CN(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:m},c)=>{let[d,p]=SN(!1),u=async b=>{let x=t?.(b);if(kN(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof gn)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=d?"loading":m;return i=f==="success"?"success":i,Ed("button",{className:IN("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:c,disabled:f==="loading"||f==="success",children:MN("div",{className:"ExcButton__contents",children:[f==="loading"?Ed(tt,{className:"ExcButton__statusIcon"}):f==="success"&&Ed("div",{className:"ExcButton__statusIcon",children:Y0}),o&&Ed("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as Mi,jsxs as AN}from"react/jsx-runtime";var yd=({title:e,children:o,actionLabel:t,onClick:r})=>AN("div",{className:"OverwriteConfirm__Actions__Action",children:[Mi("h4",{children:e}),Mi("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Mi(vr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),LN=()=>{let{t:e}=ze(),o=Ue(),t=le();return Mi(yd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Ks,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},PN=()=>{let{t:e}=ze(),o=Ue();return Mi(yd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Ca,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Eg=Object.assign(({children:e})=>Mi("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:LN,SaveToDisk:PN});import{jsx as Tr,jsxs as C3}from"react/jsx-runtime";var wd=Object.assign(Wo("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=ve(),[t,r]=ie(gg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return Tr(o.In,{children:Tr(Be,{onCloseRequest:n,title:!1,size:916,children:C3("div",{className:"OverwriteConfirm",children:[Tr("h3",{children:t.title}),C3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Tr("div",{className:"OverwriteConfirm__Description__icon",children:W0}),Tr("div",{children:t.description}),Tr("div",{className:"OverwriteConfirm__Description__spacer"}),Tr(vr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Tr(Eg,{children:e})]})})})}),{Actions:Eg,Action:yd});import QN from"clsx";import{CANVAS_SEARCH_TAB as Ig,DEFAULT_SIDEBAR as eB,LIBRARY_SIDEBAR_TAB as N3,composeEventHandlers as tB}from"@excalidraw/common";import{round as DN}from"@excalidraw/math";import _N from"clsx";import RN from"lodash.debounce";import{Fragment as NN,memo as BN,useEffect as tl,useMemo as S3,useRef as yg,useState as k3}from"react";import{CLASSES as FN,EVENT as ON,FONT_FAMILY as wg,FRAME_STYLE as vg,getLineHeight as zN}from"@excalidraw/common";import{isElementCompletelyInViewport as HN}from"@excalidraw/element";import{measureText as ol}from"@excalidraw/element";import{KEYS as Li,randomInteger as M3,addEventListener as GN,getFontString as vd}from"@excalidraw/common";import{newTextElement as UN}from"@excalidraw/element";import{isTextElement as D3,isFrameLikeElement as Td}from"@excalidraw/element";import{getDefaultFrameName as _3}from"@excalidraw/element/frame";import{Fragment as JN,jsx as Je,jsxs as To}from"react/jsx-runtime";var YN=me(""),Tg=me(null),WN=350,R3=()=>{let e=Re(),o=le(),t=yg(null),[r,n]=ie(YN),i=r.trim(),[a,l]=k3(!1),[s,m]=k3({nonce:null,items:[]}),c=yg(null),d=yg(void 0),[p,u]=ie(Tg),f=e.scene.getNonDeletedElementsMap();tl(()=>{a||(i!==c.current||e.scene.getSceneNonce()!==d.current)&&(c.current=null,A3(i,e,(y,v)=>{m({nonce:M3(),items:y}),c.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,f,e,o,u,d]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};tl(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((C,S)=>S===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),tl(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=UN({text:y.searchQuery,x:y.element.x+(y.matchedLines[0]?.offsetX??0),y:y.element.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:Td(y.element)?vg.nameFontSize:y.element.fontSize,fontFamily:Td(y.element)?wg.Assistant:y.element.fontFamily}),S=14,L=C.fontSize,k=L*v<S;if(!HN([C],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())||k){let A;k?L>=S?A={fitToContent:!0}:A={fitToViewport:!0,maxZoom:DN(S/L,1)}:A={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...A,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),tl(()=>()=>{u(null),c.current=null,d.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let w=er({goToNextItem:b,goToPreviousItem:x,searchMatches:s});tl(()=>{let y=v=>{if(v.key===Li.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[Li.CTRL_OR_CMD]&&v.key===Li.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===Li.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===Li.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===Li.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return GN(window,ON.KEYDOWN,y,{capture:!0,passive:!1})},[o,w,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return To("div",{className:"layer-ui__search",children:[Je("div",{className:"layer-ui__search-header",children:Je(gi,{className:FN.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:g("search.placeholder"),icon:Lt,onChange:y=>{n(y),l(!0);let v=y.trim();A3(v,e,(C,S)=>{m({nonce:M3(),items:C}),u(S),c.current=v,d.current=e.scene.getSceneNonce(),o({searchMatches:C.length?{focusedId:null,matches:C.map(L=>({id:L.element.id,focus:!1,matchedLines:L.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),To("div",{className:"layer-ui__search-count",children:[s.items.length>0&&To(JN,{children:[p!==null&&p>-1?To("div",{children:[p+1," / ",E]}):Je("div",{children:E}),To("div",{className:"result-nav",children:[Je(Rt,{onSelect:()=>{b()},className:"result-nav-btn",children:ls}),Je(Rt,{onSelect:()=>{x()},className:"result-nav-btn",children:ub})]})]}),s.items.length===0&&i&&c.current&&Je("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),Je(KN,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},L3=e=>{let o=[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 Je("div",{tabIndex:-1,className:_N("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Je("div",{className:"preview-text",children:o.flatMap((t,r)=>Je(NN,{children:r===2?Je("b",{children:t}):t},r))})})},VN=e=>{let o=S3(()=>e.matches.items.filter(r=>Td(r.element)),[e.matches]),t=S3(()=>e.matches.items.filter(r=>D3(r.element)),[e.matches]);return To("div",{children:[o.length>0&&To("div",{className:"layer-ui__search-result-container",children:[To("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:Gr}),Je("div",{children:g("search.frames")})]}),o.map((r,n)=>Je(L3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),t.length>0&&Je("div",{className:"layer-ui__divider"})]}),t.length>0&&To("div",{className:"layer-ui__search-result-container",children:[To("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:Tn}),Je("div",{children:g("search.texts")})]}),t.map((r,n)=>Je(L3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},XN=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,KN=BN(VN,XN),P3=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),m=a.slice(s<=0?0:s).join(" ")+(l?" ":""),c=20;m=m.length>c?m.slice(-c):m;let d=e.slice(o+t.length),p=d.split(/\s+/),u=!d.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:m.length,previewText:m+t+b,moreBefore:s>0,moreAfter:p.length>f}},ZN=(e,o)=>{let t=e.split(`
17
+ `),r=[],n=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,n);if(s>a.length+n){let m=s-(a.length+n);for(;m>0;)a+=" ",m--}}r.push(a),n=n+a.length}return r.join(`
18
+ `)},$N=(e,o,t)=>{let n=ZN(e.text,e.originalText).split(`
19
+ `),i=[],a=0,l=0;for(let d of n){let p=a,u=p+d.length-1;i.push({line:d,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,m=e.originalText.slice(t,t+o.length),c=[];for(let d of i){if(m==="")break;if(s>=d.startIndex&&s<=d.endIndex){let p=d.endIndex+1-s,u=d.line.slice(0,s-d.startIndex),f=m.slice(0,p);m=m.slice(p);let b=ol(u,vd(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&d.line.length>0){let v=ol(d.line,vd(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:w}=ol(f,vd(e),e.lineHeight),E=b.width,y=d.lineNumber*b.height;c.push({offsetX:E,offsetY:y,width:x,height:w,showOnCanvas:!0}),s+=p}}return c},jN=(e,o,t,r)=>{let n=e.name??_3(e),i=n.slice(t,t+o.length),a=n.slice(0,t),l=vd({fontSize:vg.nameFontSize,fontFamily:wg.Assistant}),s=zN(wg.Assistant),m=ol(a,l,s);a===""&&(m.width=0);let c=ol(i,l,s),d=m.width,p=-m.height-vg.strokeWidth,u=c.width;return[{offsetX:d,offsetY:p,width:u,height:c.height,showOnCanvas:d+u<=e.width*r}]},qN=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),A3=RN((e,o,t)=>{if(!e||e===""){t([],null);return}let r=o.scene.getNonDeletedElements(),n=r.filter(p=>D3(p)),i=r.filter(p=>Td(p));n.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(qN(e),"gi");for(let p of n){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=P3(f,u.index,e),x=$N(p,e,u.index);x.length>0&&a.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,f=p.name??_3(p);for(;(u=l.exec(f))!==null;){let b=P3(f,u.index,e),x=jN(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let m=new Set(o.visibleElements.map(p=>p.id)),c=[...s,...a],d=c.findIndex(p=>m.has(p.element.id))??null;t(c,d)},WN);import{jsx as so,jsxs as B3}from"react/jsx-runtime";import{createElement as oB}from"react";var F3=Wo("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=ve();return so(o.In,{children:so(Kt.Trigger,{...e,className:"default-sidebar-trigger",name:eB.name})})});F3.displayName="DefaultSidebarTrigger";var O3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=ve();return so(o.In,{children:e})};O3.displayName="DefaultTabTriggers";var Id=Object.assign(Wo("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=ge(),a=le(),{DefaultSidebarTabTriggersTunnel:l}=ve(),s=i.openSidebar?.tab===Ig;return oB(Kt,{...n,name:"default",key:"default",className:QN("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:tB(t,m=>{a({defaultSidebarDockedPreference:m})})},B3(Kt.Tabs,{children:[so(Kt.Header,{children:B3(Kt.TabTriggers,{children:[so(Kt.TabTrigger,{tab:Ig,children:Lt}),so(Kt.TabTrigger,{tab:N3,children:wn}),so(l.Out,{})]})}),so(Kt.Tab,{tab:N3,children:so(l2,{})}),so(Kt.Tab,{tab:Ig,children:so(R3,{})}),e]}))}),{Trigger:F3,TabTriggers:O3});import{useEffect as vB,useRef as kg,useState as Rd}from"react";import{isFiniteNumber as aT}from"@excalidraw/math";import{useState as X3,useRef as K3,useEffect as Z3,useDeferredValue as mB}from"react";import{EDITOR_LS_KEYS as pB,debounce as uB,isDevEnv as hB}from"@excalidraw/common";import{useEffect as rB,useRef as z3}from"react";import{EVENT as H3,KEYS as G3}from"@excalidraw/common";import{jsx as nB}from"react/jsx-runtime";var Cd=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=z3(null),i=z3(r);return i.current=r,rB(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[G3.CTRL_OR_CMD]&&s.key===G3.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(H3.KEYDOWN,l),()=>{a.removeEventListener(H3.KEYDOWN,l)}}},[]),nB("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:n})};import{jsx as Sd,jsxs as U3}from"react/jsx-runtime";var iB=({error:e})=>U3("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Sd("p",{children:e})]}),kd=({error:e,canvasRef:o,loaded:t})=>U3("div",{className:"ttd-dialog-output-wrapper",children:[e&&Sd(iB,{error:e.message}),t?Sd("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Sd(tt,{size:"2rem"})]});import Y3 from"clsx";import{jsx as Cg,jsxs as rl}from"react/jsx-runtime";var Pi=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>rl("div",{className:"ttd-dialog-panel",children:[rl("div",{className:"ttd-dialog-panel__header",children:[Cg("label",{children:e}),i?.()]}),o,rl("div",{className:Y3("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[rl(Rt,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[rl("div",{className:Y3({invisible:n}),children:[t?.label,t?.icon&&Cg("span",{children:t.icon})]}),n&&Cg(tt,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as aB}from"react/jsx-runtime";var Md=({children:e})=>aB("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as W3}from"@excalidraw/common";import{jsx as V3,jsxs as lB}from"react/jsx-runtime";var Ld=()=>lB("div",{className:"ttd-dialog-submit-shortcut",children:[V3("div",{className:"ttd-dialog-submit-shortcut__key",children:W3("CtrlOrCmd")}),V3("div",{className:"ttd-dialog-submit-shortcut__key",children:W3("Enter")})]});import{DEFAULT_EXPORT_PADDING as sB,EDITOR_LS_KEYS as cB}from"@excalidraw/common";var dB=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},Pd=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){dB({canvasRef:e,setError:r});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:m,files:c}=s;r(null),n.current={elements:Ci(m,{regenerateIds:!0}),files:c};let d=await mr({elements:n.current.elements,files:n.current.files,exportPadding:sB,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await ko(d)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(d)}catch(l){throw a.style.background="var(--default-bg-color)",t&&r(l),l}}},nl=e=>{Ut.set(cB.MERMAID_TO_EXCALIDRAW,e)},Ad=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&nl(t))};import{Fragment as bB,jsx as Io,jsxs as j3}from"react/jsx-runtime";var gB=`flowchart TD
17
20
  A[Christmas] -->|Get money| B(Go shopping)
18
21
  B --> C{Let me think}
19
22
  C -->|One| D[Laptop]
20
23
  C -->|Two| E[iPhone]
21
- C -->|Three| F[Car]`,x3=lN(Xa,300),dN=({mermaidToExcalidrawLib:e})=>{let[o,t]=g3(()=>Ht.get(aN.MERMAID_TO_EXCALIDRAW)||cN),n=iN(o.trim()),[r,i]=g3(null),a=f3(null),l=f3({elements:[],files:null}),s=_e();b3(()=>{gd({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:n}).catch(c=>{sN()&&console.error("Failed to parse mermaid definition",c)}),x3(n)},[n,e]),b3(()=>()=>{x3.flush()},[]);let m=()=>{fd({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return E3(mN,{children:[yo("div",{className:"ttd-dialog-desc",children:yo(pt,{i18nKey:"mermaid.description",flowchartLink:c=>yo("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:c}),sequenceLink:c=>yo("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:c}),classLink:c=>yo("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:c})})}),E3(ud,{children:[yo(vi,{label:g("mermaid.syntax"),children:yo(dd,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:c=>t(c.target.value),onKeyboardSubmit:()=>{m()}})}),yo(vi,{label:g("mermaid.preview"),panelAction:{action:()=>{m()},label:g("mermaid.button"),icon:wr},renderSubmitShortcut:()=>yo(hd,{}),children:yo(pd,{canvasRef:a,loaded:e.loaded,error:r})})]})]})},y3=dN;import*as v3 from"@radix-ui/react-tabs";import{useRef as w3}from"react";import{isMemberOf as pN}from"@excalidraw/common";import{jsx as uN}from"react/jsx-runtime";var T3=e=>{let o=le(),t=w3(null),n=w3(0);return uN(v3.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:r=>{if(!r)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>n.current&&(n.current=a,i.style.minHeight=`min(${n.current}px, 100%)`)}e.dialog==="ttd"&&pN(["text-to-diagram","mermaid"],r)&&o({openDialog:{name:e.dialog,tab:r}})},children:e.children})};T3.displayName="TTDDialogTabs";var I3=T3;import*as C3 from"@radix-ui/react-tabs";import{jsx as hN}from"react/jsx-runtime";var cg=({children:e,...o})=>hN(C3.List,{className:"ttd-dialog-triggers",...o,children:e});cg.displayName="TTDDialogTabTriggers";import*as k3 from"@radix-ui/react-tabs";import{jsx as S3}from"react/jsx-runtime";var bd=({children:e,tab:o,onSelect:t,...n})=>S3(k3.Trigger,{value:o,asChild:!0,onSelect:t,children:S3("button",{type:"button",className:"ttd-dialog-tab-trigger",...n,children:e})});bd.displayName="TTDDialogTabTrigger";import*as M3 from"@radix-ui/react-tabs";import{jsx as gN}from"react/jsx-runtime";var xd=({tab:e,children:o,...t})=>gN(M3.Content,{...t,value:e,children:o});xd.displayName="TTDDialogTab";import{jsx as ht,jsxs as xn}from"react/jsx-runtime";var mg=3,Ti=1e3,bN=me(null),xN=me(null),pg=e=>{let o=ge();return o.openDialog?.name!=="ttd"?null:ht(EN,{...e,tab:o.openDialog.tab})},EN=Ho("TTDDialogBase",({tab:e,...o})=>{let t=_e(),n=le(),r=dg(null),[i,a]=ie(xN),[l,s]=Ed(i?.prompt??""),m=l.trim(),c=S=>{s(S.target.value),a(L=>({generatedResponse:L?.generatedResponse??null,prompt:S.target.value}))},[d,p]=Ed(!1),[u,f]=ie(bN),b=async()=>{if(m.length>Ti||m.length<mg||d||u?.rateLimitRemaining===0||"__fallback"in o){m.length<mg&&C(new Error(`Prompt is too short (min ${mg} characters)`)),m.length>Ti&&C(new Error(`Prompt is too long (max ${Ti} characters)`));return}try{p(!0),ne("ai","generate","ttd");let{generatedResponse:S,error:L,rateLimit:k,rateLimitRemaining:A}=await o.onTextSubmit(m);if(typeof S=="string"&&a(P=>({generatedResponse:S,prompt:P?.prompt??null})),L3(k)&&L3(A)&&f({rateLimit:k,rateLimitRemaining:A}),L){C(L);return}if(!S){C(new Error("Generation failed"));return}try{await gd({canvasRef:r,data:y,mermaidToExcalidrawLib:w,setError:C,mermaidDefinition:S}),ne("ai","mermaid parse success","ttd")}catch(P){console.info(`%cTTD mermaid render errror: ${P.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
22
- TTD mermaid definition render errror: ${P.message}`,"color: yellow"),ne("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let L=S.message;(!L||L==="Failed to fetch")&&(L="Request failed"),C(new Error(L))}finally{p(!1)}},x=dg(b);x.current=b;let[w,E]=Ed({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});fN(()=>{(async()=>{await w.api,E(L=>({...L,loaded:!0}))})()},[w.api]);let y=dg({elements:[],files:null}),[v,C]=Ed(null);return ht(Ne,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:xn(I3,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?ht("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):xn(cg,{children:[ht(bd,{tab:"text-to-diagram",children:xn("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),ht("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"})]})}),ht(bd,{tab:"mermaid",children:"Mermaid"})]}),ht(xd,{className:"ttd-dialog-content",tab:"mermaid",children:ht(y3,{mermaidToExcalidrawLib:w})}),!("__fallback"in o)&&xn(xd,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[ht("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."}),xn(ud,{children:[ht(vi,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:wr},onTextSubmitInProgess:d,panelActionDisabled:m.length>Ti||u?.rateLimitRemaining===0,renderTopRight:()=>u?xn("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>ht(hd,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return xn("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Xa(i.generatedResponse),n({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",ht(tn,{icon:wr})]});let S=m.length/Ti;return S>.8?xn("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",m.length,"/",Ti]}):null},children:ht(dd,{onChange:c,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),ht(vi,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),fd({app:t,data:y})},label:"Insert",icon:wr},children:ht(pd,{canvasRef:r,error:v,loaded:w.loaded})})]})]})]})})});import{round as h5}from"@excalidraw/math";import DB from"clsx";import _B from"lodash.throttle";import{useEffect as g5,useMemo as Sg,useState as RB,memo as NB}from"react";import{STATS_PANELS as kd}from"@excalidraw/common";import{getCommonBounds as BB}from"@excalidraw/element";import{getUncroppedWidthAndHeight as FB}from"@excalidraw/element";import{isElbowArrow as OB,isImageElement as kg}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as zB}from"@excalidraw/element";import{elementsAreInSameGroup as HB}from"@excalidraw/element";import{degreesToRadians as N3,radiansToDegrees as z3}from"@excalidraw/math";import{getBoundTextElement as B3}from"@excalidraw/element";import{isArrowElement as F3,isElbowArrow as AN}from"@excalidraw/element";import{updateBindings as O3}from"@excalidraw/element";import CN from"clsx";import{useEffect as _3,useRef as wd,useState as SN}from"react";import{EVENT as Si,KEYS as kN,cloneJSON as ug}from"@excalidraw/common";import{deepCopyElement as MN}from"@excalidraw/element";import{CaptureUpdateAction as R3}from"@excalidraw/element";import{pointFrom as En,pointRotateRads as yd}from"@excalidraw/math";import{getBoundTextElement as yN}from"@excalidraw/element";import{isFrameLikeElement as A3}from"@excalidraw/element";import{getSelectedGroupIds as wN,getElementsInGroup as vN,isInGroup as TN}from"@excalidraw/element";import{getFrameChildren as IN}from"@excalidraw/element";import{updateBindings as P3}from"@excalidraw/element";var D3=.01,Ka=10,It=(e,o)=>!(o==="angle"&&A3(e)),ke=(e,o)=>{let t=e+o/2;return t-t%o},Ii=(e,o,t)=>Object.keys(e).map(n=>({original:(t??o).get(n),latest:o.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var Qn=(e,o,t,n,r,i=!0)=>{let a=n.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,m]=[t.x+t.width/2,t.y+t.height/2],[c,d]=yd(En(t.x,t.y),En(s,m),t.angle),p=e-c,u=o-d,[f,b]=yd(En(e,o),En(s+p,m+u),-t.angle);n.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),P3(l,n);let x=yN(t,r);if(x){let w=a.get(x.id);w&&n.mutateElement(w,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(A3(t)){let w=IN(r,t.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,L]=yd(En(E.x,E.y),En(v,C),E.angle),k=Math.round(S+p),A=Math.round(L+u),[P,N]=yd(En(k,A),En(v+p,C+u),-E.angle);n.mutateElement(y,{x:P,y:N},{informMutation:i,isDragging:!1}),P3(y,n,{simultaneouslyUpdated:w})})}},Ci=(e,o)=>{let n=wN(o).map(r=>vN(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!TN(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as hg,jsxs as PN}from"react/jsx-runtime";var LN=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:m,sensitivity:c=1,dragFinishedCallback:d})=>{let p=_e(),u=le(),f=wd(null),b=wd(null),[x,w]=SN(n.toString()),E=wd(null);E.current||(E.current={originalAppState:ug(m),originalElements:r,lastUpdatedValue:x,updatePending:!1}),_3(()=>{let C=n.toString();w(C),E.current.lastUpdatedValue=C},[n]);let y=(C,S,L)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let k=Number(C);if(isNaN(k)){w(n.toString());return}let A=Number(k.toFixed(2)),P=Number(n);(isNaN(P)||Math.abs(A-P)>=D3)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:A,property:l,originalAppState:L,setInputValue:N=>w(String(N)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:R3.IMMEDIATELY}))},v=wd({});return v.current.handleInputValue=y,_3(()=>{let C=f.current,S=v.current;return()=>{let L=C?.value;L&&S.handleInputValue?.(L,E.current.originalElements,E.current.originalAppState),window.removeEventListener(Si.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(Si.POINTER_UP,S.onPointerUp,!1)}},[i]),i?PN("div",{className:CN("drag-input-container",!i&&"disabled"),"data-testid":e,children:[hg("div",{className:"drag-input-label",ref:b,onPointerDown:C=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let S=Number(f.current.value);isNaN(S)&&(S=0);let L=null,k=p.scene.getNonDeletedElements().reduce((_,R)=>(_.set(R.id,MN(R)),_),new Map),A=r.map(_=>k.get(_.id)),P=ug(m),N=0,O=0,U=_=>{if(L&&k!==null&&A!==null){let R=_.clientX-L.x;R!==0&&(O+=R,Math.abs(O)>=c&&(O=Math.sign(O)*Math.floor(Math.abs(O)/c),N+=O,t({accumulatedChange:N,instantChange:O,originalElements:A,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:P,setInputValue:V=>w(String(V)),app:p,setAppState:u}),O=0))}L={x:_.clientX,y:_.clientY}},J=()=>{window.removeEventListener(Si.POINTER_MOVE,U,!1),p.syncActionResult({captureUpdate:R3.IMMEDIATELY}),d?.({app:p,setAppState:u,originalElements:A,originalAppState:P}),L=null,N=0,O=0,A=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Si.POINTER_UP,J,!1)};v.current.onPointerMove=U,v.current.onPointerUp=J,window.addEventListener(Si.POINTER_MOVE,U,!1),window.addEventListener(Si.POINTER_UP,J,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?hg(tn,{icon:o}):e}),hg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===kN.ENTER&&(y(S.value,r,m),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,w(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=r,E.current.originalAppState=ug(m)},onBlur:C=>{x?i&&y(C.target.value,E.current.originalElements,E.current.originalAppState):w(n.toString())},disabled:!i})]}):null},Je=LN;import{jsx as NN}from"react/jsx-runtime";var DN=15,_N=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a&&!AN(a)){let l=i.get(a.id);if(!l)return;if(n!==void 0){let u=N3(n);r.mutateElement(l,{angle:u}),O3(l,r);let f=B3(l,i);f&&!F3(l)&&r.mutateElement(f,{angle:u});return}let s=Math.round(z3(a.angle)*100)/100,m=Math.round(e),c=(s+m)%360;t&&(c=ke(c,DN)),c=c<0?c+360:c;let d=N3(c);r.mutateElement(l,{angle:d}),O3(l,r);let p=B3(l,i);p&&!F3(l)&&r.mutateElement(p,{angle:d})}},RN=({element:e,scene:o,appState:t,property:n})=>NN(Je,{label:"A",icon:Wl,value:Math.round(z3(e.angle)%360*100)/100,elements:[e],dragInputCallback:_N,editable:It(e,"angle"),scene:o,appState:t,property:n}),H3=RN;import{jsx as FN}from"react/jsx-runtime";var G3=5,BN=({property:e,scene:o,appState:t,setAppState:n})=>FN(Je,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let m;return r?m=r:i&&(m=a?ke(s.gridStep+G3*Math.sign(i),G3):s.gridStep+i),m?(m=Of(m),l(m),{gridStep:m}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),U3=BN;import{clamp as vd,round as gg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Td}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as Y3,getUncroppedWidthAndHeight as X3}from"@excalidraw/element";import{resizeSingleElement as W3}from"@excalidraw/element";import{isImageElement as K3}from"@excalidraw/element";import{isFrameLikeElement as fg}from"@excalidraw/element";import{getElementsInResizingFrame as bg}from"@excalidraw/element";import{replaceAllElementsInFrame as Z3}from"@excalidraw/element";import{jsx as UN}from"react/jsx-runtime";var V3=10,ON=e=>e.type==="image",zN=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:m,app:c,setAppState:d})=>{let p=m.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=n||ON(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!K3(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,C=w.scale[1]===-1,{width:S,height:L}=X3(w),k=E.naturalWidth/S,A=E.naturalHeight/L,P=v?E.width+E.x:E.naturalWidth-E.x,N=C?E.height+E.y:E.naturalHeight-E.y,O=Y3*k,U=Y3*A;if(i!==void 0){if(a==="width"){let Z=i*k,W=vd(Z,O,P);y={...y,width:W,x:v?E.x+E.width-W:E.x}}else if(a==="height"){let Z=i*A,W=vd(Z,U,N);y={...y,height:W,y:C?E.y+E.height-W:E.y}}m.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}let J=a==="width"?s:0,_=a==="height"?s:0,R=vd(E.width+J,O,P),V=vd(E.height+_,O,N);y={...E,x:v?E.x+E.width-R:E.x,y:C?E.y+E.height-V:E.y,width:R,height:V},m.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*x:u.width,Td),E=Math.max(a==="height"?i:b?i/x:u.height,Td);if(W3(w,E,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),fg(f)){let y=bg(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap()),v=Z3(m.getElementsIncludingDeleted(),y,f,c);m.replaceAllElements(v)}return}{let w=a==="width"?e:0,E=a==="height"?e:0,y=Math.max(0,u.width+w);a==="width"&&(r?y=ke(y,V3):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(r?v=ke(v,V3):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(Td,v),y=Math.max(Td,y),W3(y,v,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),fg(f)){let C=bg(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap());d({elementsToHighlight:C})}}}},HN=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&fg(a)){let l=bg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=Z3(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},GN=({property:e,element:o,scene:t,appState:n})=>{let r=gg(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&K3(o)&&o.crop){let{width:i,height:a}=X3(o);if(e==="width"){let l=i/o.crop.naturalWidth;r=gg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;r=gg(o.crop.height*l,2)}}return UN(Je,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:zN,value:r,editable:It(o,e),scene:t,appState:n,property:e,dragFinishedCallback:HN})},xg=GN;import{getBoundTextElement as YN,redrawTextBoundingBox as WN}from"@excalidraw/element";import{hasBoundTextElement as VN,isTextElement as j3}from"@excalidraw/element";import{jsx as $N}from"react/jsx-runtime";var $3=4,XN=4,KN=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!j3(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),$3);else if(a.type==="text"){let m=Math.round(a.fontSize),c=Math.round(e);s=Math.max(m+c,$3),t&&(s=ke(s,XN))}s&&(r.mutateElement(l,{fontSize:s}),WN(l,r.getContainerElement(l),r))}},ZN=({element:e,scene:o,appState:t,property:n})=>{let r=j3(e)?e:VN(e)?YN(e,o.getNonDeletedElementsMap()):null;return r?$N(Je,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:KN,icon:Nn,appState:t,scene:o,property:n}):null},q3=ZN;import{degreesToRadians as J3,radiansToDegrees as t5}from"@excalidraw/math";import{getBoundTextElement as Q3}from"@excalidraw/element";import{isArrowElement as e5}from"@excalidraw/element";import{isInGroup as Eg}from"@excalidraw/element";import{jsx as QN}from"react/jsx-runtime";var jN=15,qN=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(m=>a.get(m.id)).filter(m=>m&&!Eg(m)&&It(m,r)),s=o.filter(m=>!Eg(m)&&It(m,r));if(n!==void 0){let m=J3(n);for(let c of l){if(!c)continue;i.mutateElement(c,{angle:m});let d=Q3(c,a);d&&!e5(c)&&i.mutateElement(d,{angle:m})}i.triggerUpdate();return}for(let m=0;m<l.length;m++){let c=l[m];if(!c)continue;let d=s[m],p=Math.round(t5(d.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=ke(f,jN)),f=f<0?f+360:f;let b=J3(f);i.mutateElement(c,{angle:b});let x=Q3(c,a);x&&!e5(c)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},JN=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!Eg(s)&&It(s,"angle")),i=r.map(s=>Math.round(t5(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>It(s,"angle"));return QN(Je,{label:"A",icon:Wl,value:a,elements:e,dragInputCallback:qN,editable:l,appState:t,scene:o,property:n})},o5=JN;import{pointFrom as n5}from"@excalidraw/math";import{useMemo as eB}from"react";import{MIN_WIDTH_OR_HEIGHT as yn}from"@excalidraw/common";import{getElementsInResizingFrame as yg,isFrameLikeElement as wg,replaceAllElementsInFrame as a5,updateBoundElements as tB}from"@excalidraw/element";import{rescalePointsInElement as oB,resizeSingleElement as r5}from"@excalidraw/element";import{getBoundTextElement as nB,handleBindTextResize as rB}from"@excalidraw/element";import{isTextElement as l5}from"@excalidraw/element";import{getCommonBounds as Id}from"@excalidraw/element";import{jsx as dB}from"react/jsx-runtime";var ki=10,iB=(e,o,t,n)=>{let r=n.x-e,i=n.y-o,a=n.width*t,l=n.height*t,s=e+r*t,m=o+i*t;return{width:a,height:l,x:s,y:m,...oB(n,a,l,!1),...l5(n)?{fontSize:n.fontSize*t}:{}}},aB=(e,o,t,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),m=iB(e,o,n,i);l.mutateElement(r,m);let c=nB(i,a);if(c){let d=c.fontSize*n;tB(r,l,{newSize:{width:m.width,height:m.height}});let p=s.get(c.id);p&&l5(p)&&(l.mutateElement(p,{fontSize:d}),rB(r,l,t==="width"?"e":"s",!0))}},i5=(e,o,t,n,r,i,a,l,s,m)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let c=o/t;for(let d=0;d<l.length;d++){let p=l[d],u=a[d];aB(r[0],r[1],i,c,u,p,s,m)}},lB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:m})=>{let c=a.getNonDeletedElementsMap(),d=Ci(o,n);if(i!==void 0){for(let b of d){let x=Ii(b,c,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Id(E),L=C-y,k=S-v,A=L/k,P=Math.max(yn,l==="width"?Math.max(0,i):L),N=Math.max(yn,l==="height"?Math.max(0,i):k);i5(P,N,k,A,n5(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&It(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(r?v=ke(v,ki):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(r?C=ke(C,ki):C=Math.round(C)),v=Math.max(yn,v),C=Math.max(yn,C),r5(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),wg(E)){let S=yg(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap()),L=a5(a.getElementsIncludingDeleted(),S,E,m);a.replaceAllElements(L)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of d){let x=Ii(b,c,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Id(E),L=C-y,k=S-v,A=L/k,P=Math.max(0,L+p);l==="width"&&(r?P=ke(P,ki):P=Math.round(P));let N=Math.max(0,k+u);l==="height"&&(r?N=ke(N,ki):N=Math.round(N)),P=Math.max(yn,P),N=Math.max(yn,N),i5(P,N,k,A,n5(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&It(E,l)){let v=Math.max(0,y.width+p);l==="width"&&(r?v=ke(v,ki):v=Math.round(v));let C=Math.max(0,y.height+u);if(l==="height"&&(r?C=ke(C,ki):C=Math.round(C)),v=Math.max(yn,v),C=Math.max(yn,C),r5(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),wg(E)){let S=yg(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},sB=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&wg(a)){let l=yg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=a5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},cB=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=eB(()=>n.map(m=>{let c=Ii(m,t);if(c.length>1){let[p,u,f,b]=Id(c.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[d]=c;return Math.round((e==="width"?d.latest.width:d.latest.height)*100)/100}),[t,n,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return dB(Je,{label:e==="width"?"W":"H",elements:o,dragInputCallback:lB,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:sB})},vg=cB;import{getBoundTextElement as mB,redrawTextBoundingBox as s5}from"@excalidraw/element";import{hasBoundTextElement as pB,isTextElement as uB}from"@excalidraw/element";import{isInGroup as hB}from"@excalidraw/element";import{jsx as EB}from"react/jsx-runtime";var c5=4,gB=4,fB=(e,o)=>e.reduce((t,n)=>{if(!n||hB(n))return t;if(uB(n))return t.push(n),t;if(pB(n)){let r=mB(n,o);if(r)return t.push(r),t}return t},[]),bB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(n){l=Math.max(Math.round(n),c5);for(let s of a)r.mutateElement(s,{fontSize:l}),s5(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let m=0;m<a.length;m++){let c=a[m],d=s[m],p=Math.round(d.fontSize),u=Math.round(e),f=Math.max(p+u,c5);t&&(f=ke(f,gB)),r.mutateElement(c,{fontSize:f}),s5(c,r.getContainerElement(c),r)}r.triggerUpdate()}},xB=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=fB(e,r);if(!i.length)return null;let a=i.map(m=>Math.round(m.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return EB(Je,{label:"F",icon:Nn,elements:i,dragInputCallback:bB,value:l,editable:s,scene:o,property:n,appState:t})},d5=xB;import{pointFrom as wn,pointRotateRads as Cd}from"@excalidraw/math";import{useMemo as yB}from"react";import{isTextElement as wB}from"@excalidraw/element";import{getCommonBounds as Tg}from"@excalidraw/element";import{jsx as SB}from"react/jsx-runtime";var vB=(e,o,t,n,r,i)=>{for(let a=0;a<n.length;a++){let l=n[a],[s,m]=[l.x+l.width/2,l.y+l.height/2],[c,d]=Cd(wn(l.x,l.y),wn(s,m),l.angle),p=e==="x"?Math.round(c+o):c,u=e==="y"?Math.round(d+t):d;Qn(p,u,l,i,r,!1)}},TB=(e,o,t,n,r)=>{let i=r.getNonDeletedElementsMap(),[a,l,,]=Tg(t),s=e-a,m=o-l;for(let c=0;c<t.length;c++){let d=t[c],p=i.get(d.id);if(p&&(!wB(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=Cd(wn(p.x,p.y),wn(u,f),p.angle);Qn(b+s,x+m,d,r,n,!1)}}},IB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(r!==void 0){for(let p of Ci(o,l)){let u=Ii(p,s,t);if(u.length>1){let[f,b,,]=Tg(u.map(E=>E.latest));TB(i==="x"?r:f,i==="y"?r:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&It(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=Cd(wn(f.x,f.y),wn(x,w),f.angle);Qn(i==="x"?r:E,i==="y"?r:y,f,a,t,!1)}}}a.triggerUpdate();return}let m=n?ke(e,Ka):e;vB(i,i==="x"?m:0,i==="y"?m:0,o,t,a),a.triggerUpdate()},CB=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=yB(()=>n.map(s=>{let m=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(m.length>1){let[b,x]=Tg(m);return Math.round((e==="x"?b:x)*100)/100}let[c]=m,[d,p]=[c.x+c.width/2,c.y+c.height/2],[u,f]=Cd(wn(c.x,c.y),wn(d,p),c.angle);return Math.round((e==="x"?u:f)*100)/100}),[n,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return SB(Je,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:IB,value:l,property:e,scene:r,appState:i})},Ig=CB;import{clamp as Za,pointFrom as Sd,pointRotateRads as p5,round as m5}from"@excalidraw/math";import{getFlipAdjustedCropPosition as kB,getUncroppedWidthAndHeight as MB}from"@excalidraw/element";import{isImageElement as u5}from"@excalidraw/element";import{jsx as AB}from"react/jsx-runtime";var LB=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s})=>{let m=l.getNonDeletedElementsMap(),c=t[0],[d,p]=[c.x+c.width/2,c.y+c.height/2],[u,f]=p5(Sd(c.x,c.y),Sd(d,p),c.angle);if(s.croppingElementId===c.id){let y=m.get(c.id);if(!y||!u5(y)||!y.crop)return;let v=y.crop,C=v,S=y.scale[0]===-1,L=y.scale[1]===-1,{width:k,height:A}=MB(y);if(i!==void 0){if(a==="x"){let O=i*(v.naturalWidth/k);S?C={...v,x:Za(v.naturalWidth-O-v.width,0,v.naturalWidth-v.width)}:C={...v,x:Za(i*(v.naturalWidth/k),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:Za(i*(v.naturalHeight/A),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:C});return}let P=(a==="x"?o:0)*(S?-1:1),N=(a==="y"?o:0)*(L?-1:1);C={...v,x:Za(v.x+P,0,v.naturalWidth-v.width),y:Za(v.y+N,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:C});return}if(i!==void 0){Qn(a==="x"?i:u,a==="y"?i:f,c,l,n);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(r?ke(c.x+b,Ka):u+b):u,E=a==="y"?Math.round(r?ke(c.y+x,Ka):f+x):f;Qn(w,E,c,l,n)},PB=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=p5(Sd(o.x,o.y),Sd(o.x+o.width/2,o.y+o.height/2),o.angle),l=m5(e==="x"?i:a,2);if(r.croppingElementId===o.id&&u5(o)&&o.crop){let s=kB(o);s&&(l=m5(e==="x"?s.x:s.y,2))}return AB(Je,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:LB,scene:n,value:l,property:e,appState:r})},Cg=PB;import{Fragment as Mg,jsx as q,jsxs as Ct}from"react/jsx-runtime";var GB=50,$a=e=>{let o=mo(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=dn(e.app);return q(UB,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Te=({children:e,columns:o=1,heading:t,style:n,...r})=>q("div",{className:DB("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Te.displayName="StatsRow";var Md=({children:e,order:o,style:t,...n})=>q("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});Md.displayName="StatsRows";$a.StatsRow=Te;$a.StatsRows=Md;var UB=NB(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),m=l.getNonDeletedElementsMap(),c=le(),d=n.length===1?n[0]:null,p=n.length>1?n:null,u=r.croppingElementId&&kg(d),f=u?FB(d):null,[b,x]=RB({width:0,height:0}),w=Sg(()=>_B(v=>{let C=BB(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},GB),[]);g5(()=>{w(s)},[i,s,w]),g5(()=>()=>w.cancel(),[w]);let E=Sg(()=>Ci(n,r),[n,r]),y=Sg(()=>zB(n),[n]);return q("div",{className:"exc-stats",children:Ct(Ve,{padding:3,children:[Ct("div",{className:"title",children:[q("h2",{children:g("stats.title")}),q("div",{className:"close",onClick:o,children:Bt})]}),Ct(ia,{label:q("h3",{children:g("stats.generalStats")}),open:!!(r.stats.panels&kd.generalStats),openTrigger:()=>c(v=>({stats:{open:!0,panels:v.stats.panels^kd.generalStats}})),children:[Ct(Md,{children:[q(Te,{heading:!0,children:g("stats.scene")}),Ct(Te,{columns:2,children:[q("div",{children:g("stats.shapes")}),q("div",{children:s.length})]}),Ct(Te,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:b.width})]}),Ct(Te,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:b.height})]}),a&&Ct(Mg,{children:[q(Te,{heading:!0,children:"Canvas"}),q(Te,{children:q(U3,{property:"gridStep",scene:l,appState:r,setAppState:c})})]})]}),t?.(s,r)]}),!y&&n.length>0&&q("div",{id:"elementStats",style:{marginTop:12},children:q(ia,{label:q("h3",{children:g("stats.elementProperties")}),open:!!(r.stats.panels&kd.elementProperties),openTrigger:()=>c(v=>({stats:{open:!0,panels:v.stats.panels^kd.elementProperties}})),children:Ct(Md,{children:[d&&Ct(Mg,{children:[u&&q(Te,{heading:!0,children:g("labels.unCroppedDimension")}),r.croppingElementId&&kg(d)&&f&&Ct(Te,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:h5(f.width,2)})]}),r.croppingElementId&&kg(d)&&f&&Ct(Te,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:h5(f.height,2)})]}),q(Te,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?g("labels.imageCropping"):g(`element.${d.type}`)}),q(Te,{children:q(Cg,{element:d,property:"x",elementsMap:m,scene:l,appState:r})}),q(Te,{children:q(Cg,{element:d,property:"y",elementsMap:m,scene:l,appState:r})}),q(Te,{children:q(xg,{property:"width",element:d,scene:l,appState:r})}),q(Te,{children:q(xg,{property:"height",element:d,scene:l,appState:r})}),!OB(d)&&q(Te,{children:q(H3,{property:"angle",element:d,scene:l,appState:r})}),q(Te,{children:q(q3,{property:"fontSize",element:d,scene:l,appState:r})})]}),p&&Ct(Mg,{children:[HB(p)&&q(Te,{heading:!0,children:g("element.group")}),Ct(Te,{columns:2,style:{margin:"0.3125rem 0"},children:[q("div",{children:g("stats.shapes")}),q("div",{children:n.length})]}),q(Te,{children:q(Ig,{property:"x",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Te,{children:q(Ig,{property:"y",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Te,{children:q(vg,{property:"width",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Te,{children:q(vg,{property:"height",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Te,{children:q(o5,{property:"angle",elements:p,scene:l,appState:r})}),q(Te,{children:q(d5,{property:"fontSize",elements:p,scene:l,appState:r,elementsMap:m})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as YB,useEffect as f5,useState as b5}from"react";import{normalizeLink as WB,KEYS as Lg}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as VB,getLinkIdAndTypeFromSelection as XB}from"@excalidraw/element";import{jsx as Mi,jsxs as Ld}from"react/jsx-runtime";var KB=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=VB})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=b5(a),[m,c]=b5(!1);f5(()=>{let p=j(i,t),u=a;if(p.length>0&&r){let f=XB(p,t);f&&(u=WB(r(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,r]);let d=YB(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&n.mutateElement(p,{link:l})}if(!l&&m&&e){let p=i.get(e);p&&n.mutateElement(p,{link:null})}o?.()},[e,l,i,m,n,o]);return f5(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===Lg.ENTER&&d(),t.openDialog?.name==="elementLinkSelector"&&u.key===Lg.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,d]),Ld("div",{className:"ElementLinkDialog",children:[Ld("div",{className:"ElementLinkDialog__header",children:[Mi("h2",{children:g("elementLink.title")}),Mi("p",{children:g("elementLink.desc")})]}),Ld("div",{className:"ElementLinkDialog__input",children:[Mi(li,{value:l??"",onChange:p=>{m||c(!0),s(p)},onKeyDown:p=>{p.key===Lg.ENTER&&d()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Mi(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),c(!0)},className:"ElementLinkDialog__remove",icon:kt})]}),Ld("div",{className:"ElementLinkDialog__actions",children:[Mi(Ao,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Mi(Ao,{label:g("buttons.confirm"),onClick:d,actionType:"primary"})]})]})},x5=KB;import ZB,{useState as $B}from"react";import{Fragment as jB,jsx as Pg}from"react/jsx-runtime";var E5=({children:e,onClose:o})=>{let[t,n]=$B(!!e),{container:r}=He(),i=ZB.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return Pg(jB,{children:t&&Pg(Ne,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Pg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import qB from"react";import{isDarwin as y5,isFirefox as w5,isWindows as JB}from"@excalidraw/common";import{KEYS as Pe,getShortcutKey as X}from"@excalidraw/common";import{Fragment as T5,jsx as F,jsxs as Rt}from"react/jsx-runtime";var QB=()=>Rt("div",{className:"HelpDialog__header",children:[Rt("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:pm}),g("helpDialog.documentation")]}),Rt("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:pm}),g("helpDialog.blog")]}),Rt("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:zl}),g("helpDialog.github")]}),Rt("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:K0}),"YouTube"]})]}),eF=e=>Rt(T5,{children:[F("h3",{children:e.title}),F("div",{className:"HelpDialog__islands-container",children:e.children})]}),Ag=e=>Rt("div",{className:`HelpDialog__island ${e.className}`,children:[F("h4",{className:"HelpDialog__island-title",children:e.caption}),F("div",{className:"HelpDialog__island-content",children:e.children})]});function*tF(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var oF=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),G=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>F(nF,{children:oF(a)},a)));return Rt("div",{className:"HelpDialog__shortcut",children:[F("div",{children:e}),F("div",{className:"HelpDialog__key-container",children:[...tF(n,t?g("helpDialog.or"):null)]})]})},nF=e=>F("kbd",{className:"HelpDialog__key",...e}),v5=({onClose:e})=>{let o=qB.useCallback(()=>{e&&e()},[e]);return F(T5,{children:Rt(Ne,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[F(QB,{}),Rt(eF,{title:g("helpDialog.shortcuts"),children:[Rt(Ag,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[F(G,{label:g("toolBar.hand"),shortcuts:[Pe.H]}),F(G,{label:g("toolBar.selection"),shortcuts:[Pe.V,Pe[1]]}),F(G,{label:g("toolBar.rectangle"),shortcuts:[Pe.R,Pe[2]]}),F(G,{label:g("toolBar.diamond"),shortcuts:[Pe.D,Pe[3]]}),F(G,{label:g("toolBar.ellipse"),shortcuts:[Pe.O,Pe[4]]}),F(G,{label:g("toolBar.arrow"),shortcuts:[Pe.A,Pe[5]]}),F(G,{label:g("toolBar.line"),shortcuts:[Pe.L,Pe[6]]}),F(G,{label:g("toolBar.freedraw"),shortcuts:[Pe.P,Pe[7]]}),F(G,{label:g("toolBar.text"),shortcuts:[Pe.T,Pe[8]]}),F(G,{label:g("toolBar.image"),shortcuts:[Pe[9]]}),F(G,{label:g("toolBar.eraser"),shortcuts:[Pe.E,Pe[0]]}),F(G,{label:g("toolBar.frame"),shortcuts:[Pe.F]}),F(G,{label:g("toolBar.laser"),shortcuts:[Pe.K]}),F(G,{label:g("labels.eyeDropper"),shortcuts:[Pe.I,"Shift+S","Shift+G"]}),F(G,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[X("CtrlOrCmd+Enter")]}),F(G,{label:g("helpDialog.editText"),shortcuts:[X("Enter")]}),F(G,{label:g("helpDialog.textNewLine"),shortcuts:[X("Enter"),X("Shift+Enter")]}),F(G,{label:g("helpDialog.textFinish"),shortcuts:[X("Esc"),X("CtrlOrCmd+Enter")]}),F(G,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),F(G,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),F(G,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),X("Enter")],isOr:!0}),F(G,{label:g("helpDialog.cropFinish"),shortcuts:[X("Enter"),X("Escape")],isOr:!0}),F(G,{label:g("toolBar.lock"),shortcuts:[Pe.Q]}),F(G,{label:g("helpDialog.preventBinding"),shortcuts:[X("CtrlOrCmd")]}),F(G,{label:g("toolBar.link"),shortcuts:[X("CtrlOrCmd+K")]}),F(G,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Rt(Ag,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[F(G,{label:g("buttons.zoomIn"),shortcuts:[X("CtrlOrCmd++")]}),F(G,{label:g("buttons.zoomOut"),shortcuts:[X("CtrlOrCmd+-")]}),F(G,{label:g("buttons.resetZoom"),shortcuts:[X("CtrlOrCmd+0")]}),F(G,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),F(G,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),F(G,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),F(G,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),F(G,{label:g("buttons.zenMode"),shortcuts:[X("Alt+Z")]}),F(G,{label:g("buttons.objectsSnapMode"),shortcuts:[X("Alt+S")]}),F(G,{label:g("labels.toggleGrid"),shortcuts:[X("CtrlOrCmd+'")]}),F(G,{label:g("labels.viewMode"),shortcuts:[X("Alt+R")]}),F(G,{label:g("labels.toggleTheme"),shortcuts:[X("Alt+Shift+D")]}),F(G,{label:g("stats.fullTitle"),shortcuts:[X("Alt+/")]}),F(G,{label:g("search.title"),shortcuts:[Re("searchMenu")]}),F(G,{label:g("commandPalette.title"),shortcuts:w5?[Re("commandPalette")]:[Re("commandPalette"),Re("commandPalette",1)]})]}),Rt(Ag,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[F(G,{label:g("helpDialog.createFlowchart"),shortcuts:[X("CtrlOrCmd+Arrow Key")],isOr:!0}),F(G,{label:g("helpDialog.navigateFlowchart"),shortcuts:[X("Alt+Arrow Key")],isOr:!0}),F(G,{label:g("labels.moveCanvas"),shortcuts:[X(`Space+${g("helpDialog.drag")}`),X(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),F(G,{label:g("buttons.clearReset"),shortcuts:[X("CtrlOrCmd+Delete")]}),F(G,{label:g("labels.delete"),shortcuts:[X("Delete")]}),F(G,{label:g("labels.cut"),shortcuts:[X("CtrlOrCmd+X")]}),F(G,{label:g("labels.copy"),shortcuts:[X("CtrlOrCmd+C")]}),F(G,{label:g("labels.paste"),shortcuts:[X("CtrlOrCmd+V")]}),F(G,{label:g("labels.pasteAsPlaintext"),shortcuts:[X("CtrlOrCmd+Shift+V")]}),F(G,{label:g("labels.selectAll"),shortcuts:[X("CtrlOrCmd+A")]}),F(G,{label:g("labels.multiSelect"),shortcuts:[X(`Shift+${g("helpDialog.click")}`)]}),F(G,{label:g("helpDialog.deepSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.click")}`)]}),F(G,{label:g("helpDialog.deepBoxSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(pr||w5)&&F(G,{label:g("labels.copyAsPng"),shortcuts:[X("Shift+Alt+C")]}),F(G,{label:g("labels.copyStyles"),shortcuts:[X("CtrlOrCmd+Alt+C")]}),F(G,{label:g("labels.pasteStyles"),shortcuts:[X("CtrlOrCmd+Alt+V")]}),F(G,{label:g("labels.sendToBack"),shortcuts:[y5?X("CtrlOrCmd+Alt+["):X("CtrlOrCmd+Shift+[")]}),F(G,{label:g("labels.bringToFront"),shortcuts:[y5?X("CtrlOrCmd+Alt+]"):X("CtrlOrCmd+Shift+]")]}),F(G,{label:g("labels.sendBackward"),shortcuts:[X("CtrlOrCmd+[")]}),F(G,{label:g("labels.bringForward"),shortcuts:[X("CtrlOrCmd+]")]}),F(G,{label:g("labels.alignTop"),shortcuts:[X("CtrlOrCmd+Shift+Up")]}),F(G,{label:g("labels.alignBottom"),shortcuts:[X("CtrlOrCmd+Shift+Down")]}),F(G,{label:g("labels.alignLeft"),shortcuts:[X("CtrlOrCmd+Shift+Left")]}),F(G,{label:g("labels.alignRight"),shortcuts:[X("CtrlOrCmd+Shift+Right")]}),F(G,{label:g("labels.duplicateSelection"),shortcuts:[X("CtrlOrCmd+D"),X(`Alt+${g("helpDialog.drag")}`)]}),F(G,{label:g("helpDialog.toggleElementLock"),shortcuts:[X("CtrlOrCmd+Shift+L")]}),F(G,{label:g("buttons.undo"),shortcuts:[X("CtrlOrCmd+Z")]}),F(G,{label:g("buttons.redo"),shortcuts:JB?[X("CtrlOrCmd+Y"),X("CtrlOrCmd+Shift+Z")]:[X("CtrlOrCmd+Shift+Z")]}),F(G,{label:g("labels.group"),shortcuts:[X("CtrlOrCmd+G")]}),F(G,{label:g("labels.ungroup"),shortcuts:[X("CtrlOrCmd+Shift+G")]}),F(G,{label:g("labels.flipHorizontal"),shortcuts:[X("Shift+H")]}),F(G,{label:g("labels.flipVertical"),shortcuts:[X("Shift+V")]}),F(G,{label:g("labels.showStroke"),shortcuts:[X("S")]}),F(G,{label:g("labels.showBackground"),shortcuts:[X("G")]}),F(G,{label:g("labels.showFonts"),shortcuts:[X("Shift+F")]}),F(G,{label:g("labels.decreaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+<")]}),F(G,{label:g("labels.increaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as S5,useRef as cF,useState as vn}from"react";import{DEFAULT_EXPORT_PADDING as dF,EXPORT_IMAGE_TYPES as Dg,isFirefox as mF,EXPORT_SCALES as pF,cloneJSON as k5}from"@excalidraw/common";import{useCallback as rF,useRef as iF,useState as aF}from"react";var lF=2e3,I5=()=>{let[e,o]=aF(null),t=iF(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},lF)},r=rF(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import sF from"clsx";import{jsx as C5}from"react/jsx-runtime";var ja=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>C5("div",{className:sF("Switch",{toggled:t,disabled:r}),children:C5("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>n(!t),onKeyDown:i=>{i.key===" "&&n(!t)}})});import{jsx as Ie,jsxs as Tn}from"react/jsx-runtime";var uF="filter"in document.createElement("canvas").getContext("2d"),hF=()=>Tn("div",{children:[Ie("h3",{children:g("canvasError.cannotShowPreview")}),Ie("p",{children:Ie("span",{children:g("canvasError.canvasTooBig")})}),Tn("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),gF=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i})=>{let a=Ee(o,e),[l,s]=vn(i),[m,c]=vn(a),[d,p]=vn(e.exportBackground),[u,f]=vn(e.exportWithDarkMode),[b,x]=vn(e.exportEmbedScene),[w,E]=vn(e.exportScale),y=cF(null),[v,C]=vn(null),{onCopy:S,copyStatus:L,resetCopyStatus:k}=I5();S5(()=>{k()},[l,d,u,w,b,k]);let{exportedElements:A,exportingFrame:P}=Gn(o,e,m);return S5(()=>{let N=y.current;if(!N)return;let O=N.offsetWidth,U=N.offsetHeight;O&&rn({elements:A,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:t,exportPadding:dF,maxWidthOrHeight:Math.max(O,U),exportingFrame:P}).then(J=>(C(null),To(J).then(()=>{N.replaceChildren(J)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):_}))).catch(J=>{console.error(J),C(J)})},[e,t,A,P,l,d,u,w,b]),Tn("div",{className:"ImageExportModal",children:[Ie("h3",{children:g("imageExportDialog.header")}),Tn("div",{className:"ImageExportModal__preview",children:[Ie("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Ie(hF,{})}),Ie("div",{className:"ImageExportModal__preview__filename",children:!cr&&Ie("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:N=>{s(N.target.value),n.executeAction(Pp,"ui",N.target.value)}})})]}),Tn("div",{className:"ImageExportModal__settings",children:[Ie("h3",{children:g("imageExportDialog.header")}),a&&Ie(qa,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ie(ja,{name:"exportOnlySelected",checked:m,onChange:N=>{c(N)}})}),Ie(qa,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ie(ja,{name:"exportBackgroundSwitch",checked:d,onChange:N=>{p(N),n.executeAction(Ap,"ui",N)}})}),uF&&Ie(qa,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ie(ja,{name:"exportDarkModeSwitch",checked:u,onChange:N=>{f(N),n.executeAction(Tx,"ui",N)}})}),Ie(qa,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ie(ja,{name:"exportEmbedSwitch",checked:b,onChange:N=>{x(N),n.executeAction(Ds,"ui",N)}})}),Ie(qa,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Ie(od,{name:"exportScale",value:w,onChange:N=>{E(N),n.executeAction(vx,"ui",N)},choices:pF.map(N=>({value:N,label:`${N}\xD7`}))})}),Tn("div",{className:"ImageExportModal__settings__buttons",children:[Ie(fn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>r(Dg.png,A,{exportingFrame:P}),icon:Mm,children:g("imageExportDialog.button.exportToPng")}),Ie(fn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>r(Dg.svg,A,{exportingFrame:P}),icon:Mm,children:g("imageExportDialog.button.exportToSvg")}),(pr||mF)&&Ie(fn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await r(Dg.clipboard,A,{exportingFrame:P}),S()},icon:yr,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},qa=({label:e,children:o,tooltip:t,name:n})=>Tn("div",{className:"ImageExportModal__settings__setting",title:e,children:[Tn("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ie(Lt,{label:t,long:!0,children:S0})]}),Ie("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),M5=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=vn(()=>({appStateSnapshot:k5(o),elementsSnapshot:k5(e)}));return Ie(Ne,{onCloseRequest:i,size:"wide",title:!1,children:Ie(gF,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:n,onExportImage:r,name:a})})};import bF from"react";import{getFrame as xF}from"@excalidraw/common";import _g from"open-color";import{jsx as fF}from"react/jsx-runtime";var Rg=({children:e,color:o})=>fF("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":_g[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":_g[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":_g[o][9]},children:e});import{Fragment as yF,jsx as ro,jsxs as Pd}from"react/jsx-runtime";var EF=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return ro("div",{className:"ExportDialog ExportDialog--json",children:Pd("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Pd(Rg,{color:"lime",children:[ro("div",{className:"Card-icon",children:R1}),ro("h2",{children:g("exportDialog.disk_title")}),Pd("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!cr&&r.renderAction("changeProjectName")]}),ro(K,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(ua,"ui")}})]}),s&&Pd(Rg,{color:"pink",children:[ro("div",{className:"Card-icon",children:Wi}),ro("h2",{children:g("exportDialog.link_title")}),ro("div",{className:"Card-details",children:g("exportDialog.link_details")}),ro(K,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ne("export","link",`ui (${xF()})`),await s(e,o,n),l()}catch(m){t({errorMessage:m.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},L5=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=bF.useCallback(()=>{a({openDialog:null})},[a]);return ro(yF,{children:o.openDialog?.name==="jsonExport"&&ro(Ne,{onCloseRequest:l,title:g("buttons.export"),children:ro(EF,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import wF from"clsx";import{jsx as P5,jsxs as TF}from"react/jsx-runtime";var vF="small",A5=e=>TF("label",{className:wF("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${vF}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[P5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),P5("div",{className:"ToolIcon__icon",children:Xi})]});import{Fragment as R5,jsx as $,jsxs as Nt}from"react/jsx-runtime";var AF=({UIOptions:e})=>Nt(ct,{__fallback:!0,children:[$(ct.DefaultItems.LoadScene,{}),$(ct.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&$(ct.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&$(ct.DefaultItems.SaveAsImage,{}),$(ct.DefaultItems.SearchMenu,{}),$(ct.DefaultItems.Help,{}),$(ct.DefaultItems.ClearCanvas,{}),$(ct.Separator,{}),$(ct.Group,{title:"Excalidraw links",children:$(ct.DefaultItems.Socials,{})}),$(ct.Separator,{}),$(ct.DefaultItems.ToggleTheme,{}),$(ct.DefaultItems.ChangeCanvasBackground,{})]}),DF=()=>Nt(ad,{__fallback:!0,children:[$(ad.Actions.SaveToDisk,{}),$(ad.Actions.ExportToImage,{})]}),_F=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:m,renderTopRightUI:c,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:w,generateLinkForSelection:E})=>{let y=ce(),v=By(),C=v.tunnelsJotai.Provider,[S,L]=ie(qo),k=()=>p.canvasActions.export?$(L5,{elements:r,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:n}):null,A=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:$(M5,{elements:r,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>n({openDialog:null}),name:x.getName()}),P=()=>Nt("div",{style:{position:"relative"},children:[$(v.MainMenuTunnel.Out,{}),f&&$(v.WelcomeScreenMenuHintTunnel.Out,{})]}),N=()=>$(un,{heading:"selectedShapeActions",className:Ja("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:$(Ve,{className:CF.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:$(bc,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),O=()=>{let R=LF(o,r),V=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return $(Zc,{side:"top",children:Nt("div",{className:"App-menu App-menu_top",children:[Nt(je.Col,{gap:6,className:Ja("App-menu_top__left"),children:[P(),R&&N()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&$(un,{heading:"shapes",className:"shapes-section",children:Z=>Nt("div",{style:{position:"relative"},children:[f&&$(v.WelcomeScreenToolbarHintTunnel.Out,{}),$(je.Col,{gap:4,align:"start",children:Nt(je.Row,{gap:1,className:Ja("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Nt(Ve,{padding:1,className:Ja("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[$(jc,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),Z,Nt(je.Row,{gap:1,children:[$(qc,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),$(Kc,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),$("div",{className:"App-toolbar__divider"}),$($c,{checked:$t(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),$(xc,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),w&&$(Ve,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:$(A5,{title:g("toolBar.laser"),checked:o.activeTool.type===D5.laser,onChange:()=>x.setActiveTool({type:D5.laser}),isMobile:!0})})]})})]})}),Nt("div",{className:Ja("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&$(ed,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),c?.(y.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!J||o.openSidebar?.name!==Ng.name)&&$(v.DefaultSidebarTriggerTunnel.Out,{}),V&&$($a,{app:x,onClose:()=>{e.executeAction(Zr)},renderCustomStats:d})]})]})})},U=()=>$(cd,{__fallback:!0,onDock:R=>{ne("sidebar",`toggleDock (${R?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),J=Pl(Ua),_=Nt(R5,{children:[b,$(AF,{UIOptions:p}),$(cd.Trigger,{__fallback:!0,icon:gr,title:kF(g("toolBar.library")),onToggle:R=>{R&&ne("sidebar",`${Ng.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:Ng.defaultTab,children:g("toolBar.library")}),$(DF,{}),o.openDialog?.name==="ttd"&&$(pg,{__fallback:!0}),o.isLoading&&$(Xc,{delay:250}),o.errorMessage&&$(E5,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),S&&!y.editor.isMobile&&$(mb,{colorPickerType:S.colorPickerType,onCancel:()=>{L(null)},onChange:(R,V,Z,{altKey:W})=>{if(!(R!=="elementBackground"&&R!=="elementStroke"))if(Z.length){for(let se of Z)MF(se,SF(r),{[W&&S.swapPreviewOnAlt?R==="elementBackground"?"strokeColor":"backgroundColor":R==="elementBackground"?"backgroundColor":"strokeColor"]:V}),PF.delete(se);x.scene.triggerUpdate()}else n(R==="elementBackground"?{currentItemBackgroundColor:V}:{currentItemStrokeColor:V})},onSelect:(R,V)=>{L(Z=>Z?.keepOpenOnAlt&&V.altKey?Z:null),S?.onSelect?.(R,V)}}),o.openDialog?.name==="help"&&$(v5,{onClose:()=>{n({openDialog:null})}}),$(Vy,{}),o.openDialog?.name==="elementLinkSelector"&&$(x5,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),$(v.OverwriteConfirmDialogTunnel.Out,{}),A(),k(),o.pasteDialog.shown&&$(mv,{setAppState:n,appState:o,onClose:()=>n({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&$(cv,{app:x,appState:o,elements:r,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:A,setAppState:n,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:c,renderCustomStats:d,renderSidebars:U,device:y,renderWelcomeScreen:f,UIOptions:p}),!y.editor.isMobile&&Nt(R5,{children:[Nt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&J&&y.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&$(v.WelcomeScreenCenterTunnel.Out,{}),O(),$(gv,{appState:o,actionManager:e,showExitZenModeBtn:m,renderWelcomeScreen:f}),o.scrolledOutside&&$("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(R=>({...Dn(r,R)}))},children:g("buttons.scrollBackToContent")})]}),U()]})]});return $(Ym.Provider,{value:o,children:$(C,{children:$(zu.Provider,{value:v,children:_})})})},_5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:n,scrollX:r,scrollY:i,...a}=e;return a},RF=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...l}=o;return Ad(_5(n),_5(a),{selectedElementIds:Ad,selectedGroupIds:Ad})&&Ad(r,l)},N5=IF.memo(_F,RF);import NF from"clsx";import{jsx as B5,jsxs as FF}from"react/jsx-runtime";var BF="small",Dd=e=>FF("label",{className:NF("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${BF}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[B5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),B5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as OF,useRef as zF}from"react";import{jsx as F5}from"react/jsx-runtime";var O5=({trails:e})=>{let o=zF(null);return OF(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),F5("div",{className:"SVGLayer",children:F5("svg",{ref:o})})};import HF,{useEffect as GF,useRef as UF}from"react";import{CURSOR_TYPE as z5,isShallowEqual as YF,sceneCoordsToViewportCoords as WF}from"@excalidraw/common";import{jsx as KF}from"react/jsx-runtime";var VF=e=>{let o=UF(!1);return GF(()=>{if(!o.current){o.current=!0;return}let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,m)=>{if(s.selectedElementIds)for(let c of Object.keys(s.selectedElementIds))r.has(c)||r.set(c,[]),r.get(c).push(m);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(m,s.username),s.userState&&a.set(m,s.userState),n.set(m,WF({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(m,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";ww({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:n,remotePointerButton:t,remoteSelectedElementIds:r,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},xi())}),KF("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?z5.GRAB:z5.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:g("labels.drawingCanvas")})},H5=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,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,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,activeLockedId:e.activeLockedId}),XF=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:YF(H5(e.appState),H5(o.appState)),Bg=HF.memo(VF,XF);import ZF,{useEffect as G5,useRef as U5}from"react";import{isShallowEqual as Y5}from"@excalidraw/common";import{jsx as qF}from"react/jsx-runtime";var $F=e=>{let o=U5(null),t=U5(!1);return G5(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),G5(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static")),$f({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},xi())}),qF("div",{className:"excalidraw__canvas-wrapper",ref:o})},W5=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,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}),jF=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:Y5(W5(e.appState),W5(o.appState))&&Y5(e.renderConfig,o.renderConfig),Fg=ZF.memo($F,jF);import{useEffect as rO,useRef as iO}from"react";import{throttleRAF as JF}from"@excalidraw/common";import{getTargetFrame as QF,isInvisiblySmallElement as eO,renderElement as tO,shouldApplyFrameClip as oO}from"@excalidraw/element";var V5=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,m]=yl(e,i),c=wl({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:m});if(c.save(),c.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(eO(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=QF(t,n,a);p&&oO(t,p,a,n)&&Kf(p,c,l,a)}tO(t,n,r,o,c,l,a)}else c.clearRect(0,0,s,m);c.restore()}},nO=JF(e=>{V5(e)},{trailing:!0}),X5=(e,o)=>{if(o){nO(e);return}V5(e)};import{jsx as lO}from"react/jsx-runtime";var aO=e=>{let o=iO(null);return rO(()=>{o.current&&X5({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},xi())}),lO("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:o})},K5=aO;import{useCallback as sO,useEffect as cO,useRef as dO}from"react";import{jsx as Z5,jsxs as pO}from"react/jsx-runtime";var mO=5e3,$5=({message:e,onClose:o,closable:t=!1,duration:n=mO,style:r})=>{let i=dO(0),a=n!==1/0,l=sO(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return cO(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),pO("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[Z5("p",{className:"Toast__message",children:e}),t&&Z5(K,{icon:Bt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as uO,getElementsInGroup as hO,selectGroupsFromGivenElements as gO}from"@excalidraw/element";import{sceneCoordsToViewportCoords as fO}from"@excalidraw/common";import{flushSync as bO}from"react-dom";import{jsx as EO}from"react/jsx-runtime";var xO=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:hO(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=uO(n),{x:a,y:l}=fO({sceneX:r,sceneY:i},e.state);return EO("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{bO(()=>{let s=gO(n,e.state);e.setState({selectedElementIds:n.reduce((m,c)=>({...m,[c.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(xa)},title:g("labels.elementLock.unlock"),children:b1})},j5=xO;import{Fragment as gH,jsx as ue,jsxs as Hd}from"react/jsx-runtime";var JT=vo.createContext(null),QT=vo.createContext(null),eI={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},bf=vo.createContext(eI);bf.displayName="DeviceContext";var xf=vo.createContext({container:null,id:null});xf.displayName="ExcalidrawContainerContext";var Ef=vo.createContext([]);Ef.displayName="ExcalidrawElementsContext";var yf=vo.createContext({...Xo(),width:0,height:0,offsetLeft:0,offsetTop:0});yf.displayName="ExcalidrawAppStateContext";var wf=vo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});wf.displayName="ExcalidrawSetAppStateContext";var vf=vo.createContext(null);vf.displayName="ExcalidrawActionManagerContext";var _e=()=>Pn(JT),po=()=>Pn(QT),ce=()=>Pn(bf),He=()=>Pn(xf),Jo=()=>Pn(Ef),mo=()=>Pn(yf),le=()=>Pn(wf),Ge=()=>Pn(vf),al=!1,mf=0,ll=null,rr=!1,sl=!1,pf=!1,cl={horizontal:null,vertical:null},Ln=0,dl=!1,uf=new Map,hf=!1,ZT=0,$T=!1,ml=null,pe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},ff=class e extends vo.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"device",eI);I(this,"excalidrawContainerRef",vo.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"resizeObserver");I(this,"nearestScrollableContainer");I(this,"library");I(this,"libraryItemsFromStorage");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"handleToastClose",()=>{this.setToast(null)});I(this,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new Uz);I(this,"flowChartNavigator",new Yz);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastViewportPosition",{x:0,y:0});I(this,"animationFrameHandler",new Dc);I(this,"laserTrails",new Gc(this.animationFrameHandler,this));I(this,"eraserTrail",new Vc(this.animationFrameHandler,this));I(this,"lassoTrail",new Wc(this.animationFrameHandler,this));I(this,"onChangeEmitter",new tr);I(this,"onPointerDownEmitter",new tr);I(this,"onPointerUpEmitter",new tr);I(this,"onUserFollowEmitter",new tr);I(this,"onScrollChangeEmitter",new tr);I(this,"missingPointerEventCleanupEmitter",new tr);I(this,"onRemoveEventListenersEmitter",new tr);I(this,"defaultSelectionTool","selection");I(this,"updateEditorAtom",(t,...n)=>{let r=ze.set(t,...n);return this.triggerRender(),r});I(this,"getEffectiveGridSize",()=>dn(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),il.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(Uo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=tf(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else _i(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Fe({clientX:i.x,clientY:i.y},this.state),l=Fe({clientX:i.right,clientY:i.bottom},this.state);return n={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,n),n}return null}return n},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===Nd.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&St(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!kT(i,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===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=Fd({sceneX:i.x,sceneY:i.y},this.state),s=6,m,c=Bz(i);if(i.id===this.state.editingFrame){let d=c;m=ue("input",{autoFocus:!0,value:d,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===Y.ESCAPE||p.key===Y.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?zO:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Cn.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:d.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else m=c;return ue("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Cn.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Cn.nameFontSize,color:t?Cn.nameColorDarkTheme:Cn.nameColorLightTheme,lineHeight:Cn.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Ae.MOVE,pointerEvents:this.state.viewModeEnabled?Pi.disabled:Pi.enabled},onPointerDown:d=>this.handleCanvasPointerDown(d),onWheel:d=>this.handleWheel(d),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:m},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,n,r)=>{ne("export",t,"ui");let i=await Un(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(tz).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Tl(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:wo.magicframe}),ne("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&Qg(t[0])&&t[0];if(!n&&t.some(i=>St(i)||i.frameId)){this.setActiveTool({type:wo.magicframe});return}ne("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=Di(t),m=50;r=ET({...Cn,x:i-m,y:a-m,width:l-i+m*2,height:s-a+m*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let c of t)this.scene.mutateElement(c,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(qo,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:gt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:gt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?Mn(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:gt.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Le(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||Nd.LIGHT,s=t?.appState?.name??this.state.name,m=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(c=>{r?.id===c.id&&r!==c&&WT(c)&&io(c)&&(r=c)}),r?.isDeleted&&(r=null),this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:m}}),n=!0}n||this.scene.triggerUpdate()}));I(this,"onBlur",Le(()=>{rr=!1,this.setState({isBindingEnabled:!0})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Le(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Xo(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async i=>{if(!i.files.length)return;let a=i.files[0],l=await a.getFile();this.loadFileToCanvas(new File([l],l.name||"",{type:l.type}),a)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(i=>{console.error(i)})}catch(i){console.error(i),t={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let n=mr(t,null,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=n.appState.activeTool;n.appState={...n.appState,theme:this.props.theme||n.appState.theme,openSidebar:n.appState?.openSidebar||this.state.openSidebar,activeTool:r.type==="image"||r.type==="lasso"||r.type==="selection"?{...r,type:this.defaultSelectionTool}:n.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(n.appState={...n.appState,...Dn(n.elements,{...n.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...n,captureUpdate:gt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),cf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileOrTablet",()=>{let t="ontouchstart"in window||navigator.maxTouchPoints>0,n="matchMedia"in window&&window?.matchMedia("(pointer: coarse)")?.matches;return lz||t&&n});I(this,"isMobileBreakpoint",(t,n)=>t<RO||n<DO&&t<_O);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:n,clientHeight:r}=document.body,i=this.device.viewport,a=Vg(i,{isLandscape:n>r,isMobile:this.isMobileBreakpoint(n,r)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:NO,a=this.device.editor,l=Vg(a,{isMobile:this.isMobileBreakpoint(n,r),canFitSidebar:n>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Le(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>il.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),sT||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(cl=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",mT(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},BO));I(this,"onCut",Le(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||el(t.target)||(this.actionManager.executeAction(Gs,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Le(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||el(t.target)||(this.actionManager.executeAction(Xr,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(YO&&t.preventDefault(),!al){al=!0,t.touches.length===1&&(ll={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(mf),mf=window.setTimeout(e.resetTapTwice,FO);return}if(al&&t.touches.length===1&&ll){let n=t.touches[0];In(re(n.clientX,n.clientY),re(ll.x,ll.y))<=sz&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),al=!1,clearTimeout(mf)}t.touches.length===2&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}):pe.pointers.clear()});I(this,"pasteFromClipboard",Le(async t=>{let n=!!hf,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||el(r)))return;let l=await im(t),s=await Ml(t,n);if(this.props.onPaste)try{if(await this.props.onPaste(s,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(s,l,n),this.setActiveTool({type:this.defaultSelectionTool},!0),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let n=em(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=Di(n),s=Ai(r,a)/2,m=Ai(i,l)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Fe({clientX:c,clientY:d},this.state),f=p-s,b=u-m,[x,w]=nt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=vT({type:"everything",elements:n.map(k=>Mn(k,{x:k.x+x-r,y:k.y+w-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,zT(v,Od(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let k=Oz(E,S);af(v,k,S,this.state)}this.scene.replaceAllElements(v),E.forEach(k=>{if(io(k)&&Jg(k)){let A=DT(k,this.scene.getElementsMapIncludingDeleted());Pz(k,A,this.scene)}}),XO&&Vo.loadElementsFonts(E).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let L=rH(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&ze.get(Ua)?this.state.openSidebar:null,...Kt({editingGroupId:null,selectedElementIds:L.reduce((k,A)=>(Jg(A)||(k[A.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.defaultSelectionTool},!0),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,n)=>{this.setState(t,n)});I(this,"removePointer",t=>{Ln&&this.resetContextMenuTimer(),pe.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ne("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...Go(this.state,n.activeTool.locked?{type:this.defaultSelectionTool}:n.activeTool),locked:!n.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(sx)});I(this,"zoomCanvas",t=>{this.setState({...ko({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:lo(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if(cf(t)?s=Xz(t):s=t,s){let m=this.scene.getElementsFromId(s);m?.length?this.scrollToContent(m,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):cf(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=sa({canvasOffsets:n.canvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=Dn(r,this.state);a=s.scrollX,l=s.scrollY}if(n?.animate){let s=this.state.scrollX,m=this.state.scrollY,c=this.state.zoom.value,d=ez({fromValues:{scrollX:s,scrollY:m,zoom:c},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,oz(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});I(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});I(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});I(this,"setToast",t=>{this.setState({toast:t})});I(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,CO,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Le(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===Sn.svg))try{let s=o1(AT(n1(l.dataURL)),Sn.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});I(this,"updateScene",Le(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=n||void 0,s=r?cz({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));I(this,"applyDeltas",(t,n)=>{let r=XT.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return XT.applyTo(r,a,i,n)});I(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Le(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));I(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,n=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),r=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Io().rtl?{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width),0)+i,bottom:i,left:Math.max(n?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});I(this,"onKeyDown",Le(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!pT(t.target)){if((t.key===Y.ESCAPE||t.key===Y.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=j(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&or(a[0])&&t.key===Y.ENTER){this.startImageCropping(a[0]);return}if(t.key===Y.ESCAPE)this.updateEditorAtom(eo,null);else if(t.key===Y.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(az.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=ei(a);ze.get(eo)?.type==="panel"&&fu(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(eo,{type:"panel"})}if(t.key===Y.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=_d(t.key);if(t[Y.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=j(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&vz(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,BT(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!ef(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(t.altKey){let s=j(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),BT(t.key));if(m){this.setState(d=>({selectedElementIds:ye({[m]:!0},d)}));let c=this.scene.getNonDeletedElementsMap().get(m);c&&!ef([c],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(c,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[Y.CTRL_OR_CMD]&&t.key===Y.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Re("commandPalette")})}),t.preventDefault();return}if(t[Y.CTRL_OR_CMD]&&t.key.toLowerCase()===Y.V&&(hf=t.shiftKey,clearTimeout(ZT),ZT=window.setTimeout(()=>{hf=!1},100)),t[Y.CTRL_OR_CMD]&&el(t.target)&&(t.code===nT.MINUS||t.code===nT.EQUAL)){t.preventDefault();return}if(el(t.target)&&t.key!==Y.ESCAPE||_d(t.key)&&pT(t.target))return;if(t.key===Y.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===Y.E&&t.shiftKey&&t[Y.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===Y.PAGE_UP||t.key===Y.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===Y.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[Y.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),_d(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(Ye),s=new Set;a.filter(Ye).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let m=this.getEffectiveGridSize()&&(t.shiftKey?aT:this.getEffectiveGridSize())||(t.shiftKey?MO:aT),c=0,d=0;t.key===Y.ARROW_LEFT?c=-m:t.key===Y.ARROW_RIGHT?c=m:t.key===Y.ARROW_UP?d=-m:t.key===Y.ARROW_DOWN&&(d=m),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+c,y:p.y+d},{informMutation:!1,isDragging:!1}),Zg(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:$g(a.filter(p=>p.id!==l?.id||m!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===Y.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[Y.CTRL_OR_CMD]||df(l))Xt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Ye(l)||this.actionManager.executeAction(hi));else if(io(l)||Lz(l)){let s;io(l)||(s=l);let m=nf(l,this.state,this.scene.getNonDeletedElementsMap()),c=m.x,d=m.y;this.startTextEditing({sceneX:c,sceneY:d,container:s}),t.preventDefault();return}else St(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=Ny(t.key,this);a?(this.state.activeTool.type!==a&&ne("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===kn.sharp?kn.round:l.currentItemArrowType===kn.round?kn.elbow:kn.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===Y.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===Y.SPACE&&pe.pointers.size===0&&(rr=!0,xe(this.interactiveCanvas,Ae.GRAB),t.preventDefault()),(t.key===Y.G||t.key===Y.S)&&!t.altKey&&!t[Y.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===Y.G&&(Wo(this.state.activeTool.type)||a.some(l=>Wo(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===Y.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[Y.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===Y.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>io(l)||of(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===Y.K&&!t.altKey&&!t[Y.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.defaultSelectionTool}):this.setActiveTool({type:"laser"});return}t[Y.CTRL_OR_CMD]&&(t.key===Y.BACKSPACE||t.key===Y.DELETE)&&this.updateEditorAtom(Zn,"clearCanvas");let n=t.key.toLocaleLowerCase(),r=n===Y.S&&t.shiftKey,i=t.key===Y.I||n===Y.G&&t.shiftKey;(r||i)&&this.openEyeDropper({type:r?"stroke":"background"})}));I(this,"onKeyUp",Le(t=>{if(t.key===Y.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,Ae.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?zt(this.interactiveCanvas):(Pt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),rr=!1),!t[Y.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),_d(t.key)&&(bT(this.scene.getSelectedElements(this.state).filter(Xt),Kg(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:gt.IMMEDIATELY})),!t[Y.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:ye({[n.id]:!0},r)})),ef([n],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:gt.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=Go(this.state,t);r.type==="hand"?xe(this.interactiveCanvas,Ae.GRAB):rr||Pt(this.interactiveCanvas,{...this.state,activeTool:r}),jO(document.activeElement)&&this.focusContainer(),yz(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,activeTool:r,...n?{}:{selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null},...a}:r.type!=="selection"?{...i,activeTool:r,selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:r,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{xe(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{zt(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>pe.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${uT()}`);I(this,"onGestureStart",Le(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null}),pe.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Le(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=pe.initialScale;n&&this.setState(r=>({...ko({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:lo(n*t.scale)},r)}))}));I(this,"onGestureEnd",Le(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}),pe.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&s&&(of(i,this.scene.getNonDeletedElementsMap())||(l=!0));let m=null,c=this.scene.getSelectedElements(this.state);c.length===1?io(c[0])?m=c[0]:i?m=of(c[0],this.scene.getNonDeletedElementsMap()):m=this.getTextElementAtPosition(t,n):m=this.getTextElementAtPosition(t,n);let d=m?.fontFamily||this.state.currentItemFontFamily,p=m?.lineHeight||dT(d),u=this.state.currentItemFontSize;if(!m&&l&&i&&!jg(i)){let w=jz(Yg({fontSize:u,fontFamily:d}),p),E=qz(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),t=i.x+v/2,n=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),b=m||yT({x:s?s.elementCenterX:t,y:s?s.elementCenterY:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?GO.MIDDLE:iT,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?jg(i)?0:i.angle:0,frameId:f?f.id:null});if(!m&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!m)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||m||i?this.handleTextWysiwyg(b,{isExistingElement:!!m}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.defaultSelectionTool)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=Fe(t,this.state);if(n.length===1&&Xt(n[0])){let l=n[0];if((t[Y.CTRL_OR_CMD]&&uH(l)||df(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(hi);return}else if(this.state.selectedLinearElement&&Ye(n[0])){let s=Ce.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=s?Ce.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(m&&m>-1){this.store.scheduleCapture(),Ce.deleteFixedSegment(n[0],this.scene,m);let c=Ce.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=c?Ce.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:d,value:s,added:!1}},segmentMidPointHoveredCoords:c}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&df(l))return}if(n.length===1&&or(n[0])){this.startImageCropping(n[0]);return}if(zt(this.interactiveCanvas),oH(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&tH(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(m=>({...m,...Kt({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),m,this)}));return}}if(zt(this.interactiveCanvas),!t[Y.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(nl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(TT(s)||!QO(s.backgroundColor)||rl({point:re(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let m=nf(s,this.state,this.scene.getNonDeletedElementsMap());r=m.x,i=m.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(n&&l.id===n.id&&(i=a),l.link&&a>=i&&El(l,this.scene.getNonDeletedElementsMap(),this.state,re(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,n)=>{let r=In(re(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),re(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>kO)return;let i=Fe(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=El(this.hitLinkElement,a,this.state,re(i.x,i.y),this.device.editor.isMobile),s=Fe(this.lastPointerUpEvent,this.state),m=El(this.hitLinkElement,a,this.state,re(s.x,s.y),this.device.editor.isMobile);if(l&&m){iu();let c=this.hitLinkElement.link;if(c){c=Ug(c);let d;if(this.props.onLinkOpen&&(d=qO(ee.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let p=KO(c)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=c)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&_T(t,i,n));return r.length?r[r.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,pe.pointers.has(t.pointerId)&&pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let n=pe.initialScale;if(pe.pointers.size===2&&pe.lastCenter&&n&&pe.initialDistance){let f=fh(pe.pointers),b=f.x-pe.lastCenter.x,x=f.y-pe.lastCenter.y;pe.lastCenter=f;let w=bh(Array.from(pe.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/pe.initialDistance,y=E?lo(n*E):this.state.zoom.value;this.setState(v=>{let C=ko({viewportX:f.x,viewportY:f.y,nextZoom:y},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/y),scrollY:C.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else pe.lastCenter=pe.initialDistance=pe.initialScale=null;if(rr||sl||pf||$t(this.state))return;let i=Ch(cl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?zt(this.interactiveCanvas):Pt(this.interactiveCanvas,this.state));let a=Fe(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&ew(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=Q2(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=tl(x.snapLines,b),E=x.originSnapOffset?tl(x.originSnapOffset,f):f;return x.snapLines===w&&x.originSnapOffset===E?null:{snapLines:w,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=Ce.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&Li(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&IT(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(IT(this.state.activeTool.type)){let{newElement:f}=this.state;qg(f,!1)?this.setState({suggestedBindings:gT(f,[a],this.scene,this.state.zoom,this.state.startBoundElement)}):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:f}=this.state,{x:b,y:x}=f,{points:w,lastCommittedPoint:E}=f,y=w[w.length-1];if(Pt(this.interactiveCanvas,this.state),y===E)In(re(l-b,s-x),y)>=Gg?this.scene.mutateElement(f,{points:[...w,re(l-b,s-x)]},{informMutation:!1,isDragging:!1}):xe(this.interactiveCanvas,Ae.POINTER);else if(w.length>2&&E&&In(re(l-b,s-x),E)<Gg)xe(this.interactiveCanvas,Ae.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=nt(l,s,t[Y.CTRL_OR_CMD]||Ye(f)?null:this.getEffectiveGridSize()),[S,L]=f?.lastCommittedPoint??[0,0],k=v-b-S,A=C-x-L;Hg(t)&&({width:k,height:A}=ST(S+b,L+x,v,C)),LT(w,this.state.zoom.value)&&xe(this.interactiveCanvas,Ae.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),re(S+k,L+A)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&Ye(d[0]))){let f=GT(c,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){xe(this.interactiveCanvas,HT(f));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=UT(Di(d),l,s,this.state.zoom,t.pointerType,this.device);if(f){xe(this.interactiveCanvas,HT({transformHandleType:f}));return}}let p=this.getElementAtPosition(l,s,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p,this.hitLinkElement=this.getElementLinkAtPosition(a,p),!ft(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(xe(this.interactiveCanvas,Ae.POINTER),fE(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(iu(),u&&(u.link||Uo(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?xe(this.interactiveCanvas,io(u)?Ae.TEXT:Ae.CROSSHAIR):this.state.viewModeEnabled?xe(this.interactiveCanvas,Ae.GRAB):this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,Ae.AUTO):i?xe(this.interactiveCanvas,Ae.AUTO):t[Y.CTRL_OR_CMD]?xe(this.interactiveCanvas,Ae.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!u?.locked&&(u&&nl(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(xe(this.interactiveCanvas,Ae.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!Ye(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||d.length>0)&&xe(this.interactiveCanvas,Ae.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s)),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:tl(f.hoveredElementIds,Kt({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:tl(f.hoveredElementIds,{})})))});I(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});I(this,"handleTouchMove",t=>{dl=!0});I(this,"handleCanvasPointerDown",t=>{let n=t.target;if(n.setPointerCapture&&n.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches&&{focusedId:null,matches:d.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(ag,null)),ze.get(eo)&&this.updateEditorAtom(eo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let d=this.state.newElement;this.updateScene({...d.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==d.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:ye(Object.keys(this.state.selectedElementIds).filter(p=>p!==d.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?gt.EVENTUALLY:gt.NEVER});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(d=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Vg(this.device,{isTouchScreen:!0})),sl||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===er.ERASER&&this.state.activeTool.type!==wo.eraser){this.setState({activeTool:Go(this.state,{type:wo.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),ft(this.state)&&this.setState({activeTool:Go(this.state,{...this.state.activeTool.lastActiveTool||{type:wo.selection},lastActiveToolBeforeEraser:null})})},p=De(window,ee.POINTER_UP,d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==er.MAIN&&t.button!==er.TOUCH&&t.button!==er.ERASER||pe.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let d=i.hit.element&&this.isASelectedElement(i.hit.element),p=this.isMobileOrTablet();!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!d&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey),i.drag.blockDragging=!p),p&&i.hit.element&&!d&&(this.setState(u=>{let f={...u.selectedElementIds,[i.hit.element.id]:!0},b=[];Object.keys(u.selectedElementIds).forEach(w=>{let E=this.scene.getElement(w);E&&b.push(E)});let x=i.hit.element;if(St(x))rf(b,x.id).forEach(w=>{delete f[w.id]});else if(x.frameId)f[x.frameId]&&delete f[x.id];else{let w=x.groupIds,E=new Set(w.flatMap(y=>nr(this.scene.getNonDeletedElements(),y)).filter(y=>St(y)).map(y=>y.id));E.size>0&&b.forEach(y=>{y.frameId&&E.has(y.frameId)&&(delete f[y.id],y.groupIds.flatMap(v=>nr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete f[v.id]}))})}return{...Kt({editingGroupId:u.editingGroupId,selectedElementIds:f},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:x.link||Uo(x)?"info":!1}}),i.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Pt(this.interactiveCanvas,this.state):this.state.activeTool.type===wo.frame||this.state.activeTool.type===wo.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),m=this.onKeyDownFromPointerDownHandler(i),c=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(d=>s(d||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(ee.POINTER_MOVE,l),window.addEventListener(ee.POINTER_UP,s),window.addEventListener(ee.KEYDOWN,m),window.addEventListener(ee.KEYUP,c),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=c,i.eventListeners.onKeyDown=m)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let n=Fe({clientX:t.clientX,clientY:t.clientY},this.state),r=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&r<300){let i=this.getElementAtPosition(n.x,n.y);if(nl(i)&&this.isIframeLikeElementCenter(i,t,n.x,n.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?r<300&&nl(this.hitLinkElement)&&!Yf(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,re(n.x,n.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(dl=!1,Ln?dl=!0:Ln=window.setTimeout(()=>{Ln=0,dl||this.handleCanvasContextMenu(t)},HO))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Ln),Ln=0,dl=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{ml?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(pe.pointers.size<=1&&(t.button===er.WHEEL||t.button===er.MAIN&&rr||$t(this.state)||this.state.viewModeEnabled)))return!1;sl=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);xe(this.interactiveCanvas,Ae.GRABBING);let{clientX:i,clientY:a}=t,l=Uc(m=>{let c=i-m.clientX,d=a-m.clientY;if(i=m.clientX,a=m.clientY,r&&!n&&(Math.abs(c)>1||Math.abs(d)>1)){n=!0;let p=f=>{document.body.removeEventListener(ee.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ee.PASTE,p),window.removeEventListener(ee.POINTER_UP,u)},100)};document.body.addEventListener(ee.PASTE,p),window.addEventListener(ee.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=Le(ml=()=>{ml=null,sl=!1,rr||(this.state.viewModeEnabled?xe(this.interactiveCanvas,Ae.GRAB):Pt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,l),window.removeEventListener(ee.POINTER_UP,s),window.removeEventListener(ee.BLUR,s),l.flush()});return window.addEventListener(ee.BLUR,s),window.addEventListener(ee.POINTER_MOVE,l,{passive:!0}),window.addEventListener(ee.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,n)=>{if(this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Ye(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=GT(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType))}else a.length>1&&(n.resize.handleType=UT(Di(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.device));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=Wg(aH(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&Xt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=lH(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Ce.handlePointerDown(t,this,this.store,n.origin,p,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),m=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!m||m.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),m&&m.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,m),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=s;let c=n.hit.element,d=n.hit.allHitElements.some(p=>this.isASelectedElement(p));if((c===null||!d)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(c),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:ye({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(c!=null){if(t[Y.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[c.id]||(n.hit.wasAddedToSelection=!0),this.setState(p=>({...eH(p,c),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[c.id]||(this.state.editingGroupId&&!OT(c,this.state.editingGroupId)&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!d&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[c.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),St(c))rf(f,c.id).forEach(b=>{delete u[b.id]});else if(c.frameId)u[c.frameId]&&delete u[c.id];else{let b=c.groupIds,x=new Set(b.flatMap(w=>nr(this.scene.getNonDeletedElements(),w)).filter(w=>St(w)).map(w=>w.id));x.size>0&&f.forEach(w=>{w.frameId&&x.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(E=>nr(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(c.groupIds.some(b=>p.selectedGroupIds[b])||(u={[c.id]:!0})),{...Kt({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:c.link||Uo(c)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,a=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);TT(a)&&(l=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),zt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Go(this.state,{type:this.defaultSelectionTool})})});I(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=nt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,m=uz({type:n,x:i,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:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[re(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(m),this.setState(d=>{let p={...d.selectedElementIds};return delete p[m.id],{selectedElementIds:ye(p,d)}});let c=Xg(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:m,startBoundElement:c,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,l]=nt(t,n,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=hz({type:"iframe",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("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.scene.insertElement(s),s});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=nt(t,n,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=zd(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=xT({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:r});return this.scene.insertElement(s),s});I(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=nt(t,n,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return bz({type:"image",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:l?l.id:null,x:i-s/2,y:a-s/2,width:s,height:s})});I(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&LT(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(At);return}if(Ye(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(At);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&In(re(r.origin.x-a,r.origin.y-l),s)<Gg){this.actionManager.executeAction(At);return}this.setState(m=>({selectedElementIds:ye({...m.selectedElementIds,[i.id]:!0},m)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),xe(this.interactiveCanvas,Ae.POINTER)}else{let[i,a]=nt(r.origin.x,r.origin.y,t[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:m}=this.state,[c,d]=n==="arrow"?[s,m]:[null,null],p=n==="arrow"?gz({type:n,x:i,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.state.currentItemArrowType===kn.round?{type:Rd.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===kn.elbow,fixedSegments:this.state.currentItemArrowType===kn.elbow?[]:null}):xz({type:n,x:i,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.state.currentItemRoundness==="round"?{type:Rd.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:ye(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,re(0,0)]});let u=Xg(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,Ye(p),Ye(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=nt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),l={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=xT({type:"embeddable",...l}):s=fz({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=nt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Cn},l=n===wo.magicframe?ET(a):pz(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1,n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||Jg(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Mn(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});I(this,"initializeImage",async(t,n)=>{if(!Il(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type;if(xe(this.interactiveCanvas,"wait"),r===Sn.svg)try{n=rm(AT(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||t1(n));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{n=await Sl(n,{maxWidthOrHeight:SO})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>lT)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(lT/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await nm(n);return new Promise(async(s,m)=>{try{let c=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([c]);if(p.size)throw new Error("Image cache update resulted with an error.")}let d=await this.imageCache.get(i)?.image;if(d&&this.state.newElement?.id!==c.id){c=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(c,d);Object.assign(c,p)}s(c)}catch(c){console.error(c),m(new Error(g("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return Mn(r,{fileId:n})});I(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Fe({clientX:t,clientY:n},this.state),a=await bl({description:"Image",extensions:Object.keys(LO),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Go(this.state,{type:this.defaultSelectionTool})},()=>{this.actionManager.executeAction(At)})}});I(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(n.naturalHeight,i),l=a*(n.naturalWidth/n.naturalHeight),s=t.x+t.width/2-l/2,m=t.y+t.height/2-a/2;return{x:s,y:m,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await Mz({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(gt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>ol(a)&&i.has(a.fileId)?Mn(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=kz(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let a of r)i.has(a.fileId)&&il.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",yO(()=>{this.addNewImagesToImageCache()},PO));I(this,"updateBindingEnabledOnPointerMove",t=>{let n=mz(t);this.state.isBindingEnabled!==n&&this.setState({isBindingEnabled:n})});I(this,"maybeSuggestBindingAtCursor",(t,n)=>{let r=Xg(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,n);this.setState({suggestedBindings:r!=null?[r]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(ee.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ee.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ee.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ee.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=KT(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);a.forEach(p=>this.scene.insertElement(p));let l=await Promise.all(a.map(async(p,u)=>{try{return await this.initializeImage(p,t[u])}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),Mn(p,{isDeleted:!0})}})),s=Od(l),m=KT(l.filter(p=>!p.isDeleted),n,r,i),c=Od(m),d=this.scene.getElementsIncludingDeleted().map(p=>c.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:ye(Object.fromEntries(m.map(p=>[p.id,!0])),this.state)},elements:d,captureUpdate:gt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(At)})});I(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=Fe(t,this.state),i=await im(t);if(i.length===1){let{file:s,fileHandle:m}=i[0];if(s&&(s.type===Sn.png||s.type===Sn.svg))try{let c=await Cl(s,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...c,appState:{...c.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:gt.IMMEDIATELY});return}catch(c){if(c.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}}let a=i.map(s=>s.file).filter(s=>Il(s));if(a.length>0&&this.isToolSupported("image"))return this.insertImages(a,n,r);let l=t.dataTransfer.getData(Sn.excalidrawlib);if(l&&typeof l=="string"){try{let s=e1(l);this.addElementsFromPasteOrLibrary({elements:rc(s),position:t,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(i.length>0){let{file:s,fileHandle:m}=i[0];s&&await this.loadFileToCanvas(s,m)}if(t.dataTransfer?.types?.includes("text/plain")){let s=t.dataTransfer?.getData("text");if(s&&tf(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||zd(s)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:Ug(s)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,n)=>{t=await i1(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await tm(t,this.state,r,n)}catch(a){let l=a instanceof Hf;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===Sn.excalidraw?(qT(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:gt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:gt.IMMEDIATELY})):i.type===Sn.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==er.SECONDARY)&&this.state.activeTool.type!==this.defaultSelectionTool)return;let{x:n,y:r}=Fe(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,y:r},a),s=i||l?"element":"canvas",m=this.excalidrawContainerRef.current,{top:c,left:d}=m.getBoundingClientRect(),p=t.clientX-d,u=t.clientY-c;ne("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...Kt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Xt(i)?new Ce(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){YT({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Ai(t.origin.x,a.x),height:Ai(t.origin.y,a.y),shouldMaintainAspectRatio:Qa(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,m]=nt(a.x,a.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=ol(l)&&this.imageCache.get(l.fileId)?.image,d=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:p,snapLines:u}=J2(l,this,n,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:m-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,m+=p.y,this.setState({snapLines:u}),YT({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:m,width:Ai(t.originInGrid.x,s),height:Ai(t.originInGrid.y,m),shouldMaintainAspectRatio:or(l)?!Qa(n):Qa(n),shouldResizeFromCenter:rT(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===wo.frame||this.state.activeTool.type===wo.magicframe)&&this.setState({elementsToHighlight:lf(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=nt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&or(s)){let m=t.originalElements.get(s.id),c=ol(s)&&this.imageCache.get(s.fileId)?.image;if(m&&or(m)&&c&&!(c instanceof Promise)){let[d,p]=nt(i.x,i.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:f,snapLines:b}=wh([s],[m],this,n,u,r);this.scene.mutateElement(s,Wz(s,this.scene.getNonDeletedElementsMap(),r,c.naturalWidth,c.naturalHeight,a+f.x,l+f.y,n.shiftKey?m.width/m.height:void 0)),Zg(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:r&&r!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(d=>St(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Ye(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,m]=nt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(i.forEach(d=>{rf(this.scene.getNonDeletedElements(),d.id).forEach(u=>{c.set(d.id+u.id,{x:u.x-d.x,y:u.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,p]=nt(l.x,l.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:b,snapLines:x}=wh(r,j(f,this.state),this,n,u,a);s+=b.x,m+=b.y,this.setState({snapLines:x})}if(sH(t.originalElements,a,r,this.scene,Hg(n),rT(n),r.some(d=>or(d))?!Qa(n):Qa(n),s,m,t.resize.center.x,t.resize.center.y)){let d=$g(r,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{lf(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});I(this,"getContextMenuItems",t=>{let n=[];return n.push(Ys,Us),t==="canvas"?this.state.viewModeEnabled?[...n,Vs,Kr,hh,Zr]:[Vp,Ue,Ys,Us,Ws,Ue,Hm,vE,Ue,Vs,Xp,Kr,hh,Zr]:(n.push(Ws),this.state.viewModeEnabled?[Xr,...n]:[Ue,Gs,Xr,Vp,Ue,P2,A2,D2,Ue,dh,Ue,...n,Ue,Rp,Np,Ue,Op,z2,$p,jp,lE,zp,Ue,Up,Ue,Bm,Fm,Om,zm,Ue,Yp,Wp,Ue,hi,Ue,ba,Qs,Ue,Gm,xa,Ue,ji])});I(this,"handleWheel",Le(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[Y.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),sl)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),a=UO*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let m=this.state.zoom.value-s/100;m+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(c=>({...ko({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:lo(m)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-n/i.value,scrollY:l-r/i.value}))}));I(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:a}=Fe({clientX:t,clientY:n},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:r,pointersMap:pe.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",mT(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=n.getBoundingClientRect(),{width:s,height:m,offsetTop:c,offsetLeft:d}=this.state;if(r===s&&i===m&&a===d&&l===c){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let n=Xo();this.defaultSelectionTool=this.isMobileOrTablet()?"lasso":"selection";let{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:m=n.theme,name:c=`${g("labels.untitled")}-${uT()}`}=t;if(this.state={...n,theme:m,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??n.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.id=vO(),this.library=new ZE(this),this.actionManager=new Ac(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new VT,this.canvas=document.createElement("canvas"),this.rc=wO.canvas(this.canvas),this.renderer=new za(this.scene),this.visibleElements=[],this.store=new mH(this),this.history=new Ra(this.store),r){let d={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},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:p=>this.onChangeEmitter.on(p),onIncrement:p=>this.store.onStoreIncrementEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof r=="function"?r(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Vo(this.scene),this.history=new Ra(this.store),this.actionManager.registerAll(es),this.actionManager.registerAction(N2(this.history)),this.actionManager.registerAction(B2(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(Bd).includes(i)&&uf.set(r,i)}break}}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),_i(t)))return;let n=this.getHTMLIFrameElement(t);if(n?.contentWindow){if(n.src.includes("youtube")){let r=uf.get(t.id);switch(r||(uf.set(t.id,Bd.UNSTARTED),n.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),r){case Bd.PLAYING:case Bd.BUFFERING:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}n.src.includes("player.vimeo.com")&&n.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Uo(a)&&this.embedsValidationStatus.get(a.id)===!0||_i(a));return ue(gH,{children:i.map(a=>{let{x:l,y:s}=Fd({sceneX:a.x,sceneY:a.y},this.state),m=kT(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(a.id);if(m&&!c&&this.initializedEmbeds.add(a.id),!(m||c))return null;let p;if(_i(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>PT(`
24
+ C -->|Three| F[Car]`,$3=uB(nl,300),fB=({mermaidToExcalidrawLib:e})=>{let[o,t]=X3(()=>Ut.get(pB.MERMAID_TO_EXCALIDRAW)||gB),r=mB(o.trim()),[n,i]=X3(null),a=K3(null),l=K3({elements:[],files:null}),s=Re();Z3(()=>{Pd({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(c=>{hB()&&console.error("Failed to parse mermaid definition",c)}),$3(r)},[r,e]),Z3(()=>()=>{$3.flush()},[]);let m=()=>{Ad({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return j3(bB,{children:[Io("div",{className:"ttd-dialog-desc",children:Io(ut,{i18nKey:"mermaid.description",flowchartLink:c=>Io("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:c}),sequenceLink:c=>Io("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:c}),classLink:c=>Io("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:c})})}),j3(Md,{children:[Io(Pi,{label:g("mermaid.syntax"),children:Io(Cd,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:c=>t(c.target.value),onKeyboardSubmit:()=>{m()}})}),Io(Pi,{label:g("mermaid.preview"),panelAction:{action:()=>{m()},label:g("mermaid.button"),icon:kn},renderSubmitShortcut:()=>Io(Ld,{}),children:Io(kd,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},q3=fB;import*as Q3 from"@radix-ui/react-tabs";import{useRef as J3}from"react";import{isMemberOf as xB}from"@excalidraw/common";import{jsx as EB}from"react/jsx-runtime";var eT=e=>{let o=le(),t=J3(null),r=J3(0);return EB(Q3.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>r.current&&(r.current=a,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&xB(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};eT.displayName="TTDDialogTabs";var tT=eT;import*as oT from"@radix-ui/react-tabs";import{jsx as yB}from"react/jsx-runtime";var Sg=({children:e,...o})=>yB(oT.List,{className:"ttd-dialog-triggers",...o,children:e});Sg.displayName="TTDDialogTabTriggers";import*as nT from"@radix-ui/react-tabs";import{jsx as rT}from"react/jsx-runtime";var Dd=({children:e,tab:o,onSelect:t,...r})=>rT(nT.Trigger,{value:o,asChild:!0,onSelect:t,children:rT("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});Dd.displayName="TTDDialogTabTrigger";import*as iT from"@radix-ui/react-tabs";import{jsx as wB}from"react/jsx-runtime";var _d=({tab:e,children:o,...t})=>wB(iT.Content,{...t,value:e,children:o});_d.displayName="TTDDialogTab";import{jsx as gt,jsxs as Ir}from"react/jsx-runtime";var Mg=3,Ai=1e3,TB=me(null),IB=me(null),Lg=e=>{let o=ge();return o.openDialog?.name!=="ttd"?null:gt(CB,{...e,tab:o.openDialog.tab})},CB=Wo("TTDDialogBase",({tab:e,...o})=>{let t=Re(),r=le(),n=kg(null),[i,a]=ie(IB),[l,s]=Rd(i?.prompt??""),m=l.trim(),c=S=>{s(S.target.value),a(L=>({generatedResponse:L?.generatedResponse??null,prompt:S.target.value}))},[d,p]=Rd(!1),[u,f]=ie(TB),b=async()=>{if(m.length>Ai||m.length<Mg||d||u?.rateLimitRemaining===0||"__fallback"in o){m.length<Mg&&C(new Error(`Prompt is too short (min ${Mg} characters)`)),m.length>Ai&&C(new Error(`Prompt is too long (max ${Ai} characters)`));return}try{p(!0),re("ai","generate","ttd");let{generatedResponse:S,error:L,rateLimit:k,rateLimitRemaining:A}=await o.onTextSubmit(m);if(typeof S=="string"&&a(P=>({generatedResponse:S,prompt:P?.prompt??null})),aT(k)&&aT(A)&&f({rateLimit:k,rateLimitRemaining:A}),L){C(L);return}if(!S){C(new Error("Generation failed"));return}try{await Pd({canvasRef:n,data:y,mermaidToExcalidrawLib:w,setError:C,mermaidDefinition:S}),re("ai","mermaid parse success","ttd")}catch(P){console.info(`%cTTD mermaid render errror: ${P.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
25
+ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),re("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let L=S.message;(!L||L==="Failed to fetch")&&(L="Request failed"),C(new Error(L))}finally{p(!1)}},x=kg(b);x.current=b;let[w,E]=Rd({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});vB(()=>{(async()=>{await w.api,E(L=>({...L,loaded:!0}))})()},[w.api]);let y=kg({elements:[],files:null}),[v,C]=Rd(null);return gt(Be,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Ir(tT,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?gt("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):Ir(Sg,{children:[gt(Dd,{tab:"text-to-diagram",children:Ir("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),gt("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"})]})}),gt(Dd,{tab:"mermaid",children:"Mermaid"})]}),gt(_d,{className:"ttd-dialog-content",tab:"mermaid",children:gt(q3,{mermaidToExcalidrawLib:w})}),!("__fallback"in o)&&Ir(_d,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[gt("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."}),Ir(Md,{children:[gt(Pi,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:kn},onTextSubmitInProgess:d,panelActionDisabled:m.length>Ai||u?.rateLimitRemaining===0,renderTopRight:()=>u?Ir("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>gt(Ld,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Ir("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(nl(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",gt(ar,{icon:kn})]});let S=m.length/Ai;return S>.8?Ir("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",m.length,"/",Ai]}):null},children:gt(Cd,{onChange:c,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),gt(Pi,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Ad({app:t,data:y})},label:"Insert",icon:kn},children:gt(kd,{canvasRef:n,error:v,loaded:w.loaded})})]})]})]})})});import{round as VT}from"@excalidraw/math";import OF from"clsx";import zF from"lodash.throttle";import{useEffect as XT,useMemo as Yg,useState as HF,memo as GF}from"react";import{STATS_PANELS as Ud}from"@excalidraw/common";import{getCommonBounds as UF}from"@excalidraw/element";import{getUncroppedWidthAndHeight as YF}from"@excalidraw/element";import{isElbowArrow as WF,isImageElement as Wg}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as VF}from"@excalidraw/element";import{elementsAreInSameGroup as XF}from"@excalidraw/element";import{degreesToRadians as pT,radiansToDegrees as fT}from"@excalidraw/math";import{getBoundTextElement as uT}from"@excalidraw/element";import{isArrowElement as hT,isElbowArrow as FB}from"@excalidraw/element";import{updateBindings as gT}from"@excalidraw/element";import AB from"clsx";import{useEffect as dT,useRef as Bd,useState as DB}from"react";import{EVENT as Ri,KEYS as _B,cloneJSON as Pg}from"@excalidraw/common";import{deepCopyElement as RB}from"@excalidraw/element";import{CaptureUpdateAction as mT}from"@excalidraw/element";import{pointFrom as Cr,pointRotateRads as Nd}from"@excalidraw/math";import{getBoundTextElement as SB}from"@excalidraw/element";import{isFrameLikeElement as sT}from"@excalidraw/element";import{getSelectedGroupIds as kB,getElementsInGroup as MB,isInGroup as LB}from"@excalidraw/element";import{getFrameChildren as PB}from"@excalidraw/element";import{updateBindings as lT}from"@excalidraw/element";var cT=.01,il=10,Ct=(e,o)=>!(o==="angle"&&sT(e)),Me=(e,o)=>{let t=e+o/2;return t-t%o},Di=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var an=(e,o,t,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,m]=[t.x+t.width/2,t.y+t.height/2],[c,d]=Nd(Cr(t.x,t.y),Cr(s,m),t.angle),p=e-c,u=o-d,[f,b]=Nd(Cr(e,o),Cr(s+p,m+u),-t.angle);r.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),lT(l,r);let x=SB(t,n);if(x){let w=a.get(x.id);w&&r.mutateElement(w,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(sT(t)){let w=PB(n,t.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,L]=Nd(Cr(E.x,E.y),Cr(v,C),E.angle),k=Math.round(S+p),A=Math.round(L+u),[P,N]=Nd(Cr(k,A),Cr(v+p,C+u),-E.angle);r.mutateElement(y,{x:P,y:N},{informMutation:i,isDragging:!1}),lT(y,r,{simultaneouslyUpdated:w})})}},_i=(e,o)=>{let r=kB(o).map(n=>MB(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!LB(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as Ag,jsxs as BB}from"react/jsx-runtime";var NB=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:m,sensitivity:c=1,dragFinishedCallback:d})=>{let p=Re(),u=le(),f=Bd(null),b=Bd(null),[x,w]=DB(r.toString()),E=Bd(null);E.current||(E.current={originalAppState:Pg(m),originalElements:n,lastUpdatedValue:x,updatePending:!1}),dT(()=>{let C=r.toString();w(C),E.current.lastUpdatedValue=C},[r]);let y=(C,S,L)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let k=Number(C);if(isNaN(k)){w(r.toString());return}let A=Number(k.toFixed(2)),P=Number(r);(isNaN(P)||Math.abs(A-P)>=cT)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:A,property:l,originalAppState:L,setInputValue:N=>w(String(N)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:mT.IMMEDIATELY}))},v=Bd({});return v.current.handleInputValue=y,dT(()=>{let C=f.current,S=v.current;return()=>{let L=C?.value;L&&S.handleInputValue?.(L,E.current.originalElements,E.current.originalAppState),window.removeEventListener(Ri.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(Ri.POINTER_UP,S.onPointerUp,!1)}},[i]),i?BB("div",{className:AB("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Ag("div",{className:"drag-input-label",ref:b,onPointerDown:C=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let S=Number(f.current.value);isNaN(S)&&(S=0);let L=null,k=p.scene.getNonDeletedElements().reduce((_,R)=>(_.set(R.id,RB(R)),_),new Map),A=n.map(_=>k.get(_.id)),P=Pg(m),N=0,O=0,U=_=>{if(L&&k!==null&&A!==null){let R=_.clientX-L.x;R!==0&&(O+=R,Math.abs(O)>=c&&(O=Math.sign(O)*Math.floor(Math.abs(O)/c),N+=O,t({accumulatedChange:N,instantChange:O,originalElements:A,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:P,setInputValue:V=>w(String(V)),app:p,setAppState:u}),O=0))}L={x:_.clientX,y:_.clientY}},J=()=>{window.removeEventListener(Ri.POINTER_MOVE,U,!1),p.syncActionResult({captureUpdate:mT.IMMEDIATELY}),d?.({app:p,setAppState:u,originalElements:A,originalAppState:P}),L=null,N=0,O=0,A=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Ri.POINTER_UP,J,!1)};v.current.onPointerMove=U,v.current.onPointerUp=J,window.addEventListener(Ri.POINTER_MOVE,U,!1),window.addEventListener(Ri.POINTER_UP,J,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?Ag(ar,{icon:o}):e}),Ag("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===_B.ENTER&&(y(S.value,n,m),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,w(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=n,E.current.originalAppState=Pg(m)},onBlur:C=>{x?i&&y(C.target.value,E.current.originalElements,E.current.originalAppState):w(r.toString())},disabled:!i})]}):null},Qe=NB;import{jsx as GB}from"react/jsx-runtime";var OB=15,zB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a&&!FB(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=pT(r);n.mutateElement(l,{angle:u}),gT(l,n);let f=uT(l,i);f&&!hT(l)&&n.mutateElement(f,{angle:u});return}let s=Math.round(fT(a.angle)*100)/100,m=Math.round(e),c=(s+m)%360;t&&(c=Me(c,OB)),c=c<0?c+360:c;let d=pT(c);n.mutateElement(l,{angle:d}),gT(l,n);let p=uT(l,i);p&&!hT(l)&&n.mutateElement(p,{angle:d})}},HB=({element:e,scene:o,appState:t,property:r})=>GB(Qe,{label:"A",icon:Ql,value:Math.round(fT(e.angle)%360*100)/100,elements:[e],dragInputCallback:zB,editable:Ct(e,"angle"),scene:o,appState:t,property:r}),bT=HB;import{jsx as YB}from"react/jsx-runtime";var xT=5,UB=({property:e,scene:o,appState:t,setAppState:r})=>YB(Qe,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let m;return n?m=n:i&&(m=a?Me(s.gridStep+xT*Math.sign(i),xT):s.gridStep+i),m?(m=t1(m),l(m),{gridStep:m}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),ET=UB;import{clamp as Fd,round as Dg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Od}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as yT,getUncroppedWidthAndHeight as TT}from"@excalidraw/element";import{resizeSingleElement as wT}from"@excalidraw/element";import{isImageElement as IT}from"@excalidraw/element";import{isFrameLikeElement as _g}from"@excalidraw/element";import{getElementsInResizingFrame as Rg}from"@excalidraw/element";import{replaceAllElementsInFrame as CT}from"@excalidraw/element";import{jsx as ZB}from"react/jsx-runtime";var vT=10,WB=e=>e.type==="image",VB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:m,app:c,setAppState:d})=>{let p=m.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=r||WB(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!IT(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,C=w.scale[1]===-1,{width:S,height:L}=TT(w),k=E.naturalWidth/S,A=E.naturalHeight/L,P=v?E.width+E.x:E.naturalWidth-E.x,N=C?E.height+E.y:E.naturalHeight-E.y,O=yT*k,U=yT*A;if(i!==void 0){if(a==="width"){let Z=i*k,W=Fd(Z,O,P);y={...y,width:W,x:v?E.x+E.width-W:E.x}}else if(a==="height"){let Z=i*A,W=Fd(Z,U,N);y={...y,height:W,y:C?E.y+E.height-W:E.y}}m.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}let J=a==="width"?s:0,_=a==="height"?s:0,R=Fd(E.width+J,O,P),V=Fd(E.height+_,O,N);y={...E,x:v?E.x+E.width-R:E.x,y:C?E.y+E.height-V:E.y,width:R,height:V},m.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*x:u.width,Od),E=Math.max(a==="height"?i:b?i/x:u.height,Od);if(wT(w,E,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),_g(f)){let y=Rg(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap()),v=CT(m.getElementsIncludingDeleted(),y,f,c);m.replaceAllElements(v)}return}{let w=a==="width"?e:0,E=a==="height"?e:0,y=Math.max(0,u.width+w);a==="width"&&(n?y=Me(y,vT):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(n?v=Me(v,vT):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(Od,v),y=Math.max(Od,y),wT(y,v,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),_g(f)){let C=Rg(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap());d({elementsToHighlight:C})}}}},XB=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&_g(a)){let l=Rg(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=CT(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},KB=({property:e,element:o,scene:t,appState:r})=>{let n=Dg(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&IT(o)&&o.crop){let{width:i,height:a}=TT(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=Dg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=Dg(o.crop.height*l,2)}}return ZB(Qe,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:VB,value:n,editable:Ct(o,e),scene:t,appState:r,property:e,dragFinishedCallback:XB})},Ng=KB;import{getBoundTextElement as $B,redrawTextBoundingBox as jB}from"@excalidraw/element";import{hasBoundTextElement as qB,isTextElement as kT}from"@excalidraw/element";import{jsx as tF}from"react/jsx-runtime";var ST=4,JB=4,QB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!kT(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),ST);else if(a.type==="text"){let m=Math.round(a.fontSize),c=Math.round(e);s=Math.max(m+c,ST),t&&(s=Me(s,JB))}s&&(n.mutateElement(l,{fontSize:s}),jB(l,n.getContainerElement(l),n))}},eF=({element:e,scene:o,appState:t,property:r})=>{let n=kT(e)?e:qB(e)?$B(e,o.getNonDeletedElementsMap()):null;return n?tF(Qe,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:QB,icon:Hr,appState:t,scene:o,property:r}):null},MT=eF;import{degreesToRadians as LT,radiansToDegrees as DT}from"@excalidraw/math";import{getBoundTextElement as PT}from"@excalidraw/element";import{isArrowElement as AT}from"@excalidraw/element";import{isInGroup as Bg}from"@excalidraw/element";import{jsx as iF}from"react/jsx-runtime";var oF=15,rF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(m=>a.get(m.id)).filter(m=>m&&!Bg(m)&&Ct(m,n)),s=o.filter(m=>!Bg(m)&&Ct(m,n));if(r!==void 0){let m=LT(r);for(let c of l){if(!c)continue;i.mutateElement(c,{angle:m});let d=PT(c,a);d&&!AT(c)&&i.mutateElement(d,{angle:m})}i.triggerUpdate();return}for(let m=0;m<l.length;m++){let c=l[m];if(!c)continue;let d=s[m],p=Math.round(DT(d.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Me(f,oF)),f=f<0?f+360:f;let b=LT(f);i.mutateElement(c,{angle:b});let x=PT(c,a);x&&!AT(c)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},nF=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!Bg(s)&&Ct(s,"angle")),i=n.map(s=>Math.round(DT(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>Ct(s,"angle"));return iF(Qe,{label:"A",icon:Ql,value:a,elements:e,dragInputCallback:rF,editable:l,appState:t,scene:o,property:r})},_T=nF;import{pointFrom as RT}from"@excalidraw/math";import{useMemo as aF}from"react";import{MIN_WIDTH_OR_HEIGHT as Sr}from"@excalidraw/common";import{getElementsInResizingFrame as Fg,isFrameLikeElement as Og,replaceAllElementsInFrame as FT,updateBoundElements as lF}from"@excalidraw/element";import{rescalePointsInElement as sF,resizeSingleElement as NT}from"@excalidraw/element";import{getBoundTextElement as cF,handleBindTextResize as dF}from"@excalidraw/element";import{isTextElement as OT}from"@excalidraw/element";import{getCommonBounds as zd}from"@excalidraw/element";import{jsx as fF}from"react/jsx-runtime";var Ni=10,mF=(e,o,t,r)=>{let n=r.x-e,i=r.y-o,a=r.width*t,l=r.height*t,s=e+n*t,m=o+i*t;return{width:a,height:l,x:s,y:m,...sF(r,a,l,!1),...OT(r)?{fontSize:r.fontSize*t}:{}}},pF=(e,o,t,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),m=mF(e,o,r,i);l.mutateElement(n,m);let c=cF(i,a);if(c){let d=c.fontSize*r;lF(n,l,{newSize:{width:m.width,height:m.height}});let p=s.get(c.id);p&&OT(p)&&(l.mutateElement(p,{fontSize:d}),dF(n,l,t==="width"?"e":"s",!0))}},BT=(e,o,t,r,n,i,a,l,s,m)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let c=o/t;for(let d=0;d<l.length;d++){let p=l[d],u=a[d];pF(n[0],n[1],i,c,u,p,s,m)}},uF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l,setAppState:s,app:m})=>{let c=a.getNonDeletedElementsMap(),d=_i(o,r);if(i!==void 0){for(let b of d){let x=Di(b,c,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=zd(E),L=C-y,k=S-v,A=L/k,P=Math.max(Sr,l==="width"?Math.max(0,i):L),N=Math.max(Sr,l==="height"?Math.max(0,i):k);BT(P,N,k,A,RT(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&Ct(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(n?v=Me(v,Ni):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(n?C=Me(C,Ni):C=Math.round(C)),v=Math.max(Sr,v),C=Math.max(Sr,C),NT(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Og(E)){let S=Fg(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap()),L=FT(a.getElementsIncludingDeleted(),S,E,m);a.replaceAllElements(L)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of d){let x=Di(b,c,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=zd(E),L=C-y,k=S-v,A=L/k,P=Math.max(0,L+p);l==="width"&&(n?P=Me(P,Ni):P=Math.round(P));let N=Math.max(0,k+u);l==="height"&&(n?N=Me(N,Ni):N=Math.round(N)),P=Math.max(Sr,P),N=Math.max(Sr,N),BT(P,N,k,A,RT(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&Ct(E,l)){let v=Math.max(0,y.width+p);l==="width"&&(n?v=Me(v,Ni):v=Math.round(v));let C=Math.max(0,y.height+u);if(l==="height"&&(n?C=Me(C,Ni):C=Math.round(C)),v=Math.max(Sr,v),C=Math.max(Sr,C),NT(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Og(E)){let S=Fg(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},hF=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&Og(a)){let l=Fg(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=FT(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},gF=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=aF(()=>r.map(m=>{let c=Di(m,t);if(c.length>1){let[p,u,f,b]=zd(c.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[d]=c;return Math.round((e==="width"?d.latest.width:d.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return fF(Qe,{label:e==="width"?"W":"H",elements:o,dragInputCallback:uF,value:l,editable:s,appState:i,property:e,scene:n,dragFinishedCallback:hF})},zg=gF;import{getBoundTextElement as bF,redrawTextBoundingBox as zT}from"@excalidraw/element";import{hasBoundTextElement as xF,isTextElement as EF}from"@excalidraw/element";import{isInGroup as yF}from"@excalidraw/element";import{jsx as CF}from"react/jsx-runtime";var HT=4,wF=4,vF=(e,o)=>e.reduce((t,r)=>{if(!r||yF(r))return t;if(EF(r))return t.push(r),t;if(xF(r)){let n=bF(r,o);if(n)return t.push(n),t}return t},[]),TF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),HT);for(let s of a)n.mutateElement(s,{fontSize:l}),zT(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=o;for(let m=0;m<a.length;m++){let c=a[m],d=s[m],p=Math.round(d.fontSize),u=Math.round(e),f=Math.max(p+u,HT);t&&(f=Me(f,wF)),n.mutateElement(c,{fontSize:f}),zT(c,n.getContainerElement(c),n)}n.triggerUpdate()}},IF=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=vF(e,n);if(!i.length)return null;let a=i.map(m=>Math.round(m.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return CF(Qe,{label:"F",icon:Hr,elements:i,dragInputCallback:TF,value:l,editable:s,scene:o,property:r,appState:t})},GT=IF;import{pointFrom as kr,pointRotateRads as Hd}from"@excalidraw/math";import{useMemo as SF}from"react";import{isTextElement as kF}from"@excalidraw/element";import{getCommonBounds as Hg}from"@excalidraw/element";import{jsx as DF}from"react/jsx-runtime";var MF=(e,o,t,r,n,i)=>{for(let a=0;a<r.length;a++){let l=r[a],[s,m]=[l.x+l.width/2,l.y+l.height/2],[c,d]=Hd(kr(l.x,l.y),kr(s,m),l.angle),p=e==="x"?Math.round(c+o):c,u=e==="y"?Math.round(d+t):d;an(p,u,l,i,n,!1)}},LF=(e,o,t,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=Hg(t),s=e-a,m=o-l;for(let c=0;c<t.length;c++){let d=t[c],p=i.get(d.id);if(p&&(!kF(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=Hd(kr(p.x,p.y),kr(u,f),p.angle);an(b+s,x+m,d,n,r,!1)}}},PF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(n!==void 0){for(let p of _i(o,l)){let u=Di(p,s,t);if(u.length>1){let[f,b,,]=Hg(u.map(E=>E.latest));LF(i==="x"?n:f,i==="y"?n:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&Ct(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=Hd(kr(f.x,f.y),kr(x,w),f.angle);an(i==="x"?n:E,i==="y"?n:y,f,a,t,!1)}}}a.triggerUpdate();return}let m=r?Me(e,il):e;MF(i,i==="x"?m:0,i==="y"?m:0,o,t,a),a.triggerUpdate()},AF=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=SF(()=>r.map(s=>{let m=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(m.length>1){let[b,x]=Hg(m);return Math.round((e==="x"?b:x)*100)/100}let[c]=m,[d,p]=[c.x+c.width/2,c.y+c.height/2],[u,f]=Hd(kr(c.x,c.y),kr(d,p),c.angle);return Math.round((e==="x"?u:f)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return DF(Qe,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:PF,value:l,property:e,scene:n,appState:i})},Gg=AF;import{clamp as al,pointFrom as Gd,pointRotateRads as YT,round as UT}from"@excalidraw/math";import{getFlipAdjustedCropPosition as _F,getUncroppedWidthAndHeight as RF}from"@excalidraw/element";import{isImageElement as WT}from"@excalidraw/element";import{jsx as FF}from"react/jsx-runtime";var NF=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let m=l.getNonDeletedElementsMap(),c=t[0],[d,p]=[c.x+c.width/2,c.y+c.height/2],[u,f]=YT(Gd(c.x,c.y),Gd(d,p),c.angle);if(s.croppingElementId===c.id){let y=m.get(c.id);if(!y||!WT(y)||!y.crop)return;let v=y.crop,C=v,S=y.scale[0]===-1,L=y.scale[1]===-1,{width:k,height:A}=RF(y);if(i!==void 0){if(a==="x"){let O=i*(v.naturalWidth/k);S?C={...v,x:al(v.naturalWidth-O-v.width,0,v.naturalWidth-v.width)}:C={...v,x:al(i*(v.naturalWidth/k),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:al(i*(v.naturalHeight/A),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:C});return}let P=(a==="x"?o:0)*(S?-1:1),N=(a==="y"?o:0)*(L?-1:1);C={...v,x:al(v.x+P,0,v.naturalWidth-v.width),y:al(v.y+N,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:C});return}if(i!==void 0){an(a==="x"?i:u,a==="y"?i:f,c,l,r);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(n?Me(c.x+b,il):u+b):u,E=a==="y"?Math.round(n?Me(c.y+x,il):f+x):f;an(w,E,c,l,r)},BF=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=YT(Gd(o.x,o.y),Gd(o.x+o.width/2,o.y+o.height/2),o.angle),l=UT(e==="x"?i:a,2);if(n.croppingElementId===o.id&&WT(o)&&o.crop){let s=_F(o);s&&(l=UT(e==="x"?s.x:s.y,2))}return FF(Qe,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:NF,scene:r,value:l,property:e,appState:n})},Ug=BF;import{Fragment as Vg,jsx as q,jsxs as St}from"react/jsx-runtime";var KF=50,ll=e=>{let o=go(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=fr(e.app);return q(ZF,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Ie=({children:e,columns:o=1,heading:t,style:r,...n})=>q("div",{className:OF("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Ie.displayName="StatsRow";var Yd=({children:e,order:o,style:t,...r})=>q("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Yd.displayName="StatsRows";ll.StatsRow=Ie;ll.StatsRows=Yd;var ZF=GF(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),m=l.getNonDeletedElementsMap(),c=le(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&Wg(d),f=u?YF(d):null,[b,x]=HF({width:0,height:0}),w=Yg(()=>zF(v=>{let C=UF(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},KF),[]);XT(()=>{w(s)},[i,s,w]),XT(()=>()=>w.cancel(),[w]);let E=Yg(()=>_i(r,n),[r,n]),y=Yg(()=>VF(r),[r]);return q("div",{className:"exc-stats",children:St(Xe,{padding:3,children:[St("div",{className:"title",children:[q("h2",{children:g("stats.title")}),q("div",{className:"close",onClick:o,children:Ft})]}),St(ua,{label:q("h3",{children:g("stats.generalStats")}),open:!!(n.stats.panels&Ud.generalStats),openTrigger:()=>c(v=>({stats:{open:!0,panels:v.stats.panels^Ud.generalStats}})),children:[St(Yd,{children:[q(Ie,{heading:!0,children:g("stats.scene")}),St(Ie,{columns:2,children:[q("div",{children:g("stats.shapes")}),q("div",{children:s.length})]}),St(Ie,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:b.width})]}),St(Ie,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:b.height})]}),a&&St(Vg,{children:[q(Ie,{heading:!0,children:"Canvas"}),q(Ie,{children:q(ET,{property:"gridStep",scene:l,appState:n,setAppState:c})})]})]}),t?.(s,n)]}),!y&&r.length>0&&q("div",{id:"elementStats",style:{marginTop:12},children:q(ua,{label:q("h3",{children:g("stats.elementProperties")}),open:!!(n.stats.panels&Ud.elementProperties),openTrigger:()=>c(v=>({stats:{open:!0,panels:v.stats.panels^Ud.elementProperties}})),children:St(Yd,{children:[d&&St(Vg,{children:[u&&q(Ie,{heading:!0,children:g("labels.unCroppedDimension")}),n.croppingElementId&&Wg(d)&&f&&St(Ie,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:VT(f.width,2)})]}),n.croppingElementId&&Wg(d)&&f&&St(Ie,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:VT(f.height,2)})]}),q(Ie,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?g("labels.imageCropping"):g(`element.${d.type}`)}),q(Ie,{children:q(Ug,{element:d,property:"x",elementsMap:m,scene:l,appState:n})}),q(Ie,{children:q(Ug,{element:d,property:"y",elementsMap:m,scene:l,appState:n})}),q(Ie,{children:q(Ng,{property:"width",element:d,scene:l,appState:n})}),q(Ie,{children:q(Ng,{property:"height",element:d,scene:l,appState:n})}),!WF(d)&&q(Ie,{children:q(bT,{property:"angle",element:d,scene:l,appState:n})}),q(Ie,{children:q(MT,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&St(Vg,{children:[XF(p)&&q(Ie,{heading:!0,children:g("element.group")}),St(Ie,{columns:2,style:{margin:"0.3125rem 0"},children:[q("div",{children:g("stats.shapes")}),q("div",{children:r.length})]}),q(Ie,{children:q(Gg,{property:"x",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(Gg,{property:"y",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(zg,{property:"width",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(zg,{property:"height",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(_T,{property:"angle",elements:p,scene:l,appState:n})}),q(Ie,{children:q(GT,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:m})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as $F,useEffect as KT,useState as ZT}from"react";import{normalizeLink as jF,KEYS as Xg}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as qF,getLinkIdAndTypeFromSelection as JF}from"@excalidraw/element";import{jsx as Bi,jsxs as Wd}from"react/jsx-runtime";var QF=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=qF})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=ZT(a),[m,c]=ZT(!1);KT(()=>{let p=j(i,t),u=a;if(p.length>0&&n){let f=JF(p,t);f&&(u=jF(n(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,n]);let d=$F(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:l})}if(!l&&m&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}o?.()},[e,l,i,m,r,o]);return KT(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===Xg.ENTER&&d(),t.openDialog?.name==="elementLinkSelector"&&u.key===Xg.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,d]),Wd("div",{className:"ElementLinkDialog",children:[Wd("div",{className:"ElementLinkDialog__header",children:[Bi("h2",{children:g("elementLink.title")}),Bi("p",{children:g("elementLink.desc")})]}),Wd("div",{className:"ElementLinkDialog__input",children:[Bi(gi,{value:l??"",onChange:p=>{m||c(!0),s(p)},onKeyDown:p=>{p.key===Xg.ENTER&&d()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Bi(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),c(!0)},className:"ElementLinkDialog__remove",icon:Mt})]}),Wd("div",{className:"ElementLinkDialog__actions",children:[Bi(No,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Bi(No,{label:g("buttons.confirm"),onClick:d,actionType:"primary"})]})]})},$T=QF;import eO,{useState as tO}from"react";import{Fragment as oO,jsx as Kg}from"react/jsx-runtime";var jT=({children:e,onClose:o})=>{let[t,r]=tO(!!e),{container:n}=Ge(),i=eO.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return Kg(oO,{children:t&&Kg(Be,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Kg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import rO from"react";import{isDarwin as qT,isFirefox as JT,isWindows as nO}from"@excalidraw/common";import{KEYS as Ae,getShortcutKey as X}from"@excalidraw/common";import{Fragment as e5,jsx as F,jsxs as Nt}from"react/jsx-runtime";var iO=()=>Nt("div",{className:"HelpDialog__header",children:[Nt("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:km}),g("helpDialog.documentation")]}),Nt("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:km}),g("helpDialog.blog")]}),Nt("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:Zl}),g("helpDialog.github")]}),Nt("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:cb}),"YouTube"]})]}),aO=e=>Nt(e5,{children:[F("h3",{children:e.title}),F("div",{className:"HelpDialog__islands-container",children:e.children})]}),Zg=e=>Nt("div",{className:`HelpDialog__island ${e.className}`,children:[F("h4",{className:"HelpDialog__island-title",children:e.caption}),F("div",{className:"HelpDialog__island-content",children:e.children})]});function*lO(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var sO=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),G=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>F(cO,{children:sO(a)},a)));return Nt("div",{className:"HelpDialog__shortcut",children:[F("div",{children:e}),F("div",{className:"HelpDialog__key-container",children:[...lO(r,t?g("helpDialog.or"):null)]})]})},cO=e=>F("kbd",{className:"HelpDialog__key",...e}),QT=({onClose:e})=>{let o=rO.useCallback(()=>{e&&e()},[e]);return F(e5,{children:Nt(Be,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[F(iO,{}),Nt(aO,{title:g("helpDialog.shortcuts"),children:[Nt(Zg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[F(G,{label:g("toolBar.hand"),shortcuts:[Ae.H]}),F(G,{label:g("toolBar.selection"),shortcuts:[Ae.V,Ae[1]]}),F(G,{label:g("toolBar.rectangle"),shortcuts:[Ae.R,Ae[2]]}),F(G,{label:g("toolBar.diamond"),shortcuts:[Ae.D,Ae[3]]}),F(G,{label:g("toolBar.ellipse"),shortcuts:[Ae.O,Ae[4]]}),F(G,{label:g("toolBar.arrow"),shortcuts:[Ae.A,Ae[5]]}),F(G,{label:g("toolBar.line"),shortcuts:[Ae.L,Ae[6]]}),F(G,{label:g("toolBar.freedraw"),shortcuts:[Ae.P,Ae[7]]}),F(G,{label:g("toolBar.text"),shortcuts:[Ae.T,Ae[8]]}),F(G,{label:g("toolBar.image"),shortcuts:[Ae[9]]}),F(G,{label:g("toolBar.eraser"),shortcuts:[Ae.E,Ae[0]]}),F(G,{label:g("toolBar.frame"),shortcuts:[Ae.F]}),F(G,{label:g("toolBar.laser"),shortcuts:[Ae.K]}),F(G,{label:g("labels.eyeDropper"),shortcuts:[Ae.I,"Shift+S","Shift+G"]}),F(G,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[X("CtrlOrCmd+Enter")]}),F(G,{label:g("helpDialog.editText"),shortcuts:[X("Enter")]}),F(G,{label:g("helpDialog.textNewLine"),shortcuts:[X("Enter"),X("Shift+Enter")]}),F(G,{label:g("helpDialog.textFinish"),shortcuts:[X("Esc"),X("CtrlOrCmd+Enter")]}),F(G,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),F(G,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),F(G,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),X("Enter")],isOr:!0}),F(G,{label:g("helpDialog.cropFinish"),shortcuts:[X("Enter"),X("Escape")],isOr:!0}),F(G,{label:g("toolBar.lock"),shortcuts:[Ae.Q]}),F(G,{label:g("helpDialog.preventBinding"),shortcuts:[X("CtrlOrCmd")]}),F(G,{label:g("toolBar.link"),shortcuts:[X("CtrlOrCmd+K")]}),F(G,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Nt(Zg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[F(G,{label:g("buttons.zoomIn"),shortcuts:[X("CtrlOrCmd++")]}),F(G,{label:g("buttons.zoomOut"),shortcuts:[X("CtrlOrCmd+-")]}),F(G,{label:g("buttons.resetZoom"),shortcuts:[X("CtrlOrCmd+0")]}),F(G,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),F(G,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),F(G,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),F(G,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),F(G,{label:g("buttons.zenMode"),shortcuts:[X("Alt+Z")]}),F(G,{label:g("buttons.objectsSnapMode"),shortcuts:[X("Alt+S")]}),F(G,{label:g("labels.toggleGrid"),shortcuts:[X("CtrlOrCmd+'")]}),F(G,{label:g("labels.viewMode"),shortcuts:[X("Alt+R")]}),F(G,{label:g("labels.toggleTheme"),shortcuts:[X("Alt+Shift+D")]}),F(G,{label:g("stats.fullTitle"),shortcuts:[X("Alt+/")]}),F(G,{label:g("search.title"),shortcuts:[Ne("searchMenu")]}),F(G,{label:g("commandPalette.title"),shortcuts:JT?[Ne("commandPalette")]:[Ne("commandPalette"),Ne("commandPalette",1)]})]}),Nt(Zg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[F(G,{label:g("helpDialog.createFlowchart"),shortcuts:[X("CtrlOrCmd+Arrow Key")],isOr:!0}),F(G,{label:g("helpDialog.navigateFlowchart"),shortcuts:[X("Alt+Arrow Key")],isOr:!0}),F(G,{label:g("labels.moveCanvas"),shortcuts:[X(`Space+${g("helpDialog.drag")}`),X(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),F(G,{label:g("buttons.clearReset"),shortcuts:[X("CtrlOrCmd+Delete")]}),F(G,{label:g("labels.delete"),shortcuts:[X("Delete")]}),F(G,{label:g("labels.cut"),shortcuts:[X("CtrlOrCmd+X")]}),F(G,{label:g("labels.copy"),shortcuts:[X("CtrlOrCmd+C")]}),F(G,{label:g("labels.paste"),shortcuts:[X("CtrlOrCmd+V")]}),F(G,{label:g("labels.pasteAsPlaintext"),shortcuts:[X("CtrlOrCmd+Shift+V")]}),F(G,{label:g("labels.selectAll"),shortcuts:[X("CtrlOrCmd+A")]}),F(G,{label:g("labels.multiSelect"),shortcuts:[X(`Shift+${g("helpDialog.click")}`)]}),F(G,{label:g("helpDialog.deepSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.click")}`)]}),F(G,{label:g("helpDialog.deepBoxSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(Xn||JT)&&F(G,{label:g("labels.copyAsPng"),shortcuts:[X("Shift+Alt+C")]}),F(G,{label:g("labels.copyStyles"),shortcuts:[X("CtrlOrCmd+Alt+C")]}),F(G,{label:g("labels.pasteStyles"),shortcuts:[X("CtrlOrCmd+Alt+V")]}),F(G,{label:g("labels.sendToBack"),shortcuts:[qT?X("CtrlOrCmd+Alt+["):X("CtrlOrCmd+Shift+[")]}),F(G,{label:g("labels.bringToFront"),shortcuts:[qT?X("CtrlOrCmd+Alt+]"):X("CtrlOrCmd+Shift+]")]}),F(G,{label:g("labels.sendBackward"),shortcuts:[X("CtrlOrCmd+[")]}),F(G,{label:g("labels.bringForward"),shortcuts:[X("CtrlOrCmd+]")]}),F(G,{label:g("labels.alignTop"),shortcuts:[X("CtrlOrCmd+Shift+Up")]}),F(G,{label:g("labels.alignBottom"),shortcuts:[X("CtrlOrCmd+Shift+Down")]}),F(G,{label:g("labels.alignLeft"),shortcuts:[X("CtrlOrCmd+Shift+Left")]}),F(G,{label:g("labels.alignRight"),shortcuts:[X("CtrlOrCmd+Shift+Right")]}),F(G,{label:g("labels.duplicateSelection"),shortcuts:[X("CtrlOrCmd+D"),X(`Alt+${g("helpDialog.drag")}`)]}),F(G,{label:g("helpDialog.toggleElementLock"),shortcuts:[X("CtrlOrCmd+Shift+L")]}),F(G,{label:g("buttons.undo"),shortcuts:[X("CtrlOrCmd+Z")]}),F(G,{label:g("buttons.redo"),shortcuts:nO?[X("CtrlOrCmd+Y"),X("CtrlOrCmd+Shift+Z")]:[X("CtrlOrCmd+Shift+Z")]}),F(G,{label:g("labels.group"),shortcuts:[X("CtrlOrCmd+G")]}),F(G,{label:g("labels.ungroup"),shortcuts:[X("CtrlOrCmd+Shift+G")]}),F(G,{label:g("labels.flipHorizontal"),shortcuts:[X("Shift+H")]}),F(G,{label:g("labels.flipVertical"),shortcuts:[X("Shift+V")]}),F(G,{label:g("labels.showStroke"),shortcuts:[X("S")]}),F(G,{label:g("labels.showBackground"),shortcuts:[X("G")]}),F(G,{label:g("labels.showFonts"),shortcuts:[X("Shift+F")]}),F(G,{label:g("labels.decreaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+<")]}),F(G,{label:g("labels.increaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as r5,useRef as gO,useState as Mr}from"react";import{DEFAULT_EXPORT_PADDING as fO,EXPORT_IMAGE_TYPES as $g,isFirefox as bO,EXPORT_SCALES as xO,cloneJSON as n5}from"@excalidraw/common";import{useCallback as dO,useRef as mO,useState as pO}from"react";var uO=2e3,t5=()=>{let[e,o]=pO(null),t=mO(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},uO)},n=dO(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import hO from"clsx";import{jsx as o5}from"react/jsx-runtime";var sl=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>o5("div",{className:hO("Switch",{toggled:t,disabled:n}),children:o5("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:i=>{i.key===" "&&r(!t)}})});import{jsx as Ce,jsxs as Lr}from"react/jsx-runtime";var EO="filter"in document.createElement("canvas").getContext("2d"),yO=()=>Lr("div",{children:[Ce("h3",{children:g("canvasError.cannotShowPreview")}),Ce("p",{children:Ce("span",{children:g("canvasError.canvasTooBig")})}),Lr("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),wO=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=Ee(o,e),[l,s]=Mr(i),[m,c]=Mr(a),[d,p]=Mr(e.exportBackground),[u,f]=Mr(e.exportWithDarkMode),[b,x]=Mr(e.exportEmbedScene),[w,E]=Mr(e.exportScale),y=gO(null),[v,C]=Mr(null),{onCopy:S,copyStatus:L,resetCopyStatus:k}=t5();r5(()=>{k()},[l,d,u,w,b,k]);let{exportedElements:A,exportingFrame:P}=Kr(o,e,m);return r5(()=>{let N=y.current;if(!N)return;let O=N.offsetWidth,U=N.offsetHeight;O&&mr({elements:A,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:t,exportPadding:fO,maxWidthOrHeight:Math.max(O,U),exportingFrame:P}).then(J=>(C(null),ko(J).then(()=>{N.replaceChildren(J)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):_}))).catch(J=>{console.error(J),C(J)})},[e,t,A,P,l,d,u,w,b]),Lr("div",{className:"ImageExportModal",children:[Ce("h3",{children:g("imageExportDialog.header")}),Lr("div",{className:"ImageExportModal__preview",children:[Ce("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Ce(yO,{})}),Ce("div",{className:"ImageExportModal__preview__filename",children:!fn&&Ce("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:N=>{s(N.target.value),r.executeAction(Kp,"ui",N.target.value)}})})]}),Lr("div",{className:"ImageExportModal__settings",children:[Ce("h3",{children:g("imageExportDialog.header")}),a&&Ce(cl,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ce(sl,{name:"exportOnlySelected",checked:m,onChange:N=>{c(N)}})}),Ce(cl,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ce(sl,{name:"exportBackgroundSwitch",checked:d,onChange:N=>{p(N),r.executeAction(Zp,"ui",N)}})}),EO&&Ce(cl,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ce(sl,{name:"exportDarkModeSwitch",checked:u,onChange:N=>{f(N),r.executeAction(eE,"ui",N)}})}),Ce(cl,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ce(sl,{name:"exportEmbedSwitch",checked:b,onChange:N=>{x(N),r.executeAction(Ks,"ui",N)}})}),Ce(cl,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Ce(bd,{name:"exportScale",value:w,onChange:N=>{E(N),r.executeAction(Qx,"ui",N)},choices:xO.map(N=>({value:N,label:`${N}\xD7`}))})}),Lr("div",{className:"ImageExportModal__settings__buttons",children:[Ce(vr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>n($g.png,A,{exportingFrame:P}),icon:Ym,children:g("imageExportDialog.button.exportToPng")}),Ce(vr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>n($g.svg,A,{exportingFrame:P}),icon:Ym,children:g("imageExportDialog.button.exportToSvg")}),(Xn||bO)&&Ce(vr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await n($g.clipboard,A,{exportingFrame:P}),S()},icon:Sn,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},cl=({label:e,children:o,tooltip:t,name:r})=>Lr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Lr("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ce(Pt,{label:t,long:!0,children:U0})]}),Ce("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),i5=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Mr(()=>({appStateSnapshot:n5(o),elementsSnapshot:n5(e)}));return Ce(Be,{onCloseRequest:i,size:"wide",title:!1,children:Ce(wO,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import TO from"react";import{getFrame as IO}from"@excalidraw/common";import jg from"open-color";import{jsx as vO}from"react/jsx-runtime";var qg=({children:e,color:o})=>vO("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":jg[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":jg[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":jg[o][9]},children:e});import{Fragment as SO,jsx as co,jsxs as Vd}from"react/jsx-runtime";var CO=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return co("div",{className:"ExportDialog ExportDialog--json",children:Vd("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Vd(qg,{color:"lime",children:[co("div",{className:"Card-icon",children:j1}),co("h2",{children:g("exportDialog.disk_title")}),Vd("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!fn&&n.renderAction("changeProjectName")]}),co(K,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Ca,"ui")}})]}),s&&Vd(qg,{color:"pink",children:[co("div",{className:"Card-icon",children:Ji}),co("h2",{children:g("exportDialog.link_title")}),co("div",{className:"Card-details",children:g("exportDialog.link_details")}),co(K,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{re("export","link",`ui (${IO()})`),await s(e,o,r),l()}catch(m){t({errorMessage:m.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},a5=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=TO.useCallback(()=>{a({openDialog:null})},[a]);return co(SO,{children:o.openDialog?.name==="jsonExport"&&co(Be,{onCloseRequest:l,title:g("buttons.export"),children:co(CO,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import kO from"clsx";import{jsx as l5,jsxs as LO}from"react/jsx-runtime";var MO="small",s5=e=>LO("label",{className:kO("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${MO}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[l5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),l5("div",{className:"ToolIcon__icon",children:ea})]});import{Fragment as m5,jsx as $,jsxs as Bt}from"react/jsx-runtime";var FO=({UIOptions:e})=>Bt(dt,{__fallback:!0,children:[$(dt.DefaultItems.LoadScene,{}),$(dt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&$(dt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&$(dt.DefaultItems.SaveAsImage,{}),$(dt.DefaultItems.SearchMenu,{}),$(dt.DefaultItems.Help,{}),$(dt.DefaultItems.ClearCanvas,{}),$(dt.Separator,{}),$(dt.Group,{title:"Excalidraw links",children:$(dt.DefaultItems.Socials,{})}),$(dt.Separator,{}),$(dt.DefaultItems.ToggleTheme,{}),$(dt.DefaultItems.ChangeCanvasBackground,{})]}),OO=()=>Bt(wd,{__fallback:!0,children:[$(wd.Actions.SaveToDisk,{}),$(wd.Actions.ExportToImage,{})]}),zO=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:m,renderTopRightUI:c,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:w,generateLinkForSelection:E})=>{let y=ce(),v=u2(),C=v.tunnelsJotai.Provider,[S,L]=ie(or),k=()=>p.canvasActions.export?$(a5,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,A=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:$(i5,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),P=()=>Bt("div",{style:{position:"relative"},children:[$(v.MainMenuTunnel.Out,{}),f&&$(v.WelcomeScreenMenuHintTunnel.Out,{})]}),N=()=>$(Er,{heading:"selectedShapeActions",className:dl("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:$(Xe,{className:AO.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:$(Dc,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),O=()=>{let R=NO(o,n),V=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return $(cd,{side:"top",children:Bt("div",{className:"App-menu App-menu_top",children:[Bt(qe.Col,{gap:6,className:dl("App-menu_top__left"),children:[P(),R&&N()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&$(Er,{heading:"shapes",className:"shapes-section",children:Z=>Bt("div",{style:{position:"relative"},children:[f&&$(v.WelcomeScreenToolbarHintTunnel.Out,{}),$(qe.Col,{gap:4,align:"start",children:Bt(qe.Row,{gap:1,className:dl("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Bt(Xe,{padding:1,className:dl("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[$(md,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),Z,Bt(qe.Row,{gap:1,children:[$(pd,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),$(sd,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),$("div",{className:"App-toolbar__divider"}),$(dd,{checked:qt(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),$(_c,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),w&&$(Xe,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:$(s5,{title:g("toolBar.laser"),checked:o.activeTool.type===c5.laser,onChange:()=>x.setActiveTool({type:c5.laser}),isMobile:!0})})]})})]})}),Bt("div",{className:dl("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&$(gd,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),c?.(y.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!J||o.openSidebar?.name!==Jg.name)&&$(v.DefaultSidebarTriggerTunnel.Out,{}),V&&$(ll,{app:x,onClose:()=>{e.executeAction(oi)},renderCustomStats:d})]})]})})},U=()=>$(Id,{__fallback:!0,onDock:R=>{re("sidebar",`toggleDock (${R?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),J=zl(el),_=Bt(m5,{children:[b,$(FO,{UIOptions:p}),$(Id.Trigger,{__fallback:!0,icon:wn,title:_O(g("toolBar.library")),onToggle:R=>{R&&re("sidebar",`${Jg.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:Jg.defaultTab,children:g("toolBar.library")}),$(OO,{}),o.openDialog?.name==="ttd"&&$(Lg,{__fallback:!0}),o.isLoading&&$(ld,{delay:250}),o.errorMessage&&$(jT,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),S&&!y.editor.isMobile&&$(kb,{colorPickerType:S.colorPickerType,onCancel:()=>{L(null)},onChange:(R,V,Z,{altKey:W})=>{if(!(R!=="elementBackground"&&R!=="elementStroke"))if(Z.length){for(let se of Z)RO(se,DO(n),{[W&&S.swapPreviewOnAlt?R==="elementBackground"?"strokeColor":"backgroundColor":R==="elementBackground"?"backgroundColor":"strokeColor"]:V}),BO.delete(se);x.scene.triggerUpdate()}else r(R==="elementBackground"?{currentItemBackgroundColor:V}:{currentItemStrokeColor:V})},onSelect:(R,V)=>{L(Z=>Z?.keepOpenOnAlt&&V.altKey?Z:null),S?.onSelect?.(R,V)}}),o.openDialog?.name==="help"&&$(QT,{onClose:()=>{r({openDialog:null})}}),$(v2,{}),o.openDialog?.name==="elementLinkSelector"&&$($T,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),$(v.OverwriteConfirmDialogTunnel.Out,{}),A(),k(),o.pasteDialog.shown&&$(Uv,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&$(Hv,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:A,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:c,renderCustomStats:d,renderSidebars:U,device:y,renderWelcomeScreen:f,UIOptions:p}),!y.editor.isMobile&&Bt(m5,{children:[Bt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&J&&y.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&$(v.WelcomeScreenCenterTunnel.Out,{}),O(),$(Xv,{appState:o,actionManager:e,showExitZenModeBtn:m,renderWelcomeScreen:f}),o.scrolledOutside&&$("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(R=>({...Fr(n,R)}))},children:g("buttons.scrollBackToContent")})]}),U()]})]});return $(np.Provider,{value:o,children:$(C,{children:$(oh.Provider,{value:v,children:_})})})},d5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},HO=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return Xd(d5(r),d5(a),{selectedElementIds:Xd,selectedGroupIds:Xd})&&Xd(n,l)},p5=PO.memo(zO,HO);import GO from"clsx";import{jsx as u5,jsxs as YO}from"react/jsx-runtime";var UO="small",Kd=e=>YO("label",{className:GO("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${UO}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[u5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),u5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as WO,useRef as VO}from"react";import{jsx as h5}from"react/jsx-runtime";var g5=({trails:e})=>{let o=VO(null);return WO(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),h5("div",{className:"SVGLayer",children:h5("svg",{ref:o})})};import XO,{useEffect as KO,useRef as ZO}from"react";import{CURSOR_TYPE as f5,isShallowEqual as $O,sceneCoordsToViewportCoords as jO}from"@excalidraw/common";import{jsx as QO}from"react/jsx-runtime";var qO=e=>{let o=ZO(!1);return KO(()=>{if(!o.current){o.current=!0;return}let t=new Map,r=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,m)=>{if(s.selectedElementIds)for(let c of Object.keys(s.selectedElementIds))n.has(c)||n.set(c,[]),n.get(c).push(m);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(m,s.username),s.userState&&a.set(m,s.userState),r.set(m,jO({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(m,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Jw({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Si())}),QO("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?f5.GRAB:f5.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:g("labels.drawingCanvas")})},b5=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,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,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,activeLockedId:e.activeLockedId}),JO=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:$O(b5(e.appState),b5(o.appState)),Qg=XO.memo(qO,JO);import ez,{useEffect as x5,useRef as E5}from"react";import{isShallowEqual as y5}from"@excalidraw/common";import{jsx as rz}from"react/jsx-runtime";var tz=e=>{let o=E5(null),t=E5(!1);return x5(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),x5(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static")),p1({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Si())}),rz("div",{className:"excalidraw__canvas-wrapper",ref:o})},w5=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,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}),oz=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:y5(w5(e.appState),w5(o.appState))&&y5(e.renderConfig,o.renderConfig),ef=ez.memo(tz,oz);import{useEffect as dz,useRef as mz}from"react";import{throttleRAF as nz}from"@excalidraw/common";import{getTargetFrame as iz,isInvisiblySmallElement as az,renderElement as lz,shouldApplyFrameClip as sz}from"@excalidraw/element";var v5=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,m]=Dl(e,i),c=_l({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:m});if(c.save(),c.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(az(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=iz(t,r,a);p&&sz(t,p,a,r)&&d1(p,c,l,a)}lz(t,r,n,o,c,l,a)}else c.clearRect(0,0,s,m);c.restore()}},cz=nz(e=>{v5(e)},{trailing:!0}),T5=(e,o)=>{if(o){cz(e);return}v5(e)};import{jsx as uz}from"react/jsx-runtime";var pz=e=>{let o=mz(null);return dz(()=>{o.current&&T5({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Si())}),uz("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:o})},I5=pz;import{useCallback as hz,useEffect as gz,useRef as fz}from"react";import{jsx as C5,jsxs as xz}from"react/jsx-runtime";var bz=5e3,S5=({message:e,onClose:o,closable:t=!1,duration:r=bz,style:n})=>{let i=fz(0),a=r!==1/0,l=hz(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return gz(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),xz("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[C5("p",{className:"Toast__message",children:e}),t&&C5(K,{icon:Ft,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as Ez,getElementsInGroup as yz,selectGroupsFromGivenElements as wz}from"@excalidraw/element";import{sceneCoordsToViewportCoords as vz}from"@excalidraw/common";import{flushSync as Tz}from"react-dom";import{jsx as Cz}from"react/jsx-runtime";var Iz=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),r=t?[t]:yz(e.scene.getNonDeletedElementsMap(),o);if(r.length===0)return null;let[n,i]=Ez(r),{x:a,y:l}=vz({sceneX:n,sceneY:i},e.state);return Cz("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{Tz(()=>{let s=wz(r,e.state);e.setState({selectedElementIds:r.reduce((m,c)=>({...m,[c.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(Pa)},title:g("labels.elementLock.unlock"),children:_1})},k5=Iz;import{Fragment as wG,jsx as ue,jsxs as tm}from"react/jsx-runtime";var LI=So.createContext(null),PI=So.createContext(null),AI={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},Rf=So.createContext(AI);Rf.displayName="DeviceContext";var Nf=So.createContext({container:null,id:null});Nf.displayName="ExcalidrawContainerContext";var Bf=So.createContext([]);Bf.displayName="ExcalidrawElementsContext";var Ff=So.createContext({...qo(),width:0,height:0,offsetLeft:0,offsetTop:0});Ff.displayName="ExcalidrawAppStateContext";var Of=So.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Of.displayName="ExcalidrawSetAppStateContext";var zf=So.createContext(null);zf.displayName="ExcalidrawActionManagerContext";var Re=()=>Nr(LI),fo=()=>Nr(PI),ce=()=>Nr(Rf),Ge=()=>Nr(Nf),rr=()=>Nr(Bf),go=()=>Nr(Ff),le=()=>Nr(Of),Ue=()=>Nr(zf),xl=!1,Mf=0,El=null,mn=!1,yl=!1,Lf=!1,wl={horizontal:null,vertical:null},Rr=0,vl=!1,Pf=new Map,Af=!1,CI=0,SI=!1,Tl=null,pe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},_f=class e extends So.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"device",AI);I(this,"excalidrawContainerRef",So.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"resizeObserver");I(this,"nearestScrollableContainer");I(this,"library");I(this,"libraryItemsFromStorage");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"handleToastClose",()=>{this.setToast(null)});I(this,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new ZH);I(this,"flowChartNavigator",new $H);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastViewportPosition",{x:0,y:0});I(this,"animationFrameHandler",new Kc);I(this,"laserTrails",new od(this.animationFrameHandler,this));I(this,"eraserTrail",new ad(this.animationFrameHandler,this));I(this,"lassoTrail",new id(this.animationFrameHandler,this));I(this,"onChangeEmitter",new sn);I(this,"onPointerDownEmitter",new sn);I(this,"onPointerUpEmitter",new sn);I(this,"onUserFollowEmitter",new sn);I(this,"onScrollChangeEmitter",new sn);I(this,"missingPointerEventCleanupEmitter",new sn);I(this,"onRemoveEventListenersEmitter",new sn);I(this,"defaultSelectionTool","selection");I(this,"updateEditorAtom",(t,...r)=>{let n=He.set(t,...r);return this.triggerRender(),n});I(this,"getEffectiveGridSize",()=>fr(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),bl.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(Ko(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=Ef(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else Gi(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let i=n.getBoundingClientRect(),a=Oe({clientX:i.x,clientY:i.y},this.state),l=Oe({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===jd.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&kt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!nI(i,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===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=Jd({sceneX:i.x,sceneY:i.y},this.state),s=6,m,c=UH(i);if(i.id===this.state.editingFrame){let d=c;m=ue("input",{autoFocus:!0,value:d,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===Y.ESCAPE||p.key===Y.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?Vz:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Ar.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:d.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else m=c;return ue("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Ar.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Ar.nameFontSize,color:t?Ar.nameColorDarkTheme:Ar.nameColorLightTheme,lineHeight:Ar.nameLineHeight,width:"max-content",maxWidth:n?.id===i.id&&n?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:De.MOVE,pointerEvents:this.state.viewModeEnabled?Oi.disabled:Oi.enabled},onPointerDown:d=>this.handleCanvasPointerDown(d),onWheel:d=>this.handleWheel(d),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:m},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,r,n)=>{re("export",t,"ui");let i=await Zr(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(lH).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Nl(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,r),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Co.magicframe}),re("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&bf(t[0])&&t[0];if(!r&&t.some(i=>kt(i)||i.frameId)){this.setActiveTool({type:Co.magicframe});return}re("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=Hi(t),m=50;n=j5({...Ar,x:i-m,y:a-m,width:l-i+m*2,height:s-a+m*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let c of t)this.scene.mutateElement(c,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(or,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:ft.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:ft.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?_r(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:ft.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Pe(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||jd.LIGHT,s=t?.appState?.name??this.state.name,m=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(c=>{n?.id===c.id&&n!==c&&wI(c)&&mo(c)&&(n=c)}),n?.isDeleted&&(n=null),this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:m}}),r=!0}r||this.scene.triggerUpdate()}));I(this,"onBlur",Pe(()=>{mn=!1,this.setState({isBindingEnabled:!0})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Pe(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...qo(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async i=>{if(!i.files.length)return;let a=i.files[0],l=await a.getFile();this.loadFileToCanvas(new File([l],l.name||"",{type:l.type}),a)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(i=>{console.error(i)})}catch(i){console.error(i),t={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let r=xn(t,null,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=r.appState.activeTool;r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:n.type==="image"||n.type==="lasso"||n.type==="selection"?{...n,type:this.defaultSelectionTool}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...Fr(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:ft.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),Sf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileOrTablet",()=>{let t="ontouchstart"in window||navigator.maxTouchPoints>0,r="matchMedia"in window&&window?.matchMedia("(pointer: coarse)")?.matches;return uH||t&&r});I(this,"isMobileBreakpoint",(t,r)=>t<Hz||r<Oz&&t<zz);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=cf(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:Gz,a=this.device.editor,l=cf(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Pe(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>bl.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),z5||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(wl=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",U5(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},Uz));I(this,"onCut",Pe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||pl(t.target)||(this.actionManager.executeAction(oc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Pe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||pl(t.target)||(this.actionManager.executeAction(ei,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if($z&&t.preventDefault(),!xl){xl=!0,t.touches.length===1&&(El={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Mf),Mf=window.setTimeout(e.resetTapTwice,Yz);return}if(xl&&t.touches.length===1&&El){let r=t.touches[0];Pr(ne(r.clientX,r.clientY),ne(El.x,El.y))<=hH&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY})),xl=!1,clearTimeout(Mf)}t.touches.length===2&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}):pe.pointers.clear()});I(this,"pasteFromClipboard",Pe(async t=>{let r=!!Af,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||pl(n)))return;let l=await Ia(t),s=l.getFiles(),m=await jx(l,r);if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(c){console.error(c)}await this.insertClipboardContent(m,s,r),this.setActiveTool({type:this.defaultSelectionTool},!0),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=fm(t.elements,null,{deleteInvisibleElements:!0}),[n,i,a,l]=Hi(r),s=zi(n,a)/2,m=zi(i,l)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Oe({clientX:c,clientY:d},this.state),f=p-s,b=u-m,[x,w]=nt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=Q5({type:"everything",elements:r.map(k=>_r(k,{x:k.x+x-n,y:k.y+w-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,fI(v,Qd(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let k=WH(E,S);Tf(v,k,S,this.state)}this.scene.replaceAllElements(v),E.forEach(k=>{if(mo(k)&&ff(k)){let A=cI(k,this.scene.getElementsMapIncludingDeleted());BH(k,A,this.scene)}}),Jz&&jo.loadElementsFonts(E).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let L=dG(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&He.get(el)?this.state.openSidebar:null,...$t({editingGroupId:null,selectedElementIds:L.reduce((k,A)=>(ff(A)||(k[A.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.defaultSelectionTool},!0),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,r)=>{this.setState(t,r)});I(this,"removePointer",t=>{Rr&&this.resetContextMenuTimer(),pe.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||re("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Xo(this.state,r.activeTool.locked?{type:this.defaultSelectionTool}:r.activeTool),locked:!r.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Ix)});I(this,"zoomCanvas",t=>{this.setState({...Ao({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:uo(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(Sf(t)?s=JH(t):s=t,s){let m=this.scene.getElementsFromId(s);m?.length?this.scrollToContent(m,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):Sf(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=fa({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=Fr(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,m=this.state.scrollY,c=this.state.zoom.value,d=aH({fromValues:{scrollX:s,scrollY:m,zoom:c},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,sH(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});I(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});I(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});I(this,"setToast",t=>{this.setState({toast:t})});I(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,Az,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Pe(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===Vo.svg))try{let s=y1(sI(w1(l.dataURL)),Vo.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});I(this,"updateScene",Pe(t=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=t;if(a){let l=r||void 0,s=n?gH({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),i&&this.setState({collaborators:i})}));I(this,"applyDeltas",(t,r)=>{let n=TI.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return TI.applyTo(n,a,i,r)});I(this,"mutateElement",(t,r,n=!0)=>this.scene.mutateElement(t,r,{informMutation:n,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Pe(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));I(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Mo().rtl?{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width),0)+i,bottom:i,left:Math.max(r?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});I(this,"onKeyDown",Pe(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!Y5(t.target)){if((t.key===Y.ESCAPE||t.key===Y.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=j(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&cn(a[0])&&t.key===Y.ENTER){this.startImageCropping(a[0]);return}if(t.key===Y.ESCAPE)this.updateEditorAtom(io,null);else if(t.key===Y.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(pH.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=si(a);He.get(io)?.type==="panel"&&_u(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(io,{type:"panel"})}if(t.key===Y.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Zd(t.key);if(t[Y.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=j(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&MH(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,uI(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!xf(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(t.altKey){let s=j(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),uI(t.key));if(m){this.setState(d=>({selectedElementIds:ye({[m]:!0},d)}));let c=this.scene.getNonDeletedElementsMap().get(m);c&&!xf([c],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(c,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[Y.CTRL_OR_CMD]&&t.key===Y.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Ne("commandPalette")})}),t.preventDefault();return}if(t[Y.CTRL_OR_CMD]&&t.key.toLowerCase()===Y.V&&(Af=t.shiftKey,clearTimeout(CI),CI=window.setTimeout(()=>{Af=!1},100)),t[Y.CTRL_OR_CMD]&&pl(t.target)&&(t.code===R5.MINUS||t.code===R5.EQUAL)){t.preventDefault();return}if(pl(t.target)&&t.key!==Y.ESCAPE||Zd(t.key)&&Y5(t.target))return;if(t.key===Y.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===Y.E&&t.shiftKey&&t[Y.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===Y.PAGE_UP||t.key===Y.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===Y.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[Y.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Zd(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(We),s=new Set;a.filter(We).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let m=this.getEffectiveGridSize()&&(t.shiftKey?F5:this.getEffectiveGridSize())||(t.shiftKey?Rz:F5),c=0,d=0;t.key===Y.ARROW_LEFT?c=-m:t.key===Y.ARROW_RIGHT?c=m:t.key===Y.ARROW_UP?d=-m:t.key===Y.ARROW_DOWN&&(d=m),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+c,y:p.y+d},{informMutation:!1,isDragging:!1}),pf(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:uf(a.filter(p=>p.id!==l?.id||m!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===Y.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[Y.CTRL_OR_CMD]||kf(l))Zt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),We(l)||this.actionManager.executeAction(vi));else if(mo(l)||NH(l)){let s;mo(l)||(s=l);let m=wf(l,this.state,this.scene.getNonDeletedElementsMap()),c=m.x,d=m.y;this.startTextEditing({sceneX:c,sceneY:d,container:s}),t.preventDefault();return}else kt(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=p2(t.key,this);a?(this.state.activeTool.type!==a&&re("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Dr.sharp?Dr.round:l.currentItemArrowType===Dr.round?Dr.elbow:Dr.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===Y.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===Y.SPACE&&pe.pointers.size===0&&(mn=!0,xe(this.interactiveCanvas,De.GRAB),t.preventDefault()),(t.key===Y.G||t.key===Y.S)&&!t.altKey&&!t[Y.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===Y.G&&($o(this.state.activeTool.type)||a.some(l=>$o(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===Y.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[Y.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===Y.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>mo(l)||yf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===Y.K&&!t.altKey&&!t[Y.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.defaultSelectionTool}):this.setActiveTool({type:"laser"});return}t[Y.CTRL_OR_CMD]&&(t.key===Y.BACKSPACE||t.key===Y.DELETE)&&this.updateEditorAtom(en,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===Y.S&&t.shiftKey,i=t.key===Y.I||r===Y.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));I(this,"onKeyUp",Pe(t=>{if(t.key===Y.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,De.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Ht(this.interactiveCanvas):(At(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),mn=!1),!t[Y.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Zd(t.key)&&(Z5(this.scene.getSelectedElements(this.state).filter(Zt),mf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:ft.IMMEDIATELY})),!t[Y.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:ye({[r.id]:!0},n)})),xf([r],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(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:ft.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,r=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let n=Xo(this.state,t);n.type==="hand"?xe(this.interactiveCanvas,De.GRAB):mn||At(this.interactiveCanvas,{...this.state,activeTool:n}),oH(document.activeElement)&&this.focusContainer(),SH(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return n.type==="freedraw"&&this.store.scheduleCapture(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{xe(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{Ht(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>pe.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${W5()}`);I(this,"onGestureStart",Pe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null}),pe.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Pe(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=pe.initialScale;r&&this.setState(n=>({...Ao({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:uo(r*t.scale)},n)}))}));I(this,"onGestureEnd",Pe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}),pe.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(yf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let m=null,c=this.scene.getSelectedElements(this.state);c.length===1?mo(c[0])?m=c[0]:i?m=yf(c[0],this.scene.getNonDeletedElementsMap()):m=this.getTextElementAtPosition(t,r):m=this.getTextElementAtPosition(t,r);let d=m?.fontFamily||this.state.currentItemFontFamily,p=m?.lineHeight||G5(d),u=this.state.currentItemFontSize;if(!m&&l&&i&&!hf(i)){let w=oG(lf({fontSize:u,fontFamily:d}),p),E=rG(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=m||q5({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Kz.MIDDLE:B5,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?hf(i)?0:i.angle:0,frameId:f?f.id:null});if(!m&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!m)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||m||i?this.handleTextWysiwyg(b,{isExistingElement:!!m}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.defaultSelectionTool)return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=Oe(t,this.state);if(r.length===1&&Zt(r[0])){let l=r[0];if((t[Y.CTRL_OR_CMD]&&EG(l)||kf(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(vi);return}else if(this.state.selectedLinearElement&&We(r[0])){let s=Se.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=s?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(m&&m>-1){this.store.scheduleCapture(),Se.deleteFixedSegment(r[0],this.scene,m);let c=Se.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=c?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:d,value:s,added:!1}},segmentMidPointHoveredCoords:c}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&kf(l))return}if(r.length===1&&cn(r[0])){this.startImageCropping(r[0]);return}if(Ht(this.interactiveCanvas),sG(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&lG(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(m=>({...m,...$t({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),m,this)}));return}}if(Ht(this.interactiveCanvas),!t[Y.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(gl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(eI(s)||!iH(s.backgroundColor)||fl({point:ne(n,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let m=wf(s,this.state,this.scene.getNonDeletedElementsMap());n=m.x,i=m.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&Al(l,this.scene.getNonDeletedElementsMap(),this.state,ne(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=Pr(ne(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ne(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>_z)return;let i=Oe(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Al(this.hitLinkElement,a,this.state,ne(i.x,i.y),this.device.editor.isMobile),s=Oe(this.lastPointerUpEvent,this.state),m=Al(this.hitLinkElement,a,this.state,ne(s.x,s.y),this.device.editor.isMobile);if(l&&m){vu();let c=this.hitLinkElement.link;if(c){c=af(c);let d;if(this.props.onLinkOpen&&(d=rH(ee.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let p=Qz(c)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=c)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&dI(t,i,r));return n.length?n[n.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,pe.pointers.has(t.pointerId)&&pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=pe.initialScale;if(pe.pointers.size===2&&pe.lastCenter&&r&&pe.initialDistance){let f=_h(pe.pointers),b=f.x-pe.lastCenter.x,x=f.y-pe.lastCenter.y;pe.lastCenter=f;let w=Rh(Array.from(pe.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/pe.initialDistance,y=E?uo(r*E):this.state.zoom.value;this.setState(v=>{let C=Ao({viewportX:f.x,viewportY:f.y,nextZoom:y},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/y),scrollY:C.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else pe.lastCenter=pe.initialDistance=pe.initialScale=null;if(mn||yl||Lf||qt(this.state))return;let i=Uh(wl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Ht(this.interactiveCanvas):At(this.interactiveCanvas,this.state));let a=Oe(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Aw(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=Pw(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=ul(x.snapLines,b),E=x.originSnapOffset?ul(x.originSnapOffset,f):f;return x.snapLines===w&&x.originSnapOffset===E?null:{snapLines:w,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=Se.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&Fi(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&tI(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(tI(this.state.activeTool.type)){let{newElement:f}=this.state;gf(f,!1)?this.setState({suggestedBindings:X5(f,[a],this.scene,this.state.zoom,this.state.startBoundElement)}):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:f}=this.state,{x:b,y:x}=f,{points:w,lastCommittedPoint:E}=f,y=w[w.length-1];if(At(this.interactiveCanvas,this.state),y===E)Pr(ne(l-b,s-x),y)>=nf?this.scene.mutateElement(f,{points:[...w,ne(l-b,s-x)]},{informMutation:!1,isDragging:!1}):xe(this.interactiveCanvas,De.POINTER);else if(w.length>2&&E&&Pr(ne(l-b,s-x),E)<nf)xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=nt(l,s,t[Y.CTRL_OR_CMD]||We(f)?null:this.getEffectiveGridSize()),[S,L]=f?.lastCommittedPoint??[0,0],k=v-b-S,A=C-x-L;rf(t)&&({width:k,height:A}=rI(S+b,L+x,v,C)),aI(w,this.state.zoom.value)&&xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),ne(S+k,L+A)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&We(d[0]))){let f=xI(c,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){xe(this.interactiveCanvas,bI(f));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=EI(Hi(d),l,s,this.state.zoom,t.pointerType,this.device);if(f){xe(this.interactiveCanvas,bI({transformHandleType:f}));return}}let p=this.getElementAtPosition(l,s,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p,this.hitLinkElement=this.getElementLinkAtPosition(a,p),!bt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(xe(this.interactiveCanvas,De.POINTER),KE(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(vu(),u&&(u.link||Ko(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?xe(this.interactiveCanvas,mo(u)?De.TEXT:De.CROSSHAIR):this.state.viewModeEnabled?xe(this.interactiveCanvas,De.GRAB):this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,De.AUTO):i?xe(this.interactiveCanvas,De.AUTO):t[Y.CTRL_OR_CMD]?xe(this.interactiveCanvas,De.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!u?.locked&&(u&&gl(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(xe(this.interactiveCanvas,De.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!We(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||d.length>0)&&xe(this.interactiveCanvas,De.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s)),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:ul(f.hoveredElementIds,$t({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:ul(f.hoveredElementIds,{})})))});I(this,"handleEraser",(t,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});I(this,"handleTouchMove",t=>{vl=!0});I(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches&&{focusedId:null,matches:d.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(Tg,null)),He.get(io)&&this.updateEditorAtom(io,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let d=this.state.newElement;this.updateScene({...d.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==d.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:ye(Object.keys(this.state.selectedElementIds).filter(p=>p!==d.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?ft.EVENTUALLY:ft.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(d=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=cf(this.device,{isTouchScreen:!0})),yl||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===ln.ERASER&&this.state.activeTool.type!==Co.eraser){this.setState({activeTool:Xo(this.state,{type:Co.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),bt(this.state)&&this.setState({activeTool:Xo(this.state,{...this.state.activeTool.lastActiveTool||{type:Co.selection},lastActiveToolBeforeEraser:null})})},p=_e(window,ee.POINTER_UP,d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==ln.MAIN&&t.button!==ln.TOUCH&&t.button!==ln.ERASER||pe.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let d=i.hit.element&&this.isASelectedElement(i.hit.element),p=this.isMobileOrTablet();!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!d&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey),i.drag.blockDragging=!p),p&&i.hit.element&&!d&&(this.setState(u=>{let f={...u.selectedElementIds,[i.hit.element.id]:!0},b=[];Object.keys(u.selectedElementIds).forEach(w=>{let E=this.scene.getElement(w);E&&b.push(E)});let x=i.hit.element;if(kt(x))vf(b,x.id).forEach(w=>{delete f[w.id]});else if(x.frameId)f[x.frameId]&&delete f[x.id];else{let w=x.groupIds,E=new Set(w.flatMap(y=>dn(this.scene.getNonDeletedElements(),y)).filter(y=>kt(y)).map(y=>y.id));E.size>0&&b.forEach(y=>{y.frameId&&E.has(y.frameId)&&(delete f[y.id],y.groupIds.flatMap(v=>dn(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete f[v.id]}))})}return{...$t({editingGroupId:u.editingGroupId,selectedElementIds:f},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:x.link||Ko(x)?"info":!1}}),i.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?At(this.interactiveCanvas,this.state):this.state.activeTool.type===Co.frame||this.state.activeTool.type===Co.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),m=this.onKeyDownFromPointerDownHandler(i),c=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(d=>s(d||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(ee.POINTER_MOVE,l),window.addEventListener(ee.POINTER_UP,s),window.addEventListener(ee.KEYDOWN,m),window.addEventListener(ee.KEYUP,c),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=c,i.eventListeners.onKeyDown=m)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Oe({clientX:t.clientX,clientY:t.clientY},this.state),n=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(gl(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&gl(this.hitLinkElement)&&!a1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,ne(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(vl=!1,Rr?vl=!0:Rr=window.setTimeout(()=>{Rr=0,vl||this.handleCanvasContextMenu(t)},Xz))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Rr),Rr=0,vl=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Tl?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(pe.pointers.size<=1&&(t.button===ln.WHEEL||t.button===ln.MAIN&&mn||qt(this.state)||this.state.viewModeEnabled)))return!1;yl=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);xe(this.interactiveCanvas,De.GRABBING);let{clientX:i,clientY:a}=t,l=rd(m=>{let c=i-m.clientX,d=a-m.clientY;if(i=m.clientX,a=m.clientY,n&&!r&&(Math.abs(c)>1||Math.abs(d)>1)){r=!0;let p=f=>{document.body.removeEventListener(ee.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ee.PASTE,p),window.removeEventListener(ee.POINTER_UP,u)},100)};document.body.addEventListener(ee.PASTE,p),window.addEventListener(ee.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=Pe(Tl=()=>{Tl=null,yl=!1,mn||(this.state.viewModeEnabled?xe(this.interactiveCanvas,De.GRAB):At(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,l),window.removeEventListener(ee.POINTER_UP,s),window.removeEventListener(ee.BLUR,s),l.flush()});return window.addEventListener(ee.BLUR,s),window.addEventListener(ee.POINTER_MOVE,l,{passive:!0}),window.addEventListener(ee.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!We(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=xI(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else a.length>1&&(r.resize.handleType=EI(Hi(a),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=sf(pG(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&Zt(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=uG(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Se.handlePointerDown(t,this,this.store,r.origin,p,this.scene);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),m=this.getElementAtPosition(r.origin.x,r.origin.y,{allHitElements:l});if((!m||m.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),m&&m.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,m),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let c=r.hit.element,d=r.hit.allHitElements.some(p=>this.isASelectedElement(p));if((c===null||!d)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(c),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:ye({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(c!=null){if(t[Y.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(r.origin.x,r.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[c.id]||(r.hit.wasAddedToSelection=!0),this.setState(p=>({...aG(p,c),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[c.id]||(this.state.editingGroupId&&!gI(c,this.state.editingGroupId)&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!d&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[c.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),kt(c))vf(f,c.id).forEach(b=>{delete u[b.id]});else if(c.frameId)u[c.frameId]&&delete u[c.id];else{let b=c.groupIds,x=new Set(b.flatMap(w=>dn(this.scene.getNonDeletedElements(),w)).filter(w=>kt(w)).map(w=>w.id));x.size>0&&f.forEach(w=>{w.frameId&&x.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(E=>dn(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(c.groupIds.some(b=>p.selectedGroupIds[b])||(u={[c.id]:!0})),{...$t({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:c.link||Ko(c)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);eI(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Ht(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Xo(this.state,{type:this.defaultSelectionTool})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=nt(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,m=EH({type:r,x:i,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:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[ne(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(m),this.setState(d=>{let p={...d.selectedElementIds};return delete p[m.id],{selectedElementIds:ye(p,d)}});let c=df(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:m,startBoundElement:c,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=nt(t,r,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=yH({type:"iframe",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("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.scene.insertElement(s),s});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=nt(t,r,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=em(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=$5({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});I(this,"newImagePlaceholder",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=nt(t,r,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return TH({type:"image",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:l?l.id:null,x:i-s/2,y:a-s/2,width:s,height:s})});I(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&aI(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Dt);return}if(We(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Dt);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Pr(ne(n.origin.x-a,n.origin.y-l),s)<nf){this.actionManager.executeAction(Dt);return}this.setState(m=>({selectedElementIds:ye({...m.selectedElementIds,[i.id]:!0},m)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),xe(this.interactiveCanvas,De.POINTER)}else{let[i,a]=nt(n.origin.x,n.origin.y,t[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:m}=this.state,[c,d]=r==="arrow"?[s,m]:[null,null],p=r==="arrow"?wH({type:r,x:i,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.state.currentItemArrowType===Dr.round?{type:$d.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Dr.elbow,fixedSegments:this.state.currentItemArrowType===Dr.elbow?[]:null}):IH({type:r,x:i,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.state.currentItemRoundness==="round"?{type:$d.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:ye(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,ne(0,0)]});let u=df(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,We(p),We(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=nt(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=$5({type:"embeddable",...l}):s=vH({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=nt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Ar},l=r===Co.magicframe?j5(a):xH(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||ff(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,_r(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});I(this,"initializeImage",async(t,r)=>{if(!bm(r))throw new Error(g("errors.unsupportedFileType"));let n=r.type;if(xe(this.interactiveCanvas,"wait"),n===Vo.svg)try{r=wm(sI(await r.text()),r.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(r)||E1(r));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{r=await Fl(r,{maxWidthOrHeight:Dz})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(r.size>O5)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(O5/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await ym(r);return new Promise(async(s,m)=>{try{let c=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:n,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([c]);if(p.size)throw new Error("Image cache update resulted with an error.")}let d=await this.imageCache.get(i)?.image;if(d&&this.state.newElement?.id!==c.id){c=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(c,d);Object.assign(c,p)}s(c)}catch(c){console.error(c),m(new Error(g("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,r)=>{let n=this.scene.getElement(t.id)??t;return _r(n,{fileId:r})});I(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Oe({clientX:t,clientY:r},this.state),a=await Ll({description:"Image",extensions:Object.keys(Nz),multiple:!0});this.insertImages(a,n,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Xo(this.state,{type:this.defaultSelectionTool})},()=>{this.actionManager.executeAction(Dt)})}});I(this,"getImageNaturalDimensions",(t,r)=>{let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(r.naturalHeight,i),l=a*(r.naturalWidth/r.naturalHeight),s=t.x+t.width/2-l/2,m=t.y+t.height/2-a/2;return{x:s,y:m,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await RH({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});return i.size&&(this.store.scheduleAction(ft.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>hl(a)&&i.has(a.fileId)?_r(a,{status:"error"}):a))),{updatedFiles:n,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=_H(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);if(i.size)for(let a of n)i.has(a.fileId)&&bl.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",Sz(()=>{this.addNewImagesToImageCache()},Bz));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=bH(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=df(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(ee.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ee.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ee.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ee.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,r,n)=>{let i=50/this.state.zoom.value,a=II(t.map(()=>this.newImagePlaceholder({sceneX:r,sceneY:n})),r,n,i);a.forEach(p=>this.scene.insertElement(p));let l=await Promise.all(a.map(async(p,u)=>{try{return await this.initializeImage(p,t[u])}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),_r(p,{isDeleted:!0})}})),s=Qd(l),m=II(l.filter(p=>!p.isDeleted),r,n,i),c=Qd(m),d=this.scene.getElementsIncludingDeleted().map(p=>c.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:ye(Object.fromEntries(m.map(p=>[p.id,!0])),this.state)},elements:d,captureUpdate:ft.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(Dt)})});I(this,"handleAppOnDrop",async t=>{let{x:r,y:n}=Oe(t,this.state),i=await Ia(t),a=i.getFiles();if(a.length===1){let{file:c,fileHandle:d}=a[0];if(c&&(c.type===Vo.png||c.type===Vo.svg))try{let p=await Bl(c,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:ft.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}}let l=a.map(c=>c.file).filter(c=>bm(c));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,r,n);let s=i.getData(Vo.excalidrawlib);if(s&&typeof s=="string"){try{let c=x1(s);this.addElementsFromPasteOrLibrary({elements:Ec(c),position:t,files:null})}catch(c){this.setState({errorMessage:c.message})}return}if(a.length>0){let{file:c,fileHandle:d}=a[0];c&&await this.loadFileToCanvas(c,d)}let m=i.findByType(Vo.text);if(m){let c=m.value;if(c&&Ef(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||em(c)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:r,sceneY:n,link:af(c)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,r)=>{t=await Ol(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await xm(t,this.state,n,r)}catch(a){let l=a instanceof r1;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===Vo.excalidraw?(MI(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:ft.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:ft.IMMEDIATELY})):i.type===Vo.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==ln.SECONDARY)&&this.state.activeTool.type!==this.defaultSelectionTool)return;let{x:r,y:n}=Oe(t,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},a),s=i||l?"element":"canvas",m=this.excalidrawContainerRef.current,{top:c,left:d}=m.getBoundingClientRect(),p=t.clientX-d,u=t.clientY-c;re("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...$t({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Zt(i)?new Se(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){yI({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:zi(t.origin.x,a.x),height:zi(t.origin.y,a.y),shouldMaintainAspectRatio:ml(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,m]=nt(a.x,a.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=hl(l)&&this.imageCache.get(l.fileId)?.image,d=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=Lw(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:m-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,m+=p.y,this.setState({snapLines:u}),yI({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:m,width:zi(t.originInGrid.x,s),height:zi(t.originInGrid.y,m),shouldMaintainAspectRatio:cn(l)?!ml(r):ml(r),shouldResizeFromCenter:N5(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===Co.frame||this.state.activeTool.type===Co.magicframe)&&this.setState({elementsToHighlight:If(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=nt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&cn(s)){let m=t.originalElements.get(s.id),c=hl(s)&&this.imageCache.get(s.fileId)?.image;if(m&&cn(m)&&c&&!(c instanceof Promise)){let[d,p]=nt(i.x,i.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:f,snapLines:b}=Oh([s],[m],this,r,u,n);this.scene.mutateElement(s,jH(s,this.scene.getNonDeletedElementsMap(),n,c.naturalWidth,c.naturalHeight,a+f.x,l+f.y,r.shiftKey?m.width/m.height:void 0)),pf(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>kt(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&We(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,m]=nt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(i.forEach(d=>{vf(this.scene.getNonDeletedElements(),d.id).forEach(u=>{c.set(d.id+u.id,{x:u.x-d.x,y:u.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,p]=nt(l.x,l.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=Oh(n,j(f,this.state),this,r,u,a);s+=b.x,m+=b.y,this.setState({snapLines:x})}if(hG(t.originalElements,a,n,this.scene,rf(r),N5(r),n.some(d=>cn(d))?!ml(r):ml(r),s,m,t.resize.center.x,t.resize.center.y)){let d=uf(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{If(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});I(this,"getContextMenuItems",t=>{let r=[];return r.push(nc,rc),t==="canvas"?this.state.viewModeEnabled?[...r,ac,ti,Ah,oi]:[su,Ye,nc,rc,ic,Ye,tp,QE,Ye,ac,cu,ti,Ah,oi]:(r.push(ic),this.state.viewModeEnabled?[ei,...r]:[Ye,oc,ei,su,Ye,lw,sw,cw,Ye,kh,Ye,...r,Ye,qp,Jp,Ye,tu,fw,pu,uu,OE,ou,Ye,iu,Ye,qm,Jm,Qm,ep,Ye,au,lu,Ye,vi,Ye,La,hc,Ye,op,Pa,Ye,na])});I(this,"handleWheel",Pe(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[Y.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),yl)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=Zz*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let m=this.state.zoom.value-s/100;m+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(c=>({...Ao({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:uo(m)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-r/i.value,scrollY:l-n/i.value}))}));I(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=Oe({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:pe.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",U5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:m,offsetTop:c,offsetLeft:d}=this.state;if(n===s&&i===m&&a===d&&l===c){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=qo();this.defaultSelectionTool=this.isMobileOrTablet()?"lasso":"selection";let{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:m=r.theme,name:c=`${g("labels.untitled")}-${W5()}`}=t;if(this.state={...r,theme:m,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.id=Mz(),this.library=new Cy(this),this.actionManager=new Xc(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new vI,this.canvas=document.createElement("canvas"),this.rc=kz.canvas(this.canvas),this.renderer=new qa(this.scene),this.visibleElements=[],this.store=new bG(this),this.history=new Xa(this.store),n){let d={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},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:p=>this.onChangeEmitter.on(p),onIncrement:p=>this.store.onStoreIncrementEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof n=="function"?n(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new jo(this.scene),this.history=new Xa(this.store),this.actionManager.registerAll(cs),this.actionManager.registerAction(pw(this.history)),this.actionManager.registerAction(uw(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(qd).includes(i)&&Pf.set(n,i)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),Gi(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=Pf.get(t.id);switch(n||(Pf.set(t.id,qd.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case qd.PLAYING:case qd.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,i){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Ko(a)&&this.embedsValidationStatus.get(a.id)===!0||Gi(a));return ue(wG,{children:i.map(a=>{let{x:l,y:s}=Jd({sceneX:a.x,sceneY:a.y},this.state),m=nI(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(a.id);if(m&&!c&&this.initializedEmbeds.add(a.id),!(m||c))return null;let p;if(Gi(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>lI(`
23
26
  <style>
24
27
  html, body {
25
28
  width: 100%;
26
29
  height: 100%;
27
- color: ${this.state.theme===Nd.DARK?"white":"black"};
30
+ color: ${this.state.theme===jd.DARK?"white":"black"};
28
31
  }
29
32
  body {
30
33
  display: flex;
@@ -91,7 +94,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),ne("ai","me
91
94
  </svg>
92
95
  </div>
93
96
  <div>Generating...</div>
94
- `)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>PT(`
97
+ `)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>lI(`
95
98
  <style>
96
99
  html, body {
97
100
  height: 100%;
@@ -101,7 +104,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),ne("ai","me
101
104
  flex-direction: column;
102
105
  align-items: center;
103
106
  justify-content: center;
104
- color: ${IO.red[3]};
107
+ color: ${Pz.red[3]};
105
108
  }
106
109
  h1, h3 {
107
110
  margin-top: 0;
@@ -110,7 +113,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),ne("ai","me
110
113
  </style>
111
114
  <h1>Error!</h1>
112
115
  <h3>${x}</h3>
113
- `)}}}else p=zd(ZO(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return ue("div",{className:q5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:m?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:m?"block":"none",opacity:Qz(a,sf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?VO:1),"--embeddable-radius":`${Cz(Math.min(a.width,a.height),a)}px`},children:Hd("div",{className:"excalidraw__embeddable-container__inner",style:{width:m?`${a.width}px`:0,height:m?`${a.height}px`:0,transform:m?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Pi.enabled:Pi.disabled},children:[f&&ue("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),ue("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Uo(a)?this.props.renderEmbeddable?.(a,this.state):null)??ue("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.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:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:n,renderCustomStats:r}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,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});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",c=t[0],d=ze.get(eo)?.type==="panel";return ue("div",{className:q5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":m?Pi.disabled:Pi.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:ue(JT.Provider,{value:this,children:ue(QT.Provider,{value:this.props,children:ue(xf.Provider,{value:this.excalidrawContainerValue,children:ue(bf.Provider,{value:this.device,children:ue(wf.Provider,{value:this.setAppState,children:ue(yf.Provider,{value:this.state,children:Hd(Ef.Provider,{value:this.scene.getNonDeletedElements(),children:[Hd(vf.Provider,{value:this.actionManager,children:[ue(N5,{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:Io().code,renderTopRightUI:n,renderCustomStats:r,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.defaultSelectionTool&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),ue("div",{className:"excalidraw-textEditorContainer"}),ue("div",{className:"excalidraw-contextMenuContainer"}),ue("div",{className:"excalidraw-eye-dropper-container"}),ue(O5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ue(hE,{element:c,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&Qg(c)&&ue(Rh,{element:c,elementsMap:a,children:ue(Dd,{title:g("labels.convertToCode"),icon:Kl,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&_i(c)&&c.customData?.generationData?.status==="done"&&Hd(Rh,{element:c,elementsMap:a,children:[ue(Dd,{title:g("labels.copySource"),icon:yr,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),ue(Dd,{title:"Enter fullscreen",icon:A0,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(c);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&ue($5,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&ue(Jw,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:p=>{this.setState({contextMenu:null},()=>{this.focusContainer(),p?.()})}}),ue(Fg,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:s,visibleElements:l,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:dn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&ue(K5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),ue(Bg,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,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&&ue(ev,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&ue(j5,{app:this,activeLockedId:this.state.activeLockedId}),d&&ue(AE,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=Fz(this.scene.getNonDeletedElements(),t).filter(l=>!Qg(l));if(!i.length){n==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ne("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),ne("ai","generate (start)","d2c");try{let{html:l}=await r({frame:t,children:i});if(ne("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){ne("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(so(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let n=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{ol(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),il.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,gf()||jT()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},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.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(r=>{t(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),gf()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),sT&&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),AO()&&!Kz()&&this.setState({errorMessage:ue(Zw,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new VT,this.fonts=new Vo(this.scene),this.renderer=new za(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(),this.store.onDurableIncrementEmitter.clear(),il.destroy(),Ut.destroy(),clearTimeout(Ln),Ee.clearCache(),Kt.clearCache(),Ln=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(De(document,ee.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(De(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),De(window,ee.MESSAGE,this.onWindowMessage,!1),De(document,ee.POINTER_UP,this.removePointer,{passive:!1}),De(document,ee.COPY,this.onCopy,{passive:!1}),De(document,ee.KEYUP,this.onKeyUp,{passive:!0}),De(document,ee.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),De(document.fonts,"loadingdone",t=>{let n=t.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),De(document,ee.GESTURE_START,this.onGestureStart,!1),De(document,ee.GESTURE_CHANGE,this.onGestureChange,!1),De(document,ee.GESTURE_END,this.onGestureEnd,!1),De(window,ee.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(De(document,ee.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),De(document,ee.PASTE,this.pasteFromClipboard,{passive:!1}),De(document,ee.CUT,this.onCut,{passive:!1}),De(window,ee.RESIZE,this.onResize,!1),De(window,ee.UNLOAD,this.onUnload,!1),De(window,ee.BLUR,this.onBlur,!1),De(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),De(this.excalidrawContainerRef.current,ee.DRAG_OVER,this.disableEvent,!1),De(this.excalidrawContainerRef.current,ee.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(De($O(this.excalidrawContainerRef.current),ee.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,n){this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),n.userToFollow&&!this.state.collaborators.has(n.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(n.zoom.value!==this.state.zoom.value||n.scrollX!==this.state.scrollX||n.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)),n.userToFollow!==this.state.userToFollow&&(n.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:n.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&ft(this.state)&&this.setState({activeTool:Go(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&wp(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),ft(n)&&!ft(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),n.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(n.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&n.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===Nd.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(At)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){al=!1,ll=null}async insertClipboardContent(t,n,r){let{x:i,y:a}=Fe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(n.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(t.spreadsheet&&!r){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=n.map(c=>c.file).filter(c=>Il(c));if(l.length===0&&t.text&&!r){let c=t.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&l.push(rm(c))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(t.elements){let c=t.programmaticAPI?bi(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:c,files:t.files||null,position:this.isMobileOrTablet()?"center":"cursor",retainSeed:r});return}if(!t.text)return;if(!r&&Nw(t.text)){let c=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:d,files:p}=await c.parseMermaidToExcalidraw(t.text),u=bi(d,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:this.isMobileOrTablet()?"center":"cursor"});return}catch(d){console.warn(`parsing pasted text as mermaid definition failed: ${d.message}`)}}let s=nz(t.text).split(/\n+/).map(c=>c.trim()).filter(Boolean),m=s.map(c=>Sz(c)).filter(c=>tf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||zd(c)?.type==="video"));if(!r&&m.length>0&&m.length===s.length){let c=[];for(let d of m){let p=c[c.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Ug(d)});u&&c.push(u)}c.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(c.map(d=>[d.id,!0]))}));return}this.addTextFromPaste(t.text,r)}async addElementsFromMixedContentPaste(t,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(c=>c.type==="imageUrl").map(c=>c.value),l=await Promise.all(a.map(async c=>{try{return{file:await r1(c)}}catch(d){let p=d.message;return d.cause==="FETCH_ERROR"?p=g("errors.failedToFetchImage"):d.cause==="UNSUPPORTED"&&(p=g("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(c=>!!c.file).map(c=>c.file);await this.insertImages(s,r,i);let m=l.find(c=>!!c.errorMessage);m&&m.errorMessage&&this.setState({errorMessage:m.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
116
+ `)}}}else p=em(eH(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return ue("div",{className:M5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:m?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:m?"block":"none",opacity:iG(a,Cf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?qz:1),"--embeddable-radius":`${AH(Math.min(a.width,a.height),a)}px`},children:tm("div",{className:"excalidraw__embeddable-container__inner",style:{width:m?`${a.width}px`:0,height:m?`${a.height}px`:0,transform:m?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Oi.enabled:Oi.disabled},children:[f&&ue("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),ue("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Ko(a)?this.props.renderEmbeddable?.(a,this.state):null)??ue("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.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:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,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});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",c=t[0],d=He.get(io)?.type==="panel";return ue("div",{className:M5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":m?Oi.disabled:Oi.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:ue(LI.Provider,{value:this,children:ue(PI.Provider,{value:this.props,children:ue(Nf.Provider,{value:this.excalidrawContainerValue,children:ue(Rf.Provider,{value:this.device,children:ue(Of.Provider,{value:this.setAppState,children:ue(Ff.Provider,{value:this.state,children:tm(Bf.Provider,{value:this.scene.getNonDeletedElements(),children:[tm(zf.Provider,{value:this.actionManager,children:[ue(p5,{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:Mo().code,renderTopRightUI:r,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&&this.state.activeTool.type===this.defaultSelectionTool&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),ue("div",{className:"excalidraw-textEditorContainer"}),ue("div",{className:"excalidraw-contextMenuContainer"}),ue("div",{className:"excalidraw-eye-dropper-container"}),ue(g5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ue(VE,{element:c,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&bf(c)&&ue(qh,{element:c,elementsMap:a,children:ue(Kd,{title:g("labels.convertToCode"),icon:os,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&Gi(c)&&c.customData?.generationData?.status==="done"&&tm(qh,{element:c,elementsMap:a,children:[ue(Kd,{title:g("labels.copySource"),icon:Sn,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),ue(Kd,{title:"Enter fullscreen",icon:K0,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(c);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&ue(S5,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&ue(Lv,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:p=>{this.setState({contextMenu:null},()=>{this.focusContainer(),p?.()})}}),ue(ef,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:s,visibleElements:l,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:fr(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&ue(I5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),ue(Qg,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,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&&ue(Av,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&ue(k5,{app:this,activeLockedId:this.state.activeLockedId}),d&&ue(sy,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=YH(this.scene.getNonDeletedElements(),t).filter(l=>!bf(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),re("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),re("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(re("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){re("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(ro(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{hl(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),bl.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,Df()||kI()){let n=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},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.onDurableIncrementEmitter.on(n=>{this.history.record(n.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(n=>{t(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Df()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),z5&&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),Fz()&&!QH()&&this.setState({errorMessage:ue(Cv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new vI,this.fonts=new jo(this.scene),this.renderer=new qa(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(),this.store.onDurableIncrementEmitter.clear(),bl.destroy(),Wt.destroy(),clearTimeout(Rr),Ee.clearCache(),$t.clearCache(),Rr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(_e(document,ee.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(_e(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),_e(window,ee.MESSAGE,this.onWindowMessage,!1),_e(document,ee.POINTER_UP,this.removePointer,{passive:!1}),_e(document,ee.COPY,this.onCopy,{passive:!1}),_e(document,ee.KEYUP,this.onKeyUp,{passive:!0}),_e(document,ee.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),_e(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),_e(document,ee.GESTURE_START,this.onGestureStart,!1),_e(document,ee.GESTURE_CHANGE,this.onGestureChange,!1),_e(document,ee.GESTURE_END,this.onGestureEnd,!1),_e(window,ee.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(_e(document,ee.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),_e(document,ee.PASTE,this.pasteFromClipboard,{passive:!1}),_e(document,ee.CUT,this.onCut,{passive:!1}),_e(window,ee.RESIZE,this.onResize,!1),_e(window,ee.UNLOAD,this.onUnload,!1),_e(window,ee.BLUR,this.onBlur,!1),_e(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),_e(this.excalidrawContainerRef.current,ee.DRAG_OVER,this.disableEvent,!1),_e(this.excalidrawContainerRef.current,ee.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(_e(tH(this.excalidrawContainerRef.current),ee.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&bt(this.state)&&this.setState({activeTool:Xo(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&Bp(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),bt(r)&&!bt(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===jd.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(Dt)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){xl=!1,El=null}async insertClipboardContent(t,r,n){let{x:i,y:a}=Oe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(r.length===0&&!n&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:n,sceneX:i,sceneY:a});return}if(t.spreadsheet&&!n){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=r.map(c=>c.file);if(l.length===0&&t.text&&!n){let c=t.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&l.push(wm(c))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(t.elements){let c=t.programmaticAPI?Ci(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:c,files:t.files||null,position:this.isMobileOrTablet()?"center":"cursor",retainSeed:n});return}if(!t.text)return;if(!n&&pv(t.text)){let c=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:d,files:p}=await c.parseMermaidToExcalidraw(t.text),u=Ci(d,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:this.isMobileOrTablet()?"center":"cursor"});return}catch(d){console.warn(`parsing pasted text as mermaid definition failed: ${d.message}`)}}let s=cH(t.text).split(/\n+/).map(c=>c.trim()).filter(Boolean),m=s.map(c=>DH(c)).filter(c=>Ef(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||em(c)?.type==="video"));if(!n&&m.length>0&&m.length===s.length){let c=[];for(let d of m){let p=c[c.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:af(d)});u&&c.push(u)}c.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(c.map(d=>[d.id,!0]))}));return}this.addTextFromPaste(t.text,n)}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(c=>c.type==="imageUrl").map(c=>c.value),l=await Promise.all(a.map(async c=>{try{return{file:await v1(c)}}catch(d){let p=d.message;return d.cause==="FETCH_ERROR"?p=g("errors.failedToFetchImage"):d.cause==="UNSUPPORTED"&&(p=g("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(c=>!!c.file).map(c=>c.file);await this.insertImages(s,n,i);let m=l.find(c=>!!c.errorMessage);m&&m.errorMessage&&this.setState({errorMessage:m.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
114
117
 
115
- `),n)}}addTextFromPaste(t,n=!1){let{x:r,y:i}=Fe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:WO,verticalAlign:iT,locked:!1},l=Yg({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=dT(a.fontFamily),[m,,c]=Gz(this.state),d=Math.max(Math.min((c-m)*.5,800),200),p=10,u=i,f=n?[t]:t.split(`
116
- `),b=f.reduce((x,w,E)=>{let y=Zz(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),C=FT(y,l,s),S=C.width>d,L=S?Vz(y,l,d):y;C=S?FT(L,l,s):C;let k=r-C.width/2,A=u-C.height/2,P=yT({...a,x:k,y:A,text:L,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(P),u+=P.height+p}else f[E-1]?.trim()&&(u+=$z(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ye(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!n&&b.length>1&&$T===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:JO("CtrlOrCmd+Shift+V")}),duration:5e3}),$T=!0))}handleTextWysiwyg(t,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&io(s)?Mn(s,{originalText:a,isDeleted:l??s.isDeleted,...Ez(s,DT(s,r),r,a)}):s)])};Rw({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:m}=Fd({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,m-this.state.offsetTop]},onChange:Le(a=>{i(a,!1),WT(t)&&Zg(t,this.scene)}),onSubmit:Le(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let m=t.containerId?t.containerId:t.id;Li(()=>{this.setState(c=>({selectedElementIds:ye({...c.selectedElementIds,[m]:!0},c)}))})}s&&dz(this.scene.getNonDeletedElements(),[t]),(!s||n)&&this.store.scheduleCapture(),Li(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Pt(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,n){let r=this.getElementAtPosition(t,n,{includeBoundTextElement:!0});return r&&io(r)&&!r.isDeleted?r:null}getElementAtPosition(t,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,n,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return rl({point:re(t,n),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:St(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,n,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(io(s)&&s.containerId)))).filter(s=>this.hitElement(t,n,s)).filter(s=>{let m=sf(s,a);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?_T({x:t,y:n},m,a):!0}).filter(s=>_i(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(cT/this.state.zoom.value))}hitElement(t,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&Az([r],this.state)&&pH(re(t,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||zz(re(t,n),r,this.scene.getNonDeletedElementsMap())?!0:rl({point:re(t,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:St(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,n){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return CT(i[0],!1)?i[0]:null;let a=null;for(let l=r.length-1;l>=0;--l){if(r[l].isDeleted)continue;let[s,m,c,d]=fT(r[l],this.scene.getNonDeletedElementsMap());if(jg(r[l])&&rl({point:re(t,n),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<t&&t<c&&m<n&&n<d){a=r[l];break}}return CT(a,!1)?a:null}handleHoverSelectedLinearElement(t,n,r){let i=this.scene.getNonDeletedElementsMap(),a=Ce.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;rl({point:re(n,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Ce.getPointIndexUnderCursor(a,i,this.state.zoom,n,r),s=Ce.getSegmentMidpointHitCoords(t,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Ye(a)?l===0||l===a.points.length-1:l>=0)||s?xe(this.interactiveCanvas,Ae.POINTER):this.hitElement(n,r,a)&&(!Ye(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,Ae.MOVE)):this.hitElement(n,r,a)&&(!Ye(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,Ae.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Ce.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else xe(this.interactiveCanvas,Ae.AUTO)}updateGestureOnPointerDown(t){pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),pe.pointers.size===2&&(pe.lastCenter=fh(pe.pointers),pe.initialScale=this.state.zoom.value,pe.initialDistance=bh(Array.from(pe.pointers.values())))}initialPointerDownState(t){let n=Fe(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=Di(r),m=r.findIndex(Ye)===0;return{origin:n,withCmdOrCtrl:t[Y.CTRL_OR_CMD],originInGrid:Wg(nt(n.x,n.y,t[Y.CTRL_OR_CMD]||m?null:this.getEffectiveGridSize())),scrollbars:Ch(cl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((c,d)=>(c.set(d.id,wT(d)),c),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(n,r)},drag:{hasOccurred:!1,offset:null,origin:{...n},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;pf=!0,n.lastCoords.x=t.clientX,n.lastCoords.y=t.clientY;let r=Uc(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,n)}),i=Le(()=>{ml=null,pf=!1,Pt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,r),window.removeEventListener(ee.POINTER_UP,i),r.flush()});return ml=i,window.addEventListener(ee.POINTER_MOVE,r),window.addEventListener(ee.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,n){if(n.length<2)return!1;let r=Math.max(cT/this.state.zoom.value,1),[i,a,l,s]=Di(n);return t.x>i-r&&t.x<l+r&&t.y>a-r&&t.y<s+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:wz(t)?Rd.ADAPTIVE_RADIUS:Rd.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,n,r=!1){Bo({event:t,app:this,selectedElements:n})&&(r||!Ut.getReferenceSnapPoints())&&Ut.setReferenceSnapPoints(j2(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,n,r=!1){Bo({event:t,app:this,selectedElements:n})&&(r||!Ut.getVisibleGaps())&&Ut.setVisibleGaps($2(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Le(n=>{this.maybeHandleResize(t,n)||this.maybeDragNewGenericElement(t,n)})}onKeyUpFromPointerDownHandler(t){return Le(n=>{n.key===Y.ALT&&n.preventDefault(),!this.maybeHandleResize(t,n)&&this.maybeDragNewGenericElement(t,n)})}onPointerMoveFromPointerDownHandler(t){return Uc(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Fe(n,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=nt(r.x,r.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Ce.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Ce.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Ce.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=Wg(dH(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,t))return;if(ft(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[l,s]=nt(r.x,r.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&In(re(r.x,r.y),re(t.origin.x,t.origin.y))*this.state.zoom.value<hT)return;if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,n)||this.maybeHandleResize(t,n)))return!0;let m=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Ce.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,m)){let f=Ce.addMidpoint(this.state.selectedLinearElement,r,this,!n[Y.CTRL_OR_CMD],this.scene);if(!f)return;Li(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=Ce.handlePointDragging(n,this,r.x,r.y,p);if(u){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,this.setState(u);return}}let c=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((c||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(x=>x.locked))return;let u=p.find(x=>St(x)),f=this.getTopLayerFrameAtSceneCoords(r),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Li(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.isMobileOrTablet()&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},w=[...t.originalElements.values()],E=n.shiftKey;if(E){let C=Math.abs(x.x),S=Math.abs(x.y),L=E&&C<S,k=E&&C>S;L&&(x.x=0),k&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&or(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,L=ol(C)&&this.imageCache.get(C.fileId)?.image;if(L&&!(L instanceof Promise)){let k=TO(Q5(r.x-i.x,r.y-i.y),Math.max(this.state.zoom.value,2)),[A,P,N,O,U,J]=fT(C,m),_=zg(Og(re(A,P),re(U,J),C.angle)),R=zg(Og(re(N,P),re(U,J),C.angle)),V=zg(Og(re(A,O),re(U,J),C.angle)),Z=oT(eT(R,_)),W=oT(eT(V,_)),se=Q5(tT(k,Z),tT(k,W)),he={...S,x:J5(S.x-se[0]*Math.sign(C.scale[0]),0,L.naturalWidth-S.width),y:J5(S.y-se[1]*Math.sign(C.scale[1]),0,L.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:he});return}}}this.maybeCacheVisibleGaps(n,p),this.maybeCacheReferenceSnapPoints(n,p);let{snapOffset:y,snapLines:v}=q2(w,x,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||cH(t,p,x,this.scene,y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!Ye(p[0]))&&this.setState({suggestedBindings:$g(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),n.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,L=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!L.find(R=>R.id===S.id)&&L.push(S);let k=new Map(L.map(R=>[R.id,R])),{duplicatedElements:A,duplicateElementsMap:P,elementsWithDuplicates:N,origIdToDuplicateId:O}=vT({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:R,origElement:V})=>({frameId:R.frameId??V.frameId,seed:iz()})});A.forEach(R=>{t.originalElements.set(R.id,wT(R))});let U=N.map(R=>{if(k.has(R.id)){let V=t.originalElements.get(R.id);if(V)return Mn(R,{x:V.x,y:V.y})}return R}),J=this.props.onDuplicate?.(U,C),_=zT(J||U,Od(A));Li(()=>{if(t.hit.element){let R=O.get(t.hit.element.id),V=R&&P.get(R);t.hit.element=V||null}t.hit.allHitElements=t.hit.allHitElements.reduce((R,V)=>{let Z=O.get(V.id),W=Z&&P.get(Z);return W&&R.push(W),R},[]),t.drag.origin=Fe(n,this.state),this.setState(R=>({...iH(A,this.scene.getNonDeletedElements(),R)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(n,L,!0),this.maybeCacheReferenceSnapPoints(n,L,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,n.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,n.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,n)}else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,n.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=r.x-p.x,b=r.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.simulatePressure?p.pressures:[...p.pressures,n.pressure];this.scene.mutateElement(p,{points:[...u,re(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Xt(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Hg(n)&&u.length===2&&({width:f,height:b}=ST(p.x,p.y,r.x,r.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,re(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&Ye(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),re(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),qg(p,!1)&&this.setState({suggestedBindings:gT(p,[r],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Ce.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!n.shiftKey&&Ee(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>Kt({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?zf(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((w,E)=>(w[E.id]=!0,w),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...Kt({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&Xt(f[0])?new Ce(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||Uo(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,n){if(n.scrollbars.isOverHorizontal){let r=t.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(cl.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=t.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(cl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Le(n=>{this.removePointer(n),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:r,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:m,isRotating:c,isCropping:d}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:tl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Ut.setReferenceSnapPoints(null),Ut.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let p=t.hit.allHitElements,u=Fe({clientX:n.clientX,clientY:n.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);Tz(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>f.get(y.id)).filter(y=>Ye(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(At);else{let E=Ce.handlePointerUp(n,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Ce.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(At,"ui",{event:n,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ee.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ee.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ee.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ee.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,n),r?.type==="freedraw"){let E=Fe(n,this.state),y=r.points,v=E.x-r.x,C=E.y-r.y;v===y[0][0]&&C===y[0][1]&&(C+=1e-4,v+=1e-4);let S=r.simulatePressure?[]:[...r.pressures,n.pressure];this.scene.mutateElement(r,{points:[...y,re(v,C)],pressures:S,lastCommittedPoint:re(v,C)}),this.actionManager.executeAction(At);return}if(Xt(r)){r.points.length>1&&this.store.scheduleCapture();let E=Fe(n,this.state),y=In(re(E.x,E.y),re(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<hT)&&r&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(r,{x:r.x-v/2,points:[re(0,0),re(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(At)}else{let v=E.x-r.x,C=E.y-r.y;this.scene.mutateElement(r,{points:[...r.points,re(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:r,newElement:r})}else t.drag.hasOccurred&&!l&&(Kg(this.state)&&qg(r,!1)&&this.actionManager.executeAction(At,"ui",{event:n,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(zt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:Go(this.state,{type:this.defaultSelectionTool}),selectedElementIds:ye({...v.selectedElementIds,[r.id]:!0},v),selectedLinearElement:new Ce(r,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(io(r)){let E=Jz(Yg({fontSize:r.fontSize,fontFamily:r.fontFamily}),r.lineHeight);r.width<E&&this.scene.mutateElement(r,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(r,{isExistingElement:!0})}if(s.type!=="selection"&&r&&MT(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==r.id),appState:{newElement:null},captureUpdate:gt.NEVER});return}if(St(r)){let E=Rz(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(af(this.scene.getElementsMapIncludingDeleted(),E,r,this.state))}if(r&&(this.scene.mutateElement(r,Iz(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=Fe(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=sf(y,f);v&&y&&(Nz(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),_z([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=L=>{if(L.length>0){for(let k of L){let A=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,A)},{informMutation:!1,isDragging:!1})}C.forEach(k=>{k.groupIds.length&&nr(C,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let L=v.filter(k=>k.frameId!==y.id&&NT(k,C,this.state));this.state.editingGroupId&&S(L),C=af(C,L,y,this.state)}else if(!y&&this.state.editingGroupId){let L=v.filter(k=>k.frameId&&!NT(k,C,this.state));S(L)}C=RT(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&MT(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:gt.NEVER}),t.resize.isResizing){let E=RT(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>St(v));for(let v of y)E=Dz(E,lf(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&Xt(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Ce(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!d||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(ft(this.state)&&x&&w){if(this.eraserTrail.endPath(),In(re(x.clientX,x.clientY),re(w.clientX,w.clientY))===0){let y=Fe({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(n.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?nH(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>nr(this.scene.getNonDeletedElements(),C)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:ye(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let v=j(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...Kt({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&Xt(v[0])?new Ce(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let y={...E.selectedElementIds,[b.id]:!0};return delete y[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>nr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...Kt({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||Uo(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...Kt({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:Xt(b)&&E.selectedLinearElement?.elementId!==b.id?new Ce(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&Ye(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&Hz({point:re(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:St(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(hi):this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),xe(this.interactiveCanvas,Ae.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&r&&this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[r.id]:!0},E),showHyperlinkPopup:Uo(r)&&!r.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||Ee(this.scene.getNonDeletedElements(),this.state)||!rz(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||c||d){let E=this.scene.getSelectedElements(this.state).filter(Xt);bT(E,Kg(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(zt(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Go(this.state,{type:this.defaultSelectionTool})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&pe.pointers.size<=1&&nl(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(n=>({selectedElementIds:ye({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&t!=null&&OT(t,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,n,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=nf(i,r,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,n-l)<OO){let{x:d,y:p}=Fd({sceneX:a,sceneY:l},r);return{viewportX:d,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:n,top:r}=t.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=hr.find(n=>n.code===this.props.langCode)||co;await _l(t),this.setAppState({})}},hH=()=>{(gf()||jT())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(qT(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};hH();var tI=ff;import{useEffect as fH,useState as bH}from"react";import{jsx as xH}from"react/jsx-runtime";var oI=e=>{let[o,t]=bH(!0);return fH(()=>{let n=async()=>{await _l(r),t(!1)},r=hr.find(i=>i.code===e.langCode)||co;n()},[e.langCode]),o?xH(Xc,{theme:e.theme}):e.children};import EH from"clsx";import{jsx as nI}from"react/jsx-runtime";var rI=({children:e})=>{let{FooterCenterTunnel:o}=we(),t=ge();return nI(o.In,{children:nI("div",{className:EH("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},yH=rI;rI.displayName="FooterCenter";import wH from"clsx";import{jsx as TH,jsxs as IH}from"react/jsx-runtime";var iI=({isCollaborating:e,onSelect:o,...t})=>{let n=ge(),r=n.width<830;return IH(_t,{...t,className:wH("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:r?void 0:"auto"},title:g("labels.liveCollaboration"),children:[r?F1:g("labels.share"),n.collaborators.size>0&&TH("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},vH=iI;iI.displayName="LiveCollaborationTrigger";import{jsx as An,jsxs as lI}from"react/jsx-runtime";var CH=()=>An("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:An("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"})}),SH=()=>lI("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[An("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)"}),An("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)"}),An("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)"}),An("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)"})]}),aI=({style:e,size:o="small",withText:t})=>lI("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[An(CH,{}),t&&An(SH,{})]});import{Fragment as dI,jsx as We,jsxs as Tf}from"react/jsx-runtime";var If=({icon:e,shortcut:o,children:t})=>{let n=ce();return Tf(dI,{children:[We("div",{className:"welcome-screen-menu-item__icon",children:e}),We("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!n.editor.isMobile&&We("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};If.displayName="WelcomeScreenMenuItemContent";var pl=({onSelect:e,children:o,icon:t,shortcut:n,className:r="",...i})=>We("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:We(If,{icon:t,shortcut:n,children:o})});pl.displayName="WelcomeScreenMenuItem";var sI=({children:e,href:o,icon:t,shortcut:n,className:r="",...i})=>We("a",{...i,className:`welcome-screen-menu-item ${r}`,href:o,target:"_blank",rel:"noopener",children:We(If,{icon:t,shortcut:n,children:e})});sI.displayName="WelcomeScreenMenuItemLink";var Zt=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=we();return We(o.In,{children:We("div",{className:"welcome-screen-center",children:e||Tf(dI,{children:[We(Cf,{}),We(Sf,{children:g("welcomeScreen.defaults.center_heading")}),Tf(kf,{children:[We(Lf,{}),We(Mf,{})]})]})})})};Zt.displayName="Center";var Cf=({children:e})=>We("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||We(aI,{withText:!0})});Cf.displayName="Logo";var Sf=({children:e})=>We("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Sf.displayName="Heading";var kf=({children:e})=>We("div",{className:"welcome-screen-menu",children:e});kf.displayName="Menu";var Mf=()=>{let e=Ge();return We(pl,{onSelect:()=>e.executeAction(Wn),shortcut:"?",icon:xr,children:g("helpDialog.title")})};Mf.displayName="MenuItemHelp";var Lf=()=>{let e=ge(),o=Ge();return e.viewModeEnabled?null:We(pl,{onSelect:()=>o.executeAction(Hr),shortcut:Re("loadScene"),icon:Er,children:g("buttons.load")})};Lf.displayName="MenuItemLoadScene";var cI=({onSelect:e})=>{let{t:o}=Oe();return We(pl,{shortcut:null,onSelect:e,icon:Ul,children:o("labels.liveCollaboration")})};cI.displayName="MenuItemLiveCollaborationTrigger";Zt.Logo=Cf;Zt.Heading=Sf;Zt.Menu=kf;Zt.MenuItem=pl;Zt.MenuItemLink=sI;Zt.MenuItemHelp=Mf;Zt.MenuItemLoadScene=Lf;Zt.MenuItemLiveCollaborationTrigger=cI;import{jsx as Ri,jsxs as Pf}from"react/jsx-runtime";var Gd=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=we();return Ri(o.In,{children:Pf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[x1,Ri("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};Gd.displayName="MenuHint";var Ud=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=we();return Ri(o.In,{children:Pf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Ri("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),y1]})})};Ud.displayName="ToolbarHint";var Yd=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=we();return Ri(o.In,{children:Pf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Ri("div",{children:e||g("welcomeScreen.defaults.helpHint")}),E1]})})};Yd.displayName="HelpHint";import{Fragment as mI,jsx as ul,jsxs as MH}from"react/jsx-runtime";var Wd=e=>ul(mI,{children:e.children||MH(mI,{children:[ul(Zt,{}),ul(Gd,{}),ul(Ud,{}),ul(Yd,{})]})});Wd.displayName="WelcomeScreen";Wd.Center=Zt;Wd.Hints={MenuHint:Gd,ToolbarHint:Ud,HelpHint:Yd};var kH=Wd;var LH=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},pI=LH;import{getSceneVersion as BAe,hashElementsVersion as FAe,hashString as OAe,getNonDeletedElements as zAe}from"@excalidraw/element";import{getTextFromElements as GAe}from"@excalidraw/element";import{isInvisiblySmallElement as YAe}from"@excalidraw/element";import PH from"lodash.throttle";import{arrayToMap as AH,isDevEnv as uI,isTestEnv as hI}from"@excalidraw/common";import{orderByFractionalIndex as DH,syncInvalidIndices as gI,validateFractionalIndices as _H}from"@excalidraw/element";var RH=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),NH=PH((e,o,t)=>{if(uI()||hI()||window?.DEBUG_FRACTIONAL_INDICES){let n=gI(e.map(r=>({...r})));_H(n,{shouldThrow:hI()||uI(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),BH=(e,o,t)=>{let n=AH(e),r=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=n.get(l.id),m=RH(t,s,l);s&&m?(r.push(s),i.add(s.id)):(r.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(r.push(l),i.add(l.id));let a=DH(r);return NH(a,e,o),gI(a),a};import{getFreeDrawSvgPath as qAe}from"@excalidraw/element";import{isLinearElement as e8e}from"@excalidraw/element";import{FONT_FAMILY as o8e,THEME as n8e,MIME_TYPES as r8e,ROUNDNESS as js,DEFAULT_LASER_COLOR as i8e,UserIdleState as a8e,normalizeLink as l8e}from"@excalidraw/common";import{mutateElement as Js,newElementWith as c8e,bumpVersion as qr}from"@excalidraw/element";import{CaptureUpdateAction as m8e}from"@excalidraw/element";import{sceneCoordsToViewportCoords as DE,viewportCoordsToSceneCoords as h8e}from"@excalidraw/common";import{jsx as fI,jsxs as FH}from"react/jsx-runtime";var bI=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=we(),n=le();return fI(t.In,{children:FH(fe.Item,{onSelect:()=>{ne("ai","dialog open","ttd"),n({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??_0,children:[e??g("labels.textToDiagram"),fI(fe.Item.Badge,{children:"AI"})]})})};bI.displayName="TTDDialogTrigger";import{getCommonBounds as S8e,getVisibleSceneBounds as k8e}from"@excalidraw/element";import{useLayoutEffect as OH}from"react";var zH=e=>{let o=_e();return OH(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as D8e}from"@excalidraw/element";import{setCustomTextMetricsProvider as R8e}from"@excalidraw/element";import{jsx as Af}from"react/jsx-runtime";pI();var YH=e=>{let{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=co.code,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:w=!0,handleKeyboardGlobally:E=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:N,children:O,validateEmbeddable:U,renderEmbeddable:J,aiEnabled:_,showDeprecatedFonts:R,renderScrollbars:V}=e,Z=e.UIOptions?.canvasActions,W={...e.UIOptions,canvasActions:{...xI.canvasActions,...Z},tools:{image:e.UIOptions?.tools?.image??!0}};return Z?.export&&(W.canvasActions.export.saveFileToDisk=Z.export?.saveFileToDisk??xI.canvasActions.export.saveFileToDisk),W.canvasActions.toggleTheme===null&&typeof u>"u"&&(W.canvasActions.toggleTheme=!0),GH(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let he=de=>{typeof de.scale=="number"&&de.scale!==1&&de.preventDefault()};return document.addEventListener("touchmove",he,{passive:!1}),()=>{document.removeEventListener("touchmove",he)}},[]),Af(d1,{store:ze,children:Af(oI,{langCode:s,theme:u,children:Af(tI,{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:W,onPaste:x,detectScroll:w,handleKeyboardGlobally:E,onLibraryChange:y,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:N,validateEmbeddable:U,renderEmbeddable:J,aiEnabled:_!==!1,showDeprecatedFonts:R,renderScrollbars:V,children:O})})})},WH=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:n={},...r}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(n),m=Object.keys(a);return s.length!==m.length?!1:s.every(d=>d==="canvasActions"?Object.keys(n.canvasActions).every(u=>u==="export"&&n?.canvasActions?.export&&a?.canvasActions?.export?n.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:n?.canvasActions?.[u]===a?.canvasActions?.[u]):n[d]===a[d])&&UH(r,l)},VH=HH.memo(YH,WH);VH.displayName="Excalidraw";export{_t as Button,m8e as CaptureUpdateAction,i8e as DEFAULT_LASER_COLOR,cd as DefaultSidebar,zH as DiagramToCodePlugin,oa as Ellipsify,VH as Excalidraw,o8e as FONT_FAMILY,yH as Footer,vH as LiveCollaborationTrigger,r8e as MIME_TYPES,ct as MainMenu,js as ROUNDNESS,Vt as Sidebar,$a as Stats,n8e as THEME,pg as TTDDialog,bI as TTDDialogTrigger,a8e as UserIdleState,kH as WelcomeScreen,qr as bumpVersion,bi as convertToExcalidrawElements,co as defaultLang,c2 as elementPartiallyOverlapsWithOrContainsBBox,d2 as elementsOverlappingBBox,FE as exportToBlob,rn as exportToCanvas,UL as exportToClipboard,ti as exportToSvg,S8e as getCommonBounds,nm as getDataURL,qAe as getFreeDrawSvgPath,nc as getLibraryItemsHash,zAe as getNonDeletedElements,BAe as getSceneVersion,GAe as getTextFromElements,k8e as getVisibleSceneBounds,FAe as hashElementsVersion,OAe as hashString,ah as isElementInsideBBox,D8e as isElementLink,YAe as isInvisiblySmallElement,e8e as isLinearElement,hr as languages,Cl as loadFromBlob,om as loadLibraryFromBlob,tm as loadSceneOrLibraryFromBlob,XE as mergeLibraryItems,Js as mutateElement,c8e as newElementWith,l8e as normalizeLink,Cu as parseLibraryTokensFromUrl,BH as reconcileElements,mr as restore,TI as restoreAppState,vI as restoreElement,em as restoreElements,zi as restoreLibraryItems,DE as sceneCoordsToViewportCoords,Bi as serializeAsJSON,Qd as serializeLibraryAsJSON,R8e as setCustomTextMetricsProvider,ce as useDevice,iP as useHandleLibrary,Oe as useI18n,h8e as viewportCoordsToSceneCoords,lx as zoomToFitBounds};
118
+ `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=Oe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:jz,verticalAlign:B5,locked:!1},l=lf({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=G5(a.fontFamily),[m,,c]=KH(this.state),d=Math.max(Math.min((c-m)*.5,800),200),p=10,u=i,f=r?[t]:t.split(`
119
+ `),b=f.reduce((x,w,E)=>{let y=eG(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=hI(y,l,s),S=C.width>d,L=S?qH(y,l,d):y;C=S?hI(L,l,s):C;let k=n-C.width/2,A=u-C.height/2,P=q5({...a,x:k,y:A,text:L,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(P),u+=P.height+p}else f[E-1]?.trim()&&(u+=tG(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ye(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&SI===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:nH("CtrlOrCmd+Shift+V")}),duration:5e3}),SI=!0))}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&mo(s)?_r(s,{originalText:a,isDeleted:l??s.isDeleted,...CH(s,cI(s,n),n,a)}):s)])};mv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:m}=Jd({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,m-this.state.offsetTop]},onChange:Pe(a=>{i(a,!1),wI(t)&&pf(t,this.scene)}),onSubmit:Pe(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let m=t.containerId?t.containerId:t.id;Fi(()=>{this.setState(c=>({selectedElementIds:ye({...c.selectedElementIds,[m]:!0},c)}))})}s&&fH(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.scheduleCapture(),Fi(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&At(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&mo(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=[];if(n&&"allHitElements"in n?i=n?.allHitElements||[]:i=this.getElementsAtPosition(t,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return fl({point:ne(t,r),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:kt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n){let i=[],a=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!(mo(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let m=Cf(s,a);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?dI({x:t,y:r},m,a):!0}).filter(s=>Gi(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(H5/this.state.zoom.value))}hitElement(t,r,n,i=!0){return i&&this.state.selectedElementIds[n.id]&&FH([n],this.state)&&xG(ne(t,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||VH(ne(t,r),n,this.scene.getNonDeletedElementsMap())?!0:fl({point:ne(t,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:kt(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return oI(i[0],!1)?i[0]:null;let a=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,m,c,d]=K5(n[l],this.scene.getNonDeletedElementsMap());if(hf(n[l])&&fl({point:ne(t,r),element:n[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[l])})){a=n[l];break}else if(s<t&&t<c&&m<r&&r<d){a=n[l];break}}return oI(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=Se.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;fl({point:ne(r,n),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Se.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=Se.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(We(a)?l===0||l===a.points.length-1:l>=0)||s?xe(this.interactiveCanvas,De.POINTER):this.hitElement(r,n,a)&&(!We(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,De.MOVE)):this.hitElement(r,n,a)&&(!We(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,De.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Se.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else xe(this.interactiveCanvas,De.AUTO)}updateGestureOnPointerDown(t){pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),pe.pointers.size===2&&(pe.lastCenter=_h(pe.pointers),pe.initialScale=this.state.zoom.value,pe.initialDistance=Rh(Array.from(pe.pointers.values())))}initialPointerDownState(t){let r=Oe(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=Hi(n),m=n.findIndex(We)===0;return{origin:r,withCmdOrCtrl:t[Y.CTRL_OR_CMD],originInGrid:sf(nt(r.x,r.y,t[Y.CTRL_OR_CMD]||m?null:this.getEffectiveGridSize())),scrollbars:Uh(wl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((c,d)=>(c.set(d.id,J5(d)),c),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;Lf=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=rd(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=Pe(()=>{Tl=null,Lf=!1,At(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,n),window.removeEventListener(ee.POINTER_UP,i),n.flush()});return Tl=i,window.addEventListener(ee.POINTER_MOVE,n),window.addEventListener(ee.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=Math.max(H5/this.state.zoom.value,1),[i,a,l,s]=Hi(r);return t.x>i-n&&t.x<l+n&&t.y>a-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:kH(t)?$d.ADAPTIVE_RADIUS:$d.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Ho({event:t,app:this,selectedElements:r})&&(n||!Wt.getReferenceSnapPoints())&&Wt.setReferenceSnapPoints(kw(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Ho({event:t,app:this,selectedElements:r})&&(n||!Wt.getVisibleGaps())&&Wt.setVisibleGaps(Sw(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Pe(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return Pe(r=>{r.key===Y.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return rd(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=Oe(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=nt(n.x,n.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Se.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Se.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=sf(fG(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(bt(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=nt(n.x,n.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Pr(ne(n.x,n.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value<V5)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let m=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Se.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,m)){let f=Se.addMidpoint(this.state.selectedLinearElement,n,this,!r[Y.CTRL_OR_CMD],this.scene);if(!f)return;Fi(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=Se.handlePointDragging(r,this,n.x,n.y,p);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState(u);return}}let c=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.selectedLinearElement?.isEditing&&r.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((c||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(x=>x.locked))return;let u=p.find(x=>kt(x)),f=this.getTopLayerFrameAtSceneCoords(n),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Fi(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.isMobileOrTablet()&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.drag.origin.x,y:n.y-t.drag.origin.y},w=[...t.originalElements.values()],E=r.shiftKey;if(E){let C=Math.abs(x.x),S=Math.abs(x.y),L=E&&C<S,k=E&&C>S;L&&(x.x=0),k&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&cn(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,L=hl(C)&&this.imageCache.get(C.fileId)?.image;if(L&&!(L instanceof Promise)){let k=Lz(P5(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[A,P,N,O,U,J]=K5(C,m),_=of(tf(ne(A,P),ne(U,J),C.angle)),R=of(tf(ne(N,P),ne(U,J),C.angle)),V=of(tf(ne(A,O),ne(U,J),C.angle)),Z=_5(A5(R,_)),W=_5(A5(V,_)),se=P5(D5(k,Z),D5(k,W)),he={...S,x:L5(S.x-se[0]*Math.sign(C.scale[0]),0,L.naturalWidth-S.width),y:L5(S.y-se[1]*Math.sign(C.scale[1]),0,L.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:he});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=Mw(w,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||gG(t,p,x,this.scene,y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!We(p[0]))&&this.setState({suggestedBindings:uf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,L=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!L.find(R=>R.id===S.id)&&L.push(S);let k=new Map(L.map(R=>[R.id,R])),{duplicatedElements:A,duplicateElementsMap:P,elementsWithDuplicates:N,origIdToDuplicateId:O}=Q5({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:R,origElement:V})=>({frameId:R.frameId??V.frameId,seed:mH()})});A.forEach(R=>{t.originalElements.set(R.id,J5(R))});let U=N.map(R=>{if(k.has(R.id)){let V=t.originalElements.get(R.id);if(V)return _r(R,{x:V.x,y:V.y})}return R}),J=this.props.onDuplicate?.(U,C),_=fI(J||U,Qd(A));Fi(()=>{if(t.hit.element){let R=O.get(t.hit.element.id),V=R&&P.get(R);t.hit.element=V||null}t.hit.allHitElements=t.hit.allHitElements.reduce((R,V)=>{let Z=O.get(V.id),W=Z&&P.get(Z);return W&&R.push(W),R},[]),t.drag.origin=Oe(r,this.state),this.setState(R=>({...mG(A,this.scene.getNonDeletedElements(),R)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(r,L,!0),this.maybeCacheReferenceSnapPoints(r,L,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,r)}else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];this.scene.mutateElement(p,{points:[...u,ne(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Zt(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;rf(r)&&u.length===2&&({width:f,height:b}=rI(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,ne(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&We(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),ne(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),gf(p,!1)&&this.setState({suggestedBindings:X5(p,[n],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Se.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&Ee(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>$t({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?o1(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((w,E)=>(w[E.id]=!0,w),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...$t({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&Zt(f[0])?new Se(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||Ko(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(wl.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(wl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return Pe(r=>{this.removePointer(r),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:m,isRotating:c,isCropping:d}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:ul(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Wt.setReferenceSnapPoints(null),Wt.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let p=t.hit.allHitElements,u=Oe({clientX:r.clientX,clientY:r.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);LH(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>f.get(y.id)).filter(y=>We(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(Dt);else{let E=Se.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Se.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(Dt,"ui",{event:r,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ee.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ee.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ee.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ee.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let E=Oe(r,this.state),y=n.points,v=E.x-n.x,C=E.y-n.y;v===y[0][0]&&C===y[0][1]&&(C+=1e-4,v+=1e-4);let S=n.simulatePressure?[]:[...n.pressures,r.pressure];this.scene.mutateElement(n,{points:[...y,ne(v,C)],pressures:S,lastCommittedPoint:ne(v,C)}),this.actionManager.executeAction(Dt);return}if(Zt(n)){n.points.length>1&&this.store.scheduleCapture();let E=Oe(r,this.state),y=Pr(ne(E.x,E.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<V5)&&n&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(n,{x:n.x-v/2,points:[ne(0,0),ne(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(Dt)}else{let v=E.x-n.x,C=E.y-n.y;this.scene.mutateElement(n,{points:[...n.points,ne(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})}else t.drag.hasOccurred&&!l&&(mf(this.state)&&gf(n,!1)&&this.actionManager.executeAction(Dt,"ui",{event:r,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Ht(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:Xo(this.state,{type:this.defaultSelectionTool}),selectedElementIds:ye({...v.selectedElementIds,[n.id]:!0},v),selectedLinearElement:new Se(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(mo(n)){let E=nG(lf({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<E&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&iI(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==n.id),appState:{newElement:null},captureUpdate:ft.NEVER});return}if(kt(n)){let E=HH(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Tf(this.scene.getElementsMapIncludingDeleted(),E,n,this.state))}if(n&&(this.scene.mutateElement(n,PH(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=Oe(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=Cf(y,f);v&&y&&(GH(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),zH([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=L=>{if(L.length>0){for(let k of L){let A=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,A)},{informMutation:!1,isDragging:!1})}C.forEach(k=>{k.groupIds.length&&dn(C,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let L=v.filter(k=>k.frameId!==y.id&&pI(k,C,this.state));this.state.editingGroupId&&S(L),C=Tf(C,L,y,this.state)}else if(!y&&this.state.editingGroupId){let L=v.filter(k=>k.frameId&&!pI(k,C,this.state));S(L)}C=mI(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&iI(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:ft.NEVER}),t.resize.isResizing){let E=mI(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>kt(v));for(let v of y)E=OH(E,If(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&Zt(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Se(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!d||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(bt(this.state)&&x&&w){if(this.eraserTrail.endPath(),Pr(ne(x.clientX,x.clientY),ne(w.clientX,w.clientY))===0){let y=Oe({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?cG(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>dn(this.scene.getNonDeletedElements(),C)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:ye(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let v=j(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...$t({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&Zt(v[0])?new Se(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let y={...E.selectedElementIds,[b.id]:!0};return delete y[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>dn(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...$t({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||Ko(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...$t({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:Zt(b)&&E.selectedLinearElement?.elementId!==b.id?new Se(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&We(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&XH({point:ne(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:kt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(vi):this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),xe(this.interactiveCanvas,De.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[n.id]:!0},E),showHyperlinkPopup:Ko(n)&&!n.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||Ee(this.scene.getNonDeletedElements(),this.state)||!dH(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||c||d){let E=this.scene.getSelectedElements(this.state).filter(Zt);Z5(E,mf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(Ht(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Xo(this.state,{type:this.defaultSelectionTool})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&pe.pointers.size<=1&&gl(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(r=>({selectedElementIds:ye({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&gI(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=wf(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<Wz){let{x:d,y:p}=Jd({sceneX:a,sceneY:l},n);return{viewportX:d,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=yn.find(r=>r.code===this.props.langCode)||ho;await Ul(t),this.setAppState({})}},yG=()=>{(Df()||kI())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(MI(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};yG();var DI=_f;import{useEffect as vG,useState as TG}from"react";import{jsx as IG}from"react/jsx-runtime";var _I=e=>{let[o,t]=TG(!0);return vG(()=>{let r=async()=>{await Ul(n),t(!1)},n=yn.find(i=>i.code===e.langCode)||ho;r()},[e.langCode]),o?IG(ld,{theme:e.theme}):e.children};import CG from"clsx";import{jsx as RI}from"react/jsx-runtime";var NI=({children:e})=>{let{FooterCenterTunnel:o}=ve(),t=ge();return RI(o.In,{children:RI("div",{className:CG("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},SG=NI;NI.displayName="FooterCenter";import kG from"clsx";import{jsx as LG,jsxs as PG}from"react/jsx-runtime";var BI=({isCollaborating:e,onSelect:o,...t})=>{let r=ge(),n=r.width<830;return PG(Rt,{...t,className:kG("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:g("labels.liveCollaboration"),children:[n?Q1:g("labels.share"),r.collaborators.size>0&&LG("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},MG=BI;BI.displayName="LiveCollaborationTrigger";import{jsx as Br,jsxs as OI}from"react/jsx-runtime";var AG=()=>Br("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Br("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"})}),DG=()=>OI("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Br("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)"}),Br("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)"}),Br("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)"}),Br("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)"})]}),FI=({style:e,size:o="small",withText:t})=>OI("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Br(AG,{}),t&&Br(DG,{})]});import{Fragment as GI,jsx as Ve,jsxs as Hf}from"react/jsx-runtime";var Gf=({icon:e,shortcut:o,children:t})=>{let r=ce();return Hf(GI,{children:[Ve("div",{className:"welcome-screen-menu-item__icon",children:e}),Ve("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&Ve("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};Gf.displayName="WelcomeScreenMenuItemContent";var Il=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>Ve("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Ve(Gf,{icon:t,shortcut:r,children:o})});Il.displayName="WelcomeScreenMenuItem";var zI=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>Ve("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:Ve(Gf,{icon:t,shortcut:r,children:e})});zI.displayName="WelcomeScreenMenuItemLink";var jt=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=ve();return Ve(o.In,{children:Ve("div",{className:"welcome-screen-center",children:e||Hf(GI,{children:[Ve(Uf,{}),Ve(Yf,{children:g("welcomeScreen.defaults.center_heading")}),Hf(Wf,{children:[Ve(Xf,{}),Ve(Vf,{})]})]})})})};jt.displayName="Center";var Uf=({children:e})=>Ve("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ve(FI,{withText:!0})});Uf.displayName="Logo";var Yf=({children:e})=>Ve("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Yf.displayName="Heading";var Wf=({children:e})=>Ve("div",{className:"welcome-screen-menu",children:e});Wf.displayName="Menu";var Vf=()=>{let e=Ue();return Ve(Il,{onSelect:()=>e.executeAction(jr),shortcut:"?",icon:In,children:g("helpDialog.title")})};Vf.displayName="MenuItemHelp";var Xf=()=>{let e=ge(),o=Ue();return e.viewModeEnabled?null:Ve(Il,{onSelect:()=>o.executeAction(Zn),shortcut:Ne("loadScene"),icon:Cn,children:g("buttons.load")})};Xf.displayName="MenuItemLoadScene";var HI=({onSelect:e})=>{let{t:o}=ze();return Ve(Il,{shortcut:null,onSelect:e,icon:ql,children:o("labels.liveCollaboration")})};HI.displayName="MenuItemLiveCollaborationTrigger";jt.Logo=Uf;jt.Heading=Yf;jt.Menu=Wf;jt.MenuItem=Il;jt.MenuItemLink=zI;jt.MenuItemHelp=Vf;jt.MenuItemLoadScene=Xf;jt.MenuItemLiveCollaborationTrigger=HI;import{jsx as Ui,jsxs as Kf}from"react/jsx-runtime";var om=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=ve();return Ui(o.In,{children:Kf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[R1,Ui("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};om.displayName="MenuHint";var rm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=ve();return Ui(o.In,{children:Kf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Ui("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),B1]})})};rm.displayName="ToolbarHint";var nm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=ve();return Ui(o.In,{children:Kf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Ui("div",{children:e||g("welcomeScreen.defaults.helpHint")}),N1]})})};nm.displayName="HelpHint";import{Fragment as UI,jsx as Cl,jsxs as RG}from"react/jsx-runtime";var im=e=>Cl(UI,{children:e.children||RG(UI,{children:[Cl(jt,{}),Cl(om,{}),Cl(rm,{}),Cl(nm,{})]})});im.displayName="WelcomeScreen";im.Center=jt;im.Hints={MenuHint:om,ToolbarHint:rm,HelpHint:nm};var _G=im;var NG=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},YI=NG;import{getSceneVersion as n7e,hashElementsVersion as i7e,hashString as a7e,getNonDeletedElements as l7e}from"@excalidraw/element";import{getTextFromElements as c7e}from"@excalidraw/element";import{isInvisiblySmallElement as m7e}from"@excalidraw/element";import BG from"lodash.throttle";import{arrayToMap as FG,isDevEnv as WI,isTestEnv as VI}from"@excalidraw/common";import{orderByFractionalIndex as OG,syncInvalidIndices as XI,validateFractionalIndices as zG}from"@excalidraw/element";var HG=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),GG=BG((e,o,t)=>{if(WI()||VI()||window?.DEBUG_FRACTIONAL_INDICES){let r=XI(e.map(n=>({...n})));zG(r,{shouldThrow:VI()||WI(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),UG=(e,o,t)=>{let r=FG(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),m=HG(t,s,l);s&&m?(n.push(s),i.add(s.id)):(n.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(n.push(l),i.add(l.id));let a=OG(n);return GG(a,e,o),XI(a),a};import{getFreeDrawSvgPath as E7e}from"@excalidraw/element";import{isLinearElement as v7e}from"@excalidraw/element";import{FONT_FAMILY as I7e,THEME as C7e,MIME_TYPES as S7e,ROUNDNESS as mc,DEFAULT_LASER_COLOR as k7e,UserIdleState as M7e,normalizeLink as L7e}from"@excalidraw/common";import{mutateElement as uc,newElementWith as A7e,bumpVersion as ii}from"@excalidraw/element";import{CaptureUpdateAction as _7e}from"@excalidraw/element";import{sceneCoordsToViewportCoords as cy,viewportCoordsToSceneCoords as B7e}from"@excalidraw/common";import{jsx as KI,jsxs as YG}from"react/jsx-runtime";var ZI=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=ve(),r=le();return KI(t.In,{children:YG(fe.Item,{onSelect:()=>{re("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??$0,children:[e??g("labels.textToDiagram"),KI(fe.Item.Badge,{children:"AI"})]})})};ZI.displayName="TTDDialogTrigger";import{getCommonBounds as Z7e,getVisibleSceneBounds as $7e}from"@excalidraw/element";import{useLayoutEffect as WG}from"react";var VG=e=>{let o=Re();return WG(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as eDe}from"@excalidraw/element";import{setCustomTextMetricsProvider as oDe}from"@excalidraw/element";import{jsx as Zf}from"react/jsx-runtime";YI();var $G=e=>{let{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=ho.code,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:w=!0,handleKeyboardGlobally:E=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:N,children:O,validateEmbeddable:U,renderEmbeddable:J,aiEnabled:_,showDeprecatedFonts:R,renderScrollbars:V}=e,Z=e.UIOptions?.canvasActions,W={...e.UIOptions,canvasActions:{...$I.canvasActions,...Z},tools:{image:e.UIOptions?.tools?.image??!0}};return Z?.export&&(W.canvasActions.export.saveFileToDisk=Z.export?.saveFileToDisk??$I.canvasActions.export.saveFileToDisk),W.canvasActions.toggleTheme===null&&typeof u>"u"&&(W.canvasActions.toggleTheme=!0),KG(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let he=de=>{typeof de.scale=="number"&&de.scale!==1&&de.preventDefault()};return document.addEventListener("touchmove",he,{passive:!1}),()=>{document.removeEventListener("touchmove",he)}},[]),Zf(S1,{store:He,children:Zf(_I,{langCode:s,theme:u,children:Zf(DI,{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:W,onPaste:x,detectScroll:w,handleKeyboardGlobally:E,onLibraryChange:y,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:N,validateEmbeddable:U,renderEmbeddable:J,aiEnabled:_!==!1,showDeprecatedFonts:R,renderScrollbars:V,children:O})})})},jG=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(r),m=Object.keys(a);return s.length!==m.length?!1:s.every(d=>d==="canvasActions"?Object.keys(r.canvasActions).every(u=>u==="export"&&r?.canvasActions?.export&&a?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:r?.canvasActions?.[u]===a?.canvasActions?.[u]):r[d]===a[d])&&ZG(n,l)},qG=XG.memo($G,jG);qG.displayName="Excalidraw";export{Rt as Button,_7e as CaptureUpdateAction,k7e as DEFAULT_LASER_COLOR,Id as DefaultSidebar,VG as DiagramToCodePlugin,da as Ellipsify,qG as Excalidraw,I7e as FONT_FAMILY,SG as Footer,MG as LiveCollaborationTrigger,S7e as MIME_TYPES,dt as MainMenu,mc as ROUNDNESS,Kt as Sidebar,ll as Stats,C7e as THEME,Lg as TTDDialog,ZI as TTDDialogTrigger,M7e as UserIdleState,_G as WelcomeScreen,ii as bumpVersion,Ci as convertToExcalidrawElements,ho as defaultLang,H2 as elementPartiallyOverlapsWithOrContainsBBox,G2 as elementsOverlappingBBox,hy as exportToBlob,mr as exportToCanvas,KP as exportToClipboard,ci as exportToSvg,Z7e as getCommonBounds,ym as getDataURL,E7e as getFreeDrawSvgPath,xc as getLibraryItemsHash,l7e as getNonDeletedElements,n7e as getSceneVersion,c7e as getTextFromElements,$7e as getVisibleSceneBounds,i7e as hashElementsVersion,a7e as hashString,Th as isElementInsideBBox,eDe as isElementLink,m7e as isInvisiblySmallElement,v7e as isLinearElement,yn as languages,Bl as loadFromBlob,Em as loadLibraryFromBlob,xm as loadSceneOrLibraryFromBlob,Ty as mergeLibraryItems,uc as mutateElement,A7e as newElementWith,L7e as normalizeLink,Uu as parseLibraryTokensFromUrl,UG as reconcileElements,xn as restore,eC as restoreAppState,QI as restoreElement,fm as restoreElements,Ki as restoreLibraryItems,cy as sceneCoordsToViewportCoords,Wi as serializeAsJSON,gm as serializeLibraryAsJSON,oDe as setCustomTextMetricsProvider,ce as useDevice,dA as useHandleLibrary,ze as useI18n,B7e as viewportCoordsToSceneCoords,Tx as zoomToFitBounds};