@excalidraw/excalidraw 0.18.0-835eb8d → 0.18.0-8608d7b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/{chunk-N4PQJPAH.js → chunk-YMRX7R7U.js} +8 -3
- package/dist/dev/chunk-YMRX7R7U.js.map +7 -0
- package/dist/dev/data/{image-RT6RLBUE.js → image-L23D26XS.js} +2 -2
- package/dist/dev/index.css +272 -84
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +2930 -2161
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/chunk-HT4FKTIQ.js +4 -0
- package/dist/prod/data/{image-HPGPBQV2.js → image-NWF7UX55.js} +1 -1
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +20 -20
- package/dist/types/common/src/constants.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +15 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +65 -13
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +30 -6
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +15 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionExport.d.ts +45 -9
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +20 -4
- package/dist/types/excalidraw/actions/actionGroup.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +15 -3
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionProperties.d.ts +76 -16
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +5 -1
- package/dist/types/excalidraw/appState.d.ts +4 -1
- package/dist/types/excalidraw/components/Actions.d.ts +9 -2
- package/dist/types/excalidraw/components/App.d.ts +8 -3
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +2 -1
- package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
- package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -5
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
- package/dist/types/excalidraw/components/icons.d.ts +0 -1
- package/dist/types/excalidraw/types.d.ts +7 -2
- package/package.json +4 -4
- package/dist/dev/chunk-N4PQJPAH.js.map +0 -7
- package/dist/prod/chunk-SVEJI6WL.js +0 -4
- /package/dist/dev/data/{image-RT6RLBUE.js.map → image-L23D26XS.js.map} +0 -0
package/dist/prod/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import{$ as N1,A as BC,B as T1,C as I1,D as C1,E as ql,F as sa,G as Jl,H as Ql,I as S1,J as k1,K as ca,L as M1,M as L1,N as P1,O as A1,P as es,Q as Ar,R as D1,S as FC,T as Rm,U as OC,V as Dr,W as da,Y as _1,_ as R1,a as E1,aa as ts,b as Zn,ba as B1,c as fo,ca as Nm,d as y1,da as Bm,e as we,ea as os,f as w1,fa as F1,g as J,ga as Fm,h as aa,ha as Ro,i as bo,ia as O1,j as $n,ja as Om,k as jn,ka as z1,l as Mr,la as H1,m as qn,ma as ns,n as Lr,na as zm,o as v1,oa as G1,p as Am,pa as U1,q as rn,qa as Y1,r as an,ra as ma,s as vt,t as oo,u as Pr,v as $l,w as Dm,x as la,y as jl,z as _m}from"./chunk-SVEJI6WL.js";import{a as T}from"./chunk-A66AFZZU.js";import{J as Pm}from"./chunk-GF46JCB3.js";import{c as x1}from"./chunk-Z3N5DIM6.js";import{b as f1,c as b1,d as I}from"./chunk-SRAX5OIU.js";import OU,{useEffect as zU}from"react";import{DEFAULT_UI_OPTIONS as _C,isShallowEqual as HU}from"@excalidraw/common";import uI from"clsx";import gH from"lodash.throttle";import _o,{useContext as Xn}from"react";import{flushSync as Qi}from"react-dom";import fH from"roughjs/bin/rough";import{nanoid as bH}from"nanoid";import{clamp as hI,pointFrom as le,pointDistance as Gn,vector as gI,pointRotateRads as wf,vectorScale as xH,vectorFromPoint as vf,vectorSubtract as fI,vectorDot as bI,vectorNormalize as xI}from"@excalidraw/math";import{COLOR_PALETTE as EH,CODES as EI,shouldResizeFromCenter as yI,shouldMaintainAspectRatio as Dl,shouldRotateWithDiscreteAngle as Tf,isArrowKey as bm,KEYS as Y,APP_NAME as yH,CURSOR_TYPE as Re,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as wH,DEFAULT_VERTICAL_ALIGN as wI,DRAGGING_THRESHOLD as vH,ELEMENT_SHIFT_TRANSLATE_AMOUNT as TH,ELEMENT_TRANSLATE_AMOUNT as vI,EVENT as oe,FRAME_STYLE as Un,IMAGE_MIME_TYPES as IH,IMAGE_RENDER_TIMEOUT as CH,isBrave as SH,LINE_CONFIRM_THRESHOLD as If,MAX_ALLOWED_FILE_BYTES as TI,MIME_TYPES as Ao,MQ_RIGHT_SIDEBAR_MIN_WIDTH as kH,POINTER_BUTTON as wr,ROUNDNESS as xm,SCROLL_TIMEOUT as MH,TAP_TWICE_TIMEOUT as LH,TEXT_TO_CENTER_SNAP_THRESHOLD as PH,THEME as Em,THEME_FILTER as AH,TOUCH_CTX_MENU_TIMEOUT as DH,VERTICAL_ALIGN as _H,YOUTUBE_STATES as ym,ZOOM_STEP as RH,POINTER_EVENTS as ea,TOOL_TYPE as Do,isIOS as NH,supportsResizeObserver as II,DEFAULT_COLLISION_THRESHOLD as CI,DEFAULT_TEXT_ALIGN as BH,ARROW_TYPE as Yn,DEFAULT_REDUCED_GLOBAL_ALPHA as FH,isSafari as OH,isLocalLink as zH,normalizeLink as Cf,toValidURL as HH,getGridPoint as lt,getLineHeight as SI,debounce as kI,distance as ta,getFontString as Sf,getNearestScrollableContainer as GH,isInputLike as MI,isToolIcon as UH,isWritableElement as _l,sceneCoordsToViewportCoords as wm,tupleToCoors as kf,viewportCoordsToSceneCoords as Ge,wrapEvent as YH,updateObject as Mf,updateActiveTool as Qo,getShortcutKey as WH,isTransparent as VH,easeToValuesRAF as XH,muteFSAbortError as KH,isTestEnv as qf,isDevEnv as mC,easeOut as ZH,updateStable as Rl,addEventListener as Ne,normalizeEOL as $H,getDateTime as LI,isShallowEqual as jH,arrayToMap as vm,randomInteger as qH,CLASSES as JH,Emitter as vr,MINIMUM_ARROW_SIZE as PI,DOUBLE_TAP_POSITION_THRESHOLD as QH,isMobileOrTablet as Tr,MQ_MAX_MOBILE as eG,MQ_MIN_TABLET as tG,MQ_MAX_TABLET as oG,MQ_MAX_HEIGHT_LANDSCAPE as nG,MQ_MAX_WIDTH_LANDSCAPE as rG}from"@excalidraw/common";import{getObservedAppState as iG,getCommonBounds as oa,maybeSuggestBindingsForLinearElementAtCoords as AI,getElementAbsoluteCoords as DI,bindOrUnbindLinearElements as _I,fixBindingsAfterDeletion as aG,getHoveredElementForBinding as Lf,isBindingEnabled as Pf,shouldEnableBindingForPointerEvent as lG,updateBoundElements as Af,getSuggestedBindingsForArrows as Df,LinearElementEditor as Ie,newElementWith as Wn,newFrameElement as sG,newFreeDrawElement as cG,newEmbeddableElement as RI,newMagicFrameElement as NI,newIframeElement as dG,newArrowElement as mG,newElement as pG,newImageElement as uG,newLinearElement as hG,newTextElement as BI,refreshTextDimensions as gG,deepCopyElement as FI,duplicateElements as _f,hasBoundTextElement as OI,isArrowElement as Rf,isBindingElement as Nf,isBindingElementType as zI,isBoundToContainer as Bf,isFrameLikeElement as Mt,isImageElement as Ir,isEmbeddableElement as en,isInitializedImageElement as Nl,isLinearElement as Jt,isLinearElementType as fG,isUsingAdaptiveRadius as bG,isIframeElement as na,isIframeLikeElement as Bl,isMagicFrameElement as Ff,isTextBindableContainer as HI,isElbowArrow as Ke,isFlowchartNodeElement as xG,isBindableElement as EG,isTextElement as go,getLockedLinearCursorAlignSize as GI,getNormalizedDimensions as yG,isElementCompletelyInViewport as Of,isElementInViewport as UI,isInvisiblySmallElement as YI,getCornerRadius as wG,isPathALoop as WI,createSrcDoc as VI,embeddableURLValidator as zf,maybeParseEmbedSrc as vG,getEmbedLink as Tm,getInitializedImageElements as TG,normalizeSVG as XI,updateImageCache as IG,getBoundTextElement as Hf,getContainerCenter as Gf,getContainerElement as KI,isValidTextContainer as CG,redrawTextBoundingBox as SG,shouldShowBoundingBox as kG,getFrameChildren as Uf,isCursorInFrame as ZI,addElementsToFrame as Yf,replaceAllElementsInFrame as MG,removeElementsFromFrame as LG,getElementsInResizingFrame as Wf,getElementsInNewFrame as PG,getContainingFrame as Vf,elementOverlapsWithFrame as AG,updateFrameMembershipOfSelectedElements as $I,isElementInFrame as jI,getFrameLikeTitle as DG,getElementsOverlappingFrame as _G,filterElementsEligibleAsFrameChildren as RG,hitElementBoundText as NG,hitElementBoundingBoxOnly as BG,hitElementItself as Fl,getVisibleSceneBounds as FG,FlowChartCreator as OG,FlowChartNavigator as zG,getLinkDirectionFromKey as qI,cropElement as HG,wrapText as GG,isElementLink as Xf,parseElementLinkFromURL as UG,isMeasureTextSupported as YG,normalizeText as WG,measureText as JI,getLineHeightInPx as VG,getApproxMinLineWidth as XG,getApproxMinLineHeight as KG,getMinTextElementWidth as ZG,ShapeCache as Ol,getRenderOpacity as $G,editGroupForSelectedElement as jG,getElementsInGroup as Cr,getSelectedGroupIdForElement as qG,getSelectedGroupIds as JG,isElementInGroup as QI,isSelectedViaGroup as QG,selectGroupsForSelectedElements as Qt,syncInvalidIndices as pC,syncMovedIndices as eC,excludeElementsInFramesFromSelection as eU,getSelectionStateForElements as tU,makeNextSelectedElementIds as ve,getResizeOffsetXY as oU,getResizeArrowDirection as nU,transformElements as rU,getCursorForResizingElement as tC,getElementWithTransformHandleType as oC,getTransformHandleTypeFromCoords as nC,dragNewElement as rC,dragSelectedElements as iU,getDragOffsetXY as aU,isNonDeletedElement as iC,Scene as aC,Store as lU,CaptureUpdateAction as wt,hitElementBoundingBox as sU,isLineElement as Im,isSimpleArrow as cU,StoreDelta as lC,positionElementsOnGrid as sC}from"@excalidraw/element";import{KEYS as pp,updateActiveTool as JC}from"@excalidraw/common";import{getNonDeletedElements as up}from"@excalidraw/element";import{fixBindingsAfterDeletion as QC}from"@excalidraw/element";import{LinearElementEditor as Hb}from"@excalidraw/element";import{newElementWith as Ms}from"@excalidraw/element";import{getContainerElement as Gb}from"@excalidraw/element";import{isBoundToContainer as Ss,isElbowArrow as eS,isFrameLikeElement as tS}from"@excalidraw/element";import{getFrameChildren as oS}from"@excalidraw/element";import{getElementsInGroup as hp,selectGroupsForSelectedElements as nS}from"@excalidraw/element";import{CaptureUpdateAction as ks}from"@excalidraw/element";import{isDevEnv as UC}from"@excalidraw/common";import{atom as ue,createStore as zC}from"jotai";import{createIsolation as HC}from"jotai-scope";var W1=HC();var{useAtom:se,useSetAtom:ln,useAtomValue:rs,useStore:XU}=W1,V1=W1.Provider,Ye=zC();var GC=f1({"./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-LQE6K457.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 YC=85,xo={code:"en",label:"English"},Rr=[xo,...[{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=>x1[e.code]>=YC).sort((e,o)=>e.label>o.label?1:-1)],as="__test__";UC()&&Rr.unshift({code:as,label:"test language"},{code:`${as}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var _r=xo,is={},ls=async e=>{if(_r=e,document.documentElement.dir=_r.rtl?"rtl":"ltr",document.documentElement.lang=_r.code,e.code.startsWith(as))is={};else try{is=await GC(`./locales/${_r.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),is=Pm}Ye.set(K1,e.code)},No=()=>_r,X1=(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(_r.code.startsWith(as))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=X1(is,n)||X1(Pm,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},K1=ue(xo.code),Ue=()=>{let e=rs(K1);return{t:g,langCode:e}};import WC from"clsx";import VC from"open-color";import nt from"react";import{THEME as XC}from"@excalidraw/common";import{Fragment as xe,jsx as h,jsxs as D}from"react/jsx-runtime";var no=e=>"var(--icon-fill-color)",Z1=e=>e===XC.LIGHT?VC.white:"#1e1e1e",L=(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:WC({"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"},ne={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},sY=L(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),Nr=L(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),$1=L(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),j1=L(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),q1=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),z),J1=L(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),Hm=L(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),Jn=L(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"})})]}),ne),Br=L(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"})]}),ne),Q1=L(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}),e0=L(D(xe,{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"}),t0=L(D(xe,{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"}),o0=L(D(xe,{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"}),cY=L(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"}),Gm=L(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}),pa=L(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}),ss=L(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),cs=L(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),ds=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),z),n0=L(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),ms=L(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ne),r0=L(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),sn=L(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"})]}),ne),Fr=L(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),i0=L(D("g",{stroke:"currentColor",strokeWidth:"1.5",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),a0=L(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"})]}),ne),l0=L(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),Um=L(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ne),Ym=L(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ne),s0=L(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),At=L(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"}),ne),Wm=L(D("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ne),ua=L(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"})]}),ne),ha=L(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"}),ne),ga=L(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"})}),{...ne,strokeWidth:1.5}),ps=L(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),Qn=L(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"}),ne),Or=L(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),c0=L(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),Vm=L(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"}),ne),us=L(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"}),ne),d0=L(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"})]}),ne),m0=L(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),p0=L(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),fa=L(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"})]}),ne),u0=L("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),h0=L("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),zr=L(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"}),ne),dY=L("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),g0=L("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),hs=L(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),f0=L(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),z),gs=L(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),b0=L("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),mY=L("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),pY=L("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),x0=L("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),uY=L("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Xm=L(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"}),ne),Km=L(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"}),ne),E0=L("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),y0=L(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"}),ne),hY=L("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),gY=L("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),fY=L(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),bY=L(D(xe,{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}),xY=L(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}),w0=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"})]}),v0=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"})]}),Zm=L(v0,z),$m=L(v0,{...z,style:{transform:"rotate(180deg)"}}),jm=L(w0,z),qm=L(w0,{...z,style:{transform:"rotate(180deg)"}}),Jm=L(D(xe,{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"})})})]}),ne),Qm=L(D(xe,{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"})})})]}),ne),ep=L(D(xe,{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"})})})]}),ne),tp=L(D(xe,{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"})})})]}),ne),T0=L(D(xe,{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"})})})]}),ne),I0=L(D(xe,{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"})})})]}),ne),op=L(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"})]}),ne),np=L(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"})]}),ne),fs=L(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),EY=L("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),yY=L("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Gt=L(D(xe,{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"})})})]}),ne),wY=L("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),vY=L("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),TY=L("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),rp=nt.memo(({theme:e})=>L(D(xe,{children:[h("path",{d:"M25 26H111V111H25",fill:no(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:no(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:no(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:no(e),strokeWidth:"2"}),D("g",{fill:Z1(e),stroke:no(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})),ip=nt.memo(({theme:e})=>L(D(xe,{children:[h("path",{d:"M25 26H111V111H25",fill:no(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:no(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:no(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:no(e),strokeWidth:"2"}),D("g",{fill:Z1(e),stroke:no(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})),C0=L(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"})}),ne),S0=L(D(xe,{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"})})]}),ne),k0=L(D(xe,{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"})})})]}),ne),M0=L(D(xe,{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"})})})]}),{...ne,fill:"currentColor"}),ap=L(h(xe,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ne),L0=L(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ne),P0=L(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ne),IY=nt.memo(({theme:e})=>L(h("path",{d:"M6 10H34",stroke:no(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),A0=L(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),D0=L(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),_0=L(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"}),ne),R0=L(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"}),ne),N0=L(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"}),ne),B0=L(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"})]}),ne),F0=L(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),O0=L(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),z0=nt.memo(({flip:e=!1})=>L(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})),H0=nt.memo(({flip:e=!1})=>L(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})),G0=nt.memo(({flip:e=!1})=>L(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})),U0=nt.memo(({flip:e=!1})=>L(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})),Y0=nt.memo(({flip:e=!1})=>L(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})),W0=nt.memo(({flip:e=!1})=>L(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})),V0=nt.memo(({flip:e=!1})=>L(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})),X0=nt.memo(({flip:e=!1})=>L(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})),K0=nt.memo(({flip:e=!1})=>L(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})),Z0=nt.memo(({flip:e=!1})=>L(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})),$0=nt.memo(({flip:e=!1})=>L(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})),j0=L(D(xe,{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"})})})]}),ne),q0=L(D(xe,{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"})})})]}),ne),J0=L(D(xe,{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"})})})]}),ne),Q0=L(h(xe,{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"})}),ne),er=L(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),eb=L(h(xe,{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),ba=L(h(xe,{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"})})}),ne),bs=L(D(xe,{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"})})})]}),ne),tb=L(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),ob=L(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),nb=L(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),rb=nt.memo(({theme:e})=>L(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)),ib=nt.memo(({theme:e})=>L(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)),ab=nt.memo(({theme:e})=>L(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)),xs=L(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),lb=L(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}),CY=L(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=L(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),lp=L(D(xe,{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),Hr=L(D(xe,{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),sb=L(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),cb=L(D(xe,{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),SY=L(D(xe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),z),kY=L(D(xe,{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),db=L(D(xe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),z),mb=L(D(xe,{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),pb=L(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),ub=L(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),tr=L(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),ys=L(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"})),Gr=L(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"})]}),ne),xa=L(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),ws=L(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),MY=L(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),LY=L(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),hb=L(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),Ur=L(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),gb=L(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),fb=L(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),bb=L(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),Dt=L(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),xb=L(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),Eb=L(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),yb=L(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),Ea=L(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),wb=L(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),vb=L(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),Tb=L(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),Ib=L(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),sp=L(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),vs=L(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),Cb=L(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),Sb=L(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),kb=L(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),Mb=L(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),Lb=L(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}),PY=L(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),Pb=L(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),Ab=L(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),Db=L(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),Yr=L(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),Wr=L(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),Vr=L(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),Ts=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),z),_b=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),Rb=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),cp=L(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),Is=L(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),AY=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),z),Nb=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),z),Bb=L(D("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4"}),h("path",{d:"M6 14l8 -8"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M10 18l8 -8"}),h("path",{d:"M14 18l4 -4"})]}),z),Fb=L(D("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"6",y:"6",width:"12",height:"12",fill:"none"})]}),z);import Ob from"clsx";import mp,{useEffect as $C,useRef as zb,useState as jC}from"react";import{isPromiseLike as qC}from"@excalidraw/common";import KC from"react";import{jsx as dp}from"react/jsx-runtime";var ZC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(KC.useRef(Date.now()).current%1600);return dp("div",{className:`Spinner ${n}`,children:dp("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:dp("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},rt=ZC;import{jsx as ya,jsxs as wa}from"react/jsx-runtime";var K=mp.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=Be(),a=mp.useRef(null);mp.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,d]=jC(!1),m=zb(!0),c=async u=>{let f="onClick"in n&&n.onClick?.(u);if(qC(f))try{d(!0),await f}catch(b){if(b instanceof Lr)console.warn(b);else throw b}finally{m.current&&d(!1)}};$C(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=zb(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return wa("button",{className:Ob("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:c,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&wa("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&ya("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&ya(rt,{})]}),n.showAriaLabel&&wa("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&ya(rt,{})]}),n.children]})}return wa("label",{className:Ob("ToolIcon",t),title:n.title,onPointerDown:u=>{p.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[ya("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}),wa("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&ya("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});K.displayName="ToolButton";var Cs=[],B=e=>(Cs=Cs.concat(e),e);import{jsx as iS}from"react/jsx-runtime";var rS=(e,o,t)=>{let n=new Set(J(e.filter(m=>tS(m)),o).map(m=>m.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of n){let c=oS(e,m);for(let p of c)if(!a.has(p.id)){if(Ss(p)){let u=Gb(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let c=Ss(m)?Gb(m,i):null;return m.frameId&&n.has(m.frameId)?(l=!1,r[m.id]=!0,m):c?.frameId&&n.has(c?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&eS(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),Ms(m,{isDeleted:!0}))}return m.frameId&&n.has(m.frameId)?(l=!1,Ss(m)||(r[m.id]=!0),Ms(m,{frameId:null})):Ss(m)&&o.selectedElementIds[m.containerId]?Ms(m,{isDeleted:!0}):m}),d=o.editingGroupId;if(l&&o.editingGroupId){let m=hp(s,o.editingGroupId).filter(c=>!c.isDeleted);if(m.length>1)m[0]&&(r[m[0].id]=!0);else{d=null,m[0]&&(r[m[0].id]=!0);let c=m[0];if(c){let p=c.groupIds.findIndex(f=>f===o.editingGroupId),u=c.groupIds[p+1];if(u){let f=hp(s,u).filter(b=>!b.isDeleted);f.length>1&&(d=u,f.forEach(b=>{r[b.id]=!0}))}}}}return{elements:s,appState:{...o,...nS({selectedElementIds:r,editingGroupId:d},s,o,null)}}},Ub=(e,o)=>{if(e.editingGroupId){let t=hp(up(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},va=B({name:"deleteSelectedElements",label:"labels.delete",icon:At,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:d}=o.selectedLinearElement,m=n.scene.getNonDeletedElementsMap(),c=Hb.getElement(a,m);if(!c||l==null)return!1;if(l.length>=c.points.length){let u=e.map(b=>b.id===c.id?Ms(b,{isDeleted:!0}):b),f=Ub(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:ks.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(c.points.length-1)?null:d};return Hb.deletePoints(c,n,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:ks.IMMEDIATELY}}let{elements:r,appState:i}=rS(e,o,n);return QC(r,r.filter(a=>a.isDeleted)),i=Ub(i,r),{elements:r,appState:{...i,activeTool:JC(o,{type:n.defaultSelectionTool}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:we(up(e),o)?ks.IMMEDIATELY:ks.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===pp.BACKSPACE||e.key===pp.DELETE)&&!e[pp.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>iS(K,{type:"button",icon:At,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:we(up(e),o)})});import{KEYS as Xr,CODES as Kr,getShortcutKey as Zr,isDarwin as Ls}from"@excalidraw/common";import{moveOneLeft as aS,moveOneRight as lS,moveAllLeft as sS,moveAllRight as cS}from"@excalidraw/element";import{CaptureUpdateAction as Ps}from"@excalidraw/element";import{jsx as As}from"react/jsx-runtime";var gp=B({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:$m,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:aS(e,o,n.scene),appState:o,captureUpdate:Ps.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Xr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Kr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>As("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${Zr("CtrlOrCmd+[")}`,children:$m})}),fp=B({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Zm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:lS(e,o,n.scene),appState:o,captureUpdate:Ps.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Xr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Kr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>As("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${Zr("CtrlOrCmd+]")}`,children:Zm})}),bp=B({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:qm,trackEvent:{category:"element"},perform:(e,o)=>({elements:sS(e,o),appState:o,captureUpdate:Ps.IMMEDIATELY}),keyTest:e=>Ls?e[Xr.CTRL_OR_CMD]&&e.altKey&&e.code===Kr.BRACKET_LEFT:e[Xr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Kr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>As("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${Ls?Zr("CtrlOrCmd+Alt+["):Zr("CtrlOrCmd+Shift+[")}`,children:qm})}),xp=B({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:jm,trackEvent:{category:"element"},perform:(e,o)=>({elements:cS(e,o),appState:o,captureUpdate:Ps.IMMEDIATELY}),keyTest:e=>Ls?e[Xr.CTRL_OR_CMD]&&e.altKey&&e.code===Kr.BRACKET_RIGHT:e[Xr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Kr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>As("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${Ls?Zr("CtrlOrCmd+Alt+]"):Zr("CtrlOrCmd+Shift+]")}`,children:jm})});import{getNonDeletedElements as dS}from"@excalidraw/element";import{LinearElementEditor as mS}from"@excalidraw/element";import{isLinearElement as pS,isTextElement as uS}from"@excalidraw/element";import{arrayToMap as hS,KEYS as Yb}from"@excalidraw/common";import{selectGroupsForSelectedElements as gS}from"@excalidraw/element";import{CaptureUpdateAction as fS}from"@excalidraw/element";var Ep=B({name:"selectAll",label:"labels.selectAll",icon:wb,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(uS(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...gS({editingGroupId:null,selectedElementIds:r},dS(e),o,n),selectedLinearElement:Object.keys(r).length===1&&pS(e[0])?new mS(e[0],hS(e)):null},captureUpdate:fS.IMMEDIATELY}},keyTest:e=>e[Yb.CTRL_OR_CMD]&&e.key===Yb.A});import{DEFAULT_GRID_SIZE as Wb,KEYS as Vb,arrayToMap as Xb,getShortcutKey as bS}from"@excalidraw/common";import{getNonDeletedElements as Kb}from"@excalidraw/element";import{LinearElementEditor as xS}from"@excalidraw/element";import{getSelectedElements as ES,getSelectionStateForElements as yS}from"@excalidraw/element";import{syncMovedIndices as wS}from"@excalidraw/element";import{duplicateElements as vS}from"@excalidraw/element";import{CaptureUpdateAction as Zb}from"@excalidraw/element";import{jsx as TS}from"react/jsx-runtime";var yp=B({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ua,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=xS.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:Zb.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=vS({type:"in-place",elements:e,idsOfElementsToDuplicate:Xb(ES(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+Wb/2,y:a.y+Wb/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:wS(i,Xb(r)),appState:{...o,...yS(r,Kb(i),o)},captureUpdate:Zb.IMMEDIATELY}},keyTest:e=>e[Vb.CTRL_OR_CMD]&&e.key===Vb.D,PanelComponent:({elements:e,appState:o,updateData:t})=>TS(K,{type:"button",icon:ua,title:`${g("labels.duplicateSelection")} \u2014 ${bS("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:we(Kb(e),o)})});import{pointFrom as v4}from"@excalidraw/math";import{useEffect as Yp,useMemo as T4,useRef as Wp,useState as I4}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as C4,DEFAULT_ELEMENT_BACKGROUND_PICKS as S4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as k4,DEFAULT_ELEMENT_STROKE_PICKS as M4,ARROW_TYPE as Oo,DEFAULT_FONT_FAMILY as L4,DEFAULT_FONT_SIZE as P4,FONT_FAMILY as A4,ROUNDNESS as js,STROKE_WIDTH as Vp,VERTICAL_ALIGN as $s,KEYS as ri,randomInteger as D4,arrayToMap as Zp,getFontFamilyString as _4,getShortcutKey as R4,getLineHeight as N4,isTransparent as B4,reduceToCommonValue as F4}from"@excalidraw/common";import{canBecomePolygon as O4,getNonDeletedElements as zx}from"@excalidraw/element";import{bindLinearElement as Nx,calculateFixedPointForElbowArrowBinding as Bx,updateBoundElements as z4}from"@excalidraw/element";import{LinearElementEditor as Xp}from"@excalidraw/element";import{newElementWith as $e}from"@excalidraw/element";import{getBoundTextElement as bn,redrawTextBoundingBox as Ra}from"@excalidraw/element";import{isArrowElement as qs,isBoundToContainer as H4,isElbowArrow as Hx,isLinearElement as Kp,isLineElement as Fx,isTextElement as Tt,isUsingAdaptiveRadius as G4}from"@excalidraw/element";import{hasStrokeColor as U4}from"@excalidraw/element";import{updateElbowArrowPoints as Y4,CaptureUpdateAction as je,toggleLinePolygonState as W4}from"@excalidraw/element";import{isDevEnv as IS}from"@excalidraw/common";var CS=new Set(["command_palette","export"]),ae=(e,o,t,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!CS.has(e)||IS())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 LS from"clsx";import SS from"clsx";import{forwardRef as kS}from"react";import{jsx as MS}from"react/jsx-runtime";var $r=kS((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return MS("button",{type:"button",ref:o,title:t,"data-testid":r,className:SS(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as AS,jsx as wp,jsxs as PS}from"react/jsx-runtime";var Ut=e=>wp(AS,{children:e.options.map(o=>e.type==="button"?wp($r,{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):PS("label",{className:LS({active:e.value===o.value}),title:o.text,children:[wp("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 Hs from"@radix-ui/react-popover";import gx from"clsx";import{useRef as fx,useEffect as A6}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as Rp,COLOR_PALETTE as bx,isTransparent as D6,isWritableElement as _6}from"@excalidraw/common";import{jsx as DS}from"react/jsx-runtime";var Ds=()=>DS("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as FS,useRef as OS}from"react";import{createPortal as zS}from"react-dom";import{EVENT as dn,KEYS as HS,rgbToHex as GS}from"@excalidraw/common";import $b from"react";var vp=$b.createContext(null),fe=()=>$b.useContext(vp);import{useState as _S,useLayoutEffect as jb}from"react";import{THEME as RS}from"@excalidraw/common";var _s=e=>{let[o,t]=_S(null),n=me(),{theme:r}=fe(),{container:i}=Be();return jb(()=>{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===RS.DARK))},[o,r,n.editor.isMobile,e?.className]),jb(()=>{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 NS}from"react";import{EVENT as Rs}from"@excalidraw/common";function jr(e,o,t){NS(()=>{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(Rs.POINTER_DOWN,n),document.addEventListener(Rs.TOUCH_START,n),()=>{document.removeEventListener(Rs.POINTER_DOWN,n),document.removeEventListener(Rs.TOUCH_START,n)}},[e,o,t])}import{useRef as BS}from"react";var cn=e=>{let o=BS(e);return Object.assign(o.current,e),o.current};import{jsx as US}from"react/jsx-runtime";var mn=ue(null),qb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=_s({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=fe(),a=pn(),l=Fe(),s=J(a,i),d=cn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=Be();FS(()=>{let p=c.current;if(!p||!l.canvas||!r)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:k,clientY:P})=>{let S=f.getImageData((k-i.offsetLeft)*window.devicePixelRatio,(P-i.offsetTop)*window.devicePixelRatio,1,1).data;return GS(S[0],S[1],S[2])},x=({clientX:k,clientY:P,altKey:S})=>{p.style.top=`${P+20}px`,p.style.left=`${k+20}px`;let _=b({clientX:k,clientY:P});u&&d.onChange(n,_,d.selectedElements,{altKey:S}),p.style.background=_},y=()=>{d.onCancel()},E=(k,P)=>{d.onSelect(k,P)},w=k=>{u=!0,k.stopImmediatePropagation()},v=k=>{u=!1,m?.focus(),k.stopImmediatePropagation(),k.preventDefault(),E(b(k),k)},C=k=>{k.key===HS.ESCAPE&&(k.preventDefault(),k.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),x({clientX:d.app.lastViewportPosition.x,clientY:d.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(dn.KEYDOWN,C),r.addEventListener(dn.POINTER_DOWN,w),r.addEventListener(dn.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(dn.BLUR,y),()=>{u=!1,r.removeEventListener(dn.KEYDOWN,C),r.removeEventListener(dn.POINTER_DOWN,w),r.removeEventListener(dn.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(dn.BLUR,y)}},[d,l.canvas,r,n,m,i.offsetLeft,i.offsetTop]);let c=OS(null);return jr(c,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?zS(US("div",{ref:c,className:"excalidraw-eye-dropper-preview"}),r):null};import*as qr from"@radix-ui/react-popover";import XS from"clsx";import KS from"react";import{isInteractive as ZS}from"@excalidraw/common";import YS from"react";import WS from"clsx";import{jsx as VS}from"react/jsx-runtime";var We=YS.forwardRef(({children:e,padding:o,className:t,style:n},r)=>VS("div",{className:WS("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as Tp,jsxs as $S}from"react/jsx-runtime";var Bo=KS.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:d=!1},m)=>{let c=me();return Tp(qr.Portal,{container:o,children:$S(qr.Content,{ref:m,className:XS("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,onOpenAutoFocus:p=>{d&&c.isTouchScreen&&p.preventDefault()},onCloseAutoFocus:p=>{p.stopPropagation(),p.preventDefault(),o&&!ZS(document.activeElement)&&o.focus(),r()},children:[Tp(We,{padding:3,style:n,children:t}),Tp(qr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{useState as jS,useCallback as Ip}from"react";var Ns=()=>document.querySelector(".excalidraw-wysiwyg"),Bs=()=>{let e=Ns();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Ta=e=>{setTimeout(()=>{let o=Ns();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},Ia=(e,o,t,n)=>{o&&n&&n();let r=o&&t?Bs():null;e(),o&&t&&Ta(r)},Jb=()=>{let[e,o]=jS(null),t=Ip(()=>{let i=Bs();o(i)},[]),n=Ip(()=>{setTimeout(()=>{let i=Ns();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=Ip(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},Qb=(e=100)=>{let o=Ns();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import JS from"clsx";import{useCallback as QS,useEffect as Sp,useRef as ox,useState as e6}from"react";import{KEYS as kp,getShortcutKey as t6}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as qS}from"@excalidraw/common";var un=({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},Ca=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Cp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),tx=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[o]];return Cp({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,qS)},Yt=ue(null),ex=(e,o,t)=>(e*299+o*587+t*114)/1e3,hn=(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]),d=parseInt(l[1]),m=parseInt(l[2]);return ex(s,d,m)<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 ex(t,n,r)<o};import{Fragment as o6,jsx as Fs,jsxs as nx}from"react/jsx-runtime";var rx=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=me(),[a,l]=e6(e),[s,d]=se(Yt);Sp(()=>{l(e)},[e]);let m=QS(b=>{let x=b.toLowerCase(),y=ix(x);y&&o(y),l(x)},[o]),c=ox(null),p=ox(null);Sp(()=>{c.current&&c.current.focus()},[s]);let[u,f]=se(mn);return Sp(()=>()=>{f(null)},[f]),nx("div",{className:"color-picker__input-label",children:[Fs("div",{className:"color-picker__input-hash",children:"#"}),Fs("input",{ref:s==="hex"?c:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{m(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>d("hex"),onKeyDown:b=>{b.key!==kp.TAB&&(b.key===kp.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:r}),!i.editor.isMobile&&nx(o6,{children:[Fs("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Fs("div",{ref:p,className:JS("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${kp.I.toLocaleUpperCase()} or ${t6("Alt")} `,children:pb})]})]})};import Ap,{useEffect as Dp,useImperativeHandle as w6,useState as v6}from"react";import{EVENT as mx}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as T6,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as I6,KEYS as C6}from"@excalidraw/common";import i6 from"clsx";import{useEffect as a6,useRef as l6}from"react";import{jsxs as r6}from"react/jsx-runtime";var n6=({color:e,keyLabel:o,isShade:t=!1})=>r6("div",{className:"color-picker__button__hotkey-label",style:{color:hn(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Jr=n6;import{jsx as Mp,jsxs as s6}from"react/jsx-runtime";var ax=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=se(Yt),a=l6(null);return a6(()=>{a.current&&a.current.focus()},[o,r]),Mp("div",{className:"color-picker-content--default",children:e.map((l,s)=>s6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:i6("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:[Mp("div",{className:"color-picker__button-outline"}),Mp(Jr,{color:l,keyLabel:s+1})]},s))})};import c6 from"clsx";import{useEffect as d6,useRef as m6}from"react";import{jsx as Lp,jsxs as u6}from"react/jsx-runtime";var p6=({palette:e,color:o,onChange:t,activeShade:n})=>{let r=un({color:o,palette:e}),[i,a]=se(Yt),l=m6(null);return d6(()=>{l.current&&i==="baseColors"&&l.current.focus()},[r?.colorName,i]),Lp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,d],m)=>{let c=(Array.isArray(d)?d[n]:d)||"transparent",p=Ca[m],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return u6("button",{ref:r?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:c6("color-picker__button color-picker__button--large has-outline",{active:r?.colorName===s,"is-transparent":c==="transparent"||!c}),onClick:()=>{t(c),a("baseColors")},title:`${u}${c.startsWith("#")?` ${c}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:c?{"--swatch-color":c}:void 0,"data-testid":`color-${s}`,children:[Lp("div",{className:"color-picker__button-outline"}),Lp(Jr,{color:c,keyLabel:p})]},s)})})},lx=p6;import{jsx as g6}from"react/jsx-runtime";var h6=({children:e})=>g6("div",{className:"color-picker__heading",children:e}),Qr=h6;import f6 from"clsx";import{useEffect as b6,useRef as x6}from"react";import{jsx as Sa,jsxs as sx}from"react/jsx-runtime";var cx=({color:e,onChange:o,palette:t})=>{let n=un({color:e||"transparent",palette:t}),[r,i]=se(Yt),a=x6(null);if(b6(()=>{a.current&&r==="shades"&&a.current.focus()},[n,r]),n){let{colorName:l,shade:s}=n,d=t[l];if(Array.isArray(d))return Sa("div",{className:"color-picker-content--default shades",children:d.map((m,c)=>sx("button",{ref:c===s&&r==="shades"?a:void 0,tabIndex:-1,type:"button",className:f6("color-picker__button color-picker__button--large has-outline",{active:c===s}),"aria-label":"Shade",title:`${l} - ${c+1}`,style:m?{"--swatch-color":m}:void 0,onClick:()=>{o(m),i("shades")},children:[Sa("div",{className:"color-picker__button-outline"}),Sa(Jr,{color:m,keyLabel:c+1,isShade:!0})]},c))})}return sx("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Sa("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Sa("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 ei,COLOR_PALETTE as E6,KEYS as ka}from"@excalidraw/common";var Pp=(e,o,t)=>{let n=Math.ceil(t/ei);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+ei;return r>=t?o%ei:r}case"ArrowUp":{let r=o-ei,i=r<0?ei*n+r:r;return i>=t?void 0:i}}},y6=({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(Ca.includes(e.key)){let l=Ca.indexOf(e.key),s=Object.keys(n)[l],d=n[s],m=Array.isArray(d)?d[a]:d;return t(m),i("baseColors"),!0}return!1},dx=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:d,onEscape:m})=>{if(e[ka.CTRL_OR_CMD])return!1;if(e.key===ka.ESCAPE)return m(e),!0;if(e.key===ka.ALT)return d(!0),!0;if(e.key===ka.I)return d(),!0;let c=un({color:n,palette:t});if(e.key===ka.TAB){let p={custom:!!i.length,baseColors:!0,shades:c?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[w,v])=>(v&&E.push(w),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,y=u[x];return y&&a(y),y==="custom"?r(i[0]):y==="baseColors"&&(Object.entries(t).find(([w,v])=>Array.isArray(v)?v.includes(n):v===n?w:null)||r(E6.black)),e.preventDefault(),e.stopPropagation(),!0}if(y6({e,colorObj:c,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&c){let{shade:p}=c,u=Pp(e.key,p,ei);if(u!==void 0)return r(t[c.colorName][u]),!0}if(o==="baseColors"&&c){let{colorName:p}=c,u=Object.keys(t),f=u.indexOf(p),b=Pp(e.key,f,u.length);if(b!==void 0){let x=u[b],y=t[x];return r(Array.isArray(y)?y[s]:y),!0}}if(o==="custom"){let p=n!=null?i.indexOf(n):0,u=Pp(e.key,p,i.length);if(u!==void 0){let f=i[u];return r(f),!0}}return!1};import{jsx as or,jsxs as Os}from"react/jsx-runtime";var px=Ap.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},d)=>{let[m]=Ap.useState(()=>t==="canvasBackground"?[]:tx(n,t,r)),[c,p]=se(Yt),u=un({color:e,palette:r});Dp(()=>{if(!c){let y=!!e&&Cp({color:e,palette:r}),E=y&&!m.includes(e);p(E?null:y?"custom":u?.shade!=null?"shades":"baseColors")}},[c,e,r,p,u,m]);let[f,b]=v6(u?.shade??(t==="elementBackground"?T6:I6));Dp(()=>{u?.shade!=null&&b(u.shade);let y=E=>{E.key===C6.ALT&&l(!1)};return document.addEventListener(mx.KEYUP,y,{capture:!0}),()=>{document.removeEventListener(mx.KEYUP,y,{capture:!0})}},[u,l]);let x=Ap.useRef(null);return w6(d,()=>x.current),Dp(()=>{x?.current?.focus()},[]),or("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:Os("div",{ref:x,onKeyDown:y=>{dx({event:y,activeColorPickerSection:c,palette:r,color:e,onChange:o,onEyeDropperToggle:l,customColors:m,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(y.preventDefault(),y.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&Os("div",{children:[or(Qr,{children:g("colorPicker.mostUsedCustomColors")}),or(ax,{colors:m,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),Os("div",{children:[or(Qr,{children:g("colorPicker.colors")}),or(lx,{color:e,palette:r,onChange:o,activeShade:f})]}),Os("div",{children:[or(Qr,{children:g("colorPicker.shades")}),or(cx,{color:e,onChange:o,palette:r})]}),a]})})});import S6 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as k6,DEFAULT_CANVAS_BACKGROUND_PICKS as M6,DEFAULT_ELEMENT_BACKGROUND_PICKS as L6,DEFAULT_ELEMENT_STROKE_PICKS as P6}from"@excalidraw/common";import{jsx as _p}from"react/jsx-runtime";var ux=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=P6),o==="elementBackground"&&(r=L6),o==="canvasBackground"&&(r=M6),n&&(r=n),r?_p("div",{className:"color-picker__top-picks",children:r.map(i=>_p("button",{className:S6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!hn(i,k6)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:_p("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as _t,jsxs as zs}from"react/jsx-runtime";var hx=e=>{let o=new Option().style;return o.color=e,!!o.color},ix=e=>D6(e)?e:hx(`#${e}`)?`#${e}`:hx(e)?e:null,R6=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=bx,updateData:a,getOpenPopup:l,appState:s})=>{let{container:d}=Be(),[,m]=se(Yt),[c,p]=se(mn),u=zs("div",{children:[_t(Qr,{children:g("colorPicker.hexCode")}),_t(rx,{color:o||"",label:n,onChange:x=>{t(x)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),f=fx(null),b=()=>{f.current?.focus()};return _t(Bo,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:x=>{_6(x.target)||b(),x.preventDefault()},onPointerDownOutside:x=>{c&&x.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),m(null),s.editingTextElement&&setTimeout(()=>{let x=document.querySelector(".excalidraw-wysiwyg");x&&x.focus()},0)},children:i?_t(px,{ref:f,palette:i,color:o,onChange:x=>{let y=s.editingTextElement?Bs():null;t(x),s.editingTextElement&&y&&Ta(y)},onEyeDropperToggle:x=>{p(y=>x?(y=y||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},y.keepOpenOnAlt=!0,y):x===!1||y?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:x=>{c?p(null):a({openPopup:null})},type:e,elements:r,updateData:a,children:u}):u})},N6=({label:e,color:o,type:t,compactMode:n=!1,mode:r="background",onToggle:i,editingTextElement:a})=>{let l=s=>{s.preventDefault(),s.stopPropagation(),a&&Qb(),i()};return zs(Hs.Trigger,{type:"button",className:gx("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!hn(o,Rp)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),"data-openpopup":t,onClick:l,children:[_t("div",{className:"color-picker__button-outline",children:!o&&f0}),n&&o&&_t("div",{className:"color-picker__button-background",children:r==="background"?_t("span",{style:{color:o&&hn(o,Rp)?"#fff":"#111"},children:Bb}):_t("span",{style:{color:o&&hn(o,Rp)?"#fff":"#111"},children:Fb})})]})},Ma=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=bx,topPicks:a,updateData:l,appState:s,compactMode:d=!1})=>{let m=fx(s.openPopup);return A6(()=>{m.current=s.openPopup},[s.openPopup]),_t("div",{children:zs("div",{role:"dialog","aria-modal":"true",className:gx("color-picker-container",{"color-picker-container--no-top-picks":d}),children:[!d&&_t(ux,{activeColor:o,onChange:t,type:e,topPicks:a}),!d&&_t(Ds,{}),zs(Hs.Root,{open:s.openPopup===e,onOpenChange:c=>{c&&l({openPopup:e})},children:[_t(N6,{color:o,label:n,type:e,compactMode:d,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&_t(R6,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:l,getOpenPopup:()=>m.current,appState:s})]})]})})};import*as kx from"@radix-ui/react-popover";import c4 from"clsx";import d4,{useCallback as m4,useMemo as p4}from"react";import{FONT_FAMILY as zp}from"@excalidraw/common";import t4,{useMemo as gn,useState as o4,useRef as n4,useEffect as r4,useCallback as wx}from"react";import{arrayToList as i4,debounce as a4,FONT_FAMILY as nr,getFontFamilyString as l4}from"@excalidraw/common";import B6 from"clsx";import F6 from"react";import{jsx as O6,jsxs as z6}from"react/jsx-runtime";var Gs=F6.forwardRef(({className:e,placeholder:o,onChange:t},n)=>z6("div",{className:B6("QuickSearch__wrapper",e),children:[Dt,O6("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import H6 from"clsx";import{Children as G6}from"react";import{jsx as xx}from"react/jsx-runtime";var Us=({className:e,placeholder:o,children:t})=>{let n=!G6.count(t);return xx("div",{className:H6("ScrollableList__wrapper",e),role:"menu",children:n?xx("div",{className:"empty",children:o}):t})};import{jsx as U6,jsxs as Y6}from"react/jsx-runtime";var Ex=({children:e,className:o="",style:t,title:n})=>Y6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&U6("p",{className:"dropdown-menu-group-title",children:n}),e]}),La=Ex;Ex.displayName="DropdownMenuGroup";import{useEffect as J6,useRef as Q6}from"react";import{THEME as e4}from"@excalidraw/common";import{jsx as W6}from"react/jsx-runtime";var Pa=({children:e,...o})=>W6("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as X6,jsx as Ys,jsxs as K6}from"react/jsx-runtime";var V6=({textStyle:e,icon:o,shortcut:t,children:n})=>{let r=me();return K6(X6,{children:[o&&Ys("div",{className:"dropdown-menu-item__icon",children:o}),Ys("div",{style:e,className:"dropdown-menu-item__text",children:Ys(Pa,{children:n})}),t&&!r.editor.isMobile&&Ys("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Ws=V6;import Z6,{useContext as $6}from"react";import{EVENT as j6,composeEventHandlers as q6}from"@excalidraw/common";var Np=Z6.createContext({}),Vs=(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(),Xs=(e,o)=>{let t=$6(Np);return q6(e,n=>{let r=new CustomEvent(j6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(r),r.defaultPrevented||t.onSelect?.(r)})};import{jsx as Bp}from"react/jsx-runtime";var Fp=({icon:e,value:o,order:t,children:n,shortcut:r,className:i,hovered:a,selected:l,textStyle:s,onSelect:d,onClick:m,...c})=>{let p=Xs(m,d),u=Q6(null);return J6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),Bp("button",{...c,ref:u,value:o,onClick:p,className:Vs(i,l,a),title:c.title??c["aria-label"],children:Bp(Ws,{textStyle:s,icon:e,shortcut:r,children:n})})};Fp.displayName="DropdownMenuItem";var ti={GREEN:"green",RED:"red",BLUE:"blue"},Ks=({type:e=ti.BLUE,children:o})=>{let{theme:t}=Eo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===e4.LIGHT?"1.5px solid white":"none"};switch(e){case ti.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ti.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case ti.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Bp("div",{className:"DropDownMenuItemBadge",style:n,children:o})};Ks.displayName="DropdownMenuItemBadge";Fp.Badge=Ks;var ut=Fp;import{KEYS as oi}from"@excalidraw/common";var yx=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[oi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===oi.F)return o.current?.focus(),!0;if(e.key===oi.ESCAPE)return r(),!0;if(e.key===oi.ENTER)return t?.value&&i(t.value),!0;if(e.key===oi.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===oi.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as Aa,jsxs as vx}from"react/jsx-runtime";var s4=e=>{switch(e){case nr.Excalifont:case nr.Virgil:return sn;case nr.Nunito:case nr.Helvetica:return ba;case nr["Lilita One"]:return eb;case nr["Comic Shanns"]:case nr.Cascadia:return bs;default:return ba}},Tx=t4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=Be(),s=Fe(),{fonts:d}=s,{showDeprecatedFonts:m}=yo(),[c,p]=o4(""),u=n4(null),f=gn(()=>Array.from(rn.registered.entries()).filter(([M,{metadata:R}])=>!R.private&&!R.fallback).map(([M,{metadata:R,fontFaces:O}])=>{let V={value:M,icon:s4(M),text:O[0]?.fontFace?.family??"Unknown"};return R.deprecated&&Object.assign(V,{deprecated:R.deprecated,badge:{type:ti.RED,placeholder:g("fontList.badge.old")}}),V}).sort((M,R)=>M.text.toLowerCase()>R.text.toLowerCase()?1:-1),[]),b=gn(()=>new Set(d.getSceneFamilies()),[e]),x=gn(()=>f.filter(M=>b.has(M.value)),[f,b]),y=gn(()=>f.filter(M=>!b.has(M.value)&&(m||!M.deprecated)),[f,b,m]),E=gn(()=>i4([...x,...y].filter(M=>M.text?.toLowerCase().includes(c))),[x,y,c]),w=gn(()=>{let M;return o?M=E.find(R=>R.value===o):e&&(M=E.find(R=>R.value===e)),!M&&c&&(E[0]?.value?n(E[0].value):r()),M},[o,e,c,E,n,r]),v=wx(M=>{let R=null;if(s.state.editingTextElement){let O=document.querySelector(".excalidraw-wysiwyg");O&&(R={start:O.selectionStart,end:O.selectionEnd})}t(M),s.state.editingTextElement&&R&&setTimeout(()=>{let O=document.querySelector(".excalidraw-wysiwyg");O&&R&&(O.focus(),O.selectionStart=R.start,O.selectionEnd=R.end)},0)},[t,s.state.editingTextElement]),C=wx(M=>{yx({event:M,inputRef:u,hoveredFont:w,filteredFonts:E,onSelect:v,onHover:n,onClose:a})&&(M.preventDefault(),M.stopPropagation())},[w,E,v,n,a]);r4(()=>(i(),()=>{a()}),[]);let k=gn(()=>E.filter(M=>b.has(M.value)),[E,b]),P=gn(()=>E.filter(M=>!b.has(M.value)),[E,b]),S=(M,R)=>vx(ut,{icon:M.icon,value:M.value,order:R,textStyle:{fontFamily:l4({fontFamily:M.value})},hovered:M.value===w?.value,selected:M.value===e,tabIndex:M.value===e?0:-1,onClick:O=>{v(Number(O.currentTarget.value))},onMouseMove:()=>{w?.value!==M.value&&n(M.value)},children:[M.text,M.badge&&Aa(Ks,{type:M.badge.type,children:M.badge.placeholder})]},M.value),_=[];return k.length&&_.push(Aa(La,{title:g("fontList.sceneFonts"),children:k.map(S)},"group_1")),P.length&&_.push(Aa(La,{title:g("fontList.availableFonts"),children:P.map((M,R)=>S(M,R+k.length))},"group_2")),vx(Bo,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let M=document.querySelector(".excalidraw-wysiwyg");M&&M.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[Aa(Gs,{ref:u,placeholder:g("quickSearch.placeholder"),onChange:a4(p,20)}),Aa(Us,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:_.length?_:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Ix from"@radix-ui/react-popover";import{jsx as Op}from"react/jsx-runtime";var Cx=({selectedFontFamily:e,isOpened:o=!1})=>{let t=ce();return Op(Ix.Trigger,{asChild:!0,children:Op("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Op($r,{standalone:!0,icon:Fr,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{t(n=>({openPopup:n.openPopup==="fontFamily"?null:n.openPopup}))},style:{border:"none"}})})})};import{jsx as Da,jsxs as Sx}from"react/jsx-runtime";var Mx=[{value:zp.Excalifont,icon:sn,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:zp.Nunito,icon:ba,text:g("labels.normal"),testId:"font-family-normal"},{value:zp["Comic Shanns"],icon:bs,text:g("labels.code"),testId:"font-family-code"}],M$=new Set(Mx.map(e=>e.value));var Lx=d4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=p4(()=>Mx,[]),d=m4(m=>{m&&n(m)},[n]);return Sx("div",{role:"dialog","aria-modal":"true",className:c4("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&Da("div",{className:"buttonList",children:Da(Ut,{type:"button",options:s,value:o,onClick:d})}),!l&&Da(Ds,{}),Sx(kx.Root,{open:e,onOpenChange:a,children:[Da(Cx,{selectedFontFamily:o,isOpened:e}),e&&Da(Tx,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:d,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 ni from"@radix-ui/react-popover";import f4 from"clsx";import Zs,{useEffect as b4}from"react";import{isArrowKey as x4,KEYS as Fo}from"@excalidraw/common";import{jsx as u4}from"react/jsx-runtime";var fn=({className:e,icon:o,size:t="1em"})=>u4("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as g4,jsx as Px,jsxs as Ax}from"react/jsx-runtime";var h4=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>Ax(g4,{children:[Ax("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Px(fn,{icon:o?_b:Ts})]}),o&&Px("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),_a=h4;import{jsx as rr,jsxs as Hp}from"react/jsx-runtime";var E4=ue(!1);function y4({options:e,value:o,label:t,onChange:n,onClose:r,numberOfOptionsToAlwaysShow:i=e.length}){let a=me(),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===Fo.TAB){let b=e.findIndex(y=>y.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;n(e[x].value)}else if(x4(u.key)){let b=No().rtl,x=e.findIndex(y=>y.value===o);if(x!==-1){let y=e.length,E=x;switch(u.key){case(b?Fo.ARROW_LEFT:Fo.ARROW_RIGHT):E=(x+1)%y;break;case(b?Fo.ARROW_RIGHT:Fo.ARROW_LEFT):E=(y+x-1)%y;break;case Fo.ARROW_DOWN:{E=(x+(i??1))%y;break}case Fo.ARROW_UP:{E=(y+x-(i??1))%y;break}}n(e[E].value)}u.preventDefault()}else(u.key===Fo.ESCAPE||u.key===Fo.ENTER)&&(u.preventDefault(),r());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,d]=se(E4),m=Zs.useMemo(()=>e.slice(0,i),[e,i]),c=Zs.useMemo(()=>e.slice(i),[e,i]);b4(()=>{m.some(u=>u.value===o)||d(!0)},[o,m,d]);let p=u=>rr("div",{className:"picker-content",children:u.map((f,b)=>Hp("button",{type:"button",className:f4("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&&rr("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return rr(ni.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:Hp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),c.length>0&&rr(_a,{label:g("labels.more_options"),open:s,openTrigger:()=>{d(u=>!u)},className:"picker-collapsible",children:p(c)})]})})}function Gp({value:e,label:o,options:t,onChange:n,group:r="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Zs.useState(!1),s=Zs.useRef(null);return rr("div",{children:Hp(ni.Root,{open:a,onOpenChange:d=>l(d),children:[rr(ni.Trigger,{name:r,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(d=>d.value===e)?.icon}),a&&rr(y4,{options:t,value:e,label:o,onChange:n,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Dx,{useEffect as w4}from"react";import{jsx as Up,jsxs as _x}from"react/jsx-runtime";var Rx=({updateData:e,app:o,testId:t})=>{let n=Dx.useRef(null),r=Dx.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),d=i.reduce((m,c)=>(m!=null&&m!==c.opacity&&(a=!1),m==null||m>c.opacity?c.opacity:m),l?.opacity??null)??o.state.currentItemOpacity;return w4(()=>{if(n.current&&r.current){let m=n.current,c=r.current,p=m.offsetWidth,u=15,f=d/100*(p-u)+u/2;c.style.left=`${f}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${d}%, var(--button-bg) ${d}%, var(--button-bg) 100%)`}},[d]),_x("label",{className:"control-label",children:[g("labels.opacity"),_x("div",{className:"range-wrapper",children:[Up("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:d,className:"range-input","data-testid":t}),Up("div",{className:"value-bubble",ref:r,children:d!==0?d:null}),Up("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Ux,jsx as te,jsxs as gt}from"react/jsx-runtime";var Gx=.1,ht=(e,o,t,n=!1)=>{let r=Zp(J(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},st=function(e,o,t,n,r){let i=o.state.editingTextElement,a=zx(e),l=null;if(i&&(l=t(i)),!l)if(we(a,o.state)){let d=o.scene.getSelectedElements(o.state),m=n===!0?d:d.filter(c=>n(c));l=F4(m,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},V4=(e,o,t)=>H4(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}),$p=(e,o,t,n,r)=>{let i=new Set,a=ht(e,o,l=>{if(Tt(l)){let s=n(l);i.add(s);let d=$e(l,{fontSize:s});return Ra(d,t.scene.getContainerElement(l),t.scene),d=V4(l,d,t.scene),d}return l},!0);return J(e,o,{includeBoundTextElement:!0}).forEach(l=>{Tt(l)&&z4(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:je.IMMEDIATELY}},X4=B({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:ht(e,o,n=>U4(n.type)?$e(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?je.IMMEDIATELY:je.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>gt(Ux,{children:[o.stylesPanelMode==="full"&&te("h3",{"aria-hidden":"true",children:g("labels.stroke")}),te(Ma,{topPicks:M4,palette:k4,type:"elementStroke",label:g("labels.stroke"),color:st(e,n,i=>i.strokeColor,!0,i=>i?null:o.currentItemStrokeColor),onChange:i=>t({currentItemStrokeColor:i}),elements:e,appState:o,updateData:t,compactMode:o.stylesPanelMode==="compact"})]})}),K4=B({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:je.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!B4(t.currentItemBackgroundColor)&&i.every(l=>Fx(l)&&O4(l.points))){let l=Zp(i);r=e.map(s=>l.has(s.id)&&Fx(s)?$e(s,{backgroundColor:t.currentItemBackgroundColor,...W4(s,!0)}):s)}else r=ht(e,o,l=>$e(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:je.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>gt(Ux,{children:[o.stylesPanelMode==="full"&&te("h3",{"aria-hidden":"true",children:g("labels.background")}),te(Ma,{topPicks:S4,palette:C4,type:"elementBackground",label:g("labels.background"),color:st(e,n,i=>i.backgroundColor,!0,i=>i?null:o.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:o,updateData:t,compactMode:o.stylesPanelMode==="compact"})]})}),Z4=B({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(ae("element","changeFillStyle",`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`),{elements:ht(e,o,r=>$e(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:je.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 gt("fieldset",{children:[te("legend",{children:g("labels.fill")}),te("div",{className:"buttonList",children:te(Ut,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${R4("Alt-Click")})`,icon:i?C0:S0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:k0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:M0,testId:"fill-solid"}],value:st(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(d=>d.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),$4=B({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:ht(e,o,n=>$e(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>gt("fieldset",{children:[o.stylesPanelMode==="full"&&te("legend",{children:g("labels.strokeWidth")}),te("div",{className:"buttonList",children:te(Ut,{group:"stroke-width",options:[{value:Vp.thin,text:g("labels.thin"),icon:ap,testId:"strokeWidth-thin"},{value:Vp.bold,text:g("labels.bold"),icon:L0,testId:"strokeWidth-bold"},{value:Vp.extraBold,text:g("labels.extraBold"),icon:P0,testId:"strokeWidth-extraBold"}],value:st(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),j4=B({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:ht(e,o,n=>$e(n,{seed:D4(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>gt("fieldset",{children:[o.stylesPanelMode==="full"&&te("legend",{children:g("labels.sloppiness")}),te("div",{className:"buttonList",children:te(Ut,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:_0},{value:1,text:g("labels.artist"),icon:R0},{value:2,text:g("labels.cartoonist"),icon:N0}],value:st(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),Pj=B({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:ht(e,o,n=>$e(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>gt("fieldset",{children:[o.stylesPanelMode==="full"&&te("legend",{children:g("labels.strokeStyle")}),te("div",{className:"buttonList",children:te(Ut,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:ap},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:A0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:D0}],value:st(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),q4=B({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:ht(e,o,n=>$e(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:je.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>te(Rx,{updateData:o,app:e,testId:"opacity"})}),J4=B({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>$p(e,o,n,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>gt("fieldset",{children:[te("legend",{children:g("labels.fontSize")}),te("div",{className:"buttonList",children:te(Ut,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:j0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:q0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:J0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:Q0,testId:"fontSize-veryLarge"}],value:st(e,n,i=>{if(Tt(i))return i.fontSize;let a=bn(i,n.scene.getNonDeletedElementsMap());return a?a.fontSize:null},i=>Tt(i)||bn(i,n.scene.getNonDeletedElementsMap())!==null,i=>i?null:o.currentItemFontSize||P4),onChange:i=>{Ia(()=>t(i),o.stylesPanelMode==="compact",!!o.editingTextElement,r?.onPreventClose)}})})]})}),jp=B({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:er,trackEvent:!1,perform:(e,o,t,n)=>$p(e,o,n,r=>Math.round(1/(1+Gx)*r.fontSize)),keyTest:e=>e[ri.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ri.CHEVRON_LEFT||e.key===ri.COMMA)}),qp=B({name:"increaseFontSize",label:"labels.increaseFontSize",icon:er,trackEvent:!1,perform:(e,o,t,n)=>$p(e,o,n,r=>Math.round(r.fontSize*(1+Gx))),keyTest:e=>e[ri.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ri.CHEVRON_RIGHT||e.key===ri.PERIOD)}),Q4=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:ht(e,o,b=>{let x=r?.get(b.id);return x?$e(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:je.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:d}=t,m=je.EVENTUALLY,c,p=!1;if(s)c=s,m=je.IMMEDIATELY;else if(d){c=d,m=je.EVENTUALLY;let f=J(e,o,{includeBoundTextElement:!0}).filter(b=>Tt(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let y=f[b];x+=y?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(c&&!p){let f=new Map,b=new Set,x=!1,y=Array.from(rn.loadedFontsCache.values()),E=Object.entries(A4).find(([C,k])=>k===c)?.[0];d&&E&&y.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:ht(e,o,C=>{if(Tt(C)&&(C.fontFamily!==c||s)){let k=$e(C,{fontFamily:c,lineHeight:N4(c)}),P=r?.get(C.containerId||"")||{},S=n.scene.getContainerElement(C);return a&&S&&P&&n.scene.mutateElement(S,{...P}),x||(b=new Set([...b,...Array.from(k.originalText)])),f.set(k,S),k}return C},!0)});let w=`10px ${_4({fontFamily:c})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(w,v))for(let[C,k]of f)Ra(C,k,n.scene);else window.document.fonts.load(w,v).then(C=>{for(let[k,P]of f){let S=n.scene.getElement(k.id),_=P?n.scene.getElement(P.id):null;S&&Ra(S,_,n.scene)}n.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n,data:r})=>{let i=Wp(new Map),a=Wp(null),[l,s]=I4({}),d=Wp(!0),m=T4(()=>{let c=(p,u)=>st(p,t,f=>{if(Tt(f))return f.fontFamily;let b=bn(f,u);return b?b.fontFamily:null},f=>Tt(f)||bn(f,u)!==null,f=>f?null:o.currentItemFontFamily||L4);return l.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?c(Array.from(i.current?.values()??[]),i.current):!l.openPopup&&o.openPopup!=="fontFamily"?c(e,t.scene.getNonDeletedElementsMap()):a.current},[l.openPopup,o,e,t]);return Yp(()=>{a.current=m},[m]),Yp(()=>{Object.keys(l).length&&(n(l),s({}))},[l]),Yp(()=>(d.current=!1,()=>{d.current=!0}),[]),gt("fieldset",{children:[o.stylesPanelMode==="full"&&te("legend",{children:g("labels.fontFamily")}),te(Lx,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:o.stylesPanelMode==="compact",onSelect:c=>{Ia(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:c}),i.current.clear()},o.stylesPanelMode==="compact",!!o.editingTextElement)},onHover:c=>{s({currentHoveredFontFamily:c,cachedElements:new Map(i.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0})},onPopupChange:c=>{if(c){i.current.clear();let{editingTextElement:p}=o;if(p?.type==="text"){let u=t.scene.getElement(p.id);i.current.set(p.id,$e(u||p,{},!0))}else{let u=J(e,o,{includeBoundTextElement:!0});for(let f of u)i.current.set(f.id,$e(f,{},!0))}s({...l,openPopup:"fontFamily"})}else{let p={currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0};s({...p}),i.current.clear(),o.stylesPanelMode==="compact"&&o.editingTextElement&&Ta(null)}}})]})}}),ek=B({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:ht(e,o,r=>{if(Tt(r)){let i=$e(r,{textAlign:t});return Ra(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap();return gt("fieldset",{children:[te("legend",{children:g("labels.textAlign")}),te("div",{className:"buttonList",children:te(Ut,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:tb,testId:"align-left"},{value:"center",text:g("labels.center"),icon:ob,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:nb,testId:"align-right"}],value:st(e,n,a=>{if(Tt(a))return a.textAlign;let l=bn(a,i);return l?l.textAlign:null},a=>Tt(a)||bn(a,i)!==null,a=>a?null:o.currentItemTextAlign),onChange:a=>{Ia(()=>t(a),o.stylesPanelMode==="compact",!!o.editingTextElement,r?.onPreventClose)}})})]})}}),tk=B({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:ht(e,o,r=>{if(Tt(r)){let i=$e(r,{verticalAlign:t});return Ra(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>te("fieldset",{children:te("div",{className:"buttonList",children:te(Ut,{group:"text-align",options:[{value:$s.TOP,text:g("labels.alignTop"),icon:te(rb,{theme:o.theme}),testId:"align-top"},{value:$s.MIDDLE,text:g("labels.centerVertically"),icon:te(ab,{theme:o.theme}),testId:"align-middle"},{value:$s.BOTTOM,text:g("labels.alignBottom"),icon:te(ib,{theme:o.theme}),testId:"align-bottom"}],value:st(e,n,i=>{if(Tt(i)&&i.containerId)return i.verticalAlign;let a=bn(i,n.scene.getNonDeletedElementsMap());return a?a.verticalAlign:null},i=>Tt(i)||bn(i,n.scene.getNonDeletedElementsMap())!==null,i=>i?null:$s.MIDDLE),onChange:i=>{Ia(()=>t(i),o.stylesPanelMode==="compact",!!o.editingTextElement,r?.onPreventClose)}})})})}),Aj=B({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:ht(e,o,n=>Hx(n)?n:$e(n,{roundness:t==="round"?{type:G4(n.type)?js.ADAPTIVE_RADIUS:js.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=aa(zx(e),o).some(l=>l.roundness?.type===js.LEGACY);return gt("fieldset",{children:[te("legend",{children:g("labels.edges")}),gt("div",{className:"buttonList",children:[te(Ut,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:B0},{value:"round",text:g("labels.round"),icon:F0}],value:st(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!qs(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),Ox=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:O0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:te(z0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:te(Y0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:te(W0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:te(H0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:te(G0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:te(V0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:te(X0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:te(U0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:te(Z0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:te(K0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:te($0,{flip:e}),keyBinding:"v"}],Dj=B({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:ht(e,o,n=>{if(Kp(n)){let{position:r,type:i}=t;if(r==="start")return $e(n,{startArrowhead:i});if(r==="end")return $e(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=No().rtl;return gt("fieldset",{children:[te("legend",{children:g("labels.arrowheads")}),gt("div",{className:"iconSelectList buttonList",children:[te(Gp,{label:"arrowhead_start",options:Ox(!r),value:st(e,n,i=>Kp(i)&&Mr(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),te(Gp,{label:"arrowhead_end",group:"arrowheads",options:Ox(!!r),value:st(e,n,i=>Kp(i)&&Mr(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),ok=B({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,n)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>gt("div",{className:"selected-shape-actions",children:[r("changeArrowType"),r("changeArrowhead")]})}),_j=B({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=ht(e,o,l=>{if(!qs(l))return l;let s=$e(l,{roundness:t===Oo.round?{type:js.PROPORTIONAL_RADIUS}:null,elbowed:t===Oo.elbow,points:t===Oo.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(Hx(s)){s.fixedSegments=null;let d=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let m=Xp.getPointAtIndexGlobalCoordinates(s,0,d),c=Xp.getPointAtIndexGlobalCoordinates(s,-1,d),p=s.startBinding&&d.get(s.startBinding.elementId),u=s.endBinding&&d.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...Bx(s,p,"start",d)}:null,b=u&&s.endBinding?{...s.endBinding,...Bx(s,u,"end",d)}:null;s={...s,startBinding:f,endBinding:b,...Y4(s,d,{points:[m,c].map(x=>v4(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let d=n.scene.getNonDeletedElementsMap();if(s.startBinding){let m=d.get(s.startBinding.elementId);m&&Nx(s,m,"start",n.scene)}if(s.endBinding){let m=d.get(s.endBinding.elementId);m&&Nx(s,m,"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 Xp(l,Zp(e)))}return{elements:r,appState:i,captureUpdate:je.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>gt("fieldset",{children:[te("legend",{children:g("labels.arrowtypes")}),te("div",{className:"buttonList",children:te(Ut,{group:"arrowtypes",options:[{value:Oo.sharp,text:g("labels.arrowtype_sharp"),icon:Yr,testId:"sharp-arrow"},{value:Oo.round,text:g("labels.arrowtype_round"),icon:Vr,testId:"round-arrow"},{value:Oo.elbow,text:g("labels.arrowtype_elbowed"),icon:Wr,testId:"elbow-arrow"}],value:st(e,n,r=>qs(r)?r.elbowed?Oo.elbow:r.roundness?Oo.round:Oo.sharp:null,r=>qs(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as ou,roundToStep as ck}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as dk,CURSOR_TYPE as Kx,MAX_ZOOM as Zx,MIN_ZOOM as $x,THEME as Na,ZOOM_STEP as nu,getShortcutKey as jx,updateActiveTool as ai,CODES as vo,KEYS as Ho}from"@excalidraw/common";import{getNonDeletedElements as mk}from"@excalidraw/element";import{newElementWith as pk}from"@excalidraw/element";import{getCommonBounds as uk}from"@excalidraw/element";import{CaptureUpdateAction as ro}from"@excalidraw/element";import{useEffect as nk}from"react";import{jsx as ik}from"react/jsx-runtime";var ii=()=>{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},Jp=(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`})},rk=(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();Jp(o,r)},Rt=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(nk(()=>()=>ii().classList.remove("excalidraw-tooltip--visible"),[]),r?null:ik("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>rk(i.currentTarget,ii(),o,t),onPointerLeave:()=>ii().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import Js from"open-color";import{CURSOR_TYPE as Qp,MIME_TYPES as eu,THEME as Wx}from"@excalidraw/common";var Vx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',ak='<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"/>',lk=`data:${eu.svg},${encodeURIComponent(`${Vx}${Xx}</svg>`)}`,sk=`data:${eu.svg},${encodeURIComponent(`${Vx}${ak}${Xx}</svg>`)}`,Wt=e=>{e&&(e.style.cursor="")},Ee=(e,o)=>{e&&(e.style.cursor=o)},wo,Yx,tu=(e,o)=>{let n=()=>{let r=o===Wx.DARK;wo=document.createElement("canvas"),wo.theme=o,wo.height=20,wo.width=20;let i=wo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(wo.width/2,wo.height/2,5,0,2*Math.PI),i.fillStyle=r?Js.black:Js.white,i.fill(),i.strokeStyle=r?Js.white:Js.black,i.stroke(),Yx=wo.toDataURL(eu.svg)};(!wo||wo.theme!==o)&&n(),Ee(e,`url(${Yx}) ${20/2} ${20/2}, auto`)},Nt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Wt(e);else if(oo(o))e.style.cursor=Qp.GRAB;else if(vt(o))tu(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===Wx.LIGHT?lk:sk;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Qp.AUTO):e.style.cursor=Qp.CROSSHAIR};var zo=({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),d=-(r-r/t),m=-(i-i/t);return{scrollX:l+d,scrollY:s+m,zoom:{value:t}}};import{jsx as oc,jsxs as bk}from"react/jsx-runtime";var hk=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?ro.IMMEDIATELY:ro.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>oc(Ma,{palette:null,topPicks:dk,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t,compactMode:o.stylesPanelMode==="compact"})}),Go=B({name:"clearCanvas",label:"labels.clearCanvas",icon:At,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=>pk(r,{isDeleted:!0})),appState:{...an(),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:ro.IMMEDIATELY})}),Qs=B({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Um,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...zo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:fo(o.zoom.value+nu)},o),userToFollow:null},captureUpdate:ro.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>oc(K,{type:"button",className:"zoom-in-button zoom-button",icon:Um,title:`${g("buttons.zoomIn")} \u2014 ${jx("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=Zx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===vo.EQUAL||e.code===vo.NUM_ADD)&&(e[Ho.CTRL_OR_CMD]||e.shiftKey)}),ec=B({name:"zoomOut",label:"buttons.zoomOut",icon:Ym,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...zo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:fo(o.zoom.value-nu)},o),userToFollow:null},captureUpdate:ro.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>oc(K,{type:"button",className:"zoom-out-button zoom-button",icon:Ym,title:`${g("buttons.zoomOut")} \u2014 ${jx("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=$x,onClick:()=>{e(null)}}),keyTest:e=>(e.code===vo.MINUS||e.code===vo.NUM_SUBTRACT)&&(e[Ho.CTRL_OR_CMD]||e.shiftKey)}),tc=B({name:"resetZoom",label:"buttons.resetZoom",icon:s0,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...zo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:fo(1)},o),userToFollow:null},captureUpdate:ro.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>oc(Rt,{label:g("buttons.resetZoom"),style:{height:"100%"},children:bk(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===vo.ZERO||e.code===vo.NUM_ZERO)&&(e[Ho.CTRL_OR_CMD]||e.shiftKey)}),gk=(e,o,t=1)=>{let[n,r,i,a]=e,l=i-n,s=o.width/l,d=a-r,m=o.height/d,p=Math.min(s,m)*ou(t,.1,1);return Math.min(p,1)},qx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=ou(r,$x,Zx);let[l,s,d,m]=e,c=(l+d)/2,p=(s+m)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,y=o.width-u-b,E=o.height-f-x,w;if(n){let k=d-l,P=m-s;w=Math.min(y/k,E/P)*r}else w=gk(e,{width:y,height:E},r);let v=fo(ou(ck(w,nu,"floor"),i,a)),C=E1({scenePoint:{x:c,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:ro.EVENTUALLY}},Ba=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=uk(mk(o));return qx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},gq=B({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:vs,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return Ba({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===vo.TWO&&e.shiftKey&&!e.altKey&&!e[Ho.CTRL_OR_CMD]}),fq=B({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:vs,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return Ba({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===vo.THREE&&e.shiftKey&&!e.altKey&&!e[Ho.CTRL_OR_CMD]}),fk=B({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:vs,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>Ba({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===vo.ONE&&e.shiftKey&&!e.altKey&&!e[Ho.CTRL_OR_CMD]}),ir=B({name:"toggleTheme",label:(e,o)=>o.theme===Na.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===Na.LIGHT?ha:ga,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===Na.LIGHT?Na.DARK:Na.LIGHT)},captureUpdate:ro.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===vo.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),bq=B({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return vt(o)?r=ai(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):r=ai(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:ro.IMMEDIATELY}},keyTest:e=>e.key===Ho.E}),xq=B({name:"toggleLassoTool",label:"toolBar.lasso",icon:pa,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.defaultSelectionTool!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=ai(o,{type:"lasso",fromSelection:!1}),Ee(n.interactiveCanvas,Kx.CROSSHAIR)):r=ai(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:ro.NEVER}}}),Jx=B({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Es,viewMode:!1,perform:(e,o,t,n)=>{let r;return oo(o)?r=ai(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=ai(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),Ee(n.interactiveCanvas,Kx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:ro.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Ho.CTRL_OR_CMD]&&e.key===Ho.H});import{updateActiveTool as Qx}from"@excalidraw/common";import{CaptureUpdateAction as xk}from"@excalidraw/element";var Ek=B({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=Qx(o,{type:"embeddable"});return Nt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:Qx(o,{type:"embeddable"})},captureUpdate:xk.EVENTUALLY}}});import{pointFrom as yk}from"@excalidraw/math";import{maybeBindLinearElement as wk,bindOrUnbindLinearElement as eE,isBindingEnabled as vk}from"@excalidraw/element/binding";import{isValidPolygon as tE,LinearElementEditor as Fa,newElementWith as ru}from"@excalidraw/element";import{isBindingElement as nc,isFreeDrawElement as oE,isLinearElement as nE,isLineElement as rc}from"@excalidraw/element";import{KEYS as iu,arrayToMap as au,tupleToCoors as Tk,updateActiveTool as rE}from"@excalidraw/common";import{isPathALoop as Ik}from"@excalidraw/element";import{isInvisiblySmallElement as lu}from"@excalidraw/element";import{CaptureUpdateAction as su}from"@excalidraw/element";import{jsx as Ck}from"react/jsx-runtime";var Bt=B({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let{interactiveCanvas:r,focusContainer:i,scene:a}=n,{event:l,sceneCoords:s}=t??{},d=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=Fa.handlePointerUp(l,o.selectedLinearElement,o,n.scene),{startBindingElement:f,endBindingElement:b}=u,x=n.scene.getElement(u.elementId);if(nc(x)&&eE(x,f,b,n.scene),u!==o.selectedLinearElement){let y=e;return x&&lu(x)&&(y=y.map(E=>E.id===x.id?ru(E,{isDeleted:!0}):E)),{elements:y,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:su.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=Fa.getElement(u,d);if(x)return nc(x)&&eE(x,f,b,a),rc(x)&&!tE(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||lu(x)?e.map(y=>y.id===x.id?ru(y,{isDeleted:!0}):y):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new Fa(x,au(d),!1)},captureUpdate:su.IMMEDIATELY}}let m=e;window.document.activeElement instanceof HTMLElement&&i();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||nc(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=d.get(Object.keys(o.selectedElementIds)[0]);u&&(c=u)}if(c){if(o.multiElement&&c.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=c;(!f||u[u.length-1]!==f)&&a.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&lu(c)&&(m=m.map(u=>u.id===c?.id?ru(u,{isDeleted:!0}):u)),nE(c)||oE(c)){let u=Ik(c.points,o.zoom.value);if(u&&(rc(c)||oE(c))){let f=c.points,b=f[0],x=f.map((y,E)=>E===f.length-1?yk(b[0],b[1]):y);rc(c)?a.mutateElement(c,{points:x,polygon:!0}):a.mutateElement(c,{points:x})}if(rc(c)&&!tE(c.points)&&a.mutateElement(c,{polygon:!1}),nc(c)&&!u&&c.points.length>1&&vk(o)){let f=s??Tk(Fa.getPointAtIndexGlobalCoordinates(c,-1,au(e)));wk(c,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Wt(r);let p;return o.activeTool.type==="eraser"?p=rE(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):p=rE(o,{type:n.defaultSelectionTool}),{elements:m,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:c&&nE(c)?new Fa(c,au(m)):o.selectedLinearElement},captureUpdate:su.IMMEDIATELY}},keyTest:(e,o)=>e.key===iu.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===iu.ESCAPE||e.key===iu.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>Ck(K,{type:"button",icon:x0,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 ci,DEFAULT_EXPORT_PADDING as gM,EXPORT_SCALES as fM,THEME as mu}from"@excalidraw/common";import{getNonDeletedElements as bM}from"@excalidraw/element";import{CaptureUpdateAction as so}from"@excalidraw/element";import Sk from"clsx";import{jsx as iE,jsxs as kk}from"react/jsx-runtime";var Oa=({children:e,checked:o,onChange:t,className:n})=>kk("div",{className:Sk("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[iE("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:p0}),iE("div",{className:"Checkbox-label",children:e})]});import{THEME as za}from"@excalidraw/common";import{jsx as Ha}from"react/jsx-runtime";var lE=e=>{let o=e.title||(e.value===za.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return Ha(K,{type:"icon",icon:e.value===za.LIGHT?aE.MOON:aE.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===za.DARK?za.LIGHT:za.DARK),"data-testid":"toggle-dark-mode"})},aE={SUN:Ha("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ha("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:Ha("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ha("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 Mk}from"react";import{focusNearestParent as Lk,KEYS as Pk}from"@excalidraw/common";import{jsx as sE,jsxs as Ak}from"react/jsx-runtime";var cE=e=>{let{id:o}=Be(),[t,n]=Mk(e.value),r=a=>{e.ignoreFocus||Lk(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===Pk.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return Ak("div",{className:"ProjectName",children:[sE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),sE("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 aM,DEFAULT_FILENAME as lM,IMAGE_MIME_TYPES as CE,isFirefox as sM,MIME_TYPES as cM,cloneJSON as dM,SVG_DOCUMENT_PREAMBLE as mM}from"@excalidraw/common";import{getNonDeletedElements as pM}from"@excalidraw/element";import{isFrameLikeElement as uM}from"@excalidraw/element";import{getElementsOverlappingFrame as hM}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as Uk,EXPORT_DATA_TYPES as Ya,MIME_TYPES as ao,arrayToMap as Yk,isMemberOf as Wk,isPromiseLike as Vk,EVENT as lc}from"@excalidraw/common";import{mutateElement as Xk}from"@excalidraw/element";import{deepCopyElement as Kk}from"@excalidraw/element";import{isFrameLikeElement as Zk,isInitializedImageElement as $k}from"@excalidraw/element";import{getContainingFrame as yE}from"@excalidraw/element";import{pointFrom as xn}from"@excalidraw/math";import{COLOR_PALETTE as mE,DEFAULT_CHART_COLOR_INDEX as Dk,getAllColorsSpecificShade as _k,DEFAULT_FONT_FAMILY as Rk,DEFAULT_FONT_SIZE as pE,VERTICAL_ALIGN as Nk,randomId as uE,isDevEnv as hE}from"@excalidraw/common";import{newTextElement as ic,newLinearElement as Ua,newElement as du}from"@excalidraw/element";var io=32,Te=12,En=256,gE=50,ar="NOT_SPREADSHEET",li="VALID_SPREADSHEET",Ga=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},cu=(e,o)=>e.slice(1).every(t=>Ga(t[o])!==null),dE=e=>{let o=e[0].length;if(o>2)return{type:ar,reason:"More than 2 columns"};if(o===1){if(!cu(e,0))return{type:ar,reason:"Value is not numeric"};let s=Ga(e[0][0])===null,d=(s?e.slice(1):e).map(m=>Ga(m[0]));return d.length<2?{type:ar,reason:"Less than two rows"}:{type:li,spreadsheet:{title:s?e[0][0]:null,labels:null,values:d}}}let t=cu(e,0),n=cu(e,1);if(!t&&!n)return{type:ar,reason:"Value is not numeric"};let[r,i]=n?[0,1]:[1,0],a=Ga(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:ar,reason:"Less than 2 rows"}:{type:li,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[r]),values:l.map(s=>Ga(s[i]))}}},Bk=e=>{let o=[];for(let t=0;t<e[0].length;t++){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][t]);o.push(n)}return o},fE=e=>{let o=e.trim().split(`
|
|
3
|
-
`).map(i=>i.trim().split(" "));if(
|
|
4
|
-
`).map(i=>i.trim().split(","))),
|
|
5
|
-
`).trim()}:n:{type:"text",value:(e.getData(
|
|
1
|
+
import{$ as V1,A as tS,B as _1,C as R1,D as N1,E as us,F as Ta,G as hs,H as gs,I as B1,J as O1,K as Ia,L as F1,M as z1,N as H1,O as G1,P as fs,Q as Rr,R as U1,S as oS,T as Ym,U as nS,V as Nr,W as Ca,Y as Y1,_ as W1,a as P1,aa as bs,b as Qn,ba as X1,c as bo,ca as Wm,d as L1,da as Vm,e as ve,ea as xs,f as A1,fa as K1,g as Q,ga as Xm,h as Lr,ha as Fo,i as xo,ia as Z1,j as Ea,ja as Km,k as ya,ka as $1,l as Ar,la as j1,m as wa,ma as Es,n as Dr,na as Zm,o as D1,oa as q1,p as Hm,pa as J1,q as dn,qa as Q1,r as mn,ra as Sa,s as vt,t as no,u as _r,v as ms,w as Gm,x as va,y as ps,z as Um}from"./chunk-HT4FKTIQ.js";import{a as T}from"./chunk-A66AFZZU.js";import{J as zm}from"./chunk-GF46JCB3.js";import{c as M1}from"./chunk-Z3N5DIM6.js";import{b as S1,c as k1,d as C}from"./chunk-SRAX5OIU.js";import pY,{useEffect as uY}from"react";import{DEFAULT_UI_OPTIONS as JC,isShallowEqual as hY}from"@excalidraw/common";import D5 from"clsx";import YH from"lodash.throttle";import Oo,{useContext as qn}from"react";import{flushSync as ma}from"react-dom";import WH from"roughjs/bin/rough";import{nanoid as VH}from"nanoid";import{clamp as _5,pointFrom as se,pointDistance as Xn,vector as R5,pointRotateRads as _f,vectorScale as XH,vectorFromPoint as Rf,vectorSubtract as N5,vectorDot as B5,vectorNormalize as O5}from"@excalidraw/math";import{COLOR_PALETTE as KH,CODES as F5,shouldResizeFromCenter as z5,shouldMaintainAspectRatio as jl,shouldRotateWithDiscreteAngle as Nf,isArrowKey as Cm,KEYS as W,APP_NAME as ZH,CURSOR_TYPE as Re,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as $H,DEFAULT_VERTICAL_ALIGN as H5,DRAGGING_THRESHOLD as jH,ELEMENT_SHIFT_TRANSLATE_AMOUNT as qH,ELEMENT_TRANSLATE_AMOUNT as G5,EVENT as oe,FRAME_STYLE as Kn,IMAGE_MIME_TYPES as JH,IMAGE_RENDER_TIMEOUT as QH,isBrave as eG,LINE_CONFIRM_THRESHOLD as Bf,MAX_ALLOWED_FILE_BYTES as U5,MIME_TYPES as No,MQ_RIGHT_SIDEBAR_MIN_WIDTH as tG,POINTER_BUTTON as Ir,ROUNDNESS as Sm,SCROLL_TIMEOUT as oG,TAP_TWICE_TIMEOUT as nG,TEXT_TO_CENTER_SNAP_THRESHOLD as rG,THEME as km,THEME_FILTER as iG,TOUCH_CTX_MENU_TIMEOUT as aG,VERTICAL_ALIGN as lG,YOUTUBE_STATES as Mm,ZOOM_STEP as sG,POINTER_EVENTS as pa,TOOL_TYPE as Bo,isIOS as cG,supportsResizeObserver as Y5,DEFAULT_COLLISION_THRESHOLD as W5,DEFAULT_TEXT_ALIGN as dG,ARROW_TYPE as Zn,DEFAULT_REDUCED_GLOBAL_ALPHA as mG,isSafari as pG,isLocalLink as uG,normalizeLink as Of,toValidURL as hG,getGridPoint as lt,getLineHeight as V5,debounce as X5,distance as ua,getFontString as Ff,getNearestScrollableContainer as gG,isInputLike as K5,isToolIcon as fG,isWritableElement as ql,sceneCoordsToViewportCoords as Pm,tupleToCoors as zf,viewportCoordsToSceneCoords as Ue,wrapEvent as bG,updateObject as Hf,updateActiveTool as rn,getShortcutKey as xG,isTransparent as EG,easeToValuesRAF as yG,muteFSAbortError as wG,isTestEnv as c1,isDevEnv as LC,easeOut as vG,updateStable as Jl,addEventListener as Oe,normalizeEOL as TG,getDateTime as Z5,isShallowEqual as IG,arrayToMap as Lm,randomInteger as CG,CLASSES as SG,Emitter as Cr,MINIMUM_ARROW_SIZE as $5,DOUBLE_TAP_POSITION_THRESHOLD as kG,isMobileOrTablet as ha,MQ_MAX_MOBILE as MG,MQ_MIN_TABLET as PG,MQ_MAX_TABLET as LG,MQ_MAX_HEIGHT_LANDSCAPE as AG,MQ_MAX_WIDTH_LANDSCAPE as DG}from"@excalidraw/common";import{getObservedAppState as _G,getCommonBounds as ga,maybeSuggestBindingsForLinearElementAtCoords as j5,getElementAbsoluteCoords as q5,bindOrUnbindLinearElements as J5,fixBindingsAfterDeletion as RG,getHoveredElementForBinding as Gf,isBindingEnabled as Uf,shouldEnableBindingForPointerEvent as NG,updateBoundElements as Yf,getSuggestedBindingsForArrows as Wf,LinearElementEditor as Se,newElementWith as $n,newFrameElement as BG,newFreeDrawElement as OG,newEmbeddableElement as Q5,newMagicFrameElement as eC,newIframeElement as FG,newArrowElement as zG,newElement as HG,newImageElement as GG,newLinearElement as UG,newTextElement as tC,refreshTextDimensions as YG,deepCopyElement as oC,duplicateElements as Vf,hasBoundTextElement as nC,isArrowElement as Xf,isBindingElement as Kf,isBindingElementType as rC,isBoundToContainer as Zf,isFrameLikeElement as Mt,isImageElement as Sr,isEmbeddableElement as an,isInitializedImageElement as Ql,isLinearElement as Qt,isLinearElementType as WG,isUsingAdaptiveRadius as VG,isIframeElement as fa,isIframeLikeElement as es,isMagicFrameElement as $f,isTextBindableContainer as iC,isElbowArrow as $e,isFlowchartNodeElement as XG,isBindableElement as KG,isTextElement as fo,getLockedLinearCursorAlignSize as aC,getNormalizedDimensions as ZG,isElementCompletelyInViewport as jf,isElementInViewport as lC,isInvisiblySmallElement as sC,getCornerRadius as $G,isPathALoop as cC,createSrcDoc as dC,embeddableURLValidator as qf,maybeParseEmbedSrc as jG,getEmbedLink as Am,getInitializedImageElements as qG,normalizeSVG as mC,updateImageCache as JG,getBoundTextElement as Jf,getContainerCenter as Qf,getContainerElement as pC,isValidTextContainer as QG,redrawTextBoundingBox as eU,shouldShowBoundingBox as tU,getFrameChildren as e1,isCursorInFrame as uC,addElementsToFrame as t1,replaceAllElementsInFrame as oU,removeElementsFromFrame as nU,getElementsInResizingFrame as o1,getElementsInNewFrame as rU,getContainingFrame as n1,elementOverlapsWithFrame as iU,updateFrameMembershipOfSelectedElements as hC,isElementInFrame as gC,getFrameLikeTitle as aU,getElementsOverlappingFrame as lU,filterElementsEligibleAsFrameChildren as sU,hitElementBoundText as cU,hitElementBoundingBoxOnly as dU,hitElementItself as ts,getVisibleSceneBounds as mU,FlowChartCreator as pU,FlowChartNavigator as uU,getLinkDirectionFromKey as fC,cropElement as hU,wrapText as gU,isElementLink as r1,parseElementLinkFromURL as fU,isMeasureTextSupported as bU,normalizeText as xU,measureText as bC,getLineHeightInPx as EU,getApproxMinLineWidth as yU,getApproxMinLineHeight as wU,getMinTextElementWidth as vU,ShapeCache as os,getRenderOpacity as TU,editGroupForSelectedElement as IU,getElementsInGroup as kr,getSelectedGroupIdForElement as CU,getSelectedGroupIds as SU,isElementInGroup as xC,isSelectedViaGroup as kU,selectGroupsForSelectedElements as eo,syncInvalidIndices as AC,syncMovedIndices as EC,excludeElementsInFramesFromSelection as MU,getSelectionStateForElements as PU,makeNextSelectedElementIds as Te,getResizeOffsetXY as LU,getResizeArrowDirection as AU,transformElements as DU,getCursorForResizingElement as yC,getElementWithTransformHandleType as wC,getTransformHandleTypeFromCoords as vC,dragNewElement as TC,dragSelectedElements as _U,getDragOffsetXY as RU,isNonDeletedElement as IC,Scene as CC,Store as NU,CaptureUpdateAction as wt,hitElementBoundingBox as BU,isLineElement as Dm,isSimpleArrow as OU,StoreDelta as SC,positionElementsOnGrid as kC}from"@excalidraw/element";import{KEYS as Ep,MOBILE_ACTION_BUTTON_BG as bS,updateActiveTool as xS}from"@excalidraw/common";import{getNonDeletedElements as yp}from"@excalidraw/element";import{fixBindingsAfterDeletion as ES}from"@excalidraw/element";import{LinearElementEditor as V0}from"@excalidraw/element";import{newElementWith as Hs}from"@excalidraw/element";import{getContainerElement as X0}from"@excalidraw/element";import{isBoundToContainer as Fs,isElbowArrow as yS,isFrameLikeElement as wS}from"@excalidraw/element";import{getFrameChildren as vS}from"@excalidraw/element";import{getElementsInGroup as wp,selectGroupsForSelectedElements as TS}from"@excalidraw/element";import{CaptureUpdateAction as zs}from"@excalidraw/element";import{isDevEnv as lS}from"@excalidraw/common";import{atom as ge,createStore as rS}from"jotai";import{createIsolation as iS}from"jotai-scope";var eb=iS();var{useAtom:de,useSetAtom:pn,useAtomValue:ys,useStore:yY}=eb,tb=eb.Provider,We=rS();var aS=S1({"./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-LQE6K457.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 sS=85,Eo={code:"en",label:"English"},Or=[Eo,...[{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=>M1[e.code]>=sS).sort((e,t)=>e.label>t.label?1:-1)],vs="__test__";lS()&&Or.unshift({code:vs,label:"test language"},{code:`${vs}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Br=Eo,ws={},Ts=async e=>{if(Br=e,document.documentElement.dir=Br.rtl?"rtl":"ltr",document.documentElement.lang=Br.code,e.code.startsWith(vs))ws={};else try{ws=await aS(`./locales/${Br.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),ws=zm}We.set(nb,e.code)},zo=()=>Br,ob=(e,t)=>{for(let o=0;o<t.length;++o){let n=t[o];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},g=(e,t,o)=>{if(Br.code.startsWith(vs))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=ob(ws,n)||ob(zm,n)||o;if(r===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)r=r.replace(`{{${i}}}`,String(t[i]));return r},nb=ge(Eo.code),Ne=()=>{let e=ys(nb);return{t:g,langCode:e}};import cS from"clsx";import dS from"open-color";import rt from"react";import{THEME as mS}from"@excalidraw/common";import{Fragment as Ee,jsx as h,jsxs as D}from"react/jsx-runtime";var ro=e=>"var(--icon-fill-color)",rb=e=>e===mS.LIGHT?dS.white:"#1e1e1e",P=(e,t=512)=>{let{width:o=512,height:n=o,mirror:r,style:i,...a}=typeof t=="number"?{width:t}:t;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${o} ${n}`,className:cS({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},F={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},re={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},BY=P(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"})]}),F),Fr=P(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"})]}),F),ib=P(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"})]}),F),ab=P(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"})]}),F),lb=P(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),F),sb=P(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"})]}),F),$m=P(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"})]}),F),er=P(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"})})]}),re),zr=P(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"})]}),re),cb=P(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}),db=P(D(Ee,{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"}),mb=P(D(Ee,{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"}),pb=P(D(Ee,{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"}),OY=P(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"}),tr=P(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}),un=P(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}),Hr=P(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"})]}),F),Gr=P(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"})]}),F),Ur=P(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),F),Is=P(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"})]}),F),Yr=P(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),re),ub=P(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"})]}),F),yo=P(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"})]}),re),wo=P(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"})]}),F),hb=P(D("g",{stroke:"currentColor",strokeWidth:"1.5",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"})]}),F),ka=P(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"})]}),re),Cs=P(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"})]}),F),jm=P(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),re),qm=P(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),re),gb=P(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"})]}),F),At=P(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"}),re),Wr=P(D("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),re),Ma=P(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"})]}),re),Pa=P(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"}),re),La=P(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"})}),{...re,strokeWidth:1.5}),Ss=P(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"})]}),F),or=P(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"}),re),Vr=P(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"})]}),F),fb=P(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"})]}),F),Jm=P(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"}),re),ks=P(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"}),re),bb=P(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"})]}),re),xb=P(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"})]}),F),Eb=P(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Aa=P(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"})]}),re),yb=P("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}),wb=P("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}),Xr=P(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"}),re),FY=P("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}),vb=P("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"),Ms=P(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"})]}),F),Tb=P(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),F),Ps=P(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"})]}),F),Ib=P("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}),zY=P("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}),HY=P("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}),Cb=P("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"),GY=P("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"),Qm=P(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"}),re),ep=P(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"}),re),Sb=P("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}),kb=P(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"}),re),UY=P("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"),YY=P("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}),WY=P(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"})]}),F),VY=P(D(Ee,{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}),XY=P(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}),Mb=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"})]}),Pb=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"})]}),tp=P(Pb,F),op=P(Pb,{...F,style:{transform:"rotate(180deg)"}}),np=P(Mb,F),rp=P(Mb,{...F,style:{transform:"rotate(180deg)"}}),ip=P(D(Ee,{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"})})})]}),re),ap=P(D(Ee,{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"})})})]}),re),lp=P(D(Ee,{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"})})})]}),re),sp=P(D(Ee,{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"})})})]}),re),Lb=P(D(Ee,{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"})})})]}),re),Ab=P(D(Ee,{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"})})})]}),re),cp=P(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"})]}),re),dp=P(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"})]}),re),Ls=P(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"})]}),F),KY=P("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"),ZY=P("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"),Ht=P(D(Ee,{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"})})})]}),re),$Y=P("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}),jY=P("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}),qY=P("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}),mp=rt.memo(({theme:e})=>P(D(Ee,{children:[h("path",{d:"M25 26H111V111H25",fill:ro(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:ro(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:ro(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:ro(e),strokeWidth:"2"}),D("g",{fill:rb(e),stroke:ro(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})),pp=rt.memo(({theme:e})=>P(D(Ee,{children:[h("path",{d:"M25 26H111V111H25",fill:ro(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:ro(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:ro(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:ro(e),strokeWidth:"2"}),D("g",{fill:rb(e),stroke:ro(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})),Db=P(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"})}),re),_b=P(D(Ee,{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"})})]}),re),Rb=P(D(Ee,{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"})})})]}),re),Nb=P(D(Ee,{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"})})})]}),{...re,fill:"currentColor"}),up=P(h(Ee,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),re),Bb=P(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),re),Ob=P(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),re),JY=rt.memo(({theme:e})=>P(h("path",{d:"M6 10H34",stroke:ro(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Fb=P(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"})]}),F),zb=P(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"})]}),F),Hb=P(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"}),re),Gb=P(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"}),re),Ub=P(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"}),re),Yb=P(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"})]}),re),Wb=P(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"})]}),F),Vb=P(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"})]}),F),Xb=rt.memo(({flip:e=!1})=>P(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})),Kb=rt.memo(({flip:e=!1})=>P(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})),Zb=rt.memo(({flip:e=!1})=>P(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})),$b=rt.memo(({flip:e=!1})=>P(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})),jb=rt.memo(({flip:e=!1})=>P(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})),qb=rt.memo(({flip:e=!1})=>P(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})),Jb=rt.memo(({flip:e=!1})=>P(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})),Qb=rt.memo(({flip:e=!1})=>P(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})),e0=rt.memo(({flip:e=!1})=>P(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})),t0=rt.memo(({flip:e=!1})=>P(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})),o0=rt.memo(({flip:e=!1})=>P(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})),n0=P(D(Ee,{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"})})})]}),re),r0=P(D(Ee,{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"})})})]}),re),i0=P(D(Ee,{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"})})})]}),re),a0=P(h(Ee,{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"})}),re),nr=P(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"})]}),F),l0=P(h(Ee,{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"})]})}),F),Da=P(h(Ee,{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"})})}),re),As=P(D(Ee,{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"})})})]}),re),s0=P(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"})]}),F),c0=P(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"})]}),F),d0=P(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"})]}),F),m0=rt.memo(({theme:e})=>P(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"})]}),F)),p0=rt.memo(({theme:e})=>P(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"})]}),F)),u0=rt.memo(({theme:e})=>P(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"})]}),F)),Ds=P(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"})]}),F),h0=P(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}),QY=P(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"})),_s=P(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"})]}),F),hp=P(D(Ee,{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"})]}),F),Kr=P(D(Ee,{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"})]}),F),g0=P(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"})]}),F),f0=P(D(Ee,{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"})]}),F),eW=P(D(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),F),tW=P(D(Ee,{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"})]}),F),b0=P(D(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),F),x0=P(D(Ee,{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"})]}),F),E0=P(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"})]}),F),_a=P(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"})]}),F),io=P(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"})]}),F),Zr=P(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"})),$r=P(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"})]}),re),hn=P(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),rr=P(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"})]}),F),oW=P(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"})]}),F),nW=P(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"})]}),F),y0=P(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"})]}),F),jr=P(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"})]}),F),w0=P(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"})]}),F),v0=P(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"})]}),F),T0=P(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"})]}),F),Dt=P(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"})]}),F),I0=P(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"})]}),F),C0=P(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"})]}),F),S0=P(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"})]}),F),Ra=P(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"})]}),F),k0=P(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"})]}),F),M0=P(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"})]}),F),P0=P(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"})]}),F),L0=P(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"})]}),F),gp=P(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"})]}),F),Rs=P(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"})]}),F),A0=P(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"})]}),F),D0=P(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"})]}),F),_0=P(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"})]}),F),R0=P(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"})]}),F),N0=P(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"})]}),{...F,strokeWidth:1.5}),rW=P(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"})]}),F),B0=P(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"})]}),F),O0=P(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"})]}),F),F0=P(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"})]}),F),qr=P(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"})]}),F),Jr=P(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"})]}),F),Qr=P(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),F),Ns=P(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),F),z0=P(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),F),H0=P(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),F),fp=P(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"})]}),F),Bs=P(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"})]}),F),iW=P(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),F),G0=P(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),F),U0=P(D("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),F);import Y0 from"clsx";import xp,{useEffect as hS,useRef as W0,useState as gS}from"react";import{isPromiseLike as fS}from"@excalidraw/common";import pS from"react";import{jsx as bp}from"react/jsx-runtime";var uS=({size:e="1em",circleWidth:t=8,synchronized:o=!1,className:n=""})=>{let i=-(pS.useRef(Date.now()).current%1600);return bp("div",{className:`Spinner ${n}`,children:bp("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":o?`${i}ms`:0},children:bp("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},it=uS;import{jsx as Na,jsxs as Ba}from"react/jsx-runtime";var V=xp.forwardRef(({size:e="medium",visible:t=!0,className:o="",...n},r)=>{let{id:i}=Be(),a=xp.useRef(null);xp.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,d]=gS(!1),m=W0(!0),c=async u=>{let f="onClick"in n&&n.onClick?.(u);if(fS(f))try{d(!0),await f}catch(b){if(b instanceof Dr)console.warn(b);else throw b}finally{m.current&&d(!1)}};hS(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=W0(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return Ba("button",{className:Y0("ToolIcon_type_button",l,o,t&&!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:c,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&Ba("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&Na("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&Na(it,{})]}),n.showAriaLabel&&Ba("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&Na(it,{})]}),n.children]})}return Ba("label",{className:Y0("ToolIcon",o),title:n.title,onPointerDown:u=>{p.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[Na("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}),Ba("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&Na("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});V.displayName="ToolButton";var Os=[],O=e=>(Os=Os.concat(e),e);import{jsx as CS}from"react/jsx-runtime";var IS=(e,t,o)=>{let n=new Set(Q(e.filter(m=>wS(m)),t).map(m=>m.id)),r={},i=o.scene.getNonDeletedElementsMap(),a=new Set;for(let m of n){let c=vS(e,m);for(let p of c)if(!a.has(p.id)){if(Fs(p)){let u=X0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(t.selectedElementIds[m.id]){let c=Fs(m)?X0(m,i):null;return m.frameId&&n.has(m.frameId)?(l=!1,r[m.id]=!0,m):c?.frameId&&n.has(c?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=o.scene.getNonDeletedElementsMap().get(p.id);u&&yS(u)&&o.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),Hs(m,{isDeleted:!0}))}return m.frameId&&n.has(m.frameId)?(l=!1,Fs(m)||(r[m.id]=!0),Hs(m,{frameId:null})):Fs(m)&&t.selectedElementIds[m.containerId]?Hs(m,{isDeleted:!0}):m}),d=t.editingGroupId;if(l&&t.editingGroupId){let m=wp(s,t.editingGroupId).filter(c=>!c.isDeleted);if(m.length>1)m[0]&&(r[m[0].id]=!0);else{d=null,m[0]&&(r[m[0].id]=!0);let c=m[0];if(c){let p=c.groupIds.findIndex(f=>f===t.editingGroupId),u=c.groupIds[p+1];if(u){let f=wp(s,u).filter(b=>!b.isDeleted);f.length>1&&(d=u,f.forEach(b=>{r[b.id]=!0}))}}}}return{elements:s,appState:{...t,...TS({selectedElementIds:r,editingGroupId:d},s,t,null)}}},K0=(e,t)=>{if(e.editingGroupId){let o=wp(yp(t),e.editingGroupId);if(o.length)return{...e,selectedElementIds:{[o[0].id]:!0}}}return e},Oa=O({name:"deleteSelectedElements",label:"labels.delete",icon:At,trackEvent:{category:"element",action:"delete"},perform:(e,t,o,n)=>{if(t.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:d}=t.selectedLinearElement,m=n.scene.getNonDeletedElementsMap(),c=V0.getElement(a,m);if(!c||l==null)return!1;if(l.length>=c.points.length){let u=e.map(b=>b.id===c.id?Hs(b,{isDeleted:!0}):b),f=K0(t,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:zs.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(c.points.length-1)?null:d};return V0.deletePoints(c,n,l),{elements:e,appState:{...t,selectedLinearElement:{...t.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:zs.IMMEDIATELY}}let{elements:r,appState:i}=IS(e,t,n);return ES(r,r.filter(a=>a.isDeleted)),i=K0(i,r),{elements:r,appState:{...i,activeTool:xS(t,{type:n.state.preferredSelectionTool.type}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:ve(yp(e),t)?zs.IMMEDIATELY:zs.EVENTUALLY}},keyTest:(e,t,o)=>(e.key===Ep.BACKSPACE||e.key===Ep.DELETE)&&!e[Ep.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:o})=>CS(V,{type:"button",icon:At,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>o(null),disabled:!ve(yp(e),t),style:{...t.stylesPanelMode==="mobile"&&t.openPopup!=="compactOtherProperties"?bS:{}}})});import{KEYS as ei,CODES as ti,getShortcutKey as oi,isDarwin as Gs}from"@excalidraw/common";import{moveOneLeft as SS,moveOneRight as kS,moveAllLeft as MS,moveAllRight as PS}from"@excalidraw/element";import{CaptureUpdateAction as Us}from"@excalidraw/element";import{jsx as Ys}from"react/jsx-runtime";var vp=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:op,trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:SS(e,t,n.scene),appState:t,captureUpdate:Us.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ei.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ti.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Ys("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${oi("CtrlOrCmd+[")}`,children:op})}),Tp=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:tp,trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:kS(e,t,n.scene),appState:t,captureUpdate:Us.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ei.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ti.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Ys("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${oi("CtrlOrCmd+]")}`,children:tp})}),Ip=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:rp,trackEvent:{category:"element"},perform:(e,t)=>({elements:MS(e,t),appState:t,captureUpdate:Us.IMMEDIATELY}),keyTest:e=>Gs?e[ei.CTRL_OR_CMD]&&e.altKey&&e.code===ti.BRACKET_LEFT:e[ei.CTRL_OR_CMD]&&e.shiftKey&&e.code===ti.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Ys("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${Gs?oi("CtrlOrCmd+Alt+["):oi("CtrlOrCmd+Shift+[")}`,children:rp})}),Cp=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:np,trackEvent:{category:"element"},perform:(e,t)=>({elements:PS(e,t),appState:t,captureUpdate:Us.IMMEDIATELY}),keyTest:e=>Gs?e[ei.CTRL_OR_CMD]&&e.altKey&&e.code===ti.BRACKET_RIGHT:e[ei.CTRL_OR_CMD]&&e.shiftKey&&e.code===ti.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Ys("button",{type:"button",className:"zIndexButton",onClick:o=>e(null),title:`${g("labels.bringToFront")} \u2014 ${Gs?oi("CtrlOrCmd+Alt+]"):oi("CtrlOrCmd+Shift+]")}`,children:np})});import{getNonDeletedElements as LS}from"@excalidraw/element";import{LinearElementEditor as AS}from"@excalidraw/element";import{isLinearElement as DS,isTextElement as _S}from"@excalidraw/element";import{arrayToMap as RS,KEYS as Z0}from"@excalidraw/common";import{selectGroupsForSelectedElements as NS}from"@excalidraw/element";import{CaptureUpdateAction as BS}from"@excalidraw/element";var Sp=O({name:"selectAll",label:"labels.selectAll",icon:k0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,o,n)=>{if(t.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(_S(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...t,...NS({editingGroupId:null,selectedElementIds:r},LS(e),t,n),selectedLinearElement:Object.keys(r).length===1&&DS(e[0])?new AS(e[0],RS(e)):null},captureUpdate:BS.IMMEDIATELY}},keyTest:e=>e[Z0.CTRL_OR_CMD]&&e.key===Z0.A});import{DEFAULT_GRID_SIZE as $0,KEYS as j0,MOBILE_ACTION_BUTTON_BG as OS,arrayToMap as q0,getShortcutKey as FS}from"@excalidraw/common";import{getNonDeletedElements as J0}from"@excalidraw/element";import{LinearElementEditor as zS}from"@excalidraw/element";import{getSelectedElements as HS,getSelectionStateForElements as GS}from"@excalidraw/element";import{syncMovedIndices as US}from"@excalidraw/element";import{duplicateElements as YS}from"@excalidraw/element";import{CaptureUpdateAction as Q0}from"@excalidraw/element";import{jsx as WS}from"react/jsx-runtime";var kp=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ma,trackEvent:{category:"element"},perform:(e,t,o,n)=>{if(t.selectedElementsAreBeingDragged)return!1;if(t.selectedLinearElement?.isEditing)try{let a=zS.duplicateSelectedPoints(t,n.scene);return{elements:e,appState:a,captureUpdate:Q0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=YS({type:"in-place",elements:e,idsOfElementsToDuplicate:q0(HS(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:t,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+$0/2,y:a.y+$0/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:US(i,q0(r)),appState:{...t,...GS(r,J0(i),t)},captureUpdate:Q0.IMMEDIATELY}},keyTest:e=>e[j0.CTRL_OR_CMD]&&e.key===j0.D,PanelComponent:({elements:e,appState:t,updateData:o})=>WS(V,{type:"button",icon:Ma,title:`${g("labels.duplicateSelection")} \u2014 ${FS("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>o(null),disabled:!ve(J0(e),t),style:{...t.stylesPanelMode==="mobile"&&t.openPopup!=="compactOtherProperties"?OS:{}}})});import{pointFrom as W4}from"@excalidraw/math";import{useEffect as $p,useMemo as V4,useRef as jp,useState as X4}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as K4,DEFAULT_ELEMENT_BACKGROUND_PICKS as Z4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as $4,DEFAULT_ELEMENT_STROKE_PICKS as j4,ARROW_TYPE as Uo,DEFAULT_FONT_FAMILY as q4,DEFAULT_FONT_SIZE as J4,FONT_FAMILY as Q4,ROUNDNESS as sc,STROKE_WIDTH as qp,VERTICAL_ALIGN as lc,KEYS as pi,randomInteger as ek,arrayToMap as eu,getFontFamilyString as tk,getShortcutKey as ok,getLineHeight as nk,isTransparent as rk,reduceToCommonValue as ik}from"@excalidraw/common";import{canBecomePolygon as ak,getNonDeletedElements as Vx}from"@excalidraw/element";import{bindLinearElement as Gx,calculateFixedPointForElbowArrowBinding as Ux,updateBoundElements as lk}from"@excalidraw/element";import{LinearElementEditor as Jp}from"@excalidraw/element";import{newElementWith as qe}from"@excalidraw/element";import{getBoundTextElement as Tn,redrawTextBoundingBox as $a}from"@excalidraw/element";import{isArrowElement as cc,isBoundToContainer as sk,isElbowArrow as Xx,isLinearElement as Qp,isLineElement as Yx,isTextElement as Tt,isUsingAdaptiveRadius as ck}from"@excalidraw/element";import{hasStrokeColor as dk}from"@excalidraw/element";import{updateElbowArrowPoints as mk,CaptureUpdateAction as Je,toggleLinePolygonState as pk}from"@excalidraw/element";import{isDevEnv as VS}from"@excalidraw/common";var XS=new Set(["command_palette","export"]),ie=(e,t,o,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!XS.has(e)||VS())return;T.PROD||console.info("trackEvent",{category:e,action:t,label:o,value:n}),window.sa_event&&window.sa_event(t,{category:e,label:o,value:n})}catch(r){console.error("error during analytics",r)}};import jS from"clsx";import KS from"clsx";import{forwardRef as ZS}from"react";import{jsx as $S}from"react/jsx-runtime";var ni=ZS((e,t)=>{let{title:o,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return $S("button",{type:"button",ref:t,title:o,"data-testid":r,className:KS(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},o)});import{Fragment as JS,jsx as Mp,jsxs as qS}from"react/jsx-runtime";var Gt=e=>Mp(JS,{children:e.options.map(t=>e.type==="button"?Mp(ni,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:o=>e.onClick(t.value,o)},t.text):qS("label",{className:jS({active:e.value===t.value}),title:t.text,children:[Mp("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});import*as Js from"@radix-ui/react-popover";import wx from"clsx";import{useRef as vx,useEffect as J6}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as Ex,COLOR_PALETTE as Tx,isTransparent as Q6,isWritableElement as e4}from"@excalidraw/common";import{jsx as QS}from"react/jsx-runtime";var Ws=()=>QS("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as r6,useRef as i6}from"react";import{createPortal as a6}from"react-dom";import{EVENT as fn,KEYS as l6,rgbToHex as s6}from"@excalidraw/common";import ex from"react";var Pp=ex.createContext(null),xe=()=>ex.useContext(Pp);import{useState as e6,useLayoutEffect as tx}from"react";import{THEME as t6}from"@excalidraw/common";var Vs=e=>{let[t,o]=e6(null),n=he(),{theme:r}=xe(),{container:i}=Be();return tx(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",n.editor.isMobile),t.classList.toggle("theme--dark",r===t6.DARK))},[t,r,n.editor.isMobile,e?.className]),tx(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),o(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),t};import{useEffect as o6}from"react";import{EVENT as Xs}from"@excalidraw/common";function ri(e,t,o){o6(()=>{function n(r){let i=r;if(!e.current)return;let a=o?.(i,e.current);if(a===!0)return;if(a===!1)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||t(i)}return document.addEventListener(Xs.POINTER_DOWN,n),document.addEventListener(Xs.TOUCH_START,n),()=>{document.removeEventListener(Xs.POINTER_DOWN,n),document.removeEventListener(Xs.TOUCH_START,n)}},[e,t,o])}import{useRef as n6}from"react";var gn=e=>{let t=n6(e);return Object.assign(t.current,e),t.current};import{jsx as c6}from"react/jsx-runtime";var bn=ge(null),ox=({onCancel:e,onChange:t,onSelect:o,colorPickerType:n})=>{let r=Vs({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=xe(),a=xn(),l=Fe(),s=Q(a,i),d=gn({app:l,onCancel:e,onChange:t,onSelect:o,selectedElements:s}),{container:m}=Be();r6(()=>{let p=c.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 s6(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 R=b({clientX:S,clientY:L});u&&d.onChange(n,R,d.selectedElements,{altKey:k}),p.style.background=R},w=()=>{d.onCancel()},E=(S,L)=>{d.onSelect(S,L)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,m?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},I=S=>{S.key===l6.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),x({clientX:d.app.lastViewportPosition.x,clientY:d.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(fn.KEYDOWN,I),r.addEventListener(fn.POINTER_DOWN,y),r.addEventListener(fn.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(fn.BLUR,w),()=>{u=!1,r.removeEventListener(fn.KEYDOWN,I),r.removeEventListener(fn.POINTER_DOWN,y),r.removeEventListener(fn.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(fn.BLUR,w)}},[d,l.canvas,r,n,m,i.offsetLeft,i.offsetTop]);let c=i6(null);return ri(c,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?a6(c6("div",{ref:c,className:"excalidraw-eye-dropper-preview"}),r):null};import*as ii from"@radix-ui/react-popover";import u6 from"clsx";import h6 from"react";import{isInteractive as g6}from"@excalidraw/common";import d6 from"react";import m6 from"clsx";import{jsx as p6}from"react/jsx-runtime";var Ye=d6.forwardRef(({children:e,padding:t,className:o,style:n},r)=>p6("div",{className:m6("Island",o),style:{"--padding":t,...n},ref:r,children:e}));import{jsx as Lp,jsxs as f6}from"react/jsx-runtime";var Ho=h6.forwardRef(({className:e,container:t,children:o,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:d=!1},m)=>{let c=he();return Lp(ii.Portal,{container:t,children:f6(ii.Content,{ref:m,className:u6("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,onOpenAutoFocus:p=>{d&&c.isTouchScreen&&p.preventDefault()},onCloseAutoFocus:p=>{p.stopPropagation(),p.preventDefault(),t&&!g6(document.activeElement)&&t.focus(),r()},children:[Lp(Ye,{padding:3,style:n,children:o}),Lp(ii.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{useState as b6,useCallback as Ap}from"react";var Ks=()=>document.querySelector(".excalidraw-wysiwyg"),Zs=()=>{let e=Ks();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Fa=e=>{setTimeout(()=>{let t=Ks();t&&(t.focus(),e&&(t.selectionStart=e.start,t.selectionEnd=e.end))},0)},za=(e,t,o,n)=>{t&&n&&n();let r=t&&o?Zs():null;e(),t&&o&&Fa(r)},nx=()=>{let[e,t]=b6(null),o=Ap(()=>{let i=Zs();t(i)},[]),n=Ap(()=>{setTimeout(()=>{let i=Ks();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,t(null)))},0)},[e]),r=Ap(()=>{t(null)},[]);return{saveCaretPosition:o,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},rx=(e=100)=>{let t=Ks();if(t){let o=t.onblur;t.onblur=null,setTimeout(()=>{t.onblur=o},e)}};import E6 from"clsx";import{useCallback as y6,useEffect as _p,useRef as lx,useState as w6}from"react";import{KEYS as Rp,getShortcutKey as v6}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as x6}from"@excalidraw/common";var En=({palette:e,color:t})=>{if(!t)return null;for(let[o,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(t);if(r>-1)return{colorName:o,shade:r}}else if(n===t)return{colorName:o,shade:null};return null},Ha=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Dp=({color:e,palette:t})=>!Object.values(t).flat().includes(e),ax=(e,t,o)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[t]];return Dp({color:l,palette:o})}),i=new Map;return r.forEach(a=>{let l=a[n[t]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,x6)},Ut=ge(null),ix=(e,t,o)=>(e*299+t*587+o*114)/1e3,ir=(e,t=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]),d=parseInt(l[1]),m=parseInt(l[2]);return ix(s,d,m)<t}return!0}let o=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return ix(o,n,r)<t};import{Fragment as T6,jsx as $s,jsxs as sx}from"react/jsx-runtime";var cx=({color:e,onChange:t,label:o,colorPickerType:n,placeholder:r})=>{let i=he(),[a,l]=w6(e),[s,d]=de(Ut);_p(()=>{l(e)},[e]);let m=y6(b=>{let x=b.toLowerCase(),w=dx(x);w&&t(w),l(x)},[t]),c=lx(null),p=lx(null);_p(()=>{c.current&&c.current.focus()},[s]);let[u,f]=de(bn);return _p(()=>()=>{f(null)},[f]),sx("div",{className:"color-picker__input-label",children:[$s("div",{className:"color-picker__input-hash",children:"#"}),$s("input",{ref:s==="hex"?c:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":o,onChange:b=>{m(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>d("hex"),onKeyDown:b=>{b.key!==Rp.TAB&&(b.key===Rp.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:r}),!i.editor.isMobile&&sx(T6,{children:[$s("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),$s("div",{ref:p,className:E6("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>t(x),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${Rp.I.toLocaleUpperCase()} or ${v6("Alt")} `,children:E0})]})]})};import Fp,{useEffect as zp,useImperativeHandle as U6,useState as Y6}from"react";import{EVENT as fx}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as W6,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as V6,KEYS as X6}from"@excalidraw/common";import S6 from"clsx";import{useEffect as k6,useRef as M6}from"react";import{jsxs as C6}from"react/jsx-runtime";var I6=({color:e,keyLabel:t,isShade:o=!1})=>C6("div",{className:"color-picker__button__hotkey-label",style:{color:ir(e)?"#fff":"#000"},children:[o&&"\u21E7",t]}),ai=I6;import{jsx as Np,jsxs as P6}from"react/jsx-runtime";var mx=({colors:e,color:t,onChange:o,label:n})=>{let[r,i]=de(Ut),a=M6(null);return k6(()=>{a.current&&a.current.focus()},[t,r]),Np("div",{className:"color-picker-content--default",children:e.map((l,s)=>P6("button",{ref:t===l?a:void 0,tabIndex:-1,type:"button",className:S6("color-picker__button color-picker__button--large has-outline",{active:t===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{o(l),i("custom")},title:l,"aria-label":n,style:{"--swatch-color":l},children:[Np("div",{className:"color-picker__button-outline"}),Np(ai,{color:l,keyLabel:s+1})]},s))})};import L6 from"clsx";import{useEffect as A6,useRef as D6}from"react";import{jsx as Bp,jsxs as R6}from"react/jsx-runtime";var _6=({palette:e,color:t,onChange:o,activeShade:n,showHotKey:r=!0})=>{let i=En({color:t,palette:e}),[a,l]=de(Ut),s=D6(null);return A6(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),Bp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([d,m],c)=>{let p=(Array.isArray(m)?m[n]:m)||"transparent",u=Ha[c],f=g(`colors.${d.replace(/\d+/,"")}`,null,"");return R6("button",{ref:i?.colorName===d?s:void 0,tabIndex:-1,type:"button",className:L6("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===d,"is-transparent":p==="transparent"||!p}),onClick:()=>{o(p),l("baseColors")},title:`${f}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${f} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${d}`,children:[Bp("div",{className:"color-picker__button-outline"}),r&&Bp(ai,{color:p,keyLabel:u})]},d)})})},px=_6;import{jsx as B6}from"react/jsx-runtime";var N6=({children:e})=>B6("div",{className:"color-picker__heading",children:e}),li=N6;import O6 from"clsx";import{useEffect as F6,useRef as z6}from"react";import{jsx as Ga,jsxs as ux}from"react/jsx-runtime";var hx=({color:e,onChange:t,palette:o,showHotKey:n})=>{let r=En({color:e||"transparent",palette:o}),[i,a]=de(Ut),l=z6(null);if(F6(()=>{l.current&&i==="shades"&&l.current.focus()},[r,i]),r){let{colorName:s,shade:d}=r,m=o[s];if(Array.isArray(m))return Ga("div",{className:"color-picker-content--default shades",children:m.map((c,p)=>ux("button",{ref:p===d&&i==="shades"?l:void 0,tabIndex:-1,type:"button",className:O6("color-picker__button color-picker__button--large has-outline",{active:p===d}),"aria-label":"Shade",title:`${s} - ${p+1}`,style:c?{"--swatch-color":c}:void 0,onClick:()=>{t(c),a("shades")},children:[Ga("div",{className:"color-picker__button-outline"}),n&&Ga(ai,{color:c,keyLabel:p+1,isShade:!0})]},p))})}return ux("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Ga("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Ga("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 si,COLOR_PALETTE as H6,KEYS as Ua}from"@excalidraw/common";var Op=(e,t,o)=>{let n=Math.ceil(o/si);switch(t=t??-1,e){case"ArrowLeft":{let r=t-1;return r<0?o-1:r}case"ArrowRight":return(t+1)%o;case"ArrowDown":{let r=t+si;return r>=o?t%si:r}case"ArrowUp":{let r=t-si,i=r<0?si*n+r:r;return i>=o?void 0:i}}},G6=({e,colorObj:t,onChange:o,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return o(n[t.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return o(r[Number(e.key)-1]),i("custom"),!0;if(Ha.includes(e.key)){let l=Ha.indexOf(e.key),s=Object.keys(n)[l],d=n[s],m=Array.isArray(d)?d[a]:d;return o(m),i("baseColors"),!0}return!1},gx=({event:e,activeColorPickerSection:t,palette:o,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:d,onEscape:m})=>{if(e[Ua.CTRL_OR_CMD])return!1;if(e.key===Ua.ESCAPE)return m(e),!0;if(e.key===Ua.ALT)return d(!0),!0;if(e.key===Ua.I)return d(),!0;let c=En({color:n,palette:o});if(e.key===Ua.TAB){let p={custom:!!i.length,baseColors:!0,shades:c?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,v])=>(v&&E.push(y),E),[]),f=u.indexOf(t),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(o).find(([y,v])=>Array.isArray(v)?v.includes(n):v===n?y:null)||r(H6.black)),e.preventDefault(),e.stopPropagation(),!0}if(G6({e,colorObj:c,onChange:r,palette:o,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(t==="shades"&&c){let{shade:p}=c,u=Op(e.key,p,si);if(u!==void 0)return r(o[c.colorName][u]),!0}if(t==="baseColors"&&c){let{colorName:p}=c,u=Object.keys(o),f=u.indexOf(p),b=Op(e.key,f,u.length);if(b!==void 0){let x=u[b],w=o[x];return r(Array.isArray(w)?w[s]:w),!0}}if(t==="custom"){let p=n!=null?i.indexOf(n):0,u=Op(e.key,p,i.length);if(u!==void 0){let f=i[u];return r(f),!0}}return!1};import{jsx as yn,jsxs as js}from"react/jsx-runtime";var bx=Fp.forwardRef(({color:e,onChange:t,type:o,elements:n,palette:r,updateData:i,children:a,showTitle:l,onEyeDropperToggle:s,onEscape:d,showHotKey:m=!0},c)=>{let p=l?o==="elementStroke"?g("labels.stroke"):o==="elementBackground"?g("labels.background"):null:null,[u]=Fp.useState(()=>o==="canvasBackground"?[]:ax(n,o,r)),[f,b]=de(Ut),x=En({color:e,palette:r});zp(()=>{if(!f){let v=!!e&&Dp({color:e,palette:r}),I=v&&!u.includes(e);b(I?null:v?"custom":x?.shade!=null?"shades":"baseColors")}},[f,e,r,b,x,u]);let[w,E]=Y6(x?.shade??(o==="elementBackground"?W6:V6));zp(()=>{x?.shade!=null&&E(x.shade);let v=I=>{I.key===X6.ALT&&s(!1)};return document.addEventListener(fx.KEYUP,v,{capture:!0}),()=>{document.removeEventListener(fx.KEYUP,v,{capture:!0})}},[x,s]);let y=Fp.useRef(null);return U6(c,()=>y.current),zp(()=>{y?.current?.focus()},[]),yn("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:js("div",{ref:y,onKeyDown:v=>{gx({event:v,activeColorPickerSection:f,palette:r,color:e,onChange:t,onEyeDropperToggle:s,customColors:u,setActiveColorPickerSection:b,updateData:i,activeShade:w,onEscape:d})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[p&&yn("div",{className:"color-picker__title",children:p}),!!u.length&&js("div",{children:[yn(li,{children:g("colorPicker.mostUsedCustomColors")}),yn(mx,{colors:u,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:t})]}),js("div",{children:[yn(li,{children:g("colorPicker.colors")}),yn(px,{color:e,palette:r,onChange:t,activeShade:w,showHotKey:m})]}),js("div",{children:[yn(li,{children:g("colorPicker.shades")}),yn(hx,{color:e,onChange:t,palette:r,showHotKey:m})]}),a]})})});import K6 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as Z6,DEFAULT_CANVAS_BACKGROUND_PICKS as $6,DEFAULT_ELEMENT_BACKGROUND_PICKS as j6,DEFAULT_ELEMENT_STROKE_PICKS as q6}from"@excalidraw/common";import{jsx as Hp}from"react/jsx-runtime";var xx=({onChange:e,type:t,activeColor:o,topPicks:n})=>{let r;return t==="elementStroke"&&(r=q6),t==="elementBackground"&&(r=j6),t==="canvasBackground"&&(r=$6),n&&(r=n),r?Hp("div",{className:"color-picker__top-picks",children:r.map(i=>Hp("button",{className:K6("color-picker__button",{active:i===o,"is-transparent":i==="transparent"||!i,"has-outline":!ir(i,Z6)}),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 Yt,jsxs as qs}from"react/jsx-runtime";var yx=e=>{let t=new Option().style;return t.color=e,!!t.color},dx=e=>Q6(e)?e:yx(`#${e}`)?`#${e}`:yx(e)?e:null,t4=({type:e,color:t,onChange:o,label:n,elements:r,palette:i=Tx,updateData:a,getOpenPopup:l,appState:s})=>{let{container:d}=Be(),[,m]=de(Ut),[c,p]=de(bn),u=qs("div",{children:[Yt(li,{children:g("colorPicker.hexCode")}),Yt(cx,{color:t||"",label:n,onChange:x=>{o(x)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),f=vx(null),b=()=>{f.current?.focus()};return Yt(Ho,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:x=>{e4(x.target)||b(),x.preventDefault()},onPointerDownOutside:x=>{c&&x.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),m(null),s.editingTextElement&&setTimeout(()=>{let x=document.querySelector(".excalidraw-wysiwyg");x&&x.focus()},0)},children:i?Yt(bx,{ref:f,palette:i,color:t,onChange:x=>{let w=s.editingTextElement?Zs():null;o(x),s.editingTextElement&&w&&Fa(w)},onEyeDropperToggle:x=>{p(w=>x?(w=w||{keepOpenOnAlt:!0,onSelect:o,colorPickerType:e},w.keepOpenOnAlt=!0,w):x===!1||w?null:{keepOpenOnAlt:!1,onSelect:o,colorPickerType:e})},onEscape:x=>{c?p(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:s.stylesPanelMode==="compact"||s.stylesPanelMode==="mobile",showHotKey:s.stylesPanelMode!=="mobile",children:u}):u})},o4=({label:e,color:t,type:o,stylesPanelMode:n,mode:r="background",onToggle:i,editingTextElement:a})=>{let l=s=>{s.preventDefault(),s.stopPropagation(),a&&rx(),i()};return qs(Js.Trigger,{type:"button",className:wx("color-picker__button active-color properties-trigger",{"is-transparent":!t||t==="transparent","has-outline":!t||!ir(t,Ex),"compact-sizing":n==="compact"||n==="mobile","mobile-border":n==="mobile"}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:o==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),"data-openpopup":o,onClick:l,children:[Yt("div",{className:"color-picker__button-outline",children:!t&&Tb}),(n==="compact"||n==="mobile")&&t&&r==="stroke"&&Yt("div",{className:"color-picker__button-background",children:Yt("span",{style:{color:t&&ir(t,Ex)?"#fff":"#111"},children:U0})})]})},Ya=({type:e,color:t,onChange:o,label:n,elements:r,palette:i=Tx,topPicks:a,updateData:l,appState:s})=>{let d=vx(s.openPopup);J6(()=>{d.current=s.openPopup},[s.openPopup]);let m=s.stylesPanelMode==="compact"||s.stylesPanelMode==="mobile";return Yt("div",{children:qs("div",{role:"dialog","aria-modal":"true",className:wx("color-picker-container",{"color-picker-container--no-top-picks":m}),children:[!m&&Yt(xx,{activeColor:t,onChange:o,type:e,topPicks:a}),!m&&Yt(Ws,{}),qs(Js.Root,{open:s.openPopup===e,onOpenChange:c=>{c&&l({openPopup:e})},children:[Yt(o4,{color:t,label:n,type:e,stylesPanelMode:s.stylesPanelMode,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&Yt(t4,{type:e,color:t,onChange:o,label:n,elements:r,palette:i,updateData:l,getOpenPopup:()=>d.current,appState:s})]})]})})};import*as _x from"@radix-ui/react-popover";import A4 from"clsx";import D4,{useCallback as _4,useMemo as R4}from"react";import{FONT_FAMILY as Vp}from"@excalidraw/common";import v4,{useMemo as wn,useState as T4,useRef as I4,useEffect as C4,useCallback as kx}from"react";import{arrayToList as S4,debounce as k4,FONT_FAMILY as ar,getFontFamilyString as M4}from"@excalidraw/common";import n4 from"clsx";import r4 from"react";import{jsx as i4,jsxs as a4}from"react/jsx-runtime";var Qs=r4.forwardRef(({className:e,placeholder:t,onChange:o},n)=>a4("div",{className:n4("QuickSearch__wrapper",e),children:[Dt,i4("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:t,onChange:r=>o(r.target.value.trim().toLowerCase())})]}));import l4 from"clsx";import{Children as s4}from"react";import{jsx as Ix}from"react/jsx-runtime";var ec=({className:e,placeholder:t,children:o})=>{let n=!s4.count(o);return Ix("div",{className:l4("ScrollableList__wrapper",e),role:"menu",children:n?Ix("div",{className:"empty",children:t}):o})};import{jsx as c4,jsxs as d4}from"react/jsx-runtime";var Cx=({children:e,className:t="",style:o,title:n})=>d4("div",{className:`dropdown-menu-group ${t}`,style:o,children:[n&&c4("p",{className:"dropdown-menu-group-title",children:n}),e]}),Wa=Cx;Cx.displayName="DropdownMenuGroup";import{useEffect as E4,useRef as y4}from"react";import{THEME as w4}from"@excalidraw/common";import{jsx as m4}from"react/jsx-runtime";var Va=({children:e,...t})=>m4("span",{...t,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...t.style},children:e});import{Fragment as u4,jsx as tc,jsxs as h4}from"react/jsx-runtime";var p4=({textStyle:e,icon:t,shortcut:o,children:n})=>{let r=he();return h4(u4,{children:[t&&tc("div",{className:"dropdown-menu-item__icon",children:t}),tc("div",{style:e,className:"dropdown-menu-item__text",children:tc(Va,{children:n})}),o&&!r.editor.isMobile&&tc("div",{className:"dropdown-menu-item__shortcut",children:o})]})},oc=p4;import g4,{useContext as f4}from"react";import{EVENT as b4,composeEventHandlers as x4}from"@excalidraw/common";var Gp=g4.createContext({}),nc=(e="",t=!1,o=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
2
|
+
${t?"dropdown-menu-item--selected":""} ${o?"dropdown-menu-item--hovered":""}`.trim(),rc=(e,t)=>{let o=f4(Gp);return x4(e,n=>{let r=new CustomEvent(b4.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});t?.(r),r.defaultPrevented||o.onSelect?.(r)})};import{jsx as Up}from"react/jsx-runtime";var Yp=({icon:e,value:t,order:o,children:n,shortcut:r,className:i,hovered:a,selected:l,textStyle:s,onSelect:d,onClick:m,...c})=>{let p=rc(m,d),u=y4(null);return E4(()=>{a&&(o===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,o]),Up("button",{...c,ref:u,value:t,onClick:p,className:nc(i,l,a),title:c.title??c["aria-label"],children:Up(oc,{textStyle:s,icon:e,shortcut:r,children:n})})};Yp.displayName="DropdownMenuItem";var ci={GREEN:"green",RED:"red",BLUE:"blue"},ic=({type:e=ci.BLUE,children:t})=>{let{theme:o}=vo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:o===w4.LIGHT?"1.5px solid white":"none"};switch(e){case ci.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ci.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case ci.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Up("div",{className:"DropDownMenuItemBadge",style:n,children:t})};ic.displayName="DropdownMenuItemBadge";Yp.Badge=ic;var ut=Yp;import{KEYS as di}from"@excalidraw/common";var Sx=({event:e,inputRef:t,hoveredFont:o,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[di.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===di.F)return t.current?.focus(),!0;if(e.key===di.ESCAPE)return r(),!0;if(e.key===di.ENTER)return o?.value&&i(o.value),!0;if(e.key===di.ARROW_DOWN)return o?.next?a(o.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===di.ARROW_UP)return o?.prev?a(o.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as Xa,jsxs as Mx}from"react/jsx-runtime";var P4=e=>{switch(e){case ar.Excalifont:case ar.Virgil:return yo;case ar.Nunito:case ar.Helvetica:return Da;case ar["Lilita One"]:return l0;case ar["Comic Shanns"]:case ar.Cascadia:return As;default:return Da}},Px=v4.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:o,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=Be(),s=Fe(),{fonts:d}=s,{showDeprecatedFonts:m}=To(),[c,p]=T4(""),u=I4(null),f=wn(()=>Array.from(dn.registered.entries()).filter(([M,{metadata:_}])=>!_.private&&!_.fallback).map(([M,{metadata:_,fontFaces:N}])=>{let K={value:M,icon:P4(M),text:N[0]?.fontFace?.family??"Unknown"};return _.deprecated&&Object.assign(K,{deprecated:_.deprecated,badge:{type:ci.RED,placeholder:g("fontList.badge.old")}}),K}).sort((M,_)=>M.text.toLowerCase()>_.text.toLowerCase()?1:-1),[]),b=wn(()=>new Set(d.getSceneFamilies()),[e]),x=wn(()=>f.filter(M=>b.has(M.value)),[f,b]),w=wn(()=>f.filter(M=>!b.has(M.value)&&(m||!M.deprecated)),[f,b,m]),E=wn(()=>S4([...x,...w].filter(M=>M.text?.toLowerCase().includes(c))),[x,w,c]),y=wn(()=>{let M;return t?M=E.find(_=>_.value===t):e&&(M=E.find(_=>_.value===e)),!M&&c&&(E[0]?.value?n(E[0].value):r()),M},[t,e,c,E,n,r]),v=kx(M=>{let _=null;if(s.state.editingTextElement){let N=document.querySelector(".excalidraw-wysiwyg");N&&(_={start:N.selectionStart,end:N.selectionEnd})}o(M),s.state.editingTextElement&&_&&setTimeout(()=>{let N=document.querySelector(".excalidraw-wysiwyg");N&&_&&(N.focus(),N.selectionStart=_.start,N.selectionEnd=_.end)},0)},[o,s.state.editingTextElement]),I=kx(M=>{Sx({event:M,inputRef:u,hoveredFont:y,filteredFonts:E,onSelect:v,onHover:n,onClose:a})&&(M.preventDefault(),M.stopPropagation())},[y,E,v,n,a]);C4(()=>(i(),()=>{a()}),[]);let S=wn(()=>E.filter(M=>b.has(M.value)),[E,b]),L=wn(()=>E.filter(M=>!b.has(M.value)),[E,b]),k=(M,_)=>Mx(ut,{icon:M.icon,value:M.value,order:_,textStyle:{fontFamily:M4({fontFamily:M.value})},hovered:M.value===y?.value,selected:M.value===e,tabIndex:M.value===e?0:-1,onClick:N=>{v(Number(N.currentTarget.value))},onMouseMove:()=>{y?.value!==M.value&&n(M.value)},children:[M.text,M.badge&&Xa(ic,{type:M.badge.type,children:M.badge.placeholder})]},M.value),R=[];return S.length&&R.push(Xa(Wa,{title:g("fontList.sceneFonts"),children:S.map(k)},"group_1")),L.length&&R.push(Xa(Wa,{title:g("fontList.availableFonts"),children:L.map((M,_)=>k(M,_+S.length))},"group_2")),Mx(Ho,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let M=document.querySelector(".excalidraw-wysiwyg");M&&M.focus()},0)},onPointerLeave:r,onKeyDown:I,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[s.state.stylesPanelMode==="full"&&Xa(Qs,{ref:u,placeholder:g("quickSearch.placeholder"),onChange:k4(p,20)}),Xa(ec,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:R.length?R:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);import*as Lx from"@radix-ui/react-popover";import{MOBILE_ACTION_BUTTON_BG as L4}from"@excalidraw/common";import{jsx as Wp}from"react/jsx-runtime";var Ax=({selectedFontFamily:e,isOpened:t=!1,compactMode:o=!1})=>{let n=me(),r=o?{...L4,width:"2rem",height:"2rem"}:{};return Wp(Lx.Trigger,{asChild:!0,children:Wp("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Wp(ni,{standalone:!0,icon:wo,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:t,onClick:()=>{n(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as Ka,jsxs as Dx}from"react/jsx-runtime";var Rx=[{value:Vp.Excalifont,icon:yo,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Vp.Nunito,icon:Da,text:g("labels.normal"),testId:"font-family-normal"},{value:Vp["Comic Shanns"],icon:As,text:g("labels.code"),testId:"font-family-code"}],nj=new Set(Rx.map(e=>e.value));var Nx=D4.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:o,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=R4(()=>Rx,[]),d=_4(m=>{m&&n(m)},[n]);return Dx("div",{role:"dialog","aria-modal":"true",className:A4("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&Ka("div",{className:"buttonList",children:Ka(Gt,{type:"button",options:s,value:t,onClick:d})}),!l&&Ka(Ws,{}),Dx(_x.Root,{open:e,onOpenChange:a,children:[Ka(Ax,{selectedFontFamily:t,isOpened:e,compactMode:l}),e&&Ka(Px,{selectedFontFamily:t,hoveredFontFamily:o,onSelect:d,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);import*as mi from"@radix-ui/react-popover";import F4 from"clsx";import ac,{useEffect as z4}from"react";import{isArrowKey as H4,KEYS as Go}from"@excalidraw/common";import{jsx as N4}from"react/jsx-runtime";var vn=({className:e,icon:t,size:o="1em"})=>N4("span",{className:e,style:{width:o,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:t});import{Fragment as O4,jsx as Bx,jsxs as Ox}from"react/jsx-runtime";var B4=({label:e,open:t,openTrigger:o,children:n,className:r,showCollapsedIcon:i=!0})=>Ox(O4,{children:[Ox("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:o,children:[e,i&&Bx(vn,{icon:t?z0:Ns})]}),t&&Bx("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),Za=B4;import{jsx as lr,jsxs as Xp}from"react/jsx-runtime";var G4=ge(!1);function U4({options:e,value:t,label:o,onChange:n,onClose:r,numberOfOptionsToAlwaysShow:i=e.length}){let a=he(),l=f=>{let b=e.find(x=>x.keyBinding===f.key.toLowerCase());if(!(f.metaKey||f.altKey||f.ctrlKey)&&b)n(b.value),f.preventDefault();else if(f.key===Go.TAB){let x=e.findIndex(E=>E.value===t),w=f.shiftKey?(e.length+x-1)%e.length:(x+1)%e.length;n(e[w].value)}else if(H4(f.key)){let x=zo().rtl,w=e.findIndex(E=>E.value===t);if(w!==-1){let E=e.length,y=w;switch(f.key){case(x?Go.ARROW_LEFT:Go.ARROW_RIGHT):y=(w+1)%E;break;case(x?Go.ARROW_RIGHT:Go.ARROW_LEFT):y=(E+w-1)%E;break;case Go.ARROW_DOWN:{y=(w+(i??1))%E;break}case Go.ARROW_UP:{y=(E+w-(i??1))%E;break}}n(e[y].value)}f.preventDefault()}else(f.key===Go.ESCAPE||f.key===Go.ENTER)&&(f.preventDefault(),r());f.nativeEvent.stopImmediatePropagation(),f.stopPropagation()},[s,d]=de(G4),m=ac.useMemo(()=>e.slice(0,i),[e,i]),c=ac.useMemo(()=>e.slice(i),[e,i]);z4(()=>{m.some(f=>f.value===t)||d(!0)},[t,m,d]);let p=f=>lr("div",{className:"picker-content",children:f.map((b,x)=>Xp("button",{type:"button",className:F4("picker-option",{active:t===b.value}),onClick:w=>{n(b.value)},title:`${b.text} ${b.keyBinding&&`\u2014 ${b.keyBinding.toUpperCase()}`}`,"aria-label":b.text||"none","aria-keyshortcuts":b.keyBinding||void 0,ref:w=>{t===b.value&&setTimeout(()=>{w?.focus()},0)},children:[b.icon,b.keyBinding&&lr("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),u=a.editor.isMobile;return lr(mi.Content,{side:u?"right":"bottom",align:"start",sideOffset:u?8:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:Xp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,children:[p(m),c.length>0&&lr(Za,{label:g("labels.more_options"),open:s,openTrigger:()=>{d(f=>!f)},className:"picker-collapsible",children:p(c)})]})})}function Kp({value:e,label:t,options:o,onChange:n,group:r="",numberOfOptionsToAlwaysShow:i}){let[a,l]=ac.useState(!1),s=ac.useRef(null);return lr("div",{children:Xp(mi.Root,{open:a,onOpenChange:d=>l(d),children:[lr(mi.Trigger,{name:r,type:"button","aria-label":t,onClick:()=>l(!a),ref:s,className:a?"active":"",children:o.find(d=>d.value===e)?.icon}),a&&lr(U4,{options:o,value:e,label:t,onChange:n,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Fx,{useEffect as Y4}from"react";import{jsx as Zp,jsxs as zx}from"react/jsx-runtime";var Hx=({updateData:e,app:t,testId:o})=>{let n=Fx.useRef(null),r=Fx.useRef(null),i=t.scene.getSelectedElements(t.state),a=!0,l=i.at(0),d=i.reduce((m,c)=>(m!=null&&m!==c.opacity&&(a=!1),m==null||m>c.opacity?c.opacity:m),l?.opacity??null)??t.state.currentItemOpacity;return Y4(()=>{if(n.current&&r.current){let m=n.current,c=r.current,p=m.offsetWidth,u=15,f=d/100*(p-u)+u/2;c.style.left=`${f}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${d}%, var(--button-bg) ${d}%, var(--button-bg) 100%)`}},[d]),zx("label",{className:"control-label",children:[g("labels.opacity"),zx("div",{className:"range-wrapper",children:[Zp("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:d,className:"range-input","data-testid":o}),Zp("div",{className:"value-bubble",ref:r,children:d!==0?d:null}),Zp("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as ru,jsx as te,jsxs as gt}from"react/jsx-runtime";var Kx=.1,ht=(e,t,o,n=!1)=>{let r=eu(Q(e,t,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===t.editingTextElement?.id?o(i):i)},st=function(e,t,o,n,r){let i=t.state.editingTextElement,a=Vx(e),l=null;if(i&&(l=o(i)),!l)if(ve(a,t.state)){let d=t.scene.getSelectedElements(t.state),m=n===!0?d:d.filter(c=>n(c));l=ik(m,o)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},uk=(e,t,o)=>sk(t)||!t.autoResize?t:o.mutateElement(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2}),tu=(e,t,o,n,r)=>{let i=new Set,a=ht(e,t,l=>{if(Tt(l)){let s=n(l);i.add(s);let d=qe(l,{fontSize:s});return $a(d,o.scene.getContainerElement(l),o.scene),d=uk(l,d,o.scene),d}return l},!0);return Q(e,t,{includeBoundTextElement:!0}).forEach(l=>{Tt(l)&&lk(l,o.scene)}),{elements:a,appState:{...t,currentItemFontSize:i.size===1?[...i][0]:r??t.currentItemFontSize},captureUpdate:Je.IMMEDIATELY}},hk=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,o)=>({...o.currentItemStrokeColor&&{elements:ht(e,t,n=>dk(n.type)?qe(n,{strokeColor:o.currentItemStrokeColor}):n,!0)},appState:{...t,...o},captureUpdate:o.currentItemStrokeColor?Je.IMMEDIATELY:Je.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n,data:r})=>gt(ru,{children:[t.stylesPanelMode==="full"&&te("h3",{"aria-hidden":"true",children:g("labels.stroke")}),te(Ya,{topPicks:j4,palette:$4,type:"elementStroke",label:g("labels.stroke"),color:st(e,n,i=>i.strokeColor,!0,i=>i?null:t.currentItemStrokeColor),onChange:i=>o({currentItemStrokeColor:i}),elements:e,appState:t,updateData:o,compactMode:t.stylesPanelMode==="compact"||t.stylesPanelMode==="mobile"})]})}),gk=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,o,n)=>{if(!o.currentItemBackgroundColor)return{appState:{...t,...o},captureUpdate:Je.EVENTUALLY};let r,i=n.scene.getSelectedElements(t);if(!rk(o.currentItemBackgroundColor)&&i.every(l=>Yx(l)&&ak(l.points))){let l=eu(i);r=e.map(s=>l.has(s.id)&&Yx(s)?qe(s,{backgroundColor:o.currentItemBackgroundColor,...pk(s,!0)}):s)}else r=ht(e,t,l=>qe(l,{backgroundColor:o.currentItemBackgroundColor}));return{elements:r,appState:{...t,...o},captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:o,app:n,data:r})=>gt(ru,{children:[t.stylesPanelMode==="full"&&te("h3",{"aria-hidden":"true",children:g("labels.background")}),te(Ya,{topPicks:Z4,palette:K4,type:"elementBackground",label:g("labels.background"),color:st(e,n,i=>i.backgroundColor,!0,i=>i?null:t.currentItemBackgroundColor),onChange:i=>o({currentItemBackgroundColor:i}),elements:e,appState:t,updateData:o,compactMode:t.stylesPanelMode==="compact"||t.stylesPanelMode==="mobile"})]})}),fk=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,o,n)=>(ie("element","changeFillStyle",`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`),{elements:ht(e,t,r=>qe(r,{fillStyle:o})),appState:{...t,currentItemFillStyle:o},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>{let r=Q(e,t),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return gt("fieldset",{children:[te("legend",{children:g("labels.fill")}),te("div",{className:"buttonList",children:te(Gt,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${ok("Alt-Click")})`,icon:i?Db:_b,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:Rb,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:Nb,testId:"fill-solid"}],value:st(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:t.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(d=>d.fillStyle==="hachure")?"zigzag":a;o(s)}})})]})}}),bk=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,o)=>({elements:ht(e,t,n=>qe(n,{strokeWidth:o})),appState:{...t,currentItemStrokeWidth:o},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n,data:r})=>gt("fieldset",{children:[te("legend",{children:g("labels.strokeWidth")}),te("div",{className:"buttonList",children:te(Gt,{group:"stroke-width",options:[{value:qp.thin,text:g("labels.thin"),icon:up,testId:"strokeWidth-thin"},{value:qp.bold,text:g("labels.bold"),icon:Bb,testId:"strokeWidth-bold"},{value:qp.extraBold,text:g("labels.extraBold"),icon:Ob,testId:"strokeWidth-extraBold"}],value:st(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:t.currentItemStrokeWidth),onChange:i=>o(i)})})]})}),xk=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,o)=>({elements:ht(e,t,n=>qe(n,{seed:ek(),roughness:o})),appState:{...t,currentItemRoughness:o},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n,data:r})=>gt("fieldset",{children:[te("legend",{children:g("labels.sloppiness")}),te("div",{className:"buttonList",children:te(Gt,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:Hb},{value:1,text:g("labels.artist"),icon:Gb},{value:2,text:g("labels.cartoonist"),icon:Ub}],value:st(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:t.currentItemRoughness),onChange:i=>o(i)})})]})}),iq=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,o)=>({elements:ht(e,t,n=>qe(n,{strokeStyle:o})),appState:{...t,currentItemStrokeStyle:o},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n,data:r})=>gt("fieldset",{children:[te("legend",{children:g("labels.strokeStyle")}),te("div",{className:"buttonList",children:te(Gt,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:up},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:Fb},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:zb}],value:st(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:t.currentItemStrokeStyle),onChange:i=>o(i)})})]})}),Ek=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,o)=>({elements:ht(e,t,n=>qe(n,{opacity:o}),!0),appState:{...t,currentItemOpacity:o},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({app:e,updateData:t})=>te(Hx,{updateData:t,app:e,testId:"opacity"})}),yk=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,o,n)=>tu(e,t,n,()=>o,o),PanelComponent:({elements:e,appState:t,updateData:o,app:n,data:r})=>gt("fieldset",{children:[te("legend",{children:g("labels.fontSize")}),te("div",{className:"buttonList",children:te(Gt,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:n0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:r0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:i0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:a0,testId:"fontSize-veryLarge"}],value:st(e,n,i=>{if(Tt(i))return i.fontSize;let a=Tn(i,n.scene.getNonDeletedElementsMap());return a?a.fontSize:null},i=>Tt(i)||Tn(i,n.scene.getNonDeletedElementsMap())!==null,i=>i?null:t.currentItemFontSize||J4),onChange:i=>{za(()=>o(i),t.stylesPanelMode==="compact"||t.stylesPanelMode==="mobile",!!t.editingTextElement,r?.onPreventClose)}})})]})}),ou=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:nr,trackEvent:!1,perform:(e,t,o,n)=>tu(e,t,n,r=>Math.round(1/(1+Kx)*r.fontSize)),keyTest:e=>e[pi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===pi.CHEVRON_LEFT||e.key===pi.COMMA)}),nu=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:nr,trackEvent:!1,perform:(e,t,o,n)=>tu(e,t,n,r=>Math.round(r.fontSize*(1+Kx))),keyTest:e=>e[pi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===pi.CHEVRON_RIGHT||e.key===pi.PERIOD)}),wk=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,o,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=o;if(i)return{elements:ht(e,t,b=>{let x=r?.get(b.id);return x?qe(b,{...x}):b},!0),appState:{...t,...l},captureUpdate:Je.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:d}=o,m=Je.EVENTUALLY,c,p=!1;if(s)c=s,m=Je.IMMEDIATELY;else if(d){c=d,m=Je.EVENTUALLY;let f=Q(e,t,{includeBoundTextElement:!0}).filter(b=>Tt(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:{...t,...l},captureUpdate:m};if(c&&!p){let f=new Map,b=new Set,x=!1,w=Array.from(dn.loadedFontsCache.values()),E=Object.entries(Q4).find(([I,S])=>S===c)?.[0];d&&E&&w.some(I=>I.startsWith(E))&&(x=!0),Object.assign(u,{elements:ht(e,t,I=>{if(Tt(I)&&(I.fontFamily!==c||s)){let S=qe(I,{fontFamily:c,lineHeight:nk(c)}),L=r?.get(I.containerId||"")||{},k=n.scene.getContainerElement(I);return a&&k&&L&&n.scene.mutateElement(k,{...L}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,k),S}return I},!0)});let y=`10px ${tk({fontFamily:c})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[I,S]of f)$a(I,S,n.scene);else window.document.fonts.load(y,v).then(I=>{for(let[S,L]of f){let k=n.scene.getElement(S.id),R=L?n.scene.getElement(L.id):null;k&&$a(k,R,n.scene)}n.fonts.onLoaded(I)})}return u},PanelComponent:({elements:e,appState:t,app:o,updateData:n})=>{let r=jp(new Map),i=jp(null),[a,l]=X4({}),s=jp(!0),d=V4(()=>{let m=(c,p)=>st(c,o,u=>{if(Tt(u))return u.fontFamily;let f=Tn(u,p);return f?f.fontFamily:null},u=>Tt(u)||Tn(u,p)!==null,u=>u?null:t.currentItemFontFamily||q4);return a.openPopup==="fontFamily"&&t.openPopup==="fontFamily"?m(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&t.openPopup!=="fontFamily"?m(e,o.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,t,e,o]);return $p(()=>{i.current=d},[d]),$p(()=>{Object.keys(a).length&&(n(a),l({}))},[a]),$p(()=>(s.current=!1,()=>{s.current=!0}),[]),gt(ru,{children:[t.stylesPanelMode==="full"&&te("legend",{children:g("labels.fontFamily")}),te(Nx,{isOpened:t.openPopup==="fontFamily",selectedFontFamily:d,hoveredFontFamily:t.currentHoveredFontFamily,compactMode:t.stylesPanelMode!=="full",onSelect:m=>{za(()=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),r.current.clear()},t.stylesPanelMode==="compact"||t.stylesPanelMode==="mobile",!!t.editingTextElement)},onHover:m=>{l({currentHoveredFontFamily:m,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:m=>{if(m){r.current.clear();let{editingTextElement:c}=t;if(c?.type==="text"){let p=o.scene.getElement(c.id);r.current.set(c.id,qe(p||c,{},!0))}else{let p=Q(e,t,{includeBoundTextElement:!0});for(let u of p)r.current.set(u.id,qe(u,{},!0))}l({...a,openPopup:"fontFamily"})}else{let c={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};l({...c}),r.current.clear(),(t.stylesPanelMode==="compact"||t.stylesPanelMode==="mobile")&&t.editingTextElement&&Fa(null)}}})]})}}),vk=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,o,n)=>({elements:ht(e,t,r=>{if(Tt(r)){let i=qe(r,{textAlign:o});return $a(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...t,currentItemTextAlign:o},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap();return gt("fieldset",{children:[te("legend",{children:g("labels.textAlign")}),te("div",{className:"buttonList",children:te(Gt,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:s0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:c0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:d0,testId:"align-right"}],value:st(e,n,a=>{if(Tt(a))return a.textAlign;let l=Tn(a,i);return l?l.textAlign:null},a=>Tt(a)||Tn(a,i)!==null,a=>a?null:t.currentItemTextAlign),onChange:a=>{za(()=>o(a),t.stylesPanelMode==="compact"||t.stylesPanelMode==="mobile",!!t.editingTextElement,r?.onPreventClose)}})})]})}}),Tk=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:ht(e,t,r=>{if(Tt(r)){let i=qe(r,{verticalAlign:o});return $a(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n,data:r})=>te("fieldset",{children:te("div",{className:"buttonList",children:te(Gt,{group:"text-align",options:[{value:lc.TOP,text:g("labels.alignTop"),icon:te(m0,{theme:t.theme}),testId:"align-top"},{value:lc.MIDDLE,text:g("labels.centerVertically"),icon:te(u0,{theme:t.theme}),testId:"align-middle"},{value:lc.BOTTOM,text:g("labels.alignBottom"),icon:te(p0,{theme:t.theme}),testId:"align-bottom"}],value:st(e,n,i=>{if(Tt(i)&&i.containerId)return i.verticalAlign;let a=Tn(i,n.scene.getNonDeletedElementsMap());return a?a.verticalAlign:null},i=>Tt(i)||Tn(i,n.scene.getNonDeletedElementsMap())!==null,i=>i?null:lc.MIDDLE),onChange:i=>{za(()=>o(i),t.stylesPanelMode==="compact"||t.stylesPanelMode==="mobile",!!t.editingTextElement,r?.onPreventClose)}})})})}),aq=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,o)=>({elements:ht(e,t,n=>Xx(n)?n:qe(n,{roundness:o==="round"?{type:ck(n.type)?sc.ADAPTIVE_RADIUS:sc.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:o},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n,renderAction:r})=>{let a=Lr(Vx(e),t).some(l=>l.roundness?.type===sc.LEGACY);return gt("fieldset",{children:[te("legend",{children:g("labels.edges")}),gt("div",{className:"buttonList",children:[te(Gt,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:Yb},{value:"round",text:g("labels.round"),icon:Wb}],value:st(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!cc(l)&&l.hasOwnProperty("roundness"),l=>l?null:t.currentItemRoundness),onChange:l=>o(l)}),r("togglePolygon")]})]})}}),Wx=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:Vb},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:te(Xb,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:te(jb,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:te(qb,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:te(Kb,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:te(Zb,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:te(Jb,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:te(Qb,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:te($b,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:te(t0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:te(e0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:te(o0,{flip:e}),keyBinding:"v"}],lq=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,o)=>({elements:ht(e,t,n=>{if(Qp(n)){let{position:r,type:i}=o;if(r==="start")return qe(n,{startArrowhead:i});if(r==="end")return qe(n,{endArrowhead:i})}return n}),appState:{...t,[o.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:o.type},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>{let r=zo().rtl;return gt("fieldset",{children:[te("legend",{children:g("labels.arrowheads")}),gt("div",{className:"iconSelectList buttonList",children:[te(Kp,{label:"arrowhead_start",options:Wx(!r),value:st(e,n,i=>Qp(i)&&Ar(i.type)?i.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:i=>o({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),te(Kp,{label:"arrowhead_end",group:"arrowheads",options:Wx(!!r),value:st(e,n,i=>Qp(i)&&Ar(i.type)?i.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:i=>o({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),Ik=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,t,o,n)=>!1,PanelComponent:({elements:e,appState:t,updateData:o,app:n,renderAction:r})=>gt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),sq=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,t,o,n)=>{let r=ht(e,t,l=>{if(!cc(l))return l;let s=qe(l,{roundness:o===Uo.round?{type:sc.PROPORTIONAL_RADIUS}:null,elbowed:o===Uo.elbow,points:o===Uo.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(Xx(s)){s.fixedSegments=null;let d=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let m=Jp.getPointAtIndexGlobalCoordinates(s,0,d),c=Jp.getPointAtIndexGlobalCoordinates(s,-1,d),p=s.startBinding&&d.get(s.startBinding.elementId),u=s.endBinding&&d.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...Ux(s,p,"start",d)}:null,b=u&&s.endBinding?{...s.endBinding,...Ux(s,u,"end",d)}:null;s={...s,startBinding:f,endBinding:b,...mk(s,d,{points:[m,c].map(x=>W4(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let d=n.scene.getNonDeletedElementsMap();if(s.startBinding){let m=d.get(s.startBinding.elementId);m&&Gx(s,m,"start",n.scene)}if(s.endBinding){let m=d.get(s.endBinding.elementId);m&&Gx(s,m,"end",n.scene)}}return s}),i={...t,currentItemArrowType:o},a=t.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new Jp(l,eu(e)))}return{elements:r,appState:i,captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>gt("fieldset",{children:[te("legend",{children:g("labels.arrowtypes")}),te("div",{className:"buttonList",children:te(Gt,{group:"arrowtypes",options:[{value:Uo.sharp,text:g("labels.arrowtype_sharp"),icon:qr,testId:"sharp-arrow"},{value:Uo.round,text:g("labels.arrowtype_round"),icon:Qr,testId:"round-arrow"},{value:Uo.elbow,text:g("labels.arrowtype_elbowed"),icon:Jr,testId:"elbow-arrow"}],value:st(e,n,r=>cc(r)?r.elbowed?Uo.elbow:r.roundness?Uo.round:Uo.sharp:null,r=>cc(r),r=>r?null:t.currentItemArrowType),onChange:r=>o(r)})})]})});import{clamp as cu,roundToStep as Ak}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as Dk,CURSOR_TYPE as Jx,MAX_ZOOM as Qx,MIN_ZOOM as eE,THEME as ja,ZOOM_STEP as du,getShortcutKey as tE,updateActiveTool as hi,CODES as Co,KEYS as Wo}from"@excalidraw/common";import{getNonDeletedElements as _k}from"@excalidraw/element";import{newElementWith as Rk}from"@excalidraw/element";import{getCommonBounds as Nk}from"@excalidraw/element";import{CaptureUpdateAction as ao}from"@excalidraw/element";import{useEffect as Ck}from"react";import{jsx as kk}from"react/jsx-runtime";var ui=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},iu=(e,t,o="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=t.left+t.width/2-n.width/2;l<0?l=a:l+n.width>=r&&(l=r-n.width-a);let s;o==="bottom"?(s=t.top+t.height+a,s+n.height>=i&&(s=t.top-n.height-a)):(s=t.top-n.height-a,s<0&&(s=t.top+t.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},Sk=(e,t,o,n)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=n?"50ch":"10ch",t.style.maxWidth=n?"50ch":"15ch",t.textContent=o;let r=e.getBoundingClientRect();iu(t,r)},_t=({children:e,label:t,long:o=!1,style:n,disabled:r})=>(Ck(()=>()=>ui().classList.remove("excalidraw-tooltip--visible"),[]),r?null:kk("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>Sk(i.currentTarget,ui(),t,o),onPointerLeave:()=>ui().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import dc from"open-color";import{CURSOR_TYPE as au,MIME_TYPES as lu,THEME as $x}from"@excalidraw/common";var jx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',Mk='<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"/>',qx='<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"/>',Pk=`data:${lu.svg},${encodeURIComponent(`${jx}${qx}</svg>`)}`,Lk=`data:${lu.svg},${encodeURIComponent(`${jx}${Mk}${qx}</svg>`)}`,Wt=e=>{e&&(e.style.cursor="")},ye=(e,t)=>{e&&(e.style.cursor=t)},Io,Zx,su=(e,t)=>{let n=()=>{let r=t===$x.DARK;Io=document.createElement("canvas"),Io.theme=t,Io.height=20,Io.width=20;let i=Io.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Io.width/2,Io.height/2,5,0,2*Math.PI),i.fillStyle=r?dc.black:dc.white,i.fill(),i.strokeStyle=r?dc.white:dc.black,i.stroke(),Zx=Io.toDataURL(lu.svg)};(!Io||Io.theme!==t)&&n(),ye(e,`url(${Zx}) ${20/2} ${20/2}, auto`)},Rt=(e,t)=>{if(e)if(t.activeTool.type==="selection")Wt(e);else if(no(t))e.style.cursor=au.GRAB;else if(vt(t))su(e,t.theme);else if(t.activeTool.type==="laser"){let o=t.theme===$x.LIGHT?Pk:Lk;e.style.cursor=`url(${o}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=au.AUTO):e.style.cursor=au.CROSSHAIR};var Yo=({viewportX:e,viewportY:t,nextZoom:o},n)=>{let r=e-n.offsetLeft,i=t-n.offsetTop,a=n.zoom.value,l=n.scrollX+(r-r/a),s=n.scrollY+(i-i/a),d=-(r-r/o),m=-(i-i/o);return{scrollX:l+d,scrollY:s+m,zoom:{value:o}}};import{jsx as hc,jsxs as zk}from"react/jsx-runtime";var Bk=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,o)=>({appState:{...t,...o},captureUpdate:o.viewBackgroundColor?ao.IMMEDIATELY:ao.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,appProps:n,data:r})=>hc(Ya,{palette:null,topPicks:Dk,label:g("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:i=>o({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:o,compactMode:t.stylesPanelMode==="compact"})}),Vo=O({name:"clearCanvas",label:"labels.clearCanvas",icon:At,trackEvent:{category:"canvas"},predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector",perform:(e,t,o,n)=>(n.imageCache.clear(),{elements:e.map(r=>Rk(r,{isDeleted:!0})),appState:{...mn(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,gridStep:t.gridStep,gridModeEnabled:t.gridModeEnabled,stats:t.stats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:n.state.preferredSelectionTool.type}:t.activeTool},captureUpdate:ao.IMMEDIATELY})}),mc=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:jm,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>({appState:{...t,...Yo({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:bo(t.zoom.value+du)},t),userToFollow:null},captureUpdate:ao.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>hc(V,{type:"button",className:"zoom-in-button zoom-button",icon:jm,title:`${g("buttons.zoomIn")} \u2014 ${tE("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:t.zoom.value>=Qx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Co.EQUAL||e.code===Co.NUM_ADD)&&(e[Wo.CTRL_OR_CMD]||e.shiftKey)}),pc=O({name:"zoomOut",label:"buttons.zoomOut",icon:qm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>({appState:{...t,...Yo({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:bo(t.zoom.value-du)},t),userToFollow:null},captureUpdate:ao.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>hc(V,{type:"button",className:"zoom-out-button zoom-button",icon:qm,title:`${g("buttons.zoomOut")} \u2014 ${tE("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:t.zoom.value<=eE,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Co.MINUS||e.code===Co.NUM_SUBTRACT)&&(e[Wo.CTRL_OR_CMD]||e.shiftKey)}),uc=O({name:"resetZoom",label:"buttons.resetZoom",icon:gb,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>({appState:{...t,...Yo({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:bo(1)},t),userToFollow:null},captureUpdate:ao.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>hc(_t,{label:g("buttons.resetZoom"),style:{height:"100%"},children:zk(V,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===Co.ZERO||e.code===Co.NUM_ZERO)&&(e[Wo.CTRL_OR_CMD]||e.shiftKey)}),Ok=(e,t,o=1)=>{let[n,r,i,a]=e,l=i-n,s=t.width/l,d=a-r,m=t.height/d,p=Math.min(s,m)*cu(o,.1,1);return Math.min(p,1)},oE=({bounds:e,appState:t,canvasOffsets:o,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=cu(r,eE,Qx);let[l,s,d,m]=e,c=(l+d)/2,p=(s+m)/2,u=o?.left??0,f=o?.top??0,b=o?.right??0,x=o?.bottom??0,w=t.width-u-b,E=t.height-f-x,y;if(n){let S=d-l,L=m-s;y=Math.min(w/S,E/L)*r}else y=Ok(e,{width:w,height:E},r);let v=bo(cu(Ak(y,du,"floor"),i,a)),I=P1({scenePoint:{x:c,y:p},viewportDimensions:{width:t.width,height:t.height},offsets:o,zoom:{value:v}});return{appState:{...t,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:v}},captureUpdate:ao.EVENTUALLY}},qa=({canvasOffsets:e,targetElements:t,appState:o,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=Nk(_k(t));return oE({canvasOffsets:e,bounds:l,appState:o,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},Wq=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Rs,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return qa({targetElements:r.length?r:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===Co.TWO&&e.shiftKey&&!e.altKey&&!e[Wo.CTRL_OR_CMD]}),Vq=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Rs,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return qa({targetElements:r.length?r:e,appState:{...t,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===Co.THREE&&e.shiftKey&&!e.altKey&&!e[Wo.CTRL_OR_CMD]}),Fk=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Rs,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>qa({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===Co.ONE&&e.shiftKey&&!e.altKey&&!e[Wo.CTRL_OR_CMD]}),sr=O({name:"toggleTheme",label:(e,t)=>t.theme===ja.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ja.LIGHT?Pa:La,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o)=>({appState:{...t,theme:o||(t.theme===ja.LIGHT?ja.DARK:ja.LIGHT)},captureUpdate:ao.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===Co.D,predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),Xq=O({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t,o,n)=>{let r;return vt(t)?r=hi(t,{...t.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):r=hi(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:ao.IMMEDIATELY}},keyTest:e=>e.key===Wo.E}),Kq=O({name:"toggleLassoTool",label:"toolBar.lasso",icon:un,trackEvent:{category:"toolbar"},predicate:(e,t,o,n)=>n.state.preferredSelectionTool.type!=="lasso",perform:(e,t,o,n)=>{let r;return t.activeTool.type!=="lasso"?(r=hi(t,{type:"lasso",fromSelection:!1}),ye(n.interactiveCanvas,Jx.CROSSHAIR)):r=hi(t,{type:"selection"}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:ao.NEVER}}}),nE=O({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:_s,viewMode:!1,perform:(e,t,o,n)=>{let r;return no(t)?r=hi(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=hi(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),ye(n.interactiveCanvas,Jx.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:ao.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Wo.CTRL_OR_CMD]&&e.key===Wo.H});import{updateActiveTool as rE}from"@excalidraw/common";import{CaptureUpdateAction as Hk}from"@excalidraw/element";var Gk=O({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,t,o,n)=>{let r=rE(t,{type:"embeddable"});return Rt(n.canvas,{...t,activeTool:r}),{elements:e,appState:{...t,activeTool:rE(t,{type:"embeddable"})},captureUpdate:Hk.EVENTUALLY}}});import{pointFrom as Uk}from"@excalidraw/math";import{maybeBindLinearElement as Yk,bindOrUnbindLinearElement as iE,isBindingEnabled as Wk}from"@excalidraw/element/binding";import{isValidPolygon as aE,LinearElementEditor as Ja,newElementWith as mu}from"@excalidraw/element";import{isBindingElement as gc,isFreeDrawElement as lE,isLinearElement as sE,isLineElement as fc}from"@excalidraw/element";import{KEYS as pu,arrayToMap as uu,tupleToCoors as Vk,updateActiveTool as cE}from"@excalidraw/common";import{isPathALoop as Xk}from"@excalidraw/element";import{isInvisiblySmallElement as hu}from"@excalidraw/element";import{CaptureUpdateAction as gu}from"@excalidraw/element";import{jsx as Kk}from"react/jsx-runtime";var Nt=O({name:"finalize",label:"",trackEvent:!1,perform:(e,t,o,n)=>{let{interactiveCanvas:r,focusContainer:i,scene:a}=n,{event:l,sceneCoords:s}=o??{},d=a.getNonDeletedElementsMap();if(l&&t.selectedLinearElement){let u=Ja.handlePointerUp(l,t.selectedLinearElement,t,n.scene),{startBindingElement:f,endBindingElement:b}=u,x=n.scene.getElement(u.elementId);if(gc(x)&&iE(x,f,b,n.scene),u!==t.selectedLinearElement){let w=e;return x&&hu(x)&&(w=w.map(E=>E.id===x.id?mu(E,{isDeleted:!0}):E)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:gu.IMMEDIATELY}}}if(t.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=t.selectedLinearElement,x=Ja.getElement(u,d);if(x)return gc(x)&&iE(x,f,b,a),fc(x)&&!aE(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||hu(x)?e.map(w=>w.id===x.id?mu(w,{isDeleted:!0}):w):void 0,appState:{...t,cursorButton:"up",selectedLinearElement:new Ja(x,uu(d),!1)},captureUpdate:gu.IMMEDIATELY}}let m=e;window.document.activeElement instanceof HTMLElement&&i();let c=null;if(t.multiElement)c=t.multiElement;else if(t.newElement?.type==="freedraw"||gc(t.newElement))c=t.newElement;else if(Object.keys(t.selectedElementIds).length===1){let u=d.get(Object.keys(t.selectedElementIds)[0]);u&&(c=u)}if(c){if(t.multiElement&&c.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=c;(!f||u[u.length-1]!==f)&&a.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&hu(c)&&(m=m.map(u=>u.id===c?.id?mu(u,{isDeleted:!0}):u)),sE(c)||lE(c)){let u=Xk(c.points,t.zoom.value);if(u&&(fc(c)||lE(c))){let f=c.points,b=f[0],x=f.map((w,E)=>E===f.length-1?Uk(b[0],b[1]):w);fc(c)?a.mutateElement(c,{points:x,polygon:!0}):a.mutateElement(c,{points:x})}if(fc(c)&&!aE(c.points)&&a.mutateElement(c,{polygon:!1}),gc(c)&&!u&&c.points.length>1&&Wk(t)){let f=s??Vk(Ja.getPointAtIndexGlobalCoordinates(c,-1,uu(e)));Yk(c,t,f,a)}}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!c)&&Wt(r);let p;return t.activeTool.type==="eraser"?p=cE(t,{...t.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):p=cE(t,{type:n.state.preferredSelectionTool.type}),{elements:m,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&c?t.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:c&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[c.id]:!0}:t.selectedElementIds,selectedLinearElement:c&&sE(c)?new Ja(c,uu(m)):t.selectedLinearElement},captureUpdate:gu.IMMEDIATELY}},keyTest:(e,t)=>e.key===pu.ESCAPE&&(t.selectedLinearElement?.isEditing||!t.newElement&&t.multiElement===null)||(e.key===pu.ESCAPE||e.key===pu.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:o})=>Kk(V,{type:"button",icon:Cb,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:t,visible:e.multiElement!=null,size:o?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as bi,DEFAULT_EXPORT_PADDING as OM,EXPORT_SCALES as FM,THEME as xu}from"@excalidraw/common";import{getNonDeletedElements as zM}from"@excalidraw/element";import{CaptureUpdateAction as mo}from"@excalidraw/element";import Zk from"clsx";import{jsx as dE,jsxs as $k}from"react/jsx-runtime";var Qa=({children:e,checked:t,onChange:o,className:n})=>$k("div",{className:Zk("Checkbox",n,{"is-checked":t}),onClick:r=>{o(!t,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[dE("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":t,children:Eb}),dE("div",{className:"Checkbox-label",children:e})]});import{THEME as el}from"@excalidraw/common";import{jsx as tl}from"react/jsx-runtime";var pE=e=>{let t=e.title||(e.value===el.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return tl(V,{type:"icon",icon:e.value===el.LIGHT?mE.MOON:mE.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===el.DARK?el.LIGHT:el.DARK),"data-testid":"toggle-dark-mode"})},mE={SUN:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("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:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("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 jk}from"react";import{focusNearestParent as qk,KEYS as Jk}from"@excalidraw/common";import{jsx as uE,jsxs as Qk}from"react/jsx-runtime";var hE=e=>{let{id:t}=Be(),[o,n]=jk(e.value),r=a=>{e.ignoreFocus||qk(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===Jk.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return Qk("div",{className:"ProjectName",children:[uE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),uE("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${t}-filename`,value:o,onChange:a=>n(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as MM,DEFAULT_FILENAME as PM,IMAGE_MIME_TYPES as LE,isFirefox as LM,MIME_TYPES as AM,cloneJSON as DM,SVG_DOCUMENT_PREAMBLE as _M}from"@excalidraw/common";import{getNonDeletedElements as RM}from"@excalidraw/element";import{isFrameLikeElement as NM}from"@excalidraw/element";import{getElementsOverlappingFrame as BM}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as dM,EXPORT_DATA_TYPES as rl,MIME_TYPES as so,arrayToMap as mM,isMemberOf as pM,isPromiseLike as uM,EVENT as Ec}from"@excalidraw/common";import{mutateElement as hM}from"@excalidraw/element";import{deepCopyElement as gM}from"@excalidraw/element";import{isFrameLikeElement as fM,isInitializedImageElement as bM}from"@excalidraw/element";import{getContainingFrame as CE}from"@excalidraw/element";import{pointFrom as In}from"@excalidraw/math";import{COLOR_PALETTE as fE,DEFAULT_CHART_COLOR_INDEX as eM,getAllColorsSpecificShade as tM,DEFAULT_FONT_FAMILY as oM,DEFAULT_FONT_SIZE as bE,VERTICAL_ALIGN as nM,randomId as xE,isDevEnv as EE}from"@excalidraw/common";import{newTextElement as bc,newLinearElement as nl,newElement as bu}from"@excalidraw/element";var lo=32,Ie=12,Cn=256,yE=50,cr="NOT_SPREADSHEET",gi="VALID_SPREADSHEET",ol=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},fu=(e,t)=>e.slice(1).every(o=>ol(o[t])!==null),gE=e=>{let t=e[0].length;if(t>2)return{type:cr,reason:"More than 2 columns"};if(t===1){if(!fu(e,0))return{type:cr,reason:"Value is not numeric"};let s=ol(e[0][0])===null,d=(s?e.slice(1):e).map(m=>ol(m[0]));return d.length<2?{type:cr,reason:"Less than two rows"}:{type:gi,spreadsheet:{title:s?e[0][0]:null,labels:null,values:d}}}let o=fu(e,0),n=fu(e,1);if(!o&&!n)return{type:cr,reason:"Value is not numeric"};let[r,i]=n?[0,1]:[1,0],a=ol(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:cr,reason:"Less than 2 rows"}:{type:gi,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[r]),values:l.map(s=>ol(s[i]))}}},rM=e=>{let t=[];for(let o=0;o<e[0].length;o++){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][o]);t.push(n)}return t},wE=e=>{let t=e.trim().split(`
|
|
3
|
+
`).map(i=>i.trim().split(" "));if(t.length&&t[0].length!==2&&(t=e.trim().split(`
|
|
4
|
+
`).map(i=>i.trim().split(","))),t.length===0)return{type:cr,reason:"No values"};let o=t[0].length;if(!t.every(i=>i.length===o))return{type:cr,reason:"All rows don't have same number of columns"};let r=gE(t);if(r.type!==gi){let i=gE(rM(t));if(i.type===gi)return i}return r},xc=tM(eM),Vt={fillStyle:"hachure",fontFamily:oM,fontSize:bE,opacity:100,roughness:1,strokeColor:fE.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:nM.MIDDLE,locked:!1},vE=e=>{let t=(lo+Ie)*e.values.length+Ie,o=Cn+Ie*2;return{chartWidth:t,chartHeight:o}},iM=(e,t,o,n,r)=>e.labels?.map((i,a)=>bc({groupIds:[n],backgroundColor:r,...Vt,text:i.length>8?`${i.slice(0,5)}...`:i,x:t+a*(lo+Ie)+Ie*2,y:o+Ie/2,width:lo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],aM=(e,t,o,n,r)=>{let i=bc({groupIds:[n],backgroundColor:r,...Vt,x:t-Ie,y:o-Ie,text:"0",textAlign:"right"}),a=bc({groupIds:[n],backgroundColor:r,...Vt,x:t-Ie,y:o-Cn-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},lM=(e,t,o,n,r)=>{let{chartWidth:i,chartHeight:a}=vE(e),l=nl({backgroundColor:r,groupIds:[n],...Vt,type:"line",x:t,y:o,width:i,points:[In(0,0),In(i,0)]}),s=nl({backgroundColor:r,groupIds:[n],...Vt,type:"line",x:t,y:o,height:a,points:[In(0,0),In(0,-a)]}),d=nl({backgroundColor:r,groupIds:[n],...Vt,type:"line",x:t,y:o-Cn-Ie,strokeStyle:"dotted",width:i,opacity:yE,points:[In(0,0),In(i,0)]});return[l,s,d]},TE=(e,t,o,n,r,i)=>{let{chartWidth:a,chartHeight:l}=vE(e),s=e.title?bc({backgroundColor:r,groupIds:[n],...Vt,text:e.title,x:t+a/2,y:o-Cn-Ie*2-bE,roundness:null,textAlign:"center"}):null,d=i?bu({backgroundColor:r,groupIds:[n],...Vt,type:"rectangle",x:t,y:o-l,width:a,height:l,strokeColor:fE.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...s?[s]:[],...iM(e,t,o,n,r),...aM(e,t,o,n,r),...lM(e,t,o,n,r)]},sM=(e,t,o)=>{let n=Math.max(...e.values),r=xE(),i=xc[Math.floor(Math.random()*xc.length)];return[...e.values.map((l,s)=>{let d=l/n*Cn;return bu({backgroundColor:i,groupIds:[r],...Vt,type:"rectangle",x:t+s*(lo+Ie)+Ie,y:o-d-Ie,width:lo,height:d})}),...TE(e,t,o,r,i,EE())]},cM=(e,t,o)=>{let n=Math.max(...e.values),r=xE(),i=xc[Math.floor(Math.random()*xc.length)],a=0,l=[];for(let b of e.values){let x=a*(lo+Ie),w=-(b/n)*Cn;l.push([x,w]),a++}let s=Math.max(...l.map(b=>b[0])),d=Math.max(...l.map(b=>b[1])),m=Math.min(...l.map(b=>b[0])),c=Math.min(...l.map(b=>b[1])),p=nl({backgroundColor:i,groupIds:[r],...Vt,type:"line",x:t+Ie+lo/2,y:o-Ie,height:d-c,width:s-m,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let w=x*(lo+Ie)+Ie/2,E=-(b/n)*Cn+Ie/2;return bu({backgroundColor:i,groupIds:[r],...Vt,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:t+w+lo/2,y:o+E-Ie*2,width:Ie,height:Ie})}),f=e.values.map((b,x)=>{let w=x*(lo+Ie)+Ie/2,E=b/n*Cn+Ie/2+Ie;return nl({backgroundColor:i,groupIds:[r],...Vt,type:"line",x:t+w+lo/2+Ie/2,y:o-E,height:E,strokeStyle:"dotted",opacity:yE,points:[In(0,0),In(0,E)]})});return[...TE(e,t,o,r,i,EE()),p,...f,...u]},IE=(e,t,o,n)=>e==="line"?cM(t,o,n):sM(t,o,n);var aQ="clipboard"in navigator&&"readText"in navigator.clipboard,yc="clipboard"in navigator&&"writeText"in navigator.clipboard,fi="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,xM=e=>!!([rl.excalidraw,rl.excalidrawClipboard,rl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),SE=({types:e,files:t})=>{!e&&!t&&console.warn("createPasteEvent: no types or files provided");let o=new ClipboardEvent(Ec.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){t=t||[],t.push(r),o.clipboardData?.items.add(r);continue}try{if(o.clipboardData?.items.add(r,n),o.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(t){let n=-1;for(let r of t){n++;try{if(o.clipboardData?.items.add(r),o.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return o},EM=({elements:e,files:t})=>{let o=mM(e),n=new Set(e.filter(l=>fM(l))),r=!1,i=e.reduce((l,s)=>(bM(s)&&(r=!0,t&&t[s.fileId]&&(l[s.fileId]=t[s.fileId])),l),{});r&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:rl.excalidrawClipboard,elements:e.map(l=>{if(CE(l,o)&&!n.has(CE(l,o))){let s=gM(l);return hM(s,o,{frameId:null}),s}return l}),files:t?i:void 0};return JSON.stringify(a)},wc=async(e,t,o)=>{await co(EM({elements:e,files:t}),o)},yM=e=>{let t=wE(e);return t.type===gi?{spreadsheet:t.spreadsheet}:null};function kE(e){let t=[];for(let o of e.childNodes)if(o.nodeType===3){let n=o.textContent?.trim();n&&t.push({type:"text",value:n})}else if(o instanceof HTMLImageElement){let n=o.getAttribute("src");n&&n.startsWith("http")&&t.push({type:"imageUrl",value:n})}else t=t.concat(kE(o));return t}var wM=e=>{let t=e.value;try{let o=new DOMParser().parseFromString(t,so.html),n=kE(o.body);if(n.length)return{type:"mixedContent",value:n}}catch(o){console.error(`error in parseHTMLFromPaste: ${o.message}`)}return null},ME=async()=>{let e={},t;try{t=await navigator.clipboard?.read()}catch(o){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);let n=await navigator.clipboard?.readText();if(n)return{[so.text]:n}}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else{if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}}throw o}for(let o of t)for(let n of o.types)if(pM(dM,n))try{if(n===so.text||n===so.html)e[n]=await(await o.getType(n)).text();else if(X1(n)){let r=await o.getType(n),i=Q1(r,n,void 0);e[n]=i}else throw new Hm(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof Hm?r.message:`Cannot retrieve ${n} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},vM=async(e,t=!1)=>{try{let o=e.findByType(so.html),n=!t&&o&&wM(o);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(so.text)??n.value.map(r=>r.value).join(`
|
|
5
|
+
`).trim()}:n:{type:"text",value:(e.getData(so.text)||"").trim()}}catch{return{type:"text",value:""}}},TM=function(e){return this.find(t=>t.type===e)||null},IM=function(e){return this.find(o=>o.type===e)?.value??null},CM=function(){return this.filter(e=>e.kind==="file")},il=async e=>{let t;kM(e)?t=e.clipboardData?.items:t=e.dataTransfer?.items;let o=(await Promise.all(Array.from(t||[]).map(async n=>{if(n.kind==="file"){let r=n.getAsFile();if(r){let i=await J1(n);return r=await Sa(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(n.kind==="string"){let{type:r}=n,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{n.getAsString(l=>a(l))}),{type:r,kind:"string",value:i}}return null}))).filter(n=>n!=null);return Object.assign(o,{findByType:TM,getData:IM,getFiles:CM})},PE=async(e,t=!1)=>{let o=await vM(e,t);if(o.type==="mixedContent")return{mixedContent:o.value};try{let n=!t&&yM(o.value);if(n)return n}catch(n){console.error(n)}try{let n=JSON.parse(o.value),r=n.type===rl.excalidrawClipboardWithAPI;if(xM(n))return{elements:n.elements,files:n.files,text:t?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:o.value}},vc=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[so.png]:e})])}catch(t){if(uM(e))await navigator.clipboard.write([new window.ClipboardItem({[so.png]:await e})]);else throw t}},co=async(e,t)=>{if(yc)try{await navigator.clipboard.writeText(e||"");return}catch(o){console.error(o)}try{if(t){if(t.clipboardData?.setData(so.text,e||""),t.clipboardData?.getData(so.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(o){console.error(o)}if(!SM(e))throw new Error("Error copying to clipboard.")},SM=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",o=document.createElement("textarea");o.style.border="0",o.style.padding="0",o.style.margin="0",o.style.position="absolute",o.style[t?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;o.style.top=`${n}px`,o.style.fontSize="12pt",o.setAttribute("readonly",""),o.value=e,document.body.appendChild(o);let r=!1;try{o.select(),o.setSelectionRange(0,o.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return o.remove(),r},kM=e=>e.type===Ec.PASTE||e.type===Ec.COPY||e.type===Ec.CUT;var dr=(e,{selectedElementIds:t},o)=>{e=RM(e);let n=o&&ve(e,{selectedElementIds:t}),r=null,i=n?Q(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return n&&(i.length===1&&NM(i[0])?(r=i[0],i=BM(e,r)):i.length>1&&(i=Q(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:r,exportedElements:DM(i)}},mr=async(e,t,o,n,{exportBackground:r,exportPadding:i=MM,viewBackgroundColor:a,name:l=o.name||PM,fileHandle:s=null,exportingFrame:d=null})=>{if(t.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let c=Rr(t,{exportBackground:r,exportWithDarkMode:o.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:o.exportScale,exportEmbedScene:o.exportEmbedScene&&e==="svg"},n,{exportingFrame:d});if(e==="svg")return Gm(c.then(p=>new Blob([_M+p.outerHTML],{type:AM.svg})),{description:"Export to SVG",name:l,extension:o.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[LE.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await c.then(u=>u.outerHTML);try{await co(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let m=fs(t,o,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:d});if(e==="png"){let c=Fo(m);return o.exportEmbedScene&&(c=c.then(p=>import("./data/image-NWF7UX55.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:va(t,o,n,"local")})))),Gm(c,{description:"Export to PNG",name:l,extension:o.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[LE.png],fileHandle:s})}else if(e==="clipboard")try{let c=Fo(m);await vc(c)}catch(c){throw console.warn(c),c.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):LM&&c.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
|
|
6
6
|
|
|
7
|
-
${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var SE=async(e,o,t,n)=>{let{exportBackground:r,viewBackgroundColor:i,fileHandle:a}=o,l=R1(a);if(!a||!N1(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:d}=lr(e,o,!1);return await sr(l,s,o,t,{exportBackground:r,viewBackgroundColor:i,name:n,fileHandle:a,exportingFrame:d}),{fileHandle:a}};import{Fragment as xM,jsx as Uo,jsxs as EM}from"react/jsx-runtime";var pu=B({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:so.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>Uo(cE,{label:g("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),kE=B({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:so.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=bM(e),i=we(n,o)?J(n,o):n;return Uo(xM,{children:fM.map(a=>{let[l,s]=D1(i,gM,a),d=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Uo(K,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:d,"aria-label":d,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),uu=B({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:so.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Uo(Oa,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),mc=B({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:so.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>EM(Oa,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Uo(Rt,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Uo("div",{className:"excalidraw-tooltip-icon",children:E0})})]})}),cr=B({name:"saveToActiveFile",label:"buttons.save",icon:Qn,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}=ts(o.fileHandle)?await SE(e,o,n.files,n.getName()):await jl(e,o,n.files,n.getName());return{captureUpdate:so.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:so.EVENTUALLY}}},keyTest:e=>e.key===ci.S&&e[ci.CTRL_OR_CMD]&&!e.shiftKey}),Va=B({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Qn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{try{let{fileHandle:r}=await jl(e,{...o,fileHandle:null},n.files,n.getName());return{captureUpdate:so.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:so.EVENTUALLY}}},keyTest:e=>e.key===ci.S&&e.shiftKey&&e[ci.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Uo(K,{type:"button",icon:h0,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:me().editor.isMobile,hidden:!Pr,onClick:()=>e(null),"data-testid":"save-as-button"})}),di=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 _m(o,e);return{elements:r,appState:i,files:a,captureUpdate:so.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:so.EVENTUALLY}}},keyTest:e=>e[ci.CTRL_OR_CMD]&&e.key===ci.O}),ME=B({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:so.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Uo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Uo(lE,{value:e.exportWithDarkMode?mu.DARK:mu.LIGHT,onChange:t=>{o(t===mu.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as yM,DEFAULT_FONT_FAMILY as wM,DEFAULT_TEXT_ALIGN as vM,CODES as LE,KEYS as PE,getLineHeight as TM}from"@excalidraw/common";import{newElementWith as pc}from"@excalidraw/element";import{hasBoundTextElement as IM,canApplyRoundnessTypeToElement as CM,getDefaultRoundnessTypeForElement as SM,isFrameLikeElement as kM,isArrowElement as MM,isExcalidrawElement as LM,isTextElement as hu}from"@excalidraw/element";import{getBoundTextElement as PM,redrawTextBoundingBox as AM}from"@excalidraw/element";import{CaptureUpdateAction as gu}from"@excalidraw/element";var AE="{}",fu=B({name:"copyStyles",label:"labels.copyStyles",icon:sp,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(a=>o.selectedElementIds[a.id]);if(r.push(i),i&&IM(i)){let a=PM(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(AE=JSON.stringify(r)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:gu.EVENTUALLY}},keyTest:e=>e[PE.CTRL_OR_CMD]&&e.altKey&&e.code===LE.C}),bu=B({name:"pasteStyles",label:"labels.pasteStyles",icon:sp,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(AE),i=r[0],a=r[1];if(!LM(i))return{elements:e,captureUpdate:gu.EVENTUALLY};let l=J(e,o,{includeBoundTextElement:!0}),s=l.map(d=>d.id);return{elements:e.map(d=>{if(s.includes(d.id)){let m=i;if(hu(d)&&d.containerId&&(m=a),!m)return d;let c=pc(d,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?CM(m.roundness.type,d)?m.roundness:SM(d):null});if(hu(c)){let p=m.fontSize||yM,u=m.fontFamily||wM;c=pc(c,{fontSize:p,fontFamily:u,textAlign:m.textAlign||vM,lineHeight:m.lineHeight||TM(u)});let f=null;c.containerId&&(f=l.find(b=>hu(c)&&b.id===c.containerId)||null),AM(c,f,n.scene)}return c.type==="arrow"&&MM(m)&&(c=pc(c,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),kM(d)&&(c=pc(c,{roundness:null,backgroundColor:"transparent"})),c}return d}),captureUpdate:gu.IMMEDIATELY}},keyTest:e=>e[PE.CTRL_OR_CMD]&&e.altKey&&e.code===LE.V});import{KEYS as DM}from"@excalidraw/common";import{getNonDeletedElements as _M}from"@excalidraw/element";import{showSelectedShapeActions as RM}from"@excalidraw/element";import{CaptureUpdateAction as xu}from"@excalidraw/element";import{jsx as DE}from"react/jsx-runtime";var NM=B({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:xu.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>DE(K,{type:"button",icon:ps,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),BM=B({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:xu.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>DE(K,{visible:RM(o,_M(e)),type:"button",icon:g0,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),dr=B({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:c0,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:xu.EVENTUALLY}),keyTest:e=>e.key===DM.QUESTION_MARK});import{getNonDeletedElements as hc}from"@excalidraw/element";import{newElementWith as NE}from"@excalidraw/element";import{isBoundToContainer as FM}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as OM,getElementsInResizingFrame as zM,getFrameLikeElements as HM,getRootElements as GM,groupByFrameLikes as UM,removeElementsFromFrame as YM,replaceAllElementsInFrame as WM}from"@excalidraw/element";import{KEYS as gc,randomId as VM,arrayToMap as Eu,getShortcutKey as BE}from"@excalidraw/common";import{getSelectedGroupIds as uc,selectGroup as XM,selectGroupsForSelectedElements as KM,getElementsInGroup as _E,addToGroup as ZM,removeFromSelectedGroups as $M,isElementInGroup as FE}from"@excalidraw/element";import{syncMovedIndices as jM}from"@excalidraw/element";import{CaptureUpdateAction as Xa}from"@excalidraw/element";import{jsx as mi}from"react/jsx-runtime";var qM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&FE(r,t),!0))return!0}return!1},RE=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!qM(n)&&!OM(n)},yu=B({name:"group",label:"labels.group",icon:e=>mi(rp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=GM(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:Xa.EVENTUALLY};let i=uc(o);if(i.length===1){let x=i[0],y=new Set(_E(e,x).map(v=>v.id)),E=new Set(r.map(v=>v.id));if(new Set([...Array.from(y),...Array.from(E)]).size===y.size)return{appState:o,elements:e,captureUpdate:Xa.EVENTUALLY}}let a=[...e];new Set(r.map(x=>x.frameId)).size>1&&UM(r).forEach((y,E)=>{YM(y,n.scene.getNonDeletedElementsMap())});let s=VM(),d=Eu(r);a=a.map(x=>d.get(x.id)?NE(x,{groupIds:ZM(x.groupIds,s,o.editingGroupId)}):x);let m=_E(a,s),c=m[m.length-1],p=a.lastIndexOf(c),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!FE(x,s)),b=jM([...f,...m,...u],Eu(m));return{appState:{...o,...XM(s,{...o,selectedGroupIds:{}},hc(a))},elements:b,captureUpdate:Xa.IMMEDIATELY}},predicate:(e,o,t,n)=>RE(e,o,n),keyTest:e=>!e.shiftKey&&e[gc.CTRL_OR_CMD]&&e.key===gc.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>mi(K,{hidden:!RE(e,o,n),type:"button",icon:mi(rp,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${BE("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:we(hc(e),o)})}),wu=B({name:"ungroup",label:"labels.ungroup",icon:e=>mi(ip,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=uc(o),i=Eu(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:Xa.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{FM(p)&&l.push(p.id);let u=$M(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:NE(p,{groupIds:u})});let s=KM(o,hc(a),o,null),d=n.scene.getSelectedElements(o),m=new Set(d.filter(p=>p.frameId).map(p=>p.frameId));return HM(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=WM(a,zM(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:Xa.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[gc.CTRL_OR_CMD]&&e.key===gc.G.toUpperCase(),predicate:(e,o)=>uc(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>mi(K,{type:"button",hidden:uc(o).length===0,icon:mi(ip,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${BE("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:we(hc(e),o)})});import rL from"clsx";import{CaptureUpdateAction as UE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as JM,COLOR_VOICE_CALL as QM,COLOR_WHITE as bc,THEME as eL,UserIdleState as OE}from"@excalidraw/common";var fc=(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 tL(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 mr=(e,o)=>`hsl(${Math.abs(tL(o?.id||e))%37*10}, 100%, 83%)`,zE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},HE=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,d=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,c=14,p=l<0||l>n-m||s<0||s>r-c;l=Math.max(l,0),l=Math.min(l,n-m),s=Math.max(s,0),s=Math.min(s,r-c);let u=mr(i,d);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===OE.IDLE||f===OE.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===eL.DARK?"#2f6330":QM,y=d?.isSpeaking;y&&(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=bc,e.strokeStyle=bc,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 w=(y?l+0:l)+m/2,v=(y?s+0:s)+c+2,C=5,k=3,P=e.measureText(E),S=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,_=Math.max(S,12),M=w-1,R=v-1,O=P.width+2+C*2+2,V=_+2+k*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(M,R,O,V,8),e.fillStyle=u,e.fill(),e.strokeStyle=bc,e.stroke(),y&&(e.beginPath(),e.roundRect(M-2,R-2,O+4,V+4,8),e.strokeStyle=x,e.stroke())):fc(e,M,R,O,V,8,bc),e.fillStyle=JM,e.fillText(E,w+C+1,v+k+P.actualBoundingBoxAscent+Math.floor((_-S)/2)+2),y){e.fillStyle=x;let j=8,A=8,N=5;e.fillRect(M+O+A,R+(V/2-j/2),2,j),e.fillRect(M+O+A+N,R+(V/2-j*2/2),2,j*2),e.fillRect(M+O+A+N*2,R+(V/2-j/2),2,j)}}e.restore(),e.closePath()}};import oL from"clsx";import{useState as nL}from"react";import{jsx as GE}from"react/jsx-runtime";var vu=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=zE(t),[a,l]=nL(!1),s=!a&&n,d=s?void 0:{background:e};return GE("div",{className:oL("Avatar",r),style:d,onClick:o,children:s?GE("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as To,jsxs as xc}from"react/jsx-runtime";var iL=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:UE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:UE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=o,l=mr(n,r),s=rL({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),d=r.isInCall?r.isSpeaking?xc("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[To("div",{}),To("div",{}),To("div",{})]}):r.isMuted?To("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:yb}):To("div",{title:g("userList.hint.inCall"),children:Eb}):null;return i?xc("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[To(vu,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),To("div",{className:"UserList__collaborator-name",children:r.username}),xc("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&To("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:Ur}),d]})]}):xc("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[To(vu,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),d&&To("div",{className:"UserList__collaborator-status-icon",children:d})]})}});import{LIBRARY_DISABLED_TYPES as aL,randomId as lL}from"@excalidraw/common";import{deepCopyElement as sL}from"@excalidraw/element";import{CaptureUpdateAction as Tu}from"@excalidraw/element";var Iu=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 aL)if(r.some(a=>a.type===i))return{captureUpdate:Tu.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:lL(),status:"unpublished",elements:r.map(sL),created:Date.now()},...i])).then(()=>({captureUpdate:Tu.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:Tu.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as pi}from"@excalidraw/element";import{isFrameLikeElement as cL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as dL}from"@excalidraw/element";import{KEYS as yn,arrayToMap as mL,getShortcutKey as Ec}from"@excalidraw/common";import{alignElements as pL}from"@excalidraw/element";import{CaptureUpdateAction as ui}from"@excalidraw/element";import{getSelectedElementsByGroup as uL}from"@excalidraw/element";import{jsx as gi}from"react/jsx-runtime";var ft=(e,o)=>{let t=o.scene.getSelectedElements(e);return uL(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>cL(n))},hi=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=pL(r,n,t.scene,o),a=mL(i);return dL(e.map(l=>a.get(l.id)||l),o,t)},hL=B({name:"alignTop",label:"labels.alignTop",icon:Jm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>ft(o,n),perform:(e,o,t,n)=>({appState:o,elements:hi(e,o,n,{position:"start",axis:"y"}),captureUpdate:ui.IMMEDIATELY}),keyTest:e=>e[yn.CTRL_OR_CMD]&&e.shiftKey&&e.key===yn.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>gi(K,{hidden:!ft(o,n),type:"button",icon:Jm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${Ec("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:we(pi(e),o)})}),gL=B({name:"alignBottom",label:"labels.alignBottom",icon:Qm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>ft(o,n),perform:(e,o,t,n)=>({appState:o,elements:hi(e,o,n,{position:"end",axis:"y"}),captureUpdate:ui.IMMEDIATELY}),keyTest:e=>e[yn.CTRL_OR_CMD]&&e.shiftKey&&e.key===yn.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>gi(K,{hidden:!ft(o,n),type:"button",icon:Qm,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${Ec("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:we(pi(e),o)})}),fL=B({name:"alignLeft",label:"labels.alignLeft",icon:ep,trackEvent:{category:"element"},predicate:(e,o,t,n)=>ft(o,n),perform:(e,o,t,n)=>({appState:o,elements:hi(e,o,n,{position:"start",axis:"x"}),captureUpdate:ui.IMMEDIATELY}),keyTest:e=>e[yn.CTRL_OR_CMD]&&e.shiftKey&&e.key===yn.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>gi(K,{hidden:!ft(o,n),type:"button",icon:ep,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${Ec("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:we(pi(e),o)})}),bL=B({name:"alignRight",label:"labels.alignRight",icon:tp,trackEvent:{category:"element"},predicate:(e,o,t,n)=>ft(o,n),perform:(e,o,t,n)=>({appState:o,elements:hi(e,o,n,{position:"end",axis:"x"}),captureUpdate:ui.IMMEDIATELY}),keyTest:e=>e[yn.CTRL_OR_CMD]&&e.shiftKey&&e.key===yn.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>gi(K,{hidden:!ft(o,n),type:"button",icon:tp,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${Ec("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:we(pi(e),o)})}),xL=B({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:op,trackEvent:{category:"element"},predicate:(e,o,t,n)=>ft(o,n),perform:(e,o,t,n)=>({appState:o,elements:hi(e,o,n,{position:"center",axis:"y"}),captureUpdate:ui.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>gi(K,{hidden:!ft(o,n),type:"button",icon:op,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:we(pi(e),o)})}),EL=B({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:np,trackEvent:{category:"element"},predicate:(e,o,t,n)=>ft(o,n),perform:(e,o,t,n)=>({appState:o,elements:hi(e,o,n,{position:"center",axis:"x"}),captureUpdate:ui.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>gi(K,{hidden:!ft(o,n),type:"button",icon:np,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:we(pi(e),o)})});import{getNonDeletedElements as YE}from"@excalidraw/element";import{isFrameLikeElement as yL}from"@excalidraw/element";import{CODES as WE,KEYS as VE,arrayToMap as wL,getShortcutKey as XE}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as vL}from"@excalidraw/element";import{distributeElements as TL}from"@excalidraw/element";import{CaptureUpdateAction as KE}from"@excalidraw/element";import{getSelectedElementsByGroup as IL}from"@excalidraw/element";import{jsx as jE}from"react/jsx-runtime";var ZE=(e,o)=>{let t=o.scene.getSelectedElements(e);return IL(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>yL(n))},$E=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=TL(r,t.scene.getNonDeletedElementsMap(),n,o),a=wL(i);return vL(e.map(l=>a.get(l.id)||l),o,t)},CL=B({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:$E(e,o,n,{space:"between",axis:"x"}),captureUpdate:KE.IMMEDIATELY}),keyTest:e=>!e[VE.CTRL_OR_CMD]&&e.altKey&&e.code===WE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>jE(K,{hidden:!ZE(o,n),type:"button",icon:T0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${XE("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:we(YE(e),o)})}),SL=B({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:$E(e,o,n,{space:"between",axis:"y"}),captureUpdate:KE.IMMEDIATELY}),keyTest:e=>!e[VE.CTRL_OR_CMD]&&e.altKey&&e.code===WE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>jE(K,{hidden:!ZE(o,n),type:"button",icon:I0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${XE("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:we(YE(e),o)})});import{getNonDeletedElements as kL}from"@excalidraw/element";import{bindOrUnbindLinearElements as ML,isBindingEnabled as LL}from"@excalidraw/element";import{getCommonBoundingBox as qE}from"@excalidraw/element";import{newElementWith as PL}from"@excalidraw/element";import{deepCopyElement as AL}from"@excalidraw/element";import{resizeMultipleElements as DL}from"@excalidraw/element";import{isArrowElement as _L,isElbowArrow as RL,isLinearElement as NL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as JE}from"@excalidraw/element";import{CODES as QE,KEYS as BL,arrayToMap as FL}from"@excalidraw/common";import{CaptureUpdateAction as ey}from"@excalidraw/element";var Cu=B({name:"flipHorizontal",label:"labels.flipHorizontal",icon:Ib,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:JE(ty(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:ey.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===QE.H}),Su=B({name:"flipVertical",label:"labels.flipVertical",icon:Tb,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:JE(ty(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:ey.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===QE.V&&!e[BL.CTRL_OR_CMD]}),ty=(e,o,t,n,r)=>{let i=J(kL(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=OL(i,o,t,n,r),l=FL(a);return e.map(s=>l.get(s.id)||s)},OL=(e,o,t,n,r)=>{if(e.every(u=>_L(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return PL(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=qE(e);DL(e,o,"nw",r.scene,new Map(Array.from(o.values()).map(u=>[u.id,AL(u)])),{flipByX:n==="horizontal",flipByY:n==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),ML(e.filter(NL),LL(t),[],r.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>RL(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:d,midY:m}=qE(e),[c,p]=[i-d,a-m];return s.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),l.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),e};import{isTextElement as zL}from"@excalidraw/element";import{getTextFromElements as HL}from"@excalidraw/element";import{CODES as GL,KEYS as oy,isFirefox as UL}from"@excalidraw/common";import{CaptureUpdateAction as Ft}from"@excalidraw/element";var fi=B({name:"copy",label:"labels.copy",icon:ua,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await cc(r,n.files,t)}catch(i){return{captureUpdate:Ft.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Ft.EVENTUALLY}},keyTest:void 0}),ku=B({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await TE()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),UL?{captureUpdate:Ft.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Ft.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(wE({types:r}))}catch(i){return console.error(i),{captureUpdate:Ft.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Ft.EVENTUALLY}},keyTest:void 0}),yc=B({name:"cut",label:"labels.cut",icon:sb,trackEvent:{category:"element"},perform:(e,o,t,n)=>(fi.perform(e,o,t,n),va.perform(e,o,null,n)),keyTest:e=>e[oy.CTRL_OR_CMD]&&e.key===oy.X}),wc=B({name:"copyAsSvg",label:"labels.copyAsSvg",icon:Cb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Ft.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=lr(e,o,!0);try{await sr("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:Ft.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Ft.EVENTUALLY}}},predicate:e=>sc&&e.length>0,keywords:["svg","clipboard","copy"]}),vc=B({name:"copyAsPng",label:"labels.copyAsPng",icon:Sb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Ft.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=lr(e,o,!0);try{return await sr("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:Ft.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Ft.EVENTUALLY}}},predicate:e=>si&&e.length>0,keyTest:e=>e.code===GL.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Tc=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{lo(HL(r))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Ft.EVENTUALLY}},predicate:(e,o,t,n)=>sc&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(zL),keywords:["text","clipboard","copy"]});import{CODES as YL,KEYS as WL}from"@excalidraw/common";import{CaptureUpdateAction as VL}from"@excalidraw/element";var Ic=B({name:"gridMode",icon:Ab,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:VL.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[WL.CTRL_OR_CMD]&&e.code===YL.QUOTE});import{CODES as XL,KEYS as KL}from"@excalidraw/common";import{CaptureUpdateAction as ZL}from"@excalidraw/element";var bi=B({name:"zenMode",label:"buttons.zenMode",icon:Mb,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:ZL.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[KL.CTRL_OR_CMD]&&e.altKey&&e.code===XL.Z});import{CODES as $L,KEYS as jL}from"@excalidraw/common";import{CaptureUpdateAction as qL}from"@excalidraw/element";var Mu=B({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:kb,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:qL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[jL.CTRL_OR_CMD]&&e.altKey&&e.code===$L.S});import{CODES as JL,KEYS as QL}from"@excalidraw/common";import{CaptureUpdateAction as eP}from"@excalidraw/element";var xi=B({name:"stats",label:"stats.fullTitle",icon:vb,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:eP.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[QL.CTRL_OR_CMD]&&e.altKey&&e.code===JL.SLASH});import{BOUND_TEXT_PADDING as ny,ROUNDNESS as ry,TEXT_ALIGN as ay,VERTICAL_ALIGN as ly,arrayToMap as sy,getFontString as tP}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as oP,resetOriginalContainerCache as nP,updateOriginalContainerCache as rP}from"@excalidraw/element";import{computeBoundTextPosition as iP,computeContainerDimensionForBoundText as iy,getBoundTextElement as cy,redrawTextBoundingBox as dy}from"@excalidraw/element";import{hasBoundTextElement as aP,isArrowElement as lP,isTextBindableContainer as Lu,isTextElement as Ka,isUsingAdaptiveRadius as sP}from"@excalidraw/element";import{measureText as cP}from"@excalidraw/element";import{syncMovedIndices as my}from"@excalidraw/element";import{newElement as dP}from"@excalidraw/element";import{CaptureUpdateAction as Pu}from"@excalidraw/element";var Au=B({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>aP(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=cy(a,i);if(l){let{width:s,height:d}=cP(l.originalText,tP(l),l.lineHeight),m=oP(a.id);nP(a.id);let{x:c,y:p}=iP(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:d,text:l.originalText,x:c,y:p}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:Pu.IMMEDIATELY}}}),Du=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=Ka(r[0])||Ka(r[1]),a;if(Lu(r[0])?a=r[0]:Lu(r[1])&&(a=r[1]),i&&a&&cy(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,a;Ka(r[0])&&Lu(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:ly.MIDDLE,textAlign:ay.CENTER,autoResize:!0,angle:lP(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return dy(i,a,n.scene),rP(a.id,l),{elements:mP(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:Pu.IMMEDIATELY}}}),mP=(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),my(n,sy([o,t])),n},pP=(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),my(n,sy([o,t])),n},py=B({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(a=>Ka(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(Ka(l)){let s=dP({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:sP("rectangle")?ry.ADAPTIVE_RADIUS:ry.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-ny,y:l.y-ny,width:iy(l.width,"rectangle"),height:iy(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let d=l.boundElements.filter(c=>c.type==="arrow").map(c=>c.id);i.filter(c=>d.includes(c.id)).forEach(c=>{let p=c.startBinding,u=c.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&n.scene.mutateElement(c,{startBinding:p,endBinding:u})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:ly.MIDDLE,boundElements:null,textAlign:ay.CENTER,autoResize:!0}),dy(l,s,n.scene),i=pP([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:Pu.IMMEDIATELY}}});import{isEmbeddableElement as LP}from"@excalidraw/element";import{KEYS as vy,getShortcutKey as PP}from"@excalidraw/common";import{CaptureUpdateAction as AP}from"@excalidraw/element";import{pointFrom as fy}from"@excalidraw/math";import uP from"clsx";import{useCallback as uy,useEffect as hy,useLayoutEffect as hP,useRef as gP,useState as fP}from"react";import{EVENT as _u,HYPERLINK_TOOLTIP_DELAY as bP,KEYS as Cc}from"@excalidraw/common";import{getElementAbsoluteCoords as Ou}from"@excalidraw/element";import{hitElementBoundingBox as xP}from"@excalidraw/element";import{isElementLink as EP}from"@excalidraw/element";import{getEmbedLink as yP,embeddableURLValidator as wP}from"@excalidraw/element";import{sceneCoordsToViewportCoords as by,viewportCoordsToSceneCoords as vP,wrapEvent as TP,isLocalLink as IP,normalizeLink as Ru}from"@excalidraw/common";import{isEmbeddableElement as Nu}from"@excalidraw/element";import{jsx as Ei,jsxs as gy}from"react/jsx-runtime";var zu=380,CP=42,Bu=5,xy=85,SP=500,Fu=!1,Sc=new Map,Ey=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=Eo(),s=yo(),d=me(),m=e.link||"",[c,p]=fP(m),u=gP(null),f=l.showHyperlinkPopup==="editor",b=uy(()=>{if(!u.current)return;let v=Ru(u.current.value)||null;if(!e.link&&v&&ae("hyperlink","create"),Nu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!wP(v,s.validateEmbeddable))v&&r({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:k}=e,P=yP(v);P?.error instanceof URIError&&r({message:g("toast.unrecognizedLinkFormat"),closable:!0});let S=P?P.intrinsicSize.w/P.intrinsicSize.h:1,_=Sc.get(e.id)!==e.link;o.mutateElement(e,{..._?{width:P?.type==="video"?C>k?C:k*S:C,height:P?.type==="video"&&C>k?C/S:k}:{},link:v}),i(e,!0),Sc.has(e.id)&&Sc.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);hP(()=>()=>{b()},[b]),hy(()=>{f&&u?.current&&!(d.viewport.isMobile||d.isTouchScreen)&&u.current.select()},[f,d.viewport.isMobile,d.isTouchScreen]),hy(()=>{let v=null,C=k=>{if(f)return;v&&clearTimeout(v),MP(e,a,l,fy(k.clientX,k.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},SP))};return window.addEventListener(_u.POINTER_MOVE,C,!1),()=>{window.removeEventListener(_u.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=uy(()=>{ae("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),y=()=>{ae("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y:w}=yy(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:gy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${w}px`,left:`${E}px`,width:zu,padding:Bu},children:[f?Ei("input",{className:uP("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:c,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Cc.CTRL_OR_CMD]&&v.key===Cc.K&&v.preventDefault(),(v.key===Cc.ENTER||v.key===Cc.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?Ei("a",{href:Ru(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:IP(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&n){let C=TP(_u.EXCALIDRAW_LINK,v.nativeEvent);n({...e,link:Ru(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Ei("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),gy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&Ei(K,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:sn}),Ei(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:Is}),m&&!Nu(e)&&Ei(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:At})]})]})},yy=(e,o,t)=>{let[n,r]=Ou(e,t),{x:i,y:a}=by({sceneX:n+e.width/2,sceneY:r},o),l=i-o.offsetLeft-zu/2,s=a-o.offsetTop-xy;return{x:l,y:s}},Hu=(e,o)=>{let t=J(e,o);return Nu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Za=null,wy=(e,o,t)=>{Za&&clearTimeout(Za),Za=window.setTimeout(()=>kP(e,o,t),bP)},kP=(e,o,t)=>{if(!e.link)return;let n=ii();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=EP(e.link)?g("labels.link.goToElement"):e.link;let[r,i,a,l]=Ou(e,t),[s,d,m,c]=I1([r,i,a,l],e.angle,o),p=by({sceneX:s,sceneY:d},o);Jp(n,{left:p.x,top:p.y,width:m,height:c},"top"),ae("hyperlink","tooltip","link-icon"),Fu=!0},Gu=()=>{Za&&clearTimeout(Za),Fu&&(Fu=!1,ii().classList.remove("excalidraw-tooltip--visible"))},MP=(e,o,t,[n,r])=>{let{x:i,y:a}=vP({clientX:n,clientY:r},t),l=15/t.zoom.value;if(xP(fy(i,a),e,o))return!1;let[s,d,m]=Ou(e,o);if(i>=s&&i<=m&&a>=d-xy&&a<=d)return!1;let{x:c,y:p}=yy(e,t,o);return!(n>=c-l&&n<=c+zu+Bu*2+l&&r>=p-l&&r<=p+l+Bu*2+CP)};import{jsx as DP}from"react/jsx-runtime";var $a=B({name:"hyperlink",label:(e,o)=>Hu(e,o),icon:fa,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:AP.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[vy.CTRL_OR_CMD]&&e.key===vy.K,predicate:(e,o)=>J(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=J(e,o);return DP(K,{type:"button",icon:fa,"aria-label":g(Hu(e,o)),title:`${LP(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${PP("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as Ty,arrayToMap as Yu,randomId as _P}from"@excalidraw/common";import{elementsAreInSameGroup as RP,newElementWith as Iy,selectGroupsFromGivenElements as Cy}from"@excalidraw/element";import{CaptureUpdateAction as Sy}from"@excalidraw/element";var Uu=e=>e.every(o=>!o.locked),ja=B({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Uu(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=J(o,e);return Uu(t)?Br:Jn},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=Uu(r),a=Yu(r),l=r.length>1&&RP(r),d=r.length===1||l?null:_P(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...d?{[d]:!0}:{}};else if(l){let y=r[0].groupIds.at(-1);delete m[y]}let c=e.map(y=>{if(!a.has(y.id))return y;let E=y.groupIds;return i?d&&(E=[...E,d]):E=E.filter(w=>!o.lockedMultiSelections[w]),Iy(y,{locked:i,groupIds:E.length!==y.groupIds.length?E:y.groupIds})}),p=Yu(c),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),f=r.map(y=>p.get(y.id)||y),b=i?{}:Cy(f,o),x=i?d||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:c,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:x},captureUpdate:Sy.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===Ty.L&&e[Ty.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),ky=B({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Jn,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 Iy(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=Yu(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:Cy(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Sy.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as VD,isLinearElement as XD,isLineElement as Fi}from"@excalidraw/element";import{arrayToMap as KD,invariant as Wh}from"@excalidraw/common";import{toggleLinePolygonState as ZD,CaptureUpdateAction as Bw}from"@excalidraw/element";import lw from"clsx";import O7 from"fuzzy";import{useEffect as nd,useRef as sw,useMemo as z7,useState as od}from"react";import{DEFAULT_SIDEBAR as rw,EVENT as id,KEYS as mo,capitalizeString as H7,getShortcutKey as G7,isWritableElement as U7}from"@excalidraw/common";import{CaptureUpdateAction as fA}from"@excalidraw/element";import{useEffect as Qa,useMemo as My,useRef as Ku,useState as NP}from"react";import{getLinearElementSubType as vi,updateElbowArrowPoints as BP}from"@excalidraw/element";import{pointFrom as Mc,pointRotateRads as FP}from"@excalidraw/math";import{hasBoundTextElement as OP,isArrowBoundToElement as zP,isArrowElement as HP,isElbowArrow as GP,isLinearElement as qu,isUsingAdaptiveRadius as UP}from"@excalidraw/element";import{getCommonBoundingBox as YP,getElementAbsoluteCoords as WP}from"@excalidraw/element";import{getBoundTextElement as _y,getBoundTextMaxHeight as VP,getBoundTextMaxWidth as XP,redrawTextBoundingBox as KP}from"@excalidraw/element";import{wrapText as ZP}from"@excalidraw/element";import{assertNever as $P,CLASSES as jP,getFontString as Wu,isProdEnv as qP,mapFind as JP,reduceToCommonValue as QP,updateActiveTool as Ly}from"@excalidraw/common";import{measureText as Py}from"@excalidraw/element";import{LinearElementEditor as eA}from"@excalidraw/element";import{newArrowElement as Vu,newElement as tA,newLinearElement as oA}from"@excalidraw/element";import{ShapeCache as nA}from"@excalidraw/element";import{updateBindings as rA}from"@excalidraw/element";import{jsx as ju}from"react/jsx-runtime";var iA=8,aA=10,qa=["rectangle","diamond","ellipse"],Ja=["line","sharpArrow","curvedArrow","elbowArrow"],lA=new Set(qa),sA=new Set(Ja),Ti=e=>lA.has(e),Pc=e=>e==="arrow"||sA.has(e),co=ue(null),el=new Map,tl=new Map,cA=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Ku(null);return Qa(()=>{if(o.length===0){e.updateEditorAtom(co,null);return}let n=Ii(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(co,null),t.current=null)},[o,e]),Qa(()=>()=>{el.clear(),tl.clear()},[]),ju(dA,{app:e,elements:o})},dA=({app:e,elements:o})=>{let t=Ii(o),n=My(()=>t==="generic"?Ny(o):[],[t,o]),r=My(()=>t==="linear"?$u(o):[],[t,o]),i=t==="generic"?n.every(c=>c.type===n[0].type):t==="linear"?r.every(c=>vi(c)===vi(r[0])):!1,[a,l]=NP({x:0,y:0}),s=Ku(""),d=Ku(null);Qa(()=>{let c=[...n,...r].sort((x,y)=>x.id.localeCompare(y.id)),p=`
|
|
8
|
-
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${c.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(c.length===1){let[x,,,y,E,w]=WP(c[0],e.scene.getNonDeletedElementsMap());u=FP(Mc(x,y),Mc(E,w),c[0].angle)}else{let{minX:x,maxY:y}=YP(c);u=Mc(x,y)}let{x:f,y:b}=Fy({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[n,r,e.scene,e.state]),Qa(()=>{for(let c of r){let p=Zu(c.id,gA(c));tl.has(p)||tl.set(p,c)}},[r]),Qa(()=>{for(let c of n)if(!el.has(c.id)){let p=_y(c,e.scene.getNonDeletedElementsMap());p&&el.set(c.id,{fontSize:p.fontSize})}},[n,e.scene]);let m=t==="linear"?[["line",ms],["sharpArrow",Yr],["curvedArrow",Vr],["elbowArrow",Wr]]:t==="generic"?[["rectangle",ss],["diamond",cs],["ellipse",ds]]:[];return ju("div",{ref:d,tabIndex:-1,style:{position:"absolute",top:`${a.y+(aA+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-iA}px`,zIndex:2},className:jP.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([c,p])=>{let u=i&&(t==="generic"&&n[0].type===c||t==="linear"&&vi(r[0])===c);return ju(K,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:c,keyBindingLabel:"","aria-label":c,"data-testid":`toolbar-${c}`,onChange:()=>{e.state.activeTool.type!==c&&ae("convertElementType",c,"ui"),Ju(e,{conversionType:t,nextType:c}),d.current?.focus()}},`${o[0].id}${o[0].version}_${c}`)})})},mA=(e,o,t)=>{let n=XP(e,o),r=VP(e,o),i=ZP(o.text,Wu(o),n),a=Py(i,Wu(o),o.lineHeight),l=o.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...o,fontSize:l};a=Py(o.text,Wu(s),o.lineHeight)}Ac(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),KP(o,e,t)},Ju=(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=Ny(r),d=l.every(m=>m.type===l[0].type)?qa.indexOf(l[0].type):-1;if(t=t??qa[(d+qa.length+a)%qa.length],t&&Ti(t)){let m={};for(let p of l){let u=Dy(p,t,e);m[u.id]=u}let c=[];for(let p of e.scene.getElementsIncludingDeleted())m[p.id]?c.push(m[p.id]):c.push(p);e.scene.replaceAllElements(c);for(let p of Object.values(m)){let u=_y(p,e.scene.getNonDeletedElementsMap());u&&(el.get(p.id)&&Ac(u,e.scene.getNonDeletedElementsMap(),{fontSize:el.get(p.id)?.fontSize??u.fontSize}),mA(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:Ly(p,{type:"selection"})}))}}if(o==="linear"){let l=$u(r);if(!t){let d=QP(l,vi),m=d?Ja.indexOf(d):-1;t=Ja[(m+Ja.length+a)%Ja.length]}if(Pc(t)){let d=[],m=e.scene.getElementsMapIncludingDeleted();for(let c of l){let p=tl.get(Zu(c.id,t));if(p&&vi(p)===t)m.set(p.id,p),d.push(p);else{let u=Dy(c,t,e);m.set(u.id,u),d.push(u)}}e.scene.replaceAllElements(m);for(let c of d)if(qu(c))if(GP(c)){let p=pA(c);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=BP(c,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Ac(c,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=JP(["line","sharpArrow","curvedArrow"],u=>tl.get(Zu(c.id,u)));if(p){let u=p.points;e.scene.mutateElement(c,{points:u})}}}let s=$u(e.scene.getSelectedElements(e.state));e.setState(d=>({selectedElementIds:i,selectedLinearElement:s.length===1?new eA(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Ly(d,{type:"selection"})}))}return!0},Ii=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(Ti(t.type))return"generic";Ry(t)&&(o=!0)}return o?"linear":null},Ry=e=>qu(e)&&(!HP(e)||!zP(e)&&!OP(e)),Zu=(e,o)=>`${e}:${o}`,Ny=e=>e.filter(o=>Ti(o.type)),$u=e=>e.filter(o=>Ry(o)),kc=20,yi=(e,o)=>e[0]===o[0],Xu=(e,o)=>e[1]===o[1],Ay=(e,o)=>yi(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),pA=e=>{let o=[e.points[0]],t=uA(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])<kc?l[0]=a[0]:Math.abs(l[1]-a[1])<kc&&(l[1]=a[1]),yi(a,l)||Xu(a,l)||o.push(Mc(a[0],l[1])),o.push(l)}let n=[o[0]];for(let i=1;i<o.length-1;++i)yi(o[i-1],o[i])&&yi(o[i],o[i+1])||Xu(o[i-1],o[i])&&Xu(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],d=yi(a,l),m=yi(l,s);if(d!==m){let c=Ay(a,l),p=Ay(l,s);if(c<kc||p<kc){if(p<c)d?s[0]=a[0]:s[1]=a[1];else if(m)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},uA=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},Dy=(e,o,t)=>{if(!hA(e.type,o)){if(!qP())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(nA.delete(e),Ti(o)){let n=wi(tA({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:UP(o)?Lc.ADAPTIVE_RADIUS:Lc.PROPORTIONAL_RADIUS}:e.roundness}));return rA(n,t.scene),n}if(Pc(o))switch(o){case"line":return wi(oA({...e,type:"line"}));case"sharpArrow":return wi(Vu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return wi(Vu({...e,type:"arrow",elbowed:!1,roundness:{type:Lc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return wi(Vu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return $P(o,`unhandled conversion type: ${o}`),e},hA=(e,o)=>!!(Ti(e)&&Ti(o)||Pc(e)&&Pc(o)),gA=e=>qu(e)?vi(e):e.type,By=cA;var Oy=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 Ye.set(co,{type:"panel"}),{captureUpdate:fA.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>Ii(e)!==null});import{canCreateLinkFromElements as Qu,defaultGetElementLinkFromSelection as bA,getLinkIdAndTypeFromSelection as xA}from"@excalidraw/element";import{CaptureUpdateAction as ol}from"@excalidraw/element";var Dc=B({name:"copyElementLink",label:"labels.copyElementLink",icon:Hr,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=J(e,o);try{if(window.location){let i=xA(r,o);return i?(await lo(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):bA(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:ol.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:ol.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:ol.EVENTUALLY}},predicate:(e,o)=>Qu(J(e,o))}),zy=B({name:"linkToElement",label:"labels.linkToElement",icon:Is,perform:(e,o,t,n)=>{let r=J(e,o);return r.length!==1||!Qu(r)?{elements:e,appState:o,app:n,captureUpdate:ol.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:J(e,o)[0].id}},captureUpdate:ol.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=J(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&Qu(r)},trackEvent:!1});import{isDarwin as Hy,getShortcutKey as re}from"@excalidraw/common";var EA={toggleTheme:[re("Shift+Alt+D")],saveScene:[re("CtrlOrCmd+S")],loadScene:[re("CtrlOrCmd+O")],clearCanvas:[re("CtrlOrCmd+Delete")],imageExport:[re("CtrlOrCmd+Shift+E")],commandPalette:[re("CtrlOrCmd+/"),re("CtrlOrCmd+Shift+P")],cut:[re("CtrlOrCmd+X")],copy:[re("CtrlOrCmd+C")],paste:[re("CtrlOrCmd+V")],copyStyles:[re("CtrlOrCmd+Alt+C")],pasteStyles:[re("CtrlOrCmd+Alt+V")],selectAll:[re("CtrlOrCmd+A")],deleteSelectedElements:[re("Delete")],duplicateSelection:[re("CtrlOrCmd+D"),re(`Alt+${g("helpDialog.drag")}`)],sendBackward:[re("CtrlOrCmd+[")],bringForward:[re("CtrlOrCmd+]")],sendToBack:[Hy?re("CtrlOrCmd+Alt+["):re("CtrlOrCmd+Shift+[")],bringToFront:[Hy?re("CtrlOrCmd+Alt+]"):re("CtrlOrCmd+Shift+]")],copyAsPng:[re("Shift+Alt+C")],group:[re("CtrlOrCmd+G")],ungroup:[re("CtrlOrCmd+Shift+G")],gridMode:[re("CtrlOrCmd+'")],zenMode:[re("Alt+Z")],objectsSnapMode:[re("Alt+S")],stats:[re("Alt+/")],addToLibrary:[],flipHorizontal:[re("Shift+H")],flipVertical:[re("Shift+V")],viewMode:[re("Alt+R")],hyperlink:[re("CtrlOrCmd+K")],toggleElementLock:[re("CtrlOrCmd+Shift+L")],resetZoom:[re("CtrlOrCmd+0")],zoomOut:[re("CtrlOrCmd+-")],zoomIn:[re("CtrlOrCmd++")],zoomToFitSelection:[re("Shift+3")],zoomToFit:[re("Shift+1")],zoomToFitSelectionInViewport:[re("Shift+2")],toggleEraserTool:[re("E")],toggleHandTool:[re("H")],setFrameAsActiveTool:[re("F")],saveFileToDisk:[re("CtrlOrCmd+S")],saveToActiveFile:[re("CtrlOrCmd+S")],toggleShortcuts:[re("?")],searchMenu:[re("CtrlOrCmd+F")],wrapSelectionInFrame:[]},Oe=(e,o=0)=>{let t=EA[e];return t&&t.length>0?t[o]||t[0]:""};var yA="\\u0300-\\u036f",wA="\\ufe20-\\ufe2f",vA="\\u20d0-\\u20ff",TA=yA+wA+vA,IA=`[${TA}]`,CA=RegExp(IA,"g"),SA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,kA={\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"},pr=e=>e.replace(SA,o=>kA[o]||o).replace(CA,"");import C7 from"clsx";import{useEffect as S7,useState as k7}from"react";import{KEYS as M7,queryFocusableElements as G2}from"@excalidraw/common";import{useCallback as MA,useState as LA}from"react";var Gy=()=>{let[e,o]=LA(null),t=MA(n=>o(n),[]);return[e,t]};import{useState as N2,useCallback as xh,useMemo as B2,useEffect as Eh,memo as F2,useRef as d7}from"react";import{LIBRARY_DISABLED_TYPES as m7,randomId as p7,isShallowEqual as u7,KEYS as h7,isWritableElement as g7,addEventListener as f7,EVENT as b7,CLASSES as D2}from"@excalidraw/common";import{useEffect as Vy,useRef as Xy}from"react";import{URL_HASH_KEYS as oh,URL_QUERY_KEYS as nh,APP_NAME as Ky,EVENT as Rc,DEFAULT_SIDEBAR as _A,LIBRARY_SIDEBAR_TAB as RA,arrayToMap as rh,cloneJSON as NA,preventUnload as BA,promiseTry as Zy,resolvablePromise as FA,toValidURL as OA,Queue as zA,Emitter as HA}from"@excalidraw/common";import{hashElementsVersion as GA,hashString as UA}from"@excalidraw/element";import{getCommonBoundingBox as th}from"@excalidraw/element";import{MIME_TYPES as ur}from"@excalidraw/common";var wn=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=Dr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:d,viewBackgroundColor:m}=s;return es(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:d,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(c,p)=>{let u=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(c,p),x=n<b?n/b:o?.exportScale??1;return u.width=c*x,u.height=p*x,{canvas:u,scale:x}}let f=r?.(c,p)||{width:c,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},Uy=async e=>{let{mimeType:o=ur.png,quality:t}=e;o===ur.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ur.png}" mimeType`),o==="image/jpg"&&(o=ur.jpg),o===ur.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ur.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await wn(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===ur.png&&e.appState?.exportEmbedScene&&(a=await _1({blob:a,metadata:la(e.elements,e.appState,e.files||{},"local")})),r(a)},o,t)})},Ci=async({elements:e,appState:o=an(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:d}=Dr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),m={...d,exportPadding:n};return Ar(s,m,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},PA=async e=>{if(e.type==="svg"){let o=await Ci(e);await lo(o.outerHTML)}else if(e.type==="png")await dc(Uy(e));else if(e.type==="json")await cc(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as Yy,useState as AA}from"react";import{COLOR_PALETTE as DA}from"@excalidraw/common";var eh=ue(new Map),Wy=async e=>await Ci({elements:e,appState:{exportBackground:!1,viewBackgroundColor:DA.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),_c=(e,o,t,n)=>{let[r,i]=AA();return Yy(()=>{if(o)if(e){let a=t.get(e);a?i(a):(async()=>{let l=await Wy(o);l.querySelector(".style-fonts")?.remove(),l&&(t.set(e,l),i(l))})()}else(async()=>{let a=await Wy(o);i(a)})()},[e,o,t,i]),Yy(()=>{let a=n.current;if(a)return r&&(a.innerHTML=r.outerHTML),()=>{a.innerHTML=""}},[r,n]),r},Si=()=>{let[e]=se(eh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var YA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],jy=new HA,Yo=ue({status:"loaded",isInitialized:!1,libraryItems:[]}),nl=e=>NA(e),WA=(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)),qy=(e,o)=>{let t=[];for(let n of o)WA(e,n)&&t.push(n);return[...t,...e]},Jy=(e,o)=>{let t=rh(o),n={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=rh(e);for(let i of o){let a=r.get(i.id);a?lh(a)!==lh(i)&&n.updatedItems.set(i.id,i):n.addedItems.set(i.id,i)}return n},ih=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",nl(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)Ye.set(Yo,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{Ye.set(Yo,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=nl(this.currLibraryItems);let t=nl(this.currLibraryItems);this.app.props.onLibraryChange?.(t),jy.trigger(Jy(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Ye.set(eh,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(nl(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:_A.name,tab:RA}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),d;s instanceof Blob?d=await Fm(s,i):d=da(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:d.length}))?(t&&this.app.focusContainer(),a(n?qy(this.currLibraryItems,d):d)):l(new Lr)}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=nl(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}},Qy=ih,Mi=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:y}=th(x.elements);return Math.max(b,y)},0),i=u=>{let f=0,b=0,x=0;for(let y of e){if(f%t===0&&(b=0),b===u){let{width:E}=th(y.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,d=0,m=0,c=0,p=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,c=0,p++),c===0&&(s=r(p)),d=i(c);let{minX:f,minY:b,width:x,height:y}=th(u.elements),E=(d-x)/2,w=(s-y)/2;n.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+w-b}))),a+=d+50,m++,c++}return n},VA=(e,o=YA)=>{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}"`)},ah=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(oh.addLibrary)||new URLSearchParams(window.location.search).get(nh.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},vn=class vn{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(da(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?vn.queue.push(r):r()}getLibraryItems(o){return vn.getLibraryItems(this.adapter,o,!1)}};I(vn,"queue",new zA),I(vn,"run",async(o,t)=>{let n=new vn(o);return vn.queue.push(()=>t(n))});var ki=vn,rl=0,Nc=0,lh=e=>`${e.id}:${e.name||""}:${GA(e.elements)}`,Bc=e=>UA(e.map(o=>lh(o)).sort().join()),$y=async(e,o)=>{try{return Nc++,await ki.run(e,async t=>{let n=rh(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);if(o.updatedItems)for(let[l,s]of o.updatedItems)n.set(l,s);let i=r.concat(Array.from(n.values())),a=Bc(i);return a!==rl&&await e.save({libraryItems:i}),rl=a,i})}finally{Nc--}},XA=e=>{let{excalidrawAPI:o}=e,t=Xy(e);t.current=e;let n=Xy(!1);Vy(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let d=new Promise(async(c,p)=>{try{l=decodeURIComponent(l),l=OA(l),VA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();c(f)}catch(u){p(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(c=>{window.addEventListener("focus",()=>c(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:d,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(c){throw o.updateScene({appState:{errorMessage:c.message}}),c}finally{if(window.location.hash.includes(oh.addLibrary)){let c=new URLSearchParams(window.location.hash.slice(1));c.delete(oh.addLibrary),window.history.replaceState({},Ky,`#${c.toString()}`)}else if(window.location.search.includes(nh.addLibrary)){let c=new URLSearchParams(window.location.search);c.delete(nh.addLibrary),window.history.replaceState({},Ky,`?${c.toString()}`)}}},i=l=>{l.preventDefault();let s=ah();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=ah();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,d=FA();s?d.resolve(Zy(s.load).then(async m=>{let c=null;try{if(!m)return ki.getLibraryItems(l,"load");c=da(m.libraryItems||[],"published");let p=await $y(l,Jy([],c));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}`),c}}).catch(m=>(console.error(`error during library migration: ${m.message}`),ki.getLibraryItems(l,"load")))):d.resolve(Zy(ki.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:d.then(m=>{let c=m||[];return rl=Bc(c),c}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(Rc.HASHCHANGE,i),()=>{window.removeEventListener(Rc.HASHCHANGE,i)}},[o]),Vy(()=>{let r=jy.on(async(a,l)=>{let s=n.current,d="adapter"in t.current&&t.current.adapter||null;try{d&&rl!==Bc(l)&&await $y(d,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{Nc&&BA(a)};return window.addEventListener(Rc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(Rc.BEFORE_UNLOAD,i),r(),rl=0,Nc=0}},[])};import jA from"clsx";import{VERSIONS as KA}from"@excalidraw/common";import{jsx as $A}from"react/jsx-runtime";var ZA=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return $A("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=${KA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},e2=ZA;import{jsx as qA,jsxs as JA}from"react/jsx-runtime";var Fc=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>JA("div",{className:jA("library-menu-control-buttons",i),style:n,children:[qA(e2,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as Ai,useEffect as hh,useMemo as gh,useRef as L2,useState as P2}from"react";import{MIME_TYPES as n7,arrayToMap as r7,nextAnimationFrame as i7}from"@excalidraw/common";import{duplicateElements as a7}from"@excalidraw/element";import l7 from"clsx";import QA from"lodash.throttle";import{useEffect as e8}from"react";var t8=ue(0),t2=e=>{let[o,t]=se(t8);return e8(()=>{let{current:n}=e;if(!n)return;let r=QA(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import _8 from"clsx";import{useCallback as R8,useState as mh}from"react";import{muteFSAbortError as N8}from"@excalidraw/common";import{flushSync as o2}from"react-dom";import o8 from"clsx";import{jsx as Oc,jsxs as r8}from"react/jsx-runtime";var n8=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return r8("button",{className:o8("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[n&&Oc("div",{style:a?{visibility:"hidden"}:{},children:n}),Oc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Oc("div",{style:{position:"absolute",inset:0},children:Oc(rt,{})})]})},Wo=n8;import{jsx as n2,jsxs as r2}from"react/jsx-runtime";var i8=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=ce(),d=ln(Li),{container:m}=Be();return r2(ze,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,r2("div",{className:"confirm-dialog-buttons",children:[n2(Wo,{label:i,onClick:()=>{s({openMenu:null}),d(!1),o2(()=>{t()}),m?.focus()}}),n2(Wo,{label:r,onClick:()=>{s({openMenu:null}),d(!1),o2(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},zc=i8;import Gc from"open-color";import{useCallback as p8,useEffect as dh,useRef as i2,useState as sh}from"react";import{EDITOR_LS_KEYS as ch,EXPORT_DATA_TYPES as u8,MIME_TYPES as a2,VERSIONS as h8,chunk as g8,getExportSource as f8}from"@excalidraw/common";var Xt=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(Xt,"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(Xt,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Hc from"react";var a8=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,l8=/{{([\w-]+)}}/,s8=/<([\w-]+)>/,c8=/<\/([\w-]+)>/,d8=(e,o)=>{let t=[{name:"",children:[]}];return e.split(a8).filter(Boolean).forEach(n=>{let r=n.match(s8),i=n.match(c8),a=n.match(l8);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(),d=Hc.createElement(Hc.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(d))}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},m8=({i18nKey:e,children:o,...t})=>{let{t:n}=Ue();return Hc.createElement(Hc.Fragment,{},...d8(n(e),t))},bt=m8;import{jsx as de,jsxs as ct}from"react/jsx-runtime";var b8=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=g8(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=Gc.white,l.fillRect(0,0,a.width,a.height);for(let[s,d]of e.entries()){let m=await wn({elements:d.elements,files:null,maxWidthOrHeight:128}),{width:c,height:p}=m,u=Math.floor(s/6)*(128+n*2),f=s%6*(128+n*2);l.drawImage(m,f+(128-c)/2+n,u+(128-p)/2+n),l.lineWidth=r,l.strokeStyle=Gc.gray[4],l.strokeRect(f+n/2,u+n/2,128+n,128+n)}return await ns(new File([await Ro(a)],"preview",{type:a2.png}),{outputType:a2.jpg,maxWidthOrHeight:5e3})},x8=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=i2(null),a=i2(null);return dh(()=>{let l=i.current;l&&(async()=>{let s=await Ci({elements:e.elements,appState:{...o,viewBackgroundColor:Gc.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),ct("div",{className:"single-library-item",children:[e.status==="published"&&de("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),de("div",{ref:i,className:"single-library-item__svg"}),de(K,{"aria-label":g("buttons.remove"),type:"button",icon:Gt,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:g("buttons.remove")}),ct("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[ct("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[ct("div",{style:{padding:"0.5em 0"},children:[de("span",{style:{fontWeight:500,color:Gc.gray[6]},children:g("publishDialog.itemName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{n(l.target.value,t)}})]}),de("span",{className:"error",children:e.error})]})]})},E8=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=sh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[d,m]=sh(!1);dh(()=>{let w=Xt.get(ch.PUBLISH_LIBRARY);w&&s(w)},[]);let[c,p]=sh(o.slice());dh(()=>{p(o.slice())},[o]);let u=w=>{s({...l,[w.target.name]:w.target.value})},f=async w=>{w.preventDefault(),m(!0);let v=[],C=!1;if(c.forEach(R=>{let O="";R.name||(O=g("publishDialog.errors.required"),C=!0),v.push({...R,error:O})}),C){p(v),m(!1);return}let k=await b8(c),P={type:u8.excalidrawLibrary,version:h8.excalidrawLibrary,source:f8(),libraryItems:c},S=JSON.stringify(P,null,2),_=new Blob([S],{type:"application/json"}),M=new FormData;M.append("excalidrawLib",_),M.append("previewImage",k),M.append("previewImageType",k.type),M.append("title",l.name),M.append("authorName",l.authorName),M.append("githubHandle",l.githubHandle),M.append("name",l.name),M.append("description",l.description),M.append("twitterHandle",l.twitterHandle),M.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:M}).then(R=>R.ok?R.json().then(({url:O})=>{Xt.delete(ch.PUBLISH_LIBRARY),n({url:O,authorName:l.authorName,items:c})}):R.json().catch(()=>{throw new Error(R.statusText||"something went wrong")}).then(O=>{throw new Error(O.message||R.statusText||"something went wrong")}),R=>{console.error(R),r(R),m(!1)}).catch(R=>{console.error(R),r(R),m(!1)})},b=()=>{let w=[];return c.forEach((v,C)=>{w.push(de("div",{className:"single-library-item-wrapper",children:de(x8,{libItem:v,appState:t,index:C,onChange:(k,P)=>{let S=c.slice();S[P].name=k,p(S)},onRemove:a})},C))}),de("div",{className:"selected-library-items",children:w})},x=p8(()=>{i(c),Xt.set(ch.PUBLISH_LIBRARY,l),e()},[c,e,i,l]),y=!!o.length,E=o.some(w=>w.status==="published");return de(ze,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:y?ct("form",{onSubmit:f,children:[de("div",{className:"publish-library-note",children:de(bt,{i18nKey:"publishDialog.noteDescription",link:w=>de("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:w})})}),de("span",{className:"publish-library-note",children:de(bt,{i18nKey:"publishDialog.noteGuidelines",link:w=>de("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:w})})}),de("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&de("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),ct("div",{className:"publish-library__fields",children:[ct("label",{children:[ct("div",{children:[de("span",{children:g("publishDialog.libraryName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),ct("label",{style:{alignItems:"flex-start"},children:[ct("div",{children:[de("span",{children:g("publishDialog.libraryDesc")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),ct("label",{children:[ct("div",{children:[de("span",{children:g("publishDialog.authorName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),ct("label",{children:[de("span",{children:g("publishDialog.githubUsername")}),de("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),ct("label",{children:[de("span",{children:g("publishDialog.twitterUsername")}),de("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),ct("label",{children:[de("span",{children:g("publishDialog.website")}),de("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),de("span",{className:"publish-library-note",children:de(bt,{i18nKey:"publishDialog.noteLicense",link:w=>de("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:w})})})]}),ct("div",{className:"publish-library__buttons",children:[de(Wo,{label:g("buttons.saveLibNames"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),de(Wo,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:d})]})]}):de("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},l2=E8;import v8 from"clsx";import{useEffect as T8,useRef as I8}from"react";import{EVENT as m2,KEYS as C8}from"@excalidraw/common";import{forwardRef as s2}from"react";import c2 from"clsx";import{jsx as d2}from"react/jsx-runtime";var y8=s2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>d2("div",{className:c2("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:a,children:e})),w8=s2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>d2("div",{className:c2("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:a,children:e})),Je={Row:y8,Col:w8};import{jsx as Uc}from"react/jsx-runtime";var p2=({children:e,onClickOutside:o,className:t="",onSelect:n,style:r})=>{let i=me(),a=I8(null),l=cn({onClickOutside:o});jr(a,()=>{l.onClickOutside?.()}),T8(()=>{let d=c=>{c.key===C8.ESCAPE&&(c.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener(m2.KEYDOWN,d,m),()=>{document.removeEventListener(m2.KEYDOWN,d,m)}},[l]);let s=v8(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Uc(Np.Provider,{value:{onSelect:n},children:Uc("div",{ref:a,className:s,style:r,"data-testid":"dropdown-menu",children:i.editor.isMobile?Uc(Je.Col,{className:"dropdown-menu-container",children:e}):Uc(We,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};p2.displayName="DropdownMenuContent";var u2=p2;import{jsx as k8}from"react/jsx-runtime";var S8=({children:e,className:o="",selected:t,...n})=>k8("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),h2=S8;import{jsx as g2}from"react/jsx-runtime";var f2=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let d=Xs(s.onClick,r);return g2("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:Vs(i,a),title:s.title??s["aria-label"],onClick:d,children:g2(Ws,{icon:e,shortcut:o,children:n})})},Pi=f2;f2.displayName="DropdownMenuItemLink";import{jsx as M8}from"react/jsx-runtime";var b2=()=>M8("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),x2=b2;b2.displayName="DropdownMenuSeparator";import L8 from"clsx";import{jsx as P8}from"react/jsx-runtime";var E2=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=me(),a=L8(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return P8("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},y2=E2;E2.displayName="DropdownMenuTrigger";import Yc from"react";var w2=e=>{let o=Yc.Children.toArray(e).find(t=>Yc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},v2=e=>{let o=Yc.Children.toArray(e).find(t=>Yc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as A8,jsxs as D8}from"react/jsx-runtime";var Vo=({children:e,open:o})=>{let t=w2(e),n=v2(e);return D8(A8,{children:[t,o&&n]})};Vo.Trigger=y2;Vo.Content=u2;Vo.Item=ut;Vo.ItemLink=Pi;Vo.ItemCustom=h2;Vo.Group=La;Vo.Separator=x2;var be=Vo;Vo.displayName="DropdownMenu";import{jsx as It,jsxs as Wc}from"react/jsx-runtime";var B8=(e,o)=>e.filter(t=>o.includes(t.id)),F8=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=se(Yo),[d,m]=se(Li),c=()=>{let M=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),R=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return It(zc,{onConfirm:()=>{o.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:R,children:It("p",{children:M})})},[p,u]=mh(!1),f=!!o.length,b=f?s.libraryItems.filter(M=>o.includes(M.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[y,E]=mh(!1),[w,v]=mh(null),C=R8(()=>Wc(ze,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[It("p",{children:It(bt,{i18nKey:"publishSuccessDialog.content",authorName:w.authorName,link:M=>It("a",{href:w?.url,target:"_blank",rel:"noopener noreferrer",children:M})})}),It(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,w]),k=(M,R)=>{E(!1),v({url:M.url,authorName:M.authorName});let O=R.slice();O.forEach(V=>{o.includes(V.id)&&(V.status="published")}),t.setLibrary(O)},P=async()=>{try{await t.updateLibrary({libraryItems:$l({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(M){if(M?.name==="AbortError"){console.warn(M);return}e({errorMessage:g("errors.importLibraryError")})}},S=async()=>{let M=f?b:await t.getLatestLibrary();T1(M).catch(N8).catch(R=>{e({errorMessage:R.message})})},_=()=>Wc(be,{open:d,children:[It(be.Trigger,{onToggle:()=>m(!d),children:j1}),Wc(be.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&It(be.Item,{onSelect:P,icon:zr,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&It(be.Item,{onSelect:S,icon:Qn,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),f&&It(be.Item,{icon:lb,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")}),!!b.length&&It(be.Item,{onSelect:()=>u(!0),icon:At,children:x})]})]});return Wc("div",{className:_8("library-menu-dropdown-container",l),children:[_(),o.length>0&&It("div",{className:"library-actions-counter",children:o.length}),p&&c(),y&&It(l2,{onClose:()=>E(!1),libraryItems:B8(s.libraryItems,o),appState:a,onSuccess:M=>k(M,s.libraryItems),onError:M=>window.alert(M),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:M=>i(o.filter(R=>R!==M))}),w&&C()]})},T2=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=Fe(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=Si(),a=fe(),l=ce(),[s]=se(Yo),d=async c=>{let p=c.filter(u=>!e.includes(u.id));n.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return It(F8,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>d(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as V8,useEffect as X8,useState as K8}from"react";import O8,{useCallback as z8}from"react";function H8(){return[!1,z8(o=>o(),[])]}var I2=O8.useTransition||H8;import C2 from"clsx";import{memo as G8,useRef as U8,useState as Y8}from"react";import{jsx as Vc,jsxs as W8}from"react/jsx-runtime";var S2=G8(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=U8(null),d=_c(e,o,l,s),[m,c]=Y8(!1),p=me().editor.isMobile,u=t&&Vc("div",{className:"library-unit__adder",children:$1});return W8("div",{className:C2("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":r,"library-unit--skeleton":!d}),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[Vc("div",{className:C2("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}c(!1),a(e,f)}}),u,e&&o&&(m||p||r)&&Vc(Oa,{checked:r,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),k2=()=>Vc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as Z8,jsx as Xc}from"react/jsx-runtime";var Kc=({children:e})=>Xc("div",{className:"library-menu-items-container__grid",children:e}),il=V8(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=I2(),[s,d]=K8(0);return X8(()=>{s<e.length&&l(()=>{d(s+a)})},[s,e.length,l,a]),Xc(Z8,{children:e.map((m,c)=>c<s?Xc(S2,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:r,svgCache:i,id:m?.id,selected:n(m.id),onToggle:o,onDrag:t},m?.id??c):Xc(k2,{},c))})});import ph from"clsx";import{forwardRef as J8,useRef as Q8,useImperativeHandle as e7,useLayoutEffect as t7,useState as o7}from"react";import $8 from"clsx";import{composeEventHandlers as j8}from"@excalidraw/common";import{jsx as q8}from"react/jsx-runtime";var xt=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>q8("button",{onClick:j8(i.onClick,a=>{o()}),type:e,className:$8("excalidraw-button",r,{selected:t}),...i,children:n});import{jsx as uh,jsxs as M2}from"react/jsx-runtime";var Tn=J8(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:d,type:m,...c},p)=>{let u=Q8(null);e7(p,()=>u.current),t7(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[f,b]=o7(!1);return M2("div",{className:ph("ExcTextField",d,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{u.current?.focus()},children:[s,o&&uh("div",{className:"ExcTextField__label",children:o}),M2("div",{className:ph("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[uh("input",{className:ph({"is-redacted":"value"in c&&c.value&&l&&!f}),readOnly:r,value:"value"in c?c.value:void 0,defaultValue:"defaultValue"in c?c.defaultValue:void 0,placeholder:n,ref:u,onChange:x=>e?.(x.target.value),onKeyDown:a,type:m}),l&&uh(xt,{onSelect:()=>b(!f),style:{border:0,userSelect:"none"},children:f?gb:Ur})]})]})});import{Fragment as A2,jsx as Qe,jsxs as Io}from"react/jsx-runtime";var s7=17,c7=64;function fh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:d}){let m=me(),c=L2(null),p=t2(c);hh(()=>{p>0&&c.current?.scrollTo(0,p)},[]);let{svgCache:u}=Si(),[f,b]=P2(null),[x,y]=P2(""),E=!o.length&&!r.length,w=!E&&!!x.trim(),v=gh(()=>{let F=pr(x.trim().toLowerCase());return F?o.filter(W=>{let q=W.name||"";return q.trim()&&pr(q.toLowerCase()).includes(F)}):[]},[o,x]),C=gh(()=>o.filter(F=>F.status!=="published"),[o]),k=gh(()=>o.filter(F=>F.status==="published"),[o]),P=Ai((F,W)=>{let q=!d.includes(F),ye=[...C,...k];if(q){if(W.shiftKey&&f){let Z=ye.findIndex(to=>to.id===f),ie=ye.findIndex(to=>to.id===F);if(Z===-1||ie===-1){s([...d,F]);return}let Ce=r7(d),Lt=Math.min(Z,ie),Pt=Math.max(Z,ie),tn=ye.reduce((to,on,kr)=>((kr>=Lt&&kr<=Pt||Ce.has(on.id))&&to.push(on.id),to),[]);s(tn)}else s([...d,F]);b(F)}else b(null),s(d.filter(Z=>Z!==F))},[f,s,k,d,C]);hh(()=>{d.length||b(null)},[d]);let S=Ai(F=>{let W;return d.includes(F)?W=o.filter(q=>d.includes(q.id)):W=o.filter(q=>q.id===F),W.map(q=>({...q,elements:a7({type:"everything",elements:q.elements,randomizeSeed:!0}).duplicatedElements}))},[o,d]),_=Ai((F,W)=>{let q={itemIds:d.includes(F)?d:[F]};W.dataTransfer.setData(n7.excalidrawlibIds,JSON.stringify(q))},[d]),M=Ai(F=>F?d.includes(F):!1,[d]),R=Ai(()=>{t(r)},[r,t]),O=Ai(F=>{F&&n(S(F))},[S,n]),V=u.size>=(v.length?v:o).length?c7:s7,j=L2(null);hh(()=>{i7(()=>{j.current?.focus()})},[]);let A=!w&&Io(A2,{children:[!E&&Qe("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),!r.length&&!C.length?Io("div",{className:"library-menu-items__no-items",children:[!k.length&&Qe("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),Qe("div",{className:"library-menu-items__no-items__hint",children:k.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):Io(Kc,{children:[r.length>0&&Qe(il,{itemsRenderedPerBatch:V,items:[{id:null,elements:r}],onItemSelectToggle:P,onItemDrag:_,onClick:R,isItemSelected:M,svgCache:u}),Qe(il,{itemsRenderedPerBatch:V,items:C,onItemSelectToggle:P,onItemDrag:_,onClick:O,isItemSelected:M,svgCache:u})]}),k.length>0&&Qe("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:g("labels.excalidrawLib")}),k.length>0&&Qe(Kc,{children:Qe(il,{itemsRenderedPerBatch:V,items:k,onItemSelectToggle:P,onItemDrag:_,onClick:O,isItemSelected:M,svgCache:u})})]}),N=w&&Io(A2,{children:[Io("div",{className:"library-menu-items-container__header",children:[g("library.search.heading"),!e&&Io("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:F=>F.preventDefault(),onClick:F=>{y("")},children:[Qe("kbd",{children:"esc"})," to clear"]})]}),v.length>0?Qe(Kc,{children:Qe(il,{itemsRenderedPerBatch:V,items:v,onItemSelectToggle:P,onItemDrag:_,onClick:O,isItemSelected:M,svgCache:u})}):Io("div",{className:"library-menu-items__no-items",children:[Qe("div",{className:"library-menu-items__no-items__hint",children:g("library.search.noResults")}),Qe(xt,{onPointerDown:F=>F.preventDefault(),onSelect:()=>{y("")},style:{width:"auto",marginTop:"1rem"},children:g("library.search.clearSearch")})]})]});return Io("div",{className:"library-menu-items-container",style:r.length||C.length||k.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[Io("div",{className:"library-menu-items-header",children:[!E&&Qe(Tn,{ref:j,type:"search",className:l7("library-menu-items-container__search",{hideCancelButton:!m.editor.isMobile}),placeholder:g("library.search.inputPlaceholder"),value:x,onChange:F=>y(F)}),Qe(T2,{selectedItems:d,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),Io(Je.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:k.length>0?1:"0 1 auto",margin:E?"auto":0},ref:c,children:[e&&Qe("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Qe(rt,{})}),A,N,E&&Qe(Fc,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i})]})]})}import{jsx as In,jsxs as R2}from"react/jsx-runtime";var Li=ue(!1),_2=({children:e})=>In("div",{className:"layer-ui__library",children:e}),x7=F2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:d})=>{let[m]=se(Yo),c=xh(f=>{(async(x,y)=>{ae("element","addToLibrary","ui");for(let w of m7)if(x.some(v=>v.type===w))return n({errorMessage:g(`errors.libraryElementTypeError.${w}`)});let E=[{status:"unpublished",elements:x,id:p7(),created:Date.now()},...y];t(),i.setLibrary(E).catch(()=>{n({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[t,i,n,m.libraryItems]),p=B2(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return In(_2,{children:In("div",{className:"layer-ui__library-message",children:R2("div",{children:[In(rt,{size:"2em"}),In("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return R2(_2,{children:[In(fh,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:c,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:r,theme:l,onSelectItems:d,selectedItems:s}),u&&In(Fc,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),bh=(e,o)=>({elements:e,pending:J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),E7=(e,o)=>{let t=pn(),[n,r]=N2(()=>bh(t,e.selectedElementIds)),i=d7(new Map);return Eh(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),Eh(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(a=>{if(!u7(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),bh(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let d=l.get(s)?.version;if(d&&d!==i.current.get(s))return bh(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},O2=F2(()=>{let e=Fe(),{onInsertElements:o}=e,t=yo(),n=fe(),r=ce(),[i,a]=N2([]),l=B2(()=>e.library,[e.library]),s=E7(n,e);Eh(()=>f7(document,b7.KEYDOWN,c=>{if(c.key===h7.ESCAPE&&c.target instanceof HTMLElement){let p=c.target;if(p.closest(`.${D2.SIDEBAR}`))i.length>0?(c.stopPropagation(),a([])):g7(p)&&p instanceof HTMLInputElement&&!p.value&&(c.stopPropagation(),r({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:u,y:f}=e.lastViewportPosition;document.elementFromPoint(u,f)?.closest(`.${D2.SIDEBAR}`)&&(c.stopPropagation(),a([]))}}},{capture:!0}),[i,r,e]);let d=xh(c=>{o(Mi(c)),e.focusContainer()},[o,e]),m=xh(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return In(x7,{pendingElements:s,onInsertLibraryItems:d,onAddToLibrary:m,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import y7 from"clsx";import{useRef as w7}from"react";import{createPortal as v7}from"react-dom";import{KEYS as T7}from"@excalidraw/common";import{jsx as z2,jsxs as I7}from"react/jsx-runtime";var H2=e=>{let{closeOnClickOutside:o=!0}=e,t=_s({className:"excalidraw-modal-container"}),n=w7(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===T7.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return v7(I7("div",{className:y7("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[z2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),z2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as al,jsxs as P7}from"react/jsx-runtime";function L7(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var ze=e=>{let[o,t]=Gy(),[n]=k7(document.activeElement),{id:r}=Be(),i=me().viewport.isMobile;S7(()=>{if(!o)return;let d=G2(o);setTimeout(()=>{d.length>0&&e.autofocus!==!1&&(d[1]||d[0]).focus()});let m=c=>{if(c.key===M7.TAB){let p=G2(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&c.shiftKey?(p[p.length-1].focus(),c.preventDefault()):f===p.length-1&&!c.shiftKey&&(p[0].focus(),c.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=ce(),l=ln(Li),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return al(H2,{className:C7("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:L7(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:P7(We,{ref:t,children:[e.title&&al("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:al("span",{className:"Dialog__titleContent",children:e.title})}),i&&al("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Gt}),al("div",{className:"Dialog__content",children:e.children})]})})};import{KEYS as He}from"@excalidraw/common";var Zc=[{icon:Gm,value:"selection",key:He.V,numericKey:He[1],fillable:!0},{icon:ss,value:"rectangle",key:He.R,numericKey:He[2],fillable:!0},{icon:cs,value:"diamond",key:He.D,numericKey:He[3],fillable:!0},{icon:ds,value:"ellipse",key:He.O,numericKey:He[4],fillable:!0},{icon:n0,value:"arrow",key:He.A,numericKey:He[5],fillable:!0},{icon:ms,value:"line",key:He.L,numericKey:He[6],fillable:!0},{icon:sn,value:"freedraw",key:[He.P,He.X],numericKey:He[7],fillable:!1},{icon:Fr,value:"text",key:He.T,numericKey:He[8],fillable:!1},{icon:a0,value:"image",key:null,numericKey:He[9],fillable:!1},{icon:l0,value:"eraser",key:He.E,numericKey:He[0],fillable:!1}],yh=e=>e.defaultSelectionTool==="lasso"?[{value:"lasso",icon:Gm,key:He.V,numericKey:He[1],fillable:!0},...Zc.slice(1)]:Zc,U2=(e,o)=>yh(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 ll from"clsx";import{useState as _7}from"react";import*as So from"@radix-ui/react-popover";import{CLASSES as K2,KEYS as W2,capitalizeString as Th,isTransparent as $c}from"@excalidraw/common";import{shouldAllowVerticalAlign as Z2,suppportsHorizontalAlign as $2}from"@excalidraw/element";import{hasBoundTextElement as jc,isElbowArrow as j2,isImageElement as q2,isLinearElement as J2,isTextElement as Ch,isArrowElement as V2}from"@excalidraw/element";import{hasStrokeColor as X2,toolIsArrow as qc}from"@excalidraw/element";import{createIsolation as A7}from"jotai-scope";import wh from"react";import Co from"tunnel-rat";var vh=wh.createContext(null),Se=()=>wh.useContext(vh),D7=A7(),Y2=()=>wh.useMemo(()=>({MainMenuTunnel:Co(),WelcomeScreenMenuHintTunnel:Co(),WelcomeScreenToolbarHintTunnel:Co(),WelcomeScreenHelpHintTunnel:Co(),WelcomeScreenCenterTunnel:Co(),FooterCenterTunnel:Co(),DefaultSidebarTriggerTunnel:Co(),DefaultSidebarTabTriggersTunnel:Co(),OverwriteConfirmDialogTunnel:Co(),TTDDialogTriggerTunnel:Co(),tunnelsJotai:D7}),[]);import{Fragment as Ot,jsx as ee,jsxs as pe}from"react/jsx-runtime";var Ih=ll([K2.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),Jc=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return X2(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>X2(n.type))},Qc=(e,o)=>bo(e.activeTool.type)||o.some(t=>bo(t.type)),ed=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=aa(o,e),i=!1;r.length===2&&(jc(r[0])||jc(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=me(),s=document.documentElement.getAttribute("dir")==="rtl",d=bo(e.activeTool.type)&&!$c(e.currentItemBackgroundColor)||r.some(f=>bo(f.type)&&!$c(f.backgroundColor)),m=r.length===1||i,c=!e.selectedLinearElement?.isEditing&&r.length===1&&J2(r[0])&&!j2(r[0]),p=!e.croppingElementId&&r.length===1&&q2(r[0]),u=!i&&ft(e,n);return pe("div",{className:"selected-shape-actions",children:[ee("div",{children:Jc(e,r)&&t("changeStrokeColor")}),Qc(e,r)&&ee("div",{children:t("changeBackgroundColor")}),d&&t("changeFillStyle"),($n(e.activeTool.type)||r.some(f=>$n(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(jn(e.activeTool.type)||r.some(f=>jn(f.type)))&&pe(Ot,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(qn(e.activeTool.type)||r.some(f=>qn(f.type)))&&ee(Ot,{children:t("changeRoundness")}),(qc(e.activeTool.type)||r.some(f=>qc(f.type)))&&ee(Ot,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(Ch))&&pe(Ot,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||$2(r,o))&&t("changeTextAlign")]}),Z2(r,o)&&t("changeVerticalAlign"),(Mr(e.activeTool.type)||r.some(f=>Mr(f.type)))&&ee(Ot,{children:t("changeArrowhead")}),t("changeOpacity"),pe("fieldset",{children:[ee("legend",{children:g("labels.layers")}),pe("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&pe("fieldset",{children:[ee("legend",{children:g("labels.align")}),pe("div",{className:"buttonList",children:[s?pe(Ot,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):pe(Ot,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),ee("div",{style:{flexBasis:"100%",height:0}}),pe("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&&pe("fieldset",{children:[ee("legend",{children:g("labels.actions")}),pe("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),p&&t("cropEditor"),c&&t("toggleLinearEditor")]})]})]})},Q2=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=aa(o,e),{saveCaretPosition:a,restoreCaretPosition:l}=Jb(),{container:s}=Be(),d=!!(e.editingTextElement||e.newElement),m=bo(e.activeTool.type)&&!$c(e.currentItemBackgroundColor)||i.some(y=>bo(y.type)&&!$c(y.backgroundColor)),c=i.length===1,p=!e.selectedLinearElement?.isEditing&&i.length===1&&J2(i[0])&&!j2(i[0]),u=!e.croppingElementId&&i.length===1&&q2(i[0]),f=ft(e,n),b=!1;i.length===2&&(jc(i[0])||jc(i[1]))&&(b=!0);let x=document.documentElement.getAttribute("dir")==="rtl";return pe("div",{className:"compact-shape-actions",children:[Jc(e,i)&&ee("div",{className:ll("compact-action-item"),children:t("changeStrokeColor")}),Qc(e,i)&&ee("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),(m||$n(e.activeTool.type)||i.some(y=>$n(y.type))||jn(e.activeTool.type)||i.some(y=>jn(y.type))||qn(e.activeTool.type)||i.some(y=>qn(y.type)))&&ee("div",{className:"compact-action-item",children:pe(So.Root,{open:e.openPopup==="compactStrokeStyles",onOpenChange:y=>{r(y?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[ee(So.Trigger,{asChild:!0,children:ee("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.stroke"),onClick:y=>{y.preventDefault(),y.stopPropagation(),r({openPopup:e.openPopup==="compactStrokeStyles"?null:"compactStrokeStyles"})},children:Nb})}),e.openPopup==="compactStrokeStyles"&&ee(Bo,{className:Ih,container:s,style:{maxWidth:"13rem"},onClose:()=>{},children:pe("div",{className:"selected-shape-actions",children:[m&&t("changeFillStyle"),($n(e.activeTool.type)||i.some(y=>$n(y.type)))&&t("changeStrokeWidth"),(jn(e.activeTool.type)||i.some(y=>jn(y.type)))&&pe(Ot,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(qn(e.activeTool.type)||i.some(y=>qn(y.type)))&&t("changeRoundness"),t("changeOpacity")]})})]})}),(qc(e.activeTool.type)||i.some(y=>qc(y.type)))&&ee("div",{className:"compact-action-item",children:pe(So.Root,{open:e.openPopup==="compactArrowProperties",onOpenChange:y=>{r(y?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[ee(So.Trigger,{asChild:!0,children:ee("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.arrowtypes"),onClick:y=>{y.preventDefault(),y.stopPropagation(),r({openPopup:e.openPopup==="compactArrowProperties"?null:"compactArrowProperties"})},children:(()=>{let y=st(i,n,E=>V2(E)?E.elbowed?"elbow":E.roundness?"round":"sharp":null,E=>V2(E),E=>E?null:e.currentItemArrowType);return y==="elbow"?Wr:y==="round"?Vr:Yr})()})}),e.openPopup==="compactArrowProperties"&&ee(Bo,{container:s,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:t("changeArrowProperties")})]})}),p&&ee("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(Ch))&&pe(Ot,{children:[ee("div",{className:"compact-action-item",children:t("changeFontFamily")}),ee("div",{className:"compact-action-item",children:pe(So.Root,{open:e.openPopup==="compactTextProperties",onOpenChange:y=>{y?(e.editingTextElement&&a(),r({openPopup:"compactTextProperties"})):(r({openPopup:null}),e.editingTextElement&&l())},children:[ee(So.Trigger,{asChild:!0,children:ee("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.textAlign"),onClick:y=>{y.preventDefault(),y.stopPropagation(),e.openPopup==="compactTextProperties"?r({openPopup:null}):(e.editingTextElement&&a(),r({openPopup:"compactTextProperties"}))},children:i0})}),e.openPopup==="compactTextProperties"&&ee(Bo,{className:Ih,container:s,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:pe("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||i.some(Ch))&&t("changeFontSize"),(e.activeTool.type==="text"||$2(i,o))&&t("changeTextAlign"),Z2(i,o)&&t("changeVerticalAlign")]})})]})})]}),!d&&i.length>0&&ee("div",{className:"compact-action-item",children:t("duplicateSelection")}),!d&&i.length>0&&ee("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),!d&&i.length>0&&ee("div",{className:"compact-action-item",children:pe(So.Root,{open:e.openPopup==="compactOtherProperties",onOpenChange:y=>{r(y?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[ee(So.Trigger,{asChild:!0,children:ee("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.actions"),onClick:y=>{y.preventDefault(),y.stopPropagation(),r({openPopup:e.openPopup==="compactOtherProperties"?null:"compactOtherProperties"})},children:q1})}),e.openPopup==="compactOtherProperties"&&ee(Bo,{className:Ih,container:s,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:pe("div",{className:"selected-shape-actions",children:[pe("fieldset",{children:[ee("legend",{children:g("labels.layers")}),pe("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),f&&!b&&pe("fieldset",{children:[ee("legend",{children:g("labels.align")}),pe("div",{className:"buttonList",children:[x?pe(Ot,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):pe(Ot,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),i.length>2&&t("distributeHorizontally"),ee("div",{style:{flexBasis:"100%",height:0}}),pe("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),i.length>2&&t("distributeVertically")]})]})]}),pe("fieldset",{children:[ee("legend",{children:g("labels.actions")}),pe("div",{className:"buttonList",children:[t("group"),t("ungroup"),c&&t("hyperlink"),u&&t("cropEditor")]})]})]})})]})})]})},td=({activeTool:e,appState:o,app:t,UIOptions:n})=>{let[r,i]=_7(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso"&&t.defaultSelectionTool!=="lasso",d=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=Se();return pe(Ot,{children:[yh(t).map(({value:c,icon:p,key:u,numericKey:f,fillable:b},x)=>{if(n.tools?.[c]===!1)return null;let y=g(`toolBar.${c}`),E=u&&Th(typeof u=="string"?u:u[0]),w=E?`${E} ${g("helpDialog.or")} ${f}`:`${f}`;return ee(K,{className:ll("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===c,name:"editor-current-shape",title:`${Th(y)} \u2014 ${w}`,keyBindingLabel:f||E,"aria-label":Th(y),"aria-keyshortcuts":w,"data-testid":`toolbar-${c}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),c==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==c&&ae("toolbar",c,"ui"),c==="image"?t.setActiveTool({type:c}):t.setActiveTool({type:c})}},c)}),ee("div",{className:"App-toolbar__divider"}),pe(be,{open:r,children:[ee(be.Trigger,{className:ll("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||d||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!r),title:g("toolBar.extraTools"),children:a?tr:d?Wm:l&&!t.props.isCollaborating?xa:s?pa:ub}),pe(be.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[ee(be.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:tr,shortcut:W2.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:g("toolBar.frame")}),ee(be.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:Wm,"data-testid":"toolbar-embeddable",selected:d,children:g("toolBar.embeddable")}),ee(be.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:xa,"data-testid":"toolbar-laser",selected:l,shortcut:W2.K.toLocaleUpperCase(),children:g("toolBar.laser")}),t.defaultSelectionTool!=="lasso"&&ee(be.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:pa,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),ee("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&ee(m.Out,{}),ee(be.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:ys,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&ee(Ot,{children:pe(be.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:ws,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),ee(be.Item.Badge,{children:"AI"})]})})]})]})]})},ew=({renderAction:e,zoom:o})=>ee(Je.Col,{gap:1,className:K2.ZOOM_ACTIONS,children:pe(Je.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),tw=({renderAction:e,className:o})=>pe("div",{className:`undo-redo-buttons ${o}`,children:[ee("div",{className:"undo-button-container",children:ee(Rt,{label:g("buttons.undo"),children:e("undo")})}),ee("div",{className:"redo-button-container",children:pe(Rt,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),ow=({actionManager:e,showExitZenModeBtn:o})=>ee("button",{type:"button",className:ll("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(bi),children:g("buttons.exitZenMode")});import{useRef as R7}from"react";var Sh=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 B7,jsxs as N7}from"react/jsx-runtime";var hr=ue(null),nw=()=>{let[e,o]=se(hr),t=Ve();return e&&e==="clearCanvas"?B7(zc,{onConfirm:()=>{t.executeAction(Go),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:N7("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var kh={};b1(kh,{toggleTheme:()=>F7});var F7={...ir,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(ir,"commandPalette")}};import{jsx as et,jsxs as ko}from"react/jsx-runtime";var Y7=ue(null),Le={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},iw=e=>{switch(e){case Le.app:return 1;case Le.export:return 2;case Le.editor:return 3;case Le.tools:return 4;case Le.elements:return 5;case Le.links:return 6;default:return 10}},rd=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return ko("div",{className:lw("shortcut",o),children:[n.map((r,i)=>et("div",{className:"shortcut-wrapper",children:et("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),et("div",{className:"shortcut-desc",children:t})]})},cw=e=>!e.altKey&&e[mo.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===mo.P||e.key===mo.SLASH),zde=Object.assign(e=>{let o=fe(),t=ce();return nd(()=>{let n=r=>{cw(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ae("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(id.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(id.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:et(W7,{...e})},{defaultItems:kh});function W7({customCommandPaletteItems:e}){let o=Fe(),t=fe(),n=ce(),r=yo(),i=Ve(),[a,l]=se(Y7),[s,d]=od(null),m=sw(null),c=cn({uiAppState:t,customCommandPaletteItems:e,appProps:r}),[p]=se(Yo),u=z7(()=>p.libraryItems?.filter(S=>!!S.name).map(S=>({label:S.name,icon:et(V7,{id:S.id,elements:S.elements}),category:"Library",order:iw("Library"),haystack:pr(S.name),perform:()=>{o.onInsertElements(Mi([S]))}}))||[],[o,p.libraryItems]);nd(()=>{let{uiAppState:S,customCommandPaletteItems:_,appProps:M}=c,R=A=>{let N="";return A.label&&(typeof A.label=="function"?N=g(A.label(o.scene.getNonDeletedElements(),S,o)):N=g(A.label)),N},O=A=>typeof A.icon=="function"?A.icon(S,o.scene.getNonDeletedElements()):A.icon,V=[],j=(A,N,F)=>{let W={label:R(A),icon:O(A),category:N,shortcut:Oe(A.name),keywords:A.keywords,predicate:A.predicate,viewMode:A.viewMode,perform:()=>{i.executeAction(A,"commandPalette")}};return F?F(W,A):W};if(S&&o.scene&&i){let A=[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,$a,Dc,zy].map(Z=>j(Z,Le.elements,(ie,Ce)=>({...ie,predicate:Ce.predicate?Ce.predicate:(Lt,Pt,tn,to)=>J(Lt,Pt).length>0}))),N=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(Z=>j(Z,Le.tools)),F=[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(Z=>j(Z,Le.editor)),W=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(Z=>j(Z,Le.export));V=[...A,...F,{label:R(Go),icon:O(Go),shortcut:Oe(Go.name),category:Le.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Ye.set(hr,"clearCanvas")}},{label:g("buttons.exportImage"),category:Le.export,icon:gs,shortcut:Oe("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...W];let q=[{label:g("toolBar.library"),category:Le.app,icon:Nr,viewMode:!1,perform:()=>{S.openSidebar?n({openSidebar:null}):n({openSidebar:{name:rw.name,tab:rw.defaultTab}})}},{label:g("search.title"),category:Le.app,icon:Dt,viewMode:!0,perform:()=>{i.executeAction(sl)}},{label:g("labels.shapeSwitch"),category:Le.elements,icon:Ea,perform:()=>{i.executeAction(Oy)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Le.elements,icon:hs,viewMode:!1,predicate:(Z,ie)=>{let Ce=J(Z,ie);return Ce.length>0&&Jc(ie,Ce)},perform:()=>{n(Z=>({openMenu:Z.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:hs,category:Le.elements,viewMode:!1,predicate:(Z,ie)=>{let Ce=J(Z,ie);return Ce.length>0&&Qc(ie,Ce)},perform:()=>{n(Z=>({openMenu:Z.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:hs,category:Le.editor,viewMode:!1,perform:()=>{n(Z=>({openMenu:Z.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Zc.reduce((Z,ie)=>{let{value:Ce,icon:Lt,key:Pt,numericKey:tn}=ie;if(M.UIOptions.tools?.[Ce]===!1)return Z;let on=Pt&&H7(typeof Pt=="string"?Pt:Pt[0])||tn,kr={label:g(`toolBar.${Ce}`),category:Le.tools,shortcut:on,icon:Lt,keywords:["toolbar"],viewMode:!1,perform:({event:Kl})=>{Ce==="image"?o.setActiveTool({type:Ce}):o.setActiveTool({type:Ce})}};return Z.push(kr),Z},[]),...N,{label:g("toolBar.lock"),category:Le.tools,icon:S.activeTool.locked?Br:Jn,shortcut:mo.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Le.tools,icon:bb,viewMode:!1,predicate:M.aiEnabled,perform:()=>{n(Z=>({...Z,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Le.tools,icon:ys,viewMode:!1,predicate:M.aiEnabled,perform:()=>{n(Z=>({...Z,openDialog:{name:"ttd",tab:"mermaid"}}))}}],ye=[...V,...q,..._||[]].map(Z=>({...Z,icon:Z.icon||Ea,order:Z.order??iw(Z.category),haystack:`${pr(Z.label.toLocaleLowerCase())} ${Z.keywords?.join(" ")||""}`}));d(ye),l([...ye,...u].find(Z=>Z.label===a?.label)??null)}},[c,o,i,d,a?.label,l,n,u]);let[f,b]=od(""),[x,y]=od(null),[E,w]=od({}),v=S=>{n({openDialog:null},S),b("")},C=(S,_)=>{t.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),v(()=>{S.perform({actionManager:i,event:_}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},k=Sh(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),P=Sh(S=>{let _=U7(S.target)||cw(S)||S.key===mo.ESCAPE;if(_&&S.key!==mo.ARROW_UP&&S.key!==mo.ARROW_DOWN&&S.key!==mo.ENTER)return;let M=Object.values(E).flat(),R=a&&!f&&k(a);if(S.key===mo.ARROW_UP){S.preventDefault();let O=M.findIndex(A=>A.label===x?.label);if(R){if(O===0){y(a);return}if(x===a){let A=M[M.length-1];A&&y(A);return}}let V;O===-1?V=M.length-1:V=O===0?M.length-1:(O-1)%M.length;let j=M[V];j&&y(j);return}if(S.key===mo.ARROW_DOWN){S.preventDefault();let O=M.findIndex(A=>A.label===x?.label);if(R){if(!x||O===M.length-1){y(a);return}if(x===a){let A=M[0];A&&y(A);return}}let V=(O+1)%M.length,j=M[V];j&&y(j);return}if(S.key===mo.ENTER&&x&&setTimeout(()=>{C(x,S)}),!_){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return nd(()=>(window.addEventListener(id.KEYDOWN,P,{capture:!0}),()=>window.removeEventListener(id.KEYDOWN,P,{capture:!0})),[P]),nd(()=>{if(!s)return;let S=O=>{let V={};for(let j of O)V[j.category]?V[j.category].push(j):V[j.category]=[j];return V},_=f?.length>1?[...s,...u]:s.filter(k).sort((O,V)=>O.order-V.order),M=!f&&a&&k(a);if(!f){w(S(M?_.filter(O=>O.label!==a?.label):_)),y(M?a:_[0]||null);return}let R=pr(f.toLocaleLowerCase().replace(/[<>_| -]/g,""));_=O7.filter(R,_,{extract:O=>O.haystack??""}).sort((O,V)=>V.score-O.score).map(O=>O.original),w(S(_)),y(_[0]??null)},[f,s,k,a,u]),ko(ze,{onCloseRequest:()=>v(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[et(Tn,{value:f,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{b(S)},selectOnRender:!0,ref:m}),!o.device.viewport.isMobile&&ko("div",{className:"shortcuts-wrapper",children:[et(rd,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),et(rd,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),et(rd,{shortcut:G7("Esc"),children:g("commandPalette.shortcuts.close")})]}),ko("div",{className:"commands",children:[a&&!f&&ko("div",{className:"command-category",children:[ko("div",{className:"command-category-title",children:[g("commandPalette.recents"),et("div",{className:"icon",style:{marginLeft:"6px"},children:xb})]}),et(aw,{command:a,isSelected:a.label===x?.label,onClick:S=>C(a,S),disabled:!k(a),onMouseMove:()=>y(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(E).length>0?Object.keys(E).map((S,_)=>ko("div",{className:"command-category",children:[et("div",{className:"command-category-title",children:S}),E[S].map(M=>et(aw,{command:M,isSelected:M.label===x?.label,onClick:R=>C(M,R),onMouseMove:()=>y(M),showShortcut:!o.device.viewport.isMobile,appState:t,size:S==="Library"?"large":"small"},M.label))]},S)):s?ko("div",{className:"no-match",children:[et("div",{className:"icon",children:Dt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var V7=({id:e,elements:o})=>{let t=sw(null),{svgCache:n}=Si();return _c(e,o,n,t),et("div",{className:"library-item-icon",ref:t})},aw=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:a,size:l="small"})=>{let s=()=>{};return ko("div",{className:lw("command-item",{"item-selected":o,"item-disabled":t,"command-item-large":l==="large"}),ref:d=>{o&&!t&&d?.scrollIntoView?.({block:"nearest"})},onClick:t?s:r,onMouseMove:t?s:n,title:t?g("commandPalette.itemNotAvailable"):"",children:[ko("div",{className:"name",children:[e.icon&&et(fn,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(a):e.icon}),et(Pa,{children:e.label})]}),i&&e.shortcut&&et(rd,{shortcut:e.shortcut})]})};import{getSizeFromPoints as R0e,randomInteger as YD,getUpdatedTimestamp as WD}from"@excalidraw/common";import{simplify as _D}from"points-on-curve";import{pointsOnBezierCurves as Wde}from"points-on-curve";import{invariant as Xde}from"@excalidraw/common";import{curve as Zde,lineSegment as $de,pointFrom as jde,pointDistance as qde,pointFromArray as Jde,pointFromVector as Qde,pointRotateRads as eme,polygon as tme,polygonFromPoints as ome,PRECISION as nme,segmentsIntersectAt as rme,vector as ime,vectorAdd as ame,vectorFromPoint as lme,vectorScale as sme}from"@excalidraw/math";import{getElementAbsoluteCoords as dme}from"@excalidraw/element";var Mh=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 RD,pointDistance as Aw,pointRotateRads as x0e}from"@excalidraw/math";import{ROUGHNESS as ND,isTransparent as ul,assertNever as BD,COLOR_PALETTE as FD,LINE_POLYGON_POINT_MERGE_DISTANCE as y0e}from"@excalidraw/common";import{RoughGenerator as OD}from"roughjs/bin/generator";import A1e from"roughjs/bin/rough";import{getStroke as CD}from"perfect-freehand";import{isRightAngleRads as R1e,lineSegment as N1e,pointFrom as B1e,pointRotateRads as F1e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as z1e,DEFAULT_REDUCED_GLOBAL_ALPHA as H1e,ELEMENT_READY_TO_ERASE_OPACITY as G1e,FRAME_STYLE as U1e,MIME_TYPES as kw,THEME as Y1e,distance as W1e,getFontString as V1e,isRTL as X1e,getVerticalOffset as K1e,invariant as Z1e}from"@excalidraw/common";import Yge from"roughjs/bin/rough";import{arrayToMap as Vge,invariant as Ew,rescalePoints as Xge,sizeOf as Kge}from"@excalidraw/common";import{degreesToRadians as zh,lineSegment as $ge,pointDistance as jge,pointFrom as it,pointFromArray as cD,pointRotateRads as Bi}from"@excalidraw/math";import{pointsOnBezierCurves as Qge}from"points-on-curve";import{pointCenter as lge,pointFrom as sge,pointRotateRads as cge,pointsEqual as dge,pointDistance as mge,vectorFromPoint as pge,curveLength as uge,curvePointAtLength as hge}from"@excalidraw/math";import{DRAGGING_THRESHOLD as bge,KEYS as xge,shouldRotateWithDiscreteAngle as Ege,getGridPoint as yge,invariant as wge,tupleToCoors as vge,viewportCoordsToSceneCoords as Tge}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as Cge,isPathALoop as Sge}from"@excalidraw/element";import{KEYS as lhe,arrayToMap as she,isBindingFallthroughEnabled as che,tupleToCoors as dhe,invariant as mhe,isDevEnv as phe,isTestEnv as uhe}from"@excalidraw/common";import{lineSegment as ghe,pointFrom as fhe,pointRotateRads as bhe,vectorFromPoint as xhe,pointDistanceSq as Ehe,clamp as yhe,pointDistance as whe,pointFromVector as vhe,vectorScale as The,vectorNormalize as Ihe,vectorCross as Che,pointsEqual as She,lineSegmentIntersectionPoints as khe,PRECISION as Mhe}from"@excalidraw/math";import{isTransparent as Fpe}from"@excalidraw/common";import{curveIntersectLineSegment as zpe,isPointWithinBounds as Hpe,lineSegment as Gpe,lineSegmentIntersectionPoints as Upe,pointFrom as Ype,pointFromVector as Wpe,pointRotateRads as Vpe,pointsEqual as Xpe,vectorFromPoint as Kpe,vectorNormalize as Zpe,vectorScale as $pe}from"@excalidraw/math";import{ellipse as qpe,ellipseSegmentInterceptPoints as Jpe}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as X7,DEFAULT_PROPORTIONAL_RADIUS as Lh,LINE_CONFIRM_THRESHOLD as K7,ROUNDNESS as Ph}from"@excalidraw/common";import{curve as gme,curveCatmullRomCubicApproxPoints as fme,curveOffsetPoints as bme,lineSegment as xme,pointDistance as Z7,pointFrom as Eme,pointFromArray as yme,rectangle as wme}from"@excalidraw/math";var ad=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return Z7(t,n)<=K7/o}return!1},cl=(e,o)=>{if(o.roundness?.type===Ph.PROPORTIONAL_RADIUS||o.roundness?.type===Ph.LEGACY)return e*Lh;if(o.roundness?.type===Ph.ADAPTIVE_RADIUS){let t=o.roundness?.value??X7,n=t/Lh;return e<=n?e*Lh:t}return 0};import{ROUNDNESS as Mme,assertNever as Lme}from"@excalidraw/common";import{pointsEqual as Ame}from"@excalidraw/math";var dw=e=>!!e&&e.type==="embeddable",mw=e=>!!e&&e.type==="iframe",Dh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),gr=e=>e!=null&&e.type==="text";var ld=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var Cn=e=>e!=null&&$7(e.type);var Di=e=>e!=null&&e.type==="arrow",dl=e=>Di(e)&&e.elbowed;var $7=e=>e==="arrow"||e==="line";var _i=e=>e!==null&&"containerId"in e&&e.containerId!==null&&gr(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as ape,ARROW_LABEL_WIDTH_FRACTION as lpe,BOUND_TEXT_PADDING as spe,DEFAULT_FONT_SIZE as cpe,TEXT_ALIGN as dpe,VERTICAL_ALIGN as mpe,getFontString as ppe,isProdEnv as upe,invariant as hpe}from"@excalidraw/common";import{pointFrom as fpe,pointRotateRads as bpe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Fme,DEFAULT_FONT_SIZE as Ome,DEFAULT_FONT_FAMILY as zme,getFontString as Hme,isTestEnv as Gme,normalizeEOL as Ume}from"@excalidraw/common";var Yme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as jme,isTestEnv as qme}from"@excalidraw/common";import{curvePointDistance as Spe,distanceToLineSegment as kpe,pointRotateRads as Mpe}from"@excalidraw/math";import{ellipse as Ppe,ellipseDistanceFromPoint as Ape}from"@excalidraw/math/ellipse";import{invariant as due,isDevEnv as mue,isTestEnv as pue}from"@excalidraw/common";import{pointFrom as hue,pointFromVector as gue,pointRotateRads as fue,pointScaleFromOrigin as bue,pointsEqual as xue,triangleIncludesPoint as Eue,vectorCross as yue,vectorFromPoint as eD,vectorScale as wue}from"@excalidraw/math";var Fh=[1,0],gw=[0,1],Oh=[-1,0],fw=[0,-1],cd=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?Fh:o<=-r?Oh:t>n?gw:fw},bw=(e,o)=>cd(eD(e,o)),dd=(e,o)=>md(bw(e,o)),Bh=(e,o)=>e[0]===o[0]&&e[1]===o[1],md=e=>Bh(e,Fh)||Bh(e,Oh);import{clamp as kue,pointDistance as Mue,pointFrom as Lue,pointScaleFromOrigin as Pue,pointsEqual as Aue,pointTranslate as Due,vector as _ue,vectorCross as Rue,vectorFromPoint as Nue,vectorScale as Bue}from"@excalidraw/math";import{BinaryHeap as Oue,invariant as zue,isAnyTrue as Hue,tupleToCoors as Gue,getSizeFromPoints as Uue,isDevEnv as Yue,arrayToMap as Wue}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Yhe,viewportCoordsToSceneCoords as Whe}from"@excalidraw/common";import{normalizeRadians as Xhe,radiansBetweenAngles as Khe,radiansDifference as Zhe}from"@excalidraw/math";import{pointsEqual as jhe}from"@excalidraw/math";var Ah=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 dD=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}},mD=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Hh=(e,o,t,n)=>{if(o.length<1)return null;let r=Mh(o[0]);if(r.length<1)return null;let i=t==="start"?1:r.length-1,a=r[i].data;Ew(a.length===6,"Op data length is not 6");let l=it(a[4],a[5]),s=it(a[2],a[3]),d=it(a[0],a[1]),m=r[i-1],c=it(0,0);if(m.op==="move"){let A=cD(m.data);Ew(A!=null,"Op data is not a point"),c=A}else m.op==="bcurveTo"&&(c=it(m.data[4],m.data[5]));let p=(A,N)=>Math.pow(1-A,3)*l[N]+3*A*Math.pow(1-A,2)*s[N]+3*Math.pow(A,2)*(1-A)*d[N]+c[N]*Math.pow(A,3),[u,f]=t==="start"?c:l,[b,x]=[p(.3,0),p(.3,1)],y=Math.hypot(u-b,f-x),E=(u-b)/y,w=(f-x)/y,v=dD(n),C=0;{let[A,N]=t==="end"?e.points[e.points.length-1]:e.points[0],[F,W]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(A-F,N-W)}let P=Math.min(v,C*(n==="diamond"||n==="diamond_outline"?.25:.5)),S=u-E*P,_=f-w*P;if(n==="dot"||n==="circle"||n==="circle_outline"){let A=Math.hypot(_-f,S-u)+e.strokeWidth-2;return[u,f,A]}let M=mD(n);if(n==="crowfoot_many"||n==="crowfoot_one_or_many"){let[A,N]=Bi(it(u,f),it(S,_),zh(-M)),[F,W]=Bi(it(u,f),it(S,_),zh(M));return[S,_,A,N,F,W]}let[R,O]=Bi(it(S,_),it(u,f),-M*Math.PI/180),[V,j]=Bi(it(S,_),it(u,f),zh(M));if(n==="diamond"||n==="diamond_outline"){let A,N;if(t==="start"){let[F,W]=e.points.length>1?e.points[1]:[0,0];[A,N]=Bi(it(u+P*2,f),it(u,f),Math.atan2(W-f,F-u))}else{let[F,W]=e.points.length>1?e.points[e.points.length-2]:[0,0];[A,N]=Bi(it(u-P*2,f),it(u,f),Math.atan2(f-W,u-F))}return[u,f,R,O,A,N,V,j]}return[u,f,R,O,V,j]};import{pointFrom as ufe,pointCenter as hfe,pointRotateRads as gfe,vectorFromPoint as ffe,vectorNormalize as bfe,vectorSubtract as xfe,vectorAdd as Efe,vectorScale as yfe,pointFromVector as wfe,clamp as vfe,isCloseTo as Tfe}from"@excalidraw/math";import{arrayToMap as c1e}from"@excalidraw/common";import{isPointWithinBounds as m1e,pointFrom as p1e}from"@excalidraw/math";import{vectorCross as Mfe,vectorFromPoint as Lfe}from"@excalidraw/math";import{arrayToMap as pD}from"@excalidraw/common";import{getElementBounds as uD}from"@excalidraw/element";import{isArrowElement as hD,isExcalidrawElement as gD,isFreeDrawElement as fD,isLinearElement as bD,isTextElement as xD}from"@excalidraw/element";import{rangeIncludesValue as pd,pointFrom as Ko,pointRotateRads as ED,rangeInclusive as ud}from"@excalidraw/math";var yD=e=>e.type==="diamond"?[Ko(e.width/2,0),Ko(e.width,e.height/2),Ko(e.width/2,e.height),Ko(0,e.height/2)]:[Ko(0,0),Ko(0+e.width,0),Ko(0+e.width,e.height),Ko(0,e.height)],wD=e=>bD(e)||fD(e)?e.points:yD(e),ww=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},vw=e=>{let o=wD(e),{cx:t,cy:n}=ww(o),r=Ko(t,n),i=o.map(m=>ED(m,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:d}=ww(i);return[a+e.x,l+e.y,s+e.x,d+e.y]},Gh=(e,o,t=!1)=>{let n=vw(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},Tw=(e,o)=>{let t=vw(e);return(pd(t[0],ud(o[0],o[2]))||pd(o[0],ud(t[0],t[2])))&&(pd(t[1],ud(o[1],o[3]))||pd(o[1],ud(t[1],t[3])))},Iw=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{gD(o)&&(o=uD(o,pD(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"?Tw(a,r):t==="inside"?Gh(a,r):Gh(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);xD(a)&&a.containerId&&i.add(a.containerId),hD(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 Vfe,isShallowEqual as TD}from"@excalidraw/common";var vD=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 d={};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];d[f]=!0}}let m={},c=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>d[b]);return f&&(p[u.id]=!0,Array.isArray(m[f])?m[f].push(u.id):m[f]=[u.id]),p},{});for(let p of Object.keys(m))m[p].length<2&&d[p]&&(d[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:d,selectedElementIds:Uh({...l.selectedElementIds,...c},s)},t},r=(i,a,l,s)=>{let d=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Yh(a,i);return d.length?n(d,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Uh(i.selectedElementIds,l)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var Jfe=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}(),Yh=(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&&_i(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{ld(a)&&Cw(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var Uh=(e,o)=>TD(o.selectedElementIds,e)?o.selectedElementIds:e;var Cw=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var SD=typeof document<"u"?document.createElement("img"):{src:""};SD.src=`data:${kw.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 kD=typeof document<"u"?document.createElement("img"):{src:""};kD.src=`data:${kw.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 Mw=new WeakMap;var MD=new WeakMap([]);function Lw(e){let o=LD(e),t=new Path2D(o);return MD.set(e,t),t}function LD(e){return DD(PD(e))}function PD(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 CD(o,t)}function Sw(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var AD=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function DD(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,n,r,i)=>(r===o?t.push(n,Sw(n,i[0]),"L",i[0],"Z"):t.push(n,Sw(n,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(AD,"$1")}var Pw=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var dt=class dt{};I(dt,"rg",new OD),I(dt,"cache",new WeakMap),I(dt,"get",o=>dt.cache.get(o)),I(dt,"set",(o,t)=>dt.cache.set(o,t)),I(dt,"delete",o=>dt.cache.delete(o)),I(dt,"destroy",()=>{dt.cache=new WeakMap}),I(dt,"generateElementShape",(o,t)=>{let n=t?.isExporting?void 0:dt.get(o);if(n!==void 0)return n;Mw.delete(o);let r=GD(o,dt.rg,t||{isExporting:!1,canvasBackgroundColor:FD.white,embedsValidationStatus:null});return dt.cache.set(o,r),r});var Ni=dt,zD=e=>[8,8+e],Rw=e=>[1.5,6+e];function HD(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&&Pw(e.type)||Cn(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Xo=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?zD(e.strokeWidth):e.strokeStyle==="dotted"?Rw(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:HD(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<ND.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=ul(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"line":case"freedraw":return ad(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}`)}},Dw=(e,o,t)=>Dh(e)&&(o||dw(e)&&t?.get(e.id)!==!0)&&ul(e.backgroundColor)&&ul(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:mw(e)?{...e,strokeColor:ul(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:ul(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,_w=(e,o,t,n,r,i,a)=>{let l=Hh(e,o,t,n);if(l===null)return[];let s=(d,m)=>{if(d===null)return[];let[,,c,p,u,f]=d;return[r.line(c,p,u,f,m)]};switch(n){case"dot":case"circle":case"circle_outline":{let[d,m,c]=l;return delete i.strokeLineDash,[r.circle(d,m,c,{...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[d,m,c,p,u,f]=l;return delete i.strokeLineDash,[r.polygon([[d,m],[c,p],[u,f],[d,m]],{...i,fill:n==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[d,m,c,p,u,f,b,x]=l;return delete i.strokeLineDash,[r.polygon([[d,m],[c,p],[u,f],[b,x],[d,m]],{...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[d,m,c,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=Rw(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(c,p,d,m,i),r.line(u,f,d,m,i),...n==="crowfoot_one_or_many"?s(Hh(e,o,t,"crowfoot_one"),i):[]]}}};var GD=(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=cl(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`,Xo(Dw(e,t,r),!0))}else i=o.rectangle(0,0,e.width,e.height,Xo(Dw(e,t,r),!1));return i}case"diamond":{let i,[a,l,s,d,m,c,p,u]=Ah(e);if(e.roundness){let f=cl(Math.abs(a-p),e),b=cl(Math.abs(d-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${d-b}
|
|
7
|
+
${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var AE=async(e,t,o,n)=>{let{exportBackground:r,viewBackgroundColor:i,fileHandle:a}=t,l=W1(a);if(!a||!V1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:d}=dr(e,t,!1);return await mr(l,s,t,o,{exportBackground:r,viewBackgroundColor:i,name:n,fileHandle:a,exportingFrame:d}),{fileHandle:a}};import{Fragment as HM,jsx as Xo,jsxs as GM}from"react/jsx-runtime";var Eu=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,o)=>({appState:{...t,name:o},captureUpdate:mo.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:o,data:n,app:r})=>Xo(hE,{label:g("labels.fileTitle"),value:r.getName(),onChange:i=>t(i),ignoreFocus:n?.ignoreFocus??!1})}),DE=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,o)=>({appState:{...t,exportScale:o},captureUpdate:mo.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o})=>{let n=zM(e),i=ve(n,t)?Q(n,t):n;return Xo(HM,{children:FM.map(a=>{let[l,s]=U1(i,OM,a),d=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Xo(V,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:d,"aria-label":d,id:"export-canvas-scale",checked:a===t.exportScale,onChange:()=>o(a)},a)})})}}),yu=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,o)=>({appState:{...t,exportBackground:o},captureUpdate:mo.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>Xo(Qa,{checked:e.exportBackground,onChange:o=>t(o),children:g("imageExportDialog.label.withBackground")})}),Tc=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,o)=>({appState:{...t,exportEmbedScene:o},captureUpdate:mo.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>GM(Qa,{checked:e.exportEmbedScene,onChange:o=>t(o),children:[g("imageExportDialog.label.embedScene"),Xo(_t,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Xo("div",{className:"excalidraw-tooltip-icon",children:Sb})})]})}),pr=O({name:"saveToActiveFile",label:"buttons.save",icon:or,trackEvent:{category:"export"},predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,o,n)=>{let r=!!t.fileHandle;try{let{fileHandle:i}=bs(t.fileHandle)?await AE(e,t,n.files,n.getName()):await ps(e,t,n.files,n.getName());return{captureUpdate:mo.EVENTUALLY,appState:{...t,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:mo.EVENTUALLY}}},keyTest:e=>e.key===bi.S&&e[bi.CTRL_OR_CMD]&&!e.shiftKey}),al=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:or,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,o,n)=>{try{let{fileHandle:r}=await ps(e,{...t,fileHandle:null},n.files,n.getName());return{captureUpdate:mo.EVENTUALLY,appState:{...t,openDialog:null,fileHandle:r,toast:{message:g("toast.fileSaved")}}}}catch(r){return r?.name!=="AbortError"?console.error(r):console.warn(r),{captureUpdate:mo.EVENTUALLY}}},keyTest:e=>e.key===bi.S&&e.shiftKey&&e[bi.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Xo(V,{type:"button",icon:wb,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:he().editor.isMobile,hidden:!_r,onClick:()=>e(null),"data-testid":"save-as-button"})}),xi=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,o,n)=>{try{let{elements:r,appState:i,files:a}=await Um(t,e);return{elements:r,appState:i,files:a,captureUpdate:mo.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...t,errorMessage:r.message},files:n.files,captureUpdate:mo.EVENTUALLY}}},keyTest:e=>e[bi.CTRL_OR_CMD]&&e.key===bi.O}),_E=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,o)=>({appState:{...t,exportWithDarkMode:o},captureUpdate:mo.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>Xo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Xo(pE,{value:e.exportWithDarkMode?xu.DARK:xu.LIGHT,onChange:o=>{t(o===xu.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as UM,DEFAULT_FONT_FAMILY as YM,DEFAULT_TEXT_ALIGN as WM,CODES as RE,KEYS as NE,getLineHeight as VM}from"@excalidraw/common";import{newElementWith as Ic}from"@excalidraw/element";import{hasBoundTextElement as XM,canApplyRoundnessTypeToElement as KM,getDefaultRoundnessTypeForElement as ZM,isFrameLikeElement as $M,isArrowElement as jM,isExcalidrawElement as qM,isTextElement as wu}from"@excalidraw/element";import{getBoundTextElement as JM,redrawTextBoundingBox as QM}from"@excalidraw/element";import{CaptureUpdateAction as vu}from"@excalidraw/element";var BE="{}",Tu=O({name:"copyStyles",label:"labels.copyStyles",icon:gp,trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=[],i=e.find(a=>t.selectedElementIds[a.id]);if(r.push(i),i&&XM(i)){let a=JM(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(BE=JSON.stringify(r)),{appState:{...t,toast:{message:g("toast.copyStyles")}},captureUpdate:vu.EVENTUALLY}},keyTest:e=>e[NE.CTRL_OR_CMD]&&e.altKey&&e.code===RE.C}),Iu=O({name:"pasteStyles",label:"labels.pasteStyles",icon:gp,trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=JSON.parse(BE),i=r[0],a=r[1];if(!qM(i))return{elements:e,captureUpdate:vu.EVENTUALLY};let l=Q(e,t,{includeBoundTextElement:!0}),s=l.map(d=>d.id);return{elements:e.map(d=>{if(s.includes(d.id)){let m=i;if(wu(d)&&d.containerId&&(m=a),!m)return d;let c=Ic(d,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?KM(m.roundness.type,d)?m.roundness:ZM(d):null});if(wu(c)){let p=m.fontSize||UM,u=m.fontFamily||YM;c=Ic(c,{fontSize:p,fontFamily:u,textAlign:m.textAlign||WM,lineHeight:m.lineHeight||VM(u)});let f=null;c.containerId&&(f=l.find(b=>wu(c)&&b.id===c.containerId)||null),QM(c,f,n.scene)}return c.type==="arrow"&&jM(m)&&(c=Ic(c,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),$M(d)&&(c=Ic(c,{roundness:null,backgroundColor:"transparent"})),c}return d}),captureUpdate:vu.IMMEDIATELY}},keyTest:e=>e[NE.CTRL_OR_CMD]&&e.altKey&&e.code===RE.V});import{KEYS as eP}from"@excalidraw/common";import{getNonDeletedElements as tP}from"@excalidraw/element";import{showSelectedShapeActions as oP}from"@excalidraw/element";import{CaptureUpdateAction as Cu}from"@excalidraw/element";import{jsx as OE}from"react/jsx-runtime";var nP=O({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},captureUpdate:Cu.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>OE(V,{type:"button",icon:Ss,"aria-label":g("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})}),rP=O({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},captureUpdate:Cu.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o})=>OE(V,{visible:oP(t,tP(e)),type:"button",icon:vb,"aria-label":g("buttons.edit"),onClick:o,selected:t.openMenu==="shape"})}),ur=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:fb,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,o,{focusContainer:n})=>(t.openDialog?.name==="help"&&n(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:Cu.EVENTUALLY}),keyTest:e=>e.key===eP.QUESTION_MARK});import{getNonDeletedElements as Sc}from"@excalidraw/element";import{newElementWith as HE}from"@excalidraw/element";import{isBoundToContainer as iP}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as aP,getElementsInResizingFrame as lP,getFrameLikeElements as sP,getRootElements as cP,groupByFrameLikes as dP,removeElementsFromFrame as mP,replaceAllElementsInFrame as pP}from"@excalidraw/element";import{KEYS as kc,randomId as uP,arrayToMap as Su,getShortcutKey as GE}from"@excalidraw/common";import{getSelectedGroupIds as Cc,selectGroup as hP,selectGroupsForSelectedElements as gP,getElementsInGroup as FE,addToGroup as fP,removeFromSelectedGroups as bP,isElementInGroup as UE}from"@excalidraw/element";import{syncMovedIndices as xP}from"@excalidraw/element";import{CaptureUpdateAction as ll}from"@excalidraw/element";import{jsx as Ei}from"react/jsx-runtime";var EP=e=>{if(e.length>=2){let t=e[0].groupIds;for(let o of t)if(e.reduce((n,r)=>n&&UE(r,o),!0))return!0}return!1},zE=(e,t,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!EP(n)&&!aP(n)},ku=O({name:"group",label:"labels.group",icon:e=>Ei(mp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=cP(n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:t,elements:e,captureUpdate:ll.EVENTUALLY};let i=Cc(t);if(i.length===1){let x=i[0],w=new Set(FE(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:t,elements:e,captureUpdate:ll.EVENTUALLY}}let a=[...e];new Set(r.map(x=>x.frameId)).size>1&&dP(r).forEach((w,E)=>{mP(w,n.scene.getNonDeletedElementsMap())});let s=uP(),d=Su(r);a=a.map(x=>d.get(x.id)?HE(x,{groupIds:fP(x.groupIds,s,t.editingGroupId)}):x);let m=FE(a,s),c=m[m.length-1],p=a.lastIndexOf(c),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!UE(x,s)),b=xP([...f,...m,...u],Su(m));return{appState:{...t,...hP(s,{...t,selectedGroupIds:{}},Sc(a))},elements:b,captureUpdate:ll.IMMEDIATELY}},predicate:(e,t,o,n)=>zE(e,t,n),keyTest:e=>!e.shiftKey&&e[kc.CTRL_OR_CMD]&&e.key===kc.G,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Ei(V,{hidden:!zE(e,t,n),type:"button",icon:Ei(mp,{theme:t.theme}),onClick:()=>o(null),title:`${g("labels.group")} \u2014 ${GE("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:ve(Sc(e),t)})}),Mu=O({name:"ungroup",label:"labels.ungroup",icon:e=>Ei(pp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=Cc(t),i=Su(e);if(r.length===0)return{appState:t,elements:e,captureUpdate:ll.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{iP(p)&&l.push(p.id);let u=bP(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:HE(p,{groupIds:u})});let s=gP(t,Sc(a),t,null),d=n.scene.getSelectedElements(t),m=new Set(d.filter(p=>p.frameId).map(p=>p.frameId));return sP(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=pP(a,lP(a,p,t,i),p,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...s},elements:a,captureUpdate:ll.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[kc.CTRL_OR_CMD]&&e.key===kc.G.toUpperCase(),predicate:(e,t)=>Cc(t).length>0,PanelComponent:({elements:e,appState:t,updateData:o})=>Ei(V,{type:"button",hidden:Cc(t).length===0,icon:Ei(pp,{theme:t.theme}),onClick:()=>o(null),title:`${g("labels.ungroup")} \u2014 ${GE("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:ve(Sc(e),t)})});import SP from"clsx";import{CaptureUpdateAction as KE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as yP,COLOR_VOICE_CALL as wP,COLOR_WHITE as Pc,THEME as vP,UserIdleState as YE}from"@excalidraw/common";var Mc=(e,t,o,n,r,i,a)=>{e.beginPath(),e.moveTo(t+i,o),e.lineTo(t+n-i,o),e.quadraticCurveTo(t+n,o,t+n,o+i),e.lineTo(t+n,o+r-i),e.quadraticCurveTo(t+n,o+r,t+n-i,o+r),e.lineTo(t+i,o+r),e.quadraticCurveTo(t,o+r,t,o+r-i),e.lineTo(t,o+i),e.quadraticCurveTo(t,o,t+i,o),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function TP(e){let t=0;if(e.length===0)return t;for(let o=0;o<e.length;o++){let n=e.charCodeAt(o);t=(t<<5)-t+n}return t}var hr=(e,t)=>`hsl(${Math.abs(TP(t?.id||e))%37*10}, 100%, 83%)`,WE=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},VE=({context:e,renderConfig:t,appState:o,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of t.remotePointerViewportCoords){let{x:l,y:s}=a,d=o.collaborators.get(i);l-=o.offsetLeft,s-=o.offsetTop;let m=11,c=14,p=l<0||l>n-m||s<0||s>r-c;l=Math.max(l,0),l=Math.min(l,n-m),s=Math.max(s,0),s=Math.min(s,r-c);let u=hr(i,d);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=t.remotePointerUserStates.get(i),b=p||f===YE.IDLE||f===YE.AWAY;b&&(e.globalAlpha=.3),t.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=o.theme===vP.DARK?"#2f6330":wP,w=d?.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=Pc,e.strokeStyle=Pc,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=t.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+m/2,v=(w?s+0:s)+c+2,I=5,S=3,L=e.measureText(E),k=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,R=Math.max(k,12),M=y-1,_=v-1,N=L.width+2+I*2+2,K=R+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(M,_,N,K,8),e.fillStyle=u,e.fill(),e.strokeStyle=Pc,e.stroke(),w&&(e.beginPath(),e.roundRect(M-2,_-2,N+4,K+4,8),e.strokeStyle=x,e.stroke())):Mc(e,M,_,N,K,8,Pc),e.fillStyle=yP,e.fillText(E,y+I+1,v+S+L.actualBoundingBoxAscent+Math.floor((R-k)/2)+2),w){e.fillStyle=x;let J=8,A=8,B=5;e.fillRect(M+N+A,_+(K/2-J/2),2,J),e.fillRect(M+N+A+B,_+(K/2-J*2/2),2,J*2),e.fillRect(M+N+A+B*2,_+(K/2-J/2),2,J)}}e.restore(),e.closePath()}};import IP from"clsx";import{useState as CP}from"react";import{jsx as XE}from"react/jsx-runtime";var Pu=({color:e,onClick:t,name:o,src:n,className:r})=>{let i=WE(o),[a,l]=CP(!1),s=!a&&n,d=s?void 0:{background:e};return XE("div",{className:IP("Avatar",r),style:d,onClick:t,children:s?XE("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as So,jsxs as Lc}from"react/jsx-runtime";var kP=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,o)=>!o.socketId||t.userToFollow?.socketId===o.socketId||o.isCurrentUser?{appState:{...t,userToFollow:null},captureUpdate:KE.EVENTUALLY}:{appState:{...t,userToFollow:{socketId:o.socketId,username:o.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},captureUpdate:KE.EVENTUALLY},PanelComponent:({updateData:e,data:t,appState:o})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=t,l=hr(n,r),s=SP({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),d=r.isInCall?r.isSpeaking?Lc("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[So("div",{}),So("div",{}),So("div",{})]}):r.isMuted?So("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:S0}):So("div",{title:g("userList.hint.inCall"),children:C0}):null;return i?Lc("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[So(Pu,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),So("div",{className:"UserList__collaborator-name",children:r.username}),Lc("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&So("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:jr}),d]})]}):Lc("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[So(Pu,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),d&&So("div",{className:"UserList__collaborator-status-icon",children:d})]})}});import{LIBRARY_DISABLED_TYPES as MP,randomId as PP}from"@excalidraw/common";import{deepCopyElement as LP}from"@excalidraw/element";import{CaptureUpdateAction as Lu}from"@excalidraw/element";var Au=O({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of MP)if(r.some(a=>a.type===i))return{captureUpdate:Lu.EVENTUALLY,appState:{...t,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:PP(),status:"unpublished",elements:r.map(LP),created:Date.now()},...i])).then(()=>({captureUpdate:Lu.EVENTUALLY,appState:{...t,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:Lu.EVENTUALLY,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as yi}from"@excalidraw/element";import{isFrameLikeElement as AP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as DP}from"@excalidraw/element";import{KEYS as Sn,arrayToMap as _P,getShortcutKey as Ac}from"@excalidraw/common";import{alignElements as RP}from"@excalidraw/element";import{CaptureUpdateAction as wi}from"@excalidraw/element";import{getSelectedElementsByGroup as NP}from"@excalidraw/element";import{jsx as Ti}from"react/jsx-runtime";var ft=(e,t)=>{let o=t.scene.getSelectedElements(e);return NP(o,t.scene.getNonDeletedElementsMap(),e).length>1&&!o.some(n=>AP(n))},vi=(e,t,o,n)=>{let r=o.scene.getSelectedElements(t),i=RP(r,n,o.scene,t),a=_P(i);return DP(e.map(l=>a.get(l.id)||l),t,o)},BP=O({name:"alignTop",label:"labels.alignTop",icon:ip,trackEvent:{category:"element"},predicate:(e,t,o,n)=>ft(t,n),perform:(e,t,o,n)=>({appState:t,elements:vi(e,t,n,{position:"start",axis:"y"}),captureUpdate:wi.IMMEDIATELY}),keyTest:e=>e[Sn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Sn.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Ti(V,{hidden:!ft(t,n),type:"button",icon:ip,onClick:()=>o(null),title:`${g("labels.alignTop")} \u2014 ${Ac("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:ve(yi(e),t)})}),OP=O({name:"alignBottom",label:"labels.alignBottom",icon:ap,trackEvent:{category:"element"},predicate:(e,t,o,n)=>ft(t,n),perform:(e,t,o,n)=>({appState:t,elements:vi(e,t,n,{position:"end",axis:"y"}),captureUpdate:wi.IMMEDIATELY}),keyTest:e=>e[Sn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Sn.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Ti(V,{hidden:!ft(t,n),type:"button",icon:ap,onClick:()=>o(null),title:`${g("labels.alignBottom")} \u2014 ${Ac("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:ve(yi(e),t)})}),FP=O({name:"alignLeft",label:"labels.alignLeft",icon:lp,trackEvent:{category:"element"},predicate:(e,t,o,n)=>ft(t,n),perform:(e,t,o,n)=>({appState:t,elements:vi(e,t,n,{position:"start",axis:"x"}),captureUpdate:wi.IMMEDIATELY}),keyTest:e=>e[Sn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Sn.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Ti(V,{hidden:!ft(t,n),type:"button",icon:lp,onClick:()=>o(null),title:`${g("labels.alignLeft")} \u2014 ${Ac("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:ve(yi(e),t)})}),zP=O({name:"alignRight",label:"labels.alignRight",icon:sp,trackEvent:{category:"element"},predicate:(e,t,o,n)=>ft(t,n),perform:(e,t,o,n)=>({appState:t,elements:vi(e,t,n,{position:"end",axis:"x"}),captureUpdate:wi.IMMEDIATELY}),keyTest:e=>e[Sn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Sn.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Ti(V,{hidden:!ft(t,n),type:"button",icon:sp,onClick:()=>o(null),title:`${g("labels.alignRight")} \u2014 ${Ac("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:ve(yi(e),t)})}),HP=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:cp,trackEvent:{category:"element"},predicate:(e,t,o,n)=>ft(t,n),perform:(e,t,o,n)=>({appState:t,elements:vi(e,t,n,{position:"center",axis:"y"}),captureUpdate:wi.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Ti(V,{hidden:!ft(t,n),type:"button",icon:cp,onClick:()=>o(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:ve(yi(e),t)})}),GP=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:dp,trackEvent:{category:"element"},predicate:(e,t,o,n)=>ft(t,n),perform:(e,t,o,n)=>({appState:t,elements:vi(e,t,n,{position:"center",axis:"x"}),captureUpdate:wi.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Ti(V,{hidden:!ft(t,n),type:"button",icon:dp,onClick:()=>o(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:ve(yi(e),t)})});import{getNonDeletedElements as ZE}from"@excalidraw/element";import{isFrameLikeElement as UP}from"@excalidraw/element";import{CODES as $E,KEYS as jE,arrayToMap as YP,getShortcutKey as qE}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as WP}from"@excalidraw/element";import{distributeElements as VP}from"@excalidraw/element";import{CaptureUpdateAction as JE}from"@excalidraw/element";import{getSelectedElementsByGroup as XP}from"@excalidraw/element";import{jsx as ty}from"react/jsx-runtime";var QE=(e,t)=>{let o=t.scene.getSelectedElements(e);return XP(o,t.scene.getNonDeletedElementsMap(),e).length>2&&!o.some(n=>UP(n))},ey=(e,t,o,n)=>{let r=o.scene.getSelectedElements(t),i=VP(r,o.scene.getNonDeletedElementsMap(),n,t),a=YP(i);return WP(e.map(l=>a.get(l.id)||l),t,o)},KP=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,o,n)=>({appState:t,elements:ey(e,t,n,{space:"between",axis:"x"}),captureUpdate:JE.IMMEDIATELY}),keyTest:e=>!e[jE.CTRL_OR_CMD]&&e.altKey&&e.code===$E.H,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>ty(V,{hidden:!QE(t,n),type:"button",icon:Lb,onClick:()=>o(null),title:`${g("labels.distributeHorizontally")} \u2014 ${qE("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:ve(ZE(e),t)})}),ZP=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,o,n)=>({appState:t,elements:ey(e,t,n,{space:"between",axis:"y"}),captureUpdate:JE.IMMEDIATELY}),keyTest:e=>!e[jE.CTRL_OR_CMD]&&e.altKey&&e.code===$E.V,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>ty(V,{hidden:!QE(t,n),type:"button",icon:Ab,onClick:()=>o(null),title:`${g("labels.distributeVertically")} \u2014 ${qE("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:ve(ZE(e),t)})});import{getNonDeletedElements as $P}from"@excalidraw/element";import{bindOrUnbindLinearElements as jP,isBindingEnabled as qP}from"@excalidraw/element";import{getCommonBoundingBox as oy}from"@excalidraw/element";import{newElementWith as JP}from"@excalidraw/element";import{deepCopyElement as QP}from"@excalidraw/element";import{resizeMultipleElements as eL}from"@excalidraw/element";import{isArrowElement as tL,isElbowArrow as oL,isLinearElement as nL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as ny}from"@excalidraw/element";import{CODES as ry,KEYS as rL,arrayToMap as iL}from"@excalidraw/common";import{CaptureUpdateAction as iy}from"@excalidraw/element";var Du=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:L0,trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:ny(ay(e,n.scene.getNonDeletedElementsMap(),t,"horizontal",n),t,n),appState:t,captureUpdate:iy.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ry.H}),_u=O({name:"flipVertical",label:"labels.flipVertical",icon:P0,trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:ny(ay(e,n.scene.getNonDeletedElementsMap(),t,"vertical",n),t,n),appState:t,captureUpdate:iy.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ry.V&&!e[rL.CTRL_OR_CMD]}),ay=(e,t,o,n,r)=>{let i=Q($P(e),o,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=aL(i,t,o,n,r),l=iL(a);return e.map(s=>l.get(s.id)||s)},aL=(e,t,o,n,r)=>{if(e.every(u=>tL(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return JP(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=oy(e);eL(e,t,"nw",r.scene,new Map(Array.from(t.values()).map(u=>[u.id,QP(u)])),{flipByX:n==="horizontal",flipByY:n==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),jP(e.filter(nL),qP(o),[],r.scene,o.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>oL(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:d,midY:m}=oy(e),[c,p]=[i-d,a-m];return s.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),l.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),e};import{isTextElement as lL}from"@excalidraw/element";import{getTextFromElements as sL}from"@excalidraw/element";import{CODES as cL,KEYS as ly,isFirefox as dL}from"@excalidraw/common";import{CaptureUpdateAction as Bt}from"@excalidraw/element";var Ii=O({name:"copy",label:"labels.copy",icon:Ma,trackEvent:{category:"element"},perform:async(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await wc(r,n.files,o)}catch(i){return{captureUpdate:Bt.EVENTUALLY,appState:{...t,errorMessage:i.message}}}return{captureUpdate:Bt.EVENTUALLY}},keyTest:void 0}),Ru=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,o,n)=>{let r;try{r=await ME()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),dL?{captureUpdate:Bt.EVENTUALLY,appState:{...t,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Bt.EVENTUALLY,appState:{...t,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(SE({types:r}))}catch(i){return console.error(i),{captureUpdate:Bt.EVENTUALLY,appState:{...t,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Bt.EVENTUALLY}},keyTest:void 0}),Dc=O({name:"cut",label:"labels.cut",icon:g0,trackEvent:{category:"element"},perform:(e,t,o,n)=>(Ii.perform(e,t,o,n),Oa.perform(e,t,null,n)),keyTest:e=>e[ly.CTRL_OR_CMD]&&e.key===ly.X}),_c=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:A0,trackEvent:{category:"element"},perform:async(e,t,o,n)=>{if(!n.canvas)return{captureUpdate:Bt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=dr(e,t,!0);try{await mr("clipboard-svg",r,t,n.files,{...t,exportingFrame:i,name:n.getName()});let a=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:t.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Bt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Bt.EVENTUALLY}}},predicate:e=>yc&&e.length>0,keywords:["svg","clipboard","copy"]}),Rc=O({name:"copyAsPng",label:"labels.copyAsPng",icon:D0,trackEvent:{category:"element"},perform:async(e,t,o,n)=>{if(!n.canvas)return{captureUpdate:Bt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=dr(e,t,!0);try{return await mr("clipboard",i,t,n.files,{...t,exportingFrame:a,name:n.getName()}),{appState:{...t,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:r.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:t.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Bt.EVENTUALLY}}catch(l){return console.error(l),{appState:{...t,errorMessage:l.message},captureUpdate:Bt.EVENTUALLY}}},predicate:e=>fi&&e.length>0,keyTest:e=>e.code===cL.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Nc=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{co(sL(r))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Bt.EVENTUALLY}},predicate:(e,t,o,n)=>yc&&n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(lL),keywords:["text","clipboard","copy"]});import{CODES as mL,KEYS as pL}from"@excalidraw/common";import{CaptureUpdateAction as uL}from"@excalidraw/element";var Bc=O({name:"gridMode",icon:O0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,t){return{appState:{...t,gridModeEnabled:!this.checked(t),objectsSnapModeEnabled:!1},captureUpdate:uL.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>o.gridModeEnabled===void 0,keyTest:e=>e[pL.CTRL_OR_CMD]&&e.code===mL.QUOTE});import{CODES as hL,KEYS as gL}from"@excalidraw/common";import{CaptureUpdateAction as fL}from"@excalidraw/element";var Ci=O({name:"zenMode",label:"buttons.zenMode",icon:R0,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:fL.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,o)=>typeof o.zenModeEnabled>"u",keyTest:e=>!e[gL.CTRL_OR_CMD]&&e.altKey&&e.code===hL.Z});import{CODES as bL,KEYS as xL}from"@excalidraw/common";import{CaptureUpdateAction as EL}from"@excalidraw/element";var Nu=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:_0,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:EL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,o)=>typeof o.objectsSnapModeEnabled>"u",keyTest:e=>!e[xL.CTRL_OR_CMD]&&e.altKey&&e.code===bL.S});import{CODES as yL,KEYS as wL}from"@excalidraw/common";import{CaptureUpdateAction as vL}from"@excalidraw/element";var Si=O({name:"stats",label:"stats.fullTitle",icon:M0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:vL.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[wL.CTRL_OR_CMD]&&e.altKey&&e.code===yL.SLASH});import{BOUND_TEXT_PADDING as sy,ROUNDNESS as cy,TEXT_ALIGN as my,VERTICAL_ALIGN as py,arrayToMap as uy,getFontString as TL}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as IL,resetOriginalContainerCache as CL,updateOriginalContainerCache as SL}from"@excalidraw/element";import{computeBoundTextPosition as kL,computeContainerDimensionForBoundText as dy,getBoundTextElement as hy,redrawTextBoundingBox as gy}from"@excalidraw/element";import{hasBoundTextElement as ML,isArrowElement as PL,isTextBindableContainer as Bu,isTextElement as sl,isUsingAdaptiveRadius as LL}from"@excalidraw/element";import{measureText as AL}from"@excalidraw/element";import{syncMovedIndices as fy}from"@excalidraw/element";import{newElement as DL}from"@excalidraw/element";import{CaptureUpdateAction as Ou}from"@excalidraw/element";var Fu=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,o,n)=>n.scene.getSelectedElements(t).some(i=>ML(i)),perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=hy(a,i);if(l){let{width:s,height:d}=AL(l.originalText,TL(l),l.lineHeight),m=IL(a.id);CL(a.id);let{x:c,y:p}=kL(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:d,text:l.originalText,x:c,y:p}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:t,captureUpdate:Ou.IMMEDIATELY}}}),zu=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);if(r.length===2){let i=sl(r[0])||sl(r[1]),a;if(Bu(r[0])?a=r[0]:Bu(r[1])&&(a=r[1]),i&&a&&hy(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t),i,a;sl(r[0])&&Bu(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:py.MIDDLE,textAlign:my.CENTER,autoResize:!0,angle:PL(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return gy(i,a,n.scene),SL(a.id,l),{elements:_L(e,a,i),appState:{...t,selectedElementIds:{[a.id]:!0}},captureUpdate:Ou.IMMEDIATELY}}}),_L=(e,t,o)=>{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+1,0,o),fy(n,uy([t,o])),n},RL=(e,t,o)=>{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,0,t),fy(n,uy([t,o])),n},by=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t),i=r.some(a=>sl(a));return r.length>0&&i},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t),i=e.slice(),a={};for(let l of r)if(sl(l)){let s=DL({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:LL("rectangle")?cy.ADAPTIVE_RADIUS:cy.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-sy,y:l.y-sy,width:dy(l.width,"rectangle"),height:dy(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let d=l.boundElements.filter(c=>c.type==="arrow").map(c=>c.id);i.filter(c=>d.includes(c.id)).forEach(c=>{let p=c.startBinding,u=c.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&n.scene.mutateElement(c,{startBinding:p,endBinding:u})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:py.MIDDLE,boundElements:null,textAlign:my.CENTER,autoResize:!0}),gy(l,s,n.scene),i=RL([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...t,selectedElementIds:a},captureUpdate:Ou.IMMEDIATELY}}});import{isEmbeddableElement as qL}from"@excalidraw/element";import{KEYS as ky,getShortcutKey as JL}from"@excalidraw/common";import{CaptureUpdateAction as QL}from"@excalidraw/element";import{pointFrom as wy}from"@excalidraw/math";import NL from"clsx";import{useCallback as xy,useEffect as Ey,useLayoutEffect as BL,useRef as OL,useState as FL}from"react";import{EVENT as Hu,HYPERLINK_TOOLTIP_DELAY as zL,KEYS as Oc}from"@excalidraw/common";import{getElementAbsoluteCoords as Vu}from"@excalidraw/element";import{hitElementBoundingBox as HL}from"@excalidraw/element";import{isElementLink as GL}from"@excalidraw/element";import{getEmbedLink as UL,embeddableURLValidator as YL}from"@excalidraw/element";import{sceneCoordsToViewportCoords as vy,viewportCoordsToSceneCoords as WL,wrapEvent as VL,isLocalLink as XL,normalizeLink as Gu}from"@excalidraw/common";import{isEmbeddableElement as Uu}from"@excalidraw/element";import{jsx as ki,jsxs as yy}from"react/jsx-runtime";var Xu=380,KL=42,Yu=5,Ty=85,ZL=500,Wu=!1,Fc=new Map,Iy=({element:e,scene:t,setAppState:o,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=t.getNonDeletedElementsMap(),l=vo(),s=To(),d=he(),m=e.link||"",[c,p]=FL(m),u=OL(null),f=l.showHyperlinkPopup==="editor",b=xy(()=>{if(!u.current)return;let v=Gu(u.current.value)||null;if(!e.link&&v&&ie("hyperlink","create"),Uu(e)){if(l.activeEmbeddable?.element===e&&o({activeEmbeddable:null}),!v){t.mutateElement(e,{link:null}),i(e,!1);return}if(!YL(v,s.validateEmbeddable))v&&r({message:g("toast.unableToEmbed"),closable:!0}),e.link&&Fc.set(e.id,e.link),t.mutateElement(e,{link:v}),i(e,!1);else{let{width:I,height:S}=e,L=UL(v);L?.error instanceof URIError&&r({message:g("toast.unrecognizedLinkFormat"),closable:!0});let k=L?L.intrinsicSize.w/L.intrinsicSize.h:1,R=Fc.get(e.id)!==e.link;t.mutateElement(e,{...R?{width:L?.type==="video"?I>S?I:S*k:I,height:L?.type==="video"&&I>S?I/k:S}:{},link:v}),i(e,!0),Fc.has(e.id)&&Fc.delete(e.id)}}else t.mutateElement(e,{link:v})},[e,t,r,s.validateEmbeddable,l.activeEmbeddable,o,i]);BL(()=>()=>{b()},[b]),Ey(()=>{f&&u?.current&&!(d.viewport.isMobile||d.isTouchScreen)&&u.current.select()},[f,d.viewport.isMobile,d.isTouchScreen]),Ey(()=>{let v=null,I=S=>{if(f)return;v&&clearTimeout(v),jL(e,a,l,wy(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{o({showHyperlinkPopup:!1})},ZL))};return window.addEventListener(Hu.POINTER_MOVE,I,!1),()=>{window.removeEventListener(Hu.POINTER_MOVE,I,!1),v&&clearTimeout(v)}},[l,e,f,o,a]);let x=xy(()=>{ie("hyperlink","delete"),t.mutateElement(e,{link:null}),o({showHyperlinkPopup:!1})},[o,e,t]),w=()=>{ie("hyperlink","edit","popup-ui"),o({showHyperlinkPopup:"editor"})},{x:E,y}=Cy(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:yy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:Xu,padding:Yu},children:[f?ki("input",{className:NL("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:c,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Oc.CTRL_OR_CMD]&&v.key===Oc.K&&v.preventDefault(),(v.key===Oc.ENTER||v.key===Oc.ESCAPE)&&(b(),o({showHyperlinkPopup:"info"}))}}):e.link?ki("a",{href:Gu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:XL(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&n){let I=VL(Hu.EXCALIDRAW_LINK,v.nativeEvent);n({...e,link:Gu(e.link)},I),I.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ki("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),yy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&ki(V,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:yo}),ki(V,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{o({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Bs}),m&&!Uu(e)&&ki(V,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:At})]})]})},Cy=(e,t,o)=>{let[n,r]=Vu(e,o),{x:i,y:a}=vy({sceneX:n+e.width/2,sceneY:r},t),l=i-t.offsetLeft-Xu/2,s=a-t.offsetTop-Ty;return{x:l,y:s}},Ku=(e,t)=>{let o=Q(e,t);return Uu(o[0])?"labels.link.editEmbed":o[0]?.link?"labels.link.edit":"labels.link.create"},cl=null,Sy=(e,t,o)=>{cl&&clearTimeout(cl),cl=window.setTimeout(()=>$L(e,t,o),zL)},$L=(e,t,o)=>{if(!e.link)return;let n=ui();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=GL(e.link)?g("labels.link.goToElement"):e.link;let[r,i,a,l]=Vu(e,o),[s,d,m,c]=R1([r,i,a,l],e.angle,t),p=vy({sceneX:s,sceneY:d},t);iu(n,{left:p.x,top:p.y,width:m,height:c},"top"),ie("hyperlink","tooltip","link-icon"),Wu=!0},Zu=()=>{cl&&clearTimeout(cl),Wu&&(Wu=!1,ui().classList.remove("excalidraw-tooltip--visible"))},jL=(e,t,o,[n,r])=>{let{x:i,y:a}=WL({clientX:n,clientY:r},o),l=15/o.zoom.value;if(HL(wy(i,a),e,t))return!1;let[s,d,m]=Vu(e,t);if(i>=s&&i<=m&&a>=d-Ty&&a<=d)return!1;let{x:c,y:p}=Cy(e,o,t);return!(n>=c-l&&n<=c+Xu+Yu*2+l&&r>=p-l&&r<=p+l+Yu*2+KL)};import{jsx as eA}from"react/jsx-runtime";var dl=O({name:"hyperlink",label:(e,t)=>Ku(e,t),icon:Aa,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:QL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[ky.CTRL_OR_CMD]&&e.key===ky.K,predicate:(e,t)=>Q(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:o})=>{let n=Q(e,t);return eA(V,{type:"button",icon:Aa,"aria-label":g(Ku(e,t)),title:`${qL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${JL("CtrlOrCmd+K")}`,onClick:()=>o(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as My,arrayToMap as ju,randomId as tA}from"@excalidraw/common";import{elementsAreInSameGroup as oA,newElementWith as Py,selectGroupsFromGivenElements as Ly}from"@excalidraw/element";import{CaptureUpdateAction as Ay}from"@excalidraw/element";var $u=e=>e.every(t=>!t.locked),ml=O({name:"toggleElementLock",label:(e,t,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return $u(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,t)=>{let o=Q(t,e);return $u(o)?zr:er},trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=$u(r),a=ju(r),l=r.length>1&&oA(r),d=r.length===1||l?null:tA(),m={...t.lockedMultiSelections};if(i)m={...t.lockedMultiSelections,...d?{[d]:!0}:{}};else if(l){let w=r[0].groupIds.at(-1);delete m[w]}let c=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?d&&(E=[...E,d]):E=E.filter(y=>!t.lockedMultiSelections[y]),Py(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=ju(c),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),f=r.map(w=>p.get(w.id)||w),b=i?{}:Ly(f,t),x=i?d||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:c,appState:{...t,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:t.selectedLinearElement,lockedMultiSelections:m,activeLockedId:x},captureUpdate:Ay.IMMEDIATELY}},keyTest:(e,t,o,n)=>e.key.toLocaleLowerCase()===My.L&&e[My.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),Dy=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:er,predicate:(e,t)=>Q(e,t).length===0&&e.some(n=>n.locked),perform:(e,t)=>{let o=e.filter(a=>a.locked),n=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!t.lockedMultiSelections[s]);return Py(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=ju(n),i=o.map(a=>r.get(a.id)||a);return{elements:n,appState:{...t,selectedElementIds:Object.fromEntries(o.map(a=>[a.id,!0])),selectedGroupIds:Ly(i,t),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Ay.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as x_,isLinearElement as E_,isLineElement as Zi}from"@excalidraw/element";import{arrayToMap as y_,invariant as qh}from"@excalidraw/common";import{toggleLinePolygonState as w_,CaptureUpdateAction as $2}from"@excalidraw/element";import y2 from"clsx";import mD from"fuzzy";import{useEffect as ud,useRef as w2,useMemo as pD,useState as pd}from"react";import{DEFAULT_SIDEBAR as b2,EVENT as gd,KEYS as uo,capitalizeString as uD,getShortcutKey as hD,isWritableElement as gD}from"@excalidraw/common";import{CaptureUpdateAction as FA}from"@excalidraw/element";import{useEffect as hl,useMemo as _y,useRef as eh,useState as nA}from"react";import{getLinearElementSubType as Li,updateElbowArrowPoints as rA}from"@excalidraw/element";import{pointFrom as Hc,pointRotateRads as iA}from"@excalidraw/math";import{hasBoundTextElement as aA,isArrowBoundToElement as lA,isArrowElement as sA,isElbowArrow as cA,isLinearElement as rh,isUsingAdaptiveRadius as dA}from"@excalidraw/element";import{getCommonBoundingBox as mA,getElementAbsoluteCoords as pA}from"@excalidraw/element";import{getBoundTextElement as Fy,getBoundTextMaxHeight as uA,getBoundTextMaxWidth as hA,redrawTextBoundingBox as gA}from"@excalidraw/element";import{wrapText as fA}from"@excalidraw/element";import{assertNever as bA,CLASSES as xA,getFontString as qu,isProdEnv as EA,mapFind as yA,reduceToCommonValue as wA,updateActiveTool as Ry}from"@excalidraw/common";import{measureText as Ny}from"@excalidraw/element";import{LinearElementEditor as vA}from"@excalidraw/element";import{newArrowElement as Ju,newElement as TA,newLinearElement as IA}from"@excalidraw/element";import{ShapeCache as CA}from"@excalidraw/element";import{updateBindings as SA}from"@excalidraw/element";import{jsx as nh}from"react/jsx-runtime";var kA=8,MA=10,pl=["rectangle","diamond","ellipse"],ul=["line","sharpArrow","curvedArrow","elbowArrow"],PA=new Set(pl),LA=new Set(ul),Ai=e=>PA.has(e),Uc=e=>e==="arrow"||LA.has(e),po=ge(null),gl=new Map,fl=new Map,AA=({app:e})=>{let t=e.scene.getSelectedElements(e.state),o=eh(null);return hl(()=>{if(t.length===0){e.updateEditorAtom(po,null);return}let n=Di(t);n&&!o.current?o.current=n:(o.current&&!n||o.current&&n!==o.current)&&(e.updateEditorAtom(po,null),o.current=null)},[t,e]),hl(()=>()=>{gl.clear(),fl.clear()},[]),nh(DA,{app:e,elements:t})},DA=({app:e,elements:t})=>{let o=Di(t),n=_y(()=>o==="generic"?Hy(t):[],[o,t]),r=_y(()=>o==="linear"?oh(t):[],[o,t]),i=o==="generic"?n.every(c=>c.type===n[0].type):o==="linear"?r.every(c=>Li(c)===Li(r[0])):!1,[a,l]=nA({x:0,y:0}),s=eh(""),d=eh(null);hl(()=>{let c=[...n,...r].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}${c.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(c.length===1){let[x,,,w,E,y]=pA(c[0],e.scene.getNonDeletedElementsMap());u=iA(Hc(x,w),Hc(E,y),c[0].angle)}else{let{minX:x,maxY:w}=mA(c);u=Hc(x,w)}let{x:f,y:b}=Uy({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[n,r,e.scene,e.state]),hl(()=>{for(let c of r){let p=th(c.id,OA(c));fl.has(p)||fl.set(p,c)}},[r]),hl(()=>{for(let c of n)if(!gl.has(c.id)){let p=Fy(c,e.scene.getNonDeletedElementsMap());p&&gl.set(c.id,{fontSize:p.fontSize})}},[n,e.scene]);let m=o==="linear"?[["line",Yr],["sharpArrow",qr],["curvedArrow",Qr],["elbowArrow",Jr]]:o==="generic"?[["rectangle",Hr],["diamond",Gr],["ellipse",Ur]]:[];return nh("div",{ref:d,tabIndex:-1,style:{position:"absolute",top:`${a.y+(MA+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-kA}px`,zIndex:2},className:xA.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([c,p])=>{let u=i&&(o==="generic"&&n[0].type===c||o==="linear"&&Li(r[0])===c);return nh(V,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:c,keyBindingLabel:"","aria-label":c,"data-testid":`toolbar-${c}`,onChange:()=>{e.state.activeTool.type!==c&&ie("convertElementType",c,"ui"),ih(e,{conversionType:o,nextType:c}),d.current?.focus()}},`${t[0].id}${t[0].version}_${c}`)})})},_A=(e,t,o)=>{let n=hA(e,t),r=uA(e,t),i=fA(t.text,qu(t),n),a=Ny(i,qu(t),t.lineHeight),l=t.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...t,fontSize:l};a=Ny(t.text,qu(s),t.lineHeight)}Yc(t,o.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),gA(t,e,o)},ih=(e,{conversionType:t,nextType:o,direction:n="right"})=>{if(!t)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=n==="right"?1:-1;if(t==="generic"){let l=Hy(r),d=l.every(m=>m.type===l[0].type)?pl.indexOf(l[0].type):-1;if(o=o??pl[(d+pl.length+a)%pl.length],o&&Ai(o)){let m={};for(let p of l){let u=Oy(p,o,e);m[u.id]=u}let c=[];for(let p of e.scene.getElementsIncludingDeleted())m[p.id]?c.push(m[p.id]):c.push(p);e.scene.replaceAllElements(c);for(let p of Object.values(m)){let u=Fy(p,e.scene.getNonDeletedElementsMap());u&&(gl.get(p.id)&&Yc(u,e.scene.getNonDeletedElementsMap(),{fontSize:gl.get(p.id)?.fontSize??u.fontSize}),_A(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:Ry(p,{type:"selection"})}))}}if(t==="linear"){let l=oh(r);if(!o){let d=wA(l,Li),m=d?ul.indexOf(d):-1;o=ul[(m+ul.length+a)%ul.length]}if(Uc(o)){let d=[],m=e.scene.getElementsMapIncludingDeleted();for(let c of l){let p=fl.get(th(c.id,o));if(p&&Li(p)===o)m.set(p.id,p),d.push(p);else{let u=Oy(c,o,e);m.set(u.id,u),d.push(u)}}e.scene.replaceAllElements(m);for(let c of d)if(rh(c))if(cA(c)){let p=RA(c);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=rA(c,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Yc(c,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=yA(["line","sharpArrow","curvedArrow"],u=>fl.get(th(c.id,u)));if(p){let u=p.points;e.scene.mutateElement(c,{points:u})}}}let s=oh(e.scene.getSelectedElements(e.state));e.setState(d=>({selectedElementIds:i,selectedLinearElement:s.length===1?new vA(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Ry(d,{type:"selection"})}))}return!0},Di=e=>{if(e.length===0)return null;let t=!1;for(let o of e){if(Ai(o.type))return"generic";zy(o)&&(t=!0)}return t?"linear":null},zy=e=>rh(e)&&(!sA(e)||!lA(e)&&!aA(e)),th=(e,t)=>`${e}:${t}`,Hy=e=>e.filter(t=>Ai(t.type)),oh=e=>e.filter(t=>zy(t)),zc=20,Mi=(e,t)=>e[0]===t[0],Qu=(e,t)=>e[1]===t[1],By=(e,t)=>Mi(e,t)?Math.abs(e[1]-t[1]):Math.abs(e[0]-t[0]),RA=e=>{let t=[e.points[0]],o=NA(e.points);for(let i=1;i<o.length;++i){let a=t[t.length-1],l=[...o[i]];Math.abs(l[0]-a[0])<zc?l[0]=a[0]:Math.abs(l[1]-a[1])<zc&&(l[1]=a[1]),Mi(a,l)||Qu(a,l)||t.push(Hc(a[0],l[1])),t.push(l)}let n=[t[0]];for(let i=1;i<t.length-1;++i)Mi(t[i-1],t[i])&&Mi(t[i],t[i+1])||Qu(t[i-1],t[i])&&Qu(t[i],t[i+1])||n.push(t[i]);n.push(t[t.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],d=Mi(a,l),m=Mi(l,s);if(d!==m){let c=By(a,l),p=By(l,s);if(c<zc||p<zc){if(p<c)d?s[0]=a[0]:s[1]=a[1];else if(m)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},NA=e=>{if(e.length===0)return[];let t=[e[0]];for(let o=1;o<e.length;o++){let[n,r]=t[t.length-1],[i,a]=e[o];(n!==i||r!==a)&&t.push(e[o])}return t},Oy=(e,t,o)=>{if(!BA(e.type,t)){if(!EA())throw Error(`Invalid conversion from ${e.type} to ${t}.`);return e}if(e.type===t)return e;if(CA.delete(e),Ai(t)){let n=Pi(TA({...e,type:t,roundness:t==="diamond"&&e.roundness?{type:dA(t)?Gc.ADAPTIVE_RADIUS:Gc.PROPORTIONAL_RADIUS}:e.roundness}));return SA(n,o.scene),n}if(Uc(t))switch(t){case"line":return Pi(IA({...e,type:"line"}));case"sharpArrow":return Pi(Ju({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:o.state.currentItemStartArrowhead,endArrowhead:o.state.currentItemEndArrowhead}));case"curvedArrow":return Pi(Ju({...e,type:"arrow",elbowed:!1,roundness:{type:Gc.PROPORTIONAL_RADIUS},startArrowhead:o.state.currentItemStartArrowhead,endArrowhead:o.state.currentItemEndArrowhead}));case"elbowArrow":return Pi(Ju({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return bA(t,`unhandled conversion type: ${t}`),e},BA=(e,t)=>!!(Ai(e)&&Ai(t)||Uc(e)&&Uc(t)),OA=e=>rh(e)?Li(e):e.type,Gy=AA;var Yy=O({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,t,o,n){return We.set(po,{type:"panel"}),{captureUpdate:FA.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>Di(e)!==null});import{canCreateLinkFromElements as ah,defaultGetElementLinkFromSelection as zA,getLinkIdAndTypeFromSelection as HA}from"@excalidraw/element";import{CaptureUpdateAction as bl}from"@excalidraw/element";var Wc=O({name:"copyElementLink",label:"labels.copyElementLink",icon:Kr,trackEvent:{category:"element"},perform:async(e,t,o,n)=>{let r=Q(e,t);try{if(window.location){let i=HA(r,t);return i?(await co(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):zA(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:bl.EVENTUALLY}):{appState:t,elements:e,app:n,captureUpdate:bl.EVENTUALLY}}}catch(i){console.error(i)}return{appState:t,elements:e,app:n,captureUpdate:bl.EVENTUALLY}},predicate:(e,t)=>ah(Q(e,t))}),Wy=O({name:"linkToElement",label:"labels.linkToElement",icon:Bs,perform:(e,t,o,n)=>{let r=Q(e,t);return r.length!==1||!ah(r)?{elements:e,appState:t,app:n,captureUpdate:bl.EVENTUALLY}:{appState:{...t,openDialog:{name:"elementLinkSelector",sourceElementId:Q(e,t)[0].id}},captureUpdate:bl.IMMEDIATELY}},predicate:(e,t,o,n)=>{let r=Q(e,t);return t.openDialog?.name!=="elementLinkSelector"&&r.length===1&&ah(r)},trackEvent:!1});import{isDarwin as Vy,getShortcutKey as ae}from"@excalidraw/common";var GA={toggleTheme:[ae("Shift+Alt+D")],saveScene:[ae("CtrlOrCmd+S")],loadScene:[ae("CtrlOrCmd+O")],clearCanvas:[ae("CtrlOrCmd+Delete")],imageExport:[ae("CtrlOrCmd+Shift+E")],commandPalette:[ae("CtrlOrCmd+/"),ae("CtrlOrCmd+Shift+P")],cut:[ae("CtrlOrCmd+X")],copy:[ae("CtrlOrCmd+C")],paste:[ae("CtrlOrCmd+V")],copyStyles:[ae("CtrlOrCmd+Alt+C")],pasteStyles:[ae("CtrlOrCmd+Alt+V")],selectAll:[ae("CtrlOrCmd+A")],deleteSelectedElements:[ae("Delete")],duplicateSelection:[ae("CtrlOrCmd+D"),ae(`Alt+${g("helpDialog.drag")}`)],sendBackward:[ae("CtrlOrCmd+[")],bringForward:[ae("CtrlOrCmd+]")],sendToBack:[Vy?ae("CtrlOrCmd+Alt+["):ae("CtrlOrCmd+Shift+[")],bringToFront:[Vy?ae("CtrlOrCmd+Alt+]"):ae("CtrlOrCmd+Shift+]")],copyAsPng:[ae("Shift+Alt+C")],group:[ae("CtrlOrCmd+G")],ungroup:[ae("CtrlOrCmd+Shift+G")],gridMode:[ae("CtrlOrCmd+'")],zenMode:[ae("Alt+Z")],objectsSnapMode:[ae("Alt+S")],stats:[ae("Alt+/")],addToLibrary:[],flipHorizontal:[ae("Shift+H")],flipVertical:[ae("Shift+V")],viewMode:[ae("Alt+R")],hyperlink:[ae("CtrlOrCmd+K")],toggleElementLock:[ae("CtrlOrCmd+Shift+L")],resetZoom:[ae("CtrlOrCmd+0")],zoomOut:[ae("CtrlOrCmd+-")],zoomIn:[ae("CtrlOrCmd++")],zoomToFitSelection:[ae("Shift+3")],zoomToFit:[ae("Shift+1")],zoomToFitSelectionInViewport:[ae("Shift+2")],toggleEraserTool:[ae("E")],toggleHandTool:[ae("H")],setFrameAsActiveTool:[ae("F")],saveFileToDisk:[ae("CtrlOrCmd+S")],saveToActiveFile:[ae("CtrlOrCmd+S")],toggleShortcuts:[ae("?")],searchMenu:[ae("CtrlOrCmd+F")],wrapSelectionInFrame:[]},ze=(e,t=0)=>{let o=GA[e];return o&&o.length>0?o[t]||o[0]:""};var UA="\\u0300-\\u036f",YA="\\ufe20-\\ufe2f",WA="\\u20d0-\\u20ff",VA=UA+YA+WA,XA=`[${VA}]`,KA=RegExp(XA,"g"),ZA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,$A={\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"},gr=e=>e.replace(ZA,t=>$A[t]||t).replace(KA,"");import K7 from"clsx";import{useEffect as Z7,useState as $7}from"react";import{KEYS as j7,queryFocusableElements as Kw}from"@excalidraw/common";import{useCallback as jA,useState as qA}from"react";var Xy=()=>{let[e,t]=qA(null),o=jA(n=>t(n),[]);return[e,o]};import{useState as Gw,useCallback as Ch,useMemo as Uw,useEffect as Sh,memo as Yw,useRef as D7}from"react";import{LIBRARY_DISABLED_TYPES as _7,randomId as R7,isShallowEqual as N7,KEYS as B7,isWritableElement as O7,addEventListener as F7,EVENT as z7,CLASSES as Fw}from"@excalidraw/common";import{useEffect as jy,useRef as qy}from"react";import{URL_HASH_KEYS as ch,URL_QUERY_KEYS as dh,APP_NAME as Jy,EVENT as Xc,DEFAULT_SIDEBAR as t8,LIBRARY_SIDEBAR_TAB as o8,arrayToMap as mh,cloneJSON as n8,preventUnload as r8,promiseTry as Qy,resolvablePromise as i8,toValidURL as a8,Queue as l8,Emitter as s8}from"@excalidraw/common";import{hashElementsVersion as c8,hashString as d8}from"@excalidraw/element";import{getCommonBoundingBox as sh}from"@excalidraw/element";import{MIME_TYPES as fr}from"@excalidraw/common";var kn=({elements:e,appState:t,files:o,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=Nr({elements:e,appState:t},null,null,{deleteInvisibleElements:!0}),{exportBackground:d,viewBackgroundColor:m}=s;return fs(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},o||{},{exportBackground:d,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(c,p)=>{let u=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(c,p),x=n<b?n/b:t?.exportScale??1;return u.width=c*x,u.height=p*x,{canvas:u,scale:x}}let f=r?.(c,p)||{width:c,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},Ky=async e=>{let{mimeType:t=fr.png,quality:o}=e;t===fr.png&&typeof o=="number"&&console.warn(`"quality" will be ignored for "${fr.png}" mimeType`),t==="image/jpg"&&(t=fr.jpg),t===fr.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${fr.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await kn(e);return o=o||(/image\/jpe?g/.test(t)?.92:.8),new Promise((r,i)=>{n.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&t===fr.png&&e.appState?.exportEmbedScene&&(a=await Y1({blob:a,metadata:va(e.elements,e.appState,e.files||{},"local")})),r(a)},t,o)})},_i=async({elements:e,appState:t=mn(),files:o={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:d}=Nr({elements:e,appState:t},null,null,{deleteInvisibleElements:!0}),m={...d,exportPadding:n};return Rr(s,m,o,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},JA=async e=>{if(e.type==="svg"){let t=await _i(e);await co(t.outerHTML)}else if(e.type==="png")await vc(Ky(e));else if(e.type==="json")await wc(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as Zy,useState as QA}from"react";import{COLOR_PALETTE as e8}from"@excalidraw/common";var lh=ge(new Map),$y=async e=>await _i({elements:e,appState:{exportBackground:!1,viewBackgroundColor:e8.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),Vc=(e,t,o,n)=>{let[r,i]=QA();return Zy(()=>{if(t)if(e){let a=o.get(e);a?i(a):(async()=>{let l=await $y(t);l.querySelector(".style-fonts")?.remove(),l&&(o.set(e,l),i(l))})()}else(async()=>{let a=await $y(t);i(a)})()},[e,t,o,i]),Zy(()=>{let a=n.current;if(a)return r&&(a.innerHTML=r.outerHTML),()=>{a.innerHTML=""}},[r,n]),r},Ri=()=>{let[e]=de(lh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var m8=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],tw=new s8,Ko=ge({status:"loaded",isInitialized:!1,libraryItems:[]}),xl=e=>n8(e),p8=(e,t)=>!e.find(o=>o.elements.length!==t.elements.length?!1:o.elements.every((n,r)=>n.id===t.elements[r].id&&n.versionNonce===t.elements[r].versionNonce)),ow=(e,t)=>{let o=[];for(let n of t)p8(e,n)&&o.push(n);return[...o,...e]},nw=(e,t)=>{let o=mh(t),n={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)o.has(i.id)||n.deletedItems.set(i.id,i);let r=mh(e);for(let i of t){let a=r.get(i.id);a?hh(a)!==hh(i)&&n.updatedItems.set(i.id,i):n.addedItems.set(i.id,i)}return n},ph=class{constructor(t){C(this,"currLibraryItems",[]);C(this,"prevLibraryItems",xl(this.currLibraryItems));C(this,"app");C(this,"updateQueue",[]);C(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);C(this,"notifyListeners",()=>{if(this.updateQueue.length>0)We.set(Ko,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{We.set(Ko,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=xl(this.currLibraryItems);let o=xl(this.currLibraryItems);this.app.props.onLibraryChange?.(o),tw.trigger(nw(t,o),o)}catch(t){console.error(t)}}});C(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],We.set(lh,new Map)});C(this,"resetLibrary",()=>this.setLibrary([]));C(this,"getLatestLibrary",()=>new Promise(async t=>{try{let o=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(xl(o))}catch{return t(this.currLibraryItems)}}));C(this,"updateLibrary",async({libraryItems:t,prompt:o=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:t8.name,tab:o8}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),d;s instanceof Blob?d=await Xm(s,i):d=Ca(s,i),!o||window.confirm(g("alerts.confirmAddLibrary",{numShapes:d.length}))?(o&&this.app.focusContainer(),a(n?ow(this.currLibraryItems,d):d)):l(new Dr)}catch(s){l(s)}}))));C(this,"setLibrary",t=>{let o=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=xl(await t),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!==o),this.notifyListeners()});return this.updateQueue.push(o),this.notifyListeners(),o});this.app=t}},rw=ph,Bi=e=>{let o=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*o,u*o+o).reduce((b,x)=>{let{height:w}=sh(x.elements);return Math.max(b,w)},0),i=u=>{let f=0,b=0,x=0;for(let w of e){if(f%o===0&&(b=0),b===u){let{width:E}=sh(w.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,d=0,m=0,c=0,p=0;for(let u of e){m&&m%o===0&&(l+=s+50,a=0,c=0,p++),c===0&&(s=r(p)),d=i(c);let{minX:f,minY:b,width:x,height:w}=sh(u.elements),E=(d-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+=d+50,m++,c++}return n},u8=(e,t=m8)=>{if(typeof t=="function"?t(e):t.some(o=>{let n=new URL(`https://${o.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}"`)},uh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(ch.addLibrary)||new URLSearchParams(window.location.search).get(dh.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},Mn=class Mn{constructor(t){C(this,"adapter");this.adapter=t}static async getLibraryItems(t,o,n=!0){let r=()=>new Promise(async(i,a)=>{try{let l=await t.load({source:o});i(Ca(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?Mn.queue.push(r):r()}getLibraryItems(t){return Mn.getLibraryItems(this.adapter,t,!1)}};C(Mn,"queue",new l8),C(Mn,"run",async(t,o)=>{let n=new Mn(t);return Mn.queue.push(()=>o(n))});var Ni=Mn,El=0,Kc=0,hh=e=>`${e.id}:${e.name||""}:${c8(e.elements)}`,Zc=e=>d8(e.map(t=>hh(t)).sort().join()),ew=async(e,t)=>{try{return Kc++,await Ni.run(e,async o=>{let n=mh(await o.getLibraryItems("save"));for(let[l]of t.deletedItems)n.delete(l);let r=[];for(let[l,s]of t.addedItems)n.has(l)?n.set(l,s):r.push(s);if(t.updatedItems)for(let[l,s]of t.updatedItems)n.set(l,s);let i=r.concat(Array.from(n.values())),a=Zc(i);return a!==El&&await e.save({libraryItems:i}),El=a,i})}finally{Kc--}},h8=e=>{let{excalidrawAPI:t}=e,o=qy(e);o.current=e;let n=qy(!1);jy(()=>{if(!t)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let d=new Promise(async(c,p)=>{try{l=decodeURIComponent(l),l=a8(l),u8(l,o.current.validateLibraryUrl);let f=await(await fetch(l)).blob();c(f)}catch(u){p(u)}}),m=s!==t.id;await(m&&document.hidden?new Promise(c=>{window.addEventListener("focus",()=>c(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:d,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(c){throw t.updateScene({appState:{errorMessage:c.message}}),c}finally{if(window.location.hash.includes(ch.addLibrary)){let c=new URLSearchParams(window.location.hash.slice(1));c.delete(ch.addLibrary),window.history.replaceState({},Jy,`#${c.toString()}`)}else if(window.location.search.includes(dh.addLibrary)){let c=new URLSearchParams(window.location.search);c.delete(dh.addLibrary),window.history.replaceState({},Jy,`?${c.toString()}`)}}},i=l=>{l.preventDefault();let s=uh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=uh();if(a&&r(a),"getInitialLibraryItems"in o.current&&o.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(o.current.getInitialLibraryItems()).then(l=>{t.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in o.current&&o.current.adapter){let l=o.current.adapter,s=o.current.migrationAdapter,d=i8();s?d.resolve(Qy(s.load).then(async m=>{let c=null;try{if(!m)return Ni.getLibraryItems(l,"load");c=Ca(m.libraryItems||[],"published");let p=await ew(l,nw([],c));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}`),c}}).catch(m=>(console.error(`error during library migration: ${m.message}`),Ni.getLibraryItems(l,"load")))):d.resolve(Qy(Ni.getLibraryItems,l,"load")),t.updateLibrary({libraryItems:d.then(m=>{let c=m||[];return El=Zc(c),c}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(Xc.HASHCHANGE,i),()=>{window.removeEventListener(Xc.HASHCHANGE,i)}},[t]),jy(()=>{let r=tw.on(async(a,l)=>{let s=n.current,d="adapter"in o.current&&o.current.adapter||null;try{d&&El!==Zc(l)&&await ew(d,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&o.current.excalidrawAPI&&o.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{Kc&&r8(a)};return window.addEventListener(Xc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(Xc.BEFORE_UNLOAD,i),r(),El=0,Kc=0}},[])};import x8 from"clsx";import{VERSIONS as g8}from"@excalidraw/common";import{jsx as b8}from"react/jsx-runtime";var f8=({theme:e,id:t,libraryReturnUrl:o})=>{let n=o||window.location.origin+window.location.pathname;return b8("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${n}&useHash=true&token=${t}&theme=${e}&version=${g8.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},iw=f8;import{jsx as E8,jsxs as y8}from"react/jsx-runtime";var $c=({libraryReturnUrl:e,theme:t,id:o,style:n,children:r,className:i})=>y8("div",{className:x8("library-menu-control-buttons",i),style:n,children:[E8(iw,{id:o,libraryReturnUrl:e,theme:t}),r]});import{useCallback as zi,useEffect as wh,useMemo as vh,useRef as Nw,useState as Bw}from"react";import{MIME_TYPES as C7,arrayToMap as S7,nextAnimationFrame as k7}from"@excalidraw/common";import{duplicateElements as M7}from"@excalidraw/element";import P7 from"clsx";import w8 from"lodash.throttle";import{useEffect as v8}from"react";var T8=ge(0),aw=e=>{let[t,o]=de(T8);return v8(()=>{let{current:n}=e;if(!n)return;let r=w8(()=>{let{scrollTop:i}=n;o(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,o]),t};import t7 from"clsx";import{useCallback as o7,useState as xh}from"react";import{muteFSAbortError as n7}from"@excalidraw/common";import{flushSync as lw}from"react-dom";import I8 from"clsx";import{jsx as jc,jsxs as S8}from"react/jsx-runtime";var C8=({label:e,onClick:t,className:o,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return S8("button",{className:I8("Dialog__action-button",s,o),type:i,"aria-label":e,onClick:t,...l,children:[n&&jc("div",{style:a?{visibility:"hidden"}:{},children:n}),jc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&jc("div",{style:{position:"absolute",inset:0},children:jc(it,{})})]})},Zo=C8;import{jsx as sw,jsxs as cw}from"react/jsx-runtime";var k8=e=>{let{onConfirm:t,onCancel:o,children:n,confirmText:r=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=me(),d=pn(Oi),{container:m}=Be();return cw(He,{onCloseRequest:o,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,cw("div",{className:"confirm-dialog-buttons",children:[sw(Zo,{label:i,onClick:()=>{s({openMenu:null}),d(!1),lw(()=>{o()}),m?.focus()}}),sw(Zo,{label:r,onClick:()=>{s({openMenu:null}),d(!1),lw(()=>{t()}),m?.focus()},actionType:"danger"})]})]})},qc=k8;import Qc from"open-color";import{useCallback as R8,useEffect as bh,useRef as dw,useState as gh}from"react";import{EDITOR_LS_KEYS as fh,EXPORT_DATA_TYPES as N8,MIME_TYPES as mw,VERSIONS as B8,chunk as O8,getExportSource as F8}from"@excalidraw/common";var Xt=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(o){return console.warn(`localStorage.getItem error: ${o.message}`),!1}}static get(t){try{let o=window.localStorage.getItem(t);return o?JSON.parse(o):null}catch(o){return console.warn(`localStorage.getItem error: ${o.message}`),null}}};C(Xt,"set",(t,o)=>{try{return window.localStorage.setItem(t,JSON.stringify(o)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),C(Xt,"delete",t=>{try{window.localStorage.removeItem(t)}catch(o){console.warn(`localStorage.removeItem error: ${o.message}`)}});import Jc from"react";var M8=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,P8=/{{([\w-]+)}}/,L8=/<([\w-]+)>/,A8=/<\/([\w-]+)>/,D8=(e,t)=>{let o=[{name:"",children:[]}];return e.split(M8).filter(Boolean).forEach(n=>{let r=n.match(L8),i=n.match(A8),a=n.match(P8);if(r!==null){let l=r[1];t.hasOwnProperty(l)?o.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===o[o.length-1].name){let s=o.pop(),d=Jc.createElement(Jc.Fragment,{},...s.children),m=t[s.name];typeof m=="function"&&o[o.length-1].children.push(m(d))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(a!==null){let l=a[1];t.hasOwnProperty(l)?o[o.length-1].children.push(t[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else o[o.length-1].children.push(n)}),o.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),o[0].children},_8=({i18nKey:e,children:t,...o})=>{let{t:n}=Ne();return Jc.createElement(Jc.Fragment,{},...D8(n(e),o))},bt=_8;import{jsx as ue,jsxs as ct}from"react/jsx-runtime";var z8=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=O8(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=Qc.white,l.fillRect(0,0,a.width,a.height);for(let[s,d]of e.entries()){let m=await kn({elements:d.elements,files:null,maxWidthOrHeight:128}),{width:c,height:p}=m,u=Math.floor(s/6)*(128+n*2),f=s%6*(128+n*2);l.drawImage(m,f+(128-c)/2+n,u+(128-p)/2+n),l.lineWidth=r,l.strokeStyle=Qc.gray[4],l.strokeRect(f+n/2,u+n/2,128+n,128+n)}return await Es(new File([await Fo(a)],"preview",{type:mw.png}),{outputType:mw.jpg,maxWidthOrHeight:5e3})},H8=({libItem:e,appState:t,index:o,onChange:n,onRemove:r})=>{let i=dw(null),a=dw(null);return bh(()=>{let l=i.current;l&&(async()=>{let s=await _i({elements:e.elements,appState:{...t,viewBackgroundColor:Qc.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,t]),ct("div",{className:"single-library-item",children:[e.status==="published"&&ue("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),ue("div",{ref:i,className:"single-library-item__svg"}),ue(V,{"aria-label":g("buttons.remove"),type:"button",icon:Ht,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:g("buttons.remove")}),ct("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[ct("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[ct("div",{style:{padding:"0.5em 0"},children:[ue("span",{style:{fontWeight:500,color:Qc.gray[6]},children:g("publishDialog.itemName")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{n(l.target.value,o)}})]}),ue("span",{className:"error",children:e.error})]})]})},G8=({onClose:e,libraryItems:t,appState:o,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=gh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[d,m]=gh(!1);bh(()=>{let y=Xt.get(fh.PUBLISH_LIBRARY);y&&s(y)},[]);let[c,p]=gh(t.slice());bh(()=>{p(t.slice())},[t]);let u=y=>{s({...l,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),m(!0);let v=[],I=!1;if(c.forEach(_=>{let N="";_.name||(N=g("publishDialog.errors.required"),I=!0),v.push({..._,error:N})}),I){p(v),m(!1);return}let S=await z8(c),L={type:N8.excalidrawLibrary,version:B8.excalidrawLibrary,source:F8(),libraryItems:c},k=JSON.stringify(L,null,2),R=new Blob([k],{type:"application/json"}),M=new FormData;M.append("excalidrawLib",R),M.append("previewImage",S),M.append("previewImageType",S.type),M.append("title",l.name),M.append("authorName",l.authorName),M.append("githubHandle",l.githubHandle),M.append("name",l.name),M.append("description",l.description),M.append("twitterHandle",l.twitterHandle),M.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:M}).then(_=>_.ok?_.json().then(({url:N})=>{Xt.delete(fh.PUBLISH_LIBRARY),n({url:N,authorName:l.authorName,items:c})}):_.json().catch(()=>{throw new Error(_.statusText||"something went wrong")}).then(N=>{throw new Error(N.message||_.statusText||"something went wrong")}),_=>{console.error(_),r(_),m(!1)}).catch(_=>{console.error(_),r(_),m(!1)})},b=()=>{let y=[];return c.forEach((v,I)=>{y.push(ue("div",{className:"single-library-item-wrapper",children:ue(H8,{libItem:v,appState:o,index:I,onChange:(S,L)=>{let k=c.slice();k[L].name=S,p(k)},onRemove:a})},I))}),ue("div",{className:"selected-library-items",children:y})},x=R8(()=>{i(c),Xt.set(fh.PUBLISH_LIBRARY,l),e()},[c,e,i,l]),w=!!t.length,E=t.some(y=>y.status==="published");return ue(He,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:w?ct("form",{onSubmit:f,children:[ue("div",{className:"publish-library-note",children:ue(bt,{i18nKey:"publishDialog.noteDescription",link:y=>ue("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),ue("span",{className:"publish-library-note",children:ue(bt,{i18nKey:"publishDialog.noteGuidelines",link:y=>ue("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),ue("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&ue("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),ct("div",{className:"publish-library__fields",children:[ct("label",{children:[ct("div",{children:[ue("span",{children:g("publishDialog.libraryName")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),ct("label",{style:{alignItems:"flex-start"},children:[ct("div",{children:[ue("span",{children:g("publishDialog.libraryDesc")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),ct("label",{children:[ct("div",{children:[ue("span",{children:g("publishDialog.authorName")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),ct("label",{children:[ue("span",{children:g("publishDialog.githubUsername")}),ue("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),ct("label",{children:[ue("span",{children:g("publishDialog.twitterUsername")}),ue("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),ct("label",{children:[ue("span",{children:g("publishDialog.website")}),ue("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),ue("span",{className:"publish-library-note",children:ue(bt,{i18nKey:"publishDialog.noteLicense",link:y=>ue("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),ct("div",{className:"publish-library__buttons",children:[ue(Zo,{label:g("buttons.saveLibNames"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),ue(Zo,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:d})]})]}):ue("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},pw=G8;import Mw from"react";import W8 from"clsx";import{useEffect as V8,useRef as X8}from"react";import{EVENT as fw,KEYS as K8}from"@excalidraw/common";import{forwardRef as uw}from"react";import hw from"clsx";import{jsx as gw}from"react/jsx-runtime";var U8=uw(({children:e,gap:t,align:o,justifyContent:n,className:r,style:i},a)=>gw("div",{className:hw("Stack Stack_horizontal",r),style:{"--gap":t,alignItems:o,justifyContent:n,...i},ref:a,children:e})),Y8=uw(({children:e,gap:t,align:o,justifyContent:n,className:r,style:i},a)=>gw("div",{className:hw("Stack Stack_vertical",r),style:{"--gap":t,justifyItems:o,justifyContent:n,...i},ref:a,children:e})),It={Row:U8,Col:Y8};import{jsx as ed}from"react/jsx-runtime";var bw=({children:e,onClickOutside:t,className:o="",onSelect:n,style:r,placement:i="bottom"})=>{let a=he(),l=X8(null),s=gn({onClickOutside:t});ri(l,()=>{s.onClickOutside?.()}),V8(()=>{let m=p=>{p.key===K8.ESCAPE&&(p.stopImmediatePropagation(),s.onClickOutside?.())},c={capture:!0};return document.addEventListener(fw.KEYDOWN,m,c),()=>{document.removeEventListener(fw.KEYDOWN,m,c)}},[s]);let d=W8(`dropdown-menu ${o}`,{"dropdown-menu--mobile":a.editor.isMobile,"dropdown-menu--placement-top":i==="top"}).trim();return ed(Gp.Provider,{value:{onSelect:n},children:ed("div",{ref:l,className:d,style:r,"data-testid":"dropdown-menu",children:a.editor.isMobile?ed(It.Col,{className:"dropdown-menu-container",children:e}):ed(Ye,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};bw.displayName="DropdownMenuContent";var xw=bw;import{jsx as $8}from"react/jsx-runtime";var Z8=({children:e,className:t="",selected:o,...n})=>$8("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${o?"dropdown-menu-item--selected":""}`.trim(),children:e}),Ew=Z8;import{jsx as yw}from"react/jsx-runtime";var ww=({icon:e,shortcut:t,href:o,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let d=rc(s.onClick,r);return yw("a",{...s,href:o,target:"_blank",rel:l||"noopener",className:nc(i,a),title:s.title??s["aria-label"],onClick:d,children:yw(oc,{icon:e,shortcut:t,children:n})})},Fi=ww;ww.displayName="DropdownMenuItemLink";import{jsx as j8}from"react/jsx-runtime";var vw=()=>j8("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Tw=vw;vw.displayName="DropdownMenuSeparator";import q8 from"clsx";import{jsx as J8}from"react/jsx-runtime";var Iw=({className:e="",children:t,onToggle:o,title:n,...r})=>{let i=he(),a=q8(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return J8("button",{"data-prevent-outside-click":!0,className:a,onClick:o,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:t})},Cw=Iw;Iw.displayName="DropdownMenuTrigger";import td from"react";var Sw=e=>{let t=td.Children.toArray(e).find(o=>td.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName==="DropdownMenuTrigger");return t||null},kw=e=>{let t=td.Children.toArray(e).find(o=>td.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName==="DropdownMenuContent");return t||null};import{Fragment as Q8,jsxs as e7}from"react/jsx-runtime";var $o=({children:e,open:t,placement:o})=>{let n=Sw(e),r=kw(e),i=r&&Mw.isValidElement(r)?Mw.cloneElement(r,{placement:o}):r;return e7(Q8,{children:[n,t&&i]})};$o.Trigger=Cw;$o.Content=xw;$o.Item=ut;$o.ItemLink=Fi;$o.ItemCustom=Ew;$o.Group=Wa;$o.Separator=Tw;var le=$o;$o.displayName="DropdownMenu";import{jsx as Ct,jsxs as od}from"react/jsx-runtime";var r7=(e,t)=>e.filter(o=>t.includes(o.id)),i7=({setAppState:e,selectedItems:t,library:o,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=de(Ko),[d,m]=de(Oi),c=()=>{let M=t.length?g("alerts.removeItemsFromsLibrary",{count:t.length}):g("alerts.resetLibrary"),_=t.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return Ct(qc,{onConfirm:()=>{t.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:_,children:Ct("p",{children:M})})},[p,u]=xh(!1),f=!!t.length,b=f?s.libraryItems.filter(M=>t.includes(M.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[w,E]=xh(!1),[y,v]=xh(null),I=o7(()=>od(He,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Ct("p",{children:Ct(bt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:M=>Ct("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:M})})}),Ct(V,{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=(M,_)=>{E(!1),v({url:M.url,authorName:M.authorName});let N=_.slice();N.forEach(K=>{t.includes(K.id)&&(K.status="published")}),o.setLibrary(N)},L=async()=>{try{await o.updateLibrary({libraryItems:ms({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(M){if(M?.name==="AbortError"){console.warn(M);return}e({errorMessage:g("errors.importLibraryError")})}},k=async()=>{let M=f?b:await o.getLatestLibrary();_1(M).catch(n7).catch(_=>{e({errorMessage:_.message})})},R=()=>od(le,{open:d,children:[Ct(le.Trigger,{onToggle:()=>m(!d),children:ab}),od(le.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&Ct(le.Item,{onSelect:L,icon:Xr,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&Ct(le.Item,{onSelect:k,icon:or,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),f&&Ct(le.Item,{icon:h0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")}),!!b.length&&Ct(le.Item,{onSelect:()=>u(!0),icon:At,children:x})]})]});return od("div",{className:t7("library-menu-dropdown-container",l),children:[R(),t.length>0&&Ct("div",{className:"library-actions-counter",children:t.length}),p&&c(),w&&Ct(pw,{onClose:()=>E(!1),libraryItems:r7(s.libraryItems,t),appState:a,onSuccess:M=>S(M,s.libraryItems),onError:M=>window.alert(M),updateItemsInStorage:()=>o.setLibrary(s.libraryItems),onRemove:M=>i(t.filter(_=>_!==M))}),y&&I()]})},Pw=({selectedItems:e,onSelectItems:t,className:o})=>{let{library:n}=Fe(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=Ri(),a=xe(),l=me(),[s]=de(Ko),d=async c=>{let p=c.filter(u=>!e.includes(u.id));n.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return Ct(i7,{appState:a,setAppState:l,selectedItems:e,onSelectItems:t,library:n,onRemoveFromLibrary:()=>d(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:o})};import{memo as u7,useEffect as h7,useState as g7}from"react";import a7,{useCallback as l7}from"react";function s7(){return[!1,l7(t=>t(),[])]}var Lw=a7.useTransition||s7;import Aw from"clsx";import{memo as c7,useRef as d7,useState as m7}from"react";import{jsx as nd,jsxs as p7}from"react/jsx-runtime";var Dw=c7(({id:e,elements:t,isPending:o,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=d7(null),d=Vc(e,t,l,s),[m,c]=m7(!1),p=he().editor.isMobile,u=o&&nd("div",{className:"library-unit__adder",children:ib});return p7("div",{className:Aw("library-unit",{"library-unit__active":t,"library-unit--hover":t&&m,"library-unit--selected":r,"library-unit--skeleton":!d}),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[nd("div",{className:Aw("library-unit__dragger",{"library-unit__pulse":!!o}),ref:s,draggable:!!t,onClick:t||o?f=>{e&&f.shiftKey?i(e,f):n(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}c(!1),a(e,f)}}),u,e&&t&&(m||p||r)&&nd(Qa,{checked:r,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),_w=()=>nd("div",{className:"library-unit library-unit--skeleton"});import{Fragment as f7,jsx as rd}from"react/jsx-runtime";var id=({children:e})=>rd("div",{className:"library-menu-items-container__grid",children:e}),yl=u7(({items:e,onItemSelectToggle:t,onItemDrag:o,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Lw(),[s,d]=g7(0);return h7(()=>{s<e.length&&l(()=>{d(s+a)})},[s,e.length,l,a]),rd(f7,{children:e.map((m,c)=>c<s?rd(Dw,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:r,svgCache:i,id:m?.id,selected:n(m.id),onToggle:t,onDrag:o},m?.id??c):rd(_w,{},c))})});import Eh from"clsx";import{forwardRef as y7,useRef as w7,useImperativeHandle as v7,useLayoutEffect as T7,useState as I7}from"react";import b7 from"clsx";import{composeEventHandlers as x7}from"@excalidraw/common";import{jsx as E7}from"react/jsx-runtime";var xt=({type:e="button",onSelect:t,selected:o,children:n,className:r="",...i})=>E7("button",{onClick:x7(i.onClick,a=>{t()}),type:e,className:b7("excalidraw-button",r,{selected:o}),...i,children:n});import{jsx as yh,jsxs as Rw}from"react/jsx-runtime";var Pn=y7(({onChange:e,label:t,fullWidth:o,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:d,type:m,...c},p)=>{let u=w7(null);v7(p,()=>u.current),T7(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[f,b]=I7(!1);return Rw("div",{className:Eh("ExcTextField",d,{"ExcTextField--fullWidth":o,"ExcTextField--hasIcon":!!s}),onClick:()=>{u.current?.focus()},children:[s,t&&yh("div",{className:"ExcTextField__label",children:t}),Rw("div",{className:Eh("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[yh("input",{className:Eh({"is-redacted":"value"in c&&c.value&&l&&!f}),readOnly:r,value:"value"in c?c.value:void 0,defaultValue:"defaultValue"in c?c.defaultValue:void 0,placeholder:n,ref:u,onChange:x=>e?.(x.target.value),onKeyDown:a,type:m}),l&&yh(xt,{onSelect:()=>b(!f),style:{border:0,userSelect:"none"},children:f?w0:jr})]})]})});import{Fragment as Ow,jsx as et,jsxs as ko}from"react/jsx-runtime";var L7=17,A7=64;function Th({isLoading:e,libraryItems:t,onAddToLibrary:o,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:d}){let m=he(),c=Nw(null),p=aw(c);wh(()=>{p>0&&c.current?.scrollTo(0,p)},[]);let{svgCache:u}=Ri(),[f,b]=Bw(null),[x,w]=Bw(""),E=!t.length&&!r.length,y=!E&&!!x.trim(),v=vh(()=>{let H=gr(x.trim().toLowerCase());return H?t.filter(Y=>{let q=Y.name||"";return q.trim()&&gr(q.toLowerCase()).includes(H)}):[]},[t,x]),I=vh(()=>t.filter(H=>H.status!=="published"),[t]),S=vh(()=>t.filter(H=>H.status==="published"),[t]),L=zi((H,Y)=>{let q=!d.includes(H),pe=[...I,...S];if(q){if(Y.shiftKey&&f){let j=pe.findIndex(oo=>oo.id===f),ne=pe.findIndex(oo=>oo.id===H);if(j===-1||ne===-1){s([...d,H]);return}let we=S7(d),Pt=Math.min(j,ne),Lt=Math.max(j,ne),ln=pe.reduce((oo,sn,Pr)=>((Pr>=Pt&&Pr<=Lt||we.has(sn.id))&&oo.push(sn.id),oo),[]);s(ln)}else s([...d,H]);b(H)}else b(null),s(d.filter(j=>j!==H))},[f,s,S,d,I]);wh(()=>{d.length||b(null)},[d]);let k=zi(H=>{let Y;return d.includes(H)?Y=t.filter(q=>d.includes(q.id)):Y=t.filter(q=>q.id===H),Y.map(q=>({...q,elements:M7({type:"everything",elements:q.elements,randomizeSeed:!0}).duplicatedElements}))},[t,d]),R=zi((H,Y)=>{let q={itemIds:d.includes(H)?d:[H]};Y.dataTransfer.setData(C7.excalidrawlibIds,JSON.stringify(q))},[d]),M=zi(H=>H?d.includes(H):!1,[d]),_=zi(()=>{o(r)},[r,o]),N=zi(H=>{H&&n(k(H))},[k,n]),K=u.size>=(v.length?v:t).length?A7:L7,J=Nw(null);wh(()=>{k7(()=>{J.current?.focus()})},[]);let A=!y&&ko(Ow,{children:[!E&&et("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),!r.length&&!I.length?ko("div",{className:"library-menu-items__no-items",children:[!S.length&&et("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),et("div",{className:"library-menu-items__no-items__hint",children:S.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):ko(id,{children:[r.length>0&&et(yl,{itemsRenderedPerBatch:K,items:[{id:null,elements:r}],onItemSelectToggle:L,onItemDrag:R,onClick:_,isItemSelected:M,svgCache:u}),et(yl,{itemsRenderedPerBatch:K,items:I,onItemSelectToggle:L,onItemDrag:R,onClick:N,isItemSelected:M,svgCache:u})]}),S.length>0&&et("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:g("labels.excalidrawLib")}),S.length>0&&et(id,{children:et(yl,{itemsRenderedPerBatch:K,items:S,onItemSelectToggle:L,onItemDrag:R,onClick:N,isItemSelected:M,svgCache:u})})]}),B=y&&ko(Ow,{children:[ko("div",{className:"library-menu-items-container__header",children:[g("library.search.heading"),!e&&ko("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:H=>H.preventDefault(),onClick:H=>{w("")},children:[et("kbd",{children:"esc"})," to clear"]})]}),v.length>0?et(id,{children:et(yl,{itemsRenderedPerBatch:K,items:v,onItemSelectToggle:L,onItemDrag:R,onClick:N,isItemSelected:M,svgCache:u})}):ko("div",{className:"library-menu-items__no-items",children:[et("div",{className:"library-menu-items__no-items__hint",children:g("library.search.noResults")}),et(xt,{onPointerDown:H=>H.preventDefault(),onSelect:()=>{w("")},style:{width:"auto",marginTop:"1rem"},children:g("library.search.clearSearch")})]})]});return ko("div",{className:"library-menu-items-container",style:r.length||I.length||S.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[ko("div",{className:"library-menu-items-header",children:[!E&&et(Pn,{ref:J,type:"search",className:P7("library-menu-items-container__search",{hideCancelButton:!m.editor.isMobile}),placeholder:g("library.search.inputPlaceholder"),value:x,onChange:H=>w(H)}),et(Pw,{selectedItems:d,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),ko(It.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:S.length>0?1:"0 1 auto",margin:E?"auto":0},ref:c,children:[e&&et("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:et(it,{})}),A,B,E&&et($c,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i})]})]})}import{jsx as Ln,jsxs as Hw}from"react/jsx-runtime";var Oi=ge(!1),zw=({children:e})=>Ln("div",{className:"layer-ui__library",children:e}),H7=Yw(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:o,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:d})=>{let[m]=de(Ko),c=Ch(f=>{(async(x,w)=>{ie("element","addToLibrary","ui");for(let y of _7)if(x.some(v=>v.type===y))return n({errorMessage:g(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:R7(),created:Date.now()},...w];o(),i.setLibrary(E).catch(()=>{n({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[o,i,n,m.libraryItems]),p=Uw(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return Ln(zw,{children:Ln("div",{className:"layer-ui__library-message",children:Hw("div",{children:[Ln(it,{size:"2em"}),Ln("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||t.length>0;return Hw(zw,{children:[Ln(Th,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:c,onInsertLibraryItems:e,pendingElements:t,id:a,libraryReturnUrl:r,theme:l,onSelectItems:d,selectedItems:s}),u&&Ln($c,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),Ih=(e,t)=>({elements:e,pending:Q(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),G7=(e,t)=>{let o=xn(),[n,r]=Gw(()=>Ih(o,e.selectedElementIds)),i=D7(new Map);return Sh(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),Sh(()=>{t.state.cursorButton==="up"&&t.state.activeTool.type==="selection"&&r(a=>{if(!N7(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Ih(o,e.selectedElementIds);let l=t.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let d=l.get(s)?.version;if(d&&d!==i.current.get(s))return Ih(o,e.selectedElementIds)}return a})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,o]),n.pending},Ww=Yw(()=>{let e=Fe(),{onInsertElements:t}=e,o=To(),n=xe(),r=me(),[i,a]=Gw([]),l=Uw(()=>e.library,[e.library]),s=G7(n,e);Sh(()=>F7(document,z7.KEYDOWN,c=>{if(c.key===B7.ESCAPE&&c.target instanceof HTMLElement){let p=c.target;if(p.closest(`.${Fw.SIDEBAR}`))i.length>0?(c.stopPropagation(),a([])):O7(p)&&p instanceof HTMLInputElement&&!p.value&&(c.stopPropagation(),r({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:u,y:f}=e.lastViewportPosition;document.elementFromPoint(u,f)?.closest(`.${Fw.SIDEBAR}`)&&(c.stopPropagation(),a([]))}}},{capture:!0}),[i,r,e]);let d=Ch(c=>{t(Bi(c)),e.focusContainer()},[t,e]),m=Ch(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return Ln(H7,{pendingElements:s,onInsertLibraryItems:d,onAddToLibrary:m,setAppState:r,libraryReturnUrl:o.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import U7 from"clsx";import{useRef as Y7}from"react";import{createPortal as W7}from"react-dom";import{KEYS as V7}from"@excalidraw/common";import{jsx as Vw,jsxs as X7}from"react/jsx-runtime";var Xw=e=>{let{closeOnClickOutside:t=!0}=e,o=Vs({className:"excalidraw-modal-container"}),n=Y7(document.body.classList.contains("excalidraw-animations-disabled"));if(!o)return null;let r=i=>{i.key===V7.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return W7(X7("div",{className:U7("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Vw("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),Vw("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),o)};import{jsx as wl,jsxs as J7}from"react/jsx-runtime";function q7(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var He=e=>{let[t,o]=Xy(),[n]=$7(document.activeElement),{id:r}=Be(),i=he().viewport.isMobile;Z7(()=>{if(!t)return;let d=Kw(t);setTimeout(()=>{d.length>0&&e.autofocus!==!1&&(d[1]||d[0]).focus()});let m=c=>{if(c.key===j7.TAB){let p=Kw(t),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&c.shiftKey?(p[p.length-1].focus(),c.preventDefault()):f===p.length-1&&!c.shiftKey&&(p[0].focus(),c.preventDefault())}};return t.addEventListener("keydown",m),()=>t.removeEventListener("keydown",m)},[t,e.autofocus]);let a=me(),l=pn(Oi),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return wl(Xw,{className:K7("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:q7(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:J7(Ye,{ref:o,children:[e.title&&wl("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:wl("span",{className:"Dialog__titleContent",children:e.title})}),i&&wl("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Ht}),wl("div",{className:"Dialog__content",children:e.children})]})})};import{KEYS as Ge}from"@excalidraw/common";var ad=[{icon:tr,value:"selection",key:Ge.V,numericKey:Ge[1],fillable:!0},{icon:Hr,value:"rectangle",key:Ge.R,numericKey:Ge[2],fillable:!0},{icon:Gr,value:"diamond",key:Ge.D,numericKey:Ge[3],fillable:!0},{icon:Ur,value:"ellipse",key:Ge.O,numericKey:Ge[4],fillable:!0},{icon:Is,value:"arrow",key:Ge.A,numericKey:Ge[5],fillable:!0},{icon:Yr,value:"line",key:Ge.L,numericKey:Ge[6],fillable:!0},{icon:yo,value:"freedraw",key:[Ge.P,Ge.X],numericKey:Ge[7],fillable:!1},{icon:wo,value:"text",key:Ge.T,numericKey:Ge[8],fillable:!1},{icon:ka,value:"image",key:null,numericKey:Ge[9],fillable:!1},{icon:Cs,value:"eraser",key:Ge.E,numericKey:Ge[0],fillable:!1}],kh=e=>e.state.preferredSelectionTool.type==="lasso"?[{value:"lasso",icon:tr,key:Ge.V,numericKey:Ge[1],fillable:!0},...ad.slice(1)]:ad,Zw=(e,t)=>kh(t).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 Po from"clsx";import{useRef as rD,useState as iD}from"react";import*as Lo from"@radix-ui/react-popover";import{CLASSES as t2,KEYS as Jw,capitalizeString as Ui,isTransparent as sd}from"@excalidraw/common";import{shouldAllowVerticalAlign as o2,suppportsHorizontalAlign as n2,hasBoundTextElement as cd,isElbowArrow as Lh,isImageElement as r2,isLinearElement as Ah,isTextElement as md,isArrowElement as Qw,hasStrokeColor as e2,toolIsArrow as dd}from"@excalidraw/element";import{createIsolation as Q7}from"jotai-scope";import Mh from"react";import Mo from"tunnel-rat";var Ph=Mh.createContext(null),Ce=()=>Mh.useContext(Ph),eD=Q7(),$w=()=>Mh.useMemo(()=>({MainMenuTunnel:Mo(),WelcomeScreenMenuHintTunnel:Mo(),WelcomeScreenToolbarHintTunnel:Mo(),WelcomeScreenHelpHintTunnel:Mo(),WelcomeScreenCenterTunnel:Mo(),FooterCenterTunnel:Mo(),DefaultSidebarTriggerTunnel:Mo(),DefaultSidebarTabTriggersTunnel:Mo(),OverwriteConfirmDialogTunnel:Mo(),TTDDialogTriggerTunnel:Mo(),tunnelsJotai:eD}),[]);import{useEffect as tD,useState as oD}from"react";import jw from"clsx";import{capitalizeString as qw}from"@excalidraw/common";import*as Hi from"@radix-ui/react-popover";import{jsx as ld,jsxs as nD}from"react/jsx-runtime";var Gi=({app:e,options:t,activeTool:o,defaultOption:n,className:r="Shape",namePrefix:i,title:a,"data-testid":l,onToolChange:s,displayedOption:d,fillable:m=!1})=>{let[c,p]=oD(!1),u=o.type,f=d.type===u,b=32/2+10;return!t.some(x=>x.type===u)&&c&&p(!1),tD(()=>{let x=e.onPointerDownEmitter.on(()=>{p(!1)});return()=>x?.()},[e]),nD(Hi.Root,{open:c,children:[ld(Hi.Trigger,{asChild:!0,children:ld(V,{className:jw(r,{fillable:m,active:t.some(x=>x.type===o.type)}),type:"radio",icon:d.icon,checked:f,name:"editor-current-shape",title:a,"aria-label":a,"data-testid":l,onPointerDown:()=>{p(x=>!x),s(n)}})}),ld(Hi.Content,{className:"tool-popover-content",sideOffset:b,children:t.map(({type:x,icon:w,title:E})=>ld(V,{className:jw(r,{active:u===x}),type:"radio",icon:w,checked:u===x,name:`${i}-option`,title:E||qw(x),keyBindingLabel:"","aria-label":E||qw(x),"data-testid":`toolbar-${x}`,onChange:()=>{e.state.activeTool.type!==x&&ie("toolbar",x,"ui"),e.setActiveTool({type:x}),s?.(x)}},x))})]})};import{Fragment as Ot,jsx as X,jsxs as ce}from"react/jsx-runtime";var Dh=Po([t2.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),vl=(e,t)=>{let o=t[0]?.type||null;for(let n of t)if(n.type!==o){o=null;break}return e2(e.activeTool.type)&&o!=="image"&&o!=="frame"&&o!=="magicframe"||t.some(n=>e2(n.type))},Tl=(e,t)=>xo(e.activeTool.type)||t.some(o=>xo(o.type)),i2=({appState:e,elementsMap:t,renderAction:o,app:n})=>{let r=Lr(t,e),i=!1;r.length===2&&(cd(r[0])||cd(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=he(),s=document.documentElement.getAttribute("dir")==="rtl",d=xo(e.activeTool.type)&&!sd(e.currentItemBackgroundColor)||r.some(f=>xo(f.type)&&!sd(f.backgroundColor)),m=r.length===1||i,c=!e.selectedLinearElement?.isEditing&&r.length===1&&Ah(r[0])&&!Lh(r[0]),p=!e.croppingElementId&&r.length===1&&r2(r[0]),u=!i&&ft(e,n);return ce("div",{className:"selected-shape-actions",children:[X("div",{children:vl(e,r)&&o("changeStrokeColor")}),Tl(e,r)&&X("div",{children:o("changeBackgroundColor")}),d&&o("changeFillStyle"),(Ea(e.activeTool.type)||r.some(f=>Ea(f.type)))&&o("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(f=>f.type==="freedraw"))&&o("changeStrokeShape"),(ya(e.activeTool.type)||r.some(f=>ya(f.type)))&&ce(Ot,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(wa(e.activeTool.type)||r.some(f=>wa(f.type)))&&X(Ot,{children:o("changeRoundness")}),(dd(e.activeTool.type)||r.some(f=>dd(f.type)))&&X(Ot,{children:o("changeArrowType")}),(e.activeTool.type==="text"||r.some(md))&&ce(Ot,{children:[o("changeFontFamily"),o("changeFontSize"),(e.activeTool.type==="text"||n2(r,t))&&o("changeTextAlign")]}),o2(r,t)&&o("changeVerticalAlign"),(Ar(e.activeTool.type)||r.some(f=>Ar(f.type)))&&X(Ot,{children:o("changeArrowhead")}),o("changeOpacity"),ce("fieldset",{children:[X("legend",{children:g("labels.layers")}),ce("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),u&&!i&&ce("fieldset",{children:[X("legend",{children:g("labels.align")}),ce("div",{className:"buttonList",children:[s?ce(Ot,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):ce(Ot,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),r.length>2&&o("distributeHorizontally"),X("div",{style:{flexBasis:"100%",height:0}}),ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),r.length>2&&o("distributeVertically")]})]})]}),!a&&r.length>0&&ce("fieldset",{children:[X("legend",{children:g("labels.actions")}),ce("div",{className:"buttonList",children:[!l.editor.isMobile&&o("duplicateSelection"),!l.editor.isMobile&&o("deleteSelectedElements"),o("group"),o("ungroup"),m&&o("hyperlink"),p&&o("cropEditor"),c&&o("toggleLinearEditor")]})]})]})},a2=({appState:e,renderAction:t,setAppState:o,targetElements:n,container:r})=>{let i=xo(e.activeTool.type)&&!sd(e.currentItemBackgroundColor)||n.some(s=>xo(s.type)&&!sd(s.backgroundColor)),a=n.length>0||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",l=e.openPopup==="compactStrokeStyles";return a?X("div",{className:"compact-action-item",children:ce(Lo.Root,{open:l,onOpenChange:s=>{o(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[X(Lo.Trigger,{asChild:!0,children:X("button",{type:"button",className:Po("compact-action-button properties-trigger",{active:l}),title:g("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),o({openPopup:l?null:"compactStrokeStyles"})},children:G0})}),l&&X(Ho,{className:Dh,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:ce("div",{className:"selected-shape-actions",children:[i&&t("changeFillStyle"),(Ea(e.activeTool.type)||n.some(s=>Ea(s.type)))&&t("changeStrokeWidth"),(ya(e.activeTool.type)||n.some(s=>ya(s.type)))&&ce(Ot,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(wa(e.activeTool.type)||n.some(s=>wa(s.type)))&&t("changeRoundness"),t("changeOpacity")]})})]})}):null},l2=({appState:e,renderAction:t,setAppState:o,targetElements:n,container:r,app:i})=>{let a=dd(e.activeTool.type)||n.some(s=>dd(s.type)),l=e.openPopup==="compactArrowProperties";return a?X("div",{className:"compact-action-item",children:ce(Lo.Root,{open:l,onOpenChange:s=>{o(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[X(Lo.Trigger,{asChild:!0,children:X("button",{type:"button",className:Po("compact-action-button properties-trigger",{active:l}),title:g("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),o({openPopup:l?null:"compactArrowProperties"})},children:(()=>{let s=st(n,i,d=>Qw(d)?d.elbowed?"elbow":d.roundness?"round":"sharp":null,d=>Qw(d),d=>d?null:e.currentItemArrowType);return s==="elbow"?Jr:s==="round"?Qr:qr})()})}),l&&X(Ho,{container:r,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:t("changeArrowProperties")})]})}):null},s2=({appState:e,renderAction:t,setAppState:o,targetElements:n,container:r,elementsMap:i})=>{let{saveCaretPosition:a,restoreCaretPosition:l}=nx(),s=e.openPopup==="compactTextProperties";return X("div",{className:"compact-action-item",children:ce(Lo.Root,{open:s,onOpenChange:d=>{d?(e.editingTextElement&&a(),o({openPopup:"compactTextProperties"})):(o({openPopup:null}),e.editingTextElement&&l())},children:[X(Lo.Trigger,{asChild:!0,children:X("button",{type:"button",className:Po("compact-action-button properties-trigger",{active:s}),title:g("labels.textAlign"),onClick:d=>{d.preventDefault(),d.stopPropagation(),s?o({openPopup:null}):(e.editingTextElement&&a(),o({openPopup:"compactTextProperties"}))},children:hb})}),e.openPopup==="compactTextProperties"&&X(Ho,{className:Dh,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:ce("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||n.some(md))&&t("changeFontSize"),(e.activeTool.type==="text"||n2(n,i))&&t("changeTextAlign"),o2(n,i)&&t("changeVerticalAlign")]})})]})})},c2=({appState:e,renderAction:t,targetElements:o,setAppState:n,container:r,app:i,showDuplicate:a,showDelete:l})=>{let s=!!(e.editingTextElement||e.newElement),d=!e.croppingElementId&&o.length===1&&r2(o[0]),m=o.length===1,c=ft(e,i),p=!1;o.length===2&&(cd(o[0])||cd(o[1]))&&(p=!0);let u=document.documentElement.getAttribute("dir")==="rtl",f=e.openPopup==="compactOtherProperties";return s||o.length===0?null:X("div",{className:"compact-action-item",children:ce(Lo.Root,{open:f,onOpenChange:b=>{n(b?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[X(Lo.Trigger,{asChild:!0,children:X("button",{type:"button",className:Po("compact-action-button properties-trigger",{active:f}),title:g("labels.actions"),onClick:b=>{b.preventDefault(),b.stopPropagation(),n({openPopup:f?null:"compactOtherProperties"})},children:lb})}),f&&X(Ho,{className:Dh,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:ce("div",{className:"selected-shape-actions",children:[ce("fieldset",{children:[X("legend",{children:g("labels.layers")}),ce("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),c&&!p&&ce("fieldset",{children:[X("legend",{children:g("labels.align")}),ce("div",{className:"buttonList",children:[u?ce(Ot,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ce(Ot,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),o.length>2&&t("distributeHorizontally"),X("div",{style:{flexBasis:"100%",height:0}}),ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),o.length>2&&t("distributeVertically")]})]})]}),ce("fieldset",{children:[X("legend",{children:g("labels.actions")}),ce("div",{className:"buttonList",children:[t("group"),t("ungroup"),m&&t("hyperlink"),d&&t("cropEditor"),a&&t("duplicateSelection"),l&&t("deleteSelectedElements")]})]})]})})]})})},aD=({appState:e,renderAction:t,targetElements:o})=>!e.selectedLinearElement?.isEditing&&o.length===1&&Ah(o[0])&&!Lh(o[0])?X("div",{className:"compact-action-item",children:t("toggleLinearEditor")}):null,d2=({appState:e,elementsMap:t,renderAction:o,app:n,setAppState:r})=>{let i=Lr(t,e),{container:a}=Be(),l=!!(e.editingTextElement||e.newElement),s=!e.selectedLinearElement?.isEditing&&i.length===1&&Ah(i[0])&&!Lh(i[0]);return ce("div",{className:"compact-shape-actions",children:[vl(e,i)&&X("div",{className:Po("compact-action-item"),children:o("changeStrokeColor")}),Tl(e,i)&&X("div",{className:"compact-action-item",children:o("changeBackgroundColor")}),X(a2,{appState:e,renderAction:o,setAppState:r,targetElements:i,container:a}),X(l2,{appState:e,renderAction:o,setAppState:r,targetElements:i,container:a,app:n}),s&&X("div",{className:"compact-action-item",children:o("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(md))&&ce(Ot,{children:[X("div",{className:"compact-action-item",children:o("changeFontFamily")}),X(s2,{appState:e,renderAction:o,setAppState:r,targetElements:i,container:a,elementsMap:t})]}),!l&&i.length>0&&X("div",{className:"compact-action-item",children:o("duplicateSelection")}),!l&&i.length>0&&X("div",{className:"compact-action-item",children:o("deleteSelectedElements")}),X(c2,{appState:e,renderAction:o,targetElements:i,setAppState:r,container:a,app:n})]})},m2=({appState:e,elementsMap:t,renderAction:o,app:n,setAppState:r})=>{let i=Lr(t,e),{container:a}=Be(),l=rD(null),s=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,c=32,p=d*c+(d-1)*m,u=c+m,f=s>=p+u,b=s>=p+2*u;return ce(Ye,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:c*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:l,children:[ce("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[vl(e,i)&&X("div",{className:Po("compact-action-item"),children:o("changeStrokeColor")}),Tl(e,i)&&X("div",{className:"compact-action-item",children:o("changeBackgroundColor")}),X(a2,{appState:e,renderAction:o,setAppState:r,targetElements:i,container:a}),X(l2,{appState:e,renderAction:o,setAppState:r,targetElements:i,container:a,app:n}),X(aD,{appState:e,renderAction:o,targetElements:i}),(e.activeTool.type==="text"||i.some(md))&&ce(Ot,{children:[X("div",{className:"compact-action-item",children:o("changeFontFamily")}),X(s2,{appState:e,renderAction:o,setAppState:r,targetElements:i,container:a,elementsMap:t})]}),X(c2,{appState:e,renderAction:o,targetElements:i,setAppState:r,container:a,app:n,showDuplicate:!b,showDelete:!f})]}),ce("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[X("div",{className:"compact-action-item",children:o("undo")}),X("div",{className:"compact-action-item",children:o("redo")}),b&&X("div",{className:"compact-action-item",children:o("duplicateSelection")}),f&&X("div",{className:"compact-action-item",children:o("deleteSelectedElements")})]})]})},p2=({activeTool:e,setAppState:t,app:o,UIOptions:n})=>{let[r,i]=iD(!1),a=[{type:"selection",icon:tr,title:Ui(g("toolBar.selection"))},{type:"lasso",icon:un,title:Ui(g("toolBar.lasso"))}],l=e.type==="frame",s=e.type==="laser",d=o.state.stylesPanelMode==="full"&&e.type==="lasso"&&o.state.preferredSelectionTool.type!=="lasso",m=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=Ce();return ce(Ot,{children:[kh(o).map(({value:p,icon:u,key:f,numericKey:b,fillable:x},w)=>{if(n.tools?.[p]===!1)return null;let E=g(`toolBar.${p}`),y=f&&Ui(typeof f=="string"?f:f[0]),v=y?`${y} ${g("helpDialog.or")} ${b}`:`${b}`;return(p==="selection"||p==="lasso")&&o.state.stylesPanelMode==="compact"?X(Gi,{app:o,options:a,activeTool:e,defaultOption:o.state.preferredSelectionTool.type,namePrefix:"selectionType",title:Ui(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:I=>{(I==="selection"||I==="lasso")&&(o.setActiveTool({type:I}),t({preferredSelectionTool:{type:I,initialized:!0}}))},displayedOption:a.find(I=>I.type===o.state.preferredSelectionTool.type)||a[0],fillable:e.type==="selection"},"selection-popover"):X(V,{className:Po("Shape",{fillable:x}),type:"radio",icon:u,checked:e.type===p,name:"editor-current-shape",title:`${Ui(E)} \u2014 ${v}`,keyBindingLabel:b||y,"aria-label":Ui(E),"aria-keyshortcuts":v,"data-testid":`toolbar-${p}`,onPointerDown:({pointerType:I})=>{!o.state.penDetected&&I==="pen"&&o.togglePenMode(!0),p==="selection"&&(o.state.activeTool.type==="selection"?o.setActiveTool({type:"lasso"}):o.setActiveTool({type:"selection"}))},onChange:({pointerType:I})=>{o.state.activeTool.type!==p&&ie("toolbar",p,"ui"),p==="image"?o.setActiveTool({type:p}):o.setActiveTool({type:p})}},p)}),X("div",{className:"App-toolbar__divider"}),ce(le,{open:r,children:[X(le.Trigger,{className:Po("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":l||m||d||s&&!o.props.isCollaborating}),onToggle:()=>i(!r),title:g("toolBar.extraTools"),children:l?io:m?Wr:s&&!o.props.isCollaborating?hn:d?un:_a}),ce(le.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[X(le.Item,{onSelect:()=>o.setActiveTool({type:"frame"}),icon:io,shortcut:Jw.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:l,children:g("toolBar.frame")}),X(le.Item,{onSelect:()=>o.setActiveTool({type:"embeddable"}),icon:Wr,"data-testid":"toolbar-embeddable",selected:m,children:g("toolBar.embeddable")}),X(le.Item,{onSelect:()=>o.setActiveTool({type:"laser"}),icon:hn,"data-testid":"toolbar-laser",selected:s,shortcut:Jw.K.toLocaleUpperCase(),children:g("toolBar.laser")}),o.state.stylesPanelMode==="full"&&X(le.Item,{onSelect:()=>o.setActiveTool({type:"lasso"}),icon:un,"data-testid":"toolbar-lasso",selected:d,children:g("toolBar.lasso")}),X("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),o.props.aiEnabled!==!1&&X(c.Out,{}),X(le.Item,{onSelect:()=>o.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Zr,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),o.props.aiEnabled!==!1&&o.plugins.diagramToCode&&ce(le.Item,{onSelect:()=>o.onMagicframeToolSelect(),icon:rr,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),X(le.Item.Badge,{children:"AI"})]})]})]})]})},u2=({renderAction:e,zoom:t})=>X(It.Col,{gap:1,className:t2.ZOOM_ACTIONS,children:ce(It.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),h2=({renderAction:e,className:t})=>ce("div",{className:`undo-redo-buttons ${t}`,children:[X("div",{className:"undo-button-container",children:X(_t,{label:g("buttons.undo"),children:e("undo")})}),X("div",{className:"redo-button-container",children:ce(_t,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),g2=({actionManager:e,showExitZenModeBtn:t})=>X("button",{type:"button",className:Po("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(Ci),children:g("buttons.exitZenMode")});import{useRef as lD}from"react";var _h=e=>{let t=lD({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...o)=>t.current.userFn(...o)),t.current.stableFn};import{jsx as cD,jsxs as sD}from"react/jsx-runtime";var br=ge(null),f2=()=>{let[e,t]=de(br),o=Ve();return e&&e==="clearCanvas"?cD(qc,{onConfirm:()=>{o.executeAction(Vo),t(null)},onCancel:()=>t(null),title:g("clearCanvasDialog.title"),children:sD("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var Rh={};k1(Rh,{toggleTheme:()=>dD});var dD={...sr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(sr,"commandPalette")}};import{jsx as tt,jsxs as Ao}from"react/jsx-runtime";var fD=ge(null),Pe={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},x2=e=>{switch(e){case Pe.app:return 1;case Pe.export:return 2;case Pe.editor:return 3;case Pe.tools:return 4;case Pe.elements:return 5;case Pe.links:return 6;default:return 10}},hd=({shortcut:e,className:t,children:o})=>{let n=e.replace("++","+$").split("+");return Ao("div",{className:y2("shortcut",t),children:[n.map((r,i)=>tt("div",{className:"shortcut-wrapper",children:tt("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),tt("div",{className:"shortcut-desc",children:o})]})},v2=e=>!e.altKey&&e[uo.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===uo.P||e.key===uo.SLASH),kme=Object.assign(e=>{let t=xe(),o=me();return ud(()=>{let n=r=>{v2(r)&&(r.preventDefault(),r.stopPropagation(),o(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ie("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(gd.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(gd.KEYDOWN,n,{capture:!0})},[o]),t.openDialog?.name!=="commandPalette"?null:tt(bD,{...e})},{defaultItems:Rh});function bD({customCommandPaletteItems:e}){let t=Fe(),o=xe(),n=me(),r=To(),i=Ve(),[a,l]=de(fD),[s,d]=pd(null),m=w2(null),c=gn({uiAppState:o,customCommandPaletteItems:e,appProps:r}),[p]=de(Ko),u=pD(()=>p.libraryItems?.filter(k=>!!k.name).map(k=>({label:k.name,icon:tt(xD,{id:k.id,elements:k.elements}),category:"Library",order:x2("Library"),haystack:gr(k.name),perform:()=>{t.onInsertElements(Bi([k]))}}))||[],[t,p.libraryItems]);ud(()=>{let{uiAppState:k,customCommandPaletteItems:R,appProps:M}=c,_=A=>{let B="";return A.label&&(typeof A.label=="function"?B=g(A.label(t.scene.getNonDeletedElements(),k,t)):B=g(A.label)),B},N=A=>typeof A.icon=="function"?A.icon(k,t.scene.getNonDeletedElements()):A.icon,K=[],J=(A,B,H)=>{let Y={label:_(A),icon:N(A),category:B,shortcut:ze(A.name),keywords:A.keywords,predicate:A.predicate,viewMode:A.viewMode,perform:()=>{i.executeAction(A,"commandPalette")}};return H?H(Y,A):Y};if(k&&t.scene&&i){let A=[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,dl,Wc,Wy].map(j=>J(j,Pe.elements,(ne,we)=>({...ne,predicate:we.predicate?we.predicate:(Pt,Lt,ln,oo)=>Q(Pt,Lt).length>0}))),B=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(j=>J(j,Pe.tools)),H=[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(j=>J(j,Pe.editor)),Y=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(j=>J(j,Pe.export));K=[...A,...H,{label:_(Vo),icon:N(Vo),shortcut:ze(Vo.name),category:Pe.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{We.set(br,"clearCanvas")}},{label:g("buttons.exportImage"),category:Pe.export,icon:Ps,shortcut:ze("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...Y];let q=[{label:g("toolBar.library"),category:Pe.app,icon:Fr,viewMode:!1,perform:()=>{k.openSidebar?n({openSidebar:null}):n({openSidebar:{name:b2.name,tab:b2.defaultTab}})}},{label:g("search.title"),category:Pe.app,icon:Dt,viewMode:!0,perform:()=>{i.executeAction(Il)}},{label:g("labels.shapeSwitch"),category:Pe.elements,icon:Ra,perform:()=>{i.executeAction(Yy)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Pe.elements,icon:Ms,viewMode:!1,predicate:(j,ne)=>{let we=Q(j,ne);return we.length>0&&vl(ne,we)},perform:()=>{n(j=>({openMenu:j.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:Ms,category:Pe.elements,viewMode:!1,predicate:(j,ne)=>{let we=Q(j,ne);return we.length>0&&Tl(ne,we)},perform:()=>{n(j=>({openMenu:j.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:Ms,category:Pe.editor,viewMode:!1,perform:()=>{n(j=>({openMenu:j.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...ad.reduce((j,ne)=>{let{value:we,icon:Pt,key:Lt,numericKey:ln}=ne;if(M.UIOptions.tools?.[we]===!1)return j;let sn=Lt&&uD(typeof Lt=="string"?Lt:Lt[0])||ln,Pr={label:g(`toolBar.${we}`),category:Pe.tools,shortcut:sn,icon:Pt,keywords:["toolbar"],viewMode:!1,perform:({event:Fm})=>{we==="image"?t.setActiveTool({type:we}):t.setActiveTool({type:we})}};return j.push(Pr),j},[]),...B,{label:g("toolBar.lock"),category:Pe.tools,icon:k.activeTool.locked?zr:er,shortcut:uo.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Pe.tools,icon:T0,viewMode:!1,predicate:M.aiEnabled,perform:()=>{n(j=>({...j,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Pe.tools,icon:Zr,viewMode:!1,predicate:M.aiEnabled,perform:()=>{n(j=>({...j,openDialog:{name:"ttd",tab:"mermaid"}}))}}],pe=[...K,...q,...R||[]].map(j=>({...j,icon:j.icon||Ra,order:j.order??x2(j.category),haystack:`${gr(j.label.toLocaleLowerCase())} ${j.keywords?.join(" ")||""}`}));d(pe),l([...pe,...u].find(j=>j.label===a?.label)??null)}},[c,t,i,d,a?.label,l,n,u]);let[f,b]=pd(""),[x,w]=pd(null),[E,y]=pd({}),v=k=>{n({openDialog:null},k),b("")},I=(k,R)=>{o.openDialog?.name==="commandPalette"&&(R.stopPropagation(),R.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),v(()=>{k.perform({actionManager:i,event:R}),l(k),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},S=_h(k=>k.viewMode===!1&&o.viewModeEnabled?!1:typeof k.predicate=="function"?k.predicate(t.scene.getNonDeletedElements(),o,r,t):k.predicate===void 0||k.predicate),L=_h(k=>{let R=gD(k.target)||v2(k)||k.key===uo.ESCAPE;if(R&&k.key!==uo.ARROW_UP&&k.key!==uo.ARROW_DOWN&&k.key!==uo.ENTER)return;let M=Object.values(E).flat(),_=a&&!f&&S(a);if(k.key===uo.ARROW_UP){k.preventDefault();let N=M.findIndex(A=>A.label===x?.label);if(_){if(N===0){w(a);return}if(x===a){let A=M[M.length-1];A&&w(A);return}}let K;N===-1?K=M.length-1:K=N===0?M.length-1:(N-1)%M.length;let J=M[K];J&&w(J);return}if(k.key===uo.ARROW_DOWN){k.preventDefault();let N=M.findIndex(A=>A.label===x?.label);if(_){if(!x||N===M.length-1){w(a);return}if(x===a){let A=M[0];A&&w(A);return}}let K=(N+1)%M.length,J=M[K];J&&w(J);return}if(k.key===uo.ENTER&&x&&setTimeout(()=>{I(x,k)}),!R){if(k.stopPropagation(),/^[a-zA-Z0-9]$/.test(k.key)){m?.current?.focus();return}k.preventDefault()}});return ud(()=>(window.addEventListener(gd.KEYDOWN,L,{capture:!0}),()=>window.removeEventListener(gd.KEYDOWN,L,{capture:!0})),[L]),ud(()=>{if(!s)return;let k=N=>{let K={};for(let J of N)K[J.category]?K[J.category].push(J):K[J.category]=[J];return K},R=f?.length>1?[...s,...u]:s.filter(S).sort((N,K)=>N.order-K.order),M=!f&&a&&S(a);if(!f){y(k(M?R.filter(N=>N.label!==a?.label):R)),w(M?a:R[0]||null);return}let _=gr(f.toLocaleLowerCase().replace(/[<>_| -]/g,""));R=mD.filter(_,R,{extract:N=>N.haystack??""}).sort((N,K)=>K.score-N.score).map(N=>N.original),y(k(R)),w(R[0]??null)},[f,s,S,a,u]),Ao(He,{onCloseRequest:()=>v(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[tt(Pn,{value:f,placeholder:g("commandPalette.search.placeholder"),onChange:k=>{b(k)},selectOnRender:!0,ref:m}),!t.device.viewport.isMobile&&Ao("div",{className:"shortcuts-wrapper",children:[tt(hd,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),tt(hd,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),tt(hd,{shortcut:hD("Esc"),children:g("commandPalette.shortcuts.close")})]}),Ao("div",{className:"commands",children:[a&&!f&&Ao("div",{className:"command-category",children:[Ao("div",{className:"command-category-title",children:[g("commandPalette.recents"),tt("div",{className:"icon",style:{marginLeft:"6px"},children:I0})]}),tt(E2,{command:a,isSelected:a.label===x?.label,onClick:k=>I(a,k),disabled:!S(a),onMouseMove:()=>w(a),showShortcut:!t.device.viewport.isMobile,appState:o})]}),Object.keys(E).length>0?Object.keys(E).map((k,R)=>Ao("div",{className:"command-category",children:[tt("div",{className:"command-category-title",children:k}),E[k].map(M=>tt(E2,{command:M,isSelected:M.label===x?.label,onClick:_=>I(M,_),onMouseMove:()=>w(M),showShortcut:!t.device.viewport.isMobile,appState:o,size:k==="Library"?"large":"small"},M.label))]},k)):s?Ao("div",{className:"no-match",children:[tt("div",{className:"icon",children:Dt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var xD=({id:e,elements:t})=>{let o=w2(null),{svgCache:n}=Ri();return Vc(e,t,n,o),tt("div",{className:"library-item-icon",ref:o})},E2=({command:e,isSelected:t,disabled:o,onMouseMove:n,onClick:r,showShortcut:i,appState:a,size:l="small"})=>{let s=()=>{};return Ao("div",{className:y2("command-item",{"item-selected":t,"item-disabled":o,"command-item-large":l==="large"}),ref:d=>{t&&!o&&d?.scrollIntoView?.({block:"nearest"})},onClick:o?s:r,onMouseMove:o?s:n,title:o?g("commandPalette.itemNotAvailable"):"",children:[Ao("div",{className:"name",children:[e.icon&&tt(vn,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(a):e.icon}),tt(Va,{children:e.label})]}),i&&e.shortcut&&tt(hd,{shortcut:e.shortcut})]})};import{getSizeFromPoints as v0e,randomInteger as f_,getUpdatedTimestamp as b_}from"@excalidraw/common";import{simplify as a_}from"points-on-curve";import{pointsOnBezierCurves as Dme}from"points-on-curve";import{invariant as Rme}from"@excalidraw/common";import{curve as Bme,lineSegment as Ome,pointFrom as Fme,pointDistance as zme,pointFromArray as Hme,pointFromVector as Gme,pointRotateRads as Ume,polygon as Yme,polygonFromPoints as Wme,PRECISION as Vme,segmentsIntersectAt as Xme,vector as Kme,vectorAdd as Zme,vectorFromPoint as $me,vectorScale as jme}from"@excalidraw/math";import{getElementAbsoluteCoords as Jme}from"@excalidraw/element";var Nh=e=>{if(!e)return[];for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops};import{pointFrom as l_,pointDistance as W2,pointRotateRads as a0e}from"@excalidraw/math";import{ROUGHNESS as s_,isTransparent as Pl,assertNever as c_,COLOR_PALETTE as d_,LINE_POLYGON_POINT_MERGE_DISTANCE as s0e}from"@excalidraw/common";import{RoughGenerator as m_}from"roughjs/bin/generator";import Ebe from"roughjs/bin/rough";import{getStroke as JD}from"perfect-freehand";import{isRightAngleRads as vbe,lineSegment as Tbe,pointFrom as Ibe,pointRotateRads as Cbe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as kbe,DEFAULT_REDUCED_GLOBAL_ALPHA as Mbe,ELEMENT_READY_TO_ERASE_OPACITY as Pbe,FRAME_STYLE as Lbe,MIME_TYPES as H2,THEME as Abe,distance as Dbe,getFontString as _be,isRTL as Rbe,getVerticalOffset as Nbe,invariant as Bbe}from"@excalidraw/common";import Afe from"roughjs/bin/rough";import{arrayToMap as _fe,invariant as D2,rescalePoints as Rfe,sizeOf as Nfe}from"@excalidraw/common";import{degreesToRadians as Xh,lineSegment as Ofe,pointDistance as Ffe,pointFrom as at,pointFromArray as BD,pointRotateRads as Ki}from"@excalidraw/math";import{pointsOnBezierCurves as Gfe}from"points-on-curve";import{pointCenter as $ge,pointFrom as jge,pointRotateRads as qge,pointsEqual as Jge,pointDistance as Qge,vectorFromPoint as efe,curveLength as tfe,curvePointAtLength as ofe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as ife,KEYS as afe,shouldRotateWithDiscreteAngle as lfe,getGridPoint as sfe,invariant as cfe,tupleToCoors as dfe,viewportCoordsToSceneCoords as mfe}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as ufe,isPathALoop as hfe}from"@excalidraw/element";import{KEYS as $he,arrayToMap as jhe,isBindingFallthroughEnabled as qhe,tupleToCoors as Jhe,invariant as Qhe,isDevEnv as ege,isTestEnv as tge}from"@excalidraw/common";import{lineSegment as nge,pointFrom as rge,pointRotateRads as ige,vectorFromPoint as age,pointDistanceSq as lge,clamp as sge,pointDistance as cge,pointFromVector as dge,vectorScale as mge,vectorNormalize as pge,vectorCross as uge,pointsEqual as hge,lineSegmentIntersectionPoints as gge,PRECISION as fge}from"@excalidraw/math";import{isTransparent as Cue}from"@excalidraw/common";import{curveIntersectLineSegment as kue,isPointWithinBounds as Mue,lineSegment as Pue,lineSegmentIntersectionPoints as Lue,pointFrom as Aue,pointFromVector as Due,pointRotateRads as _ue,pointsEqual as Rue,vectorFromPoint as Nue,vectorNormalize as Bue,vectorScale as Oue}from"@excalidraw/math";import{ellipse as zue,ellipseSegmentInterceptPoints as Hue}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as ED,DEFAULT_PROPORTIONAL_RADIUS as Bh,LINE_CONFIRM_THRESHOLD as yD,ROUNDNESS as Oh}from"@excalidraw/common";import{curve as npe,curveCatmullRomCubicApproxPoints as rpe,curveOffsetPoints as ipe,lineSegment as ape,pointDistance as wD,pointFrom as lpe,pointFromArray as spe,rectangle as cpe}from"@excalidraw/math";var fd=(e,t=1)=>{if(e.length>=3){let[o,n]=[e[0],e[e.length-1]];return wD(o,n)<=yD/t}return!1},Cl=(e,t)=>{if(t.roundness?.type===Oh.PROPORTIONAL_RADIUS||t.roundness?.type===Oh.LEGACY)return e*Bh;if(t.roundness?.type===Oh.ADAPTIVE_RADIUS){let o=t.roundness?.value??ED,n=o/Bh;return e<=n?e*Bh:o}return 0};import{ROUNDNESS as fpe,assertNever as bpe}from"@excalidraw/common";import{pointsEqual as Epe}from"@excalidraw/math";var T2=e=>!!e&&e.type==="embeddable",I2=e=>!!e&&e.type==="iframe",zh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),xr=e=>e!=null&&e.type==="text";var bd=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var An=e=>e!=null&&vD(e.type);var Yi=e=>e!=null&&e.type==="arrow",Sl=e=>Yi(e)&&e.elbowed;var vD=e=>e==="arrow"||e==="line";var Wi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&xr(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Zpe,ARROW_LABEL_WIDTH_FRACTION as $pe,BOUND_TEXT_PADDING as jpe,DEFAULT_FONT_SIZE as qpe,TEXT_ALIGN as Jpe,VERTICAL_ALIGN as Qpe,getFontString as eue,isProdEnv as tue,invariant as oue}from"@excalidraw/common";import{pointFrom as rue,pointRotateRads as iue}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Cpe,DEFAULT_FONT_SIZE as Spe,DEFAULT_FONT_FAMILY as kpe,getFontString as Mpe,isTestEnv as Ppe,normalizeEOL as Lpe}from"@excalidraw/common";var Ape="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Fpe,isTestEnv as zpe}from"@excalidraw/common";import{curvePointDistance as hue,distanceToLineSegment as gue,pointRotateRads as fue}from"@excalidraw/math";import{ellipse as xue,ellipseDistanceFromPoint as Eue}from"@excalidraw/math/ellipse";import{invariant as Jue,isDevEnv as Que,isTestEnv as ehe}from"@excalidraw/common";import{pointFrom as ohe,pointFromVector as nhe,pointRotateRads as rhe,pointScaleFromOrigin as ihe,pointsEqual as ahe,triangleIncludesPoint as lhe,vectorCross as she,vectorFromPoint as kD,vectorScale as che}from"@excalidraw/math";var Wh=[1,0],M2=[0,1],Vh=[-1,0],P2=[0,-1],Ed=e=>{let[t,o]=e,n=Math.abs(t),r=Math.abs(o);return t>r?Wh:t<=-r?Vh:o>n?M2:P2},L2=(e,t)=>Ed(kD(e,t)),yd=(e,t)=>wd(L2(e,t)),Yh=(e,t)=>e[0]===t[0]&&e[1]===t[1],wd=e=>Yh(e,Wh)||Yh(e,Vh);import{clamp as ghe,pointDistance as fhe,pointFrom as bhe,pointScaleFromOrigin as xhe,pointsEqual as Ehe,pointTranslate as yhe,vector as whe,vectorCross as vhe,vectorFromPoint as The,vectorScale as Ihe}from"@excalidraw/math";import{BinaryHeap as She,invariant as khe,isAnyTrue as Mhe,tupleToCoors as Phe,getSizeFromPoints as Lhe,isDevEnv as Ahe,arrayToMap as Dhe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Age,viewportCoordsToSceneCoords as Dge}from"@excalidraw/common";import{normalizeRadians as Rge,radiansBetweenAngles as Nge,radiansDifference as Bge}from"@excalidraw/math";import{pointsEqual as Fge}from"@excalidraw/math";var Fh=e=>{let t=Math.floor(e.width/2)+1,o=0,n=e.width,r=Math.floor(e.height/2)+1,i=t,a=e.height;return[t,o,n,r,i,a,0,r]};var OD=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}},FD=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Kh=(e,t,o,n)=>{if(t.length<1)return null;let r=Nh(t[0]);if(r.length<1)return null;let i=o==="start"?1:r.length-1,a=r[i].data;D2(a.length===6,"Op data length is not 6");let l=at(a[4],a[5]),s=at(a[2],a[3]),d=at(a[0],a[1]),m=r[i-1],c=at(0,0);if(m.op==="move"){let A=BD(m.data);D2(A!=null,"Op data is not a point"),c=A}else m.op==="bcurveTo"&&(c=at(m.data[4],m.data[5]));let p=(A,B)=>Math.pow(1-A,3)*l[B]+3*A*Math.pow(1-A,2)*s[B]+3*Math.pow(A,2)*(1-A)*d[B]+c[B]*Math.pow(A,3),[u,f]=o==="start"?c: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=OD(n),I=0;{let[A,B]=o==="end"?e.points[e.points.length-1]:e.points[0],[H,Y]=e.points.length>1?o==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];I=Math.hypot(A-H,B-Y)}let L=Math.min(v,I*(n==="diamond"||n==="diamond_outline"?.25:.5)),k=u-E*L,R=f-y*L;if(n==="dot"||n==="circle"||n==="circle_outline"){let A=Math.hypot(R-f,k-u)+e.strokeWidth-2;return[u,f,A]}let M=FD(n);if(n==="crowfoot_many"||n==="crowfoot_one_or_many"){let[A,B]=Ki(at(u,f),at(k,R),Xh(-M)),[H,Y]=Ki(at(u,f),at(k,R),Xh(M));return[k,R,A,B,H,Y]}let[_,N]=Ki(at(k,R),at(u,f),-M*Math.PI/180),[K,J]=Ki(at(k,R),at(u,f),Xh(M));if(n==="diamond"||n==="diamond_outline"){let A,B;if(o==="start"){let[H,Y]=e.points.length>1?e.points[1]:[0,0];[A,B]=Ki(at(u+L*2,f),at(u,f),Math.atan2(Y-f,H-u))}else{let[H,Y]=e.points.length>1?e.points[e.points.length-2]:[0,0];[A,B]=Ki(at(u-L*2,f),at(u,f),Math.atan2(f-Y,u-H))}return[u,f,_,N,A,B,K,J]}return[u,f,_,N,K,J]};import{pointFrom as t1e,pointCenter as o1e,pointRotateRads as n1e,vectorFromPoint as r1e,vectorNormalize as i1e,vectorSubtract as a1e,vectorAdd as l1e,vectorScale as s1e,pointFromVector as c1e,clamp as d1e,isCloseTo as m1e}from"@excalidraw/math";import{arrayToMap as q1e}from"@excalidraw/common";import{isPointWithinBounds as Q1e,pointFrom as ebe}from"@excalidraw/math";import{vectorCross as f1e,vectorFromPoint as b1e}from"@excalidraw/math";import{arrayToMap as zD}from"@excalidraw/common";import{getElementBounds as HD}from"@excalidraw/element";import{isArrowElement as GD,isExcalidrawElement as UD,isFreeDrawElement as YD,isLinearElement as WD,isTextElement as VD}from"@excalidraw/element";import{rangeIncludesValue as vd,pointFrom as qo,pointRotateRads as XD,rangeInclusive as Td}from"@excalidraw/math";var KD=e=>e.type==="diamond"?[qo(e.width/2,0),qo(e.width,e.height/2),qo(e.width/2,e.height),qo(0,e.height/2)]:[qo(0,0),qo(0+e.width,0),qo(0+e.width,e.height),qo(0,e.height)],ZD=e=>WD(e)||YD(e)?e.points:KD(e),R2=e=>{let t=e.reduce((o,[n,r])=>(o.minY=Math.min(o.minY,r),o.minX=Math.min(o.minX,n),o.maxX=Math.max(o.maxX,n),o.maxY=Math.max(o.maxY,r),o),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},N2=e=>{let t=ZD(e),{cx:o,cy:n}=R2(t),r=qo(o,n),i=t.map(m=>XD(m,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:d}=R2(i);return[a+e.x,l+e.y,s+e.x,d+e.y]},Zh=(e,t,o=!1)=>{let n=N2(e),r=t[0]<=n[0]&&t[2]>=n[2]&&t[1]<=n[1]&&t[3]>=n[3];return o?r?!0:n[0]<=t[0]&&n[2]>=t[2]&&n[1]<=t[1]&&n[3]>=t[3]:r},B2=(e,t)=>{let o=N2(e);return(vd(o[0],Td(t[0],t[2]))||vd(t[0],Td(o[0],o[2])))&&(vd(o[1],Td(t[1],t[3]))||vd(t[1],Td(o[1],o[3])))},O2=({elements:e,bounds:t,type:o,errorMargin:n=0})=>{UD(t)&&(t=HD(t,zD(e)));let r=[t[0]-n,t[1]-n,t[2]+n,t[3]+n],i=new Set;for(let a of e){if(i.has(a.id))continue;if(o==="overlap"?B2(a,r):o==="inside"?Zh(a,r):Zh(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);VD(a)&&a.containerId&&i.add(a.containerId),GD(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 _1e,isShallowEqual as jD}from"@excalidraw/common";var $D=function(){let e=null,t=null,o=null,n=(i,a,l,s)=>{if(o!==void 0&&a===t&&i===e&&l.editingGroupId===o?.editingGroupId)return o;let d={};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];d[f]=!0}}let m={},c=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>d[b]);return f&&(p[u.id]=!0,Array.isArray(m[f])?m[f].push(u.id):m[f]=[u.id]),p},{});for(let p of Object.keys(m))m[p].length<2&&d[p]&&(d[p]=!1);return t=a,e=i,o={editingGroupId:l.editingGroupId,selectedGroupIds:d,selectedElementIds:$h({...l.selectedElementIds,...c},s)},o},r=(i,a,l,s)=>{let d=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):jh(a,i);return d.length?n(d,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:$h(i.selectedElementIds,l)}};return r.clearCache=()=>{t=null,e=null,o=null},r}();var H1e=function(){let e=null,t=null,o=null,n=(r,i)=>(o!=null&&r===e&&i.selectedElementIds===t||(o=r.some(a=>i.selectedElementIds[a.id]),e=r,t=i.selectedElementIds),o);return n.clearCache=()=>{e=null,t=null,o=null},n}(),jh=(e,t,o)=>{let n=new Set,r=[];for(let i of e.values()){if(t.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(o?.includeBoundTextElement&&Wi(i)&&t.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(o?.includeElementsInFrames){let i=[];return r.forEach(a=>{bd(a)&&F2(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var $h=(e,t)=>jD(t.selectedElementIds,e)?t.selectedElementIds:e;var F2=(e,t)=>{let o=[];for(let n of e.values())n.frameId===t&&o.push(n);return o};var QD=typeof document<"u"?document.createElement("img"):{src:""};QD.src=`data:${H2.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 e_=typeof document<"u"?document.createElement("img"):{src:""};e_.src=`data:${H2.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 G2=new WeakMap;var t_=new WeakMap([]);function U2(e){let t=o_(e),o=new Path2D(t);return t_.set(e,o),o}function o_(e){return i_(n_(e))}function n_(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([n,r],i)=>[n,r,e.pressures[i]]):[[0,0,.5]],o={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 JD(t,o)}function z2(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}var r_=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function i_(e){if(!e.length)return"";let t=e.length-1;return e.reduce((o,n,r,i)=>(r===t?o.push(n,z2(n,i[0]),"L",i[0],"Z"):o.push(n,z2(n,i[r+1])),o),["M",e[0],"Q"]).join(" ").replace(r_,"$1")}var Y2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var dt=class dt{};C(dt,"rg",new m_),C(dt,"cache",new WeakMap),C(dt,"get",t=>dt.cache.get(t)),C(dt,"set",(t,o)=>dt.cache.set(t,o)),C(dt,"delete",t=>dt.cache.delete(t)),C(dt,"destroy",()=>{dt.cache=new WeakMap}),C(dt,"generateElementShape",(t,o)=>{let n=o?.isExporting?void 0:dt.get(t);if(n!==void 0)return n;G2.delete(t);let r=h_(t,dt.rg,o||{isExporting:!1,canvasBackgroundColor:d_.white,embedsValidationStatus:null});return dt.cache.set(t,r),r});var Xi=dt,p_=e=>[8,8+e],K2=e=>[1.5,6+e];function u_(e){let t=e.roughness,o=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&o>=50||n>=15&&e.roundness&&Y2(e.type)||An(e)&&o>=50?t:Math.min(t/(o<10?3:2),2.5)}var jo=(e,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?p_(e.strokeWidth):e.strokeStyle==="dotted"?K2(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:u_(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<s_.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Pl(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return fd(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},V2=(e,t,o)=>zh(e)&&(t||T2(e)&&o?.get(e.id)!==!0)&&Pl(e.backgroundColor)&&Pl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:I2(e)?{...e,strokeColor:Pl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Pl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,X2=(e,t,o,n,r,i,a)=>{let l=Kh(e,t,o,n);if(l===null)return[];let s=(d,m)=>{if(d===null)return[];let[,,c,p,u,f]=d;return[r.line(c,p,u,f,m)]};switch(n){case"dot":case"circle":case"circle_outline":{let[d,m,c]=l;return delete i.strokeLineDash,[r.circle(d,m,c,{...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[d,m,c,p,u,f]=l;return delete i.strokeLineDash,[r.polygon([[d,m],[c,p],[u,f],[d,m]],{...i,fill:n==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[d,m,c,p,u,f,b,x]=l;return delete i.strokeLineDash,[r.polygon([[d,m],[c,p],[u,f],[b,x],[d,m]],{...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[d,m,c,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=K2(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(c,p,d,m,i),r.line(u,f,d,m,i),...n==="crowfoot_one_or_many"?s(Kh(e,t,o,"crowfoot_one"),i):[]]}}};var h_=(e,t,{isExporting:o,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=Cl(Math.min(a,l),e);i=t.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,jo(V2(e,o,r),!0))}else i=t.rectangle(0,0,e.width,e.height,jo(V2(e,o,r),!1));return i}case"diamond":{let i,[a,l,s,d,m,c,p,u]=Fh(e);if(e.roundness){let f=Cl(Math.abs(a-p),e),b=Cl(Math.abs(d-l),e);i=t.path(`M ${a+f} ${l+b} L ${s-f} ${d-b}
|
|
9
9
|
C ${s} ${d}, ${s} ${d}, ${s-f} ${d+b}
|
|
10
10
|
L ${m+f} ${c-b}
|
|
11
11
|
C ${m} ${c}, ${m} ${c}, ${m-f} ${c-b}
|
|
12
12
|
L ${p+f} ${u+b}
|
|
13
13
|
C ${p} ${u}, ${p} ${u}, ${p+f} ${u-b}
|
|
14
14
|
L ${a-f} ${l+b}
|
|
15
|
-
C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,Xo(e,!0))}else i=o.polygon([[a,l],[s,d],[m,c],[p,u]],Xo(e));return i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Xo(e));case"line":case"arrow":{let i,a=Xo(e),l=e.points.length?e.points:[RD(0,0)];if(dl(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(UD(l,16),Xo(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:d="arrow"}=e;if(s!==null){let m=_w(e,i,"start",s,o,a,n);i.push(...m)}if(d!==null){let m=_w(e,i,"end",d,o,a,n);i.push(...m)}}return i}case"freedraw":{let i;if(Lw(e),ad(e.points)){let a=_D(e.points,.75);i=o.curve(a,{...Xo(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return BD(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},UD=(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=dd(l,i),d=dd(a,l),m=Math.min(o,Aw(e[r],a)/2,Aw(e[r],i)/2);s?i[0]<l[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):i[1]<l[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m]),t.push(e[r]),d?a[0]<l[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):a[1]<l[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m])}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 Nw=(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??YD(),updated:WD()}};import{jsx as Fw}from"react/jsx-runtime";var Oi=B({name:"toggleLinearEditor",category:Le.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&&XD(r[0])&&!VD(r[0]))},perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];Wh(r,"No selected element found"),Wh(o.selectedLinearElement,"No selected linear element found"),Wh(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:Bw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!n)return null;let r=g(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return Fw(K,{type:"button",icon:Db,title:r,"aria-label":r,onClick:()=>o(null)})}}),j0e=B({name:"togglePolygon",category:Le.elements,icon:Hm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Fi(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=>Fi(i)&&i.points.length>=4)},perform(e,o,t,n){let r=n.scene.getSelectedElements(o);if(r.some(s=>!Fi(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=KD(i);return{elements:e.map(s=>!l.has(s.id)||!Fi(s)?s:Nw(s,{backgroundColor:a?s.backgroundColor:"transparent",...ZD(s,a)})),appState:o,captureUpdate:Bw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(a=>!Fi(a)||!a.polygon||a.points.length<3))return null;let r=n.every(a=>Fi(a)&&a.polygon),i=g(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return Fw($r,{icon:Hm,title:i,"aria-label":i,active:r,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as Ow,CANVAS_SEARCH_TAB as zw,CLASSES as $D,DEFAULT_SIDEBAR as Hw}from"@excalidraw/common";import{CaptureUpdateAction as jD}from"@excalidraw/element";var sl=B({name:"searchMenu",icon:Dt,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===Hw.name&&o.openSidebar.tab===zw){let r=n.excalidrawContainerValue.container?.querySelector(`.${$D.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...o,openSidebar:{name:Hw.name,tab:zw},openDialog:null},captureUpdate:jD.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Ow.CTRL_OR_CMD]&&e.key===Ow.F});import{isImageElement as qD}from"@excalidraw/element";import{CaptureUpdateAction as JD}from"@excalidraw/element";import{jsx as QD}from"react/jsx-runtime";var Vh=B({name:"cropEditor",label:"helpDialog.cropStart",icon:cp,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:JD.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.croppingElementId&&r.length===1&&qD(r[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=g("helpDialog.cropStart");return QD(K,{type:"button",icon:cp,title:n,"aria-label":n,onClick:()=>o(null)})}});import{getNonDeletedElements as e_}from"@excalidraw/element";import{mutateElement as t_}from"@excalidraw/element";import{newFrameElement as o_}from"@excalidraw/element";import{isFrameLikeElement as hd}from"@excalidraw/element";import{addElementsToFrame as n_,removeAllElementsFromFrame as r_}from"@excalidraw/element";import{getFrameChildren as i_}from"@excalidraw/element";import{KEYS as Gw,updateActiveTool as Uw}from"@excalidraw/common";import{getElementsInGroup as a_}from"@excalidraw/element";import{getCommonBounds as l_}from"@excalidraw/element";import{CaptureUpdateAction as fr}from"@excalidraw/element";var Yw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&hd(t[0])},Ww=B({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;if(hd(r)){let i=i_(e_(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:fr.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:fr.EVENTUALLY}},predicate:(e,o,t,n)=>Yw(o,n)}),Vw=B({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;return hd(r)?{elements:r_(e,r),appState:{...o,selectedElementIds:{[r.id]:!0}},captureUpdate:fr.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:fr.EVENTUALLY}},predicate:(e,o,t,n)=>Yw(o,n)}),ixe=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:fr.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),axe=B({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:tr,viewMode:!1,perform:(e,o,t,n)=>{let r=Uw(o,{type:"frame"});return Nt(n.interactiveCanvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:Uw(o,{type:"frame"})},captureUpdate:fr.EVENTUALLY}},keyTest:e=>!e[Gw.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===Gw.F}),Xw=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=>hd(i))},perform:(e,o,t,n)=>{let r=J(e,o),i=n.scene.getNonDeletedElementsMap(),[a,l,s,d]=l_(r,i),m=16,c=o_({x:a-m,y:l-m,width:s-a+m*2,height:d-l+m*2});if(o.editingGroupId){let u=a_(r,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);t_(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:n_([...n.scene.getElementsIncludingDeleted(),c],r,c,o),appState:{selectedElementIds:{[c.id]:!0}},captureUpdate:fr.IMMEDIATELY}}});import{isWindows as h_,KEYS as gl,matchKey as Zh,arrayToMap as Kw}from"@excalidraw/common";import{CaptureUpdateAction as Kh}from"@excalidraw/element";import{orderByFractionalIndex as g_}from"@excalidraw/element";import{Emitter as s_}from"@excalidraw/common";import{CaptureUpdateAction as c_,StoreChange as d_,StoreDelta as m_}from"@excalidraw/element";var zi=class extends m_{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)}},br=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},hl=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new s_);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 zi)return;let t=zi.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new br(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=c_.IMMEDIATELY,l=this.store.snapshot,s=o,d=t,m=!1;for(;i;){try{[s,d,m]=i.applyTo(s,d,l);let c=l.elements,p=l.maybeClone(a,s,d),u=d_.create(l,p),f=zi.applyLatestChanges(i,c,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{r(i)}if(m)break;i=n()}return[s,d]}finally{this.onHistoryChangedEmitter.trigger(new br(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=zi.inverse(t);return o.push(n)}};import{useEffect as p_,useState as u_}from"react";var Xh=(e,o)=>{let[t,n]=u_(o);return p_(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),t};import{jsx as qw}from"react/jsx-runtime";var Zw=(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:Kh.EVENTUALLY};let[r,i]=n,a=g_(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Kh.NEVER}}return{captureUpdate:Kh.EVENTUALLY}},$w=e=>({name:"undo",label:"buttons.undo",icon:Xm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>Zw(r,t,()=>e.undo(Kw(o),t)),keyTest:o=>o[gl.CTRL_OR_CMD]&&Zh(o,gl.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:n}=Xh(e.onHistoryChangedEmitter,new br(e.isUndoStackEmpty,e.isRedoStackEmpty));return qw(K,{type:"button",icon:Xm,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),jw=e=>({name:"redo",label:"buttons.redo",icon:Km,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>Zw(r,t,()=>e.redo(Kw(o),t)),keyTest:o=>o[gl.CTRL_OR_CMD]&&o.shiftKey&&Zh(o,gl.Z)||h_&&o.ctrlKey&&!o.shiftKey&&Zh(o,gl.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:n}=Xh(e.onHistoryChangedEmitter,new br(e.isUndoStackEmpty,e.isRedoStackEmpty));return qw(K,{type:"button",icon:Km,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-redo"})}});import{getFontString as f_}from"@excalidraw/common";import{newElementWith as b_}from"@excalidraw/element";import{measureText as x_}from"@excalidraw/element";import{isTextElement as Jw}from"@excalidraw/element";import{CaptureUpdateAction as E_}from"@excalidraw/element";var Qw=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&&Jw(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&&Jw(i)){let a=x_(i.originalText,f_(i),i.lineHeight);return b_(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:E_.IMMEDIATELY}}});import{CODES as y_,KEYS as w_}from"@excalidraw/common";import{CaptureUpdateAction as v_}from"@excalidraw/element";var $h=B({name:"viewMode",label:"labels.viewMode",icon:Ur,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:v_.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[w_.CTRL_OR_CMD]&&e.altKey&&e.code===y_.R});import{isPromiseLike as T_}from"@excalidraw/common";import{jsx as I_}from"react/jsx-runtime";var jh=(e,o,t,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,n,i))&&ae(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${r.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},gd=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=d=>{jh(r,"ui",l,a,this.app,d),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),d,this.app))};return I_(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(T_(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,d)=>(d.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 jh(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();jh(o,t,i,r,this.app,n),this.updater(o.perform(r,i,n,this.app))}};var fd=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 qh=e=>{let o=Array.from(e.values());return{x:ev(o,t=>t.x)/o.length,y:ev(o,t=>t.y)/o.length}},Jh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),ev=(e,o)=>e.reduce((t,n)=>t+o(n),0);import{pointFrom as G,pointRotateRads as Sn,rangeInclusive as Kt,rangeIntersection as bd,rangesOverlap as xd}from"@excalidraw/math";import{TOOL_TYPE as xr,KEYS as tv}from"@excalidraw/common";import{getCommonBounds as Qh,getDraggedElementsBounds as eg,getElementAbsoluteCoords as C_}from"@excalidraw/element";import{isBoundToContainer as iv}from"@excalidraw/element";import{getMaximumGroups as av}from"@excalidraw/element";import{getSelectedElements as S_,getVisibleAndNonSelectedElements as lv}from"@excalidraw/element";var k_=8,ov=99999,Ed=e=>k_/e,Et=class Et{};I(Et,"referenceSnapPoints",null),I(Et,"visibleGaps",null),I(Et,"setReferenceSnapPoints",o=>{Et.referenceSnapPoints=o}),I(Et,"getReferenceSnapPoints",()=>Et.referenceSnapPoints),I(Et,"setVisibleGaps",o=>{Et.visibleGaps=o}),I(Et,"getVisibleGaps",()=>Et.visibleGaps),I(Et,"destroy",()=>{Et.referenceSnapPoints=null,Et.visibleGaps=null});var Zt=Et,kn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Zo=({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[tv.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[tv.CTRL_OR_CMD]&&!kn(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},M_=(e,o,t=.01)=>Math.abs(e-o)<=t,fl=(e,o,{omitCenter:t,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,d,m,c,p]=C_(a,o);r&&(l+=r.x,d+=r.x,c+=r.x,s+=r.y,m+=r.y,p+=r.y);let u=(d-l)/2,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!n){let b=Sn(G(l,s+f),G(c,p),a.angle),x=Sn(G(l+u,s),G(c,p),a.angle),y=Sn(G(d,s+f),G(c,p),a.angle),E=Sn(G(l+u,m),G(c,p),a.angle),w=G(c,p);i=t?[b,x,y,E]:[b,x,y,E,w]}else{let b=Sn(G(l,s),G(c,p),a.angle),x=Sn(G(d,s),G(c,p),a.angle),y=Sn(G(l,m),G(c,p),a.angle),E=Sn(G(d,m),G(c,p),a.angle),w=G(c,p);i=t?[b,x,y,E]:[b,x,y,E,w]}}else if(e.length>1){let[a,l,s,d]=eg(e,r??{x:0,y:0}),m=s-a,c=d-l,p=G(a,l),u=G(s,l),f=G(a,d),b=G(s,d),x=G(a+m/2,l+c/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>G(Ae(a[0]),Ae(a[1])))},sv=(e,o,t,n)=>lv(e,o,t,n),cv=(e,o,t,n)=>{let r=sv(e,o,t,n),i=av(r,n).filter(c=>!(c.length===1&&iv(c[0]))).map(c=>Qh(c).map(p=>Ae(p))),a=i.sort((c,p)=>c[0]-p[0]),l=[],s=0;e:for(let c=0;c<a.length;c++){let p=a[c];for(let u=c+1;u<a.length;u++){if(++s>ov)break e;let f=a[u],[,b,x,y]=p,[E,w,,v]=f;x<E&&xd(Kt(b,y),Kt(w,v))&&l.push({startBounds:p,endBounds:f,startSide:[G(x,b),G(x,y)],endSide:[G(E,w),G(E,v)],length:E-x,overlap:bd(Kt(b,y),Kt(w,v))})}}let d=i.sort((c,p)=>c[1]-p[1]),m=[];s=0;e:for(let c=0;c<d.length;c++){let p=d[c];for(let u=c+1;u<d.length;u++){if(++s>ov)break e;let f=d[u],[b,,x,y]=p,[E,w,v]=f;y<w&&xd(Kt(b,x),Kt(E,v))&&m.push({startBounds:p,endBounds:f,startSide:[G(b,y),G(x,y)],endSide:[G(E,w),G(v,w)],length:w-y,overlap:bd(Kt(b,x),Kt(E,v))})}}return{horizontalGaps:l,verticalGaps:m}},nv=(e,o,t,n,r,i,a)=>{if(!Zo({app:t,event:n,selectedElements:e}))return[];if(e.length===0)return[];let l=Zt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:d}=l,[m,c,p,u]=eg(e,o).map(x=>Ae(x)),f=(m+p)/2,b=(c+u)/2;for(let x of s){if(!xd(Kt(c,u),x.overlap))continue;let y=x.startSide[0][0]+x.length/2,E=Ae(y-f);if(x.length>p-m&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(r.length=0),a.x=Math.abs(E);let M={type:"gap",direction:"center_horizontal",gap:x,offset:E};r.push(M);continue}let[,,v]=x.endBounds,C=m-v,k=Ae(x.length-C);if(Math.abs(k)<=a.x){Math.abs(k)<a.x&&(r.length=0),a.x=Math.abs(k);let M={type:"gap",direction:"side_right",gap:x,offset:k};r.push(M);continue}let[P,,,]=x.startBounds,S=P-p,_=Ae(S-x.length);if(Math.abs(_)<=a.x){Math.abs(_)<a.x&&(r.length=0),a.x=Math.abs(_);let M={type:"gap",direction:"side_left",gap:x,offset:_};r.push(M);continue}}for(let x of d){if(!xd(Kt(m,p),x.overlap))continue;let y=x.startSide[0][1]+x.length/2,E=Ae(y-b);if(x.length>u-c&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let M={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(M);continue}let[,v,,]=x.startBounds,C=v-u,k=Ae(C-x.length);if(Math.abs(k)<=a.y){Math.abs(k)<a.y&&(i.length=0),a.y=Math.abs(k);let M={type:"gap",direction:"side_top",gap:x,offset:k};i.push(M);continue}let[,,,P]=x.endBounds,S=Ae(c-P),_=x.length-S;if(Math.abs(_)<=a.y){Math.abs(_)<a.y&&(i.length=0),a.y=Math.abs(_);let M={type:"gap",direction:"side_bottom",gap:x,offset:_};i.push(M);continue}}}},dv=(e,o,t,n)=>{let r=sv(e,o,t,n);return av(r,n).filter(i=>!(i.length===1&&iv(i[0]))).flatMap(i=>fl(i,n))},Hi=(e,o,t,n,r,i,a)=>{if(!Zo({app:t,event:n,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Zt.getReferenceSnapPoints();if(l)for(let s of o)for(let d of l){let m=d[0]-s[0],c=d[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(r.length=0),r.push({type:"point",points:[s,d],offset:m}),a.x=Math.abs(m)),Math.abs(c)<=a.y&&(Math.abs(c)<a.y&&(i.length=0),i.push({type:"point",points:[s,d],offset:c}),a.y=Math.abs(c))}},mv=(e,o,t,n,r)=>{let i=t.state,a=S_(e,i);if(!Zo({app:t,event:n,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Ae(o.x),o.y=Ae(o.y);let l=[],s=[],d=Ed(i.zoom.value),m={x:d,y:d},c=fl(a,r,{dragOffset:o});Hi(a,c,t,n,l,s,m),nv(a,o,t,n,l,s,m);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let u={x:Ae(o.x+p.x),y:Ae(o.y+p.y)};Hi(a,fl(a,r,{dragOffset:u}),t,n,l,s,m),nv(a,u,t,n,l,s,m);let f=tg(l,s),b=P_(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Ae=e=>Math.round(e*10**6)/10**6,rv=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())},tg=(e,o)=>{let t={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ae(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>G(Ae(a[0]),Ae(a[1]))))}}if(o.length>0){for(let r of o)if(r.type==="point"){let i=Ae(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(a=>G(Ae(a[0]),Ae(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:rv(i.map(a=>G(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:rv(i.map(a=>G(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},L_=e=>{let o=new Map;for(let t of e){let n=t.points.flat().map(r=>[Ae(r)]).join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},P_=(e,o,t)=>{let[n,r,i,a]=eg(e,o),l=[];for(let s of t){let[d,m,c,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,y=bd(Kt(r,a),s.gap.overlap),E=bd(Kt(n,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(y){let w=(y[0]+y[1])/2;l.push({type:"gap",direction:"horizontal",points:[G(s.gap.startSide[0][0],w),G(n,w)]},{type:"gap",direction:"horizontal",points:[G(i,w),G(s.gap.endSide[0][0],w)]})}break}case"center_vertical":{if(E){let w=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[G(w,s.gap.startSide[0][1]),G(w,r)]},{type:"gap",direction:"vertical",points:[G(w,a),G(w,s.gap.endSide[0][1])]})}break}case"side_right":{if(y){let w=(y[0]+y[1])/2;l.push({type:"gap",direction:"horizontal",points:[G(c,w),G(u,w)]},{type:"gap",direction:"horizontal",points:[G(b,w),G(n,w)]})}break}case"side_left":{if(y){let w=(y[0]+y[1])/2;l.push({type:"gap",direction:"horizontal",points:[G(i,w),G(d,w)]},{type:"gap",direction:"horizontal",points:[G(c,w),G(u,w)]})}break}case"side_top":{if(E){let w=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[G(w,a),G(w,m)]},{type:"gap",direction:"vertical",points:[G(w,p),G(w,f)]})}break}case"side_bottom":{if(E){let w=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[G(w,p),G(w,f)]},{type:"gap",direction:"vertical",points:[G(w,x),G(w,r)]})}break}}}return L_(l.map(s=>({...s,points:s.points.map(d=>G(Ae(d[0]),Ae(d[1])))})))},og=(e,o,t,n,r,i)=>{if(!Zo({event:n,selectedElements:e,app:t})||e.length===0||e.length===1&&!M_(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,d]=Qh(o);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(d+=r.y));let m=[];if(i)switch(i){case"e":{m.push(G(s,l),G(s,d));break}case"w":{m.push(G(a,l),G(a,d));break}case"n":{m.push(G(a,l),G(s,l));break}case"s":{m.push(G(a,d),G(s,d));break}case"ne":{m.push(G(s,l));break}case"nw":{m.push(G(a,l));break}case"se":{m.push(G(s,d));break}case"sw":{m.push(G(a,d));break}}let c=Ed(t.state.zoom.value),p={x:c,y:c},u=[],f=[];Hi(o,m,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,y,E,w]=Qh(e).map(k=>Ae(k)),v=[G(x,y),G(x,w),G(E,y),G(E,w)];Hi(e,v,t,n,u,f,p);let C=tg(u,f);return{snapOffset:b,snapLines:C}},pv=(e,o,t,n,r,i)=>{if(!Zo({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[G(n.x+r.x,n.y+r.y)],l=Ed(o.state.zoom.value),s={x:l,y:l},d=[],m=[];Hi([e],a,o,t,d,m,s);let c={x:d[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,d.length=0,m.length=0;let p=fl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Hi([e],p,o,t,d,m,s);let u=tg(d,m);return{snapOffset:c,snapLines:u}},uv=(e,o,t,n,r)=>{if(!Zo({event:n,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=lv(e,[],o.state,r),a=Ed(o.state.zoom.value),l={x:a,y:a},s=[],d=[];for(let m of i){let c=fl([m],r);for(let p of c){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(d.length=0),d.push({type:"pointer",points:[p,G(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,G(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:d.length>0?d[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...d,...s]}},hv=e=>e===xr.rectangle||e===xr.ellipse||e===xr.diamond||e===xr.frame||e===xr.magicframe||e===xr.image||e===xr.text;import{pointFrom as yd}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as A_,DEFAULT_FONT_SIZE as D_,TEXT_ALIGN as __,VERTICAL_ALIGN as R_,getSizeFromPoints as N_,randomId as B_,arrayToMap as F_,assertNever as ng,cloneJSON as bv,getFontString as O_,isDevEnv as z_,toBrandedType as H_,getLineHeight as G_}from"@excalidraw/common";import{bindLinearElement as gv}from"@excalidraw/element";import{newArrowElement as U_,newElement as rg,newFrameElement as Y_,newImageElement as W_,newLinearElement as V_,newMagicFrameElement as X_,newTextElement as vd}from"@excalidraw/element";import{measureText as K_,normalizeText as Z_}from"@excalidraw/element";import{isArrowElement as $_}from"@excalidraw/element";import{syncInvalidIndices as j_}from"@excalidraw/element";import{redrawTextBoundingBox as q_}from"@excalidraw/element";import{LinearElementEditor as J_}from"@excalidraw/element";import{getCommonBounds as Q_}from"@excalidraw/element";import{Scene as eR}from"@excalidraw/element";var wd={width:100,height:0},Mn=100,tR=(e,o,t)=>{let n=vd({x:0,y:0,textAlign:__.CENTER,verticalAlign:R_.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:n.id})}),q_(n,e,t),[e,n]},fv=(e,o,t,n,r)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let m=o?.width??Mn,c=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-m,f=o.y||e.y-c/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=vd({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=rg({x:u,y:f,width:m,height:c,...p,...o,type:b});break}default:ng(e,`Unhandled element start type "${o.type}"`,!0)}gv(e,i,"start",r)}}if(t){let m=t?.height??Mn,c=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-m/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=vd({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=rg({x:u,y:f,width:c,height:m,...p,...t,type:b});break}default:ng(e,`Unhandled element end type "${b}"`,!0)}gv(e,a,"end",r)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,d=bv(e.points);return e.points[l][0]>e.points[l-1][0]&&(d[0][0]=s,d[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(d[0][0]=-s,d[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(d[0][1]=s,d[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(d[0][1]=-s,d[l][1]+=s),Object.assign(e,J_.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:i,endBoundElement:a}},ig=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>j_(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>H_(F_(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Gi=(e,o)=>{if(!e)return[];let t=bv(e),n=new ig,r=new Map,i=new Map;for(let s of t){let d,m=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:B_()}),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;d=rg({...s,width:p,height:u});break}case"line":{let p=s.width||wd.width,u=s.height||wd.height;d=V_({width:p,height:u,points:[yd(0,0),yd(p,u)],...s});break}case"arrow":{let p=s.width||wd.width,u=s.height||wd.height;d=U_({width:p,height:u,endArrowhead:"arrow",points:[yd(0,0),yd(p,u)],...s,type:"arrow"}),Object.assign(d,N_(d.points));break}case"text":{let p=s?.fontFamily||A_,u=s?.fontSize||D_,f=s?.lineHeight||G_(p),b=s.text??"",x=Z_(b),y=K_(x,O_({fontFamily:p,fontSize:u}),f);d=vd({width:y.width,height:y.height,fontFamily:p,fontSize:u,...s});break}case"image":{d=W_({width:s?.width||Mn,height:s?.height||Mn,...s});break}case"frame":{d=Y_({x:0,y:0,...s});break}case"magicframe":{d=X_({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{d=s;break}default:d=s,ng(s,`Unhandled element type "${s.type}"`,!0)}n.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(n.add(d),r.set(d.id,s),m&&i.set(m,d.id))}let a=n.getElementsMap(),l=new eR(a);for(let[s,d]of r){let m=n.getElement(s);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[c,p]=tR(m,d?.label,l);if(n.add(c),n.add(p),$_(c)){let u=d.type==="arrow"?d?.start:void 0,f=d.type==="arrow"?d?.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:y}=fv(c,u,f,n,l);c=b,n.add(b),n.add(x),n.add(y)}}else switch(d.type){case"arrow":{let{start:c,end:p}=d;if(c&&c.id){let x=i.get(c.id);Object.assign(c,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=fv(m,c,p,n,l);n.add(u),n.add(f),n.add(b);break}}break}}}for(let[s,d]of r){if(d.type!=="frame"&&d.type!=="magicframe")continue;let m=n.getElement(s);if(!m)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let c=[];d.children.forEach(C=>{let k=i.get(C);if(!k)throw new Error(`Element with ${C} wasn't mapped correctly`);let P=n.getElement(k);if(!P)throw new Error(`Frame element with id ${k} doesn't exist`);Object.assign(P,{frameId:m.id}),P?.boundElements?.forEach(S=>{let _=n.getElement(S.id);if(!_)throw new Error(`Bound element with id ${S.id} doesn't exist`);Object.assign(_,{frameId:m.id}),c.push(_)}),c.push(P)});let[p,u,f,b]=Q_(c),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let y=m?.x||p,E=m?.y||u,w=m?.width||f-p,v=m?.height||b-u;Object.assign(m,{x:y,y:E,width:w,height:v}),z_()&&d.children.length&&(m?.x||m?.y||m?.width||m?.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 AR}from"@excalidraw/element";import{memoize as DR,toBrandedType as _R}from"@excalidraw/common";import{pointFrom as cR,pointsEqual as dR}from"@excalidraw/math";import Id from"open-color";import{arrayToMap as mR,DEFAULT_TRANSFORM_HANDLE_SPACING as ug,FRAME_STYLE as Iv,invariant as Cv,THEME as pR,throttleRAF as uR}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as lg,maxBindingGap as Av}from"@excalidraw/element";import{LinearElementEditor as Ln}from"@excalidraw/element";import{getOmitSidesForDevice as sg,getTransformHandles as hR,getTransformHandlesFromCoords as gR,shouldShowBoundingBox as fR}from"@excalidraw/element";import{isElbowArrow as bl,isFrameLikeElement as Sv,isImageElement as kv,isLinearElement as bR,isLineElement as xR,isTextElement as Mv}from"@excalidraw/element";import{renderSelectionElement as ER}from"@excalidraw/element";import{getElementsInGroup as mg,getSelectedGroupIds as yR,isSelectedViaGroup as wR,selectGroupsFromGivenElements as vR}from"@excalidraw/element";import{getCommonBounds as pg,getElementAbsoluteCoords as xl}from"@excalidraw/element";import{pointFrom as mt}from"@excalidraw/math";import{THEME as oR}from"@excalidraw/common";var nR="#ff6b6b",rR="#ff0000",xv=1,Ev=2,yv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===oR.LIGHT||o.zenModeEnabled?nR:rR,n=(o.zenModeEnabled?xv*1.5:xv)/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,aR(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,lR(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,iR(r,e,o));e.restore()},iR=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];$t(n,r,o)}for(let n of e.points)wv(n,t,o)},aR=(e,o,t)=>{wv(e.points[0],t,o),t.zenModeEnabled||$t(e.points[0],e.points[1],o)},wv=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?Ev*1.5:Ev)/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()},$t=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},lR=(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||$t(mt(e[0],e[1]-i),mt(e[0],e[1]+i),r),$t(mt(s[0]-l,s[1]-a),mt(s[0]-l,s[1]+a),r),$t(mt(s[0]+l,s[1]-a),mt(s[0]+l,s[1]+a),r),n.zenModeEnabled||($t(mt(o[0],o[1]-i),mt(o[0],o[1]+i),r),$t(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||$t(mt(e[0]-i,e[1]),mt(e[0]+i,e[1]),r),$t(mt(s[0]-a,s[1]-l),mt(s[0]+a,s[1]-l),r),$t(mt(s[0]-a,s[1]+l),mt(s[0]+a,s[1]+l),r),n.zenModeEnabled||($t(mt(o[0]-i,o[1]),mt(o[0]+i,o[1]),r),$t(e,o,r))}};import{getGlobalCSSVariable as Td}from"@excalidraw/common";import{getCommonBounds as sR}from"@excalidraw/element";var po=4,Ct=6,vv="rgba(0,0,0,0.3)",Tv=(e,o,t,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=sR(e),s=o/n.zoom.value,d=t/n.zoom.value,m={top:parseInt(Td("sat"))||0,bottom:parseInt(Td("sab"))||0,left:parseInt(Td("sal"))||0,right:parseInt(Td("sar"))||0},c=No().rtl,p=-n.scrollX+m.left,u=-n.scrollY+m.top,f=p+s-m.right,b=u+d-m.bottom,x=Math.min(r,p),y=Math.min(i,u),E=Math.max(a,f),w=Math.max(l,b),v=a-r,C=l-i,k=E-x,P=w-y,S=Math.max(po*2,m.left+m.right)+Ct*2,_=o*(s/k)-S,M=Math.max(po*2,m.top+m.bottom)+Ct*2,R=t*(d/P)-M,O=k>v?k*n.zoom.value/(_+S):o/(_+S),V=P>C?P*n.zoom.value/(R+M):t/(R+M);return{horizontal:p===x&&f===E?null:{x:Math.max(m.left,po)+Ct+(p-x)/k*o,y:t-Ct-Math.max(po,m.bottom),width:_,height:Ct,deltaMultiplier:O},vertical:u===y&&b===w?null:{x:c?Math.max(m.left,po):o-Ct-Math.max(m.right,po),y:Math.max(m.top,po)+Ct+(u-y)/P*t,width:Ct,height:R,deltaMultiplier:V}}},ag=(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 TR=(e,o)=>{Cv(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;Cv(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Dv(t,e,o),e.restore()},IR=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r))return;let i=Ln.getElement(n,t);if(!i)return;let a=Ln.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),Dv(a,e,o),e.restore()},Dv=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",sa(o,e[0],e[1],Ln.POINT_HANDLE_SIZE/t.zoom.value,!1)},cg=(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)"),sa(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},CR=(e,o,t,n)=>{let r=Av(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":S1(e,o,t,r);break;case"diamond":M1(e,r,o,t);break;case"ellipse":{let[i,a,l,s]=xl(o,t),d=l-i,m=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=r-lg,k1(e,d+r+lg,m+r+lg,i+d/2,a+m/2,o.angle);break}}},SR=(e,o,t,n)=>{let[r,i,a]=o,l=Av(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(d=>{let[m,c]=Ln.getPointAtIndexGlobalCoordinates(r,d,t);sa(e,m,c,l,!0)})},_v=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:d,cy:m,dashed:c,activeEmbeddable:p}=t,u=a-r,f=l-i,x=(t.padding??ug*2)/o.zoom.value,y=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 w=s.length;for(let v=0;v<w;++v)e.strokeStyle=s[v],c&&e.setLineDash([y,E+(y+E)*(w-1)]),e.lineDashOffset=(y+E)*v,ca(e,r-x,i-x,u+x*2,f+x*2,d,m,n);e.restore()},kR=(e,o,t,n)=>{let r=Array.isArray(t)?SR:CR;e.save(),e.translate(o.scrollX,o.scrollY),r(e,t,n,o.zoom),e.restore()},MR=(e,o,t,n)=>{let[r,i,a,l]=xl(t,n),s=a-r,d=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Iv.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),ca(e,r,i,s,d,r+s/2,i+d/2,t.angle,!1,Iv.radius/o.zoom.value),e.restore()},Lv=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[c,p,u,f]=pg(m);return{angle:0,x1:c,x2:u,y1:p,y2:f,selectionColors:r,dashed:i,cx:c+(u-c)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},d=m=>{let c=mg(t,m);return s(c)};Object.entries(vR(l,o)).filter(([m,c])=>c).map(([m,c])=>m).map(m=>d(m)).concat(a.map(m=>s([m]))).forEach(m=>_v(e,o,m))},dg=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=Ln.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=Ln,a=o.selectedLinearElement?.isEditing?i:i/2,l=bl(t),s=xR(t);if(r.forEach((d,m)=>{if(l&&m!==0&&m!==r.length-1)return;let c=m>0&&(m!==r.length-1||!s||!t.polygon)&&dR(d,m===r.length-1?r[0]:r[m-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!p&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),cg(e,o,d,a,p,!1,c)}),bl(t)){let d=t.fixedSegments?.map(m=>m.index)||[];r.slice(0,-1).forEach((m,c)=>{Ln.isSegmentTooShort(t,r[c+1],r[c],c,o.zoom)||cg(e,o,cR((m[0]+r[c+1][0])/2,(m[1]+r[c+1][1])/2),i/2,!1,!d.includes(c+1),!1)})}else Ln.getEditorMidPoints(t,n,o).filter((m,c,p)=>m!==null&&!(bl(t)&&(c===0||c===p.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||r.length===2)&&cg(e,o,m,i/2,!1,!0,!1)});e.restore()},Pv=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,d,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?sa(e,l+d/2,s+m/2,d/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,d,m,2/t.zoom.value),e.fill(),e.stroke()):ca(e,l,s,d,m,l+d/2,s+m/2,r,!0),e.restore()}})},LR=(e,o,t,n,r)=>{let[i,a,,,l,s]=xl(n,r),d=3,m=20,c=d/t.zoom.value,p=c/2,u=l-i+c,f=s-a+c,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=c,[[[-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[[w,v],[C,k],[P,S],[_,M],[R,O]]=E;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(w+C,v+k),e.lineTo(w+P,v+S),e.stroke(),e.beginPath(),e.moveTo(w+_,v+M),e.lineTo(w+R,v+O),e.stroke(),e.restore()}),e.restore()},PR=(e,o,t,n)=>{o.save();let r=ug*2/t.zoom.value,i=e.width+r*2,a=e.height+r*2,l=e.x+i/2,s=e.y+a/2,d=-(i/2+r),m=-(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(d,m,i,a),o.restore()},Rv=({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[d,m]=Jl(e,i),c=Ql({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m});c.save(),c.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&&dg(c,a,p,o),a.selectionElement&&!a.isCropping)try{ER(a.selectionElement,c,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Mv(a.editingTextElement)){let b=r.get(a.editingTextElement.id);b&&!b.autoResize&&PR(b,c,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{kR(c,a,b,o)}),a.frameToHighlight&&MR(c,a,a.frameToHighlight,o),a.elementsToHighlight&&Lv(c,a,a.elementsToHighlight),a.activeLockedId){let b=r.get(a.activeLockedId),x=b?[b]:mg(r,a.activeLockedId);Lv(c,a,x,{colors:["#ced4da"],dashed:!0})}let u=n.some(b=>Sv(b));if(n.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===n[0].id&&dg(c,a,n[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=n.find(y=>y.id===b.elementId);b.segmentMidPointHoveredCoords?TR(c,a):(bl(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&IR(c,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=fR(n,a),x=n.length===1&&bR(n[0]);x&&a.selectedLinearElement?.elementId===n[0].id&&!n[0].locked&&dg(c,a,n[0],o);let y=l.selectionColor||Id.black;if(b){let E=mR(n),w=[];for(let C of o.values()){let k=[],P=l.remoteSelectedElementIds.get(C.id);if(x&&bl(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!wR(a,C)&&k.push(y),P&&k.push(...P.map(S=>mr(S,a.collaborators.get(S))))),k.length){let[S,_,M,R,O,V]=xl(C,o,!0);w.push({angle:C.angle,x1:S,y1:_,x2:M,y2:R,selectionColors:C.locked?["#ced4da"]:k,dashed:!!P||C.locked,cx:O,cy:V,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||kv(C)?0:void 0})}}let v=C=>{let k=mg(o,C),[P,S,_,M]=pg(k);w.push({angle:0,x1:P,x2:_,y1:S,y2:M,selectionColors:k.some(R=>R.locked)?["#ced4da"]:[Id.black],dashed:!0,cx:P+(_-P)/2,cy:S+(M-S)/2,activeEmbeddable:!1})};for(let C of yR(a))v(C);a.editingGroupId&&v(a.editingGroupId),w.forEach(C=>_v(c,a,C))}if(c.save(),c.translate(a.scrollX,a.scrollY),n.length===1){c.fillStyle=Id.white;let E=hR(n[0],a.zoom,o,"mouse",sg(s));if(!a.viewModeEnabled&&b&&!Mv(a.editingTextElement)&&!a.croppingElementId&&Pv(c,l,a,E,n[0].angle),a.croppingElementId&&!a.isCropping){let w=o.get(a.croppingElementId);w&&kv(w)&&LR(c,l,a,w,o)}}else if(n.length>1&&!a.isRotating&&!n.some(E=>E.locked)){let E=ug*2/a.zoom.value;c.fillStyle=Id.white;let[w,v,C,k]=pg(n,o),P=c.getLineDash();c.setLineDash([2/a.zoom.value]);let S=c.lineWidth;c.lineWidth=1/a.zoom.value,c.strokeStyle=y,ca(c,w-E,v-E,C-w+E*2,k-v+E*2,(w+C)/2,(v+k)/2,0),c.lineWidth=S,c.setLineDash(P);let _=gR([w,v,C,k,(w+C)/2,(v+k)/2],0,a.zoom,"mouse",u?{...sg(s),rotation:!0}:sg(s));n.some(M=>!M.locked)&&Pv(c,l,a,_,0)}c.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:y})=>{let E=o.get(b);if(E){let[w,v,,,C,k]=xl(E,o,!0);c.save(),a.theme===pR.LIGHT?x?c.fillStyle="rgba(255, 124, 0, 0.4)":c.fillStyle="rgba(255, 226, 0, 0.4)":x?c.fillStyle="rgba(229, 82, 0, 0.4)":c.fillStyle="rgba(99, 52, 0, 0.4)";let P=Sv(E)?a.zoom.value:1;c.translate(a.scrollX,a.scrollY),c.translate(C,k),c.rotate(E.angle),y.forEach(S=>{(S.showOnCanvas||x)&&c.fillRect(w+S.offsetX/P-C,v+S.offsetY/P-k,S.width/P,S.height/P)}),c.restore()}}),yv(c,a),c.restore(),HE({context:c,renderConfig:l,appState:a,normalizedWidth:d,normalizedHeight:m});let f;return l.renderScrollbars&&(f=Tv(o,d,m,a),c.save(),c.fillStyle=vv,c.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&fc(c,b.x,b.y,b.width,b.height,Ct/2)}),c.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},hg=uR(e=>{let o=Rv(e);e.callback?.(o)},{trailing:!0}),Nv=(e,o)=>{if(o){hg(e);return}let t=Rv(e);return e.callback(t),t};var El=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:d,width:m})=>{let c=[];for(let p of n.values())AR(p,m,d,{zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},n)&&c.push(p);return c},t=({elements:n,editingTextElement:r,newElementId:i})=>{let a=_R(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 DR(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d,editingTextElement:m,newElementId:c,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:m,newElementId:c}),b=o({elementsMap:f,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){hg.cancel(),P1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as RR}from"@excalidraw/common";import{getElementAbsoluteCoords as NR}from"@excalidraw/element";import{jsx as OR}from"react/jsx-runtime";var BR=5,FR=(e,o,t)=>{let[n,r]=NR(e,t),{x:i,y:a}=RR({sceneX:n+e.width,sceneY:r},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},gg=({children:e,element:o,elementsMap:t})=>{let n=Eo();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=FR(o,n,t);return OR("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:BR},children:e})};import{DEFAULT_LASER_COLOR as UR,easeOut as Fv}from"@excalidraw/common";import{LaserPointer as zR}from"@excalidraw/laser-pointer";import{SVG_NS as Bv,getSvgPathFromStroke as HR,sceneCoordsToViewportCoords as GR}from"@excalidraw/common";var $o=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(Bv,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Bv,"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 zR(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=GR({sceneX:i,sceneY:a},t);return[l.x,l.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return HR(r,!0)}};var Cd=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 $o(o,t,{...this.getTrailOptions(),fill:()=>UR})}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(Fv(i),Fv(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 $o(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||mr(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 YR}from"react";import{unstable_batchedUpdates as Ov}from"react-dom";import{throttleRAF as WR}from"@excalidraw/common";var De=e=>o=>{Ov(e,o)},Sd=e=>WR(o=>{Ov(e,o)}),Ui=(()=>{let e;try{let t=YR.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 fg,KEYS as yl,CLASSES as bg,POINTER_BUTTON as VR,isWritableElement as XR,getFontString as zv,getFontFamilyString as Hv,isTestEnv as Gv,MIME_TYPES as KR}from"@excalidraw/common";import{originalContainerCache as ZR,updateOriginalContainerCache as Uv}from"@excalidraw/element";import{LinearElementEditor as $R}from"@excalidraw/element";import{bumpVersion as jR}from"@excalidraw/element";import{getBoundTextElementId as qR,getContainerElement as xg,getTextElementAngle as JR,redrawTextBoundingBox as QR,getBoundTextMaxHeight as e9,getBoundTextMaxWidth as Yv,computeContainerDimensionForBoundText as Wv,computeBoundTextPosition as t9,getBoundTextElement as o9}from"@excalidraw/element";import{getTextWidth as n9}from"@excalidraw/element";import{normalizeText as Vv}from"@excalidraw/element";import{wrapText as r9}from"@excalidraw/element";import{isArrowElement as kd,isBoundToContainer as i9,isTextElement as Xv}from"@excalidraw/element";var a9=(e,o,t,n,r,i)=>{let{zoom:a}=n,l=180*t/Math.PI,s=e*(a.value-1)/2,d=o*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),o>i&&a.value!==1&&(d=i*(a.value-1)/2),`translate(${s}px, ${d}px) scale(${a.value}) rotate(${l}deg)`},Kv=({id:e,onChange:o,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let d=(A,N)=>{if(!N.style.fontFamily||!N.style.fontSize)return!1;let F=N.style.fontFamily.replace(/"/g,"");return Hv({fontFamily:A.fontFamily})!==F||`${A.fontSize}px`!==N.style.fontSize},m=()=>{let A=l.state,N=l.scene.getElement(e);if(!N)return;let{textAlign:F,verticalAlign:W}=N,q=l.scene.getNonDeletedElementsMap();if(N&&Xv(N)){let ye=N.x,Z=N.y,ie=xg(N,l.scene.getNonDeletedElementsMap()),Ce=N.width,Lt=N.height,Pt=N.width,tn=N.height;if(ie&&N.containerId){if(kd(ie)){let nn=$R.getBoundTextElementPosition(ie,N,q);ye=nn.x,Z=nn.y}let Zl=d(N,c),ia;if(Zl?ia=Uv(ie.id,ie.height):(ia=ZR[ie.id],ia||(ia=Uv(ie.id,ie.height))),Pt=Yv(ie,N),tn=e9(ie,N),!kd(ie)&&Lt>tn){let nn=Wv(Lt,ie.type);l.scene.mutateElement(ie,{height:nn});return}else if(!kd(ie)&&ie.height>ia.height&&Lt<tn){let nn=Wv(Lt,ie.type);l.scene.mutateElement(ie,{height:nn})}else{let{x:nn,y:NC}=t9(ie,N,q);ye=nn,Z=NC}}let[to,on]=n(ye,Z),kr=c.selectionStart,Kl=c.selectionEnd,h1=c.value.length;if(kr===Kl&&Kl!==h1){let Zl=h1-Kl;c.selectionStart=c.value.length-Zl,c.selectionEnd=c.value.length-Zl}ie?Ce+=.5:(Pt=(A.width-8-to)/A.zoom.value,Ce=Math.min(Ce,Pt)),Lt*=1.05;let RC=zv(N),g1=(A.height-on)/A.zoom.value;Object.assign(c.style,{font:RC,lineHeight:N.lineHeight,width:`${Ce}px`,height:`${Lt}px`,left:`${to}px`,top:`${on}px`,transform:a9(Ce,Lt,JR(N,ie),A,Pt,g1),textAlign:F,verticalAlign:W,color:N.strokeColor,opacity:N.opacity/100,filter:"var(--theme-filter)",maxHeight:`${g1}px`}),c.scrollTop=0,Gv()&&(c.style.fontFamily=Hv(N)),l.scene.mutateElement(N,{x:ye,y:Z})}},c=document.createElement("textarea");c.dir="auto",c.tabIndex=0,c.dataset.type="wysiwyg",c.wrap="off",c.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(i9(r)||!r.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(c.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"}),c.value=r.originalText,m(),o&&(c.onpaste=async A=>{let N=(await Wa(A)).findByType(KR.text);if(!N)return;let F=Vv(N.value);if(!F)return;let W=xg(r,l.scene.getNonDeletedElementsMap()),q=zv({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(W){let ye=o9(W,l.scene.getNonDeletedElementsMap()),Z=r9(`${c.value}${F}`,q,Yv(W,ye)),ie=n9(Z,q);c.style.width=`${ie}px`}},c.oninput=()=>{let A=Vv(c.value);if(c.value!==A){let N=c.selectionStart;c.value=A,c.selectionStart=N,c.selectionEnd=N}o(c.value)}),c.onkeydown=A=>{if(!A.shiftKey&&Qs.keyTest(A))A.preventDefault(),l.actionManager.executeAction(Qs),m();else if(!A.shiftKey&&ec.keyTest(A))A.preventDefault(),l.actionManager.executeAction(ec),m();else if(!A.shiftKey&&tc.keyTest(A))A.preventDefault(),l.actionManager.executeAction(tc),m();else if(jp.keyTest(A))l.actionManager.executeAction(jp);else if(qp.keyTest(A))l.actionManager.executeAction(qp);else if(A.key===yl.ESCAPE)A.preventDefault(),C=!0,k();else if(cr.keyTest(A))A.preventDefault(),k(),l.actionManager.executeAction(cr);else if(A.key===yl.ENTER&&A[yl.CTRL_OR_CMD]){if(A.preventDefault(),A.isComposing||A.keyCode===229)return;C=!0,k()}else if(A.key===yl.TAB||A[yl.CTRL_OR_CMD]&&(A.code===fg.BRACKET_LEFT||A.code===fg.BRACKET_RIGHT)){if(A.preventDefault(),A.isComposing)return;A.shiftKey||A.code===fg.BRACKET_LEFT?E():y(),c.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),y=()=>{let{selectionStart:A,selectionEnd:N}=c,F=w(),W=c.value;F.forEach(q=>{let ye=W.slice(0,q),Z=W.slice(q);W=`${ye}${b}${Z}`}),c.value=W,c.selectionStart=A+f,c.selectionEnd=N+f*F.length},E=()=>{let{selectionStart:A,selectionEnd:N}=c,F=w(),W=[],q=c.value;F.forEach(ye=>{let Z=q.slice(ye,ye+f).match(x);if(Z){let ie=q.slice(0,ye),Ce=q.slice(ye+Z[0].length);q=`${ie}${Ce}`,W.push(ye)}}),c.value=q,W.length&&(A>W[W.length-1]?c.selectionStart=Math.max(A-f,W[W.length-1]):c.selectionStart=A,c.selectionEnd=Math.max(c.selectionStart,N-f*W.length))},w=()=>{let{selectionStart:A,selectionEnd:N,value:F}=c,W=F.slice(0,A).match(/[^\n]*$/)[0].length;return A=A-W,F.slice(A,N).split(`
|
|
16
|
-
`).reduce((ye,Z,ie,Ce)=>ye.concat(ie?ye[ie-1]+Ce[ie-1].length+1:A),[]).reverse()},v=A=>{A.target instanceof HTMLCanvasElement&&(A.preventDefault(),A.stopPropagation())},C=!1,k=()=>{if(V)return;V=!0,P();let A=l.scene.getElement(r.id);if(!A)return;let N=xg(A,l.scene.getNonDeletedElementsMap());if(N){if(c.value.trim()){let F=qR(N);!F||F!==r.id?l.scene.mutateElement(N,{boundElements:(N.boundElements||[]).concat({type:"text",id:r.id})}):kd(N)&&jR(N)}else l.scene.mutateElement(N,{boundElements:N.boundElements?.filter(F=>!Xv(F))});QR(A,N,l.scene)}t({viaKeyboard:C,nextOriginalText:c.value})},P=()=>{c.onblur=null,c.oninput=null,c.onkeydown=null,j&&j.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",M),window.removeEventListener("pointerup",S),window.removeEventListener("blur",k),window.removeEventListener("beforeunload",k),R(),O(),c.remove()},S=A=>{window.removeEventListener("pointerup",S);let N=A?.target,F=N instanceof HTMLElement&&N.classList.contains("properties-trigger"),W=(N instanceof HTMLElement||N instanceof SVGElement)&&!!N.closest(".properties-content"),q=(N instanceof HTMLElement||N instanceof SVGElement)&&(!!N.closest(`.${bg.SHAPE_ACTIONS_MENU}`)||!!N.closest(".compact-shape-actions-island"));setTimeout(()=>{q||F||W||(c.onblur=k,c.focus())})},_=()=>{c.onblur=null,window.addEventListener("pointerup",S),window.addEventListener("blur",k)},M=A=>{let N=A?.target;if(A.button===VR.WHEEL){N instanceof HTMLTextAreaElement&&(A.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(A)),_();return}let F=N instanceof HTMLElement&&N.classList.contains("properties-trigger"),W=(N instanceof HTMLElement||N instanceof SVGElement)&&!!N.closest(".properties-content");(A.target instanceof HTMLElement||A.target instanceof SVGElement)&&(A.target.closest(`.${bg.SHAPE_ACTIONS_MENU}, .${bg.ZOOM_ACTIONS}`)||A.target.closest(".compact-shape-actions-island"))&&!XR(A.target)||F||W?_():A.target instanceof HTMLCanvasElement&&!Gv()&&requestAnimationFrame(()=>{k()})},R=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||c.focus()}),O=l.onScrollChangeEmitter.on(()=>{m()}),V=!1;s&&c.select(),S();let j=null;return i&&"ResizeObserver"in window?(j=new window.ResizeObserver(()=>{m()}),j.observe(i)):window.addEventListener("resize",m),c.onpointerdown=A=>A.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",M,{capture:!0})}),window.addEventListener("beforeunload",k),a?.querySelector(".excalidraw-textEditorContainer").appendChild(c),k};var Zv=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 f9}from"@excalidraw/math";import{getElementLineSegments as b9}from"@excalidraw/element";import{LinearElementEditor as x9}from"@excalidraw/element";import{isFrameLikeElement as E9,isLinearElement as y9,isTextElement as w9}from"@excalidraw/element";import{getFrameChildren as v9}from"@excalidraw/element";import{selectGroupsForSelectedElements as T9}from"@excalidraw/element";import{getContainerElement as I9}from"@excalidraw/element";import{arrayToMap as C9,easeOut as Jv,isShallowEqual as S9}from"@excalidraw/common";import{simplify as l9}from"points-on-curve";import{polygonFromPoints as s9,lineSegment as $v,polygonIncludesPointNonZero as c9}from"@excalidraw/math";import{computeBoundTextPosition as d9,doBoundsIntersect as m9,getBoundTextElement as p9,getElementBounds as u9,intersectElementWithLineSegment as jv}from"@excalidraw/element";var qv=e=>{let{lassoPath:o,elements:t,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=l9(o,l));let d=t.filter(p=>!p.locked);a.clear(),i.clear();let m=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 d){let u=u9(p,n);m9(m,u)&&!i.has(p.id)&&!a.has(p.id)&&(h9(s,p,r)?a.add(p.id):g9(s,p,n)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},h9=(e,o,t)=>{let n=s9(e),r=t.get(o.id);return r?r.some(i=>i.some(a=>c9(a,n))):!1},g9=(e,o,t)=>{let n=e.slice(1).map((i,a)=>$v(e[a],i)).concat([$v(e[e.length-1],e[0])]),r=p9(o,t);return n.some(i=>jv(o,t,i,0,!0).length>0||!!r&&jv({...r,...d9(o,r,t)},t,i,0,!0).length>0)};var Md=class extends $o{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(Jv(s),Jv(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,d)=>(s[d]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let d=this.app.scene.getNonDeletedElement(s);if(d&&w9(d)){let m=I9(d,this.app.scene.getNonDeletedElementsMap());m&&(r[m.id]=!0,delete r[d.id])}}for(let[s]of Object.entries(r)){let d=this.app.scene.getNonDeletedElement(s);if(d&&E9(d)){let m=v9(this.app.scene.getNonDeletedElementsMap(),d.id);for(let c of m)delete r[c.id]}}let i=T9({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&&y9(this.app.scene.getNonDeletedElement(a[0]))?new x9(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=>f9(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!S9(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=C9(this.app.visibleElements);for(let i of this.app.visibleElements){let a=b9(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=qv({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 k9,easeOut as Qv,THEME as M9}from"@excalidraw/common";import{computeBoundTextPosition as L9,doBoundsIntersect as P9,getBoundTextElement as A9,getElementBounds as D9,getElementLineSegments as _9,getFreedrawOutlineAsSegments as R9,getFreedrawOutlinePoints as N9,intersectElementWithLineSegment as e3,isArrowElement as B9,isFreeDrawElement as t3,isLineElement as F9,isPointInElement as O9}from"@excalidraw/element";import{lineSegment as z9,lineSegmentsDistance as o3,pointFrom as s3,polygon as H9,polygonIncludesPointNonZero as G9}from"@excalidraw/math";import{getElementsInGroup as n3}from"@excalidraw/element";import{shouldTestInside as U9}from"@excalidraw/element";import{hasBoundTextElement as r3,isBoundToContainer as i3}from"@excalidraw/element";import{getBoundTextElementId as a3}from"@excalidraw/element";var Ld=class extends $o{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(Qv(s),Qv(l))},fill:()=>n.state.theme===M9.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=>s3(l[0],l[1]))||[];if(n.length<2)return[];let r=z9(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=k9(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(l3(r,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(this.groupsToErase.has(d)){let m=n3(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.delete(c.id);this.groupsToErase.delete(d)}if(i3(l)&&this.elementsToErase.delete(l.containerId),r3(l)){let m=a3(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&l3(r,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(!this.groupsToErase.has(d)){let m=n3(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.add(c.id);this.groupsToErase.add(d)}if(r3(l)){let m=a3(l);m&&this.elementsToErase.add(m)}i3(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()}},l3=(e,o,t,n)=>{let r=e[1],i=t3(o)?15:o.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],l=D9(o,t),s=[l[0]-i,l[1]-i,l[2]+i,l[3]+i];if(!P9(a,s))return!1;if(U9(o)&&O9(r,o,t))return!0;if(t3(o)){let m=N9(o),c=R9(o,m,t),p=Math.max(2.25,5/n);for(let f of c)if(o3(f,e)<=p)return!0;let u=H9(...m.map(([f,b])=>s3(o.x+f,o.y+b)));return!!G9(e[0],u)}let d=A9(o,t);if(B9(o)||F9(o)&&!o.polygon){let m=Math.max(o.strokeWidth,o.strokeWidth*2/n),c=_9(o,t);for(let p of c)if(o3(p,e)<=m)return!0;return!1}return e3(o,t,e,0,!0).length>0||!!d&&e3({...d,...L9(o,d,t)},t,e,0,!0).length>0};import{jsx as jt,jsxs as c3}from"react/jsx-runtime";var Y9=()=>c3("div",{"data-testid":"brave-measure-text-error",children:[jt("p",{children:jt(bt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>jt("span",{style:{fontWeight:600},children:e})})}),jt("p",{children:jt(bt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>jt("span",{style:{fontWeight:600},children:e})})}),jt("p",{children:jt(bt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>jt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),jt("p",{children:jt(bt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>jt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>c3("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),d3=Y9;import $9 from"clsx";import j9 from"react";import{useLayoutEffect as W9,useRef as m3,useEffect as p3}from"react";import{unstable_batchedUpdates as V9}from"react-dom";import{KEYS as X9,queryFocusableElements as K9}from"@excalidraw/common";import{jsx as Z9}from"react/jsx-runtime";var u3=({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 d=m3(null);p3(()=>{let c=d.current;if(!c)return;c.contains(document.activeElement)||c.focus();let p=u=>{if(u.key===X9.TAB){let f=K9(c),{activeElement:b}=document,x=f.findIndex(y=>y===b);b===c?(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 c.addEventListener("keydown",p),()=>c.removeEventListener("keydown",p)},[]);let m=m3(null);return W9(()=>{if(r&&d.current&&t!=null&&o!=null){let c=d.current,{width:p,height:u}=c.getBoundingClientRect();if(m.current?.top===t&&m.current?.left===o)return;m.current={top:t,left:o},p>=l?(c.style.width=`${l}px`,c.style.left="0px",c.style.overflowX="scroll"):o+p-i>l?c.style.left=`${l-p-10}px`:c.style.left=`${o}px`,u>=s?(c.style.height=`${s-20}px`,c.style.top="10px",c.style.overflowY="scroll"):t+u-a>s?c.style.top=`${s-u}px`:c.style.top=`${t}px`}},[t,o,r,l,s,i,a]),p3(()=>{if(n){let c=p=>{d.current?.contains(p.target)||V9(()=>n(p))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[n]),Z9("div",{className:"popover",ref:d,tabIndex:-1,children:e})};import{jsx as Yi,jsxs as q9}from"react/jsx-runtime";var Xe="separator",h3=j9.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=Eo(),a=pn(),l=o.reduce((s,d)=>(d&&(d===Xe||!d.predicate||d.predicate(a,i,e.app.props,e.app))&&s.push(d),s),[]);return Yi(u3,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Yi("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,d)=>{if(s===Xe)return!l[d-1]||l[d-1]===Xe?null:Yi("hr",{className:"context-menu-item-separator"},d);let m=s.name,c="";return s.label&&(typeof s.label=="function"?c=g(s.label(a,i,e.app)):c=g(s.label)),Yi("li",{"data-testid":m,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:q9("button",{type:"button",className:$9("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Yi("div",{className:"context-menu-item__label",children:c}),Yi("kbd",{className:"context-menu-item__shortcut",children:m?Oe(m):""})]})},d)})})})});import{jsx as Eg,jsxs as g3}from"react/jsx-runtime";var J9=({height:e,width:o,userToFollow:t,onDisconnect:n})=>Eg("div",{className:"follow-mode",style:{width:o,height:e},children:g3("div",{className:"follow-mode__badge",children:[g3("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:n,className:"follow-mode__disconnect-btn",children:Gt})]})}),f3=J9;import yr from"clsx";import xz from"react";import{CLASSES as Ez,DEFAULT_SIDEBAR as xf,MQ_MIN_WIDTH_DESKTOP as yz,TOOL_TYPE as Z5,arrayToMap as wz,capitalizeString as vz,isShallowEqual as gm}from"@excalidraw/common";import{mutateElement as Tz}from"@excalidraw/element";import{showSelectedShapeActions as Iz}from"@excalidraw/element";import{ShapeCache as Cz}from"@excalidraw/element";import Q9 from"clsx";import{useState as eN,useEffect as tN}from"react";import{THEME as oN}from"@excalidraw/common";import{jsx as yg,jsxs as nN}from"react/jsx-runtime";var Pd=({delay:e,theme:o})=>{let[t,n]=eN(!!e);return tN(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:nN("div",{className:Q9("LoadingMessage",{"LoadingMessage--dark":o===oN.DARK}),children:[yg("div",{children:yg(rt,{})}),yg("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import rN from"clsx";import{jsx as x3,jsxs as aN}from"react/jsx-runtime";var iN="medium",b3={CHECKED:Br,UNCHECKED:Jn},Ad=e=>aN("label",{className:rN("ToolIcon ToolIcon__lock",`ToolIcon_size_${iN}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[x3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),x3("div",{className:"ToolIcon__icon",children:e.checked?b3.CHECKED:b3.UNCHECKED})]});import{showSelectedShapeActions as IN}from"@excalidraw/element";import lN from"clsx";import{jsx as sN}from"react/jsx-runtime";var Dd=({children:e,side:o,className:t})=>sN("div",{className:lN("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import cN from"clsx";import{KEYS as E3}from"@excalidraw/common";import{jsx as dN}from"react/jsx-runtime";var _d=e=>dN(K,{className:cN("Shape",{fillable:!1}),type:"radio",icon:Es,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:E3.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":E3.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as mN,DEFAULT_SIDEBAR as pN}from"@excalidraw/common";import{isFlowchartNodeElement as uN,isImageElement as y3,isLinearElement as w3,isLineElement as hN,isTextBindableContainer as gN,isTextElement as fN}from"@excalidraw/element";import{getShortcutKey as wg}from"@excalidraw/common";import{isNodeInFlowchart as bN}from"@excalidraw/element";import{jsx as v3}from"react/jsx-runtime";var xN=({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===pN.name&&e.openSidebar.tab===mN&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(vt(e))return g("hints.eraserRevert");if(r.type==="arrow"||r.type==="line")return s?g("hints.linearElementMulti"):r.type==="arrow"?g("hints.arrowTool",{arrowShortcut:wg("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 d=n.scene.getSelectedElements(e);if(i&&l==="mouse"&&d.length===1){let m=d[0];return w3(m)&&m.points.length===2?g("hints.lockAngle"):y3(m)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(d.length===1&&fN(d[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(d.length===1&&y3(d[0]))return g("hints.enterCropEditor");if(r.type==="selection"){if(e.selectionElement&&!d.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(kn(n)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!d.length&&!o)return[g("hints.canvasPanning")];if(d.length===1){if(w3(d[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):hN(d[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&gN(d[0]))return uN(d[0])?bN(d[0],n.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},Rd=({appState:e,isMobile:o,device:t,app:n})=>{let r=xN({appState:e,isMobile:o,device:t,app:n});if(!r)return null;let i=Array.isArray(r)?r.map(a=>wg(a).replace(/\. ?$/,"")).join(". "):wg(r);return v3("div",{className:"HintViewer",children:v3("span",{children:i})})};import EN from"clsx";import{jsx as T3,jsxs as wN}from"react/jsx-runtime";var yN="medium",Nd=e=>e.penDetected?wN("label",{className:EN("ToolIcon ToolIcon__penMode",`ToolIcon_size_${yN}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[T3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),T3("div",{className:"ToolIcon__icon",children:r0})]}):null;import{Fragment as vN,jsx as I3,jsxs as TN}from"react/jsx-runtime";var Pn=({heading:e,children:o,...t})=>{let{id:n}=Be(),r=I3("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:g(`headings.${e}`)});return I3("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):TN(vN,{children:[r,o]})})};import{Fragment as CN,jsx as at,jsxs as jo}from"react/jsx-runtime";var C3=({appState:e,elements:o,actionManager:t,setAppState:n,onLockToggle:r,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:d,device:m,renderWelcomeScreen:c,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=Se(),y=()=>jo(Dd,{side:"top",className:"App-top-bar",children:[c&&at(f.Out,{}),at(Pn,{heading:"shapes",children:w=>at(Je.Col,{gap:4,align:"center",children:jo(Je.Row,{gap:1,className:"App-toolbar-container",children:[jo(We,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[w,at(Je.Row,{gap:1,children:at(td,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),jo("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&at(x.Out,{}),at(Nd,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),at(Ad,{checked:e.activeTool.locked,onChange:r,title:g("toolBar.lock"),isMobile:!0}),at(_d,{checked:oo(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),at(Rd,{appState:e,isMobile:!0,device:m,app:u})]}),E=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?at("div",{className:"App-toolbar-content",children:at(b.Out,{})}):jo("div",{className:"App-toolbar-content",children:[at(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),jo("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return jo(CN,{children:[d(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&y(),at("div",{className:"App-bottom-bar",style:{marginBottom:Ct+po*2,marginLeft:Ct+po*2,marginRight:Ct+po*2},children:jo(We,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&IN(e,o)?at(Pn,{className:"App-mobile-menu",heading:"selectedShapeActions",children:at(ed,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,jo("footer",{className:"App-toolbar",children:[E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&at("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(w=>({...Zn(o,w)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import SN from"open-color";import kN,{useLayoutEffect as MN,useRef as LN,useState as PN}from"react";import{jsx as wl,jsxs as AN}from"react/jsx-runtime";var S3=e=>{let o=LN(null),[t,n]=PN(null);return MN(()=>{if(!e.spreadsheet)return;let r=EE(e.chartType,e.spreadsheet,0,0);n(r);let i,a=o.current;return(async()=>(i=await Ar(r,{exportBackground:!1,viewBackgroundColor:SN.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]),wl("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:wl("div",{ref:o})})},k3=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:n}=Fe(),r=kN.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{n(l),ae("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return wl(ze,{size:"small",onCloseRequest:r,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:AN("div",{className:"container",children:[wl(S3,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),wl(S3,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as An from"@radix-ui/react-popover";import M3 from"clsx";import Bd,{useLayoutEffect as DN}from"react";import{supportsResizeObserver as _N,isShallowEqual as RN}from"@excalidraw/common";import{Fragment as zN,jsx as Mo,jsxs as Fd}from"react/jsx-runtime";var NN=4,BN=8,FN=({shouldWrap:e,children:o,username:t})=>e?Mo(Rt,{label:t||"Unknown user",children:o}):Mo(zN,{children:o}),vg=({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 Mo(FN,{username:o.username,shouldWrap:r,children:l},t)},ON=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Od=Bd.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=Ve(),i=new Map;t.forEach((b,x)=>{let y=b.id||x;i.set(y,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Bd.useState(""),d=a.filter(b=>b.username?.toLowerCase().includes(l)),m=Bd.useRef(null);DN(()=>{if(m.current){let b=y=>{let E=Math.max(1,Math.min(8,Math.floor(y/38)));p(E)};if(b(m.current.clientWidth),!_N)return;let x=new ResizeObserver(y=>{for(let E of y){let{width:w}=E.contentRect;b(w)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[c,p]=Bd.useState(NN),f=a.slice(0,c-1).map(b=>vg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}));return o?Mo("div",{className:M3("UserList UserList_mobile",e),children:a.map(b=>vg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}))}):Mo("div",{className:"UserList__wrapper",ref:m,children:Fd("div",{className:M3("UserList",e),style:{"--max-avatars":c},children:[f,a.length>c-1&&Fd(An.Root,{children:[Fd(An.Trigger,{className:"UserList__more",children:["+",a.length-c+1]}),Mo(An.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Fd(We,{padding:2,children:[a.length>=BN&&Mo(Gs,{placeholder:g("quickSearch.placeholder"),onChange:s}),Mo(Us,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:d.length>0?[Mo("div",{className:"hint",children:g("userList.hint.text")}),d.map(b=>vg({actionManager:r,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===n}))]:[]}),Mo(An.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||!RN(r,i,ON))return!1}return!0});import Tg from"clsx";import{jsx as HN}from"react/jsx-runtime";var L3=e=>HN("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Or});import{jsx as qo,jsxs as Ig}from"react/jsx-runtime";var P3=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=Se();return Ig("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[qo("div",{className:Tg("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:qo(Je.Col,{gap:2,children:Ig(Pn,{heading:"canvasActions",children:[qo(ew,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&qo(tw,{renderAction:o.renderAction,className:Tg("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),qo(r.Out,{}),qo("div",{className:Tg("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Ig("div",{style:{position:"relative"},children:[n&&qo(i.Out,{}),qo(L3,{onClick:()=>o.executeAction(dr)})]})}),qo(ow,{actionManager:o,showExitZenModeBtn:t})]})},A3=P3;P3.displayName="Footer";import ZN from"clsx";import{useEffect as U3,useLayoutEffect as Y3,useRef as _g,useState as $N,forwardRef as W3,useImperativeHandle as jN,useCallback as z3}from"react";import{CLASSES as qN,EVENT as H3,isDevEnv as JN,KEYS as QN,updateObject as eB}from"@excalidraw/common";import UN from"clsx";import{useContext as YN}from"react";import GN from"react";var zd=GN.createContext({});import{jsx as Cg,jsxs as D3}from"react/jsx-runtime";var Sg=({children:e,className:o})=>{let t=me(),n=YN(zd),r=!!(t.editor.canFitSidebar&&n.shouldRenderDockButton);return D3("div",{className:UN("sidebar__header",o),"data-testid":"sidebar-header",children:[e,D3("div",{className:"sidebar__header__buttons",children:[r&&Cg(Rt,{label:g("labels.sidebarLock"),children:Cg(xt,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:J1})}),Cg(xt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":g("buttons.close"),children:Gt})]})]})};Sg.displayName="SidebarHeader";import*as R3 from"@radix-ui/react-tabs";import{jsx as _3}from"react/jsx-runtime";var kg=({children:e,tab:o,onSelect:t,...n})=>_3(R3.Trigger,{value:o,asChild:!0,onSelect:t,children:_3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});kg.displayName="SidebarTabTrigger";import*as N3 from"@radix-ui/react-tabs";import{jsx as WN}from"react/jsx-runtime";var Mg=({children:e,...o})=>WN(N3.List,{className:"sidebar-triggers",...o,children:e});Mg.displayName="SidebarTabTriggers";import VN from"clsx";import{jsx as Lg,jsxs as B3}from"react/jsx-runtime";var Pg=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=ce(),d=fe();return B3("label",{title:n,className:"sidebar-trigger__label-element",children:[Lg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let c=m.target.checked;s({openSidebar:c?{name:e,tab:o}:null}),i?.(c)},checked:d.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),B3("div",{className:VN("sidebar-trigger",a),style:l,children:[t&&Lg("div",{children:t}),r&&Lg("div",{className:"sidebar-trigger__label",children:r})]})]})};Pg.displayName="SidebarTrigger";import*as F3 from"@radix-ui/react-tabs";import{jsx as XN}from"react/jsx-runtime";var Ag=({children:e,...o})=>{let t=fe(),n=ce();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return XN(F3.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...o,children:e})};Ag.displayName="SidebarTabs";import*as O3 from"@radix-ui/react-tabs";import{jsx as KN}from"react/jsx-runtime";var Dg=({tab:e,children:o,...t})=>KN(O3.Content,{...t,value:e,"data-testid":e,children:o});Dg.displayName="SidebarTab";import{jsx as G3}from"react/jsx-runtime";import{createElement as tB}from"react";var vl=ue(!1),V3=W3(({name:e,children:o,onDock:t,docked:n,className:r,...i},a)=>{JN()&&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=ce(),s=ln(vl);Y3(()=>(s(!!n),()=>{s(!1)}),[s,n]);let d=_g({});d.current.onCloseRequest=()=>{l({openSidebar:null})},d.current.onDock=u=>t?.(u),d.current=eB(d.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let m=_g(null);jN(a,()=>m.current);let c=me(),p=z3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return jr(m,z3(u=>{u.target.closest(".sidebar-trigger")||(!n||!c.editor.canFitSidebar)&&p()},[p,n,c.editor.canFitSidebar])),U3(()=>{let u=f=>{f.key===QN.ESCAPE&&(!n||!c.editor.canFitSidebar)&&p()};return document.addEventListener(H3.KEYDOWN,u),()=>{document.removeEventListener(H3.KEYDOWN,u)}},[p,n,c.editor.canFitSidebar]),G3(We,{...i,className:ZN(qN.SIDEBAR,{"sidebar--docked":n},r),ref:m,children:G3(zd.Provider,{value:d.current,children:o})})});V3.displayName="SidebarInner";var qt=Object.assign(W3((e,o)=>{let t=fe(),{onStateChange:n}=e,r=_g(t.openSidebar);U3(()=>{(!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]=$N(!1);return Y3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?tB(V3,{...e,ref:o,key:e.name}):null}),{Header:Sg,TabTriggers:Mg,TabTrigger:kg,Tabs:Ag,Tab:Dg,Trigger:Pg});qt.displayName="Sidebar";import{composeEventHandlers as dB}from"@excalidraw/common";import{useLayoutEffect as oB,useRef as nB}from"react";import{jsx as rB}from"react/jsx-runtime";var Jo=(e,o)=>{let t=ue(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Se(),[,a]=i(t),l=nB({preferHost:!1,counter:0});return oB(()=>{let s=l.current;return a(d=>{let m=d+1;return s.counter=m,m}),()=>{a(d=>{let m=d-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:rB(o,{...r})};return n.displayName=e,n};var Bg={};b1(Bg,{ChangeCanvasBackground:()=>iT,ClearCanvas:()=>nT,CommandPalette:()=>eT,Export:()=>aT,Help:()=>oT,LiveCollaborationTrigger:()=>sT,LoadScene:()=>q3,SaveAsImage:()=>Q3,SaveToActiveFile:()=>J3,SearchMenu:()=>tT,Socials:()=>lT,ToggleTheme:()=>rT});import sB from"clsx";import{THEME as Dn}from"@excalidraw/common";var Rg=ue({active:!1});async function X3({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{Ye.set(Rg,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}import iB from"clsx";import{jsx as K3,jsxs as aB}from"react/jsx-runtime";var Hd=function({onChange:e,value:o,choices:t,name:n}){return K3("div",{className:"RadioGroup",children:t.map(r=>aB("div",{className:iB("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[K3("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 lB,jsx as Ng,jsxs as Z3}from"react/jsx-runtime";var $3=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i})=>{let a=me();return Z3(lB,{children:[Z3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Ng("label",{className:"dropdown-menu-item__text",htmlFor:i,children:r}),Ng(Hd,{name:i,value:e,onChange:t,choices:n})]}),o&&!a.editor.isMobile&&Ng("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};$3.displayName="DropdownMenuItemContentRadio";var j3=$3;import{Fragment as cB,jsx as qe,jsxs as cT}from"react/jsx-runtime";var q3=()=>{let{t:e}=Ue(),o=Ve(),t=pn();return o.isActionEnabled(di)?qe(ut,{icon:zr,onSelect:async()=>{(!t.length||await X3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:qe(bt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>qe("strong",{children:r}),br:()=>qe("br",{})})}))&&o.executeAction(di)},"data-testid":"load-button",shortcut:Oe("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};q3.displayName="LoadScene";var J3=()=>{let{t:e}=Ue(),o=Ve();return o.isActionEnabled(cr)?qe(ut,{shortcut:Oe("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(cr),icon:u0,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};J3.displayName="SaveToActiveFile";var Q3=()=>{let e=ce(),{t:o}=Ue();return qe(ut,{icon:gs,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Oe("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};Q3.displayName="SaveAsImage";var eT=e=>{let o=ce(),{t}=Ue();return qe(ut,{icon:Ea,"data-testid":"command-palette-button",onSelect:()=>{ae("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Oe("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};eT.displayName="CommandPalette";var tT=e=>{let{t:o}=Ue(),t=Ve();return qe(ut,{icon:Dt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(sl)},shortcut:Oe("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};tT.displayName="SearchMenu";var oT=()=>{let{t:e}=Ue(),o=Ve();return qe(ut,{"data-testid":"help-menu-item",icon:Or,onSelect:()=>o.executeAction(dr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};oT.displayName="Help";var nT=()=>{let{t:e}=Ue(),o=ln(hr);return Ve().isActionEnabled(Go)?qe(ut,{icon:At,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};nT.displayName="ClearCanvas";var rT=e=>{let{t:o}=Ue(),t=fe(),n=Ve(),r=Oe("toggleTheme");return n.isActionEnabled(ir)?e?.allowSystemTheme?qe(j3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Dn.LIGHT,label:ga,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:Dn.DARK,label:ha,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:Lb,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):qe(ut,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Dn.DARK?Dn.LIGHT:Dn.DARK);else return n.executeAction(ir)},icon:t.theme===Dn.DARK?ga:ha,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Dn.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Dn.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};rT.displayName="ToggleTheme";var iT=()=>{let{t:e}=Ue(),o=fe(),t=Ve(),n=yo();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:cT("div",{style:{marginTop:"0.5rem"},children:[qe("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),qe("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};iT.displayName="ChangeCanvasBackground";var aT=()=>{let{t:e}=Ue(),o=ce();return qe(ut,{icon:Qn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};aT.displayName="Export";var lT=()=>{let{t:e}=Ue();return cT(cB,{children:[qe(Pi,{icon:us,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),qe(Pi,{icon:m0,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),qe(Pi,{icon:d0,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};lT.displayName="Socials";var sT=({onSelect:e,isCollaborating:o})=>{let{t}=Ue();return qe(ut,{"data-testid":"collab-button",icon:fs,className:sB({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};sT.displayName="LiveCollaborationTrigger";import{jsx as Gd,jsxs as Fg}from"react/jsx-runtime";var mB=Object.assign(Jo("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Se(),n=me(),r=fe(),i=ce(),a=n.editor.isMobile?void 0:()=>i({openMenu:null});return Gd(t.In,{children:Fg(be,{open:r.openMenu==="canvas",children:[Gd(be.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:ps}),Fg(be.Content,{onClickOutside:a,onSelect:dB(o,()=>{i({openMenu:null})}),children:[e,n.editor.isMobile&&r.collaborators.size>0&&Fg("fieldset",{className:"UserList-Wrapper",children:[Gd("legend",{children:g("labels.collaborators")}),Gd(Od,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:be.Trigger,Item:be.Item,ItemLink:be.ItemLink,ItemCustom:be.ItemCustom,Group:be.Group,Separator:be.Separator,DefaultItems:Bg}),pt=mB;import pB from"clsx";import{forwardRef as uB,useState as hB}from"react";import{isPromiseLike as gB}from"@excalidraw/common";import{jsx as Ud,jsxs as fB}from"react/jsx-runtime";var _n=uB(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:d},m)=>{let[c,p]=hB(!1),u=async b=>{let x=t?.(b);if(gB(x)){let y=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof Lr)console.warn(E);else throw E}finally{clearTimeout(y),p(!1)}}},f=c?"loading":d;return i=f==="success"?"success":i,Ud("button",{className:pB("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:m,disabled:f==="loading"||f==="success",children:fB("div",{className:"ExcButton__contents",children:[f==="loading"?Ud(rt,{className:"ExcButton__statusIcon"}):f==="success"&&Ud("div",{className:"ExcButton__statusIcon",children:db}),o&&Ud("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as Wi,jsxs as EB}from"react/jsx-runtime";var Yd=({title:e,children:o,actionLabel:t,onClick:n})=>EB("div",{className:"OverwriteConfirm__Actions__Action",children:[Wi("h4",{children:e}),Wi("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Wi(_n,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),bB=()=>{let{t:e}=Ue(),o=Ve(),t=ce();return Wi(Yd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(mc,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},xB=()=>{let{t:e}=Ue(),o=Ve();return Wi(Yd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Va,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Og=Object.assign(({children:e})=>Wi("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:bB,SaveToDisk:xB});import{jsx as Rn,jsxs as dT}from"react/jsx-runtime";var Wd=Object.assign(Jo("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Se(),[t,n]=se(Rg);if(!t.active)return null;let r=()=>{t.onClose(),n(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),n(a=>({...a,active:!1}))};return Rn(o.In,{children:Rn(ze,{onCloseRequest:r,title:!1,size:916,children:dT("div",{className:"OverwriteConfirm",children:[Rn("h3",{children:t.title}),dT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Rn("div",{className:"OverwriteConfirm__Description__icon",children:mb}),Rn("div",{children:t.description}),Rn("div",{className:"OverwriteConfirm__Description__spacer"}),Rn(_n,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Rn(Og,{children:e})]})})})}),{Actions:Og,Action:Yd});import GB from"clsx";import{CANVAS_SEARCH_TAB as Yg,DEFAULT_SIDEBAR as UB,LIBRARY_SIDEBAR_TAB as yT,composeEventHandlers as YB}from"@excalidraw/common";import{round as yB}from"@excalidraw/math";import wB from"clsx";import vB from"lodash.debounce";import{Fragment as TB,memo as IB,useEffect as Tl,useMemo as mT,useRef as zg,useState as pT}from"react";import{CLASSES as CB,EVENT as SB,FONT_FAMILY as Hg,FRAME_STYLE as Gg,getLineHeight as kB}from"@excalidraw/common";import{isElementCompletelyInViewport as MB}from"@excalidraw/element";import{measureText as Il}from"@excalidraw/element";import{KEYS as Vi,randomInteger as uT,addEventListener as LB,getFontString as Vd}from"@excalidraw/common";import{newTextElement as PB}from"@excalidraw/element";import{isTextElement as bT,isFrameLikeElement as Xd}from"@excalidraw/element";import{getDefaultFrameName as xT}from"@excalidraw/element/frame";import{Fragment as HB,jsx as tt,jsxs as Lo}from"react/jsx-runtime";var AB=ue(""),Ug=ue(null),DB=350,ET=()=>{let e=Fe(),o=ce(),t=zg(null),[n,r]=se(AB),i=n.trim(),[a,l]=pT(!1),[s,d]=pT({nonce:null,items:[]}),m=zg(null),c=zg(void 0),[p,u]=se(Ug),f=e.scene.getNonDeletedElementsMap();Tl(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==c.current)&&(m.current=null,fT(i,e,(w,v)=>{d({nonce:uT(),items:w}),m.current=i,c.current=e.scene.getSceneNonce(),o({searchMatches:w.length?{focusedId:null,matches:w.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,f,e,o,u,c]);let b=()=>{s.items.length>0&&u(w=>w===null?0:(w+1)%s.items.length)},x=()=>{s.items.length>0&&u(w=>w===null?0:w-1<0?s.items.length-1:w-1)};Tl(()=>{o(w=>w.searchMatches?{searchMatches:{focusedId:p!==null&&w.searchMatches?.matches[p]?.id||null,matches:w.searchMatches.matches.map((C,k)=>k===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),Tl(()=>{if(s.items.length>0&&p!==null){let w=s.items[p];if(w){let v=e.state.zoom.value,C=PB({text:w.searchQuery,x:w.element.x+(w.matchedLines[0]?.offsetX??0),y:w.element.y+(w.matchedLines[0]?.offsetY??0),width:w.matchedLines[0]?.width,height:w.matchedLines[0]?.height,fontSize:Xd(w.element)?Gg.nameFontSize:w.element.fontSize,fontFamily:Xd(w.element)?Hg.Assistant:w.element.fontFamily}),k=14,P=C.fontSize,S=P*v<k;if(!MB([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())||S){let _;S?P>=k?_={fitToContent:!0}:_={fitToViewport:!0,maxZoom:yB(k/P,1)}:_={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,..._,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Tl(()=>()=>{u(null),m.current=null,c.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let y=cn({goToNextItem:b,goToPreviousItem:x,searchMatches:s});Tl(()=>{let w=v=>{if(v.key===Vi.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[Vi.CTRL_OR_CMD]&&v.key===Vi.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")&&y.searchMatches.items.length&&(v.key===Vi.ENTER&&(v.stopPropagation(),y.goToNextItem()),v.key===Vi.ARROW_UP?(v.stopPropagation(),y.goToPreviousItem()):v.key===Vi.ARROW_DOWN&&(v.stopPropagation(),y.goToNextItem()))};return LB(window,SB.KEYDOWN,w,{capture:!0,passive:!1})},[o,y,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return Lo("div",{className:"layer-ui__search",children:[tt("div",{className:"layer-ui__search-header",children:tt(Tn,{className:CB.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:g("search.placeholder"),icon:Dt,onChange:w=>{r(w),l(!0);let v=w.trim();fT(v,e,(C,k)=>{d({nonce:uT(),items:C}),u(k),m.current=v,c.current=e.scene.getSceneNonce(),o({searchMatches:C.length?{focusedId:null,matches:C.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Lo("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Lo(HB,{children:[p!==null&&p>-1?Lo("div",{children:[p+1," / ",E]}):tt("div",{children:E}),Lo("div",{className:"result-nav",children:[tt(xt,{onSelect:()=>{b()},className:"result-nav-btn",children:Ts}),tt(xt,{onSelect:()=>{x()},className:"result-nav-btn",children:Rb})]})]}),s.items.length===0&&i&&m.current&&tt("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),tt(NB,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},hT=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 tt("div",{tabIndex:-1,className:wB("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:tt("div",{className:"preview-text",children:o.flatMap((t,n)=>tt(TB,{children:n===2?tt("b",{children:t}):t},n))})})},_B=e=>{let o=mT(()=>e.matches.items.filter(n=>Xd(n.element)),[e.matches]),t=mT(()=>e.matches.items.filter(n=>bT(n.element)),[e.matches]);return Lo("div",{children:[o.length>0&&Lo("div",{className:"layer-ui__search-result-container",children:[Lo("div",{className:"layer-ui__search-result-title",children:[tt("div",{className:"title-icon",children:tr}),tt("div",{children:g("search.frames")})]}),o.map((n,r)=>tt(hT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&tt("div",{className:"layer-ui__divider"})]}),t.length>0&&Lo("div",{className:"layer-ui__search-result-container",children:[Lo("div",{className:"layer-ui__search-result-title",children:[tt("div",{className:"title-icon",children:Fr}),tt("div",{children:g("search.texts")})]}),t.map((n,r)=>tt(hT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},RB=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,NB=IB(_B,RB),gT=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),d=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;d=d.length>m?d.slice(-m):d;let c=e.slice(o+t.length),p=c.split(/\s+/),u=!c.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:d.length,previewText:d+t+b,moreBefore:s>0,moreAfter:p.length>f}},BB=(e,o)=>{let t=e.split(`
|
|
17
|
-
`),n=[],r=0;for(let i=0;i<
|
|
18
|
-
`)},
|
|
19
|
-
`),i=[],a=0,l=0;for(let c of r){let p=a,u=p+c.length-1;i.push({line:c,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=
|
|
15
|
+
C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,jo(e,!0))}else i=t.polygon([[a,l],[s,d],[m,c],[p,u]],jo(e));return i}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,jo(e));case"line":case"arrow":{let i,a=jo(e),l=e.points.length?e.points:[l_(0,0)];if(Sl(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[t.path(g_(l,16),jo(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[t.curve(l,a)]:a.fill?i=[t.polygon(l,a)]:i=[t.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:d="arrow"}=e;if(s!==null){let m=X2(e,i,"start",s,t,a,n);i.push(...m)}if(d!==null){let m=X2(e,i,"end",d,t,a,n);i.push(...m)}}return i}case"freedraw":{let i;if(U2(e),fd(e.points)){let a=a_(e.points,.75);i=t.curve(a,{...jo(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return c_(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},g_=(e,t)=>{let o=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=yd(l,i),d=yd(a,l),m=Math.min(t,W2(e[r],a)/2,W2(e[r],i)/2);s?i[0]<l[0]?o.push([e[r][0]-m,e[r][1]]):o.push([e[r][0]+m,e[r][1]]):i[1]<l[1]?o.push([e[r][0],e[r][1]-m]):o.push([e[r][0],e[r][1]+m]),o.push(e[r]),d?a[0]<l[0]?o.push([e[r][0]-m,e[r][1]]):o.push([e[r][0]+m,e[r][1]]):a[1]<l[1]?o.push([e[r][0],e[r][1]-m]):o.push([e[r][0],e[r][1]+m])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<o.length;r+=3)n.push(`L ${o[r][0]} ${o[r][1]}`),n.push(`Q ${o[r+1][0]} ${o[r+1][1]}, ${o[r+2][0]} ${o[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var Z2=(e,t,o=!1)=>{let n=!1;for(let r in t){let i=t[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!o?e:{...e,...t,version:t.version??e.version+1,versionNonce:t.versionNonce??f_(),updated:b_()}};import{jsx as j2}from"react/jsx-runtime";var $i=O({name:"toggleLinearEditor",category:Pe.elements,label:(e,t,o)=>o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return!!(!t.selectedLinearElement?.isEditing&&r.length===1&&E_(r[0])&&!x_(r[0]))},perform(e,t,o,n){let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];qh(r,"No selected element found"),qh(t.selectedLinearElement,"No selected linear element found"),qh(r.id===t.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...t.selectedLinearElement,isEditing:!t.selectedLinearElement.isEditing};return{appState:{...t,selectedLinearElement:i},captureUpdate:$2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:o})=>{let n=o.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!n)return null;let r=g(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return j2(V,{type:"button",icon:F0,title:r,"aria-label":r,onClick:()=>t(null)})}}),F0e=O({name:"togglePolygon",category:Pe.elements,icon:$m,keywords:["loop"],label:(e,t,o)=>!o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds}).some(i=>!Zi(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds});return r.length>0&&r.every(i=>Zi(i)&&i.points.length>=4)},perform(e,t,o,n){let r=n.scene.getSelectedElements(t);if(r.some(s=>!Zi(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=y_(i);return{elements:e.map(s=>!l.has(s.id)||!Zi(s)?s:Z2(s,{backgroundColor:a?s.backgroundColor:"transparent",...w_(s,a)})),appState:t,captureUpdate:$2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:o})=>{let n=o.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(a=>!Zi(a)||!a.polygon||a.points.length<3))return null;let r=n.every(a=>Zi(a)&&a.polygon),i=g(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return j2(ni,{icon:$m,title:i,"aria-label":i,active:r,onClick:()=>t(null),style:{marginLeft:"auto"}})}});import{KEYS as q2,CANVAS_SEARCH_TAB as J2,CLASSES as v_,DEFAULT_SIDEBAR as Q2}from"@excalidraw/common";import{CaptureUpdateAction as T_}from"@excalidraw/element";var Il=O({name:"searchMenu",icon:Dt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,t,o,n){if(t.openDialog)return!1;if(t.openSidebar?.name===Q2.name&&t.openSidebar.tab===J2){let r=n.excalidrawContainerValue.container?.querySelector(`.${v_.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...t,openSidebar:{name:Q2.name,tab:J2},openDialog:null},captureUpdate:T_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>o.gridModeEnabled===void 0,keyTest:e=>e[q2.CTRL_OR_CMD]&&e.key===q2.F});import{isImageElement as I_}from"@excalidraw/element";import{CaptureUpdateAction as C_}from"@excalidraw/element";import{jsx as S_}from"react/jsx-runtime";var Jh=O({name:"cropEditor",label:"helpDialog.cropStart",icon:fp,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,t,o,n){let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...t,isCropping:!1,croppingElementId:r.id},captureUpdate:C_.IMMEDIATELY}},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return!!(!t.croppingElementId&&r.length===1&&I_(r[0]))},PanelComponent:({appState:e,updateData:t,app:o})=>{let n=g("helpDialog.cropStart");return S_(V,{type:"button",icon:fp,title:n,"aria-label":n,onClick:()=>t(null)})}});import{getNonDeletedElements as k_}from"@excalidraw/element";import{mutateElement as M_}from"@excalidraw/element";import{newFrameElement as P_}from"@excalidraw/element";import{isFrameLikeElement as Id}from"@excalidraw/element";import{addElementsToFrame as L_,removeAllElementsFromFrame as A_}from"@excalidraw/element";import{getFrameChildren as D_}from"@excalidraw/element";import{KEYS as ev,updateActiveTool as tv}from"@excalidraw/common";import{getElementsInGroup as __}from"@excalidraw/element";import{getCommonBounds as R_}from"@excalidraw/element";import{CaptureUpdateAction as Er}from"@excalidraw/element";var ov=(e,t)=>{let o=t.scene.getSelectedElements(e);return o.length===1&&Id(o[0])},nv=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t).at(0)||null;if(Id(r)){let i=D_(k_(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:Er.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:Er.EVENTUALLY}},predicate:(e,t,o,n)=>ov(t,n)}),rv=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t).at(0)||null;return Id(r)?{elements:A_(e,r),appState:{...t,selectedElementIds:{[r.id]:!0}},captureUpdate:Er.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:Er.EVENTUALLY}},predicate:(e,t,o,n)=>ov(t,n)}),Kxe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},captureUpdate:Er.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),Zxe=O({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:io,viewMode:!1,perform:(e,t,o,n)=>{let r=tv(t,{type:"frame"});return Rt(n.interactiveCanvas,{...t,activeTool:r}),{elements:e,appState:{...t,activeTool:tv(t,{type:"frame"})},captureUpdate:Er.EVENTUALLY}},keyTest:e=>!e[ev.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===ev.F}),iv=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=Q(e,t);return r.length>0&&!r.some(i=>Id(i))},perform:(e,t,o,n)=>{let r=Q(e,t),i=n.scene.getNonDeletedElementsMap(),[a,l,s,d]=R_(r,i),m=16,c=P_({x:a-m,y:l-m,width:s-a+m*2,height:d-l+m*2});if(t.editingGroupId){let u=__(r,t.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(t.editingGroupId);M_(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:L_([...n.scene.getElementsIncludingDeleted(),c],r,c,t),appState:{selectedElementIds:{[c.id]:!0}},captureUpdate:Er.IMMEDIATELY}}});import{isWindows as G_,KEYS as Al,matchKey as tg,arrayToMap as av,MOBILE_ACTION_BUTTON_BG as lv}from"@excalidraw/common";import{CaptureUpdateAction as eg}from"@excalidraw/element";import{orderByFractionalIndex as U_}from"@excalidraw/element";import{Emitter as N_}from"@excalidraw/common";import{CaptureUpdateAction as B_,StoreChange as O_,StoreDelta as F_}from"@excalidraw/element";var ji=class extends F_{applyTo(t,o,n){let[r,i]=this.elements.applyTo(t,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(o,r);return[r,a,i||l]}static calculate(t,o){return super.calculate(t,o)}static inverse(t){return super.inverse(t)}static applyLatestChanges(t,o,n,r){return super.applyLatestChanges(t,o,n,r)}},yr=class{constructor(t=!0,o=!0){this.isUndoStackEmpty=t;this.isRedoStackEmpty=o}},Ll=class e{constructor(t){this.store=t;C(this,"onHistoryChangedEmitter",new N_);C(this,"undoStack",[]);C(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(t){if(t.isEmpty()||t instanceof ji)return;let o=ji.inverse(t);this.undoStack.push(o),o.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new yr(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(t,o){return this.perform(t,o,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(t,o){return this.perform(t,o,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(t,o,n,r){try{let i=n();if(i===null)return;let a=B_.IMMEDIATELY,l=this.store.snapshot,s=t,d=o,m=!1;for(;i;){try{[s,d,m]=i.applyTo(s,d,l);let c=l.elements,p=l.maybeClone(a,s,d),u=O_.create(l,p),f=ji.applyLatestChanges(i,c,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{r(i)}if(m)break;i=n()}return[s,d]}finally{this.onHistoryChangedEmitter.trigger(new yr(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(t){if(!t.length)return null;let o=t.pop();return o!==void 0?o:null}static push(t,o){let n=ji.inverse(o);return t.push(n)}};import{useEffect as z_,useState as H_}from"react";var Qh=(e,t)=>{let[o,n]=H_(t);return z_(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),o};import{jsx as mv}from"react/jsx-runtime";var sv=(e,t,o)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=o();if(!n)return{captureUpdate:eg.EVENTUALLY};let[r,i]=n,a=U_(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:eg.NEVER}}return{captureUpdate:eg.EVENTUALLY}},cv=e=>({name:"undo",label:"buttons.undo",icon:Qm,trackEvent:{category:"history"},viewMode:!1,perform:(t,o,n,r)=>sv(r,o,()=>e.undo(av(t),o)),keyTest:t=>t[Al.CTRL_OR_CMD]&&tg(t,Al.Z)&&!t.shiftKey,PanelComponent:({appState:t,updateData:o,data:n})=>{let{isUndoStackEmpty:r}=Qh(e.onHistoryChangedEmitter,new yr(e.isUndoStackEmpty,e.isRedoStackEmpty));return mv(V,{type:"button",icon:Qm,"aria-label":g("buttons.undo"),onClick:o,size:n?.size||"medium",disabled:r,"data-testid":"button-undo",style:{...t.stylesPanelMode==="mobile"?lv:{}}})}}),dv=e=>({name:"redo",label:"buttons.redo",icon:ep,trackEvent:{category:"history"},viewMode:!1,perform:(t,o,n,r)=>sv(r,o,()=>e.redo(av(t),o)),keyTest:t=>t[Al.CTRL_OR_CMD]&&t.shiftKey&&tg(t,Al.Z)||G_&&t.ctrlKey&&!t.shiftKey&&tg(t,Al.Y),PanelComponent:({appState:t,updateData:o,data:n})=>{let{isRedoStackEmpty:r}=Qh(e.onHistoryChangedEmitter,new yr(e.isUndoStackEmpty,e.isRedoStackEmpty));return mv(V,{type:"button",icon:ep,"aria-label":g("buttons.redo"),onClick:o,size:n?.size||"medium",disabled:r,"data-testid":"button-redo",style:{...t.stylesPanelMode==="mobile"?lv:{}}})}});import{getFontString as Y_}from"@excalidraw/common";import{newElementWith as W_}from"@excalidraw/element";import{measureText as V_}from"@excalidraw/element";import{isTextElement as pv}from"@excalidraw/element";import{CaptureUpdateAction as X_}from"@excalidraw/element";var uv=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=Q(e,t);return r.length===1&&pv(r[0])&&!r[0].autoResize},perform:(e,t,o,n)=>{let r=Q(e,t);return{appState:t,elements:e.map(i=>{if(i.id===r[0].id&&pv(i)){let a=V_(i.originalText,Y_(i),i.lineHeight);return W_(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:X_.IMMEDIATELY}}});import{CODES as K_,KEYS as Z_}from"@excalidraw/common";import{CaptureUpdateAction as $_}from"@excalidraw/element";var og=O({name:"viewMode",label:"labels.viewMode",icon:jr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:$_.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,o)=>typeof o.viewModeEnabled>"u",keyTest:e=>!e[Z_.CTRL_OR_CMD]&&e.altKey&&e.code===K_.R});import{isPromiseLike as j_}from"@excalidraw/common";import{jsx as q_}from"react/jsx-runtime";var ng=(e,t,o,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(o,n,i))&&ie(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Cd=class{constructor(t,o,n,r){C(this,"actions",{});C(this,"updater");C(this,"getAppState");C(this,"getElementsIncludingDeleted");C(this,"app");C(this,"renderAction",(t,o)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in n)||n[t])){let r=this.actions[t],i=r.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=d=>{ng(r,"ui",l,a,this.app,d),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),d,this.app))};return q_(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:o,renderAction:this.renderAction})}return null});C(this,"isActionEnabled",t=>{let o=this.getElementsIncludingDeleted(),n=this.getAppState();return!t.predicate||t.predicate(o,n,this.app.props,this.app)});this.updater=i=>{if(j_(i))i.then(a=>t(a));else return t(i)},this.getAppState=o,this.getElementsIncludingDeleted=n,this.app=r}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(o=>this.registerAction(o))}handleKeyDown(t){let o=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,d)=>(d.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in o?o[s.name]:!0)&&s.keyTest&&s.keyTest(t,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 ng(r,"keyboard",a,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(n[0].perform(i,a,l,this.app)),!0}executeAction(t,o="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();ng(t,o,i,r,this.app,n),this.updater(t.perform(r,i,n,this.app))}};var Sd=class{constructor(){C(this,"targets",new WeakMap);C(this,"rafIds",new WeakMap)}register(t,o){this.targets.set(t,{callback:o,stopped:!0})}start(t){let o=this.targets.get(t);o&&(this.rafIds.has(t)||(this.targets.set(t,{...o,stopped:!1}),this.scheduleFrame(t)))}stop(t){let o=this.targets.get(t);o&&!o.stopped&&this.targets.set(t,{...o,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return o=>{let n=this.targets.get(t);if(!n)return;let r=this.onFrame(n,o);!n.stopped&&!r?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){let o=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,o)}cancelFrame(t){if(this.rafIds.has(t)){let o=this.rafIds.get(t);cancelAnimationFrame(o)}this.rafIds.delete(t)}onFrame(t,o){return t.callback(o)??!1}};var rg=e=>{let t=Array.from(e.values());return{x:hv(t,o=>o.x)/t.length,y:hv(t,o=>o.y)/t.length}},ig=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),hv=(e,t)=>e.reduce((o,n)=>o+t(n),0);import{pointFrom as G,pointRotateRads as Dn,rangeInclusive as Kt,rangeIntersection as kd,rangesOverlap as Md}from"@excalidraw/math";import{TOOL_TYPE as wr,KEYS as gv}from"@excalidraw/common";import{getCommonBounds as ag,getDraggedElementsBounds as lg,getElementAbsoluteCoords as J_}from"@excalidraw/element";import{isBoundToContainer as Ev}from"@excalidraw/element";import{getMaximumGroups as yv}from"@excalidraw/element";import{getSelectedElements as Q_,getVisibleAndNonSelectedElements as wv}from"@excalidraw/element";var eR=8,fv=99999,Pd=e=>eR/e,Et=class Et{};C(Et,"referenceSnapPoints",null),C(Et,"visibleGaps",null),C(Et,"setReferenceSnapPoints",t=>{Et.referenceSnapPoints=t}),C(Et,"getReferenceSnapPoints",()=>Et.referenceSnapPoints),C(Et,"setVisibleGaps",t=>{Et.visibleGaps=t}),C(Et,"getVisibleGaps",()=>Et.visibleGaps),C(Et,"destroy",()=>{Et.referenceSnapPoints=null,Et.visibleGaps=null});var Zt=Et,_n=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Jo=({event:e,app:t,selectedElements:o})=>{if(e){let n=t.state.activeTool.type==="lasso"&&t.state.selectedElementsAreBeingDragged;return(t.state.activeTool.type!=="lasso"||n)&&(t.state.objectsSnapModeEnabled&&!e[gv.CTRL_OR_CMD]||!t.state.objectsSnapModeEnabled&&e[gv.CTRL_OR_CMD]&&!_n(t))}return o.length===1&&o[0].type==="arrow"?!1:t.state.objectsSnapModeEnabled},tR=(e,t,o=.01)=>Math.abs(e-t)<=o,Dl=(e,t,{omitCenter:o,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,d,m,c,p]=J_(a,t);r&&(l+=r.x,d+=r.x,c+=r.x,s+=r.y,m+=r.y,p+=r.y);let u=(d-l)/2,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!n){let b=Dn(G(l,s+f),G(c,p),a.angle),x=Dn(G(l+u,s),G(c,p),a.angle),w=Dn(G(d,s+f),G(c,p),a.angle),E=Dn(G(l+u,m),G(c,p),a.angle),y=G(c,p);i=o?[b,x,w,E]:[b,x,w,E,y]}else{let b=Dn(G(l,s),G(c,p),a.angle),x=Dn(G(d,s),G(c,p),a.angle),w=Dn(G(l,m),G(c,p),a.angle),E=Dn(G(d,m),G(c,p),a.angle),y=G(c,p);i=o?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,d]=lg(e,r??{x:0,y:0}),m=s-a,c=d-l,p=G(a,l),u=G(s,l),f=G(a,d),b=G(s,d),x=G(a+m/2,l+c/2);i=o?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>G(Ae(a[0]),Ae(a[1])))},vv=(e,t,o,n)=>wv(e,t,o,n),Tv=(e,t,o,n)=>{let r=vv(e,t,o,n),i=yv(r,n).filter(c=>!(c.length===1&&Ev(c[0]))).map(c=>ag(c).map(p=>Ae(p))),a=i.sort((c,p)=>c[0]-p[0]),l=[],s=0;e:for(let c=0;c<a.length;c++){let p=a[c];for(let u=c+1;u<a.length;u++){if(++s>fv)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&Md(Kt(b,w),Kt(y,v))&&l.push({startBounds:p,endBounds:f,startSide:[G(x,b),G(x,w)],endSide:[G(E,y),G(E,v)],length:E-x,overlap:kd(Kt(b,w),Kt(y,v))})}}let d=i.sort((c,p)=>c[1]-p[1]),m=[];s=0;e:for(let c=0;c<d.length;c++){let p=d[c];for(let u=c+1;u<d.length;u++){if(++s>fv)break e;let f=d[u],[b,,x,w]=p,[E,y,v]=f;w<y&&Md(Kt(b,x),Kt(E,v))&&m.push({startBounds:p,endBounds:f,startSide:[G(b,w),G(x,w)],endSide:[G(E,y),G(v,y)],length:y-w,overlap:kd(Kt(b,x),Kt(E,v))})}}return{horizontalGaps:l,verticalGaps:m}},bv=(e,t,o,n,r,i,a)=>{if(!Jo({app:o,event:n,selectedElements:e}))return[];if(e.length===0)return[];let l=Zt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:d}=l,[m,c,p,u]=lg(e,t).map(x=>Ae(x)),f=(m+p)/2,b=(c+u)/2;for(let x of s){if(!Md(Kt(c,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=Ae(w-f);if(x.length>p-m&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(r.length=0),a.x=Math.abs(E);let M={type:"gap",direction:"center_horizontal",gap:x,offset:E};r.push(M);continue}let[,,v]=x.endBounds,I=m-v,S=Ae(x.length-I);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(r.length=0),a.x=Math.abs(S);let M={type:"gap",direction:"side_right",gap:x,offset:S};r.push(M);continue}let[L,,,]=x.startBounds,k=L-p,R=Ae(k-x.length);if(Math.abs(R)<=a.x){Math.abs(R)<a.x&&(r.length=0),a.x=Math.abs(R);let M={type:"gap",direction:"side_left",gap:x,offset:R};r.push(M);continue}}for(let x of d){if(!Md(Kt(m,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=Ae(w-b);if(x.length>u-c&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let M={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(M);continue}let[,v,,]=x.startBounds,I=v-u,S=Ae(I-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let M={type:"gap",direction:"side_top",gap:x,offset:S};i.push(M);continue}let[,,,L]=x.endBounds,k=Ae(c-L),R=x.length-k;if(Math.abs(R)<=a.y){Math.abs(R)<a.y&&(i.length=0),a.y=Math.abs(R);let M={type:"gap",direction:"side_bottom",gap:x,offset:R};i.push(M);continue}}}},Iv=(e,t,o,n)=>{let r=vv(e,t,o,n);return yv(r,n).filter(i=>!(i.length===1&&Ev(i[0]))).flatMap(i=>Dl(i,n))},qi=(e,t,o,n,r,i,a)=>{if(!Jo({app:o,event:n,selectedElements:e})||e.length===0&&t.length===0)return[];let l=Zt.getReferenceSnapPoints();if(l)for(let s of t)for(let d of l){let m=d[0]-s[0],c=d[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(r.length=0),r.push({type:"point",points:[s,d],offset:m}),a.x=Math.abs(m)),Math.abs(c)<=a.y&&(Math.abs(c)<a.y&&(i.length=0),i.push({type:"point",points:[s,d],offset:c}),a.y=Math.abs(c))}},Cv=(e,t,o,n,r)=>{let i=o.state,a=Q_(e,i);if(!Jo({app:o,event:n,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=Ae(t.x),t.y=Ae(t.y);let l=[],s=[],d=Pd(i.zoom.value),m={x:d,y:d},c=Dl(a,r,{dragOffset:t});qi(a,c,o,n,l,s,m),bv(a,t,o,n,l,s,m);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let u={x:Ae(t.x+p.x),y:Ae(t.y+p.y)};qi(a,Dl(a,r,{dragOffset:u}),o,n,l,s,m),bv(a,u,o,n,l,s,m);let f=sg(l,s),b=nR(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Ae=e=>Math.round(e*10**6)/10**6,xv=e=>{let t=new Map;for(let o of e){let n=o.join(",");t.has(n)||t.set(n,o)}return Array.from(t.values())},sg=(e,t)=>{let o={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ae(r.points[0][0]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>G(Ae(a[0]),Ae(a[1]))))}}if(t.length>0){for(let r of t)if(r.type==="point"){let i=Ae(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(a=>G(Ae(a[0]),Ae(a[1]))))}}return Object.entries(o).map(([r,i])=>({type:"points",points:xv(i.map(a=>G(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:xv(i.map(a=>G(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},oR=e=>{let t=new Map;for(let o of e){let n=o.points.flat().map(r=>[Ae(r)]).join(",");t.has(n)||t.set(n,o)}return Array.from(t.values())},nR=(e,t,o)=>{let[n,r,i,a]=lg(e,t),l=[];for(let s of o){let[d,m,c,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=kd(Kt(r,a),s.gap.overlap),E=kd(Kt(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:[G(s.gap.startSide[0][0],y),G(n,y)]},{type:"gap",direction:"horizontal",points:[G(i,y),G(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:[G(y,s.gap.startSide[0][1]),G(y,r)]},{type:"gap",direction:"vertical",points:[G(y,a),G(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:[G(c,y),G(u,y)]},{type:"gap",direction:"horizontal",points:[G(b,y),G(n,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[G(i,y),G(d,y)]},{type:"gap",direction:"horizontal",points:[G(c,y),G(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[G(y,a),G(y,m)]},{type:"gap",direction:"vertical",points:[G(y,p),G(y,f)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[G(y,p),G(y,f)]},{type:"gap",direction:"vertical",points:[G(y,x),G(y,r)]})}break}}}return oR(l.map(s=>({...s,points:s.points.map(d=>G(Ae(d[0]),Ae(d[1])))})))},cg=(e,t,o,n,r,i)=>{if(!Jo({event:n,selectedElements:e,app:o})||e.length===0||e.length===1&&!tR(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,d]=ag(t);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(d+=r.y));let m=[];if(i)switch(i){case"e":{m.push(G(s,l),G(s,d));break}case"w":{m.push(G(a,l),G(a,d));break}case"n":{m.push(G(a,l),G(s,l));break}case"s":{m.push(G(a,d),G(s,d));break}case"ne":{m.push(G(s,l));break}case"nw":{m.push(G(a,l));break}case"se":{m.push(G(s,d));break}case"sw":{m.push(G(a,d));break}}let c=Pd(o.state.zoom.value),p={x:c,y:c},u=[],f=[];qi(t,m,o,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]=ag(e).map(S=>Ae(S)),v=[G(x,w),G(x,y),G(E,w),G(E,y)];qi(e,v,o,n,u,f,p);let I=sg(u,f);return{snapOffset:b,snapLines:I}},Sv=(e,t,o,n,r,i)=>{if(!Jo({event:o,selectedElements:[e],app:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[G(n.x+r.x,n.y+r.y)],l=Pd(t.state.zoom.value),s={x:l,y:l},d=[],m=[];qi([e],a,t,o,d,m,s);let c={x:d[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,d.length=0,m.length=0;let p=Dl([e],i,{boundingBoxCorners:!0,omitCenter:!0});qi([e],p,t,o,d,m,s);let u=sg(d,m);return{snapOffset:c,snapLines:u}},kv=(e,t,o,n,r)=>{if(!Jo({event:n,selectedElements:[],app:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=wv(e,[],t.state,r),a=Pd(t.state.zoom.value),l={x:a,y:a},s=[],d=[];for(let m of i){let c=Dl([m],r);for(let p of c){let u=p[0]-o.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(d.length=0),d.push({type:"pointer",points:[p,G(p[0],o.y)],direction:"vertical"}),l.x=u);let f=p[1]-o.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,G(o.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:d.length>0?d[0].points[0][0]-o.x:0,y:s.length>0?s[0].points[0][1]-o.y:0},snapLines:[...d,...s]}},Mv=e=>e===wr.rectangle||e===wr.ellipse||e===wr.diamond||e===wr.frame||e===wr.magicframe||e===wr.image||e===wr.text;import{pointFrom as Ld}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as rR,DEFAULT_FONT_SIZE as iR,TEXT_ALIGN as aR,VERTICAL_ALIGN as lR,getSizeFromPoints as sR,randomId as cR,arrayToMap as dR,assertNever as dg,cloneJSON as Av,getFontString as mR,isDevEnv as pR,toBrandedType as uR,getLineHeight as hR}from"@excalidraw/common";import{bindLinearElement as Pv}from"@excalidraw/element";import{newArrowElement as gR,newElement as mg,newFrameElement as fR,newImageElement as bR,newLinearElement as xR,newMagicFrameElement as ER,newTextElement as Dd}from"@excalidraw/element";import{measureText as yR,normalizeText as wR}from"@excalidraw/element";import{isArrowElement as vR}from"@excalidraw/element";import{syncInvalidIndices as TR}from"@excalidraw/element";import{redrawTextBoundingBox as IR}from"@excalidraw/element";import{LinearElementEditor as CR}from"@excalidraw/element";import{getCommonBounds as SR}from"@excalidraw/element";import{Scene as kR}from"@excalidraw/element";var Ad={width:100,height:0},Rn=100,MR=(e,t,o)=>{let n=Dd({x:0,y:0,textAlign:aR.CENTER,verticalAlign:lR.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:n.id})}),IR(n,e,o),[e,n]},Lv=(e,t,o,n,r)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let m=t?.width??Rn,c=t?.height??Rn,p;t.id&&(p=n.getElement(t.id),p||console.error(`No element for start binding with id ${t.id} found`));let u=t.x||e.x-m,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 start binding text element for ${e.id}`),i=Dd({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(i,{x:t.x||e.x-i.width,y:t.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=mg({x:u,y:f,width:m,height:c,...p,...t,type:b});break}default:dg(e,`Unhandled element start type "${t.type}"`,!0)}Pv(e,i,"start",r)}}if(o){let m=o?.height??Rn,c=o?.width??Rn,p;o.id&&(p=n.getElement(o.id),p||console.error(`No element for end binding with id ${o.id} found`));let u=o.x||e.x+e.width,f=o.y||e.y-m/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 end binding text element for ${e.id}`),a=Dd({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(a,{y:o.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=mg({x:u,y:f,width:c,height:m,...p,...o,type:b});break}default:dg(e,`Unhandled element end type "${b}"`,!0)}Pv(e,a,"end",r)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,d=Av(e.points);return e.points[l][0]>e.points[l-1][0]&&(d[0][0]=s,d[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(d[0][0]=-s,d[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(d[0][1]=s,d[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(d[0][1]=-s,d[l][1]+=s),Object.assign(e,CR.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:i,endBoundElement:a}},pg=class{constructor(){C(this,"excalidrawElements",new Map);C(this,"add",t=>{t&&this.excalidrawElements.set(t.id,t)});C(this,"getElements",()=>TR(Array.from(this.excalidrawElements.values())));C(this,"getElementsMap",()=>uR(dR(this.getElements())));C(this,"getElement",t=>this.excalidrawElements.get(t))}},Ji=(e,t)=>{if(!e)return[];let o=Av(e),n=new pg,r=new Map,i=new Map;for(let s of o){let d,m=s.id;switch(t?.regenerateIds!==!1&&Object.assign(s,{id:cR()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||Rn,u=s?.label?.text&&s.height===void 0?0:s?.height||Rn;d=mg({...s,width:p,height:u});break}case"line":{let p=s.width||Ad.width,u=s.height||Ad.height;d=xR({width:p,height:u,points:[Ld(0,0),Ld(p,u)],...s});break}case"arrow":{let p=s.width||Ad.width,u=s.height||Ad.height;d=gR({width:p,height:u,endArrowhead:"arrow",points:[Ld(0,0),Ld(p,u)],...s,type:"arrow"}),Object.assign(d,sR(d.points));break}case"text":{let p=s?.fontFamily||rR,u=s?.fontSize||iR,f=s?.lineHeight||hR(p),b=s.text??"",x=wR(b),w=yR(x,mR({fontFamily:p,fontSize:u}),f);d=Dd({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{d=bR({width:s?.width||Rn,height:s?.height||Rn,...s});break}case"frame":{d=fR({x:0,y:0,...s});break}case"magicframe":{d=ER({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{d=s;break}default:d=s,dg(s,`Unhandled element type "${s.type}"`,!0)}n.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(n.add(d),r.set(d.id,s),m&&i.set(m,d.id))}let a=n.getElementsMap(),l=new kR(a);for(let[s,d]of r){let m=n.getElement(s);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[c,p]=MR(m,d?.label,l);if(n.add(c),n.add(p),vR(c)){let u=d.type==="arrow"?d?.start:void 0,f=d.type==="arrow"?d?.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}=Lv(c,u,f,n,l);c=b,n.add(b),n.add(x),n.add(w)}}else switch(d.type){case"arrow":{let{start:c,end:p}=d;if(c&&c.id){let x=i.get(c.id);Object.assign(c,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=Lv(m,c,p,n,l);n.add(u),n.add(f),n.add(b);break}}break}}}for(let[s,d]of r){if(d.type!=="frame"&&d.type!=="magicframe")continue;let m=n.getElement(s);if(!m)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let c=[];d.children.forEach(I=>{let S=i.get(I);if(!S)throw new Error(`Element with ${I} 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:m.id}),L?.boundElements?.forEach(k=>{let R=n.getElement(k.id);if(!R)throw new Error(`Bound element with id ${k.id} doesn't exist`);Object.assign(R,{frameId:m.id}),c.push(R)}),c.push(L)});let[p,u,f,b]=SR(c),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let w=m?.x||p,E=m?.y||u,y=m?.width||f-p,v=m?.height||b-u;Object.assign(m,{x:w,y:E,width:y,height:v}),pR()&&d.children.length&&(m?.x||m?.y||m?.width||m?.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 r9}from"@excalidraw/element";import{memoize as i9,toBrandedType as a9}from"@excalidraw/common";import{pointFrom as BR,pointsEqual as OR}from"@excalidraw/math";import Rd from"open-color";import{arrayToMap as FR,DEFAULT_TRANSFORM_HANDLE_SPACING as yg,FRAME_STYLE as Fv,invariant as zv,THEME as zR,throttleRAF as HR}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as hg,maxBindingGap as Vv}from"@excalidraw/element";import{LinearElementEditor as Nn}from"@excalidraw/element";import{getOmitSidesForDevice as gg,getTransformHandles as GR,getTransformHandlesFromCoords as UR,shouldShowBoundingBox as YR}from"@excalidraw/element";import{isElbowArrow as _l,isFrameLikeElement as Hv,isImageElement as Gv,isLinearElement as WR,isLineElement as VR,isTextElement as Uv}from"@excalidraw/element";import{renderSelectionElement as XR}from"@excalidraw/element";import{getElementsInGroup as xg,getSelectedGroupIds as KR,isSelectedViaGroup as ZR,selectGroupsFromGivenElements as $R}from"@excalidraw/element";import{getCommonBounds as Eg,getElementAbsoluteCoords as Rl}from"@excalidraw/element";import{pointFrom as mt}from"@excalidraw/math";import{THEME as PR}from"@excalidraw/common";var LR="#ff6b6b",AR="#ff0000",Dv=1,_v=2,Rv=(e,t)=>{if(!t.snapLines.length)return;let o=t.theme===PR.LIGHT||t.zenModeEnabled?LR:AR,n=(t.zenModeEnabled?Dv*1.5:Dv)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let r of t.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=o,_R(r,e,t)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=o,RR(r.points[0],r.points[1],r.direction,t,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=o,DR(r,e,t));e.restore()},DR=(e,t,o)=>{if(!o.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];$t(n,r,t)}for(let n of e.points)Nv(n,o,t)},_R=(e,t,o)=>{Nv(e.points[0],o,t),o.zenModeEnabled||$t(e.points[0],e.points[1],t)},Nv=([e,t],o,n)=>{n.save();let r=(o.zenModeEnabled?_v*1.5:_v)/o.zoom.value;n.beginPath(),n.moveTo(e-r,t-r),n.lineTo(e+r,t+r),n.moveTo(e+r,t-r),n.lineTo(e-r,t+r),n.stroke(),n.restore()},$t=(e,t,o)=>{o.beginPath(),o.lineTo(e[0],e[1]),o.lineTo(t[0],t[1]),o.stroke()},RR=(e,t,o,n,r)=>{let i=8/n.zoom.value,a=i/2,l=i/4;if(o==="horizontal"){let s=[(e[0]+t[0])/2,e[1]];n.zenModeEnabled||$t(mt(e[0],e[1]-i),mt(e[0],e[1]+i),r),$t(mt(s[0]-l,s[1]-a),mt(s[0]-l,s[1]+a),r),$t(mt(s[0]+l,s[1]-a),mt(s[0]+l,s[1]+a),r),n.zenModeEnabled||($t(mt(t[0],t[1]-i),mt(t[0],t[1]+i),r),$t(e,t,r))}else{let s=[e[0],(e[1]+t[1])/2];n.zenModeEnabled||$t(mt(e[0]-i,e[1]),mt(e[0]+i,e[1]),r),$t(mt(s[0]-a,s[1]-l),mt(s[0]+a,s[1]-l),r),$t(mt(s[0]-a,s[1]+l),mt(s[0]+a,s[1]+l),r),n.zenModeEnabled||($t(mt(t[0]-i,t[1]),mt(t[0]+i,t[1]),r),$t(e,t,r))}};import{getGlobalCSSVariable as _d}from"@excalidraw/common";import{getCommonBounds as NR}from"@excalidraw/element";var Qo=4,jt=6,Bv="rgba(0,0,0,0.3)",Ov=(e,t,o,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=NR(e),s=t/n.zoom.value,d=o/n.zoom.value,m={top:parseInt(_d("sat"))||0,bottom:parseInt(_d("sab"))||0,left:parseInt(_d("sal"))||0,right:parseInt(_d("sar"))||0},c=zo().rtl,p=-n.scrollX+m.left,u=-n.scrollY+m.top,f=p+s-m.right,b=u+d-m.bottom,x=Math.min(r,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-r,I=l-i,S=E-x,L=y-w,k=Math.max(Qo*2,m.left+m.right)+jt*2,R=t*(s/S)-k,M=Math.max(Qo*2,m.top+m.bottom)+jt*2,_=o*(d/L)-M,N=S>v?S*n.zoom.value/(R+k):t/(R+k),K=L>I?L*n.zoom.value/(_+M):o/(_+M);return{horizontal:p===x&&f===E?null:{x:Math.max(m.left,Qo)+jt+(p-x)/S*t,y:o-jt-Math.max(Qo,m.bottom),width:R,height:jt,deltaMultiplier:N},vertical:u===w&&b===y?null:{x:c?Math.max(m.left,Qo):t-jt-Math.max(m.right,Qo),y:Math.max(m.top,Qo)+jt+(u-w)/L*o,width:jt,height:_,deltaMultiplier:K}}},ug=(e,t,o)=>{let[n,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=t&&t<=a.x+a.width&&a.y<=o&&o<=a.y+a.height);return{isOverEither:n||r,isOverHorizontal:n,isOverVertical:r}};var jR=(e,t)=>{zv(t.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:o}=t.selectedLinearElement;zv(o,"midPointCoords is null"),e.save(),e.translate(t.scrollX,t.scrollY),Xv(o,e,t),e.restore()},qR=(e,t,o)=>{let{elementId:n,hoverPointIndex:r}=t.selectedLinearElement;if(t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(r))return;let i=Nn.getElement(n,o);if(!i)return;let a=Nn.getPointAtIndexGlobalCoordinates(i,r,o);e.save(),e.translate(t.scrollX,t.scrollY),Xv(a,e,t),e.restore()},Xv=(e,t,o)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",Ta(t,e[0],e[1],Nn.POINT_HANDLE_SIZE/o.zoom.value,!1)},fg=(e,t,o,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)"),Ta(e,o[0],o[1],(a?n*(t.selectedLinearElement?.isEditing?1.5:2):n)/t.zoom.value,!i,!a||r)},JR=(e,t,o,n)=>{let r=Vv(t,t.width,t.height,n);switch(e.fillStyle="rgba(0,0,0,.05)",t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":B1(e,t,o,r);break;case"diamond":F1(e,r,t,o);break;case"ellipse":{let[i,a,l,s]=Rl(t,o),d=l-i,m=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=r-hg,O1(e,d+r+hg,m+r+hg,i+d/2,a+m/2,t.angle);break}}},QR=(e,t,o,n)=>{let[r,i,a]=t,l=Vv(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(d=>{let[m,c]=Nn.getPointAtIndexGlobalCoordinates(r,d,o);Ta(e,m,c,l,!0)})},Kv=(e,t,o)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:d,cy:m,dashed:c,activeEmbeddable:p}=o,u=a-r,f=l-i,x=(o.padding??yg*2)/t.zoom.value,w=8/t.zoom.value,E=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(p?4:1)/t.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],c&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*v,Ia(e,r-x,i-x,u+x*2,f+x*2,d,m,n);e.restore()},e9=(e,t,o,n)=>{let r=Array.isArray(o)?QR:JR;e.save(),e.translate(t.scrollX,t.scrollY),r(e,o,n,t.zoom),e.restore()},t9=(e,t,o,n)=>{let[r,i,a,l]=Rl(o,n),s=a-r,d=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Fv.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),Ia(e,r,i,s,d,r+s/2,i+d/2,o.angle,!1,Fv.radius/t.zoom.value),e.restore()},Yv=(e,t,o,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=o.filter(m=>m.groupIds.length===0),l=o.filter(m=>m.groupIds.length>0),s=m=>{let[c,p,u,f]=Eg(m);return{angle:0,x1:c,x2:u,y1:p,y2:f,selectionColors:r,dashed:i,cx:c+(u-c)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},d=m=>{let c=xg(o,m);return s(c)};Object.entries($R(l,t)).filter(([m,c])=>c).map(([m,c])=>m).map(m=>d(m)).concat(a.map(m=>s([m]))).forEach(m=>Kv(e,t,m))},bg=(e,t,o,n)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let r=Nn.getPointsGlobalCoordinates(o,n),{POINT_HANDLE_SIZE:i}=Nn,a=t.selectedLinearElement?.isEditing?i:i/2,l=_l(o),s=VR(o);if(r.forEach((d,m)=>{if(l&&m!==0&&m!==r.length-1)return;let c=m>0&&(m!==r.length-1||!s||!o.polygon)&&OR(d,m===r.length-1?r[0]:r[m-1],2/t.zoom.value),p=!!t.selectedLinearElement?.isEditing&&!!t.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&o.polygon&&!p&&m===o.points.length-1&&t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),fg(e,t,d,a,p,!1,c)}),_l(o)){let d=o.fixedSegments?.map(m=>m.index)||[];r.slice(0,-1).forEach((m,c)=>{Nn.isSegmentTooShort(o,r[c+1],r[c],c,t.zoom)||fg(e,t,BR((m[0]+r[c+1][0])/2,(m[1]+r[c+1][1])/2),i/2,!1,!d.includes(c+1),!1)})}else Nn.getEditorMidPoints(o,n,t).filter((m,c,p)=>m!==null&&!(_l(o)&&(c===0||c===p.length-1))).forEach(m=>{(t.selectedLinearElement?.isEditing||r.length===2)&&fg(e,t,m,i/2,!1,!0,!1)});e.restore()},Wv=(e,t,o,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,d,m]=a;e.save(),e.lineWidth=1/o.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?Ta(e,l+d/2,s+m/2,d/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,d,m,2/o.zoom.value),e.fill(),e.stroke()):Ia(e,l,s,d,m,l+d/2,s+m/2,r,!0),e.restore()}})},o9=(e,t,o,n,r)=>{let[i,a,,,l,s]=Rl(n,r),d=3,m=20,c=d/o.zoom.value,p=c/2,u=l-i+c,f=s-a+c,b=Math.min(m/o.zoom.value,u),x=Math.min(m/o.zoom.value,f);e.save(),e.fillStyle=t.selectionColor,e.strokeStyle=t.selectionColor,e.lineWidth=c,[[[-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],[I,S],[L,k],[R,M],[_,N]]=E;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(y+I,v+S),e.lineTo(y+L,v+k),e.stroke(),e.beginPath(),e.moveTo(y+R,v+M),e.lineTo(y+_,v+N),e.stroke(),e.restore()}),e.restore()},n9=(e,t,o,n)=>{t.save();let r=yg*2/o.zoom.value,i=e.width+r*2,a=e.height+r*2,l=e.x+i/2,s=e.y+a/2,d=-(i/2+r),m=-(a/2+r);t.translate(l+o.scrollX,s+o.scrollY),t.rotate(e.angle),t.lineWidth=1/o.zoom.value,t.strokeStyle=n,t.strokeRect(d,m,i,a),t.restore()},Zv=({canvas:e,elementsMap:t,visibleElements:o,selectedElements:n,allElementsMap:r,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[d,m]=hs(e,i),c=gs({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m});c.save(),c.scale(a.zoom.value,a.zoom.value);let p;if(o.forEach(b=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===b.id&&b&&(p=b)}),p&&bg(c,a,p,t),a.selectionElement&&!a.isCropping)try{XR(a.selectionElement,c,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Uv(a.editingTextElement)){let b=r.get(a.editingTextElement.id);b&&!b.autoResize&&n9(b,c,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{e9(c,a,b,t)}),a.frameToHighlight&&t9(c,a,a.frameToHighlight,t),a.elementsToHighlight&&Yv(c,a,a.elementsToHighlight),a.activeLockedId){let b=r.get(a.activeLockedId),x=b?[b]:xg(r,a.activeLockedId);Yv(c,a,x,{colors:["#ced4da"],dashed:!0})}let u=n.some(b=>Hv(b));if(n.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===n[0].id&&bg(c,a,n[0],t),a.selectedLinearElement){let b=a.selectedLinearElement,x=n.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?jR(c,a):(_l(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&qR(c,a,t)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=YR(n,a),x=n.length===1&&WR(n[0]);x&&a.selectedLinearElement?.elementId===n[0].id&&!n[0].locked&&bg(c,a,n[0],t);let w=l.selectionColor||Rd.black;if(b){let E=FR(n),y=[];for(let I of t.values()){let S=[],L=l.remoteSelectedElementIds.get(I.id);if(x&&_l(I)&&(I.startBinding||I.endBinding)||(E.has(I.id)&&!ZR(a,I)&&S.push(w),L&&S.push(...L.map(k=>hr(k,a.collaborators.get(k))))),S.length){let[k,R,M,_,N,K]=Rl(I,t,!0);y.push({angle:I.angle,x1:k,y1:R,x2:M,y2:_,selectionColors:I.locked?["#ced4da"]:S,dashed:!!L||I.locked,cx:N,cy:K,activeEmbeddable:a.activeEmbeddable?.element===I&&a.activeEmbeddable.state==="active",padding:I.id===a.croppingElementId||Gv(I)?0:void 0})}}let v=I=>{let S=xg(t,I),[L,k,R,M]=Eg(S);y.push({angle:0,x1:L,x2:R,y1:k,y2:M,selectionColors:S.some(_=>_.locked)?["#ced4da"]:[Rd.black],dashed:!0,cx:L+(R-L)/2,cy:k+(M-k)/2,activeEmbeddable:!1})};for(let I of KR(a))v(I);a.editingGroupId&&v(a.editingGroupId),y.forEach(I=>Kv(c,a,I))}if(c.save(),c.translate(a.scrollX,a.scrollY),n.length===1){c.fillStyle=Rd.white;let E=GR(n[0],a.zoom,t,"mouse",gg(s));if(!a.viewModeEnabled&&b&&!Uv(a.editingTextElement)&&!a.croppingElementId&&Wv(c,l,a,E,n[0].angle),a.croppingElementId&&!a.isCropping){let y=t.get(a.croppingElementId);y&&Gv(y)&&o9(c,l,a,y,t)}}else if(n.length>1&&!a.isRotating&&!n.some(E=>E.locked)){let E=yg*2/a.zoom.value;c.fillStyle=Rd.white;let[y,v,I,S]=Eg(n,t),L=c.getLineDash();c.setLineDash([2/a.zoom.value]);let k=c.lineWidth;c.lineWidth=1/a.zoom.value,c.strokeStyle=w,Ia(c,y-E,v-E,I-y+E*2,S-v+E*2,(y+I)/2,(v+S)/2,0),c.lineWidth=k,c.setLineDash(L);let R=UR([y,v,I,S,(y+I)/2,(v+S)/2],0,a.zoom,"mouse",u?{...gg(s),rotation:!0}:gg(s));n.some(M=>!M.locked)&&Wv(c,l,a,R,0)}c.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=t.get(b);if(E){let[y,v,,,I,S]=Rl(E,t,!0);c.save(),a.theme===zR.LIGHT?x?c.fillStyle="rgba(255, 124, 0, 0.4)":c.fillStyle="rgba(255, 226, 0, 0.4)":x?c.fillStyle="rgba(229, 82, 0, 0.4)":c.fillStyle="rgba(99, 52, 0, 0.4)";let L=Hv(E)?a.zoom.value:1;c.translate(a.scrollX,a.scrollY),c.translate(I,S),c.rotate(E.angle),w.forEach(k=>{(k.showOnCanvas||x)&&c.fillRect(y+k.offsetX/L-I,v+k.offsetY/L-S,k.width/L,k.height/L)}),c.restore()}}),Rv(c,a),c.restore(),VE({context:c,renderConfig:l,appState:a,normalizedWidth:d,normalizedHeight:m});let f;return l.renderScrollbars&&(f=Ov(t,d,m,a),c.save(),c.fillStyle=Bv,c.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&Mc(c,b.x,b.y,b.width,b.height,jt/2)}),c.restore()),{scrollBars:f,atLeastOneVisibleElement:o.length>0,elementsMap:t}},wg=HR(e=>{let t=Zv(e);e.callback?.(t)},{trailing:!0}),$v=(e,t)=>{if(t){wg(e);return}let o=Zv(e);return e.callback(o),o};var Nl=class{constructor(t){C(this,"scene");C(this,"getRenderableElements",(()=>{let t=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:d,width:m})=>{let c=[];for(let p of n.values())r9(p,m,d,{zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},n)&&c.push(p);return c},o=({elements:n,editingTextElement:r,newElementId:i})=>{let a=a9(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 i9(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d,editingTextElement:m,newElementId:c,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=o({elements:u,editingTextElement:m,newElementId:c}),b=t({elementsMap:f,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d});return{elementsMap:f,visibleElements:b}})})());this.scene=t}destroy(){wg.cancel(),H1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as l9}from"@excalidraw/common";import{getElementAbsoluteCoords as s9}from"@excalidraw/element";import{jsx as m9}from"react/jsx-runtime";var c9=5,d9=(e,t,o)=>{let[n,r]=s9(e,o),{x:i,y:a}=l9({sceneX:n+e.width,sceneY:r},t),l=i-t.offsetLeft+10,s=a-t.offsetTop;return{x:l,y:s}},vg=({children:e,element:t,elementsMap:o})=>{let n=vo();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=d9(t,n,o);return m9("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:c9},children:e})};import{DEFAULT_LASER_COLOR as g9,easeOut as qv}from"@excalidraw/common";import{LaserPointer as p9}from"@excalidraw/laser-pointer";import{SVG_NS as jv,getSvgPathFromStroke as u9,sceneCoordsToViewportCoords as h9}from"@excalidraw/common";var en=class{constructor(t,o,n){this.animationFrameHandler=t;this.app=o;this.options=n;C(this,"currentTrail");C(this,"pastTrails",[]);C(this,"container");C(this,"trailElement");C(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(jv,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(jv,"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(t,o){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===t&&this.currentTrail.originalPoints[n-1][1]===o}return!1}start(t){t&&(this.container=t),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(t,o){this.currentTrail=new p9(this.options),this.currentTrail.addPoint([t,o,performance.now()]),this.update()}addPointToPath(t,o){this.currentTrail&&(this.currentTrail.addPoint([t,o,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 t=[];for(let n of this.pastTrails)t.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);t.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.getStrokeOutline().length!==0),t.length===0&&this.stop();let o=t.join(" ").trim();this.trailElement.setAttribute("d",o),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(t,o){let n=t.getStrokeOutline(t.options.size/o.zoom.value).map(([i,a])=>{let l=h9({sceneX:i,sceneY:a},o);return[l.x,l.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return u9(r,!0)}};var Nd=class{constructor(t,o){this.animationFrameHandler=t;this.app=o;C(this,"localTrail");C(this,"collabTrails",new Map);C(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new en(t,o,{...this.getTrailOptions(),fill:()=>g9})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let r=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(qv(i),qv(r))}}}startPath(t,o){this.localTrail.startPath(t,o)}addPointToPath(t,o){this.localTrail.addPointToPath(t,o)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[t,o]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(t)?n=this.collabTrails.get(t):(n=new en(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||hr(t,o)}),n.start(this.container),this.collabTrails.set(t,n)),o.pointer&&o.pointer.tool==="laser"&&(o.button==="down"&&!n.hasCurrentTrail&&n.startPath(o.pointer.x,o.pointer.y),o.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(o.pointer.x,o.pointer.y)&&n.addPointToPath(o.pointer.x,o.pointer.y),o.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(o.pointer.x,o.pointer.y),n.endPath()))}for(let t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}};import{version as f9}from"react";import{unstable_batchedUpdates as Jv}from"react-dom";import{throttleRAF as b9}from"@excalidraw/common";var De=e=>t=>{Jv(e,t)},Bd=e=>b9(t=>{Jv(e,t)}),Qi=(()=>{let e;try{let o=f9.split(".");e=Number(o[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Tg,KEYS as Bl,CLASSES as Ig,POINTER_BUTTON as x9,isWritableElement as E9,getFontString as Qv,getFontFamilyString as e3,isTestEnv as t3,MIME_TYPES as y9}from"@excalidraw/common";import{originalContainerCache as w9,updateOriginalContainerCache as o3}from"@excalidraw/element";import{LinearElementEditor as v9}from"@excalidraw/element";import{bumpVersion as T9}from"@excalidraw/element";import{getBoundTextElementId as I9,getContainerElement as Cg,getTextElementAngle as C9,redrawTextBoundingBox as S9,getBoundTextMaxHeight as k9,getBoundTextMaxWidth as n3,computeContainerDimensionForBoundText as r3,computeBoundTextPosition as M9,getBoundTextElement as P9}from"@excalidraw/element";import{getTextWidth as L9}from"@excalidraw/element";import{normalizeText as i3}from"@excalidraw/element";import{wrapText as A9}from"@excalidraw/element";import{isArrowElement as Od,isBoundToContainer as D9,isTextElement as a3}from"@excalidraw/element";var _9=(e,t,o,n,r,i)=>{let{zoom:a}=n,l=180*o/Math.PI,s=e*(a.value-1)/2,d=t*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),t>i&&a.value!==1&&(d=i*(a.value-1)/2),`translate(${s}px, ${d}px) scale(${a.value}) rotate(${l}deg)`},l3=({id:e,onChange:t,onSubmit:o,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let d=(A,B)=>{if(!B.style.fontFamily||!B.style.fontSize)return!1;let H=B.style.fontFamily.replace(/"/g,"");return e3({fontFamily:A.fontFamily})!==H||`${A.fontSize}px`!==B.style.fontSize},m=()=>{let A=l.state,B=l.scene.getElement(e);if(!B)return;let{textAlign:H,verticalAlign:Y}=B,q=l.scene.getNonDeletedElementsMap();if(B&&a3(B)){let pe=B.x,j=B.y,ne=Cg(B,l.scene.getNonDeletedElementsMap()),we=B.width,Pt=B.height,Lt=B.width,ln=B.height;if(ne&&B.containerId){if(Od(ne)){let cn=v9.getBoundTextElementPosition(ne,B,q);pe=cn.x,j=cn.y}let QC=d(B,c),xa;if(QC?xa=o3(ne.id,ne.height):(xa=w9[ne.id],xa||(xa=o3(ne.id,ne.height))),Lt=n3(ne,B),ln=k9(ne,B),!Od(ne)&&Pt>ln){let cn=r3(Pt,ne.type);l.scene.mutateElement(ne,{height:cn});return}else if(!Od(ne)&&ne.height>xa.height&&Pt<ln){let cn=r3(Pt,ne.type);l.scene.mutateElement(ne,{height:cn})}else{let{x:cn,y:eS}=M9(ne,B,q);pe=cn,j=eS}}let[oo,sn]=n(pe,j);ne?we+=.5:(Lt=(A.width-8-oo)/A.zoom.value,we=Math.min(we,Lt)),Pt*=1.05;let Pr=Qv(B),Fm=(A.height-sn)/A.zoom.value;Object.assign(c.style,{font:Pr,lineHeight:B.lineHeight,width:`${we}px`,height:`${Pt}px`,left:`${oo}px`,top:`${sn}px`,transform:_9(we,Pt,C9(B,ne),A,Lt,Fm),textAlign:H,verticalAlign:Y,color:B.strokeColor,opacity:B.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Fm}px`}),c.scrollTop=0,t3()&&(c.style.fontFamily=e3(B)),l.scene.mutateElement(B,{x:pe,y:j})}},c=document.createElement("textarea");c.dir="auto",c.tabIndex=0,c.dataset.type="wysiwyg",c.wrap="off",c.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(D9(r)||!r.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(c.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"}),c.value=r.originalText,m(),t&&(c.onpaste=async A=>{let B=(await il(A)).findByType(y9.text);if(!B)return;let H=i3(B.value);if(!H)return;let Y=Cg(r,l.scene.getNonDeletedElementsMap()),q=Qv({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Y){let pe=P9(Y,l.scene.getNonDeletedElementsMap()),j=A9(`${c.value}${H}`,q,n3(Y,pe)),ne=L9(j,q);c.style.width=`${ne}px`}},c.oninput=()=>{let A=i3(c.value);if(c.value!==A){let B=c.selectionStart;c.value=A,c.selectionStart=B,c.selectionEnd=B}t(c.value)}),c.onkeydown=A=>{if(!A.shiftKey&&mc.keyTest(A))A.preventDefault(),l.actionManager.executeAction(mc),m();else if(!A.shiftKey&&pc.keyTest(A))A.preventDefault(),l.actionManager.executeAction(pc),m();else if(!A.shiftKey&&uc.keyTest(A))A.preventDefault(),l.actionManager.executeAction(uc),m();else if(ou.keyTest(A))l.actionManager.executeAction(ou);else if(nu.keyTest(A))l.actionManager.executeAction(nu);else if(A.key===Bl.ESCAPE)A.preventDefault(),I=!0,S();else if(pr.keyTest(A))A.preventDefault(),S(),l.actionManager.executeAction(pr);else if(A.key===Bl.ENTER&&A[Bl.CTRL_OR_CMD]){if(A.preventDefault(),A.isComposing||A.keyCode===229)return;I=!0,S()}else if(A.key===Bl.TAB||A[Bl.CTRL_OR_CMD]&&(A.code===Tg.BRACKET_LEFT||A.code===Tg.BRACKET_RIGHT)){if(A.preventDefault(),A.isComposing)return;A.shiftKey||A.code===Tg.BRACKET_LEFT?E():w(),c.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),w=()=>{let{selectionStart:A,selectionEnd:B}=c,H=y(),Y=c.value;H.forEach(q=>{let pe=Y.slice(0,q),j=Y.slice(q);Y=`${pe}${b}${j}`}),c.value=Y,c.selectionStart=A+f,c.selectionEnd=B+f*H.length},E=()=>{let{selectionStart:A,selectionEnd:B}=c,H=y(),Y=[],q=c.value;H.forEach(pe=>{let j=q.slice(pe,pe+f).match(x);if(j){let ne=q.slice(0,pe),we=q.slice(pe+j[0].length);q=`${ne}${we}`,Y.push(pe)}}),c.value=q,Y.length&&(A>Y[Y.length-1]?c.selectionStart=Math.max(A-f,Y[Y.length-1]):c.selectionStart=A,c.selectionEnd=Math.max(c.selectionStart,B-f*Y.length))},y=()=>{let{selectionStart:A,selectionEnd:B,value:H}=c,Y=H.slice(0,A).match(/[^\n]*$/)[0].length;return A=A-Y,H.slice(A,B).split(`
|
|
16
|
+
`).reduce((pe,j,ne,we)=>pe.concat(ne?pe[ne-1]+we[ne-1].length+1:A),[]).reverse()},v=A=>{A.target instanceof HTMLCanvasElement&&(A.preventDefault(),A.stopPropagation())},I=!1,S=()=>{if(K)return;K=!0,L();let A=l.scene.getElement(r.id);if(!A)return;let B=Cg(A,l.scene.getNonDeletedElementsMap());if(B){if(c.value.trim()){let H=I9(B);!H||H!==r.id?l.scene.mutateElement(B,{boundElements:(B.boundElements||[]).concat({type:"text",id:r.id})}):Od(B)&&T9(B)}else l.scene.mutateElement(B,{boundElements:B.boundElements?.filter(H=>!a3(H))});S9(A,B,l.scene)}o({viaKeyboard:I,nextOriginalText:c.value})},L=()=>{c.onblur=null,c.oninput=null,c.onkeydown=null,J&&J.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",M),window.removeEventListener("pointerup",k),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),_(),N(),c.remove()},k=A=>{window.removeEventListener("pointerup",k);let B=A?.target,H=B instanceof HTMLElement&&B.classList.contains("properties-trigger"),Y=(B instanceof HTMLElement||B instanceof SVGElement)&&!!B.closest(".properties-content"),q=(B instanceof HTMLElement||B instanceof SVGElement)&&(!!B.closest(`.${Ig.SHAPE_ACTIONS_MENU}`)||!!B.closest(".compact-shape-actions-island"));setTimeout(()=>{q||H||Y||(c.onblur=S,c.focus())})},R=()=>{c.onblur=null,window.addEventListener("pointerup",k),window.addEventListener("blur",S)},M=A=>{let B=A?.target;if(A.button===x9.WHEEL){B instanceof HTMLTextAreaElement&&(A.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(A)),R();return}let H=B instanceof HTMLElement&&B.classList.contains("properties-trigger"),Y=(B instanceof HTMLElement||B instanceof SVGElement)&&!!B.closest(".properties-content");(A.target instanceof HTMLElement||A.target instanceof SVGElement)&&(A.target.closest(`.${Ig.SHAPE_ACTIONS_MENU}, .${Ig.ZOOM_ACTIONS}`)||A.target.closest(".compact-shape-actions-island"))&&!E9(A.target)||H||Y?R():A.target instanceof HTMLCanvasElement&&!t3()&&requestAnimationFrame(()=>{S()})},_=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||c.focus()}),N=l.onScrollChangeEmitter.on(()=>{m()}),K=!1;s&&c.select(),k();let J=null;return i&&"ResizeObserver"in window?(J=new window.ResizeObserver(()=>{m()}),J.observe(i)):window.addEventListener("resize",m),c.onpointerdown=A=>A.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",M,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(c),S};var s3=e=>{let t=["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(?:${t.map(n=>`\\s*${n}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as Y9}from"@excalidraw/math";import{getElementLineSegments as W9}from"@excalidraw/element";import{LinearElementEditor as V9}from"@excalidraw/element";import{isFrameLikeElement as X9,isLinearElement as K9,isTextElement as Z9}from"@excalidraw/element";import{getFrameChildren as $9}from"@excalidraw/element";import{selectGroupsForSelectedElements as j9}from"@excalidraw/element";import{getContainerElement as q9}from"@excalidraw/element";import{arrayToMap as J9,easeOut as p3,isShallowEqual as Q9}from"@excalidraw/common";import{simplify as R9}from"points-on-curve";import{polygonFromPoints as N9,lineSegment as c3,polygonIncludesPointNonZero as B9}from"@excalidraw/math";import{computeBoundTextPosition as O9,doBoundsIntersect as F9,getBoundTextElement as z9,getElementBounds as H9,intersectElementWithLineSegment as d3}from"@excalidraw/element";var m3=e=>{let{lassoPath:t,elements:o,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=t;l&&(s=R9(t,l));let d=o.filter(p=>!p.locked);a.clear(),i.clear();let m=t.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 d){let u=H9(p,n);F9(m,u)&&!i.has(p.id)&&!a.has(p.id)&&(G9(s,p,r)?a.add(p.id):U9(s,p,n)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},G9=(e,t,o)=>{let n=N9(e),r=o.get(t.id);return r?r.some(i=>i.some(a=>B9(a,n))):!1},U9=(e,t,o)=>{let n=e.slice(1).map((i,a)=>c3(e[a],i)).concat([c3(e[e.length-1],e[0])]),r=z9(t,o);return n.some(i=>d3(t,o,i,0,!0).length>0||!!r&&d3({...r,...O9(t,r,o)},o,i,0,!0).length>0)};var Fd=class extends en{constructor(o,n){super(o,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(p3(s),p3(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});C(this,"intersectedElements",new Set);C(this,"enclosedElements",new Set);C(this,"elementsSegments",null);C(this,"canvasTranslate",null);C(this,"keepPreviousSelection",!1);C(this,"selectElementsFromIds",o=>{this.app.setState(n=>{let r=o.reduce((s,d)=>(s[d]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let d=this.app.scene.getNonDeletedElement(s);if(d&&Z9(d)){let m=q9(d,this.app.scene.getNonDeletedElementsMap());m&&(r[m.id]=!0,delete r[d.id])}}for(let[s]of Object.entries(r)){let d=this.app.scene.getNonDeletedElement(s);if(d&&X9(d)){let m=$9(this.app.scene.getNonDeletedElementsMap(),d.id);for(let c of m)delete r[c.id]}}let i=j9({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&&K9(this.app.scene.getNonDeletedElement(a[0]))?new V9(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});C(this,"addPointToPath",(o,n,r=!1)=>{super.addPointToPath(o,n),this.keepPreviousSelection=r,this.updateSelection()});C(this,"updateSelection",()=>{let o=super.getCurrentTrail()?.originalPoints?.map(r=>Y9(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!Q9(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=J9(this.app.visibleElements);for(let i of this.app.visibleElements){let a=W9(i,r);this.elementsSegments.set(i.id,a)}}if(o){let{selectedElementIds:r}=m3({lassoPath:o,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(o,n,r=!1){this.endPath(),super.startPath(o,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 eN,easeOut as u3,THEME as tN}from"@excalidraw/common";import{computeBoundTextPosition as oN,doBoundsIntersect as nN,getBoundTextElement as rN,getElementBounds as iN,getElementLineSegments as aN,getFreedrawOutlineAsSegments as lN,getFreedrawOutlinePoints as sN,intersectElementWithLineSegment as h3,isArrowElement as cN,isFreeDrawElement as g3,isLineElement as dN,isPointInElement as mN}from"@excalidraw/element";import{lineSegment as pN,lineSegmentsDistance as f3,pointFrom as v3,polygon as uN,polygonIncludesPointNonZero as hN}from"@excalidraw/math";import{getElementsInGroup as b3}from"@excalidraw/element";import{shouldTestInside as gN}from"@excalidraw/element";import{hasBoundTextElement as x3,isBoundToContainer as E3}from"@excalidraw/element";import{getBoundTextElementId as y3}from"@excalidraw/element";var zd=class extends en{constructor(o,n){super(o,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(u3(s),u3(l))},fill:()=>n.state.theme===tN.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});C(this,"elementsToErase",new Set);C(this,"groupsToErase",new Set)}startPath(o,n){this.endPath(),super.startPath(o,n),this.elementsToErase.clear()}addPointToPath(o,n,r=!1){return super.addPointToPath(o,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(o){let n=super.getCurrentTrail()?.originalPoints?.map(l=>v3(l[0],l[1]))||[];if(n.length<2)return[];let r=pN(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=eN(i);for(let l of i)if(o&&this.elementsToErase.has(l.id)){if(w3(r,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(this.groupsToErase.has(d)){let m=b3(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.delete(c.id);this.groupsToErase.delete(d)}if(E3(l)&&this.elementsToErase.delete(l.containerId),x3(l)){let m=y3(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!o&&!this.elementsToErase.has(l.id)&&w3(r,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(!this.groupsToErase.has(d)){let m=b3(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.add(c.id);this.groupsToErase.add(d)}if(x3(l)){let m=y3(l);m&&this.elementsToErase.add(m)}E3(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()}},w3=(e,t,o,n)=>{let r=e[1],i=g3(t)?15:t.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],l=iN(t,o),s=[l[0]-i,l[1]-i,l[2]+i,l[3]+i];if(!nN(a,s))return!1;if(gN(t)&&mN(r,t,o))return!0;if(g3(t)){let m=sN(t),c=lN(t,m,o),p=Math.max(2.25,5/n);for(let f of c)if(f3(f,e)<=p)return!0;let u=uN(...m.map(([f,b])=>v3(t.x+f,t.y+b)));return!!hN(e[0],u)}let d=rN(t,o);if(cN(t)||dN(t)&&!t.polygon){let m=Math.max(t.strokeWidth,t.strokeWidth*2/n),c=aN(t,o);for(let p of c)if(f3(p,e)<=m)return!0;return!1}return h3(t,o,e,0,!0).length>0||!!d&&h3({...d,...oN(t,d,o)},o,e,0,!0).length>0};import{jsx as qt,jsxs as T3}from"react/jsx-runtime";var fN=()=>T3("div",{"data-testid":"brave-measure-text-error",children:[qt("p",{children:qt(bt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>qt("span",{style:{fontWeight:600},children:e})})}),qt("p",{children:qt(bt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>qt("span",{style:{fontWeight:600},children:e})})}),qt("p",{children:qt(bt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>qt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),qt("p",{children:qt(bt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>qt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>T3("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),I3=fN;import vN from"clsx";import TN from"react";import{useLayoutEffect as bN,useRef as C3,useEffect as S3}from"react";import{unstable_batchedUpdates as xN}from"react-dom";import{KEYS as EN,queryFocusableElements as yN}from"@excalidraw/common";import{jsx as wN}from"react/jsx-runtime";var k3=({children:e,left:t,top:o,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let d=C3(null);S3(()=>{let c=d.current;if(!c)return;c.contains(document.activeElement)||c.focus();let p=u=>{if(u.key===EN.TAB){let f=yN(c),{activeElement:b}=document,x=f.findIndex(w=>w===b);b===c?(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 c.addEventListener("keydown",p),()=>c.removeEventListener("keydown",p)},[]);let m=C3(null);return bN(()=>{if(r&&d.current&&o!=null&&t!=null){let c=d.current,{width:p,height:u}=c.getBoundingClientRect();if(m.current?.top===o&&m.current?.left===t)return;m.current={top:o,left:t},p>=l?(c.style.width=`${l}px`,c.style.left="0px",c.style.overflowX="scroll"):t+p-i>l?c.style.left=`${l-p-10}px`:c.style.left=`${t}px`,u>=s?(c.style.height=`${s-20}px`,c.style.top="10px",c.style.overflowY="scroll"):o+u-a>s?c.style.top=`${s-u}px`:c.style.top=`${o}px`}},[o,t,r,l,s,i,a]),S3(()=>{if(n){let c=p=>{d.current?.contains(p.target)||xN(()=>n(p))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[n]),wN("div",{className:"popover",ref:d,tabIndex:-1,children:e})};import{jsx as ea,jsxs as IN}from"react/jsx-runtime";var Xe="separator",M3=TN.memo(({actionManager:e,items:t,top:o,left:n,onClose:r})=>{let i=vo(),a=xn(),l=t.reduce((s,d)=>(d&&(d===Xe||!d.predicate||d.predicate(a,i,e.app.props,e.app))&&s.push(d),s),[]);return ea(k3,{onCloseRequest:()=>{r()},top:o,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:ea("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,d)=>{if(s===Xe)return!l[d-1]||l[d-1]===Xe?null:ea("hr",{className:"context-menu-item-separator"},d);let m=s.name,c="";return s.label&&(typeof s.label=="function"?c=g(s.label(a,i,e.app)):c=g(s.label)),ea("li",{"data-testid":m,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:IN("button",{type:"button",className:vN("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[ea("div",{className:"context-menu-item__label",children:c}),ea("kbd",{className:"context-menu-item__shortcut",children:m?ze(m):""})]})},d)})})})});import{jsx as Sg,jsxs as P3}from"react/jsx-runtime";var CN=({height:e,width:t,userToFollow:o,onDisconnect:n})=>Sg("div",{className:"follow-mode",style:{width:t,height:e},children:P3("div",{className:"follow-mode__badge",children:[P3("div",{className:"follow-mode__badge__label",children:["Following"," ",Sg("span",{className:"follow-mode__badge__username",title:o.username,children:o.username})]}),Sg("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:Ht})]})}),L3=CN;import Tr from"clsx";import Xz from"react";import{CLASSES as Kz,DEFAULT_SIDEBAR as Lf,MQ_MIN_WIDTH_DESKTOP as Zz,TOOL_TYPE as u5,arrayToMap as $z,capitalizeString as jz,isShallowEqual as Tm}from"@excalidraw/common";import{mutateElement as qz}from"@excalidraw/element";import{showSelectedShapeActions as Jz}from"@excalidraw/element";import{ShapeCache as Qz}from"@excalidraw/element";import SN from"clsx";import{useState as kN,useEffect as MN}from"react";import{THEME as PN}from"@excalidraw/common";import{jsx as kg,jsxs as LN}from"react/jsx-runtime";var Hd=({delay:e,theme:t})=>{let[o,n]=kN(!!e);return MN(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),o?null:LN("div",{className:SN("LoadingMessage",{"LoadingMessage--dark":t===PN.DARK}),children:[kg("div",{children:kg(it,{})}),kg("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import AN from"clsx";import{jsx as D3,jsxs as _N}from"react/jsx-runtime";var DN="medium",A3={CHECKED:zr,UNCHECKED:er},_3=e=>_N("label",{className:AN("ToolIcon ToolIcon__lock",`ToolIcon_size_${DN}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[D3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),D3("div",{className:"ToolIcon__icon",children:e.checked?A3.CHECKED:A3.UNCHECKED})]});import{useState as Mg,useEffect as N3,useRef as BN}from"react";import ta from"clsx";import{KEYS as Pg,capitalizeString as Ze}from"@excalidraw/common";import RN from"clsx";import{KEYS as R3}from"@excalidraw/common";import{jsx as NN}from"react/jsx-runtime";var Gd=e=>NN(V,{className:RN("Shape",{fillable:!1,active:e.checked}),type:"radio",icon:_s,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:R3.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":R3.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{Fragment as ON,jsx as Ke,jsxs as Ud}from"react/jsx-runtime";var Lg=[{type:"rectangle",icon:Hr,title:Ze(g("toolBar.rectangle"))},{type:"diamond",icon:Gr,title:Ze(g("toolBar.diamond"))},{type:"ellipse",icon:Ur,title:Ze(g("toolBar.ellipse"))}],Ag=[{type:"selection",icon:tr,title:Ze(g("toolBar.selection"))},{type:"lasso",icon:un,title:Ze(g("toolBar.lasso"))}],Dg=[{type:"arrow",icon:Is,title:Ze(g("toolBar.arrow"))},{type:"line",icon:Yr,title:Ze(g("toolBar.line"))}],B3=({app:e,onHandToolToggle:t,setAppState:o})=>{let n=e.state.activeTool,[r,i]=Mg(!1),[a,l]=Mg("rectangle"),[s,d]=Mg("arrow"),m=BN(null);N3(()=>{(n.type==="rectangle"||n.type==="diamond"||n.type==="ellipse")&&l(n.type)},[n.type]),N3(()=>{(n.type==="arrow"||n.type==="line")&&d(n.type)},[n.type]);let c=n.type==="frame",p=n.type==="laser",u=n.type==="embeddable",{TTDDialogTriggerTunnel:f}=Ce(),b=(N,K)=>{e.state.activeTool.type!==N&&ie("toolbar",N,"ui"),N==="selection"?e.state.activeTool.type==="selection"||e.setActiveTool({type:"selection"}):e.setActiveTool({type:N})},x=m.current?.getBoundingClientRect()?.width??-8,w=36,E=4,y=7,v=y*w+(y-1)*E,I=w+E,S=x>=v+1*I,L=x>=v+2*I,k=x>=v+3*I,M=["text","frame","embeddable","laser","magicframe"].filter(N=>!(L&&N==="image"||k&&N==="frame")).includes(n.type),_=M?n.type==="frame"?io:n.type==="embeddable"?Wr:n.type==="laser"?hn:n.type==="text"?wo:n.type==="magicframe"?rr:_a:_a;return Ud("div",{className:"mobile-toolbar",ref:m,children:[Ke(Gd,{checked:no(e.state),onChange:t,title:g("toolBar.hand"),isMobile:!0}),Ke(Gi,{app:e,options:Ag,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,namePrefix:"selectionType",title:Ze(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:N=>{(N==="selection"||N==="lasso")&&(e.setActiveTool({type:N}),o({preferredSelectionTool:{type:N,initialized:!0}}))},displayedOption:Ag.find(N=>N.type===e.state.preferredSelectionTool.type)||Ag[0]}),Ke(V,{className:ta({active:n.type==="freedraw"}),type:"radio",icon:yo,checked:n.type==="freedraw",name:"editor-current-shape",title:`${Ze(g("toolBar.freedraw"))}`,"aria-label":Ze(g("toolBar.freedraw")),"data-testid":"toolbar-freedraw",onChange:()=>b("freedraw")}),Ke(V,{className:ta({active:n.type==="eraser"}),type:"radio",icon:Cs,checked:n.type==="eraser",name:"editor-current-shape",title:`${Ze(g("toolBar.eraser"))}`,"aria-label":Ze(g("toolBar.eraser")),"data-testid":"toolbar-eraser",onChange:()=>b("eraser")}),Ke(Gi,{app:e,options:Lg,activeTool:n,defaultOption:a,namePrefix:"shapeType",title:Ze(g(a==="rectangle"?"toolBar.rectangle":a==="diamond"?"toolBar.diamond":a==="ellipse"?"toolBar.ellipse":"toolBar.rectangle")),"data-testid":"toolbar-rectangle",onToolChange:N=>{(N==="rectangle"||N==="diamond"||N==="ellipse")&&(l(N),e.setActiveTool({type:N}))},displayedOption:Lg.find(N=>N.type===a)||Lg[0]}),Ke(Gi,{app:e,options:Dg,activeTool:n,defaultOption:s,namePrefix:"linearElementType",title:Ze(g(s==="arrow"?"toolBar.arrow":"toolBar.line")),"data-testid":"toolbar-arrow",fillable:!0,onToolChange:N=>{(N==="arrow"||N==="line")&&(d(N),e.setActiveTool({type:N}))},displayedOption:Dg.find(N=>N.type===s)||Dg[0]}),S&&Ke(V,{className:ta({active:n.type==="text"}),type:"radio",icon:wo,checked:n.type==="text",name:"editor-current-shape",title:`${Ze(g("toolBar.text"))}`,"aria-label":Ze(g("toolBar.text")),"data-testid":"toolbar-text",onChange:()=>b("text")}),L&&Ke(V,{className:ta({active:n.type==="image"}),type:"radio",icon:ka,checked:n.type==="image",name:"editor-current-shape",title:`${Ze(g("toolBar.image"))}`,"aria-label":Ze(g("toolBar.image")),"data-testid":"toolbar-image",onChange:()=>b("image")}),k&&Ke(V,{className:ta({active:c}),type:"radio",icon:io,checked:c,name:"editor-current-shape",title:`${Ze(g("toolBar.frame"))}`,"aria-label":Ze(g("toolBar.frame")),"data-testid":"toolbar-frame",onChange:()=>b("frame")}),Ud(le,{open:r,placement:"top",children:[Ke(le.Trigger,{className:ta("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":M||r}),onToggle:()=>i(!r),title:g("toolBar.extraTools"),style:{width:w,height:w,display:"flex",alignItems:"center",justifyContent:"center"},children:_}),Ud(le.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[!S&&Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:wo,shortcut:Pg.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:n.type==="text",children:g("toolBar.text")}),!L&&Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:ka,"data-testid":"toolbar-image",selected:n.type==="image",children:g("toolBar.image")}),!k&&Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:io,shortcut:Pg.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,children:g("toolBar.frame")}),Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Wr,"data-testid":"toolbar-embeddable",selected:u,children:g("toolBar.embeddable")}),Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:hn,"data-testid":"toolbar-laser",selected:p,shortcut:Pg.K.toLocaleUpperCase(),children:g("toolBar.laser")}),Ke("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),e.props.aiEnabled!==!1&&Ke(f.Out,{}),Ke(le.Item,{onSelect:()=>e.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Zr,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&Ke(ON,{children:Ud(le.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:rr,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),Ke(le.Item.Badge,{children:"AI"})]})})]})]})]})};import FN from"clsx";import{jsx as zN}from"react/jsx-runtime";var Yd=({children:e,side:t,className:o})=>zN("div",{className:FN("FixedSideContainer",`FixedSideContainer_side_${t}`,o),children:e});import{Fragment as HN,jsx as tn,jsxs as Ol}from"react/jsx-runtime";var O3=({appState:e,elements:t,actionManager:o,setAppState:n,onHandToolToggle:r,renderTopLeftUI:i,renderTopRightUI:a,renderSidebars:l,renderWelcomeScreen:s,UIOptions:d,app:m})=>{let{WelcomeScreenCenterTunnel:c,MainMenuTunnel:p,DefaultSidebarTriggerTunnel:u}=Ce(),f=()=>{let x=a?.(!0,e)??tn(u.Out,{}),w=Ol("div",{className:"excalidraw-ui-top-left",children:[i?.(!0,e),tn(p.Out,{})]});return e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?tn("div",{className:"App-toolbar-content",children:w}):Ol("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[w,x]})},b=()=>tn(B3,{app:m,onHandToolToggle:r,setAppState:n});return Ol(HN,{children:[l(),tn("div",{className:"App-welcome-screen",children:s&&tn(c.Out,{})}),Ol("div",{className:"App-bottom-bar",style:{marginBottom:jt+Qo},children:[tn(m2,{appState:e,elementsMap:m.scene.getNonDeletedElementsMap(),renderAction:o.renderAction,app:m,setAppState:n}),Ol(Ye,{className:"App-toolbar",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&b(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&tn("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(x=>({...Qn(t,x)}))},children:g("buttons.scrollBackToContent")})]})]}),tn(Yd,{side:"top",className:"App-top-bar",children:f()})]})};import GN from"open-color";import UN,{useLayoutEffect as YN,useRef as WN,useState as VN}from"react";import{jsx as Fl,jsxs as XN}from"react/jsx-runtime";var F3=e=>{let t=WN(null),[o,n]=VN(null);return YN(()=>{if(!e.spreadsheet)return;let r=IE(e.chartType,e.spreadsheet,0,0);n(r);let i,a=t.current;return(async()=>(i=await Rr(r,{exportBackground:!1,viewBackgroundColor:GN.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]),Fl("button",{type:"button",className:"ChartPreview",onClick:()=>{o&&e.onClick(e.chartType,o)},children:Fl("div",{ref:t})})},z3=({setAppState:e,appState:t,onClose:o})=>{let{onInsertElements:n}=Fe(),r=UN.useCallback(()=>{o&&o()},[o]),i=(a,l)=>{n(l),ie("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Fl(He,{size:"small",onCloseRequest:r,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:XN("div",{className:"container",children:[Fl(F3,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:i}),Fl(F3,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:i})]})})};import{Fragment as KN,jsx as H3,jsxs as ZN}from"react/jsx-runtime";var zl=({heading:e,children:t,...o})=>{let{id:n}=Be(),r=H3("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:g(`headings.${e}`)});return H3("section",{...o,"aria-labelledby":`${n}-${e}-title`,children:typeof t=="function"?t(r):ZN(KN,{children:[r,t]})})};import*as Bn from"@radix-ui/react-popover";import G3 from"clsx";import Wd,{useLayoutEffect as $N}from"react";import{supportsResizeObserver as jN,isShallowEqual as qN}from"@excalidraw/common";import{Fragment as oB,jsx as Do,jsxs as Vd}from"react/jsx-runtime";var JN=4,QN=8,eB=({shouldWrap:e,children:t,username:o})=>e?Do(_t,{label:o||"Unknown user",children:t}):Do(oB,{children:t}),_g=({actionManager:e,collaborator:t,socketId:o,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:o,collaborator:t,withName:n,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Do(eB,{username:t.username,shouldWrap:r,children:l},o)},tB=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Xd=Wd.memo(({className:e,mobile:t,collaborators:o,userToFollow:n})=>{let r=Ve(),i=new Map;o.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]=Wd.useState(""),d=a.filter(b=>b.username?.toLowerCase().includes(l)),m=Wd.useRef(null);$N(()=>{if(m.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(m.current.clientWidth),!jN)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[c,p]=Wd.useState(JN),f=a.slice(0,c-1).map(b=>_g({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}));return t?Do("div",{className:G3("UserList UserList_mobile",e),children:a.map(b=>_g({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}))}):Do("div",{className:"UserList__wrapper",ref:m,children:Vd("div",{className:G3("UserList",e),style:{"--max-avatars":c},children:[f,a.length>c-1&&Vd(Bn.Root,{children:[Vd(Bn.Trigger,{className:"UserList__more",children:["+",a.length-c+1]}),Do(Bn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Vd(Ye,{padding:2,children:[a.length>=QN&&Do(Qs,{placeholder:g("quickSearch.placeholder"),onChange:s}),Do(ec,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:d.length>0?[Do("div",{className:"hint",children:g("userList.hint.text")}),d.map(b=>_g({actionManager:r,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===n}))]:[]}),Do(Bn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let o=t.collaborators.keys();for(let[n,r]of e.collaborators){let i=t.collaborators.get(n);if(!i||n!==o.next().value||!qN(r,i,tB))return!1}return!0});import nB from"clsx";import{jsx as U3,jsxs as iB}from"react/jsx-runtime";var rB="medium",Y3=e=>e.penDetected?iB("label",{className:nB("ToolIcon ToolIcon__penMode",`ToolIcon_size_${rB}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[U3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),U3("div",{className:"ToolIcon__icon",children:ub})]}):null;import Rg from"clsx";import{jsx as aB}from"react/jsx-runtime";var W3=e=>aB("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Vr});import{jsx as on,jsxs as Ng}from"react/jsx-runtime";var V3=({appState:e,actionManager:t,showExitZenModeBtn:o,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=Ce();return Ng("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[on("div",{className:Rg("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:on(It.Col,{gap:2,children:Ng(zl,{heading:"canvasActions",children:[on(u2,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&on(h2,{renderAction:t.renderAction,className:Rg("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),on(r.Out,{}),on("div",{className:Rg("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Ng("div",{style:{position:"relative"},children:[n&&on(i.Out,{}),on(W3,{onClick:()=>t.executeAction(ur)})]})}),on(g2,{actionManager:t,showExitZenModeBtn:o})]})},X3=V3;V3.displayName="Footer";import hB from"clsx";import{useEffect as nT,useLayoutEffect as rT,useRef as Wg,useState as gB,forwardRef as iT,useImperativeHandle as fB,useCallback as eT}from"react";import{CLASSES as bB,EVENT as tT,isDevEnv as xB,KEYS as EB,updateObject as yB}from"@excalidraw/common";import sB from"clsx";import{useContext as cB}from"react";import lB from"react";var Kd=lB.createContext({});import{jsx as Bg,jsxs as K3}from"react/jsx-runtime";var Og=({children:e,className:t})=>{let o=he(),n=cB(Kd),r=!!(o.editor.canFitSidebar&&n.shouldRenderDockButton);return K3("div",{className:sB("sidebar__header",t),"data-testid":"sidebar-header",children:[e,K3("div",{className:"sidebar__header__buttons",children:[r&&Bg(_t,{label:g("labels.sidebarLock"),children:Bg(xt,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:sb})}),Bg(xt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":g("buttons.close"),children:Ht})]})]})};Og.displayName="SidebarHeader";import*as $3 from"@radix-ui/react-tabs";import{jsx as Z3}from"react/jsx-runtime";var Fg=({children:e,tab:t,onSelect:o,...n})=>Z3($3.Trigger,{value:t,asChild:!0,onSelect:o,children:Z3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});Fg.displayName="SidebarTabTrigger";import*as j3 from"@radix-ui/react-tabs";import{jsx as dB}from"react/jsx-runtime";var zg=({children:e,...t})=>dB(j3.List,{className:"sidebar-triggers",...t,children:e});zg.displayName="SidebarTabTriggers";import mB from"clsx";import{jsx as Hg,jsxs as q3}from"react/jsx-runtime";var Gg=({name:e,tab:t,icon:o,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=me(),d=xe();return q3("label",{title:n,className:"sidebar-trigger__label-element",children:[Hg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let c=m.target.checked;s({openSidebar:c?{name:e,tab:t}:null}),i?.(c)},checked:d.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),q3("div",{className:mB("sidebar-trigger",a),style:l,children:[o&&Hg("div",{children:o}),r&&Hg("div",{className:"sidebar-trigger__label",children:r})]})]})};Gg.displayName="SidebarTrigger";import*as J3 from"@radix-ui/react-tabs";import{jsx as pB}from"react/jsx-runtime";var Ug=({children:e,...t})=>{let o=xe(),n=me();if(!o.openSidebar)return null;let{name:r}=o.openSidebar;return pB(J3.Root,{className:"sidebar-tabs-root",value:o.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...t,children:e})};Ug.displayName="SidebarTabs";import*as Q3 from"@radix-ui/react-tabs";import{jsx as uB}from"react/jsx-runtime";var Yg=({tab:e,children:t,...o})=>uB(Q3.Content,{...o,value:e,"data-testid":e,children:t});Yg.displayName="SidebarTab";import{jsx as oT}from"react/jsx-runtime";import{createElement as wB}from"react";var Hl=ge(!1),aT=iT(({name:e,children:t,onDock:o,docked:n,className:r,...i},a)=>{xB()&&o&&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=me(),s=pn(Hl);rT(()=>(s(!!n),()=>{s(!1)}),[s,n]);let d=Wg({});d.current.onCloseRequest=()=>{l({openSidebar:null})},d.current.onDock=u=>o?.(u),d.current=yB(d.current,{docked:n,shouldRenderDockButton:!!o&&n!=null});let m=Wg(null);fB(a,()=>m.current);let c=he(),p=eT(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return ri(m,eT(u=>{u.target.closest(".sidebar-trigger")||(!n||!c.editor.canFitSidebar)&&p()},[p,n,c.editor.canFitSidebar])),nT(()=>{let u=f=>{f.key===EB.ESCAPE&&(!n||!c.editor.canFitSidebar)&&p()};return document.addEventListener(tT.KEYDOWN,u),()=>{document.removeEventListener(tT.KEYDOWN,u)}},[p,n,c.editor.canFitSidebar]),oT(Ye,{...i,className:hB(bB.SIDEBAR,{"sidebar--docked":n},r),ref:m,children:oT(Kd.Provider,{value:d.current,children:t})})});aT.displayName="SidebarInner";var Jt=Object.assign(iT((e,t)=>{let o=xe(),{onStateChange:n}=e,r=Wg(o.openSidebar);nT(()=>{(!o.openSidebar&&r?.current?.name===e.name||o.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&o.openSidebar!==r.current&&n?.(o.openSidebar?.name!==e.name?null:o.openSidebar),r.current=o.openSidebar},[o.openSidebar,n,e.name]);let[i,a]=gB(!1);return rT(()=>(a(!0),()=>a(!1)),[]),i&&o.openSidebar?.name===e.name?wB(aT,{...e,ref:t,key:e.name}):null}),{Header:Og,TabTriggers:zg,TabTrigger:Fg,Tabs:Ug,Tab:Yg,Trigger:Gg});Jt.displayName="Sidebar";import{composeEventHandlers as LB}from"@excalidraw/common";import{useLayoutEffect as vB,useRef as TB}from"react";import{jsx as IB}from"react/jsx-runtime";var nn=(e,t)=>{let o=ge(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Ce(),[,a]=i(o),l=TB({preferHost:!1,counter:0});return vB(()=>{let s=l.current;return a(d=>{let m=d+1;return s.counter=m,m}),()=>{a(d=>{let m=d-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:IB(t,{...r})};return n.displayName=e,n};var Kg={};k1(Kg,{ChangeCanvasBackground:()=>yT,ClearCanvas:()=>xT,CommandPalette:()=>gT,Export:()=>wT,Help:()=>bT,LiveCollaborationTrigger:()=>TT,LoadScene:()=>pT,SaveAsImage:()=>hT,SaveToActiveFile:()=>uT,SearchMenu:()=>fT,Socials:()=>vT,ToggleTheme:()=>ET});import MB from"clsx";import{THEME as On}from"@excalidraw/common";var Vg=ge({active:!1});async function lT({title:e,description:t,actionLabel:o,color:n}){return new Promise(r=>{We.set(Vg,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:t,actionLabel:o,color:n})})}import CB from"clsx";import{jsx as sT,jsxs as SB}from"react/jsx-runtime";var Zd=function({onChange:e,value:t,choices:o,name:n}){return sT("div",{className:"RadioGroup",children:o.map(r=>SB("div",{className:CB("RadioGroup__choice",{active:r.value===t}),title:r.ariaLabel,children:[sT("input",{name:n,type:"radio",checked:r.value===t,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as kB,jsx as Xg,jsxs as cT}from"react/jsx-runtime";var dT=({value:e,shortcut:t,onChange:o,choices:n,children:r,name:i})=>{let a=he();return cT(kB,{children:[cT("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Xg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:r}),Xg(Zd,{name:i,value:e,onChange:o,choices:n})]}),t&&!a.editor.isMobile&&Xg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};dT.displayName="DropdownMenuItemContentRadio";var mT=dT;import{Fragment as PB,jsx as Qe,jsxs as IT}from"react/jsx-runtime";var pT=()=>{let{t:e}=Ne(),t=Ve(),o=xn();return t.isActionEnabled(xi)?Qe(ut,{icon:Xr,onSelect:async()=>{(!o.length||await lT({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:Qe(bt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>Qe("strong",{children:r}),br:()=>Qe("br",{})})}))&&t.executeAction(xi)},"data-testid":"load-button",shortcut:ze("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};pT.displayName="LoadScene";var uT=()=>{let{t:e}=Ne(),t=Ve();return t.isActionEnabled(pr)?Qe(ut,{shortcut:ze("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(pr),icon:yb,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};uT.displayName="SaveToActiveFile";var hT=()=>{let e=me(),{t}=Ne();return Qe(ut,{icon:Ps,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:ze("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};hT.displayName="SaveAsImage";var gT=e=>{let t=me(),{t:o}=Ne();return Qe(ut,{icon:Ra,"data-testid":"command-palette-button",onSelect:()=>{ie("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:ze("commandPalette"),"aria-label":o("commandPalette.title"),className:e?.className,children:o("commandPalette.title")})};gT.displayName="CommandPalette";var fT=e=>{let{t}=Ne(),o=Ve();return Qe(ut,{icon:Dt,"data-testid":"search-menu-button",onSelect:()=>{o.executeAction(Il)},shortcut:ze("searchMenu"),"aria-label":t("search.title"),className:e?.className,children:t("search.title")})};fT.displayName="SearchMenu";var bT=()=>{let{t:e}=Ne(),t=Ve();return Qe(ut,{"data-testid":"help-menu-item",icon:Vr,onSelect:()=>t.executeAction(ur),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};bT.displayName="Help";var xT=()=>{let{t:e}=Ne(),t=pn(br);return Ve().isActionEnabled(Vo)?Qe(ut,{icon:At,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};xT.displayName="ClearCanvas";var ET=e=>{let{t}=Ne(),o=xe(),n=Ve(),r=ze("toggleTheme");return n.isActionEnabled(sr)?e?.allowSystemTheme?Qe(mT,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:On.LIGHT,label:La,ariaLabel:`${t("buttons.lightMode")} - ${r}`},{value:On.DARK,label:Pa,ariaLabel:`${t("buttons.darkMode")} - ${r}`},{value:"system",label:N0,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):Qe(ut,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(o.theme===On.DARK?On.LIGHT:On.DARK);else return n.executeAction(sr)},icon:o.theme===On.DARK?La:Pa,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":o.theme===On.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:o.theme===On.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};ET.displayName="ToggleTheme";var yT=()=>{let{t:e}=Ne(),t=xe(),o=Ve(),n=To();return t.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:IT("div",{style:{marginTop:"0.5rem"},children:[Qe("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),Qe("div",{style:{padding:"0 0.625rem"},children:o.renderAction("changeViewBackgroundColor")})]})};yT.displayName="ChangeCanvasBackground";var wT=()=>{let{t:e}=Ne(),t=me();return Qe(ut,{icon:or,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};wT.displayName="Export";var vT=()=>{let{t:e}=Ne();return IT(PB,{children:[Qe(Fi,{icon:ks,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),Qe(Fi,{icon:xb,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),Qe(Fi,{icon:bb,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};vT.displayName="Socials";var TT=({onSelect:e,isCollaborating:t})=>{let{t:o}=Ne();return Qe(ut,{"data-testid":"collab-button",icon:Ls,className:MB({"active-collab":t}),onSelect:e,children:o("labels.liveCollaboration")})};TT.displayName="LiveCollaborationTrigger";import{jsx as $d,jsxs as Zg}from"react/jsx-runtime";var AB=Object.assign(nn("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:o}=Ce(),n=he(),r=xe(),i=me(),a=n.editor.isMobile?void 0:()=>i({openMenu:null});return $d(o.In,{children:Zg(le,{open:r.openMenu==="canvas",children:[$d(le.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Ss}),Zg(le.Content,{onClickOutside:a,onSelect:LB(t,()=>{i({openMenu:null})}),placement:"bottom",className:n.editor.isMobile?"main-menu-dropdown":"",children:[e,n.editor.isMobile&&r.collaborators.size>0&&Zg("fieldset",{className:"UserList-Wrapper",children:[$d("legend",{children:g("labels.collaborators")}),$d(Xd,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:le.Trigger,Item:le.Item,ItemLink:le.ItemLink,ItemCustom:le.ItemCustom,Group:le.Group,Separator:le.Separator,DefaultItems:Kg}),pt=AB;import DB from"clsx";import{forwardRef as _B,useState as RB}from"react";import{isPromiseLike as NB}from"@excalidraw/common";import{jsx as jd,jsxs as BB}from"react/jsx-runtime";var Fn=_B(({children:e,icon:t,onClick:o,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:d},m)=>{let[c,p]=RB(!1),u=async b=>{let x=o?.(b);if(NB(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof Dr)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=c?"loading":d;return i=f==="success"?"success":i,jd("button",{className:DB("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:m,disabled:f==="loading"||f==="success",children:BB("div",{className:"ExcButton__contents",children:[f==="loading"?jd(it,{className:"ExcButton__statusIcon"}):f==="success"&&jd("div",{className:"ExcButton__statusIcon",children:b0}),t&&jd("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),r!=="icon"&&(e??n)]})})});import{jsx as oa,jsxs as zB}from"react/jsx-runtime";var qd=({title:e,children:t,actionLabel:o,onClick:n})=>zB("div",{className:"OverwriteConfirm__Actions__Action",children:[oa("h4",{children:e}),oa("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),oa(Fn,{variant:"outlined",color:"muted",label:o,size:"large",fullWidth:!0,onClick:n})]}),OB=()=>{let{t:e}=Ne(),t=Ve(),o=me();return oa(qd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(Tc,"ui",!0),o({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},FB=()=>{let{t:e}=Ne(),t=Ve();return oa(qd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(al,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},$g=Object.assign(({children:e})=>oa("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:OB,SaveToDisk:FB});import{jsx as zn,jsxs as CT}from"react/jsx-runtime";var Jd=Object.assign(nn("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=Ce(),[o,n]=de(Vg);if(!o.active)return null;let r=()=>{o.onClose(),n(a=>({...a,active:!1}))},i=()=>{o.onConfirm(),n(a=>({...a,active:!1}))};return zn(t.In,{children:zn(He,{onCloseRequest:r,title:!1,size:916,children:CT("div",{className:"OverwriteConfirm",children:[zn("h3",{children:o.title}),CT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${o.color}`,children:[zn("div",{className:"OverwriteConfirm__Description__icon",children:x0}),zn("div",{children:o.description}),zn("div",{className:"OverwriteConfirm__Description__spacer"}),zn(Fn,{color:o.color,size:"large",label:o.actionLabel,onClick:i})]}),zn($g,{children:e})]})})})}),{Actions:$g,Action:qd});import lO from"clsx";import{CANVAS_SEARCH_TAB as ef,DEFAULT_SIDEBAR as sO,LIBRARY_SIDEBAR_TAB as NT,composeEventHandlers as cO}from"@excalidraw/common";import{round as HB}from"@excalidraw/math";import GB from"clsx";import UB from"lodash.debounce";import{Fragment as YB,memo as WB,useEffect as Gl,useMemo as ST,useRef as jg,useState as kT}from"react";import{CLASSES as VB,EVENT as XB,FONT_FAMILY as qg,FRAME_STYLE as Jg,getLineHeight as KB}from"@excalidraw/common";import{isElementCompletelyInViewport as ZB}from"@excalidraw/element";import{measureText as Ul}from"@excalidraw/element";import{KEYS as na,randomInteger as MT,addEventListener as $B,getFontString as Qd}from"@excalidraw/common";import{newTextElement as jB}from"@excalidraw/element";import{isTextElement as DT,isFrameLikeElement as em}from"@excalidraw/element";import{getDefaultFrameName as _T}from"@excalidraw/element/frame";import{Fragment as aO,jsx as ot,jsxs as _o}from"react/jsx-runtime";var qB=ge(""),Qg=ge(null),JB=350,RT=()=>{let e=Fe(),t=me(),o=jg(null),[n,r]=de(qB),i=n.trim(),[a,l]=kT(!1),[s,d]=kT({nonce:null,items:[]}),m=jg(null),c=jg(void 0),[p,u]=de(Qg),f=e.scene.getNonDeletedElementsMap();Gl(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==c.current)&&(m.current=null,AT(i,e,(y,v)=>{d({nonce:MT(),items:y}),m.current=i,c.current=e.scene.getSceneNonce(),t({searchMatches:y.length?{focusedId:null,matches:y.map(I=>({id:I.element.id,focus:!1,matchedLines:I.matchedLines}))}:null})}))},[a,i,f,e,t,u,c]);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)};Gl(()=>{t(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((I,S)=>S===p?{...I,focus:!0}:{...I,focus:!1})}}:null)},[p,t]),Gl(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,I=jB({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:em(y.element)?Jg.nameFontSize:y.element.fontSize,fontFamily:em(y.element)?qg.Assistant:y.element.fontFamily}),S=14,L=I.fontSize,k=L*v<S;if(!ZB([I],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 R;k?L>=S?R={fitToContent:!0}:R={fitToViewport:!0,maxZoom:HB(S/L,1)}:R={fitToContent:!0},e.scrollToContent(I,{animate:!0,duration:300,...R,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Gl(()=>()=>{u(null),m.current=null,c.current=void 0,t({searchMatches:null}),l(!1)},[t,u]);let w=gn({goToNextItem:b,goToPreviousItem:x,searchMatches:s});Gl(()=>{let y=v=>{if(v.key===na.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),t({openSidebar:null});return}if(v[na.CTRL_OR_CMD]&&v.key===na.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;o.current?.matches(":focus")||(e.state.openDialog&&t({openDialog:null}),o.current?.focus(),o.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===na.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===na.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===na.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return $B(window,XB.KEYDOWN,y,{capture:!0,passive:!1})},[t,w,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return _o("div",{className:"layer-ui__search",children:[ot("div",{className:"layer-ui__search-header",children:ot(Pn,{className:VB.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:o,placeholder:g("search.placeholder"),icon:Dt,onChange:y=>{r(y),l(!0);let v=y.trim();AT(v,e,(I,S)=>{d({nonce:MT(),items:I}),u(S),m.current=v,c.current=e.scene.getSceneNonce(),t({searchMatches:I.length?{focusedId:null,matches:I.map(L=>({id:L.element.id,focus:!1,matchedLines:L.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),_o("div",{className:"layer-ui__search-count",children:[s.items.length>0&&_o(aO,{children:[p!==null&&p>-1?_o("div",{children:[p+1," / ",E]}):ot("div",{children:E}),_o("div",{className:"result-nav",children:[ot(xt,{onSelect:()=>{b()},className:"result-nav-btn",children:Ns}),ot(xt,{onSelect:()=>{x()},className:"result-nav-btn",children:H0})]})]}),s.items.length===0&&i&&m.current&&ot("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),ot(tO,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},PT=e=>{let t=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return ot("div",{tabIndex:-1,className:GB("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:o=>{e.highlighted&&o?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ot("div",{className:"preview-text",children:t.flatMap((o,n)=>ot(YB,{children:n===2?ot("b",{children:o}):o},n))})})},QB=e=>{let t=ST(()=>e.matches.items.filter(n=>em(n.element)),[e.matches]),o=ST(()=>e.matches.items.filter(n=>DT(n.element)),[e.matches]);return _o("div",{children:[t.length>0&&_o("div",{className:"layer-ui__search-result-container",children:[_o("div",{className:"layer-ui__search-result-title",children:[ot("div",{className:"title-icon",children:io}),ot("div",{children:g("search.frames")})]}),t.map((n,r)=>ot(PT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),o.length>0&&ot("div",{className:"layer-ui__divider"})]}),o.length>0&&_o("div",{className:"layer-ui__search-result-container",children:[_o("div",{className:"layer-ui__search-result-title",children:[ot("div",{className:"title-icon",children:wo}),ot("div",{children:g("search.texts")})]}),o.map((n,r)=>ot(PT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+t.length===e.focusIndex,onClick:()=>e.onItemClick(r+t.length)},n.element.id+n.index))]})]})},eO=(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex,tO=WB(QB,eO),LT=(e,t,o)=>{let i=e.slice(0,t),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),d=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;d=d.length>m?d.slice(-m):d;let c=e.slice(t+o.length),p=c.split(/\s+/),u=!c.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:d.length,previewText:d+o+b,moreBefore:s>0,moreAfter:p.length>f}},oO=(e,t)=>{let o=e.split(`
|
|
17
|
+
`),n=[],r=0;for(let i=0;i<o.length;i++){let a=o[i],l=o[i+1];if(l){let s=t.indexOf(l,r);if(s>a.length+r){let d=s-(a.length+r);for(;d>0;)a+=" ",d--}}n.push(a),r=r+a.length}return n.join(`
|
|
18
|
+
`)},nO=(e,t,o)=>{let r=oO(e.text,e.originalText).split(`
|
|
19
|
+
`),i=[],a=0,l=0;for(let c of r){let p=a,u=p+c.length-1;i.push({line:c,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=o,d=e.originalText.slice(o,o+t.length),m=[];for(let c of i){if(d==="")break;if(s>=c.startIndex&&s<=c.endIndex){let p=c.endIndex+1-s,u=c.line.slice(0,s-c.startIndex),f=d.slice(0,p);d=d.slice(p);let b=Ul(u,Qd(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&c.line.length>0){let v=Ul(c.line,Qd(e),e.lineHeight),I=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=I}let{width:x,height:w}=Ul(f,Qd(e),e.lineHeight),E=b.width,y=c.lineNumber*b.height;m.push({offsetX:E,offsetY:y,width:x,height:w,showOnCanvas:!0}),s+=p}}return m},rO=(e,t,o,n)=>{let r=e.name??_T(e),i=r.slice(o,o+t.length),a=r.slice(0,o),l=Qd({fontSize:Jg.nameFontSize,fontFamily:qg.Assistant}),s=KB(qg.Assistant),d=Ul(a,l,s);a===""&&(d.width=0);let m=Ul(i,l,s),c=d.width,p=-d.height-Jg.strokeWidth,u=m.width;return[{offsetX:c,offsetY:p,width:u,height:m.height,showOnCanvas:c+u<=e.width*n}]},iO=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),AT=UB((e,t,o)=>{if(!e||e===""){o([],null);return}let n=t.scene.getNonDeletedElements(),r=n.filter(p=>DT(p)),i=n.filter(p=>em(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(iO(e),"gi");for(let p of r){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=LT(f,u.index,e),x=nO(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??_T(p);for(;(u=l.exec(f))!==null;){let b=LT(f,u.index,e),x=rO(p,e,u.index,t.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let d=new Set(t.visibleElements.map(p=>p.id)),m=[...s,...a],c=m.findIndex(p=>d.has(p.element.id))??null;o(m,c)},JB);import{jsx as ho,jsxs as BT}from"react/jsx-runtime";import{createElement as dO}from"react";var OT=nn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=Ce();return ho(t.In,{children:ho(Jt.Trigger,{...e,className:"default-sidebar-trigger",name:sO.name})})});OT.displayName="DefaultSidebarTrigger";var FT=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=Ce();return ho(t.In,{children:e})};FT.displayName="DefaultTabTriggers";var tm=Object.assign(nn("DefaultSidebar",({children:e,className:t,onDock:o,docked:n,...r})=>{let i=xe(),a=me(),{DefaultSidebarTabTriggersTunnel:l}=Ce(),s=i.openSidebar?.tab===ef;return dO(Jt,{...r,name:"default",key:"default",className:lO("default-sidebar",t),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||o===!1||!o&&n!=null?void 0:cO(o,d=>{a({defaultSidebarDockedPreference:d})})},BT(Jt.Tabs,{children:[ho(Jt.Header,{children:BT(Jt.TabTriggers,{children:[ho(Jt.TabTrigger,{tab:ef,children:Dt}),ho(Jt.TabTrigger,{tab:NT,children:Fr}),ho(l.Out,{})]})}),ho(Jt.Tab,{tab:NT,children:ho(Ww,{})}),ho(Jt.Tab,{tab:ef,children:ho(RT,{})}),e]}))}),{Trigger:OT,TabTriggers:FT});import{useEffect as LO,useRef as nf,useState as mm}from"react";import{isFiniteNumber as aI}from"@excalidraw/math";import{useState as XT,useRef as KT,useEffect as ZT,useDeferredValue as EO}from"react";import{EDITOR_LS_KEYS as yO,debounce as wO,isDevEnv as vO}from"@excalidraw/common";import{useEffect as mO,useRef as zT}from"react";import{EVENT as HT,KEYS as GT}from"@excalidraw/common";import{jsx as pO}from"react/jsx-runtime";var om=({input:e,placeholder:t,onChange:o,onKeyboardSubmit:n})=>{let r=zT(null),i=zT(n);return i.current=n,mO(()=>{if(!i.current)return;let a=r.current;if(a){let l=s=>{s[GT.CTRL_OR_CMD]&&s.key===GT.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(HT.KEYDOWN,l),()=>{a.removeEventListener(HT.KEYDOWN,l)}}},[]),pO("textarea",{className:"ttd-dialog-input",onChange:o,value:e,placeholder:t,ref:r})};import{jsx as nm,jsxs as UT}from"react/jsx-runtime";var uO=({error:e})=>UT("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",nm("p",{children:e})]}),rm=({error:e,canvasRef:t,loaded:o})=>UT("div",{className:"ttd-dialog-output-wrapper",children:[e&&nm(uO,{error:e.message}),o?nm("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):nm(it,{size:"2rem"})]});import YT from"clsx";import{jsx as tf,jsxs as Yl}from"react/jsx-runtime";var ra=({label:e,children:t,panelAction:o,panelActionDisabled:n=!1,onTextSubmitInProgess:r,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>Yl("div",{className:"ttd-dialog-panel",children:[Yl("div",{className:"ttd-dialog-panel__header",children:[tf("label",{children:e}),i?.()]}),t,Yl("div",{className:YT("ttd-dialog-panel-button-container",{invisible:!o}),style:{display:"flex",alignItems:"center"},children:[Yl(xt,{className:"ttd-dialog-panel-button",onSelect:o?o.action:()=>{},disabled:n||r,children:[Yl("div",{className:YT({invisible:r}),children:[o?.label,o?.icon&&tf("span",{children:o.icon})]}),r&&tf(it,{})]}),!n&&!r&&a?.(),l?.()]})]});import{jsx as hO}from"react/jsx-runtime";var im=({children:e})=>hO("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as WT}from"@excalidraw/common";import{jsx as VT,jsxs as gO}from"react/jsx-runtime";var am=()=>gO("div",{className:"ttd-dialog-submit-shortcut",children:[VT("div",{className:"ttd-dialog-submit-shortcut__key",children:WT("CtrlOrCmd")}),VT("div",{className:"ttd-dialog-submit-shortcut__key",children:WT("Enter")})]});import{DEFAULT_EXPORT_PADDING as fO,EDITOR_LS_KEYS as bO}from"@excalidraw/common";var xO=({canvasRef:e,setError:t})=>{let o=e.current;if(!o)return;let n=o.parentElement;n&&(n.style.background="",t(null),o.replaceChildren())},lm=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:o,setError:n,data:r})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!o){xO({canvasRef:e,setError:n});return}try{let l=await t.api,s;try{s=await l.parseMermaidToExcalidraw(o)}catch{s=await l.parseMermaidToExcalidraw(o.replace(/"/g,"'"))}let{elements:d,files:m}=s;n(null),r.current={elements:Ji(d,{regenerateIds:!0}),files:m};let c=await kn({elements:r.current.elements,files:r.current.files,exportPadding:fO,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Fo(c)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(c)}catch(l){throw a.style.background="var(--default-bg-color)",o&&n(l),l}}},Wl=e=>{Xt.set(bO.MERMAID_TO_EXCALIDRAW,e)},sm=({app:e,data:t,text:o,shouldSaveMermaidDataToStorage:n})=>{let{elements:r,files:i}=t.current;r.length&&(e.addElementsFromPasteOrLibrary({elements:r,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),n&&o&&Wl(o))};import{Fragment as CO,jsx as Ro,jsxs as jT}from"react/jsx-runtime";var TO=`flowchart TD
|
|
20
20
|
A[Christmas] -->|Get money| B(Go shopping)
|
|
21
21
|
B --> C{Let me think}
|
|
22
22
|
C -->|One| D[Laptop]
|
|
23
23
|
C -->|Two| E[iPhone]
|
|
24
|
-
C -->|Three| F[Car]
|
|
25
|
-
TTD mermaid definition render errror: ${M.message}`,"color: yellow"),ae("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(k){let P=k.message;(!P||P==="Failed to fetch")&&(P="Request failed"),C(new Error(P))}finally{p(!1)}},x=Xg(b);x.current=b;let[y,E]=nm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});dF(()=>{(async()=>{await y.api,E(P=>({...P,loaded:!0}))})()},[y.api]);let w=Xg({elements:[],files:null}),[v,C]=nm(null);return yt(ze,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Nn(HT,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?yt("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):Nn(Vg,{children:[yt(tm,{tab:"text-to-diagram",children:Nn("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),yt("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"})]})}),yt(tm,{tab:"mermaid",children:"Mermaid"})]}),yt(om,{className:"ttd-dialog-content",tab:"mermaid",children:yt(BT,{mermaidToExcalidrawLib:y})}),!("__fallback"in o)&&Nn(om,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[yt("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."}),Nn(qd,{children:[yt(Xi,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Gr},onTextSubmitInProgess:c,panelActionDisabled:d.length>Ki||u?.rateLimitRemaining===0,renderTopRight:()=>u?Nn("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:()=>yt(Jd,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Nn("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Sl(i.generatedResponse),n({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",yt(fn,{icon:Gr})]});let k=d.length/Ki;return k>.8?Nn("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:k>1?"var(--color-danger)":void 0},children:["Length: ",d.length,"/",Ki]}):null},children:yt(Zd,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),yt(Xi,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),em({app:t,data:w})},label:"Insert",icon:Gr},children:yt(jd,{canvasRef:r,error:v,loaded:y.loaded})})]})]})]})})});import{round as P5}from"@excalidraw/math";import SO from"clsx";import kO from"lodash.throttle";import{useEffect as A5,useMemo as cf,useState as MO,memo as LO}from"react";import{STATS_PANELS as mm}from"@excalidraw/common";import{getCommonBounds as PO}from"@excalidraw/element";import{getUncroppedWidthAndHeight as AO}from"@excalidraw/element";import{isElbowArrow as DO,isImageElement as df}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as _O}from"@excalidraw/element";import{elementsAreInSameGroup as RO}from"@excalidraw/element";import{degreesToRadians as qT,radiansToDegrees as t5}from"@excalidraw/math";import{getBoundTextElement as JT}from"@excalidraw/element";import{isArrowElement as QT,isElbowArrow as CF}from"@excalidraw/element";import{updateBindings as e5}from"@excalidraw/element";import EF from"clsx";import{useEffect as $T,useRef as im,useState as yF}from"react";import{EVENT as ji,KEYS as wF,cloneJSON as $g}from"@excalidraw/common";import{deepCopyElement as vF}from"@excalidraw/element";import{CaptureUpdateAction as jT}from"@excalidraw/element";import{pointFrom as Bn,pointRotateRads as rm}from"@excalidraw/math";import{getBoundTextElement as hF}from"@excalidraw/element";import{isFrameLikeElement as KT}from"@excalidraw/element";import{getSelectedGroupIds as gF,getElementsInGroup as fF,isInGroup as bF}from"@excalidraw/element";import{getFrameChildren as xF}from"@excalidraw/element";import{updateBindings as XT}from"@excalidraw/element";var ZT=.01,kl=10,St=(e,o)=>!(o==="angle"&&KT(e)),Pe=(e,o)=>{let t=e+o/2;return t-t%o},Zi=(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 Er=(e,o,t,n,r,i=!0)=>{let a=n.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,d]=[t.x+t.width/2,t.y+t.height/2],[m,c]=rm(Bn(t.x,t.y),Bn(s,d),t.angle),p=e-m,u=o-c,[f,b]=rm(Bn(e,o),Bn(s+p,d+u),-t.angle);n.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),XT(l,n);let x=hF(t,r);if(x){let y=a.get(x.id);y&&n.mutateElement(y,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(KT(t)){let y=xF(r,t.id);y.forEach(E=>{let w=a.get(E.id);if(!w)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[k,P]=rm(Bn(E.x,E.y),Bn(v,C),E.angle),S=Math.round(k+p),_=Math.round(P+u),[M,R]=rm(Bn(S,_),Bn(v+p,C+u),-E.angle);n.mutateElement(w,{x:M,y:R},{informMutation:i,isDragging:!1}),XT(w,n,{simultaneouslyUpdated:y})})}},$i=(e,o)=>{let n=gF(o).map(r=>fF(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!bF(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as jg,jsxs as IF}from"react/jsx-runtime";var TF=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:d,sensitivity:m=1,dragFinishedCallback:c})=>{let p=Fe(),u=ce(),f=im(null),b=im(null),[x,y]=yF(n.toString()),E=im(null);E.current||(E.current={originalAppState:$g(d),originalElements:r,lastUpdatedValue:x,updatePending:!1}),$T(()=>{let C=n.toString();y(C),E.current.lastUpdatedValue=C},[n]);let w=(C,k,P)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let S=Number(C);if(isNaN(S)){y(n.toString());return}let _=Number(S.toFixed(2)),M=Number(n);(isNaN(M)||Math.abs(_-M)>=ZT)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:k,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:_,property:l,originalAppState:P,setInputValue:R=>y(String(R)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:jT.IMMEDIATELY}))},v=im({});return v.current.handleInputValue=w,$T(()=>{let C=f.current,k=v.current;return()=>{let P=C?.value;P&&k.handleInputValue?.(P,E.current.originalElements,E.current.originalAppState),window.removeEventListener(ji.POINTER_MOVE,k.onPointerMove,!1),window.removeEventListener(ji.POINTER_UP,k.onPointerUp,!1)}},[i]),i?IF("div",{className:EF("drag-input-container",!i&&"disabled"),"data-testid":e,children:[jg("div",{className:"drag-input-label",ref:b,onPointerDown:C=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let k=Number(f.current.value);isNaN(k)&&(k=0);let P=null,S=p.scene.getNonDeletedElements().reduce((A,N)=>(A.set(N.id,vF(N)),A),new Map),_=r.map(A=>S.get(A.id)),M=$g(d),R=0,O=0,V=A=>{if(P&&S!==null&&_!==null){let N=A.clientX-P.x;N!==0&&(O+=N,Math.abs(O)>=m&&(O=Math.sign(O)*Math.floor(Math.abs(O)/m),R+=O,t({accumulatedChange:R,instantChange:O,originalElements:_,originalElementsMap:S,shouldKeepAspectRatio:a,shouldChangeByStepSize:A.shiftKey,property:l,scene:s,originalAppState:M,setInputValue:F=>y(String(F)),app:p,setAppState:u}),O=0))}P={x:A.clientX,y:A.clientY}},j=()=>{window.removeEventListener(ji.POINTER_MOVE,V,!1),p.syncActionResult({captureUpdate:jT.IMMEDIATELY}),c?.({app:p,setAppState:u,originalElements:_,originalAppState:M}),P=null,R=0,O=0,_=null,S=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(ji.POINTER_UP,j,!1)};v.current.onPointerMove=V,v.current.onPointerUp=j,window.addEventListener(ji.POINTER_MOVE,V,!1),window.addEventListener(ji.POINTER_UP,j,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?jg(fn,{icon:o}):e}),jg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let k=C.target;k instanceof HTMLInputElement&&C.key===wF.ENTER&&(w(k.value,r,d),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,y(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=r,E.current.originalAppState=$g(d)},onBlur:C=>{x?i&&w(C.target.value,E.current.originalElements,E.current.originalAppState):y(n.toString())},disabled:!i})]}):null},ot=TF;import{jsx as LF}from"react/jsx-runtime";var SF=15,kF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a&&!CF(a)){let l=i.get(a.id);if(!l)return;if(n!==void 0){let u=qT(n);r.mutateElement(l,{angle:u}),e5(l,r);let f=JT(l,i);f&&!QT(l)&&r.mutateElement(f,{angle:u});return}let s=Math.round(t5(a.angle)*100)/100,d=Math.round(e),m=(s+d)%360;t&&(m=Pe(m,SF)),m=m<0?m+360:m;let c=qT(m);r.mutateElement(l,{angle:c}),e5(l,r);let p=JT(l,i);p&&!QT(l)&&r.mutateElement(p,{angle:c})}},MF=({element:e,scene:o,appState:t,property:n})=>LF(ot,{label:"A",icon:xs,value:Math.round(t5(e.angle)%360*100)/100,elements:[e],dragInputCallback:kF,editable:St(e,"angle"),scene:o,appState:t,property:n}),o5=MF;import{jsx as AF}from"react/jsx-runtime";var n5=5,PF=({property:e,scene:o,appState:t,setAppState:n})=>AF(ot,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let d;return r?d=r:i&&(d=a?Pe(s.gridStep+n5*Math.sign(i),n5):s.gridStep+i),d?(d=y1(d),l(d),{gridStep:d}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),r5=PF;import{clamp as am,round as qg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as lm}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as i5,getUncroppedWidthAndHeight as s5}from"@excalidraw/element";import{resizeSingleElement as a5}from"@excalidraw/element";import{isImageElement as c5}from"@excalidraw/element";import{isFrameLikeElement as Jg}from"@excalidraw/element";import{getElementsInResizingFrame as Qg}from"@excalidraw/element";import{replaceAllElementsInFrame as d5}from"@excalidraw/element";import{jsx as BF}from"react/jsx-runtime";var l5=10,DF=e=>e.type==="image",_F=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:d,app:m,setAppState:c})=>{let p=d.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=n||DF(u),x=u.width/u.height;if(l.croppingElementId===u.id){let y=p.get(u.id);if(!y||!c5(y)||!y.crop)return;let E=y.crop,w={...E},v=y.scale[0]===-1,C=y.scale[1]===-1,{width:k,height:P}=s5(y),S=E.naturalWidth/k,_=E.naturalHeight/P,M=v?E.width+E.x:E.naturalWidth-E.x,R=C?E.height+E.y:E.naturalHeight-E.y,O=i5*S,V=i5*_;if(i!==void 0){if(a==="width"){let W=i*S,q=am(W,O,M);w={...w,width:q,x:v?E.x+E.width-q:E.x}}else if(a==="height"){let W=i*_,q=am(W,V,R);w={...w,height:q,y:C?E.y+E.height-q:E.y}}d.mutateElement(y,{crop:w,width:w.width/(E.naturalWidth/k),height:w.height/(E.naturalHeight/P)});return}let j=a==="width"?s:0,A=a==="height"?s:0,N=am(E.width+j,O,M),F=am(E.height+A,O,R);w={...E,x:v?E.x+E.width-N:E.x,y:C?E.y+E.height-F:E.y,width:N,height:F},d.mutateElement(y,{crop:w,width:w.width/(E.naturalWidth/k),height:w.height/(E.naturalHeight/P)});return}if(i!==void 0){let y=Math.max(a==="width"?i:b?i*x:u.width,lm),E=Math.max(a==="height"?i:b?i/x:u.height,lm);if(a5(y,E,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Jg(f)){let w=Qg(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap()),v=d5(d.getElementsIncludingDeleted(),w,f,m);d.replaceAllElements(v)}return}{let y=a==="width"?e:0,E=a==="height"?e:0,w=Math.max(0,u.width+y);a==="width"&&(r?w=Pe(w,l5):w=Math.round(w));let v=Math.max(0,u.height+E);if(a==="height"&&(r?v=Pe(v,l5):v=Math.round(v)),b&&(a==="width"?v=Math.round(w/x*100)/100:w=Math.round(v*x*100)/100),v=Math.max(lm,v),w=Math.max(lm,w),a5(w,v,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Jg(f)){let C=Qg(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap());c({elementsToHighlight:C})}}}},RF=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Jg(a)){let l=Qg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=d5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},NF=({property:e,element:o,scene:t,appState:n})=>{let r=qg(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&c5(o)&&o.crop){let{width:i,height:a}=s5(o);if(e==="width"){let l=i/o.crop.naturalWidth;r=qg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;r=qg(o.crop.height*l,2)}}return BF(ot,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:_F,value:r,editable:St(o,e),scene:t,appState:n,property:e,dragFinishedCallback:RF})},ef=NF;import{getBoundTextElement as FF,redrawTextBoundingBox as OF}from"@excalidraw/element";import{hasBoundTextElement as zF,isTextElement as p5}from"@excalidraw/element";import{jsx as YF}from"react/jsx-runtime";var m5=4,HF=4,GF=({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||!p5(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),m5);else if(a.type==="text"){let d=Math.round(a.fontSize),m=Math.round(e);s=Math.max(d+m,m5),t&&(s=Pe(s,HF))}s&&(r.mutateElement(l,{fontSize:s}),OF(l,r.getContainerElement(l),r))}},UF=({element:e,scene:o,appState:t,property:n})=>{let r=p5(e)?e:zF(e)?FF(e,o.getNonDeletedElementsMap()):null;return r?YF(ot,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:GF,icon:er,appState:t,scene:o,property:n}):null},u5=UF;import{degreesToRadians as h5,radiansToDegrees as b5}from"@excalidraw/math";import{getBoundTextElement as g5}from"@excalidraw/element";import{isArrowElement as f5}from"@excalidraw/element";import{isInGroup as tf}from"@excalidraw/element";import{jsx as KF}from"react/jsx-runtime";var WF=15,VF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(d=>a.get(d.id)).filter(d=>d&&!tf(d)&&St(d,r)),s=o.filter(d=>!tf(d)&&St(d,r));if(n!==void 0){let d=h5(n);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:d});let c=g5(m,a);c&&!f5(m)&&i.mutateElement(c,{angle:d})}i.triggerUpdate();return}for(let d=0;d<l.length;d++){let m=l[d];if(!m)continue;let c=s[d],p=Math.round(b5(c.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Pe(f,WF)),f=f<0?f+360:f;let b=h5(f);i.mutateElement(m,{angle:b});let x=g5(m,a);x&&!f5(m)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},XF=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!tf(s)&&St(s,"angle")),i=r.map(s=>Math.round(b5(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>St(s,"angle"));return KF(ot,{label:"A",icon:xs,value:a,elements:e,dragInputCallback:VF,editable:l,appState:t,scene:o,property:n})},x5=XF;import{pointFrom as E5}from"@excalidraw/math";import{useMemo as ZF}from"react";import{MIN_WIDTH_OR_HEIGHT as Fn}from"@excalidraw/common";import{getElementsInResizingFrame as of,isFrameLikeElement as nf,replaceAllElementsInFrame as v5,updateBoundElements as $F}from"@excalidraw/element";import{rescalePointsInElement as jF,resizeSingleElement as y5}from"@excalidraw/element";import{getBoundTextElement as qF,handleBindTextResize as JF}from"@excalidraw/element";import{isTextElement as T5}from"@excalidraw/element";import{getCommonBounds as sm}from"@excalidraw/element";import{jsx as rO}from"react/jsx-runtime";var qi=10,QF=(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,d=o+i*t;return{width:a,height:l,x:s,y:d,...jF(n,a,l,!1),...T5(n)?{fontSize:n.fontSize*t}:{}}},eO=(e,o,t,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),d=QF(e,o,n,i);l.mutateElement(r,d);let m=qF(i,a);if(m){let c=m.fontSize*n;$F(r,l,{newSize:{width:d.width,height:d.height}});let p=s.get(m.id);p&&T5(p)&&(l.mutateElement(p,{fontSize:c}),JF(r,l,t==="width"?"e":"s",!0))}},w5=(e,o,t,n,r,i,a,l,s,d)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let m=o/t;for(let c=0;c<l.length;c++){let p=l[c],u=a[c];eO(r[0],r[1],i,m,u,p,s,d)}},tO=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:d})=>{let m=a.getNonDeletedElementsMap(),c=$i(o,n);if(i!==void 0){for(let b of c){let x=Zi(b,m,t);if(x.length>1){let y=x.map(O=>O.latest),E=x.map(O=>O.original),[w,v,C,k]=sm(E),P=C-w,S=k-v,_=P/S,M=Math.max(Fn,l==="width"?Math.max(0,i):P),R=Math.max(Fn,l==="height"?Math.max(0,i):S);w5(M,R,S,_,E5(w,v),l,y,E,t,a)}else{let[y]=x,E=y?.latest,w=y?.original;if(E&&w&&St(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(r?v=Pe(v,qi):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(r?C=Pe(C,qi):C=Math.round(C)),v=Math.max(Fn,v),C=Math.max(Fn,C),y5(v,C,E,w,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),nf(E)){let k=of(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap()),P=v5(a.getElementsIncludingDeleted(),k,E,d);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of c){let x=Zi(b,m,t);if(x.length>1){let y=x.map(O=>O.latest),E=x.map(O=>O.original),[w,v,C,k]=sm(E),P=C-w,S=k-v,_=P/S,M=Math.max(0,P+p);l==="width"&&(r?M=Pe(M,qi):M=Math.round(M));let R=Math.max(0,S+u);l==="height"&&(r?R=Pe(R,qi):R=Math.round(R)),M=Math.max(Fn,M),R=Math.max(Fn,R),w5(M,R,S,_,E5(w,v),l,y,E,t,a)}else{let[y]=x,E=y?.latest,w=y?.original;if(E&&w&&St(E,l)){let v=Math.max(0,w.width+p);l==="width"&&(r?v=Pe(v,qi):v=Math.round(v));let C=Math.max(0,w.height+u);if(l==="height"&&(r?C=Pe(C,qi):C=Math.round(C)),v=Math.max(Fn,v),C=Math.max(Fn,C),y5(v,C,E,w,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),nf(E)){let k=of(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap());f.push(...k)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},oO=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&nf(a)){let l=of(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=v5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},nO=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=ZF(()=>n.map(d=>{let m=Zi(d,t);if(m.length>1){let[p,u,f,b]=sm(m.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[c]=m;return Math.round((e==="width"?c.latest.width:c.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 rO(ot,{label:e==="width"?"W":"H",elements:o,dragInputCallback:tO,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:oO})},rf=nO;import{getBoundTextElement as iO,redrawTextBoundingBox as I5}from"@excalidraw/element";import{hasBoundTextElement as aO,isTextElement as lO}from"@excalidraw/element";import{isInGroup as sO}from"@excalidraw/element";import{jsx as uO}from"react/jsx-runtime";var C5=4,cO=4,dO=(e,o)=>e.reduce((t,n)=>{if(!n||sO(n))return t;if(lO(n))return t.push(n),t;if(aO(n)){let r=iO(n,o);if(r)return t.push(r),t}return t},[]),mO=({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}),I5(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let d=0;d<a.length;d++){let m=a[d],c=s[d],p=Math.round(c.fontSize),u=Math.round(e),f=Math.max(p+u,C5);t&&(f=Pe(f,cO)),r.mutateElement(m,{fontSize:f}),I5(m,r.getContainerElement(m),r)}r.triggerUpdate()}},pO=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=dO(e,r);if(!i.length)return null;let a=i.map(d=>Math.round(d.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return uO(ot,{label:"F",icon:er,elements:i,dragInputCallback:mO,value:l,editable:s,scene:o,property:n,appState:t})},S5=pO;import{pointFrom as On,pointRotateRads as cm}from"@excalidraw/math";import{useMemo as hO}from"react";import{isTextElement as gO}from"@excalidraw/element";import{getCommonBounds as af}from"@excalidraw/element";import{jsx as yO}from"react/jsx-runtime";var fO=(e,o,t,n,r,i)=>{for(let a=0;a<n.length;a++){let l=n[a],[s,d]=[l.x+l.width/2,l.y+l.height/2],[m,c]=cm(On(l.x,l.y),On(s,d),l.angle),p=e==="x"?Math.round(m+o):m,u=e==="y"?Math.round(c+t):c;Er(p,u,l,i,r,!1)}},bO=(e,o,t,n,r)=>{let i=r.getNonDeletedElementsMap(),[a,l,,]=af(t),s=e-a,d=o-l;for(let m=0;m<t.length;m++){let c=t[m],p=i.get(c.id);if(p&&(!gO(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=cm(On(p.x,p.y),On(u,f),p.angle);Er(b+s,x+d,c,r,n,!1)}}},xO=({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 $i(o,l)){let u=Zi(p,s,t);if(u.length>1){let[f,b,,]=af(u.map(E=>E.latest));bO(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&&St(b,i)){let[x,y]=[f.x+f.width/2,f.y+f.height/2],[E,w]=cm(On(f.x,f.y),On(x,y),f.angle);Er(i==="x"?r:E,i==="y"?r:w,f,a,t,!1)}}}a.triggerUpdate();return}let d=n?Pe(e,kl):e;fO(i,i==="x"?d:0,i==="y"?d:0,o,t,a),a.triggerUpdate()},EO=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=hO(()=>n.map(s=>{let d=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(d.length>1){let[b,x]=af(d);return Math.round((e==="x"?b:x)*100)/100}let[m]=d,[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=cm(On(m.x,m.y),On(c,p),m.angle);return Math.round((e==="x"?u:f)*100)/100}),[n,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return yO(ot,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:xO,value:l,property:e,scene:r,appState:i})},lf=EO;import{clamp as Ml,pointFrom as dm,pointRotateRads as M5,round as k5}from"@excalidraw/math";import{getFlipAdjustedCropPosition as wO,getUncroppedWidthAndHeight as vO}from"@excalidraw/element";import{isImageElement as L5}from"@excalidraw/element";import{jsx as CO}from"react/jsx-runtime";var TO=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s})=>{let d=l.getNonDeletedElementsMap(),m=t[0],[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=M5(dm(m.x,m.y),dm(c,p),m.angle);if(s.croppingElementId===m.id){let w=d.get(m.id);if(!w||!L5(w)||!w.crop)return;let v=w.crop,C=v,k=w.scale[0]===-1,P=w.scale[1]===-1,{width:S,height:_}=vO(w);if(i!==void 0){if(a==="x"){let O=i*(v.naturalWidth/S);k?C={...v,x:Ml(v.naturalWidth-O-v.width,0,v.naturalWidth-v.width)}:C={...v,x:Ml(i*(v.naturalWidth/S),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:Ml(i*(v.naturalHeight/_),0,v.naturalHeight-v.height)}),l.mutateElement(w,{crop:C});return}let M=(a==="x"?o:0)*(k?-1:1),R=(a==="y"?o:0)*(P?-1:1);C={...v,x:Ml(v.x+M,0,v.naturalWidth-v.width),y:Ml(v.y+R,0,v.naturalHeight-v.height)},l.mutateElement(w,{crop:C});return}if(i!==void 0){Er(a==="x"?i:u,a==="y"?i:f,m,l,n);return}let b=a==="x"?e:0,x=a==="y"?e:0,y=a==="x"?Math.round(r?Pe(m.x+b,kl):u+b):u,E=a==="y"?Math.round(r?Pe(m.y+x,kl):f+x):f;Er(y,E,m,l,n)},IO=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=M5(dm(o.x,o.y),dm(o.x+o.width/2,o.y+o.height/2),o.angle),l=k5(e==="x"?i:a,2);if(r.croppingElementId===o.id&&L5(o)&&o.crop){let s=wO(o);s&&(l=k5(e==="x"?s.x:s.y,2))}return CO(ot,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:TO,scene:n,value:l,property:e,appState:r})},sf=IO;import{Fragment as mf,jsx as Q,jsxs as kt}from"react/jsx-runtime";var NO=50,Ll=e=>{let o=Eo(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=kn(e.app);return Q(BO,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},ke=({children:e,columns:o=1,heading:t,style:n,...r})=>Q("div",{className:SO("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});ke.displayName="StatsRow";var pm=({children:e,order:o,style:t,...n})=>Q("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});pm.displayName="StatsRows";Ll.StatsRow=ke;Ll.StatsRows=pm;var BO=LO(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),d=l.getNonDeletedElementsMap(),m=ce(),c=n.length===1?n[0]:null,p=n.length>1?n:null,u=r.croppingElementId&&df(c),f=u?AO(c):null,[b,x]=MO({width:0,height:0}),y=cf(()=>kO(v=>{let C=PO(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},NO),[]);A5(()=>{y(s)},[i,s,y]),A5(()=>()=>y.cancel(),[y]);let E=cf(()=>$i(n,r),[n,r]),w=cf(()=>_O(n),[n]);return Q("div",{className:"exc-stats",children:kt(We,{padding:3,children:[kt("div",{className:"title",children:[Q("h2",{children:g("stats.title")}),Q("div",{className:"close",onClick:o,children:Gt})]}),kt(_a,{label:Q("h3",{children:g("stats.generalStats")}),open:!!(r.stats.panels&mm.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^mm.generalStats}})),children:[kt(pm,{children:[Q(ke,{heading:!0,children:g("stats.scene")}),kt(ke,{columns:2,children:[Q("div",{children:g("stats.shapes")}),Q("div",{children:s.length})]}),kt(ke,{columns:2,children:[Q("div",{children:g("stats.width")}),Q("div",{children:b.width})]}),kt(ke,{columns:2,children:[Q("div",{children:g("stats.height")}),Q("div",{children:b.height})]}),a&&kt(mf,{children:[Q(ke,{heading:!0,children:"Canvas"}),Q(ke,{children:Q(r5,{property:"gridStep",scene:l,appState:r,setAppState:m})})]})]}),t?.(s,r)]}),!w&&n.length>0&&Q("div",{id:"elementStats",style:{marginTop:12},children:Q(_a,{label:Q("h3",{children:g("stats.elementProperties")}),open:!!(r.stats.panels&mm.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^mm.elementProperties}})),children:kt(pm,{children:[c&&kt(mf,{children:[u&&Q(ke,{heading:!0,children:g("labels.unCroppedDimension")}),r.croppingElementId&&df(c)&&f&&kt(ke,{columns:2,children:[Q("div",{children:g("stats.width")}),Q("div",{children:P5(f.width,2)})]}),r.croppingElementId&&df(c)&&f&&kt(ke,{columns:2,children:[Q("div",{children:g("stats.height")}),Q("div",{children:P5(f.height,2)})]}),Q(ke,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?g("labels.imageCropping"):g(`element.${c.type}`)}),Q(ke,{children:Q(sf,{element:c,property:"x",elementsMap:d,scene:l,appState:r})}),Q(ke,{children:Q(sf,{element:c,property:"y",elementsMap:d,scene:l,appState:r})}),Q(ke,{children:Q(ef,{property:"width",element:c,scene:l,appState:r})}),Q(ke,{children:Q(ef,{property:"height",element:c,scene:l,appState:r})}),!DO(c)&&Q(ke,{children:Q(o5,{property:"angle",element:c,scene:l,appState:r})}),Q(ke,{children:Q(u5,{property:"fontSize",element:c,scene:l,appState:r})})]}),p&&kt(mf,{children:[RO(p)&&Q(ke,{heading:!0,children:g("element.group")}),kt(ke,{columns:2,style:{margin:"0.3125rem 0"},children:[Q("div",{children:g("stats.shapes")}),Q("div",{children:n.length})]}),Q(ke,{children:Q(lf,{property:"x",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),Q(ke,{children:Q(lf,{property:"y",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),Q(ke,{children:Q(rf,{property:"width",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),Q(ke,{children:Q(rf,{property:"height",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),Q(ke,{children:Q(x5,{property:"angle",elements:p,scene:l,appState:r})}),Q(ke,{children:Q(S5,{property:"fontSize",elements:p,scene:l,appState:r,elementsMap:d})})]})]})})})]})})},(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 FO,useEffect as D5,useState as _5}from"react";import{normalizeLink as OO,KEYS as pf}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as zO,getLinkIdAndTypeFromSelection as HO}from"@excalidraw/element";import{jsx as Ji,jsxs as um}from"react/jsx-runtime";var GO=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=zO})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=_5(a),[d,m]=_5(!1);D5(()=>{let p=J(i,t),u=a;if(p.length>0&&r){let f=HO(p,t);f&&(u=OO(r(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,r]);let c=FO(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&n.mutateElement(p,{link:l})}if(!l&&d&&e){let p=i.get(e);p&&n.mutateElement(p,{link:null})}o?.()},[e,l,i,d,n,o]);return D5(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===pf.ENTER&&c(),t.openDialog?.name==="elementLinkSelector"&&u.key===pf.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,c]),um("div",{className:"ElementLinkDialog",children:[um("div",{className:"ElementLinkDialog__header",children:[Ji("h2",{children:g("elementLink.title")}),Ji("p",{children:g("elementLink.desc")})]}),um("div",{className:"ElementLinkDialog__input",children:[Ji(Tn,{value:l??"",onChange:p=>{d||m(!0),s(p)},onKeyDown:p=>{p.key===pf.ENTER&&c()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Ji(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:At})]}),um("div",{className:"ElementLinkDialog__actions",children:[Ji(Wo,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Ji(Wo,{label:g("buttons.confirm"),onClick:c,actionType:"primary"})]})]})},R5=GO;import UO,{useState as YO}from"react";import{Fragment as WO,jsx as uf}from"react/jsx-runtime";var N5=({children:e,onClose:o})=>{let[t,n]=YO(!!e),{container:r}=Be(),i=UO.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return uf(WO,{children:t&&uf(ze,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:uf("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import VO from"react";import{isDarwin as B5,isFirefox as F5,isWindows as XO}from"@excalidraw/common";import{KEYS as _e,getShortcutKey as X}from"@excalidraw/common";import{Fragment as z5,jsx as H,jsxs as zt}from"react/jsx-runtime";var KO=()=>zt("div",{className:"HelpDialog__header",children:[zt("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[H("div",{className:"HelpDialog__link-icon",children:Vm}),g("helpDialog.documentation")]}),zt("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[H("div",{className:"HelpDialog__link-icon",children:Vm}),g("helpDialog.blog")]}),zt("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[H("div",{className:"HelpDialog__link-icon",children:us}),g("helpDialog.github")]}),zt("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[H("div",{className:"HelpDialog__link-icon",children:Pb}),"YouTube"]})]}),ZO=e=>zt(z5,{children:[H("h3",{children:e.title}),H("div",{className:"HelpDialog__islands-container",children:e.children})]}),hf=e=>zt("div",{className:`HelpDialog__island ${e.className}`,children:[H("h4",{className:"HelpDialog__island-title",children:e.caption}),H("div",{className:"HelpDialog__island-content",children:e.children})]});function*$O(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var jO=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),U=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>H(qO,{children:jO(a)},a)));return zt("div",{className:"HelpDialog__shortcut",children:[H("div",{children:e}),H("div",{className:"HelpDialog__key-container",children:[...$O(n,t?g("helpDialog.or"):null)]})]})},qO=e=>H("kbd",{className:"HelpDialog__key",...e}),O5=({onClose:e})=>{let o=VO.useCallback(()=>{e&&e()},[e]);return H(z5,{children:zt(ze,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[H(KO,{}),zt(ZO,{title:g("helpDialog.shortcuts"),children:[zt(hf,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[H(U,{label:g("toolBar.hand"),shortcuts:[_e.H]}),H(U,{label:g("toolBar.selection"),shortcuts:[_e.V,_e[1]]}),H(U,{label:g("toolBar.rectangle"),shortcuts:[_e.R,_e[2]]}),H(U,{label:g("toolBar.diamond"),shortcuts:[_e.D,_e[3]]}),H(U,{label:g("toolBar.ellipse"),shortcuts:[_e.O,_e[4]]}),H(U,{label:g("toolBar.arrow"),shortcuts:[_e.A,_e[5]]}),H(U,{label:g("toolBar.line"),shortcuts:[_e.L,_e[6]]}),H(U,{label:g("toolBar.freedraw"),shortcuts:[_e.P,_e[7]]}),H(U,{label:g("toolBar.text"),shortcuts:[_e.T,_e[8]]}),H(U,{label:g("toolBar.image"),shortcuts:[_e[9]]}),H(U,{label:g("toolBar.eraser"),shortcuts:[_e.E,_e[0]]}),H(U,{label:g("toolBar.frame"),shortcuts:[_e.F]}),H(U,{label:g("toolBar.laser"),shortcuts:[_e.K]}),H(U,{label:g("labels.eyeDropper"),shortcuts:[_e.I,"Shift+S","Shift+G"]}),H(U,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[X("CtrlOrCmd+Enter")]}),H(U,{label:g("helpDialog.editText"),shortcuts:[X("Enter")]}),H(U,{label:g("helpDialog.textNewLine"),shortcuts:[X("Enter"),X("Shift+Enter")]}),H(U,{label:g("helpDialog.textFinish"),shortcuts:[X("Esc"),X("CtrlOrCmd+Enter")]}),H(U,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),H(U,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),H(U,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),X("Enter")],isOr:!0}),H(U,{label:g("helpDialog.cropFinish"),shortcuts:[X("Enter"),X("Escape")],isOr:!0}),H(U,{label:g("toolBar.lock"),shortcuts:[_e.Q]}),H(U,{label:g("helpDialog.preventBinding"),shortcuts:[X("CtrlOrCmd")]}),H(U,{label:g("toolBar.link"),shortcuts:[X("CtrlOrCmd+K")]}),H(U,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),zt(hf,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[H(U,{label:g("buttons.zoomIn"),shortcuts:[X("CtrlOrCmd++")]}),H(U,{label:g("buttons.zoomOut"),shortcuts:[X("CtrlOrCmd+-")]}),H(U,{label:g("buttons.resetZoom"),shortcuts:[X("CtrlOrCmd+0")]}),H(U,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),H(U,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),H(U,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),H(U,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),H(U,{label:g("buttons.zenMode"),shortcuts:[X("Alt+Z")]}),H(U,{label:g("buttons.objectsSnapMode"),shortcuts:[X("Alt+S")]}),H(U,{label:g("labels.toggleGrid"),shortcuts:[X("CtrlOrCmd+'")]}),H(U,{label:g("labels.viewMode"),shortcuts:[X("Alt+R")]}),H(U,{label:g("labels.toggleTheme"),shortcuts:[X("Alt+Shift+D")]}),H(U,{label:g("stats.fullTitle"),shortcuts:[X("Alt+/")]}),H(U,{label:g("search.title"),shortcuts:[Oe("searchMenu")]}),H(U,{label:g("commandPalette.title"),shortcuts:F5?[Oe("commandPalette")]:[Oe("commandPalette"),Oe("commandPalette",1)]})]}),zt(hf,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[H(U,{label:g("helpDialog.createFlowchart"),shortcuts:[X("CtrlOrCmd+Arrow Key")],isOr:!0}),H(U,{label:g("helpDialog.navigateFlowchart"),shortcuts:[X("Alt+Arrow Key")],isOr:!0}),H(U,{label:g("labels.moveCanvas"),shortcuts:[X(`Space+${g("helpDialog.drag")}`),X(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),H(U,{label:g("buttons.clearReset"),shortcuts:[X("CtrlOrCmd+Delete")]}),H(U,{label:g("labels.delete"),shortcuts:[X("Delete")]}),H(U,{label:g("labels.cut"),shortcuts:[X("CtrlOrCmd+X")]}),H(U,{label:g("labels.copy"),shortcuts:[X("CtrlOrCmd+C")]}),H(U,{label:g("labels.paste"),shortcuts:[X("CtrlOrCmd+V")]}),H(U,{label:g("labels.pasteAsPlaintext"),shortcuts:[X("CtrlOrCmd+Shift+V")]}),H(U,{label:g("labels.selectAll"),shortcuts:[X("CtrlOrCmd+A")]}),H(U,{label:g("labels.multiSelect"),shortcuts:[X(`Shift+${g("helpDialog.click")}`)]}),H(U,{label:g("helpDialog.deepSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.click")}`)]}),H(U,{label:g("helpDialog.deepBoxSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(si||F5)&&H(U,{label:g("labels.copyAsPng"),shortcuts:[X("Shift+Alt+C")]}),H(U,{label:g("labels.copyStyles"),shortcuts:[X("CtrlOrCmd+Alt+C")]}),H(U,{label:g("labels.pasteStyles"),shortcuts:[X("CtrlOrCmd+Alt+V")]}),H(U,{label:g("labels.sendToBack"),shortcuts:[B5?X("CtrlOrCmd+Alt+["):X("CtrlOrCmd+Shift+[")]}),H(U,{label:g("labels.bringToFront"),shortcuts:[B5?X("CtrlOrCmd+Alt+]"):X("CtrlOrCmd+Shift+]")]}),H(U,{label:g("labels.sendBackward"),shortcuts:[X("CtrlOrCmd+[")]}),H(U,{label:g("labels.bringForward"),shortcuts:[X("CtrlOrCmd+]")]}),H(U,{label:g("labels.alignTop"),shortcuts:[X("CtrlOrCmd+Shift+Up")]}),H(U,{label:g("labels.alignBottom"),shortcuts:[X("CtrlOrCmd+Shift+Down")]}),H(U,{label:g("labels.alignLeft"),shortcuts:[X("CtrlOrCmd+Shift+Left")]}),H(U,{label:g("labels.alignRight"),shortcuts:[X("CtrlOrCmd+Shift+Right")]}),H(U,{label:g("labels.duplicateSelection"),shortcuts:[X("CtrlOrCmd+D"),X(`Alt+${g("helpDialog.drag")}`)]}),H(U,{label:g("helpDialog.toggleElementLock"),shortcuts:[X("CtrlOrCmd+Shift+L")]}),H(U,{label:g("buttons.undo"),shortcuts:[X("CtrlOrCmd+Z")]}),H(U,{label:g("buttons.redo"),shortcuts:XO?[X("CtrlOrCmd+Y"),X("CtrlOrCmd+Shift+Z")]:[X("CtrlOrCmd+Shift+Z")]}),H(U,{label:g("labels.group"),shortcuts:[X("CtrlOrCmd+G")]}),H(U,{label:g("labels.ungroup"),shortcuts:[X("CtrlOrCmd+Shift+G")]}),H(U,{label:g("labels.flipHorizontal"),shortcuts:[X("Shift+H")]}),H(U,{label:g("labels.flipVertical"),shortcuts:[X("Shift+V")]}),H(U,{label:g("labels.showStroke"),shortcuts:[X("S")]}),H(U,{label:g("labels.showBackground"),shortcuts:[X("G")]}),H(U,{label:g("labels.showFonts"),shortcuts:[X("Shift+F")]}),H(U,{label:g("labels.decreaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+<")]}),H(U,{label:g("labels.increaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as U5,useRef as nz,useState as zn}from"react";import{DEFAULT_EXPORT_PADDING as rz,EXPORT_IMAGE_TYPES as gf,isFirefox as iz,EXPORT_SCALES as az,cloneJSON as Y5}from"@excalidraw/common";import{useCallback as JO,useRef as QO,useState as ez}from"react";var tz=2e3,H5=()=>{let[e,o]=ez(null),t=QO(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},tz)},r=JO(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import oz from"clsx";import{jsx as G5}from"react/jsx-runtime";var Pl=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>G5("div",{className:oz("Switch",{toggled:t,disabled:r}),children:G5("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 Me,jsxs as Hn}from"react/jsx-runtime";var lz="filter"in document.createElement("canvas").getContext("2d"),sz=()=>Hn("div",{children:[Me("h3",{children:g("canvasError.cannotShowPreview")}),Me("p",{children:Me("span",{children:g("canvasError.canvasTooBig")})}),Hn("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),cz=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i})=>{let a=we(o,e),[l,s]=zn(i),[d,m]=zn(a),[c,p]=zn(e.exportBackground),[u,f]=zn(e.exportWithDarkMode),[b,x]=zn(e.exportEmbedScene),[y,E]=zn(e.exportScale),w=nz(null),[v,C]=zn(null),{onCopy:k,copyStatus:P,resetCopyStatus:S}=H5();U5(()=>{S()},[l,c,u,y,b,S]);let{exportedElements:_,exportingFrame:M}=lr(o,e,d);return U5(()=>{let R=w.current;if(!R)return;let O=R.offsetWidth,V=R.offsetHeight;O&&wn({elements:_,appState:{...e,name:l,exportBackground:c,exportWithDarkMode:u,exportScale:y,exportEmbedScene:b},files:t,exportPadding:rz,maxWidthOrHeight:Math.max(O,V),exportingFrame:M}).then(j=>(C(null),Ro(j).then(()=>{R.replaceChildren(j)}).catch(A=>{throw A.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):A}))).catch(j=>{console.error(j),C(j)})},[e,t,_,M,l,c,u,y,b]),Hn("div",{className:"ImageExportModal",children:[Me("h3",{children:g("imageExportDialog.header")}),Hn("div",{className:"ImageExportModal__preview",children:[Me("div",{className:"ImageExportModal__preview__canvas",ref:w,children:v&&Me(sz,{})}),Me("div",{className:"ImageExportModal__preview__filename",children:!Pr&&Me("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:R=>{s(R.target.value),n.executeAction(pu,"ui",R.target.value)}})})]}),Hn("div",{className:"ImageExportModal__settings",children:[Me("h3",{children:g("imageExportDialog.header")}),a&&Me(Al,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Me(Pl,{name:"exportOnlySelected",checked:d,onChange:R=>{m(R)}})}),Me(Al,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Me(Pl,{name:"exportBackgroundSwitch",checked:c,onChange:R=>{p(R),n.executeAction(uu,"ui",R)}})}),lz&&Me(Al,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Me(Pl,{name:"exportDarkModeSwitch",checked:u,onChange:R=>{f(R),n.executeAction(ME,"ui",R)}})}),Me(Al,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Me(Pl,{name:"exportEmbedSwitch",checked:b,onChange:R=>{x(R),n.executeAction(mc,"ui",R)}})}),Me(Al,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Me(Hd,{name:"exportScale",value:y,onChange:R=>{E(R),n.executeAction(kE,"ui",R)},choices:az.map(R=>({value:R,label:`${R}\xD7`}))})}),Hn("div",{className:"ImageExportModal__settings__buttons",children:[Me(_n,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>r(gf.png,_,{exportingFrame:M}),icon:lp,children:g("imageExportDialog.button.exportToPng")}),Me(_n,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>r(gf.svg,_,{exportingFrame:M}),icon:lp,children:g("imageExportDialog.button.exportToSvg")}),(si||iz)&&Me(_n,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(gf.clipboard,_,{exportingFrame:M}),k()},icon:Hr,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Al=({label:e,children:o,tooltip:t,name:n})=>Hn("div",{className:"ImageExportModal__settings__setting",title:e,children:[Hn("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&Me(Rt,{label:t,long:!0,children:cb})]}),Me("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),W5=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=zn(()=>({appStateSnapshot:Y5(o),elementsSnapshot:Y5(e)}));return Me(ze,{onCloseRequest:i,size:"wide",title:!1,children:Me(cz,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:n,onExportImage:r,name:a})})};import mz from"react";import{getFrame as pz}from"@excalidraw/common";import ff from"open-color";import{jsx as dz}from"react/jsx-runtime";var bf=({children:e,color:o})=>dz("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":ff[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":ff[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":ff[o][9]},children:e});import{Fragment as hz,jsx as ho,jsxs as hm}from"react/jsx-runtime";var uz=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return ho("div",{className:"ExportDialog ExportDialog--json",children:hm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&hm(bf,{color:"lime",children:[ho("div",{className:"Card-icon",children:b0}),ho("h2",{children:g("exportDialog.disk_title")}),hm("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!Pr&&r.renderAction("changeProjectName")]}),ho(K,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Va,"ui")}})]}),s&&hm(bf,{color:"pink",children:[ho("div",{className:"Card-icon",children:fa}),ho("h2",{children:g("exportDialog.link_title")}),ho("div",{className:"Card-details",children:g("exportDialog.link_details")}),ho(K,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ae("export","link",`ui (${pz()})`),await s(e,o,n),l()}catch(d){t({errorMessage:d.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},V5=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=mz.useCallback(()=>{a({openDialog:null})},[a]);return ho(hz,{children:o.openDialog?.name==="jsonExport"&&ho(ze,{onCloseRequest:l,title:g("buttons.export"),children:ho(uz,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import gz from"clsx";import{jsx as X5,jsxs as bz}from"react/jsx-runtime";var fz="small",K5=e=>bz("label",{className:gz("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${fz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[X5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),X5("div",{className:"ToolIcon__icon",children:xa})]});import{Fragment as j5,jsx as $,jsxs as Ht}from"react/jsx-runtime";var Sz=({UIOptions:e})=>Ht(pt,{__fallback:!0,children:[$(pt.DefaultItems.LoadScene,{}),$(pt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&$(pt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&$(pt.DefaultItems.SaveAsImage,{}),$(pt.DefaultItems.SearchMenu,{}),$(pt.DefaultItems.Help,{}),$(pt.DefaultItems.ClearCanvas,{}),$(pt.Separator,{}),$(pt.Group,{title:"Excalidraw links",children:$(pt.DefaultItems.Socials,{})}),$(pt.Separator,{}),$(pt.DefaultItems.ToggleTheme,{}),$(pt.DefaultItems.ChangeCanvasBackground,{})]}),kz=()=>Ht(Wd,{__fallback:!0,children:[$(Wd.Actions.SaveToDisk,{}),$(Wd.Actions.ExportToImage,{})]}),Mz=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:d,renderTopRightUI:m,renderCustomStats:c,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:y,generateLinkForSelection:E})=>{let w=me(),v=Y2(),C=o.stylesPanelMode==="compact"?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},k=v.tunnelsJotai.Provider,[P,S]=se(mn),_=()=>p.canvasActions.export?$(V5,{elements:r,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:n}):null,M=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:$(W5,{elements:r,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>n({openDialog:null}),name:x.getName()}),R=()=>Ht("div",{style:{position:"relative"},children:[$(v.MainMenuTunnel.Out,{}),f&&$(v.WelcomeScreenMenuHintTunnel.Out,{})]}),O=()=>{let F=o.stylesPanelMode==="compact";return $(Pn,{heading:"selectedShapeActions",className:yr("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:F?$(We,{className:yr("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:$(Q2,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x,setAppState:n})}):$(We,{className:Ez.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:$(ed,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})})},V=()=>{let F=Iz(o,r),W=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return $(Dd,{side:"top",children:Ht("div",{className:"App-menu App-menu_top",children:[Ht(Je.Col,{gap:C.menuTopGap,className:yr("App-menu_top__left"),children:[R(),$("div",{className:yr("selected-shape-actions-container",{"selected-shape-actions-container--compact":o.stylesPanelMode==="compact"}),children:F&&O()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&$(Pn,{heading:"shapes",className:"shapes-section",children:q=>Ht("div",{style:{position:"relative"},children:[f&&$(v.WelcomeScreenToolbarHintTunnel.Out,{}),$(Je.Col,{gap:C.toolbarColGap,align:"start",children:Ht(Je.Row,{gap:C.toolbarRowGap,className:yr("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Ht(We,{padding:C.islandPadding,className:yr("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":o.stylesPanelMode==="compact"}),children:[$(Rd,{appState:o,isMobile:w.editor.isMobile,device:w,app:x}),q,Ht(Je.Row,{gap:C.toolbarInnerRowGap,children:[$(Nd,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),$(Ad,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),$("div",{className:"App-toolbar__divider"}),$(_d,{checked:oo(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),$(td,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),y&&$(We,{style:{marginLeft:C.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:$(K5,{title:g("toolBar.laser"),checked:o.activeTool.type===Z5.laser,onChange:()=>x.setActiveTool({type:Z5.laser}),isMobile:!0})})]})})]})}),Ht("div",{className:yr("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":o.stylesPanelMode==="compact"}),children:[o.collaborators.size>0&&$(Od,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(w.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!A||o.openSidebar?.name!==xf.name)&&$(v.DefaultSidebarTriggerTunnel.Out,{}),W&&$(Ll,{app:x,onClose:()=>{e.executeAction(xi)},renderCustomStats:c})]})]})})},j=()=>$(Kd,{__fallback:!0,onDock:F=>{ae("sidebar",`toggleDock (${F?"dock":"undock"})`,`(${w.editor.isMobile?"mobile":"desktop"})`)}}),A=rs(vl),N=Ht(j5,{children:[b,$(Sz,{UIOptions:p}),$(Kd.Trigger,{__fallback:!0,icon:Nr,title:vz(g("toolBar.library")),onToggle:F=>{F&&ae("sidebar",`${xf.name} (open)`,`button (${w.editor.isMobile?"mobile":"desktop"})`)},tab:xf.defaultTab,children:o.stylesPanelMode==="full"&&o.width>=yz&&g("toolBar.library")}),$(kz,{}),o.openDialog?.name==="ttd"&&$(Zg,{__fallback:!0}),o.isLoading&&$(Pd,{delay:250}),o.errorMessage&&$(N5,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),P&&!w.editor.isMobile&&$(qb,{colorPickerType:P.colorPickerType,onCancel:()=>{S(null)},onChange:(F,W,q,{altKey:ye})=>{if(!(F!=="elementBackground"&&F!=="elementStroke"))if(q.length){for(let Z of q)Tz(Z,wz(r),{[ye&&P.swapPreviewOnAlt?F==="elementBackground"?"strokeColor":"backgroundColor":F==="elementBackground"?"backgroundColor":"strokeColor"]:W}),Cz.delete(Z);x.scene.triggerUpdate()}else n(F==="elementBackground"?{currentItemBackgroundColor:W}:{currentItemStrokeColor:W})},onSelect:(F,W)=>{S(q=>q?.keepOpenOnAlt&&W.altKey?q:null),P?.onSelect?.(F,W)}}),o.openDialog?.name==="help"&&$(O5,{onClose:()=>{n({openDialog:null})}}),$(nw,{}),o.openDialog?.name==="elementLinkSelector"&&$(R5,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),$(v.OverwriteConfirmDialogTunnel.Out,{}),M(),_(),o.pasteDialog.shown&&$(k3,{setAppState:n,appState:o,onClose:()=>n({pasteDialog:{shown:!1,data:null}})}),w.editor.isMobile&&$(C3,{app:x,appState:o,elements:r,actionManager:e,renderJSONExportDialog:_,renderImageExportDialog:M,setAppState:n,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:c,renderSidebars:j,device:w,renderWelcomeScreen:f,UIOptions:p}),!w.editor.isMobile&&Ht(j5,{children:[Ht("div",{className:"layer-ui__wrapper",style:o.openSidebar&&A&&w.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&$(v.WelcomeScreenCenterTunnel.Out,{}),V(),$(A3,{appState:o,actionManager:e,showExitZenModeBtn:d,renderWelcomeScreen:f}),o.scrolledOutside&&$("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(F=>({...Zn(r,F)}))},children:g("buttons.scrollBackToContent")})]}),j()]})]});return $(vp.Provider,{value:o,children:$(k,{children:$(vh.Provider,{value:v,children:N})})})},$5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:n,scrollX:r,scrollY:i,...a}=e;return a},Lz=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...l}=o;return gm($5(n),$5(a),{selectedElementIds:gm,selectedGroupIds:gm})&&gm(r,l)},q5=xz.memo(Mz,Lz);import Pz from"clsx";import{jsx as J5,jsxs as Dz}from"react/jsx-runtime";var Az="small",fm=e=>Dz("label",{className:Pz("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${Az}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[J5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),J5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as _z,useRef as Rz}from"react";import{jsx as Q5}from"react/jsx-runtime";var eI=({trails:e})=>{let o=Rz(null);return _z(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),Q5("div",{className:"SVGLayer",children:Q5("svg",{ref:o})})};import Nz,{useEffect as Bz,useRef as Fz}from"react";import{CURSOR_TYPE as tI,isShallowEqual as Oz,sceneCoordsToViewportCoords as zz}from"@excalidraw/common";import{jsx as Uz}from"react/jsx-runtime";var Hz=e=>{let o=Fz(!1);return Bz(()=>{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,d)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))r.has(m)||r.set(m,[]),r.get(m).push(d);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(d,s.username),s.userState&&a.set(d,s.userState),n.set(d,zz({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(d,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Nv({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},Ui())}),Uz("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?tI.GRAB:tI.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")})},oI=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}),Gz=(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:Oz(oI(e.appState),oI(o.appState)),Ef=Nz.memo(Hz,Gz);import Yz,{useEffect as nI,useRef as rI}from"react";import{isShallowEqual as iI}from"@excalidraw/common";import{jsx as Xz}from"react/jsx-runtime";var Wz=e=>{let o=rI(null),t=rI(!1);return nI(()=>{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]),nI(()=>{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")),A1({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Ui())}),Xz("div",{className:"excalidraw__canvas-wrapper",ref:o})},aI=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}),Vz=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:iI(aI(e.appState),aI(o.appState))&&iI(e.renderConfig,o.renderConfig),yf=Yz.memo(Wz,Vz);import{useEffect as Qz,useRef as eH}from"react";import{throttleRAF as Kz}from"@excalidraw/common";import{getTargetFrame as Zz,isInvisiblySmallElement as $z,renderElement as jz,shouldApplyFrameClip as qz}from"@excalidraw/element";var lI=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,d]=Jl(e,i),m=Ql({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:d});if(m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if($z(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=Zz(t,n,a);p&&qz(t,p,a,n)&&L1(p,m,l,a)}jz(t,n,r,o,m,l,a)}else m.clearRect(0,0,s,d);m.restore()}},Jz=Kz(e=>{lI(e)},{trailing:!0}),sI=(e,o)=>{if(o){Jz(e);return}lI(e)};import{jsx as oH}from"react/jsx-runtime";var tH=e=>{let o=eH(null);return Qz(()=>{o.current&&sI({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},Ui())}),oH("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})},cI=tH;import{useCallback as nH,useEffect as rH,useRef as iH}from"react";import{jsx as dI,jsxs as lH}from"react/jsx-runtime";var aH=5e3,mI=({message:e,onClose:o,closable:t=!1,duration:n=aH,style:r})=>{let i=iH(0),a=n!==1/0,l=nH(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return rH(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),lH("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[dI("p",{className:"Toast__message",children:e}),t&&dI(K,{icon:Gt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as sH,getElementsInGroup as cH,selectGroupsFromGivenElements as dH}from"@excalidraw/element";import{sceneCoordsToViewportCoords as mH}from"@excalidraw/common";import{flushSync as pH}from"react-dom";import{jsx as hH}from"react/jsx-runtime";var uH=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:cH(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=sH(n),{x:a,y:l}=mH({sceneX:r,sceneY:i},e.state);return hH("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{pH(()=>{let s=dH(n,e.state);e.setState({selectedElementIds:n.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(ja)},title:g("labels.elementLock.unlock"),children:Q1})},pI=uH;import{Fragment as mU,jsx as ge,jsxs as Cm}from"react/jsx-runtime";var uC=_o.createContext(null),hC=_o.createContext(null),gC={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},Qf=_o.createContext(gC);Qf.displayName="DeviceContext";var e1=_o.createContext({container:null,id:null});e1.displayName="ExcalidrawContainerContext";var t1=_o.createContext([]);t1.displayName="ExcalidrawElementsContext";var o1=_o.createContext({...an(),width:0,height:0,offsetLeft:0,offsetTop:0});o1.displayName="ExcalidrawAppStateContext";var n1=_o.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});n1.displayName="ExcalidrawSetAppStateContext";var r1=_o.createContext(null);r1.displayName="ExcalidrawActionManagerContext";var Fe=()=>Xn(uC),yo=()=>Xn(hC),me=()=>Xn(Qf),Be=()=>Xn(e1),pn=()=>Xn(t1),Eo=()=>Xn(o1),ce=()=>Xn(n1),Ve=()=>Xn(r1),zl=!1,Kf=0,Hl=null,Sr=!1,Gl=!1,Zf=!1,Ul={horizontal:null,vertical:null},Vn=0,Yl=!1,$f=new Map,jf=!1,cC=0,dC=!1,Wl=null,he={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Jf=class e extends _o.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",gC);I(this,"excalidrawContainerRef",_o.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 OG);I(this,"flowChartNavigator",new zG);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 fd);I(this,"laserTrails",new Cd(this.animationFrameHandler,this));I(this,"eraserTrail",new Ld(this.animationFrameHandler,this));I(this,"lassoTrail",new Md(this.animationFrameHandler,this));I(this,"onChangeEmitter",new vr);I(this,"onPointerDownEmitter",new vr);I(this,"onPointerUpEmitter",new vr);I(this,"onUserFollowEmitter",new vr);I(this,"onScrollChangeEmitter",new vr);I(this,"missingPointerEventCleanupEmitter",new vr);I(this,"onRemoveEventListenersEmitter",new vr);I(this,"defaultSelectionTool","selection");I(this,"updateEditorAtom",(t,...n)=>{let r=Ye.set(t,...n);return this.triggerRender(),r});I(this,"getEffectiveGridSize",()=>kn(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),Ol.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(en(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=zf(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else na(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=Ge({clientX:i.x,clientY:i.y},this.state),l=Ge({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===Em.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Mt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!UI(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}=wm({sceneX:i.x,sceneY:i.y},this.state),s=6,d,m=DG(i);if(i.id===this.state.editingFrame){let c=m;d=ge("input",{autoFocus:!0,value:c,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?AH:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Un.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else d=m;return ge("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Un.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Un.nameFontSize,color:t?Un.nameColorDarkTheme:Un.nameColorLightTheme,lineHeight:Un.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:Re.MOVE,pointerEvents:this.state.viewModeEnabled?ea.disabled:ea.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:d},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)=>{ae("export",t,"ui");let i=await sr(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(KH).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&ts(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:Do.magicframe}),ae("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&Ff(t[0])&&t[0];if(!n&&t.some(i=>Mt(i)||i.frameId)){this.setActiveTool({type:Do.magicframe});return}ae("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=oa(t),d=50;r=NI({...Un,x:i-d,y:a-d,width:l-i+d*2,height:s-a+d*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let m of t)this.scene.mutateElement(m,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(mn,{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:wt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:wt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?Wn(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:wt.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",De(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||Em.LIGHT,s=t?.appState?.name??this.state.name,d=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(m=>{r?.id===m.id&&r!==m&&iC(m)&&go(m)&&(r=m)}),r?.isDeleted&&(r=null),this.setState(m=>{let c=t.appState||{};return{...m,...c,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:d}}),n=!0}n||this.scene.triggerUpdate()}));I(this,"onBlur",De(()=>{Sr=!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",De(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...an(),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=Dr(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,...Zn(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:wt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),Xf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,n)=>t<=eG||n<nG&&t<rG);I(this,"isTabletBreakpoint",(t,n)=>{let r=Math.min(t,n),i=Math.max(t,n);return r>=tG&&i<=oG});I(this,"refreshViewportBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=this.device.viewport,a=Mf(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:kH,a=this.device.editor,l=Mf(a,{isMobile:this.isMobileBreakpoint(n,r),canFitSidebar:n>i});return this.setState({stylesPanelMode:this.isTabletBreakpoint(n,r)&&Tr()?"compact":"full"}),a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",De(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Ol.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),II||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&&(Ul=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",kI(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},MH));I(this,"onCut",De(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||_l(t.target)||(this.actionManager.executeAction(yc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",De(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||_l(t.target)||(this.actionManager.executeAction(fi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(NH&&t.preventDefault(),!zl){zl=!0,t.touches.length===1&&(Hl={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Kf),Kf=window.setTimeout(e.resetTapTwice,LH);return}if(zl&&t.touches.length===1&&Hl){let n=t.touches[0];Gn(le(n.clientX,n.clientY),le(Hl.x,Hl.y))<=QH&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),zl=!1,clearTimeout(Kf)}t.touches.length===2&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}):he.pointers.clear()});I(this,"pasteFromClipboard",De(async t=>{let n=!!jf,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)||_l(r)))return;let l=await Wa(t),s=l.getFiles(),d=await IE(l,n);if(this.props.onPaste)try{if(await this.props.onPaste(d,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(d,s,n),this.setActiveTool({type:this.defaultSelectionTool},!0),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let n=Rm(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=oa(n),s=ta(r,a)/2,d=ta(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,c=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Ge({clientX:m,clientY:c},this.state),f=p-s,b=u-d,[x,y]=lt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=_f({type:"everything",elements:n.map(S=>Wn(S,{x:S.x+x-r,y:S.y+y-i})),randomizeSeed:!t.retainSeed}),w=this.scene.getElementsIncludingDeleted(),v=[...w,...E];v=this.props.onDuplicate?.(v,w)||v,eC(v,vm(E));let k=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(k){let S=RG(E,k);Yf(v,S,k,this.state)}this.scene.replaceAllElements(v),E.forEach(S=>{if(go(S)&&Bf(S)){let _=KI(S,this.scene.getElementsMapIncludingDeleted());SG(S,_,this.scene)}}),OH&&rn.loadElementsFonts(E).then(S=>{this.fonts.onLoaded(S)}),t.files&&this.addMissingFiles(t.files);let P=eU(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Ye.get(vl)?this.state.openSidebar:null,...Qt({editingGroupId:null,selectedElementIds:P.reduce((S,_)=>(Bf(_)||(S[_.id]=!0),S),{})},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=>{Vn&&this.resetContextMenuTimer(),he.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ae("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...Qo(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(Jx)});I(this,"zoomCanvas",t=>{this.setState({...zo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:fo(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if(Xf(t)?s=UG(t):s=t,s){let d=this.scene.getElementsFromId(s);d?.length?this.scrollToContent(d,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):Xf(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}=Ba({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=Zn(r,this.state);a=s.scrollX,l=s.scrollY}if(n?.animate){let s=this.state.scrollX,d=this.state.scrollY,m=this.state.zoom.value,c=XH({fromValues:{scrollX:s,scrollY:d,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,ZH(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=()=>{c(),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,yH,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",De(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===Ao.svg))try{let s=z1(XI(H1(l.dataURL)),Ao.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",De(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=n||void 0,s=r?iG({...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=lC.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return lC.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",De(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 No().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",De(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}})),!MI(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&&Ir(a[0])&&t.key===Y.ENTER){this.startImageCropping(a[0]);return}if(t.key===Y.ESCAPE)this.updateEditorAtom(co,null);else if(t.key===Y.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(JH.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=Ii(a);Ye.get(co)?.type==="panel"&&Ju(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(co,{type:"panel"})}if(t.key===Y.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=bm(t.key);if(t[Y.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=J(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&xG(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,qI(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Of(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 d=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),qI(t.key));if(d){this.setState(c=>({selectedElementIds:ve({[d]:!0},c)}));let m=this.scene.getNonDeletedElementsMap().get(d);m&&!Of([m],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(m,{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:Oe("commandPalette")})}),t.preventDefault();return}if(t[Y.CTRL_OR_CMD]&&t.key.toLowerCase()===Y.V&&(jf=t.shiftKey,clearTimeout(cC),cC=window.setTimeout(()=>{jf=!1},100)),t[Y.CTRL_OR_CMD]&&_l(t.target)&&(t.code===EI.MINUS||t.code===EI.EQUAL)){t.preventDefault();return}if(_l(t.target)&&t.key!==Y.ESCAPE||bm(t.key)&&MI(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}),bm(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(Ke),s=new Set;a.filter(Ke).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 d=this.getEffectiveGridSize()&&(t.shiftKey?vI:this.getEffectiveGridSize())||(t.shiftKey?TH:vI),m=0,c=0;t.key===Y.ARROW_LEFT?m=-d:t.key===Y.ARROW_RIGHT?m=d:t.key===Y.ARROW_UP?c=-d:t.key===Y.ARROW_DOWN&&(c=d),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+m,y:p.y+c},{informMutation:!1,isDragging:!1}),Af(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:Df(a.filter(p=>p.id!==l?.id||d!==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]||Im(l))Jt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Ke(l)||this.actionManager.executeAction(Oi));else if(go(l)||CG(l)){let s;go(l)||(s=l);let d=Gf(l,this.state,this.scene.getNonDeletedElementsMap()),m=d.x,c=d.y;this.startTextEditing({sceneX:m,sceneY:c,container:s}),t.preventDefault();return}else Mt(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=U2(t.key,this);a?(this.state.activeTool.type!==a&&ae("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Yn.sharp?Yn.round:l.currentItemArrowType===Yn.round?Yn.elbow:Yn.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===Y.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===Y.SPACE&&he.pointers.size===0&&(Sr=!0,Ee(this.interactiveCanvas,Re.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&&(bo(this.state.activeTool.type)||a.some(l=>bo(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=>go(l)||Hf(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(hr,"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",De(t=>{if(t.key===Y.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?Ee(this.interactiveCanvas,Re.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Wt(this.interactiveCanvas):(Nt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Sr=!1),!t[Y.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),bm(t.key)&&(_I(this.scene.getSelectedElements(this.state).filter(Jt),Pf(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:wt.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:ve({[n.id]:!0},r)})),Of([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:wt.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=Qo(this.state,t);r.type==="hand"?Ee(this.interactiveCanvas,Re.GRAB):Sr||Nt(this.interactiveCanvas,{...this.state,activeTool:r}),UH(document.activeElement)&&this.focusContainer(),fG(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:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null},...a}:r.type!=="selection"?{...i,activeTool:r,selectedElementIds:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:r,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{Ee(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{Wt(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>he.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${LI()}`);I(this,"onGestureStart",De(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null}),he.initialScale=this.state.zoom.value}));I(this,"onGestureChange",De(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=he.initialScale;n&&this.setState(r=>({...zo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:fo(n*t.scale)},r)}))}));I(this,"onGestureEnd",De(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}),he.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&&(Hf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let d=null,m=this.scene.getSelectedElements(this.state);m.length===1?go(m[0])?d=m[0]:i?d=Hf(m[0],this.scene.getNonDeletedElementsMap()):d=this.getTextElementAtPosition(t,n):d=this.getTextElementAtPosition(t,n);let c=d?.fontFamily||this.state.currentItemFontFamily,p=d?.lineHeight||SI(c),u=this.state.currentItemFontSize;if(!d&&l&&i&&!Rf(i)){let y=XG(Sf({fontSize:u,fontFamily:c}),p),E=KG(u,p),w=Math.max(i.height,E),v=Math.max(i.width,y);this.scene.mutateElement(i,{height:w,width:v}),t=i.x+v/2,n=i.y+w/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),b=d||BI({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:c,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?_H.MIDDLE:wI,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?Rf(i)?0:i.angle:0,frameId:f?f.id:null});if(!d&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!d)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||d||i?this.handleTextWysiwyg(b,{isExistingElement:!!d}):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}=Ge(t,this.state);if(n.length===1&&Jt(n[0])){let l=n[0];if((t[Y.CTRL_OR_CMD]&&cU(l)||Im(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Oi);return}else if(this.state.selectedLinearElement&&Ke(n[0])){let s=Ie.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=s?Ie.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),Ie.deleteFixedSegment(n[0],this.scene,d);let m=Ie.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=m?Ie.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:c,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&Im(l))return}if(n.length===1&&Ir(n[0])){this.startImageCropping(n[0]);return}if(Wt(this.interactiveCanvas),JG(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&qG(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(d=>({...d,...Qt({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(Wt(this.interactiveCanvas),!t[Y.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(Bl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(OI(s)||!VH(s.backgroundColor)||Fl({point:le(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let d=Gf(s,this.state,this.scene.getNonDeletedElementsMap());r=d.x,i=d.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&&ql(l,this.scene.getNonDeletedElementsMap(),this.state,le(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,n)=>{let r=Gn(le(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),le(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>vH)return;let i=Ge(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=ql(this.hitLinkElement,a,this.state,le(i.x,i.y),this.device.editor.isMobile),s=Ge(this.lastPointerUpEvent,this.state),d=ql(this.hitLinkElement,a,this.state,le(s.x,s.y),this.device.editor.isMobile);if(l&&d){Gu();let m=this.hitLinkElement.link;if(m){m=Cf(m);let c;if(this.props.onLinkOpen&&(c=YH(oe.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},c)),!c?.defaultPrevented){let p=zH(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&ZI(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,he.pointers.has(t.pointerId)&&he.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let n=he.initialScale;if(he.pointers.size===2&&he.lastCenter&&n&&he.initialDistance){let f=qh(he.pointers),b=f.x-he.lastCenter.x,x=f.y-he.lastCenter.y;he.lastCenter=f;let y=Jh(Array.from(he.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:y/he.initialDistance,w=E?fo(n*E):this.state.zoom.value;this.setState(v=>{let C=zo({viewportX:f.x,viewportY:f.y,nextZoom:w},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/w),scrollY:C.scrollY+2*(x/w),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else he.lastCenter=he.initialDistance=he.initialScale=null;if(Sr||Gl||Zf||oo(this.state))return;let i=ag(Ul,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Wt(this.interactiveCanvas):Nt(this.interactiveCanvas,this.state));let a=Ge(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&hv(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=uv(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let y=Rl(x.snapLines,b),E=x.originSnapOffset?Rl(x.originSnapOffset,f):f;return x.snapLines===y&&x.originSnapOffset===E?null:{snapLines:y,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=Ie.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&Qi(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&zI(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(zI(this.state.activeTool.type)){let{newElement:f}=this.state;Nf(f,!1)?this.setState({suggestedBindings:AI(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:y,lastCommittedPoint:E}=f,w=y[y.length-1];if(Nt(this.interactiveCanvas,this.state),w===E)Gn(le(l-b,s-x),w)>=If?this.scene.mutateElement(f,{points:[...y,le(l-b,s-x)]},{informMutation:!1,isDragging:!1}):Ee(this.interactiveCanvas,Re.POINTER);else if(y.length>2&&E&&Gn(le(l-b,s-x),E)<If)Ee(this.interactiveCanvas,Re.POINTER),this.scene.mutateElement(f,{points:y.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=lt(l,s,t[Y.CTRL_OR_CMD]||Ke(f)?null:this.getEffectiveGridSize()),[k,P]=f?.lastCommittedPoint??[0,0],S=v-b-k,_=C-x-P;Tf(t)&&({width:S,height:_}=GI(k+b,P+x,v,C)),WI(y,this.state.zoom.value)&&Ee(this.interactiveCanvas,Re.POINTER),this.scene.mutateElement(f,{points:[...y.slice(0,-1),le(k+S,P+_)]},{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 m=this.scene.getNonDeletedElements(),c=this.scene.getSelectedElements(this.state);if(c.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"&&!(c.length===1&&Ke(c[0]))){let f=oC(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){Ee(this.interactiveCanvas,tC(f));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=nC(oa(c),l,s,this.state.zoom,t.pointerType,this.device);if(f){Ee(this.interactiveCanvas,tC({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),!vt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(Ee(this.interactiveCanvas,Re.POINTER),wy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Gu(),u&&(u.link||en(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Ee(this.interactiveCanvas,go(u)?Re.TEXT:Re.CROSSHAIR):this.state.viewModeEnabled?Ee(this.interactiveCanvas,Re.GRAB):this.state.openDialog?.name==="elementLinkSelector"?Ee(this.interactiveCanvas,Re.AUTO):i?Ee(this.interactiveCanvas,Re.AUTO):t[Y.CTRL_OR_CMD]?Ee(this.interactiveCanvas,Re.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,c))&&!u?.locked&&(u&&Bl(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(Ee(this.interactiveCanvas,Re.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!Ke(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||c.length>0)&&Ee(this.interactiveCanvas,Re.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:Rl(f.hoveredElementIds,Qt({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:Rl(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=>{Yl=!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(c=>({searchMatches:c.searchMatches&&{focusedId:null,matches:c.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(Ug,null)),Ye.get(co)&&this.updateEditorAtom(co,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 c=this.state.newElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==c.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:ve(Object.keys(this.state.selectedElementIds).filter(p=>p!==c.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?wt.EVENTUALLY:wt.NEVER});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Mf(this.device,{isTouchScreen:!0})),Gl||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===wr.ERASER&&this.state.activeTool.type!==Do.eraser){this.setState({activeTool:Qo(this.state,{type:Do.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{p(),u?.(),vt(this.state)&&this.setState({activeTool:Qo(this.state,{...this.state.activeTool.lastActiveTool||{type:Do.selection},lastActiveToolBeforeEraser:null})})},p=Ne(window,oe.POINTER_UP,c,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==wr.MAIN&&t.button!==wr.TOUCH&&t.button!==wr.ERASER||he.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 c=i.hit.element&&this.isASelectedElement(i.hit.element);!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!c&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey),i.drag.blockDragging=!Tr()),Tr()&&i.hit.element&&!c&&(this.setState(p=>{let u={...p.selectedElementIds,[i.hit.element.id]:!0},f=[];Object.keys(p.selectedElementIds).forEach(x=>{let y=this.scene.getElement(x);y&&f.push(y)});let b=i.hit.element;if(Mt(b))Uf(f,b.id).forEach(x=>{delete u[x.id]});else if(b.frameId)u[b.frameId]&&delete u[b.id];else{let x=b.groupIds,y=new Set(x.flatMap(E=>Cr(this.scene.getNonDeletedElements(),E)).filter(E=>Mt(E)).map(E=>E.id));y.size>0&&f.forEach(E=>{E.frameId&&y.has(E.frameId)&&(delete u[E.id],E.groupIds.flatMap(w=>Cr(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return{...Qt({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:b.link||en(b)?"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"?Nt(this.interactiveCanvas,this.state):this.state.activeTool.type===Do.frame||this.state.activeTool.type===Do.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),d=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(c=>s(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(oe.POINTER_MOVE,l),window.addEventListener(oe.POINTER_UP,s),window.addEventListener(oe.KEYDOWN,d),window.addEventListener(oe.KEYUP,m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=d)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let n=Ge({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(Bl(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&&Bl(this.hitLinkElement)&&!C1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,le(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"&&(Yl=!1,Vn?Yl=!0:Vn=window.setTimeout(()=>{Vn=0,Yl||this.handleCanvasContextMenu(t)},DH))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Vn),Vn=0,Yl=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Wl?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(he.pointers.size<=1&&(t.button===wr.WHEEL||t.button===wr.MAIN&&Sr||oo(this.state)||this.state.viewModeEnabled)))return!1;Gl=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Ee(this.interactiveCanvas,Re.GRABBING);let{clientX:i,clientY:a}=t,l=Sd(d=>{let m=i-d.clientX,c=a-d.clientY;if(i=d.clientX,a=d.clientY,r&&!n&&(Math.abs(m)>1||Math.abs(c)>1)){n=!0;let p=f=>{document.body.removeEventListener(oe.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(oe.PASTE,p),window.removeEventListener(oe.POINTER_UP,u)},100)};document.body.addEventListener(oe.PASTE,p),window.addEventListener(oe.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-c/this.state.zoom.value})}),s=De(Wl=()=>{Wl=null,Gl=!1,Sr||(this.state.viewModeEnabled?Ee(this.interactiveCanvas,Re.GRAB):Nt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(oe.POINTER_MOVE,l),window.removeEventListener(oe.POINTER_UP,s),window.removeEventListener(oe.BLUR,s),l.flush()});return window.addEventListener(oe.BLUR,s),window.addEventListener(oe.POINTER_MOVE,l,{passive:!0}),window.addEventListener(oe.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ve({},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&&!Ke(a[0])&&!(Im(a[0])&&Ie.getPointIndexUnderCursor(a[0],i,this.state.zoom,n.origin.x,n.origin.y)!==-1)&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=oC(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=nC(oa(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=kf(oU(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&Jt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=nU(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Ie.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),d=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!d||d.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),d&&d.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,d),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 m=n.hit.element,c=n.hit.allHitElements.some(p=>this.isASelectedElement(p));if((m===null||!c)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:ve({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(m!=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[m.id]||(n.hit.wasAddedToSelection=!0),this.setState(p=>({...jG(p,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!QI(m,this.state.editingGroupId)&&this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!c&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[m.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),Mt(m))Uf(f,m.id).forEach(b=>{delete u[b.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let b=m.groupIds,x=new Set(b.flatMap(y=>Cr(this.scene.getNonDeletedElements(),y)).filter(y=>Mt(y)).map(y=>y.id));x.size>0&&f.forEach(y=>{y.frameId&&x.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(E=>Cr(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(b=>p.selectedGroupIds[b])||(u={[m.id]:!0})),{...Qt({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:m.link||en(m)?"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);OI(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}),Wt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Qo(this.state,{type:this.defaultSelectionTool})})});I(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=lt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,d=cG({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:[le(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(d),this.setState(c=>{let p={...c.selectedElementIds};return delete p[d.id],{selectedElementIds:ve(p,c)}});let m=Lf(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:d,startBoundElement:m,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,l]=lt(t,n,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=dG({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]=lt(t,n,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Tm(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=RI({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]=lt(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 uG({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"&&WI(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Bt);return}if(Ke(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Bt);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Gn(le(r.origin.x-a,r.origin.y-l),s)<If){this.actionManager.executeAction(Bt);return}this.setState(d=>({selectedElementIds:ve({...d.selectedElementIds,[i.id]:!0},d)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),Ee(this.interactiveCanvas,Re.POINTER)}else{let[i,a]=lt(r.origin.x,r.origin.y,t[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:d}=this.state,[m,c]=n==="arrow"?[s,d]:[null,null],p=n==="arrow"?mG({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===Yn.round?{type:xm.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:c,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Yn.elbow,fixedSegments:this.state.currentItemArrowType===Yn.elbow?[]:null}):hG({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:xm.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:ve(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,le(0,0)]});let u=Lf(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,Ke(p),Ke(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=lt(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=RI({type:"embeddable",...l}):s=pG({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]=lt(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,...Un},l=n===Do.magicframe?NI(a):sG(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)||Bf(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Wn(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});I(this,"initializeImage",async(t,n)=>{if(!Nm(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type;if(Ee(this.interactiveCanvas,"wait"),r===Ao.svg)try{n=zm(XI(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||O1(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 ns(n,{maxWidthOrHeight:wH})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>TI)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(TI/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await Om(n);return new Promise(async(s,d)=>{try{let m=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([m]);if(p.size)throw new Error("Image cache update resulted with an error.")}let c=await this.imageCache.get(i)?.image;if(c&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(m,c);Object.assign(m,p)}s(m)}catch(m){console.error(m),d(new Error(g("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return Wn(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}=Ge({clientX:t,clientY:n},this.state),a=await $l({description:"Image",extensions:Object.keys(IH),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Qo(this.state,{type:this.defaultSelectionTool})},()=>{this.actionManager.executeAction(Bt)})}});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,d=t.y+t.height/2-a/2;return{x:s,y:d,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await IG({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(wt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Nl(a)&&i.has(a.fileId)?Wn(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=TG(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)&&Ol.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",gH(()=>{this.addNewImagesToImageCache()},CH));I(this,"updateBindingEnabledOnPointerMove",t=>{let n=lG(t);this.state.isBindingEnabled!==n&&this.setState({isBindingEnabled:n})});I(this,"maybeSuggestBindingAtCursor",(t,n)=>{let r=Lf(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(oe.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(oe.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(oe.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(oe.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=sC(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,await ma(t[u]))}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),Wn(p,{isDeleted:!0})}})),s=vm(l),d=sC(l.filter(p=>!p.isDeleted),n,r,i),m=vm(d),c=this.scene.getElementsIncludingDeleted().map(p=>m.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:ve(Object.fromEntries(d.map(p=>[p.id,!0])),this.state)},elements:c,captureUpdate:wt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(Bt)})});I(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=Ge(t,this.state),i=await Wa(t),a=i.getFiles();if(a.length===1){let{file:c,fileHandle:p}=a[0];if(c&&(c.type===Ao.png||c.type===Ao.svg))try{let u=await os(c,this.state,this.scene.getElementsIncludingDeleted(),p);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:wt.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}}let l=a.map(c=>c.file).filter(c=>Nm(c));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,n,r);let s=i.getData(Ao.excalidrawlibIds),d=i.getData(Ao.excalidrawlib);if(s||d){try{let c=null;if(s){let{itemIds:p}=JSON.parse(s);c=(await this.library.getLatestLibrary()).filter(f=>p.includes(f.id))}else d&&(c=F1(d));c?.length&&(c=c.map(p=>({...p,elements:_f({type:"everything",elements:p.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Mi(c),position:t,files:null}))}catch(c){this.setState({errorMessage:c.message})}return}if(a.length>0){let{file:c,fileHandle:p}=a[0];c&&await this.loadFileToCanvas(c,p)}let m=i.findByType(Ao.text);if(m){let c=m.value;if(c&&zf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Tm(c)?.type==="video")){let p=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:Cf(c)});p&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[p.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,n)=>{t=await ma(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Bm(t,this.state,r,n)}catch(a){let l=a instanceof v1;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===Ao.excalidraw?(pC(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:wt.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:wt.IMMEDIATELY})):i.type===Ao.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!==wr.SECONDARY)&&this.state.activeTool.type!==this.defaultSelectionTool)return;let{x:n,y:r}=Ge(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",d=this.excalidrawContainerRef.current,{top:m,left:c}=d.getBoundingClientRect(),p=t.clientX-c,u=t.clientY-m;ae("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...Qt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Jt(i)?new Ie(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"){rC({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:ta(t.origin.x,a.x),height:ta(t.origin.y,a.y),shouldMaintainAspectRatio:Dl(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,d]=lt(a.x,a.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Nl(l)&&this.imageCache.get(l.fileId)?.image,c=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:p,snapLines:u}=pv(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:d-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,d+=p.y,this.setState({snapLines:u}),rC({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:d,width:ta(t.originInGrid.x,s),height:ta(t.originInGrid.y,d),shouldMaintainAspectRatio:Ir(l)?!Dl(n):Dl(n),shouldResizeFromCenter:yI(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:c,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Do.frame||this.state.activeTool.type===Do.magicframe)&&this.setState({elementsToHighlight:Wf(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]=lt(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&&Ir(s)){let d=t.originalElements.get(s.id),m=Nl(s)&&this.imageCache.get(s.fileId)?.image;if(d&&Ir(d)&&m&&!(m instanceof Promise)){let[c,p]=lt(i.x,i.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:f,snapLines:b}=og([s],[d],this,n,u,r);this.scene.mutateElement(s,HG(s,this.scene.getNonDeletedElementsMap(),r,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,n.shiftKey?d.width/d.height:void 0)),Af(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(c=>Mt(c)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Ke(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,d]=lt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(c=>{Uf(this.scene.getNonDeletedElements(),c.id).forEach(u=>{m.set(c.id+u.id,{x:u.x-c.x,y:u.y-c.y})})}),!this.state.selectedElementsAreBeingDragged){let[c,p]=lt(l.x,l.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:b,snapLines:x}=og(r,J(f,this.state),this,n,u,a);s+=b.x,d+=b.y,this.setState({snapLines:x})}if(rU(t.originalElements,a,r,this.scene,Tf(n),yI(n),r.some(c=>Ir(c))?!Dl(n):Dl(n),s,d,t.resize.center.x,t.resize.center.y)){let c=Df(r,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{Wf(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:c}),!0}return!1});I(this,"getContextMenuItems",t=>{let n=[];return n.push(vc,wc),t==="canvas"?this.state.viewModeEnabled?[...n,Ic,bi,$h,xi]:[ku,Xe,vc,wc,Tc,Xe,Ep,ky,Xe,Ic,Mu,bi,$h,xi]:(n.push(Tc),this.state.viewModeEnabled?[fi,...n]:[Xe,yc,fi,ku,Xe,Ww,Vw,Xw,Xe,Vh,Xe,...n,Xe,fu,bu,Xe,yu,Qw,Au,Du,py,wu,Xe,Iu,Xe,gp,fp,bp,xp,Xe,Cu,Su,Xe,Oi,Xe,$a,Dc,Xe,yp,ja,Xe,va])});I(this,"handleWheel",De(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(),Gl)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),a=RH*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let d=this.state.zoom.value-s/100;d+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...zo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:fo(d)},m),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}=Ge({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:he.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",kI(()=>{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:d,offsetTop:m,offsetLeft:c}=this.state;if(r===s&&i===d&&a===c&&l===m){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let n=an();this.defaultSelectionTool=Tr()?"lasso":"selection";let{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:d=n.theme,name:m=`${g("labels.untitled")}-${LI()}`}=t;if(this.state={...n,theme:d,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??n.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight},this.id=bH(),this.library=new Qy(this),this.actionManager=new gd(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new aC,this.canvas=document.createElement("canvas"),this.rc=fH.canvas(this.canvas),this.renderer=new El(this.scene),this.visibleElements=[],this.store=new lU(this),this.history=new hl(this.store),r){let c={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(c):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new rn(this.scene),this.history=new hl(this.store),this.actionManager.registerAll(Cs),this.actionManager.registerAction($w(this.history)),this.actionManager.registerAction(jw(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(ym).includes(i)&&$f.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),na(t)))return;let n=this.getHTMLIFrameElement(t);if(n?.contentWindow){if(n.src.includes("youtube")){let r=$f.get(t.id);switch(r||($f.set(t.id,ym.UNSTARTED),n.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),r){case ym.PLAYING:case ym.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=>en(a)&&this.embedsValidationStatus.get(a.id)===!0||na(a));return ge(mU,{children:i.map(a=>{let{x:l,y:s}=wm({sceneX:a.x,sceneY:a.y},this.state),d=UI(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(d&&!m&&this.initializedEmbeds.add(a.id),!(d||m))return null;let p;if(na(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:()=>VI(`
|
|
24
|
+
C -->|Three| F[Car]`,$T=wO(Wl,300),IO=({mermaidToExcalidrawLib:e})=>{let[t,o]=XT(()=>Xt.get(yO.MERMAID_TO_EXCALIDRAW)||TO),n=EO(t.trim()),[r,i]=XT(null),a=KT(null),l=KT({elements:[],files:null}),s=Fe();ZT(()=>{lm({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:n}).catch(m=>{vO()&&console.error("Failed to parse mermaid definition",m)}),$T(n)},[n,e]),ZT(()=>()=>{$T.flush()},[]);let d=()=>{sm({app:s,data:l,text:t,shouldSaveMermaidDataToStorage:!0})};return jT(CO,{children:[Ro("div",{className:"ttd-dialog-desc",children:Ro(bt,{i18nKey:"mermaid.description",flowchartLink:m=>Ro("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:m}),sequenceLink:m=>Ro("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:m}),classLink:m=>Ro("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:m})})}),jT(im,{children:[Ro(ra,{label:g("mermaid.syntax"),children:Ro(om,{input:t,placeholder:"Write Mermaid diagram defintion here...",onChange:m=>o(m.target.value),onKeyboardSubmit:()=>{d()}})}),Ro(ra,{label:g("mermaid.preview"),panelAction:{action:()=>{d()},label:g("mermaid.button"),icon:$r},renderSubmitShortcut:()=>Ro(am,{}),children:Ro(rm,{canvasRef:a,loaded:e.loaded,error:r})})]})]})},qT=IO;import*as QT from"@radix-ui/react-tabs";import{useRef as JT}from"react";import{isMemberOf as SO}from"@excalidraw/common";import{jsx as kO}from"react/jsx-runtime";var eI=e=>{let t=me(),o=JT(null),n=JT(0);return kO(QT.Root,{ref:o,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:r=>{if(!r)return;let i=o.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"&&SO(["text-to-diagram","mermaid"],r)&&t({openDialog:{name:e.dialog,tab:r}})},children:e.children})};eI.displayName="TTDDialogTabs";var tI=eI;import*as oI from"@radix-ui/react-tabs";import{jsx as MO}from"react/jsx-runtime";var of=({children:e,...t})=>MO(oI.List,{className:"ttd-dialog-triggers",...t,children:e});of.displayName="TTDDialogTabTriggers";import*as rI from"@radix-ui/react-tabs";import{jsx as nI}from"react/jsx-runtime";var cm=({children:e,tab:t,onSelect:o,...n})=>nI(rI.Trigger,{value:t,asChild:!0,onSelect:o,children:nI("button",{type:"button",className:"ttd-dialog-tab-trigger",...n,children:e})});cm.displayName="TTDDialogTabTrigger";import*as iI from"@radix-ui/react-tabs";import{jsx as PO}from"react/jsx-runtime";var dm=({tab:e,children:t,...o})=>PO(iI.Content,{...o,value:e,children:t});dm.displayName="TTDDialogTab";import{jsx as yt,jsxs as Hn}from"react/jsx-runtime";var rf=3,ia=1e3,AO=ge(null),DO=ge(null),af=e=>{let t=xe();return t.openDialog?.name!=="ttd"?null:yt(_O,{...e,tab:t.openDialog.tab})},_O=nn("TTDDialogBase",({tab:e,...t})=>{let o=Fe(),n=me(),r=nf(null),[i,a]=de(DO),[l,s]=mm(i?.prompt??""),d=l.trim(),m=S=>{s(S.target.value),a(L=>({generatedResponse:L?.generatedResponse??null,prompt:S.target.value}))},[c,p]=mm(!1),[u,f]=de(AO),b=async()=>{if(d.length>ia||d.length<rf||c||u?.rateLimitRemaining===0||"__fallback"in t){d.length<rf&&I(new Error(`Prompt is too short (min ${rf} characters)`)),d.length>ia&&I(new Error(`Prompt is too long (max ${ia} characters)`));return}try{p(!0),ie("ai","generate","ttd");let{generatedResponse:S,error:L,rateLimit:k,rateLimitRemaining:R}=await t.onTextSubmit(d);if(typeof S=="string"&&a(M=>({generatedResponse:S,prompt:M?.prompt??null})),aI(k)&&aI(R)&&f({rateLimit:k,rateLimitRemaining:R}),L){I(L);return}if(!S){I(new Error("Generation failed"));return}try{await lm({canvasRef:r,data:y,mermaidToExcalidrawLib:w,setError:I,mermaidDefinition:S}),ie("ai","mermaid parse success","ttd")}catch(M){console.info(`%cTTD mermaid render errror: ${M.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
25
|
+
TTD mermaid definition render errror: ${M.message}`,"color: yellow"),ie("ai","mermaid parse failed","ttd"),I(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"),I(new Error(L))}finally{p(!1)}},x=nf(b);x.current=b;let[w,E]=mm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});LO(()=>{(async()=>{await w.api,E(L=>({...L,loaded:!0}))})()},[w.api]);let y=nf({elements:[],files:null}),[v,I]=mm(null);return yt(He,{className:"ttd-dialog",onCloseRequest:()=>{o.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:Hn(tI,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?yt("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):Hn(of,{children:[yt(cm,{tab:"text-to-diagram",children:Hn("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),yt("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"})]})}),yt(cm,{tab:"mermaid",children:"Mermaid"})]}),yt(dm,{className:"ttd-dialog-content",tab:"mermaid",children:yt(qT,{mermaidToExcalidrawLib:w})}),!("__fallback"in t)&&Hn(dm,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[yt("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."}),Hn(im,{children:[yt(ra,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:$r},onTextSubmitInProgess:c,panelActionDisabled:d.length>ia||u?.rateLimitRemaining===0,renderTopRight:()=>u?Hn("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:()=>yt(am,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Hn("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Wl(i.generatedResponse),n({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",yt(vn,{icon:$r})]});let S=d.length/ia;return S>.8?Hn("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",d.length,"/",ia]}):null},children:yt(om,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),yt(ra,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),sm({app:o,data:y})},label:"Insert",icon:$r},children:yt(rm,{canvasRef:r,error:v,loaded:w.loaded})})]})]})]})})});import{round as VI}from"@excalidraw/math";import XF from"clsx";import KF from"lodash.throttle";import{useEffect as XI,useMemo as yf,useState as ZF,memo as $F}from"react";import{STATS_PANELS as Em}from"@excalidraw/common";import{getCommonBounds as jF}from"@excalidraw/element";import{getUncroppedWidthAndHeight as qF}from"@excalidraw/element";import{isElbowArrow as JF,isImageElement as wf}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as QF}from"@excalidraw/element";import{elementsAreInSameGroup as ez}from"@excalidraw/element";import{degreesToRadians as pI,radiansToDegrees as fI}from"@excalidraw/math";import{getBoundTextElement as uI}from"@excalidraw/element";import{isArrowElement as hI,isElbowArrow as VO}from"@excalidraw/element";import{updateBindings as gI}from"@excalidraw/element";import zO from"clsx";import{useEffect as dI,useRef as um,useState as HO}from"react";import{EVENT as sa,KEYS as GO,cloneJSON as lf}from"@excalidraw/common";import{deepCopyElement as UO}from"@excalidraw/element";import{CaptureUpdateAction as mI}from"@excalidraw/element";import{pointFrom as Gn,pointRotateRads as pm}from"@excalidraw/math";import{getBoundTextElement as RO}from"@excalidraw/element";import{isFrameLikeElement as sI}from"@excalidraw/element";import{getSelectedGroupIds as NO,getElementsInGroup as BO,isInGroup as OO}from"@excalidraw/element";import{getFrameChildren as FO}from"@excalidraw/element";import{updateBindings as lI}from"@excalidraw/element";var cI=.01,Vl=10,St=(e,t)=>!(t==="angle"&&sI(e)),Le=(e,t)=>{let o=e+t/2;return o-o%t},aa=(e,t,o)=>Object.keys(e).map(n=>({original:(o??t).get(n),latest:t.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var vr=(e,t,o,n,r,i=!0)=>{let a=n.getNonDeletedElementsMap(),l=a.get(o.id);if(!l)return;let[s,d]=[o.x+o.width/2,o.y+o.height/2],[m,c]=pm(Gn(o.x,o.y),Gn(s,d),o.angle),p=e-m,u=t-c,[f,b]=pm(Gn(e,t),Gn(s+p,d+u),-o.angle);n.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),lI(l,n);let x=RO(o,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(sI(o)){let w=FO(r,o.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,I]=[E.x+E.width/2,E.y+E.height/2],[S,L]=pm(Gn(E.x,E.y),Gn(v,I),E.angle),k=Math.round(S+p),R=Math.round(L+u),[M,_]=pm(Gn(k,R),Gn(v+p,I+u),-E.angle);n.mutateElement(y,{x:M,y:_},{informMutation:i,isDragging:!1}),lI(y,n,{simultaneouslyUpdated:w})})}},la=(e,t)=>{let n=NO(t).map(r=>BO(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!OO(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as sf,jsxs as WO}from"react/jsx-runtime";var YO=({label:e,icon:t,dragInputCallback:o,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:d,sensitivity:m=1,dragFinishedCallback:c})=>{let p=Fe(),u=me(),f=um(null),b=um(null),[x,w]=HO(n.toString()),E=um(null);E.current||(E.current={originalAppState:lf(d),originalElements:r,lastUpdatedValue:x,updatePending:!1}),dI(()=>{let I=n.toString();w(I),E.current.lastUpdatedValue=I},[n]);let y=(I,S,L)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let k=Number(I);if(isNaN(k)){w(n.toString());return}let R=Number(k.toFixed(2)),M=Number(n);(isNaN(M)||Math.abs(R-M)>=cI)&&(E.current.lastUpdatedValue=I,o({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:R,property:l,originalAppState:L,setInputValue:_=>w(String(_)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:mI.IMMEDIATELY}))},v=um({});return v.current.handleInputValue=y,dI(()=>{let I=f.current,S=v.current;return()=>{let L=I?.value;L&&S.handleInputValue?.(L,E.current.originalElements,E.current.originalAppState),window.removeEventListener(sa.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(sa.POINTER_UP,S.onPointerUp,!1)}},[i]),i?WO("div",{className:zO("drag-input-container",!i&&"disabled"),"data-testid":e,children:[sf("div",{className:"drag-input-label",ref:b,onPointerDown:I=>{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((A,B)=>(A.set(B.id,UO(B)),A),new Map),R=r.map(A=>k.get(A.id)),M=lf(d),_=0,N=0,K=A=>{if(L&&k!==null&&R!==null){let B=A.clientX-L.x;B!==0&&(N+=B,Math.abs(N)>=m&&(N=Math.sign(N)*Math.floor(Math.abs(N)/m),_+=N,o({accumulatedChange:_,instantChange:N,originalElements:R,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:A.shiftKey,property:l,scene:s,originalAppState:M,setInputValue:H=>w(String(H)),app:p,setAppState:u}),N=0))}L={x:A.clientX,y:A.clientY}},J=()=>{window.removeEventListener(sa.POINTER_MOVE,K,!1),p.syncActionResult({captureUpdate:mI.IMMEDIATELY}),c?.({app:p,setAppState:u,originalElements:R,originalAppState:M}),L=null,_=0,N=0,R=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(sa.POINTER_UP,J,!1)};v.current.onPointerMove=K,v.current.onPointerUp=J,window.addEventListener(sa.POINTER_MOVE,K,!1),window.addEventListener(sa.POINTER_UP,J,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:t?sf(vn,{icon:t}):e}),sf("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:I=>{if(i){let S=I.target;S instanceof HTMLInputElement&&I.key===GO.ENTER&&(y(S.value,r,d),p.focusContainer())}},ref:f,value:x,onChange:I=>{E.current.updatePending=!0,w(I.target.value)},onFocus:I=>{I.target.select(),E.current.originalElements=r,E.current.originalAppState=lf(d)},onBlur:I=>{x?i&&y(I.target.value,E.current.originalElements,E.current.originalAppState):w(n.toString())},disabled:!i})]}):null},nt=YO;import{jsx as $O}from"react/jsx-runtime";var XO=15,KO=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=t[0];if(a&&!VO(a)){let l=i.get(a.id);if(!l)return;if(n!==void 0){let u=pI(n);r.mutateElement(l,{angle:u}),gI(l,r);let f=uI(l,i);f&&!hI(l)&&r.mutateElement(f,{angle:u});return}let s=Math.round(fI(a.angle)*100)/100,d=Math.round(e),m=(s+d)%360;o&&(m=Le(m,XO)),m=m<0?m+360:m;let c=pI(m);r.mutateElement(l,{angle:c}),gI(l,r);let p=uI(l,i);p&&!hI(l)&&r.mutateElement(p,{angle:c})}},ZO=({element:e,scene:t,appState:o,property:n})=>$O(nt,{label:"A",icon:Ds,value:Math.round(fI(e.angle)%360*100)/100,elements:[e],dragInputCallback:KO,editable:St(e,"angle"),scene:t,appState:o,property:n}),bI=ZO;import{jsx as qO}from"react/jsx-runtime";var xI=5,jO=({property:e,scene:t,appState:o,setAppState:n})=>qO(nt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let d;return r?d=r:i&&(d=a?Le(s.gridStep+xI*Math.sign(i),xI):s.gridStep+i),d?(d=L1(d),l(d),{gridStep:d}):(l(s.gridStep),null)})},scene:t,value:o.gridStep,property:e,appState:o}),EI=jO;import{clamp as hm,round as cf}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as gm}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as yI,getUncroppedWidthAndHeight as TI}from"@excalidraw/element";import{resizeSingleElement as wI}from"@excalidraw/element";import{isImageElement as II}from"@excalidraw/element";import{isFrameLikeElement as df}from"@excalidraw/element";import{getElementsInResizingFrame as mf}from"@excalidraw/element";import{replaceAllElementsInFrame as CI}from"@excalidraw/element";import{jsx as oF}from"react/jsx-runtime";var vI=10,JO=e=>e.type==="image",QO=({accumulatedChange:e,originalElements:t,originalElementsMap:o,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:d,app:m,setAppState:c})=>{let p=d.getNonDeletedElementsMap(),u=t[0],f=p.get(u.id);if(u&&f){let b=n||JO(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!II(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,I=w.scale[1]===-1,{width:S,height:L}=TI(w),k=E.naturalWidth/S,R=E.naturalHeight/L,M=v?E.width+E.x:E.naturalWidth-E.x,_=I?E.height+E.y:E.naturalHeight-E.y,N=yI*k,K=yI*R;if(i!==void 0){if(a==="width"){let Y=i*k,q=hm(Y,N,M);y={...y,width:q,x:v?E.x+E.width-q:E.x}}else if(a==="height"){let Y=i*R,q=hm(Y,K,_);y={...y,height:q,y:I?E.y+E.height-q:E.y}}d.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}let J=a==="width"?s:0,A=a==="height"?s:0,B=hm(E.width+J,N,M),H=hm(E.height+A,N,_);y={...E,x:v?E.x+E.width-B:E.x,y:I?E.y+E.height-H:E.y,width:B,height:H},d.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,gm),E=Math.max(a==="height"?i:b?i/x:u.height,gm);if(wI(w,E,f,u,o,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),df(f)){let y=mf(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap()),v=CI(d.getElementsIncludingDeleted(),y,f,m);d.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=Le(y,vI):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(r?v=Le(v,vI):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(gm,v),y=Math.max(gm,y),wI(y,v,f,u,o,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),df(f)){let I=mf(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap());c({elementsToHighlight:I})}}}},eF=({setAppState:e,app:t,originalElements:o,originalAppState:n})=>{let r=t.scene.getNonDeletedElementsMap(),i=o?.[0],a=i&&r.get(i.id);if(a&&df(a)){let l=mf(t.scene.getElementsIncludingDeleted(),a,n,t.scene.getNonDeletedElementsMap()),s=CI(t.scene.getElementsIncludingDeleted(),l,a,t);t.scene.replaceAllElements(s),e({elementsToHighlight:null})}},tF=({property:e,element:t,scene:o,appState:n})=>{let r=cf(e==="width"?t.width:t.height,2);if(n.croppingElementId&&n.croppingElementId===t.id&&II(t)&&t.crop){let{width:i,height:a}=TI(t);if(e==="width"){let l=i/t.crop.naturalWidth;r=cf(t.crop.width*l,2)}if(e==="height"){let l=a/t.crop.naturalHeight;r=cf(t.crop.height*l,2)}}return oF(nt,{label:e==="width"?"W":"H",elements:[t],dragInputCallback:QO,value:r,editable:St(t,e),scene:o,appState:n,property:e,dragFinishedCallback:eF})},pf=tF;import{getBoundTextElement as nF,redrawTextBoundingBox as rF}from"@excalidraw/element";import{hasBoundTextElement as iF,isTextElement as kI}from"@excalidraw/element";import{jsx as cF}from"react/jsx-runtime";var SI=4,aF=4,lF=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=t[0];if(a){let l=i.get(a.id);if(!l||!kI(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),SI);else if(a.type==="text"){let d=Math.round(a.fontSize),m=Math.round(e);s=Math.max(d+m,SI),o&&(s=Le(s,aF))}s&&(r.mutateElement(l,{fontSize:s}),rF(l,r.getContainerElement(l),r))}},sF=({element:e,scene:t,appState:o,property:n})=>{let r=kI(e)?e:iF(e)?nF(e,t.getNonDeletedElementsMap()):null;return r?cF(nt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:lF,icon:nr,appState:o,scene:t,property:n}):null},MI=sF;import{degreesToRadians as PI,radiansToDegrees as DI}from"@excalidraw/math";import{getBoundTextElement as LI}from"@excalidraw/element";import{isArrowElement as AI}from"@excalidraw/element";import{isInGroup as uf}from"@excalidraw/element";import{jsx as uF}from"react/jsx-runtime";var dF=15,mF=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=t.map(d=>a.get(d.id)).filter(d=>d&&!uf(d)&&St(d,r)),s=t.filter(d=>!uf(d)&&St(d,r));if(n!==void 0){let d=PI(n);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:d});let c=LI(m,a);c&&!AI(m)&&i.mutateElement(c,{angle:d})}i.triggerUpdate();return}for(let d=0;d<l.length;d++){let m=l[d];if(!m)continue;let c=s[d],p=Math.round(DI(c.angle)*100)/100,u=Math.round(e),f=(p+u)%360;o&&(f=Le(f,dF)),f=f<0?f+360:f;let b=PI(f);i.mutateElement(m,{angle:b});let x=LI(m,a);x&&!AI(m)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},pF=({elements:e,scene:t,appState:o,property:n})=>{let r=e.filter(s=>!uf(s)&&St(s,"angle")),i=r.map(s=>Math.round(DI(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>St(s,"angle"));return uF(nt,{label:"A",icon:Ds,value:a,elements:e,dragInputCallback:mF,editable:l,appState:o,scene:t,property:n})},_I=pF;import{pointFrom as RI}from"@excalidraw/math";import{useMemo as hF}from"react";import{MIN_WIDTH_OR_HEIGHT as Un}from"@excalidraw/common";import{getElementsInResizingFrame as hf,isFrameLikeElement as gf,replaceAllElementsInFrame as OI,updateBoundElements as gF}from"@excalidraw/element";import{rescalePointsInElement as fF,resizeSingleElement as NI}from"@excalidraw/element";import{getBoundTextElement as bF,handleBindTextResize as xF}from"@excalidraw/element";import{isTextElement as FI}from"@excalidraw/element";import{getCommonBounds as fm}from"@excalidraw/element";import{jsx as IF}from"react/jsx-runtime";var ca=10,EF=(e,t,o,n)=>{let r=n.x-e,i=n.y-t,a=n.width*o,l=n.height*o,s=e+r*o,d=t+i*o;return{width:a,height:l,x:s,y:d,...fF(n,a,l,!1),...FI(n)?{fontSize:n.fontSize*o}:{}}},yF=(e,t,o,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),d=EF(e,t,n,i);l.mutateElement(r,d);let m=bF(i,a);if(m){let c=m.fontSize*n;gF(r,l,{newSize:{width:d.width,height:d.height}});let p=s.get(m.id);p&&FI(p)&&(l.mutateElement(p,{fontSize:c}),xF(r,l,o==="width"?"e":"s",!0))}},BI=(e,t,o,n,r,i,a,l,s,d)=>{i==="width"?t=Math.round(e/n*100)/100:e=Math.round(t*n*100)/100;let m=t/o;for(let c=0;c<l.length;c++){let p=l[c],u=a[c];yF(r[0],r[1],i,m,u,p,s,d)}},wF=({accumulatedChange:e,originalElements:t,originalElementsMap:o,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:d})=>{let m=a.getNonDeletedElementsMap(),c=la(t,n);if(i!==void 0){for(let b of c){let x=aa(b,m,o);if(x.length>1){let w=x.map(N=>N.latest),E=x.map(N=>N.original),[y,v,I,S]=fm(E),L=I-y,k=S-v,R=L/k,M=Math.max(Un,l==="width"?Math.max(0,i):L),_=Math.max(Un,l==="height"?Math.max(0,i):k);BI(M,_,k,R,RI(y,v),l,w,E,o,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&St(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(r?v=Le(v,ca):v=Math.round(v));let I=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(r?I=Le(I,ca):I=Math.round(I)),v=Math.max(Un,v),I=Math.max(Un,I),NI(v,I,E,y,o,a,l==="width"?"e":"s",{shouldInformMutation:!1}),gf(E)){let S=hf(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap()),L=OI(a.getElementsIncludingDeleted(),S,E,d);a.replaceAllElements(L)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of c){let x=aa(b,m,o);if(x.length>1){let w=x.map(N=>N.latest),E=x.map(N=>N.original),[y,v,I,S]=fm(E),L=I-y,k=S-v,R=L/k,M=Math.max(0,L+p);l==="width"&&(r?M=Le(M,ca):M=Math.round(M));let _=Math.max(0,k+u);l==="height"&&(r?_=Le(_,ca):_=Math.round(_)),M=Math.max(Un,M),_=Math.max(Un,_),BI(M,_,k,R,RI(y,v),l,w,E,o,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&St(E,l)){let v=Math.max(0,y.width+p);l==="width"&&(r?v=Le(v,ca):v=Math.round(v));let I=Math.max(0,y.height+u);if(l==="height"&&(r?I=Le(I,ca):I=Math.round(I)),v=Math.max(Un,v),I=Math.max(Un,I),NI(v,I,E,y,o,a,l==="width"?"e":"s",{shouldInformMutation:!1}),gf(E)){let S=hf(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},vF=({setAppState:e,app:t,originalElements:o,originalAppState:n})=>{let r=t.scene.getNonDeletedElementsMap(),i=o?.[0],a=i&&r.get(i.id);if(a&&gf(a)){let l=hf(t.scene.getElementsIncludingDeleted(),a,n,t.scene.getNonDeletedElementsMap()),s=OI(t.scene.getElementsIncludingDeleted(),l,a,t);t.scene.replaceAllElements(s),e({elementsToHighlight:null})}},TF=({property:e,elements:t,elementsMap:o,atomicUnits:n,scene:r,appState:i})=>{let a=hF(()=>n.map(d=>{let m=aa(d,o);if(m.length>1){let[p,u,f,b]=fm(m.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[c]=m;return Math.round((e==="width"?c.latest.width:c.latest.height)*100)/100}),[o,n,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return IF(nt,{label:e==="width"?"W":"H",elements:t,dragInputCallback:wF,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:vF})},ff=TF;import{getBoundTextElement as CF,redrawTextBoundingBox as zI}from"@excalidraw/element";import{hasBoundTextElement as SF,isTextElement as kF}from"@excalidraw/element";import{isInGroup as MF}from"@excalidraw/element";import{jsx as _F}from"react/jsx-runtime";var HI=4,PF=4,LF=(e,t)=>e.reduce((o,n)=>{if(!n||MF(n))return o;if(kF(n))return o.push(n),o;if(SF(n)){let r=CF(n,t);if(r)return o.push(r),o}return o},[]),AF=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=t.map(s=>i.get(s.id)),l;if(n){l=Math.max(Math.round(n),HI);for(let s of a)r.mutateElement(s,{fontSize:l}),zI(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=t;for(let d=0;d<a.length;d++){let m=a[d],c=s[d],p=Math.round(c.fontSize),u=Math.round(e),f=Math.max(p+u,HI);o&&(f=Le(f,PF)),r.mutateElement(m,{fontSize:f}),zI(m,r.getContainerElement(m),r)}r.triggerUpdate()}},DF=({elements:e,scene:t,appState:o,property:n,elementsMap:r})=>{let i=LF(e,r);if(!i.length)return null;let a=i.map(d=>Math.round(d.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return _F(nt,{label:"F",icon:nr,elements:i,dragInputCallback:AF,value:l,editable:s,scene:t,property:n,appState:o})},GI=DF;import{pointFrom as Yn,pointRotateRads as bm}from"@excalidraw/math";import{useMemo as RF}from"react";import{isTextElement as NF}from"@excalidraw/element";import{getCommonBounds as bf}from"@excalidraw/element";import{jsx as HF}from"react/jsx-runtime";var BF=(e,t,o,n,r,i)=>{for(let a=0;a<n.length;a++){let l=n[a],[s,d]=[l.x+l.width/2,l.y+l.height/2],[m,c]=bm(Yn(l.x,l.y),Yn(s,d),l.angle),p=e==="x"?Math.round(m+t):m,u=e==="y"?Math.round(c+o):c;vr(p,u,l,i,r,!1)}},OF=(e,t,o,n,r)=>{let i=r.getNonDeletedElementsMap(),[a,l,,]=bf(o),s=e-a,d=t-l;for(let m=0;m<o.length;m++){let c=o[m],p=i.get(c.id);if(p&&(!NF(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=bm(Yn(p.x,p.y),Yn(u,f),p.angle);vr(b+s,x+d,c,r,n,!1)}}},FF=({accumulatedChange:e,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(r!==void 0){for(let p of la(t,l)){let u=aa(p,s,o);if(u.length>1){let[f,b,,]=bf(u.map(E=>E.latest));OF(i==="x"?r:f,i==="y"?r:b,u.map(E=>E.original),o,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&St(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=bm(Yn(f.x,f.y),Yn(x,w),f.angle);vr(i==="x"?r:E,i==="y"?r:y,f,a,o,!1)}}}a.triggerUpdate();return}let d=n?Le(e,Vl):e;BF(i,i==="x"?d:0,i==="y"?d:0,t,o,a),a.triggerUpdate()},zF=({property:e,elements:t,elementsMap:o,atomicUnits:n,scene:r,appState:i})=>{let a=RF(()=>n.map(s=>{let d=Object.keys(s).map(b=>o.get(b)).filter(b=>b!==void 0);if(d.length>1){let[b,x]=bf(d);return Math.round((e==="x"?b:x)*100)/100}let[m]=d,[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=bm(Yn(m.x,m.y),Yn(c,p),m.angle);return Math.round((e==="x"?u:f)*100)/100}),[n,o,e]),l=new Set(a).size===1?a[0]:"Mixed";return HF(nt,{label:e==="x"?"X":"Y",elements:t,dragInputCallback:FF,value:l,property:e,scene:r,appState:i})},xf=zF;import{clamp as Xl,pointFrom as xm,pointRotateRads as YI,round as UI}from"@excalidraw/math";import{getFlipAdjustedCropPosition as GF,getUncroppedWidthAndHeight as UF}from"@excalidraw/element";import{isImageElement as WI}from"@excalidraw/element";import{jsx as VF}from"react/jsx-runtime";var YF=({accumulatedChange:e,instantChange:t,originalElements:o,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s})=>{let d=l.getNonDeletedElementsMap(),m=o[0],[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=YI(xm(m.x,m.y),xm(c,p),m.angle);if(s.croppingElementId===m.id){let y=d.get(m.id);if(!y||!WI(y)||!y.crop)return;let v=y.crop,I=v,S=y.scale[0]===-1,L=y.scale[1]===-1,{width:k,height:R}=UF(y);if(i!==void 0){if(a==="x"){let N=i*(v.naturalWidth/k);S?I={...v,x:Xl(v.naturalWidth-N-v.width,0,v.naturalWidth-v.width)}:I={...v,x:Xl(i*(v.naturalWidth/k),0,v.naturalWidth-v.width)}}a==="y"&&(I={...v,y:Xl(i*(v.naturalHeight/R),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:I});return}let M=(a==="x"?t:0)*(S?-1:1),_=(a==="y"?t:0)*(L?-1:1);I={...v,x:Xl(v.x+M,0,v.naturalWidth-v.width),y:Xl(v.y+_,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:I});return}if(i!==void 0){vr(a==="x"?i:u,a==="y"?i:f,m,l,n);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(r?Le(m.x+b,Vl):u+b):u,E=a==="y"?Math.round(r?Le(m.y+x,Vl):f+x):f;vr(w,E,m,l,n)},WF=({property:e,element:t,elementsMap:o,scene:n,appState:r})=>{let[i,a]=YI(xm(t.x,t.y),xm(t.x+t.width/2,t.y+t.height/2),t.angle),l=UI(e==="x"?i:a,2);if(r.croppingElementId===t.id&&WI(t)&&t.crop){let s=GF(t);s&&(l=UI(e==="x"?s.x:s.y,2))}return VF(nt,{label:e==="x"?"X":"Y",elements:[t],dragInputCallback:YF,scene:n,value:l,property:e,appState:r})},Ef=WF;import{Fragment as vf,jsx as ee,jsxs as kt}from"react/jsx-runtime";var tz=50,Kl=e=>{let t=vo(),o=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),r=_n(e.app);return ee(oz,{...e,appState:t,sceneNonce:o,selectedElements:n,gridModeEnabled:r})},ke=({children:e,columns:t=1,heading:o,style:n,...r})=>ee("div",{className:XF("exc-stats__row",{"exc-stats__row--heading":o}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...n},...r,children:e});ke.displayName="StatsRow";var ym=({children:e,order:t,style:o,...n})=>ee("div",{className:"exc-stats__rows",style:{order:t,...o},...n,children:e});ym.displayName="StatsRows";Kl.StatsRow=ke;Kl.StatsRows=ym;var oz=$F(({app:e,onClose:t,renderCustomStats:o,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),d=l.getNonDeletedElementsMap(),m=me(),c=n.length===1?n[0]:null,p=n.length>1?n:null,u=r.croppingElementId&&wf(c),f=u?qF(c):null,[b,x]=ZF({width:0,height:0}),w=yf(()=>KF(v=>{let I=jF(v);x({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},tz),[]);XI(()=>{w(s)},[i,s,w]),XI(()=>()=>w.cancel(),[w]);let E=yf(()=>la(n,r),[n,r]),y=yf(()=>QF(n),[n]);return ee("div",{className:"exc-stats",children:kt(Ye,{padding:3,children:[kt("div",{className:"title",children:[ee("h2",{children:g("stats.title")}),ee("div",{className:"close",onClick:t,children:Ht})]}),kt(Za,{label:ee("h3",{children:g("stats.generalStats")}),open:!!(r.stats.panels&Em.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Em.generalStats}})),children:[kt(ym,{children:[ee(ke,{heading:!0,children:g("stats.scene")}),kt(ke,{columns:2,children:[ee("div",{children:g("stats.shapes")}),ee("div",{children:s.length})]}),kt(ke,{columns:2,children:[ee("div",{children:g("stats.width")}),ee("div",{children:b.width})]}),kt(ke,{columns:2,children:[ee("div",{children:g("stats.height")}),ee("div",{children:b.height})]}),a&&kt(vf,{children:[ee(ke,{heading:!0,children:"Canvas"}),ee(ke,{children:ee(EI,{property:"gridStep",scene:l,appState:r,setAppState:m})})]})]}),o?.(s,r)]}),!y&&n.length>0&&ee("div",{id:"elementStats",style:{marginTop:12},children:ee(Za,{label:ee("h3",{children:g("stats.elementProperties")}),open:!!(r.stats.panels&Em.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Em.elementProperties}})),children:kt(ym,{children:[c&&kt(vf,{children:[u&&ee(ke,{heading:!0,children:g("labels.unCroppedDimension")}),r.croppingElementId&&wf(c)&&f&&kt(ke,{columns:2,children:[ee("div",{children:g("stats.width")}),ee("div",{children:VI(f.width,2)})]}),r.croppingElementId&&wf(c)&&f&&kt(ke,{columns:2,children:[ee("div",{children:g("stats.height")}),ee("div",{children:VI(f.height,2)})]}),ee(ke,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?g("labels.imageCropping"):g(`element.${c.type}`)}),ee(ke,{children:ee(Ef,{element:c,property:"x",elementsMap:d,scene:l,appState:r})}),ee(ke,{children:ee(Ef,{element:c,property:"y",elementsMap:d,scene:l,appState:r})}),ee(ke,{children:ee(pf,{property:"width",element:c,scene:l,appState:r})}),ee(ke,{children:ee(pf,{property:"height",element:c,scene:l,appState:r})}),!JF(c)&&ee(ke,{children:ee(bI,{property:"angle",element:c,scene:l,appState:r})}),ee(ke,{children:ee(MI,{property:"fontSize",element:c,scene:l,appState:r})})]}),p&&kt(vf,{children:[ez(p)&&ee(ke,{heading:!0,children:g("element.group")}),kt(ke,{columns:2,style:{margin:"0.3125rem 0"},children:[ee("div",{children:g("stats.shapes")}),ee("div",{children:n.length})]}),ee(ke,{children:ee(xf,{property:"x",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),ee(ke,{children:ee(xf,{property:"y",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),ee(ke,{children:ee(ff,{property:"width",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),ee(ke,{children:ee(ff,{property:"height",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),ee(ke,{children:ee(_I,{property:"angle",elements:p,scene:l,appState:r})}),ee(ke,{children:ee(GI,{property:"fontSize",elements:p,scene:l,appState:r,elementsMap:d})})]})]})})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels&&e.gridModeEnabled===t.gridModeEnabled&&e.appState.gridStep===t.appState.gridStep&&e.appState.croppingElementId===t.appState.croppingElementId);import{useCallback as nz,useEffect as KI,useState as ZI}from"react";import{normalizeLink as rz,KEYS as Tf}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as iz,getLinkIdAndTypeFromSelection as az}from"@excalidraw/element";import{jsx as da,jsxs as wm}from"react/jsx-runtime";var lz=({sourceElementId:e,onClose:t,appState:o,scene:n,generateLinkForSelection:r=iz})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=ZI(a),[d,m]=ZI(!1);KI(()=>{let p=Q(i,o),u=a;if(p.length>0&&r){let f=az(p,o);f&&(u=rz(r(f.id,f.type)))}s(u)},[i,o,o.selectedElementIds,a,r]);let c=nz(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&n.mutateElement(p,{link:l})}if(!l&&d&&e){let p=i.get(e);p&&n.mutateElement(p,{link:null})}t?.()},[e,l,i,d,n,t]);return KI(()=>{let p=u=>{o.openDialog?.name==="elementLinkSelector"&&u.key===Tf.ENTER&&c(),o.openDialog?.name==="elementLinkSelector"&&u.key===Tf.ESCAPE&&t?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[o,t,c]),wm("div",{className:"ElementLinkDialog",children:[wm("div",{className:"ElementLinkDialog__header",children:[da("h2",{children:g("elementLink.title")}),da("p",{children:g("elementLink.desc")})]}),wm("div",{className:"ElementLinkDialog__input",children:[da(Pn,{value:l??"",onChange:p=>{d||m(!0),s(p)},onKeyDown:p=>{p.key===Tf.ENTER&&c()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&da(V,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:At})]}),wm("div",{className:"ElementLinkDialog__actions",children:[da(Zo,{label:g("buttons.cancel"),onClick:()=>{t?.()},style:{marginRight:10}}),da(Zo,{label:g("buttons.confirm"),onClick:c,actionType:"primary"})]})]})},$I=lz;import sz,{useState as cz}from"react";import{Fragment as dz,jsx as If}from"react/jsx-runtime";var jI=({children:e,onClose:t})=>{let[o,n]=cz(!!e),{container:r}=Be(),i=sz.useCallback(()=>{n(!1),t&&t(),r?.focus()},[t,r]);return If(dz,{children:o&&If(He,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:If("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import mz from"react";import{isDarwin as qI,isFirefox as JI,isWindows as pz}from"@excalidraw/common";import{KEYS as _e,getShortcutKey as Z}from"@excalidraw/common";import{Fragment as e5,jsx as z,jsxs as Ft}from"react/jsx-runtime";var uz=()=>Ft("div",{className:"HelpDialog__header",children:[Ft("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[z("div",{className:"HelpDialog__link-icon",children:Jm}),g("helpDialog.documentation")]}),Ft("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[z("div",{className:"HelpDialog__link-icon",children:Jm}),g("helpDialog.blog")]}),Ft("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[z("div",{className:"HelpDialog__link-icon",children:ks}),g("helpDialog.github")]}),Ft("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[z("div",{className:"HelpDialog__link-icon",children:B0}),"YouTube"]})]}),hz=e=>Ft(e5,{children:[z("h3",{children:e.title}),z("div",{className:"HelpDialog__islands-container",children:e.children})]}),Cf=e=>Ft("div",{className:`HelpDialog__island ${e.className}`,children:[z("h4",{className:"HelpDialog__island-title",children:e.caption}),z("div",{className:"HelpDialog__island-content",children:e.children})]});function*gz(e,t){let o=!0;for(let n of e)o||(yield t),o=!1,yield n}var fz=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),U=({label:e,shortcuts:t,isOr:o=!0})=>{let n=t.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>z(bz,{children:fz(a)},a)));return Ft("div",{className:"HelpDialog__shortcut",children:[z("div",{children:e}),z("div",{className:"HelpDialog__key-container",children:[...gz(n,o?g("helpDialog.or"):null)]})]})},bz=e=>z("kbd",{className:"HelpDialog__key",...e}),QI=({onClose:e})=>{let t=mz.useCallback(()=>{e&&e()},[e]);return z(e5,{children:Ft(He,{onCloseRequest:t,title:g("helpDialog.title"),className:"HelpDialog",children:[z(uz,{}),Ft(hz,{title:g("helpDialog.shortcuts"),children:[Ft(Cf,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[z(U,{label:g("toolBar.hand"),shortcuts:[_e.H]}),z(U,{label:g("toolBar.selection"),shortcuts:[_e.V,_e[1]]}),z(U,{label:g("toolBar.rectangle"),shortcuts:[_e.R,_e[2]]}),z(U,{label:g("toolBar.diamond"),shortcuts:[_e.D,_e[3]]}),z(U,{label:g("toolBar.ellipse"),shortcuts:[_e.O,_e[4]]}),z(U,{label:g("toolBar.arrow"),shortcuts:[_e.A,_e[5]]}),z(U,{label:g("toolBar.line"),shortcuts:[_e.L,_e[6]]}),z(U,{label:g("toolBar.freedraw"),shortcuts:[_e.P,_e[7]]}),z(U,{label:g("toolBar.text"),shortcuts:[_e.T,_e[8]]}),z(U,{label:g("toolBar.image"),shortcuts:[_e[9]]}),z(U,{label:g("toolBar.eraser"),shortcuts:[_e.E,_e[0]]}),z(U,{label:g("toolBar.frame"),shortcuts:[_e.F]}),z(U,{label:g("toolBar.laser"),shortcuts:[_e.K]}),z(U,{label:g("labels.eyeDropper"),shortcuts:[_e.I,"Shift+S","Shift+G"]}),z(U,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[Z("CtrlOrCmd+Enter")]}),z(U,{label:g("helpDialog.editText"),shortcuts:[Z("Enter")]}),z(U,{label:g("helpDialog.textNewLine"),shortcuts:[Z("Enter"),Z("Shift+Enter")]}),z(U,{label:g("helpDialog.textFinish"),shortcuts:[Z("Esc"),Z("CtrlOrCmd+Enter")]}),z(U,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),z(U,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),z(U,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),Z("Enter")],isOr:!0}),z(U,{label:g("helpDialog.cropFinish"),shortcuts:[Z("Enter"),Z("Escape")],isOr:!0}),z(U,{label:g("toolBar.lock"),shortcuts:[_e.Q]}),z(U,{label:g("helpDialog.preventBinding"),shortcuts:[Z("CtrlOrCmd")]}),z(U,{label:g("toolBar.link"),shortcuts:[Z("CtrlOrCmd+K")]}),z(U,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ft(Cf,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[z(U,{label:g("buttons.zoomIn"),shortcuts:[Z("CtrlOrCmd++")]}),z(U,{label:g("buttons.zoomOut"),shortcuts:[Z("CtrlOrCmd+-")]}),z(U,{label:g("buttons.resetZoom"),shortcuts:[Z("CtrlOrCmd+0")]}),z(U,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),z(U,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),z(U,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),z(U,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),z(U,{label:g("buttons.zenMode"),shortcuts:[Z("Alt+Z")]}),z(U,{label:g("buttons.objectsSnapMode"),shortcuts:[Z("Alt+S")]}),z(U,{label:g("labels.toggleGrid"),shortcuts:[Z("CtrlOrCmd+'")]}),z(U,{label:g("labels.viewMode"),shortcuts:[Z("Alt+R")]}),z(U,{label:g("labels.toggleTheme"),shortcuts:[Z("Alt+Shift+D")]}),z(U,{label:g("stats.fullTitle"),shortcuts:[Z("Alt+/")]}),z(U,{label:g("search.title"),shortcuts:[ze("searchMenu")]}),z(U,{label:g("commandPalette.title"),shortcuts:JI?[ze("commandPalette")]:[ze("commandPalette"),ze("commandPalette",1)]})]}),Ft(Cf,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[z(U,{label:g("helpDialog.createFlowchart"),shortcuts:[Z("CtrlOrCmd+Arrow Key")],isOr:!0}),z(U,{label:g("helpDialog.navigateFlowchart"),shortcuts:[Z("Alt+Arrow Key")],isOr:!0}),z(U,{label:g("labels.moveCanvas"),shortcuts:[Z(`Space+${g("helpDialog.drag")}`),Z(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),z(U,{label:g("buttons.clearReset"),shortcuts:[Z("CtrlOrCmd+Delete")]}),z(U,{label:g("labels.delete"),shortcuts:[Z("Delete")]}),z(U,{label:g("labels.cut"),shortcuts:[Z("CtrlOrCmd+X")]}),z(U,{label:g("labels.copy"),shortcuts:[Z("CtrlOrCmd+C")]}),z(U,{label:g("labels.paste"),shortcuts:[Z("CtrlOrCmd+V")]}),z(U,{label:g("labels.pasteAsPlaintext"),shortcuts:[Z("CtrlOrCmd+Shift+V")]}),z(U,{label:g("labels.selectAll"),shortcuts:[Z("CtrlOrCmd+A")]}),z(U,{label:g("labels.multiSelect"),shortcuts:[Z(`Shift+${g("helpDialog.click")}`)]}),z(U,{label:g("helpDialog.deepSelect"),shortcuts:[Z(`CtrlOrCmd+${g("helpDialog.click")}`)]}),z(U,{label:g("helpDialog.deepBoxSelect"),shortcuts:[Z(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(fi||JI)&&z(U,{label:g("labels.copyAsPng"),shortcuts:[Z("Shift+Alt+C")]}),z(U,{label:g("labels.copyStyles"),shortcuts:[Z("CtrlOrCmd+Alt+C")]}),z(U,{label:g("labels.pasteStyles"),shortcuts:[Z("CtrlOrCmd+Alt+V")]}),z(U,{label:g("labels.sendToBack"),shortcuts:[qI?Z("CtrlOrCmd+Alt+["):Z("CtrlOrCmd+Shift+[")]}),z(U,{label:g("labels.bringToFront"),shortcuts:[qI?Z("CtrlOrCmd+Alt+]"):Z("CtrlOrCmd+Shift+]")]}),z(U,{label:g("labels.sendBackward"),shortcuts:[Z("CtrlOrCmd+[")]}),z(U,{label:g("labels.bringForward"),shortcuts:[Z("CtrlOrCmd+]")]}),z(U,{label:g("labels.alignTop"),shortcuts:[Z("CtrlOrCmd+Shift+Up")]}),z(U,{label:g("labels.alignBottom"),shortcuts:[Z("CtrlOrCmd+Shift+Down")]}),z(U,{label:g("labels.alignLeft"),shortcuts:[Z("CtrlOrCmd+Shift+Left")]}),z(U,{label:g("labels.alignRight"),shortcuts:[Z("CtrlOrCmd+Shift+Right")]}),z(U,{label:g("labels.duplicateSelection"),shortcuts:[Z("CtrlOrCmd+D"),Z(`Alt+${g("helpDialog.drag")}`)]}),z(U,{label:g("helpDialog.toggleElementLock"),shortcuts:[Z("CtrlOrCmd+Shift+L")]}),z(U,{label:g("buttons.undo"),shortcuts:[Z("CtrlOrCmd+Z")]}),z(U,{label:g("buttons.redo"),shortcuts:pz?[Z("CtrlOrCmd+Y"),Z("CtrlOrCmd+Shift+Z")]:[Z("CtrlOrCmd+Shift+Z")]}),z(U,{label:g("labels.group"),shortcuts:[Z("CtrlOrCmd+G")]}),z(U,{label:g("labels.ungroup"),shortcuts:[Z("CtrlOrCmd+Shift+G")]}),z(U,{label:g("labels.flipHorizontal"),shortcuts:[Z("Shift+H")]}),z(U,{label:g("labels.flipVertical"),shortcuts:[Z("Shift+V")]}),z(U,{label:g("labels.showStroke"),shortcuts:[Z("S")]}),z(U,{label:g("labels.showBackground"),shortcuts:[Z("G")]}),z(U,{label:g("labels.showFonts"),shortcuts:[Z("Shift+F")]}),z(U,{label:g("labels.decreaseFontSize"),shortcuts:[Z("CtrlOrCmd+Shift+<")]}),z(U,{label:g("labels.increaseFontSize"),shortcuts:[Z("CtrlOrCmd+Shift+>")]})]})]})]})})};import{CANVAS_SEARCH_TAB as xz,DEFAULT_SIDEBAR as Ez}from"@excalidraw/common";import{isFlowchartNodeElement as yz,isImageElement as t5,isLinearElement as o5,isLineElement as wz,isTextBindableContainer as vz,isTextElement as Tz}from"@excalidraw/element";import{getShortcutKey as Sf}from"@excalidraw/common";import{isNodeInFlowchart as Iz}from"@excalidraw/element";import{jsx as n5}from"react/jsx-runtime";var Cz=({appState:e,isMobile:t,device:o,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===Ez.name&&e.openSidebar.tab===xz&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!o.editor.canFitSidebar)return null;if(vt(e))return g("hints.eraserRevert");if(r.type==="arrow"||r.type==="line")return s?g("hints.linearElementMulti"):r.type==="arrow"?g("hints.arrowTool",{arrowShortcut:Sf("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 d=n.scene.getSelectedElements(e);if(i&&l==="mouse"&&d.length===1){let m=d[0];return o5(m)&&m.points.length===2?g("hints.lockAngle"):t5(m)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(d.length===1&&Tz(d[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(d.length===1&&t5(d[0]))return g("hints.enterCropEditor");if(r.type==="selection"){if(e.selectionElement&&!d.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(_n(n)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!d.length&&!t)return[g("hints.canvasPanning")];if(d.length===1){if(o5(d[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):wz(d[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&vz(d[0]))return yz(d[0])?Iz(d[0],n.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},r5=({appState:e,isMobile:t,device:o,app:n})=>{let r=Cz({appState:e,isMobile:t,device:o,app:n});if(!r)return null;let i=Array.isArray(r)?r.map(a=>Sf(a).replace(/\. ?$/,"")).join(". "):Sf(r);return n5("div",{className:"HintViewer",children:n5("span",{children:i})})};import{useEffect as l5,useRef as Az,useState as Wn}from"react";import{DEFAULT_EXPORT_PADDING as Dz,EXPORT_IMAGE_TYPES as kf,isFirefox as _z,EXPORT_SCALES as Rz,cloneJSON as s5}from"@excalidraw/common";import{useCallback as Sz,useRef as kz,useState as Mz}from"react";var Pz=2e3,i5=()=>{let[e,t]=Mz(null),o=kz(0),n=()=>{clearTimeout(o.current),t("success"),o.current=window.setTimeout(()=>{t(null)},Pz)},r=Sz(()=>{t(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import Lz from"clsx";import{jsx as a5}from"react/jsx-runtime";var Zl=({title:e,name:t,checked:o,onChange:n,disabled:r=!1})=>a5("div",{className:Lz("Switch",{toggled:o,disabled:r}),children:a5("input",{name:t,id:t,title:e,type:"checkbox",checked:o,disabled:r,onChange:()=>n(!o),onKeyDown:i=>{i.key===" "&&n(!o)}})});import{jsx as Me,jsxs as Vn}from"react/jsx-runtime";var Nz="filter"in document.createElement("canvas").getContext("2d"),Bz=()=>Vn("div",{children:[Me("h3",{children:g("canvasError.cannotShowPreview")}),Me("p",{children:Me("span",{children:g("canvasError.canvasTooBig")})}),Vn("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),Oz=({appStateSnapshot:e,elementsSnapshot:t,files:o,actionManager:n,onExportImage:r,name:i})=>{let a=ve(t,e),[l,s]=Wn(i),[d,m]=Wn(a),[c,p]=Wn(e.exportBackground),[u,f]=Wn(e.exportWithDarkMode),[b,x]=Wn(e.exportEmbedScene),[w,E]=Wn(e.exportScale),y=Az(null),[v,I]=Wn(null),{onCopy:S,copyStatus:L,resetCopyStatus:k}=i5();l5(()=>{k()},[l,c,u,w,b,k]);let{exportedElements:R,exportingFrame:M}=dr(t,e,d);return l5(()=>{let _=y.current;if(!_)return;let N=_.offsetWidth,K=_.offsetHeight;N&&kn({elements:R,appState:{...e,name:l,exportBackground:c,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:o,exportPadding:Dz,maxWidthOrHeight:Math.max(N,K),exportingFrame:M}).then(J=>(I(null),Fo(J).then(()=>{_.replaceChildren(J)}).catch(A=>{throw A.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):A}))).catch(J=>{console.error(J),I(J)})},[e,o,R,M,l,c,u,w,b]),Vn("div",{className:"ImageExportModal",children:[Me("h3",{children:g("imageExportDialog.header")}),Vn("div",{className:"ImageExportModal__preview",children:[Me("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Me(Bz,{})}),Me("div",{className:"ImageExportModal__preview__filename",children:!_r&&Me("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:_=>{s(_.target.value),n.executeAction(Eu,"ui",_.target.value)}})})]}),Vn("div",{className:"ImageExportModal__settings",children:[Me("h3",{children:g("imageExportDialog.header")}),a&&Me($l,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Me(Zl,{name:"exportOnlySelected",checked:d,onChange:_=>{m(_)}})}),Me($l,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Me(Zl,{name:"exportBackgroundSwitch",checked:c,onChange:_=>{p(_),n.executeAction(yu,"ui",_)}})}),Nz&&Me($l,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Me(Zl,{name:"exportDarkModeSwitch",checked:u,onChange:_=>{f(_),n.executeAction(_E,"ui",_)}})}),Me($l,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Me(Zl,{name:"exportEmbedSwitch",checked:b,onChange:_=>{x(_),n.executeAction(Tc,"ui",_)}})}),Me($l,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Me(Zd,{name:"exportScale",value:w,onChange:_=>{E(_),n.executeAction(DE,"ui",_)},choices:Rz.map(_=>({value:_,label:`${_}\xD7`}))})}),Vn("div",{className:"ImageExportModal__settings__buttons",children:[Me(Fn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>r(kf.png,R,{exportingFrame:M}),icon:hp,children:g("imageExportDialog.button.exportToPng")}),Me(Fn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>r(kf.svg,R,{exportingFrame:M}),icon:hp,children:g("imageExportDialog.button.exportToSvg")}),(fi||_z)&&Me(Fn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await r(kf.clipboard,R,{exportingFrame:M}),S()},icon:Kr,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},$l=({label:e,children:t,tooltip:o,name:n})=>Vn("div",{className:"ImageExportModal__settings__setting",title:e,children:[Vn("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,o&&Me(_t,{label:o,long:!0,children:f0})]}),Me("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),c5=({elements:e,appState:t,files:o,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Wn(()=>({appStateSnapshot:s5(t),elementsSnapshot:s5(e)}));return Me(He,{onCloseRequest:i,size:"wide",title:!1,children:Me(Oz,{elementsSnapshot:s,appStateSnapshot:l,files:o,actionManager:n,onExportImage:r,name:a})})};import zz from"react";import{getFrame as Hz}from"@excalidraw/common";import Mf from"open-color";import{jsx as Fz}from"react/jsx-runtime";var Pf=({children:e,color:t})=>Fz("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":Mf[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":Mf[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":Mf[t][9]},children:e});import{Fragment as Uz,jsx as go,jsxs as vm}from"react/jsx-runtime";var Gz=({elements:e,appState:t,setAppState:o,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return go("div",{className:"ExportDialog ExportDialog--json",children:vm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&vm(Pf,{color:"lime",children:[go("div",{className:"Card-icon",children:Ib}),go("h2",{children:g("exportDialog.disk_title")}),vm("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!_r&&r.renderAction("changeProjectName")]}),go(V,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(al,"ui")}})]}),s&&vm(Pf,{color:"pink",children:[go("div",{className:"Card-icon",children:Aa}),go("h2",{children:g("exportDialog.link_title")}),go("div",{className:"Card-details",children:g("exportDialog.link_details")}),go(V,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ie("export","link",`ui (${Hz()})`),await s(e,t,n),l()}catch(d){o({errorMessage:d.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,n,a)]})})},d5=({elements:e,appState:t,files:o,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=zz.useCallback(()=>{a({openDialog:null})},[a]);return go(Uz,{children:t.openDialog?.name==="jsonExport"&&go(He,{onCloseRequest:l,title:g("buttons.export"),children:go(Gz,{elements:e,appState:t,setAppState:a,files:o,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import Yz from"clsx";import{jsx as m5,jsxs as Vz}from"react/jsx-runtime";var Wz="small",p5=e=>Vz("label",{className:Yz("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${Wz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[m5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),m5("div",{className:"ToolIcon__icon",children:hn})]});import{Fragment as g5,jsx as $,jsxs as zt}from"react/jsx-runtime";var eH=({UIOptions:e})=>zt(pt,{__fallback:!0,children:[$(pt.DefaultItems.LoadScene,{}),$(pt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&$(pt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&$(pt.DefaultItems.SaveAsImage,{}),$(pt.DefaultItems.SearchMenu,{}),$(pt.DefaultItems.Help,{}),$(pt.DefaultItems.ClearCanvas,{}),$(pt.Separator,{}),$(pt.Group,{title:"Excalidraw links",children:$(pt.DefaultItems.Socials,{})}),$(pt.Separator,{}),$(pt.DefaultItems.ToggleTheme,{}),$(pt.DefaultItems.ChangeCanvasBackground,{})]}),tH=()=>zt(Jd,{__fallback:!0,children:[$(Jd.Actions.SaveToDisk,{}),$(Jd.Actions.ExportToImage,{})]}),oH=({actionManager:e,appState:t,files:o,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:d,renderTopLeftUI:m,renderTopRightUI:c,renderCustomStats:p,UIOptions:u,onExportImage:f,renderWelcomeScreen:b,children:x,app:w,isCollaborating:E,generateLinkForSelection:y})=>{let v=he(),I=$w(),S=t.stylesPanelMode==="compact"?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},L=I.tunnelsJotai.Provider,[k,R]=de(bn),M=()=>u.canvasActions.export?$(d5,{elements:r,appState:t,files:o,actionManager:e,exportOpts:u.canvasActions.export,canvas:i,setAppState:n}):null,_=()=>!u.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:$(c5,{elements:r,appState:t,files:o,actionManager:e,onExportImage:f,onCloseRequest:()=>n({openDialog:null}),name:w.getName()}),N=()=>zt("div",{style:{position:"relative"},children:[$(I.MainMenuTunnel.Out,{}),b&&$(I.WelcomeScreenMenuHintTunnel.Out,{})]}),K=()=>{let Y=t.stylesPanelMode==="compact";return $(zl,{heading:"selectedShapeActions",className:Tr("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:Y?$(Ye,{className:Tr("compact-shape-actions-island"),padding:0,style:{maxHeight:`${t.height-166}px`},children:$(d2,{appState:t,elementsMap:w.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:w,setAppState:n})}):$(Ye,{className:Kz.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:$(i2,{appState:t,elementsMap:w.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:w})})})},J=()=>{let Y=Jz(t,r),q=t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector";return $(Yd,{side:"top",children:zt("div",{className:"App-menu App-menu_top",children:[zt(It.Col,{gap:S.menuTopGap,className:Tr("App-menu_top__left"),children:[N(),$("div",{className:Tr("selected-shape-actions-container",{"selected-shape-actions-container--compact":t.stylesPanelMode==="compact"}),children:Y&&K()})]}),!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&$(zl,{heading:"shapes",className:"shapes-section",children:pe=>zt("div",{style:{position:"relative"},children:[b&&$(I.WelcomeScreenToolbarHintTunnel.Out,{}),$(It.Col,{gap:S.toolbarColGap,align:"start",children:zt(It.Row,{gap:S.toolbarRowGap,className:Tr("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[zt(Ye,{padding:S.islandPadding,className:Tr("App-toolbar",{"zen-mode":t.zenModeEnabled,"App-toolbar--compact":t.stylesPanelMode==="compact"}),children:[$(r5,{appState:t,isMobile:v.editor.isMobile,device:v,app:w}),pe,zt(It.Row,{gap:S.toolbarInnerRowGap,children:[$(Y3,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:t.penDetected}),$(_3,{checked:t.activeTool.locked,onChange:a,title:g("toolBar.lock")}),$("div",{className:"App-toolbar__divider"}),$(Gd,{checked:no(t),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),$(p2,{setAppState:n,activeTool:t.activeTool,UIOptions:u,app:w})]})]}),E&&$(Ye,{style:{marginLeft:S.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:$(p5,{title:g("toolBar.laser"),checked:t.activeTool.type===u5.laser,onChange:()=>w.setActiveTool({type:u5.laser}),isMobile:!0})})]})})]})}),zt("div",{className:Tr("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled,"layer-ui__wrapper__top-right--compact":t.stylesPanelMode==="compact"}),children:[t.collaborators.size>0&&$(Xd,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),c?.(v.editor.isMobile,t),!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&(!B||t.openSidebar?.name!==Lf.name)&&$(I.DefaultSidebarTriggerTunnel.Out,{}),q&&$(Kl,{app:w,onClose:()=>{e.executeAction(Si)},renderCustomStats:p})]})]})})},A=()=>$(tm,{__fallback:!0,onDock:Y=>{ie("sidebar",`toggleDock (${Y?"dock":"undock"})`,`(${v.editor.isMobile?"mobile":"desktop"})`)}}),B=ys(Hl),H=zt(g5,{children:[x,$(eH,{UIOptions:u}),$(tm.Trigger,{__fallback:!0,icon:Fr,title:jz(g("toolBar.library")),onToggle:Y=>{Y&&ie("sidebar",`${Lf.name} (open)`,`button (${v.editor.isMobile?"mobile":"desktop"})`)},tab:Lf.defaultTab,children:t.stylesPanelMode==="full"&&t.width>=Zz&&g("toolBar.library")}),$(tH,{}),t.openDialog?.name==="ttd"&&$(af,{__fallback:!0}),t.isLoading&&$(Hd,{delay:250}),t.errorMessage&&$(jI,{onClose:()=>n({errorMessage:null}),children:t.errorMessage}),k&&!v.editor.isMobile&&$(ox,{colorPickerType:k.colorPickerType,onCancel:()=>{R(null)},onChange:(Y,q,pe,{altKey:j})=>{if(!(Y!=="elementBackground"&&Y!=="elementStroke"))if(pe.length){for(let ne of pe)qz(ne,$z(r),{[j&&k.swapPreviewOnAlt?Y==="elementBackground"?"strokeColor":"backgroundColor":Y==="elementBackground"?"backgroundColor":"strokeColor"]:q}),Qz.delete(ne);w.scene.triggerUpdate()}else n(Y==="elementBackground"?{currentItemBackgroundColor:q}:{currentItemStrokeColor:q})},onSelect:(Y,q)=>{R(pe=>pe?.keepOpenOnAlt&&q.altKey?pe:null),k?.onSelect?.(Y,q)}}),t.openDialog?.name==="help"&&$(QI,{onClose:()=>{n({openDialog:null})}}),$(f2,{}),t.openDialog?.name==="elementLinkSelector"&&$($I,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:w.scene,appState:t,generateLinkForSelection:y}),$(I.OverwriteConfirmDialogTunnel.Out,{}),_(),M(),t.pasteDialog.shown&&$(z3,{setAppState:n,appState:t,onClose:()=>n({pasteDialog:{shown:!1,data:null}})}),v.editor.isMobile&&$(O3,{app:w,appState:t,elements:r,actionManager:e,renderJSONExportDialog:M,renderImageExportDialog:_,setAppState:n,onHandToolToggle:l,onPenModeToggle:s,renderTopLeftUI:m,renderTopRightUI:c,renderSidebars:A,renderWelcomeScreen:b,UIOptions:u}),!v.editor.isMobile&&zt(g5,{children:[zt("div",{className:"layer-ui__wrapper",style:t.openSidebar&&B&&v.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[b&&$(I.WelcomeScreenCenterTunnel.Out,{}),J(),$(X3,{appState:t,actionManager:e,showExitZenModeBtn:d,renderWelcomeScreen:b}),t.scrolledOutside&&$("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(Y=>({...Qn(r,Y)}))},children:g("buttons.scrollBackToContent")})]}),A()]})]});return $(Pp.Provider,{value:t,children:$(L,{children:$(Ph.Provider,{value:I,children:H})})})},h5=e=>{let{suggestedBindings:t,startBoundElement:o,cursorButton:n,scrollX:r,scrollY:i,...a}=e;return a},nH=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:o,appState:n,...r}=e,{canvas:i,appState:a,...l}=t;return Tm(h5(n),h5(a),{selectedElementIds:Tm,selectedGroupIds:Tm})&&Tm(r,l)},f5=Xz.memo(oH,nH);import rH from"clsx";import{jsx as b5,jsxs as aH}from"react/jsx-runtime";var iH="small",Im=e=>aH("label",{className:rH("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${iH}`,{"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 lH,useRef as sH}from"react";import{jsx as x5}from"react/jsx-runtime";var E5=({trails:e})=>{let t=sH(null);return lH(()=>{if(t.current)for(let o of e)o.start(t.current);return()=>{for(let o of e)o.stop()}},e),x5("div",{className:"SVGLayer",children:x5("svg",{ref:t})})};import cH,{useEffect as dH,useRef as mH}from"react";import{CURSOR_TYPE as y5,isShallowEqual as pH,sceneCoordsToViewportCoords as uH}from"@excalidraw/common";import{jsx as fH}from"react/jsx-runtime";var hH=e=>{let t=mH(!1);return dH(()=>{if(!t.current){t.current=!0;return}let o=new Map,n=new Map,r=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,d)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))r.has(m)||r.set(m,[]),r.get(m).push(d);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(d,s.username),s.userState&&a.set(d,s.userState),n.set(d,uH({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),o.set(d,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";$v({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:o,remoteSelectedElementIds:r,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Qi())}),fH("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?y5.GRAB:y5.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")})},w5=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}),gH=(e,t)=>e.selectionNonce!==t.selectionNonce||e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements||e.renderScrollbars!==t.renderScrollbars?!1:pH(w5(e.appState),w5(t.appState)),Af=cH.memo(hH,gH);import bH,{useEffect as v5,useRef as T5}from"react";import{isShallowEqual as I5}from"@excalidraw/common";import{jsx as yH}from"react/jsx-runtime";var xH=e=>{let t=T5(null),o=T5(!1);return v5(()=>{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]),v5(()=>{let n=t.current;if(!n)return;let r=e.canvas;o.current||(o.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static")),G1({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Qi())}),yH("div",{className:"excalidraw__canvas-wrapper",ref:t})},C5=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}),EH=(e,t)=>e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:I5(C5(e.appState),C5(t.appState))&&I5(e.renderConfig,t.renderConfig),Df=bH.memo(xH,EH);import{useEffect as kH,useRef as MH}from"react";import{throttleRAF as wH}from"@excalidraw/common";import{getTargetFrame as vH,isInvisiblySmallElement as TH,renderElement as IH,shouldApplyFrameClip as CH}from"@excalidraw/element";var S5=({canvas:e,rc:t,newElement:o,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,d]=hs(e,i),m=gs({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:d});if(m.save(),m.scale(a.zoom.value,a.zoom.value),o&&o.type!=="selection"){if(TH(o))return;if((o.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=vH(o,n,a);p&&CH(o,p,a,n)&&z1(p,m,l,a)}IH(o,n,r,t,m,l,a)}else m.clearRect(0,0,s,d);m.restore()}},SH=wH(e=>{S5(e)},{trailing:!0}),k5=(e,t)=>{if(t){SH(e);return}S5(e)};import{jsx as LH}from"react/jsx-runtime";var PH=e=>{let t=MH(null);return kH(()=>{t.current&&k5({canvas:t.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Qi())}),LH("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:t})},M5=PH;import{useCallback as AH,useEffect as DH,useRef as _H}from"react";import{jsx as P5,jsxs as NH}from"react/jsx-runtime";var RH=5e3,L5=({message:e,onClose:t,closable:o=!1,duration:n=RH,style:r})=>{let i=_H(0),a=n!==1/0,l=AH(()=>{a&&(i.current=window.setTimeout(()=>t(),n))},[t,n,a]);return DH(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),NH("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[P5("p",{className:"Toast__message",children:e}),o&&P5(V,{icon:Ht,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})};import{getCommonBounds as BH,getElementsInGroup as OH,selectGroupsFromGivenElements as FH}from"@excalidraw/element";import{sceneCoordsToViewportCoords as zH}from"@excalidraw/common";import{flushSync as HH}from"react-dom";import{jsx as UH}from"react/jsx-runtime";var GH=({app:e,activeLockedId:t})=>{let o=e.scene.getElement(t),n=o?[o]:OH(e.scene.getNonDeletedElementsMap(),t);if(n.length===0)return null;let[r,i]=BH(n),{x:a,y:l}=zH({sceneX:r,sceneY:i},e.state);return UH("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{HH(()=>{let s=FH(n,e.state);e.setState({selectedElementIds:n.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(ml)},title:g("labels.elementLock.unlock"),children:cb})},A5=GH;import{Fragment as zU,jsx as be,jsxs as _m}from"react/jsx-runtime";var DC=Oo.createContext(null),_C=Oo.createContext(null),RC={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},m1=Oo.createContext(RC);m1.displayName="DeviceContext";var p1=Oo.createContext({container:null,id:null});p1.displayName="ExcalidrawContainerContext";var u1=Oo.createContext([]);u1.displayName="ExcalidrawElementsContext";var h1=Oo.createContext({...mn(),width:0,height:0,offsetLeft:0,offsetTop:0});h1.displayName="ExcalidrawAppStateContext";var g1=Oo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});g1.displayName="ExcalidrawSetAppStateContext";var f1=Oo.createContext(null);f1.displayName="ExcalidrawActionManagerContext";var Fe=()=>qn(DC),To=()=>qn(_C),he=()=>qn(m1),Be=()=>qn(p1),xn=()=>qn(u1),vo=()=>qn(h1),me=()=>qn(g1),Ve=()=>qn(f1),ns=!1,i1=0,rs=null,Mr=!1,is=!1,a1=!1,as={horizontal:null,vertical:null},jn=0,ls=!1,l1=new Map,s1=!1,MC=0,PC=!1,ss=null,fe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},d1=class e extends Oo.Component{constructor(o){super(o);C(this,"canvas");C(this,"interactiveCanvas",null);C(this,"rc");C(this,"unmounted",!1);C(this,"actionManager");C(this,"device",RC);C(this,"excalidrawContainerRef",Oo.createRef());C(this,"scene");C(this,"fonts");C(this,"renderer");C(this,"visibleElements");C(this,"resizeObserver");C(this,"nearestScrollableContainer");C(this,"library");C(this,"libraryItemsFromStorage");C(this,"id");C(this,"store");C(this,"history");C(this,"excalidrawContainerValue");C(this,"files",{});C(this,"imageCache",new Map);C(this,"iFrameRefs",new Map);C(this,"embedsValidationStatus",new Map);C(this,"initializedEmbeds",new Set);C(this,"handleToastClose",()=>{this.setToast(null)});C(this,"elementsPendingErasure",new Set);C(this,"flowChartCreator",new pU);C(this,"flowChartNavigator",new uU);C(this,"hitLinkElement");C(this,"lastPointerDownEvent",null);C(this,"lastPointerUpEvent",null);C(this,"lastPointerMoveEvent",null);C(this,"lastPointerMoveCoords",null);C(this,"lastViewportPosition",{x:0,y:0});C(this,"animationFrameHandler",new Sd);C(this,"laserTrails",new Nd(this.animationFrameHandler,this));C(this,"eraserTrail",new zd(this.animationFrameHandler,this));C(this,"lassoTrail",new Fd(this.animationFrameHandler,this));C(this,"onChangeEmitter",new Cr);C(this,"onPointerDownEmitter",new Cr);C(this,"onPointerUpEmitter",new Cr);C(this,"onUserFollowEmitter",new Cr);C(this,"onScrollChangeEmitter",new Cr);C(this,"missingPointerEventCleanupEmitter",new Cr);C(this,"onRemoveEventListenersEmitter",new Cr);C(this,"updateEditorAtom",(o,...n)=>{let r=We.set(o,...n);return this.triggerRender(),r});C(this,"getEffectiveGridSize",()=>_n(this)?this.state.gridSize:null);C(this,"updateEmbedValidationStatus",(o,n)=>{this.embedsValidationStatus.set(o.id,n),os.delete(o)});C(this,"updateEmbeddables",()=>{let o=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(an(r)){if(o.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=qf(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else fa(r)&&o.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{o.has(i)||this.iFrameRefs.delete(i)})});C(this,"getFrameNameDOMId",o=>`${this.id}-frame-name-${o.id}`);C(this,"frameNameBoundsCache",{get:o=>{let n=this.frameNameBoundsCache._cache.get(o.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==o.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(o));if(r){let i=r.getBoundingClientRect(),a=Ue({clientX:i.x,clientY:i.y},this.state),l=Ue({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:o.versionNonce},this.frameNameBoundsCache._cache.set(o.id,n),n}return null}return n},_cache:new Map});C(this,"resetEditingFrame",o=>{o&&this.scene.mutateElement(o,{name:o.name?.trim()||null}),this.setState({editingFrame:null})});C(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let o=this.state.theme===km.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Mt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!lC(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}=Pm({sceneX:i.x,sceneY:i.y},this.state),s=6,d,m=aU(i);if(i.id===this.state.editingFrame){let c=m;d=be("input",{autoFocus:!0,value:c,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===W.ESCAPE||p.key===W.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:o?iG:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Kn.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else d=m;return be("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Kn.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Kn.nameFontSize,color:o?Kn.nameColorDarkTheme:Kn.nameColorLightTheme,lineHeight:Kn.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:Re.MOVE,pointerEvents:this.state.viewModeEnabled?pa.disabled:pa.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:d},i.id)})});C(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});C(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());C(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());C(this,"getSceneElements",()=>this.scene.getNonDeletedElements());C(this,"onInsertElements",o=>{this.addElementsFromPasteOrLibrary({elements:o,position:"center",files:null})});C(this,"onExportImage",async(o,n,r)=>{ie("export",o,"ui");let i=await mr(o,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(wG).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&bs(i)&&this.setState({fileHandle:i})});C(this,"magicGenerations",new Map);C(this,"updateMagicGeneration",({frameElement:o,data:n})=>{n.status==="pending"?this.scene.mutateElement(o,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(o,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(o.id,n),this.triggerRender()});C(this,"plugins",{});C(this,"onMagicframeToolSelect",()=>{let o=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(o.length===0)this.setActiveTool({type:Bo.magicframe}),ie("ai","tool-select (empty-selection)","d2c");else{let n=o.length===1&&$f(o[0])&&o[0];if(!n&&o.some(i=>Mt(i)||i.frameId)){this.setActiveTool({type:Bo.magicframe});return}ie("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=ga(o),d=50;r=eC({...Kn,x:i-d,y:a-d,width:l-i+d*2,height:s-a+d*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let m of o)this.scene.mutateElement(m,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});C(this,"openEyeDropper",({type:o})=>{this.updateEditorAtom(bn,{swapPreviewOnAlt:!0,colorPickerType:o==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=o==="background"&&r.altKey||o==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:wt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:wt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?$n(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:wt.IMMEDIATELY})},keepOpenOnAlt:!1})});C(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});C(this,"syncActionResult",De(o=>{if(this.unmounted||o===!1)return;this.store.scheduleAction(o.captureUpdate);let n=!1,r=null;if(o.elements&&(this.scene.replaceAllElements(o.elements),n=!0),o.files&&(this.addMissingFiles(o.files,o.replaceFiles),this.addNewImagesToImageCache()),o.appState||r||this.state.contextMenu){let i=o?.appState?.viewModeEnabled||!1,a=o?.appState?.zenModeEnabled||!1,l=o?.appState?.theme||this.props.theme||km.LIGHT,s=o?.appState?.name??this.state.name,d=o?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=o.appState?.editingTextElement||null,o.elements&&r&&o.elements.forEach(m=>{r?.id===m.id&&r!==m&&IC(m)&&fo(m)&&(r=m)}),r?.isDeleted&&(r=null),this.setState(m=>{let c=o.appState||{};return{...m,...c,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:d}}),n=!0}n||this.scene.triggerUpdate()}));C(this,"onBlur",De(()=>{Mr=!1,this.setState({isBindingEnabled:!0})}));C(this,"onUnload",()=>{this.onBlur()});C(this,"disableEvent",o=>{o.preventDefault()});C(this,"resetHistory",()=>{this.history.clear()});C(this,"resetStore",()=>{this.store.clear()});C(this,"resetScene",De(o=>{this.scene.replaceAllElements([]),this.setState(n=>({...mn(),isLoading:o?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));C(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 o=null;try{typeof this.props.initialData=="function"?o=await this.props.initialData()||null:o=await this.props.initialData||null,o?.libraryItems&&this.library.updateLibrary({libraryItems:o.libraryItems,merge:!0}).catch(i=>{console.error(i)})}catch(i){console.error(i),o={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let n=Nr(o,null,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=n.appState.activeTool;n.appState.preferredSelectionTool.initialized||(n.appState.preferredSelectionTool={type:this.device.editor.isMobile?"lasso":"selection",initialized:!0}),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:n.appState.preferredSelectionTool.type}:n.appState.activeTool,isLoading:!1,toast:this.state.toast},o?.scrollToContent&&(n.appState={...n.appState,...Qn(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:wt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),r1(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});C(this,"isMobileBreakpoint",(o,n)=>o<=MG||n<AG&&o<DG);C(this,"isTabletBreakpoint",(o,n)=>{let r=Math.min(o,n),i=Math.max(o,n);return r>=PG&&i<=LG});C(this,"refreshViewportBreakpoints",()=>{let o=this.excalidrawContainerRef.current;if(!o)return;let{width:n,height:r}=o.getBoundingClientRect(),i=this.device.viewport,a=Hf(i,{isLandscape:n>r,isMobile:this.isMobileBreakpoint(n,r)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});C(this,"refreshEditorBreakpoints",()=>{let o=this.excalidrawContainerRef.current;if(!o)return;let{width:n,height:r}=o.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:tG,a=this.device.editor,l=Hf(a,{isMobile:this.isMobileBreakpoint(n,r),canFitSidebar:n>i}),s=this.isTabletBreakpoint(n,r)&&ha()?"compact":this.isMobileBreakpoint(n,r)?"mobile":"full";return this.setState(d=>({stylesPanelMode:s,preferredSelectionTool:s==="full"?{type:"selection",initialized:!0}:d.preferredSelectionTool})),a!==l?(this.device={...this.device,editor:l},!0):!1});C(this,"onResize",De(()=>{this.scene.getElementsIncludingDeleted().forEach(o=>os.delete(o)),this.refreshViewportBreakpoints(),this.updateDOMRect(),Y5||this.refreshEditorBreakpoints(),this.setState({})}));C(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});C(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:o,scrollBars:n,elementsMap:r})=>{n&&(as=n);let i=this.state.editingTextElement?!1:!o&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});C(this,"onScroll",X5(()=>{let{offsetTop:o,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===o?null:{offsetTop:o,offsetLeft:n})},oG));C(this,"onCut",De(o=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ql(o.target)||(this.actionManager.executeAction(Dc,"keyboard",o),o.preventDefault(),o.stopPropagation())}));C(this,"onCopy",De(o=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ql(o.target)||(this.actionManager.executeAction(Ii,"keyboard",o),o.preventDefault(),o.stopPropagation())}));C(this,"onTouchStart",o=>{if(cG&&o.preventDefault(),!ns){ns=!0,o.touches.length===1&&(rs={x:o.touches[0].clientX,y:o.touches[0].clientY}),clearTimeout(i1),i1=window.setTimeout(e.resetTapTwice,nG);return}if(ns&&o.touches.length===1&&rs){let n=o.touches[0];Xn(se(n.clientX,n.clientY),se(rs.x,rs.y))<=kG&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),ns=!1,clearTimeout(i1)}o.touches.length===2&&this.setState({selectedElementIds:Te({},this.state),activeEmbeddable:null})});C(this,"onTouchEnd",o=>{this.resetContextMenuTimer(),o.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Te(this.state.previousSelectedElementIds,this.state)}):fe.pointers.clear()});C(this,"pasteFromClipboard",De(async o=>{let n=!!s1,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(o&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(o&&(!(a instanceof HTMLCanvasElement)||ql(r)))return;let l=await il(o),s=l.getFiles(),d=await PE(l,n);if(this.props.onPaste)try{if(await this.props.onPaste(d,o)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(d,s,n),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),o?.preventDefault()}));C(this,"addElementsFromPasteOrLibrary",o=>{let n=Ym(o.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=ga(n),s=ua(r,a)/2,d=ua(i,l)/2,m=typeof o.position=="object"?o.position.clientX:o.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,c=typeof o.position=="object"?o.position.clientY:o.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Ue({clientX:m,clientY:c},this.state),f=p-s,b=u-d,[x,w]=lt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=Vf({type:"everything",elements:n.map(k=>$n(k,{x:k.x+x-r,y:k.y+w-i})),randomizeSeed:!o.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,EC(v,Lm(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let k=sU(E,S);t1(v,k,S,this.state)}this.scene.replaceAllElements(v),E.forEach(k=>{if(fo(k)&&Zf(k)){let R=pC(k,this.scene.getElementsMapIncludingDeleted());eU(k,R,this.scene)}}),pG&&dn.loadElementsFonts(E).then(k=>{this.fonts.onLoaded(k)}),o.files&&this.addMissingFiles(o.files);let L=MU(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&We.get(Hl)?this.state.openSidebar:null,...eo({editingGroupId:null,selectedElementIds:L.reduce((k,R)=>(Zf(R)||(k[R.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{o.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),o.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});C(this,"setAppState",(o,n)=>{this.setState(o,n)});C(this,"removePointer",o=>{jn&&this.resetContextMenuTimer(),fe.pointers.delete(o.pointerId)});C(this,"toggleLock",(o="ui")=>{this.state.activeTool.locked||ie("toolbar","toggleLock",`${o} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...rn(this.state,n.activeTool.locked?{type:this.state.preferredSelectionTool.type}:n.activeTool),locked:!n.activeTool.locked}}))});C(this,"updateFrameRendering",o=>{this.setState(n=>{let r=typeof o=="function"?o(n.frameRendering):o;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}}})});C(this,"togglePenMode",o=>{this.setState(n=>({penMode:o??!n.penMode,penDetected:!0}))});C(this,"onHandToolToggle",()=>{this.actionManager.executeAction(nE)});C(this,"zoomCanvas",o=>{this.setState({...Yo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:bo(o)},this.state)})});C(this,"cancelInProgressAnimation",null);C(this,"scrollToContent",(o=this.scene.getNonDeletedElements(),n)=>{if(typeof o=="string"){let s;if(r1(o)?s=fU(o):s=o,s){let d=this.scene.getElementsFromId(s);d?.length?this.scrollToContent(d,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):r1(o)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(o)?o:[o],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=qa({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=Qn(r,this.state);a=s.scrollX,l=s.scrollY}if(n?.animate){let s=this.state.scrollX,d=this.state.scrollY,m=this.state.zoom.value,c=yG({fromValues:{scrollX:s,scrollY:d,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,vG(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=()=>{c(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});C(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});C(this,"translateCanvas",o=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(o)});C(this,"setToast",o=>{this.setState({toast:o})});C(this,"restoreFileFromShare",async()=>{try{let o=await caches.open("web-share-target"),n=await o.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await o.delete("shared-file"),window.history.replaceState(null,ZH,window.location.pathname)}}catch(o){this.setState({errorMessage:o.message})}});C(this,"addFiles",De(o=>{let{addedFiles:n}=this.addMissingFiles(o);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));C(this,"addMissingFiles",(o,n=!1)=>{let r=n?{}:{...this.files},i={},a=Array.isArray(o)?o:Object.values(o);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===No.svg))try{let s=$1(mC(j1(l.dataURL)),No.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});C(this,"updateScene",De(o=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=o;if(a){let l=n||void 0,s=r?_G({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}r&&this.setState({...r,stylesPanelMode:this.state.stylesPanelMode}),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));C(this,"applyDeltas",(o,n)=>{let r=SC.squash(...o),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return SC.applyTo(r,a,i,n)});C(this,"mutateElement",(o,n,r=!0)=>this.scene.mutateElement(o,n,{informMutation:r,isDragging:!1}));C(this,"triggerRender",o=>{o===!0?this.scene.triggerUpdate():this.setState({})});C(this,"toggleSidebar",({name:o,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===o&&this.state.openSidebar?.tab===n?null:o:i=r?o:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});C(this,"updateCurrentCursorPosition",De(o=>{this.lastViewportPosition.x=o.clientX,this.lastViewportPosition.y=o.clientY}));C(this,"getEditorUIOffsets",()=>{let o=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 zo().rtl?{top:o+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:o+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});C(this,"onKeyDown",De(o=>{if("Proxy"in window&&(!o.shiftKey&&/^[A-Z]$/.test(o.key)||o.shiftKey&&/^[a-z]$/.test(o.key))&&(o=new Proxy(o,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?o.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!K5(o.target)){if((o.key===W.ESCAPE||o.key===W.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=Q(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&Sr(a[0])&&o.key===W.ENTER){this.startImageCropping(a[0]);return}if(o.key===W.ESCAPE)this.updateEditorAtom(po,null);else if(o.key===W.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(SG.CONVERT_ELEMENT_TYPE_POPUP))){o.preventDefault();let s=Di(a);We.get(po)?.type==="panel"&&ih(this,{conversionType:s,direction:o.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(po,{type:"panel"})}if(o.key===W.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Cm(o.key);if(o[W.CTRL_OR_CMD]&&l&&!o.shiftKey){o.preventDefault();let s=Q(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&XG(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,fC(o.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!jf(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(o.altKey){let s=Q(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){o.preventDefault();let d=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),fC(o.key));if(d){this.setState(c=>({selectedElementIds:Te({[d]:!0},c)}));let m=this.scene.getNonDeletedElementsMap().get(d);m&&!jf([m],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(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(o[W.CTRL_OR_CMD]&&o.key===W.P&&!o.shiftKey&&!o.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:ze("commandPalette")})}),o.preventDefault();return}if(o[W.CTRL_OR_CMD]&&o.key.toLowerCase()===W.V&&(s1=o.shiftKey,clearTimeout(MC),MC=window.setTimeout(()=>{s1=!1},100)),o[W.CTRL_OR_CMD]&&ql(o.target)&&(o.code===F5.MINUS||o.code===F5.EQUAL)){o.preventDefault();return}if(ql(o.target)&&o.key!==W.ESCAPE||Cm(o.key)&&K5(o.target))return;if(o.key===W.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(o.key.toLowerCase()===W.E&&o.shiftKey&&o[W.CTRL_OR_CMD]){o.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(o.key===W.PAGE_UP||o.key===W.PAGE_DOWN){let a=(o.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;o.key===W.PAGE_DOWN&&(a=-a),o.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(o)||this.state.viewModeEnabled)return;if(o[W.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Cm(o.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find($e),s=new Set;a.filter($e).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 d=this.getEffectiveGridSize()&&(o.shiftKey?G5:this.getEffectiveGridSize())||(o.shiftKey?qH:G5),m=0,c=0;o.key===W.ARROW_LEFT?m=-d:o.key===W.ARROW_RIGHT?m=d:o.key===W.ARROW_UP?c=-d:o.key===W.ARROW_DOWN&&(c=d),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+m,y:p.y+c},{informMutation:!1,isDragging:!1}),Yf(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:Wf(a.filter(p=>p.id!==l?.id||d!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),o.preventDefault()}else if(o.key===W.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(o[W.CTRL_OR_CMD]||Dm(l))Qt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),$e(l)||this.actionManager.executeAction($i));else if(fo(l)||QG(l)){let s;fo(l)||(s=l);let d=Qf(l,this.state,this.scene.getNonDeletedElementsMap()),m=d.x,c=d.y;this.startTextEditing({sceneX:m,sceneY:c,container:s}),o.preventDefault();return}else Mt(l)&&this.setState({editingFrame:l.id})}}else if(!o.ctrlKey&&!o.altKey&&!o.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=Zw(o.key,this);a?(this.state.activeTool.type!==a&&ie("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Zn.sharp?Zn.round:l.currentItemArrowType===Zn.round?Zn.elbow:Zn.sharp})),this.setActiveTool({type:a}),o.stopPropagation()):o.key===W.Q&&(this.toggleLock("keyboard"),o.stopPropagation())}if(o.key===W.SPACE&&fe.pointers.size===0&&(Mr=!0,ye(this.interactiveCanvas,Re.GRAB),o.preventDefault()),(o.key===W.G||o.key===W.S)&&!o.altKey&&!o[W.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;o.key===W.G&&(xo(this.state.activeTool.type)||a.some(l=>xo(l.type)))&&(this.setState({openPopup:"elementBackground"}),o.stopPropagation()),o.key===W.S&&(this.setState({openPopup:"elementStroke"}),o.stopPropagation())}if(!o[W.CTRL_OR_CMD]&&o.shiftKey&&o.key.toLowerCase()===W.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=>fo(l)||Jf(l,this.scene.getNonDeletedElementsMap())))&&(o.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(o.key===W.K&&!o.altKey&&!o[W.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:"laser"});return}o[W.CTRL_OR_CMD]&&(o.key===W.BACKSPACE||o.key===W.DELETE)&&this.updateEditorAtom(br,"clearCanvas");let n=o.key.toLocaleLowerCase(),r=n===W.S&&o.shiftKey,i=o.key===W.I||n===W.G&&o.shiftKey;(r||i)&&this.openEyeDropper({type:r?"stroke":"background"})}));C(this,"onKeyUp",De(o=>{if(o.key===W.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,Re.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Wt(this.interactiveCanvas):(Rt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Mr=!1),!o[W.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Cm(o.key)&&(J5(this.scene.getSelectedElements(this.state).filter(Qt),Uf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),o.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:wt.IMMEDIATELY})),!o[W.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:Te({[n.id]:!0},r)})),jf([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:wt.IMMEDIATELY})}}));C(this,"isToolSupported",o=>this.props.UIOptions.tools?.[o]!==!1);C(this,"setActiveTool",(o,n=!1)=>{if(!this.isToolSupported(o.type)){console.warn(`"${o.type}" tool is disabled via "UIOptions.canvasActions.tools.${o.type}"`);return}let r=rn(this.state,o);r.type==="hand"?ye(this.interactiveCanvas,Re.GRAB):Mr||Rt(this.interactiveCanvas,{...this.state,activeTool:r}),fG(document.activeElement)&&this.focusContainer(),WG(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:Te({},i),selectedGroupIds:Te({},i),editingGroupId:null,multiElement:null},...a}:r.type!=="selection"?{...i,activeTool:r,selectedElementIds:Te({},i),selectedGroupIds:Te({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:r,...a}})});C(this,"setOpenDialog",o=>{this.setState({openDialog:o})});C(this,"setCursor",o=>{ye(this.interactiveCanvas,o)});C(this,"resetCursor",()=>{Wt(this.interactiveCanvas)});C(this,"isTouchScreenMultiTouchGesture",()=>fe.pointers.size>=2);C(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${Z5()}`);C(this,"onGestureStart",De(o=>{o.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Te({},this.state),activeEmbeddable:null}),fe.initialScale=this.state.zoom.value}));C(this,"onGestureChange",De(o=>{if(o.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=fe.initialScale;n&&this.setState(r=>({...Yo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:bo(n*o.scale)},r)}))}));C(this,"onGestureEnd",De(o=>{o.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Te(this.state.previousSelectedElementIds,this.state)}),fe.initialScale=null}));C(this,"startTextEditing",({sceneX:o,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(o,n,this.state,i);i&&s&&(Jf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let d=null,m=this.scene.getSelectedElements(this.state);m.length===1?fo(m[0])?d=m[0]:i?d=Jf(m[0],this.scene.getNonDeletedElementsMap()):d=this.getTextElementAtPosition(o,n):d=this.getTextElementAtPosition(o,n);let c=d?.fontFamily||this.state.currentItemFontFamily,p=d?.lineHeight||V5(c),u=this.state.currentItemFontSize;if(!d&&l&&i&&!Xf(i)){let w=yU(Ff({fontSize:u,fontFamily:c}),p),E=wU(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),o=i.x+v/2,n=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(o,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:o,y:n}),b=d||tC({x:s?s.elementCenterX:o,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:c,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?lG.MIDDLE:H5,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?Xf(i)?0:i.angle:0,frameId:f?f.id:null});if(!d&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!d)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||d||i?this.handleTextWysiwyg(b,{isExistingElement:!!d}):this.setState({newElement:b,multiElement:null})});C(this,"startImageCropping",o=>{this.store.scheduleCapture(),this.setState({croppingElementId:o.id})});C(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});C(this,"handleCanvasDoubleClick",o=>{if(this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=Ue(o,this.state);if(n.length===1&&Qt(n[0])){let l=n[0];if((o[W.CTRL_OR_CMD]&&OU(l)||Dm(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction($i);return}else if(this.state.selectedLinearElement&&$e(n[0])){let s=Se.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=s?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),Se.deleteFixedSegment(n[0],this.scene,d);let m=Se.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=m?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:c,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&Dm(l))return}if(n.length===1&&Sr(n[0])){this.startImageCropping(n[0]);return}if(Wt(this.interactiveCanvas),SU(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&CU(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(d=>({...d,...eo({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(Wt(this.interactiveCanvas),!o[W.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(es(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(nC(s)||!EG(s.backgroundColor)||ts({point:se(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let d=Qf(s,this.state,this.scene.getNonDeletedElementsMap());r=d.x,i=d.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!o.altKey,container:s})}}});C(this,"getElementLinkAtPosition",(o,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&&us(l,this.scene.getNonDeletedElementsMap(),this.state,se(o.x,o.y),this.device.editor.isMobile))return l}});C(this,"redirectToLink",(o,n)=>{let r=Xn(se(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),se(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>jH)return;let i=Ue(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=us(this.hitLinkElement,a,this.state,se(i.x,i.y),this.device.editor.isMobile),s=Ue(this.lastPointerUpEvent,this.state),d=us(this.hitLinkElement,a,this.state,se(s.x,s.y),this.device.editor.isMobile);if(l&&d){Zu();let m=this.hitLinkElement.link;if(m){m=Of(m);let c;if(this.props.onLinkOpen&&(c=bG(oe.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},c)),!c?.defaultPrevented){let p=uG(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});C(this,"getTopLayerFrameAtSceneCoords",o=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&uC(o,i,n));return r.length?r[r.length-1]:null});C(this,"handleCanvasPointerMove",o=>{this.savePointer(o.clientX,o.clientY,this.state.cursorButton),this.lastPointerMoveEvent=o.nativeEvent,fe.pointers.has(o.pointerId)&&fe.pointers.set(o.pointerId,{x:o.clientX,y:o.clientY});let n=fe.initialScale;if(fe.pointers.size===2&&fe.lastCenter&&n&&fe.initialDistance){let f=rg(fe.pointers),b=f.x-fe.lastCenter.x,x=f.y-fe.lastCenter.y;fe.lastCenter=f;let w=ig(Array.from(fe.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/fe.initialDistance,y=E?bo(n*E):this.state.zoom.value;this.setState(v=>{let I=Yo({viewportX:f.x,viewportY:f.y,nextZoom:y},v);this.translateCanvas({zoom:I.zoom,scrollX:I.scrollX+2*(b/y),scrollY:I.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else fe.lastCenter=fe.initialDistance=fe.initialScale=null;if(Mr||is||a1||no(this.state))return;let i=ug(as,o.clientX-this.state.offsetLeft,o.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Wt(this.interactiveCanvas):Rt(this.interactiveCanvas,this.state));let a=Ue(o,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Mv(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=kv(this.scene.getNonDeletedElements(),this,{x:l,y:s},o,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=Jl(x.snapLines,b),E=x.originSnapOffset?Jl(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(o,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&ma(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&rC(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(rC(this.state.activeTool.type)){let{newElement:f}=this.state;Kf(f,!1)?this.setState({suggestedBindings:j5(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(Rt(this.interactiveCanvas,this.state),y===E)Xn(se(l-b,s-x),y)>=Bf?this.scene.mutateElement(f,{points:[...w,se(l-b,s-x)]},{informMutation:!1,isDragging:!1}):ye(this.interactiveCanvas,Re.POINTER);else if(w.length>2&&E&&Xn(se(l-b,s-x),E)<Bf)ye(this.interactiveCanvas,Re.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,I]=lt(l,s,o[W.CTRL_OR_CMD]||$e(f)?null:this.getEffectiveGridSize()),[S,L]=f?.lastCommittedPoint??[0,0],k=v-b-S,R=I-x-L;Nf(o)&&({width:k,height:R}=aC(S+b,L+x,v,I)),cC(w,this.state.zoom.value)&&ye(this.interactiveCanvas,Re.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),se(S+k,L+R)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!o.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),c=this.scene.getSelectedElements(this.state);if(c.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"&&!(c.length===1&&$e(c[0]))){let f=wC(m,this.state,l,s,this.state.zoom,o.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){ye(this.interactiveCanvas,yC(f));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=vC(ga(c),l,s,this.state.zoom,o.pointerType,this.device);if(f){ye(this.interactiveCanvas,yC({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),!vt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(ye(this.interactiveCanvas,Re.POINTER),Sy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Zu(),u&&(u.link||an(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?ye(this.interactiveCanvas,fo(u)?Re.TEXT:Re.CROSSHAIR):this.state.viewModeEnabled?ye(this.interactiveCanvas,Re.GRAB):this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,Re.AUTO):i?ye(this.interactiveCanvas,Re.AUTO):o[W.CTRL_OR_CMD]?ye(this.interactiveCanvas,Re.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,c))&&!u?.locked&&(u&&es(u)&&this.isIframeLikeElementCenter(u,o,l,s)?(ye(this.interactiveCanvas,Re.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!$e(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||c.length>0)&&ye(this.interactiveCanvas,Re.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:Jl(f.hoveredElementIds,eo({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:Jl(f.hoveredElementIds,{})})))});C(this,"handleEraser",(o,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,o.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});C(this,"handleTouchMove",o=>{ls=!0});C(this,"handleCanvasPointerDown",o=>{let n=o.target;if(n.setPointerCapture&&n.setPointerCapture(o.pointerId),this.maybeCleanupAfterMissingPointerUp(o.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(c=>({searchMatches:c.searchMatches&&{focusedId:null,matches:c.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(Qg,null)),We.get(po)&&this.updateEditorAtom(po,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(o),o.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let c=this.state.newElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==c.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Te(Object.keys(this.state.selectedElementIds).filter(p=>p!==c.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?wt.EVENTUALLY:wt.NEVER});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(o),!this.state.penDetected&&o.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(o.pointerType)&&(this.device=Hf(this.device,{isTouchScreen:!0})),is||(this.lastPointerDownEvent=o,this.handleCanvasPanUsingWheelOrSpaceDrag(o)))return;if(this.setState({lastPointerDownWith:o.pointerType,cursorButton:"down"}),this.savePointer(o.clientX,o.clientY,"down"),o.button===Ir.ERASER&&this.state.activeTool.type!==Bo.eraser){this.setState({activeTool:rn(this.state,{type:Bo.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(o);let c=()=>{p(),u?.(),vt(this.state)&&this.setState({activeTool:rn(this.state,{...this.state.activeTool.lastActiveTool||{type:Bo.selection},lastActiveToolBeforeEraser:null})})},p=Oe(window,oe.POINTER_UP,c,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(c)})});return}if(o.button!==Ir.MAIN&&o.button!==Ir.TOUCH&&o.button!==Ir.ERASER||fe.pointers.size>1)return;let i=this.initialPointerDownState(o);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(o,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(o),this.handleSelectionOnPointerDown(o,i))||!(!this.state.penMode||o.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 c=i.hit.element&&this.isASelectedElement(i.hit.element);!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!c&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,o.shiftKey),i.drag.blockDragging=!ha()),ha()&&i.hit.element&&!c&&(this.setState(p=>{let u={...p.selectedElementIds,[i.hit.element.id]:!0},f=[];Object.keys(p.selectedElementIds).forEach(x=>{let w=this.scene.getElement(x);w&&f.push(w)});let b=i.hit.element;if(Mt(b))e1(f,b.id).forEach(x=>{delete u[x.id]});else if(b.frameId)u[b.frameId]&&delete u[b.id];else{let x=b.groupIds,w=new Set(x.flatMap(E=>kr(this.scene.getNonDeletedElements(),E)).filter(E=>Mt(E)).map(E=>E.id));w.size>0&&f.forEach(E=>{E.frameId&&w.has(E.frameId)&&(delete u[E.id],E.groupIds.flatMap(y=>kr(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return{...eo({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:b.link||an(b)?"info":!1}}),i.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(o,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(o,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(o,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Rt(this.interactiveCanvas,this.state):this.state.activeTool.type===Bo.frame||this.state.activeTool.type===Bo.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,o),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),d=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(c=>s(c||o.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(oe.POINTER_MOVE,l),window.addEventListener(oe.POINTER_UP,s),window.addEventListener(oe.KEYDOWN,d),window.addEventListener(oe.KEYUP,m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=d)});C(this,"handleCanvasPointerUp",o=>{this.removePointer(o),this.lastPointerUpEvent=o;let n=Ue({clientX:o.clientX,clientY:o.clientY},this.state),r=o.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&r<300){let i=this.getElementAtPosition(n.x,n.y);if(es(i)&&this.isIframeLikeElementCenter(i,o,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&&es(this.hitLinkElement)&&!N1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,se(n.x,n.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(o,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});C(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",o=>{o.pointerType==="touch"&&(ls=!1,jn?ls=!0:jn=window.setTimeout(()=>{jn=0,ls||this.handleCanvasContextMenu(o)},aG))});C(this,"resetContextMenuTimer",()=>{clearTimeout(jn),jn=0,ls=!1});C(this,"maybeCleanupAfterMissingPointerUp",o=>{ss?.(),this.missingPointerEventCleanupEmitter.trigger(o).clear()});C(this,"handleCanvasPanUsingWheelOrSpaceDrag",o=>{if(!(fe.pointers.size<=1&&(o.button===Ir.WHEEL||o.button===Ir.MAIN&&Mr||no(this.state)||this.state.viewModeEnabled)))return!1;is=!0,this.focusContainer(),this.state.editingTextElement||o.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);ye(this.interactiveCanvas,Re.GRABBING);let{clientX:i,clientY:a}=o,l=Bd(d=>{let m=i-d.clientX,c=a-d.clientY;if(i=d.clientX,a=d.clientY,r&&!n&&(Math.abs(m)>1||Math.abs(c)>1)){n=!0;let p=f=>{document.body.removeEventListener(oe.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(oe.PASTE,p),window.removeEventListener(oe.POINTER_UP,u)},100)};document.body.addEventListener(oe.PASTE,p),window.addEventListener(oe.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-c/this.state.zoom.value})}),s=De(ss=()=>{ss=null,is=!1,Mr||(this.state.viewModeEnabled?ye(this.interactiveCanvas,Re.GRAB):Rt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(o.clientX,o.clientY,"up"),window.removeEventListener(oe.POINTER_MOVE,l),window.removeEventListener(oe.POINTER_UP,s),window.removeEventListener(oe.BLUR,s),l.flush()});return window.addEventListener(oe.BLUR,s),window.addEventListener(oe.POINTER_MOVE,l,{passive:!0}),window.addEventListener(oe.POINTER_UP,s),!0});C(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});C(this,"handleSelectionOnPointerDown",(o,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&&!$e(a[0])&&!(Dm(a[0])&&Se.getPointIndexUnderCursor(a[0],i,this.state.zoom,n.origin.x,n.origin.y)!==-1)&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=wC(r,this.state,n.origin.x,n.origin.y,this.state.zoom,o.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=vC(ga(a),n.origin.x,n.origin.y,this.state.zoom,o.pointerType,this.device));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=zf(LU(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&Qt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=AU(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Se.handlePointerDown(o,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),d=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!d||d.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),d&&d.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,d),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 m=n.hit.element,c=n.hit.allHitElements.some(p=>this.isASelectedElement(p));if((m===null||!c)&&!o.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:Te({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(m!=null){if(o[W.CTRL_OR_CMD])return o.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,o.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[m.id]||(n.hit.wasAddedToSelection=!0),this.setState(p=>({...IU(p,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!xC(m,this.state.editingGroupId)&&this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!c&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[m.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),Mt(m))e1(f,m.id).forEach(b=>{delete u[b.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let b=m.groupIds,x=new Set(b.flatMap(w=>kr(this.scene.getNonDeletedElements(),w)).filter(w=>Mt(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=>kr(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(b=>p.selectedGroupIds[b])||(u={[m.id]:!0})),{...eo({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:m.link||an(m)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});C(this,"handleTextOnPointerDown",(o,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);nC(a)&&(l=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!o.altKey,container:l,autoEdit:!1}),Wt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:rn(this.state,{type:this.state.preferredSelectionTool.type})})});C(this,"handleFreeDrawElementOnPointerDown",(o,n,r)=>{let[i,a]=lt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=o.pressure===.5,d=OG({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:[se(0,0)],pressures:s?[]:[o.pressure]});this.scene.insertElement(d),this.setState(c=>{let p={...c.selectedElementIds};return delete p[d.id],{selectedElementIds:Te(p,c)}});let m=Gf(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:d,startBoundElement:m,suggestedBindings:[]})});C(this,"insertIframeElement",({sceneX:o,sceneY:n,width:r,height:i})=>{let[a,l]=lt(o,n,this.lastPointerDownEvent?.[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=FG({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});C(this,"insertEmbeddableElement",({sceneX:o,sceneY:n,link:r})=>{let[i,a]=lt(o,n,this.lastPointerDownEvent?.[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Am(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=Q5({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});C(this,"newImagePlaceholder",({sceneX:o,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=lt(o,n,this.lastPointerDownEvent?.[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return GG({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})});C(this,"handleLinearElementOnPointerDown",(o,n,r)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&cC(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Nt);return}if($e(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Nt);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Xn(se(r.origin.x-a,r.origin.y-l),s)<Bf){this.actionManager.executeAction(Nt);return}this.setState(d=>({selectedElementIds:Te({...d.selectedElementIds,[i.id]:!0},d)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),ye(this.interactiveCanvas,Re.POINTER)}else{let[i,a]=lt(r.origin.x,r.origin.y,o[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:d}=this.state,[m,c]=n==="arrow"?[s,d]:[null,null],p=n==="arrow"?zG({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===Zn.round?{type:Sm.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:c,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Zn.elbow,fixedSegments:this.state.currentItemArrowType===Zn.elbow?[]:null}):UG({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:Sm.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:Te(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,se(0,0)]});let u=Gf(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,$e(p),$e(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});C(this,"createGenericElementOnPointerDown",(o,n)=>{let[r,i]=lt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[W.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(o),locked:!1,frameId:a?a.id:null},s;o==="embeddable"?s=Q5({type:"embeddable",...l}):s=HG({type:o,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});C(this,"createFrameElementOnPointerDown",(o,n)=>{let[r,i]=lt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Kn},l=n===Bo.magicframe?eC(a):BG(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});C(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});C(this,"eraseElements",()=>{let o=!1,n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||Zf(r)&&this.elementsPendingErasure.has(r.containerId)?(o=!0,$n(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,o&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});C(this,"initializeImage",async(o,n)=>{if(!Wm(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type;if(ye(this.interactiveCanvas,"wait"),r===No.svg)try{n=Zm(mC(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||Z1(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 Es(n,{maxWidthOrHeight:$H})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>U5)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(U5/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await Km(n);return new Promise(async(s,d)=>{try{let m=this.getLatestInitializedImageElement(o,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([m]);if(p.size)throw new Error("Image cache update resulted with an error.")}let c=await this.imageCache.get(i)?.image;if(c&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(o,i);let p=this.getImageNaturalDimensions(m,c);Object.assign(m,p)}s(m)}catch(m){console.error(m),d(new Error(g("errors.imageInsertError")))}})});C(this,"getLatestInitializedImageElement",(o,n)=>{let r=this.scene.getElement(o.id)??o;return $n(r,{fileId:n})});C(this,"onImageToolbarButtonClick",async()=>{try{let o=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Ue({clientX:o,clientY:n},this.state),a=await ms({description:"Image",extensions:Object.keys(JH),multiple:!0});this.insertImages(a,r,i)}catch(o){o.name!=="AbortError"?console.error(o):console.warn(o),this.setState({newElement:null,activeTool:rn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(Nt)})}});C(this,"getImageNaturalDimensions",(o,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=o.x+o.width/2-l/2,d=o.y+o.height/2-a/2;return{x:s,y:d,width:l,height:a,crop:null}});C(this,"updateImageCache",async(o,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await JG({imageCache:this.imageCache,fileIds:o.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(wt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Ql(a)&&i.has(a.fileId)?$n(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});C(this,"addNewImagesToImageCache",async(o=qG(this.scene.getNonDeletedElements()),n=this.files)=>{let r=o.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)&&os.delete(a);i.size&&this.scene.triggerUpdate()}});C(this,"scheduleImageRefresh",YH(()=>{this.addNewImagesToImageCache()},QH));C(this,"updateBindingEnabledOnPointerMove",o=>{let n=NG(o);this.state.isBindingEnabled!==n&&this.setState({isBindingEnabled:n})});C(this,"maybeSuggestBindingAtCursor",(o,n)=>{let r=Gf(o,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,n);this.setState({suggestedBindings:r!=null?[r]:[]})});C(this,"handleInteractiveCanvasRef",o=>{o!==null?(this.interactiveCanvas=o,this.interactiveCanvas.addEventListener(oe.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(oe.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(oe.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(oe.TOUCH_END,this.onTouchEnd))});C(this,"insertImages",async(o,n,r)=>{let i=50/this.state.zoom.value,a=kC(o.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,await Sa(o[u]))}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),$n(p,{isDeleted:!0})}})),s=Lm(l),d=kC(l.filter(p=>!p.isDeleted),n,r,i),m=Lm(d),c=this.scene.getElementsIncludingDeleted().map(p=>m.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:Te(Object.fromEntries(d.map(p=>[p.id,!0])),this.state)},elements:c,captureUpdate:wt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(Nt)})});C(this,"handleAppOnDrop",async o=>{let{x:n,y:r}=Ue(o,this.state),i=await il(o),a=i.getFiles();if(a.length===1){let{file:c,fileHandle:p}=a[0];if(c&&(c.type===No.png||c.type===No.svg))try{let u=await xs(c,this.state,this.scene.getElementsIncludingDeleted(),p);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:wt.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}}let l=a.map(c=>c.file).filter(c=>Wm(c));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,n,r);let s=i.getData(No.excalidrawlibIds),d=i.getData(No.excalidrawlib);if(s||d){try{let c=null;if(s){let{itemIds:p}=JSON.parse(s);c=(await this.library.getLatestLibrary()).filter(f=>p.includes(f.id))}else d&&(c=K1(d));c?.length&&(c=c.map(p=>({...p,elements:Vf({type:"everything",elements:p.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Bi(c),position:o,files:null}))}catch(c){this.setState({errorMessage:c.message})}return}if(a.length>0){let{file:c,fileHandle:p}=a[0];c&&await this.loadFileToCanvas(c,p)}let m=i.findByType(No.text);if(m){let c=m.value;if(c&&qf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Am(c)?.type==="video")){let p=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:Of(c)});p&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[p.id]:!0}}))}}});C(this,"loadFileToCanvas",async(o,n)=>{o=await Sa(o);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Vm(o,this.state,r,n)}catch(a){let l=a instanceof D1;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===No.excalidraw?(AC(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:wt.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:wt.IMMEDIATELY})):i.type===No.excalidrawlib&&await this.library.updateLibrary({libraryItems:o,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});C(this,"handleCanvasContextMenu",o=>{if(o.preventDefault(),("pointerType"in o.nativeEvent&&o.nativeEvent.pointerType==="touch"||"pointerType"in o.nativeEvent&&o.nativeEvent.pointerType==="pen"&&o.button!==Ir.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let{x:n,y:r}=Ue(o,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",d=this.excalidrawContainerRef.current,{top:m,left:c}=d.getBoundingClientRect(),p=o.clientX-c,u=o.clientY-m;ie("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...eo({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Qt(i)?new Se(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});C(this,"maybeDragNewGenericElement",(o,n,r=!0)=>{let i=this.state.selectionElement,a=o.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){TC({newElement:i,elementType:this.state.activeTool.type,originX:o.origin.x,originY:o.origin.y,x:a.x,y:a.y,width:ua(o.origin.x,a.x),height:ua(o.origin.y,a.y),shouldMaintainAspectRatio:jl(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,d]=lt(a.x,a.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Ql(l)&&this.imageCache.get(l.fileId)?.image,c=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:p,snapLines:u}=Sv(l,this,n,{x:o.originInGrid.x+(this.state.originSnapOffset?.x??0),y:o.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-o.originInGrid.x,y:d-o.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,d+=p.y,this.setState({snapLines:u}),TC({newElement:l,elementType:this.state.activeTool.type,originX:o.originInGrid.x,originY:o.originInGrid.y,x:s,y:d,width:ua(o.originInGrid.x,s),height:ua(o.originInGrid.y,d),shouldMaintainAspectRatio:Sr(l)?!jl(n):jl(n),shouldResizeFromCenter:z5(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:c,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Bo.frame||this.state.activeTool.type===Bo.magicframe)&&this.setState({elementsToHighlight:o1(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});C(this,"maybeHandleCrop",(o,n)=>{if(!this.state.croppingElementId)return!1;let r=o.resize.handleType,i=o.lastCoords,[a,l]=lt(i.x-o.resize.offset.x,i.y-o.resize.offset.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&Sr(s)){let d=o.originalElements.get(s.id),m=Ql(s)&&this.imageCache.get(s.fileId)?.image;if(d&&Sr(d)&&m&&!(m instanceof Promise)){let[c,p]=lt(i.x,i.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-o.originInGrid.x,y:p-o.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:f,snapLines:b}=cg([s],[d],this,n,u,r);this.scene.mutateElement(s,hU(s,this.scene.getNonDeletedElementsMap(),r,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,n.shiftKey?d.width/d.height:void 0)),Yf(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:r&&r!=="rotation",snapLines:b})}return!0}return!1});C(this,"maybeHandleResize",(o,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(c=>Mt(c)),a=o.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&$e(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=o.lastCoords,[s,d]=lt(l.x-o.resize.offset.x,l.y-o.resize.offset.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(c=>{e1(this.scene.getNonDeletedElements(),c.id).forEach(u=>{m.set(c.id+u.id,{x:u.x-c.x,y:u.y-c.y})})}),!this.state.selectedElementsAreBeingDragged){let[c,p]=lt(l.x,l.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-o.originInGrid.x,y:p-o.originInGrid.y},f=[...o.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:b,snapLines:x}=cg(r,Q(f,this.state),this,n,u,a);s+=b.x,d+=b.y,this.setState({snapLines:x})}if(DU(o.originalElements,a,r,this.scene,Nf(n),z5(n),r.some(c=>Sr(c))?!jl(n):jl(n),s,d,o.resize.center.x,o.resize.center.y)){let c=Wf(r,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{o1(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:c}),!0}return!1});C(this,"getContextMenuItems",o=>{let n=[];return n.push(Rc,_c),o==="canvas"?this.state.viewModeEnabled?[...n,Bc,Ci,og,Si]:[Ru,Xe,Rc,_c,Nc,Xe,Sp,Dy,Xe,Bc,Nu,Ci,og,Si]:(n.push(Nc),this.state.viewModeEnabled?[Ii,...n]:[Xe,Dc,Ii,Ru,Xe,nv,rv,iv,Xe,Jh,Xe,...n,Xe,Tu,Iu,Xe,ku,uv,Fu,zu,by,Mu,Xe,Au,Xe,vp,Tp,Ip,Cp,Xe,Du,_u,Xe,$i,Xe,dl,Wc,Xe,kp,ml,Xe,Oa])});C(this,"handleWheel",De(o=>{if(!(o.target instanceof HTMLCanvasElement||o.target instanceof HTMLTextAreaElement||o.target instanceof HTMLIFrameElement)){o[W.CTRL_OR_CMD]&&o.preventDefault();return}if(o.preventDefault(),is)return;let{deltaX:n,deltaY:r}=o;if(o.metaKey||o.ctrlKey){let i=Math.sign(r),a=sG*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let d=this.state.zoom.value-s/100;d+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...Yo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:bo(d)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(o.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}))}));C(this,"savePointer",(o,n,r)=>{if(!o||!n)return;let{x:i,y:a}=Ue({clientX:o,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:fe.pointers})});C(this,"resetShouldCacheIgnoreZoomDebounced",X5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));C(this,"updateDOMRect",o=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=n.getBoundingClientRect(),{width:s,height:d,offsetTop:m,offsetLeft:c}=this.state;if(r===s&&i===d&&a===c&&l===m){o&&o();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{o&&o()})}});C(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let n=mn(),{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:d=n.theme,name:m=`${g("labels.untitled")}-${Z5()}`}=o;if(this.state={...n,theme:d,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??n.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight},this.id=VH(),this.library=new rw(this),this.actionManager=new Cd(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new CC,this.canvas=document.createElement("canvas"),this.rc=WH.canvas(this.canvas),this.renderer=new Nl(this.scene),this.visibleElements=[],this.store=new NU(this),this.history=new Ll(this.store),r){let c={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(c):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new dn(this.scene),this.history=new Ll(this.store),this.actionManager.registerAll(Os),this.actionManager.registerAction(cv(this.history)),this.actionManager.registerAction(dv(this.history))}onWindowMessage(o){if(o.origin!=="https://player.vimeo.com"&&o.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(o.data)}catch{}if(n)switch(o.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===o.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(Mm).includes(i)&&l1.set(r,i)}break}}cacheEmbeddableRef(o,n){n&&this.iFrameRefs.set(o.id,n)}getHTMLIFrameElement(o){return this.iFrameRefs.get(o.id)}handleEmbeddableCenterClick(o){if(this.state.activeEmbeddable?.element===o&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:o,state:"active"},selectedElementIds:{[o.id]:!0},newElement:null,selectionElement:null})},100),fa(o)))return;let n=this.getHTMLIFrameElement(o);if(n?.contentWindow){if(n.src.includes("youtube")){let r=l1.get(o.id);switch(r||(l1.set(o.id,Mm.UNSTARTED),n.contentWindow.postMessage(JSON.stringify({event:"listening",id:o.id}),"*")),r){case Mm.PLAYING:case Mm.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(o,n,r,i){return o&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==o||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=o.x+o.width/3&&r<=o.x+2*o.width/3&&i>=o.y+o.height/3&&i<=o.y+2*o.height/3}renderEmbeddables(){let o=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>an(a)&&this.embedsValidationStatus.get(a.id)===!0||fa(a));return be(zU,{children:i.map(a=>{let{x:l,y:s}=Pm({sceneX:a.x,sceneY:a.y},this.state),d=lC(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(d&&!m&&this.initializedEmbeds.add(a.id),!(d||m))return null;let p;if(fa(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:()=>dC(`
|
|
26
26
|
<style>
|
|
27
27
|
html, body {
|
|
28
28
|
width: 100%;
|
|
29
29
|
height: 100%;
|
|
30
|
-
color: ${this.state.theme===
|
|
30
|
+
color: ${this.state.theme===km.DARK?"white":"black"};
|
|
31
31
|
}
|
|
32
32
|
body {
|
|
33
33
|
display: flex;
|
|
@@ -94,7 +94,7 @@ TTD mermaid definition render errror: ${M.message}`,"color: yellow"),ae("ai","me
|
|
|
94
94
|
</svg>
|
|
95
95
|
</div>
|
|
96
96
|
<div>Generating...</div>
|
|
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:()=>
|
|
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:()=>dC(`
|
|
98
98
|
<style>
|
|
99
99
|
html, body {
|
|
100
100
|
height: 100%;
|
|
@@ -104,7 +104,7 @@ TTD mermaid definition render errror: ${M.message}`,"color: yellow"),ae("ai","me
|
|
|
104
104
|
flex-direction: column;
|
|
105
105
|
align-items: center;
|
|
106
106
|
justify-content: center;
|
|
107
|
-
color: ${
|
|
107
|
+
color: ${KH.red[3]};
|
|
108
108
|
}
|
|
109
109
|
h1, h3 {
|
|
110
110
|
margin-top: 0;
|
|
@@ -113,7 +113,7 @@ TTD mermaid definition render errror: ${M.message}`,"color: yellow"),ae("ai","me
|
|
|
113
113
|
</style>
|
|
114
114
|
<h1>Error!</h1>
|
|
115
115
|
<h3>${x}</h3>
|
|
116
|
-
`)}}}else p=Tm(HH(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 ge("div",{className:uI("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:d?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:d?"block":"none",opacity:$G(a,Vf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?FH:1),"--embeddable-radius":`${wG(Math.min(a.width,a.height),a)}px`},children:Cm("div",{className:"excalidraw__embeddable-container__inner",style:{width:d?`${a.width}px`:0,height:d?`${a.height}px`:0,transform:d?`rotate(${a.angle}rad)`:"none",pointerEvents:u?ea.enabled:ea.disabled},children:[f&&ge("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),ge("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(en(a)?this.props.renderEmbeddable?.(a,this.state):null)??ge("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(),d="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",m=t[0],c=Ye.get(co)?.type==="panel";return ge("div",{className:uI("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":d?ea.disabled:ea.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:ge(uC.Provider,{value:this,children:ge(hC.Provider,{value:this.props,children:ge(e1.Provider,{value:this.excalidrawContainerValue,children:ge(Qf.Provider,{value:this.device,children:ge(n1.Provider,{value:this.setAppState,children:ge(o1.Provider,{value:this.state,children:Cm(t1.Provider,{value:this.scene.getNonDeletedElements(),children:[Cm(r1.Provider,{value:this.actionManager,children:[ge(q5,{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:No().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}),ge("div",{className:"excalidraw-textEditorContainer"}),ge("div",{className:"excalidraw-contextMenuContainer"}),ge("div",{className:"excalidraw-eye-dropper-container"}),ge(eI,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ge(Ey,{element:m,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&t.length===1&&Ff(m)&&ge(gg,{element:m,elementsMap:a,children:ge(fm,{title:g("labels.convertToCode"),icon:ws,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&na(m)&&m.customData?.generationData?.status==="done"&&Cm(gg,{element:m,elementsMap:a,children:[ge(fm,{title:g("labels.copySource"),icon:Hr,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),ge(fm,{title:"Enter fullscreen",icon:hb,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(m);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:m,state:"active"},selectedElementIds:{[m.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&ge(mI,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&ge(h3,{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?.()})}}),ge(yf,{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:kn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&ge(cI,{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}}),ge(Ef,{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&&ge(f3,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&ge(pI,{app:this,activeLockedId:this.state.activeLockedId}),c&&ge(By,{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=_G(this.scene.getNonDeletedElements(),t).filter(l=>!Ff(l));if(!i.length){n==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ae("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}}),ae("ai","generate (start)","d2c");try{let{html:l}=await r({frame:t,children:i});if(ae("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){ae("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"&&(lo(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=>{Nl(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),Ol.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,qf()||mC()){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(),qf()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),II&&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),SH()&&!YG()&&this.setState({errorMessage:ge(d3,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new aC,this.fonts=new rn(this.scene),this.renderer=new El(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(),Ol.destroy(),Zt.destroy(),clearTimeout(Vn),we.clearCache(),Qt.clearCache(),Vn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Ne(document,oe.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Ne(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Ne(window,oe.MESSAGE,this.onWindowMessage,!1),Ne(document,oe.POINTER_UP,this.removePointer,{passive:!1}),Ne(document,oe.COPY,this.onCopy,{passive:!1}),Ne(document,oe.KEYUP,this.onKeyUp,{passive:!0}),Ne(document,oe.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Ne(document.fonts,"loadingdone",t=>{let n=t.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),Ne(document,oe.GESTURE_START,this.onGestureStart,!1),Ne(document,oe.GESTURE_CHANGE,this.onGestureChange,!1),Ne(document,oe.GESTURE_END,this.onGestureEnd,!1),Ne(window,oe.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Ne(document,oe.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Ne(document,oe.PASTE,this.pasteFromClipboard,{passive:!1}),Ne(document,oe.CUT,this.onCut,{passive:!1}),Ne(window,oe.RESIZE,this.onResize,!1),Ne(window,oe.UNLOAD,this.onUnload,!1),Ne(window,oe.BLUR,this.onBlur,!1),Ne(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Ne(this.excalidrawContainerRef.current,oe.DRAG_OVER,this.disableEvent,!1),Ne(this.excalidrawContainerRef.current,oe.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Ne(GH(this.excalidrawContainerRef.current),oe.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&&vt(this.state)&&this.setState({activeTool:Qo(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&tu(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(),vt(n)&&!vt(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===Em.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(Bt)}),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(){zl=!1,Hl=null}async insertClipboardContent(t,n,r){let{x:i,y:a}=Ge({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(m=>m.file);if(l.length===0&&t.text&&!r){let m=t.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&l.push(zm(m))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(t.elements){let m=t.programmaticAPI?Gi(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:m,files:t.files||null,position:Tr()?"center":"cursor",retainSeed:r});return}if(!t.text)return;if(!r&&Zv(t.text)){let m=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:c,files:p}=await m.parseMermaidToExcalidraw(t.text),u=Gi(c,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:Tr()?"center":"cursor"});return}catch(c){console.warn(`parsing pasted text as mermaid definition failed: ${c.message}`)}}let s=$H(t.text).split(/\n+/).map(m=>m.trim()).filter(Boolean),d=s.map(m=>vG(m)).filter(m=>zf(m,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(m)||Tm(m)?.type==="video"));if(!r&&d.length>0&&d.length===s.length){let m=[];for(let c of d){let p=m[m.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Cf(c)});u&&m.push(u)}m.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(m.map(c=>[c.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(m=>m.type==="imageUrl").map(m=>m.value),l=await Promise.all(a.map(async m=>{try{return{file:await G1(m)}}catch(c){let p=c.message;return c.cause==="FETCH_ERROR"?p=g("errors.failedToFetchImage"):c.cause==="UNSUPPORTED"&&(p=g("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(m=>!!m.file).map(m=>m.file);await this.insertImages(s,r,i);let d=l.find(m=>!!m.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
116
|
+
`)}}}else p=Am(hG(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 be("div",{className:D5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:d?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${o})`:"none",display:d?"block":"none",opacity:TU(a,n1(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?mG:1),"--embeddable-radius":`${$G(Math.min(a.width,a.height),a)}px`},children:_m("div",{className:"excalidraw__embeddable-container__inner",style:{width:d?`${a.width}px`:0,height:d?`${a.height}px`:0,transform:d?`rotate(${a.angle}rad)`:"none",pointerEvents:u?pa.enabled:pa.disabled},children:[f&&be("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),be("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(an(a)?this.props.renderEmbeddable?.(a,this.state):null)??be("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(o){document.documentElement.style.overscrollBehaviorX=o.type==="pointerenter"?"none":"auto"}render(){let o=this.scene.getSelectedElements(this.state),{renderTopRightUI:n,renderTopLeftUI:r,renderCustomStats:i}=this.props,a=this.scene.getSceneNonce(),{elementsMap:l,visibleElements:s}=this.renderer.getRenderableElements({sceneNonce:a,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=s;let d=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=o[0],p=We.get(po)?.type==="panel";return be("div",{className:D5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":m?pa.disabled:pa.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:be(DC.Provider,{value:this,children:be(_C.Provider,{value:this.props,children:be(p1.Provider,{value:this.excalidrawContainerValue,children:be(m1.Provider,{value:this.device,children:be(g1.Provider,{value:this.setAppState,children:be(h1.Provider,{value:this.state,children:_m(u1.Provider,{value:this.scene.getNonDeletedElements(),children:[_m(f1.Provider,{value:this.actionManager,children:[be(f5,{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:zo().code,renderTopLeftUI:r,renderTopRightUI:n,renderCustomStats:i,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.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),be("div",{className:"excalidraw-textEditorContainer"}),be("div",{className:"excalidraw-contextMenuContainer"}),be("div",{className:"excalidraw-eye-dropper-container"}),be(E5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),o.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&be(Iy,{element:c,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&o.length===1&&$f(c)&&be(vg,{element:c,elementsMap:l,children:be(Im,{title:g("labels.convertToCode"),icon:rr,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),o.length===1&&fa(c)&&c.customData?.generationData?.status==="done"&&_m(vg,{element:c,elementsMap:l,children:[be(Im,{title:g("labels.copySource"),icon:Kr,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),be(Im,{title:"Enter fullscreen",icon:y0,checked:!1,onChange:()=>{let u=this.getHTMLIFrameElement(c);if(u)try{u.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},newElement:null,selectionElement:null})}catch(f){console.warn(f),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&be(L5,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&be(M3,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:u=>{this.setState({contextMenu:null},()=>{this.focusContainer(),u?.()})}}),be(Df,{canvas:this.canvas,rc:this.rc,elementsMap:l,allElementsMap:d,visibleElements:s,sceneNonce:a,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:_n(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&be(M5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:l,allElementsMap:d,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),be(Af,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:l,visibleElements:s,allElementsMap:d,selectedElements:o,sceneNonce:a,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&&be(L3,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&be(A5,{app:this,activeLockedId:this.state.activeLockedId}),p&&be(Gy,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(o){Object.assign(this.plugins,o)}async onMagicFrameGenerate(o,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=lU(this.scene.getNonDeletedElements(),o).filter(l=>!$f(l));if(!i.length){n==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ie("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:o.x+o.width+30,sceneY:o.y,width:o.width,height:o.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),ie("ai","generate (start)","d2c");try{let{html:l}=await r({frame:o,children:i});if(ie("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){ie("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(o){o.customData?.generationData?.status==="done"&&(co(o.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(o){let n=o??this.files;this.scene.getNonDeletedElements().forEach(r=>{Ql(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),os.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,c1()||LC()){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:o}=this.props;o&&this.store.onStoreIncrementEmitter.on(r=>{o(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),c1()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),Y5&&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),eG()&&!bU()&&this.setState({errorMessage:be(I3,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new CC,this.fonts=new dn(this.scene),this.renderer=new Nl(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(),os.destroy(),Zt.destroy(),clearTimeout(jn),ve.clearCache(),eo.clearCache(),jn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Oe(document,oe.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Oe(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Oe(window,oe.MESSAGE,this.onWindowMessage,!1),Oe(document,oe.POINTER_UP,this.removePointer,{passive:!1}),Oe(document,oe.COPY,this.onCopy,{passive:!1}),Oe(document,oe.KEYUP,this.onKeyUp,{passive:!0}),Oe(document,oe.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Oe(document.fonts,"loadingdone",o=>{let n=o.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),Oe(document,oe.GESTURE_START,this.onGestureStart,!1),Oe(document,oe.GESTURE_CHANGE,this.onGestureChange,!1),Oe(document,oe.GESTURE_END,this.onGestureEnd,!1),Oe(window,oe.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Oe(document,oe.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Oe(document,oe.PASTE,this.pasteFromClipboard,{passive:!1}),Oe(document,oe.CUT,this.onCut,{passive:!1}),Oe(window,oe.RESIZE,this.onResize,!1),Oe(window,oe.UNLOAD,this.onUnload,!1),Oe(window,oe.BLUR,this.onBlur,!1),Oe(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Oe(this.excalidrawContainerRef.current,oe.DRAG_OVER,this.disableEvent,!1),Oe(this.excalidrawContainerRef.current,oe.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Oe(gG(this.excalidrawContainerRef.current),oe.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(o,n){this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),o.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&&vt(this.state)&&this.setState({activeTool:rn(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&su(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),o.langCode!==this.props.langCode&&this.updateLanguage(),vt(n)&&!vt(this.state)&&this.eraserTrail.endPath(),o.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:{}})),o.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),o.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===km.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(Nt)}),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(){ns=!1,rs=null}async insertClipboardContent(o,n,r){let{x:i,y:a}=Ue({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(o.errorMessage){this.setState({errorMessage:o.errorMessage});return}if(n.length===0&&!r&&o.mixedContent){await this.addElementsFromMixedContentPaste(o.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(o.spreadsheet&&!r){this.setState({pasteDialog:{data:o.spreadsheet,shown:!0}});return}let l=n.map(m=>m.file);if(l.length===0&&o.text&&!r){let m=o.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&l.push(Zm(m))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(o.elements){let m=o.programmaticAPI?Ji(o.elements):o.elements;this.addElementsFromPasteOrLibrary({elements:m,files:o.files||null,position:ha()?"center":"cursor",retainSeed:r});return}if(!o.text)return;if(!r&&s3(o.text)){let m=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:c,files:p}=await m.parseMermaidToExcalidraw(o.text),u=Ji(c,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:ha()?"center":"cursor"});return}catch(c){console.warn(`parsing pasted text as mermaid definition failed: ${c.message}`)}}let s=TG(o.text).split(/\n+/).map(m=>m.trim()).filter(Boolean),d=s.map(m=>jG(m)).filter(m=>qf(m,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(m)||Am(m)?.type==="video"));if(!r&&d.length>0&&d.length===s.length){let m=[];for(let c of d){let p=m[m.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Of(c)});u&&m.push(u)}m.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(m.map(c=>[c.id,!0]))}));return}this.addTextFromPaste(o.text,r)}async addElementsFromMixedContentPaste(o,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&o.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=o.filter(m=>m.type==="imageUrl").map(m=>m.value),l=await Promise.all(a.map(async m=>{try{return{file:await q1(m)}}catch(c){let p=c.message;return c.cause==="FETCH_ERROR"?p=g("errors.failedToFetchImage"):c.cause==="UNSUPPORTED"&&(p=g("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(m=>!!m.file).map(m=>m.file);await this.insertImages(s,r,i);let d=l.find(m=>!!m.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=o.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
117
117
|
|
|
118
|
-
`),n)}}addTextFromPaste(
|
|
119
|
-
`),b=f.reduce((x,y,E)=>{let w=WG(y).trim();if(w.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),C=JI(w,l,s),k=C.width>c,P=k?GG(w,l,c):w;C=k?JI(P,l,s):C;let S=r-C.width/2,_=u-C.height/2,M=BI({...a,x:S,y:_,text:P,originalText:w,lineHeight:s,autoResize:!k,frameId:v?v.id:null});x.push(M),u+=M.height+p}else f[E-1]?.trim()&&(u+=VG(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ve(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!n&&b.length>1&&dC===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:WH("CtrlOrCmd+Shift+V")}),duration:5e3}),dC=!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&&go(s)?Wn(s,{originalText:a,isDeleted:l??s.isDeleted,...gG(s,KI(s,r),r,a)}):s)])};Kv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:d}=wm({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,d-this.state.offsetTop]},onChange:De(a=>{i(a,!1),iC(t)&&Af(t,this.scene)}),onSubmit:De(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let d=t.containerId?t.containerId:t.id;Qi(()=>{this.setState(m=>({selectedElementIds:ve({...m.selectedElementIds,[d]:!0},m)}))})}s&&aG(this.scene.getNonDeletedElements(),[t]),(!s||n)&&this.store.scheduleCapture(),Qi(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Nt(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:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,n){let r=this.getElementAtPosition(t,n,{includeBoundTextElement:!0});return r&&go(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 Fl({point:le(t,n),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Mt(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||!(go(s)&&s.containerId)))).filter(s=>this.hitElement(t,n,s)).filter(s=>{let d=Vf(s,a);return d&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?ZI({x:t,y:n},d,a):!0}).filter(s=>na(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(CI/this.state.zoom.value))}hitElement(t,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&kG([r],this.state)&&sU(le(t,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||NG(le(t,n),r,this.scene.getNonDeletedElementsMap())?!0:Fl({point:le(t,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Mt(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 HI(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,d,m,c]=DI(r[l],this.scene.getNonDeletedElementsMap());if(Rf(r[l])&&Fl({point:le(t,n),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<t&&t<m&&d<n&&n<c){a=r[l];break}}return HI(a,!1)?a:null}handleHoverSelectedLinearElement(t,n,r){let i=this.scene.getNonDeletedElementsMap(),a=Ie.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;Fl({point:le(n,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Ie.getPointIndexUnderCursor(a,i,this.state.zoom,n,r),s=Ie.getSegmentMidpointHitCoords(t,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Ke(a)?l===0||l===a.points.length-1:l>=0)||s?Ee(this.interactiveCanvas,Re.POINTER):this.hitElement(n,r,a)&&(!Ke(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&Ee(this.interactiveCanvas,Re.MOVE)):this.hitElement(n,r,a)&&(!Ke(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&Ee(this.interactiveCanvas,Re.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Ie.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else Ee(this.interactiveCanvas,Re.AUTO)}updateGestureOnPointerDown(t){he.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),he.pointers.size===2&&(he.lastCenter=qh(he.pointers),he.initialScale=this.state.zoom.value,he.initialDistance=Jh(Array.from(he.pointers.values())))}initialPointerDownState(t){let n=Ge(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=oa(r),d=r.findIndex(Ke)===0;return{origin:n,withCmdOrCtrl:t[Y.CTRL_OR_CMD],originInGrid:kf(lt(n.x,n.y,t[Y.CTRL_OR_CMD]||d?null:this.getEffectiveGridSize())),scrollbars:ag(Ul,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((m,c)=>(m.set(c.id,FI(c)),m),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;Zf=!0,n.lastCoords.x=t.clientX,n.lastCoords.y=t.clientY;let r=Sd(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,n)}),i=De(()=>{Wl=null,Zf=!1,Nt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(oe.POINTER_MOVE,r),window.removeEventListener(oe.POINTER_UP,i),r.flush()});return Wl=i,window.addEventListener(oe.POINTER_MOVE,r),window.addEventListener(oe.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(CI/this.state.zoom.value,1),[i,a,l,s]=oa(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:bG(t)?xm.ADAPTIVE_RADIUS:xm.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,n,r=!1){Zo({event:t,app:this,selectedElements:n})&&(r||!Zt.getReferenceSnapPoints())&&Zt.setReferenceSnapPoints(dv(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,n,r=!1){Zo({event:t,app:this,selectedElements:n})&&(r||!Zt.getVisibleGaps())&&Zt.setVisibleGaps(cv(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return De(n=>{this.maybeHandleResize(t,n)||this.maybeDragNewGenericElement(t,n)})}onKeyUpFromPointerDownHandler(t){return De(n=>{n.key===Y.ALT&&n.preventDefault(),!this.maybeHandleResize(t,n)&&this.maybeDragNewGenericElement(t,n)})}onPointerMoveFromPointerDownHandler(t){return Sd(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Ge(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]=lt(r.x,r.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Ie.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Ie.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Ie.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=kf(aU(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,t))return;if(vt(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[l,s]=lt(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")&&Gn(le(r.x,r.y),le(t.origin.x,t.origin.y))*this.state.zoom.value<PI)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 d=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Ie.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,d)){let f=Ie.addMidpoint(this.state.selectedLinearElement,r,this,!n[Y.CTRL_OR_CMD],this.scene);if(!f)return;Qi(()=>{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=Ie.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 m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),c=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&!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=>Mt(x)),f=this.getTopLayerFrameAtSceneCoords(r),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Qi(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(Tr()&&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},y=[...t.originalElements.values()],E=n.shiftKey;if(E){let C=Math.abs(x.x),k=Math.abs(x.y),P=E&&C<k,S=E&&C>k;P&&(x.x=0),S&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&Ir(C)&&C.crop!==null&&t.hit.element===C){let k=C.crop,P=Nl(C)&&this.imageCache.get(C.fileId)?.image;if(P&&!(P instanceof Promise)){let S=xH(gI(r.x-i.x,r.y-i.y),Math.max(this.state.zoom.value,2)),[_,M,R,O,V,j]=DI(C,d),A=vf(wf(le(_,M),le(V,j),C.angle)),N=vf(wf(le(R,M),le(V,j),C.angle)),F=vf(wf(le(_,O),le(V,j),C.angle)),W=xI(fI(N,A)),q=xI(fI(F,A)),ye=gI(bI(S,W),bI(S,q)),Z={...k,x:hI(k.x-ye[0]*Math.sign(C.scale[0]),0,P.naturalWidth-k.width),y:hI(k.y-ye[1]*Math.sign(C.scale[1]),0,P.naturalHeight-k.height)};this.scene.mutateElement(C,{crop:Z});return}}}this.maybeCacheVisibleGaps(n,p),this.maybeCacheReferenceSnapPoints(n,p);let{snapOffset:w,snapLines:v}=mv(y,x,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||iU(t,p,x,this.scene,w,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!Ke(p[0]))&&this.setState({suggestedBindings:Df(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),n.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),k=t.hit.element,P=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});k&&t.hit.wasAddedToSelection&&!P.find(N=>N.id===k.id)&&P.push(k);let S=new Map(P.map(N=>[N.id,N])),{duplicatedElements:_,duplicateElementsMap:M,elementsWithDuplicates:R,origIdToDuplicateId:O}=_f({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:S,overrides:({duplicateElement:N,origElement:F})=>({frameId:N.frameId??F.frameId,seed:qH()})});_.forEach(N=>{t.originalElements.set(N.id,FI(N))});let V=R.map(N=>{if(S.has(N.id)){let F=t.originalElements.get(N.id);if(F)return Wn(N,{x:F.x,y:F.y})}return N}),j=this.props.onDuplicate?.(V,C),A=eC(j||V,vm(_));Qi(()=>{if(t.hit.element){let N=O.get(t.hit.element.id),F=N&&M.get(N);t.hit.element=F||null}t.hit.allHitElements=t.hit.allHitElements.reduce((N,F)=>{let W=O.get(F.id),q=W&&M.get(W);return q&&N.push(q),N},[]),t.drag.origin=Ge(n,this.state),this.setState(N=>({...tU(_,this.scene.getNonDeletedElements(),N)})),this.scene.replaceAllElements(A),this.maybeCacheVisibleGaps(n,P,!0),this.maybeCacheReferenceSnapPoints(n,P,!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,le(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Jt(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Tf(n)&&u.length===2&&({width:f,height:b}=GI(p.x,p.y,r.x,r.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,le(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&Ke(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),le(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),Nf(p,!1)&&this.setState({suggestedBindings:AI(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)Ie.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!n.shiftKey&&we(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>Qt({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?w1(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((y,E)=>(y[E.id]=!0,y),{})};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},{...Qt({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&Jt(f[0])?new Ie(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||en(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*(Ul.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*(Ul.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return De(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:d,isRotating:m,isCropping:c}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Rl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Zt.setReferenceSnapPoints(null),Zt.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let p=t.hit.allHitElements,u=Ge({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);EG(E)&&E.boundElements?.filter(w=>w.type==="arrow").map(w=>f.get(w.id)).filter(w=>Ke(w)).forEach(w=>{w&&this.scene.mutateElement(w,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(Bt);else{let E=Ie.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=Ie.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(Bt,"ui",{event:n,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(oe.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(oe.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(oe.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(oe.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,n),r?.type==="freedraw"){let E=Ge(n,this.state),w=r.points,v=E.x-r.x,C=E.y-r.y;v===w[0][0]&&C===w[0][1]&&(C+=1e-4,v+=1e-4);let k=r.simulatePressure?[]:[...r.pressures,n.pressure];this.scene.mutateElement(r,{points:[...w,le(v,C)],pressures:k,lastCommittedPoint:le(v,C)}),this.actionManager.executeAction(Bt);return}if(Jt(r)){r.points.length>1&&this.store.scheduleCapture();let E=Ge(n,this.state),w=Gn(le(E.x,E.y),le(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||w<PI)&&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:[le(0,0),le(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(Bt)}else{let v=E.x-r.x,C=E.y-r.y;this.scene.mutateElement(r,{points:[...r.points,le(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:r,newElement:r})}else t.drag.hasOccurred&&!l&&(Pf(this.state)&&Nf(r,!1)&&this.actionManager.executeAction(Bt,"ui",{event:n,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Wt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:Qo(this.state,{type:this.defaultSelectionTool}),selectedElementIds:ve({...v.selectedElementIds,[r.id]:!0},v),selectedLinearElement:new Ie(r,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(go(r)){let E=ZG(Sf({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&&YI(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==r.id),appState:{newElement:null},captureUpdate:wt.NEVER});return}if(Mt(r)){let E=PG(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Yf(this.scene.getElementsMapIncludingDeleted(),E,r,this.state))}if(r&&(this.scene.mutateElement(r,yG(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=Ge(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let w=this.scene.getElement(this.state.selectedLinearElement.elementId);if(w?.frameId){let v=Vf(w,f);v&&w&&(AG(w,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(w,{groupIds:[]}),LG([w],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let w=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),k=P=>{if(P.length>0){for(let S of P){let _=S.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(S,{groupIds:S.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(S=>{S.groupIds.length&&Cr(C,S.groupIds[S.groupIds.length-1]).length<2&&this.scene.mutateElement(S,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(w&&!this.state.selectedElementIds[w.id]){let P=v.filter(S=>S.frameId!==w.id&&jI(S,C,this.state));this.state.editingGroupId&&k(P),C=Yf(C,P,w,this.state)}else if(!w&&this.state.editingGroupId){let P=v.filter(S=>S.frameId&&!jI(S,C,this.state));k(P)}C=$I(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&YI(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:wt.NEVER}),t.resize.isResizing){let E=$I(this.scene.getElementsIncludingDeleted(),this.state,this),w=this.scene.getSelectedElements(this.state).filter(v=>Mt(v));for(let v of w)E=MG(E,Wf(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&Jt(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Ie(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!c||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(vt(this.state)&&x&&y){if(this.eraserTrail.endPath(),Gn(le(x.clientX,x.clientY),le(y.clientX,y.clientY))===0){let w=Ge({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(w.x,w.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]?QG(this.state,b)?this.setState(E=>{let w={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>Cr(this.scene.getNonDeletedElements(),C)))delete w[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:ve(w,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let w={...E.selectedElementIds};delete w[b.id];let v=J(this.scene.getNonDeletedElements(),{selectedElementIds:w});return{...Qt({editingGroupId:E.editingGroupId,selectedElementIds:w},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&Jt(v[0])?new Ie(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let w={...E.selectedElementIds,[b.id]:!0};return delete w[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>Cr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete w[v.id]}),{...Qt({editingGroupId:E.editingGroupId,selectedElementIds:w},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||en(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...Qt({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:Jt(b)&&E.selectedLinearElement?.elementId!==b.id?new Ie(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&Ke(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&BG({point:le(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:Mt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Oi):this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Ee(this.interactiveCanvas,Re.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&r&&this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[r.id]:!0},E),showHyperlinkPopup:en(r)&&!r.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||we(this.scene.getNonDeletedElements(),this.state)||!jH(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||c){let E=this.scene.getSelectedElements(this.state).filter(Jt);_I(E,Pf(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)?(Wt(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Qo(this.state,{type:this.defaultSelectionTool})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&he.pointers.size<=1&&Bl(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(n=>({selectedElementIds:ve({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&t!=null&&QI(t,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:ve({},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=Gf(i,r,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,n-l)<PH){let{x:c,y:p}=wm({sceneX:a,sceneY:l},r);return{viewportX:c,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=Rr.find(n=>n.code===this.props.langCode)||xo;await ls(t),this.setAppState({})}},dU=()=>{(qf()||mC())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(pC(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};dU();var fC=Jf;import{useEffect as pU,useState as uU}from"react";import{jsx as hU}from"react/jsx-runtime";var bC=e=>{let[o,t]=uU(!0);return pU(()=>{let n=async()=>{await ls(r),t(!1)},r=Rr.find(i=>i.code===e.langCode)||xo;n()},[e.langCode]),o?hU(Pd,{theme:e.theme}):e.children};import gU from"clsx";import{jsx as xC}from"react/jsx-runtime";var EC=({children:e})=>{let{FooterCenterTunnel:o}=Se(),t=fe();return xC(o.In,{children:xC("div",{className:gU("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},fU=EC;EC.displayName="FooterCenter";import bU from"clsx";import{isMobileOrTablet as xU,MQ_MIN_WIDTH_DESKTOP as EU}from"@excalidraw/common";import{jsx as wU,jsxs as vU}from"react/jsx-runtime";var yC=({isCollaborating:e,onSelect:o,...t})=>{let n=fe(),r=xU()||n.width<EU;return vU(xt,{...t,className:bU("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:r?void 0:"auto"},title:g("labels.liveCollaboration"),children:[r?y0:g("labels.share"),n.collaborators.size>0&&wU("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},yU=yC;yC.displayName="LiveCollaborationTrigger";import{jsx as Kn,jsxs as vC}from"react/jsx-runtime";var TU=()=>Kn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Kn("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"})}),IU=()=>vC("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Kn("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)"}),Kn("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)"}),Kn("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)"}),Kn("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)"})]}),wC=({style:e,size:o="small",withText:t})=>vC("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Kn(TU,{}),t&&Kn(IU,{})]});import{Fragment as CC,jsx as Ze,jsxs as i1}from"react/jsx-runtime";var a1=({icon:e,shortcut:o,children:t})=>{let n=me();return i1(CC,{children:[Ze("div",{className:"welcome-screen-menu-item__icon",children:e}),Ze("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!n.editor.isMobile&&Ze("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};a1.displayName="WelcomeScreenMenuItemContent";var Vl=({onSelect:e,children:o,icon:t,shortcut:n,className:r="",...i})=>Ze("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:Ze(a1,{icon:t,shortcut:n,children:o})});Vl.displayName="WelcomeScreenMenuItem";var TC=({children:e,href:o,icon:t,shortcut:n,className:r="",...i})=>Ze("a",{...i,className:`welcome-screen-menu-item ${r}`,href:o,target:"_blank",rel:"noopener",children:Ze(a1,{icon:t,shortcut:n,children:e})});TC.displayName="WelcomeScreenMenuItemLink";var eo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Se();return Ze(o.In,{children:Ze("div",{className:"welcome-screen-center",children:e||i1(CC,{children:[Ze(l1,{}),Ze(s1,{children:g("welcomeScreen.defaults.center_heading")}),i1(c1,{children:[Ze(m1,{}),Ze(d1,{})]})]})})})};eo.displayName="Center";var l1=({children:e})=>Ze("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ze(wC,{withText:!0})});l1.displayName="Logo";var s1=({children:e})=>Ze("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});s1.displayName="Heading";var c1=({children:e})=>Ze("div",{className:"welcome-screen-menu",children:e});c1.displayName="Menu";var d1=()=>{let e=Ve();return Ze(Vl,{onSelect:()=>e.executeAction(dr),shortcut:"?",icon:Or,children:g("helpDialog.title")})};d1.displayName="MenuItemHelp";var m1=()=>{let e=fe(),o=Ve();return e.viewModeEnabled?null:Ze(Vl,{onSelect:()=>o.executeAction(di),shortcut:Oe("loadScene"),icon:zr,children:g("buttons.load")})};m1.displayName="MenuItemLoadScene";var IC=({onSelect:e})=>{let{t:o}=Ue();return Ze(Vl,{shortcut:null,onSelect:e,icon:fs,children:o("labels.liveCollaboration")})};IC.displayName="MenuItemLiveCollaborationTrigger";eo.Logo=l1;eo.Heading=s1;eo.Menu=c1;eo.MenuItem=Vl;eo.MenuItemLink=TC;eo.MenuItemHelp=d1;eo.MenuItemLoadScene=m1;eo.MenuItemLiveCollaborationTrigger=IC;import{jsx as ra,jsxs as p1}from"react/jsx-runtime";var Sm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Se();return ra(o.In,{children:p1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[e0,ra("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};Sm.displayName="MenuHint";var km=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Se();return ra(o.In,{children:p1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ra("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),o0]})})};km.displayName="ToolbarHint";var Mm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Se();return ra(o.In,{children:p1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ra("div",{children:e||g("welcomeScreen.defaults.helpHint")}),t0]})})};Mm.displayName="HelpHint";import{Fragment as SC,jsx as Xl,jsxs as SU}from"react/jsx-runtime";var Lm=e=>Xl(SC,{children:e.children||SU(SC,{children:[Xl(eo,{}),Xl(Sm,{}),Xl(km,{}),Xl(Mm,{})]})});Lm.displayName="WelcomeScreen";Lm.Center=eo;Lm.Hints={MenuHint:Sm,ToolbarHint:km,HelpHint:Mm};var CU=Lm;var kU=()=>{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)})},kC=kU;import{getSceneVersion as fDe,hashElementsVersion as bDe,hashString as xDe,getNonDeletedElements as EDe}from"@excalidraw/element";import{getTextFromElements as wDe}from"@excalidraw/element";import{isInvisiblySmallElement as TDe}from"@excalidraw/element";import MU from"lodash.throttle";import{arrayToMap as LU,isDevEnv as MC,isTestEnv as LC}from"@excalidraw/common";import{orderByFractionalIndex as PU,syncInvalidIndices as PC,validateFractionalIndices as AU}from"@excalidraw/element";var DU=(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)),_U=MU((e,o,t)=>{if(MC()||LC()||window?.DEBUG_FRACTIONAL_INDICES){let n=PC(e.map(r=>({...r})));AU(n,{shouldThrow:LC()||MC(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),RU=(e,o,t)=>{let n=LU(e),r=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=n.get(l.id),d=DU(t,s,l);s&&d?(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=PU(r);return _U(a,e,o),PC(a),a};import{getFreeDrawSvgPath as ADe}from"@excalidraw/element";import{isLinearElement as RDe}from"@excalidraw/element";import{FONT_FAMILY as BDe,THEME as FDe,MIME_TYPES as ODe,ROUNDNESS as Lc,DEFAULT_LASER_COLOR as zDe,UserIdleState as HDe,normalizeLink as GDe}from"@excalidraw/common";import{mutateElement as Ac,newElementWith as YDe,bumpVersion as wi}from"@excalidraw/element";import{CaptureUpdateAction as VDe}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Fy,viewportCoordsToSceneCoords as ZDe}from"@excalidraw/common";import{jsx as AC,jsxs as NU}from"react/jsx-runtime";var DC=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Se(),n=ce();return AC(t.In,{children:NU(be.Item,{onSelect:()=>{ae("ai","dialog open","ttd"),n({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??fb,children:[e??g("labels.textToDiagram"),AC(be.Item.Badge,{children:"AI"})]})})};DC.displayName="TTDDialogTrigger";import{getCommonBounds as a_e,getVisibleSceneBounds as l_e}from"@excalidraw/element";import{useLayoutEffect as BU}from"react";var FU=e=>{let o=Fe();return BU(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as p_e}from"@excalidraw/element";import{setCustomTextMetricsProvider as h_e}from"@excalidraw/element";import{jsx as u1}from"react/jsx-runtime";kC();var GU=e=>{let{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=xo.code,viewModeEnabled:d,zenModeEnabled:m,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:y=!0,handleKeyboardGlobally:E=!1,onLibraryChange:w,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:k,generateLinkForSelection:P,onPointerDown:S,onPointerUp:_,onScrollChange:M,onDuplicate:R,children:O,validateEmbeddable:V,renderEmbeddable:j,aiEnabled:A,showDeprecatedFonts:N,renderScrollbars:F}=e,W=e.UIOptions?.canvasActions,q={...e.UIOptions,canvasActions:{..._C.canvasActions,...W},tools:{image:e.UIOptions?.tools?.image??!0}};return W?.export&&(q.canvasActions.export.saveFileToDisk=W.export?.saveFileToDisk??_C.canvasActions.export.saveFileToDisk),q.canvasActions.toggleTheme===null&&typeof u>"u"&&(q.canvasActions.toggleTheme=!0),zU(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let Z=ie=>{typeof ie.scale=="number"&&ie.scale!==1&&ie.preventDefault()};return document.addEventListener("touchmove",Z,{passive:!1}),()=>{document.removeEventListener("touchmove",Z)}},[]),u1(V1,{store:Ye,children:u1(bC,{langCode:s,theme:u,children:u1(fC,{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:d,zenModeEnabled:m,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:q,onPaste:x,detectScroll:y,handleKeyboardGlobally:E,onLibraryChange:w,autoFocus:v,generateIdForFile:C,onLinkOpen:k,generateLinkForSelection:P,onPointerDown:S,onPointerUp:_,onScrollChange:M,onDuplicate:R,validateEmbeddable:V,renderEmbeddable:j,aiEnabled:A!==!1,showDeprecatedFonts:N,renderScrollbars:F,children:O})})})},UU=(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),d=Object.keys(a);return s.length!==d.length?!1:s.every(c=>c==="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[c]===a[c])&&HU(r,l)},YU=OU.memo(GU,UU);YU.displayName="Excalidraw";export{xt as Button,VDe as CaptureUpdateAction,zDe as DEFAULT_LASER_COLOR,Kd as DefaultSidebar,FU as DiagramToCodePlugin,Pa as Ellipsify,YU as Excalidraw,BDe as FONT_FAMILY,fU as Footer,yU as LiveCollaborationTrigger,ODe as MIME_TYPES,pt as MainMenu,Lc as ROUNDNESS,qt as Sidebar,Ll as Stats,FDe as THEME,Zg as TTDDialog,DC as TTDDialogTrigger,HDe as UserIdleState,CU as WelcomeScreen,wi as bumpVersion,Gi as convertToExcalidrawElements,xo as defaultLang,Tw as elementPartiallyOverlapsWithOrContainsBBox,Iw as elementsOverlappingBBox,Uy as exportToBlob,wn as exportToCanvas,PA as exportToClipboard,Ci as exportToSvg,a_e as getCommonBounds,Om as getDataURL,ADe as getFreeDrawSvgPath,Bc as getLibraryItemsHash,EDe as getNonDeletedElements,fDe as getSceneVersion,wDe as getTextFromElements,l_e as getVisibleSceneBounds,bDe as hashElementsVersion,xDe as hashString,Gh as isElementInsideBBox,p_e as isElementLink,TDe as isInvisiblySmallElement,RDe as isLinearElement,Rr as languages,os as loadFromBlob,Fm as loadLibraryFromBlob,Bm as loadSceneOrLibraryFromBlob,qy as mergeLibraryItems,Ac as mutateElement,YDe as newElementWith,GDe as normalizeLink,ah as parseLibraryTokensFromUrl,RU as reconcileElements,Dr as restore,OC as restoreAppState,FC as restoreElement,Rm as restoreElements,da as restoreLibraryItems,Fy as sceneCoordsToViewportCoords,la as serializeAsJSON,BC as serializeLibraryAsJSON,h_e as setCustomTextMetricsProvider,me as useDevice,XA as useHandleLibrary,Ue as useI18n,ZDe as viewportCoordsToSceneCoords,qx as zoomToFitBounds};
|
|
118
|
+
`),n)}}addTextFromPaste(o,n=!1){let{x:r,y:i}=Ue({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:o,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:dG,verticalAlign:H5,locked:!1},l=Ff({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=V5(a.fontFamily),[d,,m]=mU(this.state),c=Math.max(Math.min((m-d)*.5,800),200),p=10,u=i,f=n?[o]:o.split(`
|
|
119
|
+
`),b=f.reduce((x,w,E)=>{let y=xU(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),I=bC(y,l,s),S=I.width>c,L=S?gU(y,l,c):y;I=S?bC(L,l,s):I;let k=r-I.width/2,R=u-I.height/2,M=tC({...a,x:k,y:R,text:L,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(M),u+=M.height+p}else f[E-1]?.trim()&&(u+=EU(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:Te(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!n&&b.length>1&&PC===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:xG("CtrlOrCmd+Shift+V")}),duration:5e3}),PC=!0))}handleTextWysiwyg(o,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===o.id&&fo(s)?$n(s,{originalText:a,isDeleted:l??s.isDeleted,...YG(s,pC(s,r),r,a)}):s)])};l3({id:o.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:d}=Pm({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,d-this.state.offsetTop]},onChange:De(a=>{i(a,!1),IC(o)&&Yf(o,this.scene)}),onSubmit:De(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let d=o.containerId?o.containerId:o.id;ma(()=>{this.setState(m=>({selectedElementIds:Te({...m.selectedElementIds,[d]:!0},m)}))})}s&&RG(this.scene.getNonDeletedElements(),[o]),(!s||n)&&this.store.scheduleCapture(),ma(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Rt(this.interactiveCanvas,this.state),this.focusContainer()}),element:o,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(o.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(o,n){let r=this.getElementAtPosition(o,n,{includeBoundTextElement:!0});return r&&fo(r)&&!r.isDeleted?r:null}getElementAtPosition(o,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(o,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 ts({point:se(o,n),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Mt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(o,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||!(fo(s)&&s.containerId)))).filter(s=>this.hitElement(o,n,s)).filter(s=>{let d=n1(s,a);return d&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?uC({x:o,y:n},d,a):!0}).filter(s=>fa(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(o){return Math.max(o.strokeWidth/2+.1,.85*(W5/this.state.zoom.value))}hitElement(o,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&tU([r],this.state)&&BU(se(o,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||cU(se(o,n),r,this.scene.getNonDeletedElementsMap())?!0:ts({point:se(o,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Mt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(o,n){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return iC(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,d,m,c]=q5(r[l],this.scene.getNonDeletedElementsMap());if(Xf(r[l])&&ts({point:se(o,n),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<o&&o<m&&d<n&&n<c){a=r[l];break}}return iC(a,!1)?a:null}handleHoverSelectedLinearElement(o,n,r){let i=this.scene.getNonDeletedElementsMap(),a=Se.getElement(o.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;ts({point:se(n,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Se.getPointIndexUnderCursor(a,i,this.state.zoom,n,r),s=Se.getSegmentMidpointHitCoords(o,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),($e(a)?l===0||l===a.points.length-1:l>=0)||s?ye(this.interactiveCanvas,Re.POINTER):this.hitElement(n,r,a)&&(!$e(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,Re.MOVE)):this.hitElement(n,r,a)&&(!$e(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,Re.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 ye(this.interactiveCanvas,Re.AUTO)}updateGestureOnPointerDown(o){fe.pointers.set(o.pointerId,{x:o.clientX,y:o.clientY}),fe.pointers.size===2&&(fe.lastCenter=rg(fe.pointers),fe.initialScale=this.state.zoom.value,fe.initialDistance=ig(Array.from(fe.pointers.values())))}initialPointerDownState(o){let n=Ue(o,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=ga(r),d=r.findIndex($e)===0;return{origin:n,withCmdOrCtrl:o[W.CTRL_OR_CMD],originInGrid:zf(lt(n.x,n.y,o[W.CTRL_OR_CMD]||d?null:this.getEffectiveGridSize())),scrollbars:ug(as,o.clientX-this.state.offsetLeft,o.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((m,c)=>(m.set(c.id,oC(c)),m),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(o,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;a1=!0,n.lastCoords.x=o.clientX,n.lastCoords.y=o.clientY;let r=Bd(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,n)}),i=De(()=>{ss=null,a1=!1,Rt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(o.clientX,o.clientY,"up"),window.removeEventListener(oe.POINTER_MOVE,r),window.removeEventListener(oe.POINTER_UP,i),r.flush()});return ss=i,window.addEventListener(oe.POINTER_MOVE,r),window.addEventListener(oe.POINTER_UP,i),!0}isASelectedElement(o){return o!=null&&this.state.selectedElementIds[o.id]}isHittingCommonBoundingBoxOfSelectedElements(o,n){if(n.length<2)return!1;let r=Math.max(W5/this.state.zoom.value,1),[i,a,l,s]=ga(n);return o.x>i-r&&o.x<l+r&&o.y>a-r&&o.y<s+r}getCurrentItemRoundness(o){return this.state.currentItemRoundness==="round"?{type:VG(o)?Sm.ADAPTIVE_RADIUS:Sm.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(o,n,r=!1){Jo({event:o,app:this,selectedElements:n})&&(r||!Zt.getReferenceSnapPoints())&&Zt.setReferenceSnapPoints(Iv(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(o,n,r=!1){Jo({event:o,app:this,selectedElements:n})&&(r||!Zt.getVisibleGaps())&&Zt.setVisibleGaps(Tv(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(o){return De(n=>{this.maybeHandleResize(o,n)||this.maybeDragNewGenericElement(o,n)})}onKeyUpFromPointerDownHandler(o){return De(n=>{n.key===W.ALT&&n.preventDefault(),!this.maybeHandleResize(o,n)&&this.maybeDragNewGenericElement(o,n)})}onPointerMoveFromPointerDownHandler(o){return Bd(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Ue(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]=lt(r.x,r.y,n[W.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??o.origin;if(this.lastPointerMoveCoords=r,o.drag.offset===null&&(o.drag.offset=zf(RU(this.scene.getSelectedElements(this.state),o.origin.x,o.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,o))return;if(vt(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[l,s]=lt(r.x,r.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!o.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Xn(se(r.x,r.y),se(o.origin.x,o.origin.y))*this.state.zoom.value<$5)return;if(o.resize.isResizing&&(o.lastCoords.x=r.x,o.lastCoords.y=r.y,this.maybeHandleCrop(o,n)||this.maybeHandleResize(o,n)))return!0;let d=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Se.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,d)){let f=Se.addMidpoint(this.state.selectedLinearElement,r,this,!n[W.CTRL_OR_CMD],this.scene);if(!f)return;ma(()=>{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(n,this,r.x,r.y,p);if(u){o.lastCoords.x=r.x,o.lastCoords.y=r.y,o.drag.hasOccurred=!0,this.setState(u);return}}let m=o.hit.allHitElements.some(p=>this.isASelectedElement(p)),c=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===o.hit.element?.id;if((m||o.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&!o.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(x=>x.locked))return;let u=p.find(x=>Mt(x)),f=this.getTopLayerFrameAtSceneCoords(r),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&ma(()=>{this.setState({frameToHighlight:b})}),o.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(ha()&&o.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&o.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!o.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:r.x-o.drag.origin.x,y:r.y-o.drag.origin.y},w=[...o.originalElements.values()],E=n.shiftKey;if(E){let I=Math.abs(x.x),S=Math.abs(x.y),L=E&&I<S,k=E&&I>S;L&&(x.x=0),k&&(x.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&Sr(I)&&I.crop!==null&&o.hit.element===I){let S=I.crop,L=Ql(I)&&this.imageCache.get(I.fileId)?.image;if(L&&!(L instanceof Promise)){let k=XH(R5(r.x-i.x,r.y-i.y),Math.max(this.state.zoom.value,2)),[R,M,_,N,K,J]=q5(I,d),A=Rf(_f(se(R,M),se(K,J),I.angle)),B=Rf(_f(se(_,M),se(K,J),I.angle)),H=Rf(_f(se(R,N),se(K,J),I.angle)),Y=O5(N5(B,A)),q=O5(N5(H,A)),pe=R5(B5(k,Y),B5(k,q)),j={...S,x:_5(S.x-pe[0]*Math.sign(I.scale[0]),0,L.naturalWidth-S.width),y:_5(S.y-pe[1]*Math.sign(I.scale[1]),0,L.naturalHeight-S.height)};this.scene.mutateElement(I,{crop:j});return}}}this.maybeCacheVisibleGaps(n,p),this.maybeCacheReferenceSnapPoints(n,p);let{snapOffset:y,snapLines:v}=Cv(w,x,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||_U(o,p,x,this.scene,y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!$e(p[0]))&&this.setState({suggestedBindings:Wf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),n.altKey&&!o.hit.hasBeenDuplicated){o.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),S=o.hit.element,L=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&o.hit.wasAddedToSelection&&!L.find(B=>B.id===S.id)&&L.push(S);let k=new Map(L.map(B=>[B.id,B])),{duplicatedElements:R,duplicateElementsMap:M,elementsWithDuplicates:_,origIdToDuplicateId:N}=Vf({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:B,origElement:H})=>({frameId:B.frameId??H.frameId,seed:CG()})});R.forEach(B=>{o.originalElements.set(B.id,oC(B))});let K=_.map(B=>{if(k.has(B.id)){let H=o.originalElements.get(B.id);if(H)return $n(B,{x:H.x,y:H.y})}return B}),J=this.props.onDuplicate?.(K,I),A=EC(J||K,Lm(R));ma(()=>{if(o.hit.element){let B=N.get(o.hit.element.id),H=B&&M.get(B);o.hit.element=H||null}o.hit.allHitElements=o.hit.allHitElements.reduce((B,H)=>{let Y=N.get(H.id),q=Y&&M.get(Y);return q&&B.push(q),B},[]),o.drag.origin=Ue(n,this.state),this.setState(B=>({...PU(R,this.scene.getNonDeletedElements(),B)})),this.scene.replaceAllElements(A),this.maybeCacheVisibleGaps(n,L,!0),this.maybeCacheReferenceSnapPoints(n,L,!0)})}return}}if(this.state.selectionElement){if(o.lastCoords.x=r.x,o.lastCoords.y=r.y,n.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(o.origin.x,o.origin.y,n.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(o,n)}else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",o),o.lastCoords.x=r.x,o.lastCoords.y=r.y,this.maybeDragNewGenericElement(o,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,se(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Qt(p)){o.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Nf(n)&&u.length===2&&({width:f,height:b}=aC(p.x,p.y,r.x,r.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,se(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&$e(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),se(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),Kf(p,!1)&&this.setState({suggestedBindings:j5(p,[r],this.scene,this.state.zoom,this.state.startBoundElement)})}else o.lastCoords.x=r.x,o.lastCoords.y=r.y,this.maybeDragNewGenericElement(o,n,!1)}if(this.state.activeTool.type==="selection"){o.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Se.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!n.shiftKey&&ve(p,this.state)&&(o.withCmdOrCtrl&&o.hit.element?this.setState(b=>eo({...b,selectedElementIds:{[o.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?A1(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 o.hit.element&&(f.length?delete x[o.hit.element.id]:x[o.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...eo({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&Qt(f[0])?new Se(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||an(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(o,n){if(n.scrollbars.isOverHorizontal){let r=o.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(as.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=o.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(as.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(o){return De(n=>{this.removePointer(n),o.drag.blockDragging=!1,o.eventListeners.onMove&&o.eventListeners.onMove.flush();let{newElement:r,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:d,isRotating:m,isCropping:c}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Jl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Zt.setReferenceSnapPoints(null),Zt.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let p=o.hit.allHitElements,u=Ue({clientX:n.clientX,clientY:n.clientY},this.state);if(this.state.activeTool.type==="selection"&&!o.boxSelection.hasOccurred&&!o.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(o.drag.hasOccurred&&o.hit?.element?.id){let E=f.get(o.hit.element.id);KG(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>f.get(y.id)).filter(y=>$e(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing)if(!o.boxSelection.hasOccurred&&o.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(Nt);else{let E=Se.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=Se.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}o.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(Nt,"ui",{event:n,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(oe.POINTER_MOVE,o.eventListeners.onMove),window.removeEventListener(oe.POINTER_UP,o.eventListeners.onUp),window.removeEventListener(oe.KEYDOWN,o.eventListeners.onKeyDown),window.removeEventListener(oe.KEYUP,o.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,o),this.onPointerUpEmitter.trigger(this.state.activeTool,o,n),r?.type==="freedraw"){let E=Ue(n,this.state),y=r.points,v=E.x-r.x,I=E.y-r.y;v===y[0][0]&&I===y[0][1]&&(I+=1e-4,v+=1e-4);let S=r.simulatePressure?[]:[...r.pressures,n.pressure];this.scene.mutateElement(r,{points:[...y,se(v,I)],pressures:S,lastCommittedPoint:se(v,I)}),this.actionManager.executeAction(Nt);return}if(Qt(r)){r.points.length>1&&this.store.scheduleCapture();let E=Ue(n,this.state),y=Xn(se(E.x,E.y),se(o.origin.x,o.origin.y))*this.state.zoom.value;if((!o.drag.hasOccurred||y<$5)&&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:[se(0,0),se(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(Nt)}else{let v=E.x-r.x,I=E.y-r.y;this.scene.mutateElement(r,{points:[...r.points,se(v,I)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:r,newElement:r})}else o.drag.hasOccurred&&!l&&(Uf(this.state)&&Kf(r,!1)&&this.actionManager.executeAction(Nt,"ui",{event:n,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Wt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:rn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Te({...v.selectedElementIds,[r.id]:!0},v),selectedLinearElement:new Se(r,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(fo(r)){let E=vU(Ff({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&&sC(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==r.id),appState:{newElement:null},captureUpdate:wt.NEVER});return}if(Mt(r)){let E=rU(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(t1(this.scene.getElementsMapIncludingDeleted(),E,r,this.state))}if(r&&(this.scene.mutateElement(r,ZG(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),o.drag.hasOccurred){let E=Ue(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=n1(y,f);v&&y&&(iU(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),nU([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),I=this.scene.getElementsMapIncludingDeleted(),S=L=>{if(L.length>0){for(let k of L){let R=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,R)},{informMutation:!1,isDragging:!1})}I.forEach(k=>{k.groupIds.length&&kr(I,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&&gC(k,I,this.state));this.state.editingGroupId&&S(L),I=t1(I,L,y,this.state)}else if(!y&&this.state.editingGroupId){let L=v.filter(k=>k.frameId&&!gC(k,I,this.state));S(L)}I=hC(I,this.state,this),this.scene.replaceAllElements(I)}}if(i&&this.store.scheduleCapture(),i&&sC(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:wt.NEVER}),o.resize.isResizing){let E=hC(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>Mt(v));for(let v of y)E=oU(E,o1(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=o.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&Qt(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Se(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!c||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(vt(this.state)&&x&&w){if(this.eraserTrail.endPath(),Xn(se(x.clientX,x.clientY),se(w.clientX,w.clientY))===0){let y=Ue({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(I=>this.elementsPendingErasure.add(I.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!o.drag.hasOccurred&&!o.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!o.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(n.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?kU(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(I=>kr(this.scene.getNonDeletedElements(),I)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,I)=>({...v,...I}),{})},selectedElementIds:Te(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let v=Q(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...eo({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&Qt(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=>kr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...eo({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||an(b)?"info":!1}}):this.setState(E=>({selectedElementIds:Te({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...eo({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:Qt(b)&&E.selectedLinearElement?.elementId!==b.id?new Se(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&$e(b))&&!o.drag.hasOccurred&&!this.state.isResizing&&(b&&dU({point:se(o.origin.x,o.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:Mt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&o.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction($i):this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),ye(this.interactiveCanvas,Re.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&r&&this.setState(E=>({selectedElementIds:Te({...E.selectedElementIds,[r.id]:!0},E),showHyperlinkPopup:an(r)&&!r.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||ve(this.scene.getNonDeletedElements(),this.state)||!IG(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),o.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||c){let E=this.scene.getSelectedElements(this.state).filter(Qt);J5(E,Uf(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)?(Wt(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:rn(this.state,{type:this.state.preferredSelectionTool.type})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&fe.pointers.size<=1&&es(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,o.origin.x,o.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(o){this.setState(n=>({selectedElementIds:Te({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&o!=null&&xC(o,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:Te({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(o,n,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Qf(i,r,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(o-a,n-l)<rG){let{x:c,y:p}=Pm({sceneX:a,sceneY:l},r);return{viewportX:c,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{left:n,top:r}=o.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let o=Or.find(n=>n.code===this.props.langCode)||Eo;await Ts(o),this.setAppState({})}},FU=()=>{(c1()||LC())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(AC(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};FU();var NC=d1;import{useEffect as HU,useState as GU}from"react";import{jsx as UU}from"react/jsx-runtime";var BC=e=>{let[t,o]=GU(!0);return HU(()=>{let n=async()=>{await Ts(r),o(!1)},r=Or.find(i=>i.code===e.langCode)||Eo;n()},[e.langCode]),t?UU(Hd,{theme:e.theme}):e.children};import YU from"clsx";import{jsx as OC}from"react/jsx-runtime";var FC=({children:e})=>{let{FooterCenterTunnel:t}=Ce(),o=xe();return OC(t.In,{children:OC("div",{className:YU("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":o.zenModeEnabled}),children:e})})},WU=FC;FC.displayName="FooterCenter";import VU from"clsx";import{isMobileOrTablet as XU,MQ_MIN_WIDTH_DESKTOP as KU}from"@excalidraw/common";import{jsx as $U,jsxs as jU}from"react/jsx-runtime";var zC=({isCollaborating:e,onSelect:t,...o})=>{let n=xe(),r=XU()||n.width<KU;return jU(xt,{...o,className:VU("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:r?void 0:"auto"},title:g("labels.liveCollaboration"),children:[r?kb:g("labels.share"),n.collaborators.size>0&&$U("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},ZU=zC;zC.displayName="LiveCollaborationTrigger";import{jsx as Jn,jsxs as GC}from"react/jsx-runtime";var qU=()=>Jn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Jn("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"})}),JU=()=>GC("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Jn("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)"}),Jn("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)"}),Jn("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)"}),Jn("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)"})]}),HC=({style:e,size:t="small",withText:o})=>GC("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Jn(qU,{}),o&&Jn(JU,{})]});import{Fragment as WC,jsx as je,jsxs as b1}from"react/jsx-runtime";var x1=({icon:e,shortcut:t,children:o})=>{let n=he();return b1(WC,{children:[je("div",{className:"welcome-screen-menu-item__icon",children:e}),je("div",{className:"welcome-screen-menu-item__text",children:o}),t&&!n.editor.isMobile&&je("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};x1.displayName="WelcomeScreenMenuItemContent";var cs=({onSelect:e,children:t,icon:o,shortcut:n,className:r="",...i})=>je("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:je(x1,{icon:o,shortcut:n,children:t})});cs.displayName="WelcomeScreenMenuItem";var UC=({children:e,href:t,icon:o,shortcut:n,className:r="",...i})=>je("a",{...i,className:`welcome-screen-menu-item ${r}`,href:t,target:"_blank",rel:"noopener",children:je(x1,{icon:o,shortcut:n,children:e})});UC.displayName="WelcomeScreenMenuItemLink";var to=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=Ce();return je(t.In,{children:je("div",{className:"welcome-screen-center",children:e||b1(WC,{children:[je(E1,{}),je(y1,{children:g("welcomeScreen.defaults.center_heading")}),b1(w1,{children:[je(T1,{}),je(v1,{})]})]})})})};to.displayName="Center";var E1=({children:e})=>je("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||je(HC,{withText:!0})});E1.displayName="Logo";var y1=({children:e})=>je("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});y1.displayName="Heading";var w1=({children:e})=>je("div",{className:"welcome-screen-menu",children:e});w1.displayName="Menu";var v1=()=>{let e=Ve();return je(cs,{onSelect:()=>e.executeAction(ur),shortcut:"?",icon:Vr,children:g("helpDialog.title")})};v1.displayName="MenuItemHelp";var T1=()=>{let e=xe(),t=Ve();return e.viewModeEnabled?null:je(cs,{onSelect:()=>t.executeAction(xi),shortcut:ze("loadScene"),icon:Xr,children:g("buttons.load")})};T1.displayName="MenuItemLoadScene";var YC=({onSelect:e})=>{let{t}=Ne();return je(cs,{shortcut:null,onSelect:e,icon:Ls,children:t("labels.liveCollaboration")})};YC.displayName="MenuItemLiveCollaborationTrigger";to.Logo=E1;to.Heading=y1;to.Menu=w1;to.MenuItem=cs;to.MenuItemLink=UC;to.MenuItemHelp=v1;to.MenuItemLoadScene=T1;to.MenuItemLiveCollaborationTrigger=YC;import{jsx as ba,jsxs as I1}from"react/jsx-runtime";var Rm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=Ce();return ba(t.In,{children:I1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[db,ba("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};Rm.displayName="MenuHint";var Nm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=Ce();return ba(t.In,{children:I1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ba("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),pb]})})};Nm.displayName="ToolbarHint";var Bm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=Ce();return ba(t.In,{children:I1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ba("div",{children:e||g("welcomeScreen.defaults.helpHint")}),mb]})})};Bm.displayName="HelpHint";import{Fragment as VC,jsx as ds,jsxs as eY}from"react/jsx-runtime";var Om=e=>ds(VC,{children:e.children||eY(VC,{children:[ds(to,{}),ds(Rm,{}),ds(Nm,{}),ds(Bm,{})]})});Om.displayName="WelcomeScreen";Om.Center=to;Om.Hints={MenuHint:Rm,ToolbarHint:Nm,HelpHint:Bm};var QU=Om;var tY=()=>{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)})},XC=tY;import{getSceneVersion as f_e,hashElementsVersion as b_e,hashString as x_e,getNonDeletedElements as E_e}from"@excalidraw/element";import{getTextFromElements as w_e}from"@excalidraw/element";import{isInvisiblySmallElement as T_e}from"@excalidraw/element";import oY from"lodash.throttle";import{arrayToMap as nY,isDevEnv as KC,isTestEnv as ZC}from"@excalidraw/common";import{orderByFractionalIndex as rY,syncInvalidIndices as $C,validateFractionalIndices as iY}from"@excalidraw/element";var aY=(e,t,o)=>!!(t&&(t.id===e.editingTextElement?.id||t.id===e.resizingElement?.id||t.id===e.newElement?.id||t.version>o.version||t.version===o.version&&t.versionNonce<o.versionNonce)),lY=oY((e,t,o)=>{if(KC()||ZC()||window?.DEBUG_FRACTIONAL_INDICES){let n=$C(e.map(r=>({...r})));iY(n,{shouldThrow:ZC()||KC(),includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:o}})}},1e3*60,{leading:!0,trailing:!1}),sY=(e,t,o)=>{let n=nY(e),r=[],i=new Set;for(let l of t)if(!i.has(l.id)){let s=n.get(l.id),d=aY(o,s,l);s&&d?(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=rY(r);return lY(a,e,t),$C(a),a};import{getFreeDrawSvgPath as A_e}from"@excalidraw/element";import{isLinearElement as R_e}from"@excalidraw/element";import{FONT_FAMILY as B_e,THEME as O_e,MIME_TYPES as F_e,ROUNDNESS as Gc,DEFAULT_LASER_COLOR as z_e,UserIdleState as H_e,normalizeLink as G_e}from"@excalidraw/common";import{mutateElement as Yc,newElementWith as Y_e,bumpVersion as Pi}from"@excalidraw/element";import{CaptureUpdateAction as V_e}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Uy,viewportCoordsToSceneCoords as Z_e}from"@excalidraw/common";import{jsx as jC,jsxs as cY}from"react/jsx-runtime";var qC=({children:e,icon:t})=>{let{t:o}=Ne(),{TTDDialogTriggerTunnel:n}=Ce(),r=me();return jC(n.In,{children:cY(le.Item,{onSelect:()=>{ie("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??v0,children:[e??o("labels.textToDiagram"),jC(le.Item.Badge,{children:"AI"})]})})};qC.displayName="TTDDialogTrigger";import{getCommonBounds as aRe,getVisibleSceneBounds as lRe}from"@excalidraw/element";import{useLayoutEffect as dY}from"react";var mY=e=>{let t=Fe();return dY(()=>{t.setPlugins({diagramToCode:{generate:e.generate}})},[t,e.generate]),null};import{isElementLink as pRe}from"@excalidraw/element";import{setCustomTextMetricsProvider as hRe}from"@excalidraw/element";import{jsx as C1}from"react/jsx-runtime";XC();var gY=e=>{let{onChange:t,onIncrement:o,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:a,renderTopLeftUI:l,renderTopRightUI:s,langCode:d=Eo.code,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:p,libraryReturnUrl:u,theme:f,name:b,renderCustomStats:x,onPaste:w,detectScroll:E=!0,handleKeyboardGlobally:y=!1,onLibraryChange:v,autoFocus:I=!1,generateIdForFile:S,onLinkOpen:L,generateLinkForSelection:k,onPointerDown:R,onPointerUp:M,onScrollChange:_,onDuplicate:N,children:K,validateEmbeddable:J,renderEmbeddable:A,aiEnabled:B,showDeprecatedFonts:H,renderScrollbars:Y}=e,q=e.UIOptions?.canvasActions,pe={...e.UIOptions,canvasActions:{...JC.canvasActions,...q},tools:{image:e.UIOptions?.tools?.image??!0}};return q?.export&&(pe.canvasActions.export.saveFileToDisk=q.export?.saveFileToDisk??JC.canvasActions.export.saveFileToDisk),pe.canvasActions.toggleTheme===null&&typeof f>"u"&&(pe.canvasActions.toggleTheme=!0),uY(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ne=we=>{typeof we.scale=="number"&&we.scale!==1&&we.preventDefault()};return document.addEventListener("touchmove",ne,{passive:!1}),()=>{document.removeEventListener("touchmove",ne)}},[]),C1(tb,{store:We,children:C1(BC,{langCode:d,theme:f,children:C1(NC,{onChange:t,onIncrement:o,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:a,renderTopLeftUI:l,renderTopRightUI:s,langCode:d,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:p,libraryReturnUrl:u,theme:f,name:b,renderCustomStats:x,UIOptions:pe,onPaste:w,detectScroll:E,handleKeyboardGlobally:y,onLibraryChange:v,autoFocus:I,generateIdForFile:S,onLinkOpen:L,generateLinkForSelection:k,onPointerDown:R,onPointerUp:M,onScrollChange:_,onDuplicate:N,validateEmbeddable:J,renderEmbeddable:A,aiEnabled:B!==!1,showDeprecatedFonts:H,renderScrollbars:Y,children:K})})})},fY=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:o,UIOptions:n={},...r}=e,{initialData:i,UIOptions:a={},...l}=t,s=Object.keys(n),d=Object.keys(a);return s.length!==d.length?!1:s.every(c=>c==="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[c]===a[c])&&hY(r,l)},bY=pY.memo(gY,fY);bY.displayName="Excalidraw";export{xt as Button,V_e as CaptureUpdateAction,z_e as DEFAULT_LASER_COLOR,tm as DefaultSidebar,mY as DiagramToCodePlugin,Va as Ellipsify,bY as Excalidraw,B_e as FONT_FAMILY,WU as Footer,ZU as LiveCollaborationTrigger,F_e as MIME_TYPES,pt as MainMenu,Gc as ROUNDNESS,Jt as Sidebar,Kl as Stats,O_e as THEME,af as TTDDialog,qC as TTDDialogTrigger,H_e as UserIdleState,QU as WelcomeScreen,Pi as bumpVersion,Ji as convertToExcalidrawElements,Eo as defaultLang,B2 as elementPartiallyOverlapsWithOrContainsBBox,O2 as elementsOverlappingBBox,Ky as exportToBlob,kn as exportToCanvas,JA as exportToClipboard,_i as exportToSvg,aRe as getCommonBounds,Km as getDataURL,A_e as getFreeDrawSvgPath,Zc as getLibraryItemsHash,E_e as getNonDeletedElements,f_e as getSceneVersion,w_e as getTextFromElements,lRe as getVisibleSceneBounds,b_e as hashElementsVersion,x_e as hashString,Zh as isElementInsideBBox,pRe as isElementLink,T_e as isInvisiblySmallElement,R_e as isLinearElement,Or as languages,xs as loadFromBlob,Xm as loadLibraryFromBlob,Vm as loadSceneOrLibraryFromBlob,ow as mergeLibraryItems,Yc as mutateElement,Y_e as newElementWith,G_e as normalizeLink,uh as parseLibraryTokensFromUrl,sY as reconcileElements,Nr as restore,nS as restoreAppState,oS as restoreElement,Ym as restoreElements,Ca as restoreLibraryItems,Uy as sceneCoordsToViewportCoords,va as serializeAsJSON,tS as serializeLibraryAsJSON,hRe as setCustomTextMetricsProvider,he as useDevice,h8 as useHandleLibrary,Ne as useI18n,Z_e as viewportCoordsToSceneCoords,oE as zoomToFitBounds};
|