@myoc/excalidraw 0.19.532 → 0.19.533
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/CHANGELOG.md +107 -0
- package/dist/dev/{chunk-ASAPRLCW.js → chunk-5CVRJMG3.js} +2 -2
- package/dist/dev/{chunk-ITMOGRAW.js → chunk-AR7I2OPB.js} +23 -8
- package/dist/dev/chunk-AR7I2OPB.js.map +7 -0
- package/dist/dev/data/{image-S7APFFV6.js → image-XXT3R6SF.js} +3 -3
- package/dist/dev/index.css +239 -0
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +1294 -591
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/{chunk-GSRXJLOQ.js → chunk-6D6KWUBN.js} +1 -1
- package/dist/prod/chunk-AS35EYHE.js +4 -0
- package/dist/prod/data/image-6PNCNKLO.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +13 -13
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/src/constants.d.ts +1 -0
- package/dist/types/element/src/gif.d.ts +29 -0
- package/dist/types/element/src/image.d.ts +6 -1
- package/dist/types/element/src/index.d.ts +2 -0
- package/dist/types/element/src/newElement.d.ts +1 -0
- package/dist/types/element/src/renderGif.d.ts +5 -0
- package/dist/types/element/src/types.d.ts +12 -0
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionExport.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +4 -3
- package/dist/types/excalidraw/actions/actionGroup.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +8 -1
- package/dist/types/excalidraw/components/App.gif.d.ts +18 -0
- package/dist/types/excalidraw/components/GifPlaybackControls.d.ts +10 -0
- package/dist/types/excalidraw/components/icons.d.ts +4 -0
- package/dist/types/excalidraw/data/blob.d.ts +2 -2
- package/dist/types/excalidraw/data/json.d.ts +1 -1
- package/dist/types/excalidraw/data/restoreGif.d.ts +4 -0
- package/dist/types/excalidraw/scene/Renderer.d.ts +1 -0
- package/dist/types/excalidraw/scene/types.d.ts +2 -1
- package/dist/types/excalidraw/types.d.ts +12 -2
- package/dist/types/excalidraw/viewport.d.ts +1 -1
- package/package.json +5 -5
- package/dist/dev/chunk-ITMOGRAW.js.map +0 -7
- package/dist/prod/chunk-U3WBDUKM.js +0 -4
- package/dist/prod/data/image-MWFLMJV7.js +0 -1
- /package/dist/dev/{chunk-ASAPRLCW.js.map → chunk-5CVRJMG3.js.map} +0 -0
- /package/dist/dev/data/{image-S7APFFV6.js.map → image-XXT3R6SF.js.map} +0 -0
package/dist/prod/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import{$ as ui,A as jb,B as uu,C as is,D as fc,E as hu,F as qb,G as Jb,H as Ec,I as as,J as bc,K as xc,L as ss,M as Qb,N as ex,O as tx,P as wc,Q as Ir,R as e3,S as Tr,T as pi,V as nx,X as ox,Y as rx,Z as yc,_ as ix,a as cu,aa as ls,b as On,ba as cs,c as ro,ca as ax,d as vr,da as vc,e as ci,ea as sx,f as Fn,fa as lx,g as Vb,ga as cx,h as Me,ha as gu,i as Yb,ia as dx,j as se,ja as mx,k as di,ka as px,l as Do,la as Sr,m as Xb,n as du,o as Kb,p as os,q as Zb,r as gc,s as $b,t as mu,u as pu,v as io,w as _o,x as Jt,y as rs,z as mi}from"./chunk-U3WBDUKM.js";import{a as S}from"./chunk-GSRXJLOQ.js";import{G as lu}from"./chunk-DARW3V66.js";import{c as Wb}from"./chunk-5XKZK2GL.js";import{b as Ub,c as QM,d as I}from"./chunk-SRAX5OIU.js";import _X,{useCallback as RX,useContext as NX,useEffect as BX,useRef as OX,useState as FX}from"react";import{applyDarkModeFilter as fWe,DEFAULT_IMAGE_OPTIONS as Ao,DEFAULT_UI_OPTIONS as $M,getStrokeWidthByKey as EWe,isShallowEqual as zX}from"@excalidraw/common";import Tk from"clsx";import uV from"lodash.throttle";import En,{useContext as Mo}from"react";import{flushSync as Rt}from"react-dom";import hV from"roughjs/bin/rough";import{nanoid as gV}from"nanoid";import{clamp as Zl,pointFrom as ne,pointDistance as Qn,vector as Sk,pointRotateRads as eb,vectorFromPoint as tb,vectorSubtract as Ck,vectorDot as Pk,vectorNormalize as kk}from"@excalidraw/math";import{CODES as fr,shouldResizeFromCenter as Mk,shouldMaintainAspectRatio as $l,shouldRotateWithDiscreteAngle as Ak,isArrowKey as nb,KEYS as X,APP_NAME as fV,CURSOR_TYPE as Pe,DEFAULT_STROKE_STREAMLINE as EV,DEFAULT_STROKE_STREAMLINE_PRECISE as bV,DEFAULT_TRANSFORM_HANDLE_SPACING as xV,DEFAULT_VERTICAL_ALIGN as Lk,DRAGGING_THRESHOLD as Dk,ELEMENT_SHIFT_TRANSLATE_AMOUNT as wV,ELEMENT_TRANSLATE_AMOUNT as _k,EVENT as J,FRAME_STYLE as To,IMAGE_MIME_TYPES as yV,IMAGE_RENDER_TIMEOUT as vV,LINE_CONFIRM_THRESHOLD as ob,MIME_TYPES as Ka,MQ_RIGHT_SIDEBAR_MIN_WIDTH as IV,POINTER_BUTTON as Dn,ROUNDNESS as Op,SCROLL_TIMEOUT as TV,TAP_TWICE_TIMEOUT as Rk,TEXT_TO_CENTER_SNAP_THRESHOLD as SV,THEME as jl,TOUCH_CTX_MENU_TIMEOUT as CV,VERTICAL_ALIGN as PV,YOUTUBE_STATES as Fp,ZOOM_STEP as kV,MIN_ZOOM as MV,POINTER_EVENTS as Za,TOOL_TYPE as _n,supportsResizeObserver as AV,DEFAULT_COLLISION_THRESHOLD as Nk,DEFAULT_TEXT_ALIGN as LV,ARROW_TYPE as Er,DEFAULT_REDUCED_GLOBAL_ALPHA as DV,isLocalLink as _V,normalizeLink as zp,toValidURL as RV,getGridPoint as Ct,getLineHeight as Bk,debounce as Ok,distance as $a,getFontString as rb,getNearestScrollableContainer as NV,isInputLike as Fk,isToolIcon as BV,isWritableElement as ql,sceneCoordsToViewportCoords as Hp,tupleToCoors as ib,viewportCoordsToSceneCoords as Ce,wrapEvent as OV,updateObject as ab,updateActiveTool as jt,isTransparent as FV,muteFSAbortError as zV,isTestEnv as kM,isDevEnv as MM,updateStable as Jl,addEventListener as be,normalizeEOL as HV,getDateTime as zk,isShallowEqual as Hk,arrayToMap as Ql,applyDarkModeFilter as GV,AppEventBus as UV,randomInteger as WV,CLASSES as sb,Emitter as eo,MINIMUM_ARROW_SIZE as VV,DOUBLE_TAP_POSITION_THRESHOLD as Gk,BIND_MODE_TIMEOUT as YV,invariant as to,getFeatureFlag as So,createUserAgentDescriptor as AM,getFormFactor as XV,deriveStylesPanelMode as Jp,isIOS as KV,isBrave as ZV,isSafari as $V,loadDesktopUIModePreference as jV,setDesktopUIMode as qV,isSelectionLikeTool as Gp,oneOf as Uk,getStrokeWidthByKey as JV}from"@excalidraw/common";import{getObservedAppState as QV,getCommonBounds as ja,getElementAbsoluteCoords as Wk,bindOrUnbindBindingElements as Vk,fixBindingsAfterDeletion as eY,getHoveredElementForBinding as br,isBindingEnabled as Up,updateBoundElements as Wp,LinearElementEditor as me,newElementWith as no,newFrameElement as tY,newFreeDrawElement as nY,newEmbeddableElement as Yk,newMagicFrameElement as oY,newIframeElement as rY,newArrowElement as iY,newElement as aY,newImageElement as sY,newLinearElement as lY,newTextElement as Xk,refreshTextDimensions as cY,deepCopyElement as Kk,duplicateElements as Zk,hasBoundTextElement as $k,isArrowElement as ec,isBindingElement as oo,isBindingElementType as dY,isBoundToContainer as jk,isFrameLikeElement as vt,isImageElement as Rn,isEmbeddableElement as Co,isInitializedImageElement as qa,isLinearElement as Nt,isLinearElementType as mY,isUsingAdaptiveRadius as pY,isIframeElement as lb,isIframeLikeElement as tc,isTextBindableContainer as qk,isElbowArrow as Ut,isBindableElement as cb,isTextElement as Wt,getNormalizedDimensions as uY,isElementCompletelyInViewport as hY,isElementInViewport as Jk,isInvisiblySmallElement as Qk,generateThumbHash as gY,getCornerRadius as fY,isPathALoop as eM,embeddableURLValidator as db,maybeParseEmbedSrc as EY,getEmbedLink as Vp,getInitializedImageElements as bY,normalizeSVG as tM,updateImageCache as nM,getBoundTextElement as mb,getContainerCenter as pb,getContainerElement as oM,isValidTextContainer as rM,redrawTextBoundingBox as xY,hasBoundingBox as wY,getCommonFrameId as iM,getFrameChildren as ub,getFrameChildrenInsertionIndex as yY,isCursorInFrame as aM,addElementsToFrame as hb,replaceAllElementsInFrame as vY,removeElementsFromFrame as IY,getElementsInResizingFrame as gb,getElementsInNewFrame as TY,getContainingFrame as fb,elementOverlapsWithFrame as SY,updateFrameMembershipOfSelectedElements as sM,isElementInFrame as lM,getFrameLikeTitle as CY,filterElementsEligibleAsFrameChildren as PY,hitElementBoundText as kY,hitElementBoundingBoxOnly as MY,hitElementItself as nc,getVisibleSceneBounds as AY,cropElement as LY,wrapText as DY,isElementLink as cM,isMeasureTextSupported as _Y,normalizeText as RY,measureText as dM,getLineHeightInPx as mM,getApproxMinLineWidth as NY,getApproxMinLineHeight as BY,getMinTextElementWidth as OY,ShapeCache as Ja,getRenderOpacity as FY,editGroupForSelectedElement as zY,getElementsInGroup as si,getSelectedGroupIdForElement as HY,getSelectedGroupIds as GY,isElementInGroup as pM,isSelectedViaGroup as UY,selectGroupsForSelectedElements as Nn,syncInvalidIndices as LM,syncMovedIndices as uM,excludeElementsInFramesFromSelection as WY,getSelectionStateForElements as hM,makeNextSelectedElementIds as ke,getResizeOffsetXY as VY,getResizeArrowDirection as YY,transformElements as XY,getCursorForResizingElement as gM,getElementWithTransformHandleType as fM,getTransformHandleTypeFromCoords as EM,dragNewElement as bM,dragSelectedElements as KY,getDragOffsetXY as ZY,Scene as xM,Store as $Y,CaptureUpdateAction as qt,hitElementBoundingBox as jY,isLineElement as Eb,isSimpleArrow as bb,StoreDelta as wM,positionElementsOnGrid as yM,calculateFixedPointForNonElbowArrowBinding as vM,bindOrUnbindBindingElement as qY,mutateElement as Yp,getElementBounds as IM,doBoundsIntersect as JY,isPointInElement as TM,maxBindingDistance_simple as SM,convertToExcalidrawElements as QY,getSnapOutlineMidPoint as xb,handleFocusPointDrag as eX,handleFocusPointHover as tX,handleFocusPointPointerDown as nX,handleFocusPointPointerUp as oX,maybeHandleArrowPointlikeDrag as Xp,getUncroppedWidthAndHeight as rX,getActiveTextElement as CM,isEligibleFrameChildType as iX,getBindingStrategyForDraggingBindingElementEndpoints as aX,isNonDeletedElement as Kp}from"@excalidraw/element";import{KEYS as Ku,MOBILE_ACTION_BUTTON_BG as h3,updateActiveTool as g3}from"@excalidraw/common";import{getNonDeletedElements as Uc}from"@excalidraw/element";import{fixBindingsAfterDeletion as f3}from"@excalidraw/element";import{LinearElementEditor as i0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Gc}from"@excalidraw/element";import{getContainerElement as a0}from"@excalidraw/element";import{isBoundToContainer as zc,isElbowArrow as E3,isFrameLikeElement as b3}from"@excalidraw/element";import{getFrameChildren as x3}from"@excalidraw/element";import{getElementsInGroup as Zu,selectGroupsForSelectedElements as w3}from"@excalidraw/element";import{CaptureUpdateAction as Hc}from"@excalidraw/element";import{isDevEnv as r3}from"@excalidraw/common";import{atom as qe,createStore as t3}from"jotai";import{createIsolation as n3}from"jotai-scope";var ux=n3();var{useAtom:ze,useSetAtom:hx,useAtomValue:gx,useStore:YX}=ux,fx=ux.Provider,gt=t3();var o3=Ub({"./locales/ar-SA.json":()=>import("./locales/ar-SA-E6E2KRZ5.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RDMGQYMZ.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-CHUVCTEA.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-ZMOEPIQW.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OHZAWF5C.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-K4A7PUP4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-RVP6YORC.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-ENJX4GIQ.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-VYBKDWRU.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-6MCXRRVA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-WEDZAIPA.js"),"./locales/en.json":()=>import("./locales/en-RNZ7CUK6.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-LLEALNRO.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-M4Y34NOW.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-XSMVGGRV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-K2D3DDUS.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-EQKMVJSO.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-RCPQTYJV.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RHAGKYKH.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-3UDCLKHN.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-T3REA7IL.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-KW4N25IN.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-LJVXK4LO.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-GGGK3KPX.js"),"./locales/kaa.json":()=>import("./locales/kaa-TSEHAWJR.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-IWXTEINV.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-6GNYSAU7.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-ILUXSOEW.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-FJWHM3OT.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-DRDDAECA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-IYFIPPJI.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-7F754RSS.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-BYRIZ3PC.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-RBYJSIJ6.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-EKTZIYSK.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-UECYYIUK.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-JPXGIDBA.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-4RSIVDPZ.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-GPHFXISR.js"),"./locales/percentages.json":()=>import("./locales/percentages-Q7USCRWZ.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-HKHPAEVK.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-UBWN6CKP.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-XDY4S4SD.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-2B3UXAQO.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-EW52HAV3.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-PIEHI4JX.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-TZXYYIFD.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-VUDQNDF3.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-IJTJRA7S.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-Q5PXZT3U.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HK66ZQXE.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-CLYYPVPL.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-YR4OMRYF.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-CY4LSY5Y.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-UDAEMEBG.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-EGBL23FT.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-ZOJEG32A.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-TM5HZP7M.js")});var i3=85,zn={code:"en",label:"English"},gi=[zn,...[{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=>Wb[e.code]>=i3).sort((e,n)=>e.label>n.label?1:-1)],Tc="__test__";r3()&&gi.unshift({code:Tc,label:"test language"},{code:`${Tc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var hi=zn,Ic={},Sc=async e=>{if(hi=e,document.documentElement.dir=hi.rtl?"rtl":"ltr",document.documentElement.lang=hi.code,e.code.startsWith(Tc))Ic={};else try{Ic=await o3(`./locales/${hi.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Ic=lu}gt.set(bx,e.code)},Hn=()=>hi,Ex=(e,n)=>{for(let t=0;t<n.length;++t){let o=n[t];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},f=(e,n,t)=>{if(hi.code.startsWith(Tc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=Ex(Ic,o)||Ex(lu,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(n)for(let i in n)r=r.replace(`{{${i}}}`,String(n[i]));return r},bx=qe(zn.code),Ae=()=>{let e=gx(bx);return{t:f,langCode:e}};import a3 from"clsx";import Je from"react";import{THEME as s3}from"@excalidraw/common";import{Fragment as Se,jsx as h,jsxs as R}from"react/jsx-runtime";var xn=e=>"var(--icon-fill-color)",xx=e=>e===s3.LIGHT?"#fff":"#1e1e1e",M=(e,n=512)=>{let{width:t=512,height:o=t,mirror:r,style:i,...a}=typeof n=="number"?{width:n}:n;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${o}`,className:a3({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},G={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ie={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Pt={width:40,height:20},aK=M(R("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"})]}),G),sK=M(R("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"})]}),G),ds=M(R("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"})]}),G),wx=M(R("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"})]}),G),yx=M(R("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"})]}),G),fu=M(R("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"})]}),G),ao=M(R("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"})})]}),ie),Ro=M(R("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"})]}),ie),vx=M(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),Ix=M(R(Se,{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"}),Tx=M(R(Se,{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"}),Sx=M(R(Se,{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"}),lK=M(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),Cc=M(R("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}),fi=M(R("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}),Ei=M(R("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"})]}),G),bi=M(R("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"})]}),G),xi=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),G),Pc=M(R("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"})]}),G),No=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ie),Cx=M(R("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"})]}),G),Gn=M(R("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"})]}),ie),wn=M(R("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"})]}),G),Px=M(R("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"})]}),G),Cr=M(R("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"})]}),ie),kc=M(R("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"})]}),G),Eu=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ie),bu=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ie),kx=M(R("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"})]}),G),Pr=M(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),ie),Bo=M(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ie),ms=M(R("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"})]}),ie),ps=M(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),ie),us=M(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...ie,strokeWidth:1.5}),Mx=M(R("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"})]}),G),hs=M(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),ie),wi=M(R("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"})]}),G),Ax=M(R("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"})]}),G),cK=M(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),ie),Lx=M(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),ie),Dx=M(R("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"})]}),ie),_x=M(R("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"})]}),G),Mc=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),gs=M(R("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"})]}),ie),Rx=M("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),Nx=M("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Ac=M(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),ie),dK=M("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),mK=M("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),xu=["M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z","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","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"],Un=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),xu.map(e=>h("path",{d:e},e))]}),G),Bx=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),G),Ox=M(R("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"})]}),G),Fx=M("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),pK=M("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),uK=M("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),zx=M("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),hK=M("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),wu=M(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),ie),yu=M(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),ie),Hx=M("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),Gx=M(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),ie),gK=M("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),fK=M("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),EK=M(R("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"})]}),G),bK=M(R(Se,{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}),xK=M(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),Ux=R("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"})]}),Wx=R("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"})]}),vu=M(Wx,G),Iu=M(Wx,{...G,style:{transform:"rotate(180deg)"}}),Tu=M(Ux,G),Su=M(Ux,{...G,style:{transform:"rotate(180deg)"}}),Cu=M(R(Se,{children:[R("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"})})})]}),ie),Pu=M(R(Se,{children:[R("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"})})})]}),ie),ku=M(R(Se,{children:[R("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"})})})]}),ie),Mu=M(R(Se,{children:[R("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"})})})]}),ie),Vx=M(R(Se,{children:[R("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"})})})]}),ie),Yx=M(R(Se,{children:[R("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"})})})]}),ie),Au=M(R("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"})]}),ie),Lu=M(R("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"})]}),ie),Lc=M(R("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"})]}),G),wK=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),yK=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Qt=M(R(Se,{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"})})})]}),ie),vK=M("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),IK=M("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),TK=M("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Du=Je.memo(({theme:e})=>M(R(Se,{children:[h("path",{d:"M25 26H111V111H25",fill:xn(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:xn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:xn(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:xn(e),strokeWidth:"2"}),R("g",{fill:xx(e),stroke:xn(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})),_u=Je.memo(({theme:e})=>M(R(Se,{children:[h("path",{d:"M25 26H111V111H25",fill:xn(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:xn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:xn(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:xn(e),strokeWidth:"2"}),R("g",{fill:xx(e),stroke:xn(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})),Xx=M(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),ie),Kx=M(R(Se,{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"})})]}),ie),Zx=M(R(Se,{children:[R("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"})})})]}),ie),$x=M(R(Se,{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"})})})]}),{...ie,fill:"currentColor"}),Ru=M(h(Se,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ie),jx=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ie),qx=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ie),SK=Je.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:xn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Jx=M(R("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"})]}),G),Qx=M(R("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"})]}),G),e1=M(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),ie),t1=M(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),ie),n1=M(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),ie),Nu=M(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]}),G),Bu=M(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"2.75",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),G),o1=M(R("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"})]}),ie),r1=M(R("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"})]}),G),i1=Je.memo(({flip:e=!1})=>M(R("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[h("path",{d:"M7,11 H19"}),h("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),Pt)),a1=Je.memo(({flip:e=!1})=>M(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),Pt)),s1=Je.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Pt)),l1=Je.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[h("path",{d:"M7,11 H23"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Pt)),c1=Je.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Pt)),d1=Je.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M7,11 H25",strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Pt)),m1=Je.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Pt)),p1=Je.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[h("path",{d:"M7,11 H21"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Pt)),u1=Je.memo(({flip:e=!1})=>M(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:h("path",{d:"M11,11 H31 M31,5 V17"})}),Pt)),h1=Je.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17"})}),Pt)),g1=Je.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),Pt)),f1=Je.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),Pt)),E1=Je.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),Pt)),b1=Je.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),h("circle",{cx:"15",cy:"11",r:"4"})]}),Pt)),x1=Je.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),h("circle",{cx:"23",cy:"11",r:"4"})]}),Pt)),w1=M(R(Se,{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"})})})]}),ie),y1=M(R(Se,{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"})})})]}),ie),v1=M(R(Se,{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"})})})]}),ie),I1=M(h(Se,{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"})}),ie),kr=M(R("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"})]}),G),T1=M(h(Se,{children:R("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"})]})}),G),fs=M(h(Se,{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"})})}),ie),l3=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 8l-4 4l4 4"}),h("path",{d:"M17 8l4 4l-4 4"}),h("path",{d:"M14 4l-4 16"})]}),G),Dc=l3,S1=M(R("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"})]}),G),C1=M(R("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"})]}),G),P1=M(R("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"})]}),G),k1=Je.memo(({theme:e})=>M(R("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"})]}),G)),M1=Je.memo(({theme:e})=>M(R("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"})]}),G)),A1=Je.memo(({theme:e})=>M(R("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"})]}),G)),_c=M(R("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"})]}),G),CK=M(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),PK=M(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),L1=M(R("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"})]}),G),Ou=M(R(Se,{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"})]}),G),D1=M(R(Se,{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"})]}),G),_1=M(R("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"})]}),G),R1=M(R(Se,{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"})]}),G),kK=M(R(Se,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),G),MK=M(R(Se,{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"})]}),G),N1=M(R(Se,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),G),B1=M(R(Se,{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"})]}),G),Fu=["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","M11 7l6 6"],yi=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Fu.map(e=>h("path",{d:e},e))]}),G),Wn=M(R("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"})]}),G),AK=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),h("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),G),LK=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),h("path",{d:"M4 15l8 4l8 -4"}),h("path",{d:"M12 4v7"}),h("path",{d:"M15 8l-3 3l-3 -3"})]}),G),DK=M(R("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"})]}),ie),Mr=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0"}),h("path",{d:"M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7"})]}),G),Vn=M(R("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),_K=M(R("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"})]}),G),RK=M(R("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"})]}),G),NK=M(R("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"})]}),G),BK=M(R("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"})]}),G),Ar=M(R("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"})]}),G),O1=M(R("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"})]}),G),OK=M(R("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"})]}),G),FK=M(R("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"})]}),G),Yn=M(R("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"})]}),G),zK=M(R("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"})]}),G),HK=M(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 8l0 4l2 2"}),h("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),G),F1=M(R("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"})]}),G),z1=M(R("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"})]}),G),GK=M(R("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"})]}),G),H1=M(R("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"})]}),G),G1=M(R("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"})]}),G),U1=M(R("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"})]}),G),W1=M(R("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"})]}),G),zu=M(R("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"})]}),G),Rc=M(R("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"})]}),G),V1=M(R("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"})]}),G),Y1=M(R("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"})]}),G),Oo=M(R("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"})]}),G),UK=M(R("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"})]}),G),X1=M(R("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"})]}),{...G,strokeWidth:1.5}),WK=M(R("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"})]}),G),VK=M(R("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"})]}),G),K1=M(R("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"})]}),G),Z1=M(R("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"})]}),G),Fo=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),G),zo=M(R("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"})]}),G),Ho=M(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),G),Nc=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),G),$1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),j1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),Hu=M(R("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"})]}),G),q1=M(R("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"})]}),G),Gu=M(R("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),G),Uu=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),h("polyline",{points:"2 8 3 6 4 8"}),h("polyline",{points:"2 12 3 14 4 12"}),h("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),h("polyline",{points:"9 17 7 18 9 19"}),h("polyline",{points:"15 17 17 18 15 19"})]}),G),YK=M(R("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"})]}),G),Wu=M(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),J1=M(R("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"})]}),G),Q1=M(R("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"})]}),G),Vu=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),h("path",{d:"M13.5 6.5l4 4"})]}),G),XK=M(R("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l-5 5l5 5"}),h("path",{d:"M17 7l-5 5l5 5"})]}),G),KK=M(R("g",{strokeWidth:"1.75",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),h("path",{d:"M15 4l0 16"})]}),G),ZK=M(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),G),$K=M(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 4l18 0"}),h("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),h("path",{d:"M12 16l0 4"}),h("path",{d:"M9 20l6 0"}),h("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),G),Bc=h("div",{style:{width:"1rem",height:"1rem"}}),e0=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),G),t0=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),G),n0=M(R("g",{strokeWidth:1.25,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"})]}),G);import o0 from"clsx";import Xu,{useEffect as m3,useRef as r0,useState as p3}from"react";import{isPromiseLike as u3}from"@excalidraw/common";import c3 from"react";import{jsx as Yu}from"react/jsx-runtime";var d3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(c3.useRef(Date.now()).current%1600);return Yu("div",{className:`Spinner ${o}`,children:Yu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Yu("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},so=d3;import{jsx as Es,jsxs as Oc}from"react/jsx-runtime";var K=Xu.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=Xu.useRef(null);Xu.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=p3(!1),c=r0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(u3(u))try{l(!0),await u}catch(E){if(E instanceof gc)console.warn(E);else throw E}finally{c.current&&l(!1)}};m3(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=r0(null);return o.type==="button"||o.type==="icon"?Oc("button",{className:o0("ToolIcon_type_button",a,t,n&&!o.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!o.hidden,"ToolIcon--plain":o.type==="icon"}),style:o.style,"data-testid":o["data-testid"],hidden:o.hidden,title:o.title,"aria-label":o["aria-label"],type:"button",onClick:d,ref:i,disabled:s||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&Oc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&Es("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&Es(so,{})]}),o.showAriaLabel&&Oc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&Es(so,{})]}),o.children]}):Es("button",{className:o0("ToolIcon","ToolIcon_type_toggle",a,t,{"ToolIcon--checked":o.checked}),type:"button",style:o.style,title:o.title,"aria-label":o["aria-label"],"aria-keyshortcuts":o["aria-keyshortcuts"],"aria-pressed":o.checked,"data-testid":o["data-testid"],disabled:!!o.disabled,"aria-disabled":!!o.disabled,onPointerDown:p=>{m.current=p.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},onClick:()=>{o.onSelect?.({pointerType:m.current})},ref:i,children:Oc("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&Es("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});K.displayName="IconButton";var Fc=[],F=e=>(Fc=Fc.concat(e),e);import{jsx as v3}from"react/jsx-runtime";var y3=(e,n,t)=>{let o=new Set(se(e.filter(d=>b3(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=x3(e,d);for(let p of m)if(!a.has(p.id)){if(zc(p)){let u=a0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let s=!0,l=e.map(d=>{if(n.selectedElementIds[d.id]){let m=zc(d)?a0(d,i):null;return d.frameId&&o.has(d.frameId)?(s=!1,r[d.id]=!0,d):m?.frameId&&o.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&E3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),Gc(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,zc(d)||(r[d.id]=!0),Gc(d,{frameId:null})):zc(d)&&n.selectedElementIds[d.containerId]?Gc(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=Zu(l,n.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=Zu(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...w3({selectedElementIds:r,editingGroupId:c},Uc(l),n,null)}}},s0=(e,n)=>{if(e.editingGroupId){let t=Zu(Uc(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},bs=F({name:"deleteSelectedElements",label:"labels.delete",icon:Pr,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=n.selectedLinearElement,l=o.scene.getNonDeletedElementsMap(),c=i0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?Gc(p,{isDeleted:!0}):p),m=s0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:Hc.IMMEDIATELY}}return i0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Hc.IMMEDIATELY}}let{elements:r,appState:i}=y3(e,n,o);return f3(r,r.filter(a=>a.isDeleted)),i=s0(i,r),{elements:r,appState:{...i,activeTool:g3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Me(Uc(e),n)?Hc.IMMEDIATELY:Hc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===Ku.BACKSPACE||e.key===Ku.DELETE)&&!e[Ku.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=at()==="mobile";return v3(K,{type:"button",icon:Pr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Me(Uc(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?h3:{}}})}});import{KEYS as vi,CODES as Ii,isDarwin as Wc}from"@excalidraw/common";import{moveOneLeft as I3,moveOneRight as T3,moveAllLeft as S3,moveAllRight as C3}from"@excalidraw/element";import{CaptureUpdateAction as Vc}from"@excalidraw/element";import{isDarwin as l0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,l0?f("keys.option"):f("keys.alt")).replace(/\bShift\b/i,f("keys.shift")).replace(/\b(Enter|Return)\b/i,f("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,l0?f("keys.cmd"):f("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,f("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,f("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,f("keys.delete"));import{jsx as Yc}from"react/jsx-runtime";var $u=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Iu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:I3(e,n,o.scene),appState:n,captureUpdate:Vc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ii.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Yc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Iu})}),ju=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:vu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:T3(e,n,o.scene),appState:n,captureUpdate:Vc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ii.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Yc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:vu})}),qu=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Su,trackEvent:{category:"element"},perform:(e,n)=>({elements:S3(e,n),appState:n,captureUpdate:Vc.IMMEDIATELY}),keyTest:e=>Wc?e[vi.CTRL_OR_CMD]&&e.altKey&&e.code===Ii.BRACKET_LEFT:e[vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ii.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Yc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Wc?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Su})}),Ju=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Tu,trackEvent:{category:"element"},perform:(e,n)=>({elements:C3(e,n),appState:n,captureUpdate:Vc.IMMEDIATELY}),keyTest:e=>Wc?e[vi.CTRL_OR_CMD]&&e.altKey&&e.code===Ii.BRACKET_RIGHT:e[vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ii.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Yc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Wc?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Tu})});import{getNonDeletedElements as P3}from"@excalidraw/element";import{LinearElementEditor as k3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as M3,isTextElement as A3}from"@excalidraw/element";import{arrayToMap as L3,KEYS as c0}from"@excalidraw/common";import{selectGroupsForSelectedElements as D3}from"@excalidraw/element";import{CaptureUpdateAction as _3}from"@excalidraw/element";var Qu=F({name:"selectAll",label:"labels.selectAll",icon:H1,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(A3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...D3({editingGroupId:null,selectedElementIds:r},P3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&M3(e[0])?new k3(e[0],L3(e)):null},captureUpdate:_3.IMMEDIATELY}},keyTest:e=>e[c0.CTRL_OR_CMD]&&e.key===c0.A});import{DEFAULT_GRID_SIZE as d0,KEYS as m0,MOBILE_ACTION_BUTTON_BG as R3,arrayToMap as p0}from"@excalidraw/common";import{getNonDeletedElements as u0}from"@excalidraw/element";import{LinearElementEditor as N3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as B3,getSelectionStateForElements as O3}from"@excalidraw/element";import{syncMovedIndices as F3}from"@excalidraw/element";import{duplicateElements as z3}from"@excalidraw/element";import{CaptureUpdateAction as h0}from"@excalidraw/element";import{jsx as H3}from"react/jsx-runtime";var eh=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ms,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=N3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:h0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=z3({type:"in-place",elements:e,idsOfElementsToDuplicate:p0(B3(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+d0/2,y:a.y+d0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:F3(i,p0(r)),appState:{...n,...O3(r,u0(i),n)},captureUpdate:h0.IMMEDIATELY}},keyTest:e=>e[m0.CTRL_OR_CMD]&&e.key===m0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=at()==="mobile";return H3(K,{type:"button",icon:ms,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Me(u0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?R3:{}}})}});import{pointFrom as x4}from"@excalidraw/math";import{useEffect as yh,useMemo as Th,useRef as vh,useState as w4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as y4,COLOR_PALETTE as v4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as yw,DEFAULT_ELEMENT_BACKGROUND_PICKS as I4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as T4,DEFAULT_ELEMENT_STROKE_PICKS as S4,ARROW_TYPE as on,DEFAULT_FONT_FAMILY as C4,DEFAULT_FONT_SIZE as P4,FONT_FAMILY as k4,ROUNDNESS as pd,STROKE_WIDTH_KEYS as M4,VERTICAL_ALIGN as dd,KEYS as _i,randomInteger as A4,arrayToMap as Sh,getFontFamilyString as L4,getLineHeight as D4,isTransparent as _4,getStrokeWidthByKey as vw,reduceToCommonValue as R4,invariant as hd,FONT_SIZES as md}from"@excalidraw/common";import{canBecomePolygon as N4,getNonDeletedElements as Iw,isNonDeletedElement as B4}from"@excalidraw/element";import{bindBindingElement as fw,calculateFixedPointForElbowArrowBinding as Ew,updateBoundElements as O4}from"@excalidraw/element";import{LinearElementEditor as Dr}from"@excalidraw/element/linearElementEditor";import{newElementWith as ot}from"@excalidraw/element";import{getArrowheadForPicker as bw}from"@excalidraw/element";import{getBoundTextElement as $o,redrawTextBoundingBox as Ls}from"@excalidraw/element";import{isArrowElement as ud,isBoundToContainer as F4,isElbowArrow as Tw,isLinearElement as Ih,isLineElement as xw,isTextElement as Ot,isUsingAdaptiveRadius as z4}from"@excalidraw/element";import{hasStrokeColor as H4}from"@excalidraw/element";import{updateElbowArrowPoints as G4,CaptureUpdateAction as Qe,toggleLinePolygonState as U4}from"@excalidraw/element";import{deriveStylesPanelMode as W4}from"@excalidraw/common";import{isDevEnv as G3}from"@excalidraw/common";var U3=new Set(["command_palette","export"]),Ne=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!U3.has(e)||G3())return;S.PROD||console.info("trackEvent",{category:e,action:n,label:t,value:o}),window.sa_event&&window.sa_event(n,{category:e,label:t,value:o})}catch(r){console.error("error during analytics",r)}};import X3 from"clsx";import W3 from"clsx";import{forwardRef as V3}from"react";import{jsx as Y3}from"react/jsx-runtime";var g0=V3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return Y3("button",{type:"button",ref:n,title:t,"data-testid":r,className:W3(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as Z3,jsx as th,jsxs as K3}from"react/jsx-runtime";var Vt=e=>th(Z3,{children:e.options.map(n=>e.type==="button"?th(g0,{icon:n.icon,title:n.text,testId:n.testId,active:n.active??e.value===n.value,onClick:t=>e.onClick(n.value,t)},n.text):K3("label",{className:X3({active:e.value===n.value}),title:n.text,children:[th("input",{type:"radio",name:e.group,onChange:()=>e.onChange(n.value),checked:e.value===n.value,"data-testid":n.testId}),n.icon]},n.text))});import{Popover as Z0}from"radix-ui";import $0 from"clsx";import{memo as g5,useRef as j0,useEffect as f5}from"react";import{applyDarkModeFilter as E5,COLOR_OUTLINE_CONTRAST_THRESHOLD as X0,COLOR_PALETTE as q0,DEFAULT_ELEMENT_BACKGROUND_PICKS as b5,DEFAULT_ELEMENT_STROKE_PICKS as x5,isColorDark as K0,isWritableElement as w5,THEME as y5}from"@excalidraw/common";import{jsx as $3}from"react/jsx-runtime";var Xc=()=>$3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as tA,useLayoutEffect as nA,useRef as oA}from"react";import{createPortal as rA}from"react-dom";import{EVENT as Go,isColorDark as iA,KEYS as aA,MIME_TYPES as sA,THEME as lA,removeDarkModeFilter as cA,rgbToHex as dA}from"@excalidraw/common";import f0 from"react";var nh=f0.createContext(null),fe=()=>f0.useContext(nh);import{useState as j3,useLayoutEffect as E0}from"react";import{THEME as q3}from"@excalidraw/common";var Kc=e=>{let[n,t]=j3(null),o=ge(),{theme:r}=fe(),{container:i}=De();return E0(()=>{n&&(n.className="",n.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),n.classList.toggle("excalidraw--mobile",o.formFactor==="phone"),n.classList.toggle("theme--dark",r===q3.DARK))},[n,r,o.formFactor,e?.className]),E0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),t(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),n};import{useEffect as J3}from"react";import{EVENT as Zc}from"@excalidraw/common";function Ti(e,n,t){J3(()=>{function o(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return n(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]")||n(i)}return document.addEventListener(Zc.POINTER_DOWN,o),document.addEventListener(Zc.TOUCH_START,o),()=>{document.removeEventListener(Zc.POINTER_DOWN,o),document.removeEventListener(Zc.TOUCH_START,o)}},[e,n,t])}import{useRef as Q3}from"react";var Si=e=>{let n=Q3(e);return Object.assign(n.current,e),n.current};import{clamp as eA}from"@excalidraw/math";var b0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return eA(r,0,Math.max(0,t-n))},$c=({cursor:e,element:n,container:t,gap:o})=>({left:b0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:b0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as pA}from"react/jsx-runtime";var x0=Fu.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),mA=`url(data:${sA.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${x0}</g><g stroke="#1b1b1f" stroke-width="1.25">${x0}</g></svg>`)}) 2 21, auto`,Bt=qe(null),w0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=Kc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=fe(),a=Ci(),s=It(),l=se(a,i),c=Si({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=De();nA(()=>{if(r)return r.style.cursor=mA,()=>{r.style.cursor=""}},[r]),tA(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:A})=>{let L=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(A-i.offsetTop)*window.devicePixelRatio,1,1).data;return dA(L[0],L[1],L[2])},b=P=>i.theme===lA.DARK?cA(P):P,y=({clientX:P,clientY:A,altKey:L})=>{let{top:_,left:k}=$c({cursor:{x:P,y:A},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let D=g({clientX:P,clientY:A});u&&c.onChange(o,b(D),c.selectedElements,{altKey:L}),p.style.background=D,p.style.setProperty("--eye-dropper-preview-border-color",iA(D)?"#fff":"#222")},w=()=>{c.onCancel()},x=(P,A)=>{c.onSelect(P,A)},v=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===aA.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),y({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(Go.KEYDOWN,C),r.addEventListener(Go.POINTER_DOWN,v),r.addEventListener(Go.POINTER_UP,T),window.addEventListener("pointermove",y,{passive:!0}),window.addEventListener(Go.BLUR,w),()=>{u=!1,r.removeEventListener(Go.KEYDOWN,C),r.removeEventListener(Go.POINTER_DOWN,v),r.removeEventListener(Go.POINTER_UP,T),window.removeEventListener("pointermove",y),window.removeEventListener(Go.BLUR,w)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=oA(null);return Ti(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?rA(pA("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as oh}from"radix-ui";import fA from"clsx";import EA from"react";import{isInteractive as bA}from"@excalidraw/common";import uA from"react";import hA from"clsx";import{jsx as gA}from"react/jsx-runtime";var He=uA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>gA("div",{className:hA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as rh,jsxs as xA}from"react/jsx-runtime";var lo=EA.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let m=ge(),p=m.formFactor==="phone"&&!m.isLandscape;return rh(oh.Portal,{container:n,children:xA(oh.Content,{ref:d,className:fA("focus-visible-none",e),"data-prevent-outside-click":!0,side:p?"bottom":"right",align:p?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:n??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:m.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!bA(document.activeElement)&&n.focus(),r()},children:[rh(He,{padding:3,style:o,children:t}),rh(oh.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 wA,useCallback as ih}from"react";var jc=()=>document.querySelector(".excalidraw-wysiwyg"),qc=()=>{let e=jc();return e?{start:e.selectionStart,end:e.selectionEnd}:null},xs=e=>{setTimeout(()=>{let n=jc();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},ws=(e,n,t,o)=>{n&&o&&o();let r=n&&t?qc():null;e(),n&&t&&xs(r)},y0=()=>{let[e,n]=wA(null),t=ih(()=>{let i=qc();n(i)},[]),o=ih(()=>{setTimeout(()=>{let i=jc();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=ih(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},v0=(e=100)=>{let n=jc();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import T0 from"clsx";import{useCallback as IA,useEffect as sh,useRef as S0,useState as C0}from"react";import{KEYS as lh,normalizeInputColor as TA}from"@excalidraw/common";import{isTransparent as yA,MAX_CUSTOM_COLORS_USED_IN_CANVAS as vA}from"@excalidraw/common";var Uo=({palette:e,color:n})=>{if(!n)return null;for(let[t,o]of Object.entries(e))if(Array.isArray(o)){let r=o.indexOf(n);if(r>-1)return{colorName:t,shade:r}}else if(o===n)return{colorName:t,shade:null};return null},ys=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),ah=({color:e,palette:n})=>!Object.values(n).flat().includes(e),I0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!yA(s)&&ah({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[o[n]];i.has(s)?i.set(s,i.get(s)+1):i.set(s,1)}),[...i.entries()].sort((a,s)=>s[1]-a[1]).map(a=>a[0]).slice(0,vA)},en=qe(null);import{Fragment as SA,jsx as vs,jsxs as ch}from"react/jsx-runtime";var P0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=ge(),[a,s]=C0(e),[l,c]=C0(null),[d,m]=ze(en);sh(()=>{s(e)},[e]);let p=IA(y=>{let w=y.toLowerCase().trim(),x=TA(w);x?(n(x),c(null)):w.length===0?c(null):/^#?[0-9a-f]+$/.test(w)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(w)},[n]),u=S0(null),E=S0(null);sh(()=>{u.current&&u.current.focus()},[d]);let[g,b]=ze(Bt);return sh(()=>()=>{b(null)},[b]),ch("div",{className:"color-picker__input-label-container",children:[ch("div",{className:T0("color-picker__input-label",{"has-error":l}),children:[vs("div",{className:"color-picker__input-hash",children:"#"}),vs("input",{ref:d==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!l,onChange:y=>{p(y.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:y=>{y.key!==lh.TAB&&(y.key===lh.ESCAPE&&E.current?.focus(),y.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&ch(SA,{children:[vs("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),vs("div",{ref:E,className:T0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(y=>y?null:{keepOpenOnAlt:!1,onSelect:w=>n(w),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${lh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:yi})]})]}),l&&vs("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import ph,{useEffect as uh,useImperativeHandle as o5,useState as r5}from"react";import{EVENT as G0}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as i5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as a5,KEYS as s5}from"@excalidraw/common";import RA from"clsx";import{useEffect as NA,useRef as BA}from"react";import{applyDarkModeFilter as OA,THEME as FA}from"@excalidraw/common";import{isColorDark as CA}from"@excalidraw/common";import{jsxs as kA}from"react/jsx-runtime";var PA=({color:e,keyLabel:n,isShade:t=!1})=>kA("div",{className:"color-picker__button__hotkey-label",style:{color:CA(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),Pi=PA;import{createContext as MA,useContext as AA,useEffect as LA,useMemo as k0,useRef as M0,useState as DA}from"react";import{colorToHex as A0,isTransparent as _A}from"@excalidraw/common";var Lr="excalidraw-color-dnd-ghost",L0="excalidraw-color-dnd-active",D0=10,_0=100,R0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=A0(e);return t!==null&&t===A0(n)},dh=MA(null),tn=()=>AA(dh),N0=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=DA(null),i=M0(null),a=M0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=k0(()=>{let l=null,c=()=>{l?.activated?r({color:l.color,origin:l.origin,overIndex:l.overIndex,duplicateIndex:l.duplicateIndex,slotSpan:l.slotSpan}):r(null)},d=()=>{let k=i.current;if(!k||!l)return!1;let D=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((Z,H)=>Number(Z.dataset.topPickIndex)-Number(H.dataset.topPickIndex));if(!D.length)return!1;l.slotRects=D.map(Z=>Z.getBoundingClientRect());let[O,Y]=l.slotRects;l.slotSpan=Y?Y.left-O.left:O.width+4;let z=k.getBoundingClientRect(),W=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-W,right:z.right+W,top:z.top-14,bottom:z.bottom+14},!0},m=(k,D)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${D-l.ghostH/2}px)`)},p=(k,D,O,Y)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==D)&&(l.ghostW=k,l.ghostH=D,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${D}px`,m(O,Y))},u=(k,D)=>{if(!l)return;let{sourceRect:O,sourceEl:Y,color:z}=l,W=document.createElement("div");W.className=Lr;let Z=document.createElement("div");if(Z.className=`${Lr}__swatch`,_A(z))Z.classList.add("is-transparent");else{let H=getComputedStyle(Y).backgroundColor;Z.style.backgroundColor=H&&H!=="rgba(0, 0, 0, 0)"?H:z}W.appendChild(Z),document.body.appendChild(W),l.ghost=W,l.ghostW=O.width,l.ghostH=O.height,W.style.width=`${O.width}px`,W.style.height=`${O.height}px`,m(k,D),requestAnimationFrame(()=>{l?.ghost===W&&W.classList.add(`${Lr}--lifted`)}),document.body.classList.add(L0),l.activated=!0,c()},E=(k,D)=>{if(!l?.hitRect)return;let{hitRect:O,slotRects:Y}=l,z=null,W=null;if(k>=O.left&&k<=O.right&&D>=O.top&&D<=O.bottom){let Z=0,H=1/0;if(Y.forEach((re,B)=>{let U=Math.abs(k-(re.left+re.width/2));U<H&&(H=U,Z=B)}),l.origin.kind==="swatch"){let re=a.current.picks.findIndex(B=>R0(B,l.color));re!==-1?W=re:z=Z}else z=Z}if(z!==l.overIndex||W!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=W;let{ghost:Z}=l;Z&&(Z.classList.toggle(`${Lr}--over`,z!==null),Z.classList.toggle(`${Lr}--blocked`,W!==null)),c()}if(z!==null){let Z=l.slotRects[z];p(Z.width,Z.height,k,D)}else p(l.sourceRect.width,l.sourceRect.height,k,D)},g=k=>{if(!l?.ghost)return;let{ghost:D}=l;l.ghost=null,D.classList.add(`${Lr}--dropping`);let O=k.rect;O&&(D.style.width=`${O.width}px`,D.style.height=`${O.height}px`,D.style.transform=`translate(${O.left}px, ${O.top}px)`),window.setTimeout(()=>{D.classList.add(`${Lr}--fade`)},160),window.setTimeout(()=>{D.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let D=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let O of D)O.style.transition="none",O.style.transform="none";k.offsetWidth;for(let O of D)O.style.transition=""},y=()=>{let k=D=>{D.preventDefault(),D.stopPropagation()};window.addEventListener("click",k,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",k,{capture:!0})},100)},w=()=>{window.removeEventListener("pointermove",C,!0),window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",A,!0),window.removeEventListener("keydown",L,!0)},x=()=>{w(),document.body.classList.remove(L0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},v=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,D)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,D),E(k,D)}},C=k=>{if(!(!l||k.pointerId!==l.pointerId)){if(l.lastX=k.clientX,l.lastY=k.clientY,!l.activated){if(Math.hypot(k.clientX-l.startX,k.clientY-l.startY)<D0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let D=performance.now()-l.startTime;if(D<_0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=D0&&T(l.lastX,l.lastY))},_0-D));return}if(T(k.clientX,k.clientY),!l?.activated)return}k.preventDefault(),m(k.clientX,k.clientY),E(k.clientX,k.clientY)}},P=k=>{if(!l||k.pointerId!==l.pointerId)return;if(!l.activated){x();return}k.preventDefault(),k.stopPropagation(),y();let{overIndex:D,origin:O,color:Y,slotRects:z}=l,{picks:W,onPicksChange:Z}=a.current;if(b(),D!==null){if(O.kind==="swatch"){if(!W.some(H=>R0(H,Y))){let H=[...W];H[D]=Y,Z(H)}}else if(O.index!==D){let H=[...W],[re]=H.splice(O.index,1);H.splice(D,0,re),Z(H)}g({rect:z[D]})}else g({rect:l.sourceRect});x()},A=k=>{l&&k.pointerId===l.pointerId&&v(!0)},L=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),v(!0))};return{begin:(k,D,O)=>{!a.current.enabled||l||k.button!==0||!D||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:D,origin:O,sourceEl:k.currentTarget,sourceRect:k.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener("pointermove",C,!0),window.addEventListener("pointerup",P,!0),window.addEventListener("pointercancel",A,!0),window.addEventListener("keydown",L,!0))},destroy:()=>v(!1)}},[]);return LA(()=>()=>s.destroy(),[s]),k0(()=>({dragState:o,startSwatchDrag:(l,c)=>s.begin(l,c,{kind:"swatch"}),startPickDrag:(l,c,d)=>s.begin(l,d,{kind:"pick",index:c}),setStripEl:l=>{i.current=l}}),[o,s])};import{jsx as mh,jsxs as zA}from"react/jsx-runtime";var B0=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=ze(en),s=tn(),l=BA(null);return NA(()=>{l.current&&l.current.focus()},[t,i]),mh("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=OA(c,e===FA.DARK);return zA("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:RA("color-picker__button color-picker__button--large has-outline",{active:t===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{o(c),a("custom")},onPointerDown:s?p=>s.startSwatchDrag(p,c):void 0,title:c,"aria-label":r,style:{"--swatch-color":m},children:[mh("div",{className:"color-picker__button-outline"}),mh(Pi,{color:m,keyLabel:d+1})]},d)})})};import HA from"clsx";import{useEffect as GA,useRef as UA}from"react";import{applyDarkModeFilter as WA,isColorDark as VA,THEME as YA}from"@excalidraw/common";import{jsx as Jc,jsxs as KA}from"react/jsx-runtime";var XA=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=Uo({color:t,palette:n}),[l,c]=ze(en),d=tn(),m=UA(null);return GA(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),Jc("div",{className:"color-picker-content--default",children:Object.entries(n).map(([p,u],E)=>{let g=(Array.isArray(u)?u[r]:u)||"transparent";if(a?.includes(g))return Jc("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=ys[E],y=WA(g,e===YA.DARK),w=f(`colors.${p.replace(/\d+/,"")}`,null,"");return KA("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:HA("color-picker__button color-picker__button--large",{"has-outline":!VA(g,255),active:s?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),c("baseColors")},onPointerDown:d?x=>d.startSwatchDrag(x,g):void 0,title:`${w}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${w} \u2014 ${b}`,style:g?{"--swatch-color":y}:void 0,"data-testid":`color-${p}`,children:[Jc("div",{className:"color-picker__button-outline"}),i&&Jc(Pi,{color:y,keyLabel:b})]},p)})})},O0=XA;import{jsx as $A}from"react/jsx-runtime";var ZA=({children:e})=>$A("div",{className:"color-picker__heading",children:e}),ki=ZA;import jA from"clsx";import{useEffect as qA,useRef as JA}from"react";import{applyDarkModeFilter as QA,THEME as e5}from"@excalidraw/common";import{jsx as Is,jsxs as F0}from"react/jsx-runtime";var z0=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=Uo({color:n||"transparent",palette:o}),[a,s]=ze(en),l=tn(),c=JA(null);if(qA(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return Is("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=QA(u,e===e5.DARK);return F0("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:jA("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${d} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),s("shades")},onPointerDown:l?b=>l.startSwatchDrag(b,u):void 0,children:[Is("div",{className:"color-picker__button-outline"}),r&&Is(Pi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return F0("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Is("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Is("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:f("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Mi,COLOR_PALETTE as t5,KEYS as Ts}from"@excalidraw/common";var Qc=(e,n,t)=>{let o=Math.ceil(t/Mi);switch(n=n??-1,e){case"ArrowLeft":{let r=n-1;return r<0?t-1:r}case"ArrowRight":return(n+1)%t;case"ArrowDown":{let r=n+Mi;return r>=t?n%Mi:r}case"ArrowUp":{let r=n-Mi,i=r<0?Mi*o+r:r;return i>=t?void 0:i}}},n5=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:s})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(o[n.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(ys.includes(e.key)){let l=ys.indexOf(e.key),c=Object.keys(o)[l],d=o[c],m=Array.isArray(d)?d[a]:d;return m==null||s?.includes(m)||(t(m),i("baseColors")),!0}return!1},H0=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d,excludedColors:m})=>{if(e[Ts.CTRL_OR_CMD])return!1;if(e.key===Ts.ESCAPE)return d(e),!0;if(e.key===Ts.ALT)return c(!0),!0;if(e.key===Ts.I)return c(),!0;let p=Uo({color:o,palette:t});if(e.key===Ts.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[v,T])=>(T&&x.push(v),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,y=g+b>E.length-1?0:g+b<0?E.length-1:g+b,w=E[y];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([v,T])=>Array.isArray(T)?T.includes(o):T===o?v:null)||r(t5.black)),e.preventDefault(),e.stopPropagation(),!0}if(n5({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l,excludedColors:m}))return!0;if(n==="shades"&&p){let{shade:u}=p,E=Qc(e.key,u,Mi);if(E!==void 0)return r(t[p.colorName][E]),!0}if(n==="baseColors"&&p){let{colorName:u}=p,E=Object.keys(t),g=E.indexOf(u),b=Qc(e.key,g,E.length),y=0;for(;b!==void 0&&y++<E.length;){let w=t[E[b]],x=Array.isArray(w)?w[l]:w;if(!m?.includes(x))break;b=Qc(e.key,b,E.length)}if(b!==void 0){let w=E[b],x=t[w];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=Qc(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as co,jsxs as ed}from"react/jsx-runtime";var U0=ph.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:c,onEscape:d,showHotKey:m=!0,excludedColors:p},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=ph.useState(()=>o==="canvasBackground"?[]:I0(r,o,i)),[b,y]=ze(en),w=tn(),x=Uo({color:n,palette:i});uh(()=>{if(!b){let P=!!n&&ah({color:n,palette:i}),A=P&&!g.includes(n);y(A?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,y,x,g]);let[v,T]=r5(x?.shade??(o==="elementBackground"?i5:a5));uh(()=>{x?.shade!=null&&T(x.shade);let P=A=>{A.key===s5.ALT&&c(!1)};return document.addEventListener(G0.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(G0.KEYUP,P,{capture:!0})}},[x,c]);let C=ph.useRef(null);return o5(u,()=>C.current),uh(()=>{C?.current?.focus()},[]),co("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:ed("div",{ref:C,onKeyDown:P=>{H0({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:y,updateData:a,activeShade:v,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&co("div",{className:"color-picker__title",children:E}),!!g.length&&ed("div",{children:[co(ki,{children:f("colorPicker.mostUsedCustomColors")}),co(B0,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),ed("div",{children:[co(ki,{children:f("colorPicker.colors")}),co(O0,{theme:e,color:n,palette:i,onChange:t,activeShade:v,showHotKey:m,excludedColors:p})]}),ed("div",{children:[co(ki,{children:f("colorPicker.shades")}),co(z0,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,w&&co("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import W0 from"clsx";import{ContextMenu as Ss}from"radix-ui";import{applyDarkModeFilter as l5,COLOR_OUTLINE_CONTRAST_THRESHOLD as c5,DEFAULT_CANVAS_BACKGROUND_PICKS as d5,DEFAULT_ELEMENT_BACKGROUND_PICKS as m5,DEFAULT_ELEMENT_STROKE_PICKS as p5,isColorDark as u5,THEME as h5}from"@excalidraw/common";import{jsx as Wo,jsxs as V0}from"react/jsx-runtime";var Y0=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=tn(),l=s?.dragState??null,{container:c}=De(),d;if(t==="elementStroke"&&(d=p5),t==="elementBackground"&&(d=m5),t==="canvasBackground"&&(d=d5),r&&(d=r),!d)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!l||l.origin.kind!=="pick"||l.overIndex===null)return 0;let E=l.origin.index,g=l.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*l.slotSpan},p=V0("div",{className:W0("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&Wo("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:Wo("rect",{})}),d.map((u,E)=>{let g=m(E),b=l5(u,e===h5.DARK);return Wo("button",{className:W0("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!u5(u,c5),"is-dnd-source":l?.origin.kind==="pick"&&l.origin.index===E,"is-dnd-target":l?.origin.kind==="swatch"&&l.overIndex===E,"is-dnd-duplicate":l?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:s?y=>s.startPickDrag(y,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:Wo("div",{className:"color-picker__button-outline"})},u)})]});return i?V0(Ss.Root,{children:[Wo(Ss.Trigger,{asChild:!0,children:p}),Wo(Ss.Portal,{container:c,children:Wo(Ss.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:Wo(Ss.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as nn,jsxs as td}from"react/jsx-runtime";var v5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=q0,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=De(),m=at(),p=m!=="full",u=m==="mobile",[,E]=ze(en),[g,b]=ze(Bt),y=td("div",{children:[nn(ki,{children:f("colorPicker.hexCode")}),nn(P0,{color:n||"",label:o,onChange:v=>{t(v)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),w=j0(null),x=()=>{w.current?.focus()};return nn(lo,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:v=>{if(v.target instanceof HTMLElement&&v.target.closest(".color-picker__context-menu")){v.preventDefault();return}w5(v.target)||(v.target instanceof HTMLElement&&v.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),v.preventDefault()},onPointerDownOutside:v=>{g&&v.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let v=document.querySelector(".excalidraw-wysiwyg");v&&v.focus()},0)},children:i?nn(U0,{ref:w,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:v=>{let T=l.editingTextElement?qc():null;t(v),l.editingTextElement&&T&&xs(T)},onEyeDropperToggle:v=>{b(T=>v?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):v===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:v=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:y}):y})},I5=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",T5=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=at(),l=s!=="full",c=s==="mobile",d=tn(),m=n?E5(n,o===y5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&v0(),i()};return td(Z0.Trigger,{type:"button",className:$0("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!K0(n,X0),"compact-sizing":l,"mobile-border":c}),"aria-label":e,style:m?{"--swatch-color":m}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:p,onPointerDown:d?u=>d.startSwatchDrag(u,n):void 0,children:[nn("div",{className:"color-picker__button-outline",children:!n&&Bx}),l&&n&&r==="stroke"&&nn("div",{className:"color-picker__button-background",children:nn("span",{style:{color:m&&K0(m,X0)?"#fff":"#111"},children:Q1})})]})},S5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=q0,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=j0(l.openPopup);f5(()=>{m.current=l.openPopup},[l.openPopup]);let u=at()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?x5:b5),y=N0({enabled:E,picks:b,onPicksChange:w=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:w}})}});return nn(dh.Provider,{value:E?y:null,children:td("div",{role:"dialog","aria-modal":"true",className:$0("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&nn(Y0,{theme:l.theme,activeColor:n,onChange:w=>{t(w),I5(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&d?()=>{s({colorTopPicks:{...l.colorTopPicks,[d]:null}})}:void 0}),!u&&nn(Xc,{}),td(Z0.Root,{open:l.openPopup===e,onOpenChange:w=>{w&&s({openPopup:e})},children:[nn(T5,{color:n,label:o,type:e,theme:l.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!l.editingTextElement,onToggle:()=>{l.openPopup===e?s({openPopup:null}):l.openPopup?s({openPopup:e}):s({openPopup:e})}}),l.openPopup===e&&nn(v5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},C5=(e,n)=>e.appState.openPopup===e.type||n.appState.openPopup===n.type?!1:e.type===n.type&&e.color===n.color&&e.label===n.label&&e.appState.openPopup===n.appState.openPopup&&e.palette===n.palette&&e.topPicks===n.topPicks&&e.excludedColors===n.excludedColors&&e.customizableTopPicks===n.customizableTopPicks&&e.appState.theme===n.appState.theme&&e.appState.colorTopPicks===n.appState.colorTopPicks&&!!e.appState.editingTextElement==!!n.appState.editingTextElement,Ai=g5(S5,C5);import{Popover as e4}from"radix-ui";import t4 from"clsx";import n4,{useCallback as o4,useMemo as r4}from"react";import{FONT_FAMILY as Eh}from"@excalidraw/common";import V5,{useMemo as Ko,useState as Y5,useRef as tw,useEffect as nw,useCallback as ow}from"react";import{arrayToList as X5,debounce as K5,FONT_FAMILY as Zo,getFontFamilyString as Z5}from"@excalidraw/common";import P5 from"clsx";import k5 from"react";import{jsx as M5,jsxs as A5}from"react/jsx-runtime";var nd=k5.forwardRef(({className:e,placeholder:n,onChange:t},o)=>A5("div",{className:P5("QuickSearch__wrapper",e),children:[Yn,M5("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import L5 from"clsx";import{Children as D5}from"react";import{jsx as J0}from"react/jsx-runtime";var od=({className:e,placeholder:n,children:t})=>{let o=!D5.count(t);return J0("div",{className:L5("ScrollableList__wrapper",e),role:"menu",children:o?J0("div",{className:"empty",children:n}):t})};import{jsx as _5,jsxs as R5}from"react/jsx-runtime";var Q0=({children:e,className:n="",style:t,title:o})=>R5("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&_5("p",{className:"dropdown-menu-group-title",children:o}),e]}),Cs=Q0;Q0.displayName="DropdownMenuGroup";import{THEME as U5}from"@excalidraw/common";import{DropdownMenu as W5}from"radix-ui";import N5,{useContext as B5}from"react";import{composeEventHandlers as O5}from"@excalidraw/common";var hh=N5.createContext({}),Vo=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),rd=e=>{let n=B5(hh);return O5(e,t=>{n.onSelect?.(t)})};import{jsx as F5}from"react/jsx-runtime";var Ps=({children:e,...n})=>F5("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as H5,jsx as ks,jsxs as G5}from"react/jsx-runtime";var z5=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=ge();return G5(H5,{children:[n&&ks("div",{className:"dropdown-menu-item__icon",children:n}),ks("div",{style:e,className:"dropdown-menu-item__text",children:ks(Ps,{children:o})}),r&&ks("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&ks("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Yo=z5;import{jsx as id}from"react/jsx-runtime";var gh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=rd(s);return id(W5.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:id("button",{...l,value:t,className:Vo(i,a),title:l.title??l["aria-label"],children:id(Yo,{icon:e,shortcut:r,badge:n,children:o})})})};gh.displayName="DropdownMenuItem";var Li={GREEN:"green",RED:"red",BLUE:"blue"},ad=({type:e=Li.BLUE,children:n})=>{let{theme:t}=Xo(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===U5.LIGHT?"1.5px solid white":"none"};switch(e){case Li.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Li.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Li.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return id("div",{className:"DropDownMenuItemBadge",style:o,children:n})};ad.displayName="DropdownMenuItemBadge";gh.Badge=ad;var Yt=gh;import{KEYS as Di}from"@excalidraw/common";var ew=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[Di.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Di.F)return n.current?.focus(),!0;if(e.key===Di.ESCAPE)return r(),!0;if(e.key===Di.ENTER)return t?.value&&i(t.value),!0;if(e.key===Di.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===Di.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as mo,jsxs as q5}from"react/jsx-runtime";var $5=e=>{switch(e){case Zo.Excalifont:case Zo.Virgil:return Gn;case Zo.Nunito:case Zo.Helvetica:return fs;case Zo["Lilita One"]:return T1;case Zo["Comic Shanns"]:case Zo.Cascadia:return Dc;default:return fs}},j5=(e,n)=>Object.entries(Zo).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",rw=V5.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=De(),l=It(),{fonts:c}=l,{showDeprecatedFonts:d}=yn(),m=at(),[p,u]=Y5(""),E=tw(null),g=Ko(()=>Array.from(io.registered.entries()).filter(([k,{metadata:D}])=>!D.private&&!D.fallback).map(([k,{metadata:D,fontFaces:O}])=>{let Y={value:k,icon:$5(k),text:j5(k,O)};return D.deprecated&&Object.assign(Y,{deprecated:D.deprecated,badge:{type:Li.RED,placeholder:f("fontList.badge.old")}}),Y}).sort((k,D)=>k.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),b=Ko(()=>new Set(c.getSceneFamilies()),[e]),y=Ko(()=>g.filter(k=>b.has(k.value)),[g,b]),w=Ko(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=Ko(()=>X5([...y,...w].filter(k=>k.text?.toLowerCase().includes(p))),[y,w,p]),v=Ko(()=>{let k;return n?k=x.find(D=>D.value===n):e&&(k=x.find(D=>D.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=ow(k=>{let D=null;if(l.state.editingTextElement){let O=document.querySelector(".excalidraw-wysiwyg");O&&(D={start:O.selectionStart,end:O.selectionEnd})}t(k),l.state.editingTextElement&&D&&setTimeout(()=>{let O=document.querySelector(".excalidraw-wysiwyg");O&&D&&(O.focus(),O.selectionStart=D.start,O.selectionEnd=D.end)},0)},[t,l.state.editingTextElement]),C=ow(k=>{ew({event:k,inputRef:E,hoveredFont:v,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[v,x,T,o,a]);nw(()=>(i(),()=>{a()}),[]);let P=Ko(()=>x.filter(k=>b.has(k.value)),[x,b]),A=Ko(()=>x.filter(k=>!b.has(k.value)),[x,b]),L=({font:k,order:D})=>{let O=tw(null),Y=k.value===v?.value,z=k.value===e;return nw(()=>{Y&&(D===0?O.current?.scrollIntoView?.({block:"end"}):O.current?.scrollIntoView?.({block:"nearest"}))},[Y,D]),mo("button",{ref:O,type:"button",value:k.value,className:Vo("",z,Y),title:k.text,tabIndex:z?0:-1,onClick:W=>{T(Number(W.currentTarget.value))},onMouseMove:()=>{v?.value!==k.value&&o(k.value)},children:mo(Yo,{icon:k.icon,badge:k.badge&&mo(ad,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:Z5({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(mo(Cs,{title:f("fontList.sceneFonts"),children:P.map((k,D)=>mo(L,{font:k,order:D},k.value))},"group_1")),A.length&&_.push(mo(Cs,{title:f("fontList.availableFonts"),children:A.map((k,D)=>mo(L,{font:k,order:D+P.length},k.value))},"group_2")),q5(lo,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[m==="full"&&mo(nd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:K5(u,20)}),mo(od,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,n)=>e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as J5}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as Q5}from"@excalidraw/common";import{jsx as fh}from"react/jsx-runtime";var iw=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Be(),r=t?{...Q5,width:"2rem",height:"2rem"}:{};return fh(J5.Trigger,{asChild:!0,children:fh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:fh(K,{type:"toggle",icon:wn,title:f("labels.showFonts"),"aria-label":f("labels.showFonts"),className:"standalone properties-trigger","data-testid":"font-family-show-fonts",checked:n,onSelect:()=>{o(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as Ms,jsxs as aw}from"react/jsx-runtime";var sw=[{value:Eh.Excalifont,icon:Gn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Eh.Nunito,icon:fs,text:f("labels.normal"),testId:"font-family-normal"},{value:Eh["Comic Shanns"],icon:Dc,text:f("labels.code"),testId:"font-family-code"}],vee=new Set(sw.map(e=>e.value));var lw=n4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=r4(()=>sw,[]),c=o4(d=>{d&&o(d)},[o]);return aw("div",{role:"dialog","aria-modal":"true",className:t4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&Ms("div",{className:"buttonList",children:Ms(Vt,{type:"button",options:l,value:n,onClick:c})}),!s&&Ms(Xc,{}),aw(e4.Root,{open:e,onOpenChange:a,children:[Ms(iw,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&Ms(rw,{selectedFontFamily:n,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,n)=>e.isOpened===n.isOpened&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as bh}from"radix-ui";import l4 from"clsx";import pw,{useEffect as c4,useMemo as d4}from"react";import{isArrowKey as m4,KEYS as po}from"@excalidraw/common";import{jsx as i4}from"react/jsx-runtime";var sd=({className:e,icon:n,size:t="1em"})=>i4("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:n});import{Fragment as s4,jsx as cw,jsxs as dw}from"react/jsx-runtime";var a4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>dw(s4,{children:[dw("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&cw(sd,{icon:n?$1:Nc})]}),n&&cw("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),As=a4;import{jsx as Xn,jsxs as cd}from"react/jsx-runtime";var p4=qe(!1),ld=4,u4="default",h4=e=>e.flatMap(n=>n.options),mw=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},g4=(e,n)=>e.some(t=>t.options.some(n)),f4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/ld)},(t,o)=>n.options.slice(o*ld,o*ld+ld)));function E4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=De(),[s,l]=ze(p4),c=[...e,...n],d=h4(c),m=f4([...e,...s?n:[]]),p=g=>{let b=d.find(y=>y.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===po.TAB){let y=d.findIndex(x=>x.value===t),w=g.shiftKey?(d.length+y-1)%d.length:(y+1)%d.length;r(d[w].value)}else if(m4(g.key)){let y=Hn().rtl,w=d.findIndex(x=>x.value===t);if(w!==-1){let x=d.length,v=w;switch(g.key){case(y?po.ARROW_LEFT:po.ARROW_RIGHT):v=(w+1)%x;break;case(y?po.ARROW_RIGHT:po.ARROW_LEFT):v=(x+w-1)%x;break;case po.ARROW_DOWN:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(T+1)%m.length],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case po.ARROW_UP:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(m.length+T-1)%m.length],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[v].value)}g.preventDefault()}else(g.key===po.ESCAPE||g.key===po.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};c4(()=>{g4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>Xn("div",{className:"picker-content",children:g.map(b=>cd("button",{type:"button",className:l4("picker-option",{active:t===b.value}),onClick:()=>{r(b.value)},title:b.keyBinding?`${b.text} \u2014 ${b.keyBinding.toUpperCase()}`:b.text,"aria-label":b.text||"none","aria-keyshortcuts":b.keyBinding||void 0,ref:y=>{t===b.value&&setTimeout(()=>{y?.focus()},0)},children:[b.icon,b.keyBinding&&Xn("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,y)=>b.name===u4?Xn(pw.Fragment,{children:u(b.options)},`${b.name}-${y}`):cd("div",{className:"picker-section",children:[Xn("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${y}`));return Xn(bh.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:p,collisionBoundary:a??void 0,children:cd("div",{className:"picker-sections",children:[E(e),n.length>0&&Xn(As,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:Xn("div",{className:"picker-sections",children:E(n)})})]})})}function xh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=pw.useState(!1),s=d4(()=>mw(t,l=>l.value===e)??mw(o??[],l=>l.value===e),[t,o,e]);return Xn("div",{children:cd(bh.Root,{open:i,onOpenChange:l=>a(l),children:[Xn(bh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&Xn(E4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import uw,{useEffect as b4}from"react";import{jsx as wh,jsxs as hw}from"react/jsx-runtime";var gw=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:s=!0,testId:l})=>{let c=uw.useRef(null),d=uw.useRef(null);return b4(()=>{if(c.current&&d.current){let m=c.current,p=d.current,u=m.offsetWidth,E=parseFloat(getComputedStyle(m).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;p.style.left=`${b}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,o,n]),hw("label",{className:"control-label",children:[e,hw("div",{className:"range-wrapper",children:[wh("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":l}),wh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),wh("div",{className:"zero-label",children:a})]})]})};import{Fragment as fd,jsx as Q,jsxs as ft}from"react/jsx-runtime";var Sw=.1,_r=e=>{let n=W4(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Tt=(e,n,t,o=!1)=>{let r=Sh(se(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(B4(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},ct=function(e,n,t,o,r){let i=n.state.editingTextElement,a=Iw(e),s=null;if(i&&(s=t(i)),!s)if(Me(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=R4(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},V4=(e,n,t)=>F4(n)||!n.autoResize?n:t.mutateElement(n,{x:e.textAlign==="left"?e.x:e.x+(e.width-n.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-n.height)/2}),Ch=(e,n,t,o,r)=>{let i=new Set,a=Tt(e,n,s=>{if(Ot(s)){let l=o(s);i.add(l);let c=ot(s,{fontSize:l});return Ls(c,t.scene.getContainerElement(s),t.scene),c=V4(s,c,t.scene),c}return s},!0);return se(e,n,{includeBoundTextElement:!0}).forEach(s=>{Ot(s)&&O4(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:Qe.IMMEDIATELY}},Y4=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Tt(e,n,o=>H4(o.type)?ot(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?Qe.IMMEDIATELY:Qe.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=_r(o);return ft(fd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.stroke")}),Q(Ai,{topPicks:S4,palette:T4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:ct(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),X4=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:Qe.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!_4(t.currentItemBackgroundColor)&&i.every(s=>xw(s)&&N4(s.points))){let s=Sh(i);r=e.map(l=>s.has(l.id)&&xw(l)?ot(l,{backgroundColor:t.currentItemBackgroundColor,...U4(l,!0)}):l)}else r=Tt(e,n,s=>ot(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:Qe.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=_r(o);return ft(fd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ai,{topPicks:I4,palette:yw,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:ct(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),gd=F({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:Qe.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=_r(o);return ft(fd,{children:[r==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ai,{topPicks:y4,palette:yw,excludedColors:[v4.transparent],customizableTopPicks:"bucketFill",type:"elementBackground",label:f("labels.background"),color:o.bucketFill.getBucketFillBackgroundColor(n.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:n,updateData:t})]})}}),K4=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Ne("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Tt(e,n,r=>ot(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=se(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return ft("fieldset",{children:[Q("legend",{children:f("labels.fill")}),Q("div",{className:"buttonList",children:Q(Vt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?Xx:Kx,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:Zx,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:$x,testId:"fill-solid"}],value:ct(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),Z4=e=>M4.find(n=>vw(e.type,n)===e.strokeWidth)??null,$4=(e,n)=>vw(e.type,n),j4=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(hd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Tt(e,n,o=>ot(o,{strokeWidth:$4(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Ru,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:jx,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:qx,testId:"strokeWidth-bold"}],value:ct(e,o,Z4,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),q4=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>ot(o,{seed:A4(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:e1},{value:1,text:f("labels.artist"),icon:t1},{value:2,text:f("labels.cartoonist"),icon:n1}],value:ct(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),J4=F({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Tt(e,n,r=>r.type!=="freedraw"?r:ot(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:Qe.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=ct(e,o,a=>a.strokeOptions?.variability,a=>a.type==="freedraw",a=>a?null:n.currentItemStrokeVariability)??n.currentItemStrokeVariability;if(r?.cycle){let a=i==="variable";return Q(K,{type:"button",icon:a?Bu:Nu,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return ft("fieldset",{children:[Q("legend",{children:f("labels.pressure")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:Nu},{value:"variable",text:f("labels.pressure_variable"),icon:Bu}],value:i,onChange:a=>t(a)})})]})}}),kte=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>ot(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Ru},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:Jx},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:Qx}],value:ct(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),Q4=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>ot(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=ct(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return Q(gw,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),e6=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>Ch(e,n,o,()=>(hd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=_r(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"font-size",options:[{value:md.sm,text:f("labels.small"),icon:w1,testId:"fontSize-small"},{value:md.md,text:f("labels.medium"),icon:y1,testId:"fontSize-medium"},{value:md.lg,text:f("labels.large"),icon:v1,testId:"fontSize-large"},{value:md.xl,text:f("labels.veryLarge"),icon:I1,testId:"fontSize-veryLarge"}],value:ct(e,o,a=>{if(Ot(a))return a.fontSize;let s=$o(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Ot(a)||$o(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||P4),onChange:a=>{ws(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),Ph=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:kr,trackEvent:!1,perform:(e,n,t,o)=>Ch(e,n,o,r=>Math.round(1/(1+Sw)*r.fontSize)),keyTest:e=>e[_i.CTRL_OR_CMD]&&e.shiftKey&&(e.key===_i.CHEVRON_LEFT||e.key===_i.COMMA)}),kh=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:kr,trackEvent:!1,perform:(e,n,t,o)=>Ch(e,n,o,r=>Math.round(r.fontSize*(1+Sw))),keyTest:e=>e[_i.CTRL_OR_CMD]&&e.shiftKey&&(e.key===_i.CHEVRON_RIGHT||e.key===_i.PERIOD)}),t6=F({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:Tt(e,n,g=>{let b=r?.get(g.id);return b?ot(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:Qe.NEVER};hd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=Qe.EVENTUALLY,m,p=!1;if(l)m=l,d=Qe.IMMEDIATELY;else if(c){m=c,d=Qe.EVENTUALLY;let E=se(e,n,{includeBoundTextElement:!0}).filter(g=>Ot(g));if(E.length>200)p=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let y=E[g];b+=y?.originalText.length||0,g++}b>5e3&&(p=!0)}}let u={appState:{...n,...s},captureUpdate:d};if(m&&!p){let E=new Map,g=new Set,b=!1,y=Array.from(io.loadedFontsCache.values()),w=Object.entries(k4).find(([T,C])=>C===m)?.[0];c&&w&&y.some(T=>T.startsWith(w))&&(b=!0),Object.assign(u,{elements:Tt(e,n,T=>{if(Ot(T)&&(T.fontFamily!==m||l)){let C=ot(T,{fontFamily:m,lineHeight:D4(m)}),P=r?.get(T.containerId||"")||{},A=o.scene.getContainerElement(T);return a&&A&&P&&o.scene.mutateElement(A,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,A),C}return T},!0)});let x=`10px ${L4({fontFamily:m})}`,v=Array.from(g.values()).join();if(b||window.document.fonts.check(x,v))for(let[T,C]of E)Ls(T,C,o.scene);else window.document.fonts.load(x,v).then(T=>{for(let[C,P]of E){let A=o.scene.getElement(C.id),L=P?o.scene.getElement(P.id):null;A&&Ls(A,L,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=vh(new Map),i=vh(null),[a,s]=w4({}),l=vh(!0),{stylesPanelMode:c,isCompact:d}=_r(t),m=Th(()=>{let p=(u,E)=>ct(u,t,g=>{if(Ot(g))return g.fontFamily;let b=$o(g,E);return b?b.fontFamily:null},g=>Ot(g)||$o(g,E)!==null,g=>g?null:n.currentItemFontFamily||C4);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?p(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return yh(()=>{i.current=m},[m]),yh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),yh(()=>(l.current=!1,()=>{l.current=!0}),[]),ft(fd,{children:[c==="full"&&Q("legend",{children:f("labels.fontFamily")}),Q(lw,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{ws(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),r.current.clear()},d,!!n.editingTextElement)},onHover:p=>{s({currentHoveredFontFamily:p,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:p=>{if(p){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,ot(E||u,{},!0))}else{let E=se(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,ot(g,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&n.editingTextElement&&xs(null)}}})]})}}),n6=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Tt(e,n,r=>{if(Ot(r)){let i=ot(r,{textAlign:t});return Ls(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=_r(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:S1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:C1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:P1,testId:"align-right"}],value:ct(e,o,s=>{if(Ot(s))return s.textAlign;let l=$o(s,i);return l?l.textAlign:null},s=>Ot(s)||$o(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{ws(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),o6=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Tt(e,n,r=>{if(Ot(r)){let i=ot(r,{verticalAlign:t});return Ls(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=_r(o);return Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Vt,{group:"text-align",options:[{value:dd.TOP,text:f("labels.alignTop"),icon:Q(k1,{theme:n.theme}),testId:"align-top"},{value:dd.MIDDLE,text:f("labels.centerVertically"),icon:Q(A1,{theme:n.theme}),testId:"align-middle"},{value:dd.BOTTOM,text:f("labels.alignBottom"),icon:Q(M1,{theme:n.theme}),testId:"align-bottom"}],value:ct(e,o,a=>{if(Ot(a)&&a.containerId)return a.verticalAlign;let s=$o(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Ot(a)||$o(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:dd.MIDDLE),onChange:a=>{ws(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),Mte=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>Tw(o)?o:ot(o,{roundness:t==="round"?{type:z4(o.type)?pd.ADAPTIVE_RADIUS:pd.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=di(Iw(e),n).some(s=>s.roundness?.type===pd.LEGACY);return ft("fieldset",{children:[Q("legend",{children:f("labels.edges")}),ft("div",{className:"buttonList",children:[Q(Vt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:o1},{value:"round",text:f("labels.round"),icon:r1}],value:ct(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!ud(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),ww=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Q(i1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(a1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:Q(s1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:Q(l1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:Q(c1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(d1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:Q(m1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:Q(p1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:Q(u1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:Q(h1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:Q(g1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:Q(f1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:Q(E1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:Q(b1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:Q(x1,{flip:e}),keyBinding:null}]}]}),Ate=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(hd(t,"actionChangeArrowhead: value must be defined"),{elements:Tt(e,n,o=>{if(Ih(o)){let{position:r,type:i}=t;if(r==="start")return ot(o,{startArrowhead:i});if(r==="end")return ot(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Hn().rtl,i=Th(()=>ww(!r),[r]),a=Th(()=>ww(!!r),[r]);return ft("fieldset",{children:[Q("legend",{children:f("labels.arrowheads")}),ft("div",{className:"iconSelectList buttonList",children:[Q(xh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:ct(e,o,s=>Ih(s)&&os(s.type)?bw(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),Q(xh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:ct(e,o,s=>Ih(s)&&os(s.type)?bw(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),r6=F({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,n,t,o)=>!1,PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>ft("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),Lte=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Tt(e,n,s=>{if(!ud(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Dr.getPointAtIndexGlobalCoordinates(s,0,l),d=Dr.getPointAtIndexGlobalCoordinates(s,-1,l),m=ot(s,{x:t===on.elbow?c[0]:s.x,y:t===on.elbow?c[1]:s.y,roundness:t===on.round?{type:pd.PROPORTIONAL_RADIUS}:null,elbowed:t===on.elbow,angle:t===on.elbow?0:s.angle,points:t===on.elbow||s.elbowed?[Dr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Dr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Tw(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Dr.getPointAtIndexGlobalCoordinates(m,0,p),E=Dr.getPointAtIndexGlobalCoordinates(m,-1,p),g=m.startBinding&&p.get(m.startBinding.elementId),b=m.endBinding&&p.get(m.endBinding.elementId),y=g&&m.startBinding?{...m.startBinding,...Ew(m,g,"start",p,n.isBindingEnabled)}:null,w=b&&m.endBinding?{...m.endBinding,...Ew(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:y,endBinding:w,...G4(m,p,{points:[u,E].map(x=>x4(x[0]-m.x,x[1]-m.y)),startBinding:y,endBinding:w,fixedSegments:null})}}else{let p=o.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&fw(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&fw(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new Dr(s,Sh(e)))}return{elements:r,appState:i,captureUpdate:Qe.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ft("fieldset",{children:[Q("legend",{children:f("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"arrowtypes",options:[{value:on.sharp,text:f("labels.arrowtype_sharp"),icon:Fo,testId:"sharp-arrow"},{value:on.round,text:f("labels.arrowtype_round"),icon:Ho,testId:"round-arrow"},{value:on.elbow,text:f("labels.arrowtype_elbowed"),icon:zo,testId:"elbow-arrow"}],value:ct(e,o,r=>ud(r)?r.elbowed?on.elbow:r.roundness?on.round:on.sharp:null,r=>ud(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as m6,MAX_ZOOM as p6,MIN_ZOOM as u6,THEME as Ds,ZOOM_STEP as kw,CODES as Rr,KEYS as bd}from"@excalidraw/common";import{getNonDeletedElements as _s}from"@excalidraw/element";import{getCommonBounds as Rs}from"@excalidraw/element";import{CaptureUpdateAction as Bi}from"@excalidraw/element";import{useEffect as i6}from"react";import{jsx as s6}from"react/jsx-runtime";var Ri=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let n=document.createElement("div");return document.body.appendChild(n),n.classList.add("excalidraw-tooltip"),n},Mh=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=n.left+n.width/2-o.width/2;s<0?s=a:s+o.width>=r&&(s=r-o.width-a);let l;t==="bottom"?(l=n.top+n.height+a,l+o.height>=i&&(l=n.top-o.height-a)):(l=n.top-o.height-a,l<0&&(l=n.top+n.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},a6=(e,n,t,o)=>{n.classList.add("excalidraw-tooltip--visible"),n.style.minWidth=o?"50ch":"10ch",n.style.maxWidth=o?"50ch":"15ch",n.textContent=t;let r=e.getBoundingClientRect();Mh(n,r)},dt=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(i6(()=>()=>Ri().classList.remove("excalidraw-tooltip--visible"),[]),r?null:s6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>a6(i.currentTarget,Ri(),n,t),onPointerLeave:()=>Ri().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as Cw,useRef as Pw,useState as l6}from"react";var c6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Ah=(e,n,t)=>{if(e?.isDestroyed)return;let o=e?.getAppState();if(!o){if(!t)return;console.warn("useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?"),o=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},_o())}return c6(o,n)};function Ni(e,n=!0){let t=Ed(),[,o]=l6(0),r=Pw(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Ah(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Ah(t,e,n)),Cw(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(s=>s+1)})},[t]),r.current.latestValue}function d6(e,n){let t=Ed(),o=Pw({selector:e,callback:n});o.current.selector=e,o.current.callback=n,Cw(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Ah(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Id,jsxs as f6}from"react/jsx-runtime";var h6=F({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!n.viewModeEnabled,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:t?.viewBackgroundColor?Bi.IMMEDIATELY:Bi.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Id(Ai,{palette:null,topPicks:m6,label:f("labels.canvasBackground"),type:"canvasBackground",color:n.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:n,updateData:t})}),xd=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:Eu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...ro({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Fn(n.zoom.value+kw)},n)},captureUpdate:Bi.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Id(K,{type:"button",className:"zoom-in-button zoom-button",icon:Eu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=p6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Rr.EQUAL||e.code===Rr.NUM_ADD)&&(e[bd.CTRL_OR_CMD]||e.shiftKey)}),wd=F({name:"zoomOut",label:"buttons.zoomOut",icon:bu,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...ro({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Fn(n.zoom.value-kw)},n)},captureUpdate:Bi.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Id(K,{type:"button",className:"zoom-out-button zoom-button",icon:bu,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=u6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Rr.MINUS||e.code===Rr.NUM_SUBTRACT)&&(e[bd.CTRL_OR_CMD]||e.shiftKey)}),yd=F({name:"resetZoom",label:"buttons.resetZoom",icon:kx,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?.lockZoom?n.scrollConstraints.zoom:1;return{appState:{...n,...ro({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Fn(r)},n)},captureUpdate:Bi.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Id(dt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:f6(K,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(n*100).toFixed(0),"%"]})})},keyTest:e=>(e.code===Rr.ZERO||e.code===Rr.NUM_ZERO)&&(e[bd.CTRL_OR_CMD]||e.shiftKey)}),Lh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],lne=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Rc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?Rs(_s(r)):n.scrollConstraints?Lh(n.scrollConstraints):Rs(_s(e)),a=vr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...On(a.appState)}}},keyTest:void 0}),cne=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Rc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?Rs(_s(r)):n.scrollConstraints?Lh(n.scrollConstraints):Rs(_s(e)),a=vr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...On(a.appState)}}},keyTest:void 0}),g6=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Rc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?Lh(n.scrollConstraints):Rs(_s(e)),i=vr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...On(i.appState)}}},keyTest:void 0}),vd=F({name:"toggleTheme",label:(e,n)=>n.theme===Ds.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Ds.LIGHT?ps:us,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Ds.LIGHT?Ds.DARK:Ds.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:Bi.EVENTUALLY}},keyTest:e=>!e[bd.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Rr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as S6}from"@excalidraw/math";import{bindOrUnbindBindingElement as zw}from"@excalidraw/element/binding";import{isValidPolygon as Hw,newElementWith as Rh}from"@excalidraw/element";import{LinearElementEditor as zs}from"@excalidraw/element/linearElementEditor";import{isBindingElement as Nh,isFreeDrawElement as Gw,isLinearElement as Uw,isLineElement as Ad}from"@excalidraw/element";import{KEYS as Ld,arrayToMap as C6,invariant as Ww,shouldRotateWithDiscreteAngle as P6,updateActiveTool as Vw}from"@excalidraw/common";import{isPathALoop as k6}from"@excalidraw/element";import{isInvisiblySmallElement as Bh}from"@excalidraw/element";import{CaptureUpdateAction as Oh}from"@excalidraw/element";import w6 from"clsx";import{useEffect as y6,useState as v6}from"react";import{KEYS as rn,capitalizeString as Nr}from"@excalidraw/common";import{useEffect as E6,useState as b6}from"react";import Mw from"clsx";import{capitalizeString as Td}from"@excalidraw/common";import{Popover as Dh}from"radix-ui";import{jsx as Sd,jsxs as x6}from"react/jsx-runtime";var Oi=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=b6(!1),c=t.type,d=a.type===c,m=16,{container:p}=De();return!n.some(u=>u.type===c)&&s&&l(!1),E6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),x6(Dh.Root,{open:s,children:[Sd(Dh.Trigger,{asChild:!0,children:Sd(K,{className:Mw({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>$e(e,u.type)),title:Td(a.title),"aria-label":Td(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Sd(Dh.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Sd(K,{className:Mw({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:$e(e,u),title:Td(u),"aria-label":Td(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Ne("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as _h}from"react/jsx-runtime";var I6=e=>e,We=I6({hand:{icon:L1,letterKey:rn.H,toggle:!0},selection:{icon:Cc,letterKey:rn.V,fillable:!0},rectangle:{icon:Ei,letterKey:rn.R,fillable:!0},diamond:{icon:bi,letterKey:rn.D,fillable:!0},ellipse:{icon:xi,letterKey:rn.O,fillable:!0},arrow:{icon:Pc,letterKey:rn.A,fillable:!0},line:{icon:No,letterKey:rn.L,fillable:!0},freedraw:{icon:Gn,letterKey:rn.P},text:{icon:wn,letterKey:rn.T},image:{icon:Cr},eraser:{icon:kc,letterKey:rn.E,toggle:!0},frame:{icon:Wn,letterKey:rn.F},autoshape:{icon:Mr,letterKey:rn.X,fillable:!1},embeddable:{icon:Bo},laser:{icon:Vn},bucketfill:{icon:Un},lasso:{icon:fi,fillable:!1}});var Fi=["autoshape","rectangle","diamond","ellipse","arrow","line"],zi=Object.keys(We).filter(e=>We[e].toggle),Cd=e=>{let{letterKey:n,shiftKey:t}=We[e];if(!n)return n;let o=Nr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},Hi=e=>Cd(e),T6=e=>{let n=Cd(e);return n?.length===1?n:void 0},Aw=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(We)){let{letterKey:i,shiftKey:a}=We[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},$e=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Ft=(e,n)=>{let t=We[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Nr(f(`toolBar.${e}`)),d=l?null:Hi(o);return _h(K,{className:w6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:$e(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:T6(o),"aria-label":c,"aria-keyshortcuts":d??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:m})=>{if(!i.state.penDetected&&m==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:m});return}i.state.activeTool.type!==e&&(Ne("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Nr(e)}IconButton`,r},Pd=Ft("hand"),Lw=Ft("rectangle"),Dw=Ft("diamond"),_w=Ft("ellipse"),Rw=Ft("arrow"),Nw=Ft("line"),Ns=Ft("freedraw"),Bs=Ft("text"),Os=Ft("image"),Fs=Ft("eraser"),Bw=Ft("frame"),One=Ft("autoshape"),Ow=Ft("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Ne("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),Fw=Ft("lasso",{shortcutType:"selection"}),kd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:We.selection.icon,fillable:We.selection.fillable,title:Nr(f("toolBar.selection"))},{type:"lasso",icon:We.lasso.icon,fillable:We.lasso.fillable,title:Nr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return _h(Oi,{app:e,options:o,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",onToolChange:i=>{(i==="selection"||i==="lasso")&&(e.setActiveTool({type:i}),t({preferredSelectionTool:{type:i,initialized:!0}}))},displayedOption:r})},Md=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:We.freedraw.icon,fillable:We.freedraw.fillable,title:Nr(f("toolBar.freedraw"))},{type:"autoshape",icon:We.autoshape.icon,fillable:We.autoshape.fillable,title:Nr(f("toolBar.autoshape"))}],[o,r]=v6(n.type==="autoshape"?"autoshape":"freedraw");y6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return _h(Oi,{app:e,options:t,activeTool:n,defaultOption:o,"data-testid":"toolbar-freedraw",onToolChange:a=>{(a==="freedraw"||a==="autoshape")&&(r(a),e.setActiveTool({type:a}))},displayedOption:i})};import{jsx as M6}from"react/jsx-runtime";var mt=F({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:s}=o,l=s.getNonDeletedElementsMap(),c=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:y}=t,w=zs.getElement(n.selectedLinearElement.elementId,l);Ww(w,"Arrow element should exist if selectedLinearElement is set"),Ww(y,"sceneCoords should be defined if actionFinalize is called with event");let x=zs.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(Nh(w)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let v=!!n.newElement,T=v||!n.selectedLinearElement.selectedPointsIndices?[w.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=P6(b),P=b[Ld.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),A=T.reduce((L,_)=>(L.set(_,{point:C?w.points[_]:zs.createPointAt(w,l,y.x-x.pointerOffset.x,y.y-x.pointerOffset.y,P)}),L),new Map)??new Map;zw(w,A,y.x,y.y,s,n,{newArrow:v,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Ad(w)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!Hw(w.points)&&s.mutateElement(w,{polygon:!1});if(x!==n.selectedLinearElement){w&&Bh(w)&&(i=i.map(T=>T.id===w.id?Rh(T,{isDeleted:!0}):T));let v=n.activeTool?.locked;return{elements:w.points.length<2||Bh(w)?e.map(T=>T.id===w.id?Rh(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:v||c?null:{...x,selectedPointsIndices:null,isEditing:!1,initialState:{...x.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:Oh.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let d=o.drawShape.hasPendingGesture();(d||c)&&(o.drawShape.finalize(),d&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!c&&!d&&(n.newElement?.type==="freedraw"||Nh(n.newElement)))m=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=l.get(Object.keys(n.selectedElementIds)[0]);b&&(m=b)}if(m){if(n.selectedLinearElement&&n.multiElement&&m.type!=="freedraw"&&n.lastPointerDownWith!=="touch"){let{points:b}=m,{lastCommittedPoint:y}=n.selectedLinearElement;if((!y||b[b.length-1]!==y)&&(r=!1,s.mutateElement(m,{points:m.points.slice(0,-1)}),Nh(m)&&m.endBinding&&m.points.length>1)){let w=!!n.newElement,x=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),v=zs.getPointAtIndexGlobalCoordinates(m,-1,l);zw(m,x,v[0],v[1],s,n,{newArrow:w})}}if(m&&Bh(m)&&(i=i.map(b=>b.id===m?.id?Rh(b,{isDeleted:!0}):b)),Uw(m)||Gw(m)){if(k6(m.points,n.zoom.value)&&(Ad(m)||Gw(m))){let y=m.points,w=y[0],x=y.map((v,T)=>T===y.length-1?S6(w[0],w[1]):v);Ad(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Ad(m)&&!Hw(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;zi.includes(n.activeTool.type)?p=Vw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=Vw(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!m;E||o.cursor.applyForTool(p);let g=m&&Uw(m)?new zs(m,C6(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:c?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?Oh.IMMEDIATELY:Oh.NEVER}},keyTest:(e,n)=>e.key===Ld.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Ld.ESCAPE||e.key===Ld.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>M6(K,{type:"button",icon:zx,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:n,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as Kw,isSomeElementSelected as A6,makeNextSelectedElementIds as L6,selectGroupsForSelectedElements as D6}from"@excalidraw/element";import{CaptureUpdateAction as Yw}from"@excalidraw/element";import{KEYS as _6,isWritableElement as R6,updateActiveTool as Xw}from"@excalidraw/common";var N6=(e,n)=>zi.includes(e.activeTool.type)?Xw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):Xw(e,{type:n.state.preferredSelectionTool.type}),B6=(e,n,t)=>{if(!e.editingGroupId)return null;let o=n.scene.getNonDeletedElements(),r=n.scene.getSelectedElements({selectedElementIds:t,elements:o}),i=r.length?r:Kw(o,e.editingGroupId);for(let a of i){let s=a.groupIds.indexOf(e.editingGroupId);if(s!==-1&&a.groupIds[s+1])return a.groupIds[s+1]}return null},O6=F({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=N6(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:Kw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...D6({editingGroupId:B6(n,o,a),selectedElementIds:a},i,n,o),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Yw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:L6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Yw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==_6.ESCAPE||R6(e.target)?!1:!n.newElement&&n.multiElement===null&&!n.selectedLinearElement?.isEditing&&(n.activeEmbeddable!==null||n.activeTool.type!==o.state.preferredSelectionTool.type||!!n.editingGroupId||!!n.selectedLinearElement||A6(o.scene.getNonDeletedElements(),n))});import{KEYS as Hd,THEME as Ws}from"@excalidraw/common";import{CaptureUpdateAction as vn}from"@excalidraw/element";import F6 from"clsx";import{jsx as Zw,jsxs as z6}from"react/jsx-runtime";var Fh=({children:e,checked:n,onChange:t,className:o})=>z6("div",{className:F6("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Zw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Mc}),Zw("div",{className:"Checkbox-label",children:e})]});import{THEME as Hs}from"@excalidraw/common";import{jsx as Gs}from"react/jsx-runtime";var jw=e=>{let n=e.title||(e.value===Hs.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return Gs(K,{type:"icon",icon:e.value===Hs.LIGHT?$w.MOON:$w.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===Hs.DARK?Hs.LIGHT:Hs.DARK),"data-testid":"toggle-dark-mode"})},$w={SUN:Gs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Gs("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:Gs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Gs("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 H6}from"react";import{focusNearestParent as G6,KEYS as U6}from"@excalidraw/common";import{jsx as qw,jsxs as W6}from"react/jsx-runtime";var Jw=e=>{let{id:n}=De(),[t,o]=H6(e.value),r=a=>{e.ignoreFocus||G6(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===U6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return W6("div",{className:"ProjectName",children:[qw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),qw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as V6,useEffect as Y6,useRef as X6}from"react";import{jsx as Dd,jsxs as j6}from"react/jsx-runtime";var K6=5e3,Z6=({progress:e})=>Dd("div",{className:"Toast__progress-bar",children:Dd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),$6=({message:e,onClose:n,closable:t=!1,duration:o=K6,style:r})=>{let i=X6(0),a=o!==1/0,s=V6(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return Y6(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),j6("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Dd("div",{className:"Toast__message",children:e}),t&&Dd(K,{icon:Qt,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},_d=Object.assign($6,{ProgressBar:Z6});import{DEFAULT_EXPORT_PADDING as hL,DEFAULT_FILENAME as gL,IMAGE_MIME_TYPES as ry,isFirefox as fL,MIME_TYPES as EL,cloneJSON as bL,SVG_DOCUMENT_PREAMBLE as xL,arrayToMap as wL}from"@excalidraw/common";import{getNonDeletedElements as yL}from"@excalidraw/element";import{isFrameLikeElement as vL}from"@excalidraw/element";import{getElementsOverlappingFrame as IL}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as q6,EXPORT_DATA_TYPES as Us,MIME_TYPES as pt,arrayToMap as J6,isMemberOf as Q6,isPromiseLike as eL,EVENT as Rd}from"@excalidraw/common";import{mutateElement as tL}from"@excalidraw/element";import{deepCopyElement as nL}from"@excalidraw/element";import{isFrameLikeElement as oL,isInitializedImageElement as rL}from"@excalidraw/element";import{getContainingFrame as Qw}from"@excalidraw/element";var tre="clipboard"in navigator&&"readText"in navigator.clipboard,Nd="clipboard"in navigator&&"writeText"in navigator.clipboard,jo="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,iL=e=>!!([Us.excalidraw,Us.excalidrawClipboard,Us.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),ey=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Rd.PASTE,{clipboardData:new DataTransfer});if(e)for(let[o,r]of Object.entries(e)){if(typeof r!="string"){n=n||[],n.push(r);continue}try{if(t.clipboardData?.items.add(r,o),t.clipboardData?.getData(o)!==r)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(n){let o=-1;for(let r of n){o++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[o]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},aL=({elements:e,files:n})=>{let t=J6(e),o=new Set(e.filter(s=>oL(s))),r=!1,i=e.reduce((s,l)=>(rL(l)&&(r=!0,n&&n[l.fileId]&&(s[l.fileId]=n[l.fileId])),s),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Us.excalidrawClipboard,elements:e.map(s=>{if(Qw(s,t)&&!o.has(Qw(s,t))){let l=nL(s);return tL(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},Bd=async(e,n,t)=>{let o=aL({elements:e,files:n});await uo({[pt.excalidrawClipboard]:o,[pt.text]:o},t)};function ty(e){let n=[];for(let t of e.childNodes)if(t.nodeType===3){let o=t.textContent?.trim();o&&n.push({type:"text",value:o})}else if(t instanceof HTMLImageElement){let o=t.getAttribute("src");o&&o.startsWith("http")&&n.push({type:"imageUrl",value:o})}else n=n.concat(ty(t));return n}var sL=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,pt.html),o=ty(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},ny=async()=>{let e={},n;try{n=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let o=await navigator.clipboard?.readText();if(o)return{[pt.text]:o}}}catch(o){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);else{if(o.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${o.message}`),e;throw o}}throw t}for(let t of n)for(let o of t.types)if(Q6(q6,o))try{if(o===pt.text||o===pt.html)e[o]=await(await t.getType(o)).text();else if(ix(o)){let r=await t.getType(o),i=px(r,o,void 0);e[o]=i}else throw new pu(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof pu?r.message:`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},lL=async(e,n=!1)=>{try{let t=e.findByType(pt.html),o=!n&&t&&sL(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(pt.text)??o.value.map(r=>r.value).join(`
|
|
2
|
-
`).trim()}:o:{type:"text",value:(e.getData(
|
|
1
|
+
import{$ as Si,A as ix,B as xu,C as us,D as vc,E as yu,F as ax,G as sx,H as Ic,I as hs,J as Tc,K as Sc,L as gs,M as lx,N as cx,O as dx,P as Cc,Q as Ar,R as v3,S as Dr,T as Ti,V as mx,X as px,Y as ux,Z as Pc,_ as hx,a as gu,aa as fs,b as Vn,ba as Es,c as ho,ca as gx,d as Mr,da as kc,e as wi,ea as fx,f as Yn,fa as Ex,g as Qb,ga as bx,h as De,ha as wu,i as ex,ia as xx,j as ce,ja as yx,k as vi,ka as wx,l as Go,la as Lr,m as tx,n as fu,o as nx,p as ms,q as ox,r as wc,s as rx,t as Eu,u as bu,v as go,w as Ho,x as on,y as ps,z as Ii}from"./chunk-AS35EYHE.js";import{a as S}from"./chunk-6D6KWUBN.js";import{G as hu}from"./chunk-DARW3V66.js";import{c as Jb}from"./chunk-5XKZK2GL.js";import{b as qb,c as w3,d as v}from"./chunk-SRAX5OIU.js";import mK,{useCallback as pK,useContext as uK,useEffect as hK,useRef as gK,useState as fK}from"react";import{applyDarkModeFilter as DVe,DEFAULT_IMAGE_OPTIONS as Tn,DEFAULT_UI_OPTIONS as E3,getStrokeWidthByKey as LVe,isShallowEqual as EK}from"@excalidraw/common";import Kk from"clsx";import YV from"lodash.throttle";import vn,{useContext as Oo}from"react";import{flushSync as Ft}from"react-dom";import XV from"roughjs/bin/rough";import{nanoid as KV}from"nanoid";import{clamp as oc,pointFrom as oe,pointDistance as so,vector as $k,pointRotateRads as lb,vectorFromPoint as cb,vectorSubtract as Zk,vectorDot as jk,vectorNormalize as qk}from"@excalidraw/math";import{CODES as Tr,shouldResizeFromCenter as Jk,shouldMaintainAspectRatio as rc,shouldRotateWithDiscreteAngle as Qk,isArrowKey as db,KEYS as X,APP_NAME as $V,CURSOR_TYPE as Me,DEFAULT_STROKE_STREAMLINE as ZV,DEFAULT_STROKE_STREAMLINE_PRECISE as jV,DEFAULT_TRANSFORM_HANDLE_SPACING as qV,DEFAULT_VERTICAL_ALIGN as eM,DRAGGING_THRESHOLD as tM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as JV,ELEMENT_TRANSLATE_AMOUNT as nM,EVENT as J,FRAME_STYLE as _o,IMAGE_MIME_TYPES as QV,IMAGE_RENDER_TIMEOUT as eY,LINE_CONFIRM_THRESHOLD as mb,MIME_TYPES as lo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as tY,POINTER_BUTTON as zn,ROUNDNESS as Vp,SCROLL_TIMEOUT as nY,TAP_TWICE_TIMEOUT as oM,TEXT_TO_CENTER_SNAP_THRESHOLD as oY,THEME as ic,TOUCH_CTX_MENU_TIMEOUT as rY,VERTICAL_ALIGN as iY,YOUTUBE_STATES as Yp,ZOOM_STEP as aY,MIN_ZOOM as sY,POINTER_EVENTS as is,TOOL_TYPE as Gn,supportsResizeObserver as lY,DEFAULT_COLLISION_THRESHOLD as rM,DEFAULT_TEXT_ALIGN as cY,ARROW_TYPE as Sr,DEFAULT_REDUCED_GLOBAL_ALPHA as dY,isLocalLink as mY,normalizeLink as Xp,toValidURL as pY,getGridPoint as Mt,getLineHeight as iM,debounce as aM,distance as as,getFontString as pb,getNearestScrollableContainer as uY,isInputLike as sM,isToolIcon as hY,isWritableElement as ac,sceneCoordsToViewportCoords as Kp,tupleToCoors as ub,viewportCoordsToSceneCoords as ke,wrapEvent as gY,updateObject as hb,updateActiveTool as tn,isTransparent as fY,muteFSAbortError as EY,isTestEnv as jM,isDevEnv as qM,updateStable as sc,addEventListener as ye,normalizeEOL as bY,getDateTime as lM,isShallowEqual as cM,arrayToMap as lc,applyDarkModeFilter as xY,AppEventBus as yY,randomInteger as wY,CLASSES as gb,Emitter as co,MINIMUM_ARROW_SIZE as vY,DOUBLE_TAP_POSITION_THRESHOLD as dM,BIND_MODE_TIMEOUT as IY,invariant as mo,getFeatureFlag as Ro,createUserAgentDescriptor as JM,getFormFactor as TY,deriveStylesPanelMode as iu,isIOS as SY,isBrave as CY,isSafari as PY,loadDesktopUIModePreference as kY,setDesktopUIMode as MY,isSelectionLikeTool as $p,oneOf as mM,getStrokeWidthByKey as AY}from"@excalidraw/common";import{getObservedAppState as DY,getCommonBounds as ss,getElementAbsoluteCoords as pM,bindOrUnbindBindingElements as uM,fixBindingsAfterDeletion as LY,getHoveredElementForBinding as Cr,isBindingEnabled as Zp,updateBoundElements as jp,LinearElementEditor as ge,newElementWith as po,newFrameElement as _Y,newFreeDrawElement as RY,newEmbeddableElement as hM,newMagicFrameElement as NY,newIframeElement as BY,newArrowElement as FY,newElement as OY,newImageElement as zY,newLinearElement as GY,newTextElement as gM,refreshTextDimensions as HY,deepCopyElement as fM,duplicateElements as EM,hasBoundTextElement as bM,isArrowElement as cc,isBindingElement as uo,isBindingElementType as UY,isBoundToContainer as xM,isFrameLikeElement as Tt,isImageElement as Hn,isEmbeddableElement as No,isInitializedImageElement as fi,isLinearElement as Ot,isLinearElementType as WY,isUsingAdaptiveRadius as VY,isIframeElement as fb,isIframeLikeElement as dc,isTextBindableContainer as yM,isElbowArrow as Yt,isBindableElement as Eb,isTextElement as Xt,getNormalizedDimensions as YY,isElementCompletelyInViewport as XY,isElementInViewport as wM,isInvisiblySmallElement as vM,generateThumbHash as KY,getCornerRadius as $Y,isPathALoop as IM,embeddableURLValidator as bb,maybeParseEmbedSrc as ZY,getEmbedLink as qp,getInitializedImageElements as jY,normalizeSVG as TM,updateImageCache as xb,getBoundTextElement as yb,getContainerCenter as wb,getContainerElement as SM,isValidTextContainer as CM,redrawTextBoundingBox as qY,hasBoundingBox as JY,getCommonFrameId as PM,getFrameChildren as vb,getFrameChildrenInsertionIndex as QY,isCursorInFrame as kM,addElementsToFrame as Ib,replaceAllElementsInFrame as eX,removeElementsFromFrame as tX,getElementsInResizingFrame as Tb,getElementsInNewFrame as nX,getContainingFrame as Sb,elementOverlapsWithFrame as oX,updateFrameMembershipOfSelectedElements as MM,isElementInFrame as AM,getFrameLikeTitle as rX,filterElementsEligibleAsFrameChildren as iX,hitElementBoundText as aX,hitElementBoundingBoxOnly as sX,hitElementItself as mc,getVisibleSceneBounds as lX,cropElement as cX,wrapText as dX,isElementLink as DM,isMeasureTextSupported as mX,normalizeText as pX,measureText as LM,getLineHeightInPx as _M,getApproxMinLineWidth as uX,getApproxMinLineHeight as hX,getMinTextElementWidth as gX,ShapeCache as Ei,getRenderOpacity as fX,editGroupForSelectedElement as EX,getElementsInGroup as bi,getSelectedGroupIdForElement as bX,getSelectedGroupIds as xX,isElementInGroup as RM,isSelectedViaGroup as yX,selectGroupsForSelectedElements as Un,syncInvalidIndices as QM,syncMovedIndices as NM,excludeElementsInFramesFromSelection as wX,getSelectionStateForElements as BM,makeNextSelectedElementIds as Ae,getResizeOffsetXY as vX,getResizeArrowDirection as IX,transformElements as TX,getCursorForResizingElement as FM,getElementWithTransformHandleType as OM,getTransformHandleTypeFromCoords as zM,dragNewElement as GM,dragSelectedElements as SX,getDragOffsetXY as CX,Scene as HM,Store as PX,CaptureUpdateAction as Kt,hitElementBoundingBox as kX,isLineElement as Cb,isSimpleArrow as Pb,StoreDelta as UM,positionElementsOnGrid as WM,calculateFixedPointForNonElbowArrowBinding as VM,bindOrUnbindBindingElement as MX,mutateElement as Jp,getElementBounds as YM,doBoundsIntersect as AX,isPointInElement as XM,maxBindingDistance_simple as KM,convertToExcalidrawElements as DX,getSnapOutlineMidPoint as kb,handleFocusPointDrag as LX,handleFocusPointHover as _X,handleFocusPointPointerDown as RX,handleFocusPointPointerUp as NX,maybeHandleArrowPointlikeDrag as Qp,getUncroppedWidthAndHeight as BX,getActiveTextElement as $M,isEligibleFrameChildType as FX,getBindingStrategyForDraggingBindingElementEndpoints as OX,isNonDeletedElement as eu}from"@excalidraw/element";import{KEYS as Qu,MOBILE_ACTION_BUTTON_BG as B3,updateActiveTool as F3}from"@excalidraw/common";import{getNonDeletedElements as $c}from"@excalidraw/element";import{fixBindingsAfterDeletion as O3}from"@excalidraw/element";import{LinearElementEditor as b0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Kc}from"@excalidraw/element";import{getContainerElement as x0}from"@excalidraw/element";import{isBoundToContainer as Yc,isElbowArrow as z3,isFrameLikeElement as G3}from"@excalidraw/element";import{getFrameChildren as H3}from"@excalidraw/element";import{getElementsInGroup as eh,selectGroupsForSelectedElements as U3}from"@excalidraw/element";import{CaptureUpdateAction as Xc}from"@excalidraw/element";import{isDevEnv as C3}from"@excalidraw/common";import{atom as Je,createStore as I3}from"jotai";import{createIsolation as T3}from"jotai-scope";var vx=T3();var{useAtom:He,useSetAtom:Ix,useAtomValue:Tx,useStore:IK}=vx,Sx=vx.Provider,Et=I3();var S3=qb({"./locales/ar-SA.json":()=>import("./locales/ar-SA-E6E2KRZ5.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RDMGQYMZ.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-CHUVCTEA.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-ZMOEPIQW.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OHZAWF5C.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-K4A7PUP4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-RVP6YORC.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-ENJX4GIQ.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-VYBKDWRU.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-6MCXRRVA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-WEDZAIPA.js"),"./locales/en.json":()=>import("./locales/en-RNZ7CUK6.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-LLEALNRO.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-M4Y34NOW.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-XSMVGGRV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-K2D3DDUS.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-EQKMVJSO.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-RCPQTYJV.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RHAGKYKH.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-3UDCLKHN.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-T3REA7IL.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-KW4N25IN.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-LJVXK4LO.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-GGGK3KPX.js"),"./locales/kaa.json":()=>import("./locales/kaa-TSEHAWJR.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-IWXTEINV.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-6GNYSAU7.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-ILUXSOEW.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-FJWHM3OT.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-DRDDAECA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-IYFIPPJI.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-7F754RSS.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-BYRIZ3PC.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-RBYJSIJ6.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-EKTZIYSK.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-UECYYIUK.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-JPXGIDBA.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-4RSIVDPZ.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-GPHFXISR.js"),"./locales/percentages.json":()=>import("./locales/percentages-Q7USCRWZ.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-HKHPAEVK.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-UBWN6CKP.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-XDY4S4SD.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-2B3UXAQO.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-EW52HAV3.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-PIEHI4JX.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-TZXYYIFD.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-VUDQNDF3.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-IJTJRA7S.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-Q5PXZT3U.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HK66ZQXE.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-CLYYPVPL.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-YR4OMRYF.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-CY4LSY5Y.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-UDAEMEBG.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-EGBL23FT.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-ZOJEG32A.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-TM5HZP7M.js")});var P3=85,Xn={code:"en",label:"English"},Pi=[Xn,...[{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=>Jb[e.code]>=P3).sort((e,n)=>e.label>n.label?1:-1)],Ac="__test__";C3()&&Pi.unshift({code:Ac,label:"test language"},{code:`${Ac}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ci=Xn,Mc={},Dc=async e=>{if(Ci=e,document.documentElement.dir=Ci.rtl?"rtl":"ltr",document.documentElement.lang=Ci.code,e.code.startsWith(Ac))Mc={};else try{Mc=await S3(`./locales/${Ci.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Mc=hu}Et.set(Px,e.code)},Kn=()=>Ci,Cx=(e,n)=>{for(let t=0;t<n.length;++t){let o=n[t];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},f=(e,n,t)=>{if(Ci.code.startsWith(Ac))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=Cx(Mc,o)||Cx(hu,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(n)for(let i in n)r=r.replace(`{{${i}}}`,String(n[i]));return r},Px=Je(Xn.code),Le=()=>{let e=Tx(Px);return{t:f,langCode:e}};import k3 from"clsx";import Qe from"react";import{THEME as M3}from"@excalidraw/common";import{Fragment as Ie,jsx as h,jsxs as R}from"react/jsx-runtime";var Cn=e=>"var(--icon-fill-color)",kx=e=>e===M3.LIGHT?"#fff":"#1e1e1e",M=(e,n=512)=>{let{width:t=512,height:o=t,mirror:r,style:i,...a}=typeof n=="number"?{width:n}:n;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${o}`,className:k3({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},se={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},At={width:40,height:20},OK=M(R("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"})]}),H),zK=M(R("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"})]}),H),Mx=M("M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM288 248C288 234.7 277.3 224 264 224C250.7 224 240 234.7 240 248L240 392C240 405.3 250.7 416 264 416C277.3 416 288 405.3 288 392L288 248zM400 248C400 234.7 389.3 224 376 224C362.7 224 352 234.7 352 248L352 392C352 405.3 362.7 416 376 416C389.3 416 400 405.3 400 392L400 248z",640),bs=M(R("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"})]}),H),Ax=M(R("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"})]}),H),Dx=M(R("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"})]}),H),vu=M(R("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"})]}),H),fo=M(R("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"})})]}),se),Uo=M(R("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"})]}),se),Lx=M(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),_x=M(R(Ie,{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"}),Rx=M(R(Ie,{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"}),Nx=M(R(Ie,{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"}),GK=M(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),Lc=M(R("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}),ki=M(R("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}),Mi=M(R("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"})]}),H),Ai=M(R("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"})]}),H),Di=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),H),_c=M(R("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"})]}),H),Wo=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),se),Bx=M(R("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"})]}),H),$n=M(R("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"})]}),se),Pn=M(R("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"})]}),H),Fx=M(R("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"})]}),H),_r=M(R("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"})]}),se),Rc=M(R("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"})]}),H),Iu=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),se),Tu=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),se),Ox=M(R("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"})]}),H),Rr=M(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),se),Vo=M(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),se),xs=M(R("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"})]}),se),ys=M(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),se),ws=M(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...se,strokeWidth:1.5}),zx=M(R("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"})]}),H),vs=M(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),se),Li=M(R("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"})]}),H),Gx=M(R("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"})]}),H),HK=M(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),se),Hx=M(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),se),Ux=M(R("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"})]}),se),Wx=M(R("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"})]}),H),Nc=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Is=M(R("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"})]}),se),Vx=M("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),Yx=M("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Bc=M(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),se),UK=M("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),WK=M("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Su=["M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z","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","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"],Zn=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Su.map(e=>h("path",{d:e},e))]}),H),Xx=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),Kx=M(R("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"})]}),H),$x=M("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),VK=M("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),YK=M("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),Zx=M("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),XK=M("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Cu=M(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),se),Pu=M(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),se),jx=M("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),qx=M(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),se),KK=M("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),$K=M("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),ZK=M(R("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"})]}),H),jK=M(R(Ie,{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}),qK=M(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),Jx=R("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"})]}),Qx=R("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"})]}),ku=M(Qx,H),Mu=M(Qx,{...H,style:{transform:"rotate(180deg)"}}),Au=M(Jx,H),Du=M(Jx,{...H,style:{transform:"rotate(180deg)"}}),Lu=M(R(Ie,{children:[R("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"})})})]}),se),_u=M(R(Ie,{children:[R("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"})})})]}),se),Ru=M(R(Ie,{children:[R("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"})})})]}),se),Nu=M(R(Ie,{children:[R("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"})})})]}),se),e1=M(R(Ie,{children:[R("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"})})})]}),se),t1=M(R(Ie,{children:[R("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"})})})]}),se),Bu=M(R("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"})]}),se),Fu=M(R("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"})]}),se),Fc=M(R("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"})]}),H),JK=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),QK=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),rn=M(R(Ie,{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"})})})]}),se),e$=M("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),t$=M("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),n$=M("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Ou=Qe.memo(({theme:e})=>M(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:kx(e),stroke:Cn(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})),zu=Qe.memo(({theme:e})=>M(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:kx(e),stroke:Cn(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})),n1=M(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),se),o1=M(R(Ie,{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"})})]}),se),r1=M(R(Ie,{children:[R("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"})})})]}),se),i1=M(R(Ie,{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"})})})]}),{...se,fill:"currentColor"}),Gu=M(h(Ie,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),se),a1=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),se),s1=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),se),o$=Qe.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:Cn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),l1=M(R("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"})]}),H),c1=M(R("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"})]}),H),d1=M(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),se),m1=M(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),se),p1=M(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),se),Hu=M(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),Uu=M(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"2.75",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),u1=M(R("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"})]}),se),h1=M(R("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"})]}),H),g1=Qe.memo(({flip:e=!1})=>M(R("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[h("path",{d:"M7,11 H19"}),h("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),At)),f1=Qe.memo(({flip:e=!1})=>M(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),At)),E1=Qe.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),At)),b1=Qe.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[h("path",{d:"M7,11 H23"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),At)),x1=Qe.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),At)),y1=Qe.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M7,11 H25",strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),At)),w1=Qe.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),At)),v1=Qe.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[h("path",{d:"M7,11 H21"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),At)),I1=Qe.memo(({flip:e=!1})=>M(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:h("path",{d:"M11,11 H31 M31,5 V17"})}),At)),T1=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17"})}),At)),S1=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),At)),C1=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),At)),P1=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),At)),k1=Qe.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),h("circle",{cx:"15",cy:"11",r:"4"})]}),At)),M1=Qe.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),h("circle",{cx:"23",cy:"11",r:"4"})]}),At)),A1=M(R(Ie,{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"})})})]}),se),D1=M(R(Ie,{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"})})})]}),se),L1=M(R(Ie,{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"})})})]}),se),_1=M(h(Ie,{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"})}),se),Nr=M(R("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"})]}),H),R1=M(h(Ie,{children:R("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"})]})}),H),Ts=M(h(Ie,{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"})})}),se),A3=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 8l-4 4l4 4"}),h("path",{d:"M17 8l4 4l-4 4"}),h("path",{d:"M14 4l-4 16"})]}),H),Oc=A3,N1=M(R("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"})]}),H),B1=M(R("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"})]}),H),F1=M(R("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"})]}),H),O1=Qe.memo(({theme:e})=>M(R("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"})]}),H)),z1=Qe.memo(({theme:e})=>M(R("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"})]}),H)),G1=Qe.memo(({theme:e})=>M(R("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"})]}),H)),zc=M(R("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"})]}),H),r$=M(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),i$=M(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),H1=M(R("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"})]}),H),Wu=M(R(Ie,{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"})]}),H),U1=M(R(Ie,{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"})]}),H),W1=M(R("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"})]}),H),V1=M(R(Ie,{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"})]}),H),a$=M(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),s$=M(R(Ie,{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"})]}),H),Y1=M(R(Ie,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),H),X1=M(R(Ie,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),K1=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 6h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10a1 1 0 0 1 1 -1z"}),h("path",{d:"M7 6v12"}),h("path",{d:"M17 6v12"}),h("path",{d:"M3 10h4"}),h("path",{d:"M3 14h4"}),h("path",{d:"M17 10h4"}),h("path",{d:"M17 14h4"})]}),H),$1=M(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),Z1=M(R(Ie,{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"})]}),H),Vu=["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","M11 7l6 6"],_i=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Vu.map(e=>h("path",{d:e},e))]}),H),jn=M(R("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"})]}),H),l$=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),h("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),H),c$=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),h("path",{d:"M4 15l8 4l8 -4"}),h("path",{d:"M12 4v7"}),h("path",{d:"M15 8l-3 3l-3 -3"})]}),H),d$=M(R("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"})]}),se),Br=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0"}),h("path",{d:"M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7"})]}),H),qn=M(R("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),m$=M(R("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"})]}),H),p$=M(R("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"})]}),H),u$=M(R("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"})]}),H),h$=M(R("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"})]}),H),Fr=M(R("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"})]}),H),j1=M(R("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"})]}),H),g$=M(R("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"})]}),H),f$=M(R("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"})]}),H),Jn=M(R("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"})]}),H),E$=M(R("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"})]}),H),b$=M(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 8l0 4l2 2"}),h("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),H),q1=M(R("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"})]}),H),J1=M(R("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"})]}),H),x$=M(R("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"})]}),H),Q1=M(R("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"})]}),H),e0=M(R("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"})]}),H),t0=M(R("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"})]}),H),n0=M(R("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"})]}),H),Yu=M(R("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"})]}),H),Gc=M(R("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"})]}),H),o0=M(R("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"})]}),H),r0=M(R("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"})]}),H),Yo=M(R("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"})]}),H),y$=M(R("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"})]}),H),i0=M(R("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"})]}),{...H,strokeWidth:1.5}),w$=M(R("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"})]}),H),v$=M(R("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"})]}),H),a0=M(R("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"})]}),H),s0=M(R("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"})]}),H),Xo=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),H),Ko=M(R("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"})]}),H),$o=M(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Hc=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),l0=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),c0=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),Xu=M(R("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"})]}),H),d0=M(R("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"})]}),H),Ku=M(R("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),H),$u=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),h("polyline",{points:"2 8 3 6 4 8"}),h("polyline",{points:"2 12 3 14 4 12"}),h("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),h("polyline",{points:"9 17 7 18 9 19"}),h("polyline",{points:"15 17 17 18 15 19"})]}),H),I$=M(R("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"})]}),H),Zu=M(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),m0=M(R("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"})]}),H),p0=M(R("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"})]}),H),ju=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),h("path",{d:"M13.5 6.5l4 4"})]}),H),T$=M(R("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l-5 5l5 5"}),h("path",{d:"M17 7l-5 5l5 5"})]}),H),S$=M(R("g",{strokeWidth:"1.75",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),h("path",{d:"M15 4l0 16"})]}),H),C$=M(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),H),P$=M(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 4l18 0"}),h("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),h("path",{d:"M12 16l0 4"}),h("path",{d:"M9 20l6 0"}),h("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),H),Uc=h("div",{style:{width:"1rem",height:"1rem"}}),u0=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),H),h0=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),H),g0=M(R("g",{strokeWidth:1.25,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"})]}),H);import f0 from"clsx";import Ju,{useEffect as _3,useRef as E0,useState as R3}from"react";import{isPromiseLike as N3}from"@excalidraw/common";import D3 from"react";import{jsx as qu}from"react/jsx-runtime";var L3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(D3.useRef(Date.now()).current%1600);return qu("div",{className:`Spinner ${o}`,children:qu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:qu("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},Eo=L3;import{jsx as Ss,jsxs as Wc}from"react/jsx-runtime";var $=Ju.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=Ju.useRef(null);Ju.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=R3(!1),c=E0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(N3(u))try{l(!0),await u}catch(E){if(E instanceof wc)console.warn(E);else throw E}finally{c.current&&l(!1)}};_3(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=E0(null);return o.type==="button"||o.type==="icon"?Wc("button",{className:f0("ToolIcon_type_button",a,t,n&&!o.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!o.hidden,"ToolIcon--plain":o.type==="icon"}),style:o.style,"data-testid":o["data-testid"],hidden:o.hidden,title:o.title,"aria-label":o["aria-label"],type:"button",onClick:d,ref:i,disabled:s||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&Wc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&Ss("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&Ss(Eo,{})]}),o.showAriaLabel&&Wc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&Ss(Eo,{})]}),o.children]}):Ss("button",{className:f0("ToolIcon","ToolIcon_type_toggle",a,t,{"ToolIcon--checked":o.checked}),type:"button",style:o.style,title:o.title,"aria-label":o["aria-label"],"aria-keyshortcuts":o["aria-keyshortcuts"],"aria-pressed":o.checked,"data-testid":o["data-testid"],disabled:!!o.disabled,"aria-disabled":!!o.disabled,onPointerDown:p=>{m.current=p.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},onClick:()=>{o.onSelect?.({pointerType:m.current})},ref:i,children:Wc("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&Ss("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});$.displayName="IconButton";var Vc=[],O=e=>(Vc=Vc.concat(e),e);import{jsx as V3}from"react/jsx-runtime";var W3=(e,n,t)=>{let o=new Set(ce(e.filter(d=>G3(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=H3(e,d);for(let p of m)if(!a.has(p.id)){if(Yc(p)){let u=x0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let s=!0,l=e.map(d=>{if(n.selectedElementIds[d.id]){let m=Yc(d)?x0(d,i):null;return d.frameId&&o.has(d.frameId)?(s=!1,r[d.id]=!0,d):m?.frameId&&o.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&z3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),Kc(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,Yc(d)||(r[d.id]=!0),Kc(d,{frameId:null})):Yc(d)&&n.selectedElementIds[d.containerId]?Kc(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=eh(l,n.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=eh(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...U3({selectedElementIds:r,editingGroupId:c},$c(l),n,null)}}},y0=(e,n)=>{if(e.editingGroupId){let t=eh($c(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Cs=O({name:"deleteSelectedElements",label:"labels.delete",icon:Rr,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=n.selectedLinearElement,l=o.scene.getNonDeletedElementsMap(),c=b0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?Kc(p,{isDeleted:!0}):p),m=y0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:Xc.IMMEDIATELY}}return b0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Xc.IMMEDIATELY}}let{elements:r,appState:i}=W3(e,n,o);return O3(r,r.filter(a=>a.isDeleted)),i=y0(i,r),{elements:r,appState:{...i,activeTool:F3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:De($c(e),n)?Xc.IMMEDIATELY:Xc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===Qu.BACKSPACE||e.key===Qu.DELETE)&&!e[Qu.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return V3($,{type:"button",icon:Rr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!De($c(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?B3:{}}})}});import{KEYS as Ri,CODES as Ni,isDarwin as Zc}from"@excalidraw/common";import{moveOneLeft as Y3,moveOneRight as X3,moveAllLeft as K3,moveAllRight as $3}from"@excalidraw/element";import{CaptureUpdateAction as jc}from"@excalidraw/element";import{isDarwin as w0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,w0?f("keys.option"):f("keys.alt")).replace(/\bShift\b/i,f("keys.shift")).replace(/\b(Enter|Return)\b/i,f("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,w0?f("keys.cmd"):f("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,f("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,f("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,f("keys.delete"));import{jsx as qc}from"react/jsx-runtime";var th=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Mu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Y3(e,n,o.scene),appState:n,captureUpdate:jc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Ri.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ni.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>qc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Mu})}),nh=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:ku,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:X3(e,n,o.scene),appState:n,captureUpdate:jc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Ri.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ni.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>qc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:ku})}),oh=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Du,trackEvent:{category:"element"},perform:(e,n)=>({elements:K3(e,n),appState:n,captureUpdate:jc.IMMEDIATELY}),keyTest:e=>Zc?e[Ri.CTRL_OR_CMD]&&e.altKey&&e.code===Ni.BRACKET_LEFT:e[Ri.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ni.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>qc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Zc?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Du})}),rh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Au,trackEvent:{category:"element"},perform:(e,n)=>({elements:$3(e,n),appState:n,captureUpdate:jc.IMMEDIATELY}),keyTest:e=>Zc?e[Ri.CTRL_OR_CMD]&&e.altKey&&e.code===Ni.BRACKET_RIGHT:e[Ri.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ni.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>qc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Zc?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Au})});import{getNonDeletedElements as Z3}from"@excalidraw/element";import{LinearElementEditor as j3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as q3,isTextElement as J3}from"@excalidraw/element";import{arrayToMap as Q3,KEYS as v0}from"@excalidraw/common";import{selectGroupsForSelectedElements as eA}from"@excalidraw/element";import{CaptureUpdateAction as tA}from"@excalidraw/element";var ih=O({name:"selectAll",label:"labels.selectAll",icon:Q1,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(J3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...eA({editingGroupId:null,selectedElementIds:r},Z3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&q3(e[0])?new j3(e[0],Q3(e)):null},captureUpdate:tA.IMMEDIATELY}},keyTest:e=>e[v0.CTRL_OR_CMD]&&e.key===v0.A});import{DEFAULT_GRID_SIZE as I0,KEYS as T0,MOBILE_ACTION_BUTTON_BG as nA,arrayToMap as S0}from"@excalidraw/common";import{getNonDeletedElements as C0}from"@excalidraw/element";import{LinearElementEditor as oA}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as rA,getSelectionStateForElements as iA}from"@excalidraw/element";import{syncMovedIndices as aA}from"@excalidraw/element";import{duplicateElements as sA}from"@excalidraw/element";import{CaptureUpdateAction as P0}from"@excalidraw/element";import{jsx as lA}from"react/jsx-runtime";var ah=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:xs,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=oA.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:P0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=sA({type:"in-place",elements:e,idsOfElementsToDuplicate:S0(rA(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+I0/2,y:a.y+I0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:aA(i,S0(r)),appState:{...n,...iA(r,C0(i),n)},captureUpdate:P0.IMMEDIATELY}},keyTest:e=>e[T0.CTRL_OR_CMD]&&e.key===T0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return lA($,{type:"button",icon:xs,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!De(C0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?nA:{}}})}});import{pointFrom as H4}from"@excalidraw/math";import{useEffect as Ph,useMemo as Ah,useRef as kh,useState as U4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as W4,COLOR_PALETTE as V4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Ry,DEFAULT_ELEMENT_BACKGROUND_PICKS as Y4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as X4,DEFAULT_ELEMENT_STROKE_PICKS as K4,ARROW_TYPE as cn,DEFAULT_FONT_FAMILY as $4,DEFAULT_FONT_SIZE as Z4,FONT_FAMILY as j4,ROUNDNESS as bd,STROKE_WIDTH_KEYS as q4,VERTICAL_ALIGN as fd,KEYS as Yi,randomInteger as J4,arrayToMap as Dh,getFontFamilyString as Q4,getLineHeight as e6,isTransparent as t6,getStrokeWidthByKey as Ny,reduceToCommonValue as n6,invariant as yd,FONT_SIZES as Ed}from"@excalidraw/common";import{canBecomePolygon as o6,getNonDeletedElements as By,isNonDeletedElement as r6}from"@excalidraw/element";import{bindBindingElement as My,calculateFixedPointForElbowArrowBinding as Ay,updateBoundElements as i6}from"@excalidraw/element";import{LinearElementEditor as zr}from"@excalidraw/element/linearElementEditor";import{newElementWith as it}from"@excalidraw/element";import{getArrowheadForPicker as Dy}from"@excalidraw/element";import{getBoundTextElement as nr,redrawTextBoundingBox as zs}from"@excalidraw/element";import{isArrowElement as xd,isBoundToContainer as a6,isElbowArrow as Fy,isLinearElement as Mh,isLineElement as Ly,isTextElement as Gt,isUsingAdaptiveRadius as s6}from"@excalidraw/element";import{hasStrokeColor as l6}from"@excalidraw/element";import{updateElbowArrowPoints as c6,CaptureUpdateAction as et,toggleLinePolygonState as d6}from"@excalidraw/element";import{deriveStylesPanelMode as m6}from"@excalidraw/common";import{isDevEnv as cA}from"@excalidraw/common";var dA=new Set(["command_palette","export"]),Be=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!dA.has(e)||cA())return;S.PROD||console.info("trackEvent",{category:e,action:n,label:t,value:o}),window.sa_event&&window.sa_event(n,{category:e,label:t,value:o})}catch(r){console.error("error during analytics",r)}};import hA from"clsx";import mA from"clsx";import{forwardRef as pA}from"react";import{jsx as uA}from"react/jsx-runtime";var k0=pA((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return uA("button",{type:"button",ref:n,title:t,"data-testid":r,className:mA(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as fA,jsx as sh,jsxs as gA}from"react/jsx-runtime";var Zt=e=>sh(fA,{children:e.options.map(n=>e.type==="button"?sh(k0,{icon:n.icon,title:n.text,testId:n.testId,active:n.active??e.value===n.value,onClick:t=>e.onClick(n.value,t)},n.text):gA("label",{className:hA({active:e.value===n.value}),title:n.text,children:[sh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(n.value),checked:e.value===n.value,"data-testid":n.testId}),n.icon]},n.text))});import{Popover as sy}from"radix-ui";import ly from"clsx";import{memo as F5,useRef as cy,useEffect as O5}from"react";import{applyDarkModeFilter as z5,COLOR_OUTLINE_CONTRAST_THRESHOLD as iy,COLOR_PALETTE as dy,DEFAULT_ELEMENT_BACKGROUND_PICKS as G5,DEFAULT_ELEMENT_STROKE_PICKS as H5,isColorDark as ay,isWritableElement as U5,THEME as W5}from"@excalidraw/common";import{jsx as EA}from"react/jsx-runtime";var Jc=()=>EA("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as IA,useLayoutEffect as TA,useRef as SA}from"react";import{createPortal as CA}from"react-dom";import{EVENT as Zo,isColorDark as PA,KEYS as kA,MIME_TYPES as MA,THEME as AA,removeDarkModeFilter as DA,rgbToHex as LA}from"@excalidraw/common";import M0 from"react";var lh=M0.createContext(null),be=()=>M0.useContext(lh);import{useState as bA,useLayoutEffect as A0}from"react";import{THEME as xA}from"@excalidraw/common";var Qc=e=>{let[n,t]=bA(null),o=Ee(),{theme:r}=be(),{container:i}=Re();return A0(()=>{n&&(n.className="",n.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),n.classList.toggle("excalidraw--mobile",o.formFactor==="phone"),n.classList.toggle("theme--dark",r===xA.DARK))},[n,r,o.formFactor,e?.className]),A0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),t(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),n};import{useEffect as yA}from"react";import{EVENT as ed}from"@excalidraw/common";function Bi(e,n,t){yA(()=>{function o(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return n(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]")||n(i)}return document.addEventListener(ed.POINTER_DOWN,o),document.addEventListener(ed.TOUCH_START,o),()=>{document.removeEventListener(ed.POINTER_DOWN,o),document.removeEventListener(ed.TOUCH_START,o)}},[e,n,t])}import{useRef as wA}from"react";var Fi=e=>{let n=wA(e);return Object.assign(n.current,e),n.current};import{clamp as vA}from"@excalidraw/math";var D0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return vA(r,0,Math.max(0,t-n))},td=({cursor:e,element:n,container:t,gap:o})=>({left:D0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:D0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as RA}from"react/jsx-runtime";var L0=Vu.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),_A=`url(data:${MA.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${L0}</g><g stroke="#1b1b1f" stroke-width="1.25">${L0}</g></svg>`)}) 2 21, auto`,zt=Je(null),_0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=Qc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=be(),a=Oi(),s=St(),l=ce(a,i),c=Fi({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=Re();TA(()=>{if(r)return r.style.cursor=_A,()=>{r.style.cursor=""}},[r]),IA(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:A})=>{let D=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(A-i.offsetTop)*window.devicePixelRatio,1,1).data;return LA(D[0],D[1],D[2])},b=P=>i.theme===AA.DARK?DA(P):P,y=({clientX:P,clientY:A,altKey:D})=>{let{top:_,left:k}=td({cursor:{x:P,y:A},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let L=g({clientX:P,clientY:A});u&&c.onChange(o,b(L),c.selectedElements,{altKey:D}),p.style.background=L,p.style.setProperty("--eye-dropper-preview-border-color",PA(L)?"#fff":"#222")},w=()=>{c.onCancel()},x=(P,A)=>{c.onSelect(P,A)},I=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===kA.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),y({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(Zo.KEYDOWN,C),r.addEventListener(Zo.POINTER_DOWN,I),r.addEventListener(Zo.POINTER_UP,T),window.addEventListener("pointermove",y,{passive:!0}),window.addEventListener(Zo.BLUR,w),()=>{u=!1,r.removeEventListener(Zo.KEYDOWN,C),r.removeEventListener(Zo.POINTER_DOWN,I),r.removeEventListener(Zo.POINTER_UP,T),window.removeEventListener("pointermove",y),window.removeEventListener(Zo.BLUR,w)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=SA(null);return Bi(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?CA(RA("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as ch}from"radix-ui";import OA from"clsx";import zA from"react";import{isInteractive as GA}from"@excalidraw/common";import NA from"react";import BA from"clsx";import{jsx as FA}from"react/jsx-runtime";var Ue=NA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>FA("div",{className:BA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as dh,jsxs as HA}from"react/jsx-runtime";var bo=zA.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let m=Ee(),p=m.formFactor==="phone"&&!m.isLandscape;return dh(ch.Portal,{container:n,children:HA(ch.Content,{ref:d,className:OA("focus-visible-none",e),"data-prevent-outside-click":!0,side:p?"bottom":"right",align:p?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:n??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:m.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!GA(document.activeElement)&&n.focus(),r()},children:[dh(Ue,{padding:3,style:o,children:t}),dh(ch.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 UA,useCallback as mh}from"react";var nd=()=>document.querySelector(".excalidraw-wysiwyg"),od=()=>{let e=nd();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Ps=e=>{setTimeout(()=>{let n=nd();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},ks=(e,n,t,o)=>{n&&o&&o();let r=n&&t?od():null;e(),n&&t&&Ps(r)},R0=()=>{let[e,n]=UA(null),t=mh(()=>{let i=od();n(i)},[]),o=mh(()=>{setTimeout(()=>{let i=nd();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=mh(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},N0=(e=100)=>{let n=nd();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import F0 from"clsx";import{useCallback as YA,useEffect as uh,useRef as O0,useState as z0}from"react";import{KEYS as hh,normalizeInputColor as XA}from"@excalidraw/common";import{isTransparent as WA,MAX_CUSTOM_COLORS_USED_IN_CANVAS as VA}from"@excalidraw/common";var jo=({palette:e,color:n})=>{if(!n)return null;for(let[t,o]of Object.entries(e))if(Array.isArray(o)){let r=o.indexOf(n);if(r>-1)return{colorName:t,shade:r}}else if(o===n)return{colorName:t,shade:null};return null},Ms=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),ph=({color:e,palette:n})=>!Object.values(n).flat().includes(e),B0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!WA(s)&&ph({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[o[n]];i.has(s)?i.set(s,i.get(s)+1):i.set(s,1)}),[...i.entries()].sort((a,s)=>s[1]-a[1]).map(a=>a[0]).slice(0,VA)},an=Je(null);import{Fragment as KA,jsx as As,jsxs as gh}from"react/jsx-runtime";var G0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=Ee(),[a,s]=z0(e),[l,c]=z0(null),[d,m]=He(an);uh(()=>{s(e)},[e]);let p=YA(y=>{let w=y.toLowerCase().trim(),x=XA(w);x?(n(x),c(null)):w.length===0?c(null):/^#?[0-9a-f]+$/.test(w)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(w)},[n]),u=O0(null),E=O0(null);uh(()=>{u.current&&u.current.focus()},[d]);let[g,b]=He(zt);return uh(()=>()=>{b(null)},[b]),gh("div",{className:"color-picker__input-label-container",children:[gh("div",{className:F0("color-picker__input-label",{"has-error":l}),children:[As("div",{className:"color-picker__input-hash",children:"#"}),As("input",{ref:d==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!l,onChange:y=>{p(y.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:y=>{y.key!==hh.TAB&&(y.key===hh.ESCAPE&&E.current?.focus(),y.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&gh(KA,{children:[As("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),As("div",{ref:E,className:F0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(y=>y?null:{keepOpenOnAlt:!1,onSelect:w=>n(w),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${hh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:_i})]})]}),l&&As("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import bh,{useEffect as xh,useImperativeHandle as S5,useState as C5}from"react";import{EVENT as ey}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as P5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as k5,KEYS as M5}from"@excalidraw/common";import n5 from"clsx";import{useEffect as o5,useRef as r5}from"react";import{applyDarkModeFilter as i5,THEME as a5}from"@excalidraw/common";import{isColorDark as $A}from"@excalidraw/common";import{jsxs as jA}from"react/jsx-runtime";var ZA=({color:e,keyLabel:n,isShade:t=!1})=>jA("div",{className:"color-picker__button__hotkey-label",style:{color:$A(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),zi=ZA;import{createContext as qA,useContext as JA,useEffect as QA,useMemo as H0,useRef as U0,useState as e5}from"react";import{colorToHex as W0,isTransparent as t5}from"@excalidraw/common";var Or="excalidraw-color-dnd-ghost",V0="excalidraw-color-dnd-active",Y0=10,X0=100,K0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=W0(e);return t!==null&&t===W0(n)},fh=qA(null),sn=()=>JA(fh),$0=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=e5(null),i=U0(null),a=U0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=H0(()=>{let l=null,c=()=>{l?.activated?r({color:l.color,origin:l.origin,overIndex:l.overIndex,duplicateIndex:l.duplicateIndex,slotSpan:l.slotSpan}):r(null)},d=()=>{let k=i.current;if(!k||!l)return!1;let L=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((K,G)=>Number(K.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!L.length)return!1;l.slotRects=L.map(K=>K.getBoundingClientRect());let[B,V]=l.slotRects;l.slotSpan=V?V.left-B.left:B.width+4;let z=k.getBoundingClientRect(),U=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-U,right:z.right+U,top:z.top-14,bottom:z.bottom+14},!0},m=(k,L)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${L-l.ghostH/2}px)`)},p=(k,L,B,V)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==L)&&(l.ghostW=k,l.ghostH=L,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${L}px`,m(B,V))},u=(k,L)=>{if(!l)return;let{sourceRect:B,sourceEl:V,color:z}=l,U=document.createElement("div");U.className=Or;let K=document.createElement("div");if(K.className=`${Or}__swatch`,t5(z))K.classList.add("is-transparent");else{let G=getComputedStyle(V).backgroundColor;K.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(K),document.body.appendChild(U),l.ghost=U,l.ghostW=B.width,l.ghostH=B.height,U.style.width=`${B.width}px`,U.style.height=`${B.height}px`,m(k,L),requestAnimationFrame(()=>{l?.ghost===U&&U.classList.add(`${Or}--lifted`)}),document.body.classList.add(V0),l.activated=!0,c()},E=(k,L)=>{if(!l?.hitRect)return;let{hitRect:B,slotRects:V}=l,z=null,U=null;if(k>=B.left&&k<=B.right&&L>=B.top&&L<=B.bottom){let K=0,G=1/0;if(V.forEach((te,F)=>{let W=Math.abs(k-(te.left+te.width/2));W<G&&(G=W,K=F)}),l.origin.kind==="swatch"){let te=a.current.picks.findIndex(F=>K0(F,l.color));te!==-1?U=te:z=K}else z=K}if(z!==l.overIndex||U!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=U;let{ghost:K}=l;K&&(K.classList.toggle(`${Or}--over`,z!==null),K.classList.toggle(`${Or}--blocked`,U!==null)),c()}if(z!==null){let K=l.slotRects[z];p(K.width,K.height,k,L)}else p(l.sourceRect.width,l.sourceRect.height,k,L)},g=k=>{if(!l?.ghost)return;let{ghost:L}=l;l.ghost=null,L.classList.add(`${Or}--dropping`);let B=k.rect;B&&(L.style.width=`${B.width}px`,L.style.height=`${B.height}px`,L.style.transform=`translate(${B.left}px, ${B.top}px)`),window.setTimeout(()=>{L.classList.add(`${Or}--fade`)},160),window.setTimeout(()=>{L.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let L=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let B of L)B.style.transition="none",B.style.transform="none";k.offsetWidth;for(let B of L)B.style.transition=""},y=()=>{let k=L=>{L.preventDefault(),L.stopPropagation()};window.addEventListener("click",k,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",k,{capture:!0})},100)},w=()=>{window.removeEventListener("pointermove",C,!0),window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",A,!0),window.removeEventListener("keydown",D,!0)},x=()=>{w(),document.body.classList.remove(V0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},I=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,L)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,L),E(k,L)}},C=k=>{if(!(!l||k.pointerId!==l.pointerId)){if(l.lastX=k.clientX,l.lastY=k.clientY,!l.activated){if(Math.hypot(k.clientX-l.startX,k.clientY-l.startY)<Y0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let L=performance.now()-l.startTime;if(L<X0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=Y0&&T(l.lastX,l.lastY))},X0-L));return}if(T(k.clientX,k.clientY),!l?.activated)return}k.preventDefault(),m(k.clientX,k.clientY),E(k.clientX,k.clientY)}},P=k=>{if(!l||k.pointerId!==l.pointerId)return;if(!l.activated){x();return}k.preventDefault(),k.stopPropagation(),y();let{overIndex:L,origin:B,color:V,slotRects:z}=l,{picks:U,onPicksChange:K}=a.current;if(b(),L!==null){if(B.kind==="swatch"){if(!U.some(G=>K0(G,V))){let G=[...U];G[L]=V,K(G)}}else if(B.index!==L){let G=[...U],[te]=G.splice(B.index,1);G.splice(L,0,te),K(G)}g({rect:z[L]})}else g({rect:l.sourceRect});x()},A=k=>{l&&k.pointerId===l.pointerId&&I(!0)},D=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),I(!0))};return{begin:(k,L,B)=>{!a.current.enabled||l||k.button!==0||!L||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:L,origin:B,sourceEl:k.currentTarget,sourceRect:k.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener("pointermove",C,!0),window.addEventListener("pointerup",P,!0),window.addEventListener("pointercancel",A,!0),window.addEventListener("keydown",D,!0))},destroy:()=>I(!1)}},[]);return QA(()=>()=>s.destroy(),[s]),H0(()=>({dragState:o,startSwatchDrag:(l,c)=>s.begin(l,c,{kind:"swatch"}),startPickDrag:(l,c,d)=>s.begin(l,d,{kind:"pick",index:c}),setStripEl:l=>{i.current=l}}),[o,s])};import{jsx as Eh,jsxs as s5}from"react/jsx-runtime";var Z0=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=He(an),s=sn(),l=r5(null);return o5(()=>{l.current&&l.current.focus()},[t,i]),Eh("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=i5(c,e===a5.DARK);return s5("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:n5("color-picker__button color-picker__button--large has-outline",{active:t===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{o(c),a("custom")},onPointerDown:s?p=>s.startSwatchDrag(p,c):void 0,title:c,"aria-label":r,style:{"--swatch-color":m},children:[Eh("div",{className:"color-picker__button-outline"}),Eh(zi,{color:m,keyLabel:d+1})]},d)})})};import l5 from"clsx";import{useEffect as c5,useRef as d5}from"react";import{applyDarkModeFilter as m5,isColorDark as p5,THEME as u5}from"@excalidraw/common";import{jsx as rd,jsxs as g5}from"react/jsx-runtime";var h5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=jo({color:t,palette:n}),[l,c]=He(an),d=sn(),m=d5(null);return c5(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),rd("div",{className:"color-picker-content--default",children:Object.entries(n).map(([p,u],E)=>{let g=(Array.isArray(u)?u[r]:u)||"transparent";if(a?.includes(g))return rd("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Ms[E],y=m5(g,e===u5.DARK),w=f(`colors.${p.replace(/\d+/,"")}`,null,"");return g5("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:l5("color-picker__button color-picker__button--large",{"has-outline":!p5(g,255),active:s?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),c("baseColors")},onPointerDown:d?x=>d.startSwatchDrag(x,g):void 0,title:`${w}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${w} \u2014 ${b}`,style:g?{"--swatch-color":y}:void 0,"data-testid":`color-${p}`,children:[rd("div",{className:"color-picker__button-outline"}),i&&rd(zi,{color:y,keyLabel:b})]},p)})})},j0=h5;import{jsx as E5}from"react/jsx-runtime";var f5=({children:e})=>E5("div",{className:"color-picker__heading",children:e}),Gi=f5;import b5 from"clsx";import{useEffect as x5,useRef as y5}from"react";import{applyDarkModeFilter as w5,THEME as v5}from"@excalidraw/common";import{jsx as Ds,jsxs as q0}from"react/jsx-runtime";var J0=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=jo({color:n||"transparent",palette:o}),[a,s]=He(an),l=sn(),c=y5(null);if(x5(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return Ds("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=w5(u,e===v5.DARK);return q0("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:b5("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${d} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),s("shades")},onPointerDown:l?b=>l.startSwatchDrag(b,u):void 0,children:[Ds("div",{className:"color-picker__button-outline"}),r&&Ds(zi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return q0("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Ds("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Ds("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:f("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Hi,COLOR_PALETTE as I5,KEYS as Ls}from"@excalidraw/common";var id=(e,n,t)=>{let o=Math.ceil(t/Hi);switch(n=n??-1,e){case"ArrowLeft":{let r=n-1;return r<0?t-1:r}case"ArrowRight":return(n+1)%t;case"ArrowDown":{let r=n+Hi;return r>=t?n%Hi:r}case"ArrowUp":{let r=n-Hi,i=r<0?Hi*o+r:r;return i>=t?void 0:i}}},T5=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:s})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(o[n.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(Ms.includes(e.key)){let l=Ms.indexOf(e.key),c=Object.keys(o)[l],d=o[c],m=Array.isArray(d)?d[a]:d;return m==null||s?.includes(m)||(t(m),i("baseColors")),!0}return!1},Q0=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d,excludedColors:m})=>{if(e[Ls.CTRL_OR_CMD])return!1;if(e.key===Ls.ESCAPE)return d(e),!0;if(e.key===Ls.ALT)return c(!0),!0;if(e.key===Ls.I)return c(),!0;let p=jo({color:o,palette:t});if(e.key===Ls.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[I,T])=>(T&&x.push(I),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,y=g+b>E.length-1?0:g+b<0?E.length-1:g+b,w=E[y];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([I,T])=>Array.isArray(T)?T.includes(o):T===o?I:null)||r(I5.black)),e.preventDefault(),e.stopPropagation(),!0}if(T5({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l,excludedColors:m}))return!0;if(n==="shades"&&p){let{shade:u}=p,E=id(e.key,u,Hi);if(E!==void 0)return r(t[p.colorName][E]),!0}if(n==="baseColors"&&p){let{colorName:u}=p,E=Object.keys(t),g=E.indexOf(u),b=id(e.key,g,E.length),y=0;for(;b!==void 0&&y++<E.length;){let w=t[E[b]],x=Array.isArray(w)?w[l]:w;if(!m?.includes(x))break;b=id(e.key,b,E.length)}if(b!==void 0){let w=E[b],x=t[w];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=id(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as xo,jsxs as ad}from"react/jsx-runtime";var ty=bh.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:c,onEscape:d,showHotKey:m=!0,excludedColors:p},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=bh.useState(()=>o==="canvasBackground"?[]:B0(r,o,i)),[b,y]=He(an),w=sn(),x=jo({color:n,palette:i});xh(()=>{if(!b){let P=!!n&&ph({color:n,palette:i}),A=P&&!g.includes(n);y(A?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,y,x,g]);let[I,T]=C5(x?.shade??(o==="elementBackground"?P5:k5));xh(()=>{x?.shade!=null&&T(x.shade);let P=A=>{A.key===M5.ALT&&c(!1)};return document.addEventListener(ey.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(ey.KEYUP,P,{capture:!0})}},[x,c]);let C=bh.useRef(null);return S5(u,()=>C.current),xh(()=>{C?.current?.focus()},[]),xo("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:ad("div",{ref:C,onKeyDown:P=>{Q0({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:y,updateData:a,activeShade:I,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&xo("div",{className:"color-picker__title",children:E}),!!g.length&&ad("div",{children:[xo(Gi,{children:f("colorPicker.mostUsedCustomColors")}),xo(Z0,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),ad("div",{children:[xo(Gi,{children:f("colorPicker.colors")}),xo(j0,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),ad("div",{children:[xo(Gi,{children:f("colorPicker.shades")}),xo(J0,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,w&&xo("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import ny from"clsx";import{ContextMenu as _s}from"radix-ui";import{applyDarkModeFilter as A5,COLOR_OUTLINE_CONTRAST_THRESHOLD as D5,DEFAULT_CANVAS_BACKGROUND_PICKS as L5,DEFAULT_ELEMENT_BACKGROUND_PICKS as _5,DEFAULT_ELEMENT_STROKE_PICKS as R5,isColorDark as N5,THEME as B5}from"@excalidraw/common";import{jsx as qo,jsxs as oy}from"react/jsx-runtime";var ry=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=sn(),l=s?.dragState??null,{container:c}=Re(),d;if(t==="elementStroke"&&(d=R5),t==="elementBackground"&&(d=_5),t==="canvasBackground"&&(d=L5),r&&(d=r),!d)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!l||l.origin.kind!=="pick"||l.overIndex===null)return 0;let E=l.origin.index,g=l.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*l.slotSpan},p=oy("div",{className:ny("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&qo("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:qo("rect",{})}),d.map((u,E)=>{let g=m(E),b=A5(u,e===B5.DARK);return qo("button",{className:ny("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!N5(u,D5),"is-dnd-source":l?.origin.kind==="pick"&&l.origin.index===E,"is-dnd-target":l?.origin.kind==="swatch"&&l.overIndex===E,"is-dnd-duplicate":l?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:s?y=>s.startPickDrag(y,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:qo("div",{className:"color-picker__button-outline"})},u)})]});return i?oy(_s.Root,{children:[qo(_s.Trigger,{asChild:!0,children:p}),qo(_s.Portal,{container:c,children:qo(_s.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:qo(_s.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as ln,jsxs as sd}from"react/jsx-runtime";var V5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=dy,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=Re(),m=ct(),p=m!=="full",u=m==="mobile",[,E]=He(an),[g,b]=He(zt),y=sd("div",{children:[ln(Gi,{children:f("colorPicker.hexCode")}),ln(G0,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),w=cy(null),x=()=>{w.current?.focus()};return ln(bo,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}U5(I.target)||(I.target instanceof HTMLElement&&I.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),I.preventDefault()},onPointerDownOutside:I=>{g&&I.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let I=document.querySelector(".excalidraw-wysiwyg");I&&I.focus()},0)},children:i?ln(ty,{ref:w,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:I=>{let T=l.editingTextElement?od():null;t(I),l.editingTextElement&&T&&Ps(T)},onEyeDropperToggle:I=>{b(T=>I?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):I===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:I=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:y}):y})},Y5=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",X5=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=ct(),l=s!=="full",c=s==="mobile",d=sn(),m=n?z5(n,o===W5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&N0(),i()};return sd(sy.Trigger,{type:"button",className:ly("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!ay(n,iy),"compact-sizing":l,"mobile-border":c}),"aria-label":e,style:m?{"--swatch-color":m}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:p,onPointerDown:d?u=>d.startSwatchDrag(u,n):void 0,children:[ln("div",{className:"color-picker__button-outline",children:!n&&Xx}),l&&n&&r==="stroke"&&ln("div",{className:"color-picker__button-background",children:ln("span",{style:{color:m&&ay(m,iy)?"#fff":"#111"},children:p0})})]})},K5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=dy,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=cy(l.openPopup);O5(()=>{m.current=l.openPopup},[l.openPopup]);let u=ct()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?H5:G5),y=$0({enabled:E,picks:b,onPicksChange:w=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:w}})}});return ln(fh.Provider,{value:E?y:null,children:sd("div",{role:"dialog","aria-modal":"true",className:ly("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&ln(ry,{theme:l.theme,activeColor:n,onChange:w=>{t(w),Y5(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&d?()=>{s({colorTopPicks:{...l.colorTopPicks,[d]:null}})}:void 0}),!u&&ln(Jc,{}),sd(sy.Root,{open:l.openPopup===e,onOpenChange:w=>{w&&s({openPopup:e})},children:[ln(X5,{color:n,label:o,type:e,theme:l.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!l.editingTextElement,onToggle:()=>{l.openPopup===e?s({openPopup:null}):l.openPopup?s({openPopup:e}):s({openPopup:e})}}),l.openPopup===e&&ln(V5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},$5=(e,n)=>e.appState.openPopup===e.type||n.appState.openPopup===n.type?!1:e.type===n.type&&e.color===n.color&&e.label===n.label&&e.appState.openPopup===n.appState.openPopup&&e.palette===n.palette&&e.topPicks===n.topPicks&&e.excludedColors===n.excludedColors&&e.customizableTopPicks===n.customizableTopPicks&&e.appState.theme===n.appState.theme&&e.appState.colorTopPicks===n.appState.colorTopPicks&&!!e.appState.editingTextElement==!!n.appState.editingTextElement,Ui=F5(K5,$5);import{Popover as v4}from"radix-ui";import I4 from"clsx";import T4,{useCallback as S4,useMemo as C4}from"react";import{FONT_FAMILY as Ih}from"@excalidraw/common";import p4,{useMemo as er,useState as u4,useRef as hy,useEffect as gy,useCallback as fy}from"react";import{arrayToList as h4,debounce as g4,FONT_FAMILY as tr,getFontFamilyString as f4}from"@excalidraw/common";import Z5 from"clsx";import j5 from"react";import{jsx as q5,jsxs as J5}from"react/jsx-runtime";var ld=j5.forwardRef(({className:e,placeholder:n,onChange:t},o)=>J5("div",{className:Z5("QuickSearch__wrapper",e),children:[Jn,q5("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import Q5 from"clsx";import{Children as e4}from"react";import{jsx as my}from"react/jsx-runtime";var cd=({className:e,placeholder:n,children:t})=>{let o=!e4.count(t);return my("div",{className:Q5("ScrollableList__wrapper",e),role:"menu",children:o?my("div",{className:"empty",children:n}):t})};import{jsx as t4,jsxs as n4}from"react/jsx-runtime";var py=({children:e,className:n="",style:t,title:o})=>n4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&t4("p",{className:"dropdown-menu-group-title",children:o}),e]}),Rs=py;py.displayName="DropdownMenuGroup";import{THEME as d4}from"@excalidraw/common";import{DropdownMenu as m4}from"radix-ui";import o4,{useContext as r4}from"react";import{composeEventHandlers as i4}from"@excalidraw/common";var yh=o4.createContext({}),Jo=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),dd=e=>{let n=r4(yh);return i4(e,t=>{n.onSelect?.(t)})};import{jsx as a4}from"react/jsx-runtime";var Ns=({children:e,...n})=>a4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as l4,jsx as Bs,jsxs as c4}from"react/jsx-runtime";var s4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=Ee();return c4(l4,{children:[n&&Bs("div",{className:"dropdown-menu-item__icon",children:n}),Bs("div",{style:e,className:"dropdown-menu-item__text",children:Bs(Ns,{children:o})}),r&&Bs("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Bs("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Qo=s4;import{jsx as md}from"react/jsx-runtime";var wh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=dd(s);return md(m4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:md("button",{...l,value:t,className:Jo(i,a),title:l.title??l["aria-label"],children:md(Qo,{icon:e,shortcut:r,badge:n,children:o})})})};wh.displayName="DropdownMenuItem";var Wi={GREEN:"green",RED:"red",BLUE:"blue"},pd=({type:e=Wi.BLUE,children:n})=>{let{theme:t}=Qn(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===d4.LIGHT?"1.5px solid white":"none"};switch(e){case Wi.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Wi.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Wi.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return md("div",{className:"DropDownMenuItemBadge",style:o,children:n})};pd.displayName="DropdownMenuItemBadge";wh.Badge=pd;var jt=wh;import{KEYS as Vi}from"@excalidraw/common";var uy=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[Vi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Vi.F)return n.current?.focus(),!0;if(e.key===Vi.ESCAPE)return r(),!0;if(e.key===Vi.ENTER)return t?.value&&i(t.value),!0;if(e.key===Vi.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===Vi.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as yo,jsxs as x4}from"react/jsx-runtime";var E4=e=>{switch(e){case tr.Excalifont:case tr.Virgil:return $n;case tr.Nunito:case tr.Helvetica:return Ts;case tr["Lilita One"]:return R1;case tr["Comic Shanns"]:case tr.Cascadia:return Oc;default:return Ts}},b4=(e,n)=>Object.entries(tr).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",Ey=p4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Re(),l=St(),{fonts:c}=l,{showDeprecatedFonts:d}=kn(),m=ct(),[p,u]=u4(""),E=hy(null),g=er(()=>Array.from(go.registered.entries()).filter(([k,{metadata:L}])=>!L.private&&!L.fallback).map(([k,{metadata:L,fontFaces:B}])=>{let V={value:k,icon:E4(k),text:b4(k,B)};return L.deprecated&&Object.assign(V,{deprecated:L.deprecated,badge:{type:Wi.RED,placeholder:f("fontList.badge.old")}}),V}).sort((k,L)=>k.text.toLowerCase()>L.text.toLowerCase()?1:-1),[]),b=er(()=>new Set(c.getSceneFamilies()),[e]),y=er(()=>g.filter(k=>b.has(k.value)),[g,b]),w=er(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=er(()=>h4([...y,...w].filter(k=>k.text?.toLowerCase().includes(p))),[y,w,p]),I=er(()=>{let k;return n?k=x.find(L=>L.value===n):e&&(k=x.find(L=>L.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=fy(k=>{let L=null;if(l.state.editingTextElement){let B=document.querySelector(".excalidraw-wysiwyg");B&&(L={start:B.selectionStart,end:B.selectionEnd})}t(k),l.state.editingTextElement&&L&&setTimeout(()=>{let B=document.querySelector(".excalidraw-wysiwyg");B&&L&&(B.focus(),B.selectionStart=L.start,B.selectionEnd=L.end)},0)},[t,l.state.editingTextElement]),C=fy(k=>{uy({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,T,o,a]);gy(()=>(i(),()=>{a()}),[]);let P=er(()=>x.filter(k=>b.has(k.value)),[x,b]),A=er(()=>x.filter(k=>!b.has(k.value)),[x,b]),D=({font:k,order:L})=>{let B=hy(null),V=k.value===I?.value,z=k.value===e;return gy(()=>{V&&(L===0?B.current?.scrollIntoView?.({block:"end"}):B.current?.scrollIntoView?.({block:"nearest"}))},[V,L]),yo("button",{ref:B,type:"button",value:k.value,className:Jo("",z,V),title:k.text,tabIndex:z?0:-1,onClick:U=>{T(Number(U.currentTarget.value))},onMouseMove:()=>{I?.value!==k.value&&o(k.value)},children:yo(Qo,{icon:k.icon,badge:k.badge&&yo(pd,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:f4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(yo(Rs,{title:f("fontList.sceneFonts"),children:P.map((k,L)=>yo(D,{font:k,order:L},k.value))},"group_1")),A.length&&_.push(yo(Rs,{title:f("fontList.availableFonts"),children:A.map((k,L)=>yo(D,{font:k,order:L+P.length},k.value))},"group_2")),x4(bo,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[m==="full"&&yo(ld,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:g4(u,20)}),yo(cd,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,n)=>e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as y4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as w4}from"@excalidraw/common";import{jsx as vh}from"react/jsx-runtime";var by=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Fe(),r=t?{...w4,width:"2rem",height:"2rem"}:{};return vh(y4.Trigger,{asChild:!0,children:vh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:vh($,{type:"toggle",icon:Pn,title:f("labels.showFonts"),"aria-label":f("labels.showFonts"),className:"standalone properties-trigger","data-testid":"font-family-show-fonts",checked:n,onSelect:()=>{o(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as Fs,jsxs as xy}from"react/jsx-runtime";var yy=[{value:Ih.Excalifont,icon:$n,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Ih.Nunito,icon:Ts,text:f("labels.normal"),testId:"font-family-normal"},{value:Ih["Comic Shanns"],icon:Oc,text:f("labels.code"),testId:"font-family-code"}],ete=new Set(yy.map(e=>e.value));var wy=T4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=C4(()=>yy,[]),c=S4(d=>{d&&o(d)},[o]);return xy("div",{role:"dialog","aria-modal":"true",className:I4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&Fs("div",{className:"buttonList",children:Fs(Zt,{type:"button",options:l,value:n,onClick:c})}),!s&&Fs(Jc,{}),xy(v4.Root,{open:e,onOpenChange:a,children:[Fs(by,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&Fs(Ey,{selectedFontFamily:n,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,n)=>e.isOpened===n.isOpened&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as Th}from"radix-ui";import A4 from"clsx";import Sy,{useEffect as D4,useMemo as L4}from"react";import{isArrowKey as _4,KEYS as wo}from"@excalidraw/common";import{jsx as P4}from"react/jsx-runtime";var ud=({className:e,icon:n,size:t="1em"})=>P4("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:n});import{Fragment as M4,jsx as vy,jsxs as Iy}from"react/jsx-runtime";var k4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>Iy(M4,{children:[Iy("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&vy(ud,{icon:n?l0:Hc})]}),n&&vy("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Os=k4;import{jsx as eo,jsxs as gd}from"react/jsx-runtime";var R4=Je(!1),hd=4,N4="default",B4=e=>e.flatMap(n=>n.options),Ty=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},F4=(e,n)=>e.some(t=>t.options.some(n)),O4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/hd)},(t,o)=>n.options.slice(o*hd,o*hd+hd)));function z4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Re(),[s,l]=He(R4),c=[...e,...n],d=B4(c),m=O4([...e,...s?n:[]]),p=g=>{let b=d.find(y=>y.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===wo.TAB){let y=d.findIndex(x=>x.value===t),w=g.shiftKey?(d.length+y-1)%d.length:(y+1)%d.length;r(d[w].value)}else if(_4(g.key)){let y=Kn().rtl,w=d.findIndex(x=>x.value===t);if(w!==-1){let x=d.length,I=w;switch(g.key){case(y?wo.ARROW_LEFT:wo.ARROW_RIGHT):I=(w+1)%x;break;case(y?wo.ARROW_RIGHT:wo.ARROW_LEFT):I=(x+w-1)%x;break;case wo.ARROW_DOWN:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(T+1)%m.length],D=A[Math.min(P,A.length-1)]??d[w];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case wo.ARROW_UP:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(m.length+T-1)%m.length],D=A[Math.min(P,A.length-1)]??d[w];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[I].value)}g.preventDefault()}else(g.key===wo.ESCAPE||g.key===wo.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};D4(()=>{F4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>eo("div",{className:"picker-content",children:g.map(b=>gd("button",{type:"button",className:A4("picker-option",{active:t===b.value}),onClick:()=>{r(b.value)},title:b.keyBinding?`${b.text} \u2014 ${b.keyBinding.toUpperCase()}`:b.text,"aria-label":b.text||"none","aria-keyshortcuts":b.keyBinding||void 0,ref:y=>{t===b.value&&setTimeout(()=>{y?.focus()},0)},children:[b.icon,b.keyBinding&&eo("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,y)=>b.name===N4?eo(Sy.Fragment,{children:u(b.options)},`${b.name}-${y}`):gd("div",{className:"picker-section",children:[eo("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${y}`));return eo(Th.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:p,collisionBoundary:a??void 0,children:gd("div",{className:"picker-sections",children:[E(e),n.length>0&&eo(Os,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:eo("div",{className:"picker-sections",children:E(n)})})]})})}function Sh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=Sy.useState(!1),s=L4(()=>Ty(t,l=>l.value===e)??Ty(o??[],l=>l.value===e),[t,o,e]);return eo("div",{children:gd(Th.Root,{open:i,onOpenChange:l=>a(l),children:[eo(Th.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&eo(z4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import Cy,{useEffect as G4}from"react";import{jsx as Ch,jsxs as Py}from"react/jsx-runtime";var ky=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:s=!0,testId:l})=>{let c=Cy.useRef(null),d=Cy.useRef(null);return G4(()=>{if(c.current&&d.current){let m=c.current,p=d.current,u=m.offsetWidth,E=parseFloat(getComputedStyle(m).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;p.style.left=`${b}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,o,n]),Py("label",{className:"control-label",children:[e,Py("div",{className:"range-wrapper",children:[Ch("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":l}),Ch("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),Ch("div",{className:"zero-label",children:a})]})]})};import{Fragment as vd,jsx as Q,jsxs as bt}from"react/jsx-runtime";var Oy=.1,Gr=e=>{let n=m6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Ct=(e,n,t,o=!1)=>{let r=Dh(ce(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(r6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},mt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=By(e),s=null;if(i&&(s=t(i)),!s)if(De(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=n6(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},p6=(e,n,t)=>a6(n)||!n.autoResize?n:t.mutateElement(n,{x:e.textAlign==="left"?e.x:e.x+(e.width-n.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-n.height)/2}),Lh=(e,n,t,o,r)=>{let i=new Set,a=Ct(e,n,s=>{if(Gt(s)){let l=o(s);i.add(l);let c=it(s,{fontSize:l});return zs(c,t.scene.getContainerElement(s),t.scene),c=p6(s,c,t.scene),c}return s},!0);return ce(e,n,{includeBoundTextElement:!0}).forEach(s=>{Gt(s)&&i6(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:et.IMMEDIATELY}},u6=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Ct(e,n,o=>l6(o.type)?it(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?et.IMMEDIATELY:et.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Gr(o);return bt(vd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.stroke")}),Q(Ui,{topPicks:K4,palette:X4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:mt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),h6=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:et.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!t6(t.currentItemBackgroundColor)&&i.every(s=>Ly(s)&&o6(s.points))){let s=Dh(i);r=e.map(l=>s.has(l.id)&&Ly(l)?it(l,{backgroundColor:t.currentItemBackgroundColor,...d6(l,!0)}):l)}else r=Ct(e,n,s=>it(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Gr(o);return bt(vd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ui,{topPicks:Y4,palette:Ry,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:mt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),wd=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:et.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=Gr(o);return bt(vd,{children:[r==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ui,{topPicks:W4,palette:Ry,excludedColors:[V4.transparent],customizableTopPicks:"bucketFill",type:"elementBackground",label:f("labels.background"),color:o.bucketFill.getBucketFillBackgroundColor(n.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:n,updateData:t})]})}}),g6=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Be("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Ct(e,n,r=>it(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ce(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return bt("fieldset",{children:[Q("legend",{children:f("labels.fill")}),Q("div",{className:"buttonList",children:Q(Zt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?n1:o1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:r1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:i1,testId:"fill-solid"}],value:mt(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),f6=e=>q4.find(n=>Ny(e.type,n)===e.strokeWidth)??null,E6=(e,n)=>Ny(e.type,n),b6=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(yd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Ct(e,n,o=>it(o,{strokeWidth:E6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[Q("legend",{children:f("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Gu,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:a1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:s1,testId:"strokeWidth-bold"}],value:mt(e,o,f6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),x6=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>it(o,{seed:J4(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[Q("legend",{children:f("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:d1},{value:1,text:f("labels.artist"),icon:m1},{value:2,text:f("labels.cartoonist"),icon:p1}],value:mt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),y6=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Ct(e,n,r=>r.type!=="freedraw"?r:it(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=mt(e,o,a=>a.strokeOptions?.variability,a=>a.type==="freedraw",a=>a?null:n.currentItemStrokeVariability)??n.currentItemStrokeVariability;if(r?.cycle){let a=i==="variable";return Q($,{type:"button",icon:a?Uu:Hu,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return bt("fieldset",{children:[Q("legend",{children:f("labels.pressure")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:Hu},{value:"variable",text:f("labels.pressure_variable"),icon:Uu}],value:i,onChange:a=>t(a)})})]})}}),ane=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>it(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[Q("legend",{children:f("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Gu},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:l1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:c1}],value:mt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),w6=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>it(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=mt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return Q(ky,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),v6=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>Lh(e,n,o,()=>(yd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Gr(o);return bt("fieldset",{children:[Q("legend",{children:f("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"font-size",options:[{value:Ed.sm,text:f("labels.small"),icon:A1,testId:"fontSize-small"},{value:Ed.md,text:f("labels.medium"),icon:D1,testId:"fontSize-medium"},{value:Ed.lg,text:f("labels.large"),icon:L1,testId:"fontSize-large"},{value:Ed.xl,text:f("labels.veryLarge"),icon:_1,testId:"fontSize-veryLarge"}],value:mt(e,o,a=>{if(Gt(a))return a.fontSize;let s=nr(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Gt(a)||nr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||Z4),onChange:a=>{ks(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),_h=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Nr,trackEvent:!1,perform:(e,n,t,o)=>Lh(e,n,o,r=>Math.round(1/(1+Oy)*r.fontSize)),keyTest:e=>e[Yi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Yi.CHEVRON_LEFT||e.key===Yi.COMMA)}),Rh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Nr,trackEvent:!1,perform:(e,n,t,o)=>Lh(e,n,o,r=>Math.round(r.fontSize*(1+Oy))),keyTest:e=>e[Yi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Yi.CHEVRON_RIGHT||e.key===Yi.PERIOD)}),I6=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:Ct(e,n,g=>{let b=r?.get(g.id);return b?it(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:et.NEVER};yd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=et.EVENTUALLY,m,p=!1;if(l)m=l,d=et.IMMEDIATELY;else if(c){m=c,d=et.EVENTUALLY;let E=ce(e,n,{includeBoundTextElement:!0}).filter(g=>Gt(g));if(E.length>200)p=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let y=E[g];b+=y?.originalText.length||0,g++}b>5e3&&(p=!0)}}let u={appState:{...n,...s},captureUpdate:d};if(m&&!p){let E=new Map,g=new Set,b=!1,y=Array.from(go.loadedFontsCache.values()),w=Object.entries(j4).find(([T,C])=>C===m)?.[0];c&&w&&y.some(T=>T.startsWith(w))&&(b=!0),Object.assign(u,{elements:Ct(e,n,T=>{if(Gt(T)&&(T.fontFamily!==m||l)){let C=it(T,{fontFamily:m,lineHeight:e6(m)}),P=r?.get(T.containerId||"")||{},A=o.scene.getContainerElement(T);return a&&A&&P&&o.scene.mutateElement(A,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,A),C}return T},!0)});let x=`10px ${Q4({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,C]of E)zs(T,C,o.scene);else window.document.fonts.load(x,I).then(T=>{for(let[C,P]of E){let A=o.scene.getElement(C.id),D=P?o.scene.getElement(P.id):null;A&&zs(A,D,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=kh(new Map),i=kh(null),[a,s]=U4({}),l=kh(!0),{stylesPanelMode:c,isCompact:d}=Gr(t),m=Ah(()=>{let p=(u,E)=>mt(u,t,g=>{if(Gt(g))return g.fontFamily;let b=nr(g,E);return b?b.fontFamily:null},g=>Gt(g)||nr(g,E)!==null,g=>g?null:n.currentItemFontFamily||$4);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?p(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return Ph(()=>{i.current=m},[m]),Ph(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),Ph(()=>(l.current=!1,()=>{l.current=!0}),[]),bt(vd,{children:[c==="full"&&Q("legend",{children:f("labels.fontFamily")}),Q(wy,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{ks(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),r.current.clear()},d,!!n.editingTextElement)},onHover:p=>{s({currentHoveredFontFamily:p,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:p=>{if(p){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,it(E||u,{},!0))}else{let E=ce(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,it(g,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&n.editingTextElement&&Ps(null)}}})]})}}),T6=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Gt(r)){let i=it(r,{textAlign:t});return zs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=Gr(o);return bt("fieldset",{children:[Q("legend",{children:f("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:N1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:B1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:F1,testId:"align-right"}],value:mt(e,o,s=>{if(Gt(s))return s.textAlign;let l=nr(s,i);return l?l.textAlign:null},s=>Gt(s)||nr(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{ks(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),S6=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Gt(r)){let i=it(r,{verticalAlign:t});return zs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Gr(o);return Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Zt,{group:"text-align",options:[{value:fd.TOP,text:f("labels.alignTop"),icon:Q(O1,{theme:n.theme}),testId:"align-top"},{value:fd.MIDDLE,text:f("labels.centerVertically"),icon:Q(G1,{theme:n.theme}),testId:"align-middle"},{value:fd.BOTTOM,text:f("labels.alignBottom"),icon:Q(z1,{theme:n.theme}),testId:"align-bottom"}],value:mt(e,o,a=>{if(Gt(a)&&a.containerId)return a.verticalAlign;let s=nr(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Gt(a)||nr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:fd.MIDDLE),onChange:a=>{ks(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),sne=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>Fy(o)?o:it(o,{roundness:t==="round"?{type:s6(o.type)?bd.ADAPTIVE_RADIUS:bd.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=vi(By(e),n).some(s=>s.roundness?.type===bd.LEGACY);return bt("fieldset",{children:[Q("legend",{children:f("labels.edges")}),bt("div",{className:"buttonList",children:[Q(Zt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:u1},{value:"round",text:f("labels.round"),icon:h1}],value:mt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!xd(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),_y=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Q(g1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(f1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:Q(E1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:Q(b1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:Q(x1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(y1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:Q(w1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:Q(v1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:Q(I1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:Q(T1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:Q(S1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:Q(C1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:Q(P1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:Q(k1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:Q(M1,{flip:e}),keyBinding:null}]}]}),lne=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(yd(t,"actionChangeArrowhead: value must be defined"),{elements:Ct(e,n,o=>{if(Mh(o)){let{position:r,type:i}=t;if(r==="start")return it(o,{startArrowhead:i});if(r==="end")return it(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Kn().rtl,i=Ah(()=>_y(!r),[r]),a=Ah(()=>_y(!!r),[r]);return bt("fieldset",{children:[Q("legend",{children:f("labels.arrowheads")}),bt("div",{className:"iconSelectList buttonList",children:[Q(Sh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:mt(e,o,s=>Mh(s)&&ms(s.type)?Dy(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),Q(Sh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:mt(e,o,s=>Mh(s)&&ms(s.type)?Dy(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),C6=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,n,t,o)=>!1,PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>bt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),cne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Ct(e,n,s=>{if(!xd(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=zr.getPointAtIndexGlobalCoordinates(s,0,l),d=zr.getPointAtIndexGlobalCoordinates(s,-1,l),m=it(s,{x:t===cn.elbow?c[0]:s.x,y:t===cn.elbow?c[1]:s.y,roundness:t===cn.round?{type:bd.PROPORTIONAL_RADIUS}:null,elbowed:t===cn.elbow,angle:t===cn.elbow?0:s.angle,points:t===cn.elbow||s.elbowed?[zr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),zr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Fy(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=zr.getPointAtIndexGlobalCoordinates(m,0,p),E=zr.getPointAtIndexGlobalCoordinates(m,-1,p),g=m.startBinding&&p.get(m.startBinding.elementId),b=m.endBinding&&p.get(m.endBinding.elementId),y=g&&m.startBinding?{...m.startBinding,...Ay(m,g,"start",p,n.isBindingEnabled)}:null,w=b&&m.endBinding?{...m.endBinding,...Ay(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:y,endBinding:w,...c6(m,p,{points:[u,E].map(x=>H4(x[0]-m.x,x[1]-m.y)),startBinding:y,endBinding:w,fixedSegments:null})}}else{let p=o.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&My(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&My(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new zr(s,Dh(e)))}return{elements:r,appState:i,captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>bt("fieldset",{children:[Q("legend",{children:f("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"arrowtypes",options:[{value:cn.sharp,text:f("labels.arrowtype_sharp"),icon:Xo,testId:"sharp-arrow"},{value:cn.round,text:f("labels.arrowtype_round"),icon:$o,testId:"round-arrow"},{value:cn.elbow,text:f("labels.arrowtype_elbowed"),icon:Ko,testId:"elbow-arrow"}],value:mt(e,o,r=>xd(r)?r.elbowed?cn.elbow:r.roundness?cn.round:cn.sharp:null,r=>xd(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as _6,MAX_ZOOM as R6,MIN_ZOOM as N6,THEME as Gs,ZOOM_STEP as Hy,CODES as Hr,KEYS as Td}from"@excalidraw/common";import{getNonDeletedElements as Hs}from"@excalidraw/element";import{getCommonBounds as Us}from"@excalidraw/element";import{CaptureUpdateAction as $i}from"@excalidraw/element";import{useEffect as P6}from"react";import{jsx as M6}from"react/jsx-runtime";var Xi=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let n=document.createElement("div");return document.body.appendChild(n),n.classList.add("excalidraw-tooltip"),n},Nh=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=n.left+n.width/2-o.width/2;s<0?s=a:s+o.width>=r&&(s=r-o.width-a);let l;t==="bottom"?(l=n.top+n.height+a,l+o.height>=i&&(l=n.top-o.height-a)):(l=n.top-o.height-a,l<0&&(l=n.top+n.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},k6=(e,n,t,o)=>{n.classList.add("excalidraw-tooltip--visible"),n.style.minWidth=o?"50ch":"10ch",n.style.maxWidth=o?"50ch":"15ch",n.textContent=t;let r=e.getBoundingClientRect();Nh(n,r)},pt=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(P6(()=>()=>Xi().classList.remove("excalidraw-tooltip--visible"),[]),r?null:M6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>k6(i.currentTarget,Xi(),n,t),onPointerLeave:()=>Xi().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as zy,useRef as Gy,useState as A6}from"react";var D6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Bh=(e,n,t)=>{if(e?.isDestroyed)return;let o=e?.getAppState();if(!o){if(!t)return;console.warn("useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?"),o=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},Ho())}return D6(o,n)};function Ki(e,n=!0){let t=Id(),[,o]=A6(0),r=Gy(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Bh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Bh(t,e,n)),zy(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(s=>s+1)})},[t]),r.current.latestValue}function L6(e,n){let t=Id(),o=Gy({selector:e,callback:n});o.current.selector=e,o.current.callback=n,zy(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Bh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Md,jsxs as O6}from"react/jsx-runtime";var B6=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!n.viewModeEnabled,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:t?.viewBackgroundColor?$i.IMMEDIATELY:$i.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Md(Ui,{palette:null,topPicks:_6,label:f("labels.canvasBackground"),type:"canvasBackground",color:n.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:n,updateData:t})}),Sd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:Iu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...ho({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value+Hy)},n)},captureUpdate:$i.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ki(t=>t.zoom.value);return Md($,{type:"button",className:"zoom-in-button zoom-button",icon:Iu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=R6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Hr.EQUAL||e.code===Hr.NUM_ADD)&&(e[Td.CTRL_OR_CMD]||e.shiftKey)}),Cd=O({name:"zoomOut",label:"buttons.zoomOut",icon:Tu,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...ho({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value-Hy)},n)},captureUpdate:$i.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ki(t=>t.zoom.value);return Md($,{type:"button",className:"zoom-out-button zoom-button",icon:Tu,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=N6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Hr.MINUS||e.code===Hr.NUM_SUBTRACT)&&(e[Td.CTRL_OR_CMD]||e.shiftKey)}),Pd=O({name:"resetZoom",label:"buttons.resetZoom",icon:Ox,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?.lockZoom?n.scrollConstraints.zoom:1;return{appState:{...n,...ho({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(r)},n)},captureUpdate:$i.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=Ki(t=>t.zoom.value);return Md(pt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:O6($,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(n*100).toFixed(0),"%"]})})},keyTest:e=>(e.code===Hr.ZERO||e.code===Hr.NUM_ZERO)&&(e[Td.CTRL_OR_CMD]||e.shiftKey)}),Fh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],Gne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Gc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?Us(Hs(r)):n.scrollConstraints?Fh(n.scrollConstraints):Us(Hs(e)),a=Mr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),Hne=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Gc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?Us(Hs(r)):n.scrollConstraints?Fh(n.scrollConstraints):Us(Hs(e)),a=Mr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),F6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Gc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?Fh(n.scrollConstraints):Us(Hs(e)),i=Mr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Vn(i.appState)}}},keyTest:void 0}),kd=O({name:"toggleTheme",label:(e,n)=>n.theme===Gs.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Gs.LIGHT?ys:ws,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Gs.LIGHT?Gs.DARK:Gs.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:$i.EVENTUALLY}},keyTest:e=>!e[Td.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Hr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as K6}from"@excalidraw/math";import{bindOrUnbindBindingElement as Jy}from"@excalidraw/element/binding";import{isValidPolygon as Qy,newElementWith as Gh}from"@excalidraw/element";import{LinearElementEditor as Ks}from"@excalidraw/element/linearElementEditor";import{isBindingElement as Hh,isFreeDrawElement as ew,isLinearElement as tw,isLineElement as Bd}from"@excalidraw/element";import{KEYS as Fd,arrayToMap as $6,invariant as nw,shouldRotateWithDiscreteAngle as Z6,updateActiveTool as ow}from"@excalidraw/common";import{isPathALoop as j6}from"@excalidraw/element";import{isInvisiblySmallElement as Uh}from"@excalidraw/element";import{CaptureUpdateAction as Wh}from"@excalidraw/element";import U6 from"clsx";import{useEffect as W6,useState as V6}from"react";import{KEYS as dn,capitalizeString as Ur}from"@excalidraw/common";import{useEffect as z6,useState as G6}from"react";import Uy from"clsx";import{capitalizeString as Ad}from"@excalidraw/common";import{Popover as Oh}from"radix-ui";import{jsx as Dd,jsxs as H6}from"react/jsx-runtime";var Zi=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=G6(!1),c=t.type,d=a.type===c,m=16,{container:p}=Re();return!n.some(u=>u.type===c)&&s&&l(!1),z6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),H6(Oh.Root,{open:s,children:[Dd(Oh.Trigger,{asChild:!0,children:Dd($,{className:Uy({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>qe(e,u.type)),title:Ad(a.title),"aria-label":Ad(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Dd(Oh.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Dd($,{className:Uy({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:qe(e,u),title:Ad(u),"aria-label":Ad(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Be("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as zh}from"react/jsx-runtime";var Y6=e=>e,Ye=Y6({hand:{icon:H1,letterKey:dn.H,toggle:!0},selection:{icon:Lc,letterKey:dn.V,fillable:!0},rectangle:{icon:Mi,letterKey:dn.R,fillable:!0},diamond:{icon:Ai,letterKey:dn.D,fillable:!0},ellipse:{icon:Di,letterKey:dn.O,fillable:!0},arrow:{icon:_c,letterKey:dn.A,fillable:!0},line:{icon:Wo,letterKey:dn.L,fillable:!0},freedraw:{icon:$n,letterKey:dn.P},text:{icon:Pn,letterKey:dn.T},image:{icon:_r},eraser:{icon:Rc,letterKey:dn.E,toggle:!0},frame:{icon:jn,letterKey:dn.F},autoshape:{icon:Br,letterKey:dn.X,fillable:!1},embeddable:{icon:Vo},laser:{icon:qn},bucketfill:{icon:Zn},lasso:{icon:ki,fillable:!1}});var ji=["autoshape","rectangle","diamond","ellipse","arrow","line"],qi=Object.keys(Ye).filter(e=>Ye[e].toggle),Ld=e=>{let{letterKey:n,shiftKey:t}=Ye[e];if(!n)return n;let o=Ur(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},Ji=e=>Ld(e),X6=e=>{let n=Ld(e);return n?.length===1?n:void 0},Wy=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(Ye)){let{letterKey:i,shiftKey:a}=Ye[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},qe=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Ht=(e,n)=>{let t=Ye[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Ur(f(`toolBar.${e}`)),d=l?null:Ji(o);return zh($,{className:U6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:qe(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:X6(o),"aria-label":c,"aria-keyshortcuts":d??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:m})=>{if(!i.state.penDetected&&m==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:m});return}i.state.activeTool.type!==e&&(Be("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Ur(e)}IconButton`,r},_d=Ht("hand"),Vy=Ht("rectangle"),Yy=Ht("diamond"),Xy=Ht("ellipse"),Ky=Ht("arrow"),$y=Ht("line"),Ws=Ht("freedraw"),Vs=Ht("text"),Ys=Ht("image"),Xs=Ht("eraser"),Zy=Ht("frame"),goe=Ht("autoshape"),jy=Ht("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Be("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),qy=Ht("lasso",{shortcutType:"selection"}),Rd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:Ye.selection.icon,fillable:Ye.selection.fillable,title:Ur(f("toolBar.selection"))},{type:"lasso",icon:Ye.lasso.icon,fillable:Ye.lasso.fillable,title:Ur(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return zh(Zi,{app:e,options:o,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",onToolChange:i=>{(i==="selection"||i==="lasso")&&(e.setActiveTool({type:i}),t({preferredSelectionTool:{type:i,initialized:!0}}))},displayedOption:r})},Nd=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:Ye.freedraw.icon,fillable:Ye.freedraw.fillable,title:Ur(f("toolBar.freedraw"))},{type:"autoshape",icon:Ye.autoshape.icon,fillable:Ye.autoshape.fillable,title:Ur(f("toolBar.autoshape"))}],[o,r]=V6(n.type==="autoshape"?"autoshape":"freedraw");W6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return zh(Zi,{app:e,options:t,activeTool:n,defaultOption:o,"data-testid":"toolbar-freedraw",onToolChange:a=>{(a==="freedraw"||a==="autoshape")&&(r(a),e.setActiveTool({type:a}))},displayedOption:i})};import{jsx as q6}from"react/jsx-runtime";var ut=O({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:s}=o,l=s.getNonDeletedElementsMap(),c=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:y}=t,w=Ks.getElement(n.selectedLinearElement.elementId,l);nw(w,"Arrow element should exist if selectedLinearElement is set"),nw(y,"sceneCoords should be defined if actionFinalize is called with event");let x=Ks.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(Hh(w)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[w.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=Z6(b),P=b[Fd.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),A=T.reduce((D,_)=>(D.set(_,{point:C?w.points[_]:Ks.createPointAt(w,l,y.x-x.pointerOffset.x,y.y-x.pointerOffset.y,P)}),D),new Map)??new Map;Jy(w,A,y.x,y.y,s,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Bd(w)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!Qy(w.points)&&s.mutateElement(w,{polygon:!1});if(x!==n.selectedLinearElement){w&&Uh(w)&&(i=i.map(T=>T.id===w.id?Gh(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:w.points.length<2||Uh(w)?e.map(T=>T.id===w.id?Gh(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:I||c?null:{...x,selectedPointsIndices:null,isEditing:!1,initialState:{...x.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:Wh.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let d=o.drawShape.hasPendingGesture();(d||c)&&(o.drawShape.finalize(),d&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!c&&!d&&(n.newElement?.type==="freedraw"||Hh(n.newElement)))m=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=l.get(Object.keys(n.selectedElementIds)[0]);b&&(m=b)}if(m){if(n.selectedLinearElement&&n.multiElement&&m.type!=="freedraw"&&n.lastPointerDownWith!=="touch"){let{points:b}=m,{lastCommittedPoint:y}=n.selectedLinearElement;if((!y||b[b.length-1]!==y)&&(r=!1,s.mutateElement(m,{points:m.points.slice(0,-1)}),Hh(m)&&m.endBinding&&m.points.length>1)){let w=!!n.newElement,x=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),I=Ks.getPointAtIndexGlobalCoordinates(m,-1,l);Jy(m,x,I[0],I[1],s,n,{newArrow:w})}}if(m&&Uh(m)&&(i=i.map(b=>b.id===m?.id?Gh(b,{isDeleted:!0}):b)),tw(m)||ew(m)){if(j6(m.points,n.zoom.value)&&(Bd(m)||ew(m))){let y=m.points,w=y[0],x=y.map((I,T)=>T===y.length-1?K6(w[0],w[1]):I);Bd(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Bd(m)&&!Qy(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;qi.includes(n.activeTool.type)?p=ow(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=ow(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!m;E||o.cursor.applyForTool(p);let g=m&&tw(m)?new Ks(m,$6(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:c?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?Wh.IMMEDIATELY:Wh.NEVER}},keyTest:(e,n)=>e.key===Fd.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Fd.ESCAPE||e.key===Fd.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>q6($,{type:"button",icon:Zx,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:n,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as aw,isSomeElementSelected as J6,makeNextSelectedElementIds as Q6,selectGroupsForSelectedElements as eD}from"@excalidraw/element";import{CaptureUpdateAction as rw}from"@excalidraw/element";import{KEYS as tD,isWritableElement as nD,updateActiveTool as iw}from"@excalidraw/common";var oD=(e,n)=>qi.includes(e.activeTool.type)?iw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):iw(e,{type:n.state.preferredSelectionTool.type}),rD=(e,n,t)=>{if(!e.editingGroupId)return null;let o=n.scene.getNonDeletedElements(),r=n.scene.getSelectedElements({selectedElementIds:t,elements:o}),i=r.length?r:aw(o,e.editingGroupId);for(let a of i){let s=a.groupIds.indexOf(e.editingGroupId);if(s!==-1&&a.groupIds[s+1])return a.groupIds[s+1]}return null},iD=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=oD(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:aw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...eD({editingGroupId:rD(n,o,a),selectedElementIds:a},i,n,o),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:rw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:Q6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:rw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==tD.ESCAPE||nD(e.target)?!1:!n.newElement&&n.multiElement===null&&!n.selectedLinearElement?.isEditing&&(n.activeEmbeddable!==null||n.activeTool.type!==o.state.preferredSelectionTool.type||!!n.editingGroupId||!!n.selectedLinearElement||J6(o.scene.getNonDeletedElements(),n))});import{KEYS as Xd,THEME as qs}from"@excalidraw/common";import{CaptureUpdateAction as Mn}from"@excalidraw/element";import aD from"clsx";import{jsx as sw,jsxs as sD}from"react/jsx-runtime";var Vh=({children:e,checked:n,onChange:t,className:o})=>sD("div",{className:aD("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[sw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Nc}),sw("div",{className:"Checkbox-label",children:e})]});import{THEME as $s}from"@excalidraw/common";import{jsx as Zs}from"react/jsx-runtime";var cw=e=>{let n=e.title||(e.value===$s.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return Zs($,{type:"icon",icon:e.value===$s.LIGHT?lw.MOON:lw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===$s.DARK?$s.LIGHT:$s.DARK),"data-testid":"toggle-dark-mode"})},lw={SUN:Zs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Zs("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:Zs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Zs("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 lD}from"react";import{focusNearestParent as cD,KEYS as dD}from"@excalidraw/common";import{jsx as dw,jsxs as mD}from"react/jsx-runtime";var mw=e=>{let{id:n}=Re(),[t,o]=lD(e.value),r=a=>{e.ignoreFocus||cD(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===dD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return mD("div",{className:"ProjectName",children:[dw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),dw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as pD,useEffect as uD,useRef as hD}from"react";import{jsx as Od,jsxs as bD}from"react/jsx-runtime";var gD=5e3,fD=({progress:e})=>Od("div",{className:"Toast__progress-bar",children:Od("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),ED=({message:e,onClose:n,closable:t=!1,duration:o=gD,style:r})=>{let i=hD(0),a=o!==1/0,s=pD(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return uD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),bD("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Od("div",{className:"Toast__message",children:e}),t&&Od($,{icon:rn,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},zd=Object.assign(ED,{ProgressBar:fD});import{DEFAULT_EXPORT_PADDING as BD,DEFAULT_FILENAME as FD,IMAGE_MIME_TYPES as Ew,isFirefox as OD,MIME_TYPES as zD,cloneJSON as GD,SVG_DOCUMENT_PREAMBLE as HD,arrayToMap as UD}from"@excalidraw/common";import{getNonDeletedElements as WD}from"@excalidraw/element";import{isFrameLikeElement as VD}from"@excalidraw/element";import{getElementsOverlappingFrame as YD}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as xD,EXPORT_DATA_TYPES as js,MIME_TYPES as ht,arrayToMap as yD,isMemberOf as wD,isPromiseLike as vD,EVENT as Gd}from"@excalidraw/common";import{mutateElement as ID}from"@excalidraw/element";import{deepCopyElement as TD}from"@excalidraw/element";import{isFrameLikeElement as SD,isInitializedImageElement as CD}from"@excalidraw/element";import{getContainingFrame as pw}from"@excalidraw/element";var _re="clipboard"in navigator&&"readText"in navigator.clipboard,Hd="clipboard"in navigator&&"writeText"in navigator.clipboard,or="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,PD=e=>!!([js.excalidraw,js.excalidrawClipboard,js.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),uw=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Gd.PASTE,{clipboardData:new DataTransfer});if(e)for(let[o,r]of Object.entries(e)){if(typeof r!="string"){n=n||[],n.push(r);continue}try{if(t.clipboardData?.items.add(r,o),t.clipboardData?.getData(o)!==r)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(n){let o=-1;for(let r of n){o++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[o]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},kD=({elements:e,files:n})=>{let t=yD(e),o=new Set(e.filter(s=>SD(s))),r=!1,i=e.reduce((s,l)=>(CD(l)&&(r=!0,n&&n[l.fileId]&&(s[l.fileId]=n[l.fileId])),s),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:js.excalidrawClipboard,elements:e.map(s=>{if(pw(s,t)&&!o.has(pw(s,t))){let l=TD(s);return ID(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},Ud=async(e,n,t)=>{let o=kD({elements:e,files:n});await vo({[ht.excalidrawClipboard]:o,[ht.text]:o},t)};function hw(e){let n=[];for(let t of e.childNodes)if(t.nodeType===3){let o=t.textContent?.trim();o&&n.push({type:"text",value:o})}else if(t instanceof HTMLImageElement){let o=t.getAttribute("src");o&&o.startsWith("http")&&n.push({type:"imageUrl",value:o})}else n=n.concat(hw(t));return n}var MD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,ht.html),o=hw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},gw=async()=>{let e={},n;try{n=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let o=await navigator.clipboard?.readText();if(o)return{[ht.text]:o}}}catch(o){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);else{if(o.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${o.message}`),e;throw o}}throw t}for(let t of n)for(let o of t.types)if(wD(xD,o))try{if(o===ht.text||o===ht.html)e[o]=await(await t.getType(o)).text();else if(hx(o)){let r=await t.getType(o),i=wx(r,o,void 0);e[o]=i}else throw new bu(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof bu?r.message:`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},AD=async(e,n=!1)=>{try{let t=e.findByType(ht.html),o=!n&&t&&MD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(ht.text)??o.value.map(r=>r.value).join(`
|
|
2
|
+
`).trim()}:o:{type:"text",value:(e.getData(ht.text)||"").trim()}}catch{return{type:"text",value:""}}},DD=function(e){return this.find(n=>n.type===e)||null},LD=function(e){return this.find(t=>t.type===e)?.value??null},_D=function(){return this.filter(e=>e.kind==="file")},Yh=e=>{let n=Xh(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),ht.text,ht.html,"text/uri-list","public.url","public.plain-text","text/x-moz-url"])),r={};for(let i of o)try{let a=n?.getData(i);a&&(r[i]=a)}catch{}return{items:Array.from(n?.items??[]).map(i=>({kind:i.kind,type:i.type})),files:Array.from(n?.files??[]).map(i=>({name:i.name,type:i.type,size:i.size,lastModified:i.lastModified})),types:t,data:r}},RD=e=>e.map(n=>n.kind==="string"?{kind:n.kind,type:n.type,value:n.value}:{kind:n.kind,type:n.type,file:{name:n.file.name,type:n.file.type,size:n.file.size,lastModified:n.file.lastModified}}),Wd=(e,n,t)=>{let o=[],r=[],i=[],a=(u,E)=>{let g=E?.trim();g&&!u.includes(g)&&u.push(g)},s=(u,E)=>{E.split(/\r?\n/).map(g=>g.trim()).filter(g=>g&&!g.startsWith("#")).forEach(g=>a(u,g))};e.forEach(u=>{if(u.kind==="string")if(u.type===ht.html)try{let E=new DOMParser().parseFromString(u.value,ht.html);for(let g of Array.from(E.body.querySelectorAll("img")))a(o,g.getAttribute("src")),a(i,g.getAttribute("alt"))}catch{}else u.type===ht.text?a(r,u.value):u.type==="text/uri-list"&&s(r,u.value)});let l=[...o,...r.filter(u=>!o.includes(u))],c=Array.from({length:n},()=>({})),d={...t??{items:[],files:[],types:[],data:{}},parsedItems:RD(e)};c.forEach((u,E)=>{let g=l[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=d});let m=l.slice(c.length),p=c[0];return p&&m.length>0&&m.forEach((u,E)=>{p[`additionalUrl${E+1}`]=u}),c},fw=e=>{let n;Xh(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=new Set;for(let o of Array.from(n||[]))t.has(o.type)||t.add(o.type);return t},Wr=async e=>{let n;Xh(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=(await Promise.all(Array.from(n||[]).map(async o=>{if(o.kind==="file"){let r=o.getAsFile();if(r){let i=await yx(o);return r=await Lr(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(o.kind==="string"){let{type:r}=o,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{o.getAsString(s=>a(s))}),{type:r,kind:"string",value:i}}return null}))).filter(o=>o!=null);return Object.assign(t,{findByType:DD,getData:LD,getFiles:_D})},Vd=async(e,n=!1)=>{let t=await AD(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===js.excalidrawClipboardWithAPI;if(PD(o))return{elements:o.elements,files:o.files,text:n?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},Yd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[ht.png]:e})])}catch(n){if(vD(e))await navigator.clipboard.write([new ClipboardItem({[ht.png]:await e})]);else throw n}},vo=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[ht.text]:e}:e);try{if(n){for(let[r,i]of t)if(n.clipboardData?.setData(r,i),n.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let o=t.find(([r])=>r===ht.text);if(Hd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!ND(o[1]))throw new Error("Error copying to clipboard.")},ND=e=>{e||(e=" ");let n=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[n?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${o}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},Xh=e=>e.type===Gd.PASTE||e.type===Gd.COPY||e.type===Gd.CUT;var Vr=(e,{selectedElementIds:n},t)=>{let o=WD(e),r=UD(o),i=t&&De(o,{selectedElementIds:n}),a=null,s=i?ce(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&VD(l)?(a=l,s=YD(o,l,r)):s.length>1&&(s=ce(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:GD(s)}},Yr=async(e,n,t,o,{exportBackground:r,exportPadding:i=BD,viewBackgroundColor:a,name:s=t.name||FD,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Ar(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return xu(m.then(p=>new Blob([HD+p.outerHTML],{type:zD.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Ew.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await vo(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=Cc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Es(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-6PNCNKLO.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:us(n,t,o,"local")})))),xu(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Ew.png],fileHandle:l})}else if(e==="clipboard")try{let m=Es(d);await Yd(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):OD&&m.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
|
|
3
3
|
|
|
4
|
-
${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var iy=async(e,n,t)=>{let o=ox(n);if(!rx(o))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:a}=await e,{exportBackground:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=Or(r,i,!1);return await Fr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as SL,jsx as qo,jsxs as cy}from"react/jsx-runtime";var Uh=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>qo(Jw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),ay=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:vn.EVENTUALLY})}),Wh=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>qo(Fh,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),Gd=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>cy(Fh,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),qo(dt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:qo("div",{className:"excalidraw-tooltip-icon",children:Hx})})]})}),Gi=!1,Gh=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?cy(SL,{children:[t,qo(_d.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function TL(e,n){if(n.app.state.isLoading&&(Gh(n.app,{progress:null}),await n.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(n.signal.aborted){e.return();return}if(t.type==="progress")Gh(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Gh(n.app,{progress:null}),await e)}function sy(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await TL(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,signal:i})}catch(l){l?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",l)}s({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var zr=F({name:"saveToActiveFile",label:"buttons.save",icon:hs,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(Gi)return!1;Gi=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=sy(e,n,o.files,o);try{let{fileHandle:l}=yc(r)?await iy(s,r,i):await fc({data:s,filename:i,fileHandle:r});return{captureUpdate:vn.NEVER,appState:{fileHandle:l,toast:{message:r&&l?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${l.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(l){return a.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:vn.NEVER,appState:{toast:null}}}finally{Gi=!1}},keyTest:e=>!1}),Vs=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:hs,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(Gi)return!1;Gi=!0;let{abortController:r,data:i}=sy(e,n,o.files,o);try{let{fileHandle:a}=await fc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:vn.NEVER,appState:{openDialog:null,fileHandle:a,toast:{message:f("toast.fileSaved"),duration:3e3}}}}catch(a){return r.abort(),a?.name!=="AbortError"?console.error(a):console.warn(a),{captureUpdate:vn.NEVER,appState:{toast:null}}}finally{Gi=!1}},keyTest:e=>e.key.toLowerCase()===Hd.S&&e.shiftKey&&e[Hd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>qo(K,{type:"button",icon:Nx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:ge().formFactor==="phone",hidden:!mi,onClick:()=>e(null),"data-testid":"save-as-button"})}),Ui=F({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{try{let{elements:r,appState:i,files:a}=await hu(n,e);return{elements:r,appState:i,files:a,captureUpdate:vn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:vn.EVENTUALLY}}},keyTest:e=>e[Hd.CTRL_OR_CMD]&&e.key===Hd.O}),ly=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?Ws.DARK:Ws.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>qo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:qo(jw,{value:e.exportWithDarkMode?Ws.DARK:Ws.LIGHT,onChange:t=>{n(t===Ws.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as CL,DEFAULT_FONT_FAMILY as PL,DEFAULT_TEXT_ALIGN as kL,getLineHeight as ML}from"@excalidraw/common";import{newElementWith as Ud}from"@excalidraw/element";import{hasBoundTextElement as AL,canApplyRoundnessTypeToElement as LL,getDefaultRoundnessTypeForElement as DL,isFrameLikeElement as _L,isArrowElement as RL,isExcalidrawElement as NL,isTextElement as dy}from"@excalidraw/element";import{getBoundTextElement as BL,redrawTextBoundingBox as OL}from"@excalidraw/element";import{CaptureUpdateAction as Vh}from"@excalidraw/element";var my="{}",FL=F({name:"copyStyles",label:"labels.copyStyles",icon:zu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&AL(i)){let a=BL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(my=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:Vh.EVENTUALLY}}}),zL=F({name:"pasteStyles",label:"labels.pasteStyles",icon:zu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(my),i=r[0],a=r[1];if(!NL(i))return{elements:e,captureUpdate:Vh.EVENTUALLY};let s=se(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(dy(c)&&c.containerId&&(d=a),!d)return c;let m=Ud(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?LL(d.roundness.type,c)?d.roundness:DL(c):null});if(dy(m)){let p=d.fontSize||CL,u=d.fontFamily||PL,E=Ud(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||kL,lineHeight:d.lineHeight||ML(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),OL(E,g,o.scene)}return m.type==="arrow"&&RL(d)&&(m=Ud(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),_L(c)&&(m=Ud(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:Vh.IMMEDIATELY}}});import{KEYS as HL}from"@excalidraw/common";import{CaptureUpdateAction as GL}from"@excalidraw/element";var Hr=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Ax,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,n,t,{focusContainer:o})=>(n.openDialog?.name==="help"&&o(),{appState:{...n,openDialog:n.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:GL.EVENTUALLY}),keyTest:e=>e.key===HL.QUESTION_MARK});import{getNonDeletedElements as Vd}from"@excalidraw/element";import{newElementWith as uy}from"@excalidraw/element";import{isBoundToContainer as UL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as WL,getElementsInResizingFrame as VL,getFrameLikeElements as YL,getRootElements as XL,groupByFrameLikes as KL,removeElementsFromFrame as ZL,replaceAllElementsInFrame as $L}from"@excalidraw/element";import{KEYS as Yd,randomId as jL,arrayToMap as Xh}from"@excalidraw/common";import{getSelectedGroupIds as Wd,selectGroup as qL,selectGroupsForSelectedElements as JL,getElementsInGroup as py,addToGroup as QL,removeFromSelectedGroups as eD,isElementInGroup as hy}from"@excalidraw/element";import{syncMovedIndices as tD}from"@excalidraw/element";import{CaptureUpdateAction as Ys}from"@excalidraw/element";import{jsx as Wi}from"react/jsx-runtime";var nD=(e,n)=>{if(e.length>=2){let t=n?e[0].groupIds.indexOf(n):-1,o=t>-1?e[0].groupIds.slice(0,t):e[0].groupIds;for(let r of o)if(e.every(i=>hy(i,r)))return!0}return!1},Yh=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!nD(t,e.editingGroupId)&&!WL(t)},Kh=F({name:"group",label:"labels.group",icon:e=>Wi(Du,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!Yh(n,o))return!1;let r=XL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:Ys.EVENTUALLY};let i=Wd(n);if(i.length===1){let b=i[0],y=new Set(py(e,b).map(v=>v.id)),w=new Set(r.map(v=>v.id));if(new Set([...Array.from(y),...Array.from(w)]).size===y.size)return{appState:n,elements:e,captureUpdate:Ys.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&KL(r).forEach((y,w)=>{ZL(y,o.scene.getNonDeletedElementsMap())});let l=jL(),c=Xh(r);a=a.map(b=>c.get(b.id)?uy(b,{groupIds:QL(b.groupIds,l,n.editingGroupId)}):b);let d=py(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!hy(b,l)),g=tD([...E,...d,...u],Xh(d));return{appState:{...n,...qL(l,{...n,selectedGroupIds:{}},Vd(a))},elements:g,captureUpdate:Ys.IMMEDIATELY}},predicate:(e,n,t,o)=>Yh(n,o),keyTest:e=>!e.shiftKey&&e[Yd.CTRL_OR_CMD]&&e.key===Yd.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Wi(K,{hidden:!Yh(n,o),type:"button",icon:Wi(Du,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Me(Vd(e),n)})}),Zh=F({name:"ungroup",label:"labels.ungroup",icon:e=>Wi(_u,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=Wd(n),i=Xh(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:Ys.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{UL(p)&&s.push(p.id);let u=eD(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:uy(p,{groupIds:u})});let l=JL(n,Vd(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return YL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=$L(a,VL(a,p,n,i),p))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,E])=>(E&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...n,...l},elements:a,captureUpdate:Ys.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Yd.CTRL_OR_CMD]&&e.key===Yd.G.toUpperCase(),predicate:(e,n)=>Wd(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>Wi(K,{type:"button",hidden:Wd(n).length===0,icon:Wi(_u,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Me(Vd(e),n)})});import cD from"clsx";import{CaptureUpdateAction as xy}from"@excalidraw/element";import{invariant as dD}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as oD,COLOR_VOICE_CALL as rD,COLOR_WHITE as Kd,THEME as iD,UserIdleState as gy}from"@excalidraw/common";var Xd=(e,n,t,o,r,i,a)=>{e.beginPath(),e.moveTo(n+i,t),e.lineTo(n+o-i,t),e.quadraticCurveTo(n+o,t,n+o,t+i),e.lineTo(n+o,t+r-i),e.quadraticCurveTo(n+o,t+r,n+o-i,t+r),e.lineTo(n+i,t+r),e.quadraticCurveTo(n,t+r,n,t+r-i),e.lineTo(n,t+i),e.quadraticCurveTo(n,t,n+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function aD(e){let n=0;if(e.length===0)return n;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);n=(n<<5)-n+o}return n}var Gr=(e,n)=>`hsl(${Math.abs(aD(n?.id||e))%37*10}, 100%, 83%)`,fy=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},Ey=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:s,y:l}=a,c=t.collaborators.get(i);s-=t.offsetLeft,l-=t.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>r-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,r-m);let u=Gr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===gy.IDLE||E===gy.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===iD.DARK?"#2f6330":rD,y=c?.isSpeaking;y&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Kd,e.strokeStyle=Kd,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(s-1,l-1),e.lineTo(s-1,l+15),e.lineTo(s+5,l+10),e.lineTo(s+12,l+9),e.closePath(),e.fill()):(e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.fill(),e.stroke());let w=n.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let x=(y?s+0:s)+d/2,v=(y?l+0:l)+m+2,T=5,C=3,P=e.measureText(w),A=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,L=Math.max(A,12),_=x-1,k=v-1,D=P.width+2+T*2+2,O=L+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,D,O,8),e.fillStyle=u,e.fill(),e.strokeStyle=Kd,e.stroke(),y&&(e.beginPath(),e.roundRect(_-2,k-2,D+4,O+4,8),e.strokeStyle=b,e.stroke())):Xd(e,_,k,D,O,8,Kd),e.fillStyle=oD,e.fillText(w,x+T+1,v+C+P.actualBoundingBoxAscent+Math.floor((L-A)/2)+2),y){e.fillStyle=b;let Y=8,z=8,W=5;e.fillRect(_+D+z,k+(O/2-Y/2),2,Y),e.fillRect(_+D+z+W,k+(O/2-Y*2/2),2,Y*2),e.fillRect(_+D+z+W*2,k+(O/2-Y/2),2,Y)}}e.restore(),e.closePath()}};import sD from"clsx";import{useState as lD}from"react";import{jsx as by}from"react/jsx-runtime";var $h=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=fy(t),[a,s]=lD(!1),l=!a&&o,c=l?void 0:{background:e};return by("div",{className:sD("Avatar",r),style:c,onClick:n,children:l?by("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as Kn,jsxs as Zd}from"react/jsx-runtime";var mD=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(dD(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.props.userToFollow?.socketId===t.socketId||t.isCurrentUser?(o.requestUnfollow(),{appState:n,captureUpdate:xy.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:xy.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=Gr(o,r),l=cD({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),c=r.isInCall?r.isSpeaking?Zd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[Kn("div",{}),Kn("div",{}),Kn("div",{})]}):r.isMuted?Kn("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:z1}):Kn("div",{title:f("userList.hint.inCall"),children:F1}):null;return i?Zd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[Kn($h,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),Kn("div",{className:"UserList__collaborator-name",children:r.username}),Zd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Kn("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Ar}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):Zd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[Kn($h,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&Kn("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as Vi}from"@excalidraw/element";import{isFrameLikeElement as pD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as uD}from"@excalidraw/element";import{KEYS as Jo,arrayToMap as hD}from"@excalidraw/common";import{alignElements as gD}from"@excalidraw/element";import{CaptureUpdateAction as Yi}from"@excalidraw/element";import{getSelectedElementsByGroup as fD}from"@excalidraw/element";import{jsx as Ki}from"react/jsx-runtime";var st=(e,n)=>{let t=n.scene.getSelectedElements(e);return fD(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>pD(o))},Xi=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=gD(r,o,t.scene,n),a=hD(i);return uD(e.map(s=>a.get(s.id)||s),n,t)},ED=F({name:"alignTop",label:"labels.alignTop",icon:Cu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"start",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Jo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Jo.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!st(n,o),type:"button",icon:Cu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Me(Vi(e),n)})}),bD=F({name:"alignBottom",label:"labels.alignBottom",icon:Pu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"end",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Jo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Jo.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!st(n,o),type:"button",icon:Pu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Me(Vi(e),n)})}),xD=F({name:"alignLeft",label:"labels.alignLeft",icon:ku,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"start",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Jo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Jo.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!st(n,o),type:"button",icon:ku,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Me(Vi(e),n)})}),wD=F({name:"alignRight",label:"labels.alignRight",icon:Mu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"end",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Jo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Jo.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!st(n,o),type:"button",icon:Mu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Me(Vi(e),n)})}),yD=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Au,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"center",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!st(n,o),type:"button",icon:Au,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Me(Vi(e),n)})}),vD=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Lu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"center",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!st(n,o),type:"button",icon:Lu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Me(Vi(e),n)})});import{getNonDeletedElements as wy}from"@excalidraw/element";import{isFrameLikeElement as ID}from"@excalidraw/element";import{CODES as yy,KEYS as vy,arrayToMap as TD}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as SD}from"@excalidraw/element";import{distributeElements as CD}from"@excalidraw/element";import{CaptureUpdateAction as Iy}from"@excalidraw/element";import{getSelectedElementsByGroup as PD}from"@excalidraw/element";import{jsx as Cy}from"react/jsx-runtime";var Ty=(e,n)=>{let t=n.scene.getSelectedElements(e);return PD(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>ID(o))},Sy=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=CD(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=TD(i);return SD(e.map(s=>a.get(s.id)||s),n,t)},kD=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Sy(e,n,o,{space:"between",axis:"x"}),captureUpdate:Iy.IMMEDIATELY}),keyTest:e=>!e[vy.CTRL_OR_CMD]&&e.altKey&&e.code===yy.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Cy(K,{hidden:!Ty(n,o),type:"button",icon:Vx,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Me(wy(e),n)})}),MD=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Sy(e,n,o,{space:"between",axis:"y"}),captureUpdate:Iy.IMMEDIATELY}),keyTest:e=>!e[vy.CTRL_OR_CMD]&&e.altKey&&e.code===yy.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Cy(K,{hidden:!Ty(n,o),type:"button",icon:Yx,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Me(wy(e),n)})});import{arrayToMap as Py,KEYS as LD,matchKey as DD}from"@excalidraw/common";import{CaptureUpdateAction as _D}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as RD}from"@excalidraw/element/frame";import{arrangeElements as ND}from"@excalidraw/element/arrange";var AD={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},Zi=(e,n)=>({smartZoom:{...AD,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as FD}from"react/jsx-runtime";var BD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Py(e),{arrange:i}=Zi(n,t.props.editorPreferences),a=ND(t.scene,o,r,i.algorithm,i.gap),s=Py(a);return RD(e.map(l=>s.get(l.id)||l),n,t)},OD=st,jh=F({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Gu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>OD(n,o),perform:(e,n,t,o)=>({appState:n,elements:BD(e,n,o),captureUpdate:_D.IMMEDIATELY}),keyTest:e=>e.shiftKey&&DD(e,LD.R),PanelComponent:({updateData:e})=>FD("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:Gu})});import{arrayToMap as ky}from"@excalidraw/common";import{CaptureUpdateAction as zD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as HD}from"@excalidraw/element/frame";import{normaliseElements as GD}from"@excalidraw/element/normalise";import{jsx as VD}from"react/jsx-runtime";var UD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=ky(e),{normalise:i}=Zi(n,t.props.editorPreferences),a=GD(t.scene,o,r,i.mode,i.metric),s=ky(a);return HD(e.map(l=>s.get(l.id)||l),n,t)},WD=st,qh=F({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:Uu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>WD(n,o),perform:(e,n,t,o)=>({appState:n,elements:UD(e,n,o),captureUpdate:zD.IMMEDIATELY}),PanelComponent:({updateData:e})=>VD("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:Uu})});import{getNonDeletedElements as YD}from"@excalidraw/element";import{bindOrUnbindBindingElements as XD}from"@excalidraw/element";import{getCommonBoundingBox as My}from"@excalidraw/element";import{newElementWith as KD}from"@excalidraw/element";import{deepCopyElement as ZD}from"@excalidraw/element";import{resizeMultipleElements as $D}from"@excalidraw/element";import{isArrowElement as Ay,isElbowArrow as jD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Ly}from"@excalidraw/element";import{CODES as Dy,KEYS as qD,arrayToMap as JD}from"@excalidraw/common";import{CaptureUpdateAction as _y}from"@excalidraw/element";var Jh=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:W1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ly(Ry(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:_y.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Dy.H}),Qh=F({name:"flipVertical",label:"labels.flipVertical",icon:U1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ly(Ry(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:_y.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Dy.V&&!e[qD.CTRL_OR_CMD]}),Ry=(e,n,t,o,r)=>{let i=se(YD(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=QD(i,n,o,r),s=JD(a);return e.map(l=>s.get(l.id)||l)},QD=(e,n,t,o)=>{if(e.every(p=>Ay(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return KD(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=My(e);$D(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,ZD(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),XD(e.filter(Ay),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>jD(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=My(e),[d,m]=[r-l,i-c];return s.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),e};import{isTextElement as e_}from"@excalidraw/element";import{getTextFromElements as t_}from"@excalidraw/element";import{CODES as n_,KEYS as Ny,isFirefox as o_}from"@excalidraw/common";import{CaptureUpdateAction as Xt}from"@excalidraw/element";var $i=F({name:"copy",label:"labels.copy",icon:ms,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Bd(r,o.files,t)}catch(i){return{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Xt.EVENTUALLY}},keyTest:void 0}),eg=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await ny()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),o_?{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(ey({types:r}))}catch(i){return console.error(i),{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Xt.EVENTUALLY}},keyTest:void 0}),$d=F({name:"cut",label:"labels.cut",icon:_1,trackEvent:{category:"element"},perform:(e,n,t,o)=>($i.perform(e,n,t,o),bs.perform(e,n,null,o)),keyTest:e=>e[Ny.CTRL_OR_CMD]&&e.key===Ny.X}),r_=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:V1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Xt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Or(e,n,!0);try{await Fr("clipboard-svg",r,n,o.files,{...n,exportingFrame:i,name:o.getName()});let a=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Xt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Xt.EVENTUALLY}}},predicate:e=>Nd&&e.length>0,keywords:["svg","clipboard","copy"]}),i_=F({name:"copyAsPng",label:"labels.copyAsPng",icon:Y1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Xt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Or(e,n,!0);try{return await Fr("clipboard",i,n,o.files,{...n,exportingFrame:a,name:o.getName()}),{appState:{...n,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Xt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Xt.EVENTUALLY}}},predicate:e=>jo&&e.length>0,keyTest:e=>e.code===n_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),a_=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{uo(t_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Xt.EVENTUALLY}},predicate:(e,n,t,o)=>Nd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(e_),keywords:["text","clipboard","copy"]});import{CODES as s_,KEYS as l_}from"@excalidraw/common";import{CaptureUpdateAction as c_}from"@excalidraw/element";var ji=F({name:"gridMode",icon:K1,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,n){return{appState:{...n,gridModeEnabled:!this.checked(n),objectsSnapModeEnabled:!1},captureUpdate:c_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[l_.CTRL_OR_CMD]&&e.code===s_.QUOTE});import{KEYS as jd}from"@excalidraw/common";import{CaptureUpdateAction as d_}from"@excalidraw/element/store";import{jsx as m_}from"react/jsx-runtime";var Xs=F({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:Wu,viewMode:!0,perform:(e,n,t,o)=>{let r=Zi(n,o.props.editorPreferences).smartZoom,i=se(e,n);return o.viewport.setViewport({target:i.length?i:e,fit:r.fitToViewport?"contain":"none",animation:r.animate?{duration:r.duration}:!1,offsets:r.respectUIElements?{ui:!0}:void 0,viewportZoomFactor:r.viewportZoomFactor}),{captureUpdate:d_.NEVER}},keyTest:e=>!e[jd.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===jd.F,PanelComponent:({data:e,updateData:n})=>m_(K,{type:"button",icon:Wu,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${jd.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:jd.F.toLocaleUpperCase()})});import{CODES as p_,KEYS as u_}from"@excalidraw/common";import{CaptureUpdateAction as h_}from"@excalidraw/element";var kt=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Oo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:h_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[u_.CTRL_OR_CMD]&&e.altKey&&e.code===p_.S});import{CaptureUpdateAction as g_}from"@excalidraw/element";var Ks=F({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,n){let t=n.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...n,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:g_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as f_}from"@excalidraw/element";var Zs=F({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,n){return{appState:{...n,isMidpointSnappingEnabled:!this.checked(n)},captureUpdate:f_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as E_,KEYS as b_}from"@excalidraw/common";import{CaptureUpdateAction as x_}from"@excalidraw/element";var Qo=F({name:"stats",label:"stats.fullTitle",icon:G1,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:x_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[b_.CTRL_OR_CMD]&&e.altKey&&e.code===E_.SLASH});import{BOUND_TEXT_PADDING as By,ROUNDNESS as Oy,TEXT_ALIGN as Hy,VERTICAL_ALIGN as Gy,arrayToMap as Uy,getFontString as w_,getStrokeWidthByKey as y_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as v_,isBoundToContainer as Fy,resetOriginalContainerCache as I_,updateOriginalContainerCache as T_}from"@excalidraw/element";import{computeBoundTextPosition as S_,computeContainerDimensionForBoundText as zy,getBoundTextElement as Wy,redrawTextBoundingBox as Vy}from"@excalidraw/element";import{hasBoundTextElement as C_,isArrowElement as P_,isTextBindableContainer as tg,isTextElement as $s,isUsingAdaptiveRadius as k_}from"@excalidraw/element";import{measureText as M_}from"@excalidraw/element";import{syncMovedIndices as Yy}from"@excalidraw/element";import{newElement as A_}from"@excalidraw/element";import{CaptureUpdateAction as ng}from"@excalidraw/element";var og=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>C_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=Wy(a,i);if(s){let{width:l,height:c}=M_(s.originalText,w_(s),s.lineHeight),d=v_(a.id);I_(a.id);let{x:m,y:p}=S_(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:n,captureUpdate:ng.IMMEDIATELY}}}),rg=F({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);if(r.length===2){let i=$s(r[0])||$s(r[1]),a;if(tg(r[0])?a=r[0]:tg(r[1])&&(a=r[1]),i&&a&&Wy(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;$s(r[0])&&tg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:Gy.MIDDLE,textAlign:Hy.CENTER,autoResize:!0,angle:P_(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return Vy(i,a,o.scene),T_(a.id,s),{elements:L_(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:ng.IMMEDIATELY}}}),L_=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===t.id);o.splice(r,1);let i=o.findIndex(a=>a.id===n.id);return o.splice(i+1,0,t),Yy(o,Uy([n,t])),o},D_=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===n.id);o.splice(r,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i,0,n),Yy(o,Uy([n,t])),o},Xy=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>$s(a)&&!Fy(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let s of r)if($s(s)&&!Fy(s)){let l=A_({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:y_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:k_("rectangle")?Oy.ADAPTIVE_RADIUS:Oy.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-By,y:s.y-By,width:zy(s.width,"rectangle"),height:zy(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===s.id&&(p={...p,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(p||u)&&o.scene.mutateElement(m,{startBinding:p,endBinding:u})})}o.scene.mutateElement(s,{containerId:l.id,verticalAlign:Gy.MIDDLE,boundElements:null,textAlign:Hy.CENTER,autoResize:!0}),Vy(s,l,o.scene),i=D_([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:ng.IMMEDIATELY}}});import{getNonDeletedElements as nv,isEmbeddableElement as $_}from"@excalidraw/element";import{KEYS as ov}from"@excalidraw/common";import{CaptureUpdateAction as j_}from"@excalidraw/element";import{pointFrom as jy}from"@excalidraw/math";import __ from"clsx";import{useCallback as Ky,useEffect as Zy,useLayoutEffect as R_,useRef as N_,useState as B_}from"react";import{EVENT as ig,HYPERLINK_TOOLTIP_DELAY as O_,KEYS as qd}from"@excalidraw/common";import{getElementAbsoluteCoords as dg}from"@excalidraw/element";import{hitElementBoundingBox as F_}from"@excalidraw/element";import{isElementLink as z_}from"@excalidraw/element";import{getEmbedLink as H_,embeddableURLValidator as G_}from"@excalidraw/element";import{sceneCoordsToViewportCoords as qy,viewportCoordsToSceneCoords as U_,wrapEvent as W_,isLocalLink as V_,normalizeLink as ag}from"@excalidraw/common";import{isEmbeddableElement as sg}from"@excalidraw/element";import{jsx as qi,jsxs as $y}from"react/jsx-runtime";var mg=380,Y_=42,lg=5,Jy=85,X_=500,cg=!1,Jd=new Map,Qy=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Xo(),l=yn(),c=ge(),d=e.link||"",[m,p]=B_(d),u=N_(null),E=s.showHyperlinkPopup==="editor",g=Ky(()=>{if(!u.current)return;let v=ag(u.current.value)||null;if(!e.link&&v&&Ne("hyperlink","create"),sg(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){n.mutateElement(e,{link:null}),i(e,!1);return}if(!G_(v,l.validateEmbeddable))v&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&Jd.set(e.id,e.link),n.mutateElement(e,{link:v}),i(e,!1);else{let{width:T,height:C}=e,P=H_(v);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let A=P?P.intrinsicSize.w/P.intrinsicSize.h:1,L=Jd.get(e.id)!==e.link;n.mutateElement(e,{...L?{width:P?.type==="video"?T>C?T:C*A:T,height:P?.type==="video"&&T>C?T/A:C}:{},link:v}),i(e,!0),Jd.has(e.id)&&Jd.delete(e.id)}}else n.mutateElement(e,{link:v})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);R_(()=>()=>{g()},[g]),Zy(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),Zy(()=>{let v=null,T=C=>{if(E)return;v&&clearTimeout(v),Z_(e,a,s,jy(C.clientX,C.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},X_))};return window.addEventListener(ig.POINTER_MOVE,T,!1),()=>{window.removeEventListener(ig.POINTER_MOVE,T,!1),v&&clearTimeout(v)}},[s,e,E,t,a]);let b=Ky(()=>{Ne("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),y=()=>{Ne("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y:x}=ev(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:$y("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${w}px`,width:mg,padding:lg},children:[E?qi("input",{className:__("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[qd.CTRL_OR_CMD]&&v.key===qd.K&&v.preventDefault(),(v.key===qd.ENTER||v.key===qd.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?qi("a",{href:ag(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:V_(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&o){let T=W_(ig.EXCALIDRAW_LINK,v.nativeEvent);o({...e,link:ag(e.link)},T),T.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):qi("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),$y("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&qi(K,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:Gn}),qi(K,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:q1}),d&&!sg(e)&&qi(K,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Pr})]})]})},ev=(e,n,t)=>{let[o,r]=dg(e,t),{x:i,y:a}=qy({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-mg/2,l=a-n.offsetTop-Jy;return{x:s,y:l}},pg=(e,n)=>{let t=se(e,n);return sg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},js=null,tv=(e,n,t)=>{js&&clearTimeout(js),js=window.setTimeout(()=>K_(e,n,t),O_)},K_=(e,n,t)=>{if(!e.link)return;let o=Ri();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=z_(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=dg(e,t),[l,c,d,m]=qb([r,i,a,s],e.angle,n),p=qy({sceneX:l,sceneY:c},n);Mh(o,{left:p.x,top:p.y,width:d,height:m},"top"),Ne("hyperlink","tooltip","link-icon"),cg=!0},Qd=()=>{js&&clearTimeout(js),cg&&(cg=!1,Ri().classList.remove("excalidraw-tooltip--visible"))},Z_=(e,n,t,[o,r])=>{let{x:i,y:a}=U_({clientX:o,clientY:r},t),s=15/t.zoom.value;if(F_(jy(i,a),e,n))return!1;let[l,c,d]=dg(e,n);if(i>=l&&i<=d&&a>=c-Jy&&a<=c)return!1;let{x:m,y:p}=ev(e,t,n);return!(o>=m-s&&o<=m+mg+lg*2+s&&r>=p-s&&r<=p+s+lg*2+Y_)};import{jsx as q_}from"react/jsx-runtime";var ug=F({name:"hyperlink",label:(e,n)=>pg(nv(e),n),icon:gs,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:j_.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[ov.CTRL_OR_CMD]&&e.key===ov.K,predicate:(e,n)=>se(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=se(e,n);return q_(K,{type:"toggle",icon:gs,"aria-label":f(pg(nv(e),n)),title:`${$_(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onSelect:()=>t(null),checked:o.length===1&&!!o[0].link})}});import{KEYS as rv,arrayToMap as gg,randomId as J_}from"@excalidraw/common";import{elementsAreInSameGroup as Q_,getNonDeletedElements as iv,newElementWith as av,selectGroupsFromGivenElements as sv}from"@excalidraw/element";import{CaptureUpdateAction as lv}from"@excalidraw/element";var hg=e=>e.every(n=>!n.locked),qs=F({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return hg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=se(n,e);return hg(t)?Ro:ao},trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=hg(r),a=gg(r),s=r.length>1&&Q_(r),c=r.length===1||s?null:J_(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let y=r[0].groupIds.at(-1);delete d[y]}let m=e.map(y=>{if(!a.has(y.id))return y;let w=y.groupIds;return i?c&&(w=[...w,c]):w=w.filter(x=>!n.lockedMultiSelections[x]),av(y,{locked:i,groupIds:w.length!==y.groupIds.length?w:y.groupIds})}),p=gg(m),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),E=r.map(y=>p.get(y.id)||y),g=i?{}:sv(iv(E),n),b=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:d,activeLockedId:b},captureUpdate:lv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===rv.L&&e[rv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),cv=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:ao,predicate:(e,n)=>se(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(s=>s.locked),o=e.map(s=>{if(s.locked){let l=s.groupIds.filter(c=>!n.lockedMultiSelections[c]);return av(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=gg(o),i=t.map(s=>r.get(s.id)||s),a=iv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:sv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:lv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as m8,isLinearElement as p8,isLineElement as ia}from"@excalidraw/element";import{arrayToMap as u8,invariant as Kv}from"@excalidraw/common";import{toggleLinePolygonState as h8,CaptureUpdateAction as Zv}from"@excalidraw/element";import{getSizeFromPoints as AIe,randomInteger as c8,getUpdatedTimestamp as d8}from"@excalidraw/common";import{simplify as WR}from"points-on-curve";import{getStroke as VR,getStrokePoints as mIe}from"perfect-freehand";function Xe([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function Ji([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function et([e,n,t],o){return[e*o,n*o,t*o]}function Wr([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function Et([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function dv(e,n,t){return Xe(e,et(Ji(n,e),t))}function fg(e,n,t){return Math.atan2(t[1]-e[1],t[0]-e[0])-Math.atan2(n[1]-e[1],n[0]-e[0])}function Eg(e){return Math.atan2(Math.sin(e),Math.cos(e))}function bg([e,n]){return Math.sqrt(e**2+n**2)}function Ur([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function mv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Ur(e[t-1],e[t]);return n+=Ur(e[e.length-2],e[e.length-1]),n}var eR=(e,n,t)=>Math.max(n,Math.min(t,e));function pv(e,n,t){let o=Ur(n,t);if(o===0)return Ur(e,n);let r=eR(((e[0]-n[0])*(t[0]-n[0])+(e[1]-n[1])*(t[1]-n[1]))/o**2,0,1),i=[n[0]+r*(t[0]-n[0]),n[1]+r*(t[1]-n[1]),e[2]];return Ur(i,e)}function Js(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,s],l,c)=>{let d=pv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...Js([t,...e.slice(1,i),a],n).slice(0,-1),a,...Js([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var er=class er{constructor(n){I(this,"options");I(this,"originalPoints",[]);I(this,"stablePoints",[]);I(this,"tailPoints",[]);I(this,"isFresh",!0);this.options=Object.assign({},er.defaults,n)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(n){let t=this.originalPoints[this.originalPoints.length-1];if(!(t&&t[0]===n[0]&&t[1]===n[1])){if(this.originalPoints.push(n),this.isFresh){this.isFresh=!1,this.stablePoints.push(n);return}this.options.streamline>0&&(n=dv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),mv(this.tailPoints)>er.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase==="tail")throw new Error("Not implemented yet");this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(n,t,o,r,i){return(n??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:o,totalLength:r})}getStrokeOutline(n){if(this.isFresh)return[];let t=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase==="input"&&(t=Js(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let P=t[0],A=this.getSize(n,P[2],0,o,0);if(A<.5)return[];let L=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)L.push(Xe(P,et(Et([1,0,0],_),A)));return L.push(Xe(P,et([1,0,0],this.getSize(n,P[2],0,o,0)))),L}if(o===2){let P=t[0],A=t[1],L=this.getSize(n,P[2],0,o,0),_=this.getSize(n,A[2],0,o,0);if(L<.5||_<.5)return[];let k=[],D=fg(P,[P[0],P[1]-100,P[2]],A);for(let O=D;O<=Math.PI+D;O+=Math.PI/16)k.push(Xe(P,et(Et([1,0,0],O),L)));for(let O=Math.PI+D;O<=Math.PI*2+D;O+=Math.PI/16)k.push(Xe(A,et(Et([1,0,0],O),_)));return k.push(k[0]),k}let r=[],i=[],a=0,s=0,l=0,c=0;for(let P=1;P<o-1;P++){let A=t[P-1],L=t[P],_=t[P+1],k=L[2],D=Ur(A,L);c+=D,a=s+(D-s)*.2;let O=this.getSize(n,k,P,o,c);if(O===0){l=P+1;continue}let Y=Wr(Ji(A,L)),z=Wr(Ji(_,L)),W=Et(Y,Math.PI/2),Z=Et(Y,-Math.PI/2),H=Et(z,Math.PI/2),re=Et(z,-Math.PI/2),B=Xe(L,et(W,O)),U=Xe(L,et(Z,O)),ue=Xe(L,et(H,O)),we=Xe(L,et(re,O)),pe=Xe(W,re),he=Xe(Z,H),ye=Xe(L,et(bg(pe)===0?Y:Wr(pe),O)),ae=Xe(L,et(bg(he)===0?z:Wr(he),O)),ve=Eg(fg(L,A,_)),lt=er.constants.cornerDetectionMaxAngle/180*Math.PI*er.constants.cornerDetectionVariance(a);if(Math.abs(ve)<lt){let je=Math.abs(Eg(Math.PI-ve));if(je===0)continue;if(ve<0){i.push(U,ae);for(let Re=0;Re<=je;Re+=je/4)r.push(Xe(L,Et(et(W,O),Re)));for(let Re=je;Re>=0;Re-=je/4)i.push(Xe(L,Et(et(W,O),Re)));i.push(ae,ue)}else{r.push(B,ye);for(let Re=0;Re<=je;Re+=je/4)i.push(Xe(L,Et(et(W,-O),-Re)));for(let Re=je;Re>=0;Re-=je/4)r.push(Xe(L,Et(et(W,-O),-Re)));r.push(ye,we)}}else r.push(ye),i.push(ae);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],A=[];for(let L=0;L<=Math.PI*2;L+=Math.PI/16)A.push(Xe(P,et(Et([1,0,0],L),this.options.size)));return A.push(Xe(P,et([1,0,0],this.options.size))),A}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=Wr(Ji(m,d)),g=Wr(Ji(p,u)),b=Et(E,-Math.PI/2),y=Et(g,Math.PI/2),w=this.getSize(n,d[2],0,o,0),x=[],v=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(w>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(Xe(d,Et(et(b,w),-P)));x.unshift(Xe(d,et(b,-w)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(Xe(u,Et(et(y,-v),-P)));let C=[...x,...r,...T.reverse(),...i.reverse()];return x.length>0&&C.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?Js(C,this.options.simplify):C}};I(er,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),I(er,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var Qi=er;import{pointsOnBezierCurves as Sce}from"points-on-curve";import{invariant as Pce}from"@excalidraw/common";import{curve as Mce,lineSegment as Ace,pointFrom as Lce,pointDistance as Dce,pointFromArray as _ce,pointFromVector as Rce,pointRotateRads as Nce,polygon as Bce,polygonFromPoints as Oce,PRECISION as Fce,segmentsIntersectAt as zce,vector as Hce,vectorAdd as Gce,vectorFromPoint as Uce,vectorScale as Wce}from"@excalidraw/math";import{getElementAbsoluteCoords as Yce}from"@excalidraw/element";var xg=e=>{if(!e)return[];for(let n of e.sets)if(n.type==="path")return n.ops;return e.sets[0].ops};import{pointFrom as YR,pointDistance as Gv,pointRotateRads as gIe}from"@excalidraw/math";import{ROUGHNESS as XR,THEME as Og,isTransparent as ml,assertNever as KR,COLOR_PALETTE as ZR,LINE_POLYGON_POINT_MERGE_DISTANCE as EIe,applyDarkModeFilter as pl,DEFAULT_STROKE_STREAMLINE as $R}from"@excalidraw/common";import{RoughGenerator as jR}from"roughjs/bin/generator";import T2e from"roughjs/bin/rough";import{isRightAngleRads as C2e,lineSegment as P2e,pointFrom as k2e,pointRotateRads as M2e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as L2e,DEFAULT_REDUCED_GLOBAL_ALPHA as D2e,ELEMENT_READY_TO_ERASE_OPACITY as _2e,FRAME_STYLE as R2e,DARK_THEME_FILTER as N2e,MIME_TYPES as Hv,THEME as B2e,distance as O2e,getFontString as F2e,isRTL as z2e,getVerticalOffset as H2e,invariant as G2e,applyDarkModeFilter as U2e,isSafari as W2e}from"@excalidraw/common";import $ve from"roughjs/bin/rough";import{arrayToMap as qve,invariant as zv,rescalePoints as Jve,sizeOf as Qve}from"@excalidraw/common";import{degreesToRadians as _g,lineSegment as t2e,pointFrom as bt,pointFromArray as BR,pointRotateRads as ra}from"@excalidraw/math";import{pointsOnBezierCurves as r2e}from"points-on-curve";import{pointCenter as uve,pointFrom as hve,pointRotateRads as gve,pointsEqual as fve,pointDistance as Eve,vectorFromPoint as bve,curveLength as xve,curvePointAtLength as wve}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Ive,KEYS as Tve,shouldRotateWithDiscreteAngle as Sve,getGridPoint as Cve,invariant as Pve,isShallowEqual as kve,getFeatureFlag as Mve}from"@excalidraw/common";import{arrayToMap as kye,getFeatureFlag as Mye,getGridPoint as Aye,invariant as Lye,isTransparent as Dye}from"@excalidraw/common";import{PRECISION as Rye,clamp as Nye,lineSegment as Bye,pointDistance as Oye,pointDistanceSq as Fye,pointFrom as zye,pointFromArray as Hye,pointFromVector as Gye,pointRotateRads as Uye,pointsEqual as Wye,vectorFromPoint as Vye,vectorNormalize as Yye,vectorScale as Xye}from"@excalidraw/math";import{invariant as $we,isTransparent as jwe}from"@excalidraw/common";import{curveIntersectLineSegment as Jwe,isPointWithinBounds as Qwe,lineSegment as eye,lineSegmentIntersectionPoints as tye,pointFrom as nye,pointFromVector as oye,pointRotateRads as rye,pointsEqual as iye,vectorFromPoint as aye,vectorNormalize as sye,vectorScale as lye}from"@excalidraw/math";import{ellipse as dye,ellipseSegmentInterceptPoints as mye}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as rR,DEFAULT_PROPORTIONAL_RADIUS as vg,invariant as nde,LINE_CONFIRM_THRESHOLD as iR,ROUNDNESS as Ig}from"@excalidraw/common";import{bezierEquation as rde,curve as ide,curveCatmullRomCubicApproxPoints as ade,curveOffsetPoints as sde,lineSegment as lde,lineSegmentIntersectionPoints as cde,pointDistance as aR,pointFrom as dde,pointFromArray as mde,pointFromVector as pde,pointRotateRads as ude,pointTranslate as hde,rectangle as gde,vectorFromPoint as fde,vectorNormalize as Ede,vectorScale as bde}from"@excalidraw/math";import{ROUNDNESS as $ce,assertNever as jce}from"@excalidraw/common";import{pointsEqual as Jce}from"@excalidraw/math";var uv=e=>!!e&&e.type==="embeddable",wg=e=>!!e&&e.type==="iframe",yg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),an=e=>e!=null&&e.type==="text";var Zn=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var sn=e=>e!=null&&nR(e.type);var In=e=>e!=null&&e.type==="arrow",Tn=e=>In(e)&&e.elbowed;var nR=e=>e==="arrow"||e==="line";var ho=e=>e!==null&&"containerId"in e&&e.containerId!==null&&an(e);var ea=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return aR(t,o)<=iR/n}return!1},Qs=(e,n)=>{if(n.roundness?.type===Ig.PROPORTIONAL_RADIUS||n.roundness?.type===Ig.LEGACY)return e*vg;if(n.roundness?.type===Ig.ADAPTIVE_RADIUS){let t=n.roundness?.value??rR,o=t/vg;return e<=o?e*vg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as kwe,ARROW_LABEL_WIDTH_FRACTION as Mwe,BOUND_TEXT_PADDING as Awe,DEFAULT_FONT_SIZE as Lwe,TEXT_ALIGN as Dwe,VERTICAL_ALIGN as _we,getFontString as Rwe,isProdEnv as Nwe,invariant as Bwe}from"@excalidraw/common";import{pointFrom as Fwe,pointRotateRads as zwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Dde,DEFAULT_FONT_SIZE as _de,DEFAULT_FONT_FAMILY as Rde,getFontString as Nde,isTestEnv as Bde,normalizeEOL as Ode}from"@excalidraw/common";var Fde="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Yde,isTestEnv as Xde}from"@excalidraw/common";import{toIterable as I0e}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as qde,viewportCoordsToSceneCoords as Jde}from"@excalidraw/common";import{normalizeRadians as eme,radiansBetweenAngles as tme,radiansDifference as nme}from"@excalidraw/math";import{pointsEqual as rme}from"@excalidraw/math";import{arrayToMap as Ume,isShallowEqual as dR}from"@excalidraw/common";import{arrayToMap as vme}from"@excalidraw/common";import{isPointWithinBounds as Tme,pointFrom as Sme,segmentsIntersectAt as Cme}from"@excalidraw/math";import{arrayToMap as dme}from"@excalidraw/common";import{validateOrderKey as pme,generateNKeysBetween as ume}from"@excalidraw/fractional-indexing";var Tg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var jme=function(){let e=null,n=null,t=null,o=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===n||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,n=i.selectedElementIds),t);return o.clearCache=()=>{e=null,n=null,t=null},o}(),rl=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){Vr(i)?(r.push(i),o.add(i.id)):console.error("[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection");continue}if(t?.includeBoundTextElement&&ho(i)&&Vr(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{Zn(a)&&Tg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var Cg=(e,n)=>dR(n.selectedElementIds,e)?n.selectedElementIds:e;var mR=function(){let e=null,n=null,t=null,o=(i,a,s,l)=>{if(t!==void 0&&a===n&&i===e&&s.editingGroupId===t?.editingGroupId)return t;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let E=u.indexOf(s.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];c[E]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>c[g]);return E&&(p[u.id]=!0,Array.isArray(d[E])?d[E].push(u.id):d[E]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Cg({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):rl(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Cg(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var hpe=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as due,VERTICAL_ALIGN as mue}from"@excalidraw/common";import{pointDistance as uue,pointFromVector as hue,pointsEqual as gue,vector as fue,vectorDot as Eue,vectorFromPoint as bue,vectorNormalize as xue,vectorScale as wue}from"@excalidraw/math";import{invariant as Cpe,isDevEnv as Ppe,isTestEnv as kpe}from"@excalidraw/common";import{pointFrom as Ape,pointFromVector as Lpe,pointRotateRads as Dpe,pointScaleFromOrigin as _pe,pointsEqual as Rpe,triangleIncludesPoint as Npe,vectorCross as Bpe,vectorFromPoint as hR,vectorScale as Ope}from"@excalidraw/math";var sl=[1,0],rm=[0,1],ll=[-1,0],im=[0,-1],am=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?sl:n<=-r?ll:t>o?rm:im},vv=(e,n)=>am(hR(e,n)),sm=(e,n)=>lm(vv(e,n)),al=(e,n)=>e[0]===n[0]&&e[1]===n[1],lm=e=>al(e,sl)||al(e,ll);import{DEFAULT_ELEMENT_PROPS as Upe,DEFAULT_FONT_FAMILY as Wpe,DEFAULT_FONT_SIZE as Vpe,DEFAULT_TEXT_ALIGN as Ype,DEFAULT_VERTICAL_ALIGN as Xpe,DEFAULT_STROKE_STREAMLINE as Kpe,VERTICAL_ALIGN as Zpe,randomInteger as $pe,randomId as jpe,getFontString as qpe,getUpdatedTimestamp as Jpe,getLineHeight as Qpe}from"@excalidraw/common";import{pointsOnBezierCurves as Wue,simplify as Vue}from"points-on-curve";import{curveToBezier as Xue}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Zue,lineSegment as $ue,lineSegmentIntersectionPoints as jue,pointDistance as que,pointFrom as Jue,pointRotateRads as Que,polygonArea as ehe,polygonIncludesPoint as the,polygonIncludesPointNonZero as nhe,polygonSignedArea as ohe}from"@excalidraw/math";import{isOpaqueColor as ihe,isTransparent as ahe}from"@excalidraw/common";var Cv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as Lue,distanceToLineSegment as Due,pointRotateRads as _ue}from"@excalidraw/math";import{ellipse as Nue,ellipseDistanceFromPoint as Bue}from"@excalidraw/math/ellipse";import{pointFrom as whe,pointCenter as yhe,pointRotateRads as vhe,vectorFromPoint as Ihe,vectorNormalize as The,vectorSubtract as She,vectorAdd as Che,vectorScale as Phe,pointFromVector as khe,clamp as Mhe,isCloseTo as Ahe}from"@excalidraw/math";import{arrayToMap as ife,arrayToObject as afe,assertNever as sfe,isDevEnv as lfe,isShallowEqual as cfe,isTestEnv as dfe,randomInteger as mfe}from"@excalidraw/common";import{assertNever as pge,COLOR_PALETTE as uge,isDevEnv as hge,isTestEnv as gge,randomId as fge,Emitter as Ege,toIterable as bge}from"@excalidraw/common";import{ORIG_ID as Whe,randomId as Vhe,randomInteger as Yhe,arrayToMap as Xhe,castArray as Khe,findLastIndex as Zhe,getUpdatedTimestamp as $he,isTestEnv as jhe}from"@excalidraw/common";import{arrayToMap as Nhe}from"@excalidraw/common";import ER from"lodash.throttle";import{randomInteger as _ge,arrayToMap as Rge,toBrandedType as Nge,isDevEnv as Av,isTestEnv as Lv,toArray as Bge}from"@excalidraw/common";import{isNonDeletedElement as Fge}from"@excalidraw/element";import{isFrameLikeElement as Hge}from"@excalidraw/element";import{getElementsInGroup as Uge}from"@excalidraw/element";import{syncInvalidIndices as Vge,syncMovedIndices as Yge,validateFractionalIndices as bR}from"@excalidraw/element";import{getSelectedElements as Kge}from"@excalidraw/element";import{mutateElement as $ge}from"@excalidraw/element";var jge=ER(e=>{(Av()||Lv()||window?.DEBUG_FRACTIONAL_INDICES)&&bR(e,{shouldThrow:Av()||Lv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as Bfe,getGridPoint as Ofe,getFontString as Ffe,DRAGGING_THRESHOLD as zfe}from"@excalidraw/common";import{clamp as jfe,pointDistance as qfe,pointFrom as Jfe,pointScaleFromOrigin as Qfe,pointsEqual as eEe,pointTranslate as tEe,vector as nEe,vectorCross as oEe,vectorFromPoint as rEe,vectorScale as iEe}from"@excalidraw/math";import{BinaryHeap as sEe,invariant as lEe,isAnyTrue as cEe,getSizeFromPoints as dEe,isDevEnv as mEe,arrayToMap as pEe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as CEe,normalizeLink as PEe}from"@excalidraw/common";import{FONT_FAMILY as DEe,VERTICAL_ALIGN as _Ee,escapeDoubleQuotes as REe,getFontString as NEe}from"@excalidraw/common";import{invariant as VEe,toBrandedType as YEe}from"@excalidraw/common";import{clamp as KEe,pointFrom as ZEe}from"@excalidraw/math";import{pointDistance as Ibe,pointFrom as Tbe}from"@excalidraw/math";import{invariant as Cbe}from"@excalidraw/common";import{arrayToMap as lbe,findIndex as cbe,findLastIndex as dbe}from"@excalidraw/common";import{isFiniteNumber as pbe}from"@excalidraw/math";import{MIME_TYPES as Bbe,SVG_NS as Obe}from"@excalidraw/common";import{rgbaToThumbHash as zbe,thumbHashToRGBA as Hbe}from"thumbhash";import{pointCenter as nxe,normalizeRadians as oxe,pointFrom as rxe,pointRotateRads as ixe}from"@excalidraw/math";import{MIN_FONT_SIZE as sxe,SHIFT_LOCKING_ANGLE as lxe,rescalePoints as cxe,getFontString as dxe}from"@excalidraw/common";import{pointFrom as Oxe,pointOnLineSegment as Fxe,pointRotateRads as zxe}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as Gxe}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as Txe}from"@excalidraw/common";import{pointFrom as Cxe,pointRotateRads as Pxe}from"@excalidraw/math";import{KEYS as Cn}from"@excalidraw/common";var Jxe=[{icon:Cc,value:"selection",key:Cn.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Ei,value:"rectangle",key:Cn.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:bi,value:"diamond",key:Cn.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:xi,value:"ellipse",key:Cn.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Pc,value:"arrow",key:Cn.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:No,value:"line",key:Cn.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Gn,value:"freedraw",key:[Cn.P,Cn.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:wn,value:"text",key:Cn.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Cr,value:"image",key:[Cn.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:kc,value:"eraser",key:Cn.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as d1e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as p1e,DEFAULT_FONT_SIZE as u1e,TEXT_ALIGN as h1e,VERTICAL_ALIGN as g1e,getSizeFromPoints as f1e,randomId as E1e,arrayToMap as b1e,assertNever as x1e,cloneJSON as w1e,getFontString as y1e,isDevEnv as v1e,toBrandedType as I1e,getLineHeight as T1e}from"@excalidraw/common";import{getBoundsFromPoints as K1e,getElementAbsoluteCoords as Z1e}from"@excalidraw/element/bounds";import{newArrowElement as j1e,newElement as q1e,newLinearElement as J1e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as e0e,getStrokeWidthByKey as t0e,ROUNDNESS as n0e}from"@excalidraw/common";import{convexHull as r0e,distanceToLineSegment as i0e,elongation as a0e,kurtosis as s0e,lineSegment as l0e,orientPrincipalAxes as c0e,pointFrom as d0e,polygonArea as m0e,principalAxes as p0e,principalCoords as u0e,skewness as h0e}from"@excalidraw/math";var b0e=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}];var Vr=e=>!e.isDeleted;var MR=10/1.5;var em=e=>{let n=Math.floor(e.width/2)+1,t=0,o=e.width,r=Math.floor(e.height/2)+1,i=n,a=e.height;return[n,t,o,r,i,a,0,r]};var OR=20,FR=15,zR=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"cardinality_many":case"cardinality_one_or_many":case"cardinality_zero_or_many":return FR;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return OR;default:return 15}},HR=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},At=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=xg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;zv(s.length===6,"Op data length is not 6");let l=bt(s[4],s[5]),c=bt(s[2],s[3]),d=bt(s[0],s[1]),m=i[a-1],p=bt(0,0);if(m.op==="move"){let H=BR(m.data);zv(H!=null,"Op data is not a point"),p=H}else m.op==="bcurveTo"&&(p=bt(m.data[4],m.data[5]));let u=(H,re)=>Math.pow(1-H,3)*l[re]+3*H*Math.pow(1-H,2)*c[re]+3*Math.pow(H,2)*(1-H)*d[re]+p[re]*Math.pow(H,3),[E,g]=t==="start"?p:l,[b,y]=[u(.3,0),u(.3,1)],w=Math.hypot(E-b,g-y),x=(E-b)/w,v=(g-y)/w,T=zR(o),C=0;{let[H,re]=t==="end"?e.points[e.points.length-1]:e.points[0],[B,U]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(H-B,re-U)}let A=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),L=E-x*A*r,_=g-v*A*r,k=L-x*A,D=_-v*A;if(o==="circle"||o==="circle_outline"){let H=Math.hypot(D-_,k-L)+e.strokeWidth-2;return[L,_,H]}let O=HR(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[H,re]=ra(bt(L,_),bt(k,D),_g(-O)),[B,U]=ra(bt(L,_),bt(k,D),_g(O));return[k,D,H,re,B,U]}let[Y,z]=ra(bt(k,D),bt(L,_),-O*Math.PI/180),[W,Z]=ra(bt(k,D),bt(L,_),_g(O));if(o==="diamond"||o==="diamond_outline"){let H,re;if(t==="start"){let[B,U]=e.points.length>1?e.points[1]:[0,0];[H,re]=ra(bt(L+A*2,_),bt(L,_),Math.atan2(U-_,B-L))}else{let[B,U]=e.points.length>1?e.points[e.points.length-2]:[0,0];[H,re]=ra(bt(L-A*2,_),bt(L,_),Math.atan2(_-U,L-B))}return[L,_,Y,z,H,re,W,Z]}return[L,_,Y,z,W,Z]};var GR=typeof document<"u"?document.createElement("img"):{src:""};GR.src=`data:${Hv.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 UR=typeof document<"u"?document.createElement("img"):{src:""};UR.src=`data:${Hv.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 Rg=new WeakMap;var zt=class zt{};I(zt,"rg",new jR),I(zt,"cache",new WeakMap),I(zt,"get",(n,t)=>{let o=zt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),I(zt,"delete",n=>{zt.cache.delete(n),Rg.delete(n)}),I(zt,"destroy",()=>{zt.cache=new WeakMap}),I(zt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:zt.get(n,t?t.theme:null);if(o!==void 0)return o;Rg.delete(n);let r=QR(n,zt.rg,t||{isExporting:!1,canvasBackgroundColor:ZR.white,embedsValidationStatus:null,theme:Og.LIGHT});return t?.isExporting||zt.cache.set(n,{shape:r,theme:t?.theme||Og.LIGHT}),r});var oa=zt,qR=e=>[8,8+e],Yv=e=>[1.5,6+e];function JR(e){let n=e.roughness,t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&t>=50||o>=15&&e.roundness&&Cv(e.type)||sn(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var fo=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?qR(e.strokeWidth):e.strokeStyle==="dotted"?Yv(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:JR(e),stroke:pl(e.strokeColor,t),preserveVertices:n||e.roughness<XR.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=ml(e.backgroundColor)?void 0:pl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return ea(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:pl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},Uv=(e,n,t)=>yg(e)&&(n||uv(e)&&t?.get(e.id)!==!0)&&ml(e.backgroundColor)&&ml(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:wg(e)?{...e,strokeColor:ml(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:ml(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,dl=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},dm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},Xr=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=Yv(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Ng=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,s,l]=o,c={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete c.strokeLineDash,[e.circle(a,s,l*i,c)]},Wv=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=pl(e.strokeColor,s),c=pl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return Ng(r,i,l,At(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=At(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w]=p,x={...i,fill:o==="triangle_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete x.strokeLineDash,[r.polygon([[u,E],[g,b],[y,w],[u,E]],x)]}case"diamond":case"diamond_outline":{let p=At(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w,x,v]=p,T={...i,fill:o==="diamond_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete T.strokeLineDash,[r.polygon([[u,E],[g,b],[y,w],[x,v],[u,E]],T)]}case"cardinality_one":return dl(r,At(e,n,t,o),Xr(e,i));case"cardinality_many":return dm(r,At(e,n,t,o),Xr(e,i));case"cardinality_one_or_many":{let p=Xr(e,i);return[...dm(r,At(e,n,t,"cardinality_many"),p),...dl(r,At(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=Xr(e,i);return[...dl(r,At(e,n,t,"cardinality_one",-.5),p),...dl(r,At(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=Xr(e,i);return[...Ng(r,i,l,At(e,n,t,"circle_outline",1.5),c,m),...dl(r,At(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=Xr(e,i);return[...dm(r,At(e,n,t,"cardinality_many"),p),...Ng(r,i,l,At(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return dm(r,At(e,n,t,o),Xr(e,i))}};var QR=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===Og.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=Qs(Math.min(l,c),e);s=n.path(`M ${d} 0 L ${l-d} 0 Q ${l} 0, ${l} ${d} L ${l} ${c-d} Q ${l} ${c}, ${l-d} ${c} L ${d} ${c} Q 0 ${c}, 0 ${c-d} L 0 ${d} Q 0 0, ${d} 0`,fo(Uv(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,fo(Uv(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=em(e);if(e.roundness){let b=Qs(Math.abs(l-E),e),y=Qs(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+y} L ${d-b} ${m-y}
|
|
4
|
+
${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var bw=async(e,n,t)=>{let o=px(n);if(!ux(o))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:a}=await e,{exportBackground:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=Vr(r,i,!1);return await Yr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as KD,jsx as rr,jsxs as vw}from"react/jsx-runtime";var $h=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>rr(mw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),xw=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:Mn.EVENTUALLY})}),Zh=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>rr(Vh,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),Kd=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>vw(Vh,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),rr(pt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:rr("div",{className:"excalidraw-tooltip-icon",children:jx})})]})}),Qi=!1,Kh=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?vw(KD,{children:[t,rr(zd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function XD(e,n){if(n.app.state.isLoading&&(Kh(n.app,{progress:null}),await n.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(n.signal.aborted){e.return();return}if(t.type==="progress")Kh(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Kh(n.app,{progress:null}),await e)}function yw(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await XD(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,signal:i})}catch(l){l?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",l)}s({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var Xr=O({name:"saveToActiveFile",label:"buttons.save",icon:vs,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(Qi)return!1;Qi=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=yw(e,n,o.files,o);try{let{fileHandle:l}=Pc(r)?await bw(s,r,i):await vc({data:s,filename:i,fileHandle:r});return{captureUpdate:Mn.NEVER,appState:{fileHandle:l,toast:{message:r&&l?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${l.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(l){return a.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:Mn.NEVER,appState:{toast:null}}}finally{Qi=!1}},keyTest:e=>!1}),Js=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:vs,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(Qi)return!1;Qi=!0;let{abortController:r,data:i}=yw(e,n,o.files,o);try{let{fileHandle:a}=await vc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:Mn.NEVER,appState:{openDialog:null,fileHandle:a,toast:{message:f("toast.fileSaved"),duration:3e3}}}}catch(a){return r.abort(),a?.name!=="AbortError"?console.error(a):console.warn(a),{captureUpdate:Mn.NEVER,appState:{toast:null}}}finally{Qi=!1}},keyTest:e=>e.key.toLowerCase()===Xd.S&&e.shiftKey&&e[Xd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>rr($,{type:"button",icon:Yx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Ee().formFactor==="phone",hidden:!Ii,onClick:()=>e(null),"data-testid":"save-as-button"})}),ea=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{try{let{elements:r,appState:i,files:a}=await yu(n,e);return{elements:r,appState:i,files:a,captureUpdate:Mn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:Mn.EVENTUALLY}}},keyTest:e=>e[Xd.CTRL_OR_CMD]&&e.key===Xd.O}),ww=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?qs.DARK:qs.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>rr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:rr(cw,{value:e.exportWithDarkMode?qs.DARK:qs.LIGHT,onChange:t=>{n(t===qs.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as $D,DEFAULT_FONT_FAMILY as ZD,DEFAULT_TEXT_ALIGN as jD,getLineHeight as qD}from"@excalidraw/common";import{newElementWith as $d}from"@excalidraw/element";import{hasBoundTextElement as JD,canApplyRoundnessTypeToElement as QD,getDefaultRoundnessTypeForElement as eL,isFrameLikeElement as tL,isArrowElement as nL,isExcalidrawElement as oL,isTextElement as Iw}from"@excalidraw/element";import{getBoundTextElement as rL,redrawTextBoundingBox as iL}from"@excalidraw/element";import{CaptureUpdateAction as jh}from"@excalidraw/element";var Tw="{}",aL=O({name:"copyStyles",label:"labels.copyStyles",icon:Yu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&JD(i)){let a=rL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Tw=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:jh.EVENTUALLY}}}),sL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:Yu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(Tw),i=r[0],a=r[1];if(!oL(i))return{elements:e,captureUpdate:jh.EVENTUALLY};let s=ce(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(Iw(c)&&c.containerId&&(d=a),!d)return c;let m=$d(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?QD(d.roundness.type,c)?d.roundness:eL(c):null});if(Iw(m)){let p=d.fontSize||$D,u=d.fontFamily||ZD,E=$d(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||jD,lineHeight:d.lineHeight||qD(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),iL(E,g,o.scene)}return m.type==="arrow"&&nL(d)&&(m=$d(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),tL(c)&&(m=$d(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:jh.IMMEDIATELY}}});import{KEYS as lL}from"@excalidraw/common";import{CaptureUpdateAction as cL}from"@excalidraw/element";var Kr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Gx,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,n,t,{focusContainer:o})=>(n.openDialog?.name==="help"&&o(),{appState:{...n,openDialog:n.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:cL.EVENTUALLY}),keyTest:e=>e.key===lL.QUESTION_MARK});import{getNonDeletedElements as jd}from"@excalidraw/element";import{newElementWith as Cw}from"@excalidraw/element";import{isBoundToContainer as dL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as mL,getElementsInResizingFrame as pL,getFrameLikeElements as uL,getRootElements as hL,groupByFrameLikes as gL,removeElementsFromFrame as fL,replaceAllElementsInFrame as EL}from"@excalidraw/element";import{KEYS as qd,randomId as bL,arrayToMap as Jh}from"@excalidraw/common";import{getSelectedGroupIds as Zd,selectGroup as xL,selectGroupsForSelectedElements as yL,getElementsInGroup as Sw,addToGroup as wL,removeFromSelectedGroups as vL,isElementInGroup as Pw}from"@excalidraw/element";import{syncMovedIndices as IL}from"@excalidraw/element";import{CaptureUpdateAction as Qs}from"@excalidraw/element";import{jsx as ta}from"react/jsx-runtime";var TL=(e,n)=>{if(e.length>=2){let t=n?e[0].groupIds.indexOf(n):-1,o=t>-1?e[0].groupIds.slice(0,t):e[0].groupIds;for(let r of o)if(e.every(i=>Pw(i,r)))return!0}return!1},qh=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!TL(t,e.editingGroupId)&&!mL(t)},Qh=O({name:"group",label:"labels.group",icon:e=>ta(Ou,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!qh(n,o))return!1;let r=hL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:Qs.EVENTUALLY};let i=Zd(n);if(i.length===1){let b=i[0],y=new Set(Sw(e,b).map(I=>I.id)),w=new Set(r.map(I=>I.id));if(new Set([...Array.from(y),...Array.from(w)]).size===y.size)return{appState:n,elements:e,captureUpdate:Qs.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&gL(r).forEach((y,w)=>{fL(y,o.scene.getNonDeletedElementsMap())});let l=bL(),c=Jh(r);a=a.map(b=>c.get(b.id)?Cw(b,{groupIds:wL(b.groupIds,l,n.editingGroupId)}):b);let d=Sw(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!Pw(b,l)),g=IL([...E,...d,...u],Jh(d));return{appState:{...n,...xL(l,{...n,selectedGroupIds:{}},jd(a))},elements:g,captureUpdate:Qs.IMMEDIATELY}},predicate:(e,n,t,o)=>qh(n,o),keyTest:e=>!e.shiftKey&&e[qd.CTRL_OR_CMD]&&e.key===qd.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ta($,{hidden:!qh(n,o),type:"button",icon:ta(Ou,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:De(jd(e),n)})}),eg=O({name:"ungroup",label:"labels.ungroup",icon:e=>ta(zu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=Zd(n),i=Jh(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:Qs.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{dL(p)&&s.push(p.id);let u=vL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:Cw(p,{groupIds:u})});let l=yL(n,jd(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return uL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=EL(a,pL(a,p,n,i),p))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,E])=>(E&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...n,...l},elements:a,captureUpdate:Qs.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[qd.CTRL_OR_CMD]&&e.key===qd.G.toUpperCase(),predicate:(e,n)=>Zd(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>ta($,{type:"button",hidden:Zd(n).length===0,icon:ta(zu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:De(jd(e),n)})});import DL from"clsx";import{CaptureUpdateAction as Lw}from"@excalidraw/element";import{invariant as LL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as SL,COLOR_VOICE_CALL as CL,COLOR_WHITE as Qd,THEME as PL,UserIdleState as kw}from"@excalidraw/common";var Jd=(e,n,t,o,r,i,a)=>{e.beginPath(),e.moveTo(n+i,t),e.lineTo(n+o-i,t),e.quadraticCurveTo(n+o,t,n+o,t+i),e.lineTo(n+o,t+r-i),e.quadraticCurveTo(n+o,t+r,n+o-i,t+r),e.lineTo(n+i,t+r),e.quadraticCurveTo(n,t+r,n,t+r-i),e.lineTo(n,t+i),e.quadraticCurveTo(n,t,n+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function kL(e){let n=0;if(e.length===0)return n;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);n=(n<<5)-n+o}return n}var $r=(e,n)=>`hsl(${Math.abs(kL(n?.id||e))%37*10}, 100%, 83%)`,Mw=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},Aw=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:s,y:l}=a,c=t.collaborators.get(i);s-=t.offsetLeft,l-=t.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>r-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,r-m);let u=$r(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===kw.IDLE||E===kw.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===PL.DARK?"#2f6330":CL,y=c?.isSpeaking;y&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Qd,e.strokeStyle=Qd,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(s-1,l-1),e.lineTo(s-1,l+15),e.lineTo(s+5,l+10),e.lineTo(s+12,l+9),e.closePath(),e.fill()):(e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.fill(),e.stroke());let w=n.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let x=(y?s+0:s)+d/2,I=(y?l+0:l)+m+2,T=5,C=3,P=e.measureText(w),A=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,D=Math.max(A,12),_=x-1,k=I-1,L=P.width+2+T*2+2,B=D+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,L,B,8),e.fillStyle=u,e.fill(),e.strokeStyle=Qd,e.stroke(),y&&(e.beginPath(),e.roundRect(_-2,k-2,L+4,B+4,8),e.strokeStyle=b,e.stroke())):Jd(e,_,k,L,B,8,Qd),e.fillStyle=SL,e.fillText(w,x+T+1,I+C+P.actualBoundingBoxAscent+Math.floor((D-A)/2)+2),y){e.fillStyle=b;let V=8,z=8,U=5;e.fillRect(_+L+z,k+(B/2-V/2),2,V),e.fillRect(_+L+z+U,k+(B/2-V*2/2),2,V*2),e.fillRect(_+L+z+U*2,k+(B/2-V/2),2,V)}}e.restore(),e.closePath()}};import ML from"clsx";import{useState as AL}from"react";import{jsx as Dw}from"react/jsx-runtime";var tg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=Mw(t),[a,s]=AL(!1),l=!a&&o,c=l?void 0:{background:e};return Dw("div",{className:ML("Avatar",r),style:c,onClick:n,children:l?Dw("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as to,jsxs as em}from"react/jsx-runtime";var _L=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(LL(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.props.userToFollow?.socketId===t.socketId||t.isCurrentUser?(o.requestUnfollow(),{appState:n,captureUpdate:Lw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:Lw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=$r(o,r),l=DL({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),c=r.isInCall?r.isSpeaking?em("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[to("div",{}),to("div",{}),to("div",{})]}):r.isMuted?to("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:J1}):to("div",{title:f("userList.hint.inCall"),children:q1}):null;return i?em("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[to(tg,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),to("div",{className:"UserList__collaborator-name",children:r.username}),em("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&to("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Fr}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):em("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[to(tg,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&to("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as na}from"@excalidraw/element";import{isFrameLikeElement as RL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as NL}from"@excalidraw/element";import{KEYS as ir,arrayToMap as BL}from"@excalidraw/common";import{alignElements as FL}from"@excalidraw/element";import{CaptureUpdateAction as oa}from"@excalidraw/element";import{getSelectedElementsByGroup as OL}from"@excalidraw/element";import{jsx as ia}from"react/jsx-runtime";var dt=(e,n)=>{let t=n.scene.getSelectedElements(e);return OL(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>RL(o))},ra=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=FL(r,o,t.scene,n),a=BL(i);return NL(e.map(s=>a.get(s.id)||s),n,t)},zL=O({name:"alignTop",label:"labels.alignTop",icon:Lu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"start",axis:"y"}),captureUpdate:oa.IMMEDIATELY}),keyTest:e=>e[ir.CTRL_OR_CMD]&&e.shiftKey&&e.key===ir.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Lu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:De(na(e),n)})}),GL=O({name:"alignBottom",label:"labels.alignBottom",icon:_u,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"end",axis:"y"}),captureUpdate:oa.IMMEDIATELY}),keyTest:e=>e[ir.CTRL_OR_CMD]&&e.shiftKey&&e.key===ir.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:_u,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:De(na(e),n)})}),HL=O({name:"alignLeft",label:"labels.alignLeft",icon:Ru,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"start",axis:"x"}),captureUpdate:oa.IMMEDIATELY}),keyTest:e=>e[ir.CTRL_OR_CMD]&&e.shiftKey&&e.key===ir.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Ru,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:De(na(e),n)})}),UL=O({name:"alignRight",label:"labels.alignRight",icon:Nu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"end",axis:"x"}),captureUpdate:oa.IMMEDIATELY}),keyTest:e=>e[ir.CTRL_OR_CMD]&&e.shiftKey&&e.key===ir.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Nu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:De(na(e),n)})}),WL=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Bu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"center",axis:"y"}),captureUpdate:oa.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Bu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:De(na(e),n)})}),VL=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Fu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"center",axis:"x"}),captureUpdate:oa.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Fu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:De(na(e),n)})});import{getNonDeletedElements as _w}from"@excalidraw/element";import{isFrameLikeElement as YL}from"@excalidraw/element";import{CODES as Rw,KEYS as Nw,arrayToMap as XL}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as KL}from"@excalidraw/element";import{distributeElements as $L}from"@excalidraw/element";import{CaptureUpdateAction as Bw}from"@excalidraw/element";import{getSelectedElementsByGroup as ZL}from"@excalidraw/element";import{jsx as zw}from"react/jsx-runtime";var Fw=(e,n)=>{let t=n.scene.getSelectedElements(e);return ZL(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>YL(o))},Ow=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=$L(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=XL(i);return KL(e.map(s=>a.get(s.id)||s),n,t)},jL=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Ow(e,n,o,{space:"between",axis:"x"}),captureUpdate:Bw.IMMEDIATELY}),keyTest:e=>!e[Nw.CTRL_OR_CMD]&&e.altKey&&e.code===Rw.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>zw($,{hidden:!Fw(n,o),type:"button",icon:e1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:De(_w(e),n)})}),qL=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Ow(e,n,o,{space:"between",axis:"y"}),captureUpdate:Bw.IMMEDIATELY}),keyTest:e=>!e[Nw.CTRL_OR_CMD]&&e.altKey&&e.code===Rw.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>zw($,{hidden:!Fw(n,o),type:"button",icon:t1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:De(_w(e),n)})});import{arrayToMap as Gw,KEYS as QL,matchKey as e_}from"@excalidraw/common";import{CaptureUpdateAction as t_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as n_}from"@excalidraw/element/frame";import{arrangeElements as o_}from"@excalidraw/element/arrange";var JL={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},aa=(e,n)=>({smartZoom:{...JL,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as a_}from"react/jsx-runtime";var r_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Gw(e),{arrange:i}=aa(n,t.props.editorPreferences),a=o_(t.scene,o,r,i.algorithm,i.gap),s=Gw(a);return n_(e.map(l=>s.get(l.id)||l),n,t)},i_=dt,ng=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Ku,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>i_(n,o),perform:(e,n,t,o)=>({appState:n,elements:r_(e,n,o),captureUpdate:t_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e_(e,QL.R),PanelComponent:({updateData:e})=>a_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:Ku})});import{arrayToMap as Hw}from"@excalidraw/common";import{CaptureUpdateAction as s_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as l_}from"@excalidraw/element/frame";import{normaliseElements as c_}from"@excalidraw/element/normalise";import{jsx as p_}from"react/jsx-runtime";var d_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Hw(e),{normalise:i}=aa(n,t.props.editorPreferences),a=c_(t.scene,o,r,i.mode,i.metric),s=Hw(a);return l_(e.map(l=>s.get(l.id)||l),n,t)},m_=dt,og=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:$u,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>m_(n,o),perform:(e,n,t,o)=>({appState:n,elements:d_(e,n,o),captureUpdate:s_.IMMEDIATELY}),PanelComponent:({updateData:e})=>p_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:$u})});import{getNonDeletedElements as u_}from"@excalidraw/element";import{bindOrUnbindBindingElements as h_}from"@excalidraw/element";import{getCommonBoundingBox as Uw}from"@excalidraw/element";import{newElementWith as g_}from"@excalidraw/element";import{deepCopyElement as f_}from"@excalidraw/element";import{resizeMultipleElements as E_}from"@excalidraw/element";import{isArrowElement as Ww,isElbowArrow as b_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Vw}from"@excalidraw/element";import{CODES as Yw,KEYS as x_,arrayToMap as y_}from"@excalidraw/common";import{CaptureUpdateAction as Xw}from"@excalidraw/element";var rg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:n0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Vw(Kw(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:Xw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Yw.H}),ig=O({name:"flipVertical",label:"labels.flipVertical",icon:t0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Vw(Kw(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:Xw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Yw.V&&!e[x_.CTRL_OR_CMD]}),Kw=(e,n,t,o,r)=>{let i=ce(u_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=w_(i,n,o,r),s=y_(a);return e.map(l=>s.get(l.id)||l)},w_=(e,n,t,o)=>{if(e.every(p=>Ww(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return g_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Uw(e);E_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,f_(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),h_(e.filter(Ww),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>b_(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=Uw(e),[d,m]=[r-l,i-c];return s.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),e};import{isTextElement as v_}from"@excalidraw/element";import{getTextFromElements as I_}from"@excalidraw/element";import{CODES as T_,KEYS as $w,isFirefox as S_}from"@excalidraw/common";import{CaptureUpdateAction as qt}from"@excalidraw/element";var sa=O({name:"copy",label:"labels.copy",icon:xs,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Ud(r,o.files,t)}catch(i){return{captureUpdate:qt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:qt.EVENTUALLY}},keyTest:void 0}),ag=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await gw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),S_?{captureUpdate:qt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(uw({types:r}))}catch(i){return console.error(i),{captureUpdate:qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:qt.EVENTUALLY}},keyTest:void 0}),tm=O({name:"cut",label:"labels.cut",icon:W1,trackEvent:{category:"element"},perform:(e,n,t,o)=>(sa.perform(e,n,t,o),Cs.perform(e,n,null,o)),keyTest:e=>e[$w.CTRL_OR_CMD]&&e.key===$w.X}),C_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:o0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:qt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Vr(e,n,!0);try{await Yr("clipboard-svg",r,n,o.files,{...n,exportingFrame:i,name:o.getName()});let a=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:qt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:qt.EVENTUALLY}}},predicate:e=>Hd&&e.length>0,keywords:["svg","clipboard","copy"]}),P_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:r0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:qt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Vr(e,n,!0);try{return await Yr("clipboard",i,n,o.files,{...n,exportingFrame:a,name:o.getName()}),{appState:{...n,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:qt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:qt.EVENTUALLY}}},predicate:e=>or&&e.length>0,keyTest:e=>e.code===T_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),k_=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{vo(I_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:qt.EVENTUALLY}},predicate:(e,n,t,o)=>Hd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(v_),keywords:["text","clipboard","copy"]});import{CODES as M_,KEYS as A_}from"@excalidraw/common";import{CaptureUpdateAction as D_}from"@excalidraw/element";var la=O({name:"gridMode",icon:a0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,n){return{appState:{...n,gridModeEnabled:!this.checked(n),objectsSnapModeEnabled:!1},captureUpdate:D_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[A_.CTRL_OR_CMD]&&e.code===M_.QUOTE});import{KEYS as nm}from"@excalidraw/common";import{CaptureUpdateAction as L_}from"@excalidraw/element/store";import{jsx as __}from"react/jsx-runtime";var el=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:Zu,viewMode:!0,perform:(e,n,t,o)=>{let r=aa(n,o.props.editorPreferences).smartZoom,i=ce(e,n);return o.viewport.setViewport({target:i.length?i:e,fit:r.fitToViewport?"contain":"none",animation:r.animate?{duration:r.duration}:!1,offsets:r.respectUIElements?{ui:!0}:void 0,viewportZoomFactor:r.viewportZoomFactor}),{captureUpdate:L_.NEVER}},keyTest:e=>!e[nm.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===nm.F,PanelComponent:({data:e,updateData:n})=>__($,{type:"button",icon:Zu,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${nm.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:nm.F.toLocaleUpperCase()})});import{CODES as R_,KEYS as N_}from"@excalidraw/common";import{CaptureUpdateAction as B_}from"@excalidraw/element";var Dt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Yo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:B_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[N_.CTRL_OR_CMD]&&e.altKey&&e.code===R_.S});import{CaptureUpdateAction as F_}from"@excalidraw/element";var tl=O({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,n){let t=n.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...n,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:F_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as O_}from"@excalidraw/element";var nl=O({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,n){return{appState:{...n,isMidpointSnappingEnabled:!this.checked(n)},captureUpdate:O_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as z_,KEYS as G_}from"@excalidraw/common";import{CaptureUpdateAction as H_}from"@excalidraw/element";var ar=O({name:"stats",label:"stats.fullTitle",icon:e0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:H_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[G_.CTRL_OR_CMD]&&e.altKey&&e.code===z_.SLASH});import{BOUND_TEXT_PADDING as Zw,ROUNDNESS as jw,TEXT_ALIGN as Qw,VERTICAL_ALIGN as ev,arrayToMap as tv,getFontString as U_,getStrokeWidthByKey as W_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as V_,isBoundToContainer as qw,resetOriginalContainerCache as Y_,updateOriginalContainerCache as X_}from"@excalidraw/element";import{computeBoundTextPosition as K_,computeContainerDimensionForBoundText as Jw,getBoundTextElement as nv,redrawTextBoundingBox as ov}from"@excalidraw/element";import{hasBoundTextElement as $_,isArrowElement as Z_,isTextBindableContainer as sg,isTextElement as ol,isUsingAdaptiveRadius as j_}from"@excalidraw/element";import{measureText as q_}from"@excalidraw/element";import{syncMovedIndices as rv}from"@excalidraw/element";import{newElement as J_}from"@excalidraw/element";import{CaptureUpdateAction as lg}from"@excalidraw/element";var cg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>$_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=nv(a,i);if(s){let{width:l,height:c}=q_(s.originalText,U_(s),s.lineHeight),d=V_(a.id);Y_(a.id);let{x:m,y:p}=K_(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:n,captureUpdate:lg.IMMEDIATELY}}}),dg=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);if(r.length===2){let i=ol(r[0])||ol(r[1]),a;if(sg(r[0])?a=r[0]:sg(r[1])&&(a=r[1]),i&&a&&nv(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;ol(r[0])&&sg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:ev.MIDDLE,textAlign:Qw.CENTER,autoResize:!0,angle:Z_(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return ov(i,a,o.scene),X_(a.id,s),{elements:Q_(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:lg.IMMEDIATELY}}}),Q_=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===t.id);o.splice(r,1);let i=o.findIndex(a=>a.id===n.id);return o.splice(i+1,0,t),rv(o,tv([n,t])),o},eR=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===n.id);o.splice(r,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i,0,n),rv(o,tv([n,t])),o},iv=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>ol(a)&&!qw(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let s of r)if(ol(s)&&!qw(s)){let l=J_({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:W_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:j_("rectangle")?jw.ADAPTIVE_RADIUS:jw.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-Zw,y:s.y-Zw,width:Jw(s.width,"rectangle"),height:Jw(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===s.id&&(p={...p,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(p||u)&&o.scene.mutateElement(m,{startBinding:p,endBinding:u})})}o.scene.mutateElement(s,{containerId:l.id,verticalAlign:ev.MIDDLE,boundElements:null,textAlign:Qw.CENTER,autoResize:!0}),ov(s,l,o.scene),i=eR([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:lg.IMMEDIATELY}}});import{getNonDeletedElements as gv,isEmbeddableElement as ER}from"@excalidraw/element";import{KEYS as fv}from"@excalidraw/common";import{CaptureUpdateAction as bR}from"@excalidraw/element";import{pointFrom as cv}from"@excalidraw/math";import tR from"clsx";import{useCallback as av,useEffect as sv,useLayoutEffect as nR,useRef as oR,useState as rR}from"react";import{EVENT as mg,HYPERLINK_TOOLTIP_DELAY as iR,KEYS as om}from"@excalidraw/common";import{getElementAbsoluteCoords as fg}from"@excalidraw/element";import{hitElementBoundingBox as aR}from"@excalidraw/element";import{isElementLink as sR}from"@excalidraw/element";import{getEmbedLink as lR,embeddableURLValidator as cR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as dv,viewportCoordsToSceneCoords as dR,wrapEvent as mR,isLocalLink as pR,normalizeLink as pg}from"@excalidraw/common";import{isEmbeddableElement as ug}from"@excalidraw/element";import{jsx as ca,jsxs as lv}from"react/jsx-runtime";var Eg=380,uR=42,hg=5,mv=85,hR=500,gg=!1,rm=new Map,pv=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Qn(),l=kn(),c=Ee(),d=e.link||"",[m,p]=rR(d),u=oR(null),E=s.showHyperlinkPopup==="editor",g=av(()=>{if(!u.current)return;let I=pg(u.current.value)||null;if(!e.link&&I&&Be("hyperlink","create"),ug(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!cR(I,l.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&rm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:C}=e,P=lR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let A=P?P.intrinsicSize.w/P.intrinsicSize.h:1,D=rm.get(e.id)!==e.link;n.mutateElement(e,{...D?{width:P?.type==="video"?T>C?T:C*A:T,height:P?.type==="video"&&T>C?T/A:C}:{},link:I}),i(e,!0),rm.has(e.id)&&rm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);nR(()=>()=>{g()},[g]),sv(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),sv(()=>{let I=null,T=C=>{if(E)return;I&&clearTimeout(I),fR(e,a,s,cv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},hR))};return window.addEventListener(mg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(mg.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[s,e,E,t,a]);let b=av(()=>{Be("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),y=()=>{Be("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y:x}=uv(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:lv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${w}px`,width:Eg,padding:hg},children:[E?ca("input",{className:tR("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:I=>p(I.target.value),autoFocus:!0,onKeyDown:I=>{I.stopPropagation(),I[om.CTRL_OR_CMD]&&I.key===om.K&&I.preventDefault(),(I.key===om.ENTER||I.key===om.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ca("a",{href:pg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:pR(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=mR(mg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:pg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ca("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),lv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&ca($,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:$n}),ca($,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:d0}),d&&!ug(e)&&ca($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Rr})]})]})},uv=(e,n,t)=>{let[o,r]=fg(e,t),{x:i,y:a}=dv({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-Eg/2,l=a-n.offsetTop-mv;return{x:s,y:l}},bg=(e,n)=>{let t=ce(e,n);return ug(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},rl=null,hv=(e,n,t)=>{rl&&clearTimeout(rl),rl=window.setTimeout(()=>gR(e,n,t),iR)},gR=(e,n,t)=>{if(!e.link)return;let o=Xi();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=sR(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=fg(e,t),[l,c,d,m]=ax([r,i,a,s],e.angle,n),p=dv({sceneX:l,sceneY:c},n);Nh(o,{left:p.x,top:p.y,width:d,height:m},"top"),Be("hyperlink","tooltip","link-icon"),gg=!0},im=()=>{rl&&clearTimeout(rl),gg&&(gg=!1,Xi().classList.remove("excalidraw-tooltip--visible"))},fR=(e,n,t,[o,r])=>{let{x:i,y:a}=dR({clientX:o,clientY:r},t),s=15/t.zoom.value;if(aR(cv(i,a),e,n))return!1;let[l,c,d]=fg(e,n);if(i>=l&&i<=d&&a>=c-mv&&a<=c)return!1;let{x:m,y:p}=uv(e,t,n);return!(o>=m-s&&o<=m+Eg+hg*2+s&&r>=p-s&&r<=p+s+hg*2+uR)};import{jsx as xR}from"react/jsx-runtime";var xg=O({name:"hyperlink",label:(e,n)=>bg(gv(e),n),icon:Is,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:bR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[fv.CTRL_OR_CMD]&&e.key===fv.K,predicate:(e,n)=>ce(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=ce(e,n);return xR($,{type:"toggle",icon:Is,"aria-label":f(bg(gv(e),n)),title:`${ER(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onSelect:()=>t(null),checked:o.length===1&&!!o[0].link})}});import{KEYS as Ev,arrayToMap as wg,randomId as yR}from"@excalidraw/common";import{elementsAreInSameGroup as wR,getNonDeletedElements as bv,newElementWith as xv,selectGroupsFromGivenElements as yv}from"@excalidraw/element";import{CaptureUpdateAction as wv}from"@excalidraw/element";var yg=e=>e.every(n=>!n.locked),il=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return yg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=ce(n,e);return yg(t)?Uo:fo},trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=yg(r),a=wg(r),s=r.length>1&&wR(r),c=r.length===1||s?null:yR(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let y=r[0].groupIds.at(-1);delete d[y]}let m=e.map(y=>{if(!a.has(y.id))return y;let w=y.groupIds;return i?c&&(w=[...w,c]):w=w.filter(x=>!n.lockedMultiSelections[x]),xv(y,{locked:i,groupIds:w.length!==y.groupIds.length?w:y.groupIds})}),p=wg(m),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),E=r.map(y=>p.get(y.id)||y),g=i?{}:yv(bv(E),n),b=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:d,activeLockedId:b},captureUpdate:wv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===Ev.L&&e[Ev.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),vv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:fo,predicate:(e,n)=>ce(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(s=>s.locked),o=e.map(s=>{if(s.locked){let l=s.groupIds.filter(c=>!n.lockedMultiSelections[c]);return xv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=wg(o),i=t.map(s=>r.get(s.id)||s),a=bv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:yv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:wv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as _8,isLinearElement as R8,isLineElement as Ea}from"@excalidraw/element";import{arrayToMap as N8,invariant as i2}from"@excalidraw/common";import{toggleLinePolygonState as B8,CaptureUpdateAction as a2}from"@excalidraw/element";import{getSizeFromPoints as CTe,randomInteger as D8,getUpdatedTimestamp as L8}from"@excalidraw/common";import{simplify as m8}from"points-on-curve";import{getStroke as p8,getStrokePoints as sTe}from"perfect-freehand";function $e([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function da([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function tt([e,n,t],o){return[e*o,n*o,t*o]}function jr([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function xt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function Iv(e,n,t){return $e(e,tt(da(n,e),t))}function vg(e,n,t){return Math.atan2(t[1]-e[1],t[0]-e[0])-Math.atan2(n[1]-e[1],n[0]-e[0])}function Ig(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Tg([e,n]){return Math.sqrt(e**2+n**2)}function Zr([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function Tv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Zr(e[t-1],e[t]);return n+=Zr(e[e.length-2],e[e.length-1]),n}var vR=(e,n,t)=>Math.max(n,Math.min(t,e));function Sv(e,n,t){let o=Zr(n,t);if(o===0)return Zr(e,n);let r=vR(((e[0]-n[0])*(t[0]-n[0])+(e[1]-n[1])*(t[1]-n[1]))/o**2,0,1),i=[n[0]+r*(t[0]-n[0]),n[1]+r*(t[1]-n[1]),e[2]];return Zr(i,e)}function al(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,s],l,c)=>{let d=Sv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...al([t,...e.slice(1,i),a],n).slice(0,-1),a,...al([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var sr=class sr{constructor(n){v(this,"options");v(this,"originalPoints",[]);v(this,"stablePoints",[]);v(this,"tailPoints",[]);v(this,"isFresh",!0);this.options=Object.assign({},sr.defaults,n)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(n){let t=this.originalPoints[this.originalPoints.length-1];if(!(t&&t[0]===n[0]&&t[1]===n[1])){if(this.originalPoints.push(n),this.isFresh){this.isFresh=!1,this.stablePoints.push(n);return}this.options.streamline>0&&(n=Iv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),Tv(this.tailPoints)>sr.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase==="tail")throw new Error("Not implemented yet");this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(n,t,o,r,i){return(n??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:o,totalLength:r})}getStrokeOutline(n){if(this.isFresh)return[];let t=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase==="input"&&(t=al(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let P=t[0],A=this.getSize(n,P[2],0,o,0);if(A<.5)return[];let D=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)D.push($e(P,tt(xt([1,0,0],_),A)));return D.push($e(P,tt([1,0,0],this.getSize(n,P[2],0,o,0)))),D}if(o===2){let P=t[0],A=t[1],D=this.getSize(n,P[2],0,o,0),_=this.getSize(n,A[2],0,o,0);if(D<.5||_<.5)return[];let k=[],L=vg(P,[P[0],P[1]-100,P[2]],A);for(let B=L;B<=Math.PI+L;B+=Math.PI/16)k.push($e(P,tt(xt([1,0,0],B),D)));for(let B=Math.PI+L;B<=Math.PI*2+L;B+=Math.PI/16)k.push($e(A,tt(xt([1,0,0],B),_)));return k.push(k[0]),k}let r=[],i=[],a=0,s=0,l=0,c=0;for(let P=1;P<o-1;P++){let A=t[P-1],D=t[P],_=t[P+1],k=D[2],L=Zr(A,D);c+=L,a=s+(L-s)*.2;let B=this.getSize(n,k,P,o,c);if(B===0){l=P+1;continue}let V=jr(da(A,D)),z=jr(da(_,D)),U=xt(V,Math.PI/2),K=xt(V,-Math.PI/2),G=xt(z,Math.PI/2),te=xt(z,-Math.PI/2),F=$e(D,tt(U,B)),W=$e(D,tt(K,B)),le=$e(D,tt(G,B)),we=$e(D,tt(te,B)),de=$e(U,te),he=$e(K,G),ve=$e(D,tt(Tg(de)===0?V:jr(de),B)),ae=$e(D,tt(Tg(he)===0?z:jr(he),B)),fe=Ig(vg(D,A,_)),rt=sr.constants.cornerDetectionMaxAngle/180*Math.PI*sr.constants.cornerDetectionVariance(a);if(Math.abs(fe)<rt){let Ge=Math.abs(Ig(Math.PI-fe));if(Ge===0)continue;if(fe<0){i.push(W,ae);for(let Pe=0;Pe<=Ge;Pe+=Ge/4)r.push($e(D,xt(tt(U,B),Pe)));for(let Pe=Ge;Pe>=0;Pe-=Ge/4)i.push($e(D,xt(tt(U,B),Pe)));i.push(ae,le)}else{r.push(F,ve);for(let Pe=0;Pe<=Ge;Pe+=Ge/4)i.push($e(D,xt(tt(U,-B),-Pe)));for(let Pe=Ge;Pe>=0;Pe-=Ge/4)r.push($e(D,xt(tt(U,-B),-Pe)));r.push(ve,we)}}else r.push(ve),i.push(ae);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],A=[];for(let D=0;D<=Math.PI*2;D+=Math.PI/16)A.push($e(P,tt(xt([1,0,0],D),this.options.size)));return A.push($e(P,tt([1,0,0],this.options.size))),A}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=jr(da(m,d)),g=jr(da(p,u)),b=xt(E,-Math.PI/2),y=xt(g,Math.PI/2),w=this.getSize(n,d[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(w>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift($e(d,xt(tt(b,w),-P)));x.unshift($e(d,tt(b,-w)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push($e(u,xt(tt(y,-I),-P)));let C=[...x,...r,...T.reverse(),...i.reverse()];return x.length>0&&C.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?al(C,this.options.simplify):C}};v(sr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),v(sr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var ma=sr;import{pointsOnBezierCurves as ode}from"points-on-curve";import{invariant as ide}from"@excalidraw/common";import{curve as sde,lineSegment as lde,pointFrom as cde,pointDistance as dde,pointFromArray as mde,pointFromVector as pde,pointRotateRads as ude,polygon as hde,polygonFromPoints as gde,PRECISION as fde,segmentsIntersectAt as Ede,vector as bde,vectorAdd as xde,vectorFromPoint as yde,vectorScale as wde}from"@excalidraw/math";import{getElementAbsoluteCoords as Ide}from"@excalidraw/element";var Sg=e=>{if(!e)return[];for(let n of e.sets)if(n.type==="path")return n.ops;return e.sets[0].ops};import{pointFrom as u8,pointDistance as Qv,pointRotateRads as mTe}from"@excalidraw/math";import{ROUGHNESS as h8,THEME as Vg,isTransparent as xl,assertNever as g8,COLOR_PALETTE as f8,LINE_POLYGON_POINT_MERGE_DISTANCE as uTe,applyDarkModeFilter as yl,DEFAULT_STROKE_STREAMLINE as E8}from"@excalidraw/common";import{RoughGenerator as b8}from"roughjs/bin/generator";import bIe from"roughjs/bin/rough";import{isRightAngleRads as yIe,lineSegment as wIe,pointFrom as vIe,pointRotateRads as IIe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as SIe,DEFAULT_REDUCED_GLOBAL_ALPHA as CIe,ELEMENT_READY_TO_ERASE_OPACITY as PIe,FRAME_STYLE as kIe,DARK_THEME_FILTER as MIe,MIME_TYPES as Jv,THEME as AIe,distance as DIe,getFontString as LIe,isRTL as _Ie,getVerticalOffset as RIe,invariant as NIe,applyDarkModeFilter as BIe,isSafari as FIe}from"@excalidraw/common";import H2e from"roughjs/bin/rough";import{arrayToMap as W2e,invariant as qv,rescalePoints as V2e,sizeOf as Y2e}from"@excalidraw/common";import{degreesToRadians as Gg,lineSegment as K2e,pointFrom as yt,pointFromArray as r8,pointRotateRads as fa}from"@excalidraw/math";import{pointsOnBezierCurves as j2e}from"points-on-curve";import{pointCenter as i2e,pointFrom as a2e,pointRotateRads as s2e,pointsEqual as l2e,pointDistance as c2e,vectorFromPoint as d2e,curveLength as m2e,curvePointAtLength as p2e}from"@excalidraw/math";import{DRAGGING_THRESHOLD as g2e,KEYS as f2e,shouldRotateWithDiscreteAngle as E2e,getGridPoint as b2e,invariant as x2e,isShallowEqual as y2e,getFeatureFlag as w2e}from"@excalidraw/common";import{arrayToMap as yve,getFeatureFlag as wve,getGridPoint as vve,invariant as Ive,isTransparent as Tve}from"@excalidraw/common";import{PRECISION as Cve,clamp as Pve,lineSegment as kve,pointDistance as Mve,pointDistanceSq as Ave,pointFrom as Dve,pointFromArray as Lve,pointFromVector as _ve,pointRotateRads as Rve,pointsEqual as Nve,vectorFromPoint as Bve,vectorNormalize as Fve,vectorScale as Ove}from"@excalidraw/math";import{invariant as Hwe,isTransparent as Uwe}from"@excalidraw/common";import{curveIntersectLineSegment as Vwe,isPointWithinBounds as Ywe,lineSegment as Xwe,lineSegmentIntersectionPoints as Kwe,pointFrom as $we,pointFromVector as Zwe,pointRotateRads as jwe,pointsEqual as qwe,vectorFromPoint as Jwe,vectorNormalize as Qwe,vectorScale as eve}from"@excalidraw/math";import{ellipse as nve,ellipseSegmentInterceptPoints as ove}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as CR,DEFAULT_PROPORTIONAL_RADIUS as kg,invariant as Rde,LINE_CONFIRM_THRESHOLD as PR,ROUNDNESS as Mg}from"@excalidraw/common";import{bezierEquation as Bde,curve as Fde,curveCatmullRomCubicApproxPoints as Ode,curveOffsetPoints as zde,lineSegment as Gde,lineSegmentIntersectionPoints as Hde,pointDistance as kR,pointFrom as Ude,pointFromArray as Wde,pointFromVector as Vde,pointRotateRads as Yde,pointTranslate as Xde,rectangle as Kde,vectorFromPoint as $de,vectorNormalize as Zde,vectorScale as jde}from"@excalidraw/math";import{ROUNDNESS as Pde,assertNever as kde}from"@excalidraw/common";import{pointsEqual as Ade}from"@excalidraw/math";var Cv=e=>!!e&&e.type==="embeddable",Cg=e=>!!e&&e.type==="iframe",Pg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),mn=e=>e!=null&&e.type==="text";var no=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var pn=e=>e!=null&&TR(e.type);var An=e=>e!=null&&e.type==="arrow",Dn=e=>An(e)&&e.elbowed;var TR=e=>e==="arrow"||e==="line";var Io=e=>e!==null&&"containerId"in e&&e.containerId!==null&&mn(e);var pa=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return kR(t,o)<=PR/n}return!1},sl=(e,n)=>{if(n.roundness?.type===Mg.PROPORTIONAL_RADIUS||n.roundness?.type===Mg.LEGACY)return e*kg;if(n.roundness?.type===Mg.ADAPTIVE_RADIUS){let t=n.roundness?.value??CR,o=t/kg;return e<=o?e*kg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as ywe,ARROW_LABEL_WIDTH_FRACTION as wwe,BOUND_TEXT_PADDING as vwe,DEFAULT_FONT_SIZE as Iwe,TEXT_ALIGN as Twe,VERTICAL_ALIGN as Swe,getFontString as Cwe,isProdEnv as Pwe,invariant as kwe}from"@excalidraw/common";import{pointFrom as Awe,pointRotateRads as Dwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as dme,DEFAULT_FONT_SIZE as mme,DEFAULT_FONT_FAMILY as pme,getFontString as ume,isTestEnv as hme,normalizeEOL as gme}from"@excalidraw/common";var fme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Ime,isTestEnv as Tme}from"@excalidraw/common";import{toIterable as uye}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Mme,viewportCoordsToSceneCoords as Ame}from"@excalidraw/common";import{normalizeRadians as Lme,radiansBetweenAngles as _me,radiansDifference as Rme}from"@excalidraw/math";import{pointsEqual as Bme}from"@excalidraw/math";import{arrayToMap as ype,isShallowEqual as LR}from"@excalidraw/common";import{arrayToMap as epe}from"@excalidraw/common";import{isPointWithinBounds as npe,pointFrom as ope,segmentsIntersectAt as rpe}from"@excalidraw/math";import{arrayToMap as Ume}from"@excalidraw/common";import{validateOrderKey as Vme,generateNKeysBetween as Yme}from"@excalidraw/fractional-indexing";var Ag=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var kpe=function(){let e=null,n=null,t=null,o=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===n||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,n=i.selectedElementIds),t);return o.clearCache=()=>{e=null,n=null,t=null},o}(),pl=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){qr(i)?(r.push(i),o.add(i.id)):console.error("[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection");continue}if(t?.includeBoundTextElement&&Io(i)&&qr(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{no(a)&&Ag(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var Lg=(e,n)=>LR(n.selectedElementIds,e)?n.selectedElementIds:e;var _R=function(){let e=null,n=null,t=null,o=(i,a,s,l)=>{if(t!==void 0&&a===n&&i===e&&s.editingGroupId===t?.editingGroupId)return t;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let E=u.indexOf(s.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];c[E]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>c[g]);return E&&(p[u.id]=!0,Array.isArray(d[E])?d[E].push(u.id):d[E]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Lg({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):pl(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Lg(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Xpe=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as Uue,VERTICAL_ALIGN as Wue}from"@excalidraw/common";import{pointDistance as Yue,pointFromVector as Xue,pointsEqual as Kue,vector as $ue,vectorDot as Zue,vectorFromPoint as jue,vectorNormalize as que,vectorScale as Jue}from"@excalidraw/math";import{invariant as rue,isDevEnv as iue,isTestEnv as aue}from"@excalidraw/common";import{pointFrom as lue,pointFromVector as cue,pointRotateRads as due,pointScaleFromOrigin as mue,pointsEqual as pue,triangleIncludesPoint as uue,vectorCross as hue,vectorFromPoint as BR,vectorScale as gue}from"@excalidraw/math";var gl=[1,0],dm=[0,1],fl=[-1,0],mm=[0,-1],pm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?gl:n<=-r?fl:t>o?dm:mm},Nv=(e,n)=>pm(BR(e,n)),um=(e,n)=>hm(Nv(e,n)),hl=(e,n)=>e[0]===n[0]&&e[1]===n[1],hm=e=>hl(e,gl)||hl(e,fl);import{DEFAULT_ELEMENT_PROPS as yue,DEFAULT_FONT_FAMILY as wue,DEFAULT_FONT_SIZE as vue,DEFAULT_TEXT_ALIGN as Iue,DEFAULT_VERTICAL_ALIGN as Tue,DEFAULT_STROKE_STREAMLINE as Sue,VERTICAL_ALIGN as Cue,randomInteger as Pue,randomId as kue,getFontString as Mue,getUpdatedTimestamp as Aue,getLineHeight as Due}from"@excalidraw/common";import{pointsOnBezierCurves as whe,simplify as vhe}from"points-on-curve";import{curveToBezier as The}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Che,lineSegment as Phe,lineSegmentIntersectionPoints as khe,pointDistance as Mhe,pointFrom as Ahe,pointRotateRads as Dhe,polygonArea as Lhe,polygonIncludesPoint as _he,polygonIncludesPointNonZero as Rhe,polygonSignedArea as Nhe}from"@excalidraw/math";import{isOpaqueColor as Fhe,isTransparent as Ohe}from"@excalidraw/common";var zv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as che,distanceToLineSegment as dhe,pointRotateRads as mhe}from"@excalidraw/math";import{ellipse as uhe,ellipseDistanceFromPoint as hhe}from"@excalidraw/math/ellipse";import{pointFrom as Jhe,pointCenter as Qhe,pointRotateRads as ege,vectorFromPoint as tge,vectorNormalize as nge,vectorSubtract as oge,vectorAdd as rge,vectorScale as ige,pointFromVector as age,clamp as sge,isCloseTo as lge}from"@excalidraw/math";import{arrayToMap as Ffe,arrayToObject as Ofe,assertNever as zfe,isDevEnv as Gfe,isShallowEqual as Hfe,isTestEnv as Ufe,randomInteger as Wfe}from"@excalidraw/common";import{assertNever as Vge,COLOR_PALETTE as Yge,isDevEnv as Xge,isTestEnv as Kge,randomId as $ge,Emitter as Zge,toIterable as jge}from"@excalidraw/common";import{ORIG_ID as wge,randomId as vge,randomInteger as Ige,arrayToMap as Tge,castArray as Sge,findLastIndex as Cge,getUpdatedTimestamp as Pge,isTestEnv as kge}from"@excalidraw/common";import{arrayToMap as uge}from"@excalidraw/common";import zR from"lodash.throttle";import{randomInteger as mfe,arrayToMap as pfe,toBrandedType as ufe,isDevEnv as Uv,isTestEnv as Wv,toArray as hfe}from"@excalidraw/common";import{isNonDeletedElement as ffe}from"@excalidraw/element";import{isFrameLikeElement as bfe}from"@excalidraw/element";import{getElementsInGroup as yfe}from"@excalidraw/element";import{syncInvalidIndices as vfe,syncMovedIndices as Ife,validateFractionalIndices as GR}from"@excalidraw/element";import{getSelectedElements as Sfe}from"@excalidraw/element";import{mutateElement as Pfe}from"@excalidraw/element";var kfe=zR(e=>{(Uv()||Wv()||window?.DEBUG_FRACTIONAL_INDICES)&&GR(e,{shouldThrow:Uv()||Wv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as hEe,getGridPoint as gEe,getFontString as fEe,DRAGGING_THRESHOLD as EEe}from"@excalidraw/common";import{clamp as kEe,pointDistance as MEe,pointFrom as AEe,pointScaleFromOrigin as DEe,pointsEqual as LEe,pointTranslate as _Ee,vector as REe,vectorCross as NEe,vectorFromPoint as BEe,vectorScale as FEe}from"@excalidraw/math";import{BinaryHeap as zEe,invariant as GEe,isAnyTrue as HEe,getSizeFromPoints as UEe,isDevEnv as WEe,arrayToMap as VEe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as rbe,normalizeLink as ibe}from"@excalidraw/common";import{FONT_FAMILY as dbe,VERTICAL_ALIGN as mbe,escapeDoubleQuotes as pbe,getFontString as ube}from"@excalidraw/common";import{invariant as vbe,toBrandedType as Ibe}from"@excalidraw/common";import{clamp as Sbe,pointFrom as Cbe}from"@excalidraw/math";import{pointDistance as txe,pointFrom as nxe}from"@excalidraw/math";import{invariant as rxe}from"@excalidraw/common";import{arrayToMap as Gbe,findIndex as Hbe,findLastIndex as Ube}from"@excalidraw/common";import{isFiniteNumber as Vbe}from"@excalidraw/math";import{decode as hxe,decodeFrames as gxe}from"modern-gif";import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as vxe,MIME_TYPES as Ixe,SVG_NS as Txe}from"@excalidraw/common";import{rgbaToThumbHash as Cxe,thumbHashToRGBA as Pxe}from"thumbhash";import{pointCenter as Xxe,normalizeRadians as Kxe,pointFrom as $xe,pointRotateRads as Zxe}from"@excalidraw/math";import{MIN_FONT_SIZE as qxe,SHIFT_LOCKING_ANGLE as Jxe,rescalePoints as Qxe,getFontString as e1e}from"@excalidraw/common";import{pointFrom as P1e,pointOnLineSegment as k1e,pointRotateRads as M1e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as D1e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as h1e}from"@excalidraw/common";import{pointFrom as f1e,pointRotateRads as E1e}from"@excalidraw/math";import{KEYS as _n}from"@excalidraw/common";var U1e=[{icon:Lc,value:"selection",key:_n.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Mi,value:"rectangle",key:_n.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ai,value:"diamond",key:_n.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Di,value:"ellipse",key:_n.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:_c,value:"arrow",key:_n.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Wo,value:"line",key:_n.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:$n,value:"freedraw",key:[_n.P,_n.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Pn,value:"text",key:_n.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:_r,value:"image",key:[_n.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Rc,value:"eraser",key:_n.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as e0e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as n0e,DEFAULT_FONT_SIZE as o0e,TEXT_ALIGN as r0e,VERTICAL_ALIGN as i0e,getSizeFromPoints as a0e,randomId as s0e,arrayToMap as l0e,assertNever as c0e,cloneJSON as d0e,getFontString as m0e,isDevEnv as p0e,toBrandedType as u0e,getLineHeight as h0e}from"@excalidraw/common";import{getBoundsFromPoints as F0e,getElementAbsoluteCoords as O0e}from"@excalidraw/element/bounds";import{newArrowElement as G0e,newElement as H0e,newLinearElement as U0e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as V0e,getStrokeWidthByKey as Y0e,ROUNDNESS as X0e}from"@excalidraw/common";import{convexHull as $0e,distanceToLineSegment as Z0e,elongation as j0e,kurtosis as q0e,lineSegment as J0e,orientPrincipalAxes as Q0e,pointFrom as eye,polygonArea as tye,principalAxes as nye,principalCoords as oye,skewness as rye}from"@excalidraw/math";var lye=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}];var qr=e=>!e.isDeleted;var qR=10/1.5;var am=e=>{let n=Math.floor(e.width/2)+1,t=0,o=e.width,r=Math.floor(e.height/2)+1,i=n,a=e.height;return[n,t,o,r,i,a,0,r]};var i8=20,a8=15,s8=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"cardinality_many":case"cardinality_one_or_many":case"cardinality_zero_or_many":return a8;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return i8;default:return 15}},l8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},_t=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Sg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;qv(s.length===6,"Op data length is not 6");let l=yt(s[4],s[5]),c=yt(s[2],s[3]),d=yt(s[0],s[1]),m=i[a-1],p=yt(0,0);if(m.op==="move"){let G=r8(m.data);qv(G!=null,"Op data is not a point"),p=G}else m.op==="bcurveTo"&&(p=yt(m.data[4],m.data[5]));let u=(G,te)=>Math.pow(1-G,3)*l[te]+3*G*Math.pow(1-G,2)*c[te]+3*Math.pow(G,2)*(1-G)*d[te]+p[te]*Math.pow(G,3),[E,g]=t==="start"?p:l,[b,y]=[u(.3,0),u(.3,1)],w=Math.hypot(E-b,g-y),x=(E-b)/w,I=(g-y)/w,T=s8(o),C=0;{let[G,te]=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(G-F,te-W)}let A=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),D=E-x*A*r,_=g-I*A*r,k=D-x*A,L=_-I*A;if(o==="circle"||o==="circle_outline"){let G=Math.hypot(L-_,k-D)+e.strokeWidth-2;return[D,_,G]}let B=l8(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,te]=fa(yt(D,_),yt(k,L),Gg(-B)),[F,W]=fa(yt(D,_),yt(k,L),Gg(B));return[k,L,G,te,F,W]}let[V,z]=fa(yt(k,L),yt(D,_),-B*Math.PI/180),[U,K]=fa(yt(k,L),yt(D,_),Gg(B));if(o==="diamond"||o==="diamond_outline"){let G,te;if(t==="start"){let[F,W]=e.points.length>1?e.points[1]:[0,0];[G,te]=fa(yt(D+A*2,_),yt(D,_),Math.atan2(W-_,F-D))}else{let[F,W]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,te]=fa(yt(D-A*2,_),yt(D,_),Math.atan2(_-W,D-F))}return[D,_,V,z,G,te,U,K]}return[D,_,V,z,U,K]};var c8=typeof document<"u"?document.createElement("img"):{src:""};c8.src=`data:${Jv.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 d8=typeof document<"u"?document.createElement("img"):{src:""};d8.src=`data:${Jv.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 Hg=new WeakMap;var Ut=class Ut{};v(Ut,"rg",new b8),v(Ut,"cache",new WeakMap),v(Ut,"get",(n,t)=>{let o=Ut.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),v(Ut,"delete",n=>{Ut.cache.delete(n),Hg.delete(n)}),v(Ut,"destroy",()=>{Ut.cache=new WeakMap}),v(Ut,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Ut.get(n,t?t.theme:null);if(o!==void 0)return o;Hg.delete(n);let r=w8(n,Ut.rg,t||{isExporting:!1,canvasBackgroundColor:f8.white,embedsValidationStatus:null,theme:Vg.LIGHT});return t?.isExporting||Ut.cache.set(n,{shape:r,theme:t?.theme||Vg.LIGHT}),r});var ga=Ut,x8=e=>[8,8+e],o2=e=>[1.5,6+e];function y8(e){let n=e.roughness,t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&t>=50||o>=15&&e.roundness&&zv(e.type)||pn(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var So=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?x8(e.strokeWidth):e.strokeStyle==="dotted"?o2(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:y8(e),stroke:yl(e.strokeColor,t),preserveVertices:n||e.roughness<h8.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=xl(e.backgroundColor)?void 0:yl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return pa(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:yl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},e2=(e,n,t)=>Pg(e)&&(n||Cv(e)&&t?.get(e.id)!==!0)&&xl(e.backgroundColor)&&xl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Cg(e)?{...e,strokeColor:xl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:xl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,bl=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},fm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},Qr=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=o2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Ug=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,s,l]=o,c={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete c.strokeLineDash,[e.circle(a,s,l*i,c)]},t2=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=yl(e.strokeColor,s),c=yl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return Ug(r,i,l,_t(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=_t(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w]=p,x={...i,fill:o==="triangle_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete x.strokeLineDash,[r.polygon([[u,E],[g,b],[y,w],[u,E]],x)]}case"diamond":case"diamond_outline":{let p=_t(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w,x,I]=p,T={...i,fill:o==="diamond_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete T.strokeLineDash,[r.polygon([[u,E],[g,b],[y,w],[x,I],[u,E]],T)]}case"cardinality_one":return bl(r,_t(e,n,t,o),Qr(e,i));case"cardinality_many":return fm(r,_t(e,n,t,o),Qr(e,i));case"cardinality_one_or_many":{let p=Qr(e,i);return[...fm(r,_t(e,n,t,"cardinality_many"),p),...bl(r,_t(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=Qr(e,i);return[...bl(r,_t(e,n,t,"cardinality_one",-.5),p),...bl(r,_t(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=Qr(e,i);return[...Ug(r,i,l,_t(e,n,t,"circle_outline",1.5),c,m),...bl(r,_t(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=Qr(e,i);return[...fm(r,_t(e,n,t,"cardinality_many"),p),...Ug(r,i,l,_t(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return fm(r,_t(e,n,t,o),Qr(e,i))}};var w8=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===Vg.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=sl(Math.min(l,c),e);s=n.path(`M ${d} 0 L ${l-d} 0 Q ${l} 0, ${l} ${d} L ${l} ${c-d} Q ${l} ${c}, ${l-d} ${c} L ${d} ${c} Q 0 ${c}, 0 ${c-d} L 0 ${d} Q 0 0, ${d} 0`,So(e2(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,So(e2(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=am(e);if(e.roundness){let b=sl(Math.abs(l-E),e),y=sl(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+y} L ${d-b} ${m-y}
|
|
5
5
|
C ${d} ${m}, ${d} ${m}, ${d-b} ${m+y}
|
|
6
6
|
L ${p+b} ${u-y}
|
|
7
7
|
C ${p} ${u}, ${p} ${u}, ${p-b} ${u-y}
|
|
8
8
|
L ${E+b} ${g+y}
|
|
9
9
|
C ${E} ${g}, ${E} ${g}, ${E+b} ${g-y}
|
|
10
10
|
L ${l-b} ${c+y}
|
|
11
|
-
C ${l} ${c}, ${l} ${c}, ${l+b} ${c+y}`,fo(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],fo(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,fo(e,!1,a));case"line":case"arrow":{let s,l=fo(e,!1,a),c=e.points.length?e.points:[YR(0,0)];if(Tn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(e8(c,16),fo(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),s=[]):e.roundness?s=[n.curve(c,l)]:l.fill?s=[n.polygon(c,l)]:s=[n.linearPath(c,l)],e.type==="arrow"){let{startArrowhead:d=null,endArrowhead:m="arrow"}=e;if(d!==null){let p=Wv(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=Wv(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(ea(e.points)){let l=WR(e.points,.75);s.push(n.curve(l,{...fo(e,!1,a),stroke:"none"}))}return s.push(t8(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return KR(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},e8=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],s=e[r],l=sm(s,i),c=sm(a,s),d=Math.min(n,Gv(e[r],a)/2,Gv(e[r],i)/2);l?i[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),c?a[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)o.push(`L ${t[r][0]} ${t[r][1]}`),o.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")};var t8=e=>l8(a8(e)),Bg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},n8={SIZE_FACTOR:1.4},Xv=e=>e.strokeOptions?.streamline??$R,o8=e=>{let n=e.simulatePressure?e.points:e.points.length?e.points.map(([t,o],r)=>[t,o,e.pressures[r]]):[[0,0,.5]];return VR(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Bg.SIZE_FACTOR,thinning:Bg.THINNING,smoothing:Bg.SMOOTHING,streamline:Xv(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},r8=e=>new Qi({size:e.strokeWidth*n8.SIZE_FACTOR,streamline:Xv(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),i8=e=>{let n=r8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},a8=e=>e.strokeOptions?.variability==="constant"?i8(e):o8(e);var Vv=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],s8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,l8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,Vv(o,i[0]),"L",i[0],"Z"):t.push(o,Vv(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(s8,"$1")};var Yr=(e,n,t=!1)=>{let o=!1;for(let r in n){let i=n[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!t?e:{...e,...n,version:n.version??e.version+1,versionNonce:n.versionNonce??c8(),updated:d8()}};import{jsx as $v}from"react/jsx-runtime";var aa=F({name:"toggleLinearEditor",label:(e,n,t)=>t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.selectedLinearElement?.isEditing&&r.length===1&&p8(r[0])&&!m8(r[0]))},perform(e,n,t,o){Kv(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);Kv(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:Zv.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!o)return null;let r=f(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return $v(K,{type:"button",icon:Z1,title:r,"aria-label":r,onClick:()=>n(null)})}}),VIe=F({name:"togglePolygon",icon:fu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!ia(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds});return r.length>0&&r.every(i=>ia(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!ia(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=u8(i);return{elements:e.map(l=>!s.has(l.id)||!ia(l)?l:Yr(l,{backgroundColor:a?l.backgroundColor:"transparent",...h8(l,a)})),appState:n,captureUpdate:Zv.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!ia(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>ia(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return $v(K,{type:"toggle",icon:fu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as jv,CANVAS_SEARCH_TAB as qv,CLASSES as g8,DEFAULT_SIDEBAR as Jv}from"@excalidraw/common";import{CaptureUpdateAction as f8}from"@excalidraw/element";var ul=F({name:"searchMenu",icon:Yn,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,n,t,o){if(n.openDialog)return!1;if(n.openSidebar?.name===Jv.name&&n.openSidebar.tab===qv){let r=o.excalidrawContainerValue.container?.querySelector(`.${g8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:Jv.name,tab:qv},openDialog:null},captureUpdate:f8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[jv.CTRL_OR_CMD]&&e.key===jv.F});import{isImageElement as E8}from"@excalidraw/element";import{CaptureUpdateAction as b8}from"@excalidraw/element";import{jsx as x8}from"react/jsx-runtime";var Fg=F({name:"cropEditor",label:"helpDialog.cropStart",icon:Hu,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,n,t,o){let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...n,isCropping:!1,croppingElementId:r.id},captureUpdate:b8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&E8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return x8(K,{type:"button",icon:Hu,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as w8}from"@excalidraw/element";import{mutateElement as y8}from"@excalidraw/element";import{newFrameElement as v8}from"@excalidraw/element";import{isFrameLikeElement as mm}from"@excalidraw/element";import{addElementsToFrame as I8,removeAllElementsFromFrame as T8}from"@excalidraw/element";import{getFrameChildren as S8}from"@excalidraw/element";import{getElementsInGroup as C8}from"@excalidraw/element";import{getCommonBounds as P8}from"@excalidraw/element";import{CaptureUpdateAction as sa}from"@excalidraw/element";var Qv=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&mm(t[0])},e2=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(mm(r)){let i=S8(w8(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},captureUpdate:sa.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:sa.EVENTUALLY}},predicate:(e,n,t,o)=>Qv(n,o)}),t2=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return mm(r)?{elements:T8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:sa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:sa.EVENTUALLY}},predicate:(e,n,t,o)=>Qv(n,o)}),QTe=F({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>({elements:e,appState:{...n,frameRendering:{...n.frameRendering,enabled:!n.frameRendering.enabled}},captureUpdate:sa.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),n2=F({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=se(e,n);return r.length>0&&!r.some(i=>mm(i))},perform:(e,n,t,o)=>{let r=se(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=P8(r,i),d=16,m=v8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=C8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);y8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:I8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:sa.IMMEDIATELY}}});import{KEYS as ca,matchKey as Gg,arrayToMap as o2,MOBILE_ACTION_BUTTON_BG as r2}from"@excalidraw/common";import{CaptureUpdateAction as Hg}from"@excalidraw/element";import{orderByFractionalIndex as R8}from"@excalidraw/element";import{Emitter as k8}from"@excalidraw/common";import{CaptureUpdateAction as M8,StoreChange as A8,StoreDelta as L8}from"@excalidraw/element";var la=class extends L8{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,s]=this.appState.applyTo(t,r);return[r,a,i||s]}static calculate(n,t){return super.calculate(n,t)}static inverse(n){return super.inverse(n)}static applyLatestChanges(n,t,o,r){return super.applyLatestChanges(n,t,o,r)}},Kr=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},hl=class e{constructor(n){this.store=n;I(this,"onHistoryChangedEmitter",new k8);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(n){if(n.isEmpty()||n instanceof la)return;let t=la.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Kr(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(n,t){return this.perform(n,t,()=>e.pop(this.undoStack),o=>e.push(this.redoStack,o))}redo(n,t){return this.perform(n,t,()=>e.pop(this.redoStack),o=>e.push(this.undoStack,o))}perform(n,t,o,r){try{let i=o();if(i===null)return;let a=M8.IMMEDIATELY,s=this.store.snapshot,l=n,c=t,d=!1;for(;i;){try{[l,c,d]=i.applyTo(l,c,s);let m=s.elements,p=s.maybeClone(a,l,c),u=A8.create(s,p),E=la.applyLatestChanges(i,m,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=p}finally{r(i)}if(d)break;i=o()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new Kr(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(n){if(!n.length)return null;let t=n.pop();return t!==void 0?t:null}static push(n,t){let o=la.inverse(t);return n.push(o)}};import{useEffect as D8,useState as _8}from"react";var zg=(e,n)=>{let[t,o]=_8(n);return D8(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as l2}from"react/jsx-runtime";var i2=(e,n,t)=>{if(!n.multiElement&&!n.resizingElement&&!n.editingTextElement&&!n.newElement&&!n.selectedElementsAreBeingDragged&&!n.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let o=t();if(!o)return{captureUpdate:Hg.EVENTUALLY};let[r,i]=o,a=R8(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Hg.NEVER}}return{captureUpdate:Hg.EVENTUALLY}},a2=e=>({name:"undo",label:"buttons.undo",icon:wu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>i2(r,t,()=>e.undo(o2(n),t)),keyTest:n=>n[ca.CTRL_OR_CMD]&&Gg(n,ca.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=zg(e.onHistoryChangedEmitter,new Kr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=at()==="mobile";return l2(K,{type:"button",icon:wu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?r2:{}}})}}),s2=e=>({name:"redo",label:"buttons.redo",icon:yu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>i2(r,t,()=>e.redo(o2(n),t)),keyTest:n=>n[ca.CTRL_OR_CMD]&&n.shiftKey&&Gg(n,ca.Z)||n[ca.CTRL_OR_CMD]&&!n.shiftKey&&Gg(n,ca.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=zg(e.onHistoryChangedEmitter,new Kr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=at()==="mobile";return l2(K,{type:"button",icon:yu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?r2:{}}})}});import{getFontString as N8}from"@excalidraw/common";import{getTextAnchorRatios as B8,isExcalidrawElement as O8,isNonDeletedElement as F8,newElementWith as z8,updateBoundElements as H8}from"@excalidraw/element";import{measureText as G8}from"@excalidraw/element";import{isTextElement as Ug}from"@excalidraw/element";import{CaptureUpdateAction as U8}from"@excalidraw/element";var Wg=F({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=se(e,n);return o.length===1&&Ug(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=se(e,n),i=O8(t)&&Ug(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!Ug(a))return!1;let s=G8(a.originalText,N8(a),a.lineHeight),l=B8(a),c=z8(a,{autoResize:!0,width:s.width,height:s.height,x:a.x+(a.width-s.width)*l.x,y:a.y+(a.height-s.height)*l.y,text:a.originalText});return F8(c)&&H8(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:U8.IMMEDIATELY}}});import{CODES as W8,KEYS as V8}from"@excalidraw/common";import Y8 from"clsx";import{CaptureUpdateAction as X8}from"@excalidraw/element";import{jsx as K8}from"react/jsx-runtime";var da=F({name:"viewMode",label:"labels.viewMode",icon:Ar,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:X8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[V8.CTRL_OR_CMD]&&e.altKey&&e.code===W8.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>{if(t.viewModeOnly||o.viewModeOnly)return null;let r=t.viewModeEnabled?"Edit mode":f("labels.viewMode");return K8(K,{type:"button",icon:t.viewModeEnabled?Vu:Ar,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:Y8({enabled:t.viewModeEnabled})})}});import{isPromiseLike as Z8}from"@excalidraw/common";import{jsx as $8}from"react/jsx-runtime";var Vg=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Ne(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},pm=class{constructor(n,t,o,r){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);I(this,"renderAction",(n,t)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[n]&&"PanelComponent"in this.actions[n]&&(!(n in o)||o[n])){let r=this.actions[n],i=r.PanelComponent;i.displayName="PanelComponent";let a=s=>{this.isActionBlockedByViewportTransition(r)||(Vg(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return $8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(this,"isActionEnabled",n=>{let t=this.getElementsIncludingDeleted(),o=this.getAppState();return!n.predicate||n.predicate(t,o,this.app.props,this.app)});this.updater=i=>{if(Z8(i))i.then(a=>n(a));else return n(i)},this.getAppState=t,this.getElementsIncludingDeleted=o,this.app=r}registerAction(n){this.actions[n.name]=n}registerAll(n){n.forEach(t=>this.registerAction(t))}handleKeyDown(n){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in t?t[l.name]:!0)&&l.keyTest&&l.keyTest(n,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let r=o[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return n.preventDefault(),n.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),s=null;return Vg(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,s,this.app)),!0}executeAction(n,t="api",o=null){if(t!=="api"&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&n.navigation===!0)||this.isActionBlockedByViewportTransition(n))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();Vg(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var Yg=e=>{let n=Array.from(e.values());return{x:c2(n,t=>t.x)/n.length,y:c2(n,t=>t.y)/n.length}},Xg=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),c2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as V,pointRotateRads as tr,rangeInclusive as ln,rangeIntersection as um,rangesOverlap as hm}from"@excalidraw/math";import{TOOL_TYPE as Zr,KEYS as d2}from"@excalidraw/common";import{getCommonBounds as Kg,getDraggedElementsBounds as Zg,getElementAbsoluteCoords as j8}from"@excalidraw/element";import{isBoundToContainer as h2}from"@excalidraw/element";import{getMaximumGroups as g2}from"@excalidraw/element";import{getSelectedElements as q8,getVisibleAndNonSelectedElements as f2}from"@excalidraw/element";var J8=8,m2=99999,gm=e=>J8/e,Lt=class Lt{};I(Lt,"referenceSnapPoints",null),I(Lt,"visibleGaps",null),I(Lt,"setReferenceSnapPoints",n=>{Lt.referenceSnapPoints=n}),I(Lt,"getReferenceSnapPoints",()=>Lt.referenceSnapPoints),I(Lt,"setVisibleGaps",n=>{Lt.visibleGaps=n}),I(Lt,"getVisibleGaps",()=>Lt.visibleGaps),I(Lt,"destroy",()=>{Lt.referenceSnapPoints=null,Lt.visibleGaps=null});var cn=Lt,nr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Eo=({event:e,app:n,selectedElements:t})=>{if(e){let o=n.state.activeTool.type==="lasso"&&n.state.selectedElementsAreBeingDragged;return(n.state.activeTool.type!=="lasso"||o)&&(n.state.objectsSnapModeEnabled&&!e[d2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[d2.CTRL_OR_CMD]&&!nr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},Q8=(e,n,t=.01)=>Math.abs(e-n)<=t,gl=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=j8(a,n);r&&(s+=r.x,c+=r.x,m+=r.x,l+=r.y,d+=r.y,p+=r.y);let u=(c-s)/2,E=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=tr(V(s,l+E),V(m,p),a.angle),b=tr(V(s+u,l),V(m,p),a.angle),y=tr(V(c,l+E),V(m,p),a.angle),w=tr(V(s+u,d),V(m,p),a.angle),x=V(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}else{let g=tr(V(s,l),V(m,p),a.angle),b=tr(V(c,l),V(m,p),a.angle),y=tr(V(s,d),V(m,p),a.angle),w=tr(V(c,d),V(m,p),a.angle),x=V(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}}else if(e.length>1){let[a,s,l,c]=Zg(e,r??{x:0,y:0}),d=l-a,m=c-s,p=V(a,s),u=V(l,s),E=V(a,c),g=V(l,c),b=V(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>V(Ve(a[0]),Ve(a[1])))},E2=(e,n,t,o)=>f2(e,n,t,o),b2=(e,n,t,o)=>{let r=E2(e,n,t,o),i=g2(r,o).filter(m=>!(m.length===1&&h2(m[0]))).map(m=>Kg(m).map(p=>Ve(p))),a=i.sort((m,p)=>m[0]-p[0]),s=[],l=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++l>m2)break e;let E=a[u],[,g,b,y]=p,[w,x,,v]=E;b<w&&hm(ln(g,y),ln(x,v))&&s.push({startBounds:p,endBounds:E,startSide:[V(b,g),V(b,y)],endSide:[V(w,x),V(w,v)],length:w-b,overlap:um(ln(g,y),ln(x,v))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];l=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++l>m2)break e;let E=c[u],[g,,b,y]=p,[w,x,v]=E;y<x&&hm(ln(g,b),ln(w,v))&&d.push({startBounds:p,endBounds:E,startSide:[V(g,y),V(b,y)],endSide:[V(w,x),V(v,x)],length:x-y,overlap:um(ln(g,b),ln(w,v))})}}return{horizontalGaps:s,verticalGaps:d}},p2=(e,n,t,o,r,i,a)=>{if(!Eo({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=cn.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=Zg(e,n).map(b=>Ve(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!hm(ln(m,u),b.overlap))continue;let y=b.startSide[0][0]+b.length/2,w=Ve(y-E);if(b.length>p-d&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(r.length=0),a.x=Math.abs(w);let _={type:"gap",direction:"center_horizontal",gap:b,offset:w};r.push(_);continue}let[,,v]=b.endBounds,T=d-v,C=Ve(b.length-T);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(r.length=0),a.x=Math.abs(C);let _={type:"gap",direction:"side_right",gap:b,offset:C};r.push(_);continue}let[P,,,]=b.startBounds,A=P-p,L=Ve(A-b.length);if(Math.abs(L)<=a.x){Math.abs(L)<a.x&&(r.length=0),a.x=Math.abs(L);let _={type:"gap",direction:"side_left",gap:b,offset:L};r.push(_);continue}}for(let b of c){if(!hm(ln(d,p),b.overlap))continue;let y=b.startSide[0][1]+b.length/2,w=Ve(y-g);if(b.length>u-m&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let _={type:"gap",direction:"center_vertical",gap:b,offset:w};i.push(_);continue}let[,v,,]=b.startBounds,T=v-u,C=Ve(T-b.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let _={type:"gap",direction:"side_top",gap:b,offset:C};i.push(_);continue}let[,,,P]=b.endBounds,A=Ve(m-P),L=b.length-A;if(Math.abs(L)<=a.y){Math.abs(L)<a.y&&(i.length=0),a.y=Math.abs(L);let _={type:"gap",direction:"side_bottom",gap:b,offset:L};i.push(_);continue}}}},x2=(e,n,t,o)=>{let r=E2(e,n,t,o);return g2(r,o).filter(i=>!(i.length===1&&h2(i[0]))).flatMap(i=>gl(i,o))},ma=(e,n,t,o,r,i,a)=>{if(!Eo({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=cn.getReferenceSnapPoints();if(s)for(let l of n)for(let c of s){let d=c[0]-l[0],m=c[1]-l[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[l,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:m}),a.y=Math.abs(m))}},w2=(e,n,t,o,r)=>{let i=t.state,a=q8(e,i);if(!Eo({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Ve(n.x),n.y=Ve(n.y);let s=[],l=[],c=gm(i.zoom.value),d={x:c,y:c},m=gl(a,r,{dragOffset:n});ma(a,m,t,o,s,l,d),p2(a,n,t,o,s,l,d);let p={x:s[0]?.offset??0,y:l[0]?.offset??0};d.x=0,d.y=0,s.length=0,l.length=0;let u={x:Ve(n.x+p.x),y:Ve(n.y+p.y)};ma(a,gl(a,r,{dragOffset:u}),t,o,s,l,d),p2(a,u,t,o,s,l,d);let E=$g(s,l),g=tN(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Ve=e=>Math.round(e*10**6)/10**6,u2=e=>{let n=new Map;for(let t of e){let o=t.join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},$g=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ve(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>V(Ve(a[0]),Ve(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Ve(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>V(Ve(a[0]),Ve(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:u2(i.map(a=>V(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:u2(i.map(a=>V(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},eN=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Ve(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},tN=(e,n,t)=>{let[o,r,i,a]=Zg(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,y=um(ln(r,a),l.gap.overlap),w=um(ln(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(l.gap.startSide[0][0],x),V(o,x)]},{type:"gap",direction:"horizontal",points:[V(i,x),V(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,l.gap.startSide[0][1]),V(x,r)]},{type:"gap",direction:"vertical",points:[V(x,a),V(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(m,x),V(u,x)]},{type:"gap",direction:"horizontal",points:[V(g,x),V(o,x)]})}break}case"side_left":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(i,x),V(c,x)]},{type:"gap",direction:"horizontal",points:[V(m,x),V(u,x)]})}break}case"side_top":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,a),V(x,d)]},{type:"gap",direction:"vertical",points:[V(x,p),V(x,E)]})}break}case"side_bottom":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,p),V(x,E)]},{type:"gap",direction:"vertical",points:[V(x,b),V(x,r)]})}break}}}return eN(s.map(l=>({...l,points:l.points.map(c=>V(Ve(c[0]),Ve(c[1])))})))},jg=(e,n,t,o,r,i)=>{if(!Eo({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!Q8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=Kg(n);i&&(i.includes("e")?l+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?s+=r.y:i.includes("s")&&(c+=r.y));let d=[];if(i)switch(i){case"e":{d.push(V(l,s),V(l,c));break}case"w":{d.push(V(a,s),V(a,c));break}case"n":{d.push(V(a,s),V(l,s));break}case"s":{d.push(V(a,c),V(l,c));break}case"ne":{d.push(V(l,s));break}case"nw":{d.push(V(a,s));break}case"se":{d.push(V(l,c));break}case"sw":{d.push(V(a,c));break}}let m=gm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];ma(n,d,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,y,w,x]=Kg(e).map(C=>Ve(C)),v=[V(b,y),V(b,x),V(w,y),V(w,x)];ma(e,v,t,o,u,E,p);let T=$g(u,E);return{snapOffset:g,snapLines:T}},y2=(e,n,t,o,r,i)=>{if(!Eo({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[V(o.x+r.x,o.y+r.y)],s=gm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];ma([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=gl([e],i,{boundingBoxCorners:!0,omitCenter:!0});ma([e],p,n,t,c,d,l);let u=$g(c,d);return{snapOffset:m,snapLines:u}},v2=(e,n,t,o,r)=>{if(!Eo({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=f2(e,[],n.state,r),a=gm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=gl([d],r);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,V(p[0],t.y)],direction:"vertical"}),s.x=u);let E=p[1]-t.y;Math.abs(E)<=Math.abs(s.y)&&(Math.abs(E)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,V(t.x,p[1])],direction:"horizontal"}),s.y=E)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:l.length>0?l[0].points[0][1]-t.y:0},snapLines:[...c,...l]}},I2=e=>e===Zr.rectangle||e===Zr.ellipse||e===Zr.diamond||e===Zr.frame||e===Zr.magicframe||e===Zr.image||e===Zr.text;import{getCommonFrameId as nN,getFrameChildrenInsertionIndex as oN,isElementInViewport as rN}from"@excalidraw/element";import{arrayToMap as iN,memoize as aN,toBrandedType as sN}from"@excalidraw/common";var fl=class{constructor(n){I(this,"scene");I(this,"_getRenderableElements",aN(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:c,newElement:d})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:c,newElement:d}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l});return{elementsMap:p,visibleElements:E,newElementCanvasElement:u,canvasNonce:n}}));I(this,"getRenderableElements",n=>{let{newElement:t}=n,o=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:""}`,r=this._getRenderableElements({canvasNonce:o,zoom:n.zoom,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,scrollX:n.scrollX,scrollY:n.scrollY,height:n.height,width:n.width,editingTextElement:n.editingTextElement,newElement:n.newElement});if(n.frameToHighlight&&n.selectedElementsAreBeingDragged&&nN(n.selectedElements)!==n.frameToHighlight.id){let i=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:n.selectedElements,frameToHighlight:n.frameToHighlight});return{...r,visibleElements:i}}return r});this.scene=n}getVisibleCanvasElements({elementsMap:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l}){let c=[];for(let d of n.values())rN(d,l,s,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&c.push(d);return c}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=sN(new Map),i=o?.frameId?null:o;for(let a of n)i?.id!==a.id&&(!t||t.type!=="text"||a.id!==t.id)&&r.set(a.id,a);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:n,selectedElements:t,frameToHighlight:o}){if(!t.length)return n;let r=iN(t),i=n.filter(s=>!r.has(s.id)),a=oN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){ex.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as pN,easeOut as C2}from"@excalidraw/common";import{SVG_NS as S2,getSvgPathFromStroke as dN,sceneCoordsToViewportCoords as mN}from"@excalidraw/common";import{version as lN}from"react";import{unstable_batchedUpdates as T2}from"react-dom";import{throttleRAF as cN}from"@excalidraw/common";var Ye=e=>n=>{T2(e,n)},fm=e=>cN(n=>{T2(e,n)}),pa=(()=>{let e;try{let t=lN.split(".");e=Number(t[0])>17}catch{e=!1}let n=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(n||(n=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var ce=class ce{static start(n,t){if(ce.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};ce.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw ce.animations.get(n)===o&&(ce.animations.delete(n),ce.cancelScheduledFrameIfIdle()),i}if(ce.animations.get(n)===o){if(!r){ce.animations.delete(n),ce.cancelScheduledFrameIfIdle();return}o.state=r,ce.scheduleNextFrame()}}static scheduleNextFrame(){ce.scheduledFrame||(pa()?ce.scheduledFrame={id:requestAnimationFrame(ce.tick),type:"raf"}:ce.scheduledFrame={id:setTimeout(ce.tick,0),type:"timeout"})}static cancelScheduledFrame(){ce.scheduledFrame&&(ce.scheduledFrame.type==="raf"?cancelAnimationFrame(ce.scheduledFrame.id):clearTimeout(ce.scheduledFrame.id),ce.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return ce.animations.size>0?!1:(ce.cancelScheduledFrame(),!0)}static tick(){if(ce.scheduledFrame=null,ce.animations.size>0){let n=[...ce.animations];for(let[t,o]of n){if(ce.animations.get(t)!==o)continue;let r=performance.now(),i=o.lastTime===0?0:r-o.lastTime,a=o.animation({deltaTime:i,state:o.state});if(ce.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(ce.animations.delete(t),ce.cancelScheduledFrameIfIdle())return}}if(ce.cancelScheduledFrameIfIdle())return;ce.scheduleNextFrame()}}static running(n){return ce.animations.has(n)}static cancel(n){ce.animations.delete(n),ce.cancelScheduledFrameIfIdle()}static reset(){ce.animations.clear(),ce.cancelScheduledFrame()}};I(ce,"scheduledFrame",null),I(ce,"animations",new Map);var rt=ce;var Em=class Em{constructor(n,t){this.app=n;this.options=t;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");I(this,"key");this.key=`animated-trail-${Em.counter++}`,this.trailElement=document.createElementNS(S2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(S2,"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(n,t){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===n&&this.currentTrail.originalPoints[o-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(n){n&&(this.container=n),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),rt.running(this.key)||rt.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){rt.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new Qi(this.options),this.currentTrail.addPoint([n,t,performance.now()]),this.update()}addPointToPath(n,t){this.currentTrail&&(this.currentTrail.addPoint([n,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 n=[];for(let o of this.pastTrails)n.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);n.push(o)}if(this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline(o.options.size/this.app.state.zoom.value).length!==0),n.length===0)return this.trailElement.setAttribute("d",""),!1;let t=n.join(" ").trim();return 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)),!0}drawTrail(n,t){let o=n.getStrokeOutline(n.options.size/t.zoom.value).map(([i,a])=>{let s=mN({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return dN(r,!0)}};I(Em,"counter",0);var Pn=Em;var bm=class{constructor(n){this.app=n;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.localTrail=new Pn(n,{...this.getTrailOptions(),fill:()=>pN})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:n=>{let r=Math.max(0,1-(performance.now()-n.pressure)/1e3),i=(50-Math.min(50,n.totalLength-n.currentIndex))/50;return Math.min(C2(i),C2(r))}}}startPath(n,t){this.localTrail.startPath(n,t)}addPointToPath(n,t){this.localTrail.addPointToPath(n,t)}endPath(){this.localTrail.endPath()}start(n){this.container=n,this.localTrail.start(n)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(n){for(let[t,o]of this.collabTrails)n?.get(t)||(o.stop(),this.collabTrails.delete(t))}updateCollabTrails(n){if(this.stopCollabTrails(n),!(!this.container||n.size===0))for(let[t,o]of n.entries()){if(o.isCurrentUser)continue;let r=this.collabTrails.get(t);if(r||(r=new Pn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||Gr(t,o)}),r.start(this.container),this.collabTrails.set(t,r)),o.pointer&&o.pointer.tool==="laser"){let i=o.button==="down",a=o.button==="up",s=r.hasCurrentTrail;i&&!s&&r.startPath(o.pointer.x,o.pointer.y);let l=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&l&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&s&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as uN}from"@excalidraw/common";import{pointFrom as El,pointRotateRads as xm}from"@excalidraw/math";var hN=12,qg=16,gN=10,fN=qg+2,EN=.8,Jg=e=>uN*2/e,Qg=(e,n,t)=>{let o=Jg(n);if(t!=="desktop"||qg>(e.height+o*2)*n*EN)return null;let r=hN/n,i=qg/n,a=El(e.x+e.width/2,e.y+e.height/2),s=xm(El(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:xm(El(s[0],s[1]-i/2),s,e.angle),end:xm(El(s[0],s[1]+i/2),s,e.angle),hitboxWidth:gN/n,hitboxHeight:fN/n}},P2=(e,n,t,o)=>{let r=Qg(n,t,o);if(!r)return!1;let i=xm(El(e.x,e.y),r.center,-n.angle);return Math.abs(i[0]-r.center[0])<=r.hitboxWidth/2&&Math.abs(i[1]-r.center[1])<=r.hitboxHeight/2};import{CODES as ef,KEYS as bl,CLASSES as tf,POINTER_BUTTON as bN,THEME as xN,isWritableElement as wN,getFontString as k2,getFontFamilyString as M2,isTestEnv as A2,MIME_TYPES as nf,applyDarkModeFilter as yN,isRTL as vN}from"@excalidraw/common";import{pointFrom as L2,pointRotateRads as IN}from"@excalidraw/math";import{getTextFromElements as TN,originalContainerCache as SN,updateBoundElements as D2,updateOriginalContainerCache as _2}from"@excalidraw/element";import{LinearElementEditor as CN}from"@excalidraw/element/linearElementEditor";import{bumpVersion as PN}from"@excalidraw/element";import{getBoundTextElementId as kN,getContainerElement as of,getTextElementAngle as MN,redrawTextBoundingBox as AN,getBoundTextMaxHeight as LN,getBoundTextMaxWidth as R2,computeContainerDimensionForBoundText as N2,computeBoundTextPosition as DN,getBoundTextElement as _N}from"@excalidraw/element";import{getTextWidth as RN}from"@excalidraw/element";import{getLineHeightInPx as NN}from"@excalidraw/element";import{getLineWidth as BN}from"@excalidraw/element";import{normalizeText as B2}from"@excalidraw/element";import{wrapText as ON}from"@excalidraw/element";import{getWrappedTextLines as FN}from"@excalidraw/element";import{isArrowElement as wm,isBoundToContainer as zN,isTextElement as O2}from"@excalidraw/element";var HN=(e,n,t,o,r,i)=>{let{zoom:a}=o,s=180*t/Math.PI,l=e*(a.value-1)/2,c=n*(a.value-1)/2;return e>r&&a.value!==1&&(l=r*(a.value-1)/2),n>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value}) rotate(${s}deg)`},GN=(e,n)=>{let t=e.lastIndexOf(`
|
|
11
|
+
C ${l} ${c}, ${l} ${c}, ${l+b} ${c+y}`,So(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],So(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,So(e,!1,a));case"line":case"arrow":{let s,l=So(e,!1,a),c=e.points.length?e.points:[u8(0,0)];if(Dn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(v8(c,16),So(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),s=[]):e.roundness?s=[n.curve(c,l)]:l.fill?s=[n.polygon(c,l)]:s=[n.linearPath(c,l)],e.type==="arrow"){let{startArrowhead:d=null,endArrowhead:m="arrow"}=e;if(d!==null){let p=t2(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=t2(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(pa(e.points)){let l=m8(e.points,.75);s.push(n.curve(l,{...So(e,!1,a),stroke:"none"}))}return s.push(I8(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return g8(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},v8=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],s=e[r],l=um(s,i),c=um(a,s),d=Math.min(n,Qv(e[r],a)/2,Qv(e[r],i)/2);l?i[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),c?a[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)o.push(`L ${t[r][0]} ${t[r][1]}`),o.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")};var I8=e=>A8(k8(e)),Wg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},T8={SIZE_FACTOR:1.4},r2=e=>e.strokeOptions?.streamline??E8,S8=e=>{let n=e.simulatePressure?e.points:e.points.length?e.points.map(([t,o],r)=>[t,o,e.pressures[r]]):[[0,0,.5]];return p8(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Wg.SIZE_FACTOR,thinning:Wg.THINNING,smoothing:Wg.SMOOTHING,streamline:r2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},C8=e=>new ma({size:e.strokeWidth*T8.SIZE_FACTOR,streamline:r2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),P8=e=>{let n=C8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},k8=e=>e.strokeOptions?.variability==="constant"?P8(e):S8(e);var n2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],M8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,A8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,n2(o,i[0]),"L",i[0],"Z"):t.push(o,n2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(M8,"$1")};var Jr=(e,n,t=!1)=>{let o=!1;for(let r in n){let i=n[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!t?e:{...e,...n,version:n.version??e.version+1,versionNonce:n.versionNonce??D8(),updated:L8()}};import{jsx as s2}from"react/jsx-runtime";var ba=O({name:"toggleLinearEditor",label:(e,n,t)=>t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.selectedLinearElement?.isEditing&&r.length===1&&R8(r[0])&&!_8(r[0]))},perform(e,n,t,o){i2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);i2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:a2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!o)return null;let r=f(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return s2($,{type:"button",icon:s0,title:r,"aria-label":r,onClick:()=>n(null)})}}),GTe=O({name:"togglePolygon",icon:vu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!Ea(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds});return r.length>0&&r.every(i=>Ea(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!Ea(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=N8(i);return{elements:e.map(l=>!s.has(l.id)||!Ea(l)?l:Jr(l,{backgroundColor:a?l.backgroundColor:"transparent",...B8(l,a)})),appState:n,captureUpdate:a2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!Ea(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>Ea(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return s2($,{type:"toggle",icon:vu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as l2,CANVAS_SEARCH_TAB as c2,CLASSES as F8,DEFAULT_SIDEBAR as d2}from"@excalidraw/common";import{CaptureUpdateAction as O8}from"@excalidraw/element";var wl=O({name:"searchMenu",icon:Jn,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,n,t,o){if(n.openDialog)return!1;if(n.openSidebar?.name===d2.name&&n.openSidebar.tab===c2){let r=o.excalidrawContainerValue.container?.querySelector(`.${F8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:d2.name,tab:c2},openDialog:null},captureUpdate:O8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[l2.CTRL_OR_CMD]&&e.key===l2.F});import{isImageElement as z8}from"@excalidraw/element";import{CaptureUpdateAction as G8}from"@excalidraw/element";import{jsx as H8}from"react/jsx-runtime";var Yg=O({name:"cropEditor",label:"helpDialog.cropStart",icon:Xu,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,n,t,o){let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...n,isCropping:!1,croppingElementId:r.id},captureUpdate:G8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&z8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return H8($,{type:"button",icon:Xu,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as U8}from"@excalidraw/element";import{mutateElement as W8}from"@excalidraw/element";import{newFrameElement as V8}from"@excalidraw/element";import{isFrameLikeElement as Em}from"@excalidraw/element";import{addElementsToFrame as Y8,removeAllElementsFromFrame as X8}from"@excalidraw/element";import{getFrameChildren as K8}from"@excalidraw/element";import{getElementsInGroup as $8}from"@excalidraw/element";import{getCommonBounds as Z8}from"@excalidraw/element";import{CaptureUpdateAction as xa}from"@excalidraw/element";var m2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&Em(t[0])},p2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(Em(r)){let i=K8(U8(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},captureUpdate:xa.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:xa.EVENTUALLY}},predicate:(e,n,t,o)=>m2(n,o)}),u2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return Em(r)?{elements:X8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:xa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:xa.EVENTUALLY}},predicate:(e,n,t,o)=>m2(n,o)}),ZSe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>({elements:e,appState:{...n,frameRendering:{...n.frameRendering,enabled:!n.frameRendering.enabled}},captureUpdate:xa.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),h2=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=ce(e,n);return r.length>0&&!r.some(i=>Em(i))},perform:(e,n,t,o)=>{let r=ce(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=Z8(r,i),d=16,m=V8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=$8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);W8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:Y8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:xa.IMMEDIATELY}}});import{KEYS as wa,matchKey as $g,arrayToMap as g2,MOBILE_ACTION_BUTTON_BG as f2}from"@excalidraw/common";import{CaptureUpdateAction as Kg}from"@excalidraw/element";import{orderByFractionalIndex as nN}from"@excalidraw/element";import{Emitter as j8}from"@excalidraw/common";import{CaptureUpdateAction as q8,StoreChange as J8,StoreDelta as Q8}from"@excalidraw/element";var ya=class extends Q8{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,s]=this.appState.applyTo(t,r);return[r,a,i||s]}static calculate(n,t){return super.calculate(n,t)}static inverse(n){return super.inverse(n)}static applyLatestChanges(n,t,o,r){return super.applyLatestChanges(n,t,o,r)}},ei=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},vl=class e{constructor(n){this.store=n;v(this,"onHistoryChangedEmitter",new j8);v(this,"undoStack",[]);v(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(n){if(n.isEmpty()||n instanceof ya)return;let t=ya.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ei(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(n,t){return this.perform(n,t,()=>e.pop(this.undoStack),o=>e.push(this.redoStack,o))}redo(n,t){return this.perform(n,t,()=>e.pop(this.redoStack),o=>e.push(this.undoStack,o))}perform(n,t,o,r){try{let i=o();if(i===null)return;let a=q8.IMMEDIATELY,s=this.store.snapshot,l=n,c=t,d=!1;for(;i;){try{[l,c,d]=i.applyTo(l,c,s);let m=s.elements,p=s.maybeClone(a,l,c),u=J8.create(s,p),E=ya.applyLatestChanges(i,m,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=p}finally{r(i)}if(d)break;i=o()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new ei(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(n){if(!n.length)return null;let t=n.pop();return t!==void 0?t:null}static push(n,t){let o=ya.inverse(t);return n.push(o)}};import{useEffect as eN,useState as tN}from"react";var Xg=(e,n)=>{let[t,o]=tN(n);return eN(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as y2}from"react/jsx-runtime";var E2=(e,n,t)=>{if(!n.multiElement&&!n.resizingElement&&!n.editingTextElement&&!n.newElement&&!n.selectedElementsAreBeingDragged&&!n.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let o=t();if(!o)return{captureUpdate:Kg.EVENTUALLY};let[r,i]=o,a=nN(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Kg.NEVER}}return{captureUpdate:Kg.EVENTUALLY}},b2=e=>({name:"undo",label:"buttons.undo",icon:Cu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>E2(r,t,()=>e.undo(g2(n),t)),keyTest:n=>n[wa.CTRL_OR_CMD]&&$g(n,wa.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Xg(e.onHistoryChangedEmitter,new ei(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return y2($,{type:"button",icon:Cu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?f2:{}}})}}),x2=e=>({name:"redo",label:"buttons.redo",icon:Pu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>E2(r,t,()=>e.redo(g2(n),t)),keyTest:n=>n[wa.CTRL_OR_CMD]&&n.shiftKey&&$g(n,wa.Z)||n[wa.CTRL_OR_CMD]&&!n.shiftKey&&$g(n,wa.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Xg(e.onHistoryChangedEmitter,new ei(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return y2($,{type:"button",icon:Pu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?f2:{}}})}});import{getFontString as oN}from"@excalidraw/common";import{getTextAnchorRatios as rN,isExcalidrawElement as iN,isNonDeletedElement as aN,newElementWith as sN,updateBoundElements as lN}from"@excalidraw/element";import{measureText as cN}from"@excalidraw/element";import{isTextElement as Zg}from"@excalidraw/element";import{CaptureUpdateAction as dN}from"@excalidraw/element";var jg=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=ce(e,n);return o.length===1&&Zg(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=ce(e,n),i=iN(t)&&Zg(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!Zg(a))return!1;let s=cN(a.originalText,oN(a),a.lineHeight),l=rN(a),c=sN(a,{autoResize:!0,width:s.width,height:s.height,x:a.x+(a.width-s.width)*l.x,y:a.y+(a.height-s.height)*l.y,text:a.originalText});return aN(c)&&lN(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:dN.IMMEDIATELY}}});import{CODES as mN,KEYS as pN}from"@excalidraw/common";import uN from"clsx";import{CaptureUpdateAction as hN}from"@excalidraw/element";import{jsx as gN}from"react/jsx-runtime";var va=O({name:"viewMode",label:"labels.viewMode",icon:Fr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:hN.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[pN.CTRL_OR_CMD]&&e.altKey&&e.code===mN.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>{if(t.viewModeOnly||o.viewModeOnly)return null;let r=t.viewModeEnabled?"Edit mode":f("labels.viewMode");return gN($,{type:"button",icon:t.viewModeEnabled?ju:Fr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:uN({enabled:t.viewModeEnabled})})}});import{isPromiseLike as fN}from"@excalidraw/common";import{jsx as EN}from"react/jsx-runtime";var qg=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Be(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},bm=class{constructor(n,t,o,r){v(this,"actions",{});v(this,"updater");v(this,"getAppState");v(this,"getElementsIncludingDeleted");v(this,"app");v(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);v(this,"renderAction",(n,t)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[n]&&"PanelComponent"in this.actions[n]&&(!(n in o)||o[n])){let r=this.actions[n],i=r.PanelComponent;i.displayName="PanelComponent";let a=s=>{this.isActionBlockedByViewportTransition(r)||(qg(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return EN(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});v(this,"isActionEnabled",n=>{let t=this.getElementsIncludingDeleted(),o=this.getAppState();return!n.predicate||n.predicate(t,o,this.app.props,this.app)});this.updater=i=>{if(fN(i))i.then(a=>n(a));else return n(i)},this.getAppState=t,this.getElementsIncludingDeleted=o,this.app=r}registerAction(n){this.actions[n.name]=n}registerAll(n){n.forEach(t=>this.registerAction(t))}handleKeyDown(n){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in t?t[l.name]:!0)&&l.keyTest&&l.keyTest(n,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let r=o[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return n.preventDefault(),n.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),s=null;return qg(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,s,this.app)),!0}executeAction(n,t="api",o=null){if(t!=="api"&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&n.navigation===!0)||this.isActionBlockedByViewportTransition(n))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();qg(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var Jg=e=>{let n=Array.from(e.values());return{x:w2(n,t=>t.x)/n.length,y:w2(n,t=>t.y)/n.length}},Qg=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),w2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as Y,pointRotateRads as lr,rangeInclusive as un,rangeIntersection as xm,rangesOverlap as ym}from"@excalidraw/math";import{TOOL_TYPE as ti,KEYS as v2}from"@excalidraw/common";import{getCommonBounds as ef,getDraggedElementsBounds as tf,getElementAbsoluteCoords as bN}from"@excalidraw/element";import{isBoundToContainer as C2}from"@excalidraw/element";import{getMaximumGroups as P2}from"@excalidraw/element";import{getSelectedElements as xN,getVisibleAndNonSelectedElements as k2}from"@excalidraw/element";var yN=8,I2=99999,wm=e=>yN/e,Rt=class Rt{};v(Rt,"referenceSnapPoints",null),v(Rt,"visibleGaps",null),v(Rt,"setReferenceSnapPoints",n=>{Rt.referenceSnapPoints=n}),v(Rt,"getReferenceSnapPoints",()=>Rt.referenceSnapPoints),v(Rt,"setVisibleGaps",n=>{Rt.visibleGaps=n}),v(Rt,"getVisibleGaps",()=>Rt.visibleGaps),v(Rt,"destroy",()=>{Rt.referenceSnapPoints=null,Rt.visibleGaps=null});var hn=Rt,cr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Co=({event:e,app:n,selectedElements:t})=>{if(e){let o=n.state.activeTool.type==="lasso"&&n.state.selectedElementsAreBeingDragged;return(n.state.activeTool.type!=="lasso"||o)&&(n.state.objectsSnapModeEnabled&&!e[v2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[v2.CTRL_OR_CMD]&&!cr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},wN=(e,n,t=.01)=>Math.abs(e-n)<=t,Il=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=bN(a,n);r&&(s+=r.x,c+=r.x,m+=r.x,l+=r.y,d+=r.y,p+=r.y);let u=(c-s)/2,E=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=lr(Y(s,l+E),Y(m,p),a.angle),b=lr(Y(s+u,l),Y(m,p),a.angle),y=lr(Y(c,l+E),Y(m,p),a.angle),w=lr(Y(s+u,d),Y(m,p),a.angle),x=Y(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}else{let g=lr(Y(s,l),Y(m,p),a.angle),b=lr(Y(c,l),Y(m,p),a.angle),y=lr(Y(s,d),Y(m,p),a.angle),w=lr(Y(c,d),Y(m,p),a.angle),x=Y(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}}else if(e.length>1){let[a,s,l,c]=tf(e,r??{x:0,y:0}),d=l-a,m=c-s,p=Y(a,s),u=Y(l,s),E=Y(a,c),g=Y(l,c),b=Y(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>Y(Xe(a[0]),Xe(a[1])))},M2=(e,n,t,o)=>k2(e,n,t,o),A2=(e,n,t,o)=>{let r=M2(e,n,t,o),i=P2(r,o).filter(m=>!(m.length===1&&C2(m[0]))).map(m=>ef(m).map(p=>Xe(p))),a=i.sort((m,p)=>m[0]-p[0]),s=[],l=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++l>I2)break e;let E=a[u],[,g,b,y]=p,[w,x,,I]=E;b<w&&ym(un(g,y),un(x,I))&&s.push({startBounds:p,endBounds:E,startSide:[Y(b,g),Y(b,y)],endSide:[Y(w,x),Y(w,I)],length:w-b,overlap:xm(un(g,y),un(x,I))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];l=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++l>I2)break e;let E=c[u],[g,,b,y]=p,[w,x,I]=E;y<x&&ym(un(g,b),un(w,I))&&d.push({startBounds:p,endBounds:E,startSide:[Y(g,y),Y(b,y)],endSide:[Y(w,x),Y(I,x)],length:x-y,overlap:xm(un(g,b),un(w,I))})}}return{horizontalGaps:s,verticalGaps:d}},T2=(e,n,t,o,r,i,a)=>{if(!Co({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=hn.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=tf(e,n).map(b=>Xe(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!ym(un(m,u),b.overlap))continue;let y=b.startSide[0][0]+b.length/2,w=Xe(y-E);if(b.length>p-d&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(r.length=0),a.x=Math.abs(w);let _={type:"gap",direction:"center_horizontal",gap:b,offset:w};r.push(_);continue}let[,,I]=b.endBounds,T=d-I,C=Xe(b.length-T);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(r.length=0),a.x=Math.abs(C);let _={type:"gap",direction:"side_right",gap:b,offset:C};r.push(_);continue}let[P,,,]=b.startBounds,A=P-p,D=Xe(A-b.length);if(Math.abs(D)<=a.x){Math.abs(D)<a.x&&(r.length=0),a.x=Math.abs(D);let _={type:"gap",direction:"side_left",gap:b,offset:D};r.push(_);continue}}for(let b of c){if(!ym(un(d,p),b.overlap))continue;let y=b.startSide[0][1]+b.length/2,w=Xe(y-g);if(b.length>u-m&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let _={type:"gap",direction:"center_vertical",gap:b,offset:w};i.push(_);continue}let[,I,,]=b.startBounds,T=I-u,C=Xe(T-b.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let _={type:"gap",direction:"side_top",gap:b,offset:C};i.push(_);continue}let[,,,P]=b.endBounds,A=Xe(m-P),D=b.length-A;if(Math.abs(D)<=a.y){Math.abs(D)<a.y&&(i.length=0),a.y=Math.abs(D);let _={type:"gap",direction:"side_bottom",gap:b,offset:D};i.push(_);continue}}}},D2=(e,n,t,o)=>{let r=M2(e,n,t,o);return P2(r,o).filter(i=>!(i.length===1&&C2(i[0]))).flatMap(i=>Il(i,o))},Ia=(e,n,t,o,r,i,a)=>{if(!Co({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=hn.getReferenceSnapPoints();if(s)for(let l of n)for(let c of s){let d=c[0]-l[0],m=c[1]-l[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[l,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:m}),a.y=Math.abs(m))}},L2=(e,n,t,o,r)=>{let i=t.state,a=xN(e,i);if(!Co({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Xe(n.x),n.y=Xe(n.y);let s=[],l=[],c=wm(i.zoom.value),d={x:c,y:c},m=Il(a,r,{dragOffset:n});Ia(a,m,t,o,s,l,d),T2(a,n,t,o,s,l,d);let p={x:s[0]?.offset??0,y:l[0]?.offset??0};d.x=0,d.y=0,s.length=0,l.length=0;let u={x:Xe(n.x+p.x),y:Xe(n.y+p.y)};Ia(a,Il(a,r,{dragOffset:u}),t,o,s,l,d),T2(a,u,t,o,s,l,d);let E=nf(s,l),g=IN(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Xe=e=>Math.round(e*10**6)/10**6,S2=e=>{let n=new Map;for(let t of e){let o=t.join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},nf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Xe(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>Y(Xe(a[0]),Xe(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Xe(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>Y(Xe(a[0]),Xe(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:S2(i.map(a=>Y(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:S2(i.map(a=>Y(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},vN=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Xe(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},IN=(e,n,t)=>{let[o,r,i,a]=tf(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,y=xm(un(r,a),l.gap.overlap),w=xm(un(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[Y(l.gap.startSide[0][0],x),Y(o,x)]},{type:"gap",direction:"horizontal",points:[Y(i,x),Y(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[Y(x,l.gap.startSide[0][1]),Y(x,r)]},{type:"gap",direction:"vertical",points:[Y(x,a),Y(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[Y(m,x),Y(u,x)]},{type:"gap",direction:"horizontal",points:[Y(g,x),Y(o,x)]})}break}case"side_left":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[Y(i,x),Y(c,x)]},{type:"gap",direction:"horizontal",points:[Y(m,x),Y(u,x)]})}break}case"side_top":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[Y(x,a),Y(x,d)]},{type:"gap",direction:"vertical",points:[Y(x,p),Y(x,E)]})}break}case"side_bottom":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[Y(x,p),Y(x,E)]},{type:"gap",direction:"vertical",points:[Y(x,b),Y(x,r)]})}break}}}return vN(s.map(l=>({...l,points:l.points.map(c=>Y(Xe(c[0]),Xe(c[1])))})))},of=(e,n,t,o,r,i)=>{if(!Co({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!wN(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=ef(n);i&&(i.includes("e")?l+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?s+=r.y:i.includes("s")&&(c+=r.y));let d=[];if(i)switch(i){case"e":{d.push(Y(l,s),Y(l,c));break}case"w":{d.push(Y(a,s),Y(a,c));break}case"n":{d.push(Y(a,s),Y(l,s));break}case"s":{d.push(Y(a,c),Y(l,c));break}case"ne":{d.push(Y(l,s));break}case"nw":{d.push(Y(a,s));break}case"se":{d.push(Y(l,c));break}case"sw":{d.push(Y(a,c));break}}let m=wm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];Ia(n,d,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,y,w,x]=ef(e).map(C=>Xe(C)),I=[Y(b,y),Y(b,x),Y(w,y),Y(w,x)];Ia(e,I,t,o,u,E,p);let T=nf(u,E);return{snapOffset:g,snapLines:T}},_2=(e,n,t,o,r,i)=>{if(!Co({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[Y(o.x+r.x,o.y+r.y)],s=wm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];Ia([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=Il([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ia([e],p,n,t,c,d,l);let u=nf(c,d);return{snapOffset:m,snapLines:u}},R2=(e,n,t,o,r)=>{if(!Co({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=k2(e,[],n.state,r),a=wm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=Il([d],r);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,Y(p[0],t.y)],direction:"vertical"}),s.x=u);let E=p[1]-t.y;Math.abs(E)<=Math.abs(s.y)&&(Math.abs(E)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,Y(t.x,p[1])],direction:"horizontal"}),s.y=E)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:l.length>0?l[0].points[0][1]-t.y:0},snapLines:[...c,...l]}},N2=e=>e===ti.rectangle||e===ti.ellipse||e===ti.diamond||e===ti.frame||e===ti.magicframe||e===ti.image||e===ti.text;import{getCommonFrameId as TN,getFrameChildrenInsertionIndex as SN,isElementInViewport as CN}from"@excalidraw/element";import{arrayToMap as PN,memoize as kN,toBrandedType as MN}from"@excalidraw/common";var Tl=class{constructor(n){v(this,"scene");v(this,"_getRenderableElements",kN(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:c,newElement:d})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:c,newElement:d}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l});return{elementsMap:p,visibleElements:E,newElementCanvasElement:u,canvasNonce:n}}));v(this,"getRenderableElements",n=>{let{newElement:t}=n,o=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:""}`,r=this._getRenderableElements({canvasNonce:o,zoom:n.zoom,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,scrollX:n.scrollX,scrollY:n.scrollY,height:n.height,width:n.width,editingTextElement:n.editingTextElement,newElement:n.newElement});if(n.frameToHighlight&&n.selectedElementsAreBeingDragged&&TN(n.selectedElements)!==n.frameToHighlight.id){let i=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:n.selectedElements,frameToHighlight:n.frameToHighlight});return{...r,visibleElements:i}}return r});this.scene=n}getVisibleCanvasElements({elementsMap:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l}){let c=[];for(let d of n.values())CN(d,l,s,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&c.push(d);return c}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=MN(new Map),i=o?.frameId?null:o;for(let a of n)i?.id!==a.id&&(!t||t.type!=="text"||a.id!==t.id)&&r.set(a.id,a);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:n,selectedElements:t,frameToHighlight:o}){if(!t.length)return n;let r=PN(t),i=n.filter(s=>!r.has(s.id)),a=SN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){cx.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as RN,easeOut as O2}from"@excalidraw/common";import{SVG_NS as F2,getSvgPathFromStroke as LN,sceneCoordsToViewportCoords as _N}from"@excalidraw/common";import{version as AN}from"react";import{unstable_batchedUpdates as B2}from"react-dom";import{throttleRAF as DN}from"@excalidraw/common";var Ke=e=>n=>{B2(e,n)},vm=e=>DN(n=>{B2(e,n)}),Ta=(()=>{let e;try{let t=AN.split(".");e=Number(t[0])>17}catch{e=!1}let n=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(n||(n=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var pe=class pe{static start(n,t){if(pe.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};pe.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw pe.animations.get(n)===o&&(pe.animations.delete(n),pe.cancelScheduledFrameIfIdle()),i}if(pe.animations.get(n)===o){if(!r){pe.animations.delete(n),pe.cancelScheduledFrameIfIdle();return}o.state=r,pe.scheduleNextFrame()}}static scheduleNextFrame(){pe.scheduledFrame||(Ta()?pe.scheduledFrame={id:requestAnimationFrame(pe.tick),type:"raf"}:pe.scheduledFrame={id:setTimeout(pe.tick,0),type:"timeout"})}static cancelScheduledFrame(){pe.scheduledFrame&&(pe.scheduledFrame.type==="raf"?cancelAnimationFrame(pe.scheduledFrame.id):clearTimeout(pe.scheduledFrame.id),pe.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return pe.animations.size>0?!1:(pe.cancelScheduledFrame(),!0)}static tick(){if(pe.scheduledFrame=null,pe.animations.size>0){let n=[...pe.animations];for(let[t,o]of n){if(pe.animations.get(t)!==o)continue;let r=performance.now(),i=o.lastTime===0?0:r-o.lastTime,a=o.animation({deltaTime:i,state:o.state});if(pe.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(pe.animations.delete(t),pe.cancelScheduledFrameIfIdle())return}}if(pe.cancelScheduledFrameIfIdle())return;pe.scheduleNextFrame()}}static running(n){return pe.animations.has(n)}static cancel(n){pe.animations.delete(n),pe.cancelScheduledFrameIfIdle()}static reset(){pe.animations.clear(),pe.cancelScheduledFrame()}};v(pe,"scheduledFrame",null),v(pe,"animations",new Map);var at=pe;var Im=class Im{constructor(n,t){this.app=n;this.options=t;v(this,"currentTrail");v(this,"pastTrails",[]);v(this,"container");v(this,"trailElement");v(this,"trailAnimation");v(this,"key");this.key=`animated-trail-${Im.counter++}`,this.trailElement=document.createElementNS(F2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(F2,"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(n,t){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===n&&this.currentTrail.originalPoints[o-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(n){n&&(this.container=n),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),at.running(this.key)||at.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){at.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new ma(this.options),this.currentTrail.addPoint([n,t,performance.now()]),this.update()}addPointToPath(n,t){this.currentTrail&&(this.currentTrail.addPoint([n,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 n=[];for(let o of this.pastTrails)n.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);n.push(o)}if(this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline(o.options.size/this.app.state.zoom.value).length!==0),n.length===0)return this.trailElement.setAttribute("d",""),!1;let t=n.join(" ").trim();return 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)),!0}drawTrail(n,t){let o=n.getStrokeOutline(n.options.size/t.zoom.value).map(([i,a])=>{let s=_N({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return LN(r,!0)}};v(Im,"counter",0);var Rn=Im;var Tm=class{constructor(n){this.app=n;v(this,"localTrail");v(this,"collabTrails",new Map);v(this,"container");this.localTrail=new Rn(n,{...this.getTrailOptions(),fill:()=>RN})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:n=>{let r=Math.max(0,1-(performance.now()-n.pressure)/1e3),i=(50-Math.min(50,n.totalLength-n.currentIndex))/50;return Math.min(O2(i),O2(r))}}}startPath(n,t){this.localTrail.startPath(n,t)}addPointToPath(n,t){this.localTrail.addPointToPath(n,t)}endPath(){this.localTrail.endPath()}start(n){this.container=n,this.localTrail.start(n)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(n){for(let[t,o]of this.collabTrails)n?.get(t)||(o.stop(),this.collabTrails.delete(t))}updateCollabTrails(n){if(this.stopCollabTrails(n),!(!this.container||n.size===0))for(let[t,o]of n.entries()){if(o.isCurrentUser)continue;let r=this.collabTrails.get(t);if(r||(r=new Rn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||$r(t,o)}),r.start(this.container),this.collabTrails.set(t,r)),o.pointer&&o.pointer.tool==="laser"){let i=o.button==="down",a=o.button==="up",s=r.hasCurrentTrail;i&&!s&&r.startPath(o.pointer.x,o.pointer.y);let l=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&l&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&s&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as NN}from"@excalidraw/common";import{pointFrom as Sl,pointRotateRads as Sm}from"@excalidraw/math";var BN=12,rf=16,FN=10,ON=rf+2,zN=.8,af=e=>NN*2/e,sf=(e,n,t)=>{let o=af(n);if(t!=="desktop"||rf>(e.height+o*2)*n*zN)return null;let r=BN/n,i=rf/n,a=Sl(e.x+e.width/2,e.y+e.height/2),s=Sm(Sl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Sm(Sl(s[0],s[1]-i/2),s,e.angle),end:Sm(Sl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:FN/n,hitboxHeight:ON/n}},z2=(e,n,t,o)=>{let r=sf(n,t,o);if(!r)return!1;let i=Sm(Sl(e.x,e.y),r.center,-n.angle);return Math.abs(i[0]-r.center[0])<=r.hitboxWidth/2&&Math.abs(i[1]-r.center[1])<=r.hitboxHeight/2};import{CODES as lf,KEYS as Cl,CLASSES as cf,POINTER_BUTTON as GN,THEME as HN,isWritableElement as UN,getFontString as G2,getFontFamilyString as H2,isTestEnv as U2,MIME_TYPES as df,applyDarkModeFilter as WN,isRTL as VN}from"@excalidraw/common";import{pointFrom as W2,pointRotateRads as YN}from"@excalidraw/math";import{getTextFromElements as XN,originalContainerCache as KN,updateBoundElements as V2,updateOriginalContainerCache as Y2}from"@excalidraw/element";import{LinearElementEditor as $N}from"@excalidraw/element/linearElementEditor";import{bumpVersion as ZN}from"@excalidraw/element";import{getBoundTextElementId as jN,getContainerElement as mf,getTextElementAngle as qN,redrawTextBoundingBox as JN,getBoundTextMaxHeight as QN,getBoundTextMaxWidth as X2,computeContainerDimensionForBoundText as K2,computeBoundTextPosition as e7,getBoundTextElement as t7}from"@excalidraw/element";import{getTextWidth as n7}from"@excalidraw/element";import{getLineHeightInPx as o7}from"@excalidraw/element";import{getLineWidth as r7}from"@excalidraw/element";import{normalizeText as $2}from"@excalidraw/element";import{wrapText as i7}from"@excalidraw/element";import{getWrappedTextLines as a7}from"@excalidraw/element";import{isArrowElement as Cm,isBoundToContainer as s7,isTextElement as Z2}from"@excalidraw/element";var l7=(e,n,t,o,r,i)=>{let{zoom:a}=o,s=180*t/Math.PI,l=e*(a.value-1)/2,c=n*(a.value-1)/2;return e>r&&a.value!==1&&(l=r*(a.value-1)/2),n>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value}) rotate(${s}deg)`},c7=(e,n)=>{let t=e.lastIndexOf(`
|
|
12
12
|
`,Math.max(0,n-1))+1,o=e.indexOf(`
|
|
13
|
-
`,n),r=e.slice(t,o===-1?e.length:o);return
|
|
14
|
-
`).reduce((he,ye,ae,ve)=>he.concat(ae?he[ae-1]+ve[ae-1].length+1:B),[]).reverse()},A=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},L=!1,_=()=>{if(H)return;H=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let U=of(B,a.scene.getNonDeletedElementsMap());if(U){if(u.value.trim()){let ue=kN(U);!ue||ue!==o.id?a.scene.mutateElement(U,{boundElements:(U.boundElements||[]).concat({type:"text",id:o.id})}):wm(U)&&PN(U)}else a.scene.mutateElement(U,{boundElements:U.boundElements?.filter(ue=>!O2(ue))});AN(B,U,a.scene)}n({viaKeyboard:L,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,re&&re.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",A,!0),window.removeEventListener("pointerdown",Y),window.removeEventListener("pointerup",D),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),W(),z(),Z(),u.remove()},D=B=>{window.removeEventListener("pointerup",D);let U=B?.target,ue=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),we=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content"),pe=(U instanceof HTMLElement||U instanceof SVGElement)&&(!!U.closest(`.${tf.SHAPE_ACTIONS_MENU}`)||!!U.closest(".compact-shape-actions-island"));setTimeout(()=>{pe||ue||we||(u.onblur=_,u.focus(),y&&(u.setSelectionRange(y.start,y.end),y=null))})},O=()=>{u.onblur=null,window.addEventListener("pointerup",D),window.addEventListener("blur",_)},Y=B=>{let U=B?.target;if(B.button===bN.WHEEL){U instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),O();return}let ue=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),we=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${tf.SHAPE_ACTIONS_MENU}, .${tf.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!wN(B.target)||ue||we?O():B.target instanceof HTMLCanvasElement&&!A2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),W=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),Z=a.onScrollChangeEmitter.on(()=>{p()}),H=!1;s&&!y&&u.select(),D();let re=null;return r&&"ResizeObserver"in window?(re=new window.ResizeObserver(()=>{p()}),re.observe(r)):window.addEventListener("resize",p),u.onpointerdown=B=>B.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",Y,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as ym}from"@excalidraw/common";import{getCommonBounds as VN}from"@excalidraw/element";var bo=4,dn=6,z2="rgba(0,0,0,0.3)",H2=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=VN(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(ym("sat"))||0,bottom:parseInt(ym("sab"))||0,left:parseInt(ym("sal"))||0,right:parseInt(ym("sar"))||0},m=Hn().rtl,p=-o.scrollX+d.left,u=-o.scrollY+d.top,E=p+l-d.right,g=u+c-d.bottom,b=Math.min(r,p),y=Math.min(i,u),w=Math.max(a,E),x=Math.max(s,g),v=a-r,T=s-i,C=w-b,P=x-y,A=Math.max(bo*2,d.left+d.right)+dn*2,L=n*(l/C)-A,_=Math.max(bo*2,d.top+d.bottom)+dn*2,k=t*(c/P)-_,D=C>v?C*o.zoom.value/(L+A):n/(L+A),O=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===w?null:{x:Math.max(d.left,bo)+dn+(p-b)/C*n,y:t-dn-Math.max(bo,d.bottom),width:L,height:dn,deltaMultiplier:D},vertical:u===y&&g===x?null:{x:m?Math.max(d.left,bo):n-dn-Math.max(d.right,bo),y:Math.max(d.top,bo)+dn+(u-y)/P*t,width:dn,height:k,deltaMultiplier:O}}},rf=(e,n,t)=>{let[o,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=n&&n<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:o||r,isOverHorizontal:o,isOverVertical:r}};import{pointFrom as c7}from"@excalidraw/math";import{getElementLineSegments as d7}from"@excalidraw/element";import{LinearElementEditor as m7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as p7,isLinearElement as u7}from"@excalidraw/element";import{getFrameChildren as h7}from"@excalidraw/element";import{selectGroupsForSelectedElements as g7}from"@excalidraw/element";import{arrayToMap as f7,easeOut as K2,isShallowEqual as E7}from"@excalidraw/common";import{simplify as YN}from"points-on-curve";import{polygonFromPoints as XN,lineSegment as Im,pointFrom as ua,pointOnLineSegment as KN,polygonIncludesPointNonZero as ZN,PRECISION as vm}from"@excalidraw/math";import{boundsContainBounds as U2,computeBoundTextPosition as $N,doBoundsIntersect as jN,elementOverlapsWithFrame as qN,getBoundTextElement as W2,getContainingFrame as JN,getElementBounds as V2,intersectElementWithLineSegment as QN,isBoundToContainer as Y2,pointInsideBoundsInclusive as e7}from"@excalidraw/element";var X2=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=YN(n,s));let d=t.filter(g=>!g.locked&&!Y2(g));a.clear(),i.clear();let m=n.reduce((g,b)=>[Math.min(g[0],b[0]),Math.min(g[1],b[1]),Math.max(g[2],b[0]),Math.max(g[3],b[1])],[1/0,1/0,-1/0,-1/0]),p=XN(c),u=[m[0]-vm,m[1]-vm,m[2]+vm,m[3]+vm];for(let g of d){let b=V2(g,o),y=t7(g,b,o),w=n7(b,y);if(jN(m,w)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!U2(u,w))continue;let x=o7(g,o,r,y),v=a7(p,x,w,l);l==="contain"?v&&!G2(c,g,o,y)&&a.add(g.id):v?a.add(g.id):G2(c,g,o,y)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?i7([...a],o):[...i,...a]}},t7=(e,n,t)=>{let o=JN(e,t);if(!o)return null;let r=V2(o,t);return U2(r,n)?null:qN(e,o,t)?r:null},n7=(e,n)=>n?[Math.max(e[0],n[0]),Math.max(e[1],n[1]),Math.min(e[2],n[2]),Math.min(e[3],n[3])]:e,o7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=W2(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?r7(s,o):s},r7=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[c,d]]of e){let m=c-s,p=d-l,u=0,E=1,g=!0;for(let[b,y]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){if(b===0){if(y<0){g=!1;break}continue}let w=y/b;if(b<0){if(w>E){g=!1;break}u=Math.max(u,w)}else{if(w<u){g=!1;break}E=Math.min(E,w)}}g&&a.push(Im(ua(s+u*m,l+u*p),ua(s+E*m,l+E*p)))}return a},i7=(e,n)=>{if(!e.some(r=>n.get(r)?.groupIds.length))return e;let t=new Map;for(let r of n.values()){let i=r.groupIds.at(-1);if(!i||r.locked||Y2(r))continue;let a=t.get(i);a?a.push(r.id):t.set(i,[r.id])}if(!t.size)return e;let o=new Set(e);return e.filter(r=>{let i=n.get(r)?.groupIds.at(-1),a=i?t.get(i):null;return!a||a.every(s=>o.has(s))})},a7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>ZN(a,e)||o==="contain"&&l7(a,e);return n.length===0?s7(t)[r](i):n[r](a=>a[r](i))},s7=([e,n,t,o])=>[ua(e,n),ua(t,n),ua(t,o),ua(e,o)],l7=(e,n)=>n.some((t,o)=>o>0&&KN(e,Im(n[o-1],t))),G2=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Im(e[l],s)).concat([Im(e[e.length-1],e[0])]),i=W2(n,t),a=(s,l)=>{let c=QN(s,t,l,0,!o);return o?c.some(d=>e7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...$N(n,i,t)},s))};var Tm=class extends Pn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),s=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(K2(s),K2(a))},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(o=>{let r=t.reduce((l,c)=>(l[c]=!0,l),{});if(this.keepPreviousSelection)for(let l of Object.keys(o.selectedElementIds))r[l]=!0;for(let[l]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(l);if(c&&p7(c)){let d=h7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=g7({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],s=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!s.length&&u7(this.app.scene.getNonDeletedElement(a[0]))?new m7(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>c7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!E7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=f7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=d7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=X2({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,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(r)}})}startPath(t,o,r=!1){this.endPath(),super.startPath(t,o),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 b7,easeOut as Z2,THEME as x7}from"@excalidraw/common";import{computeBoundTextPosition as w7,doBoundsIntersect as y7,getBoundTextElement as v7,getElementBounds as I7,getElementLineSegments as T7,getFreedrawOutlineAsSegments as S7,getFreedrawOutlinePoints as C7,intersectElementWithLineSegment as $2,isArrowElement as P7,isFreeDrawElement as j2,isLineElement as k7,isPointInElement as M7}from"@excalidraw/element";import{lineSegment as A7,lineSegmentsDistance as q2,pointFrom as oI,polygon as L7,polygonIncludesPointNonZero as D7}from"@excalidraw/math";import{getElementsInGroup as J2}from"@excalidraw/element";import{shouldTestInside as _7}from"@excalidraw/element";import{hasBoundTextElement as Q2,isBoundToContainer as eI}from"@excalidraw/element";import{getBoundTextElementId as tI}from"@excalidraw/element";var Sm=class extends Pn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),s=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(Z2(s),Z2(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===x7.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,o){this.endPath(),super.startPath(t,o),this.elementsToErase.clear()}addPointToPath(t,o,r=!1){return super.addPointToPath(t,o),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let o=super.getCurrentTrail()?.originalPoints?.map(s=>oI(s[0],s[1]))||[];if(o.length<2)return[];let r=A7(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=b7(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(nI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=J2(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(eI(s)&&this.elementsToErase.delete(s.containerId),Q2(s)){let d=tI(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&nI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=J2(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(Q2(s)){let d=tI(s);d&&this.elementsToErase.add(d)}eI(s)&&this.elementsToErase.add(s.containerId),this.elementsToErase.add(s.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},nI=(e,n,t,o)=>{let r=e[1],i=j2(n)?15:n.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],s=I7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!y7(a,l))return!1;if(_7(n)&&M7(r,n,t))return!0;if(j2(n)){let d=C7(n),m=S7(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(q2(E,e)<=p)return!0;let u=L7(...d.map(([E,g])=>oI(n.x+E,n.y+g)));return!!D7(e[0],u)}let c=v7(n,t);if(P7(n)||k7(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=T7(n,t);for(let p of m)if(q2(p,e)<=d)return!0;return!1}return $2(n,t,e,0,!0).length>0||!!c&&$2({...c,...w7(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as $7}from"@excalidraw/common";import{newElement as j7}from"@excalidraw/element";import{COLOR_PALETTE as R7,DEFAULT_FONT_FAMILY as N7,DEFAULT_FONT_SIZE as B7,VERTICAL_ALIGN as O7}from"@excalidraw/common";var rI=44,iI=22,aI=66,sI=48,xl=14,lI=304,cI=320,af=5.87,dI=28,mI=4,pI=2,sf=10,uI=10,hI=8,$n=12,ha=256,$r=10,lf=4,ga=$n*2,cf=$n*2,gI=100,fI=140,wl=.35,EI=$n/2,or=20,Cm=$n*2,df=$n,_e={fillStyle:"hachure",fontFamily:N7,fontSize:B7,opacity:100,roughness:1,strokeColor:R7.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:O7.MIDDLE,locked:!1};import{pointFrom as fa}from"@excalidraw/math";import{COLOR_PALETTE as vI,DEFAULT_CHART_COLOR_INDEX as F7,FONT_FAMILY as uf,FONT_SIZES as Pm,ROUNDNESS as bI,DEFAULT_FONT_SIZE as z7,getAllColorsSpecificShade as H7,getFontString as hf,getLineHeight as gf,ROUGHNESS as xI}from"@excalidraw/common";import{getApproxMinLineWidth as ff,measureText as rr,newElement as pf,newLinearElement as mf,newTextElement as Ea,wrapText as II}from"@excalidraw/element";var jr=H7(F7),G7=e=>e.labels?.length??e.series[0]?.values.length??0,ba=(e,n)=>{if(!e)return!1;let t=G7(e);return t<2?!1:n==="radar"?t>=3:!0},wI=(e,n)=>{let t=n<=1?0:Math.min(aI,(n-1)*iI);return e+t},km=(e,n)=>{if(e==="line"){let o=wI(sI,n);return{slotWidth:o,gap:xl,chartHeight:cI,xLabelMaxWidth:o+xl*3+sf}}let t=wI(rI,n);return{slotWidth:t,gap:xl,chartHeight:lI,xLabelMaxWidth:t+xl*3+sf}},xa=(e,n)=>{let t=(n.slotWidth+n.gap)*e.series[0].values.length+n.gap,o=n.chartHeight+n.gap*2;return{chartWidth:t,chartHeight:o}},TI=()=>{let e=ha+cf*2,n=ha+cf*2;return{chartWidth:e,chartHeight:n}},U7=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},wa=(e,n)=>{if(e<=0||jr.length===0)return[];let t=jr.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(s,l)=>l).filter(s=>s!==o));for(;r.length<i;){let s=-1,l=-1,c=-1;for(let d of a){let m=r.map(E=>U7(d,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>l||p===l&&u>c)&&(s=d,l=p,c=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>jr[r[l%r.length]])},ya=e=>{if(jr.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*jr.length);let n=e.toString(),t=0;for(let o=0;o<n.length;o++)t=t*31+n.charCodeAt(o)|0;return Math.abs(t)%jr.length},va=e=>jr[e],SI=(e,n)=>{let t=e.flatMap(s=>s.values.map(l=>Math.max(0,l))),o=t.filter(s=>s>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=gI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},W7=e=>/\s/.test(e.trim()),Mm=(e,n,t)=>W7(e)?II(e,n,t):e,CI=(e,n,t,o,r,i)=>{let a=uf.Excalifont,s=Pm.sm,l=gf(a),c=hf({fontFamily:a,fontSize:s}),d=Math.min(fI,r*(e.length>8?.56:.72)),m=ff(c,l),p=e.map((g,b)=>{let y=n[b],w=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>rr(z,c,l).width)),x=Math.max(m,d,w),v=Mm(g,c,x),T=rr(v,c,l),C=Math.cos(y),P=Math.sin(y),A=C>wl?"left":C<-wl?"right":"center",L=A==="center"?T.width/2:0,_=Math.abs(C)*L+Math.abs(P)*(T.height/2),k=ga+_+EI,D=t+C*(r+k),O=o+P*(r+k),Y=P>wl?$n/3:P<-wl?-$n/3:0;return Ea({backgroundColor:i,..._e,text:v,originalText:g,x:D,y:O+Y,fontFamily:a,fontSize:s,lineHeight:l,textAlign:A,verticalAlign:"middle"})}),u=Math.min(...p.map(g=>g.y)),E=Math.max(...p.map(g=>g.y+g.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:E}},Ia=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=uf["Lilita One"],s=Pm.lg,l=gf(a),c=hf({fontFamily:a,fontSize:s}),d=e.map((v,T)=>{let C=v.title?.trim()||`Series ${T+1}`,P=Mm(C,c,ha),A=rr(P,c,l),L=or+df+A.width;return{label:C,displayLabel:P,color:n[T],width:L,height:A.height}}),m=Math.max(or/2,...d.map(v=>v.height/2)),p=Math.max(r,o+m+ga),u=Cm,E=or*.6,g=d.reduce((v,T)=>v+T.width,0)+Cm*Math.max(0,d.length-1),b=g+u*2,y=m*2+E*2,w=[];w.push(pf({..._e,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:vI.black,x:t-b/2,y:p-y/2,width:b,height:y,roughness:xI.architect,roundness:{type:bI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(v=>{w.push(pf({..._e,backgroundColor:v.color,type:"rectangle",x,y:p-or/2,width:or,height:or,fillStyle:"solid",strokeColor:v.color,roughness:xI.architect,roundness:{type:bI.PROPORTIONAL_RADIUS}})),w.push(Ea({..._e,text:v.displayLabel,originalText:v.label,autoResize:!1,x:x+or+df,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=v.width+Cm}),w},V7=(e,n,t,o)=>{if(rr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(rr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},Y7=(e,n,t,o)=>{if(rr(e,t,o).width<=n)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(a=>rr(a,t,o).width>n)&&n>=ff(t,o)?{wrapped:!0,text:II(e,t,n)}:{wrapped:!1,text:V7(e,n,t,o)}},PI=(e,n,t)=>{let o=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*o+n*r,height:e*r+n*o}},yI=e=>e.includes("..."),X7=(e,n,t,o,r)=>{let i=Math.max(dI,Math.ceil(ff(o,r))),a=Math.max(i,Math.floor(n)),s=[];for(let u=a;u>=i;u-=4)s.push(u);s[s.length-1]!==i&&s.push(i);let l=u=>{let E=yI(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
|
|
15
|
-
`).length;return{ellipsified:E,visibleChars:g,lineCount:b}},c=(u,E)=>{let g=l(u),b=l(E);return g.ellipsified!==b.ellipsified?!g.ellipsified:g.visibleChars!==b.visibleChars?g.visibleChars>b.visibleChars:g.lineCount!==b.lineCount?g.lineCount<b.lineCount:u.rotatedHeight<E.rotatedHeight},d=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=
|
|
13
|
+
`,n),r=e.slice(t,o===-1?e.length:o);return VN(r)?"rtl":"ltr"},d7=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},m7=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=d7(e),a=document.createElement("div"),s=document.createTextNode(e),l=document.createRange(),c=[];a.dir=o,Object.assign(a.style,{position:"fixed",top:"0",left:"0",margin:0,padding:0,border:0,opacity:"0",pointerEvents:"none",whiteSpace:"pre",font:n,lineHeight:`${t}px`}),a.append(s),document.body.append(a);try{for(let u of i){l.setStart(s,u),l.setEnd(s,u);let E=l.getBoundingClientRect();if(!Number.isFinite(E.left))return null;c.push(E.left)}}catch{return null}finally{a.remove()}let d=Math.min(...c),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(c[u]-d-r);E<p&&(p=E,m=i[u])}return m},j2=({onChange:e,onSubmit:n,getViewportCoords:t,element:o,canvas:r,excalidrawContainer:i,app:a,autoSelect:s=!0,initialCaretSceneCoords:l=null})=>{let c=null,d=(F,W)=>{if(!W.style.fontFamily||!W.style.fontSize)return!1;let le=W.style.fontFamily.replace(/"/g,"");return H2({fontFamily:F.fontFamily})!==le||`${F.fontSize}px`!==W.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let F=a.state,W=a.scene.getElement(o.id);if(!W)return;let{textAlign:le,verticalAlign:we}=W,de=a.scene.getNonDeletedElementsMap();if(W&&Z2(W)){let he=W.x,ve=W.y,ae=mf(W,a.scene.getNonDeletedElementsMap()),fe=W.width,rt=W.height,Ge=W.width,Pe=W.height;if(ae&&W.containerId){if(Cm(ae)){let nn=$N.getBoundTextElementPosition(ae,W,de);he=nn.x,ve=nn.y}let $t=d(W,u),Sn;if($t?Sn=Y2(ae.id,ae.height):(Sn=KN[ae.id],Sn||(Sn=Y2(ae.id,ae.height))),Ge=X2(ae,W),Pe=QN(ae,W),!Cm(ae)&&rt>Pe){let nn=K2(rt,ae.type);a.scene.mutateElement(ae,{height:nn}),V2(ae,a.scene);return}else if(!Cm(ae)&&ae.height>Sn.height&&rt<Pe){let nn=K2(rt,ae.type);a.scene.mutateElement(ae,{height:nn}),V2(ae,a.scene)}else{let{x:nn,y:yi}=e7(ae,W,de);he=nn,ve=yi}}let[Wn,zo]=t(he,ve);ae?fe+=.5:(Ge=(F.width-8-Wn)/F.zoom.value,fe=Math.min(fe,Ge)),rt*=1.05;let xi=G2(W),re=qN(W,ae),lt=(F.height-zo)/F.zoom.value;Object.assign(u.style,{font:xi,lineHeight:W.lineHeight,width:`${fe}px`,height:`${rt}px`,left:`${Wn}px`,top:`${zo}px`,transform:l7(fe,rt,re,F,Ge,lt),textAlign:le,verticalAlign:we,color:WN(W.strokeColor,F.theme===HN.DARK),opacity:W.opacity/100,maxHeight:`${lt}px`}),c={angle:re,font:xi,height:W.height,lineHeightPx:o7(W.fontSize,W.lineHeight),textAlign:le,width:W.width,x:he,y:ve},u.scrollTop=0,U2()&&(u.style.fontFamily=H2(W)),a.scene.mutateElement(W,{x:he,y:ve})}},u=document.createElement("textarea");u.dir="auto",u.tabIndex=0,u.dataset.type="wysiwyg",u.wrap="off",u.classList.add("excalidraw-wysiwyg");let E="pre",g="normal";(s7(o)||!o.autoResize)&&(E="pre-wrap",g="break-word"),Object.assign(u.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:g,whiteSpace:E,overflowWrap:"break-word",boxSizing:"content-box"}),u.value=o.originalText,p();let b=()=>{if(!l||!c)return null;let F=c,W=W2(F.x+F.width/2,F.y+F.height/2),[le,we]=YN(W2(l.x,l.y),W,-F.angle),de=le-F.x,he=we-F.y,ve=a7(u.value,F.font,E==="pre-wrap"?F.width:1/0),ae=Math.max(0,Math.min(ve.length-1,Math.floor(he/F.lineHeightPx))),fe=ve[ae],rt=c7(u.value,fe.start),Ge=r7(fe.text,F.font),Pe=F.textAlign==="center"?(F.width-Ge)/2:F.textAlign==="right"?F.width-Ge:0,Wn=de-Pe;if(!fe.text)return fe.start;let zo=m7({text:fe.text,font:F.font,lineHeightPx:F.lineHeightPx,direction:rt,targetX:Wn});return fe.start+(zo||0)},y=(()=>{let F=b();return F===null?null:{start:F,end:F}})();e&&(u.onpaste=async F=>{let W=fw(F),le=null;if(W.has(df.excalidrawClipboard)||W.has(df.excalidraw)){F.preventDefault(),le=await Wr(F);try{let ae=await Vd(le);if(ae.elements){let fe=XN(ae.elements);if(fe){let{selectionStart:rt,selectionEnd:Ge,value:Pe}=u;u.value=Pe.slice(0,rt)+fe+Pe.slice(Ge);let Wn=rt+fe.length;u.selectionStart=u.selectionEnd=Wn,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}le=le||await Wr(F);let we=le.findByType(df.text);if(!we)return;let de=$2(we.value);if(!de)return;let he=mf(o,a.scene.getNonDeletedElementsMap()),ve=G2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(he){let ae=t7(he,a.scene.getNonDeletedElementsMap()),fe=i7(`${u.value}${de}`,ve,X2(he,ae)),rt=n7(fe,ve);u.style.width=`${rt}px`}},u.oninput=()=>{let F=$2(u.value);if(u.value!==F){let W=u.selectionStart;u.value=F,u.selectionStart=W,u.selectionEnd=W}e(u.value)}),u.onkeydown=F=>{if(!F.shiftKey&&Sd.keyTest(F))F.preventDefault(),a.actionManager.executeAction(Sd),p();else if(!F.shiftKey&&Cd.keyTest(F))F.preventDefault(),a.actionManager.executeAction(Cd),p();else if(!F.shiftKey&&Pd.keyTest(F))F.preventDefault(),a.actionManager.executeAction(Pd),p();else if(_h.keyTest(F))a.actionManager.executeAction(_h);else if(Rh.keyTest(F))a.actionManager.executeAction(Rh);else if(F.key===Cl.ESCAPE)F.preventDefault(),D=!0,_();else if(Xr.keyTest(F))F.preventDefault(),_(),a.actionManager.executeAction(Xr);else if(F.key===Cl.ENTER&&F[Cl.CTRL_OR_CMD]){if(F.preventDefault(),F.isComposing||F.keyCode===229)return;D=!0,_()}else if(F.key===Cl.TAB||F[Cl.CTRL_OR_CMD]&&(F.code===lf.BRACKET_LEFT||F.code===lf.BRACKET_RIGHT)){if(F.preventDefault(),F.isComposing)return;F.shiftKey||F.code===lf.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let w=4,x=" ".repeat(w),I=new RegExp(`^ {1,${w}}`),T=()=>{let{selectionStart:F,selectionEnd:W}=u,le=P(),we=u.value;le.forEach(de=>{let he=we.slice(0,de),ve=we.slice(de);we=`${he}${x}${ve}`}),u.value=we,u.selectionStart=F+w,u.selectionEnd=W+w*le.length},C=()=>{let{selectionStart:F,selectionEnd:W}=u,le=P(),we=[],de=u.value;le.forEach(he=>{let ve=de.slice(he,he+w).match(I);if(ve){let ae=de.slice(0,he),fe=de.slice(he+ve[0].length);de=`${ae}${fe}`,we.push(he)}}),u.value=de,we.length&&(F>we[we.length-1]?u.selectionStart=Math.max(F-w,we[we.length-1]):u.selectionStart=F,u.selectionEnd=Math.max(u.selectionStart,W-w*we.length))},P=()=>{let{selectionStart:F,selectionEnd:W,value:le}=u,we=le.slice(0,F).match(/[^\n]*$/)[0].length;return F=F-we,le.slice(F,W).split(`
|
|
14
|
+
`).reduce((he,ve,ae,fe)=>he.concat(ae?he[ae-1]+fe[ae-1].length+1:F),[]).reverse()},A=F=>{F.target instanceof HTMLCanvasElement&&(F.preventDefault(),F.stopPropagation())},D=!1,_=()=>{if(G)return;G=!0,k();let F=a.scene.getElement(o.id);if(!F)return;let W=mf(F,a.scene.getNonDeletedElementsMap());if(W){if(u.value.trim()){let le=jN(W);!le||le!==o.id?a.scene.mutateElement(W,{boundElements:(W.boundElements||[]).concat({type:"text",id:o.id})}):Cm(W)&&ZN(W)}else a.scene.mutateElement(W,{boundElements:W.boundElements?.filter(le=>!Z2(le))});JN(F,W,a.scene)}n({viaKeyboard:D,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,te&&te.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",A,!0),window.removeEventListener("pointerdown",V),window.removeEventListener("pointerup",L),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),U(),z(),K(),u.remove()},L=F=>{window.removeEventListener("pointerup",L);let W=F?.target,le=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),we=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content"),de=(W instanceof HTMLElement||W instanceof SVGElement)&&(!!W.closest(`.${cf.SHAPE_ACTIONS_MENU}`)||!!W.closest(".compact-shape-actions-island"));setTimeout(()=>{de||le||we||(u.onblur=_,u.focus(),y&&(u.setSelectionRange(y.start,y.end),y=null))})},B=()=>{u.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",_)},V=F=>{let W=F?.target;if(F.button===GN.WHEEL){W instanceof HTMLTextAreaElement&&(F.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(F)),B();return}let le=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),we=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content");(F.target instanceof HTMLElement||F.target instanceof SVGElement)&&(F.target.closest(`.${cf.SHAPE_ACTIONS_MENU}, .${cf.ZOOM_ACTIONS}`)||F.target.closest(".compact-shape-actions-island"))&&!UN(F.target)||le||we?B():F.target instanceof HTMLCanvasElement&&!U2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(F=>{a.state.theme!==m&&p()}),U=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),K=a.onScrollChangeEmitter.on(()=>{p()}),G=!1;s&&!y&&u.select(),L();let te=null;return r&&"ResizeObserver"in window?(te=new window.ResizeObserver(()=>{p()}),te.observe(r)):window.addEventListener("resize",p),u.onpointerdown=F=>F.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",V,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as Pm}from"@excalidraw/common";import{getCommonBounds as p7}from"@excalidraw/element";var Po=4,gn=6,q2="rgba(0,0,0,0.3)",J2=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=p7(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(Pm("sat"))||0,bottom:parseInt(Pm("sab"))||0,left:parseInt(Pm("sal"))||0,right:parseInt(Pm("sar"))||0},m=Kn().rtl,p=-o.scrollX+d.left,u=-o.scrollY+d.top,E=p+l-d.right,g=u+c-d.bottom,b=Math.min(r,p),y=Math.min(i,u),w=Math.max(a,E),x=Math.max(s,g),I=a-r,T=s-i,C=w-b,P=x-y,A=Math.max(Po*2,d.left+d.right)+gn*2,D=n*(l/C)-A,_=Math.max(Po*2,d.top+d.bottom)+gn*2,k=t*(c/P)-_,L=C>I?C*o.zoom.value/(D+A):n/(D+A),B=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===w?null:{x:Math.max(d.left,Po)+gn+(p-b)/C*n,y:t-gn-Math.max(Po,d.bottom),width:D,height:gn,deltaMultiplier:L},vertical:u===y&&g===x?null:{x:m?Math.max(d.left,Po):n-gn-Math.max(d.right,Po),y:Math.max(d.top,Po)+gn+(u-y)/P*t,width:gn,height:k,deltaMultiplier:B}}},pf=(e,n,t)=>{let[o,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=n&&n<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:o||r,isOverHorizontal:o,isOverVertical:r}};import{pointFrom as D7}from"@excalidraw/math";import{getElementLineSegments as L7}from"@excalidraw/element";import{LinearElementEditor as _7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as R7,isLinearElement as N7}from"@excalidraw/element";import{getFrameChildren as B7}from"@excalidraw/element";import{selectGroupsForSelectedElements as F7}from"@excalidraw/element";import{arrayToMap as O7,easeOut as iI,isShallowEqual as z7}from"@excalidraw/common";import{simplify as u7}from"points-on-curve";import{polygonFromPoints as h7,lineSegment as Mm,pointFrom as Sa,pointOnLineSegment as g7,polygonIncludesPointNonZero as f7,PRECISION as km}from"@excalidraw/math";import{boundsContainBounds as eI,computeBoundTextPosition as E7,doBoundsIntersect as b7,elementOverlapsWithFrame as x7,getBoundTextElement as tI,getContainingFrame as y7,getElementBounds as nI,intersectElementWithLineSegment as w7,isBoundToContainer as oI,pointInsideBoundsInclusive as v7}from"@excalidraw/element";var rI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=u7(n,s));let d=t.filter(g=>!g.locked&&!oI(g));a.clear(),i.clear();let m=n.reduce((g,b)=>[Math.min(g[0],b[0]),Math.min(g[1],b[1]),Math.max(g[2],b[0]),Math.max(g[3],b[1])],[1/0,1/0,-1/0,-1/0]),p=h7(c),u=[m[0]-km,m[1]-km,m[2]+km,m[3]+km];for(let g of d){let b=nI(g,o),y=I7(g,b,o),w=T7(b,y);if(b7(m,w)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!eI(u,w))continue;let x=S7(g,o,r,y),I=k7(p,x,w,l);l==="contain"?I&&!Q2(c,g,o,y)&&a.add(g.id):I?a.add(g.id):Q2(c,g,o,y)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?P7([...a],o):[...i,...a]}},I7=(e,n,t)=>{let o=y7(e,t);if(!o)return null;let r=nI(o,t);return eI(r,n)?null:x7(e,o,t)?r:null},T7=(e,n)=>n?[Math.max(e[0],n[0]),Math.max(e[1],n[1]),Math.min(e[2],n[2]),Math.min(e[3],n[3])]:e,S7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=tI(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?C7(s,o):s},C7=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[c,d]]of e){let m=c-s,p=d-l,u=0,E=1,g=!0;for(let[b,y]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){if(b===0){if(y<0){g=!1;break}continue}let w=y/b;if(b<0){if(w>E){g=!1;break}u=Math.max(u,w)}else{if(w<u){g=!1;break}E=Math.min(E,w)}}g&&a.push(Mm(Sa(s+u*m,l+u*p),Sa(s+E*m,l+E*p)))}return a},P7=(e,n)=>{if(!e.some(r=>n.get(r)?.groupIds.length))return e;let t=new Map;for(let r of n.values()){let i=r.groupIds.at(-1);if(!i||r.locked||oI(r))continue;let a=t.get(i);a?a.push(r.id):t.set(i,[r.id])}if(!t.size)return e;let o=new Set(e);return e.filter(r=>{let i=n.get(r)?.groupIds.at(-1),a=i?t.get(i):null;return!a||a.every(s=>o.has(s))})},k7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>f7(a,e)||o==="contain"&&A7(a,e);return n.length===0?M7(t)[r](i):n[r](a=>a[r](i))},M7=([e,n,t,o])=>[Sa(e,n),Sa(t,n),Sa(t,o),Sa(e,o)],A7=(e,n)=>n.some((t,o)=>o>0&&g7(e,Mm(n[o-1],t))),Q2=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Mm(e[l],s)).concat([Mm(e[e.length-1],e[0])]),i=tI(n,t),a=(s,l)=>{let c=w7(s,t,l,0,!o);return o?c.some(d=>v7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...E7(n,i,t)},s))};var Am=class extends Rn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),s=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(iI(s),iI(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});v(this,"intersectedElements",new Set);v(this,"enclosedElements",new Set);v(this,"elementsSegments",null);v(this,"canvasTranslate",null);v(this,"keepPreviousSelection",!1);v(this,"selectElementsFromIds",t=>{this.app.setState(o=>{let r=t.reduce((l,c)=>(l[c]=!0,l),{});if(this.keepPreviousSelection)for(let l of Object.keys(o.selectedElementIds))r[l]=!0;for(let[l]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(l);if(c&&R7(c)){let d=B7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=F7({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],s=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!s.length&&N7(this.app.scene.getNonDeletedElement(a[0]))?new _7(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});v(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});v(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>D7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!z7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=O7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=L7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=rI({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,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(r)}})}startPath(t,o,r=!1){this.endPath(),super.startPath(t,o),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 G7,easeOut as aI,THEME as H7}from"@excalidraw/common";import{computeBoundTextPosition as U7,doBoundsIntersect as W7,getBoundTextElement as V7,getElementBounds as Y7,getElementLineSegments as X7,getFreedrawOutlineAsSegments as K7,getFreedrawOutlinePoints as $7,intersectElementWithLineSegment as sI,isArrowElement as Z7,isFreeDrawElement as lI,isLineElement as j7,isPointInElement as q7}from"@excalidraw/element";import{lineSegment as J7,lineSegmentsDistance as cI,pointFrom as gI,polygon as Q7,polygonIncludesPointNonZero as eB}from"@excalidraw/math";import{getElementsInGroup as dI}from"@excalidraw/element";import{shouldTestInside as tB}from"@excalidraw/element";import{hasBoundTextElement as mI,isBoundToContainer as pI}from"@excalidraw/element";import{getBoundTextElementId as uI}from"@excalidraw/element";var Dm=class extends Rn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),s=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(aI(s),aI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===H7.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});v(this,"elementsToErase",new Set);v(this,"groupsToErase",new Set)}startPath(t,o){this.endPath(),super.startPath(t,o),this.elementsToErase.clear()}addPointToPath(t,o,r=!1){return super.addPointToPath(t,o),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let o=super.getCurrentTrail()?.originalPoints?.map(s=>gI(s[0],s[1]))||[];if(o.length<2)return[];let r=J7(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=G7(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(hI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=dI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(pI(s)&&this.elementsToErase.delete(s.containerId),mI(s)){let d=uI(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&hI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=dI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(mI(s)){let d=uI(s);d&&this.elementsToErase.add(d)}pI(s)&&this.elementsToErase.add(s.containerId),this.elementsToErase.add(s.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},hI=(e,n,t,o)=>{let r=e[1],i=lI(n)?15:n.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],s=Y7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!W7(a,l))return!1;if(tB(n)&&q7(r,n,t))return!0;if(lI(n)){let d=$7(n),m=K7(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(cI(E,e)<=p)return!0;let u=Q7(...d.map(([E,g])=>gI(n.x+E,n.y+g)));return!!eB(e[0],u)}let c=V7(n,t);if(Z7(n)||j7(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=X7(n,t);for(let p of m)if(cI(p,e)<=d)return!0;return!1}return sI(n,t,e,0,!0).length>0||!!c&&sI({...c,...U7(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as EB}from"@excalidraw/common";import{newElement as bB}from"@excalidraw/element";import{COLOR_PALETTE as nB,DEFAULT_FONT_FAMILY as oB,DEFAULT_FONT_SIZE as rB,VERTICAL_ALIGN as iB}from"@excalidraw/common";var fI=44,EI=22,bI=66,xI=48,Pl=14,yI=304,wI=320,uf=5.87,vI=28,II=4,TI=2,hf=10,SI=10,CI=8,oo=12,Ca=256,ni=10,gf=4,Pa=oo*2,ff=oo*2,PI=100,kI=140,kl=.35,MI=oo/2,dr=20,Lm=oo*2,Ef=oo,Ne={fillStyle:"hachure",fontFamily:oB,fontSize:rB,opacity:100,roughness:1,strokeColor:nB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:iB.MIDDLE,locked:!1};import{pointFrom as ka}from"@excalidraw/math";import{COLOR_PALETTE as RI,DEFAULT_CHART_COLOR_INDEX as aB,FONT_FAMILY as yf,FONT_SIZES as _m,ROUNDNESS as AI,DEFAULT_FONT_SIZE as sB,getAllColorsSpecificShade as lB,getFontString as wf,getLineHeight as vf,ROUGHNESS as DI}from"@excalidraw/common";import{getApproxMinLineWidth as If,measureText as mr,newElement as xf,newLinearElement as bf,newTextElement as Ma,wrapText as NI}from"@excalidraw/element";var oi=lB(aB),cB=e=>e.labels?.length??e.series[0]?.values.length??0,Aa=(e,n)=>{if(!e)return!1;let t=cB(e);return t<2?!1:n==="radar"?t>=3:!0},LI=(e,n)=>{let t=n<=1?0:Math.min(bI,(n-1)*EI);return e+t},Rm=(e,n)=>{if(e==="line"){let o=LI(xI,n);return{slotWidth:o,gap:Pl,chartHeight:wI,xLabelMaxWidth:o+Pl*3+hf}}let t=LI(fI,n);return{slotWidth:t,gap:Pl,chartHeight:yI,xLabelMaxWidth:t+Pl*3+hf}},Da=(e,n)=>{let t=(n.slotWidth+n.gap)*e.series[0].values.length+n.gap,o=n.chartHeight+n.gap*2;return{chartWidth:t,chartHeight:o}},BI=()=>{let e=Ca+ff*2,n=Ca+ff*2;return{chartWidth:e,chartHeight:n}},dB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},La=(e,n)=>{if(e<=0||oi.length===0)return[];let t=oi.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(s,l)=>l).filter(s=>s!==o));for(;r.length<i;){let s=-1,l=-1,c=-1;for(let d of a){let m=r.map(E=>dB(d,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>l||p===l&&u>c)&&(s=d,l=p,c=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>oi[r[l%r.length]])},_a=e=>{if(oi.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*oi.length);let n=e.toString(),t=0;for(let o=0;o<n.length;o++)t=t*31+n.charCodeAt(o)|0;return Math.abs(t)%oi.length},Ra=e=>oi[e],FI=(e,n)=>{let t=e.flatMap(s=>s.values.map(l=>Math.max(0,l))),o=t.filter(s=>s>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=PI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},mB=e=>/\s/.test(e.trim()),Nm=(e,n,t)=>mB(e)?NI(e,n,t):e,OI=(e,n,t,o,r,i)=>{let a=yf.Excalifont,s=_m.sm,l=vf(a),c=wf({fontFamily:a,fontSize:s}),d=Math.min(kI,r*(e.length>8?.56:.72)),m=If(c,l),p=e.map((g,b)=>{let y=n[b],w=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>mr(z,c,l).width)),x=Math.max(m,d,w),I=Nm(g,c,x),T=mr(I,c,l),C=Math.cos(y),P=Math.sin(y),A=C>kl?"left":C<-kl?"right":"center",D=A==="center"?T.width/2:0,_=Math.abs(C)*D+Math.abs(P)*(T.height/2),k=Pa+_+MI,L=t+C*(r+k),B=o+P*(r+k),V=P>kl?oo/3:P<-kl?-oo/3:0;return Ma({backgroundColor:i,...Ne,text:I,originalText:g,x:L,y:B+V,fontFamily:a,fontSize:s,lineHeight:l,textAlign:A,verticalAlign:"middle"})}),u=Math.min(...p.map(g=>g.y)),E=Math.max(...p.map(g=>g.y+g.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:E}},Na=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=yf["Lilita One"],s=_m.lg,l=vf(a),c=wf({fontFamily:a,fontSize:s}),d=e.map((I,T)=>{let C=I.title?.trim()||`Series ${T+1}`,P=Nm(C,c,Ca),A=mr(P,c,l),D=dr+Ef+A.width;return{label:C,displayLabel:P,color:n[T],width:D,height:A.height}}),m=Math.max(dr/2,...d.map(I=>I.height/2)),p=Math.max(r,o+m+Pa),u=Lm,E=dr*.6,g=d.reduce((I,T)=>I+T.width,0)+Lm*Math.max(0,d.length-1),b=g+u*2,y=m*2+E*2,w=[];w.push(xf({...Ne,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:RI.black,x:t-b/2,y:p-y/2,width:b,height:y,roughness:DI.architect,roundness:{type:AI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(I=>{w.push(xf({...Ne,backgroundColor:I.color,type:"rectangle",x,y:p-dr/2,width:dr,height:dr,fillStyle:"solid",strokeColor:I.color,roughness:DI.architect,roundness:{type:AI.PROPORTIONAL_RADIUS}})),w.push(Ma({...Ne,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+dr+Ef,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=I.width+Lm}),w},pB=(e,n,t,o)=>{if(mr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(mr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},uB=(e,n,t,o)=>{if(mr(e,t,o).width<=n)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(a=>mr(a,t,o).width>n)&&n>=If(t,o)?{wrapped:!0,text:NI(e,t,n)}:{wrapped:!1,text:pB(e,n,t,o)}},zI=(e,n,t)=>{let o=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*o+n*r,height:e*r+n*o}},_I=e=>e.includes("..."),hB=(e,n,t,o,r)=>{let i=Math.max(vI,Math.ceil(If(o,r))),a=Math.max(i,Math.floor(n)),s=[];for(let u=a;u>=i;u-=4)s.push(u);s[s.length-1]!==i&&s.push(i);let l=u=>{let E=_I(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
|
|
15
|
+
`).length;return{ellipsified:E,visibleChars:g,lineCount:b}},c=(u,E)=>{let g=l(u),b=l(E);return g.ellipsified!==b.ellipsified?!g.ellipsified:g.visibleChars!==b.visibleChars?g.visibleChars>b.visibleChars:g.lineCount!==b.lineCount?g.lineCount<b.lineCount:u.rotatedHeight<E.rotatedHeight},d=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=uB(e,u,o,r),b=mr(g,o,r),y=zI(b.width,b.height,uf),w={originalText:e,text:g,metrics:b,rotatedWidth:y.width,rotatedHeight:y.height,wrapped:E},x=y.width-t;if(x<=0){(!d||c(w,d))&&(d=w);continue}(!m||x<m.overflow||x===m.overflow&&c(w,m.spec))&&(m={overflow:x,spec:w}),!_I(w.text)&&(!p||x<p.overflow||x===p.overflow&&c(w,p.spec))&&(p={overflow:x,spec:w})}return d||(p&&m&&p.overflow<=m.overflow+CI?p.spec:m.spec)},Bm=e=>{if(e.type!=="text")return e.y+e.height;let n=zI(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},Ml=(e,n,t,o,r)=>{let i=Ne.fontFamily,a=_m.sm,s=vf(i),l=wf({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-II*2+SI),d=t;return e.labels?.map((m,p)=>{let u=hB(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+TI+(u.rotatedHeight-u.metrics.height)/2;return Ma({backgroundColor:o,...Ne,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:uf,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},gB=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=Ma({backgroundColor:o,...Ne,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=Ma({backgroundColor:o,...Ne,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},fB=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=Da(e,r),s=bf({backgroundColor:o,...Ne,type:"line",x:n,y:t,width:i,points:[ka(0,0),ka(i,0)]}),l=bf({backgroundColor:o,...Ne,type:"line",x:n,y:t,height:a,points:[ka(0,0),ka(0,-a)]}),c=bf({backgroundColor:o,...Ne,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:ni,points:[ka(0,0),ka(i,0)]});return[s,l,c]},Fm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=Da(e,r),c=e.title?Ma({backgroundColor:o,...Ne,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-sB,roundness:null,textAlign:"center",fontSize:_m.xl,fontFamily:yf["Lilita One"]}):null,d=a?xf({backgroundColor:o,...Ne,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:RI.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...Ml(e,n,t,o,r),...gB(e,n,t,o,r,i),...fB(e,n,t,o,r)]};var GI=(e,n,t,o)=>{let r=e.series,i=Rm("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(T=>Math.max(0,T)))),s=_a(o),l=Ra(s),c=La(r.length,s),d=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,m=r.length>1?Math.max(2,(i.slotWidth-d*(r.length-1))/r.length):i.slotWidth,p=r.length*m+d*(r.length-1),u=(i.slotWidth-p)/2,E=r[0].values.flatMap((I,T)=>r.map((C,P)=>{let D=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return bB({backgroundColor:_,...Ne,type:"rectangle",fillStyle:r.length>1?"solid":Ne.fillStyle,strokeColor:r.length>1?_:Ne.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-D-i.gap,width:m,height:D})})),g=Fm(e,n,t,l,i,a,EB()),b=Ml(e,n,t,l,i),y=Math.max(t+i.gap/2,...b.map(I=>Bm(I))),{chartWidth:w}=Da(e,i),x=Na(r,c,n+w/2,y,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as Tf}from"@excalidraw/math";import{isDevEnv as xB}from"@excalidraw/common";import{newElement as yB,newLinearElement as HI}from"@excalidraw/element";var UI=(e,n,t,o)=>{let r=e.series,i=Rm("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=_a(o),l=Ra(s),c=La(r.length,s),d=r.map((x,I)=>{let T=x.values.map((_,k)=>Tf(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...T.map(_=>_[0])),P=Math.max(...T.map(_=>_[1])),A=Math.min(...T.map(_=>_[0])),D=Math.min(...T.map(_=>_[1]));return HI({backgroundColor:"transparent",...Ne,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-D,width:C-A,strokeColor:c[I],strokeWidth:2,points:T})}),m=r.flatMap((x,I)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,A=-(T/a)*i.chartHeight+i.gap/2;return yB({backgroundColor:c[I],...Ne,fillStyle:"solid",strokeColor:c[I],strokeWidth:2,type:"ellipse",x:n+P+i.slotWidth/2,y:t+A-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((x,I)=>Math.max(0,...r.map(T=>T.values[I]??0))).map((x,I)=>{let T=I*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return HI({backgroundColor:l,...Ne,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:ni,points:[Tf(0,0),Tf(0,C)]})}),E=Fm(e,n,t,l,i,a,xB()),g=Ml(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Bm(x))),{chartWidth:y}=Da(e,i),w=Na(r,c,n+y/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...w]};var Nn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},wB=(e,n)=>e.slice(1).every(t=>Nn(t[n])!==null),WI=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Nn(m)===null),s=a?e.slice(1):e;if(s.length<1)return{ok:!1,reason:"No data rows"};if(s.some(m=>m.slice(1).some(p=>Nn(p)===null)))return{ok:!1,reason:"Value is not numeric"};if(n-1>s.length){let m=a?e[0].slice(1).map(E=>E.trim()):null,p=s.map(E=>({title:E[0]?.trim()||null,values:E.slice(1).map(g=>Nn(g))}));return{ok:!0,data:{title:p.length===1?p[0].title:a&&e[0][0].trim()||null,labels:m,series:p}}}let d=e[0].slice(1).map((m,p)=>{let u=p+1,E=`Series ${u}`;return{title:a&&m.trim()||E,values:s.map(g=>Nn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:s.map(m=>m[0]),series:d}}}if(n===1){if(!wB(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Nn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>Nn(c[0]));return l.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:s,labels:null,series:[{title:s,values:l}]}}}let t=Nn(e[0][1])===null,o=t?e.slice(1):e;if(o.length<2)return{ok:!1,reason:"Less than 2 rows"};if(o.some(a=>Nn(a[1])===null))return{ok:!1,reason:"Value is not numeric"};let i=t?e[0][1]:null;return{ok:!0,data:{title:i,labels:o.map(a=>a[0]),series:[{title:i,values:o.map(a=>Nn(a[1]))}]}}},Om=e=>{let n=s=>e.replace(/\r\n?/g,`
|
|
16
16
|
`).split(`
|
|
17
|
-
`).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=n(s),c=l[0]?.length??0,d=l.length>0&&l.every(m=>m.length===c);return{delimiter:s,parsed:l,numCols:c,isConsistent:d}}),r=(t.find(s=>s.isConsistent&&s.numCols>1)??t.find(s=>s.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(s=>s.length===i)?LI(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ta}from"@excalidraw/math";import{FONT_FAMILY as eB,FONT_SIZES as tB,getFontString as nB,getLineHeight as oB,ROUGHNESS as DI}from"@excalidraw/common";import{measureText as rB,newLinearElement as bf,newTextElement as iB}from"@excalidraw/element";var _I=(e,n,t,o)=>{if(!ba(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,W)=>`Value ${W+1}`),i=e.series,{normalize:a,renderSteps:s}=SI(i,r.length),l=ya(o),c=va(l),d=wa(i.length,l),{chartWidth:m,chartHeight:p}=TI(),u=n+m/2,E=t-p/2,g=ha/2,b=r.map((z,W)=>-Math.PI/2+Math.PI*2*W/r.length),{axisLabels:y,axisLabelTopY:w,axisLabelBottomY:x}=CI(r,b,u,E,g,c),v=eB["Lilita One"],T=tB.xl,C=oB(v),P=nB({fontFamily:v,fontSize:T}),A=e.title?Mm(e.title,P,m+ga*2):null,L=A?rB(A,P,C):null,_=A?iB({backgroundColor:c,..._e,text:A,originalText:e.title??A,x:n+m/2,y:w-ga-L.height/2,fontFamily:v,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:lf},(z,W)=>{let Z=(W+1)/lf,H=g*Z,re=b.map(B=>Ta(Math.cos(B)*H,Math.sin(B)*H));return re.push(Ta(re[0][0],re[0][1])),bf({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:H*2,height:H*2,strokeStyle:"solid",roughness:DI.architect,opacity:$r,polygon:!0,points:re})}):[],D=b.map(z=>{let W=Math.cos(z)*g,Z=Math.sin(z)*g;return bf({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:Math.abs(W),height:Math.abs(Z),strokeStyle:"solid",roughness:DI.architect,opacity:$r,points:[Ta(0,0),Ta(W,Z)]})}),O=i.map((z,W)=>{let Z=b.map((H,re)=>{let B=z.values[re]??0,U=a(B,re)*g;return Ta(Math.cos(H)*U,Math.sin(H)*U)});return Z.push(Ta(Z[0][0],Z[0][1])),bf({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[W],strokeWidth:2,polygon:!0,points:Z})}),Y=Ia(i,d,u,x,t+$n*5,c);return[..._?[_]:[],...y,...k,...D,...O,...Y]};var xf=(e,n,t,o,r)=>e==="line"?AI(n,t,o,r):e==="radar"?_I(n,t,o,r):kI(n,t,o,r);import{clamp as _m,pointFrom as Sa,pointsEqual as pB,bezierEquation as WI,pointRotateRads as Rm,pointDistance as uB}from"@excalidraw/math";import{arrayToMap as hB,BIND_MODE_TIMEOUT as vl,DEFAULT_TRANSFORM_HANDLE_SPACING as VI,FRAME_STYLE as pn,getFeatureFlag as gB,invariant as FI,shouldRotateWithDiscreteAngle as YI,THEME as xo}from"@excalidraw/common";import{deconstructDiamondElement as Tf,deconstructRectanguloidElement as XI,elementCenterPoint as Ca,getDiamondBaseCorners as fB,FOCUS_POINT_SIZE as EB,getOmitSidesForEditorInterface as wf,getTransformHandles as bB,getTransformHandlesFromCoords as xB,hasBoundingBox as wB,hitElementItself as yB,isArrowElement as KI,isBindableElement as ZI,isElbowArrow as Pa,isFrameLikeElement as ka,isImageElement as Nm,isLinearElement as vB,isLineElement as IB,maxBindingDistance_simple as TB,isTextElement as SB,LinearElementEditor as un,getActiveTextElement as CB,getElementsInGroup as Sf,getSelectedGroupIds as PB,isSelectedViaGroup as kB,selectGroupsFromGivenElements as MB}from"@excalidraw/element";import{renderSelectionElement as AB}from"@excalidraw/element";import{getCommonBounds as Cf,getElementAbsoluteCoords as Tl}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as zI,isFocusPointVisible as LB}from"@excalidraw/element";import{pointFrom as St}from"@excalidraw/math";import{THEME as aB}from"@excalidraw/common";var sB="#ff6b6b",lB="#ff0000",RI=1,NI=2,BI=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===aB.LIGHT||n.zenModeEnabled?sB:lB,o=(n.zenModeEnabled?RI*1.5:RI)/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY);for(let r of n.snapLines)r.type==="pointer"?(e.lineWidth=o,e.strokeStyle=t,dB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,mB(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,cB(r,e,n));e.restore()},cB=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];mn(o,r,n)}for(let o of e.points)OI(o,t,n)},dB=(e,n,t)=>{OI(e.points[0],t,n),t.zenModeEnabled||mn(e.points[0],e.points[1],n)},OI=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?NI*1.5:NI)/t.zoom.value;o.beginPath(),o.moveTo(e-r,n-r),o.lineTo(e+r,n+r),o.moveTo(e+r,n-r),o.lineTo(e-r,n+r),o.stroke(),o.restore()},mn=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},mB=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(t==="horizontal"){let l=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||mn(St(e[0],e[1]-i),St(e[0],e[1]+i),r),mn(St(l[0]-s,l[1]-a),St(l[0]-s,l[1]+a),r),mn(St(l[0]+s,l[1]-a),St(l[0]+s,l[1]+a),r),o.zenModeEnabled||(mn(St(n[0],n[1]-i),St(n[0],n[1]+i),r),mn(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||mn(St(e[0]-i,e[1]),St(e[0]+i,e[1]),r),mn(St(l[0]-a,l[1]-s),St(l[0]+a,l[1]-s),r),mn(St(l[0]-a,l[1]+s),St(l[0]+a,l[1]+s),r),o.zenModeEnabled||(mn(St(n[0]-i,n[1]),St(n[0]+i,n[1]),r),mn(e,n,r))}};var DB=(e,n)=>{FI(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;FI(t,"midPointCoords is null"),Bm(t,e,n)},_B=(e,n,t)=>{let{elementId:o,hoverPointIndex:r}=n.selectedLinearElement;if(n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(r)||n.selectedLinearElement?.isDragging)return;let i=un.getElement(o,t);if(!i)return;let a=un.getPointAtIndexGlobalCoordinates(i,r,t);Bm(a,e,n)},Bm=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",as(n,e[0],e[1],un.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},RB=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!KI(i)||i.isDeleted)return;let a=r==="label"?un.getBoundTextElementCenter(i,t):un.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);Bm(a,e,n)},yf=(e,n,t,o,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)"),as(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},NB=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&ka(a)&&(e.translate(a.x,a.y),e.beginPath(),pn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,pn.radius/o.zoom.value):e.rect(-1,-1,a.width+1,a.height+1),e.clip(),e.translate(-a.x,-a.y)),n.element.type){case"magicframe":case"frame":e.save(),e.translate(n.element.x,n.element.y),e.lineWidth=pn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===xo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",pn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,pn.radius/o.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,n.element.width,n.element.height),e.restore();break;default:e.save();let s=Ca(n.element,t);switch(e.translate(s[0],s[1]),e.rotate(n.element.angle),e.translate(-s[0],-s[1]),e.translate(n.element.x,n.element.y),e.lineWidth=_m(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===xo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",n.element.type){case"ellipse":e.beginPath(),e.ellipse(n.element.width/2,n.element.height/2,n.element.width/2,n.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[l,c]=Tf(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break;default:{let[l,c]=XI(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break}e.restore();break}if(o.isMidpointSnappingEnabled&&!o.gridModeEnabled&&!i&&(ka(n.element)||ZI(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&un.getElement(s?.elementId,t),c=r&&yB({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&Pa(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Ca(n.element,t),p;if(n.element.type==="diamond"){let b=Ca(n.element,t);p=fB(n.element).map(y=>{let w=WI(y,.5),x=Rm(w,b,n.element.angle);return Sa(x[0],x[1])})}else p=[{x:n.element.width,y:n.element.height/2},{x:n.element.width/2,y:n.element.height},{x:0,y:n.element.height/2},{x:n.element.width/2,y:0}].map(y=>{let w=Sa(y.x+n.element.x,y.y+n.element.y),x=Rm(w,m,n.element.angle);return Sa(x[0],x[1])});let u=r&&p.reduce((b,y,w)=>{let x=uB(y,r);return w===-1||x<b.distance?{idx:w,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=TB(o.zoom)+n.element.strokeWidth/2;p.forEach((b,y)=>{let w=(!c||d)&&u?.idx===y&&u.distance<=g,x=!w&&(d||y===u?.idx&&u.distance<=g*2);w?(e.fillStyle=o.theme===xo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill()):x&&(e.fillStyle=o.theme===xo.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill())}),e.restore()}}},BB=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=vl-(a?.runtime??(s?0:vl)),c=_m(1/vl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&ka(m)&&(n.translate(m.x,m.y),n.beginPath(),pn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,pn.radius/r.zoom.value):n.rect(-1,-1,m.width+1,m.height+1),n.clip(),n.translate(-m.x,-m.y)),t.type){case"magicframe":case"frame":n.save(),n.translate(t.x,t.y),n.lineWidth=pn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===xo.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,pn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,pn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=Ca(t,o),E=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(n.translate(E,g),n.rotate(t.angle),n.translate(-E,-g),n.translate(t.x+r.scrollX-d,t.y+r.scrollY-d),n.lineWidth=_m(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===xo.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+d*2)/2,(t.height+d*2)/2,(t.width+d*2)/2,(t.height+d*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,y]=Tf(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,v,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break;default:{let[b,y]=XI(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,v,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break}n.restore();break}if(!s||(a?.runtime??0)>vl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!ka(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/vl*l;if(n.strokeStyle="rgba(0, 0, 0, 0.2)",n.lineWidth=1/r.zoom.value,n.setLineDash([4/r.zoom.value,4/r.zoom.value]),n.lineDashOffset=-u*10/r.zoom.value,n.beginPath(),n.ellipse(t.width/2,t.height/2,p,p,0,0,2*Math.PI),n.stroke(),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.ellipse(t.width/2,t.height/2,p*(1-c),p*(1-c),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!YI(e.lastPointerMoveEvent))){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let E=5/r.zoom.value,g=5/r.zoom.value,b=E+g,y;if(t.type==="diamond"){let[,w]=Tf(t),x=Ca(t,o);y=w.map(v=>{let T=WI(v,.5),C=Rm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let w=Ca(t,o);y=[{x:t.width/2,y:0},{x:t.width,y:t.height/2},{x:t.width/2,y:t.height},{x:0,y:t.height/2}].map(v=>{let T=Sa(v.x+t.x,v.y+t.y),C=Rm(T,w,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}y.forEach(w=>{n.clearRect(w.x-b,w.y-b,b*2,b*2)}),n.fillStyle=r.theme===xo.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,y.forEach(w=>{n.beginPath(),n.arc(w.x,w.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},OB=(e,n,t,o,r,i,a)=>{if(t===null)return;if(gB("COMPLEX_BINDINGS"))return BB(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Sa(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&YI(e.lastPointerMoveEvent);NB(n,t,o,r,s,l),n.restore()},$I=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=t,u=a-r,E=s-i,b=(t.padding??VI*2)/n.zoom.value,y=8/n.zoom.value,w=4/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=(p?4:1)/n.zoom.value;let x=l.length;for(let v=0;v<x;++v)e.strokeStyle=l[v],m&&e.setLineDash([y,w+(y+w)*(x-1)]),e.lineDashOffset=(y+w)*v,ss(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},FB=(e,n,t,o)=>{let[r,i,a,s]=Tl(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=pn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),ss(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,pn.radius/n.zoom.value),e.restore()},HI=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[m,p,u,E]=Cf(d);return{angle:0,x1:m,x2:u,y1:p,y2:E,selectionColors:r,dashed:i,cx:m+(u-m)/2,cy:p+(E-p)/2,activeEmbeddable:!1}},c=d=>{let m=Sf(t,d);return l(m)};Object.entries(MB(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>$I(e,n,d))},vf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=un.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=un,a=n.selectedLinearElement?.isEditing?i:i/2,s=Pa(t),l=IB(t);if(r.forEach((c,d)=>{if(s&&d!==0&&d!==r.length-1)return;let m=d>0&&(d!==r.length-1||!l||!t.polygon)&&pB(c,d===r.length-1?r[0]:r[d-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!p&&d===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),yf(e,n,c,a,p,!1,m)}),Pa(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{un.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||yf(e,n,Sa((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else un.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(Pa(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&yf(e,n,d,i/2,!1,!0,!1)});e.restore()},zB=(e,n,t,o)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([4/n.zoom.value,4/n.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(o[0],o[1]),e.stroke(),e.restore()},HB=(e,n,t,o,r)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",as(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},GI=({arrow:e,appState:n,type:t,context:o,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!ZI(a)||a.isDeleted)return;let s=zI(i.fixedPoint,a,r);if(!LB(s,e,a,r,n,t))return;let l=n.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,m=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&Bm(s,o,n),!(m&&c)){let p=zI(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=un.getPointAtIndexGlobalCoordinates(e,d,r);zB(o,n,E,p),HB(o,n,p,EB/1.5,u)}},UI=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?as(e,s+c/2,l+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):ss(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},GB=(e,n,t,o,r)=>{let[i,a,,,s,l]=Tl(o,r),c=3,d=20,m=c/t.zoom.value,p=m/2,u=s-i+m,E=l-a+m,g=Math.min(d/t.zoom.value,u),b=Math.min(d/t.zoom.value,E);e.save(),e.fillStyle=n.selectionColor,e.strokeStyle=n.selectionColor,e.lineWidth=m,[[[-u,-E],[0,p],[g,p],[p,0],[p,b]],[[u-p,-E],[p,p],[-g+p,p],[0,0],[0,b]],[[-u,E],[0,-p],[g,-p],[p,0],[p,-b]],[[u-p,E],[p,-p],[-g+p,-p],[0,0],[0,-b]]].forEach(w=>{let[[x,v],[T,C],[P,A],[L,_],[k,D]]=w;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,v+C),e.lineTo(x+P,v+A),e.stroke(),e.beginPath(),e.moveTo(x+L,v+_),e.lineTo(x+k,v+D),e.stroke(),e.restore()}),e.restore()},UB=(e,n,t,o)=>{n.save();let r=Jg(t.zoom.value),i=e.width+r*2,a=e.height+r*2,s=e.x+e.width/2,l=e.y+e.height/2,c=-(e.width/2+r),d=-(e.height/2+r);n.translate(s+t.scrollX,l+t.scrollY),n.rotate(e.angle),n.lineWidth=1/t.zoom.value,n.strokeStyle=o,n.globalAlpha=.5,n.setLineDash([6/t.zoom.value,4/t.zoom.value]),n.strokeRect(c,d,i,a),n.restore()},WB=(e,n,t,o,r)=>{let i=Qg(e,t.zoom.value,r);i&&(n.save(),n.globalAlpha=.5,n.lineWidth=1.5/t.zoom.value,n.lineCap="round",n.strokeStyle=o,n.beginPath(),n.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),n.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),n.stroke(),n.restore())},VB=(e,n,t,o,r,i)=>{for(let a of n){if(!Nm(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Il(a,t,r,"center");d&&qI(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,r,s?.downloadError??void 0)}else{let d=o.imageLoadingProgress.get(a.fileId);if(d!==void 0){let m=Il(a,t,r,"center");m&&jI(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Il(a,t,r,"top-right");d&&XB(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Il=(e,n,t,o)=>{if(!Nm(e))return null;let[r,i,a,s]=Tl(e,n),l=t.zoom.value,c=Math.min(a-r,s-i)*l,d=Math.min(o==="center"?14:11.7,c/(o==="center"?4:4.62))/l,m=Math.min((o==="center"?3:2.6)/l,d/2);if(d<=0||m<=0)return null;if(o==="top-right"){let p=6/l;return{centerX:a-p-d,centerY:i+p+d,radius:d,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:d,lineWidth:m}},jI=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===xo.DARK?"rgba(255, 255, 255, 0.35)":"rgba(0, 0, 0, 0.25)"),e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),i>0&&(e.strokeStyle=l?.color??s,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*_m(i,0,1)),e.stroke()),e.restore()},If=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,YB=(e,n,t,o,r)=>{e.save(),e.strokeStyle=r.color,e.lineWidth=r.lineWidth,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(n-o*.48,t+o*.26),e.bezierCurveTo(n-o*.68,t+o*.14,n-o*.58,t-o*.22,n-o*.34,t-o*.22),e.bezierCurveTo(n-o*.14,t-o*.48,n+o*.26,t-o*.48,n+o*.34,t-o*.18),e.bezierCurveTo(n+o*.58,t-o*.2,n+o*.7,t+o*.26,n+o*.42,t+o*.26),e.lineTo(n-o*.48,t+o*.26),e.stroke(),e.restore()},XB=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??If("--color-primary",s),d=i.color??If("--color-warning-darkest","#ec8b14");if(l==="failed"){qI(e,n,t,o,a,{color:i.color??If("--color-danger","#e03131")});return}if(l==="uploading"&&jI(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),YB(e,n,t-o*.02,o*1.125,{color:l==="error"?d:c,lineWidth:Math.max(r*.75,1/a.zoom.value)}),l==="error"){e.save(),e.strokeStyle=d,e.fillStyle=d,e.lineWidth=Math.max(r*.75,1/a.zoom.value),e.lineCap="round",e.beginPath();let m=o*.18,p=t-o*.09;e.moveTo(n-m,p-m),e.lineTo(n+m,p+m),e.moveTo(n+m,p-m),e.lineTo(n-m,p+m),e.stroke(),e.restore()}else l==="pending"&&(e.save(),e.strokeStyle=c,e.lineWidth=Math.max(r*.65,1/a.zoom.value),e.lineCap="round",e.beginPath(),e.moveTo(n,t+o*.072),e.lineTo(n,t-o*.18),e.moveTo(n-o*.144,t-o*.036),e.lineTo(n,t-o*.18),e.lineTo(n+o*.144,t-o*.036),e.stroke(),e.restore())},qI=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",s=Math.max(o*.16,1.5/r.zoom.value);i?.backgroundColor&&(e.fillStyle=i.backgroundColor,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.fill()),e.strokeStyle=a,e.lineWidth=s,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),e.strokeStyle=a,e.fillStyle=a,e.lineCap="round",e.beginPath(),e.moveTo(n,t-o*.45),e.lineTo(n,t+o*.12),e.stroke(),e.beginPath(),e.arc(n,t+o*.48,o*.11,0,Math.PI*2),e.fill(),i?.text&&(e.font=`600 ${Math.max(11/r.zoom.value,o*.65)}px Assistant, system-ui, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif`,e.textAlign="center",e.textBaseline="top",e.fillText(i.text,n,t+o+6/r.zoom.value)),e.restore()},KB=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:c,animationState:d,deltaTime:m})=>{if(n===null)return{};let[p,u]=bc(n,a),E=d,g=xc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),g.scale(s.zoom.value,s.zoom.value);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&vf(g,s,b,t),s.selectionElement&&!s.isCropping)try{AB(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let y=CB(r,s);if(y&&!y.autoResize&&WB(y,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&UB(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:OB(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&RB(g,s,i),s.frameToHighlight&&FB(g,s,s.frameToHighlight,t),s.elementsToHighlight&&HI(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:Sf(i,s.activeLockedId);HI(g,s,P,{colors:["#ced4da"],dashed:!0})}let w=r.some(C=>ka(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&vf(g,s,r[0],t);let x=s.selectedLinearElement,v=x&&un.getElement(x.elementId,i);if(v&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?DB(g,s):(Pa(v)?x.hoverPointIndex===0||x.hoverPointIndex===v.points.length-1:x.hoverPointIndex>=0)&&_B(g,s,t)),KI(v)&&(GI({arrow:v,elementsMap:i,appState:s,context:g,type:"start"}),GI({arrow:v,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=wB(r,s,c),P=r.length===1&&vB(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&vf(g,s,r[0],t);let A=l.selectionColor||"#000";if(C){let L=hB(r),_=[];for(let D of t.values()){let O=[],Y=l.remoteSelectedElementIds.get(D.id);if(P&&Pa(D)&&(D.startBinding||D.endBinding)||(L.has(D.id)&&!kB(s,D)&&O.push(A),Y&&O.push(...Y.map(z=>Gr(z,s.collaborators.get(z))))),O.length){let[z,W,Z,H,re,B]=Tl(D,t,!0);_.push({angle:D.angle,x1:z,y1:W,x2:Z,y2:H,selectionColors:D.locked?["#ced4da"]:O,dashed:!!Y||D.locked,cx:re,cy:B,activeEmbeddable:s.activeEmbeddable?.element===D&&s.activeEmbeddable.state==="active",padding:D.id===s.croppingElementId||Nm(D)?0:void 0})}}let k=D=>{let O=Sf(t,D),[Y,z,W,Z]=Cf(O);_.push({angle:0,x1:Y,x2:W,y1:z,y2:Z,selectionColors:O.some(H=>H.locked)?["#ced4da"]:["#000"],dashed:!0,cx:Y+(W-Y)/2,cy:z+(Z-z)/2,activeEmbeddable:!1})};for(let D of PB(s))k(D);s.editingGroupId&&k(s.editingGroupId),_.forEach(D=>$I(g,s,D))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let L=bB(r[0],s.zoom,t,"mouse",wf(c));if(!s.viewModeEnabled&&C&&!SB(s.editingTextElement)&&!s.croppingElementId&&UI(g,l,s,L,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Nm(_)&&GB(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(L=>L.locked)){let L=VI*2/s.zoom.value;g.fillStyle="#fff";let[_,k,D,O]=Cf(r,t),Y=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=A,ss(g,_-L,k-L,D-_+L*2,O-k+L*2,(_+D)/2,(k+O)/2,0),g.lineWidth=z,g.setLineDash(Y);let W=xB([_,k,D,O,(_+D)/2,(k+O)/2],0,s.zoom,"mouse",w?{...wf(c),rotation:!0}:wf(c));r.some(Z=>!Z.locked)&&UI(g,l,s,W,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:A})=>{let L=t.get(C);if(L){let[_,k,,,D,O]=Tl(L,t,!0);g.save(),s.theme===xo.LIGHT?P?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":P?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let Y=ka(L)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(D,O),g.rotate(L.angle),A.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/Y-D,k+z.offsetY/Y-O,z.width/Y,z.height/Y)}),g.restore()}}),BI(g,s),VB(g,o,t,e,s,l.selectionColor),g.restore(),Ey({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=H2(t,p,u,s),g.save(),g.fillStyle=z2,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&Xd(g,C.x,C.y,C.width,C.height,dn/2)}),g.restore()),{scrollBars:T,animationState:E}},Pf=e=>{let n=KB(e);return e.callback(n),n};import{useEffect as kl,useMemo as JI,useRef as Df,useState as ZB}from"react";import{bumpVersion as Sl,getLinearElementSubType as Aa,mutateElement as _f,updateElbowArrowPoints as $B}from"@excalidraw/element";import{pointFrom as Fm,pointRotateRads as jB}from"@excalidraw/math";import{hasBoundTextElement as qB,isArrowBoundToElement as JB,isArrowElement as QB,isElbowArrow as eO,isLinearElement as Of,isUsingAdaptiveRadius as tO}from"@excalidraw/element";import{getCommonBoundingBox as nO,getElementAbsoluteCoords as oO}from"@excalidraw/element";import{getBoundTextElement as oT,getBoundTextMaxHeight as rO,getBoundTextMaxWidth as iO,redrawTextBoundingBox as aO}from"@excalidraw/element";import{wrapText as sO}from"@excalidraw/element";import{assertNever as lO,CLASSES as cO,getFontString as kf,isProdEnv as dO,mapFind as mO,reduceToCommonValue as pO,ROUNDNESS as Mf,sceneCoordsToViewportCoords as uO,updateActiveTool as QI}from"@excalidraw/common";import{measureText as eT}from"@excalidraw/element";import{LinearElementEditor as hO}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Af,newElement as gO,newLinearElement as fO}from"@excalidraw/element";import{ShapeCache as EO}from"@excalidraw/element";import{updateBindings as bO}from"@excalidraw/element";import{jsx as Bf}from"react/jsx-runtime";var xO=8,wO=10,Cl=["rectangle","diamond","ellipse"],Pl=["line","sharpArrow","curvedArrow","elbowArrow"],yO=new Set(Cl),vO=new Set(Pl),La=e=>yO.has(e),zm=e=>e==="arrow"||vO.has(e),jn=qe(null),Ml=new Map,Al=new Map,IO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=Df(null);return kl(()=>{if(n.length===0){e.updateEditorAtom(jn,null);return}let o=Hm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(jn,null),t.current=null)},[n,e]),kl(()=>()=>{Ml.clear(),Al.clear()},[]),Bf(TO,{app:e,elements:n})},TO=({app:e,elements:n})=>{let t=Hm(n),o=JI(()=>t==="generic"?iT(n):[],[t,n]),r=JI(()=>t==="linear"?Nf(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Aa(m)===Aa(r[0])):!1,[a,s]=ZB({x:0,y:0}),l=Df(""),c=Df(null);kl(()=>{let m=[...o,...r].sort((b,y)=>b.id.localeCompare(y.id)),p=`
|
|
18
|
-
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(b=>b.id).join(",")}`;if(p===l.current)return;l.current=p;let u;if(m.length===1){let[b,,,y,w,x]=oO(m[0],e.scene.getNonDeletedElementsMap());u=jB(Fm(b,y),Fm(w,x),m[0].angle)}else{let{minX:b,maxY:y}=nO(m);u=Fm(b,y)}let{x:E,y:g}=uO({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),kl(()=>{for(let m of r){let p=Rf(m.id,MO(m));Al.has(p)||Al.set(p,m)}},[r]),kl(()=>{for(let m of o)if(!Ml.has(m.id)){let p=oT(m,e.scene.getNonDeletedElementsMap());p&&Ml.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",No],["sharpArrow",Fo],["curvedArrow",Ho],["elbowArrow",zo]]:t==="generic"?[["rectangle",Ei],["diamond",bi],["ellipse",xi]]:[];return Bf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(wO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-xO}px`,zIndex:2},className:cO.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Aa(r[0])===m);return Bf(K,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Ne("convertElementType",m,"ui"),Ff(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},SO=(e,n,t)=>{let o=iO(e,n),r=rO(e,n),i=sO(n.text,kf(n),o),a=eT(i,kf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=eT(n.text,kf(l),n.lineHeight)}_f(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),aO(n,e,t)},Ff=(e,{conversionType:n,nextType:t,direction:o="right"})=>{if(!n)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((s,l)=>({...s,[l.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let s=iT(r),c=s.every(d=>d.type===s[0].type)?Cl.indexOf(s[0].type):-1;if(t=t??Cl[(c+Cl.length+a)%Cl.length],t&&La(t)){let d={};for(let p of s){let u=nT(p,t,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=oT(p,e.scene.getNonDeletedElementsMap());u&&(Ml.get(p.id)&&_f(u,e.scene.getNonDeletedElementsMap(),{fontSize:Ml.get(p.id)?.fontSize??u.fontSize}),SO(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:QI(p,{type:"selection"})}))}}if(n==="linear"){let s=Nf(r);if(!t){let c=pO(s,Aa),d=c?Pl.indexOf(c):-1;t=Pl[(d+Pl.length+a)%Pl.length]}if(zm(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Al.get(Rf(m.id,t));if(p&&Aa(p)===t)d.set(p.id,p),c.push(p);else{let u=nT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(Of(m))if(eO(m)){let p=CO(m);if(p.length<2)continue;let u=[];for(let g=1;g<p.length-2;g++)u.push({start:p[g],end:p[g+1],index:g+1});let E=$B(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});_f(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=mO(["line","sharpArrow","curvedArrow"],u=>Al.get(Rf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=Nf(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new hO(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:QI(c,{type:"selection"})}))}return!0},Hm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(La(t.type))return"generic";rT(t)&&(n=!0)}return n?"linear":null},rT=e=>Of(e)&&(!QB(e)||!JB(e)&&!qB(e)),Rf=(e,n)=>`${e}:${n}`,iT=e=>e.filter(n=>La(n.type)),Nf=e=>e.filter(n=>rT(n)),Om=20,Ma=(e,n)=>e[0]===n[0],Lf=(e,n)=>e[1]===n[1],tT=(e,n)=>Ma(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),CO=e=>{let n=[e.points[0]],t=PO(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<Om?s[0]=a[0]:Math.abs(s[1]-a[1])<Om&&(s[1]=a[1]),Ma(a,s)||Lf(a,s)||n.push(Fm(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)Ma(n[i-1],n[i])&&Ma(n[i],n[i+1])||Lf(n[i-1],n[i])&&Lf(n[i],n[i+1])||o.push(n[i]);o.push(n[n.length-1]);let r=[o[0]];for(let i=1;i<o.length-1;++i){let a=r[r.length-1],s=o[i],l=o[i+1],c=Ma(a,s),d=Ma(s,l);if(c!==d){let m=tT(a,s),p=tT(s,l);if(m<Om||p<Om){if(p<m)c?l[0]=a[0]:l[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=s[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=s[1];continue}}r.push(s)}return r.push(o[o.length-1]),r},PO=e=>{if(e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++){let[o,r]=n[n.length-1],[i,a]=e[t];(o!==i||r!==a)&&n.push(e[t])}return n},nT=(e,n,t)=>{if(!kO(e.type,n)){if(!dO())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(EO.delete(e),La(n)){let o=Sl(gO({...e,type:n,roundness:e.roundness?{type:tO(n)?Mf.ADAPTIVE_RADIUS:Mf.PROPORTIONAL_RADIUS}:e.roundness}));return bO(o,t.scene,t.state),o}if(zm(n))switch(n){case"line":return Sl(fO({...e,type:"line"}));case"sharpArrow":return Sl(Af({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Sl(Af({...e,type:"arrow",elbowed:!1,roundness:{type:Mf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Sl(Af({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return lO(n,`unhandled conversion type: ${n}`),e},kO=(e,n)=>!!(La(e)&&La(n)||zm(e)&&zm(n)),MO=e=>Of(e)?Aa(e):e.type,aT=IO;import{bindBindingElementToFixedPoint as AO,dragNewTextElement as LO,getBoundTextElement as DO,getEndpointBoundTextDragAnchor as _O,getTextBindingForArrowEndpoint as RO,getUnboundArrowEndpointAtPoint as NO,isArrowElement as BO,isBindingEnabled as OO,isEndpointBoundText as FO,isTextElement as zO}from"@excalidraw/element";import{pointFrom as HO}from"@excalidraw/math";var Gm=class{constructor(n){this.app=n;I(this,"updateHoveredAnchor",n=>{let t=this.app.state.activeTool.type==="text"&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(n.x,n.y):null,o=this.app.state.hoveredArrowTextAnchor;return(o?.elementId!==t?.elementId||o?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t});I(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!OO(this.app.state))return null;let o=NO(HO(n,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!o||this.app.getTextElementAtPosition(n,t))return null;let r=this.app.getElementAtPosition(n,t,{includeLockedElements:!0});return r&&r.id!==o.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(o.arrow.id)?null:o}getAnchorAtPosition(n,t){let o=this.getBindableEndpointAtPosition(n,t);if(o)return{elementId:o.arrow.id,anchor:o.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(n,t);return!BO(r)||DO(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(n,t,this.app.state,r)?{elementId:r.id,anchor:"label"}:null}getTextBinding({arrow:n,startOrEnd:t},o){return RO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){AO(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!zO(n)||!FO(n,this.app.scene.getNonDeletedElementsMap())?!1:(LO({newElement:n,..._O(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as GO,BUCKET_FILL_BACKGROUND_PICKS as UO,COLOR_PALETTE as lT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as WO,getSizeFromPoints as VO,isTransparent as YO,THEME as XO}from"@excalidraw/common";import{pointFrom as sT}from"@excalidraw/math";import{computeBucketFillPolygon as KO,isBucketFillCompatible as ZO,isFrameLikeElement as $O,isRestylableFill as jO,newLinearElement as qO,ShapeCache as JO}from"@excalidraw/element";var zf=UO.filter(e=>e!==lT.white),Um=class{constructor(n){this.app=n;I(this,"temporaryEyeDropper",null);I(this,"pending",null);I(this,"handlePointerDown",n=>{this.pending=n});I(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});I(this,"cancel",()=>{this.pending=null});I(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=zf.indexOf(n),o=zf[(t+1)%zf.length];this.app.actionManager.executeAction(gd,"keyboard",{currentItemBackgroundColor:o})});I(this,"openTemporaryEyeDropper",()=>{if(gt.get(Bt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(gd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Bt,n)});I(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&>.get(Bt)===n&&this.app.updateEditorAtom(Bt,null)});I(this,"restyle",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);n.backgroundColor===t&&n.fillStyle===this.app.state.currentItemFillStyle&&n.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(n,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),JO.delete(n),this.app.scheduleCapture())});I(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=sT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=KO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&ZO(a)){this.restyle(a);return}s.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(s.reason==="open_region"||s.reason==="too_small"||s.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&jO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=VO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(w=>sT(w[0]-d,w[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?$O(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(w=>r.get(w)?.groupIds).filter(w=>!!w).reduce((w,x)=>w===null?x:w.filter(v=>x.includes(v)),null)??[],b=qO({type:"line",x:d,y:m,width:l,height:c,points:p,polygon:!0,strokeColor:"transparent",backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:E,groupIds:g}),y=this.app.scene.getElementsIncludingDeleted().findIndex(w=>w.id===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],y<0?null:s.insertion.placement==="above"?y+1:y),this.app.scheduleCapture()});I(this,"getBucketFillBackgroundColor",(n,t)=>YO(n)?lT.green[WO]:GO(n,t===XO.DARK))}};import{CURSOR_TYPE as Ll,MIME_TYPES as Vm,THEME as cT}from"@excalidraw/common";var dT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',QO='<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"/>',mT='<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"/>',eF=`data:${Vm.svg},${encodeURIComponent(`${dT}${mT}</svg>`)}`,tF=`data:${Vm.svg},${encodeURIComponent(`${dT}${QO}${mT}</svg>`)}`,nF=e=>{let n=xu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${Vm.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${n}</g><g stroke="#1b1b1f" stroke-width="1.25">${n}</g></svg>`)}`},Wm=class{constructor(n){this.app=n;I(this,"toolCursorMemo",null);I(this,"eraserCanvasCache",null);I(this,"eraserPreviewDataURL",null);I(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});I(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(Ll.GRAB):this.clear():this.applyForTool()});I(this,"applyForTool",(n=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let o=n.type==="eraser"||n.type==="laser"||n.type==="bucketfill"?this.app.state.theme:void 0,r=n.type==="bucketfill"?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,o):void 0,i=this.toolCursorMemo;if(!(i?.canvas===t&&i.type===n.type&&i.bucketFillColor===r&&i.theme===o)){if(n.type==="selection")this.clear();else if(rs({activeTool:n}))this.set(Ll.GRAB);else if(Jt({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(Ll.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${nF(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===cT.LIGHT?eF:tF;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(Ll.AUTO):this.set(Ll.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});I(this,"clear",()=>{this.set("")});I(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===cT.DARK;this.eraserCanvasCache=document.createElement("canvas"),this.eraserCanvasCache.theme=t,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let r=this.eraserCanvasCache.getContext("2d");r.lineWidth=1,r.beginPath(),r.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),r.fillStyle=o?"#000":"#fff",r.fill(),r.strokeStyle=o?"#fff":"#000",r.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(Vm.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as sF}from"@excalidraw/common";import{bindBindingElement as lF,convertToShape as cF,convertToShapeHandlePointerMoveFromPointerDown as dF,getHoveredElementForBinding as pT,isBindingElement as mF,isLineElement as pF,LinearElementEditor as Hf,maxBindingDistance_simple as uT,newArrowElement as uF,updateBoundPoint as hF}from"@excalidraw/element";import{getStrokeWidthByKey as oF,THEME as rF}from"@excalidraw/common";import{clamp as iF,pointFrom as aF}from"@excalidraw/math";var Ym=class{constructor(n){this.app=n;I(this,"trail");this.trail=new Pn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===rF.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>iF(oF("line",this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(n,t){this.trail.startPath(n,t)}addPointToPath(n,t){this.trail.addPointToPath(n,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let n=this.trail.getCurrentTrail();return n?n.originalPoints.map(([t,o])=>aF(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var Xm=class{constructor(n){this.app=n;I(this,"trail");I(this,"gestureInProgress",!1);I(this,"stop",()=>{this.trail.stop()});I(this,"hasPendingGesture",()=>this.gestureInProgress);I(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(mt),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});I(this,"handlePointerMove",n=>dF(this.app,n));I(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=uT(t.state.zoom),a=["start","end"].map(d=>{let m=Hf.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:pT(m,r,o,i)}}),s=!!a[0].target&&a[0].target===a[1].target,l=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:d,globalPoint:m,target:p}of a)p&&lF(n,p,s?"inside":"orbit",d,t.scene,m,t.state.isBindingEnabled,l);if(s)return;let c=new Map;for(let{startOrEnd:d,target:m}of a){if(!m)continue;let p=hF(n,d==="start"?"startBinding":"endBinding",d==="start"?n.startBinding:n.endBinding,m,o);p&&c.set(d==="start"?0:n.points.length-1,{point:p})}c.size&&Hf.movePoints(n,t.scene,c)});I(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=uT(t.state.zoom),[a,s]=[0,-1].map(l=>pT(Hf.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:uF({type:"arrow",x:n.x,y:n.y,width:n.width,height:n.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:n.points,groupIds:n.groupIds,frameId:n.frameId,locked:!1,angle:n.angle,strokeColor:n.strokeColor,backgroundColor:n.backgroundColor,fillStyle:n.fillStyle,roughness:n.roughness,opacity:n.opacity,strokeStyle:n.strokeStyle,strokeWidth:n.strokeWidth})});I(this,"finalize",()=>{let{app:n}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let o=n.state.newElement||cF(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:sF(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&pF(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&mF(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new Ym(n)}};import{isArrowKey as gF,KEYS as qr}from"@excalidraw/common";import{makeNextSelectedElementIds as fF,CaptureUpdateAction as EF,FlowChartCreator as bF,FlowChartNavigator as xF,getSelectedElements as hT,isFlowchartNodeElement as wF}from"@excalidraw/element";var Km=class e{constructor(n){this.app=n;I(this,"creator",new bF);I(this,"navigator",new xF);I(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});I(this,"handleKeyEvent",n=>{let t=this.resolveKeyboardEventToOperation(n);switch(t.type){case"none":return!1;case"canceled":return this.app.triggerRender(!0),!0;case"creating":return n.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case"navigating":{n.preventDefault();let o=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return o&&this.selectAndReveal(o),!0}case"committed":{t.nodes.length&&this.app.insertNewElements(t.nodes);let o=t.nodes[0];return o&&this.selectAndReveal(o),this.captureUpdate(),!0}case"navigationEnded":return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(n){let{creator:t,navigator:o,app:r}=this;if(n.type==="keydown"){if(n.key===qr.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!gF(n.key))return{type:"none"};if(n[qr.CTRL_OR_CMD]&&!n.shiftKey){let a=hT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&wF(a[0])&&t.createNodes(a[0],r.state,e.getLinkDirectionFromKey(n.key),r.scene),{type:"creating",pending:t.pendingNodes??[]}}if(n.altKey){let a=r.scene.getNonDeletedElementsMap(),s=hT(a,r.state);if(s.length===1)return{type:"navigating",nodeId:o.exploreByDirection(s[0],a,e.getLinkDirectionFromKey(n.key))}}return{type:"none"}}let i=!n.altKey&&o.isExploring;if(i&&o.clear(),!n[qr.CTRL_OR_CMD]&&t.isCreatingChart){let a=t.pendingNodes??[];return t.clear(),{type:"committed",nodes:a}}return i?{type:"navigationEnded"}:{type:"none"}}selectAndReveal(n){this.app.setState(t=>({selectedElementIds:fF({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:EF.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case qr.ARROW_UP:return"up";case qr.ARROW_DOWN:return"down";case qr.ARROW_RIGHT:return"right";case qr.ARROW_LEFT:return"left";default:return"right"}}};import{debounce as yF,easeOut as wT,isBounds as vF}from"@excalidraw/common";import{clamp as yT}from"@excalidraw/math";import{getCommonBounds as gT,getElementsInGroup as IF,isElementLink as TF,isExcalidrawElement as SF,parseElementLinkFromURL as CF}from"@excalidraw/element";var Zm="animateScrollToContent",Da="animateScrollConstraintsSnapBack",fT=500,PF=250,kF=200,Gf=302,ET={full:216,compact:64},MF=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.x=="number"&&typeof n.y=="number"&&(n.width==null||typeof n.width=="number")&&(n.height==null||typeof n.height=="number")},AF=(e,n)=>{let t=n.get(e);return t?[t]:IF(n,e)},bT=(e,n,t)=>{if(typeof e=="string"){let a=TF(e),s=a?"link":"element",l=a?CF(e):e,c=l?AF(l,n):[];return c.length?{bounds:gT(c,n),type:s}:{bounds:null,type:s}}if(vF(e))return{bounds:e,type:"area"};if(MF(e)&&!SF(e)){let a=e.width??t.width,s=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+s],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,s)=>{if(s&&!s.isDeleted){let l=n.get(s.id);l&&a.push(l)}return a},[]),i=!r.length;return(r.length!==o.length||i)&&console.warn("supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out"),i?{bounds:null,type:"element"}:{bounds:gT(r,n),type:"element"}},LF=e=>e===!1?0:e===!0||e==null?cu:Math.max(e,0),DF=(e,n,t="scale-down",o,r)=>{let{appState:i}=vr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},xT=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=DF(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[s,l,c,d]=n,m={x:s,y:l,width:c-s,height:d-l,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:LF(r.overscroll),offsets:o};return{...On({...e,...a,scrollConstraints:m}),scrollConstraints:m}},_F=({from:e,target:n,factor:t})=>{if(t>=1)return{...n};let o=e.zoom.value*Math.pow(n.zoom.value/e.zoom.value,t),r=n.zoom.value===e.zoom.value?t:(o-e.zoom.value)/(n.zoom.value-e.zoom.value);return{scrollX:((1-r)*e.scrollX*e.zoom.value+r*n.scrollX*n.zoom.value)/o,scrollY:((1-r)*e.scrollY*e.zoom.value+r*n.scrollY*n.zoom.value)/o,zoom:{value:o}}},RF=e=>e===!1?null:e===!0||e==null?fT:e.duration??fT,NF=(e,n,t,o,r)=>{rt.start(Zm,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=wT(yT(l,0,1));return l<1?(o({..._F({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},BF=(e,n,t=PF)=>{let o=On(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||rt.running(Zm))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;rt.start(Da,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-wT(yT(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=On(m),u=p.zoom.value;return{scrollX:p.scrollX+r*d/u,scrollY:p.scrollY+i*d/u,zoom:p.zoom}}),c<1?{elapsed:l}:null})},$m=class{constructor(n,t){this.app=n;this.dependencies=t;I(this,"lastPosition",{x:0,y:0});I(this,"activeTransition",null);I(this,"uiLastMeasured",new Map);I(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});I(this,"resolveOffsets",n=>{if(!n)return n;let{ui:t,...o}=n;if(!t)return o;let r=this.getOffsets(t===!0?void 0:t);return{top:o.top??r.top,right:o.right??r.right,bottom:o.bottom??r.bottom,left:o.left??r.left}});I(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=Hn().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&o)for(let u of t.querySelectorAll("[data-viewport-ui]")){let E=u.getBoundingClientRect(),g={top:E.top-o.top,right:E.right-o.left,bottom:E.bottom-o.top,left:E.left-o.left,width:E.width};switch(u.dataset.viewportUi){case"top":i.top=Math.max(i.top,g.bottom);break;case"bottom":i.bottom=Math.max(i.bottom,this.app.state.height-g.top);break;case"side":{let[b,y]=g.left+g.width/2<this.app.state.width/2?["left",g.right]:["right",this.app.state.width-g.left];i[b]=Math.max(i[b],y);let w=u.dataset.viewportUiName;w&&(a.add(w),y>0&&this.uiLastMeasured.set(w,{side:b,offset:y}));break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:y}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],y)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?ET.compact:ET.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:Gf})}let s=n?.padding??24,l=n?.paddingTop??s,c=(r?n?.paddingLeft:n?.paddingRight)??s,d=n?.paddingBottom??s,m=(r?n?.paddingRight:n?.paddingLeft)??s,p={top:i.top+l,right:i.right+c,bottom:i.bottom+d,left:i.left+m};return{top:n?.top??p.top,right:(r?n?.left:n?.right)??p.right,bottom:n?.bottom??p.bottom,left:(r?n?.right:n?.left)??p.left}});I(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=bT(n.target,t,o);return r?xT(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});I(this,"setViewport",n=>{if(n===null){this.cancelTransition(),rt.cancel(Da),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,s=this.resolveOffsets(n.offsets),{bounds:l,type:c}=bT(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!l){c==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let d=xT(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=RF(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),rt.cancel(Da),this.snapBackDebounced.cancel(),m===null){this.app.setState({...d,shouldCacheIgnoreZoom:!1});return}let u={target:d};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),NF(p,d,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});I(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||rt.cancel(Da),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let o=this.app.state.zoom.value;return this.app.setState(n),this.app.setState(r=>{if(!r.scrollConstraints)return null;let a=!t?.zoomPreConstrained&&r.zoom.value!==o?0:r.scrollConstraints.overscroll;return a>0&&this.snapBackDebounced(),On(r,a)}),!0});I(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?On(t,n):null)});I(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});I(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||BF(this.app.state,n=>this.app.setState(t=>n(t)))});I(this,"snapBackDebounced",yF(this.snapBack,kF));I(this,"cancelTransition",()=>{this.activeTransition=null,rt.cancel(Zm)});I(this,"destroy",()=>{this.cancelTransition(),rt.cancel(Da),this.snapBackDebounced.cancel()})}get isAnimating(){return rt.running(Zm)||rt.running(Da)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import jm from"react";var OF=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,FF=/{{([\w-]+)}}/,zF=/<([\w-]+)>/,HF=/<\/([\w-]+)>/,GF=(e,n)=>{let t=[{name:"",children:[]}];return e.split(OF).filter(Boolean).forEach(o=>{let r=o.match(zF),i=o.match(HF),a=o.match(FF);if(r!==null){let s=r[1];n.hasOwnProperty(s)?t.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let l=t.pop(),c=jm.createElement(jm.Fragment,{},...l.children),d=n[l.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];n.hasOwnProperty(s)?t[t.length-1].children.push(n[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else t[t.length-1].children.push(o)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},UF=({i18nKey:e,children:n,...t})=>{let{t:o}=Ae();return jm.createElement(jm.Fragment,{},...GF(o(e),t))},Jr=UF;import{jsx as hn,jsxs as vT}from"react/jsx-runtime";var WF=()=>vT("div",{"data-testid":"brave-measure-text-error",children:[hn("p",{children:hn(Jr,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>hn("span",{style:{fontWeight:600},children:e})})}),hn("p",{children:hn(Jr,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>hn("span",{style:{fontWeight:600},children:e})})}),hn("p",{children:hn(Jr,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>hn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),hn("p",{children:hn(Jr,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>hn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>vT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),IT=WF;import qF from"clsx";import JF from"react";import{isDarwin as TT}from"@excalidraw/common";var VF={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],imageExport:[N("CtrlOrCmd+Shift+E")],cut:[N("CtrlOrCmd+X")],copy:[N("CtrlOrCmd+C")],paste:[N("CtrlOrCmd+V")],copyStyles:[N("CtrlOrCmd+Alt+C")],pasteStyles:[N("CtrlOrCmd+Alt+V")],selectAll:[N("CtrlOrCmd+A")],deleteSelectedElements:[N("Delete")],duplicateSelection:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)],sendBackward:[N("CtrlOrCmd+[")],bringForward:[N("CtrlOrCmd+]")],sendToBack:[TT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[TT?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],flipHorizontal:[N("Shift+H")],flipVertical:[N("Shift+V")],viewMode:[N("Alt+R")],hyperlink:[N("CtrlOrCmd+K")],toggleElementLock:[N("CtrlOrCmd+Shift+L")],resetZoom:[N("CtrlOrCmd+0")],zoomOut:[N("CtrlOrCmd+-")],zoomIn:[N("CtrlOrCmd++")],zoomToFitSelection:[],zoomToFit:[],zoomToFitSelectionInViewport:[],smartZoom:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[N("Shift+R")],toolLock:[N("Q")]},Ke=(e,n=0)=>{let t=VF[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as YF,useRef as ST,useEffect as CT}from"react";import{unstable_batchedUpdates as XF}from"react-dom";import{KEYS as KF,queryFocusableElements as ZF}from"@excalidraw/common";import{clamp as PT}from"@excalidraw/math";import $F from"clsx";import{jsx as jF}from"react/jsx-runtime";var ir=10,kT=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=ST(null);CT(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===KF.TAB){let u=ZF(d),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===d?(p.shiftKey?u[u.length-1]?.focus():u[0].focus(),p.preventDefault(),p.stopImmediatePropagation()):g===0&&p.shiftKey?(u[u.length-1]?.focus(),p.preventDefault(),p.stopImmediatePropagation()):g===u.length-1&&!p.shiftKey&&(u[0]?.focus(),p.preventDefault(),p.stopImmediatePropagation())}};return d.addEventListener("keydown",m),()=>d.removeEventListener("keydown",m)},[]);let c=ST(null);return YF(()=>{if(r&&l.current&&t!=null&&n!=null){let d=l.current,{width:m,height:p}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===n)return;c.current={top:t,left:n};let u=Math.max(0,i-ir*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${ir}px`,d.style.overflowX="scroll"):d.style.left=`${PT(n,ir,i-ir-m)}px`;let E=Math.max(0,a-ir*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${ir}px`,d.style.overflowY="scroll"):d.style.top=`${PT(t,ir,a-ir-p)}px`}},[t,n,r,i,a]),CT(()=>{if(o){let d=m=>{l.current?.contains(m.target)||XF(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),jF("div",{className:$F("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as wo,jsxs as AT}from"react/jsx-runtime";var Ze="separator",MT=e=>"onSelect"in e,LT=JF.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Xo(),a=Ci(),s=n.reduce((l,c)=>c?c===Ze||MT(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return wo(kT,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:wo("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===Ze)return!s[c-1]||s[c-1]===Ze?null:wo("hr",{className:"context-menu-item-separator"},c);if(MT(l))return wo("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:AT("button",{type:"button",className:"context-menu-item",children:[wo("div",{className:"context-menu-item__label",children:l.label}),wo("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=f(l.label(a,i,e.app)):m=f(l.label)),wo("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:AT("button",{type:"button",className:qF("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[wo("div",{className:"context-menu-item__label",children:m}),wo("kbd",{className:"context-menu-item__shortcut",children:d?Ke(d):""})]})},c)})})})});import{useId as QF}from"react";import e9 from"clsx";import{Fragment as t9,jsx as Dl,jsxs as DT}from"react/jsx-runtime";var qm=({border:e,style:n})=>Dl("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),Jm=({label:e,border:n})=>{let t=QF(),o=DT(t9,{children:[e.icon&&Dl("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return DT("div",{className:e9("viewport-status-frame__badge",{"viewport-status-frame__badge--clickable":e.onClick}),role:"status",style:{"--viewport-status-frame-badge-background":e.background||n||"var(--color-primary)",color:e.color},children:[e.onClick&&Dl("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),Dl("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&Dl("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:Qt})]})};import Xa from"clsx";import yW from"react";import{CLASSES as vW,TOOL_TYPE as tk,arrayToMap as IW,isShallowEqual as Dp}from"@excalidraw/common";import{mutateElement as TW}from"@excalidraw/element";import{showSelectedShapeActions as SW}from"@excalidraw/element";import{ShapeCache as CW}from"@excalidraw/element";import{createIsolation as n9}from"jotai-scope";import Uf from"react";import yo from"tunnel-rat";var Wf=Uf.createContext(null),tt=()=>Uf.useContext(Wf),o9=n9(),_T=()=>Uf.useMemo(()=>({MainMenuTunnel:yo(),WelcomeScreenMenuHintTunnel:yo(),WelcomeScreenToolbarHintTunnel:yo(),WelcomeScreenHelpHintTunnel:yo(),WelcomeScreenCenterTunnel:yo(),FooterCenterTunnel:yo(),DefaultSidebarTriggerTunnel:yo(),DefaultSidebarTabTriggersTunnel:yo(),OverwriteConfirmDialogTunnel:yo(),tunnelsJotai:o9}),[]);import sr from"clsx";import{useRef as p9}from"react";import{Popover as ar}from"radix-ui";import{CLASSES as VT}from"@excalidraw/common";import{isArrowElement as WT}from"@excalidraw/element";import{forwardRef as RT}from"react";import NT from"clsx";import{jsx as BT}from"react/jsx-runtime";var r9=RT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>BT("div",{className:NT("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),i9=RT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>BT("div",{className:NT("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Dt={Row:r9,Col:i9};import{isTransparent as OT}from"@excalidraw/common";import{shouldAllowVerticalAlign as a9,suppportsHorizontalAlign as s9,hasBoundTextElement as FT,isElbowArrow as l9,isImageElement as zT,isLinearElement as c9,isTextElement as d9,hasStrokeColor as HT,toolIsArrow as m9}from"@excalidraw/element";var GT=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return HT(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>HT(o.type))},UT=(e,n)=>Do(e.activeTool.type)||n.some(t=>Do(t.type)),Qm=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(m=>d(m.type)),a=n.length===1,s=n.length===2&&(FT(n[0])||FT(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:GT(e,n),backgroundColor:UT(e,n),fill:r==="bucketfill"||Do(r)&&!OT(e.currentItemBackgroundColor)||n.some(d=>Do(d.type)&&!OT(d.backgroundColor)),strokeWidth:i(Xb),freedrawMode:i(Kb),strokeStyle:i(du),sloppiness:i(du),roundness:i(Zb),arrowType:i(m9),arrowheads:i(os),text:r==="text"||n.some(d9),textAlign:r==="text"||s9(n,t),verticalAlign:a9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||se(t,e).some(d=>d.type==="freedraw"),align:!s&&st(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(zT)&&st(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&zT(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&c9(n[0])&&!l9(n[0])}};import{Fragment as Kt,jsx as j,jsxs as Ie}from"react/jsx-runtime";var Vf=sr([VT.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),YT=({renderAction:e})=>Ie("fieldset",{children:[j("legend",{children:f("labels.layers")}),Ie("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),XT=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Ie("fieldset",{children:[j("legend",{children:f("labels.align")}),Ie("div",{className:"buttonList",children:[o?Ie(Kt,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Ie(Kt,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),j("div",{style:{flexBasis:"100%",height:0}}),Ie("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Ie(Kt,{children:[j("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},KT=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=di(n,e),i=Qm(e,r,n,o);return e.activeTool.type==="bucketfill"?Ie("div",{className:"selected-shape-actions",children:[j("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Ie("div",{className:"selected-shape-actions",children:[j("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&j("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&j(Kt,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&j(Kt,{children:t("changeSloppiness")}),i.roundness&&j(Kt,{children:t("changeRoundness")}),i.arrowType&&j(Kt,{children:t("changeArrowType")}),i.text&&Ie(Kt,{children:[j("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&j(Kt,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&j(YT,{renderAction:t}),i.align&&j(XT,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Ie("fieldset",{children:[j("legend",{children:f("labels.actions")}),Ie("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},ZT=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return i?j("div",{className:"compact-action-item",children:Ie(ar.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[j(ar.Trigger,{asChild:!0,children:j("button",{type:"button",className:sr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:J1})}),a&&j(lo,{className:Vf,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Ie("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&j(Kt,{children:n("changeStrokeStyle")}),o.sloppiness&&j(Kt,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},$T=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let s=e.openPopup==="compactArrowProperties";return j("div",{className:"compact-action-item",children:Ie(ar.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[j(ar.Trigger,{asChild:!0,children:j("button",{type:"button",className:sr("compact-action-button properties-trigger",{active:s}),title:f("labels.arrowtypes"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactArrowProperties"})},children:(()=>{let l=ct(o,a,c=>WT(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>WT(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?zo:l==="round"?Ho:Fo})()})}),s&&j(lo,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},jT=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=y0(),s=e.openPopup==="compactTextProperties";return j("div",{className:"compact-action-item",children:Ie(ar.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[j(ar.Trigger,{asChild:!0,children:j("button",{type:"button",className:sr("compact-action-button properties-trigger",{active:s}),title:f("labels.textAlign"),onClick:l=>{l.preventDefault(),l.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:Px})}),e.openPopup==="compactTextProperties"&&j(lo,{className:Vf,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Ie("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},qT=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?j("div",{className:"compact-action-item",children:Ie(ar.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[j(ar.Trigger,{asChild:!0,children:j("button",{type:"button",className:sr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:wx})}),s&&j(lo,{className:Vf,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Ie("div",{className:"selected-shape-actions",children:[t.layers&&j(YT,{renderAction:n}),t.align&&j(XT,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Ie("fieldset",{children:[j("legend",{children:f("labels.actions")}),Ie("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),n("smartZoom"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},u9=({renderAction:e,predicates:n})=>n.lineEditor?j("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,JT=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=di(n,e),a=Qm(e,i,n,o),{container:s}=De();return Ie("div",{className:"compact-shape-actions",children:[a.strokeColor&&j("div",{className:sr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&j("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),j(ZT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j($T,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&j("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Ie(Kt,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(jT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),j(qT,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},QT=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=di(n,e),a=Qm(e,i,n,o),{container:s}=De(),l=p9(null),c=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,p=32,u=d*p+(d-1)*m,E=p+m,g=c>=u+E,b=c>=u+2*E;return Ie(He,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:l,children:[Ie("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&j("div",{className:sr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),j(ZT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j($T,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),j(u9,{renderAction:t,predicates:a}),a.text&&Ie(Kt,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(jT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),j(qT,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Ie("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[j("div",{className:"compact-action-item",children:t("undo")}),j("div",{className:"compact-action-item",children:t("redo")}),b&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},eS=({renderAction:e})=>j(Dt.Col,{gap:1,className:VT.ZOOM_ACTIONS,children:Ie(Dt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),tS=({renderAction:e,className:n})=>Ie("div",{className:`undo-redo-buttons ${n}`,children:[j("div",{className:"undo-button-container",children:j(dt,{label:f("buttons.undo"),children:e("undo")})}),j("div",{className:"redo-button-container",children:Ie(dt,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),nS=({showExitZenModeBtn:e})=>j("button",{type:"button",className:sr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import h9 from"clsx";import{useState as g9,useEffect as f9}from"react";import{THEME as E9}from"@excalidraw/common";import{jsx as Yf,jsxs as b9}from"react/jsx-runtime";var ep=({delay:e,theme:n})=>{let[t,o]=g9(!!e);return f9(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:b9("div",{className:h9("LoadingMessage",{"LoadingMessage--dark":n===E9.DARK}),children:[Yf("div",{children:Yf(so,{})}),Yf("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as rp,useEffect as TS}from"react";import K9 from"clsx";import{KEYS as $f,capitalizeString as SS}from"@excalidraw/common";import IS from"react";import{DropdownMenu as W9}from"radix-ui";import{CLASSES as V9}from"@excalidraw/common";import x9 from"clsx";import{useCallback as w9,useEffect as y9,useRef as v9}from"react";import{CLASSES as I9,EVENT as oS,KEYS as T9}from"@excalidraw/common";import{DropdownMenu as S9}from"radix-ui";import{jsx as tp}from"react/jsx-runtime";var rS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=ge(),l=v9(null),c=Si({onClickOutside:n});Ti(l,w9(m=>{l.current?.closest(`.${I9.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),y9(()=>{if(!r)return;let m=u=>{u.key===T9.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(oS.KEYDOWN,m,p),()=>{document.removeEventListener(oS.KEYDOWN,m,p)}},[c,r]);let d=x9(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return tp(hh.Provider,{value:{onSelect:o},children:tp(S9.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?tp(Dt.Col,{className:"dropdown-menu-container",children:e}):tp(He,{className:"dropdown-menu-container",padding:2,children:e})})})};rS.displayName="DropdownMenuContent";var iS=rS;import{jsx as P9}from"react/jsx-runtime";var C9=({children:e,className:n="",selected:t,...o})=>P9("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),aS=C9;import{DropdownMenu as k9}from"radix-ui";import{jsx as Xf}from"react/jsx-runtime";var sS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=rd(r);return Xf(k9.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Xf("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:Vo(i,a),title:l.title??l["aria-label"],children:Xf(Yo,{icon:e,shortcut:n,children:o})})})},_a=sS;sS.displayName="DropdownMenuItemLink";import{jsx as M9}from"react/jsx-runtime";var lS=()=>M9("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),cS=lS;lS.displayName="DropdownMenuSeparator";import{DropdownMenu as B9}from"radix-ui";import A9 from"clsx";import{DropdownMenu as L9}from"radix-ui";import{useCallback as D9,useState as dS}from"react";import{jsx as Zf}from"react/jsx-runtime";var Kf=-4,_9=4,mS=({children:e,className:n})=>{let t=ge(),o=A9(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=D9(c=>{if(c){let m=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=c.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+Kf),l(Kf+8))}}},[]),[i,a]=dS(_9),[s,l]=dS(Kf);return Zf(L9.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?Zf(Dt.Col,{className:"dropdown-menu-container",children:e}):Zf(He,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},pS=mS;mS.displayName="DropdownMenuSubContent";import{DropdownMenu as R9}from"radix-ui";import{jsx as uS,jsxs as N9}from"react/jsx-runtime";var hS=({children:e,icon:n,shortcut:t,className:o})=>N9(R9.SubTrigger,{className:`${Vo(o)} dropdown-menu__submenu-trigger`,children:[uS(Yo,{icon:n,shortcut:t,children:e}),uS("div",{className:"dropdown-menu__submenu-trigger-icon",children:t0})]}),gS=hS;hS.displayName="DropdownMenuSubTrigger";import fS from"react";var np=e=>n=>{let t=fS.Children.toArray(n).find(o=>fS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},ES=np("DropdownMenuTrigger"),bS=np("DropdownMenuContent"),xS=np("DropdownMenuSubTrigger"),wS=np("DropdownMenuSubContent");import{jsxs as O9}from"react/jsx-runtime";var op=({children:e})=>{let n=xS(e),t=wS(e);return O9(B9.Sub,{children:[n,t]})};op.Trigger=gS;op.Content=pS;op.displayName="DropdownMenuSub";var lr=op;import F9 from"clsx";import{DropdownMenu as z9}from"radix-ui";import{jsx as H9}from"react/jsx-runtime";var yS=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=ge(),a=F9(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return H9(z9.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},vS=yS;yS.displayName="DropdownMenuTrigger";import{jsx as U9}from"react/jsx-runtime";var G9=e=>U9(Yt,{...e,icon:e.checked?Mc:Bc}),qn=G9;import{jsx as X9,jsxs as Y9}from"react/jsx-runtime";var Mn=({children:e,open:n})=>{let t=ES(e),o=bS(e),r=o&&IS.isValidElement(o)?IS.cloneElement(o,{open:n}):o;return X9(W9.Root,{open:n,modal:!1,children:Y9("div",{className:V9.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Mn.Trigger=vS;Mn.Content=iS;Mn.Item=Yt;Mn.ItemCheckbox=qn;Mn.ItemLink=_a;Mn.ItemCustom=aS;Mn.Group=Cs;Mn.Separator=cS;Mn.Sub=lr;var de=Mn;Mn.displayName="DropdownMenu";import{Fragment as jf,jsx as Le,jsxs as Ra}from"react/jsx-runtime";var Z9=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=f("buttons.objectsSnapMode");return Le(K,{type:"toggle",icon:Oo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(kt,"ui")})},$9=({app:e})=>Le(K,{type:"button",icon:yi,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),CS=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=rp(!1),[l,c]=rp("rectangle"),[d,m]=rp("arrow");TS(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),TS(()=>{(o.type==="arrow"||o.type==="line")&&m(o.type)},[o.type]);let p=o.type==="frame",u=o.type==="autoshape",E=o.type==="laser",g=o.type==="embeddable",b=o.type==="bucketfill",y=["rectangle","diamond","ellipse"].map(H=>({type:H,icon:We[H].icon,title:SS(f(`toolBar.${H}`)),fillable:We[H].fillable})),w=["arrow","line"].map(H=>({type:H,icon:We[H].icon,title:SS(f(`toolBar.${H}`)),fillable:We[H].fillable})),[x,v]=rp(0),T=36,C=4,P=7,A=P*T+(P-1)*C,L=T+C,_=x>=A+1*L,k=i&&x>=A+2*L,D=x>=A+3*L,O=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(H=>!(_&&H==="text"||(!i||k)&&H==="image"||D&&H==="frame")),Y=r&&Fi.includes(o.type),z=Y||O.includes(o.type),W=z?Y?We[o.type].icon:o.type==="text"?wn:o.type==="image"?Cr:o.type==="frame"?Wn:o.type==="embeddable"?Bo:o.type==="laser"?Vn:o.type==="bucketfill"?Un:ds:ds,Z={app:e,activeTool:o,hideShortcut:!0};return Ra("div",{className:"mobile-toolbar",ref:H=>{H&&v(H.getBoundingClientRect().width)},children:[Le(Pd,{...Z}),Le(kd,{...Z,setAppState:t}),r?Le(Ns,{...Z}):Le(Md,{...Z}),Le(Fs,{...Z}),!r&&Le(Oi,{app:e,options:y,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:H=>{(H==="rectangle"||H==="diamond"||H==="ellipse")&&(c(H),e.setActiveTool({type:H}))},displayedOption:y.find(H=>H.type===l)||y[0]}),!r&&Le(Oi,{app:e,options:w,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:H=>{(H==="arrow"||H==="line")&&(m(H),e.setActiveTool({type:H}))},displayedOption:w.find(H=>H.type===d)||w[0]}),_&&Le(Bs,{...Z}),r&&k&&Le($9,{app:e}),k&&Le(Os,{...Z}),!r&&D&&Le(Bw,{...Z,hideShortcut:!0}),Ra(de,{open:a,children:[Le(de.Trigger,{className:K9("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":z||a}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:W}),Ra(de.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&Fi.map(H=>Le(de.Item,{onSelect:()=>e.setActiveTool({type:H}),icon:We[H].icon,"data-testid":`toolbar-${H}`,selected:o.type===H,shortcut:Cd(H),disabled:$e(e,H),children:f(`toolBar.${H}`)},H)),!r&&Le("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(kt)&&Le(de.Item,{onSelect:()=>n.executeAction(kt,"ui"),icon:Oo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Ke("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&Ra(jf,{children:[r&&Le("div",{className:"App-toolbar__dropdown-divider"}),Le(de.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Ro:ao,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:$f.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:wn,shortcut:$f.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:$e(e,"text"),children:f("toolBar.text")}),i&&!k&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Cr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:$e(e,"image"),children:f("toolBar.image")}),!r&&!D&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Wn,shortcut:$f.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:$e(e,"frame"),children:f("toolBar.frame")}),!r&&Ra(jf,{children:[Le(de.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Bo,"data-testid":"toolbar-embeddable",selected:g,disabled:$e(e,"embeddable"),children:f("toolBar.embeddable")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Mr,shortcut:Hi("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:$e(e,"autoshape"),children:f("toolBar.autoshape")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Vn,"data-testid":"toolbar-laser",selected:E,disabled:$e(e,"laser"),children:f("toolBar.laser")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Un,"data-testid":"toolbar-bucketfill",selected:b,disabled:$e(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&Ra(jf,{children:[Le("div",{className:"App-toolbar__divider"}),Le(Z9,{actionManager:n,app:e})]})]})};import j9 from"clsx";import{jsx as q9}from"react/jsx-runtime";var ip=({children:e,side:n,className:t})=>q9("div",{className:j9("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import J9 from"clsx";import{jsx as Q9}from"react/jsx-runtime";var Na=e=>e.penDetected?Q9(K,{className:J9("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Cx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as PS,jsx as xt,jsxs as Qr}from"react/jsx-runtime";var kS=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=tt(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=xt("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&Qr(PS,{children:[l&&xt(Na,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),xt(E.Out,{})]}))}),A=Qr("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),xt(u.Out,{})]});return Qr("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[A,P]})},b=()=>xt(CS,{app:d,actionManager:t,setAppState:o}),y=c&&e.scrolledOutside,w=l,x=l&&(!e.viewModeEnabled||w),v=y&&!e.openMenu&&!e.openSidebar?xt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...ci(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?xt(Jm,{label:T,border:d.props.viewportStatusFrame?.border}):null;return Qr(PS,{children:[a(),xt("div",{className:"App-welcome-screen",children:s&&xt(p.Out,{})}),x&&Qr("div",{className:"App-bottom-bar",style:{marginBottom:dn+bo,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[v&&xt("div",{className:"floating-status-stack",children:v}),Qr("div",{className:"App-bottom-bar__actions-row",children:[w&&Qr(He,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&xt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),xt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&xt(QT,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&xt(He,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&v&&xt("div",{className:"floating-status-stack",children:v}),C&&xt("div",{className:"viewport-status-frame__badge-row",children:C}),xt(ip,{side:"top",className:"App-top-bar",children:g()})]})};import NS,{useLayoutEffect as BS,useRef as OS,useState as FS}from"react";import{newTextElement as zS}from"@excalidraw/element";import az from"clsx";import{useEffect as sz,useState as lz}from"react";import{KEYS as cz,queryFocusableElements as _S}from"@excalidraw/common";import{useCallback as ez,useState as tz}from"react";var MS=()=>{let[e,n]=tz(null),t=ez(o=>n(o),[]);return[e,t]};import AS from"clsx";import{useRef as nz}from"react";import{createPortal as oz}from"react-dom";import{KEYS as rz}from"@excalidraw/common";import{jsx as LS,jsxs as iz}from"react/jsx-runtime";var DS=e=>{let{closeOnClickOutside:n=!0}=e,t=Kc({className:AS("excalidraw-modal-container",e.portalContainerClassName)}),o=nz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===rz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return oz(iz("div",{className:AS("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[LS("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),LS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as ap,jsxs as RS}from"react/jsx-runtime";function dz(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var gn=e=>{let[n,t]=MS(),[o]=lz(document.activeElement),{id:r}=De(),i=ge().formFactor==="phone";sz(()=>{if(!n)return;let l=_S(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===cz.TAB){let m=_S(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Be(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return ap(DS,{className:az("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:dz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:RS(He,{ref:t,children:[e.title&&RS("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[ap("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&ap("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Qt}),ap("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as vo,jsxs as sp}from"react/jsx-runtime";var mz=e=>{switch(e){case"bar":return f("labels.chartType_bar");case"line":return f("labels.chartType_line");case"radar":return f("labels.chartType_radar");default:return e}},pz=e=>{let n=OS(null),[t,o]=FS(null),{theme:r}=fe();BS(()=>{if(!e.spreadsheet){o(null);return}let a=xf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let s,l=n.current;return(async()=>(s=await Ir(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),s.querySelector(".style-fonts")?.remove(),l.replaceChildren(),l.appendChild(s)))(),()=>{l.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=mz(e.chartType);return sp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[vo("div",{className:"ChartPreview__canvas",ref:n}),vo("div",{className:"ChartPreview__label",children:i})]})},uz=e=>{let n=OS(null),{theme:t}=fe();return BS(()=>{if(!e.rawText)return;let o=zS({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Ir([o],{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:t==="dark"},null,{skipInliningFonts:!0});i.querySelector(".style-fonts")?.remove(),r.replaceChildren(),r.appendChild(i)})(),()=>{r.replaceChildren()}},[e.rawText,t]),sp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[vo("div",{className:"ChartPreview__canvas",ref:n}),vo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},HS=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=It(),[i,a]=FS(Math.random()),s=NS.useCallback(()=>{a(Math.random())},[]),l=NS.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),Ne("paste","chart",m),t(),r()},d=m=>{let p=zS({text:m,x:0,y:0});o([p]),Ne("paste","chart","plaintext"),t(),r()};return vo(gn,{size:"regular",onCloseRequest:l,title:sp("div",{className:"PasteChartDialog__title",children:[vo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),vo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Un})]}),className:"PasteChartDialog",autofocus:!1,children:sp("div",{className:"container",children:[["bar","line","radar"].map(m=>ba(e,m)?vo(pz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&vo(uz,{rawText:n,onClick:d})]})})};import{Fragment as hz,jsx as GS,jsxs as gz}from"react/jsx-runtime";var _l=({heading:e,children:n,...t})=>{let{id:o}=De(),r=GS("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return GS("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):gz(hz,{children:[r,n]})})};import{Popover as Rl}from"radix-ui";import US from"clsx";import lp,{useLayoutEffect as fz}from"react";import{supportsResizeObserver as Ez,isShallowEqual as bz}from"@excalidraw/common";import{Fragment as Qf,jsx as wt,jsxs as Ba}from"react/jsx-runtime";var xz=4,wz=8,qf=38,WS=21,yz=({shouldWrap:e,children:n,username:t})=>e?wt(dt,{label:t||"Unknown user",children:n}):wt(Qf,{children:n}),Jf=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return wt(yz,{username:n.username,shouldWrap:r,children:s},t)},vz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],cp=lp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=nt(),a=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,P])=>({...P,socketId:C})).filter(C=>C.username?.trim()),l=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[d,m]=lp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=lp.useRef(null);fz(()=>{if(u.current){let C=A=>{g(A)};if(C(u.current.clientWidth),!Ez)return;let P=new ResizeObserver(A=>{for(let L of A){let{width:_}=L.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=lp.useState(xz*qf),b=l?E-WS:E,y=Math.max(1,Math.min(8,Math.floor(b/qf))),w=l?Math.max(0,y-1):y,x=c.slice(0,w),v=l?[...x,l]:x,T=v.map(C=>{let P=Jf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?Ba(Rl.Root,{children:[wt(Rl.Trigger,{asChild:!0,children:Ba("div",{className:"UserList__pill",children:[P,wt("div",{className:"UserList__pill-chevron",children:e0})]})}),wt(Rl.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Ba(He,{padding:2,children:[s.length>=wz&&wt(nd,{placeholder:f("quickSearch.placeholder"),onChange:m}),wt(od,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[wt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(A=>Jf({actionManager:i,collaborator:A,socketId:A.socketId,withName:!0,isBeingFollowed:A.socketId===o}))]:[]}),a&&Ba(Qf,{children:[wt("div",{className:"UserList__menu-divider"}),wt(Rl.Close,{asChild:!0,children:wt("div",{className:"dropdown-menu",children:a})})]}),wt(Rl.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]},C.socketId):P});return n?Ba("div",{className:US("UserList UserList_mobile",e),children:[wt("div",{className:"UserList_mobile__avatars",children:s.map(C=>Jf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&Ba(Qf,{children:[wt("div",{className:"UserList__menu-divider"}),a]})]}):wt("div",{className:"UserList__wrapper",ref:u,children:wt("div",{className:US("UserList",e),style:{"--max-avatars":v.length+(l?WS/qf:0)},children:T})})},(e,n)=>{if(e.collaborators.size!==n.collaborators.size||e.mobile!==n.mobile||e.className!==n.className||e.userToFollow!==n.userToFollow||e.currentUserControls!==n.currentUserControls)return!1;let t=n.collaborators.keys();for(let[o,r]of e.collaborators){let i=n.collaborators.get(o);if(!i||o!==t.next().value||!bz(r,i,vz))return!1}return!0});import Nl from"clsx";import{jsx as VS}from"react/jsx-runtime";var YS=e=>VS(dt,{label:`${f("helpDialog.title")} \u2014 ?`,children:VS("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:wi})});import{jsx as Zt,jsxs as eE}from"react/jsx-runtime";var XS=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=tt(),l=It();return eE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&Zt("div",{className:Nl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Zt(Dt.Col,{gap:2,children:eE(_l,{heading:"canvasActions",children:[!e.viewModeOnly&&Zt(dt,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:Zt("div",{className:Nl("view-mode-button"),children:n.renderAction("viewMode")})}),Zt(dt,{label:f("buttons.smartZoom"),children:Zt("div",{className:Nl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&Zt(eS,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&Zt(tS,{renderAction:n.renderAction,className:Nl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Zt(a.Out,{}),(r||o)&&Zt("div",{className:Nl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:eE("div",{style:{position:"relative"},children:[o&&Zt(s.Out,{}),r&&Zt(YS,{onClick:()=>n.executeAction(Hr)})]})}),r&&Zt(nS,{showExitZenModeBtn:t})]})},KS=XS;XS.displayName="Footer";import{composeEventHandlers as Az}from"@excalidraw/common";import{useLayoutEffect as Iz,useRef as Tz}from"react";import{jsx as Sz}from"react/jsx-runtime";var ei=(e,n)=>{let t=qe(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=tt(),[,a]=i(t),s=Tz({preferHost:!1,counter:0});return Iz(()=>{let l=s.current;return a(c=>{let d=c+1;return l.counter=d,d}),()=>{a(c=>{let d=c-1;return l.counter=d,d||(l.preferHost=!1),d})}},[a]),r.__fallback||(s.current.preferHost=!0),!s.current.counter&&r.__fallback&&s.current.preferHost||s.current.counter>1&&r.__fallback?null:Sz(n,{...r})};return o.displayName=e,o};var rE={};QM(rE,{ChangeCanvasBackground:()=>rC,Export:()=>iC,Help:()=>nC,LiveCollaborationTrigger:()=>sC,LoadScene:()=>JS,Preferences:()=>Jn,PreferencesToggleGridModeItem:()=>oE,SaveAsImage:()=>eC,SaveToActiveFile:()=>QS,SearchMenu:()=>tC,Socials:()=>aC,ToggleTheme:()=>oC});import Mz from"clsx";import{THEME as Ol}from"@excalidraw/common";var tE=qe({active:!1});async function ZS({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{gt.set(tE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import Cz from"clsx";import{jsx as $S,jsxs as Pz}from"react/jsx-runtime";var dp=function({onChange:e,value:n,choices:t,name:o}){return $S("div",{className:"RadioGroup",children:t.map(r=>Pz("div",{className:Cz("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[$S("input",{name:o,type:"radio",checked:r.value===n,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as kz,jsx as Bl,jsxs as jS}from"react/jsx-runtime";var qS=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=ge();return jS(kz,{children:[jS("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&Bl("div",{className:"dropdown-menu-item__icon",children:a}),Bl("label",{className:"dropdown-menu-item__text",children:Bl(Ps,{children:r})}),Bl(dp,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&Bl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};qS.displayName="DropdownMenuItemContentRadio";var nE=qS;import{Fragment as gC,jsx as Ee,jsxs as Fl}from"react/jsx-runtime";var JS=()=>{let{t:e}=Ae(),n=nt(),t=Ci();return n.isActionEnabled(Ui)?Ee(Yt,{icon:Ac,onSelect:async()=>{(!t.length||await ZS({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:Ee(Jr,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>Ee("strong",{children:r}),br:()=>Ee("br",{})})}))&&n.executeAction(Ui)},"data-testid":"load-button",shortcut:Ke("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};JS.displayName="LoadScene";var QS=()=>{let{t:e}=Ae(),n=nt();return n.isActionEnabled(zr)?Ee(Yt,{shortcut:Ke("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(zr),icon:Rx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};QS.displayName="SaveToActiveFile";var eC=()=>{let e=Be(),{t:n}=Ae();return Ee(Yt,{icon:Ox,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ke("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};eC.displayName="SaveAsImage";var tC=e=>{let{t:n}=Ae(),t=nt();return Ee(Yt,{icon:Yn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(ul)},shortcut:Ke("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};tC.displayName="SearchMenu";var nC=()=>{let{t:e}=Ae(),n=nt();return Ee(Yt,{"data-testid":"help-menu-item",icon:wi,onSelect:()=>n.executeAction(Hr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};nC.displayName="Help";var oC=e=>{let{t:n}=Ae(),t=fe(),o=nt(),r=Ke("toggleTheme"),i=yn();return o.isActionEnabled(vd)?e?.allowSystemTheme?Ee(nE,{name:"theme",value:e.theme,onChange:a=>{if(i.onThemeChange){i.onThemeChange(a);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:Ol.LIGHT,label:us,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:Ol.DARK,label:ps,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:X1,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):Ee(Yt,{onSelect:a=>{a.preventDefault(),o.executeAction(vd)},icon:t.theme===Ol.DARK?us:ps,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Ol.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===Ol.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};oC.displayName="ToggleTheme";var rC=()=>{let{t:e}=Ae(),n=fe(),t=nt(),o=yn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Fl("div",{style:{marginTop:"0.75rem"},children:[Ee("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),Ee("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};rC.displayName="ChangeCanvasBackground";var iC=()=>{let{t:e}=Ae(),n=Be();return Ee(Yt,{icon:hs,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};iC.displayName="Export";var aC=()=>{let{t:e}=Ae();return Fl(gC,{children:[Ee(_a,{icon:Lx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),Ee(_a,{icon:_x,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),Ee(_a,{icon:Dx,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};aC.displayName="Socials";var sC=({onSelect:e,isCollaborating:n})=>{let{t}=Ae();return Ee(Yt,{"data-testid":"collab-button",icon:Lc,className:Mz({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};sC.displayName="LiveCollaborationTrigger";var lC=()=>{let{t:e}=Ae(),n=It(),t=fe();return Ee(qn,{checked:t.activeTool.locked,shortcut:Ke("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},cC=()=>{let{t:e}=Ae(),n=fe(),t=Be();return Ee(nE,{name:"boxSelectionMode",icon:Bc,value:n.boxSelectionMode,onChange:o=>{t({boxSelectionMode:o})},choices:[{value:"contain",label:e("labels.boxSelectionContain"),ariaLabel:e("labels.boxSelectionContain")},{value:"overlap",label:e("labels.boxSelectionOverlap"),ariaLabel:e("labels.boxSelectionOverlap")}],children:e("labels.boxSelectionMode")})},dC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(qn,{checked:t.objectsSnapModeEnabled,shortcut:Ke("objectsSnapMode"),onSelect:o=>{n.executeAction(kt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},mC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(qn,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(Ks),o.preventDefault()},children:e("labels.arrowBinding")})},pC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(qn,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(Zs),o.preventDefault()},children:e("labels.midpointSnapping")})},oE=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(qn,{checked:t.gridModeEnabled,shortcut:Ke("gridMode"),onSelect:o=>{n.executeAction(ji),o.preventDefault()},children:e("labels.toggleGrid")})},uC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return t.viewModeOnly?null:Ee(qn,{checked:t.viewModeEnabled,shortcut:Ke("viewMode"),onSelect:o=>{n.executeAction(da),o.preventDefault()},children:e("labels.viewMode")})},hC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(qn,{checked:t.stats.open,shortcut:Ke("stats"),onSelect:o=>{n.executeAction(Qo),o.preventDefault()},children:e("stats.fullTitle")})},Jn=({children:e,additionalItems:n})=>{let{t}=Ae();return Fl(lr,{children:[Ee(lr.Trigger,{icon:n0,children:t("labels.preferences")}),Fl(lr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Fl(gC,{children:[Ee(cC,{}),Ee(lC,{}),Ee(dC,{}),Ee(oE,{}),Ee(uC,{}),Ee(hC,{}),Ee(mC,{}),Ee(pC,{})]}),n]})]})};Jn.ToggleToolLock=lC;Jn.BoxSelectionMode=cC;Jn.ToggleSnapMode=dC;Jn.ToggleArrowBinding=mC;Jn.ToggleMidpointSnapping=pC;Jn.ToggleGridMode=oE;Jn.ToggleViewMode=uC;Jn.ToggleElementProperties=hC;Jn.displayName="Preferences";import{jsx as mp,jsxs as iE}from"react/jsx-runtime";var Lz=Object.assign(ei("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=tt(),o=ge(),r=fe(),i=yn(),a=Be();return mp(t.In,{children:iE(de,{open:r.openMenu==="canvas",children:[mp(de.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Mx}),iE(de.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:Az(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&iE("fieldset",{className:"UserList-Wrapper",children:[mp("legend",{children:f("labels.collaborators")}),mp(cp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:de.Trigger,Item:de.Item,ItemLink:de.ItemLink,ItemCustom:de.ItemCustom,Group:de.Group,Separator:de.Separator,Sub:lr,DefaultItems:rE}),_t=Lz;import Dz from"clsx";import{forwardRef as _z,useState as Rz}from"react";import{isPromiseLike as Nz}from"@excalidraw/common";import{jsx as pp,jsxs as Bz}from"react/jsx-runtime";var cr=_z(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:c,disabled:d},m)=>{let[p,u]=Rz(!1),E=async b=>{let y=t?.(b);if(Nz(y)){let w=window.setTimeout(()=>{u(!0)},50);try{await y}catch(x){if(x instanceof gc)console.warn(x);else throw x}finally{clearTimeout(w),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,pp("button",{className:Dz("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":s},l),onClick:E,type:"button","aria-label":o,ref:m,disabled:d||g==="loading"||g==="success",children:Bz("div",{className:"ExcButton__contents",children:[g==="loading"?pp(so,{className:"ExcButton__statusIcon"}):g==="success"&&pp("div",{className:"ExcButton__statusIcon",children:N1}),n&&pp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as Oa,jsxs as zz}from"react/jsx-runtime";var up=({title:e,children:n,actionLabel:t,onClick:o})=>zz("div",{className:"OverwriteConfirm__Actions__Action",children:[Oa("h4",{children:e}),Oa("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),Oa(cr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),Oz=()=>{let{t:e}=Ae(),n=nt(),t=Be();return Oa(up,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(Gd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},Fz=()=>{let{t:e}=Ae(),n=nt();return Oa(up,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(Vs,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},aE=Object.assign(({children:e})=>Oa("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:Oz,SaveToDisk:Fz});import{jsx as dr,jsxs as fC}from"react/jsx-runtime";var hp=Object.assign(ei("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=tt(),[t,o]=ze(tE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return dr(n.In,{children:dr(gn,{onCloseRequest:r,title:!1,size:916,children:fC("div",{className:"OverwriteConfirm",children:[dr("h3",{children:t.title}),fC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[dr("div",{className:"OverwriteConfirm__Description__icon",children:B1}),dr("div",{children:t.description}),dr("div",{className:"OverwriteConfirm__Description__spacer"}),dr(cr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),dr(aE,{children:e})]})})})}),{Actions:aE,Action:up});import{round as aP}from"@excalidraw/math";import oG from"clsx";import rG from"lodash.throttle";import{useEffect as sP,useMemo as wE,useState as iG,memo as aG}from"react";import{STATS_PANELS as Ip}from"@excalidraw/common";import{getCommonBounds as sG}from"@excalidraw/element";import{getUncroppedWidthAndHeight as lG}from"@excalidraw/element";import{isImageElement as yE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as cG}from"@excalidraw/element";import{elementsAreInSameGroup as dG}from"@excalidraw/element";import{degreesToRadians as TC,radiansToDegrees as kC}from"@excalidraw/math";import{getBoundTextElement as SC}from"@excalidraw/element";import{isArrowElement as CC,isElbowArrow as Qz}from"@excalidraw/element";import{updateBindings as PC}from"@excalidraw/element";import Kz from"clsx";import{useEffect as vC,useRef as fp,useState as Zz}from"react";import{EVENT as Ha,KEYS as $z,cloneJSON as sE}from"@excalidraw/common";import{deepCopyElement as jz}from"@excalidraw/element";import{CaptureUpdateAction as IC}from"@excalidraw/element";import{pointFrom as mr,pointRotateRads as gp}from"@excalidraw/math";import{getBoundTextElement as Hz,getNonDeletedElements as Gz,isBindingElement as Uz,unbindBindingElement as EC}from"@excalidraw/element";import{isFrameLikeElement as wC}from"@excalidraw/element";import{getSelectedGroupIds as Wz,getElementsInGroup as Vz,isInGroup as Yz}from"@excalidraw/element";import{getFrameChildren as Xz}from"@excalidraw/element";import{updateBindings as bC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as xC}from"@excalidraw/common";var yC=.01,zl=10,Ht=(e,n)=>!(n==="angle"&&wC(e)),Ge=(e,n)=>{let t=e+n/2;return t-t%n},Fa=(e,n,t)=>Object.keys(e).map(o=>({original:(t??n).get(o),latest:n.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0);var ti=(e,n,t,o,r,i,a=!0)=>{if(Uz(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<xC&&Math.abs(n-t.y)<xC)return;EC(t,"start",o),EC(t,"end",o)}let s=o.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[c,d]=[t.x+t.width/2,t.y+t.height/2],[m,p]=gp(mr(t.x,t.y),mr(c,d),t.angle),u=e-m,E=n-p,[g,b]=gp(mr(e,n),mr(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),bC(l,o,r);let y=Hz(t,i);if(y){let w=s.get(y.id);w&&o.mutateElement(w,{x:y.x+u,y:y.y+E},{informMutation:a,isDragging:!1})}if(wC(t)){let w=Xz(i,t.id);w.forEach(x=>{let v=s.get(x.id);if(!v)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,A]=gp(mr(x.x,x.y),mr(T,C),x.angle),L=Math.round(P+u),_=Math.round(A+E),[k,D]=gp(mr(L,_),mr(T+u,C+E),-x.angle);o.mutateElement(v,{x:k,y:D},{informMutation:a,isDragging:!1}),bC(v,o,r,{simultaneouslyUpdated:Gz(w)})})}},za=(e,n)=>{let o=Wz(n).map(r=>Vz(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!Yz(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as lE,jsxs as Jz}from"react/jsx-runtime";var qz=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=It(),u=Be(),E=fp(null),g=fp(null),[b,y]=Zz(o.toString()),w=fp(null);w.current||(w.current={originalAppState:sE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),vC(()=>{let T=o.toString();y(T),w.current.lastUpdatedValue=T},[o]);let x=(T,C,P)=>{if(!w.current.updatePending)return!1;w.current.updatePending=!1;let A=Number(T);if(isNaN(A)){y(o.toString());return}let L=Number(A.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(L-_)>=yC)&&(w.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:L,property:s,originalAppState:P,setInputValue:k=>y(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:IC.IMMEDIATELY}))},v=fp({});return v.current.handleInputValue=x,vC(()=>{let T=E.current,C=v.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,w.current.originalElements,w.current.originalAppState),window.removeEventListener(Ha.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(Ha.POINTER_UP,C.onPointerUp,!1)}},[i]),i?Jz("div",{className:Kz("drag-input-container",!i&&"disabled"),"data-testid":e,children:[lE("div",{className:"drag-input-label",ref:g,onPointerDown:T=>{if(E.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(E.current.value);isNaN(C)&&(C=0);let P=null,A=p.scene.getNonDeletedElements().reduce((z,W)=>(z.set(W.id,jz(W)),z),new Map),L=r.map(z=>A.get(z.id)),_=sE(c),k=0,D=0,O=z=>{if(P&&A!==null&&L!==null){let W=z.clientX-P.x;W!==0&&(D+=W,Math.abs(D)>=d&&(D=Math.sign(D)*Math.floor(Math.abs(D)/d),k+=D,t({accumulatedChange:k,instantChange:D,originalElements:L,originalElementsMap:A,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:Z=>y(String(Z)),app:p,setAppState:u}),D=0))}P={x:z.clientX,y:z.clientY}},Y=()=>{window.removeEventListener(Ha.POINTER_MOVE,O,!1),p.syncActionResult({captureUpdate:IC.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:L,originalAppState:_}),P=null,k=0,D=0,L=null,A=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Ha.POINTER_UP,Y,!1)};v.current.onPointerMove=O,v.current.onPointerUp=Y,window.addEventListener(Ha.POINTER_MOVE,O,!1),window.addEventListener(Ha.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?lE(sd,{icon:n}):e}),lE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===$z.ENTER&&(x(C.value,r,c),p.focusContainer())}},ref:E,value:b,onChange:T=>{w.current.updatePending=!0,y(T.target.value)},onFocus:T=>{T.target.select(),w.current.originalElements=r,w.current.originalAppState=sE(c)},onBlur:T=>{b?i&&x(T.target.value,w.current.originalElements,w.current.originalAppState):y(o.toString())},disabled:!i})]}):null},ut=qz;import{jsx as oH}from"react/jsx-runtime";var eH=15,tH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!Qz(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=TC(o);r.mutateElement(l,{angle:E}),PC(l,r,i.state);let g=SC(l,a);g&&!CC(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(kC(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=Ge(m,eH)),m=m<0?m+360:m;let p=TC(m);r.mutateElement(l,{angle:p}),PC(l,r,i.state);let u=SC(l,a);u&&!CC(l)&&r.mutateElement(u,{angle:p})}},nH=({element:e,scene:n,appState:t,property:o})=>oH(ut,{label:"A",icon:_c,value:Math.round(kC(e.angle)%360*100)/100,elements:[e],dragInputCallback:tH,editable:Ht(e,"angle"),scene:n,appState:t,property:o}),MC=nH;import{jsx as iH}from"react/jsx-runtime";var AC=5,rH=({property:e,scene:n,appState:t,setAppState:o})=>iH(ut,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{o(l=>{let c;return r?c=r:i&&(c=a?Ge(l.gridStep+AC*Math.sign(i),AC):l.gridStep+i),c?(c=Vb(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),LC=rH;import{clamp as Ep,round as cE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as bp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as DC,getNonDeletedElements as aH,getUncroppedWidthAndHeight as NC}from"@excalidraw/element";import{resizeSingleElement as _C}from"@excalidraw/element";import{isImageElement as BC}from"@excalidraw/element";import{isFrameLikeElement as dE}from"@excalidraw/element";import{getElementsInResizingFrame as mE}from"@excalidraw/element";import{replaceAllElementsInFrame as OC}from"@excalidraw/element";import{jsx as mH}from"react/jsx-runtime";var RC=10,sH=e=>e.type==="image",lH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||sH(u),b=u.width/u.height;if(s.croppingElementId===u.id){let y=p.get(u.id);if(!y||!BC(y)||!y.crop)return;let w=y.crop,x={...w},v=y.scale[0]===-1,T=y.scale[1]===-1,{width:C,height:P}=NC(y),A=w.naturalWidth/C,L=w.naturalHeight/P,_=v?w.width+w.x:w.naturalWidth-w.x,k=T?w.height+w.y:w.naturalHeight-w.y,D=DC*A,O=DC*L;if(i!==void 0){if(a==="width"){let H=i*A,re=Ep(H,D,_);x={...x,width:re,x:v?w.x+w.width-re:w.x}}else if(a==="height"){let H=i*L,re=Ep(H,O,k);x={...x,height:re,y:T?w.y+w.height-re:w.y}}c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}let Y=a==="width"?l:0,z=a==="height"?l:0,W=Ep(w.width+Y,D,_),Z=Ep(w.height+z,D,k);x={...w,x:v?w.x+w.width-W:w.x,y:T?w.y+w.height-Z:w.y,width:W,height:Z},c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}if(i!==void 0){let y=Math.max(a==="width"?i:g?i*b:u.width,bp),w=Math.max(a==="height"?i:g?i/b:u.height,bp);if(_C(y,w,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),dE(E)){let x=mE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),v=OC(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(v)}return}{let y=a==="width"?e:0,w=a==="height"?e:0,x=Math.max(0,u.width+y);a==="width"&&(r?x=Ge(x,RC):x=Math.round(x));let v=Math.max(0,u.height+w);if(a==="height"&&(r?v=Ge(v,RC):v=Math.round(v)),g&&(a==="width"?v=Math.round(x/b*100)/100:x=Math.round(v*b*100)/100),v=Math.max(bp,v),x=Math.max(bp,x),_C(x,v,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),dE(E)){let T=aH(mE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},cH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&dE(a)){let s=mE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=OC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},dH=({property:e,element:n,scene:t,appState:o})=>{let r=cE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&BC(n)&&n.crop){let{width:i,height:a}=NC(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=cE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=cE(n.crop.height*s,2)}}return mH(ut,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:lH,value:r,editable:Ht(n,e),scene:t,appState:o,property:e,dragFinishedCallback:cH})},pE=dH;import{getBoundTextElement as pH,redrawTextBoundingBox as uH}from"@excalidraw/element";import{hasBoundTextElement as hH,isTextElement as zC}from"@excalidraw/element";import{jsx as bH}from"react/jsx-runtime";var FC=4,gH=4,fH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let s=i.get(a.id);if(!s||!zC(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),FC);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,FC),t&&(l=Ge(l,gH))}l&&(r.mutateElement(s,{fontSize:l}),uH(s,r.getContainerElement(s),r))}},EH=({element:e,scene:n,appState:t,property:o})=>{let r=zC(e)?e:hH(e)?pH(e,n.getNonDeletedElementsMap()):null;return r?bH(ut,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:fH,icon:kr,appState:t,scene:n,property:o}):null},HC=EH;import{degreesToRadians as GC,radiansToDegrees as VC}from"@excalidraw/math";import{getBoundTextElement as UC}from"@excalidraw/element";import{isArrowElement as WC}from"@excalidraw/element";import{isInGroup as uE}from"@excalidraw/element";import{jsx as vH}from"react/jsx-runtime";var xH=15,wH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=n.map(c=>a.get(c.id)).filter(c=>c&&!uE(c)&&Ht(c,r)),l=n.filter(c=>!uE(c)&&Ht(c,r));if(o!==void 0){let c=GC(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=UC(d,a);m&&!WC(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let m=l[c],p=Math.round(VC(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=Ge(E,xH)),E=E<0?E+360:E;let g=GC(E);i.mutateElement(d,{angle:g});let b=UC(d,a);b&&!WC(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},yH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!uE(l)&&Ht(l,"angle")),i=r.map(l=>Math.round(VC(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Ht(l,"angle"));return vH(ut,{label:"A",icon:_c,value:a,elements:e,dragInputCallback:wH,editable:s,appState:t,scene:n,property:o})},YC=yH;import{pointFrom as $C}from"@excalidraw/math";import{useMemo as TH}from"react";import{MIN_WIDTH_OR_HEIGHT as pr}from"@excalidraw/common";import{getElementsInResizingFrame as hE,getNonDeletedElements as SH,isFrameLikeElement as gE,replaceAllElementsInFrame as JC,updateBoundElements as CH}from"@excalidraw/element";import{rescalePointsInElement as PH,resizeSingleElement as jC}from"@excalidraw/element";import{getBoundTextElement as kH,handleBindTextResize as MH}from"@excalidraw/element";import{isTextElement as QC}from"@excalidraw/element";import{MIME_TYPES as ni}from"@excalidraw/common";import{getNonDeletedElements as XC}from"@excalidraw/element";var xp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=XC(Tr(e,null,{deleteInvisibleElements:!0})),l=pi(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return wc(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(m,p),b=o<g?o/g:n?.exportScale??1;return u.width=m*b,u.height=p*b,{canvas:u,scale:b}}let E=r?.(m,p)||{width:m,height:p};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},KC=async e=>{let{mimeType:n=ni.png,quality:t}=e;n===ni.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ni.png}" mimeType`),n==="image/jpg"&&(n=ni.jpg),n===ni.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ni.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await xp(e);return t=t||(/image\/jpe?g/.test(n)?.92:.8),new Promise((r,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&n===ni.png&&e.appState?.exportEmbedScene&&(a=await nx({blob:a,metadata:is(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},ZC=async({elements:e,appState:n=_o(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=XC(Tr(e,null,{deleteInvisibleElements:!0})),d={...pi(n,null),exportPadding:o};return Ir(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},IH=async e=>{if(e.type==="svg"){let n=await ZC(e);await uo(n.outerHTML)}else if(e.type==="png")await zd(KC(e));else if(e.type==="json")await Bd(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as t8e}from"@excalidraw/element";import{getCommonBounds as wp}from"@excalidraw/element";import{jsx as NH}from"react/jsx-runtime";var Ga=10,AH=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,s=o.height*t,l=e+r*t,c=n+i*t;return{width:a,height:s,x:l,y:c,...PH(o,a,s,!1),...QC(o)?{fontSize:o.fontSize*t}:{}}},LH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=AH(e,n,o,i);s.mutateElement(r,c);let d=kH(i,a);if(d){let m=d.fontSize*o;CH(r,s);let p=l.get(d.id);p&&QC(p)&&(s.mutateElement(p,{fontSize:m}),MH(r,s,t==="width"?"e":"s",!0))}},qC=(e,n,t,o,r,i,a,s,l,c)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let d=n/t;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];LH(r[0],r[1],i,d,u,p,l,c)}},DH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),m=za(n,o);if(i!==void 0){for(let g of m){let b=Fa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,T,C]=wp(w),P=T-x,A=C-v,L=P/A,_=Math.max(pr,s==="width"?Math.max(0,i):P),k=Math.max(pr,s==="height"?Math.max(0,i):A);qC(_,k,A,L,$C(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&Ht(w,s)){let v=s==="width"?Math.max(0,i):w.width;s==="width"&&(r?v=Ge(v,Ga):v=Math.round(v));let T=s==="height"?Math.max(0,i):w.height;if(s==="height"&&(r?T=Ge(T,Ga):T=Math.round(T)),v=Math.max(pr,v),T=Math.max(pr,T),jC(v,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),gE(w)){let C=hE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()),P=JC(a.getElementsIncludingDeleted(),C,w);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=s==="width"?e:0,u=s==="height"?e:0,E=[];for(let g of m){let b=Fa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,T,C]=wp(w),P=T-x,A=C-v,L=P/A,_=Math.max(0,P+p);s==="width"&&(r?_=Ge(_,Ga):_=Math.round(_));let k=Math.max(0,A+u);s==="height"&&(r?k=Ge(k,Ga):k=Math.round(k)),_=Math.max(pr,_),k=Math.max(pr,k),qC(_,k,A,L,$C(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&Ht(w,s)){let v=Math.max(0,x.width+p);s==="width"&&(r?v=Ge(v,Ga):v=Math.round(v));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=Ge(T,Ga):T=Math.round(T)),v=Math.max(pr,v),T=Math.max(pr,T),jC(v,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),gE(w)){let C=SH(hE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},_H=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&gE(a)){let s=hE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=JC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},RH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=TH(()=>o.map(c=>{let d=Fa(c,t);if(d.length>1){let[p,u,E,g]=wp(d.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return NH(ut,{label:e==="width"?"W":"H",elements:n,dragInputCallback:DH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:_H})},fE=RH;import{getBoundTextElement as BH,redrawTextBoundingBox as eP}from"@excalidraw/element";import{hasBoundTextElement as OH,isTextElement as FH}from"@excalidraw/element";import{isInGroup as zH}from"@excalidraw/element";import{jsx as VH}from"react/jsx-runtime";var tP=4,HH=4,GH=(e,n)=>e.reduce((t,o)=>{if(!o||zH(o))return t;if(FH(o))return t.push(o),t;if(OH(o)){let r=BH(o,n);if(r)return t.push(r),t}return t},[]),UH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),tP);for(let l of a)r.mutateElement(l,{fontSize:s}),eP(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,tP);t&&(E=Ge(E,HH)),r.mutateElement(d,{fontSize:E}),eP(d,r.getContainerElement(d),r)}r.triggerUpdate()}},WH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=GH(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return VH(ut,{label:"F",icon:kr,elements:i,dragInputCallback:UH,value:s,editable:l,scene:n,property:o,appState:t})},nP=WH;import{pointFrom as ur,pointRotateRads as yp}from"@excalidraw/math";import{useMemo as YH}from"react";import{isTextElement as XH}from"@excalidraw/element";import{getCommonBounds as EE}from"@excalidraw/element";import{jsx as qH}from"react/jsx-runtime";var KH=(e,n,t,o,r,i,a)=>{for(let s=0;s<o.length;s++){let l=o[s],[c,d]=[l.x+l.width/2,l.y+l.height/2],[m,p]=yp(ur(l.x,l.y),ur(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;ti(u,E,l,i,a,r,!1)}},ZH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=EE(t),c=e-s,d=n-l;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!XH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,y]=yp(ur(u.x,u.y),ur(E,g),u.angle);ti(b+c,y+d,p,r,i,o,!1)}}},$H=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of za(n,s)){let E=Fa(u,c,t);if(E.length>1){let[g,b,,]=EE(E.map(x=>x.latest));ZH(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,l.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&Ht(b,i)){let[y,w]=[g.x+g.width/2,g.y+g.height/2],[x,v]=yp(ur(g.x,g.y),ur(y,w),g.angle);ti(i==="x"?r:x,i==="y"?r:v,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?Ge(e,zl):e;KH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},jH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=YH(()=>o.map(l=>{let c=Object.keys(l).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,b]=EE(c);return Math.round((e==="x"?g:b)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,E]=yp(ur(d.x,d.y),ur(m,p),d.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return qH(ut,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:$H,value:s,property:e,scene:r,appState:i})},bE=jH;import{clamp as Hl,pointFrom as vp,pointRotateRads as rP,round as oP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as JH,getUncroppedWidthAndHeight as QH}from"@excalidraw/element";import{isImageElement as iP}from"@excalidraw/element";import{jsx as nG}from"react/jsx-runtime";var eG=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:c})=>{let d=s.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=rP(vp(m.x,m.y),vp(p,u),m.angle);if(l.croppingElementId===m.id){let v=d.get(m.id);if(!v||!iP(v)||!v.crop)return;let T=v.crop,C=T,P=v.scale[0]===-1,A=v.scale[1]===-1,{width:L,height:_}=QH(v);if(i!==void 0){if(a==="x"){let O=i*(T.naturalWidth/L);P?C={...T,x:Hl(T.naturalWidth-O-T.width,0,T.naturalWidth-T.width)}:C={...T,x:Hl(i*(T.naturalWidth/L),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:Hl(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(v,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),D=(a==="y"?n:0)*(A?-1:1);C={...T,x:Hl(T.x+k,0,T.naturalWidth-T.width),y:Hl(T.y+D,0,T.naturalHeight-T.height)},s.mutateElement(v,{crop:C});return}if(i!==void 0){ti(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,y=a==="y"?e:0,w=a==="x"?Math.round(r?Ge(m.x+b,zl):E+b):E,x=a==="y"?Math.round(r?Ge(m.y+y,zl):g+y):g;ti(w,x,m,s,c.state,o)},tG=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=rP(vp(n.x,n.y),vp(n.x+n.width/2,n.y+n.height/2),n.angle),a=oP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&iP(n)&&n.crop){let s=JH(n);s&&(a=oP(e==="x"?s.x:s.y,2))}return nG(ut,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:eG,scene:t,value:a,property:e,appState:o})},xE=tG;import{Fragment as vE,jsx as te,jsxs as Gt}from"react/jsx-runtime";var mG=50,Gl=e=>{let n=Xo(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=nr(e.app);return te(pG,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Oe=({children:e,columns:n=1,heading:t,style:o,...r})=>te("div",{className:oG("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Oe.displayName="StatsRow";var Tp=({children:e,order:n,style:t,...o})=>te("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Tp.displayName="StatsRows";Gl.StatsRow=Oe;Gl.StatsRows=Tp;var pG=aG(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=Be(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&yE(m),E=u?lG(m):null,[g,b]=iG({width:0,height:0}),y=wE(()=>rG(v=>{let T=sG(v);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},mG),[]);sP(()=>{y(l)},[i,l,y]),sP(()=>()=>y.cancel(),[y]);let w=wE(()=>za(o,r),[o,r]),x=wE(()=>cG(o),[o]);return te("div",{className:"exc-stats",children:Gt(He,{padding:3,children:[Gt("div",{className:"title",children:[te("h2",{children:f("stats.title")}),te("div",{className:"close",onClick:n,children:Qt})]}),Gt(As,{label:te("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Ip.generalStats),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^Ip.generalStats}})),children:[Gt(Tp,{children:[te(Oe,{heading:!0,children:f("stats.scene")}),Gt(Oe,{columns:2,children:[te("div",{children:f("stats.shapes")}),te("div",{children:l.length})]}),Gt(Oe,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:g.width})]}),Gt(Oe,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:g.height})]}),a&&Gt(vE,{children:[te(Oe,{heading:!0,children:"Canvas"}),te(Oe,{children:te(LC,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&te("div",{id:"elementStats",style:{marginTop:12},children:te(As,{label:te("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Ip.elementProperties),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^Ip.elementProperties}})),children:Gt(Tp,{children:[m&&Gt(vE,{children:[u&&te(Oe,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&yE(m)&&E&&Gt(Oe,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:aP(E.width,2)})]}),r.croppingElementId&&yE(m)&&E&&Gt(Oe,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:aP(E.height,2)})]}),te(Oe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):m.type==="magicframe"?f("element.frame"):f(`element.${m.type}`)}),te(Oe,{children:te(xE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),te(Oe,{children:te(xE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),te(Oe,{children:te(pE,{property:"width",element:m,scene:s,appState:r})}),te(Oe,{children:te(pE,{property:"height",element:m,scene:s,appState:r})}),te(Oe,{children:te(MC,{property:"angle",element:m,scene:s,appState:r})}),te(Oe,{children:te(HC,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Gt(vE,{children:[dG(p)&&te(Oe,{heading:!0,children:f("element.group")}),Gt(Oe,{columns:2,style:{margin:"0.3125rem 0"},children:[te("div",{children:f("stats.shapes")}),te("div",{children:o.length})]}),te(Oe,{children:te(bE,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Oe,{children:te(bE,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Oe,{children:te(fE,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Oe,{children:te(fE,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Oe,{children:te(YC,{property:"angle",elements:p,scene:s,appState:r})}),te(Oe,{children:te(nP,{property:"fontSize",elements:p,scene:s,appState:r,elementsMap:c})})]})]})})})]})})},(e,n)=>e.sceneNonce===n.sceneNonce&&e.selectedElements===n.selectedElements&&e.appState.stats.panels===n.appState.stats.panels&&e.gridModeEnabled===n.gridModeEnabled&&e.appState.gridStep===n.appState.gridStep&&e.appState.croppingElementId===n.appState.croppingElementId);import{useCallback as TG,useEffect as cP,useState as dP}from"react";import{normalizeLink as SG,KEYS as CE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as CG,getLinkIdAndTypeFromSelection as PG}from"@excalidraw/element";import uG from"clsx";import{jsx as Sp,jsxs as gG}from"react/jsx-runtime";var hG=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return gG("button",{className:uG("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Sp("div",{style:a?{visibility:"hidden"}:{},children:o}),Sp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Sp("div",{style:{position:"absolute",inset:0},children:Sp(so,{})})]})},IE=hG;import TE from"clsx";import{forwardRef as xG,useRef as wG,useImperativeHandle as yG,useLayoutEffect as vG,useState as IG}from"react";import fG from"clsx";import{composeEventHandlers as EG}from"@excalidraw/common";import{jsx as bG}from"react/jsx-runtime";var fn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>bG("button",{onClick:EG(i.onClick,a=>{n()}),type:e,className:fG("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as SE,jsxs as lP}from"react/jsx-runtime";var Cp=xG(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...m},p)=>{let u=wG(null);yG(p,()=>u.current),vG(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=IG(!1);return lP("div",{className:TE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&SE("div",{className:"ExcTextField__label",children:n}),lP("div",{className:TE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[SE("input",{className:TE({"is-redacted":"value"in m&&m.value&&s&&!E}),readOnly:r,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:o,ref:u,onChange:b=>e?.(b.target.value),onKeyDown:a,type:d}),s&&SE(fn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?O1:Ar})]})]})});import{jsx as Ua,jsxs as Pp}from"react/jsx-runtime";var kG=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=CG})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=dP(a),[c,d]=dP(!1);cP(()=>{let p=se(i,t),u=a;if(p.length>0&&r){let E=PG(p,t);E&&(u=SG(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=TG(()=>{if(s&&s!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:s})}if(!s&&c&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,s,i,c,o,n]);return cP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===CE.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===CE.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Pp("div",{className:"ElementLinkDialog",children:[Pp("div",{className:"ElementLinkDialog__header",children:[Ua("h2",{children:f("elementLink.title")}),Ua("p",{children:f("elementLink.desc")})]}),Pp("div",{className:"ElementLinkDialog__input",children:[Ua(Cp,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===CE.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&Ua(K,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Pr})]}),Pp("div",{className:"ElementLinkDialog__actions",children:[Ua(IE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),Ua(IE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},mP=kG;import MG,{useState as AG}from"react";import{Fragment as LG,jsx as PE}from"react/jsx-runtime";var pP=({children:e,onClose:n})=>{let[t,o]=AG(!!e),{container:r}=De(),i=MG.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return PE(LG,{children:t&&PE(gn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:PE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import uP,{useMemo as zG}from"react";import hP from"clsx";import{isDarwin as gP,isFirefox as HG,isWindows as GG}from"@excalidraw/common";import{KEYS as Wa}from"@excalidraw/common";import{SHAPES as UG}from"@excalidraw/element/shapes";import{isFirefox as DG,KEYS as kE}from"@excalidraw/common";import{SHAPES as _G}from"@excalidraw/element/shapes";import{Fragment as FG,jsx as Ue,jsxs as oi}from"react/jsx-runtime";var RG=e=>oi(FG,{children:[Ue("h3",{children:e.title}),Ue("div",{className:"HelpDialog__islands-container",children:e.children})]}),ME=e=>oi("div",{className:`HelpDialog__island ${e.className}`,children:[Ue("h4",{className:"HelpDialog__island-title",children:e.caption}),Ue("div",{className:"HelpDialog__island-content",children:e.children})]});function*NG(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var BG=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),yt=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ue(OG,{children:BG(a)},a)));return oi("div",{className:"HelpDialog__shortcut",children:[Ue("div",{children:e}),Ue("div",{className:"HelpDialog__key-container",children:[...NG(o,t?f("helpDialog.or"):null)]})]})},OG=e=>Ue("kbd",{className:"HelpDialog__key",...e});function AE(){return oi(RG,{title:f("helpDialog.shortcuts"),children:[oi(ME,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ue(yt,{label:f("toolBar.hand"),shortcuts:[kE.H]}),_G.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ue(yt,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ue(yt,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ue(yt,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),oi(ME,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ue(yt,{label:f("helpDialog.smartZoom"),shortcuts:[kE.F]}),Ue(yt,{label:f("helpDialog.dragToZoom"),shortcuts:[`${kE.Z}+${f("helpDialog.drag")}`]}),Ue(yt,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),oi(ME,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ue(yt,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ue(yt,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ue(yt,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ue(yt,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(jo||DG)&&Ue(yt,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ue(yt,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ue(yt,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ue(yt,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ue(yt,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ue(yt,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as EP,jsx as $,jsxs as ri}from"react/jsx-runtime";var WG=e=>ri(EP,{children:[$("h3",{children:e.title}),$("div",{className:"HelpDialog__islands-container",children:e.children})]}),LE=e=>ri("div",{className:`HelpDialog__island ${e.className}`,children:[$("h4",{className:"HelpDialog__island-title",children:e.caption}),$("div",{className:"HelpDialog__island-content",children:e.children})]});function*VG(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var YG=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),q=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>$(XG,{children:YG(a)},a)));return ri("div",{className:"HelpDialog__shortcut",children:[$("div",{children:e}),$("div",{className:"HelpDialog__key-container",children:[...VG(o,t?f("helpDialog.or"):null)]})]})},XG=e=>$("kbd",{className:"HelpDialog__key",...e}),fP=({onClose:e})=>{let[n,t]=uP.useState(!1),o=uP.useCallback(()=>{e&&e()},[e]),r=zG(()=>n?$("button",{className:hP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):$("button",{className:hP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return $(EP,{children:$(gn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?ri(WG,{title:f("helpDialog.shortcuts"),children:[ri(LE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[$(q,{label:f("toolBar.hand"),shortcuts:[Wa.H]}),UG.map(({value:i,key:a})=>$(q,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),$(q,{label:f("toolBar.frame"),shortcuts:[Wa.F]}),$(q,{label:f("labels.eyeDropper"),shortcuts:[Wa.I,"Shift+S","Shift+I"]}),$(q,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),$(q,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),$(q,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),$(q,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),$(q,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),$(q,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),$(q,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),$(q,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),$(q,{label:f("toolBar.lock"),shortcuts:[Wa.Q]}),$(q,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),$(q,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),$(q,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),ri(LE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[$(q,{label:f("helpDialog.smartZoom"),shortcuts:[Wa.F]}),$(q,{label:f("helpDialog.dragToZoom"),shortcuts:[`${Wa.Z}+${f("helpDialog.drag")}`]}),$(q,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),$(q,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),$(q,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),$(q,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),$(q,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),$(q,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),$(q,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),$(q,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),$(q,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),$(q,{label:f("search.title"),shortcuts:[Ke("searchMenu")]})]}),ri(LE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[$(q,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),$(q,{label:f("labels.delete"),shortcuts:[N("Delete")]}),$(q,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),$(q,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),$(q,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),$(q,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),$(q,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),$(q,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),$(q,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),$(q,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(jo||HG)&&$(q,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),$(q,{label:f("labels.sendToBack"),shortcuts:[gP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),$(q,{label:f("labels.bringToFront"),shortcuts:[gP?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),$(q,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),$(q,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),$(q,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),$(q,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),$(q,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),$(q,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),$(q,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+R")]}),$(q,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),$(q,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),$(q,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),$(q,{label:f("buttons.redo"),shortcuts:GG?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),$(q,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),$(q,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),$(q,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),$(q,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),$(q,{label:f("labels.showStroke"),shortcuts:[N("S")]}),$(q,{label:f("labels.showBackground"),shortcuts:[N("G")]}),$(q,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),$(q,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),$(q,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):$(AE,{})})})};import{useEffect as wP,useRef as yP,useState as ii}from"react";import{DEFAULT_EXPORT_PADDING as JG,EXPORT_IMAGE_TYPES as DE,isFirefox as QG,EXPORT_SCALES as eU,cloneJSON as vP}from"@excalidraw/common";import{useCallback as KG,useRef as ZG,useState as $G}from"react";var jG=2e3,bP=()=>{let[e,n]=$G(null),t=ZG(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},jG)},r=KG(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import qG from"clsx";import{jsx as xP}from"react/jsx-runtime";var Ul=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>xP("div",{className:qG("Switch",{toggled:t,disabled:r}),children:xP("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});import{jsx as Fe,jsxs as hr}from"react/jsx-runtime";var tU=()=>hr("div",{children:[Fe("h3",{children:f("canvasError.cannotShowPreview")}),Fe("p",{children:Fe("span",{children:f("canvasError.canvasTooBig")})}),hr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),nU=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Me(n,e),[l,c]=ii(i),[d,m]=ii(s),[p,u]=ii(e.exportBackground),[E,g]=ii(e.exportEmbedScene),[b,y]=ii(e.exportScale),w=yP(null),x=yP(0),[v,T]=ii(null),{onCopy:C,copyStatus:P,resetCopyStatus:A}=bP();wP(()=>{A()},[l,p,a,b,E,A]);let{exportedElements:L,exportingFrame:_}=Or(n,e,d);return wP(()=>{let k=w.current;if(!k)return;let D=k.offsetWidth,O=k.offsetHeight;if(!D)return;let Y=++x.current,z=()=>Y!==x.current;return xp({elements:L,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:JG,maxWidthOrHeight:Math.max(D,O),exportingFrame:_}).then(async W=>{if(!z()){try{await cs(W)}catch(Z){throw Z.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):Z}z()||(T(null),k.replaceChildren(W))}}).catch(W=>{z()||(console.error(W),T(W))}),()=>{x.current+=1}},[e,t,L,_,l,p,a,b,E]),hr("div",{className:"ImageExportModal",children:[Fe("h3",{children:f("imageExportDialog.header")}),hr("div",{className:"ImageExportModal__preview",children:[Fe("div",{className:"ImageExportModal__preview__canvas",ref:w,children:v&&Fe(tU,{})}),Fe("div",{className:"ImageExportModal__preview__filename",children:!mi&&Fe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(Uh,"ui",k.target.value)}})})]}),hr("div",{className:"ImageExportModal__settings",children:[Fe("h3",{children:f("imageExportDialog.header")}),s&&Fe(Wl,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Fe(Ul,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Fe(Wl,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Fe(Ul,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(Wh,"ui",k)}})}),Fe(Wl,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Fe(Ul,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(ly,"ui",k)}})}),Fe(Wl,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Fe(Ul,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(Gd,"ui",k)}})}),Fe(Wl,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Fe(dp,{name:"exportScale",value:b,onChange:k=>{y(k),o.executeAction(ay,"ui",k)},choices:eU.map(k=>({value:k,label:`${k}\xD7`}))})}),hr("div",{className:"ImageExportModal__settings__buttons",children:[Fe(cr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(DE.png,L,{exportingFrame:_}),icon:Ou,children:f("imageExportDialog.button.exportToPng")}),Fe(cr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(DE.svg,L,{exportingFrame:_}),icon:Ou,children:f("imageExportDialog.button.exportToSvg")}),(jo||QG)&&Fe(cr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(DE.clipboard,L,{exportingFrame:_}),C()},icon:D1,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Wl=({label:e,children:n,tooltip:t,name:o})=>hr("div",{className:"ImageExportModal__settings__setting",title:e,children:[hr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Fe(dt,{label:t,long:!0,children:R1})]}),Fe("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),IP=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=ii(()=>({appStateSnapshot:vP(n),elementsSnapshot:vP(e)}));return Fe(gn,{onCloseRequest:i,size:"wide",title:!1,children:Fe(nU,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import VU from"clsx";import{CANVAS_SEARCH_TAB as UP,DEFAULT_SIDEBAR as YU}from"@excalidraw/common";import oU from"clsx";import rU from"lodash.debounce";import{Fragment as iU,memo as aU,useEffect as Vl,useMemo as TP,useRef as _E,useState as SP}from"react";import{CLASSES as sU,EVENT as lU,FONT_FAMILY as RE,FRAME_STYLE as NE,getLineHeight as cU}from"@excalidraw/common";import{getCommonBounds as dU,isElementCompletelyInViewport as mU}from"@excalidraw/element";import{measureText as Yl}from"@excalidraw/element";import{KEYS as Va,randomInteger as CP,addEventListener as pU,getFontString as kp}from"@excalidraw/common";import{newTextElement as uU}from"@excalidraw/element";import{isTextElement as AP,isFrameLikeElement as Mp}from"@excalidraw/element";import{getDefaultFrameName as LP}from"@excalidraw/element/frame";import{Fragment as IU,jsx as ht,jsxs as An}from"react/jsx-runtime";var hU=qe(""),BE=qe(null),gU=350,DP=()=>{let e=It(),n=Be(),t=_E(null),[o,r]=ze(hU),i=o.trim(),[a,s]=SP(!1),[l,c]=SP({nonce:null,items:[]}),d=_E(null),m=_E(void 0),[p,u]=ze(BE),E=e.scene.getNonDeletedElementsMap();Vl(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,MP(i,e,(x,v)=>{c({nonce:CP(),items:x}),d.current=i,m.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[a,i,E,e,n,u,m]);let g=()=>{l.items.length>0&&u(x=>x===null?0:(x+1)%l.items.length)},b=()=>{l.items.length>0&&u(x=>x===null?0:x-1<0?l.items.length-1:x-1)};Vl(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((T,C)=>C===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,n]),Vl(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let v=e.state.zoom.value,T=uU({text:x.searchQuery,x:x.element.x+(x.matchedLines[0]?.offsetX??0),y:x.element.y+(x.matchedLines[0]?.offsetY??0),width:x.matchedLines[0]?.width,height:x.matchedLines[0]?.height,fontSize:Mp(x.element)?NE.nameFontSize:x.element.fontSize,fontFamily:Mp(x.element)?RE.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,A=P*v<C;if(!mU([T],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.viewport.getOffsets())||A){let L=A&&P<C?"contain":"scale-down";e.viewport.setViewport({target:dU([T]),fit:L,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),Vl(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let y=Si({goToNextItem:g,goToPreviousItem:b,searchMatches:l});Vl(()=>{let x=v=>{if(v.key===Va.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),n({openSidebar:null});return}if(v[Va.CTRL_OR_CMD]&&v.key===Va.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&y.searchMatches.items.length&&(v.key===Va.ENTER&&(v.stopPropagation(),y.goToNextItem()),v.key===Va.ARROW_UP?(v.stopPropagation(),y.goToPreviousItem()):v.key===Va.ARROW_DOWN&&(v.stopPropagation(),y.goToNextItem()))};return pU(window,lU.KEYDOWN,x,{capture:!0,passive:!1})},[n,y,e]);let w=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return An("div",{className:"layer-ui__search",children:[An("div",{className:"layer-ui__search-header",children:[ht(Cp,{className:sU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Yn,onChange:x=>{r(x),s(!0);let v=x.trim();MP(v,e,(T,C)=>{c({nonce:CP(),items:T}),u(C),d.current=v,m.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0}),ht(fn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:Qt})]}),An("div",{className:"layer-ui__search-count",children:[l.items.length>0&&An(IU,{children:[p!==null&&p>-1?An("div",{children:[p+1," / ",w]}):ht("div",{children:w}),An("div",{className:"result-nav",children:[ht(fn,{onSelect:()=>{g()},className:"result-nav-btn",children:Nc}),ht(fn,{onSelect:()=>{b()},className:"result-nav-btn",children:j1})]})]}),l.items.length===0&&i&&d.current&&ht("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ht(bU,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},PP=e=>{let n=[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 ht("div",{tabIndex:-1,className:oU("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ht("div",{className:"preview-text",children:n.flatMap((t,o)=>ht(iU,{children:o===2?ht("b",{children:t}):t},o))})})},fU=e=>{let n=TP(()=>e.matches.items.filter(o=>Mp(o.element)),[e.matches]),t=TP(()=>e.matches.items.filter(o=>AP(o.element)),[e.matches]);return An("div",{className:"layer-ui__search-results",children:[n.length>0&&An("div",{className:"layer-ui__search-result-container",children:[An("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:Wn}),ht("div",{children:f("search.frames")})]}),n.map((o,r)=>ht(PP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ht("div",{className:"layer-ui__divider"})]}),t.length>0&&An("div",{className:"layer-ui__search-result-container",children:[An("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:wn}),ht("div",{children:f("search.texts")})]}),t.map((o,r)=>ht(PP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},EU=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,bU=aU(fU,EU),kP=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),s=i.endsWith(" "),l=a.length-2-1-(s?0:1),c=a.slice(l<=0?0:l).join(" ")+(s?" ":""),d=20;c=c.length>d?c.slice(-d):c;let m=e.slice(n+t.length),p=m.split(/\s+/),u=!m.startsWith(" "),E=u?6:5,g=(u?"":" ")+p.slice(0,E).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:l>0,moreAfter:p.length>E}},xU=(e,n)=>{let t=e.split(`
|
|
17
|
+
`).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=n(s),c=l[0]?.length??0,d=l.length>0&&l.every(m=>m.length===c);return{delimiter:s,parsed:l,numCols:c,isConsistent:d}}),r=(t.find(s=>s.isConsistent&&s.numCols>1)??t.find(s=>s.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(s=>s.length===i)?WI(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ba}from"@excalidraw/math";import{FONT_FAMILY as vB,FONT_SIZES as IB,getFontString as TB,getLineHeight as SB,ROUGHNESS as VI}from"@excalidraw/common";import{measureText as CB,newLinearElement as Sf,newTextElement as PB}from"@excalidraw/element";var YI=(e,n,t,o)=>{if(!Aa(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,U)=>`Value ${U+1}`),i=e.series,{normalize:a,renderSteps:s}=FI(i,r.length),l=_a(o),c=Ra(l),d=La(i.length,l),{chartWidth:m,chartHeight:p}=BI(),u=n+m/2,E=t-p/2,g=Ca/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:y,axisLabelTopY:w,axisLabelBottomY:x}=OI(r,b,u,E,g,c),I=vB["Lilita One"],T=IB.xl,C=SB(I),P=TB({fontFamily:I,fontSize:T}),A=e.title?Nm(e.title,P,m+Pa*2):null,D=A?CB(A,P,C):null,_=A?PB({backgroundColor:c,...Ne,text:A,originalText:e.title??A,x:n+m/2,y:w-Pa-D.height/2,fontFamily:I,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:gf},(z,U)=>{let K=(U+1)/gf,G=g*K,te=b.map(F=>Ba(Math.cos(F)*G,Math.sin(F)*G));return te.push(Ba(te[0][0],te[0][1])),Sf({backgroundColor:"transparent",...Ne,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:VI.architect,opacity:ni,polygon:!0,points:te})}):[],L=b.map(z=>{let U=Math.cos(z)*g,K=Math.sin(z)*g;return Sf({backgroundColor:"transparent",...Ne,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(K),strokeStyle:"solid",roughness:VI.architect,opacity:ni,points:[Ba(0,0),Ba(U,K)]})}),B=i.map((z,U)=>{let K=b.map((G,te)=>{let F=z.values[te]??0,W=a(F,te)*g;return Ba(Math.cos(G)*W,Math.sin(G)*W)});return K.push(Ba(K[0][0],K[0][1])),Sf({backgroundColor:"transparent",...Ne,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[U],strokeWidth:2,polygon:!0,points:K})}),V=Na(i,d,u,x,t+oo*5,c);return[..._?[_]:[],...y,...k,...L,...B,...V]};var Cf=(e,n,t,o,r)=>e==="line"?UI(n,t,o,r):e==="radar"?YI(n,t,o,r):GI(n,t,o,r);import{clamp as zm,pointFrom as Fa,pointsEqual as RB,bezierEquation as tT,pointRotateRads as Gm,pointDistance as NB}from"@excalidraw/math";import{arrayToMap as BB,BIND_MODE_TIMEOUT as Al,DEFAULT_TRANSFORM_HANDLE_SPACING as nT,FRAME_STYLE as En,getFeatureFlag as FB,invariant as jI,shouldRotateWithDiscreteAngle as oT,THEME as ko}from"@excalidraw/common";import{deconstructDiamondElement as Df,deconstructRectanguloidElement as rT,elementCenterPoint as Oa,getDiamondBaseCorners as OB,FOCUS_POINT_SIZE as zB,getOmitSidesForEditorInterface as Pf,getTransformHandles as GB,getTransformHandlesFromCoords as HB,hasBoundingBox as UB,hitElementItself as WB,isArrowElement as iT,isBindableElement as aT,isElbowArrow as za,isFrameLikeElement as Ga,isImageElement as Hm,isLinearElement as VB,isLineElement as YB,maxBindingDistance_simple as XB,isTextElement as KB,LinearElementEditor as bn,getActiveTextElement as $B,getElementsInGroup as Lf,getSelectedGroupIds as ZB,isSelectedViaGroup as jB,selectGroupsFromGivenElements as qB}from"@excalidraw/element";import{renderSelectionElement as JB}from"@excalidraw/element";import{getCommonBounds as _f,getElementAbsoluteCoords as Ll}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as qI,isFocusPointVisible as QB}from"@excalidraw/element";import{pointFrom as Pt}from"@excalidraw/math";import{THEME as kB}from"@excalidraw/common";var MB="#ff6b6b",AB="#ff0000",XI=1,KI=2,$I=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===kB.LIGHT||n.zenModeEnabled?MB:AB,o=(n.zenModeEnabled?XI*1.5:XI)/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY);for(let r of n.snapLines)r.type==="pointer"?(e.lineWidth=o,e.strokeStyle=t,LB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,_B(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,DB(r,e,n));e.restore()},DB=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];fn(o,r,n)}for(let o of e.points)ZI(o,t,n)},LB=(e,n,t)=>{ZI(e.points[0],t,n),t.zenModeEnabled||fn(e.points[0],e.points[1],n)},ZI=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?KI*1.5:KI)/t.zoom.value;o.beginPath(),o.moveTo(e-r,n-r),o.lineTo(e+r,n+r),o.moveTo(e+r,n-r),o.lineTo(e-r,n+r),o.stroke(),o.restore()},fn=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},_B=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(t==="horizontal"){let l=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||fn(Pt(e[0],e[1]-i),Pt(e[0],e[1]+i),r),fn(Pt(l[0]-s,l[1]-a),Pt(l[0]-s,l[1]+a),r),fn(Pt(l[0]+s,l[1]-a),Pt(l[0]+s,l[1]+a),r),o.zenModeEnabled||(fn(Pt(n[0],n[1]-i),Pt(n[0],n[1]+i),r),fn(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||fn(Pt(e[0]-i,e[1]),Pt(e[0]+i,e[1]),r),fn(Pt(l[0]-a,l[1]-s),Pt(l[0]+a,l[1]-s),r),fn(Pt(l[0]-a,l[1]+s),Pt(l[0]+a,l[1]+s),r),o.zenModeEnabled||(fn(Pt(n[0]-i,n[1]),Pt(n[0]+i,n[1]),r),fn(e,n,r))}};var eF=(e,n)=>{jI(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;jI(t,"midPointCoords is null"),Um(t,e,n)},tF=(e,n,t)=>{let{elementId:o,hoverPointIndex:r}=n.selectedLinearElement;if(n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(r)||n.selectedLinearElement?.isDragging)return;let i=bn.getElement(o,t);if(!i)return;let a=bn.getPointAtIndexGlobalCoordinates(i,r,t);Um(a,e,n)},Um=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",hs(n,e[0],e[1],bn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},nF=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!iT(i)||i.isDeleted)return;let a=r==="label"?bn.getBoundTextElementCenter(i,t):bn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);Um(a,e,n)},kf=(e,n,t,o,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)"),hs(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},oF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Ga(a)&&(e.translate(a.x,a.y),e.beginPath(),En.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,En.radius/o.zoom.value):e.rect(-1,-1,a.width+1,a.height+1),e.clip(),e.translate(-a.x,-a.y)),n.element.type){case"magicframe":case"frame":e.save(),e.translate(n.element.x,n.element.y),e.lineWidth=En.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===ko.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",En.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,En.radius/o.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,n.element.width,n.element.height),e.restore();break;default:e.save();let s=Oa(n.element,t);switch(e.translate(s[0],s[1]),e.rotate(n.element.angle),e.translate(-s[0],-s[1]),e.translate(n.element.x,n.element.y),e.lineWidth=zm(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===ko.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",n.element.type){case"ellipse":e.beginPath(),e.ellipse(n.element.width/2,n.element.height/2,n.element.width/2,n.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[l,c]=Df(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break;default:{let[l,c]=rT(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break}e.restore();break}if(o.isMidpointSnappingEnabled&&!o.gridModeEnabled&&!i&&(Ga(n.element)||aT(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&bn.getElement(s?.elementId,t),c=r&&WB({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&za(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Oa(n.element,t),p;if(n.element.type==="diamond"){let b=Oa(n.element,t);p=OB(n.element).map(y=>{let w=tT(y,.5),x=Gm(w,b,n.element.angle);return Fa(x[0],x[1])})}else p=[{x:n.element.width,y:n.element.height/2},{x:n.element.width/2,y:n.element.height},{x:0,y:n.element.height/2},{x:n.element.width/2,y:0}].map(y=>{let w=Fa(y.x+n.element.x,y.y+n.element.y),x=Gm(w,m,n.element.angle);return Fa(x[0],x[1])});let u=r&&p.reduce((b,y,w)=>{let x=NB(y,r);return w===-1||x<b.distance?{idx:w,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=XB(o.zoom)+n.element.strokeWidth/2;p.forEach((b,y)=>{let w=(!c||d)&&u?.idx===y&&u.distance<=g,x=!w&&(d||y===u?.idx&&u.distance<=g*2);w?(e.fillStyle=o.theme===ko.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill()):x&&(e.fillStyle=o.theme===ko.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill())}),e.restore()}}},rF=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Al-(a?.runtime??(s?0:Al)),c=zm(1/Al*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&Ga(m)&&(n.translate(m.x,m.y),n.beginPath(),En.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,En.radius/r.zoom.value):n.rect(-1,-1,m.width+1,m.height+1),n.clip(),n.translate(-m.x,-m.y)),t.type){case"magicframe":case"frame":n.save(),n.translate(t.x,t.y),n.lineWidth=En.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===ko.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,En.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,En.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=Oa(t,o),E=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(n.translate(E,g),n.rotate(t.angle),n.translate(-E,-g),n.translate(t.x+r.scrollX-d,t.y+r.scrollY-d),n.lineWidth=zm(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===ko.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+d*2)/2,(t.height+d*2)/2,(t.width+d*2)/2,(t.height+d*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,y]=Df(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,I,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break;default:{let[b,y]=rT(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,I,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break}n.restore();break}if(!s||(a?.runtime??0)>Al)return;let p=.5*(Math.min(t.width,t.height)/2);if(!Ga(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Al*l;if(n.strokeStyle="rgba(0, 0, 0, 0.2)",n.lineWidth=1/r.zoom.value,n.setLineDash([4/r.zoom.value,4/r.zoom.value]),n.lineDashOffset=-u*10/r.zoom.value,n.beginPath(),n.ellipse(t.width/2,t.height/2,p,p,0,0,2*Math.PI),n.stroke(),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.ellipse(t.width/2,t.height/2,p*(1-c),p*(1-c),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!oT(e.lastPointerMoveEvent))){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let E=5/r.zoom.value,g=5/r.zoom.value,b=E+g,y;if(t.type==="diamond"){let[,w]=Df(t),x=Oa(t,o);y=w.map(I=>{let T=tT(I,.5),C=Gm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let w=Oa(t,o);y=[{x:t.width/2,y:0},{x:t.width,y:t.height/2},{x:t.width/2,y:t.height},{x:0,y:t.height/2}].map(I=>{let T=Fa(I.x+t.x,I.y+t.y),C=Gm(T,w,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}y.forEach(w=>{n.clearRect(w.x-b,w.y-b,b*2,b*2)}),n.fillStyle=r.theme===ko.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,y.forEach(w=>{n.beginPath(),n.arc(w.x,w.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},iF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(FB("COMPLEX_BINDINGS"))return rF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Fa(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&oT(e.lastPointerMoveEvent);oF(n,t,o,r,s,l),n.restore()},sT=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=t,u=a-r,E=s-i,b=(t.padding??nT*2)/n.zoom.value,y=8/n.zoom.value,w=4/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=(p?4:1)/n.zoom.value;let x=l.length;for(let I=0;I<x;++I)e.strokeStyle=l[I],m&&e.setLineDash([y,w+(y+w)*(x-1)]),e.lineDashOffset=(y+w)*I,gs(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},aF=(e,n,t,o)=>{let[r,i,a,s]=Ll(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=En.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),gs(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,En.radius/n.zoom.value),e.restore()},JI=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[m,p,u,E]=_f(d);return{angle:0,x1:m,x2:u,y1:p,y2:E,selectionColors:r,dashed:i,cx:m+(u-m)/2,cy:p+(E-p)/2,activeEmbeddable:!1}},c=d=>{let m=Lf(t,d);return l(m)};Object.entries(qB(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>sT(e,n,d))},Mf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=bn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=bn,a=n.selectedLinearElement?.isEditing?i:i/2,s=za(t),l=YB(t);if(r.forEach((c,d)=>{if(s&&d!==0&&d!==r.length-1)return;let m=d>0&&(d!==r.length-1||!l||!t.polygon)&&RB(c,d===r.length-1?r[0]:r[d-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!p&&d===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),kf(e,n,c,a,p,!1,m)}),za(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{bn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||kf(e,n,Fa((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else bn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(za(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&kf(e,n,d,i/2,!1,!0,!1)});e.restore()},sF=(e,n,t,o)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([4/n.zoom.value,4/n.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(o[0],o[1]),e.stroke(),e.restore()},lF=(e,n,t,o,r)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",hs(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},QI=({arrow:e,appState:n,type:t,context:o,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!aT(a)||a.isDeleted)return;let s=qI(i.fixedPoint,a,r);if(!QB(s,e,a,r,n,t))return;let l=n.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,m=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&Um(s,o,n),!(m&&c)){let p=qI(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=bn.getPointAtIndexGlobalCoordinates(e,d,r);sF(o,n,E,p),lF(o,n,p,zB/1.5,u)}},eT=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?hs(e,s+c/2,l+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):gs(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},cF=(e,n,t,o,r)=>{let[i,a,,,s,l]=Ll(o,r),c=3,d=20,m=c/t.zoom.value,p=m/2,u=s-i+m,E=l-a+m,g=Math.min(d/t.zoom.value,u),b=Math.min(d/t.zoom.value,E);e.save(),e.fillStyle=n.selectionColor,e.strokeStyle=n.selectionColor,e.lineWidth=m,[[[-u,-E],[0,p],[g,p],[p,0],[p,b]],[[u-p,-E],[p,p],[-g+p,p],[0,0],[0,b]],[[-u,E],[0,-p],[g,-p],[p,0],[p,-b]],[[u-p,E],[p,-p],[-g+p,-p],[0,0],[0,-b]]].forEach(w=>{let[[x,I],[T,C],[P,A],[D,_],[k,L]]=w;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,I+C),e.lineTo(x+P,I+A),e.stroke(),e.beginPath(),e.moveTo(x+D,I+_),e.lineTo(x+k,I+L),e.stroke(),e.restore()}),e.restore()},dF=(e,n,t,o)=>{n.save();let r=af(t.zoom.value),i=e.width+r*2,a=e.height+r*2,s=e.x+e.width/2,l=e.y+e.height/2,c=-(e.width/2+r),d=-(e.height/2+r);n.translate(s+t.scrollX,l+t.scrollY),n.rotate(e.angle),n.lineWidth=1/t.zoom.value,n.strokeStyle=o,n.globalAlpha=.5,n.setLineDash([6/t.zoom.value,4/t.zoom.value]),n.strokeRect(c,d,i,a),n.restore()},mF=(e,n,t,o,r)=>{let i=sf(e,t.zoom.value,r);i&&(n.save(),n.globalAlpha=.5,n.lineWidth=1.5/t.zoom.value,n.lineCap="round",n.strokeStyle=o,n.beginPath(),n.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),n.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),n.stroke(),n.restore())},pF=(e,n,t,o,r,i)=>{for(let a of n){if(!Hm(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Dl(a,t,r,"center");d&&cT(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,r,s?.downloadError??void 0)}else{let d=o.imageLoadingProgress.get(a.fileId);if(d!==void 0){let m=Dl(a,t,r,"center");m&&lT(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Dl(a,t,r,"top-right");d&&hF(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Dl=(e,n,t,o)=>{if(!Hm(e))return null;let[r,i,a,s]=Ll(e,n),l=t.zoom.value,c=Math.min(a-r,s-i)*l,d=Math.min(o==="center"?14:11.7,c/(o==="center"?4:4.62))/l,m=Math.min((o==="center"?3:2.6)/l,d/2);if(d<=0||m<=0)return null;if(o==="top-right"){let p=6/l;return{centerX:a-p-d,centerY:i+p+d,radius:d,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:d,lineWidth:m}},lT=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===ko.DARK?"rgba(255, 255, 255, 0.35)":"rgba(0, 0, 0, 0.25)"),e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),i>0&&(e.strokeStyle=l?.color??s,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*zm(i,0,1)),e.stroke()),e.restore()},Af=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,uF=(e,n,t,o,r)=>{e.save(),e.strokeStyle=r.color,e.lineWidth=r.lineWidth,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(n-o*.48,t+o*.26),e.bezierCurveTo(n-o*.68,t+o*.14,n-o*.58,t-o*.22,n-o*.34,t-o*.22),e.bezierCurveTo(n-o*.14,t-o*.48,n+o*.26,t-o*.48,n+o*.34,t-o*.18),e.bezierCurveTo(n+o*.58,t-o*.2,n+o*.7,t+o*.26,n+o*.42,t+o*.26),e.lineTo(n-o*.48,t+o*.26),e.stroke(),e.restore()},hF=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??Af("--color-primary",s),d=i.color??Af("--color-warning-darkest","#ec8b14");if(l==="failed"){cT(e,n,t,o,a,{color:i.color??Af("--color-danger","#e03131")});return}if(l==="uploading"&&lT(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),uF(e,n,t-o*.02,o*1.125,{color:l==="error"?d:c,lineWidth:Math.max(r*.75,1/a.zoom.value)}),l==="error"){e.save(),e.strokeStyle=d,e.fillStyle=d,e.lineWidth=Math.max(r*.75,1/a.zoom.value),e.lineCap="round",e.beginPath();let m=o*.18,p=t-o*.09;e.moveTo(n-m,p-m),e.lineTo(n+m,p+m),e.moveTo(n+m,p-m),e.lineTo(n-m,p+m),e.stroke(),e.restore()}else l==="pending"&&(e.save(),e.strokeStyle=c,e.lineWidth=Math.max(r*.65,1/a.zoom.value),e.lineCap="round",e.beginPath(),e.moveTo(n,t+o*.072),e.lineTo(n,t-o*.18),e.moveTo(n-o*.144,t-o*.036),e.lineTo(n,t-o*.18),e.lineTo(n+o*.144,t-o*.036),e.stroke(),e.restore())},cT=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",s=Math.max(o*.16,1.5/r.zoom.value);i?.backgroundColor&&(e.fillStyle=i.backgroundColor,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.fill()),e.strokeStyle=a,e.lineWidth=s,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),e.strokeStyle=a,e.fillStyle=a,e.lineCap="round",e.beginPath(),e.moveTo(n,t-o*.45),e.lineTo(n,t+o*.12),e.stroke(),e.beginPath(),e.arc(n,t+o*.48,o*.11,0,Math.PI*2),e.fill(),i?.text&&(e.font=`600 ${Math.max(11/r.zoom.value,o*.65)}px Assistant, system-ui, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif`,e.textAlign="center",e.textBaseline="top",e.fillText(i.text,n,t+o+6/r.zoom.value)),e.restore()},gF=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:c,animationState:d,deltaTime:m})=>{if(n===null)return{};let[p,u]=Tc(n,a),E=d,g=Sc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),g.scale(s.zoom.value,s.zoom.value);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&Mf(g,s,b,t),s.selectionElement&&!s.isCropping)try{JB(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let y=$B(r,s);if(y&&!y.autoResize&&mF(y,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&dF(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:iF(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&nF(g,s,i),s.frameToHighlight&&aF(g,s,s.frameToHighlight,t),s.elementsToHighlight&&JI(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:Lf(i,s.activeLockedId);JI(g,s,P,{colors:["#ced4da"],dashed:!0})}let w=r.some(C=>Ga(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&Mf(g,s,r[0],t);let x=s.selectedLinearElement,I=x&&bn.getElement(x.elementId,i);if(I&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?eF(g,s):(za(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&tF(g,s,t)),iT(I)&&(QI({arrow:I,elementsMap:i,appState:s,context:g,type:"start"}),QI({arrow:I,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=UB(r,s,c),P=r.length===1&&VB(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Mf(g,s,r[0],t);let A=l.selectionColor||"#000";if(C){let D=BB(r),_=[];for(let L of t.values()){let B=[],V=l.remoteSelectedElementIds.get(L.id);if(P&&za(L)&&(L.startBinding||L.endBinding)||(D.has(L.id)&&!jB(s,L)&&B.push(A),V&&B.push(...V.map(z=>$r(z,s.collaborators.get(z))))),B.length){let[z,U,K,G,te,F]=Ll(L,t,!0);_.push({angle:L.angle,x1:z,y1:U,x2:K,y2:G,selectionColors:L.locked?["#ced4da"]:B,dashed:!!V||L.locked,cx:te,cy:F,activeEmbeddable:s.activeEmbeddable?.element===L&&s.activeEmbeddable.state==="active",padding:L.id===s.croppingElementId||Hm(L)?0:void 0})}}let k=L=>{let B=Lf(t,L),[V,z,U,K]=_f(B);_.push({angle:0,x1:V,x2:U,y1:z,y2:K,selectionColors:B.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:V+(U-V)/2,cy:z+(K-z)/2,activeEmbeddable:!1})};for(let L of ZB(s))k(L);s.editingGroupId&&k(s.editingGroupId),_.forEach(L=>sT(g,s,L))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let D=GB(r[0],s.zoom,t,"mouse",Pf(c));if(!s.viewModeEnabled&&C&&!KB(s.editingTextElement)&&!s.croppingElementId&&eT(g,l,s,D,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Hm(_)&&cF(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(D=>D.locked)){let D=nT*2/s.zoom.value;g.fillStyle="#fff";let[_,k,L,B]=_f(r,t),V=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=A,gs(g,_-D,k-D,L-_+D*2,B-k+D*2,(_+L)/2,(k+B)/2,0),g.lineWidth=z,g.setLineDash(V);let U=HB([_,k,L,B,(_+L)/2,(k+B)/2],0,s.zoom,"mouse",w?{...Pf(c),rotation:!0}:Pf(c));r.some(K=>!K.locked)&&eT(g,l,s,U,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:A})=>{let D=t.get(C);if(D){let[_,k,,,L,B]=Ll(D,t,!0);g.save(),s.theme===ko.LIGHT?P?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":P?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let V=Ga(D)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(L,B),g.rotate(D.angle),A.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/V-L,k+z.offsetY/V-B,z.width/V,z.height/V)}),g.restore()}}),$I(g,s),pF(g,o,t,e,s,l.selectionColor),g.restore(),Aw({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=J2(t,p,u,s),g.save(),g.fillStyle=q2,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&Jd(g,C.x,C.y,C.width,C.height,gn/2)}),g.restore()),{scrollBars:T,animationState:E}},Rf=e=>{let n=gF(e);return e.callback(n),n};import{useEffect as Bl,useMemo as dT,useRef as zf,useState as fF}from"react";import{bumpVersion as _l,getLinearElementSubType as Ua,mutateElement as Gf,updateElbowArrowPoints as EF}from"@excalidraw/element";import{pointFrom as Vm,pointRotateRads as bF}from"@excalidraw/math";import{hasBoundTextElement as xF,isArrowBoundToElement as yF,isArrowElement as wF,isElbowArrow as vF,isLinearElement as Vf,isUsingAdaptiveRadius as IF}from"@excalidraw/element";import{getCommonBoundingBox as TF,getElementAbsoluteCoords as SF}from"@excalidraw/element";import{getBoundTextElement as gT,getBoundTextMaxHeight as CF,getBoundTextMaxWidth as PF,redrawTextBoundingBox as kF}from"@excalidraw/element";import{wrapText as MF}from"@excalidraw/element";import{assertNever as AF,CLASSES as DF,getFontString as Nf,isProdEnv as LF,mapFind as _F,reduceToCommonValue as RF,ROUNDNESS as Bf,sceneCoordsToViewportCoords as NF,updateActiveTool as mT}from"@excalidraw/common";import{measureText as pT}from"@excalidraw/element";import{LinearElementEditor as BF}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Ff,newElement as FF,newLinearElement as OF}from"@excalidraw/element";import{ShapeCache as zF}from"@excalidraw/element";import{updateBindings as GF}from"@excalidraw/element";import{jsx as Wf}from"react/jsx-runtime";var HF=8,UF=10,Rl=["rectangle","diamond","ellipse"],Nl=["line","sharpArrow","curvedArrow","elbowArrow"],WF=new Set(Rl),VF=new Set(Nl),Wa=e=>WF.has(e),Ym=e=>e==="arrow"||VF.has(e),ro=Je(null),Fl=new Map,Ol=new Map,YF=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=zf(null);return Bl(()=>{if(n.length===0){e.updateEditorAtom(ro,null);return}let o=Xm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(ro,null),t.current=null)},[n,e]),Bl(()=>()=>{Fl.clear(),Ol.clear()},[]),Wf(XF,{app:e,elements:n})},XF=({app:e,elements:n})=>{let t=Xm(n),o=dT(()=>t==="generic"?ET(n):[],[t,n]),r=dT(()=>t==="linear"?Uf(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Ua(m)===Ua(r[0])):!1,[a,s]=fF({x:0,y:0}),l=zf(""),c=zf(null);Bl(()=>{let m=[...o,...r].sort((b,y)=>b.id.localeCompare(y.id)),p=`
|
|
18
|
+
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(b=>b.id).join(",")}`;if(p===l.current)return;l.current=p;let u;if(m.length===1){let[b,,,y,w,x]=SF(m[0],e.scene.getNonDeletedElementsMap());u=bF(Vm(b,y),Vm(w,x),m[0].angle)}else{let{minX:b,maxY:y}=TF(m);u=Vm(b,y)}let{x:E,y:g}=NF({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),Bl(()=>{for(let m of r){let p=Hf(m.id,qF(m));Ol.has(p)||Ol.set(p,m)}},[r]),Bl(()=>{for(let m of o)if(!Fl.has(m.id)){let p=gT(m,e.scene.getNonDeletedElementsMap());p&&Fl.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",Wo],["sharpArrow",Xo],["curvedArrow",$o],["elbowArrow",Ko]]:t==="generic"?[["rectangle",Mi],["diamond",Ai],["ellipse",Di]]:[];return Wf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(UF+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-HF}px`,zIndex:2},className:DF.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Ua(r[0])===m);return Wf($,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Be("convertElementType",m,"ui"),Yf(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},KF=(e,n,t)=>{let o=PF(e,n),r=CF(e,n),i=MF(n.text,Nf(n),o),a=pT(i,Nf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=pT(n.text,Nf(l),n.lineHeight)}Gf(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),kF(n,e,t)},Yf=(e,{conversionType:n,nextType:t,direction:o="right"})=>{if(!n)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((s,l)=>({...s,[l.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let s=ET(r),c=s.every(d=>d.type===s[0].type)?Rl.indexOf(s[0].type):-1;if(t=t??Rl[(c+Rl.length+a)%Rl.length],t&&Wa(t)){let d={};for(let p of s){let u=hT(p,t,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=gT(p,e.scene.getNonDeletedElementsMap());u&&(Fl.get(p.id)&&Gf(u,e.scene.getNonDeletedElementsMap(),{fontSize:Fl.get(p.id)?.fontSize??u.fontSize}),KF(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:mT(p,{type:"selection"})}))}}if(n==="linear"){let s=Uf(r);if(!t){let c=RF(s,Ua),d=c?Nl.indexOf(c):-1;t=Nl[(d+Nl.length+a)%Nl.length]}if(Ym(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Ol.get(Hf(m.id,t));if(p&&Ua(p)===t)d.set(p.id,p),c.push(p);else{let u=hT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(Vf(m))if(vF(m)){let p=$F(m);if(p.length<2)continue;let u=[];for(let g=1;g<p.length-2;g++)u.push({start:p[g],end:p[g+1],index:g+1});let E=EF(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Gf(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=_F(["line","sharpArrow","curvedArrow"],u=>Ol.get(Hf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=Uf(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new BF(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:mT(c,{type:"selection"})}))}return!0},Xm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(Wa(t.type))return"generic";fT(t)&&(n=!0)}return n?"linear":null},fT=e=>Vf(e)&&(!wF(e)||!yF(e)&&!xF(e)),Hf=(e,n)=>`${e}:${n}`,ET=e=>e.filter(n=>Wa(n.type)),Uf=e=>e.filter(n=>fT(n)),Wm=20,Ha=(e,n)=>e[0]===n[0],Of=(e,n)=>e[1]===n[1],uT=(e,n)=>Ha(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),$F=e=>{let n=[e.points[0]],t=ZF(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<Wm?s[0]=a[0]:Math.abs(s[1]-a[1])<Wm&&(s[1]=a[1]),Ha(a,s)||Of(a,s)||n.push(Vm(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)Ha(n[i-1],n[i])&&Ha(n[i],n[i+1])||Of(n[i-1],n[i])&&Of(n[i],n[i+1])||o.push(n[i]);o.push(n[n.length-1]);let r=[o[0]];for(let i=1;i<o.length-1;++i){let a=r[r.length-1],s=o[i],l=o[i+1],c=Ha(a,s),d=Ha(s,l);if(c!==d){let m=uT(a,s),p=uT(s,l);if(m<Wm||p<Wm){if(p<m)c?l[0]=a[0]:l[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=s[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=s[1];continue}}r.push(s)}return r.push(o[o.length-1]),r},ZF=e=>{if(e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++){let[o,r]=n[n.length-1],[i,a]=e[t];(o!==i||r!==a)&&n.push(e[t])}return n},hT=(e,n,t)=>{if(!jF(e.type,n)){if(!LF())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(zF.delete(e),Wa(n)){let o=_l(FF({...e,type:n,roundness:e.roundness?{type:IF(n)?Bf.ADAPTIVE_RADIUS:Bf.PROPORTIONAL_RADIUS}:e.roundness}));return GF(o,t.scene,t.state),o}if(Ym(n))switch(n){case"line":return _l(OF({...e,type:"line"}));case"sharpArrow":return _l(Ff({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return _l(Ff({...e,type:"arrow",elbowed:!1,roundness:{type:Bf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return _l(Ff({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return AF(n,`unhandled conversion type: ${n}`),e},jF=(e,n)=>!!(Wa(e)&&Wa(n)||Ym(e)&&Ym(n)),qF=e=>Vf(e)?Ua(e):e.type,bT=YF;import{bindBindingElementToFixedPoint as JF,dragNewTextElement as QF,getBoundTextElement as eO,getEndpointBoundTextDragAnchor as tO,getTextBindingForArrowEndpoint as nO,getUnboundArrowEndpointAtPoint as oO,isArrowElement as rO,isBindingEnabled as iO,isEndpointBoundText as aO,isTextElement as sO}from"@excalidraw/element";import{pointFrom as lO}from"@excalidraw/math";var Km=class{constructor(n){this.app=n;v(this,"updateHoveredAnchor",n=>{let t=this.app.state.activeTool.type==="text"&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(n.x,n.y):null,o=this.app.state.hoveredArrowTextAnchor;return(o?.elementId!==t?.elementId||o?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t});v(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!iO(this.app.state))return null;let o=oO(lO(n,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!o||this.app.getTextElementAtPosition(n,t))return null;let r=this.app.getElementAtPosition(n,t,{includeLockedElements:!0});return r&&r.id!==o.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(o.arrow.id)?null:o}getAnchorAtPosition(n,t){let o=this.getBindableEndpointAtPosition(n,t);if(o)return{elementId:o.arrow.id,anchor:o.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(n,t);return!rO(r)||eO(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(n,t,this.app.state,r)?{elementId:r.id,anchor:"label"}:null}getTextBinding({arrow:n,startOrEnd:t},o){return nO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){JF(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!sO(n)||!aO(n,this.app.scene.getNonDeletedElementsMap())?!1:(QF({newElement:n,...tO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as cO,BUCKET_FILL_BACKGROUND_PICKS as dO,COLOR_PALETTE as yT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as mO,getSizeFromPoints as pO,isTransparent as uO,THEME as hO}from"@excalidraw/common";import{pointFrom as xT}from"@excalidraw/math";import{computeBucketFillPolygon as gO,isBucketFillCompatible as fO,isFrameLikeElement as EO,isRestylableFill as bO,newLinearElement as xO,ShapeCache as yO}from"@excalidraw/element";var Xf=dO.filter(e=>e!==yT.white),$m=class{constructor(n){this.app=n;v(this,"temporaryEyeDropper",null);v(this,"pending",null);v(this,"handlePointerDown",n=>{this.pending=n});v(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});v(this,"cancel",()=>{this.pending=null});v(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=Xf.indexOf(n),o=Xf[(t+1)%Xf.length];this.app.actionManager.executeAction(wd,"keyboard",{currentItemBackgroundColor:o})});v(this,"openTemporaryEyeDropper",()=>{if(Et.get(zt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(wd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(zt,n)});v(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&Et.get(zt)===n&&this.app.updateEditorAtom(zt,null)});v(this,"restyle",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);n.backgroundColor===t&&n.fillStyle===this.app.state.currentItemFillStyle&&n.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(n,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),yO.delete(n),this.app.scheduleCapture())});v(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=xT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=gO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&fO(a)){this.restyle(a);return}s.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(s.reason==="open_region"||s.reason==="too_small"||s.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&bO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=pO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(w=>xT(w[0]-d,w[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?EO(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(w=>r.get(w)?.groupIds).filter(w=>!!w).reduce((w,x)=>w===null?x:w.filter(I=>x.includes(I)),null)??[],b=xO({type:"line",x:d,y:m,width:l,height:c,points:p,polygon:!0,strokeColor:"transparent",backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:E,groupIds:g}),y=this.app.scene.getElementsIncludingDeleted().findIndex(w=>w.id===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],y<0?null:s.insertion.placement==="above"?y+1:y),this.app.scheduleCapture()});v(this,"getBucketFillBackgroundColor",(n,t)=>uO(n)?yT.green[mO]:cO(n,t===hO.DARK))}};import{CURSOR_TYPE as zl,MIME_TYPES as jm,THEME as wT}from"@excalidraw/common";var vT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',wO='<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"/>',IT='<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"/>',vO=`data:${jm.svg},${encodeURIComponent(`${vT}${IT}</svg>`)}`,IO=`data:${jm.svg},${encodeURIComponent(`${vT}${wO}${IT}</svg>`)}`,TO=e=>{let n=Su.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${jm.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${n}</g><g stroke="#1b1b1f" stroke-width="1.25">${n}</g></svg>`)}`},Zm=class{constructor(n){this.app=n;v(this,"toolCursorMemo",null);v(this,"eraserCanvasCache",null);v(this,"eraserPreviewDataURL",null);v(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});v(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(zl.GRAB):this.clear():this.applyForTool()});v(this,"applyForTool",(n=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let o=n.type==="eraser"||n.type==="laser"||n.type==="bucketfill"?this.app.state.theme:void 0,r=n.type==="bucketfill"?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,o):void 0,i=this.toolCursorMemo;if(!(i?.canvas===t&&i.type===n.type&&i.bucketFillColor===r&&i.theme===o)){if(n.type==="selection")this.clear();else if(ps({activeTool:n}))this.set(zl.GRAB);else if(on({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(zl.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${TO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===wT.LIGHT?vO:IO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(zl.AUTO):this.set(zl.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});v(this,"clear",()=>{this.set("")});v(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===wT.DARK;this.eraserCanvasCache=document.createElement("canvas"),this.eraserCanvasCache.theme=t,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let r=this.eraserCanvasCache.getContext("2d");r.lineWidth=1,r.beginPath(),r.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),r.fillStyle=o?"#000":"#fff",r.fill(),r.strokeStyle=o?"#fff":"#000",r.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(jm.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as MO}from"@excalidraw/common";import{bindBindingElement as AO,convertToShape as DO,convertToShapeHandlePointerMoveFromPointerDown as LO,getHoveredElementForBinding as TT,isBindingElement as _O,isLineElement as RO,LinearElementEditor as Kf,maxBindingDistance_simple as ST,newArrowElement as NO,updateBoundPoint as BO}from"@excalidraw/element";import{getStrokeWidthByKey as SO,THEME as CO}from"@excalidraw/common";import{clamp as PO,pointFrom as kO}from"@excalidraw/math";var qm=class{constructor(n){this.app=n;v(this,"trail");this.trail=new Rn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===CO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>PO(SO("line",this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(n,t){this.trail.startPath(n,t)}addPointToPath(n,t){this.trail.addPointToPath(n,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let n=this.trail.getCurrentTrail();return n?n.originalPoints.map(([t,o])=>kO(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var Jm=class{constructor(n){this.app=n;v(this,"trail");v(this,"gestureInProgress",!1);v(this,"stop",()=>{this.trail.stop()});v(this,"hasPendingGesture",()=>this.gestureInProgress);v(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(ut),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});v(this,"handlePointerMove",n=>LO(this.app,n));v(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=ST(t.state.zoom),a=["start","end"].map(d=>{let m=Kf.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:TT(m,r,o,i)}}),s=!!a[0].target&&a[0].target===a[1].target,l=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:d,globalPoint:m,target:p}of a)p&&AO(n,p,s?"inside":"orbit",d,t.scene,m,t.state.isBindingEnabled,l);if(s)return;let c=new Map;for(let{startOrEnd:d,target:m}of a){if(!m)continue;let p=BO(n,d==="start"?"startBinding":"endBinding",d==="start"?n.startBinding:n.endBinding,m,o);p&&c.set(d==="start"?0:n.points.length-1,{point:p})}c.size&&Kf.movePoints(n,t.scene,c)});v(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=ST(t.state.zoom),[a,s]=[0,-1].map(l=>TT(Kf.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:NO({type:"arrow",x:n.x,y:n.y,width:n.width,height:n.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:n.points,groupIds:n.groupIds,frameId:n.frameId,locked:!1,angle:n.angle,strokeColor:n.strokeColor,backgroundColor:n.backgroundColor,fillStyle:n.fillStyle,roughness:n.roughness,opacity:n.opacity,strokeStyle:n.strokeStyle,strokeWidth:n.strokeWidth})});v(this,"finalize",()=>{let{app:n}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let o=n.state.newElement||DO(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:MO(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&RO(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&_O(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new qm(n)}};import{isArrowKey as FO,KEYS as ri}from"@excalidraw/common";import{makeNextSelectedElementIds as OO,CaptureUpdateAction as zO,FlowChartCreator as GO,FlowChartNavigator as HO,getSelectedElements as CT,isFlowchartNodeElement as UO}from"@excalidraw/element";var Qm=class e{constructor(n){this.app=n;v(this,"creator",new GO);v(this,"navigator",new HO);v(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});v(this,"handleKeyEvent",n=>{let t=this.resolveKeyboardEventToOperation(n);switch(t.type){case"none":return!1;case"canceled":return this.app.triggerRender(!0),!0;case"creating":return n.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case"navigating":{n.preventDefault();let o=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return o&&this.selectAndReveal(o),!0}case"committed":{t.nodes.length&&this.app.insertNewElements(t.nodes);let o=t.nodes[0];return o&&this.selectAndReveal(o),this.captureUpdate(),!0}case"navigationEnded":return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(n){let{creator:t,navigator:o,app:r}=this;if(n.type==="keydown"){if(n.key===ri.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!FO(n.key))return{type:"none"};if(n[ri.CTRL_OR_CMD]&&!n.shiftKey){let a=CT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&UO(a[0])&&t.createNodes(a[0],r.state,e.getLinkDirectionFromKey(n.key),r.scene),{type:"creating",pending:t.pendingNodes??[]}}if(n.altKey){let a=r.scene.getNonDeletedElementsMap(),s=CT(a,r.state);if(s.length===1)return{type:"navigating",nodeId:o.exploreByDirection(s[0],a,e.getLinkDirectionFromKey(n.key))}}return{type:"none"}}let i=!n.altKey&&o.isExploring;if(i&&o.clear(),!n[ri.CTRL_OR_CMD]&&t.isCreatingChart){let a=t.pendingNodes??[];return t.clear(),{type:"committed",nodes:a}}return i?{type:"navigationEnded"}:{type:"none"}}selectAndReveal(n){this.app.setState(t=>({selectedElementIds:OO({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:zO.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case ri.ARROW_UP:return"up";case ri.ARROW_DOWN:return"down";case ri.ARROW_RIGHT:return"right";case ri.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as PT,hasPlayableGif as WO,isInitializedImageElement as VO,newElementWith as kT,ShapeCache as YO}from"@excalidraw/element";import{MIME_TYPES as MT}from"@excalidraw/common";var ep=class{constructor(n){this.app=n;v(this,"playbackRaf",null);v(this,"runtimeState",new Map);v(this,"stop",()=>{this.playbackRaf!==null&&(cancelAnimationFrame(this.playbackRaf),this.playbackRaf=null),this.runtimeState.clear()});v(this,"getFrameIndex",n=>n.gifPlayback?.playing?this.runtimeState.get(n.id)?.frameIndex??n.gifPlayback.frameIndex:n.gifPlayback?.frameIndex);v(this,"setFrameIndex",(n,t)=>{this.runtimeState.set(n.id,{frameIndex:t,lastFrameTime:performance.now()})});v(this,"ensureLoop",()=>{this.playbackRaf!==null||this.app.unmounted||WO(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});v(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==MT.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:MT.gif,gifDecodeStatus:"pending"});let r=kT(n,{fileId:o,gifPlayback:PT({playing:!0})});return this.app.scene.replaceAllElements(this.app.scene.getElementsIncludingDeleted().map(i=>i.id===r.id?r:i)),this.app.imagePlaceholderUpdateEmitter.trigger(),o});v(this,"ensureElementPlaybackMetadata",(n,t={})=>n.gifPlayback&&(t.playing===void 0||n.gifPlayback.playing===t.playing)?n:kT(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:PT(t)}));v(this,"removePlaceholderDecodeState",n=>{n&&this.app.imageCache.delete(n)});v(this,"tick",()=>{if(this.playbackRaf=null,this.app.unmounted)return;let n=performance.now(),t=!1,o=!1;for(let r of this.app.scene.getNonDeletedElements()){if(!VO(r)||!r.gifPlayback?.playing)continue;let i=this.app.imageCache.get(r.fileId)?.gif;if(!i||i.frames.length<2)continue;o=!0;let a=Math.max(r.gifPlayback.speed||1,.1),s=this.runtimeState.get(r.id)??{frameIndex:r.gifPlayback.frameIndex,lastFrameTime:n};this.runtimeState.set(r.id,s);let l=s.frameIndex,c=i.delays[l]??100;n-s.lastFrameTime>=c/a&&(s.frameIndex=(l+1)%i.frames.length,s.lastFrameTime=n,YO.delete(r),t=!0)}t&&this.app.scene.triggerUpdate(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as XO,easeOut as NT,isBounds as KO}from"@excalidraw/common";import{clamp as BT}from"@excalidraw/math";import{getCommonBounds as AT,getElementsInGroup as $O,isElementLink as ZO,isExcalidrawElement as jO,parseElementLinkFromURL as qO}from"@excalidraw/element";var tp="animateScrollToContent",Va="animateScrollConstraintsSnapBack",DT=500,JO=250,QO=200,$f=302,LT={full:216,compact:64},e9=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.x=="number"&&typeof n.y=="number"&&(n.width==null||typeof n.width=="number")&&(n.height==null||typeof n.height=="number")},t9=(e,n)=>{let t=n.get(e);return t?[t]:$O(n,e)},_T=(e,n,t)=>{if(typeof e=="string"){let a=ZO(e),s=a?"link":"element",l=a?qO(e):e,c=l?t9(l,n):[];return c.length?{bounds:AT(c,n),type:s}:{bounds:null,type:s}}if(KO(e))return{bounds:e,type:"area"};if(e9(e)&&!jO(e)){let a=e.width??t.width,s=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+s],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,s)=>{if(s&&!s.isDeleted){let l=n.get(s.id);l&&a.push(l)}return a},[]),i=!r.length;return(r.length!==o.length||i)&&console.warn("supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out"),i?{bounds:null,type:"element"}:{bounds:AT(r,n),type:"element"}},n9=e=>e===!1?0:e===!0||e==null?gu:Math.max(e,0),o9=(e,n,t="scale-down",o,r)=>{let{appState:i}=Mr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},RT=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=o9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[s,l,c,d]=n,m={x:s,y:l,width:c-s,height:d-l,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:n9(r.overscroll),offsets:o};return{...Vn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},r9=({from:e,target:n,factor:t})=>{if(t>=1)return{...n};let o=e.zoom.value*Math.pow(n.zoom.value/e.zoom.value,t),r=n.zoom.value===e.zoom.value?t:(o-e.zoom.value)/(n.zoom.value-e.zoom.value);return{scrollX:((1-r)*e.scrollX*e.zoom.value+r*n.scrollX*n.zoom.value)/o,scrollY:((1-r)*e.scrollY*e.zoom.value+r*n.scrollY*n.zoom.value)/o,zoom:{value:o}}},i9=e=>e===!1?null:e===!0||e==null?DT:e.duration??DT,a9=(e,n,t,o,r)=>{at.start(tp,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=NT(BT(l,0,1));return l<1?(o({...r9({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},s9=(e,n,t=JO)=>{let o=Vn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||at.running(tp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;at.start(Va,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-NT(BT(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Vn(m),u=p.zoom.value;return{scrollX:p.scrollX+r*d/u,scrollY:p.scrollY+i*d/u,zoom:p.zoom}}),c<1?{elapsed:l}:null})},np=class{constructor(n,t){this.app=n;this.dependencies=t;v(this,"lastPosition",{x:0,y:0});v(this,"activeTransition",null);v(this,"uiLastMeasured",new Map);v(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});v(this,"resolveOffsets",n=>{if(!n)return n;let{ui:t,...o}=n;if(!t)return o;let r=this.getOffsets(t===!0?void 0:t);return{top:o.top??r.top,right:o.right??r.right,bottom:o.bottom??r.bottom,left:o.left??r.left}});v(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=Kn().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&o)for(let u of t.querySelectorAll("[data-viewport-ui]")){let E=u.getBoundingClientRect(),g={top:E.top-o.top,right:E.right-o.left,bottom:E.bottom-o.top,left:E.left-o.left,width:E.width};switch(u.dataset.viewportUi){case"top":i.top=Math.max(i.top,g.bottom);break;case"bottom":i.bottom=Math.max(i.bottom,this.app.state.height-g.top);break;case"side":{let[b,y]=g.left+g.width/2<this.app.state.width/2?["left",g.right]:["right",this.app.state.width-g.left];i[b]=Math.max(i[b],y);let w=u.dataset.viewportUiName;w&&(a.add(w),y>0&&this.uiLastMeasured.set(w,{side:b,offset:y}));break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:y}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],y)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?LT.compact:LT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:$f})}let s=n?.padding??24,l=n?.paddingTop??s,c=(r?n?.paddingLeft:n?.paddingRight)??s,d=n?.paddingBottom??s,m=(r?n?.paddingRight:n?.paddingLeft)??s,p={top:i.top+l,right:i.right+c,bottom:i.bottom+d,left:i.left+m};return{top:n?.top??p.top,right:(r?n?.left:n?.right)??p.right,bottom:n?.bottom??p.bottom,left:(r?n?.right:n?.left)??p.left}});v(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=_T(n.target,t,o);return r?RT(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});v(this,"setViewport",n=>{if(n===null){this.cancelTransition(),at.cancel(Va),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,s=this.resolveOffsets(n.offsets),{bounds:l,type:c}=_T(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!l){c==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let d=RT(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=i9(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),at.cancel(Va),this.snapBackDebounced.cancel(),m===null){this.app.setState({...d,shouldCacheIgnoreZoom:!1});return}let u={target:d};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),a9(p,d,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});v(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||at.cancel(Va),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let o=this.app.state.zoom.value;return this.app.setState(n),this.app.setState(r=>{if(!r.scrollConstraints)return null;let a=!t?.zoomPreConstrained&&r.zoom.value!==o?0:r.scrollConstraints.overscroll;return a>0&&this.snapBackDebounced(),Vn(r,a)}),!0});v(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Vn(t,n):null)});v(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});v(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||s9(this.app.state,n=>this.app.setState(t=>n(t)))});v(this,"snapBackDebounced",XO(this.snapBack,QO));v(this,"cancelTransition",()=>{this.activeTransition=null,at.cancel(tp)});v(this,"destroy",()=>{this.cancelTransition(),at.cancel(Va),this.snapBackDebounced.cancel()})}get isAnimating(){return at.running(tp)||at.running(Va)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import op from"react";var l9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,c9=/{{([\w-]+)}}/,d9=/<([\w-]+)>/,m9=/<\/([\w-]+)>/,p9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(l9).filter(Boolean).forEach(o=>{let r=o.match(d9),i=o.match(m9),a=o.match(c9);if(r!==null){let s=r[1];n.hasOwnProperty(s)?t.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let l=t.pop(),c=op.createElement(op.Fragment,{},...l.children),d=n[l.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];n.hasOwnProperty(s)?t[t.length-1].children.push(n[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else t[t.length-1].children.push(o)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},u9=({i18nKey:e,children:n,...t})=>{let{t:o}=Le();return op.createElement(op.Fragment,{},...p9(o(e),t))},ii=u9;import{jsx as xn,jsxs as FT}from"react/jsx-runtime";var h9=()=>FT("div",{"data-testid":"brave-measure-text-error",children:[xn("p",{children:xn(ii,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>xn("span",{style:{fontWeight:600},children:e})})}),xn("p",{children:xn(ii,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>xn("span",{style:{fontWeight:600},children:e})})}),xn("p",{children:xn(ii,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>xn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),xn("p",{children:xn(ii,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>xn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>FT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),OT=h9;import v9 from"clsx";import I9 from"react";import{isDarwin as zT}from"@excalidraw/common";var g9={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],imageExport:[N("CtrlOrCmd+Shift+E")],cut:[N("CtrlOrCmd+X")],copy:[N("CtrlOrCmd+C")],paste:[N("CtrlOrCmd+V")],copyStyles:[N("CtrlOrCmd+Alt+C")],pasteStyles:[N("CtrlOrCmd+Alt+V")],selectAll:[N("CtrlOrCmd+A")],deleteSelectedElements:[N("Delete")],duplicateSelection:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)],sendBackward:[N("CtrlOrCmd+[")],bringForward:[N("CtrlOrCmd+]")],sendToBack:[zT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[zT?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],flipHorizontal:[N("Shift+H")],flipVertical:[N("Shift+V")],viewMode:[N("Alt+R")],hyperlink:[N("CtrlOrCmd+K")],toggleElementLock:[N("CtrlOrCmd+Shift+L")],resetZoom:[N("CtrlOrCmd+0")],zoomOut:[N("CtrlOrCmd+-")],zoomIn:[N("CtrlOrCmd++")],zoomToFitSelection:[],zoomToFit:[],zoomToFitSelectionInViewport:[],smartZoom:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[N("Shift+R")],toolLock:[N("Q")]},Ze=(e,n=0)=>{let t=g9[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as f9,useRef as GT,useEffect as HT}from"react";import{unstable_batchedUpdates as E9}from"react-dom";import{KEYS as b9,queryFocusableElements as x9}from"@excalidraw/common";import{clamp as UT}from"@excalidraw/math";import y9 from"clsx";import{jsx as w9}from"react/jsx-runtime";var pr=10,WT=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=GT(null);HT(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===b9.TAB){let u=x9(d),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===d?(p.shiftKey?u[u.length-1]?.focus():u[0].focus(),p.preventDefault(),p.stopImmediatePropagation()):g===0&&p.shiftKey?(u[u.length-1]?.focus(),p.preventDefault(),p.stopImmediatePropagation()):g===u.length-1&&!p.shiftKey&&(u[0]?.focus(),p.preventDefault(),p.stopImmediatePropagation())}};return d.addEventListener("keydown",m),()=>d.removeEventListener("keydown",m)},[]);let c=GT(null);return f9(()=>{if(r&&l.current&&t!=null&&n!=null){let d=l.current,{width:m,height:p}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===n)return;c.current={top:t,left:n};let u=Math.max(0,i-pr*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${pr}px`,d.style.overflowX="scroll"):d.style.left=`${UT(n,pr,i-pr-m)}px`;let E=Math.max(0,a-pr*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${pr}px`,d.style.overflowY="scroll"):d.style.top=`${UT(t,pr,a-pr-p)}px`}},[t,n,r,i,a]),HT(()=>{if(o){let d=m=>{l.current?.contains(m.target)||E9(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),w9("div",{className:y9("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as Mo,jsxs as YT}from"react/jsx-runtime";var je="separator",VT=e=>"onSelect"in e,XT=I9.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Qn(),a=Oi(),s=n.reduce((l,c)=>c?c===je||VT(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return Mo(WT,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Mo("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===je)return!s[c-1]||s[c-1]===je?null:Mo("hr",{className:"context-menu-item-separator"},c);if(VT(l))return Mo("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:YT("button",{type:"button",className:"context-menu-item",children:[Mo("div",{className:"context-menu-item__label",children:l.label}),Mo("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=f(l.label(a,i,e.app)):m=f(l.label)),Mo("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:YT("button",{type:"button",className:v9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[Mo("div",{className:"context-menu-item__label",children:m}),Mo("kbd",{className:"context-menu-item__shortcut",children:d?Ze(d):""})]})},c)})})})});import{useId as T9}from"react";import S9 from"clsx";import{Fragment as C9,jsx as Gl,jsxs as KT}from"react/jsx-runtime";var rp=({border:e,style:n})=>Gl("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),ip=({label:e,border:n})=>{let t=T9(),o=KT(C9,{children:[e.icon&&Gl("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return KT("div",{className:S9("viewport-status-frame__badge",{"viewport-status-frame__badge--clickable":e.onClick}),role:"status",style:{"--viewport-status-frame-badge-background":e.background||n||"var(--color-primary)",color:e.color},children:[e.onClick&&Gl("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),Gl("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&Gl("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:rn})]})};import rs from"clsx";import JW from"react";import{CLASSES as QW,TOOL_TYPE as Tk,arrayToMap as eV,isShallowEqual as zp}from"@excalidraw/common";import{mutateElement as tV,ShapeCache as nV}from"@excalidraw/element";import{showSelectedShapeActions as oV}from"@excalidraw/element";import{createIsolation as P9}from"jotai-scope";import Zf from"react";import Ao from"tunnel-rat";var jf=Zf.createContext(null),nt=()=>Zf.useContext(jf),k9=P9(),$T=()=>Zf.useMemo(()=>({MainMenuTunnel:Ao(),WelcomeScreenMenuHintTunnel:Ao(),WelcomeScreenToolbarHintTunnel:Ao(),WelcomeScreenHelpHintTunnel:Ao(),WelcomeScreenCenterTunnel:Ao(),FooterCenterTunnel:Ao(),DefaultSidebarTriggerTunnel:Ao(),DefaultSidebarTabTriggersTunnel:Ao(),OverwriteConfirmDialogTunnel:Ao(),tunnelsJotai:k9}),[]);import hr from"clsx";import{useRef as F9}from"react";import{Popover as ur}from"radix-ui";import{CLASSES as iS}from"@excalidraw/common";import{isArrowElement as rS}from"@excalidraw/element";import{forwardRef as ZT}from"react";import jT from"clsx";import{jsx as qT}from"react/jsx-runtime";var M9=ZT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>qT("div",{className:jT("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),A9=ZT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>qT("div",{className:jT("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Nt={Row:M9,Col:A9};import{isTransparent as JT}from"@excalidraw/common";import{shouldAllowVerticalAlign as D9,suppportsHorizontalAlign as L9,hasBoundTextElement as QT,isElbowArrow as _9,isImageElement as eS,isLinearElement as R9,isTextElement as N9,hasStrokeColor as tS,toolIsArrow as B9}from"@excalidraw/element";var nS=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return tS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>tS(o.type))},oS=(e,n)=>Go(e.activeTool.type)||n.some(t=>Go(t.type)),ap=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(m=>d(m.type)),a=n.length===1,s=n.length===2&&(QT(n[0])||QT(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:nS(e,n),backgroundColor:oS(e,n),fill:r==="bucketfill"||Go(r)&&!JT(e.currentItemBackgroundColor)||n.some(d=>Go(d.type)&&!JT(d.backgroundColor)),strokeWidth:i(tx),freedrawMode:i(nx),strokeStyle:i(fu),sloppiness:i(fu),roundness:i(ox),arrowType:i(B9),arrowheads:i(ms),text:r==="text"||n.some(N9),textAlign:r==="text"||L9(n,t),verticalAlign:D9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||ce(t,e).some(d=>d.type==="freedraw"),align:!s&&dt(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(eS)&&dt(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&eS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&R9(n[0])&&!_9(n[0])}};import{Fragment as Jt,jsx as j,jsxs as Se}from"react/jsx-runtime";var qf=hr([iS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),aS=({renderAction:e})=>Se("fieldset",{children:[j("legend",{children:f("labels.layers")}),Se("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),sS=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Se("fieldset",{children:[j("legend",{children:f("labels.align")}),Se("div",{className:"buttonList",children:[o?Se(Jt,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Se(Jt,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),j("div",{style:{flexBasis:"100%",height:0}}),Se("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Se(Jt,{children:[j("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},lS=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=vi(n,e),i=ap(e,r,n,o);return e.activeTool.type==="bucketfill"?Se("div",{className:"selected-shape-actions",children:[j("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Se("div",{className:"selected-shape-actions",children:[j("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&j("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&j(Jt,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&j(Jt,{children:t("changeSloppiness")}),i.roundness&&j(Jt,{children:t("changeRoundness")}),i.arrowType&&j(Jt,{children:t("changeArrowType")}),i.text&&Se(Jt,{children:[j("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&j(Jt,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&j(aS,{renderAction:t}),i.align&&j(sS,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Se("fieldset",{children:[j("legend",{children:f("labels.actions")}),Se("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},cS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return i?j("div",{className:"compact-action-item",children:Se(ur.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[j(ur.Trigger,{asChild:!0,children:j("button",{type:"button",className:hr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:m0})}),a&&j(bo,{className:qf,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Se("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&j(Jt,{children:n("changeStrokeStyle")}),o.sloppiness&&j(Jt,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},dS=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let s=e.openPopup==="compactArrowProperties";return j("div",{className:"compact-action-item",children:Se(ur.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[j(ur.Trigger,{asChild:!0,children:j("button",{type:"button",className:hr("compact-action-button properties-trigger",{active:s}),title:f("labels.arrowtypes"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactArrowProperties"})},children:(()=>{let l=mt(o,a,c=>rS(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>rS(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Ko:l==="round"?$o:Xo})()})}),s&&j(bo,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},mS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=R0(),s=e.openPopup==="compactTextProperties";return j("div",{className:"compact-action-item",children:Se(ur.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[j(ur.Trigger,{asChild:!0,children:j("button",{type:"button",className:hr("compact-action-button properties-trigger",{active:s}),title:f("labels.textAlign"),onClick:l=>{l.preventDefault(),l.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:Fx})}),e.openPopup==="compactTextProperties"&&j(bo,{className:qf,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Se("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},pS=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?j("div",{className:"compact-action-item",children:Se(ur.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[j(ur.Trigger,{asChild:!0,children:j("button",{type:"button",className:hr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Ax})}),s&&j(bo,{className:qf,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Se("div",{className:"selected-shape-actions",children:[t.layers&&j(aS,{renderAction:n}),t.align&&j(sS,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Se("fieldset",{children:[j("legend",{children:f("labels.actions")}),Se("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),n("smartZoom"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},O9=({renderAction:e,predicates:n})=>n.lineEditor?j("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,uS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=vi(n,e),a=ap(e,i,n,o),{container:s}=Re();return Se("div",{className:"compact-shape-actions",children:[a.strokeColor&&j("div",{className:hr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&j("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),j(cS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(dS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&j("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Se(Jt,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(mS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),j(pS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},hS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=vi(n,e),a=ap(e,i,n,o),{container:s}=Re(),l=F9(null),c=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,p=32,u=d*p+(d-1)*m,E=p+m,g=c>=u+E,b=c>=u+2*E;return Se(Ue,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:l,children:[Se("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&j("div",{className:hr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),j(cS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(dS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),j(O9,{renderAction:t,predicates:a}),a.text&&Se(Jt,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(mS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),j(pS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Se("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[j("div",{className:"compact-action-item",children:t("undo")}),j("div",{className:"compact-action-item",children:t("redo")}),b&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},gS=({renderAction:e})=>j(Nt.Col,{gap:1,className:iS.ZOOM_ACTIONS,children:Se(Nt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),fS=({renderAction:e,className:n})=>Se("div",{className:`undo-redo-buttons ${n}`,children:[j("div",{className:"undo-button-container",children:j(pt,{label:f("buttons.undo"),children:e("undo")})}),j("div",{className:"redo-button-container",children:Se(pt,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),ES=({showExitZenModeBtn:e})=>j("button",{type:"button",className:hr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import z9 from"clsx";import{useState as G9,useEffect as H9}from"react";import{THEME as U9}from"@excalidraw/common";import{jsx as Jf,jsxs as W9}from"react/jsx-runtime";var sp=({delay:e,theme:n})=>{let[t,o]=G9(!!e);return H9(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:W9("div",{className:z9("LoadingMessage",{"LoadingMessage--dark":n===U9.DARK}),children:[Jf("div",{children:Jf(Eo,{})}),Jf("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as mp,useEffect as zS}from"react";import bz from"clsx";import{KEYS as nE,capitalizeString as GS}from"@excalidraw/common";import OS from"react";import{DropdownMenu as hz}from"radix-ui";import{CLASSES as gz}from"@excalidraw/common";import V9 from"clsx";import{useCallback as Y9,useEffect as X9,useRef as K9}from"react";import{CLASSES as $9,EVENT as bS,KEYS as Z9}from"@excalidraw/common";import{DropdownMenu as j9}from"radix-ui";import{jsx as lp}from"react/jsx-runtime";var xS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=Ee(),l=K9(null),c=Fi({onClickOutside:n});Bi(l,Y9(m=>{l.current?.closest(`.${$9.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),X9(()=>{if(!r)return;let m=u=>{u.key===Z9.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(bS.KEYDOWN,m,p),()=>{document.removeEventListener(bS.KEYDOWN,m,p)}},[c,r]);let d=V9(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return lp(yh.Provider,{value:{onSelect:o},children:lp(j9.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?lp(Nt.Col,{className:"dropdown-menu-container",children:e}):lp(Ue,{className:"dropdown-menu-container",padding:2,children:e})})})};xS.displayName="DropdownMenuContent";var yS=xS;import{jsx as J9}from"react/jsx-runtime";var q9=({children:e,className:n="",selected:t,...o})=>J9("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),wS=q9;import{DropdownMenu as Q9}from"radix-ui";import{jsx as Qf}from"react/jsx-runtime";var vS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=dd(r);return Qf(Q9.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Qf("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:Jo(i,a),title:l.title??l["aria-label"],children:Qf(Qo,{icon:e,shortcut:n,children:o})})})},Ya=vS;vS.displayName="DropdownMenuItemLink";import{jsx as ez}from"react/jsx-runtime";var IS=()=>ez("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),TS=IS;IS.displayName="DropdownMenuSeparator";import{DropdownMenu as sz}from"radix-ui";import tz from"clsx";import{DropdownMenu as nz}from"radix-ui";import{useCallback as oz,useState as SS}from"react";import{jsx as tE}from"react/jsx-runtime";var eE=-4,rz=4,CS=({children:e,className:n})=>{let t=Ee(),o=tz(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=oz(c=>{if(c){let m=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=c.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+eE),l(eE+8))}}},[]),[i,a]=SS(rz),[s,l]=SS(eE);return tE(nz.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?tE(Nt.Col,{className:"dropdown-menu-container",children:e}):tE(Ue,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},PS=CS;CS.displayName="DropdownMenuSubContent";import{DropdownMenu as iz}from"radix-ui";import{jsx as kS,jsxs as az}from"react/jsx-runtime";var MS=({children:e,icon:n,shortcut:t,className:o})=>az(iz.SubTrigger,{className:`${Jo(o)} dropdown-menu__submenu-trigger`,children:[kS(Qo,{icon:n,shortcut:t,children:e}),kS("div",{className:"dropdown-menu__submenu-trigger-icon",children:h0})]}),AS=MS;MS.displayName="DropdownMenuSubTrigger";import DS from"react";var cp=e=>n=>{let t=DS.Children.toArray(n).find(o=>DS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},LS=cp("DropdownMenuTrigger"),_S=cp("DropdownMenuContent"),RS=cp("DropdownMenuSubTrigger"),NS=cp("DropdownMenuSubContent");import{jsxs as lz}from"react/jsx-runtime";var dp=({children:e})=>{let n=RS(e),t=NS(e);return lz(sz.Sub,{children:[n,t]})};dp.Trigger=AS;dp.Content=PS;dp.displayName="DropdownMenuSub";var gr=dp;import cz from"clsx";import{DropdownMenu as dz}from"radix-ui";import{jsx as mz}from"react/jsx-runtime";var BS=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=Ee(),a=cz(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return mz(dz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},FS=BS;BS.displayName="DropdownMenuTrigger";import{jsx as uz}from"react/jsx-runtime";var pz=e=>uz(jt,{...e,icon:e.checked?Nc:Uc}),io=pz;import{jsx as Ez,jsxs as fz}from"react/jsx-runtime";var Bn=({children:e,open:n})=>{let t=LS(e),o=_S(e),r=o&&OS.isValidElement(o)?OS.cloneElement(o,{open:n}):o;return Ez(hz.Root,{open:n,modal:!1,children:fz("div",{className:gz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Bn.Trigger=FS;Bn.Content=yS;Bn.Item=jt;Bn.ItemCheckbox=io;Bn.ItemLink=Ya;Bn.ItemCustom=wS;Bn.Group=Rs;Bn.Separator=TS;Bn.Sub=gr;var ue=Bn;Bn.displayName="DropdownMenu";import{Fragment as oE,jsx as _e,jsxs as Xa}from"react/jsx-runtime";var xz=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Dt))return null;let t=f("buttons.objectsSnapMode");return _e($,{type:"toggle",icon:Yo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Dt,"ui")})},yz=({app:e})=>_e($,{type:"button",icon:_i,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),HS=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=mp(!1),[l,c]=mp("rectangle"),[d,m]=mp("arrow");zS(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),zS(()=>{(o.type==="arrow"||o.type==="line")&&m(o.type)},[o.type]);let p=o.type==="frame",u=o.type==="autoshape",E=o.type==="laser",g=o.type==="embeddable",b=o.type==="bucketfill",y=["rectangle","diamond","ellipse"].map(G=>({type:G,icon:Ye[G].icon,title:GS(f(`toolBar.${G}`)),fillable:Ye[G].fillable})),w=["arrow","line"].map(G=>({type:G,icon:Ye[G].icon,title:GS(f(`toolBar.${G}`)),fillable:Ye[G].fillable})),[x,I]=mp(0),T=36,C=4,P=7,A=P*T+(P-1)*C,D=T+C,_=x>=A+1*D,k=i&&x>=A+2*D,L=x>=A+3*D,B=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(G=>!(_&&G==="text"||(!i||k)&&G==="image"||L&&G==="frame")),V=r&&ji.includes(o.type),z=V||B.includes(o.type),U=z?V?Ye[o.type].icon:o.type==="text"?Pn:o.type==="image"?_r:o.type==="frame"?jn:o.type==="embeddable"?Vo:o.type==="laser"?qn:o.type==="bucketfill"?Zn:bs:bs,K={app:e,activeTool:o,hideShortcut:!0};return Xa("div",{className:"mobile-toolbar",ref:G=>{G&&I(G.getBoundingClientRect().width)},children:[_e(_d,{...K}),_e(Rd,{...K,setAppState:t}),r?_e(Ws,{...K}):_e(Nd,{...K}),_e(Xs,{...K}),!r&&_e(Zi,{app:e,options:y,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(c(G),e.setActiveTool({type:G}))},displayedOption:y.find(G=>G.type===l)||y[0]}),!r&&_e(Zi,{app:e,options:w,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(m(G),e.setActiveTool({type:G}))},displayedOption:w.find(G=>G.type===d)||w[0]}),_&&_e(Vs,{...K}),r&&k&&_e(yz,{app:e}),k&&_e(Ys,{...K}),!r&&L&&_e(Zy,{...K,hideShortcut:!0}),Xa(ue,{open:a,children:[_e(ue.Trigger,{className:bz("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":z||a}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),Xa(ue.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&ji.map(G=>_e(ue.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:Ye[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Ld(G),disabled:qe(e,G),children:f(`toolBar.${G}`)},G)),!r&&_e("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(Dt)&&_e(ue.Item,{onSelect:()=>n.executeAction(Dt,"ui"),icon:Yo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Ze("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&Xa(oE,{children:[r&&_e("div",{className:"App-toolbar__dropdown-divider"}),_e(ue.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Uo:fo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:nE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Pn,shortcut:nE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:qe(e,"text"),children:f("toolBar.text")}),i&&!k&&_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:_r,"data-testid":"toolbar-image",selected:o.type==="image",disabled:qe(e,"image"),children:f("toolBar.image")}),!r&&!L&&_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:nE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:qe(e,"frame"),children:f("toolBar.frame")}),!r&&Xa(oE,{children:[_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Vo,"data-testid":"toolbar-embeddable",selected:g,disabled:qe(e,"embeddable"),children:f("toolBar.embeddable")}),_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Br,shortcut:Ji("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:qe(e,"autoshape"),children:f("toolBar.autoshape")}),_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:E,disabled:qe(e,"laser"),children:f("toolBar.laser")}),_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:b,disabled:qe(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&Xa(oE,{children:[_e("div",{className:"App-toolbar__divider"}),_e(xz,{actionManager:n,app:e})]})]})};import wz from"clsx";import{jsx as vz}from"react/jsx-runtime";var pp=({children:e,side:n,className:t})=>vz("div",{className:wz("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import Iz from"clsx";import{jsx as Tz}from"react/jsx-runtime";var Ka=e=>e.penDetected?Tz($,{className:Iz("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Bx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as US,jsx as wt,jsxs as ai}from"react/jsx-runtime";var WS=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=nt(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=wt("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&ai(US,{children:[l&&wt(Ka,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),wt(E.Out,{})]}))}),A=ai("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),wt(u.Out,{})]});return ai("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[A,P]})},b=()=>wt(HS,{app:d,actionManager:t,setAppState:o}),y=c&&e.scrolledOutside,w=l,x=l&&(!e.viewModeEnabled||w),I=y&&!e.openMenu&&!e.openSidebar?wt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...wi(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?wt(ip,{label:T,border:d.props.viewportStatusFrame?.border}):null;return ai(US,{children:[a(),wt("div",{className:"App-welcome-screen",children:s&&wt(p.Out,{})}),x&&ai("div",{className:"App-bottom-bar",style:{marginBottom:gn+Po,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[I&&wt("div",{className:"floating-status-stack",children:I}),ai("div",{className:"App-bottom-bar__actions-row",children:[w&&ai(Ue,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&wt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),wt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&wt(hS,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&wt(Ue,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&I&&wt("div",{className:"floating-status-stack",children:I}),C&&wt("div",{className:"viewport-status-frame__badge-row",children:C}),wt(pp,{side:"top",className:"App-top-bar",children:g()})]})};import jS,{useLayoutEffect as qS,useRef as JS,useState as QS}from"react";import{newTextElement as eC}from"@excalidraw/element";import Dz from"clsx";import{useEffect as Lz,useState as _z}from"react";import{KEYS as Rz,queryFocusableElements as $S}from"@excalidraw/common";import{useCallback as Sz,useState as Cz}from"react";var VS=()=>{let[e,n]=Cz(null),t=Sz(o=>n(o),[]);return[e,t]};import YS from"clsx";import{useRef as Pz}from"react";import{createPortal as kz}from"react-dom";import{KEYS as Mz}from"@excalidraw/common";import{jsx as XS,jsxs as Az}from"react/jsx-runtime";var KS=e=>{let{closeOnClickOutside:n=!0}=e,t=Qc({className:YS("excalidraw-modal-container",e.portalContainerClassName)}),o=Pz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===Mz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return kz(Az("div",{className:YS("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[XS("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),XS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as up,jsxs as ZS}from"react/jsx-runtime";function Nz(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var yn=e=>{let[n,t]=VS(),[o]=_z(document.activeElement),{id:r}=Re(),i=Ee().formFactor==="phone";Lz(()=>{if(!n)return;let l=$S(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===Rz.TAB){let m=$S(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Fe(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return up(KS,{className:Dz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:Nz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:ZS(Ue,{ref:t,children:[e.title&&ZS("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[up("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&up("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:rn}),up("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as Do,jsxs as hp}from"react/jsx-runtime";var Bz=e=>{switch(e){case"bar":return f("labels.chartType_bar");case"line":return f("labels.chartType_line");case"radar":return f("labels.chartType_radar");default:return e}},Fz=e=>{let n=JS(null),[t,o]=QS(null),{theme:r}=be();qS(()=>{if(!e.spreadsheet){o(null);return}let a=Cf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let s,l=n.current;return(async()=>(s=await Ar(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),s.querySelector(".style-fonts")?.remove(),l.replaceChildren(),l.appendChild(s)))(),()=>{l.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=Bz(e.chartType);return hp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Do("div",{className:"ChartPreview__canvas",ref:n}),Do("div",{className:"ChartPreview__label",children:i})]})},Oz=e=>{let n=JS(null),{theme:t}=be();return qS(()=>{if(!e.rawText)return;let o=eC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Ar([o],{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:t==="dark"},null,{skipInliningFonts:!0});i.querySelector(".style-fonts")?.remove(),r.replaceChildren(),r.appendChild(i)})(),()=>{r.replaceChildren()}},[e.rawText,t]),hp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Do("div",{className:"ChartPreview__canvas",ref:n}),Do("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},tC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=St(),[i,a]=QS(Math.random()),s=jS.useCallback(()=>{a(Math.random())},[]),l=jS.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),Be("paste","chart",m),t(),r()},d=m=>{let p=eC({text:m,x:0,y:0});o([p]),Be("paste","chart","plaintext"),t(),r()};return Do(yn,{size:"regular",onCloseRequest:l,title:hp("div",{className:"PasteChartDialog__title",children:[Do("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),Do("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Zn})]}),className:"PasteChartDialog",autofocus:!1,children:hp("div",{className:"container",children:[["bar","line","radar"].map(m=>Aa(e,m)?Do(Fz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&Do(Oz,{rawText:n,onClick:d})]})})};import{Fragment as zz,jsx as nC,jsxs as Gz}from"react/jsx-runtime";var Hl=({heading:e,children:n,...t})=>{let{id:o}=Re(),r=nC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return nC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):Gz(zz,{children:[r,n]})})};import{Popover as Ul}from"radix-ui";import oC from"clsx";import gp,{useLayoutEffect as Hz}from"react";import{supportsResizeObserver as Uz,isShallowEqual as Wz}from"@excalidraw/common";import{Fragment as aE,jsx as vt,jsxs as $a}from"react/jsx-runtime";var Vz=4,Yz=8,rE=38,rC=21,Xz=({shouldWrap:e,children:n,username:t})=>e?vt(pt,{label:t||"Unknown user",children:n}):vt(aE,{children:n}),iE=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return vt(Xz,{username:n.username,shouldWrap:r,children:s},t)},Kz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],fp=gp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=ot(),a=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,P])=>({...P,socketId:C})).filter(C=>C.username?.trim()),l=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[d,m]=gp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=gp.useRef(null);Hz(()=>{if(u.current){let C=A=>{g(A)};if(C(u.current.clientWidth),!Uz)return;let P=new ResizeObserver(A=>{for(let D of A){let{width:_}=D.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=gp.useState(Vz*rE),b=l?E-rC:E,y=Math.max(1,Math.min(8,Math.floor(b/rE))),w=l?Math.max(0,y-1):y,x=c.slice(0,w),I=l?[...x,l]:x,T=I.map(C=>{let P=iE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?$a(Ul.Root,{children:[vt(Ul.Trigger,{asChild:!0,children:$a("div",{className:"UserList__pill",children:[P,vt("div",{className:"UserList__pill-chevron",children:u0})]})}),vt(Ul.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:$a(Ue,{padding:2,children:[s.length>=Yz&&vt(ld,{placeholder:f("quickSearch.placeholder"),onChange:m}),vt(cd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[vt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(A=>iE({actionManager:i,collaborator:A,socketId:A.socketId,withName:!0,isBeingFollowed:A.socketId===o}))]:[]}),a&&$a(aE,{children:[vt("div",{className:"UserList__menu-divider"}),vt(Ul.Close,{asChild:!0,children:vt("div",{className:"dropdown-menu",children:a})})]}),vt(Ul.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]},C.socketId):P});return n?$a("div",{className:oC("UserList UserList_mobile",e),children:[vt("div",{className:"UserList_mobile__avatars",children:s.map(C=>iE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&$a(aE,{children:[vt("div",{className:"UserList__menu-divider"}),a]})]}):vt("div",{className:"UserList__wrapper",ref:u,children:vt("div",{className:oC("UserList",e),style:{"--max-avatars":I.length+(l?rC/rE:0)},children:T})})},(e,n)=>{if(e.collaborators.size!==n.collaborators.size||e.mobile!==n.mobile||e.className!==n.className||e.userToFollow!==n.userToFollow||e.currentUserControls!==n.currentUserControls)return!1;let t=n.collaborators.keys();for(let[o,r]of e.collaborators){let i=n.collaborators.get(o);if(!i||o!==t.next().value||!Wz(r,i,Kz))return!1}return!0});import Wl from"clsx";import{jsx as iC}from"react/jsx-runtime";var aC=e=>iC(pt,{label:`${f("helpDialog.title")} \u2014 ?`,children:iC("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Li})});import{jsx as Qt,jsxs as sE}from"react/jsx-runtime";var sC=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=nt(),l=St();return sE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&Qt("div",{className:Wl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Qt(Nt.Col,{gap:2,children:sE(Hl,{heading:"canvasActions",children:[!e.viewModeOnly&&Qt(pt,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:Qt("div",{className:Wl("view-mode-button"),children:n.renderAction("viewMode")})}),Qt(pt,{label:f("buttons.smartZoom"),children:Qt("div",{className:Wl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&Qt(gS,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&Qt(fS,{renderAction:n.renderAction,className:Wl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Qt(a.Out,{}),(r||o)&&Qt("div",{className:Wl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:sE("div",{style:{position:"relative"},children:[o&&Qt(s.Out,{}),r&&Qt(aC,{onClick:()=>n.executeAction(Kr)})]})}),r&&Qt(ES,{showExitZenModeBtn:t})]})},lC=sC;sC.displayName="Footer";import{composeEventHandlers as tG}from"@excalidraw/common";import{useLayoutEffect as $z,useRef as Zz}from"react";import{jsx as jz}from"react/jsx-runtime";var si=(e,n)=>{let t=Je(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=nt(),[,a]=i(t),s=Zz({preferHost:!1,counter:0});return $z(()=>{let l=s.current;return a(c=>{let d=c+1;return l.counter=d,d}),()=>{a(c=>{let d=c-1;return l.counter=d,d||(l.preferHost=!1),d})}},[a]),r.__fallback||(s.current.preferHost=!0),!s.current.counter&&r.__fallback&&s.current.preferHost||s.current.counter>1&&r.__fallback?null:jz(n,{...r})};return o.displayName=e,o};var mE={};w3(mE,{ChangeCanvasBackground:()=>xC,Export:()=>yC,Help:()=>EC,LiveCollaborationTrigger:()=>vC,LoadScene:()=>uC,Preferences:()=>ao,PreferencesToggleGridModeItem:()=>dE,SaveAsImage:()=>gC,SaveToActiveFile:()=>hC,SearchMenu:()=>fC,Socials:()=>wC,ToggleTheme:()=>bC});import eG from"clsx";import{THEME as Yl}from"@excalidraw/common";var lE=Je({active:!1});async function cC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{Et.set(lE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import qz from"clsx";import{jsx as dC,jsxs as Jz}from"react/jsx-runtime";var Ep=function({onChange:e,value:n,choices:t,name:o}){return dC("div",{className:"RadioGroup",children:t.map(r=>Jz("div",{className:qz("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[dC("input",{name:o,type:"radio",checked:r.value===n,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as Qz,jsx as Vl,jsxs as mC}from"react/jsx-runtime";var pC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=Ee();return mC(Qz,{children:[mC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&Vl("div",{className:"dropdown-menu-item__icon",children:a}),Vl("label",{className:"dropdown-menu-item__text",children:Vl(Ns,{children:r})}),Vl(Ep,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&Vl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};pC.displayName="DropdownMenuItemContentRadio";var cE=pC;import{Fragment as AC,jsx as xe,jsxs as Xl}from"react/jsx-runtime";var uC=()=>{let{t:e}=Le(),n=ot(),t=Oi();return n.isActionEnabled(ea)?xe(jt,{icon:Bc,onSelect:async()=>{(!t.length||await cC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:xe(ii,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>xe("strong",{children:r}),br:()=>xe("br",{})})}))&&n.executeAction(ea)},"data-testid":"load-button",shortcut:Ze("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};uC.displayName="LoadScene";var hC=()=>{let{t:e}=Le(),n=ot();return n.isActionEnabled(Xr)?xe(jt,{shortcut:Ze("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(Xr),icon:Vx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};hC.displayName="SaveToActiveFile";var gC=()=>{let e=Fe(),{t:n}=Le();return xe(jt,{icon:Kx,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ze("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};gC.displayName="SaveAsImage";var fC=e=>{let{t:n}=Le(),t=ot();return xe(jt,{icon:Jn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(wl)},shortcut:Ze("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};fC.displayName="SearchMenu";var EC=()=>{let{t:e}=Le(),n=ot();return xe(jt,{"data-testid":"help-menu-item",icon:Li,onSelect:()=>n.executeAction(Kr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};EC.displayName="Help";var bC=e=>{let{t:n}=Le(),t=be(),o=ot(),r=Ze("toggleTheme"),i=kn();return o.isActionEnabled(kd)?e?.allowSystemTheme?xe(cE,{name:"theme",value:e.theme,onChange:a=>{if(i.onThemeChange){i.onThemeChange(a);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:Yl.LIGHT,label:ws,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:Yl.DARK,label:ys,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:i0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):xe(jt,{onSelect:a=>{a.preventDefault(),o.executeAction(kd)},icon:t.theme===Yl.DARK?ws:ys,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Yl.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===Yl.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};bC.displayName="ToggleTheme";var xC=()=>{let{t:e}=Le(),n=be(),t=ot(),o=kn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Xl("div",{style:{marginTop:"0.75rem"},children:[xe("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),xe("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};xC.displayName="ChangeCanvasBackground";var yC=()=>{let{t:e}=Le(),n=Fe();return xe(jt,{icon:vs,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};yC.displayName="Export";var wC=()=>{let{t:e}=Le();return Xl(AC,{children:[xe(Ya,{icon:Hx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),xe(Ya,{icon:Wx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),xe(Ya,{icon:Ux,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};wC.displayName="Socials";var vC=({onSelect:e,isCollaborating:n})=>{let{t}=Le();return xe(jt,{"data-testid":"collab-button",icon:Fc,className:eG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};vC.displayName="LiveCollaborationTrigger";var IC=()=>{let{t:e}=Le(),n=St(),t=be();return xe(io,{checked:t.activeTool.locked,shortcut:Ze("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},TC=()=>{let{t:e}=Le(),n=be(),t=Fe();return xe(cE,{name:"boxSelectionMode",icon:Uc,value:n.boxSelectionMode,onChange:o=>{t({boxSelectionMode:o})},choices:[{value:"contain",label:e("labels.boxSelectionContain"),ariaLabel:e("labels.boxSelectionContain")},{value:"overlap",label:e("labels.boxSelectionOverlap"),ariaLabel:e("labels.boxSelectionOverlap")}],children:e("labels.boxSelectionMode")})},SC=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.objectsSnapModeEnabled,shortcut:Ze("objectsSnapMode"),onSelect:o=>{n.executeAction(Dt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},CC=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(tl),o.preventDefault()},children:e("labels.arrowBinding")})},PC=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(nl),o.preventDefault()},children:e("labels.midpointSnapping")})},dE=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.gridModeEnabled,shortcut:Ze("gridMode"),onSelect:o=>{n.executeAction(la),o.preventDefault()},children:e("labels.toggleGrid")})},kC=()=>{let{t:e}=Le(),n=ot(),t=be();return t.viewModeOnly?null:xe(io,{checked:t.viewModeEnabled,shortcut:Ze("viewMode"),onSelect:o=>{n.executeAction(va),o.preventDefault()},children:e("labels.viewMode")})},MC=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.stats.open,shortcut:Ze("stats"),onSelect:o=>{n.executeAction(ar),o.preventDefault()},children:e("stats.fullTitle")})},ao=({children:e,additionalItems:n})=>{let{t}=Le();return Xl(gr,{children:[xe(gr.Trigger,{icon:g0,children:t("labels.preferences")}),Xl(gr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Xl(AC,{children:[xe(TC,{}),xe(IC,{}),xe(SC,{}),xe(dE,{}),xe(kC,{}),xe(MC,{}),xe(CC,{}),xe(PC,{})]}),n]})]})};ao.ToggleToolLock=IC;ao.BoxSelectionMode=TC;ao.ToggleSnapMode=SC;ao.ToggleArrowBinding=CC;ao.ToggleMidpointSnapping=PC;ao.ToggleGridMode=dE;ao.ToggleViewMode=kC;ao.ToggleElementProperties=MC;ao.displayName="Preferences";import{jsx as bp,jsxs as pE}from"react/jsx-runtime";var nG=Object.assign(si("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=nt(),o=Ee(),r=be(),i=kn(),a=Fe();return bp(t.In,{children:pE(ue,{open:r.openMenu==="canvas",children:[bp(ue.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:zx}),pE(ue.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:tG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&pE("fieldset",{className:"UserList-Wrapper",children:[bp("legend",{children:f("labels.collaborators")}),bp(fp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:ue.Trigger,Item:ue.Item,ItemLink:ue.ItemLink,ItemCustom:ue.ItemCustom,Group:ue.Group,Separator:ue.Separator,Sub:gr,DefaultItems:mE}),Bt=nG;import oG from"clsx";import{forwardRef as rG,useState as iG}from"react";import{isPromiseLike as aG}from"@excalidraw/common";import{jsx as xp,jsxs as sG}from"react/jsx-runtime";var fr=rG(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:c,disabled:d},m)=>{let[p,u]=iG(!1),E=async b=>{let y=t?.(b);if(aG(y)){let w=window.setTimeout(()=>{u(!0)},50);try{await y}catch(x){if(x instanceof wc)console.warn(x);else throw x}finally{clearTimeout(w),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,xp("button",{className:oG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":s},l),onClick:E,type:"button","aria-label":o,ref:m,disabled:d||g==="loading"||g==="success",children:sG("div",{className:"ExcButton__contents",children:[g==="loading"?xp(Eo,{className:"ExcButton__statusIcon"}):g==="success"&&xp("div",{className:"ExcButton__statusIcon",children:$1}),n&&xp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as Za,jsxs as dG}from"react/jsx-runtime";var yp=({title:e,children:n,actionLabel:t,onClick:o})=>dG("div",{className:"OverwriteConfirm__Actions__Action",children:[Za("h4",{children:e}),Za("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),Za(fr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),lG=()=>{let{t:e}=Le(),n=ot(),t=Fe();return Za(yp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(Kd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},cG=()=>{let{t:e}=Le(),n=ot();return Za(yp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(Js,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},uE=Object.assign(({children:e})=>Za("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:lG,SaveToDisk:cG});import{jsx as Er,jsxs as DC}from"react/jsx-runtime";var wp=Object.assign(si("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=nt(),[t,o]=He(lE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return Er(n.In,{children:Er(yn,{onCloseRequest:r,title:!1,size:916,children:DC("div",{className:"OverwriteConfirm",children:[Er("h3",{children:t.title}),DC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Er("div",{className:"OverwriteConfirm__Description__icon",children:Z1}),Er("div",{children:t.description}),Er("div",{className:"OverwriteConfirm__Description__spacer"}),Er(fr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Er(uE,{children:e})]})})})}),{Actions:uE,Action:yp});import{round as wP}from"@excalidraw/math";import kH from"clsx";import MH from"lodash.throttle";import{useEffect as vP,useMemo as PE,useState as AH,memo as DH}from"react";import{STATS_PANELS as Ap}from"@excalidraw/common";import{getCommonBounds as LH}from"@excalidraw/element";import{getUncroppedWidthAndHeight as _H}from"@excalidraw/element";import{isImageElement as kE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as RH}from"@excalidraw/element";import{elementsAreInSameGroup as NH}from"@excalidraw/element";import{degreesToRadians as zC,radiansToDegrees as WC}from"@excalidraw/math";import{getBoundTextElement as GC}from"@excalidraw/element";import{isArrowElement as HC,isElbowArrow as TG}from"@excalidraw/element";import{updateBindings as UC}from"@excalidraw/element";import bG from"clsx";import{useEffect as FC,useRef as Ip,useState as xG}from"react";import{EVENT as Ja,KEYS as yG,cloneJSON as hE}from"@excalidraw/common";import{deepCopyElement as wG}from"@excalidraw/element";import{CaptureUpdateAction as OC}from"@excalidraw/element";import{pointFrom as br,pointRotateRads as vp}from"@excalidraw/math";import{getBoundTextElement as mG,getNonDeletedElements as pG,isBindingElement as uG,unbindBindingElement as LC}from"@excalidraw/element";import{isFrameLikeElement as NC}from"@excalidraw/element";import{getSelectedGroupIds as hG,getElementsInGroup as gG,isInGroup as fG}from"@excalidraw/element";import{getFrameChildren as EG}from"@excalidraw/element";import{updateBindings as _C}from"@excalidraw/element";import{DRAGGING_THRESHOLD as RC}from"@excalidraw/common";var BC=.01,Kl=10,Wt=(e,n)=>!(n==="angle"&&NC(e)),We=(e,n)=>{let t=e+n/2;return t-t%n},ja=(e,n,t)=>Object.keys(e).map(o=>({original:(t??n).get(o),latest:n.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0);var li=(e,n,t,o,r,i,a=!0)=>{if(uG(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<RC&&Math.abs(n-t.y)<RC)return;LC(t,"start",o),LC(t,"end",o)}let s=o.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[c,d]=[t.x+t.width/2,t.y+t.height/2],[m,p]=vp(br(t.x,t.y),br(c,d),t.angle),u=e-m,E=n-p,[g,b]=vp(br(e,n),br(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),_C(l,o,r);let y=mG(t,i);if(y){let w=s.get(y.id);w&&o.mutateElement(w,{x:y.x+u,y:y.y+E},{informMutation:a,isDragging:!1})}if(NC(t)){let w=EG(i,t.id);w.forEach(x=>{let I=s.get(x.id);if(!I)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,A]=vp(br(x.x,x.y),br(T,C),x.angle),D=Math.round(P+u),_=Math.round(A+E),[k,L]=vp(br(D,_),br(T+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:L},{informMutation:a,isDragging:!1}),_C(I,o,r,{simultaneouslyUpdated:pG(w)})})}},qa=(e,n)=>{let o=hG(n).map(r=>gG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!fG(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as gE,jsxs as IG}from"react/jsx-runtime";var vG=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=St(),u=Fe(),E=Ip(null),g=Ip(null),[b,y]=xG(o.toString()),w=Ip(null);w.current||(w.current={originalAppState:hE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),FC(()=>{let T=o.toString();y(T),w.current.lastUpdatedValue=T},[o]);let x=(T,C,P)=>{if(!w.current.updatePending)return!1;w.current.updatePending=!1;let A=Number(T);if(isNaN(A)){y(o.toString());return}let D=Number(A.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(D-_)>=BC)&&(w.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:D,property:s,originalAppState:P,setInputValue:k=>y(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:OC.IMMEDIATELY}))},I=Ip({});return I.current.handleInputValue=x,FC(()=>{let T=E.current,C=I.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,w.current.originalElements,w.current.originalAppState),window.removeEventListener(Ja.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(Ja.POINTER_UP,C.onPointerUp,!1)}},[i]),i?IG("div",{className:bG("drag-input-container",!i&&"disabled"),"data-testid":e,children:[gE("div",{className:"drag-input-label",ref:g,onPointerDown:T=>{if(E.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(E.current.value);isNaN(C)&&(C=0);let P=null,A=p.scene.getNonDeletedElements().reduce((z,U)=>(z.set(U.id,wG(U)),z),new Map),D=r.map(z=>A.get(z.id)),_=hE(c),k=0,L=0,B=z=>{if(P&&A!==null&&D!==null){let U=z.clientX-P.x;U!==0&&(L+=U,Math.abs(L)>=d&&(L=Math.sign(L)*Math.floor(Math.abs(L)/d),k+=L,t({accumulatedChange:k,instantChange:L,originalElements:D,originalElementsMap:A,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:K=>y(String(K)),app:p,setAppState:u}),L=0))}P={x:z.clientX,y:z.clientY}},V=()=>{window.removeEventListener(Ja.POINTER_MOVE,B,!1),p.syncActionResult({captureUpdate:OC.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:D,originalAppState:_}),P=null,k=0,L=0,D=null,A=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Ja.POINTER_UP,V,!1)};I.current.onPointerMove=B,I.current.onPointerUp=V,window.addEventListener(Ja.POINTER_MOVE,B,!1),window.addEventListener(Ja.POINTER_UP,V,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?gE(ud,{icon:n}):e}),gE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===yG.ENTER&&(x(C.value,r,c),p.focusContainer())}},ref:E,value:b,onChange:T=>{w.current.updatePending=!0,y(T.target.value)},onFocus:T=>{T.target.select(),w.current.originalElements=r,w.current.originalAppState=hE(c)},onBlur:T=>{b?i&&x(T.target.value,w.current.originalElements,w.current.originalAppState):y(o.toString())},disabled:!i})]}):null},gt=vG;import{jsx as kG}from"react/jsx-runtime";var SG=15,CG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!TG(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=zC(o);r.mutateElement(l,{angle:E}),UC(l,r,i.state);let g=GC(l,a);g&&!HC(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(WC(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=We(m,SG)),m=m<0?m+360:m;let p=zC(m);r.mutateElement(l,{angle:p}),UC(l,r,i.state);let u=GC(l,a);u&&!HC(l)&&r.mutateElement(u,{angle:p})}},PG=({element:e,scene:n,appState:t,property:o})=>kG(gt,{label:"A",icon:zc,value:Math.round(WC(e.angle)%360*100)/100,elements:[e],dragInputCallback:CG,editable:Wt(e,"angle"),scene:n,appState:t,property:o}),VC=PG;import{jsx as AG}from"react/jsx-runtime";var YC=5,MG=({property:e,scene:n,appState:t,setAppState:o})=>AG(gt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{o(l=>{let c;return r?c=r:i&&(c=a?We(l.gridStep+YC*Math.sign(i),YC):l.gridStep+i),c?(c=Qb(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),XC=MG;import{clamp as Tp,round as fE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Sp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as KC,getNonDeletedElements as DG,getUncroppedWidthAndHeight as jC}from"@excalidraw/element";import{resizeSingleElement as $C}from"@excalidraw/element";import{isImageElement as qC}from"@excalidraw/element";import{isFrameLikeElement as EE}from"@excalidraw/element";import{getElementsInResizingFrame as bE}from"@excalidraw/element";import{replaceAllElementsInFrame as JC}from"@excalidraw/element";import{jsx as BG}from"react/jsx-runtime";var ZC=10,LG=e=>e.type==="image",_G=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||LG(u),b=u.width/u.height;if(s.croppingElementId===u.id){let y=p.get(u.id);if(!y||!qC(y)||!y.crop)return;let w=y.crop,x={...w},I=y.scale[0]===-1,T=y.scale[1]===-1,{width:C,height:P}=jC(y),A=w.naturalWidth/C,D=w.naturalHeight/P,_=I?w.width+w.x:w.naturalWidth-w.x,k=T?w.height+w.y:w.naturalHeight-w.y,L=KC*A,B=KC*D;if(i!==void 0){if(a==="width"){let G=i*A,te=Tp(G,L,_);x={...x,width:te,x:I?w.x+w.width-te:w.x}}else if(a==="height"){let G=i*D,te=Tp(G,B,k);x={...x,height:te,y:T?w.y+w.height-te:w.y}}c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}let V=a==="width"?l:0,z=a==="height"?l:0,U=Tp(w.width+V,L,_),K=Tp(w.height+z,L,k);x={...w,x:I?w.x+w.width-U:w.x,y:T?w.y+w.height-K:w.y,width:U,height:K},c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}if(i!==void 0){let y=Math.max(a==="width"?i:g?i*b:u.width,Sp),w=Math.max(a==="height"?i:g?i/b:u.height,Sp);if($C(y,w,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),EE(E)){let x=bE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),I=JC(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(I)}return}{let y=a==="width"?e:0,w=a==="height"?e:0,x=Math.max(0,u.width+y);a==="width"&&(r?x=We(x,ZC):x=Math.round(x));let I=Math.max(0,u.height+w);if(a==="height"&&(r?I=We(I,ZC):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Sp,I),x=Math.max(Sp,x),$C(x,I,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),EE(E)){let T=DG(bE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},RG=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&EE(a)){let s=bE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=JC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},NG=({property:e,element:n,scene:t,appState:o})=>{let r=fE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&qC(n)&&n.crop){let{width:i,height:a}=jC(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=fE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=fE(n.crop.height*s,2)}}return BG(gt,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:_G,value:r,editable:Wt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:RG})},xE=NG;import{getBoundTextElement as FG,redrawTextBoundingBox as OG}from"@excalidraw/element";import{hasBoundTextElement as zG,isTextElement as eP}from"@excalidraw/element";import{jsx as WG}from"react/jsx-runtime";var QC=4,GG=4,HG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let s=i.get(a.id);if(!s||!eP(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),QC);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,QC),t&&(l=We(l,GG))}l&&(r.mutateElement(s,{fontSize:l}),OG(s,r.getContainerElement(s),r))}},UG=({element:e,scene:n,appState:t,property:o})=>{let r=eP(e)?e:zG(e)?FG(e,n.getNonDeletedElementsMap()):null;return r?WG(gt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:HG,icon:Nr,appState:t,scene:n,property:o}):null},tP=UG;import{degreesToRadians as nP,radiansToDegrees as iP}from"@excalidraw/math";import{getBoundTextElement as oP}from"@excalidraw/element";import{isArrowElement as rP}from"@excalidraw/element";import{isInGroup as yE}from"@excalidraw/element";import{jsx as KG}from"react/jsx-runtime";var VG=15,YG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=n.map(c=>a.get(c.id)).filter(c=>c&&!yE(c)&&Wt(c,r)),l=n.filter(c=>!yE(c)&&Wt(c,r));if(o!==void 0){let c=nP(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=oP(d,a);m&&!rP(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let m=l[c],p=Math.round(iP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=We(E,VG)),E=E<0?E+360:E;let g=nP(E);i.mutateElement(d,{angle:g});let b=oP(d,a);b&&!rP(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},XG=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!yE(l)&&Wt(l,"angle")),i=r.map(l=>Math.round(iP(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Wt(l,"angle"));return KG(gt,{label:"A",icon:zc,value:a,elements:e,dragInputCallback:YG,editable:s,appState:t,scene:n,property:o})},aP=XG;import{pointFrom as dP}from"@excalidraw/math";import{useMemo as ZG}from"react";import{MIN_WIDTH_OR_HEIGHT as xr}from"@excalidraw/common";import{getElementsInResizingFrame as wE,getNonDeletedElements as jG,isFrameLikeElement as vE,replaceAllElementsInFrame as uP,updateBoundElements as qG}from"@excalidraw/element";import{rescalePointsInElement as JG,resizeSingleElement as mP}from"@excalidraw/element";import{getBoundTextElement as QG,handleBindTextResize as eH}from"@excalidraw/element";import{isTextElement as hP}from"@excalidraw/element";import{MIME_TYPES as ci}from"@excalidraw/common";import{getNonDeletedElements as sP}from"@excalidraw/element";var Cp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=sP(Dr(e,null,{deleteInvisibleElements:!0})),l=Ti(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return Cc(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(m,p),b=o<g?o/g:n?.exportScale??1;return u.width=m*b,u.height=p*b,{canvas:u,scale:b}}let E=r?.(m,p)||{width:m,height:p};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},lP=async e=>{let{mimeType:n=ci.png,quality:t}=e;n===ci.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ci.png}" mimeType`),n==="image/jpg"&&(n=ci.jpg),n===ci.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ci.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Cp(e);return t=t||(/image\/jpe?g/.test(n)?.92:.8),new Promise((r,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&n===ci.png&&e.appState?.exportEmbedScene&&(a=await mx({blob:a,metadata:us(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},cP=async({elements:e,appState:n=Ho(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=sP(Dr(e,null,{deleteInvisibleElements:!0})),d={...Ti(n,null),exportPadding:o};return Ar(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},$G=async e=>{if(e.type==="svg"){let n=await cP(e);await vo(n.outerHTML)}else if(e.type==="png")await Yd(lP(e));else if(e.type==="json")await Ud(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as nNe}from"@excalidraw/element";import{getCommonBounds as Pp}from"@excalidraw/element";import{jsx as aH}from"react/jsx-runtime";var Qa=10,tH=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,s=o.height*t,l=e+r*t,c=n+i*t;return{width:a,height:s,x:l,y:c,...JG(o,a,s,!1),...hP(o)?{fontSize:o.fontSize*t}:{}}},nH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=tH(e,n,o,i);s.mutateElement(r,c);let d=QG(i,a);if(d){let m=d.fontSize*o;qG(r,s);let p=l.get(d.id);p&&hP(p)&&(s.mutateElement(p,{fontSize:m}),eH(r,s,t==="width"?"e":"s",!0))}},pP=(e,n,t,o,r,i,a,s,l,c)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let d=n/t;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];nH(r[0],r[1],i,d,u,p,l,c)}},oH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),m=qa(n,o);if(i!==void 0){for(let g of m){let b=ja(g,d,t);if(b.length>1){let y=b.map(L=>L.latest),w=b.map(L=>L.original),[x,I,T,C]=Pp(w),P=T-x,A=C-I,D=P/A,_=Math.max(xr,s==="width"?Math.max(0,i):P),k=Math.max(xr,s==="height"?Math.max(0,i):A);pP(_,k,A,D,dP(x,I),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&Wt(w,s)){let I=s==="width"?Math.max(0,i):w.width;s==="width"&&(r?I=We(I,Qa):I=Math.round(I));let T=s==="height"?Math.max(0,i):w.height;if(s==="height"&&(r?T=We(T,Qa):T=Math.round(T)),I=Math.max(xr,I),T=Math.max(xr,T),mP(I,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),vE(w)){let C=wE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()),P=uP(a.getElementsIncludingDeleted(),C,w);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=s==="width"?e:0,u=s==="height"?e:0,E=[];for(let g of m){let b=ja(g,d,t);if(b.length>1){let y=b.map(L=>L.latest),w=b.map(L=>L.original),[x,I,T,C]=Pp(w),P=T-x,A=C-I,D=P/A,_=Math.max(0,P+p);s==="width"&&(r?_=We(_,Qa):_=Math.round(_));let k=Math.max(0,A+u);s==="height"&&(r?k=We(k,Qa):k=Math.round(k)),_=Math.max(xr,_),k=Math.max(xr,k),pP(_,k,A,D,dP(x,I),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&Wt(w,s)){let I=Math.max(0,x.width+p);s==="width"&&(r?I=We(I,Qa):I=Math.round(I));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=We(T,Qa):T=Math.round(T)),I=Math.max(xr,I),T=Math.max(xr,T),mP(I,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),vE(w)){let C=jG(wE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},rH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&vE(a)){let s=wE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=uP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},iH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=ZG(()=>o.map(c=>{let d=ja(c,t);if(d.length>1){let[p,u,E,g]=Pp(d.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return aH(gt,{label:e==="width"?"W":"H",elements:n,dragInputCallback:oH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:rH})},IE=iH;import{getBoundTextElement as sH,redrawTextBoundingBox as gP}from"@excalidraw/element";import{hasBoundTextElement as lH,isTextElement as cH}from"@excalidraw/element";import{isInGroup as dH}from"@excalidraw/element";import{jsx as gH}from"react/jsx-runtime";var fP=4,mH=4,pH=(e,n)=>e.reduce((t,o)=>{if(!o||dH(o))return t;if(cH(o))return t.push(o),t;if(lH(o)){let r=sH(o,n);if(r)return t.push(r),t}return t},[]),uH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),fP);for(let l of a)r.mutateElement(l,{fontSize:s}),gP(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,fP);t&&(E=We(E,mH)),r.mutateElement(d,{fontSize:E}),gP(d,r.getContainerElement(d),r)}r.triggerUpdate()}},hH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=pH(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return gH(gt,{label:"F",icon:Nr,elements:i,dragInputCallback:uH,value:s,editable:l,scene:n,property:o,appState:t})},EP=hH;import{pointFrom as yr,pointRotateRads as kp}from"@excalidraw/math";import{useMemo as fH}from"react";import{isTextElement as EH}from"@excalidraw/element";import{getCommonBounds as TE}from"@excalidraw/element";import{jsx as vH}from"react/jsx-runtime";var bH=(e,n,t,o,r,i,a)=>{for(let s=0;s<o.length;s++){let l=o[s],[c,d]=[l.x+l.width/2,l.y+l.height/2],[m,p]=kp(yr(l.x,l.y),yr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;li(u,E,l,i,a,r,!1)}},xH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=TE(t),c=e-s,d=n-l;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!EH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,y]=kp(yr(u.x,u.y),yr(E,g),u.angle);li(b+c,y+d,p,r,i,o,!1)}}},yH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of qa(n,s)){let E=ja(u,c,t);if(E.length>1){let[g,b,,]=TE(E.map(x=>x.latest));xH(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,l.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&Wt(b,i)){let[y,w]=[g.x+g.width/2,g.y+g.height/2],[x,I]=kp(yr(g.x,g.y),yr(y,w),g.angle);li(i==="x"?r:x,i==="y"?r:I,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?We(e,Kl):e;bH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},wH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=fH(()=>o.map(l=>{let c=Object.keys(l).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,b]=TE(c);return Math.round((e==="x"?g:b)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,E]=kp(yr(d.x,d.y),yr(m,p),d.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return vH(gt,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:yH,value:s,property:e,scene:r,appState:i})},SE=wH;import{clamp as $l,pointFrom as Mp,pointRotateRads as xP,round as bP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as IH,getUncroppedWidthAndHeight as TH}from"@excalidraw/element";import{isImageElement as yP}from"@excalidraw/element";import{jsx as PH}from"react/jsx-runtime";var SH=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:c})=>{let d=s.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=xP(Mp(m.x,m.y),Mp(p,u),m.angle);if(l.croppingElementId===m.id){let I=d.get(m.id);if(!I||!yP(I)||!I.crop)return;let T=I.crop,C=T,P=I.scale[0]===-1,A=I.scale[1]===-1,{width:D,height:_}=TH(I);if(i!==void 0){if(a==="x"){let B=i*(T.naturalWidth/D);P?C={...T,x:$l(T.naturalWidth-B-T.width,0,T.naturalWidth-T.width)}:C={...T,x:$l(i*(T.naturalWidth/D),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:$l(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(I,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),L=(a==="y"?n:0)*(A?-1:1);C={...T,x:$l(T.x+k,0,T.naturalWidth-T.width),y:$l(T.y+L,0,T.naturalHeight-T.height)},s.mutateElement(I,{crop:C});return}if(i!==void 0){li(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,y=a==="y"?e:0,w=a==="x"?Math.round(r?We(m.x+b,Kl):E+b):E,x=a==="y"?Math.round(r?We(m.y+y,Kl):g+y):g;li(w,x,m,s,c.state,o)},CH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=xP(Mp(n.x,n.y),Mp(n.x+n.width/2,n.y+n.height/2),n.angle),a=bP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&yP(n)&&n.crop){let s=IH(n);s&&(a=bP(e==="x"?s.x:s.y,2))}return PH(gt,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:SH,scene:t,value:a,property:e,appState:o})},CE=CH;import{Fragment as ME,jsx as ne,jsxs as Vt}from"react/jsx-runtime";var BH=50,Zl=e=>{let n=Qn(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=cr(e.app);return ne(FH,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Oe=({children:e,columns:n=1,heading:t,style:o,...r})=>ne("div",{className:kH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Oe.displayName="StatsRow";var Dp=({children:e,order:n,style:t,...o})=>ne("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Dp.displayName="StatsRows";Zl.StatsRow=Oe;Zl.StatsRows=Dp;var FH=DH(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=Fe(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&kE(m),E=u?_H(m):null,[g,b]=AH({width:0,height:0}),y=PE(()=>MH(I=>{let T=LH(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},BH),[]);vP(()=>{y(l)},[i,l,y]),vP(()=>()=>y.cancel(),[y]);let w=PE(()=>qa(o,r),[o,r]),x=PE(()=>RH(o),[o]);return ne("div",{className:"exc-stats",children:Vt(Ue,{padding:3,children:[Vt("div",{className:"title",children:[ne("h2",{children:f("stats.title")}),ne("div",{className:"close",onClick:n,children:rn})]}),Vt(Os,{label:ne("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Ap.generalStats),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Ap.generalStats}})),children:[Vt(Dp,{children:[ne(Oe,{heading:!0,children:f("stats.scene")}),Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:l.length})]}),Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:g.width})]}),Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:g.height})]}),a&&Vt(ME,{children:[ne(Oe,{heading:!0,children:"Canvas"}),ne(Oe,{children:ne(XC,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Os,{label:ne("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Ap.elementProperties),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Ap.elementProperties}})),children:Vt(Dp,{children:[m&&Vt(ME,{children:[u&&ne(Oe,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&kE(m)&&E&&Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:wP(E.width,2)})]}),r.croppingElementId&&kE(m)&&E&&Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:wP(E.height,2)})]}),ne(Oe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):m.type==="magicframe"?f("element.frame"):f(`element.${m.type}`)}),ne(Oe,{children:ne(CE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),ne(Oe,{children:ne(CE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),ne(Oe,{children:ne(xE,{property:"width",element:m,scene:s,appState:r})}),ne(Oe,{children:ne(xE,{property:"height",element:m,scene:s,appState:r})}),ne(Oe,{children:ne(VC,{property:"angle",element:m,scene:s,appState:r})}),ne(Oe,{children:ne(tP,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Vt(ME,{children:[NH(p)&&ne(Oe,{heading:!0,children:f("element.group")}),Vt(Oe,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:o.length})]}),ne(Oe,{children:ne(SE,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Oe,{children:ne(SE,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Oe,{children:ne(IE,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Oe,{children:ne(IE,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Oe,{children:ne(aP,{property:"angle",elements:p,scene:s,appState:r})}),ne(Oe,{children:ne(EP,{property:"fontSize",elements:p,scene:s,appState:r,elementsMap:c})})]})]})})})]})})},(e,n)=>e.sceneNonce===n.sceneNonce&&e.selectedElements===n.selectedElements&&e.appState.stats.panels===n.appState.stats.panels&&e.gridModeEnabled===n.gridModeEnabled&&e.appState.gridStep===n.appState.gridStep&&e.appState.croppingElementId===n.appState.croppingElementId);import{useCallback as ZH,useEffect as TP,useState as SP}from"react";import{normalizeLink as jH,KEYS as _E}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as qH,getLinkIdAndTypeFromSelection as JH}from"@excalidraw/element";import OH from"clsx";import{jsx as Lp,jsxs as GH}from"react/jsx-runtime";var zH=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return GH("button",{className:OH("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Lp("div",{style:a?{visibility:"hidden"}:{},children:o}),Lp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Lp("div",{style:{position:"absolute",inset:0},children:Lp(Eo,{})})]})},AE=zH;import DE from"clsx";import{forwardRef as VH,useRef as YH,useImperativeHandle as XH,useLayoutEffect as KH,useState as $H}from"react";import HH from"clsx";import{composeEventHandlers as UH}from"@excalidraw/common";import{jsx as WH}from"react/jsx-runtime";var wn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>WH("button",{onClick:UH(i.onClick,a=>{n()}),type:e,className:HH("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as LE,jsxs as IP}from"react/jsx-runtime";var _p=VH(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...m},p)=>{let u=YH(null);XH(p,()=>u.current),KH(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=$H(!1);return IP("div",{className:DE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&LE("div",{className:"ExcTextField__label",children:n}),IP("div",{className:DE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[LE("input",{className:DE({"is-redacted":"value"in m&&m.value&&s&&!E}),readOnly:r,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:o,ref:u,onChange:b=>e?.(b.target.value),onKeyDown:a,type:d}),s&&LE(wn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?j1:Fr})]})]})});import{jsx as es,jsxs as Rp}from"react/jsx-runtime";var QH=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=qH})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=SP(a),[c,d]=SP(!1);TP(()=>{let p=ce(i,t),u=a;if(p.length>0&&r){let E=JH(p,t);E&&(u=jH(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=ZH(()=>{if(s&&s!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:s})}if(!s&&c&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,s,i,c,o,n]);return TP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===_E.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===_E.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Rp("div",{className:"ElementLinkDialog",children:[Rp("div",{className:"ElementLinkDialog__header",children:[es("h2",{children:f("elementLink.title")}),es("p",{children:f("elementLink.desc")})]}),Rp("div",{className:"ElementLinkDialog__input",children:[es(_p,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===_E.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&es($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Rr})]}),Rp("div",{className:"ElementLinkDialog__actions",children:[es(AE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),es(AE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},CP=QH;import eU,{useState as tU}from"react";import{Fragment as nU,jsx as RE}from"react/jsx-runtime";var PP=({children:e,onClose:n})=>{let[t,o]=tU(!!e),{container:r}=Re(),i=eU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return RE(nU,{children:t&&RE(yn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:RE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import kP from"clsx";import wr from"react";import{MIME_TYPES as MP,sceneCoordsToViewportCoords as NE}from"@excalidraw/common";import{getCommonBounds as _P,isInitializedImageElement as AP,ShapeCache as oU}from"@excalidraw/element";import{Fragment as lU,jsx as kt,jsxs as di}from"react/jsx-runtime";var rU=kt("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:kt("path",{d:"M8 5v14l11 -7z"})}),iU=di("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[kt("path",{d:"M8 5v14"}),kt("path",{d:"M16 5v14"})]}),aU=76,RP=4,jl=aU+RP,DP=8,mi=8,sU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+mi),window.innerWidth-t-mi)},LP=(e,n)=>{let[,,t,o]=_P([e]),r=NE({sceneX:t,sceneY:o},n);return{left:Math.min(Math.max(r.x-n.offsetLeft,8),n.width-8),top:Math.min(Math.max(r.y-n.offsetTop,8),n.height-8)}},NP=({app:e,files:n,setAppState:t})=>{let o=Qn(),[,r]=wr.useReducer(y=>y+1,0),[i,a]=wr.useState(0),s=wr.useRef(null),l=wr.useRef(null),c=wr.useRef(null),d=wr.useRef(null),[m,p]=wr.useState(null);wr.useLayoutEffect(()=>{let y=o.openPopup;if(y!=="gifSpeedPicker"&&y!=="gifFrameGallery"){m!==null&&p(null);return}let w=y==="gifSpeedPicker"?s.current:l.current,x=y==="gifSpeedPicker"?c.current:d.current;if(!w||!x)return;let I=w.getBoundingClientRect(),T=x.getBoundingClientRect(),C=sU(I.left+I.width/2,T.width),P=y==="gifSpeedPicker"?Math.max(mi,I.top-T.height-mi):Math.min(window.innerHeight-T.height-mi,I.bottom+mi),A={left:C,top:Math.max(mi,P)};p(D=>D?.left===A.left&&D.top===A.top?D:A)},[i,m,o.openPopup,o.scrollX,o.scrollY,o.zoom.value]);let u=(y,w)=>{oU.delete(y),e.scene.mutateElement(y,{gifPlayback:w}),e.scheduleUpdate(),t({}),r(),w.playing&&e.ensureGifPlaybackLoop()},E=e.scene.getNonDeletedElements().filter(y=>AP(y)&&!o.selectedElementIds[y.id]&&n[y.fileId]?.mimeType===MP.gif&&e.imageCache.get(y.fileId)?.gifDecodeStatus==="deferred").map(y=>{let w=LP(y,o);return kt("span",{className:"gif-playback-controls gif-playback-controls__deferred-badge",role:"img","aria-label":"GIF paused",style:w,children:Mx},y.id)}),g=e.scene.getSelectedElements(o);return di(lU,{children:[E,(()=>{if(g.length!==1)return null;let y=g[0];if(!AP(y)||n[y.fileId]?.mimeType!==MP.gif)return null;let w=e.imageCache.get(y.fileId),x=w?.gif,[I,,T,C]=_P([y]),P=NE({sceneX:I,sceneY:C},o),D=NE({sceneX:T,sceneY:C},o).x-P.x,_=P.x-o.offsetLeft+D/2,k=Math.max(12,Math.min(o.height-86,P.y-o.offsetTop+16));if(w?.gifDecodeStatus==="deferred"){let re=LP(y,o);return kt("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:re,onPointerDown:lt=>lt.stopPropagation(),children:kt("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(y.fileId)},children:"Load Large GIF"})})}if(w?.gifDecodeStatus==="pending")return null;let L=x?.frames.length??0;if(!x||L<2)return null;let B=y.gifPlayback??{frameIndex:0,speed:1,playing:!1},V=e.state,z=e.getGifPlaybackFrameIndex(y)??B.frameIndex,U=Math.min(Math.max(z,0),L-1),K=Math.min(V.height-120,k+48),G=Math.max(12,k-52),te=re=>{let lt=(re+L)%L;e.setGifPlaybackFrameIndex(y,lt),u(y,{...B,frameIndex:lt,playing:!1})},F=re=>{re.preventDefault(),re.stopPropagation(),te(U+(re.deltaY<0?1:-1))},W=re=>{e.setGifPlaybackFrameIndex(y,U),u(y,{...B,frameIndex:U,playing:re})},le=[.25,.5,.75,1,1.25,1.5,1.75,2,4],we=re=>{let lt=le.indexOf(re);return lt!==-1?lt:le.reduce(($t,Sn,nn)=>Math.abs(Sn-re)<Math.abs(le[$t]-re)?nn:$t,0)},de=re=>{u(y,{...B,speed:re})},he=re=>{let lt=we(B.speed);de(le[Math.min(Math.max(lt+re,0),le.length-1)])},ve=Number.isInteger(B.speed)?`${B.speed}`:`${B.speed}`,ae=L*jl-RP,fe=Math.min(Math.max(V.width*.9,1),ae),rt=Math.max(ae-fe,0),Ge=Math.min(i,rt),Pe=Math.max(Math.floor(Ge/jl)-DP,0),Wn=Math.ceil(fe/jl)+DP*2,zo=Math.min(Pe+Wn,L),xi=x.frames.slice(Pe,zo);return di("div",{className:"gif-playback-controls",style:{left:_,top:k},onPointerDown:re=>re.stopPropagation(),children:[o.openPopup==="gifSpeedPicker"&&kt("div",{className:"gif-speed-picker",ref:c,style:m??{left:_,top:G},children:le.map(re=>{let lt=Number.isInteger(re)?`${re}`:`${re}`;return di("button",{type:"button",className:kP("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":re===B.speed}),onClick:()=>de(re),title:`${lt}x`,children:["x",lt]},re)})}),di("div",{className:"gif-playback-controls__bar",children:[di("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:s,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:re=>{re.preventDefault(),re.stopPropagation(),he(re.deltaY<0?1:-1)},title:"Speed",children:["x",ve]}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>te(U-1),onWheel:F,title:"Previous frame",children:Y1}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>W(!B.playing),onWheel:F,title:B.playing?"Pause":"Play",children:B.playing?iU:rU}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>te(U+1),onWheel:F,title:"Next frame",children:X1}),kt("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:l,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(U*jl-fe/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:F,title:"Frames",children:K1})]}),o.openPopup==="gifFrameGallery"&&kt("div",{className:"gif-frame-gallery",style:{...m??{left:_,top:K},width:fe},ref:re=>{d.current=re,re&&re.scrollLeft!==Ge&&(re.scrollLeft=Ge)},onScroll:re=>{a(re.currentTarget.scrollLeft)},onWheelCapture:re=>{re.preventDefault(),re.stopPropagation(),re.currentTarget.scrollLeft+=re.deltaY,a(re.currentTarget.scrollLeft)},children:kt("div",{className:"gif-frame-gallery__spacer",style:{width:ae},children:xi.map((re,lt)=>{let $t=Pe+lt;return di("button",{type:"button",className:kP("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":$t===U}),style:{left:$t*jl},onClick:()=>te($t),title:`Frame ${$t+1}`,children:[kt("canvas",{width:re.width,height:re.height,ref:Sn=>{Sn?.getContext("2d")?.drawImage(re,0,0)}}),kt("span",{children:$t+1})]},$t)})})})]})})()]})};import BP,{useMemo as fU}from"react";import FP from"clsx";import{isDarwin as OP,isFirefox as EU,isWindows as bU}from"@excalidraw/common";import{KEYS as ts}from"@excalidraw/common";import{SHAPES as xU}from"@excalidraw/element/shapes";import{isFirefox as cU,KEYS as BE}from"@excalidraw/common";import{SHAPES as dU}from"@excalidraw/element/shapes";import{Fragment as gU,jsx as Ve,jsxs as pi}from"react/jsx-runtime";var mU=e=>pi(gU,{children:[Ve("h3",{children:e.title}),Ve("div",{className:"HelpDialog__islands-container",children:e.children})]}),FE=e=>pi("div",{className:`HelpDialog__island ${e.className}`,children:[Ve("h4",{className:"HelpDialog__island-title",children:e.caption}),Ve("div",{className:"HelpDialog__island-content",children:e.children})]});function*pU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var uU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),It=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ve(hU,{children:uU(a)},a)));return pi("div",{className:"HelpDialog__shortcut",children:[Ve("div",{children:e}),Ve("div",{className:"HelpDialog__key-container",children:[...pU(o,t?f("helpDialog.or"):null)]})]})},hU=e=>Ve("kbd",{className:"HelpDialog__key",...e});function OE(){return pi(mU,{title:f("helpDialog.shortcuts"),children:[pi(FE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ve(It,{label:f("toolBar.hand"),shortcuts:[BE.H]}),dU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ve(It,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ve(It,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ve(It,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),pi(FE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ve(It,{label:f("helpDialog.smartZoom"),shortcuts:[BE.F]}),Ve(It,{label:f("helpDialog.dragToZoom"),shortcuts:[`${BE.Z}+${f("helpDialog.drag")}`]}),Ve(It,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),pi(FE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ve(It,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ve(It,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ve(It,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ve(It,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(or||cU)&&Ve(It,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ve(It,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ve(It,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ve(It,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ve(It,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ve(It,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as GP,jsx as Z,jsxs as ui}from"react/jsx-runtime";var yU=e=>ui(GP,{children:[Z("h3",{children:e.title}),Z("div",{className:"HelpDialog__islands-container",children:e.children})]}),zE=e=>ui("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*wU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var vU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),q=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Z(IU,{children:vU(a)},a)));return ui("div",{className:"HelpDialog__shortcut",children:[Z("div",{children:e}),Z("div",{className:"HelpDialog__key-container",children:[...wU(o,t?f("helpDialog.or"):null)]})]})},IU=e=>Z("kbd",{className:"HelpDialog__key",...e}),zP=({onClose:e})=>{let[n,t]=BP.useState(!1),o=BP.useCallback(()=>{e&&e()},[e]),r=fU(()=>n?Z("button",{className:FP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):Z("button",{className:FP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return Z(GP,{children:Z(yn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?ui(yU,{title:f("helpDialog.shortcuts"),children:[ui(zE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Z(q,{label:f("toolBar.hand"),shortcuts:[ts.H]}),xU.map(({value:i,key:a})=>Z(q,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),Z(q,{label:f("toolBar.frame"),shortcuts:[ts.F]}),Z(q,{label:f("labels.eyeDropper"),shortcuts:[ts.I,"Shift+S","Shift+I"]}),Z(q,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),Z(q,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),Z(q,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),Z(q,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),Z(q,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Z(q,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Z(q,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Z(q,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),Z(q,{label:f("toolBar.lock"),shortcuts:[ts.Q]}),Z(q,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),Z(q,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),Z(q,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),ui(zE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Z(q,{label:f("helpDialog.smartZoom"),shortcuts:[ts.F]}),Z(q,{label:f("helpDialog.dragToZoom"),shortcuts:[`${ts.Z}+${f("helpDialog.drag")}`]}),Z(q,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),Z(q,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),Z(q,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),Z(q,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),Z(q,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),Z(q,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),Z(q,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),Z(q,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),Z(q,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),Z(q,{label:f("search.title"),shortcuts:[Ze("searchMenu")]})]}),ui(zE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Z(q,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),Z(q,{label:f("labels.delete"),shortcuts:[N("Delete")]}),Z(q,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),Z(q,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),Z(q,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),Z(q,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Z(q,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),Z(q,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Z(q,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Z(q,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(or||EU)&&Z(q,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Z(q,{label:f("labels.sendToBack"),shortcuts:[OP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),Z(q,{label:f("labels.bringToFront"),shortcuts:[OP?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),Z(q,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),Z(q,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),Z(q,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),Z(q,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),Z(q,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),Z(q,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),Z(q,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+R")]}),Z(q,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),Z(q,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Z(q,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),Z(q,{label:f("buttons.redo"),shortcuts:bU?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),Z(q,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Z(q,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Z(q,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Z(q,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),Z(q,{label:f("labels.showStroke"),shortcuts:[N("S")]}),Z(q,{label:f("labels.showBackground"),shortcuts:[N("G")]}),Z(q,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),Z(q,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),Z(q,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):Z(OE,{})})})};import{useEffect as WP,useRef as VP,useState as hi}from"react";import{DEFAULT_EXPORT_PADDING as MU,EXPORT_IMAGE_TYPES as GE,isFirefox as AU,EXPORT_SCALES as DU,cloneJSON as YP}from"@excalidraw/common";import{useCallback as TU,useRef as SU,useState as CU}from"react";var PU=2e3,HP=()=>{let[e,n]=CU(null),t=SU(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},PU)},r=TU(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import kU from"clsx";import{jsx as UP}from"react/jsx-runtime";var ql=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>UP("div",{className:kU("Switch",{toggled:t,disabled:r}),children:UP("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});import{jsx as ze,jsxs as vr}from"react/jsx-runtime";var LU=()=>vr("div",{children:[ze("h3",{children:f("canvasError.cannotShowPreview")}),ze("p",{children:ze("span",{children:f("canvasError.canvasTooBig")})}),vr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),_U=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=De(n,e),[l,c]=hi(i),[d,m]=hi(s),[p,u]=hi(e.exportBackground),[E,g]=hi(e.exportEmbedScene),[b,y]=hi(e.exportScale),w=VP(null),x=VP(0),[I,T]=hi(null),{onCopy:C,copyStatus:P,resetCopyStatus:A}=HP();WP(()=>{A()},[l,p,a,b,E,A]);let{exportedElements:D,exportingFrame:_}=Vr(n,e,d);return WP(()=>{let k=w.current;if(!k)return;let L=k.offsetWidth,B=k.offsetHeight;if(!L)return;let V=++x.current,z=()=>V!==x.current;return Cp({elements:D,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:MU,maxWidthOrHeight:Math.max(L,B),exportingFrame:_}).then(async U=>{if(!z()){try{await Es(U)}catch(K){throw K.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):K}z()||(T(null),k.replaceChildren(U))}}).catch(U=>{z()||(console.error(U),T(U))}),()=>{x.current+=1}},[e,t,D,_,l,p,a,b,E]),vr("div",{className:"ImageExportModal",children:[ze("h3",{children:f("imageExportDialog.header")}),vr("div",{className:"ImageExportModal__preview",children:[ze("div",{className:"ImageExportModal__preview__canvas",ref:w,children:I&&ze(LU,{})}),ze("div",{className:"ImageExportModal__preview__filename",children:!Ii&&ze("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction($h,"ui",k.target.value)}})})]}),vr("div",{className:"ImageExportModal__settings",children:[ze("h3",{children:f("imageExportDialog.header")}),s&&ze(Jl,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:ze(ql,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),ze(Jl,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:ze(ql,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(Zh,"ui",k)}})}),ze(Jl,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:ze(ql,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(ww,"ui",k)}})}),ze(Jl,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:ze(ql,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(Kd,"ui",k)}})}),ze(Jl,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:ze(Ep,{name:"exportScale",value:b,onChange:k=>{y(k),o.executeAction(xw,"ui",k)},choices:DU.map(k=>({value:k,label:`${k}\xD7`}))})}),vr("div",{className:"ImageExportModal__settings__buttons",children:[ze(fr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(GE.png,D,{exportingFrame:_}),icon:Wu,children:f("imageExportDialog.button.exportToPng")}),ze(fr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(GE.svg,D,{exportingFrame:_}),icon:Wu,children:f("imageExportDialog.button.exportToSvg")}),(or||AU)&&ze(fr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(GE.clipboard,D,{exportingFrame:_}),C()},icon:U1,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Jl=({label:e,children:n,tooltip:t,name:o})=>vr("div",{className:"ImageExportModal__settings__setting",title:e,children:[vr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&ze(pt,{label:t,long:!0,children:V1})]}),ze("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),XP=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=hi(()=>({appStateSnapshot:YP(n),elementsSnapshot:YP(e)}));return ze(yn,{onCloseRequest:i,size:"wide",title:!1,children:ze(_U,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import wW from"clsx";import{CANVAS_SEARCH_TAB as mk,DEFAULT_SIDEBAR as vW}from"@excalidraw/common";import RU from"clsx";import NU from"lodash.debounce";import{Fragment as BU,memo as FU,useEffect as Ql,useMemo as KP,useRef as HE,useState as $P}from"react";import{CLASSES as OU,EVENT as zU,FONT_FAMILY as UE,FRAME_STYLE as WE,getLineHeight as GU}from"@excalidraw/common";import{getCommonBounds as HU,isElementCompletelyInViewport as UU}from"@excalidraw/element";import{measureText as ec}from"@excalidraw/element";import{KEYS as ns,randomInteger as ZP,addEventListener as WU,getFontString as Np}from"@excalidraw/common";import{newTextElement as VU}from"@excalidraw/element";import{isTextElement as QP,isFrameLikeElement as Bp}from"@excalidraw/element";import{getDefaultFrameName as ek}from"@excalidraw/element/frame";import{Fragment as eW,jsx as ft,jsxs as Fn}from"react/jsx-runtime";var YU=Je(""),VE=Je(null),XU=350,tk=()=>{let e=St(),n=Fe(),t=HE(null),[o,r]=He(YU),i=o.trim(),[a,s]=$P(!1),[l,c]=$P({nonce:null,items:[]}),d=HE(null),m=HE(void 0),[p,u]=He(VE),E=e.scene.getNonDeletedElementsMap();Ql(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,JP(i,e,(x,I)=>{c({nonce:ZP(),items:x}),d.current=i,m.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[a,i,E,e,n,u,m]);let g=()=>{l.items.length>0&&u(x=>x===null?0:(x+1)%l.items.length)},b=()=>{l.items.length>0&&u(x=>x===null?0:x-1<0?l.items.length-1:x-1)};Ql(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((T,C)=>C===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,n]),Ql(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let I=e.state.zoom.value,T=VU({text:x.searchQuery,x:x.element.x+(x.matchedLines[0]?.offsetX??0),y:x.element.y+(x.matchedLines[0]?.offsetY??0),width:x.matchedLines[0]?.width,height:x.matchedLines[0]?.height,fontSize:Bp(x.element)?WE.nameFontSize:x.element.fontSize,fontFamily:Bp(x.element)?UE.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,A=P*I<C;if(!UU([T],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.viewport.getOffsets())||A){let D=A&&P<C?"contain":"scale-down";e.viewport.setViewport({target:HU([T]),fit:D,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),Ql(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let y=Fi({goToNextItem:g,goToPreviousItem:b,searchMatches:l});Ql(()=>{let x=I=>{if(I.key===ns.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[ns.CTRL_OR_CMD]&&I.key===ns.F){if(I.preventDefault(),I.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}I.target instanceof HTMLElement&&I.target.closest(".layer-ui__search")&&y.searchMatches.items.length&&(I.key===ns.ENTER&&(I.stopPropagation(),y.goToNextItem()),I.key===ns.ARROW_UP?(I.stopPropagation(),y.goToPreviousItem()):I.key===ns.ARROW_DOWN&&(I.stopPropagation(),y.goToNextItem()))};return WU(window,zU.KEYDOWN,x,{capture:!0,passive:!1})},[n,y,e]);let w=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return Fn("div",{className:"layer-ui__search",children:[Fn("div",{className:"layer-ui__search-header",children:[ft(_p,{className:OU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Jn,onChange:x=>{r(x),s(!0);let I=x.trim();JP(I,e,(T,C)=>{c({nonce:ZP(),items:T}),u(C),d.current=I,m.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0}),ft(wn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:rn})]}),Fn("div",{className:"layer-ui__search-count",children:[l.items.length>0&&Fn(eW,{children:[p!==null&&p>-1?Fn("div",{children:[p+1," / ",w]}):ft("div",{children:w}),Fn("div",{className:"result-nav",children:[ft(wn,{onSelect:()=>{g()},className:"result-nav-btn",children:Hc}),ft(wn,{onSelect:()=>{b()},className:"result-nav-btn",children:c0})]})]}),l.items.length===0&&i&&d.current&&ft("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ft(ZU,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},jP=e=>{let n=[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 ft("div",{tabIndex:-1,className:RU("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ft("div",{className:"preview-text",children:n.flatMap((t,o)=>ft(BU,{children:o===2?ft("b",{children:t}):t},o))})})},KU=e=>{let n=KP(()=>e.matches.items.filter(o=>Bp(o.element)),[e.matches]),t=KP(()=>e.matches.items.filter(o=>QP(o.element)),[e.matches]);return Fn("div",{className:"layer-ui__search-results",children:[n.length>0&&Fn("div",{className:"layer-ui__search-result-container",children:[Fn("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:jn}),ft("div",{children:f("search.frames")})]}),n.map((o,r)=>ft(jP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ft("div",{className:"layer-ui__divider"})]}),t.length>0&&Fn("div",{className:"layer-ui__search-result-container",children:[Fn("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:Pn}),ft("div",{children:f("search.texts")})]}),t.map((o,r)=>ft(jP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},$U=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,ZU=FU(KU,$U),qP=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),s=i.endsWith(" "),l=a.length-2-1-(s?0:1),c=a.slice(l<=0?0:l).join(" ")+(s?" ":""),d=20;c=c.length>d?c.slice(-d):c;let m=e.slice(n+t.length),p=m.split(/\s+/),u=!m.startsWith(" "),E=u?6:5,g=(u?"":" ")+p.slice(0,E).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:l>0,moreAfter:p.length>E}},jU=(e,n)=>{let t=e.split(`
|
|
19
19
|
`),o=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],s=t[i+1];if(s){let l=n.indexOf(s,r);if(l>a.length+r){let c=l-(a.length+r);for(;c>0;)a+=" ",c--}}o.push(a),r=r+a.length}return o.join(`
|
|
20
|
-
`)},
|
|
21
|
-
`),i=[],a=0,s=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:s}),a=u+1,s++}let l=t,c=e.originalText.slice(t,t+n.length),d=[];for(let m of i){if(c==="")break;if(l>=m.startIndex&&l<=m.endIndex){let p=m.endIndex+1-l,u=m.line.slice(0,l-m.startIndex),E=c.slice(0,p);c=c.slice(p);let g=Yl(u,kp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let v=Yl(m.line,kp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;g.width+=T}let{width:b,height:y}=Yl(E,kp(e),e.lineHeight),w=g.width,x=m.lineNumber*g.height;d.push({offsetX:w,offsetY:x,width:b,height:y,showOnCanvas:!0}),l+=p}}return d},yU=(e,n,t,o)=>{let r=e.name??LP(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=kp({fontSize:NE.nameFontSize,fontFamily:RE.Assistant}),l=cU(RE.Assistant),c=Yl(a,s,l);a===""&&(c.width=0);let d=Yl(i,s,l),m=c.width,p=-c.height-NE.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},vU=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),MP=rU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>AP(p)),i=o.filter(p=>Mp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(vU(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=kP(E,u.index,e),b=wU(p,e,u.index);b.length>0&&a.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let l=[];for(let p of i){let u=null,E=p.name??LP(p);for(;(u=s.exec(E))!==null;){let g=kP(E,u.index,e),b=yU(p,e,u.index,n.state.zoom.value);b.length>0&&l.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let c=new Set(n.visibleElements.map(p=>p.id)),d=[...l,...a],m=d.findIndex(p=>c.has(p.element.id))??null;t(d,m)},gU);import BU from"clsx";import{useEffect as FP,useLayoutEffect as zP,useRef as YE,useState as OU,forwardRef as HP,useImperativeHandle as FU,useCallback as NP}from"react";import{CLASSES as zU,EVENT as BP,isDevEnv as HU,KEYS as GU,updateObject as UU}from"@excalidraw/common";import SU from"clsx";import{useContext as CU}from"react";import TU from"react";var Ap=TU.createContext({});import{jsx as OE,jsxs as _P}from"react/jsx-runtime";var FE=({children:e,className:n})=>{let t=ge(),o=CU(Ap),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return _P("div",{className:SU("sidebar__header",n),"data-testid":"sidebar-header",children:[e,_P("div",{className:"sidebar__header__buttons",children:[r&&OE(dt,{label:f("labels.sidebarLock"),children:OE(fn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:yx})}),OE(fn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:Qt})]})]})};FE.displayName="SidebarHeader";import{Tabs as PU}from"radix-ui";import{jsx as RP}from"react/jsx-runtime";var zE=({children:e,tab:n,onSelect:t,...o})=>RP(PU.Trigger,{value:n,asChild:!0,onSelect:t,children:RP("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});zE.displayName="SidebarTabTrigger";import{Tabs as kU}from"radix-ui";import{jsx as MU}from"react/jsx-runtime";var HE=({children:e,...n})=>MU(kU.List,{className:"sidebar-triggers",...n,children:e});HE.displayName="SidebarTabTriggers";import AU from"clsx";import{jsx as GE,jsxs as LU}from"react/jsx-runtime";var UE=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Be(),d=fe().openSidebar?.name===e;return GE("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":d,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!d;l({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:LU("div",{className:AU("sidebar-trigger",a),style:s,children:[t&&GE("div",{children:t}),r&&GE("div",{className:"sidebar-trigger__label",children:r})]})})};UE.displayName="SidebarTrigger";import{Tabs as DU}from"radix-ui";import{jsx as _U}from"react/jsx-runtime";var WE=({children:e,...n})=>{let t=fe(),o=Be();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return _U(DU.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};WE.displayName="SidebarTabs";import{Tabs as RU}from"radix-ui";import{jsx as NU}from"react/jsx-runtime";var VE=({tab:e,children:n,...t})=>NU(RU.Content,{...t,value:e,"data-testid":e,children:n});VE.displayName="SidebarTab";import{jsx as OP}from"react/jsx-runtime";import{createElement as WU}from"react";var XE=qe(!1),GP=HP(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{HU()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Be(),l=hx(XE);zP(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=YE({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=UU(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=YE(null);FU(a,()=>d.current);let m=ge(),p=NP(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Ti(d,NP(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),FP(()=>{let u=E=>{E.key===GU.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(BP.KEYDOWN,u),()=>{document.removeEventListener(BP.KEYDOWN,u)}},[p,o,m.canFitSidebar]),OP(He,{...i,className:BU(zU.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":m.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":m.formFactor!=="phone"?"sidebar":void 0,ref:d,children:OP(Ap.Provider,{value:c.current,children:n})})});GP.displayName="SidebarInner";var gr=Object.assign(HP((e,n)=>{let t=fe(),{onStateChange:o}=e,r=YE(t.openSidebar);FP(()=>{(!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&&o?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,o,e.name]);let[i,a]=OU(!1);return zP(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?WU(GP,{...e,ref:n,key:e.name}):null}),{Header:FE,TabTriggers:HE,TabTrigger:zE,Tabs:WE,Tab:VE,Trigger:UE});gr.displayName="Sidebar";import{jsx as Ya,jsxs as XU}from"react/jsx-runtime";import{createElement as KU}from"react";var WP=ei("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=tt();return Ya(n.In,{children:Ya(gr.Trigger,{...e,className:"default-sidebar-trigger",name:YU.name})})});WP.displayName="DefaultSidebarTrigger";var VP=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=tt();return Ya(n.In,{children:e})};VP.displayName="DefaultTabTriggers";var KE=Object.assign(ei("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=fe(),a=Be(),s=i.openSidebar?.tab===UP,l=s?!1:t??i.defaultSidebarDockedPreference,c=!s&&t==null&&o!==!1;return KU(gr,{...r,name:"default",key:"default",className:VU("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:c?d=>{a({defaultSidebarDockedPreference:d}),o?.(d)}:void 0},XU(gr.Tabs,{children:[!s&&Ya(gr.Header,{}),Ya(gr.Tab,{tab:UP,children:Ya(DP,{})}),!s&&e]}))}),{Trigger:WP,TabTriggers:VP});import $U from"react";import{getFrame as jU}from"@excalidraw/common";import{jsx as ZU}from"react/jsx-runtime";var ZE={primary:{base:"var(--color-primary)",darker:"var(--color-primary-darker)",darkest:"var(--color-primary-darkest)"},lime:{base:"#74b816",darker:"#66a80f",darkest:"#5c940d"},pink:{base:"#d6336c",darker:"#c2255c",darkest:"#a61e4d"}},$E=({children:e,color:n})=>ZU("div",{className:"Card",style:{"--card-color":ZE[n].base,"--card-color-darker":ZE[n].darker,"--card-color-darkest":ZE[n].darkest},children:e});import{Fragment as JU,jsx as Ln,jsxs as Lp}from"react/jsx-runtime";var qU=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return Ln("div",{className:"ExportDialog ExportDialog--json",children:Lp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Lp($E,{color:"lime",children:[Ln("div",{className:"Card-icon",children:Fx}),Ln("h2",{children:f("exportDialog.disk_title")}),Lp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!mi&&r.renderAction("changeProjectName")]}),Ln(K,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Vs,"ui")}})]}),l&&Lp($E,{color:"pink",children:[Ln("div",{className:"Card-icon",children:gs}),Ln("h2",{children:f("exportDialog.link_title")}),Ln("div",{className:"Card-details",children:f("exportDialog.link_details")}),Ln(K,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ne("export","link",`ui (${jU()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},YP=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=$U.useCallback(()=>{a({openDialog:null})},[a]);return Ln(JU,{children:n.openDialog?.name==="jsonExport"&&Ln(gn,{onCloseRequest:s,title:f("buttons.export"),children:Ln(qU,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import QU from"clsx";import{jsx as eW}from"react/jsx-runtime";var XP=e=>eW(K,{className:QU("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:Vn,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import QP from"clsx";import{useState as pW}from"react";import{CANVAS_SEARCH_TAB as uW,DEFAULT_SIDEBAR as hW,KEYS as Xl}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as tW,DEFAULT_SIDEBAR as nW}from"@excalidraw/common";import{isArrowElement as oW,isFlowchartNodeElement as rW,isImageElement as KP,isLinearElement as ZP,isLineElement as iW,isTextBindableContainer as aW,isTextElement as sW}from"@excalidraw/element";import{isNodeInFlowchart as lW}from"@excalidraw/element";import{jsx as jE}from"react/jsx-runtime";var xe=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,cW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===nW.name&&e.openSidebar.tab===tW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:xe("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(Jt(e))return f("hints.eraserRevert",{shortcut:xe("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:xe("Ctrl"),shortcut_2:xe("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:xe("Escape"),shortcut_2:xe("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:xe("A")}):f("hints.linearElement");if(r.type==="freedraw")return f("hints.freeDraw");if(r.type==="text")return f("hints.text");if(r.type==="embeddable")return f("hints.embeddable");if(r.type==="autoshape")return f("hints.autoshape");if(i&&s==="mouse"&&c.length===1){let d=c[0];return ZP(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:xe("Shift")}):KP(d)?f("hints.resizeImage",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")}):f("hints.resize",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:xe("Shift")});if(c.length===1&&sW(c[0]))return f("hints.text_selected",{shortcut:xe("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:xe("Escape"),shortcut_2:xe(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:xe("Enter"),shortcut_2:xe("Escape")});if(c.length===1&&KP(c[0]))return f("hints.enterCropEditor",{shortcut:xe("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:xe("CtrlOrCmd")});if(nr(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:xe("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:xe(f("keys.mmb")),shortcut_2:xe("Space")});if(c.length===1){if(ZP(c[0]))return oW(c[0])&&e.selectedLinearElement?.elementId===c[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===c[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:xe("Delete"),shortcut_2:xe(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")}):iW(c[0])?f("hints.lineEditor_line_info",{shortcut:xe("Enter")}):f("hints.lineEditor_info",{shortcut_1:xe("CtrlOrCmd"),shortcut_2:xe(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&aW(c[0])){let d=f("hints.bindTextToElement",{shortcut:xe("Enter")}),m=f("hints.createFlowchart",{shortcut:xe(["CtrlOrCmd","\u2191\u2193"])});return rW(c[0])?lW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},$P=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=cW({appState:e,isMobile:n,editorInterface:t,app:o});if(!r)return null;let a=(Array.isArray(r)?r.map(s=>s.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((s,l)=>{if(l%2===1){let c=s[0]==="<"&&s.match(/^<kbd>([^<]+)<\/kbd>$/);return jE("kbd",{children:c?c[1]:s},l)}return s});return jE("div",{className:"HintViewer",children:jE("span",{children:a})})};import dW from"clsx";import{jsx as mW}from"react/jsx-runtime";var jP=e=>mW(K,{className:dW("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?Ro:ao,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as ai,jsx as oe,jsxs as Io}from"react/jsx-runtime";var gW=(e,n)=>e==="image"&&n.tools?.image===!1,fW=({app:e,activeTool:n,type:t,shortcut:o})=>oe(de.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:We[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??Hi(t),disabled:$e(e,t),children:f(`toolBar.${t}`)}),qP=({app:e})=>oe(de.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Ro:ao,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:Xl.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),EW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=Ke("objectsSnapMode");return oe(de.Item,{onSelect:()=>e.executeAction(kt,"ui"),icon:Oo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},bW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=f("buttons.objectsSnapMode"),o=Ke("objectsSnapMode");return oe(K,{type:"toggle",icon:Oo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(kt,"ui")})},JP=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Ke("searchMenu");return oe(de.Item,{onSelect:()=>e.executeAction(ul,"ui"),icon:Yn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===hW.name&&n.openSidebar.tab===uW,shortcut:o,children:t})},xW=({app:e})=>oe(K,{type:"button",icon:yi,title:`${f("labels.eyeDropper")} - ${Xl.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":Xl.I.toLocaleUpperCase(),keyBindingLabel:Xl.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),wW=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=pW(!1),l=at()==="full",c=n.type==="frame",d=n.type==="autoshape",m=n.type==="laser",p=n.type==="bucketfill",u=l&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",E=n.type==="embeddable",g=r&&Fi.includes(n.type);return Io(de,{open:a,children:[oe(de.Trigger,{className:QP("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":g||c||E||!r&&l&&d||u||p||m&&!e.props.isCollaborating}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:g?We[n.type].icon:c?Wn:E?Bo:!r&&l&&d?Mr:m&&!e.props.isCollaborating?Vn:u?fi:p?Un:ds}),oe(de.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?Io(ai,{children:[l&&oe(de.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:fi,"data-testid":"toolbar-lasso",selected:u,disabled:$e(e,"lasso"),children:f("toolBar.lasso")}),Fi.filter(b=>!gW(b,o)).map(b=>oe(fW,{app:e,activeTool:n,type:b},b)),oe("div",{className:"App-toolbar__dropdown-divider"}),oe(JP,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe(ai,{children:oe(qP,{app:e})})]}):Io(ai,{children:[oe(de.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Wn,shortcut:Xl.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:$e(e,"frame"),children:f("toolBar.frame")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Bo,"data-testid":"toolbar-embeddable",selected:E,disabled:$e(e,"embeddable"),children:f("toolBar.embeddable")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Mr,shortcut:Hi("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:$e(e,"autoshape"),children:f("toolBar.autoshape")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Vn,"data-testid":"toolbar-laser",selected:m,disabled:$e(e,"laser"),children:f("toolBar.laser")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Un,"data-testid":"toolbar-bucketfill",selected:p,disabled:$e(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&oe(de.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:fi,"data-testid":"toolbar-lasso",selected:u,disabled:$e(e,"lasso"),children:f("toolBar.lasso")}),oe("div",{className:"App-toolbar__dropdown-divider"}),oe(EW,{actionManager:i,app:e}),oe(JP,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe(qP,{app:e})]})})]})},ek=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=ge(),c=at()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?oe(kd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?oe(Fw,{...m}):oe(Ow,{...m});return Io(He,{padding:1,className:QP("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[oe($P,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,Io(Dt.Row,{gap:c?.5:1,children:[!c&&oe(Na,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&Io(ai,{children:[oe(jP,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),oe("div",{className:"App-toolbar__divider"})]}),oe(Pd,{...m}),u,p?Io(ai,{children:[oe(Ns,{...m}),oe(Bs,{...m}),oe(xW,{app:e}),o.tools?.image!==!1&&oe(Os,{...m}),oe(Fs,{...m})]}):Io(ai,{children:[oe(Lw,{...m}),oe(Dw,{...m}),oe(_w,{...m}),oe(Rw,{...m}),oe(Nw,{...m}),c?oe(Md,{...m}):oe(Ns,{...m}),oe(Bs,{...m}),o.tools?.image!==!1&&oe(Os,{...m}),oe(Fs,{...m})]}),oe("div",{className:"App-toolbar__divider"}),oe(wW,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&Io(ai,{children:[oe("div",{className:"App-toolbar__divider"}),oe(bW,{actionManager:r,app:e})]})]})]})};import{Fragment as qE,jsx as ee,jsxs as $t}from"react/jsx-runtime";var PW=({UIOptions:e})=>$t(_t,{__fallback:!0,children:[ee(_t.DefaultItems.LoadScene,{}),ee(_t.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(_t.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(_t.DefaultItems.SaveAsImage,{}),ee(_t.DefaultItems.SearchMenu,{}),ee(_t.DefaultItems.Help,{}),ee(_t.Separator,{}),ee(_t.Group,{title:"Excalidraw links",children:ee(_t.DefaultItems.Socials,{})}),ee(_t.Separator,{}),ee(_t.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),ee(_t.DefaultItems.ChangeCanvasBackground,{})]}),kW=()=>$t(hp,{__fallback:!0,children:[ee(hp.Actions.SaveToDisk,{}),ee(hp.Actions.ExportToImage,{})]}),MW=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:y,zoomUIEnabled:w,scrollBackToContentUIEnabled:x,isCollaborating:v,generateLinkForSelection:T,currentUserControls:C})=>{let P=ge(),A=yn(),_=at()==="compact",k=_T(),D=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},O=k.tunnelsJotai.Provider,[Y,z]=ze(Bt),W=()=>p.canvasActions.export?ee(YP,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,Z=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:ee(IP,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),H=()=>$t("div",{style:{position:"relative"},children:[$t("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),ee(k.MainMenuTunnel.Out,{}),ee(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&ee(k.WelcomeScreenMenuHintTunnel.Out,{})]}),re=()=>ee(_l,{heading:"selectedShapeActions",className:Xa("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?ee(He,{className:Xa("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:ee(JT,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):ee(He,{className:vW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:ee(KT,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),B=()=>{let pe=y&&SW(n,r),he=y&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return ee(ip,{side:"top",children:$t("div",{className:"App-menu App-menu_top",children:[$t(Dt.Col,{gap:D.menuTopGap,className:Xa("App-menu_top__left"),children:[H(),y&&ee("div",{className:Xa("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:pe&&re()}),y&&_&&!n.viewModeEnabled&&pe&&ee(Na,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),y&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&ee(_l,{heading:"shapes",className:"shapes-section",children:ye=>$t("div",{style:{position:"relative"},children:[E&&ee(k.WelcomeScreenToolbarHintTunnel.Out,{}),ee(Dt.Col,{gap:D.toolbarColGap,align:"start",children:$t(Dt.Row,{gap:D.toolbarRowGap,className:Xa("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[ee(ek,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ye}),v&&ee(He,{style:{marginLeft:D.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ee(XP,{title:f("toolBar.laser"),checked:n.activeTool.type===tk.laser,onChange:()=>b.setActiveTool({type:tk.laser}),isMobile:!0})})]})})]})}),$t("div",{className:Xa("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[y&&n.collaborators.size>0&&ee(cp,{collaborators:n.collaborators,userToFollow:A.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),he&&ee(Gl,{app:b,onClose:()=>{e.executeAction(Qo)},renderCustomStats:m})]})]})})},U=()=>ee(KE,{}),ue=!1,we=$t(qE,{children:[g,y&&ee(qE,{children:ee(PW,{UIOptions:p})}),ee(kW,{}),y&&n.isLoading&&ee(ep,{delay:250}),y&&n.errorMessage&&ee(pP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),y&&Y&&P.formFactor!=="phone"&&ee(w0,{colorPickerType:Y.colorPickerType,onCancel:()=>{z(null)},onChange:(pe,he,ye,{altKey:ae})=>{if(!(pe!=="elementBackground"&&pe!=="elementStroke"))if(ye.length){for(let ve of ye)TW(ve,IW(r),{[ae&&Y.swapPreviewOnAlt?pe==="elementBackground"?"strokeColor":"backgroundColor":pe==="elementBackground"?"backgroundColor":"strokeColor"]:he}),CW.delete(ve);b.scene.triggerUpdate()}else o(pe==="elementBackground"?{currentItemBackgroundColor:he}:{currentItemStrokeColor:he})},onSelect:(pe,he)=>{z(ye=>ye?.keepOpenOnAlt&&he.altKey?ye:null),Y?.onSelect?.(pe,he)}}),n.openDialog?.name==="help"&&ee(fP,{onClose:()=>{o({openDialog:null})}}),y&&n.openDialog?.name==="elementLinkSelector"&&ee(mP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),ee(k.OverwriteConfirmDialogTunnel.Out,{}),Z(),W(),y&&n.openDialog?.name==="charts"&&ee(HS,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),P.formFactor==="phone"&&ee(kS,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:W,renderImageExportDialog:Z,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:U,renderWelcomeScreen:E,defaultUIEnabled:y,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&$t(qE,{children:[A.viewportStatusFrame?.border&&ee(qm,{border:A.viewportStatusFrame.border,style:ue?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),$t("div",{className:"layer-ui__wrapper",style:ue?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&ee(k.WelcomeScreenCenterTunnel.Out,{}),B(),ee(KS,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:y,zoomUIEnabled:w}),(n.toast||x&&n.scrolledOutside||A.viewportStatusFrame?.label)&&$t("div",{className:"floating-status-stack",children:[n.toast&&ee(_d,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&ee("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(pe=>({...ci(r,pe)}))},children:f("buttons.scrollBackToContent")}),A.viewportStatusFrame?.label&&ee(Jm,{label:A.viewportStatusFrame.label,border:A.viewportStatusFrame.border})]})]})]}),U()]});return ee(nh.Provider,{value:n,children:ee(O,{children:ee(Wf.Provider,{value:k,children:we})})})},nk=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:c,elementsToHighlight:d,...m}=e;return m},AW=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return Dp(nk(o),nk(a),{selectedElementIds:Dp,selectedGroupIds:Dp})&&Dp(r,s)},ok=yW.memo(MW,AW);import{useEffect as LW,useRef as DW}from"react";import{jsx as rk}from"react/jsx-runtime";var ik=({trails:e})=>{let n=DW(null);return LW(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),rk("div",{className:"SVGLayer",children:rk("svg",{ref:n})})};import _W,{useEffect as ak,useRef as sk}from"react";import{isShallowEqual as RW,sceneCoordsToViewportCoords as NW}from"@excalidraw/common";import{jsx as FW}from"react/jsx-runtime";var lk="animateInteractiveScene",BW=e=>{let n=sk(!1),t=sk(null);return ak(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Pf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),ak(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,s=new Map;e.appState.collaborators.forEach((c,d)=>{if(c.selectedElementIds)for(let m of Object.keys(c.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(d);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(d,c.username),c.userState&&s.set(d,c.userState),r.set(d,NW({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),o.set(d,c.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:o,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:s,selectionColor:l,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},rt.running(lk)||rt.start(lk,({deltaTime:c,state:d})=>{let m=Pf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),FW("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},ck=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,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,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,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,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),OW=(e,n)=>e.selectionNonce!==n.selectionNonce||e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements||e.selectedElements!==n.selectedElements||e.renderScrollbars!==n.renderScrollbars||e.interactionEnabled!==n.interactionEnabled||e.navigationEnabled!==n.navigationEnabled?!1:RW(ck(e.appState),ck(n.appState)),JE=_W.memo(BW,OW);import pk,{useEffect as _p,useRef as Kl}from"react";import{isShallowEqual as dk}from"@excalidraw/common";import{jsx as GW}from"react/jsx-runtime";var zW=e=>{let n=Kl(null),t=Kl(!1),o=Kl(e),r=Kl(()=>{}),i=Kl(null);o.current=e;let a=pk.useCallback(()=>{let s=o.current,l=n.current;if(!l)return;let c=getComputedStyle(l).getPropertyValue("--color-grid-bold").trim(),d=getComputedStyle(l).getPropertyValue("--color-grid-regular").trim();tx({canvas:s.canvas,rc:s.rc,scale:s.scale,elementsMap:s.elementsMap,allElementsMap:s.allElementsMap,visibleElements:s.visibleElements,appState:s.appState,renderConfig:{...s.renderConfig,gridColorBold:c,gridColorRegular:d}},pa());let m=s.renderConfig.imageTransitionDuration??0;m>0&&s.visibleElements.some(u=>{if(u.type!=="image"||!u.fileId)return!1;let E=s.renderConfig.imageCache.get(u.fileId)?.transitionStart;return E!==void 0&&performance.now()-E<m})&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,_p(()=>{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]),_p(()=>{let s=n.current;if(!s)return;let l=e.canvas;t.current||(t.current=!0,s.replaceChildren(l),l.classList.add("excalidraw__canvas","static")),a()}),_p(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),_p(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),GW("div",{className:"excalidraw__canvas-wrapper",ref:n})},mk=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,suggestedBinding:e.suggestedBinding}),HW=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:dk(mk(e.appState),mk(n.appState))&&dk(e.renderConfig,n.renderConfig),QE=pk.memo(zW,HW);import{useEffect as ZW,useRef as $W}from"react";import{throttleRAF as UW}from"@excalidraw/common";import{getTargetFrame as WW,isInvisiblySmallElement as VW,renderElement as YW,shouldApplyFrameClip as XW}from"@excalidraw/element";var uk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=bc(e,i),d=xc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(VW(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=WW(t,o,a);u&&XW(t,u,a,o)&&Qb(u,d,s,a)}YW(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},KW=UW(e=>{uk(e)}),hk=(e,n)=>{if(n){KW(e);return}uk(e)};import{jsx as qW}from"react/jsx-runtime";var jW=e=>{let n=$W(null);return ZW(()=>{n.current&&hk({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},pa())}),qW("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:n})},gk=jW;import JW from"clsx";import{useLayoutEffect as QW,useEffect as fk,useRef as eV,useState as tV}from"react";import{ARROW_TYPE as Ek,EVENT as Rp}from"@excalidraw/common";import{jsx as iV}from"react/jsx-runtime";var bk=700,nV=100,oV=16,rV=5*60*1e3,wk=qe(null),xk=e=>e===Ek.elbow?zo:e===Ek.round?Ho:Fo,Np=class{constructor(n){I(this,"app");I(this,"lastShownAt",0);I(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(wk,{content:n,nonce:Math.random()}))});I(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<rV);I(this,"onArrowTypeCycled",n=>{this.show(xk(n))});I(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?No:xk(this.app.state.currentItemArrowType))});this.app=n}},yk=()=>{let[e,n]=ze(wk),t=It(),{container:o}=De(),r=eV(null),[i,a]=tV(!1),s=e?.nonce;return QW(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=$c({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:oV});p.style.transform=`translate(${u}px, ${E}px)`};l(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let c=d=>{l(d.clientX,d.clientY)};return window.addEventListener(Rp.POINTER_MOVE,c),()=>{window.removeEventListener(Rp.POINTER_MOVE,c)}},[s,o,t]),fk(()=>()=>{n(null)},[n]),fk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},bk),c=window.setTimeout(()=>{n(null)},bk+nV),d=()=>{n(null)};return window.addEventListener(Rp.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Rp.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?iV("div",{ref:r,className:JW("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Bp=class{constructor(n){this.getState=n;I(this,"listeners",[]);I(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(n,t,o);return a?l&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),s)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:s}):l?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:d=>c(d),once:!0})})})}isStateChangePredicateOptions(n){return typeof n=="object"&&!Array.isArray(n)&&"predicate"in n}subscribe(n){return this.listeners.push(n),()=>{this.listeners=this.listeners.filter(t=>t!==n)}}normalize(n,t,o){let r,i,a=t,s=o?.once??!1,l=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:c,callback:d,once:m}=n;r=c,i=p=>p,a=d?(p,u)=>d(u):void 0,s=m??!1,l=c(this.getState())}else if(typeof n=="function"){let c=n;r=(d,m)=>c(d)!==c(m),i=d=>c(d)}else if(Array.isArray(n)){let c=n;r=(d,m)=>c.some(p=>d[p]!==m[p]),i=d=>d}else{let c=n;r=(d,m)=>d[c]!==m[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}flush(n){if(!this.listeners.length)return;let t=this.getState(),o=[];for(let r of this.listeners)r.predicate(t,n)?(r.callback(r.getValue(t),t),r.once||o.push(r)):o.push(r);this.listeners=o}clear(){this.listeners=[]}};import{getCommonBounds as aV,getElementsInGroup as sV,isNonDeletedElement as vk,selectGroupsFromGivenElements as lV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as cV}from"@excalidraw/common";import{flushSync as dV}from"react-dom";import{jsx as pV}from"react/jsx-runtime";var mV=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!vk(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&vk(t)?t:null,r=o?[o]:sV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=aV(r),{x:s,y:l}=cV({sceneX:i,sceneY:a},e.state);return pV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{dV(()=>{let c=lV(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(qs)},title:f("labels.elementLock.unlock"),children:vx})},Ik=mV;import{Fragment as dX,jsx as Te,jsxs as yb}from"react/jsx-runtime";var DM=En.createContext(null),_M=En.createContext(null),vb={formFactor:"desktop",desktopUIMode:"full",userAgent:AM(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Tb=En.createContext(vb);Tb.displayName="EditorInterfaceContext";var sX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Sb=En.createContext({container:null,id:null});Sb.displayName="ExcalidrawContainerContext";var Cb=En.createContext([]);Cb.displayName="ExcalidrawElementsContext";var Pb=En.createContext({..._o(),width:0,height:0,offsetLeft:0,offsetTop:0});Pb.displayName="ExcalidrawAppStateContext";var kb=En.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});kb.displayName="ExcalidrawSetAppStateContext";var Mb=En.createContext(null);Mb.displayName="ExcalidrawActionManagerContext";var es=En.createContext(null);es.displayName="ExcalidrawAPIContext";var Qp=En.createContext(null);Qp.displayName="ExcalidrawAPISetContext";var It=()=>Mo(DM),yn=()=>Mo(_M),ge=()=>Mo(Tb),at=()=>Jp(ge()),De=()=>Mo(Sb),Ci=()=>Mo(Cb),Xo=()=>Mo(Pb),Be=()=>Mo(kb),nt=()=>Mo(Mb),Ed=()=>Mo(es),oc=!1,rc=0,ic=null,Po=!1,Zp=!1,ko=!1,$p=!1,ac={horizontal:null,vertical:null},xr=0,sc=!1,wb=new Map,lX=4,jp=!1,qp=0,PM=!1,Qa=null,le={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Ib=class e extends En.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"sessionExportThemeOverride");I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"editorInterface",vb);I(this,"stylesPanelMode",Jp(vb));I(this,"excalidrawContainerRef",En.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"hasRenderableElements",!1);I(this,"resizeObserver");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"imageLoadingProgress",new Map);I(this,"imageLoadingProgressEmitter",new eo);I(this,"imageStatus",new Map);I(this,"imageStatusEmitter",new eo);I(this,"imagePlaceholderUpdateEmitter",new eo);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"elementsPendingErasure",new Set);I(this,"_initialized",!1);I(this,"editorLifecycleEvents",new UV(sX));I(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));I(this,"appStateObserver",new Bp(()=>this.state));I(this,"onStateChange",this.appStateObserver.onStateChange);I(this,"bucketFill",new Um(this));I(this,"flowchart",new Km(this));I(this,"cursor",new Wm(this));I(this,"zDragZoom",null);I(this,"arrowText",new Gm(this));I(this,"viewport",new $m(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>le.pointers.size>=2||ko}));I(this,"bindModeHandler",null);I(this,"textWysiwygSubmitHandler",null);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerUpIsDoubleClick",!1);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastCompletedCanvasClicks",[]);I(this,"previousPointerMoveCoords",null);I(this,"drawShape",new Xm(this));I(this,"laserTrails",new bm(this));I(this,"eraserTrail",new Sm(this));I(this,"lassoTrail",new Tm(this));I(this,"cursorHints",new Np(this));I(this,"onChangeEmitter",new eo);I(this,"onPointerDownEmitter",new eo);I(this,"onPointerUpEmitter",new eo);I(this,"onUserFollowEmitter",new eo);I(this,"onScrollChangeEmitter",new eo);I(this,"missingPointerEventCleanupEmitter",new eo);I(this,"onRemoveEventListenersEmitter",new eo);I(this,"api");I(this,"isToolSupported",(t,o=this.props)=>{if(t==="magicframe"||o.UIOptions.tools?.[t]===!1)return!1;if(this.isInteractionEnabled(o))return!0;let r=typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.tools:void 0;return t==="laser"?r?.laser===!0:t==="custom"?r?.custom===!0:!1});I(this,"updateEditorAtom",(t,...o)=>{let r=gt.set(t,...o);return this.triggerRender(),r});I(this,"previousHoveredBindableElement",null);I(this,"getEffectiveGridSize",()=>nr(this)?this.state.gridSize:null);I(this,"getTextCreationGridPoint",(t,o)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(o)}});I(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&tc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Pe.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));I(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=Rk);I(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),Ja.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Co(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=db(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else lb(r)&&t.add(r.id);return!1}),o&&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 o=this.frameNameBoundsCache._cache.get(t.id);if(!o||o.zoom!==this.state.zoom.value||o.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Ce({clientX:i.x,clientY:i.y},this.state),s=Ce({clientX:i.right,clientY:i.bottom},this.state);return o={x:a.x,y:a.y,width:s.x-a.x,height:s.y-a.y,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_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===jl.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&vt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!Jk(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:s}=Hp({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=CY(i);if(i.id===this.state.editingFrame){let m=d;c=Te("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===X.ESCAPE||p.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:GV(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${To.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?To.nameColorDarkTheme:To.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Te("div",{id:this.getFrameNameDOMId(i),className:sb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+To.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:To.nameFontSize,color:t?To.nameColorDarkTheme:To.nameColorLightTheme,lineHeight:To.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:Pe.MOVE,pointerEvents:this.state.viewModeEnabled?Za.disabled:Za.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},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,o,r)=>{Ne("export",t,"ui");let i=await Fr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(zV).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&yc(i)&&this.setState({fileHandle:i})});I(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Bt,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:qt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:qt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?no(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:qt.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Ye(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||jl.LIGHT,s=t?.appState?.name??this.state.name,l=t?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),r=t.appState?.editingTextElement||null,t.elements&&r){let c=r.id,d=t.elements.find(m=>m.id===c);r=d&&Kp(d)&&Wt(d)?d:null}this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:s,errorMessage:l}}),o=!0}o||this.scene.triggerUpdate()}));I(this,"scheduleCapture",()=>this.store.scheduleCapture());I(this,"onBlur",Ye(()=>{Po=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"preventBrowserZoomWheel",t=>{t[X.CTRL_OR_CMD]&&t.preventDefault()});I(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});I(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==X.PAGE_UP&&t.key!==X.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===X.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});I(this,"preventBrowserZoomKeyDown",t=>{t[X.CTRL_OR_CMD]&&(t.code===fr.EQUAL||t.code===fr.MINUS||t.code===fr.ZERO||t.code===fr.NUM_ADD||t.code===fr.NUM_SUBTRACT||t.code===fr.NUM_ZERO)&&t.preventDefault()});I(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Po=!1,Zp=!1,ko=!1,$p=!1,Qa=null,le.pointers.clear(),le.lastCenter=null,le.initialDistance=null,le.initialScale=null,clearTimeout(rc),rc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(qp),qp=0,jp=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),gt.set(Bt,null),gt.set(jn,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&vt(t)?t:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:"up",bindMode:"orbit",activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())});I(this,"handleInteractionStateChange",(t,o)=>{let r=this.isInteractionEnabled(t),i=r!==this.isInteractionEnabled(),a=t.viewModeEnabled!==this.props.viewModeEnabled,s=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(s=!!this.props.viewModeEnabled):s=!0,s!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:s});let l=r&&!o.viewModeEnabled,c=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||l&&!c)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,Qd(),this.cursor.reset())),this.isEmbedsEnabled(t)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(o.activeTool.type,t)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!=="selection"&&this.setState({activeTool:jt(this.state,{type:"selection"})}),(this.isBrowserZoomEnabled(t)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(t)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),o.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())});I(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));I(this,"handleForcedToolChange",(t,o)=>{let r=this.props.activeTool;if(!r)return;let i=!this.isSameForcedTool(t.activeTool,r);if(r.type==="image"){i&&console.warn('"image" tool cannot be forced via "props.activeTool"');return}this.isSameForcedTool(r,this.state.activeTool)||(i||o.activeTool!==this.state.activeTool||this.isToolSupported(r.type,t)!==this.isToolSupported(r.type,this.props))&&this.setActiveTool(r)});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Ye(t=>{this.scene.replaceAllElements([]),this.setState(o=>({..._o(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async l=>{if(!l.files.length)return;let c=l.files[0],d=await c.getFile();this.loadFileToCanvas(new File([d],d.name||"",{type:d.type}),c)}),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}catch(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let o=Tr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=pi(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,viewModeOnly:this.props.viewModeOnly||r.viewModeOnly,viewModeEnabled:this.props.viewModeOnly||this.props.viewModeEnabled||r.viewModeEnabled,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast};let a={...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},s=this.props.initialState?.viewport;if(s){let l=o.filter(m=>!m.isDeleted),c=Ql(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...ci(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:qt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),cM(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});I(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??XV(t,o));I(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=jV(),a=AM(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:IV,l=ab(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>s,isLandscape:o>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});I(this,"reconcileStylesPanelMode",t=>{let o=Jp(t);if(o===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=o,this.viewport.invalidateUIOffset("stylesPanel"),r!=="full"&&o==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});I(this,"setDesktopUIMode",t=>{let o=qV(t);this.editorInterface=ab(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});I(this,"onResize",Ye(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Ja.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(ac=t),this.scheduleImageRefresh()});I(this,"onScroll",Ok(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},TV));I(this,"onCut",Ye(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||ql(t.target)||(this.actionManager.executeAction($d,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Ye(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||ql(t.target)||(this.actionManager.executeAction($i,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(KV&&t.preventDefault(),!oc){oc=!0,t.touches.length===1&&(ic={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(rc),rc=window.setTimeout(e.resetTapTwice,Rk);return}if(oc&&t.touches.length===1&&ic){let o=t.touches[0];Qn(ne(o.clientX,o.clientY),ne(ic.x,ic.y))<=Gk&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),oc=!1,clearTimeout(rc)}t.touches.length===2&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null})}});I(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}):le.pointers.clear())});I(this,"pasteFromClipboard",Ye(async t=>{if(!this.isInteractionEnabled())return;let o=!!jp,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||ql(r)))return;let s=await Br(t),l=s.getFiles(),c=await Fd(s,o);if(this.state.viewModeEnabled){if(!this.containsImagePaste(c,l,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:l.map(d=>d.file),data:c,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let o=Tr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=ja(o),l=$a(r,a)/2,c=$a(i,s)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Ce({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,y]=Ct(E,g,this.getEffectiveGridSize()),{duplicatedElements:w}=Zk({type:"everything",elements:o.map(A=>no(A,{x:A.x+b-r,y:A.y+y-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),v=[...x,...w];v=this.props.onDuplicate?.(v,x)||v,uM(v,Ql(w));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let A=PY(w,C);v=hb(v,A,C)}this.scene.replaceAllElements(v),w.forEach(A=>{if(Wt(A)&&jk(A)){let L=oM(A,this.scene.getElementsMapIncludingDeleted());xY(A,L,this.scene)}}),$V&&io.loadElementsFonts(w).then(A=>{this.fonts.onLoaded(A)}),t.files&&this.addMissingFiles(t.files);let P=WY(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&>.get(XE)?this.state.openSidebar:null,...hM(P,this.scene.getNonDeletedElements(),this.state)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t.fit&&this.viewport.setViewport({target:w,fit:t.fit,animation:!1,offsets:{ui:!0}})});I(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});I(this,"setAppState",(t,o)=>{let r=a=>!a||!this.state.viewModeOnly?a:{...a,viewModeOnly:!0,viewModeEnabled:!0},i=typeof t=="function"?(a,s)=>r(t(a,s)):r(t);this.setState(i,o)});I(this,"removePointer",t=>{xr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=le.pointers.size>=2;le.pointers.delete(t.pointerId),o&&le.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});I(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Ne("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...jt(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});I(this,"updateFrameRendering",t=>{this.setState(o=>{let r=typeof t=="function"?t(o.frameRendering):t;return{frameRendering:{enabled:r?.enabled??o.frameRendering.enabled,clip:r?.clip??o.frameRendering.clip,name:r?.name??o.frameRendering.name,outline:r?.outline??o.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});I(this,"revealIfHidden",t=>{!t.length||hY(t,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.viewport.getOffsets())||this.viewport.setViewport({target:ja(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});I(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:Fn(t.zoom)},shouldCacheIgnoreZoom:!1})});I(this,"scrollToContent",(t,o)=>{this.viewport.setViewport({target:t??this.scene.getNonDeletedElements(),fit:o?.fitToViewport?"contain":"scale-down",animation:o?.animate?{duration:o.duration??500}:!1,offsets:{ui:!0}})});I(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});I(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});I(this,"setToast",t=>{this.setState({toast:t})});I(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),o=await t.match("shared-file");if(o){let r=await o.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,fV,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Ye(t=>{let o=new Map;for(let s of t){let l=s.id,c=this.imageCache.get(l);c&&!this.files[l]&&o.set(l,Promise.resolve(c.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());nM({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files}).then(async({updatedFiles:s})=>{for(let[l,c]of o){let d=this.imageCache.get(l);!d||!s.has(l)||(this.imageCache.set(l,{...d,placeholderImage:await c,transitionStart:performance.now()}),this.clearImageLoadingProgress(l))}i.size&&this.imagePlaceholderUpdateEmitter.trigger()}),i.size||this.addNewImagesToImageCache()}));I(this,"addImageElementsToScene",async(t,o,r)=>{let i=await Promise.all(t.map(async({file:s,customData:l})=>({file:await Sr(s),customData:l??{}}))),a=i.find(({file:s})=>!ui(s));if(a)throw new mu(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:s})=>s),o,r,i.map(({customData:s})=>s))});I(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await Sr(o);if(!ui(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((l,c)=>{i.onload=()=>l(i),i.onerror=()=>c(new Error(f("errors.imageInsertError")))}),s={image:a,mimeType:r.type,isPlaceholder:!0};this.imageCache.set(t,s),i.src=await vc(r);try{let l=await a;if(this.imageCache.get(t)!==s||this.files[t])return;this.imageCache.set(t,{...s,image:l}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(l){throw this.imageCache.get(t)===s&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),l}});I(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=Zl(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});I(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});I(this,"setUploadProgress",(t,o,r)=>{if(o===null){this.updateImageStatus(t,i=>({...i,uploadProgress:null}));return}typeof o=="number"&&!Number.isFinite(o)||this.updateImageStatus(t,i=>{let a=i?.uploadProgress??void 0,s=r===void 0?a:r??void 0,l=typeof o=="number";return{...i,uploadProgress:{...s,state:l?"uploading":o,...l?{progress:Zl(o,0,1)}:{progress:void 0}}}})});I(this,"updateImageStatus",(t,o)=>{let r=this.imageStatus.get(t),i=o(r);this.areImageStatusesEqual(r,i)||(i.downloadError===void 0&&!i.uploadProgress?this.imageStatus.delete(t):this.imageStatus.set(t,i),this.imageStatusEmitter.trigger())});I(this,"areImageStatusesEqual",(t,o)=>!!t?.downloadError==!!o?.downloadError&&!!t?.uploadProgress==!!o?.uploadProgress&&t?.downloadError?.backgroundColor===o?.downloadError?.backgroundColor&&t?.downloadError?.color===o?.downloadError?.color&&t?.downloadError?.trackColor===o?.downloadError?.trackColor&&t?.downloadError?.text===o?.downloadError?.text&&t?.downloadError?.onClick===o?.downloadError?.onClick&&t?.uploadProgress?.backgroundColor===o?.uploadProgress?.backgroundColor&&t?.uploadProgress?.color===o?.uploadProgress?.color&&t?.uploadProgress?.trackColor===o?.uploadProgress?.trackColor&&t?.uploadProgress?.state===o?.uploadProgress?.state&&t?.uploadProgress?.text===o?.uploadProgress?.text&&t?.uploadProgress?.onClick===o?.uploadProgress?.onClick&&t?.uploadProgress?.progress===o?.uploadProgress?.progress);I(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});I(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())qa(o)&&o.fileId===t&&Ja.delete(o)});I(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let s of a)if(!r[s.id]&&(i[s.id]=s,r[s.id]=s,s.mimeType===Ka.svg))try{let l=sx(tM(lx(s.dataURL)),Ka.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});I(this,"updateScene",Ye(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?QV({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}r&&this.setState(r),o&&this.scene.replaceAllElements(o),i&&(this.laserTrails.updateCollabTrails(i),this.setState({collaborators:i}))}));I(this,"applyDeltas",(t,o)=>{let r=wM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return wM.applyTo(r,a,i,o)});I(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:o,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===o?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&o&&(a.tab=o),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Ye(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));I(this,"onKeyDown",Ye(t=>{if(!this.isInteractionEnabled())return;if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(l,c){let d=l[c];return typeof d=="function"?d.bind(l):c==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():d}})),!Fk(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=se(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Rn(l[0])&&t.key===X.ENTER){this.startImageCropping(l[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom(jn,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(sb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Hm(l);gt.get(jn)?.type==="panel"&&Ff(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(jn,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(jp=t.shiftKey,clearTimeout(qp),qp=window.setTimeout(()=>{jp=!1},100)),t[X.CTRL_OR_CMD]&&ql(t.target)&&(t.code===fr.MINUS||t.code===fr.EQUAL)){t.preventDefault();return}if(ql(t.target)&&t.key!==X.ESCAPE||nb(t.key)&&Fk(t.target))return;if(t.key===X.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===X.E&&t.shiftKey&&t[X.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===X.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else So("COMPLEX_BINDINGS")?this.handleSkipBindMode():Xp({app:this,event:t});if(this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===X.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=Aw(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!Uk(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&Ne("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===Er.sharp?Er.round:this.state.currentItemArrowType===Er.round?Er.elbow:Er.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),t.stopPropagation();return}else if(t.key===X.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[X.CTRL_OR_CMD]&&!t.repeat&&(So("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Rt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Xp({app:this,event:t})),nb(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>oo(u)).filter(u=>{let E=u.startBinding&&!l.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!l.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>c.add(u.id)),l=l.filter(u=>!c.has(u.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?_k:this.getEffectiveGridSize())||(t.shiftKey?wV:_k),m=0,p=0;t.key===X.ARROW_LEFT?m=-d:t.key===X.ARROW_RIGHT?m=d:t.key===X.ARROW_UP?p=-d:t.key===X.ARROW_DOWN&&(p=d),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),Wp(u,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===X.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let c=l[0];if(t[X.CTRL_OR_CMD]||Eb(c))Nt(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Ut(c)||this.actionManager.executeAction(aa));else if(Wt(c)||rM(c)){let d;Wt(c)||(d=c);let m=pb(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else vt(c)&&this.setState({editingFrame:c.id})}}if(t.key===X.SPACE&&le.pointers.size===0&&(Po=!0,this.cursor.set(Pe.GRAB),t.preventDefault()),t.key.toLowerCase()===X.Z&&!t[X.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(Zp=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===X.G||t.key===X.S)&&!t.altKey&&!t[X.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===X.G&&(Do(this.state.activeTool.type)||l.some(c=>Do(c.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===X.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[X.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===X.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(c=>Wt(c)||mb(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===X.I&&!t.shiftKey&&!t[X.CTRL_OR_CMD],a=r===X.S&&t.shiftKey&&!t[X.CTRL_OR_CMD]||i,s=r===X.I&&t.shiftKey&&!t[X.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));I(this,"onKeyUp",Ye(t=>{if(this.isInteractionEnabled()){if(t.key===X.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Pe.GRAB):Gp(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Po=!1),t.key.toLowerCase()===X.Z&&(Zp=!1,this.cursor.reset()),t.key===X.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Xp({app:this,event:t})),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!Up(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&So("COMPLEX_BINDINGS"))){let o=Ce({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=br(ne(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=me.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());oo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Rt(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),Xp({app:this,event:t})}if(nb(t.key)){Vk(this.scene.getSelectedElements(this.state).filter(ec),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(bb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...vM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...vM(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));I(this,"setActiveTool",(t,o={})=>{let{keepSelection:r=!1}=o;if(!this.isToolSupported(t.type)){console.warn(this.isInteractionEnabled()?`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`:`"${t.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,t)){console.warn(`"${t.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(mt);let i=zi.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?jt(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?jt(this.state,{...t,lastActiveTool:this.state.activeTool}):jt(this.state,t);s.type==="hand"?this.cursor.set(Pe.GRAB):Po||this.cursor.applyForTool(s),BV(document.activeElement)&&this.focusContainer(),mY(s.type)||this.setState({suggestedBinding:null}),s.type==="image"&&this.onImageToolbarButtonClick(),this.setState(l=>{let c={snapLines:l.snapLines.length?[]:l.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:Gp(s.type)?l.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return s.type==="freedraw"&&this.store.scheduleCapture(),s.type==="lasso"?{...l,...c,activeTool:s,...r?{}:{selectedElementIds:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"isTouchScreenMultiTouchGesture",()=>le.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${zk()}`);I(this,"onGestureStart",Ye(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null}),le.initialScale=this.state.zoom.value)}));I(this,"onGestureChange",Ye(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=le.initialScale;o&&this.viewport.translate(r=>({...ro({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Fn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));I(this,"onGestureEnd",Ye(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}),le.initialScale=null)}));I(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=CM(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&P2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});I(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=CM(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(Wg,"ui",r),this.cursor.reset(),!0)});I(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s,arrowEndpoint:l})=>{let c=!1,d=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));d&&(i=null,r=!1,t=d.anchor[0],o=d.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(mb(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||Bk(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!ec(i)){let C=NY(rb({fontSize:g,fontFamily:u}),E),P=BY(g,E),A=Math.max(i.height,P),L=Math.max(i.width,C);this.scene.mutateElement(i,{height:A,width:L}),t=i.x+L/2,o=i.y+A/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),y=d?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-mM(g,E)/2:b.y},w=this.getTopLayerFrameAtSceneCoords({x:y.x,y:y.y}),x=w&&(!c||!i||i.frameId===w.id)?w.id:null,v=p||Xk({x:y.x,y:y.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:g,fontFamily:u,textAlign:d?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(m?PV.MIDDLE:Lk),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?ec(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:v.id})}),this.setState({editingTextElement:v}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([v],T+1)}else this.insertNewElement(v);l&&d&&this.arrowText.bindText(l,v,d.fixedPoint),a||p||i?this.handleTextWysiwyg(v,{isExistingElement:!!p,initialCaretSceneCoords:p?s:null}):this.setState({newElement:v,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,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[o,r]=this.lastCompletedCanvasClicks;return Qn(ne(o.x,o.y),ne(r.x,r.y))<=Gk});I(this,"handleCanvasDoubleClick",t=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!=="autoshape")return;let o=this.scene.getSelectedElements(this.state),{x:r,y:i}=Ce(t,this.state);if(o.length===1&&Nt(o[0])){let s=o[0];if((t[X.CTRL_OR_CMD]&&bb(s)||Eb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(aa);return}else if(this.state.selectedLinearElement&&Ut(o[0])){let l=me.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),me.deleteFixedSegment(o[0],this.scene,c);let d=me.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&Eb(s))return}if(o.length===1&&Rn(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),GY(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&HY(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,...Nn({editingGroupId:l,selectedElementIds:{[s.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let s=this.getElementAtPosition(r,i);if(tc(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let l=!t[X.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(l&&(this.state.activeTool.type==="autoshape"||$k(l)||!FV(l.backgroundColor)||nc({point:ne(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=pb(l,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});I(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==Dn.MAIN){this.lastCompletedCanvasClicks=[];return}let o=Ce(t,this.state),r=this.getImageStatusActionAtPosition(o);if(r){t.preventDefault(),t.stopPropagation(),r();return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});I(this,"getImageStatusActionAtPosition",t=>{if(!this.imageStatus.size)return null;let o=this.scene.getNonDeletedElementsMap(),r=this.visibleElements.length?this.visibleElements:this.scene.getNonDeletedElements();for(let i=r.length-1;i>=0;i--){let a=r[i];if(!Rn(a)||!a.fileId)continue;let s=this.imageStatus.get(a.fileId),l=s?.uploadProgress?.onClick;if(l&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>l(a.fileId);let c=s?.downloadError?.onClick;if(c&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>c(a.fileId)}return null});I(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Il(o,r,this.state,i);return!!a&&Qn(ne(t.x,t.y),ne(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});I(this,"getElementLinkAtPosition",(t,o)=>{if(o&&o.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let s=r[a];if(o&&s.id===o.id&&(i=a),s.link&&a>=i&&Ec(s,this.scene.getNonDeletedElementsMap(),this.state,ne(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});I(this,"getElementLinkAtPositionForContextMenu",(t,o)=>{let r=this.getElementLinkAtPosition(t,o);if(r)return r;let i=this.scene.getNonDeletedElementsMap();for(let a of this.scene.getNonDeletedElements().slice().reverse())if(a.link&&!a.locked&&Jb(a,i,this.state,ne(t.x,t.y)))return a});I(this,"handleElementLinkClick",t=>{let o=d=>d===Dn.MAIN||d===Dn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=Qn(ne(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ne(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>Dk)return;let i=Ce(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=Ec(this.hitLinkElement,a,this.state,ne(i.x,i.y),this.editorInterface.formFactor==="phone"),l=Ce(this.lastPointerUpEvent,this.state),c=Ec(this.hitLinkElement,a,this.state,ne(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(Qd(),this.openElementLink(this.hitLinkElement,t))});I(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=zp(r);let i;if(this.props.onLinkOpen&&o&&(i=OV(J.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=_V(r)?"_self":"_blank",s=window.open(void 0,a);s&&(s.opener=null,s.location=r)}});I(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Pe.POINTER),tv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(Qd(),!1));I(this,"maybeHandleElementLinkClick",(t,o)=>{if(this.editorInterface.isTouchScreen){let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(o,r)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(t),!0):!1});I(this,"handleInteractiveContentPointerMove",t=>{let o=Ce(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});I(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Ce(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&aM(t,l,r));if(!i.length)return null;let a=i.at(-1),s=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(l=>!o?.excludeElementIds?.[l.id]);if(s){if(vt(s)&&!s.locked)return a;let l=this.scene.getElementIndex(s.id),c=this.scene.getElementIndex(a.id);if(l!==-1&&c!==-1&&l<=c)return a;let d=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return d||(s.frameId?i.find(m=>m.id===s.frameId)??null:null)}return a});I(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});I(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&iX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});I(this,"insertNewElements",t=>{if(!t.length)return;let o=[];for(let r of t){let i=o[o.length-1];i?.[0].frameId===r.frameId?i.push(r):o.push([r])}for(let r of o){let i=r[0].frameId,a=i?yY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});I(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&vt(o)?o:null)});I(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=Fn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...ro({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});I(this,"handleCanvasPointerMove",t=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(t),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!ko&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Ce(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),Po||ko||$p||rs(this.state))return;let s=rf(ac,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?this.cursor.set(Pe.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Pe.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&I2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=v2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(y=>{let w=Jl(y.snapLines,b),x=y.originSnapOffset?Jl(y.originSnapOffset,g):g;return y.snapLines===w&&y.originSnapOffset===x?null:{snapLines:w,originSnapOffset:x}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let g=this.state.newElement?null:me.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Rt(()=>{this.setState({selectedLinearElement:g})})}if(dY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&Up(this.state)){let b=ne(r,i),y=this.scene.getNonDeletedElementsMap(),w=br(b,this.scene.getNonDeletedElements(),y,SM(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:xb(b,w,y,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:b}=this.state,{x:y,y:w,points:x}=g,v=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),v===T)Qn(ne(r-y,i-w),v)>=ob?(this.store.scheduleCapture(),Rt(()=>{to(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length}}})}),this.scene.mutateElement(g,{points:[...x,ne(r-y,i-w)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Pe.POINTER);else if(x.length>2&&T&&Qn(ne(r-y,i-w),T)<ob){this.cursor.set(Pe.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let C=g.points.length-1;this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?[...new Set(b.selectedPointsIndices.map(P=>Math.min(P,C)))]:b.selectedPointsIndices,lastCommittedPoint:g.points[C],initialState:{...b.initialState,lastClickedPoint:C}}})}else{eM(x,this.state.zoom.value)&&this.cursor.set(Pe.POINTER);let C=this.scene.getNonDeletedElementsMap();if(bb(g)){let A=br(ne(r,i),this.scene.getNonDeletedElements(),C);So("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,A)}to(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=me.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);P&&this.setState(P)}return}if(this.state.activeTool.type==="arrow"&&!this.state.newElement){let g=ne(r,i),b=br(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),SM(this.state.zoom)),y=this.scene.getNonDeletedElementsMap();b&&!TM(g,b,y)&&this.setState({suggestedBinding:{element:b,midPoint:xb(g,b,y,this.state.zoom)}})}let l=!!t.buttons,c=this.state.activeTool.type==="laser";if(l||!c&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(Pe.POINTER);return}if(m.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(m.length===1&&Ut(m[0]))&&!(Nt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=fM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(gM(g));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=EM(ja(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(gM({transformHandleType:g}));return}}if(Jt(this.state))return;let p=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p;let E=this.arrowText.updateHoveredAnchor(o);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:o,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(o,p)),!this.applyElementLinkHoverAffordance()){if(c)return;u&&(u.link||Co(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?this.cursor.set(E?Pe.POINTER:Wt(u)?Pe.TEXT:Pe.CROSSHAIR):!t[X.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Pe.MOVE):this.state.viewModeEnabled?this.cursor.set(Pe.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Pe.AUTO):s?this.cursor.set(Pe.AUTO):!t[X.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Ut(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Pe.MOVE):this.cursor.set(Pe.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:Jl(g.hoveredElementIds,Nn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:Jl(g.hoveredElementIds,{})}))});I(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});I(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(sc=!0)});I(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),ko||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=Ce(t,this.state),{x:i,y:a}=r;this.lastPointerMoveCoords={x:i,y:a};let s=t.target;if(s.setPointerCapture&&s.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.state.activeTool.type!=="laser"&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(BE,null)),gt.get(jn)&&this.updateEditorAtom(jn,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),Zp){t.preventDefault(),this.focusContainer(),this.zDragZoom={origin:{clientX:t.clientX,clientY:t.clientY},initialZoom:this.state.zoom.value},this.setState({cursorButton:"down"});return}if(t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let g=this.state.newElement;this.updateScene({...g.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:ke(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,y)=>(b[y]=this.state.selectedElementIds[y],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?qt.EVENTUALLY:qt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=ab(this.editorInterface,{isTouchScreen:!0})),ko||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Dn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==_n.eraser){this.setState({activeTool:jt(this.state,{type:_n.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),y?.(),Jt(this.state)&&this.setState({activeTool:jt(this.state,{...this.state.activeTool.lastActiveTool||{type:_n.selection},lastActiveTool:null})})},b=be(window,J.POINTER_UP,g,{once:!0}),y;requestAnimationFrame(()=>{y=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Dn.MAIN&&t.button!==Dn.TOUCH&&t.button!==Dn.ERASER||le.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!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 g=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[X.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(w=>{let x={...w.selectedElementIds,[c.hit.element.id]:!0},v=[];Object.keys(w.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&v.push(P)});let T=c.hit.element;if(vt(T))ub(v,T.id).forEach(C=>{delete x[C.id]});else if(T.frameId)x[T.frameId]&&delete x[T.id];else{let C=T.groupIds,P=new Set(C.flatMap(A=>si(this.scene.getNonDeletedElements(),A)).filter(A=>vt(A)).map(A=>A.id));P.size>0&&v.forEach(A=>{A.frameId&&P.has(A.frameId)&&(delete x[A.id],A.groupIds.flatMap(L=>si(this.scene.getNonDeletedElements(),L)).forEach(L=>{delete x[L.id]}))})}return{...Nn({editingGroupId:w.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:T.link||Co(T)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===_n.frame||this.state.activeTool.type===_n.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(c):this.state.activeTool.type===_n.bucketfill?this.bucketFill.handlePointerDown(r):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(c),p=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),E=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(J.POINTER_MOVE,m),window.addEventListener(J.POINTER_UP,p),window.addEventListener(J.KEYDOWN,u),window.addEventListener(J.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});I(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(So("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let o=Ce({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(sc=!1,xr?sc=!0:xr=window.setTimeout(()=>{xr=0,sc||this.handleCanvasContextMenu(t)},CV))});I(this,"resetContextMenuTimer",()=>{clearTimeout(xr),xr=0,sc=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Qa?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(le.pointers.size<=1&&((t.button===Dn.WHEEL||t.button===Dn.MAIN&&Po||rs(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;ko=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let o=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);this.cursor.set(Pe.GRABBING);let{clientX:i,clientY:a}=t,s=fm(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!o&&(Math.abs(d)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(J.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(J.PASTE,p),window.removeEventListener(J.POINTER_UP,u)},100)};document.body.addEventListener(J.PASTE,p),window.addEventListener(J.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-m/this.state.zoom.value})}),l=Ye(Qa=()=>{Qa=null,ko=!1,Po||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,s),window.removeEventListener(J.POINTER_UP,l),window.removeEventListener(J.BLUR,l),s.flush()});return window.addEventListener(J.BLUR,l),window.addEventListener(J.POINTER_MOVE,s,{passive:!0}),window.addEventListener(J.POINTER_UP,l),!0});I(this,"updateMultiTouchGesture",t=>{le.pointers.has(t.pointerId)&&le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=le.initialScale;if(le.pointers.size===2&&le.lastCenter&&o&&le.initialDistance){let r=Yg(le.pointers),i=r.x-le.lastCenter.x,a=r.y-le.lastCenter.y;le.lastCenter=r;let s=Xg(Array.from(le.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/le.initialDistance,c=l?Fn(o*l):this.state.zoom.value;this.setState(d=>{let m=ro({viewportX:r.x,viewportY:r.y,nextZoom:c},d),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i/p,scrollY:m.scrollY+2*a/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else le.lastCenter=le.initialDistance=le.initialScale=null});I(this,"clearSelectionIfNotUsingSelection",()=>{Gp(this.state.activeTool.type)||this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,o)=>{if(Gp(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Ut(a[0])&&!(Nt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=fM(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType))}else a.length>1&&(o.resize.handleType=EM(ja(a),o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(o.resize.handleType)o.resize.isResizing=!0,o.resize.offset=ib(VY(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Nt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=YY(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=me.handlePointerDown(t,this,this.store,o.origin,p,this.scene);if(u.hitElement&&(o.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let E=this.scene.getNonDeletedElementsMap(),g=me.getElement(p.elementId,E);if(g&&oo(g)){let{hitFocusPoint:b,pointerOffset:y,arrowOtherEndpointInitialBinding:w}=nX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:y,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:w}}}),!1}}let s=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),l=s.filter(p=>!p.locked),c=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:s});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!l.some(p=>this.state.selectedElementIds[p.id])?o.hit.element=null:o.hit.element=o.hit.element??this.getElementAtPosition(o.origin.x,o.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(o.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&o.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),o.hit.element&&this.getElementLinkAtPosition({x:o.origin.x,y:o.origin.y},o.hit.element))return!1;o.hit.allHitElements=l;let d=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||d&&d?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?ke({[p.selectedLinearElement.elementId]:!0},this.state):ke({},p)}));else if(d!=null){if(t[X.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...zY(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!pM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),vt(d))ub(E,d.id).forEach(g=>{delete u[g.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let g=d.groupIds,b=new Set(g.flatMap(y=>si(this.scene.getNonDeletedElements(),y)).filter(y=>vt(y)).map(y=>y.id));b.size>0&&E.forEach(y=>{y.frameId&&b.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(w=>si(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{...Nn({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Co(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,o)=>{if(this.state.editingTextElement)return;let r=o.origin.x,i=o.origin.y;this.setState({hoveredArrowTextAnchor:null});let a=this.arrowText.getBindableEndpointAtPosition(r,i);if(a)this.startTextEditing({sceneX:r,sceneY:i,autoEdit:!1,arrowEndpoint:a});else{let s=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);$k(s)&&(l=s,r=s.x+s.width/2,i=s.y+s.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:jt(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});I(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Ct(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=nY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("freedraw"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:l,strokeOptions:{variability:c,streamline:t.pointerType!=="mouse"?bV:EV},locked:!1,frameId:s?s.id:null,points:[ne(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:ke(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});I(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=rY({type:"iframe",x:a,y:s,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("iframe"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.insertNewElement(l),l});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=Vp(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=Yk({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("embeddable"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:s.intrinsicSize.w,height:s.intrinsicSize.h,link:r});return this.insertNewElement(l),l});I(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return sY({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("image"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,customData:i,x:a-c/2,y:s-c/2,width:c,height:c})});I(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Rt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(to(a,"selectedLinearElement is expected to be set"),i.type==="line"&&eM(i.points,this.state.zoom.value)){Rt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(mt);return}if(Ut(i)&&i.points.length>1){this.actionManager.executeAction(mt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=Ce(t,this.state),{start:m,end:p}=oo(i)&&Up(this.state)?aX(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),d.x,d.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),E=m?.mode!=null&&p.mode!=null&&m.element.id===p.element.id&&!TM(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&Qn(ne(r.origin.x-s,r.origin.y-l),c)<ob;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(mt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(y=>({selectedElementIds:ke({...y.selectedElementIds,[i.id]:!0},y)})),this.cursor.set(Pe.POINTER)}else{let[i,a]=Ct(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?iY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Er.round?{type:Op.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Er.elbow,fixedSegments:this.state.currentItemArrowType===Er.elbow?[]:null}):lY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Op.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=ne(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=Up(this.state)?br(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[ne(0,0),ne(0,0)]}),this.insertNewElement(p),oo(p)&&qY(p,new Map([[0,{point:ne(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:Ak(t.nativeEvent)}),Rt(()=>{this.setState(b=>{let y=null,w=b.selectedElementIds;if(Nt(p)){y=new me(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;y={...y,selectedPointsIndices:[x],initialState:{...y.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:ne(r.origin.x,r.origin.y)}}}return w=this.isToolLocked()?b.selectedElementIds:ke({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&oo(p)?{element:g,midPoint:xb(u,g,E,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:y}})}),oo(p)&&So("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});I(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Ct(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},l;t==="embeddable"?l=Yk({type:"embeddable",...s}):l=aY({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});I(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Ct(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...To},s=o===_n.magicframe?oY(a):tY(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(oo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);Yp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);Yp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else cb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&Yp(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&Yp(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||jk(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,no(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});I(this,"initializeImage",async(t,o)=>{if(!ui(o))throw new Error(f("errors.unsupportedFileType"));if(this.cursor.set("wait"),o.type===Ka.svg)try{o=gu(tM(await o.text()),o.name)}catch(l){throw console.warn(l),new Error(f("errors.svgImageInsertError"))}else{let{maxWidthOrHeight:l}=this.props.imageOptions;try{o=await(this.props.compressImageFile??cx)(o,{maxWidthOrHeight:l})}catch(c){console.error("Error trying to resize image file on insertion",c)}}let r=o.type,i=await(this.props.generateIdForFile?.(o)||ax(o));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[i]?.dataURL){let{maxFileSizeBytes:l}=this.props.imageOptions;if(o.size>l)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(l/1024/1024)}MB`}))}let s=this.files[i]?.dataURL||await vc(o);return new Promise(async(l,c)=>{try{let d=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:s,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:u}=await this.updateImageCache([d]);if(u.size)throw new Error("Image cache update resulted with an error.")}let m=await this.imageCache.get(i)?.image,p=m?gY(m):null;if(m&&this.state.newElement?.id!==d.id){d=this.getLatestInitializedImageElement(t,i);let u=this.getImageNaturalDimensions(d,m);Object.assign(d,u)}d=no(d,{fileName:o.name,thumbHash:p,status:"saved"}),this.files={...this.files,[i]:{...this.files[i],fileName:o.name,thumbHash:p??void 0}},l(d)}catch(d){console.error(d),c(new Error(f("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return no(r,{fileId:o})});I(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Ce({clientX:t,clientY:o},this.state),a=await jb({description:"Image",extensions:Object.keys(yV),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:jt(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(mt)})}});I(this,"getImageNaturalDimensions",(t,o)=>{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(o.naturalHeight,i),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;return{x:l,y:c,width:s,height:a,crop:null}});I(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let s of t){let l=this.imageCache.get(s.fileId);l&&r.set(s.fileId,Promise.resolve(l.image))}let{updatedFiles:i,erroredFiles:a}=await nM({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(qt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(qa(s)){if(a.has(s.fileId))return no(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return no(s,{status:"saved"})}return s}))),{updatedFiles:i,erroredFiles:a}});I(this,"addNewImagesToImageCache",async(t=bY(this.scene.getNonDeletedElements()),o=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,o);if(i.size)for(let a of r)i.has(a.fileId)&&Ja.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",uV(()=>{this.addNewImagesToImageCache()},vV));I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(J.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(J.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(J.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(J.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=yM(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(s);let l=await Promise.all(s.map(async(u,E)=>{try{return await this.initializeImage(u,await Sr(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),no(u,{isDeleted:!0})}})),c=Ql(l),d=yM(l.filter(u=>!u.isDeleted),o,r,a),m=Ql(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:ke(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:qt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(mt)})});I(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Ce(t,this.state),i=zh(t),a=await Br(t),s=a.getFiles(),l=s.map(d=>d.file).filter(d=>ui(d));if(this.state.viewModeEnabled)return l.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:l,event:t})?void 0:this.insertImages(l,o,r,Od(a,l.length,i));if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===Ka.png||d.type===Ka.svg))try{let p=await ls(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:qt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,Od(a,l.length,i));if(s.length>0){let{file:d,fileHandle:m}=s[0];d&&await this.loadFileToCanvas(d,m)}let c=a.findByType(Ka.text);if(c){let d=c.value;if(d&&db(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||Vp(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:zp(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,o)=>{t=await Sr(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await ls(t,this.state,r,o)}catch(a){let s=a instanceof $b;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let l=s?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;LM(r.concat(i.elements)),this.store.scheduleMicroAction({action:qt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:qt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Dn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Ce(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,s=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},s),c=l&&s.length===1&&s[0].link?s[0]:void 0,d=i??a??c,m=d||l?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;Ne("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Nn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Nt(d)?new me(d,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,d)}})})});I(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){bM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:$a(t.origin.x,a.x),height:$a(t.origin.y,a.y),shouldMaintainAspectRatio:$l(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s||this.arrowText.maybeDragNewText(s,a))return;let[l,c]=Ct(a.x,a.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=qa(s)&&this.imageCache.get(s.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:p,snapLines:u}=y2(s,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:l-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());l+=p.x,c+=p.y,this.setState({snapLines:u}),oo(s)||bM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:$a(t.originInGrid.x,l),height:$a(t.originInGrid.y,c),shouldMaintainAspectRatio:Rn(s)?!$l(o):$l(o),shouldResizeFromCenter:Mk(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===_n.frame||this.state.activeTool.type===_n.magicframe)&&this.setState({elementsToHighlight:gb(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=Ct(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Rn(l)){let c=t.originalElements.get(l.id),d=qa(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Rn(c)&&d&&!(d instanceof Promise)){let[m,p]=Ct(i.x,i.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=jg([l],[c],this,o,u,r);this.scene.mutateElement(l,LY(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),Wp(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});I(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(vt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Ut(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Ct(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{ub(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=Ct(s.x,s.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=jg(r,se(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(XY(t.originalElements,a,r,this.scene,Ak(o),Mk(o),r.some(m=>Rn(m))?!$l(o):$l(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{gb(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{Kp(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});I(this,"getImageContextMenuItems",t=>{let o=this.props.imageContextMenuItems;if(!o)return[];let r=this.scene.getSelectedElements(this.state);return r.length>0&&r.every(i=>Rn(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Rn(t)?[...o([t.id])]:[]});I(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Rn(r))&&(!t||this.state.selectedElementIds[t.id])?[jh,qh]:[]});I(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=zp(t.link),r=cM(o);return[{key:"goToLink",label:r?f("labels.link.goToElement"):"Go to link",onSelect:()=>this.openElementLink(t)},!r&&{key:"copyLink",label:f("buttons.copyLink"),onSelect:async()=>{await uo(o),this.setState({toast:{message:f("toast.elementLinkCopied"),closable:!0}})}}]});I(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o),i=this.getImageActionContextMenuItems(o),a=this.getElementLinkContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[Xs,ji,da,Qo]:[eg,Ze,Qu,cv,Ze,ji,kt,Ks,Zs,da,Qo];if(this.state.viewModeEnabled)return[...a,a.length>0&&Ze,Xs,$i,r.length>0&&Ze,...r];let s=this.editorInterface.formFactor==="desktop"?[Ze,$u,ju,qu,Ju]:[];return[Ze,Xs,Ze,$d,$i,eg,r.length>0&&Ze,...r,i.length>0&&Ze,...i,Ze,e2,t2,n2,Ze,Fg,Ze,Kh,Wg,og,rg,Xy,Zh,Ze,...s,Ze,Jh,Qh,Ze,aa,Ze,ug,a.length>0&&Ze,...a,Ze,eh,qs,Ze,bs]});I(this,"handleWheel",Ye(t=>{if(!this.isNavigationEnabled())return;if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&(t.target.classList.contains(sb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),ko)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=kV*100,s=Math.abs(r),l=r;s>a&&(l=a*i);let c=this.state.zoom.value-l/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,s/20);let d=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:MV;c=Math.max(c,d),this.viewport.translate(p=>({...ro({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Fn(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a})=>({scrollX:a-(r||o)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s})=>({scrollX:a-o/i.value,scrollY:s-r/i.value}))}));I(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Ce({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:le.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",Ok(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:s}=o.getBoundingClientRect(),{width:l,height:c,offsetTop:d,offsetLeft:m}=this.state;if(r===l&&i===c&&a===m&&s===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:s},()=>{t&&t()}),this.viewport.constrain()}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});I(this,"watchState",()=>{});let o=_o(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${zk()}`,wheelZoomsOnDefault:d=!1}=t,m=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?m=jt(o,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...o,theme:l,exportWithDarkMode:l===jl.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:m??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:s,gridModeEnabled:a??o.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:d},this.refreshEditorInterface(),this.stylesPanelMode=Jp(this.editorInterface),this.id=gV(),this.actionManager=new pm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new xM,this.canvas=document.createElement("canvas"),this.rc=hV.canvas(this.canvas),this.renderer=new fl(this.scene),this.visibleElements=[],this.store=new $Y(this),this.history=new hl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new io(this.scene),this.history=new hl(this.store),this.actionManager.registerAll(Fc),this.actionManager.registerAction(a2(this.history)),this.actionManager.registerAction(s2(this.history)),this.api=this.createExcalidrawAPI()}get lastViewportPosition(){return this.viewport.lastPosition}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,addFiles:this.addFiles,addImagePlaceholder:this.addImagePlaceholder,setDownloadProgress:this.setDownloadProgress,setDownloadError:this.setDownloadError,setUploadProgress:this.setUploadProgress,addImageElementsToScene:this.addImageElementsToScene,scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:o=>{this.actionManager.registerAction(o)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:o=>this.onChangeEmitter.on(o),onIncrement:o=>this.store.onStoreIncrementEmitter.on(o),onPointerDown:o=>this.onPointerDownEmitter.on(o),onPointerUp:o=>this.onPointerUpEmitter.on(o),onScrollChange:o=>this.onScrollChangeEmitter.on(o),onUserFollow:o=>this.onUserFollowEmitter.on(o),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(t=this.props){return t.interaction!==!1&&typeof t.interaction!="object"}isLinksEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.links===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isNavigationEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.navigation===!0:t.interaction!==!1}isEmbedsEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.embeds===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isBrowserZoomEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.browserZoom===!0:!1}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type==="laser"||this.state.activeTool.type==="custom":this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(t=this.props){return t.ui!==!1&&(typeof t.ui!="object"||t.ui===null)}isUIControlEnabled(t,o=this.props){return typeof o.ui=="object"&&o.ui!==null?o.ui.enabled?.[t]===!0:o.ui!==!1}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let o=null;try{o=JSON.parse(t.data)}catch{}if(o)switch(t.origin){case"https://player.vimeo.com":if(o.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:o.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(o.event==="infoDelivery"&&o.info&&o.id&&typeof o.info.playerState=="number"){let r=o.id,i=o.info.playerState;Object.values(Fp).includes(i)&&wb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){to(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=br(ne(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=me.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Rt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;to(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?me.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):me.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);s&&this.setState(s)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||Ut(t))return;let r=()=>{if(this.bindModeHandler=null,to(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let E=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!E&&!g||E&&g)return}let{x:m,y:p}=this.lastPointerMoveCoords,u=br(ne(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){to(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Rt(()=>{to(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:E}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;to(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,y=p-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?me.handlePointerMove(g,this,b,y,this.state.selectedLinearElement):me.handlePointDragging(g,this,b,y,this.state.selectedLinearElement);w&&this.setState(w)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let m=this.scene.getNonDeletedElementsMap(),p=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),E=p?o:t.startBinding&&m.get(t.startBinding.elementId),g=u?o:t.endBinding&&m.get(t.endBinding.elementId),b=E&&IM(E,m),y=g&&IM(g,m);i=!!(b&&y&&E.id!==g.id&&JY(b,y))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Rt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,YV)),this.previousHoveredBindableElement=o}cacheEmbeddableRef(t,o){o&&this.iFrameRefs.set(t.id,o)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Dn.MAIN||Po||!Uk(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=ne(Ce({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=ne(Ce({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Qn(t,o)>Dk)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&le.pointers.size<2&&tc(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let s=i;if(this.state.activeEmbeddable?.element===s&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:s,state:"active"},selectedElementIds:{[s.id]:!0},newElement:null,selectionElement:null})},100),lb(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=wb.get(s.id);switch(c||(wb.set(s.id,Fp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case Fp.PLAYING:case Fp.BUFFERING:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return l.src.includes("player.vimeo.com")&&l.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}isIframeLikeElementCenter(t,o,r,i){return t&&!o.altKey&&!o.shiftKey&&!o.metaKey&&!o.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,o=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Co(a)&&this.embedsValidationStatus.get(a.id)===!0||lb(a));return Te(dX,{children:i.map(a=>{let{x:s,y:l}=Hp({sceneX:a.x,sceneY:a.y},this.state),c=Jk(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p=Vp(RV(a.link||"")),u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",E=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover",g=p?.type==="video",b=Zl(g?t:1,.75,lX);return Te("div",{className:Tk("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:c?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:FY(a,fb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?DV:1),"--embeddable-radius":`${fY(Math.min(a.width,a.height),a)}px`},children:yb("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Za.enabled:Za.disabled},children:[E&&Te("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Te("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Te("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Co(a)?this.props.renderEmbeddable?.(a,this.state):null)??Te("iframe",{ref:y=>this.cacheEmbeddableRef(a,y),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:o,renderTopLeftUI:r,renderCustomStats:i}=this.props,{elementsMap:a,visibleElements:s,canvasNonce:l,newElementCanvasElement:c}=this.renderer.getRenderableElements({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,newElement:this.state.newElement,selectedElements:t,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=s,this.hasRenderableElements=a.size>0;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",p=t[0],u=gt.get(jn)?.type==="panel";return Te("div",{translate:"no",className:Tk("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor==="phone"&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":m?Za.disabled:Za.enabled,"--right-sidebar-width":`${Gf}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:Te(es.Provider,{value:this.api,children:Te(DM.Provider,{value:this,children:Te(_M.Provider,{value:this.props,children:Te(Sb.Provider,{value:this.excalidrawContainerValue,children:Te(Tb.Provider,{value:this.editorInterface,children:Te(kb.Provider,{value:this.setAppState,children:Te(Pb.Provider,{value:this.state,children:yb(Cb.Provider,{value:this.scene.getNonDeletedElements(),children:[yb(Mb.Provider,{value:this.actionManager,children:[Te(ok,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled("zoom"),scrollBackToContentUIEnabled:this.isUIControlEnabled("scrollBackToContent"),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:Hn().code,renderTopLeftUI:r,renderTopRightUI:o,renderCustomStats:i,showExitZenModeBtn:!1,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,currentUserControls:this.props.currentUserControls,children:this.props.children}),Te("div",{className:"excalidraw-textEditorContainer"}),Te("div",{className:"excalidraw-contextMenuContainer"}),Te("div",{className:"excalidraw-eye-dropper-container"}),Te(ik,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Te(yk,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Te(Qy,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.isDefaultUIEnabled()&&this.state.contextMenu&&Te(LT,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:E=>{this.setState({contextMenu:null},()=>{this.focusContainer(),E?.()})}}),Te(QE,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:d,visibleElements:s,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:nr(this),renderLinks:this.isLinksEnabled(),imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),c&&Te(gk,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,isExporting:!1,imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Te(JE,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:d,selectedElements:t,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor==="phone"&&Te(qm,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Te(Ik,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Te(aT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{qa(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),Ja.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,kM()||MM()){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)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(r=>{this.props.onIncrement?.(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),AV&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),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),ZV()&&!_Y()&&this.setState({errorMessage:Te(IT,{})});let o={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",o),this.props.onMount?.(o),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.api={...this.api,isDestroyed:!0};for(let t of Object.keys(this.api))(t.startsWith("get")||t==="onStateChange"||t==="onEvent")&&typeof this.api[t]=="function"&&(this.api[t]=()=>{throw new Error("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new xM,this.fonts=new io(this.scene),this.renderer=new fl(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),Ja.destroy(),cn.destroy(),clearTimeout(xr),Me.clearCache(),Nn.clearCache(),xr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(be(window,J.MESSAGE,this.onWindowMessage,!1),be(document,J.POINTER_UP,this.removePointer,{passive:!1}),be(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),be(window,J.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.handleNavigationModeKeyDown,!1),be(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),be(document,J.GESTURE_START,this.onGestureStart,!1),be(document,J.GESTURE_CHANGE,this.onGestureChange,!1),be(document,J.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),be(this.excalidrawContainerRef.current,J.GESTURE_START,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.GESTURE_CHANGE,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(be(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(be(document,J.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(document,J.COPY,this.onCopy,{passive:!1}),be(document,J.KEYUP,this.onKeyUp,{passive:!0}),be(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),be(document,J.GESTURE_START,this.onGestureStart,!1),be(document,J.GESTURE_CHANGE,this.onGestureChange,!1),be(document,J.GESTURE_END,this.onGestureEnd,!1),be(document,J.PASTE,this.pasteFromClipboard,{passive:!1}),be(this.excalidrawContainerRef.current,J.DRAG_OVER,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(be(document,J.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),be(document,J.CUT,this.onCut,{passive:!1}),be(window,J.RESIZE,this.onResize,!1),be(window,J.UNLOAD,this.onUnload,!1),be(window,J.BLUR,this.onBlur,!1),be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(be(NV(this.excalidrawContainerRef.current),J.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,o){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(t,o),this.handleForcedToolChange(t,o),this.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===jl.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.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)),Object.keys(this.state.selectedElementIds).length&&Jt(this.state)&&this.setState({activeTool:jt(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&o.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type==="bucketfill"&&o.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),o.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),Jt(o)&&!Jt(this.state)&&this.eraserTrail.endPath(),(o.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&o.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===jl.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(mt)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let c=s.filter(d=>{let m=this.scene.getElement(d);return!m||m.isDeleted});c.length&&this.setState(d=>{let m={...d.selectedElementIds};for(let p of c)delete m[p];return{selectedElementIds:ke(m,d)}})}if(this.state.editingTextElement){let c=this.scene.getElement(this.state.editingTextElement.id);(!c||c.isDeleted)&&this.setState({editingTextElement:null})}let l=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==l&&this.setState({scrolledOutside:l}),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(){oc=!1,ic=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let d=Dm(t.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:t.text}});return}}let s=o.map(d=>d.file);if(s.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&s.push(gu(d))}if(s.length>0){this.isToolSupported("image")?await this.insertImages(s,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(t.elements){let d=t.programmaticAPI?QY(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!t.text)return;let l=HV(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>EY(d)).filter(d=>db(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||Vp(d)?.type==="video"));if(!r&&c.length>0&&c.length===l.length){let d=[];for(let m of c){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:zp(m)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>ui(a.file))||!r&&t.mixedContent?.some(a=>a.type==="imageUrl"))return!0;if(r||!t.text)return!1;let i=t.text.trim();return i.startsWith("<svg")&&i.endsWith("</svg>")}shouldInsertImageInViewMode({source:t,files:o,data:r,event:i}){return this.state.viewModeEnabled?this.state.viewModeOnly||this.props.viewModeImageInsertBehavior==="reject"?(this.props.onViewModeImageInsertRejected?.({source:t,files:o,data:r,event:i}),!1):(Rt(()=>{this.setState({viewModeEnabled:!1})}),!0):!0}async addElementsFromMixedContentPaste(t,{isPlainPaste:o,sceneX:r,sceneY:i}){if(!o&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(d=>d.type==="imageUrl").map(d=>d.value),s=await Promise.all(a.map(async d=>{try{return{file:await dx(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(l,r,i);let c=s.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(s=>s.type==="text");a.length&&this.addTextFromPaste(a.map(s=>s.value).join(`
|
|
20
|
+
`)},qU=(e,n,t)=>{let r=jU(e.text,e.originalText).split(`
|
|
21
|
+
`),i=[],a=0,s=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:s}),a=u+1,s++}let l=t,c=e.originalText.slice(t,t+n.length),d=[];for(let m of i){if(c==="")break;if(l>=m.startIndex&&l<=m.endIndex){let p=m.endIndex+1-l,u=m.line.slice(0,l-m.startIndex),E=c.slice(0,p);c=c.slice(p);let g=ec(u,Np(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=ec(m.line,Np(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:y}=ec(E,Np(e),e.lineHeight),w=g.width,x=m.lineNumber*g.height;d.push({offsetX:w,offsetY:x,width:b,height:y,showOnCanvas:!0}),l+=p}}return d},JU=(e,n,t,o)=>{let r=e.name??ek(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Np({fontSize:WE.nameFontSize,fontFamily:UE.Assistant}),l=GU(UE.Assistant),c=ec(a,s,l);a===""&&(c.width=0);let d=ec(i,s,l),m=c.width,p=-c.height-WE.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},QU=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),JP=NU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>QP(p)),i=o.filter(p=>Bp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(QU(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=qP(E,u.index,e),b=qU(p,e,u.index);b.length>0&&a.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let l=[];for(let p of i){let u=null,E=p.name??ek(p);for(;(u=s.exec(E))!==null;){let g=qP(E,u.index,e),b=JU(p,e,u.index,n.state.zoom.value);b.length>0&&l.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let c=new Set(n.visibleElements.map(p=>p.id)),d=[...l,...a],m=d.findIndex(p=>c.has(p.element.id))??null;t(d,m)},XU);import uW from"clsx";import{useEffect as sk,useLayoutEffect as lk,useRef as QE,useState as hW,forwardRef as ck,useImperativeHandle as gW,useCallback as rk}from"react";import{CLASSES as fW,EVENT as ik,isDevEnv as EW,KEYS as bW,updateObject as xW}from"@excalidraw/common";import nW from"clsx";import{useContext as oW}from"react";import tW from"react";var Fp=tW.createContext({});import{jsx as YE,jsxs as nk}from"react/jsx-runtime";var XE=({children:e,className:n})=>{let t=Ee(),o=oW(Fp),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return nk("div",{className:nW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,nk("div",{className:"sidebar__header__buttons",children:[r&&YE(pt,{label:f("labels.sidebarLock"),children:YE(wn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:Dx})}),YE(wn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:rn})]})]})};XE.displayName="SidebarHeader";import{Tabs as rW}from"radix-ui";import{jsx as ok}from"react/jsx-runtime";var KE=({children:e,tab:n,onSelect:t,...o})=>ok(rW.Trigger,{value:n,asChild:!0,onSelect:t,children:ok("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});KE.displayName="SidebarTabTrigger";import{Tabs as iW}from"radix-ui";import{jsx as aW}from"react/jsx-runtime";var $E=({children:e,...n})=>aW(iW.List,{className:"sidebar-triggers",...n,children:e});$E.displayName="SidebarTabTriggers";import sW from"clsx";import{jsx as ZE,jsxs as lW}from"react/jsx-runtime";var jE=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Fe(),d=be().openSidebar?.name===e;return ZE("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":d,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!d;l({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:lW("div",{className:sW("sidebar-trigger",a),style:s,children:[t&&ZE("div",{children:t}),r&&ZE("div",{className:"sidebar-trigger__label",children:r})]})})};jE.displayName="SidebarTrigger";import{Tabs as cW}from"radix-ui";import{jsx as dW}from"react/jsx-runtime";var qE=({children:e,...n})=>{let t=be(),o=Fe();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return dW(cW.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};qE.displayName="SidebarTabs";import{Tabs as mW}from"radix-ui";import{jsx as pW}from"react/jsx-runtime";var JE=({tab:e,children:n,...t})=>pW(mW.Content,{...t,value:e,"data-testid":e,children:n});JE.displayName="SidebarTab";import{jsx as ak}from"react/jsx-runtime";import{createElement as yW}from"react";var eb=Je(!1),dk=ck(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{EW()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Fe(),l=Ix(eb);lk(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=QE({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=xW(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=QE(null);gW(a,()=>d.current);let m=Ee(),p=rk(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Bi(d,rk(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),sk(()=>{let u=E=>{E.key===bW.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(ik.KEYDOWN,u),()=>{document.removeEventListener(ik.KEYDOWN,u)}},[p,o,m.canFitSidebar]),ak(Ue,{...i,className:uW(fW.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":m.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":m.formFactor!=="phone"?"sidebar":void 0,ref:d,children:ak(Fp.Provider,{value:c.current,children:n})})});dk.displayName="SidebarInner";var Ir=Object.assign(ck((e,n)=>{let t=be(),{onStateChange:o}=e,r=QE(t.openSidebar);sk(()=>{(!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&&o?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,o,e.name]);let[i,a]=hW(!1);return lk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?yW(dk,{...e,ref:n,key:e.name}):null}),{Header:XE,TabTriggers:$E,TabTrigger:KE,Tabs:qE,Tab:JE,Trigger:jE});Ir.displayName="Sidebar";import{jsx as os,jsxs as IW}from"react/jsx-runtime";import{createElement as TW}from"react";var pk=si("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=nt();return os(n.In,{children:os(Ir.Trigger,{...e,className:"default-sidebar-trigger",name:vW.name})})});pk.displayName="DefaultSidebarTrigger";var uk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=nt();return os(n.In,{children:e})};uk.displayName="DefaultTabTriggers";var tb=Object.assign(si("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=be(),a=Fe(),s=i.openSidebar?.tab===mk,l=s?!1:t??i.defaultSidebarDockedPreference,c=!s&&t==null&&o!==!1;return TW(Ir,{...r,name:"default",key:"default",className:wW("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:c?d=>{a({defaultSidebarDockedPreference:d}),o?.(d)}:void 0},IW(Ir.Tabs,{children:[!s&&os(Ir.Header,{}),os(Ir.Tab,{tab:mk,children:os(tk,{})}),!s&&e]}))}),{Trigger:pk,TabTriggers:uk});import CW from"react";import{getFrame as PW}from"@excalidraw/common";import{jsx as SW}from"react/jsx-runtime";var nb={primary:{base:"var(--color-primary)",darker:"var(--color-primary-darker)",darkest:"var(--color-primary-darkest)"},lime:{base:"#74b816",darker:"#66a80f",darkest:"#5c940d"},pink:{base:"#d6336c",darker:"#c2255c",darkest:"#a61e4d"}},ob=({children:e,color:n})=>SW("div",{className:"Card",style:{"--card-color":nb[n].base,"--card-color-darker":nb[n].darker,"--card-color-darkest":nb[n].darkest},children:e});import{Fragment as MW,jsx as On,jsxs as Op}from"react/jsx-runtime";var kW=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return On("div",{className:"ExportDialog ExportDialog--json",children:Op("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Op(ob,{color:"lime",children:[On("div",{className:"Card-icon",children:$x}),On("h2",{children:f("exportDialog.disk_title")}),Op("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Ii&&r.renderAction("changeProjectName")]}),On($,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Js,"ui")}})]}),l&&Op(ob,{color:"pink",children:[On("div",{className:"Card-icon",children:Is}),On("h2",{children:f("exportDialog.link_title")}),On("div",{className:"Card-details",children:f("exportDialog.link_details")}),On($,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Be("export","link",`ui (${PW()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},hk=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=CW.useCallback(()=>{a({openDialog:null})},[a]);return On(MW,{children:n.openDialog?.name==="jsonExport"&&On(yn,{onCloseRequest:s,title:f("buttons.export"),children:On(kW,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import AW from"clsx";import{jsx as DW}from"react/jsx-runtime";var gk=e=>DW($,{className:AW("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:qn,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import vk from"clsx";import{useState as WW}from"react";import{CANVAS_SEARCH_TAB as VW,DEFAULT_SIDEBAR as YW,KEYS as tc}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as LW,DEFAULT_SIDEBAR as _W}from"@excalidraw/common";import{isArrowElement as RW,isFlowchartNodeElement as NW,isImageElement as fk,isLinearElement as Ek,isLineElement as BW,isTextBindableContainer as FW,isTextElement as OW}from"@excalidraw/element";import{isNodeInFlowchart as zW}from"@excalidraw/element";import{jsx as rb}from"react/jsx-runtime";var Te=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,GW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===_W.name&&e.openSidebar.tab===LW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:Te("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(on(e))return f("hints.eraserRevert",{shortcut:Te("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:Te("Ctrl"),shortcut_2:Te("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:Te("Escape"),shortcut_2:Te("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:Te("A")}):f("hints.linearElement");if(r.type==="freedraw")return f("hints.freeDraw");if(r.type==="text")return f("hints.text");if(r.type==="embeddable")return f("hints.embeddable");if(r.type==="autoshape")return f("hints.autoshape");if(i&&s==="mouse"&&c.length===1){let d=c[0];return Ek(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:Te("Shift")}):fk(d)?f("hints.resizeImage",{shortcut_1:Te("Shift"),shortcut_2:Te("Alt")}):f("hints.resize",{shortcut_1:Te("Shift"),shortcut_2:Te("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:Te("Shift")});if(c.length===1&&OW(c[0]))return f("hints.text_selected",{shortcut:Te("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:Te("Escape"),shortcut_2:Te(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:Te("Enter"),shortcut_2:Te("Escape")});if(c.length===1&&fk(c[0]))return f("hints.enterCropEditor",{shortcut:Te("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Te("CtrlOrCmd")});if(cr(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Te("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:Te(f("keys.mmb")),shortcut_2:Te("Space")});if(c.length===1){if(Ek(c[0]))return RW(c[0])&&e.selectedLinearElement?.elementId===c[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===c[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:Te("Delete"),shortcut_2:Te(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Te("Shift"),shortcut_2:Te("Alt")}):BW(c[0])?f("hints.lineEditor_line_info",{shortcut:Te("Enter")}):f("hints.lineEditor_info",{shortcut_1:Te("CtrlOrCmd"),shortcut_2:Te(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&FW(c[0])){let d=f("hints.bindTextToElement",{shortcut:Te("Enter")}),m=f("hints.createFlowchart",{shortcut:Te(["CtrlOrCmd","\u2191\u2193"])});return NW(c[0])?zW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},bk=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=GW({appState:e,isMobile:n,editorInterface:t,app:o});if(!r)return null;let a=(Array.isArray(r)?r.map(s=>s.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((s,l)=>{if(l%2===1){let c=s[0]==="<"&&s.match(/^<kbd>([^<]+)<\/kbd>$/);return rb("kbd",{children:c?c[1]:s},l)}return s});return rb("div",{className:"HintViewer",children:rb("span",{children:a})})};import HW from"clsx";import{jsx as UW}from"react/jsx-runtime";var xk=e=>UW($,{className:HW("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?Uo:fo,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as gi,jsx as ie,jsxs as Lo}from"react/jsx-runtime";var XW=(e,n)=>e==="image"&&n.tools?.image===!1,KW=({app:e,activeTool:n,type:t,shortcut:o})=>ie(ue.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:Ye[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??Ji(t),disabled:qe(e,t),children:f(`toolBar.${t}`)}),yk=({app:e})=>ie(ue.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Uo:fo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:tc.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),$W=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Dt))return null;let t=Ze("objectsSnapMode");return ie(ue.Item,{onSelect:()=>e.executeAction(Dt,"ui"),icon:Yo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},ZW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Dt))return null;let t=f("buttons.objectsSnapMode"),o=Ze("objectsSnapMode");return ie($,{type:"toggle",icon:Yo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Dt,"ui")})},wk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Ze("searchMenu");return ie(ue.Item,{onSelect:()=>e.executeAction(wl,"ui"),icon:Jn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===YW.name&&n.openSidebar.tab===VW,shortcut:o,children:t})},jW=({app:e})=>ie($,{type:"button",icon:_i,title:`${f("labels.eyeDropper")} - ${tc.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":tc.I.toLocaleUpperCase(),keyBindingLabel:tc.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),qW=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=WW(!1),l=ct()==="full",c=n.type==="frame",d=n.type==="autoshape",m=n.type==="laser",p=n.type==="bucketfill",u=l&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",E=n.type==="embeddable",g=r&&ji.includes(n.type);return Lo(ue,{open:a,children:[ie(ue.Trigger,{className:vk("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":g||c||E||!r&&l&&d||u||p||m&&!e.props.isCollaborating}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:g?Ye[n.type].icon:c?jn:E?Vo:!r&&l&&d?Br:m&&!e.props.isCollaborating?qn:u?ki:p?Zn:bs}),ie(ue.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?Lo(gi,{children:[l&&ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:ki,"data-testid":"toolbar-lasso",selected:u,disabled:qe(e,"lasso"),children:f("toolBar.lasso")}),ji.filter(b=>!XW(b,o)).map(b=>ie(KW,{app:e,activeTool:n,type:b},b)),ie("div",{className:"App-toolbar__dropdown-divider"}),ie(wk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(gi,{children:ie(yk,{app:e})})]}):Lo(gi,{children:[ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:tc.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:qe(e,"frame"),children:f("toolBar.frame")}),ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Vo,"data-testid":"toolbar-embeddable",selected:E,disabled:qe(e,"embeddable"),children:f("toolBar.embeddable")}),ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Br,shortcut:Ji("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:qe(e,"autoshape"),children:f("toolBar.autoshape")}),ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:m,disabled:qe(e,"laser"),children:f("toolBar.laser")}),ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:p,disabled:qe(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:ki,"data-testid":"toolbar-lasso",selected:u,disabled:qe(e,"lasso"),children:f("toolBar.lasso")}),ie("div",{className:"App-toolbar__dropdown-divider"}),ie($W,{actionManager:i,app:e}),ie(wk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(yk,{app:e})]})})]})},Ik=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=Ee(),c=ct()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?ie(Rd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?ie(qy,{...m}):ie(jy,{...m});return Lo(Ue,{padding:1,className:vk("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[ie(bk,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,Lo(Nt.Row,{gap:c?.5:1,children:[!c&&ie(Ka,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&Lo(gi,{children:[ie(xk,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),ie("div",{className:"App-toolbar__divider"})]}),ie(_d,{...m}),u,p?Lo(gi,{children:[ie(Ws,{...m}),ie(Vs,{...m}),ie(jW,{app:e}),o.tools?.image!==!1&&ie(Ys,{...m}),ie(Xs,{...m})]}):Lo(gi,{children:[ie(Vy,{...m}),ie(Yy,{...m}),ie(Xy,{...m}),ie(Ky,{...m}),ie($y,{...m}),c?ie(Nd,{...m}):ie(Ws,{...m}),ie(Vs,{...m}),o.tools?.image!==!1&&ie(Ys,{...m}),ie(Xs,{...m})]}),ie("div",{className:"App-toolbar__divider"}),ie(qW,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&Lo(gi,{children:[ie("div",{className:"App-toolbar__divider"}),ie(ZW,{actionManager:r,app:e})]})]})]})};import{Fragment as ib,jsx as ee,jsxs as en}from"react/jsx-runtime";var rV=({UIOptions:e})=>en(Bt,{__fallback:!0,children:[ee(Bt.DefaultItems.LoadScene,{}),ee(Bt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(Bt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(Bt.DefaultItems.SaveAsImage,{}),ee(Bt.DefaultItems.SearchMenu,{}),ee(Bt.DefaultItems.Help,{}),ee(Bt.Separator,{}),ee(Bt.Group,{title:"Excalidraw links",children:ee(Bt.DefaultItems.Socials,{})}),ee(Bt.Separator,{}),ee(Bt.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),ee(Bt.DefaultItems.ChangeCanvasBackground,{})]}),iV=()=>en(wp,{__fallback:!0,children:[ee(wp.Actions.SaveToDisk,{}),ee(wp.Actions.ExportToImage,{})]}),aV=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:y,zoomUIEnabled:w,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:T,currentUserControls:C})=>{let P=Ee(),A=kn(),_=ct()==="compact",k=$T(),L=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},B=k.tunnelsJotai.Provider,[V,z]=He(zt),U=()=>p.canvasActions.export?ee(hk,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,K=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:ee(XP,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),G=()=>en("div",{style:{position:"relative"},children:[en("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),ee(k.MainMenuTunnel.Out,{}),ee(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&ee(k.WelcomeScreenMenuHintTunnel.Out,{})]}),te=()=>ee(Hl,{heading:"selectedShapeActions",className:rs("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?ee(Ue,{className:rs("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:ee(uS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):ee(Ue,{className:QW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:ee(lS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),F=()=>{let de=y&&oV(n,r),he=y&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return ee(pp,{side:"top",children:en("div",{className:"App-menu App-menu_top",children:[en(Nt.Col,{gap:L.menuTopGap,className:rs("App-menu_top__left"),children:[G(),y&&ee("div",{className:rs("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:de&&te()}),y&&_&&!n.viewModeEnabled&&de&&ee(Ka,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),y&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&ee(Hl,{heading:"shapes",className:"shapes-section",children:ve=>en("div",{style:{position:"relative"},children:[E&&ee(k.WelcomeScreenToolbarHintTunnel.Out,{}),ee(Nt.Col,{gap:L.toolbarColGap,align:"start",children:en(Nt.Row,{gap:L.toolbarRowGap,className:rs("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[ee(Ik,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ve}),I&&ee(Ue,{style:{marginLeft:L.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ee(gk,{title:f("toolBar.laser"),checked:n.activeTool.type===Tk.laser,onChange:()=>b.setActiveTool({type:Tk.laser}),isMobile:!0})})]})})]})}),en("div",{className:rs("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[y&&n.collaborators.size>0&&ee(fp,{collaborators:n.collaborators,userToFollow:A.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),he&&ee(Zl,{app:b,onClose:()=>{e.executeAction(ar)},renderCustomStats:m})]})]})})},W=()=>ee(tb,{}),le=!1,we=en(ib,{children:[g,y&&ee(ib,{children:ee(rV,{UIOptions:p})}),ee(iV,{}),y&&n.isLoading&&ee(sp,{delay:250}),y&&n.errorMessage&&ee(PP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),y&&V&&P.formFactor!=="phone"&&ee(_0,{colorPickerType:V.colorPickerType,onCancel:()=>{z(null)},onChange:(de,he,ve,{altKey:ae})=>{if(!(de!=="elementBackground"&&de!=="elementStroke"))if(ve.length){for(let fe of ve)tV(fe,eV(r),{[ae&&V.swapPreviewOnAlt?de==="elementBackground"?"strokeColor":"backgroundColor":de==="elementBackground"?"backgroundColor":"strokeColor"]:he}),nV.delete(fe);b.scene.triggerUpdate()}else o(de==="elementBackground"?{currentItemBackgroundColor:he}:{currentItemStrokeColor:he})},onSelect:(de,he)=>{z(ve=>ve?.keepOpenOnAlt&&he.altKey?ve:null),V?.onSelect?.(de,he)}}),n.openDialog?.name==="help"&&ee(zP,{onClose:()=>{o({openDialog:null})}}),y&&n.openDialog?.name==="elementLinkSelector"&&ee(CP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),ee(k.OverwriteConfirmDialogTunnel.Out,{}),K(),U(),y&&n.openDialog?.name==="charts"&&ee(tC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),y&&ee(NP,{app:b,files:t,setAppState:o}),P.formFactor==="phone"&&ee(WS,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:U,renderImageExportDialog:K,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:W,renderWelcomeScreen:E,defaultUIEnabled:y,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&en(ib,{children:[A.viewportStatusFrame?.border&&ee(rp,{border:A.viewportStatusFrame.border,style:le?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),en("div",{className:"layer-ui__wrapper",style:le?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&ee(k.WelcomeScreenCenterTunnel.Out,{}),F(),ee(lC,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:y,zoomUIEnabled:w}),(n.toast||x&&n.scrolledOutside||A.viewportStatusFrame?.label)&&en("div",{className:"floating-status-stack",children:[n.toast&&ee(zd,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&ee("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(de=>({...wi(r,de)}))},children:f("buttons.scrollBackToContent")}),A.viewportStatusFrame?.label&&ee(ip,{label:A.viewportStatusFrame.label,border:A.viewportStatusFrame.border})]})]})]}),W()]});return ee(lh.Provider,{value:n,children:ee(B,{children:ee(jf.Provider,{value:k,children:we})})})},Sk=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:c,elementsToHighlight:d,...m}=e;return m},sV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return zp(Sk(o),Sk(a),{selectedElementIds:zp,selectedGroupIds:zp})&&zp(r,s)},Ck=JW.memo(aV,sV);import{useEffect as lV,useRef as cV}from"react";import{jsx as Pk}from"react/jsx-runtime";var kk=({trails:e})=>{let n=cV(null);return lV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Pk("div",{className:"SVGLayer",children:Pk("svg",{ref:n})})};import dV,{useEffect as Mk,useRef as Ak}from"react";import{isShallowEqual as mV,sceneCoordsToViewportCoords as pV}from"@excalidraw/common";import{jsx as gV}from"react/jsx-runtime";var Dk="animateInteractiveScene",uV=e=>{let n=Ak(!1),t=Ak(null);return Mk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Rf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),Mk(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,s=new Map;e.appState.collaborators.forEach((c,d)=>{if(c.selectedElementIds)for(let m of Object.keys(c.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(d);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(d,c.username),c.userState&&s.set(d,c.userState),r.set(d,pV({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),o.set(d,c.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:o,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:s,selectionColor:l,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},at.running(Dk)||at.start(Dk,({deltaTime:c,state:d})=>{let m=Rf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),gV("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},Lk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,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,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,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,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),hV=(e,n)=>e.selectionNonce!==n.selectionNonce||e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements||e.selectedElements!==n.selectedElements||e.renderScrollbars!==n.renderScrollbars||e.interactionEnabled!==n.interactionEnabled||e.navigationEnabled!==n.navigationEnabled?!1:mV(Lk(e.appState),Lk(n.appState)),ab=dV.memo(uV,hV);import Nk,{useEffect as Gp,useRef as nc}from"react";import{isShallowEqual as _k}from"@excalidraw/common";import{hasActiveGifDecode as fV}from"@excalidraw/element";import{jsx as xV}from"react/jsx-runtime";var EV=e=>{let n=nc(null),t=nc(!1),o=nc(e),r=nc(()=>{}),i=nc(null);o.current=e;let a=Nk.useCallback(()=>{let s=o.current,l=n.current;if(!l)return;let c=getComputedStyle(l).getPropertyValue("--color-grid-bold").trim(),d=getComputedStyle(l).getPropertyValue("--color-grid-regular").trim();dx({canvas:s.canvas,rc:s.rc,scale:s.scale,elementsMap:s.elementsMap,allElementsMap:s.allElementsMap,visibleElements:s.visibleElements,appState:s.appState,renderConfig:{...s.renderConfig,gridColorBold:c,gridColorRegular:d}},Ta());let m=s.renderConfig.imageTransitionDuration??0,p=m>0&&s.visibleElements.some(E=>{if(E.type!=="image"||!E.fileId)return!1;let g=s.renderConfig.imageCache.get(E.fileId)?.transitionStart;return g!==void 0&&performance.now()-g<m}),u=fV(s.visibleElements,s.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,Gp(()=>{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]),Gp(()=>{let s=n.current;if(!s)return;let l=e.canvas;t.current||(t.current=!0,s.replaceChildren(l),l.classList.add("excalidraw__canvas","static")),a()}),Gp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),Gp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),xV("div",{className:"excalidraw__canvas-wrapper",ref:n})},Rk=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,suggestedBinding:e.suggestedBinding}),bV=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:_k(Rk(e.appState),Rk(n.appState))&&_k(e.renderConfig,n.renderConfig),sb=Nk.memo(EV,bV);import{useEffect as CV,useRef as PV}from"react";import{throttleRAF as yV}from"@excalidraw/common";import{getTargetFrame as wV,isInvisiblySmallElement as vV,renderElement as IV,shouldApplyFrameClip as TV}from"@excalidraw/element";var Bk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Tc(e,i),d=Sc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(vV(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=wV(t,o,a);u&&TV(t,u,a,o)&&lx(u,d,s,a)}IV(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},SV=yV(e=>{Bk(e)}),Fk=(e,n)=>{if(n){SV(e);return}Bk(e)};import{jsx as MV}from"react/jsx-runtime";var kV=e=>{let n=PV(null);return CV(()=>{n.current&&Fk({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Ta())}),MV("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:n})},Ok=kV;import AV from"clsx";import{useLayoutEffect as DV,useEffect as zk,useRef as LV,useState as _V}from"react";import{ARROW_TYPE as Gk,EVENT as Hp}from"@excalidraw/common";import{jsx as FV}from"react/jsx-runtime";var Hk=700,RV=100,NV=16,BV=5*60*1e3,Wk=Je(null),Uk=e=>e===Gk.elbow?Ko:e===Gk.round?$o:Xo,Up=class{constructor(n){v(this,"app");v(this,"lastShownAt",0);v(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(Wk,{content:n,nonce:Math.random()}))});v(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<BV);v(this,"onArrowTypeCycled",n=>{this.show(Uk(n))});v(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?Wo:Uk(this.app.state.currentItemArrowType))});this.app=n}},Vk=()=>{let[e,n]=He(Wk),t=St(),{container:o}=Re(),r=LV(null),[i,a]=_V(!1),s=e?.nonce;return DV(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=td({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:NV});p.style.transform=`translate(${u}px, ${E}px)`};l(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let c=d=>{l(d.clientX,d.clientY)};return window.addEventListener(Hp.POINTER_MOVE,c),()=>{window.removeEventListener(Hp.POINTER_MOVE,c)}},[s,o,t]),zk(()=>()=>{n(null)},[n]),zk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},Hk),c=window.setTimeout(()=>{n(null)},Hk+RV),d=()=>{n(null)};return window.addEventListener(Hp.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Hp.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?FV("div",{ref:r,className:AV("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Wp=class{constructor(n){this.getState=n;v(this,"listeners",[]);v(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(n,t,o);return a?l&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),s)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:s}):l?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:d=>c(d),once:!0})})})}isStateChangePredicateOptions(n){return typeof n=="object"&&!Array.isArray(n)&&"predicate"in n}subscribe(n){return this.listeners.push(n),()=>{this.listeners=this.listeners.filter(t=>t!==n)}}normalize(n,t,o){let r,i,a=t,s=o?.once??!1,l=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:c,callback:d,once:m}=n;r=c,i=p=>p,a=d?(p,u)=>d(u):void 0,s=m??!1,l=c(this.getState())}else if(typeof n=="function"){let c=n;r=(d,m)=>c(d)!==c(m),i=d=>c(d)}else if(Array.isArray(n)){let c=n;r=(d,m)=>c.some(p=>d[p]!==m[p]),i=d=>d}else{let c=n;r=(d,m)=>d[c]!==m[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}flush(n){if(!this.listeners.length)return;let t=this.getState(),o=[];for(let r of this.listeners)r.predicate(t,n)?(r.callback(r.getValue(t),t),r.once||o.push(r)):o.push(r);this.listeners=o}clear(){this.listeners=[]}};import{getCommonBounds as OV,getElementsInGroup as zV,isNonDeletedElement as Yk,selectGroupsFromGivenElements as GV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as HV}from"@excalidraw/common";import{flushSync as UV}from"react-dom";import{jsx as VV}from"react/jsx-runtime";var WV=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!Yk(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&Yk(t)?t:null,r=o?[o]:zV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=OV(r),{x:s,y:l}=HV({sceneX:i,sceneY:a},e.state);return VV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{UV(()=>{let c=GV(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(il)},title:f("labels.elementLock.unlock"),children:Lx})},Xk=WV;import{Fragment as UX,jsx as Ce,jsxs as Ab}from"react/jsx-runtime";var e3=vn.createContext(null),t3=vn.createContext(null),Db={formFactor:"desktop",desktopUIMode:"full",userAgent:JM(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},_b=vn.createContext(Db);_b.displayName="EditorInterfaceContext";var zX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Rb=vn.createContext({container:null,id:null});Rb.displayName="ExcalidrawContainerContext";var Nb=vn.createContext([]);Nb.displayName="ExcalidrawElementsContext";var Bb=vn.createContext({...Ho(),width:0,height:0,offsetLeft:0,offsetTop:0});Bb.displayName="ExcalidrawAppStateContext";var Fb=vn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Fb.displayName="ExcalidrawSetAppStateContext";var Ob=vn.createContext(null);Ob.displayName="ExcalidrawActionManagerContext";var cs=vn.createContext(null);cs.displayName="ExcalidrawAPIContext";var au=vn.createContext(null);au.displayName="ExcalidrawAPISetContext";var St=()=>Oo(e3),kn=()=>Oo(t3),Ee=()=>Oo(_b),ct=()=>iu(Ee()),Re=()=>Oo(Rb),Oi=()=>Oo(Nb),Qn=()=>Oo(Bb),Fe=()=>Oo(Fb),ot=()=>Oo(Ob),Id=()=>Oo(cs),pc=!1,uc=0,hc=null,Bo=!1,tu=!1,Fo=!1,nu=!1,gc={horizontal:null,vertical:null},Pr=0,fc=!1,Mb=new Map,GX=4,ou=!1,ru=0,ZM=!1,ls=null,me={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Lb=class e extends vn.Component{constructor(t){super(t);v(this,"canvas");v(this,"interactiveCanvas",null);v(this,"sessionExportThemeOverride");v(this,"rc");v(this,"unmounted",!1);v(this,"actionManager");v(this,"editorInterface",Db);v(this,"stylesPanelMode",iu(Db));v(this,"excalidrawContainerRef",vn.createRef());v(this,"scene");v(this,"fonts");v(this,"renderer");v(this,"visibleElements");v(this,"hasRenderableElements",!1);v(this,"resizeObserver");v(this,"id");v(this,"store");v(this,"history");v(this,"excalidrawContainerValue");v(this,"files",{});v(this,"imageCache",new Map);v(this,"imageLoadingProgress",new Map);v(this,"imageLoadingProgressEmitter",new co);v(this,"imageStatus",new Map);v(this,"imageStatusEmitter",new co);v(this,"imagePlaceholderUpdateEmitter",new co);v(this,"iFrameRefs",new Map);v(this,"embedsValidationStatus",new Map);v(this,"initializedEmbeds",new Set);v(this,"elementsPendingErasure",new Set);v(this,"_initialized",!1);v(this,"editorLifecycleEvents",new yY(zX));v(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));v(this,"appStateObserver",new Wp(()=>this.state));v(this,"onStateChange",this.appStateObserver.onStateChange);v(this,"bucketFill",new $m(this));v(this,"flowchart",new Qm(this));v(this,"cursor",new Zm(this));v(this,"gifPlayback",new ep(this));v(this,"zDragZoom",null);v(this,"arrowText",new Km(this));v(this,"viewport",new np(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>me.pointers.size>=2||Fo}));v(this,"bindModeHandler",null);v(this,"textWysiwygSubmitHandler",null);v(this,"hitLinkElement");v(this,"lastPointerDownEvent",null);v(this,"lastPointerUpEvent",null);v(this,"lastPointerUpIsDoubleClick",!1);v(this,"lastPointerMoveEvent",null);v(this,"lastPointerMoveCoords",null);v(this,"lastCompletedCanvasClicks",[]);v(this,"previousPointerMoveCoords",null);v(this,"drawShape",new Jm(this));v(this,"laserTrails",new Tm(this));v(this,"eraserTrail",new Dm(this));v(this,"lassoTrail",new Am(this));v(this,"cursorHints",new Up(this));v(this,"onChangeEmitter",new co);v(this,"onPointerDownEmitter",new co);v(this,"onPointerUpEmitter",new co);v(this,"onUserFollowEmitter",new co);v(this,"onScrollChangeEmitter",new co);v(this,"missingPointerEventCleanupEmitter",new co);v(this,"onRemoveEventListenersEmitter",new co);v(this,"api");v(this,"isToolSupported",(t,o=this.props)=>{if(t==="magicframe"||o.UIOptions.tools?.[t]===!1)return!1;if(this.isInteractionEnabled(o))return!0;let r=typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.tools:void 0;return t==="laser"?r?.laser===!0:t==="custom"?r?.custom===!0:!1});v(this,"updateEditorAtom",(t,...o)=>{let r=Et.set(t,...o);return this.triggerRender(),r});v(this,"previousHoveredBindableElement",null);v(this,"getEffectiveGridSize",()=>cr(this)?this.state.gridSize:null);v(this,"getTextCreationGridPoint",(t,o)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(o)}});v(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&dc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Me.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));v(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=oM);v(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),Ei.delete(t)});v(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(No(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=bb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else fb(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});v(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);v(this,"frameNameBoundsCache",{get:t=>{let o=this.frameNameBoundsCache._cache.get(t.id);if(!o||o.zoom!==this.state.zoom.value||o.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=ke({clientX:i.x,clientY:i.y},this.state),s=ke({clientX:i.right,clientY:i.bottom},this.state);return o={x:a.x,y:a.y,width:s.x-a.x,height:s.y-a.y,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_cache:new Map});v(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});v(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===ic.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&Tt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!wM(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:s}=Kp({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=rX(i);if(i.id===this.state.editingFrame){let m=d;c=Ce("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===X.ESCAPE||p.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:xY(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${_o.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?_o.nameColorDarkTheme:_o.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Ce("div",{id:this.getFrameNameDOMId(i),className:gb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+_o.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:_o.nameFontSize,color:t?_o.nameColorDarkTheme:_o.nameColorLightTheme,lineHeight:_o.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:Me.MOVE,pointerEvents:this.state.viewModeEnabled?is.disabled:is.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});v(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});v(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());v(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());v(this,"getSceneElements",()=>this.scene.getNonDeletedElements());v(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});v(this,"onExportImage",async(t,o,r)=>{Be("export",t,"ui");let i=await Yr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(EY).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Pc(i)&&this.setState({fileHandle:i})});v(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(zt,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:Kt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:Kt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?po(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:Kt.IMMEDIATELY})},keepOpenOnAlt:!1})});v(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});v(this,"syncActionResult",Ke(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||ic.LIGHT,s=t?.appState?.name??this.state.name,l=t?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),r=t.appState?.editingTextElement||null,t.elements&&r){let c=r.id,d=t.elements.find(m=>m.id===c);r=d&&eu(d)&&Xt(d)?d:null}this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:s,errorMessage:l}}),o=!0}o||this.scene.triggerUpdate()}));v(this,"scheduleCapture",()=>this.store.scheduleCapture());v(this,"scheduleUpdate",()=>this.store.scheduleAction(Kt.NEVER));v(this,"onBlur",Ke(()=>{Bo=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));v(this,"onUnload",()=>{this.onBlur()});v(this,"disableEvent",t=>{t.preventDefault()});v(this,"preventBrowserZoomWheel",t=>{t[X.CTRL_OR_CMD]&&t.preventDefault()});v(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});v(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==X.PAGE_UP&&t.key!==X.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===X.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});v(this,"preventBrowserZoomKeyDown",t=>{t[X.CTRL_OR_CMD]&&(t.code===Tr.EQUAL||t.code===Tr.MINUS||t.code===Tr.ZERO||t.code===Tr.NUM_ADD||t.code===Tr.NUM_SUBTRACT||t.code===Tr.NUM_ZERO)&&t.preventDefault()});v(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Bo=!1,tu=!1,Fo=!1,nu=!1,ls=null,me.pointers.clear(),me.lastCenter=null,me.initialDistance=null,me.initialScale=null,clearTimeout(uc),uc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(ru),ru=0,ou=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),Et.set(zt,null),Et.set(ro,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&Tt(t)?t:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:"up",bindMode:"orbit",activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())});v(this,"handleInteractionStateChange",(t,o)=>{let r=this.isInteractionEnabled(t),i=r!==this.isInteractionEnabled(),a=t.viewModeEnabled!==this.props.viewModeEnabled,s=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(s=!!this.props.viewModeEnabled):s=!0,s!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:s});let l=r&&!o.viewModeEnabled,c=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||l&&!c)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,im(),this.cursor.reset())),this.isEmbedsEnabled(t)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(o.activeTool.type,t)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!=="selection"&&this.setState({activeTool:tn(this.state,{type:"selection"})}),(this.isBrowserZoomEnabled(t)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(t)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),o.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())});v(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));v(this,"handleForcedToolChange",(t,o)=>{let r=this.props.activeTool;if(!r)return;let i=!this.isSameForcedTool(t.activeTool,r);if(r.type==="image"){i&&console.warn('"image" tool cannot be forced via "props.activeTool"');return}this.isSameForcedTool(r,this.state.activeTool)||(i||o.activeTool!==this.state.activeTool||this.isToolSupported(r.type,t)!==this.isToolSupported(r.type,this.props))&&this.setActiveTool(r)});v(this,"resetHistory",()=>{this.history.clear()});v(this,"resetStore",()=>{this.store.clear()});v(this,"resetScene",Ke(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Ho(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));v(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async l=>{if(!l.files.length)return;let c=l.files[0],d=await c.getFile();this.loadFileToCanvas(new File([d],d.name||"",{type:d.type}),c)}),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}catch(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let o=Dr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=Ti(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,viewModeOnly:this.props.viewModeOnly||r.viewModeOnly,viewModeEnabled:this.props.viewModeOnly||this.props.viewModeEnabled||r.viewModeEnabled,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast};let a={...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},s=this.props.initialState?.viewport;if(s){let l=o.filter(m=>!m.isDeleted),c=lc(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...wi(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:Kt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),DM(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});v(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??TY(t,o));v(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=kY(),a=JM(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:tY,l=hb(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>s,isLandscape:o>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});v(this,"reconcileStylesPanelMode",t=>{let o=iu(t);if(o===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=o,this.viewport.invalidateUIOffset("stylesPanel"),r!=="full"&&o==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});v(this,"setDesktopUIMode",t=>{let o=MY(t);this.editorInterface=hb(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});v(this,"onResize",Ke(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Ei.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));v(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(gc=t),this.scheduleImageRefresh()});v(this,"onScroll",aM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},nY));v(this,"onCut",Ke(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||ac(t.target)||(this.actionManager.executeAction(tm,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onCopy",Ke(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||ac(t.target)||(this.actionManager.executeAction(sa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(SY&&t.preventDefault(),!pc){pc=!0,t.touches.length===1&&(hc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(uc),uc=window.setTimeout(e.resetTapTwice,oM);return}if(pc&&t.touches.length===1&&hc){let o=t.touches[0];so(oe(o.clientX,o.clientY),oe(hc.x,hc.y))<=dM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),pc=!1,clearTimeout(uc)}t.touches.length===2&&this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null})}});v(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}):me.pointers.clear())});v(this,"pasteFromClipboard",Ke(async t=>{if(!this.isInteractionEnabled())return;let o=!!ou,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||ac(r)))return;let s=await Wr(t),l=s.getFiles(),c=await Vd(s,o);if(this.state.viewModeEnabled){if(!this.containsImagePaste(c,l,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:l.map(d=>d.file),data:c,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));v(this,"addElementsFromPasteOrLibrary",t=>{let o=Dr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=ss(o),l=as(r,a)/2,c=as(i,s)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=ke({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,y]=Mt(E,g,this.getEffectiveGridSize()),{duplicatedElements:w}=EM({type:"everything",elements:o.map(A=>po(A,{x:A.x+b-r,y:A.y+y-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),I=[...x,...w];I=this.props.onDuplicate?.(I,x)||I,NM(I,lc(w));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let A=iX(w,C);I=Ib(I,A,C)}this.scene.replaceAllElements(I),w.forEach(A=>{if(Xt(A)&&xM(A)){let D=SM(A,this.scene.getElementsMapIncludingDeleted());qY(A,D,this.scene)}}),PY&&go.loadElementsFonts(w).then(A=>{this.fonts.onLoaded(A)}),t.files&&this.addMissingFiles(t.files);let P=wX(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Et.get(eb)?this.state.openSidebar:null,...BM(P,this.scene.getNonDeletedElements(),this.state)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t.fit&&this.viewport.setViewport({target:w,fit:t.fit,animation:!1,offsets:{ui:!0}})});v(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});v(this,"setAppState",(t,o)=>{let r=a=>!a||!this.state.viewModeOnly?a:{...a,viewModeOnly:!0,viewModeEnabled:!0},i=typeof t=="function"?(a,s)=>r(t(a,s)):r(t);this.setState(i,o)});v(this,"removePointer",t=>{Pr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=me.pointers.size>=2;me.pointers.delete(t.pointerId),o&&me.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});v(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Be("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...tn(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});v(this,"updateFrameRendering",t=>{this.setState(o=>{let r=typeof t=="function"?t(o.frameRendering):t;return{frameRendering:{enabled:r?.enabled??o.frameRendering.enabled,clip:r?.clip??o.frameRendering.clip,name:r?.name??o.frameRendering.name,outline:r?.outline??o.frameRendering.outline}}})});v(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});v(this,"revealIfHidden",t=>{!t.length||XY(t,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.viewport.getOffsets())||this.viewport.setViewport({target:ss(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});v(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:Yn(t.zoom)},shouldCacheIgnoreZoom:!1})});v(this,"scrollToContent",(t,o)=>{this.viewport.setViewport({target:t??this.scene.getNonDeletedElements(),fit:o?.fitToViewport?"contain":"scale-down",animation:o?.animate?{duration:o.duration??500}:!1,offsets:{ui:!0}})});v(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});v(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});v(this,"setToast",t=>{this.setState({toast:t})});v(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),o=await t.match("shared-file");if(o){let r=await o.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,$V,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});v(this,"addFiles",Ke(t=>{let o=new Map;for(let s of t){let l=s.id,c=this.imageCache.get(l);c&&!this.files[l]&&o.set(l,Promise.resolve(c.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());xb({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes}).then(async({updatedFiles:s})=>{for(let[l,c]of o){let d=this.imageCache.get(l);!d||!s.has(l)||(this.imageCache.set(l,{...d,placeholderImage:await c,transitionStart:performance.now()}),this.clearImageLoadingProgress(l))}i.size&&this.imagePlaceholderUpdateEmitter.trigger()}),i.size||this.addNewImagesToImageCache()}));v(this,"addImageElementsToScene",async(t,o,r)=>{let i=await Promise.all(t.map(async({file:s,customData:l})=>({file:await Lr(s),customData:l??{}}))),a=i.find(({file:s})=>!Si(s));if(a)throw new Eu(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:s})=>s),o,r,i.map(({customData:s})=>s))});v(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await Lr(o);if(!Si(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((l,c)=>{i.onload=()=>l(i),i.onerror=()=>c(new Error(f("errors.imageInsertError")))}),s={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===lo.gif?"pending":void 0};this.imageCache.set(t,s),s.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await kc(r);try{let l=await a;if(this.imageCache.get(t)!==s||this.files[t])return;this.imageCache.set(t,{...s,image:l}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(l){throw this.imageCache.get(t)===s&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),l}});v(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=oc(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});v(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});v(this,"setUploadProgress",(t,o,r)=>{if(o===null){this.updateImageStatus(t,i=>({...i,uploadProgress:null}));return}typeof o=="number"&&!Number.isFinite(o)||this.updateImageStatus(t,i=>{let a=i?.uploadProgress??void 0,s=r===void 0?a:r??void 0,l=typeof o=="number";return{...i,uploadProgress:{...s,state:l?"uploading":o,...l?{progress:oc(o,0,1)}:{progress:void 0}}}})});v(this,"updateImageStatus",(t,o)=>{let r=this.imageStatus.get(t),i=o(r);this.areImageStatusesEqual(r,i)||(i.downloadError===void 0&&!i.uploadProgress?this.imageStatus.delete(t):this.imageStatus.set(t,i),this.imageStatusEmitter.trigger())});v(this,"areImageStatusesEqual",(t,o)=>!!t?.downloadError==!!o?.downloadError&&!!t?.uploadProgress==!!o?.uploadProgress&&t?.downloadError?.backgroundColor===o?.downloadError?.backgroundColor&&t?.downloadError?.color===o?.downloadError?.color&&t?.downloadError?.trackColor===o?.downloadError?.trackColor&&t?.downloadError?.text===o?.downloadError?.text&&t?.downloadError?.onClick===o?.downloadError?.onClick&&t?.uploadProgress?.backgroundColor===o?.uploadProgress?.backgroundColor&&t?.uploadProgress?.color===o?.uploadProgress?.color&&t?.uploadProgress?.trackColor===o?.uploadProgress?.trackColor&&t?.uploadProgress?.state===o?.uploadProgress?.state&&t?.uploadProgress?.text===o?.uploadProgress?.text&&t?.uploadProgress?.onClick===o?.uploadProgress?.onClick&&t?.uploadProgress?.progress===o?.uploadProgress?.progress);v(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});v(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())fi(o)&&o.fileId===t&&Ei.delete(o)});v(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let s of a)if(!r[s.id]&&(i[s.id]=s,r[s.id]=s,s.mimeType===lo.svg))try{let l=fx(TM(Ex(s.dataURL)),lo.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});v(this,"updateScene",Ke(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?DY({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}r&&this.setState(r),o&&this.scene.replaceAllElements(o),i&&(this.laserTrails.updateCollabTrails(i),this.setState({collaborators:i}))}));v(this,"applyDeltas",(t,o)=>{let r=UM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return UM.applyTo(r,a,i,o)});v(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));v(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});v(this,"toggleSidebar",({name:t,tab:o,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===o?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&o&&(a.tab=o),this.setState({openSidebar:a}),!!i});v(this,"updateCurrentCursorPosition",Ke(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));v(this,"onKeyDown",Ke(t=>{if(!this.isInteractionEnabled())return;if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(l,c){let d=l[c];return typeof d=="function"?d.bind(l):c==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():d}})),!sM(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=ce(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Hn(l[0])&&t.key===X.ENTER){this.startImageCropping(l[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom(ro,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(gb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Xm(l);Et.get(ro)?.type==="panel"&&Yf(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(ro,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(ou=t.shiftKey,clearTimeout(ru),ru=window.setTimeout(()=>{ou=!1},100)),t[X.CTRL_OR_CMD]&&ac(t.target)&&(t.code===Tr.MINUS||t.code===Tr.EQUAL)){t.preventDefault();return}if(ac(t.target)&&t.key!==X.ESCAPE||db(t.key)&&sM(t.target))return;if(t.key===X.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===X.E&&t.shiftKey&&t[X.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===X.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Ro("COMPLEX_BINDINGS")?this.handleSkipBindMode():Qp({app:this,event:t});if(this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===X.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=Wy(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!mM(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&Be("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===Sr.sharp?Sr.round:this.state.currentItemArrowType===Sr.round?Sr.elbow:Sr.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),t.stopPropagation();return}else if(t.key===X.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[X.CTRL_OR_CMD]&&!t.repeat&&(Ro("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Ft(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Qp({app:this,event:t})),db(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>uo(u)).filter(u=>{let E=u.startBinding&&!l.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!l.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>c.add(u.id)),l=l.filter(u=>!c.has(u.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?nM:this.getEffectiveGridSize())||(t.shiftKey?JV:nM),m=0,p=0;t.key===X.ARROW_LEFT?m=-d:t.key===X.ARROW_RIGHT?m=d:t.key===X.ARROW_UP?p=-d:t.key===X.ARROW_DOWN&&(p=d),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),jp(u,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===X.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let c=l[0];if(t[X.CTRL_OR_CMD]||Cb(c))Ot(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Yt(c)||this.actionManager.executeAction(ba));else if(Xt(c)||CM(c)){let d;Xt(c)||(d=c);let m=wb(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else Tt(c)&&this.setState({editingFrame:c.id})}}if(t.key===X.SPACE&&me.pointers.size===0&&(Bo=!0,this.cursor.set(Me.GRAB),t.preventDefault()),t.key.toLowerCase()===X.Z&&!t[X.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(tu=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===X.G||t.key===X.S)&&!t.altKey&&!t[X.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===X.G&&(Go(this.state.activeTool.type)||l.some(c=>Go(c.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===X.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[X.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===X.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(c=>Xt(c)||yb(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===X.I&&!t.shiftKey&&!t[X.CTRL_OR_CMD],a=r===X.S&&t.shiftKey&&!t[X.CTRL_OR_CMD]||i,s=r===X.I&&t.shiftKey&&!t[X.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));v(this,"onKeyUp",Ke(t=>{if(this.isInteractionEnabled()){if(t.key===X.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.GRAB):$p(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Bo=!1),t.key.toLowerCase()===X.Z&&(tu=!1,this.cursor.reset()),t.key===X.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Qp({app:this,event:t})),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!Zp(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Ro("COMPLEX_BINDINGS"))){let o=ke({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Cr(oe(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=ge.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());uo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Ft(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),Qp({app:this,event:t})}if(db(t.key)){uM(this.scene.getSelectedElements(this.state).filter(cc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Pb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...VM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...VM(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));v(this,"setActiveTool",(t,o={})=>{let{keepSelection:r=!1}=o;if(!this.isToolSupported(t.type)){console.warn(this.isInteractionEnabled()?`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`:`"${t.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,t)){console.warn(`"${t.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(ut);let i=qi.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?tn(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?tn(this.state,{...t,lastActiveTool:this.state.activeTool}):tn(this.state,t);s.type==="hand"?this.cursor.set(Me.GRAB):Bo||this.cursor.applyForTool(s),hY(document.activeElement)&&this.focusContainer(),WY(s.type)||this.setState({suggestedBinding:null}),s.type==="image"&&this.onImageToolbarButtonClick(),this.setState(l=>{let c={snapLines:l.snapLines.length?[]:l.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:$p(s.type)?l.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return s.type==="freedraw"&&this.store.scheduleCapture(),s.type==="lasso"?{...l,...c,activeTool:s,...r?{}:{selectedElementIds:Ae({},l),selectedGroupIds:Ae({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:Ae({},l),selectedGroupIds:Ae({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});v(this,"setOpenDialog",t=>{this.setState({openDialog:t})});v(this,"isTouchScreenMultiTouchGesture",()=>me.pointers.size>=2);v(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${lM()}`);v(this,"onGestureStart",Ke(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null}),me.initialScale=this.state.zoom.value)}));v(this,"onGestureChange",Ke(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=me.initialScale;o&&this.viewport.translate(r=>({...ho({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));v(this,"onGestureEnd",Ke(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}),me.initialScale=null)}));v(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=$M(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&z2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});v(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=$M(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(jg,"ui",r),this.cursor.reset(),!0)});v(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s,arrowEndpoint:l})=>{let c=!1,d=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));d&&(i=null,r=!1,t=d.anchor[0],o=d.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(yb(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||iM(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!cc(i)){let C=uX(pb({fontSize:g,fontFamily:u}),E),P=hX(g,E),A=Math.max(i.height,P),D=Math.max(i.width,C);this.scene.mutateElement(i,{height:A,width:D}),t=i.x+D/2,o=i.y+A/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),y=d?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-_M(g,E)/2:b.y},w=this.getTopLayerFrameAtSceneCoords({x:y.x,y:y.y}),x=w&&(!c||!i||i.frameId===w.id)?w.id:null,I=p||gM({x:y.x,y:y.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:g,fontFamily:u,textAlign:d?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(m?iY.MIDDLE:eM),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?cc(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],T+1)}else this.insertNewElement(I);l&&d&&this.arrowText.bindText(l,I,d.fixedPoint),a||p||i?this.handleTextWysiwyg(I,{isExistingElement:!!p,initialCaretSceneCoords:p?s:null}):this.setState({newElement:I,multiElement:null})});v(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});v(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});v(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[o,r]=this.lastCompletedCanvasClicks;return so(oe(o.x,o.y),oe(r.x,r.y))<=dM});v(this,"handleCanvasDoubleClick",t=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!=="autoshape")return;let o=this.scene.getSelectedElements(this.state),{x:r,y:i}=ke(t,this.state);if(o.length===1&&Ot(o[0])){let s=o[0];if((t[X.CTRL_OR_CMD]&&Pb(s)||Cb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(ba);return}else if(this.state.selectedLinearElement&&Yt(o[0])){let l=ge.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?ge.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),ge.deleteFixedSegment(o[0],this.scene,c);let d=ge.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?ge.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&Cb(s))return}if(o.length===1&&Hn(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),xX(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&bX(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,...Un({editingGroupId:l,selectedElementIds:{[s.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let s=this.getElementAtPosition(r,i);if(dc(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let l=!t[X.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(l&&(this.state.activeTool.type==="autoshape"||bM(l)||!fY(l.backgroundColor)||mc({point:oe(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=wb(l,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});v(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==zn.MAIN){this.lastCompletedCanvasClicks=[];return}let o=ke(t,this.state),r=this.getImageStatusActionAtPosition(o);if(r){t.preventDefault(),t.stopPropagation(),r();return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});v(this,"getImageStatusActionAtPosition",t=>{if(!this.imageStatus.size)return null;let o=this.scene.getNonDeletedElementsMap(),r=this.visibleElements.length?this.visibleElements:this.scene.getNonDeletedElements();for(let i=r.length-1;i>=0;i--){let a=r[i];if(!Hn(a)||!a.fileId)continue;let s=this.imageStatus.get(a.fileId),l=s?.uploadProgress?.onClick;if(l&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>l(a.fileId);let c=s?.downloadError?.onClick;if(c&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>c(a.fileId)}return null});v(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Dl(o,r,this.state,i);return!!a&&so(oe(t.x,t.y),oe(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});v(this,"getElementLinkAtPosition",(t,o)=>{if(o&&o.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let s=r[a];if(o&&s.id===o.id&&(i=a),s.link&&a>=i&&Ic(s,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});v(this,"getElementLinkAtPositionForContextMenu",(t,o)=>{let r=this.getElementLinkAtPosition(t,o);if(r)return r;let i=this.scene.getNonDeletedElementsMap();for(let a of this.scene.getNonDeletedElements().slice().reverse())if(a.link&&!a.locked&&sx(a,i,this.state,oe(t.x,t.y)))return a});v(this,"handleElementLinkClick",t=>{let o=d=>d===zn.MAIN||d===zn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=so(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>tM)return;let i=ke(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=Ic(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),l=ke(this.lastPointerUpEvent,this.state),c=Ic(this.hitLinkElement,a,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(im(),this.openElementLink(this.hitLinkElement,t))});v(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=Xp(r);let i;if(this.props.onLinkOpen&&o&&(i=gY(J.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=mY(r)?"_self":"_blank",s=window.open(void 0,a);s&&(s.opener=null,s.location=r)}});v(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Me.POINTER),hv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(im(),!1));v(this,"maybeHandleElementLinkClick",(t,o)=>{if(this.editorInterface.isTouchScreen){let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(o,r)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(t),!0):!1});v(this,"handleInteractiveContentPointerMove",t=>{let o=ke(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});v(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=ke(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&kM(t,l,r));if(!i.length)return null;let a=i.at(-1),s=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(l=>!o?.excludeElementIds?.[l.id]);if(s){if(Tt(s)&&!s.locked)return a;let l=this.scene.getElementIndex(s.id),c=this.scene.getElementIndex(a.id);if(l!==-1&&c!==-1&&l<=c)return a;let d=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return d||(s.frameId?i.find(m=>m.id===s.frameId)??null:null)}return a});v(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});v(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&FX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});v(this,"insertNewElements",t=>{if(!t.length)return;let o=[];for(let r of t){let i=o[o.length-1];i?.[0].frameId===r.frameId?i.push(r):o.push([r])}for(let r of o){let i=r[0].frameId,a=i?QY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});v(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&Tt(o)?o:null)});v(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=Yn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...ho({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});v(this,"handleCanvasPointerMove",t=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(t),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!Fo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=ke(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),Bo||Fo||nu||ps(this.state))return;let s=pf(gc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?this.cursor.set(Me.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Me.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&N2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=R2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(y=>{let w=sc(y.snapLines,b),x=y.originSnapOffset?sc(y.originSnapOffset,g):g;return y.snapLines===w&&y.originSnapOffset===x?null:{snapLines:w,originSnapOffset:x}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let g=this.state.newElement?null:ge.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Ft(()=>{this.setState({selectedLinearElement:g})})}if(UY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&Zp(this.state)){let b=oe(r,i),y=this.scene.getNonDeletedElementsMap(),w=Cr(b,this.scene.getNonDeletedElements(),y,KM(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:kb(b,w,y,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:b}=this.state,{x:y,y:w,points:x}=g,I=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),I===T)so(oe(r-y,i-w),I)>=mb?(this.store.scheduleCapture(),Ft(()=>{mo(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length}}})}),this.scene.mutateElement(g,{points:[...x,oe(r-y,i-w)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Me.POINTER);else if(x.length>2&&T&&so(oe(r-y,i-w),T)<mb){this.cursor.set(Me.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let C=g.points.length-1;this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?[...new Set(b.selectedPointsIndices.map(P=>Math.min(P,C)))]:b.selectedPointsIndices,lastCommittedPoint:g.points[C],initialState:{...b.initialState,lastClickedPoint:C}}})}else{IM(x,this.state.zoom.value)&&this.cursor.set(Me.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Pb(g)){let A=Cr(oe(r,i),this.scene.getNonDeletedElements(),C);Ro("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,A)}mo(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=ge.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);P&&this.setState(P)}return}if(this.state.activeTool.type==="arrow"&&!this.state.newElement){let g=oe(r,i),b=Cr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),KM(this.state.zoom)),y=this.scene.getNonDeletedElementsMap();b&&!XM(g,b,y)&&this.setState({suggestedBinding:{element:b,midPoint:kb(g,b,y,this.state.zoom)}})}let l=!!t.buttons,c=this.state.activeTool.type==="laser";if(l||!c&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(Me.POINTER);return}if(m.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(m.length===1&&Yt(m[0]))&&!(Ot(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=OM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(FM(g));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=zM(ss(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(FM({transformHandleType:g}));return}}if(on(this.state))return;let p=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p;let E=this.arrowText.updateHoveredAnchor(o);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:o,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(o,p)),!this.applyElementLinkHoverAffordance()){if(c)return;u&&(u.link||No(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?this.cursor.set(E?Me.POINTER:Xt(u)?Me.TEXT:Me.CROSSHAIR):!t[X.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Me.MOVE):this.state.viewModeEnabled?this.cursor.set(Me.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.AUTO):s?this.cursor.set(Me.AUTO):!t[X.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Yt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Me.MOVE):this.cursor.set(Me.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:sc(g.hoveredElementIds,Un({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:sc(g.hoveredElementIds,{})}))});v(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});v(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(fc=!0)});v(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),Fo||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=ke(t,this.state),{x:i,y:a}=r;this.lastPointerMoveCoords={x:i,y:a};let s=t.target;if(s.setPointerCapture&&s.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.state.activeTool.type!=="laser"&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(VE,null)),Et.get(ro)&&this.updateEditorAtom(ro,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),tu){t.preventDefault(),this.focusContainer(),this.zDragZoom={origin:{clientX:t.clientX,clientY:t.clientY},initialZoom:this.state.zoom.value},this.setState({cursorButton:"down"});return}if(t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let g=this.state.newElement;this.updateScene({...g.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:Ae(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,y)=>(b[y]=this.state.selectedElementIds[y],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Kt.EVENTUALLY:Kt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=hb(this.editorInterface,{isTouchScreen:!0})),Fo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===zn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Gn.eraser){this.setState({activeTool:tn(this.state,{type:Gn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),y?.(),on(this.state)&&this.setState({activeTool:tn(this.state,{...this.state.activeTool.lastActiveTool||{type:Gn.selection},lastActiveTool:null})})},b=ye(window,J.POINTER_UP,g,{once:!0}),y;requestAnimationFrame(()=>{y=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==zn.MAIN&&t.button!==zn.TOUCH&&t.button!==zn.ERASER||me.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!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 g=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[X.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(w=>{let x={...w.selectedElementIds,[c.hit.element.id]:!0},I=[];Object.keys(w.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&I.push(P)});let T=c.hit.element;if(Tt(T))vb(I,T.id).forEach(C=>{delete x[C.id]});else if(T.frameId)x[T.frameId]&&delete x[T.id];else{let C=T.groupIds,P=new Set(C.flatMap(A=>bi(this.scene.getNonDeletedElements(),A)).filter(A=>Tt(A)).map(A=>A.id));P.size>0&&I.forEach(A=>{A.frameId&&P.has(A.frameId)&&(delete x[A.id],A.groupIds.flatMap(D=>bi(this.scene.getNonDeletedElements(),D)).forEach(D=>{delete x[D.id]}))})}return{...Un({editingGroupId:w.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:T.link||No(T)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===Gn.frame||this.state.activeTool.type===Gn.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(c):this.state.activeTool.type===Gn.bucketfill?this.bucketFill.handlePointerDown(r):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(c),p=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),E=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(J.POINTER_MOVE,m),window.addEventListener(J.POINTER_UP,p),window.addEventListener(J.KEYDOWN,u),window.addEventListener(J.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});v(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Ro("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let o=ke({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});v(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(fc=!1,Pr?fc=!0:Pr=window.setTimeout(()=>{Pr=0,fc||this.handleCanvasContextMenu(t)},rY))});v(this,"resetContextMenuTimer",()=>{clearTimeout(Pr),Pr=0,fc=!1});v(this,"maybeCleanupAfterMissingPointerUp",t=>{ls?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});v(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(me.pointers.size<=1&&((t.button===zn.WHEEL||t.button===zn.MAIN&&Bo||ps(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Fo=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let o=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);this.cursor.set(Me.GRABBING);let{clientX:i,clientY:a}=t,s=vm(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!o&&(Math.abs(d)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(J.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(J.PASTE,p),window.removeEventListener(J.POINTER_UP,u)},100)};document.body.addEventListener(J.PASTE,p),window.addEventListener(J.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-m/this.state.zoom.value})}),l=Ke(ls=()=>{ls=null,Fo=!1,Bo||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,s),window.removeEventListener(J.POINTER_UP,l),window.removeEventListener(J.BLUR,l),s.flush()});return window.addEventListener(J.BLUR,l),window.addEventListener(J.POINTER_MOVE,s,{passive:!0}),window.addEventListener(J.POINTER_UP,l),!0});v(this,"updateMultiTouchGesture",t=>{me.pointers.has(t.pointerId)&&me.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=me.initialScale;if(me.pointers.size===2&&me.lastCenter&&o&&me.initialDistance){let r=Jg(me.pointers),i=r.x-me.lastCenter.x,a=r.y-me.lastCenter.y;me.lastCenter=r;let s=Qg(Array.from(me.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/me.initialDistance,c=l?Yn(o*l):this.state.zoom.value;this.setState(d=>{let m=ho({viewportX:r.x,viewportY:r.y,nextZoom:c},d),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i/p,scrollY:m.scrollY+2*a/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else me.lastCenter=me.initialDistance=me.initialScale=null});v(this,"clearSelectionIfNotUsingSelection",()=>{$p(this.state.activeTool.type)||this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});v(this,"handleSelectionOnPointerDown",(t,o)=>{if($p(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Yt(a[0])&&!(Ot(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=OM(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType))}else a.length>1&&(o.resize.handleType=zM(ss(a),o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(o.resize.handleType)o.resize.isResizing=!0,o.resize.offset=ub(vX(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Ot(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=IX(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=ge.handlePointerDown(t,this,this.store,o.origin,p,this.scene);if(u.hitElement&&(o.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let E=this.scene.getNonDeletedElementsMap(),g=ge.getElement(p.elementId,E);if(g&&uo(g)){let{hitFocusPoint:b,pointerOffset:y,arrowOtherEndpointInitialBinding:w}=RX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:y,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:w}}}),!1}}let s=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),l=s.filter(p=>!p.locked),c=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:s});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!l.some(p=>this.state.selectedElementIds[p.id])?o.hit.element=null:o.hit.element=o.hit.element??this.getElementAtPosition(o.origin.x,o.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(o.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&o.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),o.hit.element&&this.getElementLinkAtPosition({x:o.origin.x,y:o.origin.y},o.hit.element))return!1;o.hit.allHitElements=l;let d=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||d&&d?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?Ae({[p.selectedLinearElement.elementId]:!0},this.state):Ae({},p)}));else if(d!=null){if(t[X.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...EX(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!RM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),Tt(d))vb(E,d.id).forEach(g=>{delete u[g.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let g=d.groupIds,b=new Set(g.flatMap(y=>bi(this.scene.getNonDeletedElements(),y)).filter(y=>Tt(y)).map(y=>y.id));b.size>0&&E.forEach(y=>{y.frameId&&b.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(w=>bi(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{...Un({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||No(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});v(this,"handleTextOnPointerDown",(t,o)=>{if(this.state.editingTextElement)return;let r=o.origin.x,i=o.origin.y;this.setState({hoveredArrowTextAnchor:null});let a=this.arrowText.getBindableEndpointAtPosition(r,i);if(a)this.startTextEditing({sceneX:r,sceneY:i,autoEdit:!1,arrowEndpoint:a});else{let s=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);bM(s)&&(l=s,r=s.x+s.width/2,i=s.y+s.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:tn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});v(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Mt(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=RY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("freedraw"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:l,strokeOptions:{variability:c,streamline:t.pointerType!=="mouse"?jV:ZV},locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:Ae(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});v(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=BY({type:"iframe",x:a,y:s,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("iframe"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.insertNewElement(l),l});v(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Mt(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=qp(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=hM({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("embeddable"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:s.intrinsicSize.w,height:s.intrinsicSize.h,link:r});return this.insertNewElement(l),l});v(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return zY({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("image"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,customData:i,x:a-c/2,y:s-c/2,width:c,height:c})});v(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Ft(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(mo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&IM(i.points,this.state.zoom.value)){Ft(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(ut);return}if(Yt(i)&&i.points.length>1){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=ke(t,this.state),{start:m,end:p}=uo(i)&&Zp(this.state)?OX(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),d.x,d.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),E=m?.mode!=null&&p.mode!=null&&m.element.id===p.element.id&&!XM(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&so(oe(r.origin.x-s,r.origin.y-l),c)<mb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(y=>({selectedElementIds:Ae({...y.selectedElementIds,[i.id]:!0},y)})),this.cursor.set(Me.POINTER)}else{let[i,a]=Mt(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?FY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Sr.round?{type:Vp.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Sr.elbow,fixedSegments:this.state.currentItemArrowType===Sr.elbow?[]:null}):GY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Vp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=Zp(this.state)?Cr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(p),uo(p)&&MX(p,new Map([[0,{point:oe(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:Qk(t.nativeEvent)}),Ft(()=>{this.setState(b=>{let y=null,w=b.selectedElementIds;if(Ot(p)){y=new ge(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;y={...y,selectedPointsIndices:[x],initialState:{...y.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:oe(r.origin.x,r.origin.y)}}}return w=this.isToolLocked()?b.selectedElementIds:Ae({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&uo(p)?{element:g,midPoint:kb(u,g,E,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:y}})}),uo(p)&&Ro("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});v(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Mt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},l;t==="embeddable"?l=hM({type:"embeddable",...s}):l=OY({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});v(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Mt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,..._o},s=o===Gn.magicframe?NY(a):_Y(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});v(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});v(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(uo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);Jp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);Jp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else Eb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&Jp(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&Jp(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||xM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,po(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});v(this,"initializeImage",async(t,o)=>{if(!Si(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===lo.svg)try{o=wu(TM(await o.text()),o.name)}catch(d){throw console.warn(d),new Error(f("errors.svgImageInsertError"))}else if(o.type!==lo.gif){let{maxWidthOrHeight:d}=this.props.imageOptions;try{o=await(this.props.compressImageFile??bx)(o,{maxWidthOrHeight:d})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===lo.gif,s=await(this.props.generateIdForFile?.(o)||gx(o));if(!s)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[s]?.dataURL){let{maxFileSizeBytes:d}=this.props.imageOptions;if(o.size>d)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(d/1024/1024)}MB`}))}let c=this.files[s]?.dataURL||await kc(o);return new Promise(async(d,m)=>{try{let p=this.getLatestInitializedImageElement(t,s);if(this.addMissingFiles([{mimeType:i,id:s,dataURL:c,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),a&&(p=this.gifPlayback.ensureElementPlaybackMetadata(p),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(g=>g.id===p.id?p:g)),this.imagePlaceholderUpdateEmitter.trigger()),!this.imageCache.get(s)){a||this.addNewImagesToImageCache();let{erroredFiles:g}=await this.updateImageCache([p]);if(g.size)throw new Error("Image cache update resulted with an error.")}let u=await this.imageCache.get(s)?.image,E=u?KY(u):null;if(u&&this.state.newElement?.id!==p.id){p=this.getLatestInitializedImageElement(t,s);let g=this.getImageNaturalDimensions(p,u);Object.assign(p,g)}p=po(p,{fileName:o.name,thumbHash:E,gifPlayback:a?this.gifPlayback.ensureElementPlaybackMetadata(p,{playing:!0}).gifPlayback:null,status:"saved"}),this.files={...this.files,[s]:{...this.files[s],fileName:o.name,thumbHash:E??void 0}},r&&r!==s&&this.gifPlayback.removePlaceholderDecodeState(r),d(p)}catch(p){this.gifPlayback.removePlaceholderDecodeState(r),console.error(p),m(new Error(f("errors.imageInsertError")))}})});v(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return po(r,{fileId:o})});v(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=ke({clientX:t,clientY:o},this.state),a=await ix({description:"Image",extensions:Object.keys(QV),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:tn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(ut)})}});v(this,"getImageNaturalDimensions",(t,o)=>{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(o.naturalHeight,i),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;return{x:l,y:c,width:s,height:a,crop:null}});v(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())fi(o)&&o.fileId===t&&Ei.delete(o);this.imagePlaceholderUpdateEmitter.trigger(),this.scene.triggerUpdate(),this.ensureGifPlaybackLoop()});v(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let s of t){let l=this.imageCache.get(s.fileId);l&&r.set(s.fileId,Promise.resolve(l.image))}let{updatedFiles:i,erroredFiles:a}=await xb({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(Kt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(fi(s)){if(a.has(s.fileId))return po(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return po(s,{status:"saved"})}return s}))),{updatedFiles:i,erroredFiles:a}});v(this,"ensureGifPlaybackLoop",()=>{this.gifPlayback.ensureLoop()});v(this,"loadDeferredGif",async t=>{let o=this.imageCache.get(t);this.files[t]?.mimeType!==lo.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await xb({imageCache:this.imageCache,fileIds:[t],files:this.files,onImageCacheUpdate:i=>this.handleImageCacheUpdate(i),forceGifDecode:!0}))});v(this,"getGifPlaybackFrameIndex",t=>this.gifPlayback.getFrameIndex(t));v(this,"setGifPlaybackFrameIndex",(t,o)=>{this.gifPlayback.setFrameIndex(t,o)});v(this,"addNewImagesToImageCache",async(t=jY(this.scene.getNonDeletedElements()),o=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,o);if(i.size)for(let a of r)i.has(a.fileId)&&Ei.delete(a);i.size&&this.scene.triggerUpdate()}});v(this,"scheduleImageRefresh",YV(()=>{this.addNewImagesToImageCache()},eY));v(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(J.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(J.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(J.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(J.TOUCH_END,this.onTouchEnd))});v(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=WM(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(s);let l=await Promise.all(s.map(async(u,E)=>{try{return await this.initializeImage(u,await Lr(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),po(u,{isDeleted:!0})}})),c=lc(l),d=WM(l.filter(u=>!u.isDeleted),o,r,a),m=lc(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:Ae(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:Kt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(ut)})});v(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=ke(t,this.state),i=Yh(t),a=await Wr(t),s=a.getFiles(),l=s.map(d=>d.file).filter(d=>Si(d));if(this.state.viewModeEnabled)return l.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:l,event:t})?void 0:this.insertImages(l,o,r,Wd(a,l.length,i));if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===lo.png||d.type===lo.svg))try{let p=await fs(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Kt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,Wd(a,l.length,i));if(s.length>0){let{file:d,fileHandle:m}=s[0];d&&await this.loadFileToCanvas(d,m)}let c=a.findByType(lo.text);if(c){let d=c.value;if(d&&bb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||qp(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:Xp(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});v(this,"loadFileToCanvas",async(t,o)=>{t=await Lr(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await fs(t,this.state,r,o)}catch(a){let s=a instanceof rx;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let l=s?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;QM(r.concat(i.elements)),this.store.scheduleMicroAction({action:Kt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Kt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});v(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==zn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=ke(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,s=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},s),c=l&&s.length===1&&s[0].link?s[0]:void 0,d=i??a??c,m=d||l?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;Be("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Un({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Ot(d)?new ge(d,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,d)}})})});v(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){GM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:as(t.origin.x,a.x),height:as(t.origin.y,a.y),shouldMaintainAspectRatio:rc(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s||this.arrowText.maybeDragNewText(s,a))return;let[l,c]=Mt(a.x,a.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=fi(s)&&this.imageCache.get(s.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:p,snapLines:u}=_2(s,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:l-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());l+=p.x,c+=p.y,this.setState({snapLines:u}),uo(s)||GM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:as(t.originInGrid.x,l),height:as(t.originInGrid.y,c),shouldMaintainAspectRatio:Hn(s)?!rc(o):rc(o),shouldResizeFromCenter:Jk(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===Gn.frame||this.state.activeTool.type===Gn.magicframe)&&this.setState({elementsToHighlight:Tb(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});v(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=Mt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Hn(l)){let c=t.originalElements.get(l.id),d=fi(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Hn(c)&&d&&!(d instanceof Promise)){let[m,p]=Mt(i.x,i.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=of([l],[c],this,o,u,r);this.scene.mutateElement(l,cX(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),jp(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});v(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(Tt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Yt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Mt(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{vb(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=Mt(s.x,s.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=of(r,ce(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(TX(t.originalElements,a,r,this.scene,Qk(o),Jk(o),r.some(m=>Hn(m))?!rc(o):rc(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{Tb(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{eu(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});v(this,"getImageContextMenuItems",t=>{let o=this.props.imageContextMenuItems;if(!o)return[];let r=this.scene.getSelectedElements(this.state);return r.length>0&&r.every(i=>Hn(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Hn(t)?[...o([t.id])]:[]});v(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Hn(r))&&(!t||this.state.selectedElementIds[t.id])?[ng,og]:[]});v(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=Xp(t.link),r=DM(o);return[{key:"goToLink",label:r?f("labels.link.goToElement"):"Go to link",onSelect:()=>this.openElementLink(t)},!r&&{key:"copyLink",label:f("buttons.copyLink"),onSelect:async()=>{await vo(o),this.setState({toast:{message:f("toast.elementLinkCopied"),closable:!0}})}}]});v(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o),i=this.getImageActionContextMenuItems(o),a=this.getElementLinkContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[el,la,va,ar]:[ag,je,ih,vv,je,la,Dt,tl,nl,va,ar];if(this.state.viewModeEnabled)return[...a,a.length>0&&je,el,sa,r.length>0&&je,...r];let s=this.editorInterface.formFactor==="desktop"?[je,th,nh,oh,rh]:[];return[je,el,je,tm,sa,ag,r.length>0&&je,...r,i.length>0&&je,...i,je,p2,u2,h2,je,Yg,je,Qh,jg,cg,dg,iv,eg,je,...s,je,rg,ig,je,ba,je,xg,a.length>0&&je,...a,je,ah,il,je,Cs]});v(this,"handleWheel",Ke(t=>{if(!this.isNavigationEnabled())return;if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&(t.target.classList.contains(gb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Fo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=aY*100,s=Math.abs(r),l=r;s>a&&(l=a*i);let c=this.state.zoom.value-l/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,s/20);let d=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:sY;c=Math.max(c,d),this.viewport.translate(p=>({...ho({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a})=>({scrollX:a-(r||o)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s})=>({scrollX:a-o/i.value,scrollY:s-r/i.value}))}));v(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=ke({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:me.pointers})});v(this,"resetShouldCacheIgnoreZoomDebounced",aM(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));v(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:s}=o.getBoundingClientRect(),{width:l,height:c,offsetTop:d,offsetLeft:m}=this.state;if(r===l&&i===c&&a===m&&s===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:s},()=>{t&&t()}),this.viewport.constrain()}});v(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});v(this,"watchState",()=>{});let o=Ho(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${lM()}`,wheelZoomsOnDefault:d=!1}=t,m=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?m=tn(o,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...o,theme:l,exportWithDarkMode:l===ic.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:m??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:s,gridModeEnabled:a??o.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:d},this.refreshEditorInterface(),this.stylesPanelMode=iu(this.editorInterface),this.id=KV(),this.actionManager=new bm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new HM,this.canvas=document.createElement("canvas"),this.rc=XV.canvas(this.canvas),this.renderer=new Tl(this.scene),this.visibleElements=[],this.store=new PX(this),this.history=new vl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new go(this.scene),this.history=new vl(this.store),this.actionManager.registerAll(Vc),this.actionManager.registerAction(b2(this.history)),this.actionManager.registerAction(x2(this.history)),this.api=this.createExcalidrawAPI()}get lastViewportPosition(){return this.viewport.lastPosition}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,addFiles:this.addFiles,addImagePlaceholder:this.addImagePlaceholder,setDownloadProgress:this.setDownloadProgress,setDownloadError:this.setDownloadError,setUploadProgress:this.setUploadProgress,addImageElementsToScene:this.addImageElementsToScene,scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:o=>{this.actionManager.registerAction(o)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:o=>this.onChangeEmitter.on(o),onIncrement:o=>this.store.onStoreIncrementEmitter.on(o),onPointerDown:o=>this.onPointerDownEmitter.on(o),onPointerUp:o=>this.onPointerUpEmitter.on(o),onScrollChange:o=>this.onScrollChangeEmitter.on(o),onUserFollow:o=>this.onUserFollowEmitter.on(o),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(t=this.props){return t.interaction!==!1&&typeof t.interaction!="object"}isLinksEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.links===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isNavigationEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.navigation===!0:t.interaction!==!1}isEmbedsEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.embeds===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isBrowserZoomEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.browserZoom===!0:!1}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type==="laser"||this.state.activeTool.type==="custom":this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(t=this.props){return t.ui!==!1&&(typeof t.ui!="object"||t.ui===null)}isUIControlEnabled(t,o=this.props){return typeof o.ui=="object"&&o.ui!==null?o.ui.enabled?.[t]===!0:o.ui!==!1}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let o=null;try{o=JSON.parse(t.data)}catch{}if(o)switch(t.origin){case"https://player.vimeo.com":if(o.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:o.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(o.event==="infoDelivery"&&o.info&&o.id&&typeof o.info.playerState=="number"){let r=o.id,i=o.info.playerState;Object.values(Yp).includes(i)&&Mb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){mo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Cr(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=ge.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Ft(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;mo(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?ge.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):ge.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);s&&this.setState(s)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||Yt(t))return;let r=()=>{if(this.bindModeHandler=null,mo(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let E=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!E&&!g||E&&g)return}let{x:m,y:p}=this.lastPointerMoveCoords,u=Cr(oe(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){mo(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Ft(()=>{mo(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:E}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;mo(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,y=p-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?ge.handlePointerMove(g,this,b,y,this.state.selectedLinearElement):ge.handlePointDragging(g,this,b,y,this.state.selectedLinearElement);w&&this.setState(w)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let m=this.scene.getNonDeletedElementsMap(),p=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),E=p?o:t.startBinding&&m.get(t.startBinding.elementId),g=u?o:t.endBinding&&m.get(t.endBinding.elementId),b=E&&YM(E,m),y=g&&YM(g,m);i=!!(b&&y&&E.id!==g.id&&AX(b,y))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Ft(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,IY)),this.previousHoveredBindableElement=o}cacheEmbeddableRef(t,o){o&&this.iFrameRefs.set(t.id,o)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==zn.MAIN||Bo||!mM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(ke({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=oe(ke({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(so(t,o)>tM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&me.pointers.size<2&&dc(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let s=i;if(this.state.activeEmbeddable?.element===s&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:s,state:"active"},selectedElementIds:{[s.id]:!0},newElement:null,selectionElement:null})},100),fb(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=Mb.get(s.id);switch(c||(Mb.set(s.id,Yp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case Yp.PLAYING:case Yp.BUFFERING:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return l.src.includes("player.vimeo.com")&&l.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}isIframeLikeElementCenter(t,o,r,i){return t&&!o.altKey&&!o.shiftKey&&!o.metaKey&&!o.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,o=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>No(a)&&this.embedsValidationStatus.get(a.id)===!0||fb(a));return Ce(UX,{children:i.map(a=>{let{x:s,y:l}=Kp({sceneX:a.x,sceneY:a.y},this.state),c=wM(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p=qp(pY(a.link||"")),u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",E=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover",g=p?.type==="video",b=oc(g?t:1,.75,GX);return Ce("div",{className:Kk("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:c?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:fX(a,Sb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?dY:1),"--embeddable-radius":`${$Y(Math.min(a.width,a.height),a)}px`},children:Ab("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?is.enabled:is.disabled},children:[E&&Ce("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Ce("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Ce("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(No(a)?this.props.renderEmbeddable?.(a,this.state):null)??Ce("iframe",{ref:y=>this.cacheEmbeddableRef(a,y),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:o,renderTopLeftUI:r,renderCustomStats:i}=this.props,{elementsMap:a,visibleElements:s,canvasNonce:l,newElementCanvasElement:c}=this.renderer.getRenderableElements({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,newElement:this.state.newElement,selectedElements:t,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=s,this.hasRenderableElements=a.size>0;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",p=t[0],u=Et.get(ro)?.type==="panel";return Ce("div",{translate:"no",className:Kk("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor==="phone"&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":m?is.disabled:is.enabled,"--right-sidebar-width":`${$f}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:Ce(cs.Provider,{value:this.api,children:Ce(e3.Provider,{value:this,children:Ce(t3.Provider,{value:this.props,children:Ce(Rb.Provider,{value:this.excalidrawContainerValue,children:Ce(_b.Provider,{value:this.editorInterface,children:Ce(Fb.Provider,{value:this.setAppState,children:Ce(Bb.Provider,{value:this.state,children:Ab(Nb.Provider,{value:this.scene.getNonDeletedElements(),children:[Ab(Ob.Provider,{value:this.actionManager,children:[Ce(Ck,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled("zoom"),scrollBackToContentUIEnabled:this.isUIControlEnabled("scrollBackToContent"),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:Kn().code,renderTopLeftUI:r,renderTopRightUI:o,renderCustomStats:i,showExitZenModeBtn:!1,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,currentUserControls:this.props.currentUserControls,children:this.props.children}),Ce("div",{className:"excalidraw-textEditorContainer"}),Ce("div",{className:"excalidraw-contextMenuContainer"}),Ce("div",{className:"excalidraw-eye-dropper-container"}),Ce(kk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Ce(Vk,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Ce(pv,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.isDefaultUIEnabled()&&this.state.contextMenu&&Ce(XT,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:E=>{this.setState({contextMenu:null},()=>{this.focusContainer(),E?.()})}}),Ce(sb,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:d,visibleElements:s,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,renderGrid:cr(this),renderLinks:this.isLinksEnabled(),imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),c&&Ce(Ok,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Ce(ab,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:d,selectedElements:t,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor==="phone"&&Ce(rp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Ce(Xk,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Ce(bT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{fi(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),Ei.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,jM()||qM()){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)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(r=>{this.props.onIncrement?.(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),lY&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),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),CY()&&!mX()&&this.setState({errorMessage:Ce(OT,{})});let o={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",o),this.props.onMount?.(o),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.gifPlayback.stop(),this.api={...this.api,isDestroyed:!0};for(let t of Object.keys(this.api))(t.startsWith("get")||t==="onStateChange"||t==="onEvent")&&typeof this.api[t]=="function"&&(this.api[t]=()=>{throw new Error("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new HM,this.fonts=new go(this.scene),this.renderer=new Tl(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),Ei.destroy(),hn.destroy(),clearTimeout(Pr),De.clearCache(),Un.clearCache(),Pr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(ye(window,J.MESSAGE,this.onWindowMessage,!1),ye(document,J.POINTER_UP,this.removePointer,{passive:!1}),ye(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),ye(window,J.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(ye(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),ye(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.handleNavigationModeKeyDown,!1),ye(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ye(document,J.GESTURE_START,this.onGestureStart,!1),ye(document,J.GESTURE_CHANGE,this.onGestureChange,!1),ye(document,J.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(ye(this.excalidrawContainerRef.current,J.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),ye(this.excalidrawContainerRef.current,J.GESTURE_START,this.disableEvent,!1),ye(this.excalidrawContainerRef.current,J.GESTURE_CHANGE,this.disableEvent,!1),ye(this.excalidrawContainerRef.current,J.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(ye(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(ye(document,J.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(ye(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),ye(document,J.COPY,this.onCopy,{passive:!1}),ye(document,J.KEYUP,this.onKeyUp,{passive:!0}),ye(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ye(document,J.GESTURE_START,this.onGestureStart,!1),ye(document,J.GESTURE_CHANGE,this.onGestureChange,!1),ye(document,J.GESTURE_END,this.onGestureEnd,!1),ye(document,J.PASTE,this.pasteFromClipboard,{passive:!1}),ye(this.excalidrawContainerRef.current,J.DRAG_OVER,this.disableEvent,!1),ye(this.excalidrawContainerRef.current,J.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(ye(document,J.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),ye(document,J.CUT,this.onCut,{passive:!1}),ye(window,J.RESIZE,this.onResize,!1),ye(window,J.UNLOAD,this.onUnload,!1),ye(window,J.BLUR,this.onBlur,!1),ye(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(ye(uY(this.excalidrawContainerRef.current),J.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,o){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(t,o),this.handleForcedToolChange(t,o),this.ensureGifPlaybackLoop(),this.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===ic.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.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)),Object.keys(this.state.selectedElementIds).length&&on(this.state)&&this.setState({activeTool:tn(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&o.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type==="bucketfill"&&o.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),o.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),on(o)&&!on(this.state)&&this.eraserTrail.endPath(),(o.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&o.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ic.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(ut)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let c=s.filter(d=>{let m=this.scene.getElement(d);return!m||m.isDeleted});c.length&&this.setState(d=>{let m={...d.selectedElementIds};for(let p of c)delete m[p];return{selectedElementIds:Ae(m,d)}})}if(this.state.editingTextElement){let c=this.scene.getElement(this.state.editingTextElement.id);(!c||c.isDeleted)&&this.setState({editingTextElement:null})}let l=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==l&&this.setState({scrolledOutside:l}),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(){pc=!1,hc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=ke({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let d=Om(t.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:t.text}});return}}let s=o.map(d=>d.file);if(s.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&s.push(wu(d))}if(s.length>0){this.isToolSupported("image")?await this.insertImages(s,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(t.elements){let d=t.programmaticAPI?DX(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!t.text)return;let l=bY(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>ZY(d)).filter(d=>bb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||qp(d)?.type==="video"));if(!r&&c.length>0&&c.length===l.length){let d=[];for(let m of c){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Xp(m)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Si(a.file))||!r&&t.mixedContent?.some(a=>a.type==="imageUrl"))return!0;if(r||!t.text)return!1;let i=t.text.trim();return i.startsWith("<svg")&&i.endsWith("</svg>")}shouldInsertImageInViewMode({source:t,files:o,data:r,event:i}){return this.state.viewModeEnabled?this.state.viewModeOnly||this.props.viewModeImageInsertBehavior==="reject"?(this.props.onViewModeImageInsertRejected?.({source:t,files:o,data:r,event:i}),!1):(Ft(()=>{this.setState({viewModeEnabled:!1})}),!0):!0}async addElementsFromMixedContentPaste(t,{isPlainPaste:o,sceneX:r,sceneY:i}){if(!o&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(d=>d.type==="imageUrl").map(d=>d.value),s=await Promise.all(a.map(async d=>{try{return{file:await xx(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(l,r,i);let c=s.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(s=>s.type==="text");a.length&&this.addTextFromPaste(a.map(s=>s.value).join(`
|
|
22
22
|
|
|
23
|
-
`),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=
|
|
24
|
-
`),g=E.reduce((b,y,w)=>{let x=RY(y).trim();if(x.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=dM(x,s,l),C=T.width>m,P=C?DY(x,s,m):x;T=C?dM(P,s,l):T;let A=r-T.width/2,L=u-T.height/2,_=Xk({...a,x:A,y:L,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:v?v.id:null});b.push(_),u+=_.height+p}else E[w-1]?.trim()&&(u+=mM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:ke(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&PM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),PM=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(s,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===t.id&&Wt(c)?no(c,{originalText:s,isDeleted:l??c.isDeleted,...cY(c,oM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=F2({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=Hp({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Ye(s=>{a(s,!1),Kp(t)&&Wp(t,this.scene)}),onSubmit:Ye(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Rt(()=>{this.setState(m=>({selectedElementIds:ke({...m.selectedElementIds,[d]:!0},m)}))}),c&&eY(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Rt(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(t){let o=this.scene.getSelectedElements(this.state);if(o.length!==1)return null;let r=o[0];return Wt(r)?r:t?mb(r,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(t,o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1||!t||t.id!==r[0].id)return null;let i=r[0];if(Wt(i))return null;if(!rM(i))return;let a=this.getSelectedTextElement(i),s=this.getTextElementAtPosition(o.x,o.y);if(!(!a||s?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&Wt(r)&&!r.isDeleted?r:null}getElementAtPosition(t,o,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,o,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let s=i.length-1;s>-1;s--)if(this.state.selectedElementIds[i[s].id])return i[s]}let a=i[i.length-1];return nc({point:ne(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,o,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(r?.includeLockedElements||!l.locked)&&(r?.includeBoundTextElement||!(Wt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=fb(l,a);return c&&!Kp(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!tc(l)?aM({x:t,y:o},c,a):!0}).filter(l=>tc(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(Nk/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&wY([r],this.state,this.editorInterface)&&jY(ne(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||kY(ne(t,o),r,this.scene.getNonDeletedElementsMap())?!0:nc({point:ne(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,o){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return qk(i[0],!1)?i[0]:null;let a=null;for(let s=r.length-1;s>=0;--s){if(r[s].isDeleted)continue;let[l,c,d,m]=Wk(r[s],this.scene.getNonDeletedElementsMap());if(ec(r[s])&&nc({point:ne(t,o),element:r[s],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[s])})){a=r[s];break}else if(l<t&&t<d&&c<o&&o<m){if(vt(r[s]))continue;a=r[s];break}}return qk(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Wt(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=me.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;nc({point:ne(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=me.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=me.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Ut(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Pe.POINTER):this.hitElement(o,r,a)&&(!Ut(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE)):this.hitElement(o,r,a)&&(!Ut(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),me.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=tX(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(Pe.POINTER)}else this.cursor.set(Pe.AUTO)}updateGestureOnPointerDown(t){le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),le.pointers.size===2&&(le.lastCenter=Yg(le.pointers),le.initialScale=this.state.zoom.value,le.initialDistance=Xg(Array.from(le.pointers.values())))}initialPointerDownState(t){let o=Ce(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=ja(r),c=r.findIndex(Ut)===0;return{origin:o,withCmdOrCtrl:t[X.CTRL_OR_CMD],originInGrid:ib(Ct(o.x,o.y,t[X.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:rf(ac,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,Kk(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(s+i)/2,y:(l+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(o,r)},drag:{hasOccurred:!1,offset:null,origin:{...o},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,o){if(!(o.scrollbars.isOverEither&&!this.state.multiElement))return!1;$p=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=fm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Ye(()=>{Qa=null,$p=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,r),window.removeEventListener(J.POINTER_UP,i),r.flush()});return Qa=i,window.addEventListener(J.POINTER_MOVE,r),window.addEventListener(J.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,o){if(o.length<2)return!1;let r=Math.max(Nk/this.state.zoom.value,1),i=xV*2/this.state.zoom.value,[a,s,l,c]=ja(o);return t.x>a-i-r&&t.x<l+i+r&&t.y>s-i-r&&t.y<c+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:pY(t)?Op.ADAPTIVE_RADIUS:Op.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return JV(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){Eo({event:t,app:this,selectedElements:o})&&(r||!cn.getReferenceSnapPoints())&&cn.setReferenceSnapPoints(x2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){Eo({event:t,app:this,selectedElements:o})&&(r||!cn.getVisibleGaps())&&cn.setVisibleGaps(b2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ye(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Ye(o=>{o.key===X.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return fm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Ce(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=Ct(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=me.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=me.moveFixedSegment(this.state.selectedLinearElement,E,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:g.segmentMidPointHoveredCoords,initialState:g.initialState}});return}let i=this.previousPointerMoveCoords??t.origin;if(this.previousPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=ib(ZY(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(Jt(this.state)){this.handleEraser(o,r);return}if(this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y),this.drawShape.handlePointerMove(r))return;let[s,l]=Ct(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){eX(p,c,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...p,isDragging:!1,selectedPointsIndices:[],initialState:{...p.initialState,lastClickedPoint:-1}}});return}if(me.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=me.addMidpoint(this.state.selectedLinearElement,r,this,!o[X.CTRL_OR_CMD],this.scene);if(!u)return;Rt(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=me.getElement(p.elementId,c);if(u?.isDeleted)return;if(oo(u)){let g=br(ne(r.x,r.y),this.scene.getNonDeletedElements(),c);So("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&So("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=me.handlePointDragging(o,this,r.x,r.y,p);if(E){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(E.suggestedBinding!==this.state.suggestedBinding||!Hk(E.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||E.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||E.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==E.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==E.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(E);return}}}}let d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(g=>g.locked))return;let E=p.some(g=>vt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:iM(p),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(E),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&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 g={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},b=[...t.originalElements.values()],y=o.shiftKey;if(y){let v=Math.abs(g.x),T=Math.abs(g.y),C=y&&v<T,P=y&&v>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let v=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(v&&Rn(v)&&v.crop!==null&&t.hit.element===v){let T=v.crop,C=qa(v)&&this.imageCache.get(v.fileId)?.image;if(C&&!(C instanceof Promise)){let P=rX(v),A=Sk(r.x-i.x,r.y-i.y);A[0]*=C.naturalWidth/P.width,A[1]*=C.naturalHeight/P.height;let[L,_,k,D,O,Y]=Wk(v,c),z=tb(eb(ne(L,_),ne(O,Y),v.angle)),W=tb(eb(ne(k,_),ne(O,Y),v.angle)),Z=tb(eb(ne(L,D),ne(O,Y),v.angle)),H=kk(Ck(W,z)),re=kk(Ck(Z,z)),B=Sk(Pk(A,H),Pk(A,re)),U={...T,x:Zl(T.x-B[0]*Math.sign(v.scale[0]),0,C.naturalWidth-T.width),y:Zl(T.y-B[1]*Math.sign(v.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(v,{crop:U});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:w,snapLines:x}=w2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||KY(t,p,g,this.scene,w,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let v=this.scene.getElementsIncludingDeleted(),T=t.hit.element,C=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});T&&t.hit.wasAddedToSelection&&!C.find(z=>z.id===T.id)&&C.push(T);let P=new Map(C.map(z=>[z.id,z])),{duplicatedElements:A,duplicateElementsMap:L,elementsWithDuplicates:_,origIdToDuplicateId:k}=Zk({type:"in-place",elements:v,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:W})=>({frameId:z.frameId??W.frameId,seed:WV()})});A.forEach(z=>{t.originalElements.set(z.id,Kk(z))});let D=_.map(z=>{if(P.has(z.id)){let W=t.originalElements.get(z.id);if(W)return no(z,{x:W.x,y:W.y})}return z}),O=this.props.onDuplicate?.(D,v),Y=uM(O||D,Ql(A));Rt(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),W=z&&L.get(z);t.hit.element=W||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,W)=>{let Z=k.get(W.id),H=Z&&L.get(Z);return H&&z.push(H),z},[]),t.drag.origin=Ce(o,this.state),this.setState(z=>({...hM(A,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(Y),C.forEach(z=>{cb(z)&&z.boundElements?.some(W=>W.type==="arrow")&&Wp(z,this.scene)}),this.maybeCacheVisibleGaps(o,C,!0),this.maybeCacheReferenceSnapPoints(o,C,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,o.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},{keepSelection:o.shiftKey}),this.lassoTrail.startPath(t.origin.x,t.origin.y,o.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,o)}else if(this.state.activeTool.type==="lasso")!o.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,o),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,o.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,E=r.x-p.x,g=r.y-p.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===E&&b[1]===g)){let w=p.simulatePressure?p.pressures:[...p.pressures,o.pressure];this.scene.mutateElement(p,{points:[...u,ne(E,g)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Nt(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;to(u.length>1,"Do not create linear elements with less than 2 points");let E=this.state.selectedLinearElement;(!E||E.elementId!==p.id)&&(E=new me(p,this.scene.getNonDeletedElementsMap())),E&&(E.initialState.lastClickedPoint<0||E.initialState.lastClickedPoint>=u.length)&&(console.warn("Last clicked point is out of bounds. Attempting to fix it."),E={...E,selectedPointsIndices:[u.length-1],initialState:{...E.initialState,prevSelectedPointsIndices:null,lastClickedPoint:u.length-1},hoverPointIndex:u.length-1}),this.setState({newElement:p,...me.handlePointDragging(o,this,s,l,E)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)me.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Me(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Nn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?Yb(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((y,w)=>(y[w.id]=!0,y),{})};return t.hit.element&&(E.length?delete b[t.hit.element.id]:b[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...Nn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Nt(E[0])?new me(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Co(E[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,o){if(o.scrollbars.isOverHorizontal){let r=t.clientX,i=r-o.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-i*(ac.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.x=r,!0}if(o.scrollbars.isOverVertical){let r=t.clientY,i=r-o.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-i*(ac.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ye(o=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(o),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush(),o.type==="pointerup"&&this.state.activeTool.type===_n.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:c,isResizing:d,isRotating:m,isCropping:p}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Jl(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,cn.setReferenceSnapPoints(null),cn.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Ce({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(So("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let x=r.get(t.hit.element.id);cb(x)&&x.boundElements?.filter(v=>v.type==="arrow").map(v=>r.get(v.id)).filter(v=>Ut(v)).forEach(v=>{v&&this.scene.mutateElement(v,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(mt);else{let x=me.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(mt,"ui",{event:o,sceneCoords:E}),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:x,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=me.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(oX(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(mt,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Nt(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:x}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x.points[x.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(J.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(J.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(J.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(J.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Ce(o,this.state),v=i.points,T=x.x-i.x,C=x.y-i.y;T===v[0][0]&&C===v[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...v,ne(T,C)],pressures:P}),this.actionManager.executeAction(mt);return}if(Nt(i)&&this.state.activeTool.type!=="autoshape"){let x=Ce(o,this.state),v=Qn(ne(x.x,x.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||v<VV)&&i&&!l)if(this.editorInterface.isTouchScreen){let T=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-T/2,points:[ne(0,0),ne(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(mt)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Nt(i)&&this.actionManager.executeAction(mt,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:jt(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ke({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new me(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Wt(i)){let x=OY(rb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&Qk(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:qt.NEVER});return}if(vt(i)){let x=TY(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(hb(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,uY(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Ce(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let v=this.scene.getElement(this.state.selectedLinearElement.elementId);if(v?.frameId){let T=fb(v,r);T&&v&&(SY(v,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(v,{groupIds:[]}),IY([v],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let v=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:iM(v),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=A=>{if(A.length>0){for(let L of A){let _=L.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(L,{groupIds:L.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(L=>{L.groupIds.length&&si(C,L.groupIds[L.groupIds.length-1]).length<2&&this.scene.mutateElement(L,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let A=v.filter(L=>lM(L,C,this.state));this.state.editingGroupId&&P(A),C=hb(C,A,T)}else if(!T&&this.state.editingGroupId){let A=v.filter(L=>L.frameId&&!lM(L,C,this.state));P(A)}C=sM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&Qk(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:qt.NEVER}),t.resize.isResizing){let x=sM(this.scene.getElementsIncludingDeleted(),this.state,this),v=this.scene.getSelectedElements(this.state).filter(vt);for(let T of v)x=vY(x,gb(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Nt(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new me(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Jt(this.state)&&b&&y){if(this.eraserTrail.endPath(),Qn(ne(b.clientX,b.clientY),ne(y.clientX,y.clientY))===0){let v=Ce({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(v.x,v.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(g&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(o.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?UY(this.state,g)?this.setState(x=>{let v={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>si(this.scene.getNonDeletedElements(),C)))delete v[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:ke(v,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let v={...x.selectedElementIds};delete v[g.id];let T=se(this.scene.getNonDeletedElements(),{selectedElementIds:v});return{...Nn({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Nt(T[0])?new me(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let v={...x.selectedElementIds,[g.id]:!0};return delete v[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>si(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete v[T.id]}),{...Nn({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Co(g)?"info":!1}}):this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Nn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Nt(g)&&x.selectedLinearElement?.elementId!==g.id?new me(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Ut(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&MY({point:ne(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:vt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(aa):this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Pe.AUTO);return}let w=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[X.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Wt(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||w)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:w,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Co(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Me(this.scene.getNonDeletedElements(),this.state)||!Hk(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||p){let x=this.scene.getSelectedElements(this.state).filter(ec);Vk(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(mt);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==_n.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:jt(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:ke({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&pM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,s=i.y+i.height/2,l=pb(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<SV){let{x:m,y:p}=Hp({sceneX:a,sceneY:s},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:s}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:o,top:r}=t.getBoundingClientRect();return{offsetLeft:o,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=gi.find(o=>o.code===this.props.langCode)||zn;await Sc(t),this.setAppState({})}},cX=()=>{(kM()||MM())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(LM(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};cX();var RM=Ib;import{useEffect as mX,useState as pX}from"react";import{jsx as uX}from"react/jsx-runtime";var NM=e=>{let[n,t]=pX(!0);return mX(()=>{let o=async()=>{await Sc(r),t(!1)},r=gi.find(i=>i.code===e.langCode)||zn;o()},[e.langCode]),n?uX(ep,{theme:e.theme}):e.children};import hX from"clsx";import{jsx as BM}from"react/jsx-runtime";var OM=({children:e})=>{let{FooterCenterTunnel:n}=tt(),t=fe();return BM(n.In,{children:BM("div",{className:hX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},gX=OM;OM.displayName="FooterCenter";import fX from"clsx";import{MQ_MIN_WIDTH_DESKTOP as EX}from"@excalidraw/common";import{jsx as xX,jsxs as wX}from"react/jsx-runtime";var FM=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=fe(),i=t?.formFactor!=="desktop"||r.width<EX;return wX(fn,{...o,className:fX("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?Gx:f("labels.share"),r.collaborators.size>0&&xX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},bX=FM;FM.displayName="LiveCollaborationTrigger";import{jsx as wr,jsxs as HM}from"react/jsx-runtime";var yX=()=>wr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:wr("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"})}),vX=()=>HM("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[wr("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)"}),wr("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)"}),wr("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)"}),wr("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)"})]}),zM=({style:e,size:n="small",withText:t})=>HM("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[wr(yX,{}),t&&wr(vX,{})]});import{Fragment as WM,jsx as it,jsxs as Ab}from"react/jsx-runtime";var Lb=({icon:e,shortcut:n,children:t})=>{let o=ge();return Ab(WM,{children:[it("div",{className:"welcome-screen-menu-item__icon",children:e}),it("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&it("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};Lb.displayName="WelcomeScreenMenuItemContent";var lc=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>it("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:it(Lb,{icon:t,shortcut:o,children:n})});lc.displayName="WelcomeScreenMenuItem";var GM=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>it("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:it(Lb,{icon:t,shortcut:o,children:e})});GM.displayName="WelcomeScreenMenuItemLink";var bn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=tt();return it(n.In,{children:it("div",{className:"welcome-screen-center",children:e||Ab(WM,{children:[it(Db,{}),it(_b,{children:f("welcomeScreen.defaults.center_heading")}),Ab(Rb,{children:[it(Bb,{}),it(Nb,{})]})]})})})};bn.displayName="Center";var Db=({children:e})=>it("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||it(zM,{withText:!0})});Db.displayName="Logo";var _b=({children:e})=>it("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});_b.displayName="Heading";var Rb=({children:e})=>it("div",{className:"welcome-screen-menu",children:e});Rb.displayName="Menu";var Nb=()=>{let e=nt();return it(lc,{onSelect:()=>e.executeAction(Hr),shortcut:"?",icon:wi,children:f("helpDialog.title")})};Nb.displayName="MenuItemHelp";var Bb=()=>{let e=fe(),n=nt();return e.viewModeEnabled?null:it(lc,{onSelect:()=>n.executeAction(Ui),shortcut:Ke("loadScene"),icon:Ac,children:f("buttons.load")})};Bb.displayName="MenuItemLoadScene";var UM=({onSelect:e})=>{let{t:n}=Ae();return it(lc,{shortcut:null,onSelect:e,icon:Lc,children:n("labels.liveCollaboration")})};UM.displayName="MenuItemLiveCollaborationTrigger";bn.Logo=Db;bn.Heading=_b;bn.Menu=Rb;bn.MenuItem=lc;bn.MenuItemLink=GM;bn.MenuItemHelp=Nb;bn.MenuItemLoadScene=Bb;bn.MenuItemLiveCollaborationTrigger=UM;import{jsx as ts,jsxs as Ob}from"react/jsx-runtime";var eu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=tt();return ts(n.In,{children:Ob("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Ix,ts("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};eu.displayName="MenuHint";var tu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=tt();return ts(n.In,{children:Ob("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ts("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),Sx]})})};tu.displayName="ToolbarHint";var nu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=tt();return ts(n.In,{children:Ob("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ts("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Tx]})})};nu.displayName="HelpHint";import{Fragment as VM,jsx as cc,jsxs as TX}from"react/jsx-runtime";var ou=e=>cc(VM,{children:e.children||TX(VM,{children:[cc(bn,{}),cc(eu,{}),cc(tu,{}),cc(nu,{})]})});ou.displayName="WelcomeScreen";ou.Center=bn;ou.Hints={MenuHint:eu,ToolbarHint:tu,HelpHint:nu};var IX=ou;var SX=()=>{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}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,n){return this.slice().reverse().find((t,o)=>e.call(n,t,this.length-o-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,n){for(let t=0;t<this.length;t++)if(e.call(n,this[t],t,this))return t;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,n){let t=this.slice().reverse().findIndex((o,r)=>e.call(n,o,this.length-r-1,this));return t===-1?-1:this.length-t-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},YM=SX;import{getSceneVersion as BWe,hashElementsVersion as OWe,hashString as FWe,getNonDeletedElements as zWe}from"@excalidraw/element";import{getTextFromElements as GWe}from"@excalidraw/element";import{isInvisiblySmallElement as WWe}from"@excalidraw/element";import CX from"lodash.throttle";import{arrayToMap as PX,isDevEnv as XM,isTestEnv as KM}from"@excalidraw/common";import{orderByFractionalIndex as kX,syncInvalidIndices as ZM,validateFractionalIndices as MX}from"@excalidraw/element";var AX=(e,n,t)=>!!(n&&(n.id===e.editingTextElement?.id||n.id===e.resizingElement?.id||n.id===e.newElement?.id||n.version>t.version||n.version===t.version&&n.versionNonce<=t.versionNonce)),LX=CX((e,n,t)=>{if(XM()||KM()||window?.DEBUG_FRACTIONAL_INDICES){let o=ZM(e.map(r=>({...r})));MX(o,{shouldThrow:KM()||XM(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),DX=(e,n,t)=>{let o=PX(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=AX(t,l,s);l&&c?(r.push(l),i.add(l.id)):(r.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(r.push(s),i.add(s.id));let a=kX(r);return LX(a,e,n),ZM(a),a};import{isLinearElement as QWe}from"@excalidraw/element";import{FONT_FAMILY as tVe,THEME as nVe,MIME_TYPES as oVe,ROUNDNESS as rVe,DEFAULT_LASER_COLOR as iVe,UserIdleState as aVe,normalizeLink as sVe,sceneCoordsToViewportCoords as lVe,viewportCoordsToSceneCoords as cVe,getFormFactor as dVe,throttleRAF as mVe}from"@excalidraw/common";import{mutateElement as uVe,newElementWith as hVe,bumpVersion as gVe}from"@excalidraw/element";import{CaptureUpdateAction as EVe}from"@excalidraw/element";import{getCommonBounds as CVe,getVisibleSceneBounds as PVe,convertToExcalidrawElements as kVe}from"@excalidraw/element";import{elementsOverlappingBBox as AVe}from"@excalidraw/element";import{isElementLink as _Ve}from"@excalidraw/element";import{setCustomTextMetricsProvider as BVe}from"@excalidraw/element";import{jsx as dc}from"react/jsx-runtime";YM();var LWe=({children:e})=>{let[n,t]=FX(null);return dc(es.Provider,{value:n,children:dc(Qp.Provider,{value:t,children:e})})},HX=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=zn.code,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,onPaste:O,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:W=!0,handleKeyboardGlobally:Z=!1,autoFocus:H=!1,compressImageFile:re,generateIdForFile:B,onLinkOpen:U,generateLinkForSelection:ue,onPointerDown:we,onPointerUp:pe,onScrollChange:he,onUserFollow:ye,userToFollow:ae,onDuplicate:ve,imageContextMenuItems:lt,children:je,validateEmbeddable:Re,renderEmbeddable:Lo,showDeprecatedFonts:li,wheelZoomsOnDefault:mc,strokeColorTopPicks:pc,backgroundColorTopPicks:uc,renderScrollbars:ru,viewportStatusFrame:yr,currentUserControls:Bn,imageOptions:ns,showDropEventDebugAlert:jM}=e,iu=e.UIOptions?.canvasActions,hc={...e.UIOptions,canvasActions:{...$M.canvasActions,...iu},tools:{image:e.UIOptions?.tools?.image??!0}};iu?.export&&(hc.canvasActions.export.saveFileToDisk=iu.export?.saveFileToDisk??$M.canvasActions.export.saveFileToDisk),hc.canvasActions.toggleTheme===null&&(P==null||r)&&(hc.canvasActions.toggleTheme=!0);let qM={maxFileSizeBytes:ns?.maxFileSizeBytes??Ao.maxFileSizeBytes,maxWidthOrHeight:ns?.maxWidthOrHeight??Ao.maxWidthOrHeight,placeholderTransitionDuration:ns?.placeholderTransitionDuration??Ao.placeholderTransitionDuration},Fb=NX(Qp),zb=OX(l);zb.current=l;let JM=RX(au=>{Fb?.(au),zb.current?.(au)},[Fb]),Hb=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return BX(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Hb)return;let Gb=su=>{typeof su.scale=="number"&&su.scale!==1&&su.preventDefault()};return document.addEventListener("touchmove",Gb,{passive:!1}),()=>{document.removeEventListener("touchmove",Gb)}},[Hb]),dc(fx,{store:gt,children:dc(NM,{langCode:b,theme:P,children:dc(RM,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:JM,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,UIOptions:hc,onPaste:O,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:W,handleKeyboardGlobally:Z,autoFocus:H,compressImageFile:re,generateIdForFile:B,onLinkOpen:U,generateLinkForSelection:ue,onPointerDown:we,onPointerUp:pe,onScrollChange:he,onUserFollow:ye,userToFollow:ae,onDuplicate:ve,imageContextMenuItems:lt,validateEmbeddable:Re,renderEmbeddable:Lo,showDeprecatedFonts:li,wheelZoomsOnDefault:mc,strokeColorTopPicks:pc,backgroundColorTopPicks:uc,renderScrollbars:ru,viewportStatusFrame:yr,currentUserControls:Bn,imageOptions:qM,showDropEventDebugAlert:jM,children:je})})})},GX=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:s,...l}=e,{initialData:c,UIOptions:d={},imageOptions:m,interaction:p,ui:u,activeTool:E,...g}=n;if(!(s===E||s?.type===E?.type&&(s?.type==="custom"?s.customType:null)===(E?.type==="custom"?E.customType:null))||!(i===p||typeof i=="object"&&i!==null&&typeof p=="object"&&p!==null&&!!i.enabled?.links==!!p.enabled?.links&&!!i.enabled?.embeds==!!p.enabled?.embeds&&!!i.enabled?.interactiveContent==!!p.enabled?.interactiveContent&&!!i.enabled?.navigation==!!p.enabled?.navigation&&!!i.enabled?.browserZoom==!!p.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!p.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!p.enabled?.tools?.custom)||!(a===u||typeof a=="object"&&a!==null&&typeof u=="object"&&u!==null&&!!a.enabled?.zoom==!!u.enabled?.zoom&&!!a.enabled?.scrollBackToContent==!!u.enabled?.scrollBackToContent))return!1;let x=Object.keys(o),v=Object.keys(d);if(x.length!==v.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(L=>L==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[L]===d?.canvasActions?.[L]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Ao.maxWidthOrHeight)===(m?.maxWidthOrHeight??Ao.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Ao.maxFileSizeBytes)===(m?.maxFileSizeBytes??Ao.maxFileSizeBytes)&&(r?.placeholderTransitionDuration??Ao.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Ao.placeholderTransitionDuration);return T&&C&&zX(l,g)},UX=_X.memo(HX,GX);UX.displayName="Excalidraw";function DWe(e){return Ni(e,!1)}export{fn as Button,EVe as CaptureUpdateAction,iVe as DEFAULT_LASER_COLOR,cu as DEFAULT_OVERSCROLL,KE as DefaultSidebar,Ps as Ellipsify,UX as Excalidraw,es as ExcalidrawAPIContext,LWe as ExcalidrawAPIProvider,tVe as FONT_FAMILY,io as Fonts,gX as Footer,bX as LiveCollaborationTrigger,oVe as MIME_TYPES,_t as MainMenu,rVe as ROUNDNESS,gr as Sidebar,Gl as Stats,nVe as THEME,mu as UnsupportedImageFileTypeError,aVe as UserIdleState,IX as WelcomeScreen,fWe as applyDarkModeFilter,gVe as bumpVersion,zh as captureDragEventData,kVe as convertToExcalidrawElements,zn as defaultLang,AVe as elementsOverlappingBBox,KC as exportToBlob,xp as exportToCanvas,IH as exportToClipboard,ZC as exportToSvg,CVe as getCommonBounds,vc as getDataURL,dVe as getFormFactor,zWe as getNonDeletedElements,BWe as getSceneVersion,EWe as getStrokeWidthByKey,GWe as getTextFromElements,PVe as getVisibleSceneBounds,OWe as hashElementsVersion,FWe as hashString,_Ve as isElementLink,WWe as isInvisiblySmallElement,QWe as isLinearElement,ba as isSpreadsheetValidForChartType,gi as languages,ls as loadFromBlob,uVe as mutateElement,hVe as newElementWith,sVe as normalizeLink,Br as parseDataTransferEvent,Od as parseDragImageMetadata,DX as reconcileElements,xf as renderSpreadsheet,pi as restoreAppState,e3 as restoreElement,Tr as restoreElements,lVe as sceneCoordsToViewportCoords,is as serializeAsJSON,BVe as setCustomTextMetricsProvider,mVe as throttleRAF,Dm as tryParseSpreadsheet,ge as useEditorInterface,Ed as useExcalidrawAPI,DWe as useExcalidrawStateValue,Ae as useI18n,d6 as useOnExcalidrawStateChange,at as useStylesPanelMode,cVe as viewportCoordsToSceneCoords,vr as zoomToFitBounds};
|
|
23
|
+
`),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=ke({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:cY,verticalAlign:eM,locked:!1},s=pb({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=iM(a.fontFamily),[c,,d]=lX(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,E=o?[t]:t.split(`
|
|
24
|
+
`),g=E.reduce((b,y,w)=>{let x=pX(y).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=LM(x,s,l),C=T.width>m,P=C?dX(x,s,m):x;T=C?LM(P,s,l):T;let A=r-T.width/2,D=u-T.height/2,_=gM({...a,x:A,y:D,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:I?I.id:null});b.push(_),u+=_.height+p}else E[w-1]?.trim()&&(u+=_M(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:Ae(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&ZM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),ZM=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(s,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===t.id&&Xt(c)?po(c,{originalText:s,isDeleted:l??c.isDeleted,...HY(c,SM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=j2({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=Kp({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Ke(s=>{a(s,!1),eu(t)&&jp(t,this.scene)}),onSubmit:Ke(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Ft(()=>{this.setState(m=>({selectedElementIds:Ae({...m.selectedElementIds,[d]:!0},m)}))}),c&&LY(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Ft(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(t){let o=this.scene.getSelectedElements(this.state);if(o.length!==1)return null;let r=o[0];return Xt(r)?r:t?yb(r,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(t,o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1||!t||t.id!==r[0].id)return null;let i=r[0];if(Xt(i))return null;if(!CM(i))return;let a=this.getSelectedTextElement(i),s=this.getTextElementAtPosition(o.x,o.y);if(!(!a||s?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&Xt(r)&&!r.isDeleted?r:null}getElementAtPosition(t,o,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,o,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let s=i.length-1;s>-1;s--)if(this.state.selectedElementIds[i[s].id])return i[s]}let a=i[i.length-1];return mc({point:oe(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,o,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(r?.includeLockedElements||!l.locked)&&(r?.includeBoundTextElement||!(Xt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=Sb(l,a);return c&&!eu(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!dc(l)?kM({x:t,y:o},c,a):!0}).filter(l=>dc(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(rM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&JY([r],this.state,this.editorInterface)&&kX(oe(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||aX(oe(t,o),r,this.scene.getNonDeletedElementsMap())?!0:mc({point:oe(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,o){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return yM(i[0],!1)?i[0]:null;let a=null;for(let s=r.length-1;s>=0;--s){if(r[s].isDeleted)continue;let[l,c,d,m]=pM(r[s],this.scene.getNonDeletedElementsMap());if(cc(r[s])&&mc({point:oe(t,o),element:r[s],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[s])})){a=r[s];break}else if(l<t&&t<d&&c<o&&o<m){if(Tt(r[s]))continue;a=r[s];break}}return yM(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Xt(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=ge.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;mc({point:oe(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=ge.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=ge.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Yt(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Me.POINTER):this.hitElement(o,r,a)&&(!Yt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE)):this.hitElement(o,r,a)&&(!Yt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),ge.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=_X(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(Me.POINTER)}else this.cursor.set(Me.AUTO)}updateGestureOnPointerDown(t){me.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),me.pointers.size===2&&(me.lastCenter=Jg(me.pointers),me.initialScale=this.state.zoom.value,me.initialDistance=Qg(Array.from(me.pointers.values())))}initialPointerDownState(t){let o=ke(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=ss(r),c=r.findIndex(Yt)===0;return{origin:o,withCmdOrCtrl:t[X.CTRL_OR_CMD],originInGrid:ub(Mt(o.x,o.y,t[X.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:pf(gc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,fM(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(s+i)/2,y:(l+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(o,r)},drag:{hasOccurred:!1,offset:null,origin:{...o},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,o){if(!(o.scrollbars.isOverEither&&!this.state.multiElement))return!1;nu=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=vm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Ke(()=>{ls=null,nu=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,r),window.removeEventListener(J.POINTER_UP,i),r.flush()});return ls=i,window.addEventListener(J.POINTER_MOVE,r),window.addEventListener(J.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,o){if(o.length<2)return!1;let r=Math.max(rM/this.state.zoom.value,1),i=qV*2/this.state.zoom.value,[a,s,l,c]=ss(o);return t.x>a-i-r&&t.x<l+i+r&&t.y>s-i-r&&t.y<c+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:VY(t)?Vp.ADAPTIVE_RADIUS:Vp.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return AY(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){Co({event:t,app:this,selectedElements:o})&&(r||!hn.getReferenceSnapPoints())&&hn.setReferenceSnapPoints(D2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){Co({event:t,app:this,selectedElements:o})&&(r||!hn.getVisibleGaps())&&hn.setVisibleGaps(A2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ke(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Ke(o=>{o.key===X.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return vm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=ke(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=Mt(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=ge.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?ge.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=ge.moveFixedSegment(this.state.selectedLinearElement,E,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:g.segmentMidPointHoveredCoords,initialState:g.initialState}});return}let i=this.previousPointerMoveCoords??t.origin;if(this.previousPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=ub(CX(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(on(this.state)){this.handleEraser(o,r);return}if(this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y),this.drawShape.handlePointerMove(r))return;let[s,l]=Mt(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){LX(p,c,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...p,isDragging:!1,selectedPointsIndices:[],initialState:{...p.initialState,lastClickedPoint:-1}}});return}if(ge.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=ge.addMidpoint(this.state.selectedLinearElement,r,this,!o[X.CTRL_OR_CMD],this.scene);if(!u)return;Ft(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=ge.getElement(p.elementId,c);if(u?.isDeleted)return;if(uo(u)){let g=Cr(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);Ro("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Ro("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=ge.handlePointDragging(o,this,r.x,r.y,p);if(E){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(E.suggestedBinding!==this.state.suggestedBinding||!cM(E.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||E.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||E.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==E.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==E.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(E);return}}}}let d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(g=>g.locked))return;let E=p.some(g=>Tt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:PM(p),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(E),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&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 g={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},b=[...t.originalElements.values()],y=o.shiftKey;if(y){let I=Math.abs(g.x),T=Math.abs(g.y),C=y&&I<T,P=y&&I>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&Hn(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,C=fi(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=BX(I),A=$k(r.x-i.x,r.y-i.y);A[0]*=C.naturalWidth/P.width,A[1]*=C.naturalHeight/P.height;let[D,_,k,L,B,V]=pM(I,c),z=cb(lb(oe(D,_),oe(B,V),I.angle)),U=cb(lb(oe(k,_),oe(B,V),I.angle)),K=cb(lb(oe(D,L),oe(B,V),I.angle)),G=qk(Zk(U,z)),te=qk(Zk(K,z)),F=$k(jk(A,G),jk(A,te)),W={...T,x:oc(T.x-F[0]*Math.sign(I.scale[0]),0,C.naturalWidth-T.width),y:oc(T.y-F[1]*Math.sign(I.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:W});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:w,snapLines:x}=L2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||SX(t,p,g,this.scene,w,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),T=t.hit.element,C=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});T&&t.hit.wasAddedToSelection&&!C.find(z=>z.id===T.id)&&C.push(T);let P=new Map(C.map(z=>[z.id,z])),{duplicatedElements:A,duplicateElementsMap:D,elementsWithDuplicates:_,origIdToDuplicateId:k}=EM({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:wY()})});A.forEach(z=>{t.originalElements.set(z.id,fM(z))});let L=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return po(z,{x:U.x,y:U.y})}return z}),B=this.props.onDuplicate?.(L,I),V=NM(B||L,lc(A));Ft(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),U=z&&D.get(z);t.hit.element=U||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,U)=>{let K=k.get(U.id),G=K&&D.get(K);return G&&z.push(G),z},[]),t.drag.origin=ke(o,this.state),this.setState(z=>({...BM(A,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(V),C.forEach(z=>{Eb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&jp(z,this.scene)}),this.maybeCacheVisibleGaps(o,C,!0),this.maybeCacheReferenceSnapPoints(o,C,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,o.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},{keepSelection:o.shiftKey}),this.lassoTrail.startPath(t.origin.x,t.origin.y,o.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,o)}else if(this.state.activeTool.type==="lasso")!o.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,o),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,o.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,E=r.x-p.x,g=r.y-p.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===E&&b[1]===g)){let w=p.simulatePressure?p.pressures:[...p.pressures,o.pressure];this.scene.mutateElement(p,{points:[...u,oe(E,g)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Ot(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;mo(u.length>1,"Do not create linear elements with less than 2 points");let E=this.state.selectedLinearElement;(!E||E.elementId!==p.id)&&(E=new ge(p,this.scene.getNonDeletedElementsMap())),E&&(E.initialState.lastClickedPoint<0||E.initialState.lastClickedPoint>=u.length)&&(console.warn("Last clicked point is out of bounds. Attempting to fix it."),E={...E,selectedPointsIndices:[u.length-1],initialState:{...E.initialState,prevSelectedPointsIndices:null,lastClickedPoint:u.length-1},hoverPointIndex:u.length-1}),this.setState({newElement:p,...ge.handlePointDragging(o,this,s,l,E)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)ge.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&De(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Un({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?ex(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((y,w)=>(y[w.id]=!0,y),{})};return t.hit.element&&(E.length?delete b[t.hit.element.id]:b[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...Un({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Ot(E[0])?new ge(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||No(E[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,o){if(o.scrollbars.isOverHorizontal){let r=t.clientX,i=r-o.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-i*(gc.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.x=r,!0}if(o.scrollbars.isOverVertical){let r=t.clientY,i=r-o.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-i*(gc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ke(o=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(o),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush(),o.type==="pointerup"&&this.state.activeTool.type===Gn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:c,isResizing:d,isRotating:m,isCropping:p}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:sc(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,hn.setReferenceSnapPoints(null),hn.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=ke({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Ro("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let x=r.get(t.hit.element.id);Eb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>Yt(I)).forEach(I=>{I&&this.scene.mutateElement(I,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(ut);else{let x=ge.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E}),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:x,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=ge.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(NX(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Ot(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:x}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x.points[x.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(J.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(J.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(J.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(J.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=ke(o,this.state),I=i.points,T=x.x-i.x,C=x.y-i.y;T===I[0][0]&&C===I[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...I,oe(T,C)],pressures:P}),this.actionManager.executeAction(ut);return}if(Ot(i)&&this.state.activeTool.type!=="autoshape"){let x=ke(o,this.state),I=so(oe(x.x,x.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<vY)&&i&&!l)if(this.editorInterface.isTouchScreen){let T=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-T/2,points:[oe(0,0),oe(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(ut)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Ot(i)&&this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:tn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Ae({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new ge(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Xt(i)){let x=gX(pb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&vM(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:Kt.NEVER});return}if(Tt(i)){let x=nX(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Ib(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,YY(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=ke(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let I=this.scene.getElement(this.state.selectedLinearElement.elementId);if(I?.frameId){let T=Sb(I,r);T&&I&&(oX(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),tX([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:PM(I),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=A=>{if(A.length>0){for(let D of A){let _=D.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(D,{groupIds:D.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(D=>{D.groupIds.length&&bi(C,D.groupIds[D.groupIds.length-1]).length<2&&this.scene.mutateElement(D,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let A=I.filter(D=>AM(D,C,this.state));this.state.editingGroupId&&P(A),C=Ib(C,A,T)}else if(!T&&this.state.editingGroupId){let A=I.filter(D=>D.frameId&&!AM(D,C,this.state));P(A)}C=MM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&vM(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:Kt.NEVER}),t.resize.isResizing){let x=MM(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(Tt);for(let T of I)x=eX(x,Tb(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Ot(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new ge(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(on(this.state)&&b&&y){if(this.eraserTrail.endPath(),so(oe(b.clientX,b.clientY),oe(y.clientX,y.clientY))===0){let I=ke({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(I.x,I.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(g&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(o.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?yX(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>bi(this.scene.getNonDeletedElements(),C)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:Ae(I,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let I={...x.selectedElementIds};delete I[g.id];let T=ce(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...Un({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Ot(T[0])?new ge(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let I={...x.selectedElementIds,[g.id]:!0};return delete I[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>bi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...Un({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||No(g)?"info":!1}}):this.setState(x=>({selectedElementIds:Ae({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Un({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Ot(g)&&x.selectedLinearElement?.elementId!==g.id?new ge(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Yt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&sX({point:oe(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:Tt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(ba):this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Me.AUTO);return}let w=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[X.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Xt(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||w)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:w,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:Ae({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:No(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||De(this.scene.getNonDeletedElements(),this.state)||!cM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||p){let x=this.scene.getSelectedElements(this.state).filter(cc);uM(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(ut);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Gn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:tn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:Ae({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&RM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,s=i.y+i.height/2,l=wb(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<oY){let{x:m,y:p}=Kp({sceneX:a,sceneY:s},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:s}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:o,top:r}=t.getBoundingClientRect();return{offsetLeft:o,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Pi.find(o=>o.code===this.props.langCode)||Xn;await Dc(t),this.setAppState({})}},HX=()=>{(jM()||qM())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(QM(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};HX();var n3=Lb;import{useEffect as WX,useState as VX}from"react";import{jsx as YX}from"react/jsx-runtime";var o3=e=>{let[n,t]=VX(!0);return WX(()=>{let o=async()=>{await Dc(r),t(!1)},r=Pi.find(i=>i.code===e.langCode)||Xn;o()},[e.langCode]),n?YX(sp,{theme:e.theme}):e.children};import XX from"clsx";import{jsx as r3}from"react/jsx-runtime";var i3=({children:e})=>{let{FooterCenterTunnel:n}=nt(),t=be();return r3(n.In,{children:r3("div",{className:XX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},KX=i3;i3.displayName="FooterCenter";import $X from"clsx";import{MQ_MIN_WIDTH_DESKTOP as ZX}from"@excalidraw/common";import{jsx as qX,jsxs as JX}from"react/jsx-runtime";var a3=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=be(),i=t?.formFactor!=="desktop"||r.width<ZX;return JX(wn,{...o,className:$X("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?qx:f("labels.share"),r.collaborators.size>0&&qX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},jX=a3;a3.displayName="LiveCollaborationTrigger";import{jsx as kr,jsxs as l3}from"react/jsx-runtime";var QX=()=>kr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:kr("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"})}),eK=()=>l3("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[kr("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)"}),kr("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)"}),kr("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)"}),kr("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)"})]}),s3=({style:e,size:n="small",withText:t})=>l3("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[kr(QX,{}),t&&kr(eK,{})]});import{Fragment as m3,jsx as st,jsxs as zb}from"react/jsx-runtime";var Gb=({icon:e,shortcut:n,children:t})=>{let o=Ee();return zb(m3,{children:[st("div",{className:"welcome-screen-menu-item__icon",children:e}),st("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&st("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};Gb.displayName="WelcomeScreenMenuItemContent";var Ec=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>st("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:st(Gb,{icon:t,shortcut:o,children:n})});Ec.displayName="WelcomeScreenMenuItem";var c3=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>st("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:st(Gb,{icon:t,shortcut:o,children:e})});c3.displayName="WelcomeScreenMenuItemLink";var In=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=nt();return st(n.In,{children:st("div",{className:"welcome-screen-center",children:e||zb(m3,{children:[st(Hb,{}),st(Ub,{children:f("welcomeScreen.defaults.center_heading")}),zb(Wb,{children:[st(Yb,{}),st(Vb,{})]})]})})})};In.displayName="Center";var Hb=({children:e})=>st("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||st(s3,{withText:!0})});Hb.displayName="Logo";var Ub=({children:e})=>st("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Ub.displayName="Heading";var Wb=({children:e})=>st("div",{className:"welcome-screen-menu",children:e});Wb.displayName="Menu";var Vb=()=>{let e=ot();return st(Ec,{onSelect:()=>e.executeAction(Kr),shortcut:"?",icon:Li,children:f("helpDialog.title")})};Vb.displayName="MenuItemHelp";var Yb=()=>{let e=be(),n=ot();return e.viewModeEnabled?null:st(Ec,{onSelect:()=>n.executeAction(ea),shortcut:Ze("loadScene"),icon:Bc,children:f("buttons.load")})};Yb.displayName="MenuItemLoadScene";var d3=({onSelect:e})=>{let{t:n}=Le();return st(Ec,{shortcut:null,onSelect:e,icon:Fc,children:n("labels.liveCollaboration")})};d3.displayName="MenuItemLiveCollaborationTrigger";In.Logo=Hb;In.Heading=Ub;In.Menu=Wb;In.MenuItem=Ec;In.MenuItemLink=c3;In.MenuItemHelp=Vb;In.MenuItemLoadScene=Yb;In.MenuItemLiveCollaborationTrigger=d3;import{jsx as ds,jsxs as Xb}from"react/jsx-runtime";var su=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=nt();return ds(n.In,{children:Xb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[_x,ds("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};su.displayName="MenuHint";var lu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=nt();return ds(n.In,{children:Xb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ds("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),Nx]})})};lu.displayName="ToolbarHint";var cu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=nt();return ds(n.In,{children:Xb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ds("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Rx]})})};cu.displayName="HelpHint";import{Fragment as p3,jsx as bc,jsxs as nK}from"react/jsx-runtime";var du=e=>bc(p3,{children:e.children||nK(p3,{children:[bc(In,{}),bc(su,{}),bc(lu,{}),bc(cu,{})]})});du.displayName="WelcomeScreen";du.Center=In;du.Hints={MenuHint:su,ToolbarHint:lu,HelpHint:cu};var tK=du;var oK=()=>{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}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,n){return this.slice().reverse().find((t,o)=>e.call(n,t,this.length-o-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,n){for(let t=0;t<this.length;t++)if(e.call(n,this[t],t,this))return t;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,n){let t=this.slice().reverse().findIndex((o,r)=>e.call(n,o,this.length-r-1,this));return t===-1?-1:this.length-t-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},u3=oK;import{getSceneVersion as qVe,hashElementsVersion as JVe,hashString as QVe,getNonDeletedElements as eYe}from"@excalidraw/element";import{getTextFromElements as nYe}from"@excalidraw/element";import{isInvisiblySmallElement as rYe}from"@excalidraw/element";import rK from"lodash.throttle";import{arrayToMap as iK,isDevEnv as h3,isTestEnv as g3}from"@excalidraw/common";import{orderByFractionalIndex as aK,syncInvalidIndices as f3,validateFractionalIndices as sK}from"@excalidraw/element";var lK=(e,n,t)=>!!(n&&(n.id===e.editingTextElement?.id||n.id===e.resizingElement?.id||n.id===e.newElement?.id||n.version>t.version||n.version===t.version&&n.versionNonce<=t.versionNonce)),cK=rK((e,n,t)=>{if(h3()||g3()||window?.DEBUG_FRACTIONAL_INDICES){let o=f3(e.map(r=>({...r})));sK(o,{shouldThrow:g3()||h3(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),dK=(e,n,t)=>{let o=iK(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=lK(t,l,s);l&&c?(r.push(l),i.add(l.id)):(r.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(r.push(s),i.add(s.id));let a=aK(r);return cK(a,e,n),f3(a),a};import{isLinearElement as hYe}from"@excalidraw/element";import{FONT_FAMILY as fYe,THEME as EYe,MIME_TYPES as bYe,ROUNDNESS as xYe,DEFAULT_LASER_COLOR as yYe,UserIdleState as wYe,normalizeLink as vYe,sceneCoordsToViewportCoords as IYe,viewportCoordsToSceneCoords as TYe,getFormFactor as SYe,throttleRAF as CYe}from"@excalidraw/common";import{mutateElement as kYe,newElementWith as MYe,bumpVersion as AYe}from"@excalidraw/element";import{CaptureUpdateAction as LYe}from"@excalidraw/element";import{getCommonBounds as HYe,getVisibleSceneBounds as UYe,convertToExcalidrawElements as WYe}from"@excalidraw/element";import{elementsOverlappingBBox as YYe}from"@excalidraw/element";import{isElementLink as $Ye}from"@excalidraw/element";import{setCustomTextMetricsProvider as qYe}from"@excalidraw/element";import{jsx as xc}from"react/jsx-runtime";u3();var XVe=({children:e})=>{let[n,t]=fK(null);return xc(cs.Provider,{value:n,children:xc(au.Provider,{value:t,children:e})})},bK=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=Xn.code,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,onPaste:B,viewModeImageInsertBehavior:V,onViewModeImageInsertRejected:z,detectScroll:U=!0,handleKeyboardGlobally:K=!1,autoFocus:G=!1,compressImageFile:te,generateIdForFile:F,onLinkOpen:W,generateLinkForSelection:le,onPointerDown:we,onPointerUp:de,onScrollChange:he,onUserFollow:ve,userToFollow:ae,onDuplicate:fe,imageContextMenuItems:rt,children:Ge,validateEmbeddable:Pe,renderEmbeddable:Wn,showDeprecatedFonts:zo,wheelZoomsOnDefault:xi,strokeColorTopPicks:re,backgroundColorTopPicks:lt,renderScrollbars:$t,viewportStatusFrame:Sn,currentUserControls:nn,imageOptions:yi,showDropEventDebugAlert:b3}=e,mu=e.UIOptions?.canvasActions,yc={...e.UIOptions,canvasActions:{...E3.canvasActions,...mu},tools:{image:e.UIOptions?.tools?.image??!0}};mu?.export&&(yc.canvasActions.export.saveFileToDisk=mu.export?.saveFileToDisk??E3.canvasActions.export.saveFileToDisk),yc.canvasActions.toggleTheme===null&&(P==null||r)&&(yc.canvasActions.toggleTheme=!0);let x3={maxFileSizeBytes:yi?.maxFileSizeBytes??Tn.maxFileSizeBytes,maxWidthOrHeight:yi?.maxWidthOrHeight??Tn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:yi?.gifAutoDecodeMaxFileSizeBytes??Tn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:yi?.placeholderTransitionDuration??Tn.placeholderTransitionDuration},Kb=uK(au),$b=gK(l);$b.current=l;let y3=pK(pu=>{Kb?.(pu),$b.current?.(pu)},[Kb]),Zb=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return hK(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Zb)return;let jb=uu=>{typeof uu.scale=="number"&&uu.scale!==1&&uu.preventDefault()};return document.addEventListener("touchmove",jb,{passive:!1}),()=>{document.removeEventListener("touchmove",jb)}},[Zb]),xc(Sx,{store:Et,children:xc(o3,{langCode:b,theme:P,children:xc(n3,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:y3,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,UIOptions:yc,onPaste:B,viewModeImageInsertBehavior:V,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:K,autoFocus:G,compressImageFile:te,generateIdForFile:F,onLinkOpen:W,generateLinkForSelection:le,onPointerDown:we,onPointerUp:de,onScrollChange:he,onUserFollow:ve,userToFollow:ae,onDuplicate:fe,imageContextMenuItems:rt,validateEmbeddable:Pe,renderEmbeddable:Wn,showDeprecatedFonts:zo,wheelZoomsOnDefault:xi,strokeColorTopPicks:re,backgroundColorTopPicks:lt,renderScrollbars:$t,viewportStatusFrame:Sn,currentUserControls:nn,imageOptions:x3,showDropEventDebugAlert:b3,children:Ge})})})},xK=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:s,...l}=e,{initialData:c,UIOptions:d={},imageOptions:m,interaction:p,ui:u,activeTool:E,...g}=n;if(!(s===E||s?.type===E?.type&&(s?.type==="custom"?s.customType:null)===(E?.type==="custom"?E.customType:null))||!(i===p||typeof i=="object"&&i!==null&&typeof p=="object"&&p!==null&&!!i.enabled?.links==!!p.enabled?.links&&!!i.enabled?.embeds==!!p.enabled?.embeds&&!!i.enabled?.interactiveContent==!!p.enabled?.interactiveContent&&!!i.enabled?.navigation==!!p.enabled?.navigation&&!!i.enabled?.browserZoom==!!p.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!p.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!p.enabled?.tools?.custom)||!(a===u||typeof a=="object"&&a!==null&&typeof u=="object"&&u!==null&&!!a.enabled?.zoom==!!u.enabled?.zoom&&!!a.enabled?.scrollBackToContent==!!u.enabled?.scrollBackToContent))return!1;let x=Object.keys(o),I=Object.keys(d);if(x.length!==I.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(D=>D==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[D]===d?.canvasActions?.[D]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Tn.maxWidthOrHeight)===(m?.maxWidthOrHeight??Tn.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Tn.maxFileSizeBytes)===(m?.maxFileSizeBytes??Tn.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Tn.gifAutoDecodeMaxFileSizeBytes)===(m?.gifAutoDecodeMaxFileSizeBytes??Tn.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Tn.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Tn.placeholderTransitionDuration);return T&&C&&EK(l,g)},yK=mK.memo(bK,xK);yK.displayName="Excalidraw";function KVe(e){return Ki(e,!1)}export{wn as Button,LYe as CaptureUpdateAction,yYe as DEFAULT_LASER_COLOR,gu as DEFAULT_OVERSCROLL,tb as DefaultSidebar,Ns as Ellipsify,yK as Excalidraw,cs as ExcalidrawAPIContext,XVe as ExcalidrawAPIProvider,fYe as FONT_FAMILY,go as Fonts,KX as Footer,jX as LiveCollaborationTrigger,bYe as MIME_TYPES,Bt as MainMenu,xYe as ROUNDNESS,Ir as Sidebar,Zl as Stats,EYe as THEME,Eu as UnsupportedImageFileTypeError,wYe as UserIdleState,tK as WelcomeScreen,DVe as applyDarkModeFilter,AYe as bumpVersion,Yh as captureDragEventData,WYe as convertToExcalidrawElements,Xn as defaultLang,YYe as elementsOverlappingBBox,lP as exportToBlob,Cp as exportToCanvas,$G as exportToClipboard,cP as exportToSvg,HYe as getCommonBounds,kc as getDataURL,SYe as getFormFactor,eYe as getNonDeletedElements,qVe as getSceneVersion,LVe as getStrokeWidthByKey,nYe as getTextFromElements,UYe as getVisibleSceneBounds,JVe as hashElementsVersion,QVe as hashString,$Ye as isElementLink,rYe as isInvisiblySmallElement,hYe as isLinearElement,Aa as isSpreadsheetValidForChartType,Pi as languages,fs as loadFromBlob,kYe as mutateElement,MYe as newElementWith,vYe as normalizeLink,Wr as parseDataTransferEvent,Wd as parseDragImageMetadata,dK as reconcileElements,Cf as renderSpreadsheet,Ti as restoreAppState,v3 as restoreElement,Dr as restoreElements,IYe as sceneCoordsToViewportCoords,us as serializeAsJSON,qYe as setCustomTextMetricsProvider,CYe as throttleRAF,Om as tryParseSpreadsheet,Ee as useEditorInterface,Id as useExcalidrawAPI,KVe as useExcalidrawStateValue,Le as useI18n,L6 as useOnExcalidrawStateChange,ct as useStylesPanelMode,TYe as viewportCoordsToSceneCoords,Mr as zoomToFitBounds};
|