@excalidraw/excalidraw 0.17.1-d2f67e6 → 0.17.1-e63dd02
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 +4 -0
- package/dist/browser/dev/excalidraw-assets-dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-EM6LVGFW.js → chunk-IT7T3AIK.js} +23 -5
- package/dist/browser/dev/excalidraw-assets-dev/chunk-IT7T3AIK.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-B4UMSLQQ.js → chunk-RNHSD5AR.js} +7451 -2098
- package/dist/browser/dev/excalidraw-assets-dev/chunk-RNHSD5AR.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{dist-6QVAH5JA.js → dist-DNSPZDOZ.js} +31 -19
- package/dist/browser/dev/excalidraw-assets-dev/dist-DNSPZDOZ.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{en-AZFA5HJJ.js → en-XV7OZCPP.js} +6 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-V7E6IT6R.js → image-77HZYGLG.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css → image-WDHYGKKP.css} +1 -1
- package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css.map → image-WDHYGKKP.css.map} +2 -2
- package/dist/browser/dev/index.css +449 -114
- package/dist/browser/dev/index.css.map +3 -3
- package/dist/browser/dev/index.js +4143 -5956
- package/dist/browser/dev/index.js.map +4 -4
- package/dist/browser/prod/excalidraw-assets/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/chunk-OYEADJSR.js +63 -0
- package/dist/browser/prod/excalidraw-assets/{chunk-7DXALCB2.js → chunk-PDYFZJMS.js} +3 -3
- package/dist/browser/prod/excalidraw-assets/dist-NLUQPPQQ.js +7 -0
- package/dist/browser/prod/excalidraw-assets/en-YVAVVILW.js +1 -0
- package/dist/browser/prod/excalidraw-assets/image-X3GFZHNN.js +1 -0
- package/dist/browser/prod/index.css +1 -1
- package/dist/browser/prod/index.js +40 -50
- package/dist/dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/dev/{en-EB2MBPAV.json → en-YNVBSAIL.json} +18 -4
- package/dist/dev/index.css +449 -114
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +21626 -18122
- package/dist/dev/index.js.map +4 -4
- package/dist/excalidraw/actions/actionAddToLibrary.d.ts +9 -3
- package/dist/excalidraw/actions/actionBoundText.d.ts +6 -2
- package/dist/excalidraw/actions/actionCanvas.d.ts +36 -12
- package/dist/excalidraw/actions/actionClipboard.d.ts +22 -7
- package/dist/excalidraw/actions/actionDeleteSelected.d.ts +12 -5
- package/dist/excalidraw/actions/actionDeleteSelected.js +24 -5
- package/dist/excalidraw/actions/actionDuplicateSelection.js +1 -2
- package/dist/excalidraw/actions/actionElementLock.d.ts +6 -2
- package/dist/excalidraw/actions/actionExport.d.ts +27 -9
- package/dist/excalidraw/actions/actionFinalize.d.ts +6 -2
- package/dist/excalidraw/actions/actionFinalize.js +2 -2
- package/dist/excalidraw/actions/actionFlip.js +2 -2
- package/dist/excalidraw/actions/actionFrame.d.ts +12 -4
- package/dist/excalidraw/actions/actionGroup.d.ts +6 -2
- package/dist/excalidraw/actions/actionHistory.js +4 -4
- package/dist/excalidraw/actions/actionLinearEditor.d.ts +3 -1
- package/dist/excalidraw/actions/actionLinearEditor.js +3 -2
- package/dist/excalidraw/actions/actionLink.d.ts +3 -1
- package/dist/excalidraw/actions/actionMenu.d.ts +9 -3
- package/dist/excalidraw/actions/actionNavigate.d.ts +6 -2
- package/dist/excalidraw/actions/actionProperties.d.ts +411 -56
- package/dist/excalidraw/actions/actionProperties.js +383 -58
- package/dist/excalidraw/actions/actionSelectAll.d.ts +3 -1
- package/dist/excalidraw/actions/actionStyles.d.ts +3 -1
- package/dist/excalidraw/actions/actionStyles.js +3 -2
- package/dist/excalidraw/actions/actionToggleGridMode.d.ts +3 -1
- package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +3 -1
- package/dist/excalidraw/actions/actionToggleStats.d.ts +3 -1
- package/dist/excalidraw/actions/actionToggleViewMode.d.ts +3 -1
- package/dist/excalidraw/actions/actionToggleZenMode.d.ts +3 -1
- package/dist/excalidraw/actions/types.d.ts +1 -1
- package/dist/excalidraw/analytics.js +9 -7
- package/dist/excalidraw/appState.d.ts +1 -0
- package/dist/excalidraw/appState.js +9 -1
- package/dist/excalidraw/binaryheap.d.ts +12 -0
- package/dist/excalidraw/binaryheap.js +93 -0
- package/dist/excalidraw/change.d.ts +2 -1
- package/dist/excalidraw/change.js +6 -4
- package/dist/excalidraw/charts.js +0 -10
- package/dist/excalidraw/components/Actions.js +7 -5
- package/dist/excalidraw/components/App.d.ts +5 -9
- package/dist/excalidraw/components/App.js +218 -161
- package/dist/excalidraw/components/ButtonIcon.d.ts +15 -0
- package/dist/excalidraw/components/ButtonIcon.js +8 -0
- package/dist/excalidraw/components/ButtonIconSelect.js +2 -3
- package/dist/excalidraw/components/ButtonSeparator.d.ts +2 -0
- package/dist/excalidraw/components/ButtonSeparator.js +7 -0
- package/dist/excalidraw/components/ColorPicker/ColorPicker.js +47 -79
- package/dist/excalidraw/components/ColorPicker/Picker.js +1 -1
- package/dist/excalidraw/components/FontPicker/FontPicker.d.ts +21 -0
- package/dist/excalidraw/components/FontPicker/FontPicker.js +49 -0
- package/dist/excalidraw/components/FontPicker/FontPickerList.d.ts +25 -0
- package/dist/excalidraw/components/FontPicker/FontPickerList.js +119 -0
- package/dist/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +7 -0
- package/dist/excalidraw/components/FontPicker/FontPickerTrigger.js +13 -0
- package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +14 -0
- package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.js +38 -0
- package/dist/excalidraw/components/HelpDialog.js +1 -1
- package/dist/excalidraw/components/HintViewer.js +6 -3
- package/dist/excalidraw/components/PropertiesPopover.d.ts +15 -0
- package/dist/excalidraw/components/PropertiesPopover.js +31 -0
- package/dist/excalidraw/components/QuickSearch.d.ts +9 -0
- package/dist/excalidraw/components/QuickSearch.js +8 -0
- package/dist/excalidraw/components/ScrollableList.d.ts +9 -0
- package/dist/excalidraw/components/ScrollableList.js +8 -0
- package/dist/excalidraw/components/Stats/Angle.d.ts +7 -3
- package/dist/excalidraw/components/Stats/Angle.js +39 -31
- package/dist/excalidraw/components/Stats/Dimension.d.ts +6 -3
- package/dist/excalidraw/components/Stats/Dimension.js +51 -49
- package/dist/excalidraw/components/Stats/DragInput.d.ts +15 -6
- package/dist/excalidraw/components/Stats/DragInput.js +59 -26
- package/dist/excalidraw/components/Stats/FontSize.d.ts +8 -4
- package/dist/excalidraw/components/Stats/FontSize.js +39 -36
- package/dist/excalidraw/components/Stats/MultiAngle.d.ts +5 -3
- package/dist/excalidraw/components/Stats/MultiAngle.js +43 -34
- package/dist/excalidraw/components/Stats/MultiDimension.d.ts +5 -3
- package/dist/excalidraw/components/Stats/MultiDimension.js +101 -99
- package/dist/excalidraw/components/Stats/MultiFontSize.d.ts +6 -3
- package/dist/excalidraw/components/Stats/MultiFontSize.js +47 -32
- package/dist/excalidraw/components/Stats/MultiPosition.d.ts +3 -1
- package/dist/excalidraw/components/Stats/MultiPosition.js +52 -48
- package/dist/excalidraw/components/Stats/Position.d.ts +5 -1
- package/dist/excalidraw/components/Stats/Position.js +31 -29
- package/dist/excalidraw/components/Stats/index.js +5 -17
- package/dist/excalidraw/components/Stats/utils.d.ts +14 -3
- package/dist/excalidraw/components/Stats/utils.js +48 -9
- package/dist/excalidraw/components/TTDDialog/common.d.ts +2 -2
- package/dist/excalidraw/components/TTDDialog/common.js +3 -7
- package/dist/excalidraw/components/UserList.js +22 -22
- package/dist/excalidraw/components/canvases/StaticCanvas.js +1 -0
- package/dist/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +12 -3
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +24 -4
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.js +55 -14
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -1
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +2 -2
- package/dist/excalidraw/components/dropdownMenu/common.d.ts +1 -1
- package/dist/excalidraw/components/dropdownMenu/common.js +3 -2
- package/dist/excalidraw/components/icons.d.ts +4 -0
- package/dist/excalidraw/components/icons.js +7 -0
- package/dist/excalidraw/components/main-menu/MainMenu.d.ts +12 -3
- package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +2 -2
- package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +3 -3
- package/dist/excalidraw/constants.d.ts +17 -2
- package/dist/excalidraw/constants.js +21 -4
- package/dist/excalidraw/data/reconcile.js +18 -1
- package/dist/excalidraw/data/restore.js +55 -9
- package/dist/excalidraw/data/transform.js +8 -5
- package/dist/excalidraw/element/binding.d.ts +28 -9
- package/dist/excalidraw/element/binding.js +303 -71
- package/dist/excalidraw/element/collision.d.ts +1 -1
- package/dist/excalidraw/element/collision.js +4 -1
- package/dist/excalidraw/element/dragElements.d.ts +2 -2
- package/dist/excalidraw/element/dragElements.js +13 -3
- package/dist/excalidraw/element/embeddable.d.ts +3 -1
- package/dist/excalidraw/element/heading.d.ts +11 -0
- package/dist/excalidraw/element/heading.js +81 -0
- package/dist/excalidraw/element/index.d.ts +1 -1
- package/dist/excalidraw/element/index.js +1 -1
- package/dist/excalidraw/element/linearElementEditor.d.ts +21 -13
- package/dist/excalidraw/element/linearElementEditor.js +133 -56
- package/dist/excalidraw/element/newElement.d.ts +8 -3
- package/dist/excalidraw/element/newElement.js +15 -2
- package/dist/excalidraw/element/resizeElements.d.ts +4 -3
- package/dist/excalidraw/element/resizeElements.js +47 -23
- package/dist/excalidraw/element/routing.d.ts +13 -0
- package/dist/excalidraw/element/routing.js +641 -0
- package/dist/excalidraw/element/textElement.d.ts +3 -26
- package/dist/excalidraw/element/textElement.js +54 -110
- package/dist/excalidraw/element/textWysiwyg.js +39 -47
- package/dist/excalidraw/element/transformHandles.js +7 -2
- package/dist/excalidraw/element/typeChecks.d.ts +5 -2
- package/dist/excalidraw/element/typeChecks.js +17 -0
- package/dist/excalidraw/element/types.d.ts +12 -1
- package/dist/excalidraw/fonts/ExcalidrawFont.d.ts +21 -0
- package/dist/excalidraw/fonts/ExcalidrawFont.js +112 -0
- package/dist/excalidraw/fonts/index.d.ts +58 -0
- package/dist/excalidraw/fonts/index.js +240 -0
- package/dist/excalidraw/fonts/metadata.d.ts +36 -0
- package/dist/excalidraw/fonts/metadata.js +91 -0
- package/dist/excalidraw/fractionalIndex.d.ts +11 -4
- package/dist/excalidraw/fractionalIndex.js +38 -6
- package/dist/excalidraw/frame.d.ts +1 -1
- package/dist/excalidraw/frame.js +3 -3
- package/dist/excalidraw/history.d.ts +4 -3
- package/dist/excalidraw/history.js +8 -8
- package/dist/excalidraw/index.d.ts +1 -1
- package/dist/excalidraw/index.js +3 -3
- package/dist/excalidraw/locales/en.json +18 -4
- package/dist/excalidraw/math.d.ts +43 -0
- package/dist/excalidraw/math.js +110 -0
- package/dist/excalidraw/mermaid.js +4 -3
- package/dist/excalidraw/renderer/interactiveScene.js +33 -17
- package/dist/excalidraw/renderer/renderElement.d.ts +2 -0
- package/dist/excalidraw/renderer/renderElement.js +74 -54
- package/dist/excalidraw/renderer/staticSvgScene.js +2 -1
- package/dist/excalidraw/scene/Scene.js +9 -3
- package/dist/excalidraw/scene/Shape.js +56 -5
- package/dist/excalidraw/scene/comparisons.d.ts +1 -0
- package/dist/excalidraw/scene/comparisons.js +1 -1
- package/dist/excalidraw/scene/export.d.ts +2 -1
- package/dist/excalidraw/scene/export.js +33 -35
- package/dist/excalidraw/scene/types.d.ts +1 -4
- package/dist/excalidraw/shapes.d.ts +8 -0
- package/dist/excalidraw/shapes.js +57 -0
- package/dist/excalidraw/types.d.ts +8 -3
- package/dist/excalidraw/utils.d.ts +11 -1
- package/dist/excalidraw/utils.js +22 -0
- package/dist/prod/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/prod/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/prod/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/prod/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/prod/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/prod/{en-EB2MBPAV.json → en-YNVBSAIL.json} +18 -4
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +49 -53
- package/dist/utils/export.d.ts +2 -1
- package/dist/utils/export.js +2 -1
- package/dist/utils/geometry/geometry.d.ts +2 -1
- package/dist/utils/geometry/geometry.js +5 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/history.ts +9 -2
- package/package.json +2 -2
- package/dist/browser/dev/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/browser/dev/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/chunk-B4UMSLQQ.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/chunk-EM6LVGFW.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/dist-6QVAH5JA.js.map +0 -7
- package/dist/browser/prod/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/browser/prod/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/chunk-EGOLGOLD.js +0 -55
- package/dist/browser/prod/excalidraw-assets/dist-567JAXHK.js +0 -7
- package/dist/browser/prod/excalidraw-assets/en-6E7MYLWO.js +0 -1
- package/dist/browser/prod/excalidraw-assets/image-SI7BKULC.js +0 -1
- package/dist/dev/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/dev/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/excalidraw/scene/Fonts.d.ts +0 -19
- package/dist/excalidraw/scene/Fonts.js +0 -66
- package/dist/prod/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/prod/Virgil-UZN6MUT6.woff2 +0 -0
- /package/dist/browser/dev/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets-dev/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets-dev/Assistant-Medium-DZ25RZU3.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets-dev/Assistant-Regular-PLF2XOGW.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets-dev/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{en-AZFA5HJJ.js.map → en-XV7OZCPP.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-V7E6IT6R.js.map → image-77HZYGLG.js.map} +0 -0
- /package/dist/browser/prod/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets/Assistant-Medium-DZ25RZU3.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets/Assistant-Regular-PLF2XOGW.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
package/dist/prod/index.js
CHANGED
|
@@ -1,68 +1,64 @@
|
|
|
1
|
-
var NC=Object.defineProperty;var hx=e=>t=>{var r=e[t];if(r)return r();throw new Error("Module not found in bundle: "+t)};var Q=(e,t)=>()=>(e&&(t=e(e=0)),t);var gh=(e,t)=>{for(var r in t)NC(e,r,{get:t[r],enumerable:!0})};var T,f=Q(()=>{T={PROD:!0}});var bh,Ex=Q(()=>{bh={}});import KC from"open-color";var $C,xx,ta,yx,ts,rs,Ro,No,ue,wx,Ad,kd,Md,vx,Tx,Sx,Ix,ir=Q(()=>{"use strict";f();$C=(e,t)=>t.reduce((r,o)=>(o in e&&(r[o]=e[o]),r),{}),xx=5,ta=5,yx=4,ts=4,rs=1,Ro=[0,2,4,6,8],No=(e,t)=>t.map(r=>KC[e][r]),ue={transparent:"transparent",black:"#1e1e1e",white:"#ffffff",gray:No("gray",Ro),red:No("red",Ro),pink:No("pink",Ro),grape:No("grape",Ro),violet:No("violet",Ro),blue:No("blue",Ro),cyan:No("cyan",Ro),teal:No("teal",Ro),green:No("green",Ro),yellow:No("yellow",Ro),orange:No("orange",Ro),bronze:["#f8f1ee","#eaddd7","#d2bab0","#a18072","#846358"]},wx=$C(ue,["cyan","blue","violet","grape","pink","green","teal","yellow","orange","red"]),Ad=[ue.black,ue.red[ts],ue.green[ts],ue.blue[ts],ue.yellow[ts]],kd=[ue.transparent,ue.red[rs],ue.green[rs],ue.blue[rs],ue.yellow[rs]],Md=[ue.white,"#f8f9fa","#f5faff","#fffce8","#fdf8f6"],vx={transparent:ue.transparent,white:ue.white,gray:ue.gray,black:ue.black,bronze:ue.bronze,...wx},Tx={transparent:ue.transparent,white:ue.white,gray:ue.gray,black:ue.black,bronze:ue.bronze,...wx},Sx=e=>[ue.cyan[e],ue.blue[e],ue.violet[e],ue.grape[e],ue.pink[e],ue.green[e],ue.teal[e],ue.yellow[e],ue.orange[e],ue.red[e]],Ix=(e,t,r)=>`#${((1<<24)+(e<<16)+(t<<8)+r).toString(16).slice(1)}`});var br,Ld,Cx,_n,XC,X7,Pd,Ax,Rl,Nl,kx,Rn,os,Mx,Eh,Lx,on,xh,Ne,di,ra,Ol,Mr,Dd,mt,ce,qe,yh,_d,Tt,Zt,nn,oa,Nn,Rd,ZC,Px,Bl,Dx,_x,On,Fl,Rx,oe,Nd,ar,zl,Nx,Ox,Bx,Fx,na,ns,wh,zx,is,Od,Bd,vh,Hx,Ux,Gx,Wx,Vx,as,ss,Oo,Yx,Th,We,ia,ht,Kx,$x,St,mi,Xx,Fd,Zx,lt,Sh,zd,nt,Hl,Xr,Hd,xt,lo,Ud,pi,Lr,Y=Q(()=>{"use strict";f();Ex();ir();br=/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ld=/^Win/.test(navigator.platform),Cx=/\b(android)\b/i.test(navigator.userAgent),_n="netscape"in window&&navigator.userAgent.indexOf("rv:")>1&&navigator.userAgent.indexOf("Gecko")>1,XC=navigator.userAgent.indexOf("Chrome")!==-1,X7=!XC&&navigator.userAgent.indexOf("Safari")!==-1,Pd=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,Ax=()=>navigator.brave?.isBrave?.name==="isBrave",Rl=typeof window<"u"&&"ResizeObserver"in window,Nl="Excalidraw",kx=36,Rn=10,os=8,Mx=5,Eh=1,Lx=30,on=Math.PI/12,xh="red",Ne={TEXT:"text",CROSSHAIR:"crosshair",GRABBING:"grabbing",GRAB:"grab",POINTER:"pointer",MOVE:"move",AUTO:""},di={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},ra={enabled:"all",disabled:"none",inheritFromUI:"var(--ui-pointerEvents)"},Ol={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},Mr={TEST:"test",DEVELOPMENT:"development"},Dd={SHAPE_ACTIONS_MENU:"App-menu__left"},mt={Virgil:1,Helvetica:2,Cascadia:3,Assistant:4},ce={LIGHT:"light",DARK:"dark"},qe={strokeColor:"#bbb",strokeWidth:2,strokeStyle:"solid",fillStyle:"solid",roughness:0,roundness:null,backgroundColor:"transparent",radius:8,nameOffsetY:3,nameColorLightTheme:"#999999",nameColorDarkTheme:"#7a7a7a",nameFontSize:14,nameLineHeight:1.25},yh="Segoe UI Emoji",_d=1,Tt=20,Zt=mt.Virgil,nn="left",oa="top",Nn=2,Rd=2*Nn,ZC=1e-5,Px=2*Rd-ZC,Bl="#ffffff",Dx="#1e1e1e",_x="#a2f1a6",On=20,Fl={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif"},Rx=["text/plain","text/html"],oe={json:"application/json",excalidraw:"application/vnd.excalidraw+json",excalidrawlib:"application/vnd.excalidrawlib+json","excalidraw.svg":"image/svg+xml","excalidraw.png":"image/png",binary:"application/octet-stream",...Fl},Nd={png:"png",svg:"svg",clipboard:"clipboard"},ar={excalidraw:"excalidraw",excalidrawClipboard:"excalidraw/clipboard",excalidrawLibrary:"excalidrawlib",excalidrawClipboardWithAPI:"excalidraw-api/clipboard"},zl=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,Nx=500,Ox=300,Bx=500,Fx=100,na=.1,ns=.1,wh=30,zx=300,is=bh.themeFilter,Od={addLibrary:"addLibrary"},Bd={addLibrary:"addLibrary"},vh={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},Hx=730,Ux=1e3,Gx=500,Wx=1229,Vx=parseInt(bh.rightSidebarWidth),as=2,ss=[1,2,3],Oo=10,Yx=1440,Th=2*1024*1024,We="http://www.w3.org/2000/svg",ia={excalidraw:2,excalidrawLibrary:2},ht=5,Kx=.7,$x=11,St={TOP:"top",MIDDLE:"middle",BOTTOM:"bottom"},mi={LEFT:"left",CENTER:"center",RIGHT:"right"},Xx=20,Fd=.25,Zx=32,lt={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},Sh={architect:0,artist:1,cartoonist:2},zd={thin:1,bold:2,extraBold:4},nt={strokeColor:ue.black,backgroundColor:ue.transparent,fillStyle:"solid",strokeWidth:2,strokeStyle:"solid",roughness:Sh.artist,opacity:100,locked:!1},Hl="library",Xr={name:"default",defaultTab:Hl},Hd=new Set(["iframe","embeddable","image"]),xt={selection:"selection",rectangle:"rectangle",diamond:"diamond",ellipse:"ellipse",arrow:"arrow",line:"line",freedraw:"freedraw",text:"text",image:"image",eraser:"eraser",hand:"hand",frame:"frame",magicframe:"magicframe",embeddable:"embeddable",laser:"laser"},lo={OAI_API_KEY:"excalidraw-oai-api-key",MERMAID_TO_EXCALIDRAW:"mermaid-to-excalidraw",PUBLISH_LIBRARY:"publish-library-data"},Ud="Untitled",pi={generalStats:1,elementProperties:2},Lr=1});function gt(e,t,r,o){return e?(e?.addEventListener?.(t,r,o),()=>{e?.removeEventListener?.(t,r,o)}):()=>{}}function p1(e,t=!0){let r=e.length;if(r<4)return"";let o=e[0],n=e[1],i=e[2],a=`M${o[0].toFixed(2)},${o[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${Wd(n[0],i[0]).toFixed(2)},${Wd(n[1],i[1]).toFixed(2)} T`;for(let s=2,l=r-1;s<l;s++)o=e[s],n=e[s+1],a+=`${Wd(o[0],n[0]).toFixed(2)},${Wd(o[1],n[1]).toFixed(2)} `;return t&&(a+="Z"),a}var qx,Ch,ui,e1,Ah,t1,co,ls,Ie,aa,cs,Bn,Jx,r1,o1,_t,et,R,$e,Ht,Ul,o5,n5,i5,Vd,Bo,Yd,kh,Mh,Er,Kd,n1,i1,a1,s1,Fn,X,l1,an,Pr,c1,$d,ds,d1,sn,Gl,Qx,tt,hi,Fo,m1,Wl,ln,Lh,Xd,Wd,Zd,Zr,Vl,G=Q(()=>{"use strict";f();ir();Y();qx=null,Ch=()=>{if(qx)return qx;let e=new Date,t=e.getFullYear(),r=`${e.getMonth()+1}`.padStart(2,"0"),o=`${e.getDate()}`.padStart(2,"0"),n=`${e.getHours()}`.padStart(2,"0"),i=`${e.getMinutes()}`.padStart(2,"0");return`${t}-${r}-${o}-${n}${i}`},ui=e=>e.charAt(0).toUpperCase()+e.slice(1),e1=e=>e instanceof HTMLElement&&e.className.includes("ToolIcon"),Ah=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,t1=e=>Ah(e)||e instanceof Element&&!!e.closest("label, button"),co=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type==="text"||e.type==="number"||e.type==="password"),ls=({fontFamily:e})=>{for(let[t,r]of Object.entries(mt))if(r===e)return`${t}, ${yh}`;return yh},Ie=({fontSize:e,fontFamily:t})=>`${e}px ${ls({fontFamily:t})}`,aa=(e,t)=>{let r=0,o=null,n=(...i)=>{o=i,clearTimeout(r),r=window.setTimeout(()=>{o=null,e(...i)},t)};return n.flush=()=>{if(clearTimeout(r),o){let i=o;o=null,e(...i)}},n.cancel=()=>{o=null,clearTimeout(r)},n},cs=(e,t)=>{let r=null,o=null,n=null,i=s=>{r=window.requestAnimationFrame(()=>{r=null,e(...s),o=null,n&&(o=n,n=null,i(o))})},a=(...s)=>{if(T.MODE==="test"){e(...s);return}o=s,r===null?i(o):t?.trailing&&(n=s)};return a.flush=()=>{r!==null&&(cancelAnimationFrame(r),r=null),o&&(e(...n||o),o=n=null)},a.cancel=()=>{o=n=null,r!==null&&(cancelAnimationFrame(r),r=null)},a},Bn=e=>1-Math.pow(1-e,4),Jx=(e,t,r)=>(t-e)*Bn(r)+e,r1=({fromValues:e,toValues:t,onStep:r,duration:o=250,interpolateValue:n,onStart:i,onEnd:a,onCancel:s})=>{let l=!1,c=0,d;function m(p){if(l)return;d===void 0&&(d=p,i?.());let u=Math.min(p-d,o),h=Bn(u/o),g={};if(Object.keys(e).forEach(x=>{let v=x,y=(t[v]-e[v])*h+e[v];g[v]=y}),r(g),u<o){let x=u/o,v={};Object.keys(e).forEach(y=>{let w=y,I=e[w],A=t[w],C;C=n?n(I,A,x,w):Jx(I,A,x),C==null&&(C=Jx(I,A,x)),v[w]=C}),r(v),c=window.requestAnimationFrame(m)}else r(t),a?.()}return c=window.requestAnimationFrame(m),()=>{s?.(),l=!0,window.cancelAnimationFrame(c)}},o1=(e,t)=>{if(!e.length||t<1)return[];let r=0,o=0,n=Array(Math.ceil(e.length/t));for(;r<e.length;)n[o++]=e.slice(r,r+=t);return n},_t=(e,t)=>Math.abs(e-t),et=(e,t)=>t.type==="custom"?{...e.activeTool,type:"custom",customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked},R=e=>(e=e.replace(/\bAlt\b/i,"Alt").replace(/\bShift\b/i,"Shift").replace(/\b(Enter|Return)\b/i,"Enter"),br?e.replace(/\bCtrlOrCmd\b/gi,"Cmd").replace(/\bAlt\b/i,"Option"):e.replace(/\bCtrlOrCmd\b/gi,"Ctrl")),$e=({clientX:e,clientY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let s=(e-o)/r.value-i,l=(t-n)/r.value-a;return{x:s,y:l}},Ht=({sceneX:e,sceneY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let s=(e+i)*r.value+o,l=(t+a)*r.value+n;return{x:s,y:l}},Ul=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),o5="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF",n5="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",i5=new RegExp(`^[^${o5}]*[${n5}]`),Vd=e=>i5.test(e),Bo=e=>{let[t,r]=e;return{x:t,y:r}},Yd=e=>{if(e?.name==="AbortError"){console.warn(e);return}throw e},kh=(e,t,r=0)=>{r<0&&(r=e.length+r),r=Math.min(e.length,Math.max(r,0));let o=r-1;for(;++o<e.length;)if(t(e[o],o,e))return o;return-1},Mh=(e,t,r=e.length-1)=>{r<0&&(r=e.length+r),r=Math.min(e.length-1,Math.max(r,0));let o=r+1;for(;--o>-1;)if(t(e[o],o,e))return o;return-1},Er=e=>{let t=e.length===5&&e.substr(4,1)==="0",r=e.length===9&&e.substr(7,2)==="00";return t||r||e===ue.transparent},Kd=()=>{let e,t,r=new Promise((o,n)=>{e=o,t=n});return r.resolve=e,r.reject=t,r},n1=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:r}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(r==="auto"||r==="scroll"||r==="overlay"))return t;t=t.parentElement}return document},i1=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},a1=e=>{e.preventDefault(),e.returnValue=""},s1=e=>Array.from(e).map(t=>`0${t.toString(16)}`.slice(-2)).join(""),Fn=()=>Pr()?1:Date.now(),X=e=>e instanceof Map?e:e.reduce((t,r)=>(t.set(typeof r=="string"?r:r.id,r),t),new Map),l1=e=>e.reduce((t,r,o)=>(t.set(r.id,[r,o]),t),new Map),an=(e,t)=>e.reduce((r,o)=>(r[t?t(o):String(o)]=o,r),{}),Pr=()=>T.MODE==="test",c1=()=>T.MODE==="development",$d=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),ds=(e,t)=>{let r=!1;for(let o in t){let n=t[o];if(typeof n<"u"){if(e[o]===n&&(typeof n!="object"||n===null))continue;r=!0}}return r?{...e,...t}:e},d1=()=>{try{return window.self===window.top?"top":"iframe"}catch{return"iframe"}},sn=e=>!!e&&typeof e=="object"&&"then"in e&&"catch"in e&&"finally"in e,Gl=e=>{let t=e?.querySelectorAll("button, a, input, select, textarea, div[tabindex], label[tabindex]");return t?Array.from(t).filter(r=>r.tabIndex>-1&&!r.disabled):[]},Qx=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,tt=(e,t,r,o=!1)=>{let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return o&&console.warn("%cisShallowEqual: objects don't have same properties ->","color: #8B4000",e,t),!1;if(r&&Array.isArray(r)){for(let a of r)if(!(e[a]===t[a]||Qx(e[a],t[a])))return o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),!1;return!0}return n.every(a=>{let s=r?.[a],l=s?s(e[a],t[a]):e[a]===t[a]||Qx(e[a],t[a]);return!l&&o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),l})},hi=(e,t,{checkForDefaultPrevented:r=!0}={})=>function(n){if(e?.(n),!r||!n?.defaultPrevented)return t?.(n)},Fo=(e,t,r)=>{if(!t)return e;if(r)return console.error(t),e;throw new Error(t)},m1=e=>{let t,r,o=function(n){let i=Object.entries(n);if(t){let s=!0;for(let[l,c]of i)if(t.get(l)!==c){s=!1;break}if(s)return r}let a=e(n);return t=new Map(i),r=a,a};return o.clear=()=>{t=void 0,r=void 0},o},Wl=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):"includes"in e?e.includes(t):e.hasOwnProperty(t),ln=e=>JSON.parse(JSON.stringify(e)),Lh=e=>typeof e=="number"&&Number.isFinite(e),Xd=(e,t)=>tt(e,t)?e:t;Wd=(e,t)=>(e+t)/2;Zd=e=>e.replace(/\r?\n|\r/g,`
|
|
2
|
-
`),Zr=e=>e,Vl=async(e,...t)=>new Promise(r=>{r(e(...t))})});var xr,mo,kt,po,jt,U,gi,sa,re,Rt,a5,ie,xe,Yl,Dr,Ph,la,cn,Kl,sr,Me,dn,u1,h1,g1,le=Q(()=>{"use strict";f();Y();G();xr=e=>!!e&&e.type==="image"&&!!e.fileId,mo=e=>!!e&&e.type==="image",kt=e=>!!e&&e.type==="embeddable",po=e=>!!e&&e.type==="iframe",jt=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),U=e=>e!=null&&e.type==="text",gi=e=>e!=null&&e.type==="frame",sa=e=>e!=null&&e.type==="magicframe",re=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Rt=e=>e!=null&&a5(e.type),a5=e=>e==="freedraw",ie=e=>e!=null&&Yl(e.type),xe=e=>e!=null&&e.type==="arrow",Yl=e=>e==="arrow"||e==="line",Dr=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&Ph(e.type),Ph=e=>e==="arrow",la=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),cn=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||xe(e)),Kl=e=>{let t=e?.type;if(!t)return!1;switch(t){case"text":case"diamond":case"rectangle":case"iframe":case"embeddable":case"ellipse":case"arrow":case"freedraw":case"line":case"frame":case"magicframe":case"image":case"selection":return!0;default:return Fo(t,null),!1}},sr=e=>cn(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),Me=e=>e!==null&&"containerId"in e&&e.containerId!==null&&U(e),dn=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",u1=e=>e==="line"||e==="arrow"||e==="diamond",h1=(e,t)=>!!((e===lt.ADAPTIVE_RADIUS||e===lt.LEGACY)&&dn(t.type)||e===lt.PROPORTIONAL_RADIUS&&u1(t.type)),g1=e=>u1(e.type)?{type:lt.PROPORTIONAL_RADIUS}:dn(e.type)?{type:lt.ADAPTIVE_RADIUS}:null});import{Random as s5}from"roughjs/bin/math";import{nanoid as l5}from"nanoid";var c5,d5,uo,Nt,zo=Q(()=>{"use strict";f();G();c5=new s5(Date.now()),d5=0,uo=()=>Math.floor(c5.next()*2**31),Nt=()=>Pr()?`id${d5++}`:l5()});var jd,mn,Ho,qd,fi=Q(()=>{"use strict";f();jd=class extends Error{constructor(t="Couldn't export canvas.",r="CANVAS_ERROR"){super(),this.name=r,this.message=t}},mn=class extends DOMException{constructor(t="Request Aborted"){super(t,"AbortError")}},Ho=class extends Error{code;constructor(t="Image Scene Data Error",r="IMAGE_SCENE_DATA_ERROR"){super(t),this.name="EncodingError",this.code=r}},qd=class extends Error{code="ELEMENT_HAS_INVALID_INDEX"}});import{generateNKeysBetween as m5}from"fractional-indexing";var _h,Jd,Ut,yr,p5,u5,Dh,b1,f1,ho=Q(()=>{"use strict";f();Ae();fi();_h=e=>{for(let[t,r]of e.entries()){let o=e[t-1],n=e[t+1];if(!Dh(r,o,n))throw new qd(`Fractional indices invariant for element has been compromised - ["${o}", "${r}", "${n}"] [predecessor, current, successor]`)}},Jd=e=>e.sort((t,r)=>f1(t)&&f1(r)?t.index<r.index?-1:t.index>r.index?1:t.id<r.id?-1:1:1),Ut=(e,t)=>{try{let r=p5(e,t),o=b1(e,r);_h(e.map(n=>o.get(n)?.index||n.index));for(let[n,i]of o)O(n,i,!1)}catch{yr(e)}return e},yr=e=>{let t=u5(e),r=b1(e,t);for(let[o,n]of r)O(o,n,!1);return e},p5=(e,t)=>{let r=[],o=0;for(;o<e.length;)if(t.has(e[o].id)){let n=[o-1,o];for(;++o<e.length&&t.has(e[o].id);)n.push(o);n.push(o),r.push(n)}else o++;return r},u5=e=>{let t=[],r,o,n=-1,i=0,a=c=>{let d=e[n]?e[n].index:void 0,m=e[c-1]?.index;return!d&&m||d&&m&&m>d?[m,c-1]:[d,n]},s=c=>{let d=e[i]?e[i].index:void 0;if(d&&c<i)return[d,i];let m=i;for(;++m<e.length;){let p=e[m]?.index;if(!d&&p||d&&p&&p>d)return[p,m]}return[void 0,m]},l=0;for(;l<e.length;){let c=e[l].index;if([r,n]=a(l),[o,i]=s(l),Dh(c,r,o))l++;else{let d=[n,l];for(;++l<e.length;){let m=e[l].index,[p,u]=a(l),[h,g]=s(l);if(Dh(m,p,h))break;[r,n]=[p,u],[o,i]=[h,g],d.push(l)}d.push(i),t.push(d)}}return t},Dh=(e,t,r)=>e?t&&r?t<e&&e<r:!t&&r?e<r:t&&!r?t<e:!!e:!1,b1=(e,t)=>{let r=new Map;for(let o of t){let n=o.shift(),i=o.pop(),a=m5(e[n]?.index,e[i]?.index,o.length);for(let s=0;s<o.length;s++){let l=e[o[s]];r.set(l,{index:a[s]})}}return r},f1=e=>!!e.index});var E1,h5,x1,Rh,Mt,bi=Q(()=>{"use strict";f();be();le();Ei();zo();ho();G();G();Y();E1=e=>{let t=new Map,r=[];for(let o of e)o.isDeleted||(r.push(o),t.set(o.id,o));return{elementsMap:t,elements:r}},h5=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],r="";for(let o of t)r+=`${o}:${e[o]?"1":"0"}`;return r},x1=e=>typeof e=="string",Rh=class e{static sceneMapByElement=new WeakMap;static sceneMapById=new Map;static mapElementToScene(t,r){x1(t)?this.sceneMapById.set(t,r):(this.sceneMapByElement.set(t,r),this.sceneMapById.set(t.id,r))}static getScene(t){return x1(t)?this.sceneMapById.get(t)||null:this.sceneMapByElement.get(t)||null}callbacks=new Set;nonDeletedElements=[];nonDeletedElementsMap=Zr(new Map);elements=[];nonDeletedFramesLikes=[];frames=[];elementsMap=Zr(new Map);selectedElementsCache={selectedElementIds:null,elements:null,cache:new Map};sceneNonce;getSceneNonce(){return this.sceneNonce}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(t){let r=h5(t),o=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===o&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let i=this.selectedElementsCache.cache.get(r);if(i)return i}else t?.elements==null&&this.selectedElementsCache.cache.clear();let n=pe(o,{selectedElementIds:t.selectedElementIds},t);return t?.elements==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(r,n)),n}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getNonDeletedElement(t){let r=this.getElement(t);return r&&$l(r)?r:null}mapElements(t){let r=!1,o=this.elements.map(n=>{let i=t(n);return i!==n&&(r=!0),i});return r&&this.replaceAllElements(o),r}replaceAllElements(t){let r=t instanceof Array?t:Array.from(t.values()),o=[];(T.DEV||T.MODE===Mr.TEST)&&_h(r.map(i=>i.index)),this.elements=yr(r),this.elementsMap.clear(),this.elements.forEach(i=>{re(i)&&o.push(i),this.elementsMap.set(i.id,i),e.mapElementToScene(i,this)});let n=E1(this.elements);this.nonDeletedElements=n.elements,this.nonDeletedElementsMap=n.elementsMap,this.frames=o,this.nonDeletedFramesLikes=E1(this.frames).elements,this.triggerUpdate()}triggerUpdate(){this.sceneNonce=uo();for(let t of Array.from(this.callbacks))t()}onUpdate(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),e.sceneMapById.forEach((t,r)=>{t===this&&e.sceneMapById.delete(r)}),this.callbacks.clear()}insertElementAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),t,...this.elements.slice(r)];Ut(o,X([t])),this.replaceAllElements(o)}insertElementsAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),...t,...this.elements.slice(r)];Ut(o,X(t)),this.replaceAllElements(o)}insertElement=t=>{let r=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,r)};insertElements=t=>{let r=t[0].frameId?this.getElementIndex(t[0].frameId):this.elements.length;this.insertElementsAtIndex(t,r)};getElementIndex(t){return this.elements.findIndex(r=>r.id===t)}getContainerElement=t=>t&&t.containerId&&this.getElement(t.containerId)||null},Mt=Rh});var ms,xi,ps=Q(()=>{"use strict";f();ms=e=>{let t=e.map(o=>o[0]),r=e.map(o=>o[1]);return{width:Math.max(...t)-Math.min(...t),height:Math.max(...r)-Math.min(...r)}},xi=(e,t,r,o)=>{let n=r.map(u=>u[e]),i=Math.max(...n),a=Math.min(...n),s=i-a,l=s===0?1:t/s,c=1/0,d=r.map(u=>{let h=u[e]*l,g=[...u];return g[e]=h,h<c&&(c=h),g});if(!o||d.length===2)return d;let m=a-c;return d.map(u=>u.map((h,g)=>g===e?h+m:h))}});var he,Pe,y1,It,us,wr,Qd,Lt,Uo,Nh,Oh,g5,w1,v1,T1,Bh,S1,hs,gs,Xl,Zl,jl,ft=Q(()=>{"use strict";f();Y();it();pn();he=(e,t,r,o,n)=>[(e-r)*Math.cos(n)-(t-o)*Math.sin(n)+r,(e-r)*Math.sin(n)+(t-o)*Math.cos(n)+o],Pe=(e,t,r)=>he(e[0],e[1],t[0],t[1],r),y1=(e,t,r,o,n,i,a,s)=>{let l=Math.cos(o),c=Math.sin(o);return e.e&&e.w?t+=n+a:e.e?(t+=n*(1+l),r+=n*c,t+=a*(1-l),r+=a*-c):e.w&&(t+=n*(1-l),r+=n*-c,t+=a*(1+l),r+=a*c),e.n&&e.s?r+=i+s:e.n?(t+=i*c,r+=i*(1-l),t+=s*-c,r+=s*(1+l)):e.s&&(t+=i*-c,r+=i*(1+l),t+=s*c,r+=s*(1-l)),[t,r]},It=(e,t,r,o)=>{let n=r-e,i=o-t;return Math.hypot(n,i)},us=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],wr=(e,t=1)=>{if(e.length>=3){let[r,o]=[e[0],e[e.length-1]];return It(r[0],r[1],o[0],o[1])<=os/t}return!1},Qd=(e,t,r)=>t[0]<=Math.max(e[0],r[0])&&t[0]>=Math.min(e[0],r[0])&&t[1]<=Math.max(e[1],r[1])&&t[1]>=Math.min(e[1],r[1]),Lt=(e,t,r)=>r?[Math.round(e/r)*r,Math.round(t/r)*r]:[e,t],Uo=(e,t)=>{if(t.roundness?.type===lt.PROPORTIONAL_RADIUS||t.roundness?.type===lt.LEGACY)return e*Fd;if(t.roundness?.type===lt.ADAPTIVE_RADIUS){let r=t.roundness?.value??Zx,o=r/Fd;return e<=o?e*Fd:r}return 0},Nh=(e,t)=>{let r=Oe.generateElementShape(e,null);if(!r)return null;let o=yi(r[0]),n=[0,0],i=0,a=1/0,s=null;for(;i<o.length;){let{op:l,data:c}=o[i];if(l==="move"&&(n=c),l==="bcurveTo"){let d=n,m=[c[0],c[1]],p=[c[2],c[3]],u=[c[4],c[5]],h=It(u[0],u[1],t[0],t[1]);h<a&&(a=h,s=[d,m,p,u]),n=u}i++}return s},Oh=(e,t,r,o,n)=>{let i=(l,c)=>Math.pow(1-l,3)*o[c]+3*l*Math.pow(1-l,2)*r[c]+3*Math.pow(l,2)*(1-l)*t[c]+e[c]*Math.pow(l,3),a=i(n,0),s=i(n,1);return[a,s]},g5=(e,t)=>{let r=Nh(e,t);if(!r)return[];let o=[],n=1;for(;n>0;){let i=Oh(r[0],r[1],r[2],r[3],n);o.push([i[0],i[1]]),n-=.05}return o.length&&Bh(o.at(-1),t)&&o.push([t[0],t[1]]),o},w1=(e,t)=>{let r=[];r[0]=0;let o=g5(e,t),n=0,i=0;for(;n<o.length-1;){let a=It(o[n][0],o[n][1],o[n+1][0],o[n+1][1]);i+=a,r.push(i),n++}return r},v1=(e,t)=>w1(e,t).at(-1),T1=(e,t,r)=>{let o=w1(e,t),n=o.length-1,i=o.at(-1),a=r*i,s=0,l=n,c=0;for(;s<l;)c=Math.floor(s+(l-s)/2),o[c]<a?s=c+1:l=c;return o[c]>a&&c--,o[c]===a?c/n:1-(c+(a-o[c])/(o[c+1]-o[c]))/n},Bh=(e,t)=>e[0]===t[0]&&e[1]===t[1],S1=e=>Math.round(e/Math.PI*1e4)%5e3===0,hs=e=>e*180/Math.PI,gs=e=>e/180*Math.PI,Xl=([e,t],[r,o])=>e<=r?t>=r:e>=r?o>=e:!1,Zl=(e,t)=>{let r=Math.max(e[0],t[0]),o=Math.min(e[1],t[1]);return r<=o?[r,o]:null},jl=(e,t,r)=>e>=t&&e<=r});var zn,ql,em,tm,fs,ca,Fh,Jl=Q(()=>{"use strict";f();le();zn=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",ql=e=>e!=="image"&&e!=="frame"&&e!=="magicframe",em=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",tm=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",fs=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="arrow"||e==="line"||e==="diamond"||e==="image",ca=e=>e==="arrow",Fh=(e,t)=>{let r=null;for(let o=e.length-1;o>=0;--o){let n=e[o];if(!n.isDeleted&&t(n)){r=n;break}}return r}});import{simplify as f5}from"points-on-curve";function E5(e){let t=e.roughness,r=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&r>=50||o>=15&&e.roundness&&fs(e.type)||ie(e)&&r>=50?t:Math.min(t/(r<10?3:2),2.5)}var b5,A1,jr,I1,C1,k1,zh=Q(()=>{"use strict";f();be();ft();Hn();G();Y();le();Jl();b5=e=>[8,8+e],A1=e=>[1.5,6+e];jr=(e,t=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?b5(e.strokeWidth):e.strokeStyle==="dotted"?A1(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:E5(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<Sh.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return r.fillStyle=e.fillStyle,r.fill=Er(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(r.curveFitting=1),r;case"line":case"freedraw":return wr(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),r;case"arrow":return r;default:throw new Error(`Unimplemented type ${e.type}`)}},I1=(e,t,r)=>jt(e)&&(t||kt(e)&&r?.get(e.id)!==!0)&&Er(e.backgroundColor)&&Er(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:po(e)?{...e,strokeColor:Er(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Er(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,C1=(e,t,r,o,n,i,a)=>{let s=Uh(e,t,r,o);if(s===null)return[];switch(o){case"dot":case"circle":case"circle_outline":{let[l,c,d]=s;return delete i.strokeLineDash,[n.circle(l,c,d,{...i,fill:o==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[l,c,d,m,p,u]=s;return delete i.strokeLineDash,[n.polygon([[l,c],[d,m],[p,u],[l,c]],{...i,fill:o==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[l,c,d,m,p,u,h,g]=s;return delete i.strokeLineDash,[n.polygon([[l,c],[d,m],[p,u],[h,g],[l,c]],{...i,fill:o==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"bar":case"arrow":default:{let[l,c,d,m,p,u]=s;if(e.strokeStyle==="dotted"){let h=A1(e.strokeWidth-1);i.strokeLineDash=[h[0],h[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(d,m,l,c,i),n.line(p,u,l,c,i)]}}},k1=(e,t,{isExporting:r,canvasBackgroundColor:o,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,s=e.height,l=Uo(Math.min(a,s),e);i=t.path(`M ${l} 0 L ${a-l} 0 Q ${a} 0, ${a} ${l} L ${a} ${s-l} Q ${a} ${s}, ${a-l} ${s} L ${l} ${s} Q 0 ${s}, 0 ${s-l} L 0 ${l} Q 0 0, ${l} 0`,jr(I1(e,r,n),!0))}else i=t.rectangle(0,0,e.width,e.height,jr(I1(e,r,n),!1));return i}case"diamond":{let i,[a,s,l,c,d,m,p,u]=Hh(e);if(e.roundness){let h=Uo(Math.abs(a-p),e),g=Uo(Math.abs(c-s),e);i=t.path(`M ${a+h} ${s+g} L ${l-h} ${c-g}
|
|
3
|
-
C ${l} ${c}, ${l} ${c}, ${l-h} ${c+g}
|
|
4
|
-
L ${d+h} ${m-g}
|
|
5
|
-
C ${d} ${m}, ${d} ${m}, ${d-h} ${m-g}
|
|
6
|
-
L ${p+h} ${u+g}
|
|
7
|
-
C ${p} ${u}, ${p} ${u}, ${p+h} ${u-g}
|
|
8
|
-
L ${a-h} ${s+g}
|
|
9
|
-
C ${a} ${s}, ${a} ${s}, ${a+h} ${s+g}`,jr(e,!0))}else i=t.polygon([[a,s],[l,c],[d,m],[p,u]],jr(e));return i}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,jr(e));case"line":case"arrow":{let i,a=jr(e),s=e.points.length?e.points:[[0,0]];if(e.roundness?i=[t.curve(s,a)]:a.fill?i=[t.polygon(s,a)]:i=[t.linearPath(s,a)],e.type==="arrow"){let{startArrowhead:l=null,endArrowhead:c="arrow"}=e;if(l!==null){let d=C1(e,i,"start",l,t,a,o);i.push(...d)}if(c!==null){let d=C1(e,i,"end",c,t,a,o);i.push(...d)}}return i}case"freedraw":{let i;if(M1(e),wr(e.points)){let a=f5(e.points,.75);i=t.curve(a,{...jr(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return Fo(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}}});var lr,L1,da,bs,P1,Gh,wi,x5,Wh,rm,Vh,D1,Yh,_1,ma,R1,Kh,cN,dN,mN,pN,uN,hN,gN,pa=Q(()=>{"use strict";f();lr=(e,t)=>[0,0,0,0,t,e,1,0],L1=(e,t)=>[0,0,0,0,t,e,0,0],da=(e=0,t=0)=>{let r=[0,0,0,0,0,0,0,0];if(t<0||t>7)throw new Error(`Expected \`index\` between 0 and 7, got \`${t}\``);return e!==0&&(r[t]=e),r},bs=e=>[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7]],P1=(e,t)=>Kh(t)?[e[0]+t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]+t[0],e[1]+t[1],e[2]+t[2],e[3]+t[3],e[4]+t[4],e[5]+t[5],e[6]+t[6],e[7]+t[7]],Gh=(e,t)=>Kh(t)?[e[0]-t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3],e[4]-t[4],e[5]-t[5],e[6]-t[6],e[7]-t[7]],wi=(e,t)=>Kh(t)?[e[0]*t,e[1]*t,e[2]*t,e[3]*t,e[4]*t,e[5]*t,e[6]*t,e[7]*t]:[x5(e,t),t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[7]*e[3]+t[0]*e[4]+t[6]*e[5]-t[5]*e[6]+t[3]*e[7],t[5]*e[0]-t[3]*e[1]+t[7]*e[2]+t[1]*e[3]-t[6]*e[4]+t[0]*e[5]+t[4]*e[6]+t[2]*e[7],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]+t[0]*e[7]],x5=(e,t)=>t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],Wh=(e,t)=>[t[0]*e[0],t[1]*e[0]+t[0]*e[1],t[2]*e[0]+t[0]*e[2],t[3]*e[0]+t[0]*e[3],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[0]*e[4],t[5]*e[0]-t[3]*e[1]+t[1]*e[3]+t[0]*e[5],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]],rm=(e,t)=>[Vh(e,t),e[1]*t[7]+e[4]*t[5]-e[5]*t[4]+e[7]*t[1],e[2]*t[7]-e[4]*t[6]+e[6]*t[4]+e[7]*t[2],e[3]*t[7]+e[5]*t[6]-e[6]*t[5]+e[7]*t[3],e[4]*t[7]+e[7]*t[4],e[5]*t[7]+e[7]*t[5],e[6]*t[7]+e[7]*t[6],e[7]*t[7]],Vh=(e,t)=>e[0]*t[7]+e[1]*t[6]+e[2]*t[5]+e[3]*t[4]+e[4]*t[3]+e[5]*t[2]+e[6]*t[1]+e[7]*t[0],D1=(e,t)=>[t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[7]*e[3]+t[0]*e[4]+t[3]*e[7],t[5]*e[0]+t[7]*e[2]+t[0]*e[5]+t[2]*e[7],t[6]*e[0]+t[0]*e[6],t[7]*e[0]+t[0]*e[7]],Yh=e=>Math.sqrt(Math.abs(e[0]*e[0]-e[2]*e[2]-e[3]*e[3]+e[6]*e[6])),_1=e=>Math.sqrt(Math.abs(e[7]*e[7]-e[5]*e[5]-e[4]*e[4]+e[1]*e[1])),ma=e=>{let t=Yh(e);if(t===0||t===1)return e;let r=e[6]<0?-1:1;return wi(e,r/t)},R1=e=>{let t=_1(e);return t===0||t===1?e:wi(e,1/t)},Kh=e=>typeof e=="number",cN=da(1,1),dN=da(1,2),mN=da(1,3),pN=da(1,4),uN=da(1,5),hN=da(1,6),gN=da(1,7)});var om,Es,N1,O1,B1,$h=Q(()=>{"use strict";f();pa();om=(e,t,r)=>ma([0,r,e,t,0,0,0,0]),Es=(e,t)=>ma(rm(t,e)),N1=(e,t)=>D1(e,t),O1=(e,t)=>N1(Es(e,t),t),B1=e=>Math.sign(e[1])});var ua,ha,z1,H1,Xh,vi,U1=Q(()=>{"use strict";f();pa();$h();pa();ua=([e,t])=>[0,0,0,0,t,e,1,0],ha=e=>[e[5],e[4]],z1=e=>[0,0,0,0,Math.abs(e[4]),Math.abs(e[5]),1,0],H1=(e,t)=>ma(Wh(e,t)),Xh=(e,t)=>Yh(rm(e,t)),vi=(e,t)=>Vh(e,t)});var Zh,G1,jh=Q(()=>{"use strict";f();pa();Zh=e=>[0,0,0,0,e[4],e[5],0,0],G1=(e,t)=>R1([0,0,0,0,t[4]-e[4],t[5]-e[5],0,0])});var qh,V1,Y1,K1,Go,$1=Q(()=>{"use strict";f();pa();jh();qh=(e,t)=>P1(wi(e,Math.sin(t/2)),Math.cos(t/2)),V1=e=>[1,0,0,0,-(.5*e[5]),.5*e[4],0,0],Y1=(e,t)=>{let r=.5*t;return[1,0,0,0,r*e[4],r*e[5],0,0]},K1=(e,t)=>wi(t,e),Go=(e,t)=>ma(wi(wi(e,t),bs(e)))});var xs,v5,ys,un,T5,X1,S5,yt,I5,Jh,C5,Z1,A5,ga,Qh,k5,M5,eg,j1,tg,q1,L5,J1,Q1,nm=Q(()=>{"use strict";f();ft();xs=1e-4,v5=e=>{let t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},ys=e=>v5(e)?e:[...e,e[0]],un=e=>e*180/Math.PI,T5=e=>e/180*Math.PI,X1=(e,t)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)],S5=e=>e[0]===0&&e[1]===0,yt=(e,t,r)=>{let o=T5(t);return!r||S5(r)?X1(e,o):X1(e.map((n,i)=>n-r[i]),o).map((n,i)=>n+r[i])},I5=e=>[-e[0],-e[1]],Jh=(e,t)=>[e[0]+t[0],e[1]+t[1]],C5=(e,t)=>It(...e,...t),Z1=(e,t,r)=>{let o=Jh(e,I5(t));return yt(o,-un(r))},A5=(e,t)=>{let[r,o]=e,[[n,i],[a,s]]=t,l=r-n,c=o-i,d=a-n,m=s-i,p=l*d+c*m,u=d*d+m*m,h=-1;u!==0&&(h=p/u);let g,x;h<0?(g=n,x=i):h>1?(g=a,x=s):(g=n+h*d,x=i+h*m);let v=r-g,y=o-x;return Math.sqrt(v*v+y*y)},ga=(e,t,r=xs)=>{let o=A5(e,t);return o===0?!0:o<r},Qh=(e,t,r=xs)=>t.some(o=>ga(e,o,r)),k5=e=>{let[t,r,o,n]=e;return(i,a)=>Math.pow(1-i,3)*n[a]+3*i*Math.pow(1-i,2)*o[a]+3*Math.pow(i,2)*(1-i)*r[a]+t[a]*Math.pow(i,3)},M5=(e,t=10)=>{let r=k5(e),o=[r(0,0),r(0,1)],n=[],i=0,a=1/t;for(let s=0;s<t;s++)if(i+=a,i<=1){let l=[r(i,0),r(i,1)];n.push([o,l]),o=l}return n},eg=(e,t,r=xs)=>Qh(e,M5(t),r),j1=(e,t,r=xs)=>t.some(o=>eg(e,o,r)),tg=(e,t)=>{let r=e[0],o=e[1],n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){let s=t[i][0],l=t[i][1],c=t[a][0],d=t[a][1];(l>o&&d<=o||l<=o&&d>o)&&r<(c-s)*(o-l)/(d-l)+s&&(n=!n)}return n},q1=(e,t,r=xs)=>{let o=!1,n=ys(t);for(let i=0,a=n.length-1;i<a;i++)if(ga(e,[n[i],n[i+1]],r)){o=!0;break}return o},L5=(e,t)=>{let{angle:r,halfWidth:o,halfHeight:n,center:i}=t,a=o,s=n,[l,c]=Z1(e,i,r),d=Math.abs(l),m=Math.abs(c),p=.707,u=.707;for(let x=0;x<3;x++){let v=a*p,y=s*u,w=(a*a-s*s)*p**3/a,I=(s*s-a*a)*u**3/s,A=v-w,C=y-I,L=d-w,M=m-I,z=Math.hypot(C,A),k=Math.hypot(M,L);p=Math.min(1,Math.max(0,(L*z/k+w)/a)),u=Math.min(1,Math.max(0,(M*z/k+I)/s));let N=Math.hypot(u,p);p/=N,u/=N}let[h,g]=[a*p*Math.sign(l),s*u*Math.sign(c)];return C5([l,c],[h,g])},J1=(e,t,r=xs)=>L5(e,t)<=r,Q1=(e,t)=>{let{center:r,angle:o,halfWidth:n,halfHeight:i}=t,[a,s]=Z1(e,r,o);return a/n*(a/n)+s/i*(s/i)<=1}});var ec,ws,im=Q(()=>{"use strict";f();nm();ec=(e,t,r=0)=>{switch(t.type){case"polygon":return q1(e,t.data,r);case"ellipse":return J1(e,t.data,r);case"line":return ga(e,t.data,r);case"polyline":return Qh(e,t.data,r);case"curve":return eg(e,t.data,r);case"polycurve":return j1(e,t.data,r);default:throw Error(`shape ${t} is not implemented`)}},ws=(e,t)=>{switch(t.type){case"polygon":return tg(e,t.data);case"line":return!1;case"curve":return!1;case"ellipse":return Q1(e,t.data);case"polyline":{let r=ys(t.data.flat());return tg(e,r)}case"polycurve":return!1;default:throw Error(`shape ${t} is not implemented`)}}});var ye,S,vs,am,Ts,fa,ge=Q(()=>{"use strict";f();Y();ye={EQUAL:"Equal",MINUS:"Minus",NUM_ADD:"NumpadAdd",NUM_SUBTRACT:"NumpadSubtract",NUM_ZERO:"Numpad0",BRACKET_RIGHT:"BracketRight",BRACKET_LEFT:"BracketLeft",ONE:"Digit1",TWO:"Digit2",THREE:"Digit3",NINE:"Digit9",QUOTE:"Quote",ZERO:"Digit0",SLASH:"Slash",C:"KeyC",D:"KeyD",H:"KeyH",V:"KeyV",Z:"KeyZ",R:"KeyR",S:"KeyS"},S={ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",BACKSPACE:"Backspace",ALT:"Alt",CTRL_OR_CMD:br?"metaKey":"ctrlKey",DELETE:"Delete",ENTER:"Enter",ESCAPE:"Escape",QUESTION_MARK:"?",SPACE:" ",TAB:"Tab",CHEVRON_LEFT:"<",CHEVRON_RIGHT:">",PERIOD:".",COMMA:",",SUBTRACT:"-",SLASH:"/",A:"a",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",L:"l",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",V:"v",X:"x",Y:"y",Z:"z",K:"k",W:"w",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9"},vs=e=>e===S.ARROW_LEFT||e===S.ARROW_RIGHT||e===S.ARROW_DOWN||e===S.ARROW_UP,am=e=>e.altKey,Ts=e=>e.shiftKey,fa=e=>e.shiftKey});var o0,hn,P5,Ea,e0,D5,n0,_5,R5,rc,cm,oc,ba,i0,rg,a0,N5,gn,O5,qt,B5,F5,z5,t0,Ss,s0,dm,r0,mm,tc,l0,nc,H5,U5,G5,W5,V5,og,ng,ig,Y5,K5,$5,X5,c0,Z5,j5,q5,J5,Q5,eA,d0,sm,lm,Ti,Si,_r=Q(()=>{"use strict";f();pa();U1();jh();$h();$1();it();im();Xe();le();Ae();bi();Jt();G();ge();Je();o0=e=>!e[S.CTRL_OR_CMD],hn=e=>e.isBindingEnabled,P5=(e,t)=>{let r=[];return t.forEach(o=>{let n=e.getNonDeletedElement(o);n!=null&&r.push(n)}),r},Ea=(e,t,r,o)=>{let n=new Set,i=new Set;e0(e,t,r,"start",n,i,o),e0(e,r,t,"end",n,i,o);let a=Array.from(i).filter(s=>!n.has(s));P5(Mt.getScene(e),a).forEach(s=>{O(s,{boundElements:s.boundElements?.filter(l=>l.type!=="arrow"||l.id!==e.id)})})},e0=(e,t,r,o,n,i,a)=>{if(t!=="keep"){if(t===null){let s=N5(e,o);s!=null&&i.add(s);return}a0(e)?(r==null||(r==="keep"?!i0(e,t,o):o==="start"||r.id!==t.id))&&(ba(e,t,o,a),n.add(t.id)):(ba(e,t,o,a),n.add(t.id))}},D5=(e,t,r)=>{let o=r.scene.getNonDeletedElementsMap(),n=s0(e,t,o),i=t==="start"?e.startBinding?.elementId:e.endBinding?.elementId;if(i){let a=o.get(i);if(l0(a,n,r))return a}return null},n0=(e,t)=>["start","end"].map(r=>D5(e,r,t)),_5=(e,t,r,o)=>{let i=e.points.length-1,a=r.findIndex(d=>d===0)>-1,s=r.findIndex(d=>d===i)>-1,l=a?t?Ss(e,"start",o):null:Ss(e,"start",o),c=s?t?Ss(e,"end",o):null:Ss(e,"end",o);return[l,c]},R5=(e,t,r)=>{let[o,n]=n0(e,t),i=o&&r?Ss(e,"start",t):null,a=n&&r?Ss(e,"end",t):null;return[i,a]},rc=(e,t,r,o)=>{e.forEach(n=>{let[i,a]=o?.length?_5(n,r,o??[],t):R5(n,t,r);Ea(n,i,a,t.scene.getNonDeletedElementsMap())})},cm=(e,t)=>e.length>50?[]:e.filter(ie).flatMap(r=>n0(r,t)).filter(r=>r!==null).filter(r=>e.filter(o=>o.id===r?.id).length===0),oc=(e,t,r,o)=>{t.startBoundElement!=null&&ba(e,t.startBoundElement,"start",o.scene.getNonDeletedElementsMap());let n=gn(r,o);n!=null&&!i0(e,n,"end")&&ba(e,n,"end",o.scene.getNonDeletedElementsMap())},ba=(e,t,r,o)=>{O(e,{[r==="start"?"startBinding":"endBinding"]:{elementId:t.id,...O5(e,t,r,o)}}),X(t.boundElements||[]).has(e.id)||O(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},i0=(e,t,r)=>{let o=e[r==="start"?"endBinding":"startBinding"];return rg(e,o?.elementId,t)},rg=(e,t,r)=>t===r.id&&a0(e),a0=e=>e.points.length<3,N5=(e,t)=>{let r=t==="start"?"startBinding":"endBinding",o=e[r];return o==null?null:(O(e,{[r]:null}),o.elementId)},gn=(e,t)=>Fh(t.scene.getNonDeletedElements(),o=>la(o,!1)&&l0(o,e,t)),O5=(e,t,r,o)=>{let n=r==="start"?-1:1,i=n===-1?0:e.points.length-1,a=i-n,s=j.getPointAtIndexGlobalCoordinates(e,i,o),l=j.getPointAtIndexGlobalCoordinates(e,a,o);return{focus:Y5(t,l,s,o),gap:Math.max(1,H5(t,s,o))}},qt=(e,t,r)=>{let{newSize:o,simultaneouslyUpdated:n}=r??{},i=F5(n);la(e)&&sm(t,e,a=>{if(!ie(a)||a.isDeleted||!B5(a,e))return;let s={startBinding:t0(e,a.startBinding,o),endBinding:t0(e,a.endBinding,o)};if(i.has(a.id)){O(a,s);return}lm(t,a,(c,d)=>{c&&la(c)&&(d==="startBinding"||d==="endBinding")&&z5(a,d,s[d],c,t)});let l=ae(a,t);l&&!l.isDeleted&&Wo(a,t,!1)})},B5=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,F5=e=>new Set((e||[]).map(t=>t.id)),z5=(e,t,r,o,n)=>{if(r==null||r.elementId!==o.id&&e.points.length>2)return;let i=t==="startBinding"?-1:1,a=i===-1?0:e.points.length-1,s=a-i,l=j.getPointAtIndexGlobalCoordinates(e,s,n),c=K5(o,r.focus,l,n),d;if(r.gap===0)d=c;else{let m=$5(o,l,c,r.gap,n);m.length===0?d=c:d=m[0]}j.movePoints(e,[{index:a,point:j.pointFromAbsoluteCoords(e,d,n)}],{[t]:r})},t0=(e,t,r)=>{if(t==null||r==null)return t;let{gap:o,focus:n,elementId:i}=t,{width:a,height:s}=r,{width:l,height:c}=e,d=Math.max(1,Math.min(nc(e,a,s),o*(a<s?a/l:s/c)));return{elementId:i,gap:d,focus:n}},Ss=(e,t,r)=>gn(s0(e,t,r.scene.getNonDeletedElementsMap()),r),s0=(e,t,r)=>{let o=t==="start"?0:-1;return Bo(j.getPointAtIndexGlobalCoordinates(e,o,r))},dm=(e,t,r,o)=>{let n=new Set,i=new Set,a=o==="duplicatesServeAsOld";t.forEach(s=>{let{boundElements:l}=s;if(l!=null&&l.length>0&&(l.forEach(c=>{a&&!r.has(c.id)&&n.add(c.id)}),i.add(r.get(s.id))),Dr(s)){if(s.startBinding!=null){let{elementId:c}=s.startBinding;a&&!r.has(c)&&i.add(c)}if(s.endBinding!=null){let{elementId:c}=s.endBinding;a&&!r.has(c)&&i.add(c)}(s.startBinding!=null||s.endBinding!=null)&&n.add(r.get(s.id))}}),e.filter(({id:s})=>n.has(s)).forEach(s=>{let{startBinding:l,endBinding:c}=s;O(s,{startBinding:r0(l,r),endBinding:r0(c,r)})}),e.filter(({id:s})=>i.has(s)).forEach(s=>{let{boundElements:l}=s;l!=null&&l.length>0&&O(s,{boundElements:l.map(c=>r.has(c.id)?{id:r.get(c.id),type:c.type}:c)})})},r0=(e,t)=>{if(e==null)return null;let{elementId:r,focus:o,gap:n}=e;return{focus:o,gap:n,elementId:t.get(r)??r}},mm=(e,t)=>{let r=X(e);for(let o of t)Ti.unbindAffected(r,o,O),Si.unbindAffected(r,o,O)},tc=(e,t,r=[])=>{if(!e)return null;let o=e.filter(n=>!t.has(n.id));return o.push(...r.map(n=>({id:n.id,type:n.type}))),o},l0=(e,{x:t,y:r},o)=>{let n=nc(e,e.width,e.height),i=o.getElementShape(e);return ec([t,r],i,n)},nc=(e,t,r)=>{let n=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,r);return Math.max(16,Math.min(.25*n,32))},H5=(e,t,r)=>{switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return U5(e,t,r);case"diamond":return G5(e,t,r);case"ellipse":return W5(e,t,r)}},U5=(e,t,r)=>{let[,o,n,i]=og(e,t,r);return Math.max(vi(o,om(0,1,-i)),vi(o,om(1,0,-n)))},G5=(e,t,r)=>{let[,o,n,i]=og(e,t,r),a=om(i,n,-i*n);return vi(o,a)},W5=(e,t,r)=>{let[o,n]=V5(e,t,r);return-B1(n)*vi(o,n)},V5=(e,t,r)=>{let[,o,n,i]=og(e,t,r),[a,s]=ha(o),l=.707,c=.707,d=n,m=i;[0,1,2,3].forEach(h=>{let g=d*l,x=m*c,v=(d*d-m*m)*l**3/d,y=(m*m-d*d)*c**3/m,w=g-v,I=x-y,A=a-v,C=s-y,L=Math.hypot(I,w),M=Math.hypot(C,A);l=Math.min(1,Math.max(0,(A*L/M+v)/d)),c=Math.min(1,Math.max(0,(C*L/M+y)/m));let z=Math.hypot(c,l);l/=z,c/=z});let p=lr(d*l,m*c),u=O1(o,p);return[o,u]},og=(e,t,r)=>{let o=ua(t),[n,i,a,s]=ne(e,r),l=ig(n,i,a,s),c=qh(l,e.angle),d=Go(c,o),m=Gh(d,Zh(l)),p=z1(m),u=L1(e.x,e.y),h=Gh(d,u),g=(a-n)/2,x=(s-i)/2;return[h,p,g,x]},ng=(e,t)=>{let[r,o,n,i]=ne(e,t),a=ig(r,o,n,i),s=qh(a,e.angle),l=bs(V1(Zh(a)));return K1(s,l)},ig=(e,t,r,o)=>lr((e+r)/2,(t+o)/2),Y5=(e,t,r,o)=>{let n=ng(e,o),i=Go(n,ua(t)),a=Go(n,ua(r)),s=Es(i,a),l=e.height/e.width,c=e.width/2,d=e.height/2,m=s[2],p=s[3],u=s[1],h=Math.abs(p),g=Math.abs(m),x;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":x=u/(c*(g+l*h));break;case"diamond":x=h<g?u/(g*c):u/(h*d);break;case"ellipse":x=u/(c*Math.sqrt(m**2+l**2*p**2));break}return x||0},K5=(e,t,r,o)=>{if(t===0){let[l,c,d,m]=ne(e,o),p=ig(l,c,d,m);return ha(p)}let n=ng(e,o),i=Go(n,ua(r)),a=bs(n),s;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":s=eA(e,t,i);break;case"ellipse":s=Q5(e,t,i);break}return ha(Go(a,s))},$5=(e,t,r,o=0,n)=>{let i=ng(e,n),a=Go(i,ua(t)),s=Go(i,ua(r)),l=Es(a,s),c=bs(i);return X5(e,l,a,o).map(m=>ha(Go(c,m)))},X5=(e,t,r,o=0)=>{let n;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":let a=c0(e);n=a.flatMap((s,l)=>{let c=[s,a[(l+1)%4]];return Z5(t,j5(c,o))}).concat(a.flatMap(s=>J5(s,o,t)));break;case"ellipse":n=q5(e,o,t);break}if(n.length<2)return[];let i=n.sort((a,s)=>Xh(a,r)-Xh(s,r));return[i[0],i[i.length-1]]},c0=(e,t=1)=>{let r=t*e.width/2,o=t*e.height/2;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return[lr(r,o),lr(r,-o),lr(-r,-o),lr(-r,o)];case"diamond":return[lr(0,o),lr(r,0),lr(0,-o),lr(-r,0)]}},Z5=(e,t)=>{let[r,o]=t,n=vi(r,e),i=vi(o,e);return n*i>=0?[]:[H1(e,Es(r,o))]},j5=(e,t)=>{let[r,o]=e,n=Y1(G1(r,o),t);return[Go(n,r),Go(n,o)]},q5=(e,t,r)=>{let o=e.width/2+t,n=e.height/2+t,i=r[2],a=r[3],s=r[1],l=o*o*i*i+n*n*a*a,c=l-s*s;if(l===0||c<=0)return[];let d=Math.sqrt(c),m=-o*o*i*s,p=-n*n*a*s;return[lr((m+o*n*a*d)/l,(p-o*n*i*d)/l),lr((m-o*n*a*d)/l,(p+o*n*i*d)/l)]},J5=(e,t,r)=>{if(t===0)return vi(r,e)===0?[e]:[];let o=r[2],n=r[3],i=r[1],[a,s]=ha(e),l=t,c=o*o+n*n,d=l*l*c-(o*a+n*s+i)**2;if(c===0||d<=0)return[];let m=Math.sqrt(d),p=a*n*n-s*o*n-o*i,u=s*o*o-a*o*n-n*i;return[lr((p+n*m)/c,(u-o*m)/c),lr((p-n*m)/c,(u+o*m)/c)]},Q5=(e,t,r)=>{let o=Math.abs(t),n=e.width*o/2,i=e.height*o/2,a=Math.sign(t),[s,l]=ha(r),c=l===0?1e-4:l,d=s**2*i**2+c**2*n**2,m=(-s*i**2+a*c*Math.sqrt(Math.max(0,d-n**2*i**2)))/d,p=(-m*s-1)/c;p===0&&(p=(Object.is(p,-0)?-1:1)*.01);let u=-(n**2*m)/(p**2*i**2+m**2*n**2);return lr(u,(-m*u-1)/p)},eA=(e,t,r)=>{let o=Math.abs(t),n=Math.sign(t),i=c0(e,o),a=0,s=null;return i.forEach(l=>{let c=n*Es(r,l)[1];c>a&&(a=c,s=l)}),s},d0=new Set(["boundElements","frameId","containerId","startBinding","endBinding"]),sm=(e,t,r)=>{la(t)&&(t.boundElements?.slice()??[]).forEach(({id:n})=>{r(e.get(n),"boundElements",n)})},lm=(e,t,r)=>{if(t.frameId){let o=t.frameId;r(e.get(o),"frameId",o)}if(Me(t)){let o=t.containerId;r(e.get(o),"containerId",o)}if(xe(t)){if(t.startBinding){let o=t.startBinding.elementId;r(e.get(o),"startBinding",o)}if(t.endBinding){let o=t.endBinding.elementId;r(e.get(o),"endBinding",o)}}},Ti=class{static unbindAffected(t,r,o){r&&lm(t,r,n=>{!n||n.isDeleted||sm(t,n,(i,a,s)=>{s===r.id&&o(n,{boundElements:tc(n.boundElements,new Set([s]))})})})}static rebindAffected=(t,r,o)=>{!r||r.isDeleted||lm(t,r,(n,i)=>{if(!n||n.isDeleted){o(r,{[i]:null});return}i!=="frameId"&&(n.boundElements?.find(a=>a.id===r.id)||(xe(r)&&o(n,{boundElements:tc(n.boundElements,new Set,new Array(r))}),U(r)&&(n.boundElements?.find(a=>a.type==="text")?o(r,{[i]:null}):o(n,{boundElements:tc(n.boundElements,new Set,new Array(r))}))))})}},Si=class{static unbindAffected(t,r,o){r&&sm(t,r,n=>{!n||n.isDeleted||lm(t,n,(i,a,s)=>{s===r.id&&o(n,{[a]:null})})})}static rebindAffected=(t,r,o)=>{!r||r.isDeleted||sm(t,r,(n,i,a)=>{if(!n||n.isDeleted){o(r,{boundElements:tc(r.boundElements,new Set([a]))});return}U(n)&&((r.boundElements?.slice()??[]).reverse().find(l=>l.type==="text")?.id===n.id?n.containerId!==r.id&&o(n,{containerId:r.id}):(n.containerId!==null&&o(n,{containerId:null}),o(r,{boundElements:tc(r.boundElements,new Set([n.id]))})))})}}});var Un,j,tA,Jt=Q(()=>{"use strict";f();ft();be();it();Ae();_r();G();le();ge();Je();Y();pn();Un={version:null,points:[],zoom:null},j=class e{elementId;selectedPointsIndices;pointerDownState;isDragging;lastUncommittedPoint;pointerOffset;startBindingElement;endBindingElement;hoverPointIndex;segmentMidPointHoveredCoords;constructor(t){this.elementId=t.id,e.normalizePoints(t),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null}static POINT_HANDLE_SIZE=10;static getElement(t,r){let o=r.get(t);return o||null}static handleBoxSelection(t,r,o,n){if(!r.editingLinearElement||r.draggingElement?.type!=="selection")return!1;let{editingLinearElement:i}=r,{selectedPointsIndices:a,elementId:s}=i,l=e.getElement(s,n);if(!l)return!1;let[c,d,m,p]=ne(r.draggingElement,n),h=e.getPointsGlobalCoordinates(l,n).reduce((g,x,v)=>((x[0]>=c&&x[0]<=m&&x[1]>=d&&x[1]<=p||t.shiftKey&&a?.includes(v))&&g.push(v),g),[]);o({editingLinearElement:{...i,selectedPointsIndices:h.length?h:null}})}static handlePointDragging(t,r,o,n,i,a,s){if(!a)return!1;let{selectedPointsIndices:l,elementId:c}=a,d=e.getElement(c,s);if(!d)return!1;let m=d.points[a.pointerDownState.lastClickedPoint];if(l&&m){if(fa(t)&&l.length===1&&d.points.length>1){let u=l[0],h=d.points[u===0?1:u-1],[g,x]=e._getShiftLockedDelta(d,s,h,[o,n],t[S.CTRL_OR_CMD]?null:r.gridSize);e.movePoints(d,[{index:u,point:[g+h[0],x+h[1]],isDragging:u===a.pointerDownState.lastClickedPoint}])}else{let u=e.createPointAt(d,s,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize),h=u[0]-m[0],g=u[1]-m[1];e.movePoints(d,l.map(x=>{let v=x===a.pointerDownState.lastClickedPoint?e.createPointAt(d,s,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize):[d.points[x][0]+h,d.points[x][1]+g];return{index:x,point:v,isDragging:x===a.pointerDownState.lastClickedPoint}}))}if(ae(d,s)&&Wo(d,s,!1),Dr(d,!1)){let u=[];l[0]===0&&u.push(Bo(e.getPointGlobalCoordinates(d,d.points[0],s)));let g=l[l.length-1];g===d.points.length-1&&u.push(Bo(e.getPointGlobalCoordinates(d,d.points[g],s))),u.length&&i(d,u)}return!0}return!1}static handlePointerUp(t,r,o,n){let i=n.scene.getNonDeletedElementsMap(),{elementId:a,selectedPointsIndices:s,isDragging:l,pointerDownState:c}=r,d=e.getElement(a,i);if(!d)return r;let m={};if(l&&s){for(let p of s)if(p===0||p===d.points.length-1){wr(d.points,o.zoom.value)&&e.movePoints(d,[{index:p,point:p===0?d.points[d.points.length-1]:d.points[0]}]);let u=hn(o)?gn(Bo(e.getPointAtIndexGlobalCoordinates(d,p,i)),n):null;m[p===0?"startBindingElement":"endBindingElement"]=u}}return{...r,...m,selectedPointsIndices:l||t.shiftKey?!l&&t.shiftKey&&c.prevSelectedPointsIndices?.includes(c.lastClickedPoint)?s&&s.filter(p=>p!==c.lastClickedPoint):s:s?.includes(c.lastClickedPoint)?[c.lastClickedPoint]:s,isDragging:!1,pointerOffset:{x:0,y:0}}}static getEditorMidPoints=(t,r,o)=>{let n=ae(t,r);return!o.editingLinearElement&&t.points.length>2&&!n?[]:(Un.version===t.version&&Un.zoom===o.zoom.value||e.updateEditorMidPointsCache(t,r,o),Un.points)};static updateEditorMidPointsCache=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,r),i=0,a=[];for(;i<n.length-1;){if(e.isSegmentTooShort(t,t.points[i],t.points[i+1],o.zoom)){a.push(null),i++;continue}let s=e.getSegmentMidPoint(t,n[i],n[i+1],i+1,r);a.push(s),i++}Un.points=a,Un.version=t.version,Un.zoom=o.zoom.value};static getSegmentMidpointHitCoords=(t,r,o,n)=>{let{elementId:i}=t,a=e.getElement(i,n);if(!a||e.getPointIndexUnderCursor(a,n,o.zoom,r.x,r.y)>=0||e.getPointsGlobalCoordinates(a,n).length>=3&&!o.editingLinearElement)return null;let c=e.POINT_HANDLE_SIZE/o.zoom.value,d=t.segmentMidPointHoveredCoords;if(d&&It(d[0],d[1],r.x,r.y)<=c)return d;let m=0,p=e.getEditorMidPoints(a,n,o);for(;m<p.length;){if(p[m]!==null&&It(p[m][0],p[m][1],r.x,r.y)<=c)return p[m];m++}return null};static isSegmentTooShort(t,r,o,n){let i=It(r[0],r[1],o[0],o[1]);return t.points.length>2&&t.roundness&&(i=v1(t,o)),i*n.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,r,o,n,i){let a=us(r,o);if(t.points.length>2&&t.roundness){let s=Nh(t,t.points[n]);if(s){let l=T1(t,t.points[n],.5),[c,d]=Oh(s[0],s[1],s[2],s[3],l);a=e.getPointGlobalCoordinates(t,[c,d],i)}}return a}static getSegmentMidPointIndex(t,r,o,n){let i=e.getElement(t.elementId,n);if(!i)return-1;let a=e.getEditorMidPoints(i,n,r),s=0;for(;s<a.length;){if(e.arePointsEqual(o,a[s]))return s+1;s++}return-1}static handlePointerDown(t,r,o,n,i,a){let s=a.scene.getNonDeletedElementsMap(),l={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!i)return l;let{elementId:c}=i,d=e.getElement(c,s);if(!d)return l;let m=e.getSegmentMidpointHitCoords(i,n,r,s),p=null;if(m&&(p=e.getSegmentMidPointIndex(i,r,m,s)),t.altKey&&r.editingLinearElement)return i.lastUncommittedPoint==null&&(O(d,{points:[...d.points,e.createPointAt(d,s,n.x,n.y,t[S.CTRL_OR_CMD]?null:r.gridSize)]}),l.didAddPoint=!0),o.shouldCaptureIncrement(),l.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:-1,origin:{x:n.x,y:n.y},segmentMidpoint:{value:m,index:p,added:!1}},selectedPointsIndices:[d.points.length-1],lastUncommittedPoint:null,endBindingElement:gn(n,a)},l.didAddPoint=!0,l;let u=e.getPointIndexUnderCursor(d,s,r.zoom,n.x,n.y);if(u>=0||m)l.hitElement=d;else{let{startBindingElement:C,endBindingElement:L}=i;hn(r)&&Dr(d)&&Ea(d,C,L,s)}let[h,g,x,v]=ne(d,s),y=(h+x)/2,w=(g+v)/2,I=u>-1&&he(d.x+d.points[u][0],d.y+d.points[u][1],y,w,d.angle),A=u>-1||t.shiftKey?t.shiftKey||i.selectedPointsIndices?.includes(u)?tA([...i.selectedPointsIndices||[],u]):[u]:null;return l.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:u,origin:{x:n.x,y:n.y},segmentMidpoint:{value:m,index:p,added:!1}},selectedPointsIndices:A,pointerOffset:I?{x:n.x-I[0],y:n.y-I[1]}:{x:0,y:0}},l}static arePointsEqual(t,r){return!t&&!r?!0:!t||!r?!1:Bh(t,r)}static handlePointerMove(t,r,o,n,i){if(!n.editingLinearElement)return null;let{elementId:a,lastUncommittedPoint:s}=n.editingLinearElement,l=e.getElement(a,i);if(!l)return n.editingLinearElement;let{points:c}=l,d=c[c.length-1];if(!t.altKey)return d===s&&e.deletePoints(l,[c.length-1]),{...n.editingLinearElement,lastUncommittedPoint:null};let m;if(fa(t)&&c.length>=2){let p=c[c.length-2],[u,h]=e._getShiftLockedDelta(l,i,p,[r,o],t[S.CTRL_OR_CMD]?null:n.gridSize);m=[u+p[0],h+p[1]]}else m=e.createPointAt(l,i,r-n.editingLinearElement.pointerOffset.x,o-n.editingLinearElement.pointerOffset.y,t[S.CTRL_OR_CMD]?null:n.gridSize);return d===s?e.movePoints(l,[{index:l.points.length-1,point:m}]):e.addPoints(l,n,[{point:m}]),{...n.editingLinearElement,lastUncommittedPoint:l.points[l.points.length-1]}}static getPointGlobalCoordinates(t,r,o){let[n,i,a,s]=ne(t,o),l=(n+a)/2,c=(i+s)/2,{x:d,y:m}=t;return[d,m]=he(d+r[0],m+r[1],l,c,t.angle),[d,m]}static getPointsGlobalCoordinates(t,r){let[o,n,i,a]=ne(t,r),s=(o+i)/2,l=(n+a)/2;return t.points.map(c=>{let{x:d,y:m}=t;return[d,m]=he(d+c[0],m+c[1],s,l,t.angle),[d,m]})}static getPointAtIndexGlobalCoordinates(t,r,o){let n=r<0?t.points.length+r:r,[i,a,s,l]=ne(t,o),c=(i+s)/2,d=(a+l)/2,m=t.points[n],{x:p,y:u}=t;return m?he(p+m[0],u+m[1],c,d,t.angle):he(p,u,c,d,t.angle)}static pointFromAbsoluteCoords(t,r,o){let[n,i,a,s]=ne(t,o),l=(n+a)/2,c=(i+s)/2,[d,m]=he(r[0],r[1],l,c,-t.angle);return[d-t.x,m-t.y]}static getPointIndexUnderCursor(t,r,o,n,i){let a=e.getPointsGlobalCoordinates(t,r),s=a.length;for(;--s>-1;){let l=a[s];if(It(n,i,l[0],l[1])*o.value<e.POINT_HANDLE_SIZE+1)return s}return-1}static createPointAt(t,r,o,n,i){let a=Lt(o,n,i),[s,l,c,d]=ne(t,r),m=(s+c)/2,p=(l+d)/2,[u,h]=he(a[0],a[1],m,p,-t.angle);return[u-t.x,h-t.y]}static getNormalizedPoints(t){let{points:r}=t,o=r[0][0],n=r[0][1];return{points:r.map((i,a)=>[i[0]-o,i[1]-n]),x:t.x+o,y:t.y+n}}static normalizePoints(t){O(t,e.getNormalizedPoints(t))}static duplicateSelectedPoints(t,r){if(!t.editingLinearElement)return!1;let{selectedPointsIndices:o,elementId:n}=t.editingLinearElement,i=e.getElement(n,r);if(!i||o===null)return!1;let{points:a}=i,s=[],l=!1,c=-1,d=a.reduce((m,p,u)=>{if(++c,m.push(p),o.includes(u)){let g=a[u+1];g||(l=!0),m.push(g?[(p[0]+g[0])/2,(p[1]+g[1])/2]:[p[0],p[1]]),s.push(c+1),++c}return m},[]);if(O(i,{points:d}),l){let m=i.points[i.points.length-1];e.movePoints(i,[{index:i.points.length-1,point:[m[0]+30,m[1]+30]}])}return{appState:{...t,editingLinearElement:{...t.editingLinearElement,selectedPointsIndices:s}}}}static deletePoints(t,r){let o=0,n=0;if(r.includes(0)){let s=t.points.find((l,c)=>!r.includes(c));s&&(o=s[0],n=s[1])}let a=t.points.reduce((s,l,c)=>(r.includes(c)||s.push(s.length?[l[0]-o,l[1]-n]:[0,0]),s),[]);e._updatePoints(t,a,o,n)}static addPoints(t,r,o){let a=[...t.points,...o.map(s=>s.point)];e._updatePoints(t,a,0,0)}static movePoints(t,r,o){let{points:n}=t,i=0,a=0,s=r.find(({index:c})=>c===0);s&&(i=s.point[0]+n[s.index][0],a=s.point[1]+n[s.index][1]);let l=n.map((c,d)=>{let m=r.find(p=>p.index===d);if(m){if(s)return c;let p=m.point[0]-n[m.index][0],u=m.point[1]-n[m.index][1];return[c[0]+p,c[1]+u]}return i||a?[c[0]-i,c[1]-a]:c});e._updatePoints(t,l,i,a,o)}static shouldAddMidpoint(t,r,o,n){if(!e.getElement(t.elementId,n))return!1;let{segmentMidpoint:a}=t.pointerDownState;if(a.added||a.value===null||a.index===null||t.pointerDownState.origin===null)return!1;let s=t.pointerDownState.origin,l=It(s.x,s.y,r.x,r.y);return!(!o.editingLinearElement&&l<Rn/o.zoom.value)}static addMidpoint(t,r,o,n,i){let a=e.getElement(t.elementId,i);if(!a)return;let{segmentMidpoint:s}=t.pointerDownState,l={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,i,r.x,r.y,n?o.gridSize:null),d=[...a.points.slice(0,s.index),c,...a.points.slice(s.index)];return O(a,{points:d}),l.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:s.index},l.selectedPointsIndices=[s.index],l}static _updatePoints(t,r,o,n,i){let a=ag(t,r),s=ag(t,t.points),l=(a[0]+a[2])/2,c=(a[1]+a[3])/2,d=(s[0]+s[2])/2,m=(s[1]+s[3])/2,p=d-l,u=m-c,h=he(o,n,p,u,t.angle);O(t,{...i,points:r,x:t.x+h[0],y:t.y+h[1]})}static _getShiftLockedDelta(t,r,o,n,i){let a=e.getPointGlobalCoordinates(t,o,r),[s,l]=Lt(n[0],n[1],i),{width:c,height:d}=Is(a[0],a[1],s,l);return Pe([c,d],[0,0],-t.angle)}static getBoundTextElementPosition=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,o);n.length<2&&O(r,{isDeleted:!0});let i=0,a=0;if(t.points.length%2===1){let s=Math.floor(t.points.length/2),l=e.getPointGlobalCoordinates(t,t.points[s],o);i=l[0]-r.width/2,a=l[1]-r.height/2}else{let s=t.points.length/2-1,l=Un.points[s];t.points.length===2&&(l=us(n[0],n[1])),(!l||Un.version!==t.version)&&(l=e.getSegmentMidPoint(t,n[s],n[s+1],s+1,o)),i=l[0]-r.width/2,a=l[1]-r.height/2}return{x:i,y:a}};static getMinMaxXYWithBoundText=(t,r,o,n)=>{let[i,a,s,l]=o,c=(i+s)/2,d=(a+l)/2,{x:m,y:p}=e.getBoundTextElementPosition(t,n,r),u=m+n.width,h=p+n.height,g=Pe([i,a],[c,d],t.angle),x=Pe([s,a],[c,d],t.angle),v=Pe([m,p],[c,d],-t.angle),y=Pe([u,p],[c,d],-t.angle),w=Pe([m,h],[c,d],-t.angle),I=Pe([u,h],[c,d],-t.angle);return g[0]<x[0]&&g[1]>=x[1]?(i=Math.min(i,w[0]),s=Math.max(s,Math.max(y[0],I[0])),a=Math.min(a,v[1]),l=Math.max(l,I[1])):g[0]>=x[0]&&g[1]>x[1]?(i=Math.min(i,I[0]),s=Math.max(s,Math.max(v[0],y[0])),a=Math.min(a,w[1]),l=Math.max(l,y[1])):g[0]>=x[0]?(i=Math.min(i,y[0]),s=Math.max(s,w[0]),a=Math.min(a,I[1]),l=Math.max(l,v[1])):g[1]<=x[1]&&(i=Math.min(i,Math.min(y[0],v[0])),s=Math.max(s,I[0]),a=Math.min(a,y[1]),l=Math.max(l,w[1])),[i,a,s,l,c,d]};static getElementAbsoluteCoords=(t,r,o=!1)=>{let n,i,a,s,l;if(t.points.length<2||!Oe.get(t)){let{minX:p,minY:u,maxX:h,maxY:g}=t.points.reduce((x,[v,y])=>(x.minY=Math.min(x.minY,y),x.minX=Math.min(x.minX,v),x.maxX=Math.max(x.maxX,v),x.maxY=Math.max(x.maxY,y),x),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});i=p+t.x,a=u+t.y,s=h+t.x,l=g+t.y}else{let p=Oe.generateElementShape(t,null),u=yi(p[0]),[h,g,x,v]=ic(u);i=h+t.x,a=g+t.y,s=x+t.x,l=v+t.y}let c=(i+s)/2,d=(a+l)/2;if(n=[i,a,s,l,c,d],!o)return n;let m=ae(t,r);return m&&(n=e.getMinMaxXYWithBoundText(t,r,[i,a,s,l],m)),n}},tA=e=>{let t=[...new Set(e.filter(r=>r!==null&&r!==-1))];return t=t.sort((r,o)=>r-o),t.length?t:null}});var xa,ya,pm,m0,um=Q(()=>{"use strict";f();xa={},ya=(e,t)=>{let r=xa[e]||(xa[e]={height:t});return r.height=t,r},pm=e=>{xa[e]&&delete xa[e]},m0=e=>xa[e]?.height??null});var Ii,cg,Ot,hm,Wo,Cs,Bt,u0,Ci,gm,As,sg,ac,sc,rA,oA,go,h0,g0,ks,nA,Vo,ae,wt,fm,dg,f0,b0,E0,iA,x0,Gn,cr,wa,y0,lg,p0,qr,Ms,Je=Q(()=>{"use strict";f();G();Ae();Y();be();le();Jt();um();Ii=e=>Zd(e).replace(/\t/g," "),cg=e=>Ii(e).split(`
|
|
10
|
-
`),Ot=(e,t,r,o=!0)=>{let n,i={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height,angle:t?.angle??e.angle};i.text=e.text,(t||!e.autoResize)&&(n=t?cr(t,e):e.width,i.text=go(e.originalText,Ie(e),n));let a=Bt(i.text,Ie(e),e.lineHeight);if(e.autoResize&&(i.width=a.width),i.height=a.height,t){let s=wa(t,e),l=cr(t,e);if(!xe(t)&&a.height>s){let p=Gn(a.height,t.type);O(t,{height:p},o),ya(t.id,p)}if(a.width>l){let p=Gn(a.width,t.type);O(t,{width:p},o)}let c={...e,...i},{x:d,y:m}=Cs(t,c,r);i.x=d,i.y=m}O(e,i,o)},hm=(e,t,r)=>{let o=X(e);t.forEach(n=>{let i=r.get(n.id),a=Vo(n);if(a){let s=r.get(a);if(s){let l=o.get(i);l&&O(l,{boundElements:(n.boundElements||[]).filter(d=>d.id!==s&&d.id!==a).concat({type:"text",id:s})});let c=o.get(s);c&&U(c)&&O(c,{containerId:l?i:null})}}})},Wo=(e,t,r,o=!1)=>{if(!Vo(e))return;pm(e.id);let i=ae(e,t);if(i&&i.text){if(!e)return;let a=i.text,s=i.height,l=i.width,c=cr(e,i),d=wa(e,i),m=e.height;if(o||r!=="n"&&r!=="s"){a&&(a=go(i.originalText,Ie(i),c));let p=Bt(a,Ie(i),i.lineHeight);s=p.height,l=p.width}if(s>d){m=Gn(s,e.type);let p=m-e.height,u=!xe(e)&&(r==="ne"||r==="nw"||r==="n")?e.y-p:e.y;O(e,{height:m,y:u})}O(i,{text:a,width:l,height:s}),xe(e)||O(i,Cs(e,i,t))}},Cs=(e,t,r)=>{if(xe(e))return j.getBoundTextElementPosition(e,t,r);let o=dg(e),n=wa(e,t),i=cr(e,t),a,s;return t.verticalAlign===St.TOP?s=o.y:t.verticalAlign===St.BOTTOM?s=o.y+(n-t.height):s=o.y+(n/2-t.height/2),t.textAlign===mi.LEFT?a=o.x:t.textAlign===mi.RIGHT?a=o.x+(i-t.width):a=o.x+(i/2-t.width/2),{x:a,y:s}},Bt=(e,t,r)=>{e=e.split(`
|
|
11
|
-
`).map(a=>a||" ").join(`
|
|
12
|
-
`);let o=parseFloat(t),n=rA(e,o,r);return{width:sc(e,t),height:n}},u0=e=>{let t=cg(e.text).length;return e.height/t/e.fontSize},Ci=(e,t)=>e*t,gm=(e,t,r)=>{let{unitsPerEm:o,ascender:n,descender:i}=p0[e]||p0[mt.Helvetica],a=t/o,s=r-a*n+a*i;return a*n+s},As=(e,t)=>Ci(e,t)+ht*2,ac=(e,t)=>{sg||(sg=document.createElement("canvas"));let r=sg.getContext("2d");r.font=t;let o=r.measureText(e).width;return Pr()?o*10:o},sc=(e,t)=>{let r=cg(e),o=0;return r.forEach(n=>{o=Math.max(o,ac(n,t))}),o},rA=(e,t,r)=>{let o=cg(e).length;return Ci(t,r)*o},oA=e=>{let t=e.split("-");return t.length>1&&t.forEach((r,o)=>{o!==t.length-1&&(t[o]=r+="-")}),t.join(" ").split(" ")},go=(e,t,r)=>{if(!Number.isFinite(r)||r<0)return e;let o=[],n=e.split(`
|
|
13
|
-
`),i=ac(" ",t),a="",s=0,l=d=>{d.trim()&&o.push(d)},c=()=>{a="",s=0};return n.forEach(d=>{if(sc(d,t)<=r){o.push(d);return}let p=oA(d);c();let u=0;for(;u<p.length;){let h=ac(p[u],t);if(h===r)l(p[u]),u++;else if(h>r){for(l(a),c();p[u].length>0;){let g=String.fromCodePoint(p[u].codePointAt(0)),x=h0.calculate(g,t);s+=x,p[u]=p[u].slice(g.length),s>=r?(l(a),a=g,s=x):a+=g}s+i>=r?(l(a),c()):a.endsWith("-")||(a+=" ",s+=i),u++}else for(;s<r&&u<p.length;){let g=p[u];if(s=ac(a+g,t),s>r){l(a),c();break}u++;let x=!g.endsWith("-");if(a+=g,x&&(a+=" "),s+i>=r){x?o.push(a.slice(0,-1)):o.push(a),c();break}}}a.slice(-1)===" "&&(a=a.slice(0,-1),l(a))}),o.join(`
|
|
14
|
-
`)},h0=(()=>{let e={};return{calculate:(o,n)=>{let i=o.charCodeAt(0);if(e[n]||(e[n]=[]),!e[n][i]){let a=ac(o,n);e[n][i]=a}return e[n][i]},getCache:o=>e[o]}})(),g0="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),ks=(e,t)=>{let r=nA(e);return r===0?Bt(g0.split("").join(`
|
|
15
|
-
`),e,t).width+ht*2:r+ht*2},nA=e=>{let t=h0.getCache(e);if(!t)return 0;let r=t.filter(o=>o!==void 0);return Math.max(...r)},Vo=e=>e?.boundElements?.length&&e?.boundElements?.filter(t=>t.type==="text")[0]?.id||null,ae=(e,t)=>{if(!e)return null;let r=Vo(e);return r&&t.get(r)||null},wt=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,fm=(e,t,r)=>{if(!xe(e))return{x:e.x+e.width/2,y:e.y+e.height/2};let o=j.getPointsGlobalCoordinates(e,r);if(o.length%2===1){let a=Math.floor(e.points.length/2),s=j.getPointGlobalCoordinates(e,e.points[a],r);return{x:s[0],y:s[1]}}let n=e.points.length/2-1,i=j.getEditorMidPoints(e,r,t)[n];return i||(i=j.getSegmentMidPoint(e,o[n],o[n+1],n+1,r)),{x:i[0],y:i[1]}},dg=e=>{let t=ht,r=ht;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),r+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,r+=e.height/4),{x:e.x+t,y:e.y+r}},f0=(e,t)=>!t||xe(t)?e.angle:t.angle,b0=(e,t)=>e.some(r=>{if(Me(r)){let o=wt(r,t);return!xe(o)}return!1}),E0=(e,t)=>e.some(r=>{if(Me(r)){let o=wt(r,t);return!xe(o)}return U(r)}),iA=new Set(["rectangle","ellipse","diamond","arrow"]),x0=e=>iA.has(e.type),Gn=(e,t)=>{e=Math.ceil(e);let r=ht*2;return t==="ellipse"?Math.round((e+r)/Math.sqrt(2)*2):t==="arrow"?e+r*8:t==="diamond"?2*(e+r):e+r},cr=(e,t)=>{let{width:r}=e;if(xe(e)){let o=(t?.fontSize??Tt)*$x;return Math.max(Kx*r,o)}return e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-ht*2:e.type==="diamond"?Math.round(r/2)-ht*2:r-ht*2},wa=(e,t)=>{let{height:r}=e;return xe(e)?r-ht*8*2<=0?t.height:r:e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-ht*2:e.type==="diamond"?Math.round(r/2)-ht*2:r-ht*2},y0=()=>sc(g0,Ie({fontSize:Tt,fontFamily:Zt}))>0,lg={[mt.Virgil]:1.25,[mt.Helvetica]:1.15,[mt.Cascadia]:1.2},p0={[mt.Virgil]:{unitsPerEm:1e3,ascender:886,descender:-374},[mt.Helvetica]:{unitsPerEm:2048,ascender:1577,descender:-471},[mt.Cascadia]:{unitsPerEm:2048,ascender:1977,descender:-480},[mt.Assistant]:{unitsPerEm:1e3,ascender:1021,descender:-287}},qr=e=>e in lg?lg[e]:lg[Zt],Ms=(e,t)=>Bt("",e,t).width+ht*2});import pg from"roughjs/bin/rough";var mg,ne,ug,Hh,yi,w0,v0,aA,ic,hg,sA,lA,cA,Uh,dA,mA,Jr,we,bm,Wn,ag,gg,Rr,fg,it=Q(()=>{"use strict";f();ft();zh();le();ps();Je();Jt();pn();G();mg=class e{static boundsCache=new WeakMap;static getBounds(t,r){let o=e.boundsCache.get(t);if(o?.version&&o.version===t.version&&!Me(t))return o.bounds;let n=e.calculateBounds(t,r);return e.boundsCache.set(t,{version:t.version,bounds:n}),n}static calculateBounds(t,r){let o,[n,i,a,s,l,c]=ne(t,r);if(Rt(t)){let[d,m,p,u]=hg(t.points.map(([h,g])=>he(h,g,l-t.x,c-t.y,t.angle)));return[d+t.x,m+t.y,p+t.x,u+t.y]}else if(ie(t))o=mA(t,l,c,r);else if(t.type==="diamond"){let[d,m]=he(l,i,l,c,t.angle),[p,u]=he(l,s,l,c,t.angle),[h,g]=he(n,c,l,c,t.angle),[x,v]=he(a,c,l,c,t.angle),y=Math.min(d,p,h,x),w=Math.min(m,u,g,v),I=Math.max(d,p,h,x),A=Math.max(m,u,g,v);o=[y,w,I,A]}else if(t.type==="ellipse"){let d=(a-n)/2,m=(s-i)/2,p=Math.cos(t.angle),u=Math.sin(t.angle),h=Math.hypot(d*p,m*u),g=Math.hypot(m*p,d*u);o=[l-h,c-g,l+h,c+g]}else{let[d,m]=he(n,i,l,c,t.angle),[p,u]=he(n,s,l,c,t.angle),[h,g]=he(a,s,l,c,t.angle),[x,v]=he(a,i,l,c,t.angle),y=Math.min(d,p,h,x),w=Math.min(m,u,g,v),I=Math.max(d,p,h,x),A=Math.max(m,u,g,v);o=[y,w,I,A]}return o}},ne=(e,t,r=!1)=>{if(Rt(e))return sA(e);if(ie(e))return j.getElementAbsoluteCoords(e,t,r);if(U(e)){let o=t?wt(e,t):null;if(xe(o)){let n=j.getBoundTextElementPosition(o,e,t);return[n.x,n.y,n.x+e.width,n.y+e.height,n.x+e.width/2,n.y+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]},ug=(e,t)=>{let[r,o,n,i,a,s]=ne(e,t),l=[a,s];if(ie(e)||Rt(e)){let v=[],y=0;for(;y<e.points.length-1;)v.push([Pe([e.points[y][0]+e.x,e.points[y][1]+e.y],l,e.angle),Pe([e.points[y+1][0]+e.x,e.points[y+1][1]+e.y],l,e.angle)]),y++;return v}let[c,d,m,p,u,h,g,x]=[[r,o],[n,o],[r,i],[n,i],[a,o],[a,i],[r,s],[n,s]].map(v=>Pe(v,l,e.angle));return e.type==="diamond"?[[u,g],[u,x],[h,g],[h,x]]:e.type==="ellipse"?[[u,g],[u,x],[h,g],[h,x],[u,g],[u,x],[h,g],[h,x]]:[[c,d],[m,p],[c,m],[d,p],[c,x],[m,x],[d,g],[p,g]]},Hh=e=>{let t=Math.floor(e.width/2)+1,r=0,o=e.width,n=Math.floor(e.height/2)+1,i=t,a=e.height;return[t,r,o,n,i,a,0,n]},yi=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},w0=(e,t,r,o,n)=>{let i=1-e;return Math.pow(i,3)*t+3*Math.pow(i,2)*e*r+3*i*Math.pow(e,2)*o+Math.pow(e,3)*n},v0=(e,t,r,o)=>{let n=t-e,i=r-t,a=o-r,s=3*n-6*i+3*a,l=6*i-6*n,c=3*n,d=l*l-4*s*c;if(!(d>=0))return!1;let p=null,u=null,h=1/0,g=1/0;return s===0?h=g=-c/l:(h=(-l+Math.sqrt(d))/(2*s),g=(-l-Math.sqrt(d))/(2*s)),h>=0&&h<=1&&(p=w0(h,e,t,r,o)),g>=0&&g<=1&&(u=w0(g,e,t,r,o)),[p,u]},aA=(e,t,r,o)=>{let n=v0(e[0],t[0],r[0],o[0]),i=v0(e[1],t[1],r[1],o[1]),a=Math.min(e[0],o[0]),s=Math.max(e[0],o[0]);if(n){let d=n.filter(m=>m!==null);a=Math.min(a,...d),s=Math.max(s,...d)}let l=Math.min(e[1],o[1]),c=Math.max(e[1],o[1]);if(i){let d=i.filter(m=>m!==null);l=Math.min(l,...d),c=Math.max(c,...d)}return[a,l,s,c]},ic=(e,t)=>{let r=[0,0],{minX:o,minY:n,maxX:i,maxY:a}=e.reduce((s,{op:l,data:c})=>{if(l==="move")r=c;else if(l==="bcurveTo"){let d=[c[0],c[1]],m=[c[2],c[3]],p=[c[4],c[5]],u=t?t(...d):d,h=t?t(...m):m,g=t?t(...p):p,x=t?t(...r):r;r=p;let[v,y,w,I]=aA(x,u,h,g);s.minX=Math.min(s.minX,v),s.minY=Math.min(s.minY,y),s.maxX=Math.max(s.maxX,w),s.maxY=Math.max(s.maxY,I)}return s},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[o,n,i,a]},hg=e=>{let t=1/0,r=1/0,o=-1/0,n=-1/0;for(let[i,a]of e)t=Math.min(t,i),r=Math.min(r,a),o=Math.max(o,i),n=Math.max(n,a);return[t,r,o,n]},sA=e=>{let[t,r,o,n]=hg(e.points),i=t+e.x,a=r+e.y,s=o+e.x,l=n+e.y;return[i,a,s,l,(i+s)/2,(a+l)/2]},lA=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;default:return 15}},cA=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Uh=(e,t,r,o)=>{let n=yi(t[0]);if(n.length<1)return null;let i=r==="start"?1:n.length-1,a=n[i].data,s=[a[4],a[5]],l=[a[2],a[3]],c=[a[0],a[1]],d=n[i-1],m=[0,0];d.op==="move"?m=d.data:d.op==="bcurveTo"&&(m=[d.data[4],d.data[5]]);let p=(Z,J)=>Math.pow(1-Z,3)*s[J]+3*Z*Math.pow(1-Z,2)*l[J]+3*Math.pow(Z,2)*(1-Z)*c[J]+m[J]*Math.pow(Z,3),[u,h]=r==="start"?m:s,[g,x]=[p(.3,0),p(.3,1)],v=Math.hypot(u-g,h-x),y=(u-g)/v,w=(h-x)/v,I=lA(o),A=0;{let[Z,J]=r==="end"?e.points[e.points.length-1]:e.points[0],[Se,W]=e.points.length>1?r==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];A=Math.hypot(Z-Se,J-W)}let L=Math.min(I,A*(o==="diamond"||o==="diamond_outline"?.25:.5)),M=u-y*L,z=h-w*L;if(o==="dot"||o==="circle"||o==="circle_outline"){let Z=Math.hypot(z-h,M-u)+e.strokeWidth-2;return[u,h,Z]}let k=cA(o),[N,B]=he(M,z,u,h,-k*Math.PI/180),[_,V]=he(M,z,u,h,k*Math.PI/180);if(o==="diamond"||o==="diamond_outline"){let Z,J;if(r==="start"){let[Se,W]=e.points.length>1?e.points[1]:[0,0];[Z,J]=he(u+L*2,h,u,h,Math.atan2(W-h,Se-u))}else{let[Se,W]=e.points.length>1?e.points[e.points.length-2]:[0,0];[Z,J]=he(u-L*2,h,u,h,Math.atan2(h-W,u-Se))}return[u,h,N,B,Z,J,_,V]}return[u,h,N,B,_,V]},dA=e=>{let t=pg.generator(),r=jr(e),o=e.roundness?"curve":r.fill?"polygon":"linearPath";return t[o](e.points,r)},mA=(e,t,r,o)=>{let n=ae(e,o);if(e.points.length<2){let[m,p]=e.points[0],[u,h]=he(e.x+m,e.y+p,t,r,e.angle),g=[u,h,u,h];if(n){let x=j.getMinMaxXYWithBoundText(e,o,[u,h,u,h],n);g=[x[0],x[1],x[2],x[3]]}return g}let a=Oe.get(e)?.[0]??dA(e),s=yi(a),c=ic(s,(m,p)=>he(e.x+m,e.y+p,t,r,e.angle)),d=[c[0],c[1],c[2],c[3]];if(n){let m=j.getMinMaxXYWithBoundText(e,o,d,n);d=[m[0],m[1],m[2],m[3]]}return d},Jr=(e,t)=>mg.getBounds(e,t),we=e=>{if(!e.length)return[0,0,0,0];let t=1/0,r=-1/0,o=1/0,n=-1/0,i=X(e);return e.forEach(a=>{let[s,l,c,d]=Jr(a,i);t=Math.min(t,s),o=Math.min(o,l),r=Math.max(r,c),n=Math.max(n,d)}),[t,o,r,n]},bm=(e,t)=>{let[r,o,n,i]=we(e);return[r+t.x,o+t.y,n+t.x,i+t.y]},Wn=(e,t,r,o)=>{if(!(ie(e)||Rt(e)))return[e.x,e.y,e.x+t,e.y+r];let n=xi(0,t,xi(1,r,e.points,o),o),i;if(Rt(e))i=hg(n);else{let d=pg.generator(),m=e.roundness?d.curve(n,jr(e)):d.linearPath(n,jr(e)),p=yi(m);i=ic(p)}let[a,s,l,c]=i;return[a+e.x,s+e.y,l+e.x,c+e.y]},ag=(e,t)=>{let r=pg.generator(),o=e.roundness==null?r.linearPath(t,jr(e)):r.curve(t,jr(e)),n=yi(o),[i,a,s,l]=ic(n);return[i+e.x,a+e.y,s+e.x,l+e.y]},gg=(e,t)=>{if(!e.length)return[0,0,0,0];let r=1/0,o=e[0],n=X(e);return e.forEach(i=>{let[a,s,l,c]=Jr(i,n),d=It((a+l)/2,(s+c)/2,t.x,t.y);d<r&&(r=d,o=i)}),Jr(o,n)},Rr=e=>{let[t,r,o,n]=we(e);return{minX:t,minY:r,maxX:o,maxY:n,width:o-t,height:n-r,midX:(t+o)/2,midY:(r+n)/2}},fg=({scrollX:e,scrollY:t,width:r,height:o,zoom:n})=>[-e,-t,-e+r/n.value,-t+o/n.value]});var pA,Qt,uA,T0,Em,S0,Nr,Yo,Or=Q(()=>{"use strict";f();ir();Y();pA=ss.includes(devicePixelRatio)?devicePixelRatio:1,Qt=()=>({showWelcomeScreen:!1,theme:ce.LIGHT,collaborators:new Map,currentChartType:"bar",currentItemBackgroundColor:nt.backgroundColor,currentItemEndArrowhead:"arrow",currentItemFillStyle:nt.fillStyle,currentItemFontFamily:Zt,currentItemFontSize:Tt,currentItemOpacity:nt.opacity,currentItemRoughness:nt.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:nt.strokeColor,currentItemRoundness:"round",currentItemStrokeStyle:nt.strokeStyle,currentItemStrokeWidth:nt.strokeWidth,currentItemTextAlign:nn,cursorButton:"up",activeEmbeddable:null,draggingElement:null,editingElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:"selection",customType:null,locked:nt.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:pA,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:null,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:"mouse",multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,stats:{open:!1,panels:pi.generalStats|pi.elementProperties},startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:ue.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set}),uA=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},draggingElement:{browser:!1,export:!1,server:!1},editingElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},stats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1}}),T0=(e,t)=>{let r={};for(let o of Object.keys(e))if(uA[o]?.[t]){let i=e[o];r[o]=i}return r},Em=e=>T0(e,"export"),S0=e=>T0(e,"server"),Nr=({activeTool:e})=>e.type==="eraser",Yo=({activeTool:e})=>e.type==="hand"});var bg,er,xm,Eg,Ko,ym,I0,va,Qe,C0,A0,k0,M0,Ta,L0,P0,$o,Gt=Q(()=>{"use strict";f();Xe();Je();Ei();bg=(e,t,r)=>{let o=r.reduce((n,i)=>(i.groupIds.includes(e)&&(n[i.id]=!0),n),{});return Object.keys(o).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...o}}},er=function(){let e=null,t=null,r=null,o=(i,a,s,l)=>{if(r!==void 0&&a===t&&i===e&&s.editingGroupId===r?.editingGroupId)return r;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let h=u.indexOf(s.editingGroupId);h>-1&&(u=u.slice(0,h))}if(u.length>0){let h=u[u.length-1];c[h]=!0}}let d={},m=a.reduce((p,u)=>{let h=u.groupIds.find(g=>c[g]);return h&&(p[u.id]=!0,Array.isArray(d[h])?d[h].push(u.id):d[h]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return t=a,e=i,r={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Fe({...s.selectedElementIds,...m},l)},r},n=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):pe(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Fe(i.selectedElementIds,s)}};return n.clearCache=()=>{t=null,e=null,r=null},n}(),xm=(e,t)=>Eg(e,t)!=null,Eg=(e,t)=>t.groupIds.filter(r=>r!==e.editingGroupId).find(r=>e.selectedGroupIds[r]),Ko=e=>Object.entries(e.selectedGroupIds).filter(([t,r])=>r).map(([t,r])=>t),ym=(e,t)=>{let r={...t,selectedGroupIds:{}};for(let o of e){let n=o.groupIds;if(t.editingGroupId){let i=n.indexOf(t.editingGroupId);i>-1&&(n=n.slice(0,i))}if(n.length>0){let i=n[n.length-1];r={...r,...bg(i,r,e)}}}return r.selectedGroupIds},I0=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),va=(e,t)=>e.groupIds.includes(t),Qe=(e,t)=>{let r=[];for(let o of e.values())va(o,t)&&r.push(o);return r},C0=(e,t)=>e.groupIds.find(r=>t[r]),A0=(e,t,r)=>{let o=[...e],n=t?e.indexOf(t):-1,i=n>-1?n:e.length;for(let a=0;a<i;a++)o[a]=r(o[a]);return o},k0=(e,t,r)=>{let o=[...e],n=r?o.indexOf(r):-1,i=n>-1?n:o.length;return o.splice(i,0,t),o},M0=(e,t)=>e.filter(r=>!t[r]),Ta=(e,t)=>{let r=new Map;return e.forEach(o=>{let n=o.groupIds.length===0?o.id:o.groupIds[o.groupIds.length-1],i=r.get(n)||[],a=ae(o,t);a&&i.push(a),r.set(n,[...i,o])}),Array.from(r.values())},L0=e=>{let t=new Set;for(let[,r]of e)if(!r.isDeleted)for(let o of r.groupIds??[])t.add(o);return t},P0=e=>{let t=e.flatMap(n=>n.groupIds),r=new Map,o=0;for(let n of t)r.set(n,(r.get(n)??0)+1),r.get(n)>o&&(o=r.get(n));return o===e.length},$o=e=>e.groupIds.length>0});import{sanitizeUrl as hA}from"@braintree/sanitize-url";var wm,vr,vm,Tm,Sa=Q(()=>{"use strict";f();wm=e=>e.replace(/"/g,"""),vr=e=>(e=e.trim(),e&&hA(wm(e))),vm=e=>!!(e?.includes(location.origin)||e?.startsWith("/")),Tm=e=>{if(e=vr(e),e.startsWith("/"))return`${location.origin}${e}`;try{new URL(e)}catch{return"about:blank"}return e}});var Sm,H,Ve=Q(()=>{"use strict";f();Sm=[],H=e=>(Sm=Sm.concat(e),e)});import Im from"open-color";var _0,gA,R0,fA,bA,Qr,Ye,fn,D0,xg,eo,Ls=Q(()=>{"use strict";f();Y();Or();_0='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',gA='<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"/>',R0='<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"/>',fA=`data:${oe.svg},${encodeURIComponent(`${_0}${R0}</svg>`)}`,bA=`data:${oe.svg},${encodeURIComponent(`${_0}${gA}${R0}</svg>`)}`,Qr=e=>{e&&(e.style.cursor="")},Ye=(e,t)=>{e&&(e.style.cursor=t)},xg=(e,t)=>{let o=()=>{let n=t===ce.DARK;fn=document.createElement("canvas"),fn.theme=t,fn.height=20,fn.width=20;let i=fn.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(fn.width/2,fn.height/2,5,0,2*Math.PI),i.fillStyle=n?Im.black:Im.white,i.fill(),i.strokeStyle=n?Im.white:Im.black,i.stroke(),D0=fn.toDataURL(oe.svg)};(!fn||fn.theme!==t)&&o(),Ye(e,`url(${D0}) ${20/2} ${20/2}, auto`)},eo=(e,t)=>{if(e)if(t.activeTool.type==="selection")Qr(e);else if(Yo(t))e.style.cursor=Ne.GRAB;else if(Nr(t))xg(e,t.theme);else if(t.activeTool.type==="laser"){let r=t.theme===ce.LIGHT?fA:bA;e.style.cursor=`url(${r}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=Ne.AUTO):e.style.cursor=Ne.CROSSHAIR}});var Vn,to,yg,N0,km,lc,O0,Wt,EA,Xo,B0,fo,cc,Cm,Zo,Am,dc,Mm,jo=Q(()=>{"use strict";f();G();zo();Ae();Gt();be();ft();it();Je();Y();Vn=(e,{x:t,y:r,strokeColor:o=nt.strokeColor,backgroundColor:n=nt.backgroundColor,fillStyle:i=nt.fillStyle,strokeWidth:a=nt.strokeWidth,strokeStyle:s=nt.strokeStyle,roughness:l=nt.roughness,opacity:c=nt.opacity,width:d=0,height:m=0,angle:p=0,groupIds:u=[],frameId:h=null,index:g=null,roundness:x=null,boundElements:v=null,link:y=null,locked:w=nt.locked,...I})=>({id:I.id||Nt(),type:e,x:t,y:r,width:d,height:m,angle:p,strokeColor:o,backgroundColor:n,fillStyle:i,strokeWidth:a,strokeStyle:s,roughness:l,opacity:c,groupIds:u,frameId:h,index:g,roundness:x,seed:I.seed??uo(),version:I.version||1,versionNonce:I.versionNonce??0,isDeleted:!1,boundElements:v,updated:Fn(),link:y,locked:w,customData:I.customData}),to=e=>Vn(e.type,e),yg=e=>Vn("embeddable",e),N0=e=>({...Vn("iframe",e)}),km=e=>se({...Vn("frame",e),type:"frame",name:e?.name||null},{}),lc=e=>se({...Vn("magicframe",e),type:"magicframe",name:e?.name||null},{}),O0=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),Wt=e=>{let t=e.fontFamily||Zt,r=e.fontSize||Tt,o=e.lineHeight||qr(t),n=Ii(e.text),i=Bt(n,Ie({fontFamily:t,fontSize:r}),o),a=e.textAlign||nn,s=e.verticalAlign||oa,l=O0({textAlign:a,verticalAlign:s},i),c={...Vn("text",e),text:n,fontSize:r,fontFamily:t,textAlign:a,verticalAlign:s,x:e.x-l.x,y:e.y-l.y,width:i.width,height:i.height,containerId:e.containerId||null,originalText:e.originalText??n,autoResize:e.autoResize??!0,lineHeight:o};return se(c,{})},EA=(e,t,r)=>{let{width:o,height:n}=Bt(r,Ie(e),e.lineHeight);e.autoResize||(o=e.width);let{textAlign:i,verticalAlign:a}=e,s,l;if(i==="center"&&a===St.MIDDLE&&!e.containerId&&e.autoResize){let c=Bt(e.text,Ie(e),e.lineHeight),d=O0(e,{width:o-c.width,height:n-c.height});s=e.x-d.x,l=e.y-d.y}else{let[c,d,m,p]=ne(e,t),[u,h,g,x]=Wn(e,o,n,!1),v=(c-u)/2,y=(d-h)/2,w=(m-g)/2,I=(p-x)/2;[s,l]=y1({s:!0,e:i==="center"||i==="left",w:i==="center"||i==="right"},e.x,e.y,e.angle,v,y,w,I)}return{width:o,height:n,x:Number.isFinite(s)?s:e.x,y:Number.isFinite(l)?l:e.y}},Xo=(e,t,r,o=e.text)=>{if(e.isDeleted)return;(t||!e.autoResize)&&(o=go(o,Ie(e),t?cr(t,e):e.width));let n=EA(e,r,o);return{text:o,...n}},B0=e=>({...Vn(e.type,e),points:e.points||[],pressures:[],simulatePressure:e.simulatePressure,lastCommittedPoint:null}),fo=e=>({...Vn(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null}),cc=e=>({...Vn("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1]}),Cm=(e,t=0)=>{if(e==null||typeof e!="object")return e;let r=Object.prototype.toString.call(e);if(r==="[object Object]"){let o=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(t===0&&(n==="shape"||n==="canvas"))continue;o[n]=Cm(e[n],t+1)}return o}if(Array.isArray(e)){let o=e.length,n=new Array(o);for(;o--;)n[o]=Cm(e[o],t+1);return n}return T.DEV&&r!=="[object Object]"&&r!=="[object Array]"&&r.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${r}. This value will not be cloned!`),e},Zo=e=>Cm(e),Am=e=>{if(Pr()&&e){let t=`${e}_copy`;return window.h?.app?.getSceneElementsIncludingDeleted().find(r=>r.id===t)&&(t+="_copy"),t}return Nt()},dc=(e,t,r,o)=>{let n=Zo(r);return n.id=Am(n.id),n.boundElements=null,n.updated=Fn(),n.seed=uo(),n.groupIds=A0(n.groupIds,e,i=>(t.has(i)||t.set(i,Am(i)),t.get(i))),o&&(n=Object.assign(n,o)),n},Mm=(e,t)=>{let r=[],o=X(e),n=new Map,i=s=>{if(n.has(s))return n.get(s);if(o.has(s)){let l=Am(s);return n.set(s,l),l}return null},a=new Map;for(let s of e){let l=Cm(s);if(l.id=i(s.id),t?.randomizeSeed&&(l.seed=uo(),Ai(l)),l.groupIds&&(l.groupIds=l.groupIds.map(c=>(a.has(c)||a.set(c,Am(c)),a.get(c)))),"containerId"in l&&l.containerId){let c=i(l.containerId);l.containerId=c}if("boundElements"in l&&l.boundElements&&(l.boundElements=l.boundElements.reduce((c,d)=>{let m=i(d.id);return m&&c.push({...d,id:m}),c},[])),"endBinding"in l&&l.endBinding){let c=i(l.endBinding.elementId);l.endBinding=c?{...l.endBinding,elementId:c}:null}if("startBinding"in l&&l.startBinding){let c=i(l.startBinding.elementId);l.startBinding=c?{...l.startBinding,elementId:c}:null}l.frameId&&(l.frameId=i(l.frameId)),r.push(l)}return r}});var bt,mc,pc,F0=Q(()=>{"use strict";f();Y();_r();Jt();Ae();Je();le();ho();Gt();De();G();bt=class e{constructor(t,r){this.deleted=t;this.inserted=r}static create(t,r,o,n){let i=o&&n!=="inserted"?o(t):t,a=o&&n!=="deleted"?o(r):r;return new e(i,a)}static calculate(t,r,o,n){if(t===r)return e.empty();let i={},a={};for(let c of this.distinctKeysIterator("full",t,r))i[c]=t[c],a[c]=r[c];let[s,l]=n?n(i,a):[i,a];return e.create(s,l,o)}static empty(){return new e({},{})}static isEmpty(t){return!Object.keys(t.deleted).length&&!Object.keys(t.inserted).length}static mergeObjects(t,r,o){let n={...t};for(let i of Object.keys(o))delete n[i];return{...n,...r}}static mergeArrays(t,r,o,n){return Object.values(e.mergeObjects(an(t??[],n),an(r??[],n),an(o??[],n)))}static diffObjects(t,r,o,n){if(!(!t[o]&&!r[o])&&(typeof t[o]=="object"||typeof r[o]=="object")){let i=t[o]??{},a=r[o]??{},s=e.getLeftDifferences(i,a).reduce((c,d)=>(c[d]=n(i[d]),c),{}),l=e.getRightDifferences(i,a).reduce((c,d)=>(c[d]=n(a[d]),c),{});Object.keys(s).length||Object.keys(l).length?(Reflect.set(t,o,s),Reflect.set(r,o,l)):(Reflect.deleteProperty(t,o),Reflect.deleteProperty(r,o))}}static diffArrays(t,r,o,n){if(!(!t[o]&&!r[o])&&(Array.isArray(t[o])||Array.isArray(r[o]))){let i=Array.isArray(t[o])?t[o]:[],a=Array.isArray(r[o])?r[o]:[],s=an(e.getLeftDifferences(an(i,n),an(a,n))),l=an(e.getRightDifferences(an(i,n),an(a,n)));if(Object.keys(s).length||Object.keys(l).length){let c=i.filter(m=>s[n?n(m):String(m)]),d=a.filter(m=>l[n?n(m):String(m)]);Reflect.set(t,o,c),Reflect.set(r,o,d)}else Reflect.deleteProperty(t,o),Reflect.deleteProperty(r,o)}}static isLeftDifferent(t,r,o=!1){return!!this.distinctKeysIterator("left",t,r,o).next().value}static isRightDifferent(t,r,o=!1){return!!this.distinctKeysIterator("right",t,r,o).next().value}static getLeftDifferences(t,r,o=!1){return Array.from(this.distinctKeysIterator("left",t,r,o))}static getRightDifferences(t,r,o=!1){return Array.from(this.distinctKeysIterator("right",t,r,o))}static*distinctKeysIterator(t,r,o,n=!1){if(r===o)return;let i=[];t==="left"?i=Object.keys(r):t==="right"?i=Object.keys(o):t==="full"?i=Array.from(new Set([...Object.keys(r),...Object.keys(o)])):Fo(t,`Unknown distinctKeysIterator's join param "${t}"`,!0);for(let a of i){let s=r[a],l=o[a];if(s!==l){if(!n&&typeof s=="object"&&typeof l=="object"&&s!==null&&l!==null&&tt(s,l))continue;yield a}}}},mc=class e{constructor(t){this.delta=t}static calculate(t,r){let o=bt.calculate(t,r,void 0,e.postProcess);return new e(o)}static empty(){return new e(bt.create({},{}))}inverse(){let t=bt.create(this.delta.inserted,this.delta.deleted);return new e(t)}applyTo(t,r){try{let{selectedElementIds:o={},selectedGroupIds:n={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:s,editingLinearElementId:l,...c}=this.delta.inserted,d=bt.mergeObjects(t.selectedElementIds,i,o),m=bt.mergeObjects(t.selectedGroupIds,a,n),p=s&&r.has(s)?new j(r.get(s)):null,u=l&&r.has(l)?new j(r.get(l)):null,h={...t,...c,selectedElementIds:d,selectedGroupIds:m,selectedLinearElement:typeof s<"u"?p:t.selectedLinearElement,editingLinearElement:typeof l<"u"?u:t.editingLinearElement},g=this.filterInvisibleChanges(t,h,r);return[h,g]}catch(o){if(console.error("Couldn't apply appstate change",o),T.DEV||T.MODE===Mr.TEST)throw o;return[t,!1]}}isEmpty(){return bt.isEmpty(this.delta)}static postProcess(t,r){try{bt.diffObjects(t,r,"selectedElementIds",o=>!0),bt.diffObjects(t,r,"selectedGroupIds",o=>o??!1)}catch(o){if(console.error("Couldn't postprocess appstate change deltas."),T.DEV||T.MODE===Mr.TEST)throw o}finally{return[t,r]}}filterInvisibleChanges(t,r,o){let n=uc(t),i=uc(r),a=bt.isRightDifferent(e.stripElementsProps(n),e.stripElementsProps(i)),s=bt.isRightDifferent(e.stripStandaloneProps(n),e.stripStandaloneProps(i));if(!a&&!s)return!1;let l={value:a};if(s){let c=bt.getRightDifferences(e.stripStandaloneProps(n),e.stripStandaloneProps(i)),d=new Set;(c.includes("editingGroupId")||c.includes("selectedGroupIds"))&&(d=L0(o));for(let m of c)switch(m){case"selectedElementIds":r[m]=e.filterSelectedElements(r[m],o,l);break;case"selectedGroupIds":r[m]=e.filterSelectedGroups(r[m],d,l);break;case"editingGroupId":let p=r[m];p?d.has(p)?l.value=!0:r[m]=null:l.value=!0;break;case"selectedLinearElementId":case"editingLinearElementId":let u=e.convertToAppStateKey(m),h=r[u];if(!h)l.value=!0;else{let g=o.get(h.elementId);g&&!g.isDeleted?l.value=!0:r[u]=null}break;default:Fo(m,`Unknown ObservedElementsAppState's key "${m}"`,!0)}}return l.value}static convertToAppStateKey(t){switch(t){case"selectedLinearElementId":return"selectedLinearElement";case"editingLinearElementId":return"editingLinearElement"}}static filterSelectedElements(t,r,o){let n=Object.keys(t);if(!n.length)return o.value=!0,t;let i={...t};for(let a of n){let s=r.get(a);s&&!s.isDeleted?o.value=!0:delete i[a]}return i}static filterSelectedGroups(t,r,o){if(!Object.keys(t).length)return o.value=!0,t;let i={...t};for(let a of Object.keys(i))r.has(a)?o.value=!0:delete i[a];return i}static stripElementsProps(t){let{editingGroupId:r,selectedGroupIds:o,selectedElementIds:n,editingLinearElementId:i,selectedLinearElementId:a,...s}=t;return s}static stripStandaloneProps(t){let{name:r,viewBackgroundColor:o,...n}=t;return n}},pc=class e{constructor(t,r,o){this.added=t;this.removed=r;this.updated=o}static create(t,r,o,n={shouldRedistribute:!1}){let i;if(n.shouldRedistribute){let a=new Map,s=new Map,l=new Map,c=[...t,...r,...o];for(let[d,m]of c)this.satisfiesAddition(m)?a.set(d,m):this.satisfiesRemoval(m)?s.set(d,m):l.set(d,m);i=new e(a,s,l)}else i=new e(t,r,o);return(T.DEV||T.MODE===Mr.TEST)&&(e.validate(i,"added",this.satisfiesAddition),e.validate(i,"removed",this.satisfiesRemoval),e.validate(i,"updated",this.satisfiesUpdate)),i}static satisfiesAddition=({deleted:t,inserted:r})=>t.isDeleted===!0&&!r.isDeleted;static satisfiesRemoval=({deleted:t,inserted:r})=>!t.isDeleted&&r.isDeleted===!0;static satisfiesUpdate=({deleted:t,inserted:r})=>!!t.isDeleted==!!r.isDeleted;static validate(t,r,o){for(let[n,i]of t[r].entries())if(!o(i))throw console.error(`Broken invariant for "${r}" delta, element "${n}", delta:`,i),new Error(`ElementsChange invariant broken for element "${n}".`)}static calculate(t,r){if(t===r)return e.empty();let o=new Map,n=new Map,i=new Map;for(let a of t.values())if(!r.get(a.id)){let l={...a,isDeleted:!1},c={isDeleted:!0},d=bt.create(l,c,e.stripIrrelevantProps);n.set(a.id,d)}for(let a of r.values()){let s=t.get(a.id);if(!s){let l={isDeleted:!0},c={...a,isDeleted:!1},d=bt.create(l,c,e.stripIrrelevantProps);o.set(a.id,d);continue}if(s.versionNonce!==a.versionNonce){let l=bt.calculate(s,a,e.stripIrrelevantProps,e.postProcess);if(typeof s.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&s.isDeleted!==a.isDeleted){s.isDeleted&&!a.isDeleted?o.set(a.id,l):n.set(a.id,l);continue}bt.isEmpty(l)||i.set(a.id,l)}}return e.create(o,n,i)}static empty(){return e.create(new Map,new Map,new Map)}inverse(){let t=i=>{let a=new Map;for(let[s,l]of i.entries())a.set(s,bt.create(l.inserted,l.deleted));return a},r=t(this.added),o=t(this.removed),n=t(this.updated);return e.create(o,r,n)}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}applyLatestChanges(t){let r=s=>l=>{let c={};for(let d of Object.keys(l))switch(d){case"boundElements":c[d]=l[d];break;default:c[d]=s[d]}return c},o=s=>{let l=new Map;for(let[c,d]of s.entries()){let m=t.get(c);if(m){let p=bt.create(d.deleted,d.inserted,r(m),"inserted");l.set(c,p)}else l.set(c,d)}return l},n=o(this.added),i=o(this.removed),a=o(this.updated);return e.create(n,i,a,{shouldRedistribute:!0})}applyTo(t,r){let o=Zr(new Map(t)),n,i={containsVisibleDifference:!1,containsZindexDifference:!1};try{let a=e.createApplier(o,r,i),s=a(this.added),l=a(this.removed),c=a(this.updated),d=this.resolveConflicts(t,o);n=new Map([...s,...l,...c,...d])}catch(a){if(console.error("Couldn't apply elements change",a),T.DEV||T.MODE===Mr.TEST)throw a;return[t,!0]}try{e.redrawTextBoundingBoxes(o,n),e.redrawBoundArrows(o,n),o=e.reorderElements(o,n,i)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),T.DEV||T.MODE===Mr.TEST)throw a}finally{return[o,i.containsVisibleDifference]}}static createApplier=(t,r,o)=>{let n=e.createGetter(t,r,o);return i=>Array.from(i.entries()).reduce((a,[s,l])=>{let c=n(s,l.inserted);if(c){let d=e.applyDelta(c,l,o);t.set(d.id,d),a.set(d.id,d)}return a},new Map)};static createGetter=(t,r,o)=>(n,i)=>{let a=t.get(n);return a||(a=r.get(n),a&&(o.containsZindexDifference=!0,(i.isDeleted===!1||i.isDeleted!==!0&&a.isDeleted===!1)&&(o.containsVisibleDifference=!0))),a};static applyDelta(t,r,o={containsVisibleDifference:!0,containsZindexDifference:!0}){let{boundElements:n,...i}=r.inserted;if(r.deleted.boundElements?.length||r.inserted.boundElements?.length){let a=bt.mergeArrays(t.boundElements,r.inserted.boundElements,r.deleted.boundElements,s=>s.id);Object.assign(i,{boundElements:a})}if(!o.containsVisibleDifference){let{index:a,...s}=i,l=e.checkForVisibleDifference(t,s);o.containsVisibleDifference=l}return o.containsZindexDifference||(o.containsZindexDifference=r.deleted.index!==r.inserted.index),se(t,i)}static checkForVisibleDifference(t,r){return t.isDeleted&&r.isDeleted!==!1?!1:t.isDeleted&&r.isDeleted===!1||t.isDeleted===!1&&r.isDeleted?!0:bt.isRightDifferent(t,r)}resolveConflicts(t,r){let o=new Map,n=(c,d)=>{let m=r.get(c.id);if(!m)return;let p;t.get(c.id)===m?p=se(m,d):p=O(m,d),o.set(p.id,p),r.set(p.id,p)};for(let[c]of this.removed)e.unbindAffected(t,r,c,n);for(let[c]of this.added)e.rebindAffected(t,r,c,n);for(let[c]of Array.from(this.updated).filter(([d,m])=>Object.keys({...m.deleted,...m.inserted}).find(p=>d0.has(p)))){let d=r.get(c);!d||d.isDeleted||e.rebindAffected(t,r,c,n)}let i=new Map(Array.from(t).filter(([c])=>o.has(c))),{added:a,removed:s,updated:l}=e.calculate(i,o);for(let[c,d]of a)this.added.set(c,d);for(let[c,d]of s)this.removed.set(c,d);for(let[c,d]of l)this.updated.set(c,d);return o}static unbindAffected(t,r,o,n){let i=()=>t.get(o),a=()=>r.get(o);Ti.unbindAffected(r,i(),n),Ti.unbindAffected(r,a(),n),Si.unbindAffected(r,i(),n),Si.unbindAffected(r,a(),n)}static rebindAffected(t,r,o,n){let i=()=>t.get(o),a=()=>r.get(o);Ti.unbindAffected(r,i(),n),Ti.rebindAffected(r,a(),n),Si.unbindAffected(r,i(),(s,l)=>{U(s)&&n(s,l)}),Si.rebindAffected(r,a(),n)}static redrawTextBoundingBoxes(t,r){let o=new Map;for(let n of r.values()){if(Me(n)){let{containerId:i}=n,a=i?t.get(i):void 0;a&&o.set(a.id,{container:a,boundText:n})}if(sr(n)){let i=Vo(n),a=i?t.get(i):void 0;a&&o.set(n.id,{container:n,boundText:a})}}for(let{container:n,boundText:i}of o.values())n.isDeleted||i.isDeleted||Ot(i,n,t,!1)}static redrawBoundArrows(t,r){for(let o of r.values())!o.isDeleted&&la(o)&&qt(o,t)}static reorderElements(t,r,o){if(!o.containsZindexDifference)return t;let n=Array.from(t.values()),i=Jd([...n]),a=bt.getRightDifferences(n,i,!0).reduce((s,l)=>{let c=n[Number(l)];return c&&r.has(c.id)&&s.set(c.id,c),s},new Map);return!o.containsVisibleDifference&&a.size&&(o.containsVisibleDifference=!0),X(Ut(i,a))}static postProcess(t,r){try{bt.diffArrays(t,r,"boundElements",o=>o.id)}catch(o){if(console.error("Couldn't postprocess elements change deltas."),T.DEV||T.MODE===Mr.TEST)throw o}finally{return[t,r]}}static stripIrrelevantProps(t){let{id:r,updated:o,version:n,versionNonce:i,seed:a,...s}=t;return s}}});var dr,hc=Q(()=>{"use strict";f();dr=class{subscribers=[];on(...t){let r=t.flat().filter(o=>typeof o=="function");return this.subscribers.push(...r),()=>this.off(r)}once(...t){let r=t.flat().filter(n=>typeof n=="function");r.push(()=>o());let o=this.on(...r);return o}off(...t){let r=t.flat();this.subscribers=this.subscribers.filter(o=>!r.includes(o))}trigger(...t){for(let r of this.subscribers)r(...t);return this}clear(){this.subscribers=[]}}});var z0,uc,xA,D,wg,Lm,Pm,De=Q(()=>{"use strict";f();Or();F0();Y();Ae();jo();hc();G();z0="__observedAppState",uc=e=>{let t={name:e.name,editingGroupId:e.editingGroupId,viewBackgroundColor:e.viewBackgroundColor,selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,editingLinearElementId:e.editingLinearElement?.elementId||null,selectedLinearElementId:e.selectedLinearElement?.elementId||null};return Reflect.defineProperty(t,z0,{value:!0,enumerable:!1}),t},xA=e=>!!Reflect.get(e,z0),D={CAPTURE:"capture",UPDATE:"update",NONE:"none"},wg=class{constructor(t,r){this.elementsChange=t;this.appStateChange=r}},Lm=class{onStoreIncrementEmitter=new dr;scheduledActions=new Set;_snapshot=Pm.empty();get snapshot(){return this._snapshot}set snapshot(t){this._snapshot=t}shouldCaptureIncrement=()=>{this.scheduleAction(D.CAPTURE)};shouldUpdateSnapshot=()=>{this.scheduleAction(D.UPDATE)};scheduleAction=t=>{this.scheduledActions.add(t),this.satisfiesScheduledActionsInvariant()};commit=(t,r)=>{try{this.scheduledActions.has(D.CAPTURE)?this.captureIncrement(t,r):this.scheduledActions.has(D.UPDATE)&&this.updateSnapshot(t,r)}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledActions=new Set}};captureIncrement=(t,r)=>{let o=this.snapshot,n=this.snapshot.maybeClone(t,r);if(o!==n){let i=n.meta.didElementsChange?pc.calculate(o.elements,n.elements):pc.empty(),a=n.meta.didAppStateChange?mc.calculate(o.appState,n.appState):mc.empty();(!i.isEmpty()||!a.isEmpty())&&this.onStoreIncrementEmitter.trigger(new wg(i,a)),this.snapshot=n}};updateSnapshot=(t,r)=>{let o=this.snapshot.maybeClone(t,r);this.snapshot!==o&&(this.snapshot=o)};filterUncomittedElements=(t,r)=>{for(let[o,n]of t.entries()){if(!r.get(o))continue;let a=this.snapshot.elements.get(o);a?a.version<n.version&&r.set(o,a):r.delete(o)}return r};clear=()=>{this.snapshot=Pm.empty(),this.scheduledActions=new Set};satisfiesScheduledActionsInvariant=()=>{if(!(this.scheduledActions.size>=0&&this.scheduledActions.size<=3)){let t=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledActions.size}".`;if(console.error(t,this.scheduledActions.values()),T.DEV||T.MODE===Mr.TEST)throw new Error(t)}}},Pm=class e{constructor(t,r,o={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=t;this.appState=r;this.meta=o}static empty(){return new e(new Map,uc(Qt()),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return this.meta.isEmpty}maybeClone(t,r){let o=this.maybeCreateElementsSnapshot(t),n=this.maybeCreateAppStateSnapshot(r),i=!1,a=!1;return this.elements!==o&&(i=!0),this.appState!==n&&(a=!0),!i&&!a?this:new e(o,n,{didElementsChange:i,didAppStateChange:a})}maybeCreateAppStateSnapshot(t){if(!t)return this.appState;let r=xA(t)?t:uc(t);return this.detectChangedAppState(r)?r:this.appState}detectChangedAppState(t){return!tt(this.appState,t,{selectedElementIds:tt,selectedGroupIds:tt})}maybeCreateElementsSnapshot(t){return t?this.detectChangedElements(t)?this.createElementsSnapshot(t):this.elements:this.elements}detectChangedElements(t){if(this.elements===t)return!1;if(this.elements.size!==t.size)return!0;let r=Array.from(t.keys());for(let o=r.length-1;o>=0;o--){let n=this.elements.get(r[o]),i=t.get(r[o]);if(!n||!i||n.id!==i.id||n.versionNonce!==i.versionNonce)return!0}return!1}createElementsSnapshot(t){let r=new Map;for(let[o,n]of this.elements.entries())t.get(o)?r.set(o,n):r.set(o,se(n,{isDeleted:!0}));for(let[o,n]of t.entries()){let i=r.get(o);(!i||i&&i.versionNonce!==n.versionNonce)&&r.set(o,Zo(n))}return r}}});var Yn,yA,wA,vA,H0,TA,U0,SA,IA,CA,G0,vg,W0,gc,Kn,Dm,RO,Tg,V0,Ps,fc=Q(()=>{"use strict";f();Ve();Y();G();Ls();jo();Je();le();Sa();De();Yn=new Map,yA=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)(?:\?t=|&t=|\?start=|&start=)?([a-zA-Z0-9_-]+)?[^\s]*$/,wA=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}\.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,vA=/^https:\/\/(?:www\.)?figma\.com/,H0=/^https:\/\/gist\.github\.com\/([\w_-]+)\/([\w_-]+)/,TA=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist\.github\.com\/.*?)\.js["']/i,U0=/(?:https?:\/\/)?(?:(?:w){3}\.)?(?:twitter|x)\.com\/[^/]+\/status\/(\d+)/,SA=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:twitter|x)\.com\/[^"']*)/i,IA=/^https:\/\/(?:www\.)?val\.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,CA=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,G0=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,vg=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","link.excalidraw.com","gist.github.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","val.town","giphy.com"]),W0=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com"]),gc=e=>`<html><body>${e}</body></html>`,Kn=e=>{if(!e)return null;if(Yn.has(e))return Yn.get(e);let t=e,r=W0.has(Tg(e,W0)||""),o="generic",n={w:560,h:840},i=e.match(yA);if(i?.[2]){let c=i[3]?`&start=${i[3]}`:"",d=e.includes("shorts");switch(o="video",i[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${c}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${i[2]}&enablejsapi=1${c}`;break;default:e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${c}`;break}return n=d?{w:315,h:560}:{w:560,h:315},Yn.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}}let a=e.match(wA);if(a?.[1]){let c=a?.[1],d=/^\d+$/.test(c)?void 0:new URIError("Invalid embed link format");return o="video",e=`https://player.vimeo.com/video/${c}?api=1`,n={w:560,h:315},Yn.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,error:d,sandbox:{allowSameOrigin:r}}}if(e.match(vA))return o="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,n={w:550,h:550},Yn.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}};let l=e.match(IA);if(l)return e=l[1]==="embed"?l[0]:l[0].replace("/v","/embed"),Yn.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}};if(U0.test(e)){let c=e.match(U0)[1],d=wm(`https://twitter.com/x/status/${c}`),m={type:"document",srcdoc:p=>gc(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${p}"><a href="${d}"></a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`),intrinsicSize:{w:480,h:480},sandbox:{allowSameOrigin:r}};return Yn.set(t,m),m}if(H0.test(e)){let[,c,d]=e.match(H0),m=wm(`https://gist.github.com/${c}/${d}`),p={type:"document",srcdoc:()=>gc(`
|
|
1
|
+
var $A=Object.defineProperty;var Ox=e=>t=>{var r=e[t];if(r)return r();throw new Error("Module not found in bundle: "+t)};var X=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ch=(e,t)=>{for(var r in t)$A(e,r,{get:t[r],enumerable:!0})};var T,f=X(()=>{T={PROD:!0}});var Mh,Hx=X(()=>{Mh={}});import i6 from"open-color";var a6,Ux,Ma,Gx,_s,Rs,Yo,Xo,Ee,Wx,fm,bm,Em,Vx,Yx,Xx,Kx,pr=X(()=>{"use strict";f();a6=(e,t)=>t.reduce((r,o)=>(o in e&&(r[o]=e[o]),r),{}),Ux=5,Ma=5,Gx=4,_s=4,Rs=1,Yo=[0,2,4,6,8],Xo=(e,t)=>t.map(r=>i6[e][r]),Ee={transparent:"transparent",black:"#1e1e1e",white:"#ffffff",gray:Xo("gray",Yo),red:Xo("red",Yo),pink:Xo("pink",Yo),grape:Xo("grape",Yo),violet:Xo("violet",Yo),blue:Xo("blue",Yo),cyan:Xo("cyan",Yo),teal:Xo("teal",Yo),green:Xo("green",Yo),yellow:Xo("yellow",Yo),orange:Xo("orange",Yo),bronze:["#f8f1ee","#eaddd7","#d2bab0","#a18072","#846358"]},Wx=a6(Ee,["cyan","blue","violet","grape","pink","green","teal","yellow","orange","red"]),fm=[Ee.black,Ee.red[_s],Ee.green[_s],Ee.blue[_s],Ee.yellow[_s]],bm=[Ee.transparent,Ee.red[Rs],Ee.green[Rs],Ee.blue[Rs],Ee.yellow[Rs]],Em=[Ee.white,"#f8f9fa","#f5faff","#fffce8","#fdf8f6"],Vx={transparent:Ee.transparent,white:Ee.white,gray:Ee.gray,black:Ee.black,bronze:Ee.bronze,...Wx},Yx={transparent:Ee.transparent,white:Ee.white,gray:Ee.gray,black:Ee.black,bronze:Ee.bronze,...Wx},Xx=e=>[Ee.cyan[e],Ee.blue[e],Ee.violet[e],Ee.grape[e],Ee.pink[e],Ee.green[e],Ee.teal[e],Ee.yellow[e],Ee.orange[e],Ee.red[e]],Kx=(e,t,r)=>`#${((1<<24)+(e<<16)+(t<<8)+r).toString(16).slice(1)}`});var Cr,xm,$x,ti,s6,Zx,ym,jx,hc,fc,qx,ri,Ns,Jx,wm,Qx,wn,kh,Be,Ni,ka,bc,Kt,vm,Le,ue,rt,Ph,Tm,ur,gr,vn,Pa,oi,Sm,l6,e0,Ec,t0,r0,ni,xc,o0,se,Im,hr,yc,n0,i0,a0,s0,La,Os,Lh,l0,Fs,Cm,Am,Dh,c0,d0,m0,p0,u0,Bs,zs,Ko,g0,_h,Ke,Da,wt,h0,f0,kt,Oi,b0,Mm,E0,ct,Rh,km,pt,wc,co,Pm,It,To,Lm,Fi,Vr,_t,Y=X(()=>{"use strict";f();Hx();pr();Cr=/Mac|iPod|iPhone|iPad/.test(navigator.platform),xm=/^Win/.test(navigator.platform),$x=/\b(android)\b/i.test(navigator.userAgent),ti="netscape"in window&&navigator.userAgent.indexOf("rv:")>1&&navigator.userAgent.indexOf("Gecko")>1,s6=navigator.userAgent.indexOf("Chrome")!==-1,Zx=!s6&&navigator.userAgent.indexOf("Safari")!==-1,ym=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,jx=()=>navigator.brave?.isBrave?.name==="isBrave",hc=typeof window<"u"&&"ResizeObserver"in window,fc="Excalidraw",qx=36,ri=10,Ns=8,Jx=5,wm=1,Qx=30,wn=Math.PI/12,kh="red",Be={TEXT:"text",CROSSHAIR:"crosshair",GRABBING:"grabbing",GRAB:"grab",POINTER:"pointer",MOVE:"move",AUTO:""},Ni={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},ka={enabled:"all",disabled:"none",inheritFromUI:"var(--ui-pointerEvents)"},bc={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},Kt={TEST:"test",DEVELOPMENT:"development"},vm={SHAPE_ACTIONS_MENU:"App-menu__left"},Le={Virgil:1,Helvetica:2,Cascadia:3,Excalifont:5,Nunito:6,"Lilita One":7,"Comic Shanns":8,"Liberation Sans":9},ue={LIGHT:"light",DARK:"dark"},rt={strokeColor:"#bbb",strokeWidth:2,strokeStyle:"solid",fillStyle:"solid",roughness:0,roundness:null,backgroundColor:"transparent",radius:8,nameOffsetY:3,nameColorLightTheme:"#999999",nameColorDarkTheme:"#7a7a7a",nameFontSize:14,nameLineHeight:1.25},Ph="Segoe UI Emoji",Tm=1,ur=20,gr=Le.Excalifont,vn="left",Pa="top",oi=2,Sm=2*oi,l6=1e-5,e0=2*Sm-l6,Ec="#ffffff",t0="#1e1e1e",r0="#a2f1a6",ni=20,xc={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif"},o0=["text/plain","text/html"],se={json:"application/json",excalidraw:"application/vnd.excalidraw+json",excalidrawlib:"application/vnd.excalidrawlib+json","excalidraw.svg":"image/svg+xml","excalidraw.png":"image/png",binary:"application/octet-stream",...xc},Im={png:"png",svg:"svg",clipboard:"clipboard"},hr={excalidraw:"excalidraw",excalidrawClipboard:"excalidraw/clipboard",excalidrawLibrary:"excalidrawlib",excalidrawClipboardWithAPI:"excalidraw-api/clipboard"},yc=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,n0=500,i0=300,a0=500,s0=100,La=.1,Os=.1,Lh=30,l0=300,Fs=Mh.themeFilter,Cm={addLibrary:"addLibrary"},Am={addLibrary:"addLibrary"},Dh={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},c0=730,d0=1e3,m0=500,p0=1229,u0=parseInt(Mh.rightSidebarWidth),Bs=2,zs=[1,2,3],Ko=10,g0=1440,_h=4*1024*1024,Ke="http://www.w3.org/2000/svg",Da={excalidraw:2,excalidrawLibrary:2},wt=5,h0=.7,f0=11,kt={TOP:"top",MIDDLE:"middle",BOTTOM:"bottom"},Oi={LEFT:"left",CENTER:"center",RIGHT:"right"},b0=20,Mm=.25,E0=32,ct={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},Rh={architect:0,artist:1,cartoonist:2},km={thin:1,bold:2,extraBold:4},pt={strokeColor:Ee.black,backgroundColor:Ee.transparent,fillStyle:"solid",strokeWidth:2,strokeStyle:"solid",roughness:Rh.artist,opacity:100,locked:!1},wc="library",co={name:"default",defaultTab:wc},Pm=new Set(["iframe","embeddable","image"]),It={selection:"selection",rectangle:"rectangle",diamond:"diamond",ellipse:"ellipse",arrow:"arrow",line:"line",freedraw:"freedraw",text:"text",image:"image",eraser:"eraser",hand:"hand",frame:"frame",magicframe:"magicframe",embeddable:"embeddable",laser:"laser"},To={OAI_API_KEY:"excalidraw-oai-api-key",MERMAID_TO_EXCALIDRAW:"mermaid-to-excalidraw",PUBLISH_LIBRARY:"publish-library-data"},Lm="Untitled",Fi={generalStats:1,elementProperties:2},Vr=1,_t={sharp:"sharp",round:"round",elbow:"elbow"}});function vt(e,t,r,o){return e?(e?.addEventListener?.(t,r,o),()=>{e?.removeEventListener?.(t,r,o)}):()=>{}}function O0(e,t=!0){let r=e.length;if(r<4)return"";let o=e[0],n=e[1],i=e[2],a=`M${o[0].toFixed(2)},${o[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${_m(n[0],i[0]).toFixed(2)},${_m(n[1],i[1]).toFixed(2)} T`;for(let s=2,l=r-1;s<l;s++)o=e[s],n=e[s+1],a+=`${_m(o[0],n[0]).toFixed(2)},${_m(o[1],n[1]).toFixed(2)} `;return t&&(a+="Z"),a}var y0,Oh,Bi,T0,Fh,S0,Tn,Sn,Me,ii,Hs,ai,w0,I0,C0,Ht,nt,O,Qe,$t,vc,f6,b6,E6,Rm,ar,Nm,Bh,zh,Ar,Om,A0,M0,k0,P0,si,Z,L0,In,D0,Yr,_0,Fm,Us,R0,Cn,Tc,v0,it,zi,$o,N0,Sc,Xr,Hh,Bm,_m,zm,Mr,Ic,F0,V=X(()=>{"use strict";f();pr();Y();y0=null,Oh=()=>{if(y0)return y0;let e=new Date,t=e.getFullYear(),r=`${e.getMonth()+1}`.padStart(2,"0"),o=`${e.getDate()}`.padStart(2,"0"),n=`${e.getHours()}`.padStart(2,"0"),i=`${e.getMinutes()}`.padStart(2,"0");return`${t}-${r}-${o}-${n}${i}`},Bi=e=>e.charAt(0).toUpperCase()+e.slice(1),T0=e=>e instanceof HTMLElement&&e.className.includes("ToolIcon"),Fh=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,S0=e=>Fh(e)||e instanceof Element&&!!e.closest("label, button"),Tn=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type==="text"||e.type==="number"||e.type==="password"),Sn=({fontFamily:e})=>{for(let[t,r]of Object.entries(Le))if(r===e)return`${t}, ${Ph}`;return Ph},Me=({fontSize:e,fontFamily:t})=>`${e}px ${Sn({fontFamily:t})}`,ii=(e,t)=>{let r=0,o=null,n=(...i)=>{o=i,clearTimeout(r),r=window.setTimeout(()=>{o=null,e(...i)},t)};return n.flush=()=>{if(clearTimeout(r),o){let i=o;o=null,e(...i)}},n.cancel=()=>{o=null,clearTimeout(r)},n},Hs=(e,t)=>{let r=null,o=null,n=null,i=s=>{r=window.requestAnimationFrame(()=>{r=null,e(...s),o=null,n&&(o=n,n=null,i(o))})},a=(...s)=>{if(T.MODE==="test"){e(...s);return}o=s,r===null?i(o):t?.trailing&&(n=s)};return a.flush=()=>{r!==null&&(cancelAnimationFrame(r),r=null),o&&(e(...n||o),o=n=null)},a.cancel=()=>{o=n=null,r!==null&&(cancelAnimationFrame(r),r=null)},a},ai=e=>1-Math.pow(1-e,4),w0=(e,t,r)=>(t-e)*ai(r)+e,I0=({fromValues:e,toValues:t,onStep:r,duration:o=250,interpolateValue:n,onStart:i,onEnd:a,onCancel:s})=>{let l=!1,c=0,d;function m(p){if(l)return;d===void 0&&(d=p,i?.());let u=Math.min(p-d,o),g=ai(u/o),h={};if(Object.keys(e).forEach(x=>{let v=x,y=(t[v]-e[v])*g+e[v];h[v]=y}),r(h),u<o){let x=u/o,v={};Object.keys(e).forEach(y=>{let w=y,C=e[w],M=t[w],I;I=n?n(C,M,x,w):w0(C,M,x),I==null&&(I=w0(C,M,x)),v[w]=I}),r(v),c=window.requestAnimationFrame(m)}else r(t),a?.()}return c=window.requestAnimationFrame(m),()=>{s?.(),l=!0,window.cancelAnimationFrame(c)}},C0=(e,t)=>{if(!e.length||t<1)return[];let r=0,o=0,n=Array(Math.ceil(e.length/t));for(;r<e.length;)n[o++]=e.slice(r,r+=t);return n},Ht=(e,t)=>Math.abs(e-t),nt=(e,t)=>t.type==="custom"?{...e.activeTool,type:"custom",customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked},O=e=>(e=e.replace(/\bAlt\b/i,"Alt").replace(/\bShift\b/i,"Shift").replace(/\b(Enter|Return)\b/i,"Enter"),Cr?e.replace(/\bCtrlOrCmd\b/gi,"Cmd").replace(/\bAlt\b/i,"Option"):e.replace(/\bCtrlOrCmd\b/gi,"Ctrl")),Qe=({clientX:e,clientY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let s=(e-o)/r.value-i,l=(t-n)/r.value-a;return{x:s,y:l}},$t=({sceneX:e,sceneY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let s=(e+i)*r.value+o,l=(t+a)*r.value+n;return{x:s,y:l}},vc=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),f6="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF",b6="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",E6=new RegExp(`^[^${f6}]*[${b6}]`),Rm=e=>E6.test(e),ar=e=>{let[t,r]=e;return{x:t,y:r}},Nm=e=>{if(e?.name==="AbortError"){console.warn(e);return}throw e},Bh=(e,t,r=0)=>{r<0&&(r=e.length+r),r=Math.min(e.length,Math.max(r,0));let o=r-1;for(;++o<e.length;)if(t(e[o],o,e))return o;return-1},zh=(e,t,r=e.length-1)=>{r<0&&(r=e.length+r),r=Math.min(e.length-1,Math.max(r,0));let o=r+1;for(;--o>-1;)if(t(e[o],o,e))return o;return-1},Ar=e=>{let t=e.length===5&&e.substr(4,1)==="0",r=e.length===9&&e.substr(7,2)==="00";return t||r||e===Ee.transparent},Om=()=>{let e,t,r=new Promise((o,n)=>{e=o,t=n});return r.resolve=e,r.reject=t,r},A0=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:r}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(r==="auto"||r==="scroll"||r==="overlay"))return t;t=t.parentElement}return document},M0=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},k0=e=>{e.preventDefault(),e.returnValue=""},P0=e=>Array.from(e).map(t=>`0${t.toString(16)}`.slice(-2)).join(""),si=()=>Yr()?1:Date.now(),Z=e=>e instanceof Map?e:e.reduce((t,r)=>(t.set(typeof r=="string"?r:r.id,r),t),new Map),L0=e=>e.reduce((t,r,o)=>(t.set(r.id,[r,o]),t),new Map),In=(e,t)=>e.reduce((r,o)=>(r[t?t(o):String(o)]=o,r),{}),D0=e=>e.reduce((t,r,o)=>{let n={...r,prev:null,next:null};if(o!==0){let i=t[o-1];if(n.prev=i,i.next=n,o===e.length-1){let a=t[0];n.next=a,a.prev=n}}return t.push(n),t},[]),Yr=()=>T.MODE==="test",_0=()=>T.MODE==="development",Fm=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),Us=(e,t)=>{let r=!1;for(let o in t){let n=t[o];if(typeof n<"u"){if(e[o]===n&&(typeof n!="object"||n===null))continue;r=!0}}return r?{...e,...t}:e},R0=()=>{try{return window.self===window.top?"top":"iframe"}catch{return"iframe"}},Cn=e=>!!e&&typeof e=="object"&&"then"in e&&"catch"in e&&"finally"in e,Tc=e=>{let t=e?.querySelectorAll("button, a, input, select, textarea, div[tabindex], label[tabindex]");return t?Array.from(t).filter(r=>r.tabIndex>-1&&!r.disabled):[]},v0=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,it=(e,t,r,o=!1)=>{let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return o&&console.warn("%cisShallowEqual: objects don't have same properties ->","color: #8B4000",e,t),!1;if(r&&Array.isArray(r)){for(let a of r)if(!(e[a]===t[a]||v0(e[a],t[a])))return o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),!1;return!0}return n.every(a=>{let s=r?.[a],l=s?s(e[a],t[a]):e[a]===t[a]||v0(e[a],t[a]);return!l&&o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),l})},zi=(e,t,{checkForDefaultPrevented:r=!0}={})=>function(n){if(e?.(n),!r||!n?.defaultPrevented)return t?.(n)},$o=(e,t,r)=>{if(!t)return e;if(r)return console.error(t),e;throw new Error(t)},N0=e=>{let t,r,o=function(n){let i=Object.entries(n);if(t){let s=!0;for(let[l,c]of i)if(t.get(l)!==c){s=!1;break}if(s)return r}let a=e(n);return t=new Map(i),r=a,a};return o.clear=()=>{t=void 0,r=void 0},o},Sc=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):"includes"in e?e.includes(t):e.hasOwnProperty(t),Xr=e=>JSON.parse(JSON.stringify(e)),Hh=e=>typeof e=="number"&&Number.isFinite(e),Bm=(e,t)=>it(e,t)?e:t;_m=(e,t)=>(e+t)/2;zm=e=>e.replace(/\r?\n|\r/g,`
|
|
2
|
+
`),Mr=e=>e,Ic=async(e,...t)=>new Promise(r=>{r(e(...t))}),F0=(...e)=>Math.max(...e.map(t=>t?1:0))>0});var kr,So,Rt,Io,sr,H,B0,_a,Q,Zt,x6,ie,ne,de,Cc,Kr,Uh,An,z0,Mn,Ac,Ct,ze,kn,H0,U0,G0,Gh,me=X(()=>{"use strict";f();Y();V();kr=e=>!!e&&e.type==="image"&&!!e.fileId,So=e=>!!e&&e.type==="image",Rt=e=>!!e&&e.type==="embeddable",Io=e=>!!e&&e.type==="iframe",sr=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),H=e=>e!=null&&e.type==="text",B0=e=>e!=null&&e.type==="frame",_a=e=>e!=null&&e.type==="magicframe",Q=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Zt=e=>e!=null&&x6(e.type),x6=e=>e==="freedraw",ie=e=>e!=null&&Cc(e.type),ne=e=>e!=null&&e.type==="arrow",de=e=>ne(e)&&e.elbowed,Cc=e=>e==="arrow"||e==="line",Kr=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&Uh(e.type),Uh=e=>e==="arrow",An=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),z0=e=>e!=null&&(e.type==="rectangle"||e.type==="diamond"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),Mn=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||ne(e)),Ac=e=>{let t=e?.type;if(!t)return!1;switch(t){case"text":case"diamond":case"rectangle":case"iframe":case"embeddable":case"ellipse":case"arrow":case"freedraw":case"line":case"frame":case"magicframe":case"image":case"selection":return!0;default:return $o(t,null),!1}},Ct=e=>Mn(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),ze=e=>e!==null&&"containerId"in e&&e.containerId!==null&&H(e),kn=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",H0=e=>e==="line"||e==="arrow"||e==="diamond",U0=(e,t)=>!!((e===ct.ADAPTIVE_RADIUS||e===ct.LEGACY)&&kn(t.type)||e===ct.PROPORTIONAL_RADIUS&&H0(t.type)),G0=e=>H0(e.type)?{type:ct.PROPORTIONAL_RADIUS}:kn(e.type)?{type:ct.ADAPTIVE_RADIUS}:null,Gh=e=>e.fixedPoint!=null});import{Random as y6}from"roughjs/bin/math";import{nanoid as w6}from"nanoid";var v6,T6,Co,Ut,Zo=X(()=>{"use strict";f();V();v6=new y6(Date.now()),T6=0,Co=()=>Math.floor(v6.next()*2**31),Ut=()=>Yr()?`id${T6++}`:w6()});var Hm,Pn,jo,Um,Hi=X(()=>{"use strict";f();Hm=class extends Error{constructor(t="Couldn't export canvas.",r="CANVAS_ERROR"){super(),this.name=r,this.message=t}},Pn=class extends DOMException{constructor(t="Request Aborted"){super(t,"AbortError")}},jo=class extends Error{code;constructor(t="Image Scene Data Error",r="IMAGE_SCENE_DATA_ERROR"){super(t),this.name="EncodingError",this.code=r}},Um=class extends Error{code="ELEMENT_HAS_INVALID_INDEX"}});var S6,lr,I6,W0,Gm,V0,$r,qo,Zr=X(()=>{"use strict";f();pr();Y();S6=zs.includes(devicePixelRatio)?devicePixelRatio:1,lr=()=>({showWelcomeScreen:!1,theme:ue.LIGHT,collaborators:new Map,currentChartType:"bar",currentItemBackgroundColor:pt.backgroundColor,currentItemEndArrowhead:"arrow",currentItemFillStyle:pt.fillStyle,currentItemFontFamily:gr,currentItemFontSize:ur,currentItemOpacity:pt.opacity,currentItemRoughness:pt.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:pt.strokeColor,currentItemRoundness:"round",currentItemArrowType:_t.round,currentItemStrokeStyle:pt.strokeStyle,currentItemStrokeWidth:pt.strokeWidth,currentItemTextAlign:vn,currentHoveredFontFamily:null,cursorButton:"up",activeEmbeddable:null,draggingElement:null,editingElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:"selection",customType:null,locked:pt.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:S6,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:null,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:"mouse",multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,stats:{open:!1,panels:Fi.generalStats|Fi.elementProperties},startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:Ee.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set}),I6=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemArrowType:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},currentHoveredFontFamily:{browser:!1,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},draggingElement:{browser:!1,export:!1,server:!1},editingElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},stats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1}}),W0=(e,t)=>{let r={};for(let o of Object.keys(e))if(I6[o]?.[t]){let i=e[o];r[o]=i}return r},Gm=e=>W0(e,"export"),V0=e=>W0(e,"server"),$r=({activeTool:e})=>e.type==="eraser",qo=({activeTool:e})=>e.type==="hand"});var Wh,cr,Wm,Vh,Jo,Vm,Y0,Ra,ot,X0,K0,$0,Z0,Na,j0,q0,Ln,Gt=X(()=>{"use strict";f();et();He();Ui();Wh=(e,t,r)=>{let o=r.reduce((n,i)=>(i.groupIds.includes(e)&&(n[i.id]=!0),n),{});return Object.keys(o).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...o}}},cr=function(){let e=null,t=null,r=null,o=(i,a,s,l)=>{if(r!==void 0&&a===t&&i===e&&s.editingGroupId===r?.editingGroupId)return r;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let g=u.indexOf(s.editingGroupId);g>-1&&(u=u.slice(0,g))}if(u.length>0){let g=u[u.length-1];c[g]=!0}}let d={},m=a.reduce((p,u)=>{let g=u.groupIds.find(h=>c[h]);return g&&(p[u.id]=!0,Array.isArray(d[g])?d[g].push(u.id):d[g]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return t=a,e=i,r={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Ge({...s.selectedElementIds,...m},l)},r},n=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):he(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Ge(i.selectedElementIds,s)}};return n.clearCache=()=>{t=null,e=null,r=null},n}(),Wm=(e,t)=>Vh(e,t)!=null,Vh=(e,t)=>t.groupIds.filter(r=>r!==e.editingGroupId).find(r=>e.selectedGroupIds[r]),Jo=e=>Object.entries(e.selectedGroupIds).filter(([t,r])=>r).map(([t,r])=>t),Vm=(e,t)=>{let r={...t,selectedGroupIds:{}};for(let o of e){let n=o.groupIds;if(t.editingGroupId){let i=n.indexOf(t.editingGroupId);i>-1&&(n=n.slice(0,i))}if(n.length>0){let i=n[n.length-1];r={...r,...Wh(i,r,e)}}}return r.selectedGroupIds},Y0=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),Ra=(e,t)=>e.groupIds.includes(t),ot=(e,t)=>{let r=[];for(let o of e.values())Ra(o,t)&&r.push(o);return r},X0=(e,t)=>e.groupIds.find(r=>t[r]),K0=(e,t,r)=>{let o=[...e],n=t?e.indexOf(t):-1,i=n>-1?n:e.length;for(let a=0;a<i;a++)o[a]=r(o[a]);return o},$0=(e,t,r)=>{let o=[...e],n=r?o.indexOf(r):-1,i=n>-1?n:o.length;return o.splice(i,0,t),o},Z0=(e,t)=>e.filter(r=>!t[r]),Na=(e,t)=>{let r=new Map;return e.forEach(o=>{let n=o.groupIds.length===0?o.id:o.groupIds[o.groupIds.length-1],i=r.get(n)||[],a=J(o,t);a&&i.push(a),r.set(n,[...i,o])}),Array.from(r.values())},j0=e=>{let t=new Set;for(let[,r]of e)if(!r.isDeleted)for(let o of r.groupIds??[])t.add(o);return t},q0=e=>{let t=e.flatMap(n=>n.groupIds),r=new Map,o=0;for(let n of t)r.set(n,(r.get(n)??0)+1),r.get(n)>o&&(o=r.get(n));return o===e.length},Ln=e=>e.groupIds.length>0});import{sanitizeUrl as C6}from"@braintree/sanitize-url";var Ym,Pr,Xm,Km,Oa=X(()=>{"use strict";f();Ym=e=>e.replace(/"/g,"""),Pr=e=>(e=e.trim(),e&&C6(Ym(e))),Xm=e=>!!(e?.includes(location.origin)||e?.startsWith("/")),Km=e=>{if(e=Pr(e),e.startsWith("/"))return`${location.origin}${e}`;try{new URL(e)}catch{return"about:blank"}return e}});var $m,G,$e=X(()=>{"use strict";f();$m=[],G=e=>($m=$m.concat(e),e)});import Zm from"open-color";var Q0,A6,ey,M6,k6,mo,Ze,Dn,J0,Yh,po,Gs=X(()=>{"use strict";f();Y();Zr();Q0='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',A6='<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"/>',ey='<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"/>',M6=`data:${se.svg},${encodeURIComponent(`${Q0}${ey}</svg>`)}`,k6=`data:${se.svg},${encodeURIComponent(`${Q0}${A6}${ey}</svg>`)}`,mo=e=>{e&&(e.style.cursor="")},Ze=(e,t)=>{e&&(e.style.cursor=t)},Yh=(e,t)=>{let o=()=>{let n=t===ue.DARK;Dn=document.createElement("canvas"),Dn.theme=t,Dn.height=20,Dn.width=20;let i=Dn.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Dn.width/2,Dn.height/2,5,0,2*Math.PI),i.fillStyle=n?Zm.black:Zm.white,i.fill(),i.strokeStyle=n?Zm.white:Zm.black,i.stroke(),J0=Dn.toDataURL(se.svg)};(!Dn||Dn.theme!==t)&&o(),Ze(e,`url(${J0}) ${20/2} ${20/2}, auto`)},po=(e,t)=>{if(e)if(t.activeTool.type==="selection")mo(e);else if(qo(t))e.style.cursor=Be.GRAB;else if($r(t))Yh(e,t.theme);else if(t.activeTool.type==="laser"){let r=t.theme===ue.LIGHT?M6:k6;e.style.cursor=`url(${r}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=Be.AUTO):e.style.cursor=Be.CROSSHAIR}});import{RoughGenerator as P6}from"roughjs/bin/generator";var _e,Qo=X(()=>{"use strict";f();li();Xh();pr();_e=class e{static rg=new P6;static cache=new WeakMap;static get=t=>e.cache.get(t);static set=(t,r)=>e.cache.set(t,r);static delete=t=>e.cache.delete(t);static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,r)=>{let o=r?.isExporting?void 0:e.get(t);if(o!==void 0)return o;jm.delete(t);let n=ty(t,e.rg,r||{isExporting:!1,canvasBackgroundColor:Ee.white,embedsValidationStatus:null});return e.cache.set(t,n),n}}});import jr from"react";import L6 from"open-color";import D6 from"clsx";import{Fragment as je,jsx as b,jsxs as B}from"react/jsx-runtime";var en,ry,L,j,ve,IF,qm,oy,ny,iy,Fa,Ws,ay,sy,ly,CF,cy,dy,my,py,uy,gy,hy,ci,Jm,fy,by,Kh,$h,Ey,tn,xy,Mc,kc,Pc,Qm,Ba,Vs,yy,Zh,ep,wy,vy,Ty,Lc,Sy,Iy,Ys,AF,Cy,tp,rp,Ay,MF,kF,My,PF,jh,qh,ky,Py,LF,DF,_F,RF,NF,Ly,Dy,Jh,Qh,ef,tf,rf,of,nf,af,_y,Ry,sf,lf,op,OF,FF,Ao,BF,zF,HF,cf,df,Ny,Oy,Fy,By,mf,zy,Hy,UF,Uy,Gy,Wy,Vy,Yy,Xy,Ky,$y,Zy,pf,jy,qy,Jy,Qy,ew,tw,rw,ow,nw,iw,za,aw,Xs,Dc,sw,lw,cw,dw,mw,pw,np,uw,GF,ip,uf,ap,gw,hw,WF,VF,YF,fw,bw,Ew,sp,lp,Ks,cp,$s,XF,_c,xw,Zs,yw,ww,vw,dp,Tw,Sw,Iw,mp,Cw,Aw,Mw,kw,gf,pp,Pw,Lw,Dw,_w,Rw,KF,Nw,Ow,Fw,Bw,zw,Hw,Uw,Gw,ee=X(()=>{"use strict";f();Y();en=e=>"var(--icon-fill-color)",ry=e=>e===ue.LIGHT?L6.white:"#1e1e1e",L=(e,t=512)=>{let{width:r=512,height:o=r,mirror:n,style:i,...a}=typeof t=="number"?{width:t}:t;return b("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${r} ${o}`,className:D6({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?b("path",{fill:"currentColor",d:e}):e})},j={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ve={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},IF=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:3,y:8,width:18,height:4,rx:1}),b("line",{x1:12,y1:8,x2:12,y2:21}),b("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),b("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"})]}),j),qm=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),b("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),b("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),j),oy=L(B("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),j),ny=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"1"}),b("circle",{cx:"12",cy:"19",r:"1"}),b("circle",{cx:"12",cy:"5",r:"1"})]}),j),iy=L(B("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),b("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),b("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),j),Fa=L(B("g",{children:[b("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"}),b("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"}),b("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:b("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"})}),b("g",{mask:"url(#UnlockedIcon)",children:b("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"})})]}),ve),Ws=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),b("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"})]}),ve),ay=L(B(je,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),b("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"}),sy=L(B(je,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),b("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"}),ly=L(B(je,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),b("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"}),CF=L(b("g",{fill:"currentColor",children:b("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"}),cy=L(B("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),dy=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),j),my=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"})]}),j),py=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"})]}),j),uy=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),j),gy=L(b("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ve),hy=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),b("path",{d:"M16 7h4"}),b("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),j),ci=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"m11.25 5.417 3.333 3.333"})]}),ve),Jm=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),b("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),b("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),b("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),b("polyline",{points:"5 20 11 4 13 4 20 20"})]}),j),fy=L(B("g",{strokeWidth:"1.25",children:[b("path",{d:"M12.5 6.667h.01"}),b("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"}),b("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),b("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ve),by=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M18 13.3l-6.3 -6.3"})]}),j),Kh=L(b("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ve),$h=L(b("path",{d:"M5 10h10",strokeWidth:"1.25"}),ve),Ey=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 21l-6 -6"}),b("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"}),b("path",{d:"M3 4v4h4"})]}),j),tn=L(b("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"}),ve),xy=L(B("g",{strokeWidth:"1.25",children:[b("polyline",{points:"12 16 18 10 12 4"}),b("polyline",{points:"8 4 2 10 8 16"})]}),ve),Mc=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),ve),kc=L(b("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"}),ve),Pc=L(b("g",{stroke:"currentColor",strokeLinejoin:"round",children:b("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"})}),{...ve,strokeWidth:1.5}),Qm=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),b("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),j),Ba=L(b("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"}),ve),Vs=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),j),yy=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),j),Zh=L(b("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"}),ve),ep=L(b("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"}),ve),wy=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),ve),vy=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),b("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),j),Ty=L(b("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Lc=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),ve),Sy=L("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),Iy=L("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Ys=L(b("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"}),ve),AF=L("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),Cy=L("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),tp=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),b("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),b("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),j),rp=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 8h.01"}),b("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),b("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),b("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),b("path",{d:"M19 16v6"}),b("path",{d:"M22 19l-3 3l-3 -3"})]}),j),Ay=L("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),MF=L("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),kF=L("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),My=L("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),PF=L("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),jh=L(b("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"}),ve),qh=L(b("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"}),ve),ky=L("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),Py=L(b("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"}),ve),LF=L("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),DF=L("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),_F=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 14v-11"}),b("path",{d:"M9 6l3 -3l3 3"})]}),j),RF=L(B(je,{children:[b("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"}),b("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}),NF=L(b("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}),Ly=B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 10l0 10"}),b("path",{d:"M12 10l4 4"}),b("path",{d:"M12 10l-4 4"}),b("path",{d:"M4 4l16 0"})]}),Dy=B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 5l0 14"}),b("path",{d:"M16 9l-4 -4"}),b("path",{d:"M8 9l4 -4"})]}),Jh=L(Dy,j),Qh=L(Dy,{...j,style:{transform:"rotate(180deg)"}}),ef=L(Ly,j),tf=L(Ly,{...j,style:{transform:"rotate(180deg)"}}),rf=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),of=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),nf=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),af=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),_y=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),Ry=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),sf=L(B("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),b("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),ve),lf=L(B("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),b("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),ve),op=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"9",cy:"7",r:"4"}),b("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),b("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),b("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),j),OF=L("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),FF=L("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Ao=L(B(je,{children:[b("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"M15 5 5 15M5 5l10 10"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),BF=L("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),zF=L("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),HF=L("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),cf=jr.memo(({theme:e})=>L(B(je,{children:[b("path",{d:"M25 26H111V111H25",fill:en(e)}),b("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:en(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:en(e)}),b("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:en(e),strokeWidth:"2"}),B("g",{fill:ry(e),stroke:en(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),df=jr.memo(({theme:e})=>L(B(je,{children:[b("path",{d:"M25 26H111V111H25",fill:en(e)}),b("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:en(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:en(e)}),b("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:en(e),strokeWidth:"2"}),B("g",{fill:ry(e),stroke:en(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),b("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Ny=L(b("g",{strokeWidth:1.25,children:b("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"})}),ve),Oy=L(B(je,{children:[b("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"}),b("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:b("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"})}),b("g",{mask:"url(#FillHachureIcon)",children:b("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"})})]}),ve),Fy=L(B(je,{children:[B("g",{clipPath:"url(#a)",children:[b("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"}),b("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:b("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"})}),b("g",{mask:"url(#FillCrossHatchIcon)",children:b("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"})})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),By=L(B(je,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ve,fill:"currentColor"}),mf=L(b(je,{children:b("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ve),zy=L(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ve),Hy=L(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ve),UF=jr.memo(({theme:e})=>L(b("path",{d:"M6 10H34",stroke:en(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Uy=L(B("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12h2"}),b("path",{d:"M17 12h2"}),b("path",{d:"M11 12h2"})]}),j),Gy=L(B("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M8 12v.01"}),b("path",{d:"M12 12v.01"}),b("path",{d:"M16 12v.01"}),b("path",{d:"M20 12v.01"})]}),j),Wy=L(b("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"}),ve),Vy=L(b("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"}),ve),Yy=L(b("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"}),ve),Xy=L(B("svg",{strokeWidth:"1.5",children:[b("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"}),b("path",{d:"M13.3333 3.33331V3.34331"}),b("path",{d:"M16.6667 3.33331V3.34331"}),b("path",{d:"M16.6667 6.66669V6.67669"}),b("path",{d:"M16.6667 10V10.01"}),b("path",{d:"M3.33334 13.3333V13.3433"}),b("path",{d:"M16.6667 13.3333V13.3433"}),b("path",{d:"M3.33334 16.6667V16.6767"}),b("path",{d:"M6.66666 16.6667V16.6767"}),b("path",{d:"M10 16.6667V16.6767"}),b("path",{d:"M13.3333 16.6667V16.6767"}),b("path",{d:"M16.6667 16.6667V16.6767"})]}),ve),Ky=L(B("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),b("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),b("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),b("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),b("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),b("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),b("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),b("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),b("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),b("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),b("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),b("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),j),$y=L(b("path",{d:"M6 10H34",stroke:"currentColor",strokeWidth:2,fill:"none"}),{width:40,height:20}),Zy=jr.memo(({flip:e=!1})=>L(B("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[b("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),b("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),pf=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[b("path",{d:"M32 10L6 10",strokeWidth:2}),b("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),jy=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[b("path",{d:"M26 10L6 10"}),b("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),qy=jr.memo(({flip:e=!1})=>L(b("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:b("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),Jy=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[b("path",{d:"M32 10L6 10",strokeWidth:2}),b("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Qy=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[b("path",{d:"M6,9.5H27"}),b("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),ew=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M6,9.5H20"}),b("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),tw=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M6,9.5H20"}),b("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),rw=L(B(je,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),ow=L(B(je,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),nw=L(B(je,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),iw=L(b(je,{children:b("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"})}),ve),za=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 7v-2h13v2"}),b("path",{d:"M10 5v14"}),b("path",{d:"M12 19h-4"}),b("path",{d:"M15 13v-1h6v1"}),b("path",{d:"M18 12v7"}),b("path",{d:"M17 19h2"})]}),j),aw=L(b(je,{children:B("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 12h10"}),b("path",{d:"M7 5v14"}),b("path",{d:"M17 5v14"}),b("path",{d:"M15 19h4"}),b("path",{d:"M15 5h4"}),b("path",{d:"M5 19h4"}),b("path",{d:"M5 5h4"})]})}),j),Xs=L(b(je,{children:b("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("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"})})}),ve),Dc=L(B(je,{children:[b("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),sw=L(B("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),b("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),j),lw=L(B("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),b("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),j),cw=L(B("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),j),dw=jr.memo(({theme:e})=>L(B("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),b("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),j)),mw=jr.memo(({theme:e})=>L(B("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),b("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),j)),pw=jr.memo(({theme:e})=>L(B("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),b("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),b("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),j)),np=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 19h-18l9 -15"}),b("path",{d:"M20.615 15.171h.015"}),b("path",{d:"M19.515 11.771h.015"}),b("path",{d:"M17.715 8.671h.015"}),b("path",{d:"M15.415 5.971h.015"})]}),j),uw=L(b("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}),GF=L(b("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"})),ip=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),b("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),b("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),b("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"})]}),j),uf=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),b("path",{d:"M7 11l5 5l5 -5"}),b("path",{d:"M12 4l0 12"})]}),j),ap=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),j),gw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M9.15 14.85l8.85 -10.85"}),b("path",{d:"M6 4l8.85 10.85"})]}),j),hw=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),b("path",{d:"M12 17l0 .01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),j),WF=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 4v16l13 -8z"})]}),j),VF=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"})]}),j),YF=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12l5 5l10 -10"})]}),j),fw=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 9v4"}),b("path",{d:"M12 17h.01"})]}),j),bw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11 7l6 6"}),b("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),j),Ew=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l-4 7h8z"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),j),sp=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 7l16 0"}),b("path",{d:"M4 17l16 0"}),b("path",{d:"M7 4l0 16"}),b("path",{d:"M17 4l0 16"})]}),j),lp=L(b("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),Ks=L(B("g",{strokeWidth:"1.25",children:[b("path",{d:"M4.16602 10H15.8327"}),b("path",{d:"M12.5 13.3333L15.8333 10"}),b("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ve),cp=L(B("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[b("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"}),b("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),$s=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("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"})]}),j),XF=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("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"})]}),j),_c=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),b("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),b("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"}),b("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),b("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),b("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"})]}),j),xw=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),b("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),b("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),b("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),j),Zs=L(B("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),b("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"})]}),j),yw=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),b("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"}),b("path",{d:"M3 3l18 18"})]}),j),ww=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),j),vw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),j),dp=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),b("path",{d:"M21 21l-6 -6"})]}),j),Tw=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),b("path",{d:"M12 7v5l3 3"}),b("path",{d:"M19 16l-2 3h4l-2 3"})]}),j),Sw=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 14 0"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),j),Iw=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 3l18 18"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),j),mp=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),j),Cw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 20v.01"}),b("path",{d:"M16 20v.01"}),b("path",{d:"M8 20v.01"}),b("path",{d:"M4 20v.01"}),b("path",{d:"M4 16v.01"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M4 8v.01"}),b("path",{d:"M4 4v.01"}),b("path",{d:"M8 4v.01"}),b("path",{d:"M12 4v.01"}),b("path",{d:"M16 4v.01"}),b("path",{d:"M20 4v.01"}),b("path",{d:"M20 8v.01"}),b("path",{d:"M20 12v.01"}),b("path",{d:"M20 16v.01"}),b("path",{d:"M20 20v.01"})]}),j),Aw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 3v18"}),b("path",{d:"M19 21v-18"}),b("path",{d:"M5 7h14"}),b("path",{d:"M5 15h14"}),b("path",{d:"M8 13v4"}),b("path",{d:"M11 13v4"}),b("path",{d:"M16 13v4"}),b("path",{d:"M14 5v4"}),b("path",{d:"M11 5v4"}),b("path",{d:"M8 5v4"}),b("path",{d:"M3 21h18"})]}),j),Mw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 12l18 0"}),b("path",{d:"M7 16l10 0l-10 5l0 -5"}),b("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),j),kw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l0 18"}),b("path",{d:"M16 7l0 10l5 0l-5 -10"}),b("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),j),gf=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),b("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"})]}),j),pp=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),b("path",{d:"M22 22l-3 -3"}),b("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),b("path",{d:"M3 11v-1"}),b("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),b("path",{d:"M10 3h1"}),b("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),j),Pw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("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"}),b("path",{d:"M10 15l2 6l2 -6"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),j),Lw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),b("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),b("path",{d:"M11 21v-6l3 6v-6"})]}),j),Dw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M4 8l5 0"}),b("path",{d:"M15 8l4 0"})]}),j),_w=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),b("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),j),Rw=L(B("g",{stroke:"currentColor",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"})]}),{...j,strokeWidth:1.5}),KF=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M21 12h-13l3 -3"}),b("path",{d:"M11 15l-3 -3"})]}),j),Nw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M10 9l5 3l-5 3z"})]}),j),Ow=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 6h18"}),b("path",{d:"M3 12h18"}),b("path",{d:"M3 18h18"}),b("path",{d:"M6 3v18"}),b("path",{d:"M12 3v18"}),b("path",{d:"M18 3v18"})]}),j),Fw=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),j),Bw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 18l12 -12"}),b("path",{d:"M18 10v-4h-4"})]}),j),zw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),b("path",{d:"M18 4l3 3l-3 3"})]}),j),Hw=L(B("g",{children:[b("path",{d:"M16,12L20,9L16,6"}),b("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),j),Uw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 9l6 6l6 -6"})]}),j),Gw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 15l6 -6l6 6"})]}),j)});var rn,Gi,up,hf=X(()=>{"use strict";f();ee();Y();rn={[Le.Excalifont]:{metrics:{unitsPerEm:1e3,ascender:886,descender:-374,lineHeight:1.25},icon:ci},[Le.Nunito]:{metrics:{unitsPerEm:1e3,ascender:1011,descender:-353,lineHeight:1.35},icon:Xs},[Le["Lilita One"]]:{metrics:{unitsPerEm:1e3,ascender:923,descender:-220,lineHeight:1.15},icon:aw},[Le["Comic Shanns"]]:{metrics:{unitsPerEm:1e3,ascender:750,descender:-250,lineHeight:1.25},icon:Dc},[Le.Virgil]:{metrics:{unitsPerEm:1e3,ascender:886,descender:-374,lineHeight:1.25},icon:ci,deprecated:!0},[Le.Helvetica]:{metrics:{unitsPerEm:2048,ascender:1577,descender:-471,lineHeight:1.15},icon:Xs,deprecated:!0,local:!0},[Le.Cascadia]:{metrics:{unitsPerEm:2048,ascender:1900,descender:-480,lineHeight:1.2},icon:Dc,deprecated:!0},[Le["Liberation Sans"]]:{metrics:{unitsPerEm:2048,ascender:1854,descender:-434,lineHeight:1.15},icon:Xs,serverSide:!0}},Gi={LATIN:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD",LATIN_EXT:"U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF",CYRILIC_EXT:"U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F",CYRILIC:"U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116",VIETNAMESE:"U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB"},up="local:"});import{fileOpen as _6,fileSave as R6,supported as Wi}from"browser-fs-access";var Ww,js,qs,di=X(()=>{"use strict";f();Y();Hi();V();Ww=500,js=e=>{let t=e.extensions?.reduce((o,n)=>(o.push(se[n]),o),[]),r=e.extensions?.reduce((o,n)=>n==="jpg"?o.concat(".jpg",".jpeg"):o.concat(`.${n}`),[]);return _6({description:e.description,extensions:r,mimeTypes:t,multiple:e.multiple??!1,legacySetup:(o,n,i)=>{let a=ii(n,Ww),s=()=>{l(),document.addEventListener("keyup",a),document.addEventListener("pointerup",a),a()},l=()=>{if(i.files?.length){let d=e.multiple?[...i.files]:i.files[0];o(d)}};requestAnimationFrame(()=>{window.addEventListener("focus",s)});let c=window.setInterval(()=>{l()},Ww);return d=>{clearInterval(c),a.cancel(),window.removeEventListener("focus",s),document.removeEventListener("keyup",a),document.removeEventListener("pointerup",a),d&&(console.warn("Opening the file was canceled (legacy-fs)."),d(new Pn))}}})},qs=(e,t)=>R6(e,{fileName:`${t.name}.${t.extension}`,description:t.description,extensions:[`.${t.extension}`]},t.fileHandle)});var N6,Vi,gp,ff,Vw,bf,hp,Yw,mi=X(()=>{"use strict";f();di();Zr();Y();we();qr();N6=(e,t)=>{let r={};for(let o of e)!o.isDeleted&&"fileId"in o&&o.fileId&&t[o.fileId]&&(r[o.fileId]=t[o.fileId]);return r},Vi=(e,t,r,o)=>{let n={type:hr.excalidraw,version:Da.excalidraw,source:yc,elements:o==="local"?fp(e):Xw(e),appState:o==="local"?Gm(t):V0(t),files:o==="local"?N6(e,r):void 0};return JSON.stringify(n,null,2)},gp=async(e,t,r,o=t.name||Lm)=>{let n=Vi(e,t,r,"local"),i=new Blob([n],{type:se.excalidraw});return{fileHandle:await qs(i,{name:o,extension:"excalidraw",description:"Excalidraw file",fileHandle:Js(t.fileHandle)?null:t.fileHandle})}},ff=async(e,t)=>{let r=await js({description:"Excalidraw files"});return Qs(await Rc(r),e,t,r.handle)},Vw=e=>e?.type===hr.excalidraw&&(!e.elements||Array.isArray(e.elements)&&(!e.appState||typeof e.appState=="object")),bf=e=>typeof e=="object"&&e&&e.type===hr.excalidrawLibrary&&(e.version===1||e.version===2),hp=e=>{let t={type:hr.excalidrawLibrary,version:Da.excalidrawLibrary,source:yc,libraryItems:e};return JSON.stringify(t,null,2)},Yw=async e=>{let t=hp(e);await qs(new Blob([t],{type:se.excalidrawlib}),{name:"library",extension:"excalidrawlib",description:"Excalidraw library file"})}});var pi,Yi,Ha=X(()=>{"use strict";f();pi=e=>{let t=e.map(o=>o[0]),r=e.map(o=>o[1]);return{width:Math.max(...t)-Math.min(...t),height:Math.max(...r)-Math.min(...r)}},Yi=(e,t,r,o)=>{let n=r.map(u=>u[e]),i=Math.max(...n),a=Math.min(...n),s=i-a,l=s===0?1:t/s,c=1/0,d=r.map(u=>{let g=u[e]*l,h=[...u];return h[e]=g,g<c&&(c=g),h});if(!o||d.length===2)return d;let m=a-c;return d.map(u=>u.map((g,h)=>h===e?g+m:g))}});var O6,F6,bp,Ua,B6,z6,H6,U6,Nc,G6,Kw,Zw,Xi,$w,Ga,el=X(()=>{"use strict";f();we();me();Zo();Y();Zr();Wt();De();V();V();He();Oa();ko();Ha();on();O6={selection:!0,text:!0,rectangle:!0,diamond:!0,ellipse:!0,line:!0,image:!0,arrow:!0,freedraw:!0,eraser:!1,custom:!0,frame:!0,embeddable:!0,hand:!0,laser:!1,magicframe:!1},F6=e=>Object.keys(Le).includes(e)?Le[e]:gr,bp=(e,t)=>t?{...t,focus:t.focus||0,fixedPoint:de(e)?t.fixedPoint??[0,0]:null}:null,Ua=(e,t)=>{let r={type:t.type||e.type,version:e.version||1,versionNonce:e.versionNonce??0,index:e.index??null,isDeleted:e.isDeleted??!1,id:e.id||Ut(),fillStyle:e.fillStyle||pt.fillStyle,strokeWidth:e.strokeWidth||pt.strokeWidth,strokeStyle:e.strokeStyle??pt.strokeStyle,roughness:e.roughness??pt.roughness,opacity:e.opacity==null?pt.opacity:e.opacity,angle:e.angle||0,x:t.x??e.x??0,y:t.y??e.y??0,strokeColor:e.strokeColor||pt.strokeColor,backgroundColor:e.backgroundColor||pt.backgroundColor,width:e.width||0,height:e.height||0,seed:e.seed??1,groupIds:e.groupIds??[],frameId:e.frameId??null,roundness:e.roundness?e.roundness:e.strokeSharpness==="round"?{type:kn(e.type)?ct.LEGACY:ct.PROPORTIONAL_RADIUS}:null,boundElements:e.boundElementIds?e.boundElementIds.map(o=>({type:"arrow",id:o})):e.boundElements??[],updated:e.updated??si(),link:e.link?Pr(e.link):null,locked:e.locked??!1};return("customData"in e||"customData"in t)&&(r.customData="customData"in t?t.customData:e.customData),{...r,...Fc(r),...t}},B6=e=>{switch(e.type){case"text":let t=e.fontSize,r=e.fontFamily;if("font"in e){let[d,m]=e.font.split(" ");t=parseFloat(d),r=F6(m)}let o=typeof e.text=="string"&&e.text||"",n=e.lineHeight||(e.height?jw(e):uo(e.fontFamily));return e=Ua(e,{fontSize:t,fontFamily:r,text:o,textAlign:e.textAlign||vn,verticalAlign:e.verticalAlign||Pa,containerId:e.containerId??null,originalText:e.originalText||o,autoResize:e.autoResize??!0,lineHeight:n}),!o&&!e.isDeleted&&(e={...e,originalText:o,isDeleted:!0},e=Ki(e)),e;case"freedraw":return Ua(e,{points:e.points,lastCommittedPoint:null,simulatePressure:e.simulatePressure,pressures:e.pressures});case"image":return Ua(e,{status:e.status||"pending",fileId:e.fileId,scale:e.scale||[1,1]});case"line":case"draw":let{startArrowhead:i=null,endArrowhead:a=null}=e,s=e.x,l=e.y,c=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(c[0][0]!==0||c[0][1]!==0)&&({points:c,x:s,y:l}=K.getNormalizedPoints(e)),Ua(e,{type:e.type==="draw"?"line":e.type,startBinding:bp(e,e.startBinding),endBinding:bp(e,e.endBinding),lastCommittedPoint:null,startArrowhead:i,endArrowhead:a,points:c,x:s,y:l,...pi(c)});case"arrow":{let{startArrowhead:d=null,endArrowhead:m="arrow"}=e,p=e.x,u=e.y,g=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(g[0][0]!==0||g[0][1]!==0)&&({points:g,x:p,y:u}=K.getNormalizedPoints(e)),Ua(e,{type:e.type,startBinding:bp(e,e.startBinding),endBinding:bp(e,e.endBinding),lastCommittedPoint:null,startArrowhead:d,endArrowhead:m,points:g,x:p,y:u,elbowed:e.elbowed,...pi(g)})}case"ellipse":case"rectangle":case"diamond":case"iframe":case"embeddable":return Ua(e,{});case"magicframe":case"frame":return Ua(e,{name:e.name??null})}return null},z6=(e,t)=>{if(e.boundElements){let r=e.boundElements.slice(),o=new Set;e.boundElements=r.reduce((n,i)=>{let a=t.get(i.id);if(a&&!o.has(i.id)){if(o.add(i.id),a.isDeleted)return n;n.push(i),H(a)&&!a.containerId&&(a.containerId=e.id)}return n},[])}},H6=(e,t)=>{let r=e.containerId?t.get(e.containerId):null;if(!r){e.containerId=null;return}if(!e.isDeleted&&r.boundElements&&!r.boundElements.find(o=>o.id===e.id)){let o=(r.boundElements||(r.boundElements=[])).slice();o.push({type:"text",id:e.id}),r.boundElements=o}},U6=(e,t)=>{e.frameId&&(t.get(e.frameId)||(e.frameId=null))},Nc=(e,t,r)=>{let o=new Set,n=t?Z(t):null,i=fr((e||[]).reduce((s,l)=>{if(l.type!=="selection"&&!Po(l)){let c=B6(l);if(c){let d=n?.get(l.id);d&&d.version>c.version&&(c=Ki(c,d.version)),o.has(c.id)&&(c={...c,id:Ut()}),o.add(c.id),s.push(c)}}return s},[]));if(!r?.repairBindings)return i;let a=Z(i);for(let s of i)s.frameId&&U6(s,a),H(s)&&s.containerId?H6(s,a):s.boundElements&&z6(s,a),r.refreshDimensions&&H(s)&&Object.assign(s,Oc(s,Et(s,a),a)),ie(s)&&(s.startBinding&&(!a.has(s.startBinding.elementId)||!ne(s))&&(s.startBinding=null),s.endBinding&&(!a.has(s.endBinding.elementId)||!ne(s))&&(s.endBinding=null));return i},G6=(e,t,r)=>{let o=t[e];return o!==void 0?o:r[e]},Kw={isSidebarDocked:(e,t)=>["defaultSidebarDockedPreference",e.isSidebarDocked??G6("defaultSidebarDockedPreference",e,t)]},Zw=(e,t)=>{e=e||{};let r=lr(),o={};for(let n of Object.keys(Kw))if(n in e){let[i,a]=Kw[n](e,r);o[i]=a}for(let[n,i]of Object.entries(r)){let a=e[n],s=t?t[n]:void 0;o[n]=a!==void 0?a:s!==void 0?s:i}return{...o,cursorButton:t?.cursorButton||"up",penDetected:t?.penDetected??(e.penMode?e.penDetected??!1:!1),activeTool:{...nt(r,o.activeTool.type&&O6[o.activeTool.type]?o.activeTool:{type:"selection"}),lastActiveTool:null,locked:o.activeTool.locked??!1},zoom:typeof e.zoom=="number"?{value:e.zoom}:e.zoom?.value?e.zoom:r.zoom,openSidebar:typeof e.openSidebar=="string"?{name:co.name}:o.openSidebar}},Xi=(e,t,r,o)=>({elements:Nc(e?.elements,r,o),appState:Zw(e?.appState,t||null),files:e?.files||{}}),$w=e=>{let t=Nc(Ae(e.elements),null);return t.length?{...e,elements:t}:null},Ga=(e=[],t)=>{let r=[];for(let o of e)if(Array.isArray(o)){let n=$w({status:t,elements:o,id:Ut(),created:Date.now()});n&&r.push(n)}else{let n=o,i=$w({...n,id:n.id||Ut(),status:n.status||t,created:n.created||Date.now()});i&&r.push(i)}return r}});var Bc={};Ch(Bc,{decodePngMetadata:()=>V6,decodeSvgMetadata:()=>X6,encodePngMetadata:()=>Ef,encodeSvgMetadata:()=>Y6,getTEXtChunk:()=>Qw});import qw from"png-chunks-extract";import Jw from"png-chunk-text";import W6 from"png-chunks-encode";var Qw,Ef,V6,Y6,X6,tl=X(()=>{"use strict";f();wf();Y();qr();Qw=async e=>{let r=qw(new Uint8Array(await ui(e))).find(o=>o.name==="tEXt");return r?Jw.decode(r.data):null},Ef=async({blob:e,metadata:t})=>{let r=qw(new Uint8Array(await ui(e))),o=Jw.encode(se.excalidraw,JSON.stringify(await xf({text:t,compress:!0})));return r.splice(-1,0,o),new Blob([W6(r)],{type:se.png})},V6=async e=>{let t=await Qw(e);if(t?.keyword===se.excalidraw)try{let r=JSON.parse(t.text);if(!("encoded"in r)){if("type"in r&&r.type===hr.excalidraw)return t.text;throw new Error("FAILED")}return await yf(r)}catch(r){throw console.error(r),new Error("FAILED")}throw new Error("INVALID")},Y6=async({text:e})=>{let t=await Ep(JSON.stringify(await xf({text:e})),!0),r="";return r+=`<!-- payload-type:${se.excalidraw} -->`,r+="<!-- payload-version:2 -->",r+="<!-- payload-start -->",r+=t,r+="<!-- payload-end -->",r},X6=async({svg:e})=>{if(e.includes(`payload-type:${se.excalidraw}`)){let t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw new Error("INVALID");let n=(e.match(/<!-- payload-version:(\d+) -->/)?.[1]||"1")!=="1";try{let i=await e2(t[1],n),a=JSON.parse(i);if(!("encoded"in a)){if("type"in a&&a.type===hr.excalidraw)return i;throw new Error("FAILED")}return await yf(a)}catch(i){throw console.error(i),new Error("FAILED")}}throw new Error("INVALID")}});import{nanoid as K6}from"nanoid";var r2,vf,o2,Js,$i,yp,Qs,Tf,Sf,gi,n2,wp,i2,zc,If,a2,s2,$6,t2,xp,Rc,ui,qr=X(()=>{"use strict";f();Zr();Y();we();Hi();et();V();di();mi();el();r2=async e=>{let t;if(e.type===se.png)try{return await(await Promise.resolve().then(()=>(tl(),Bc))).decodePngMetadata(e)}catch(r){throw r.message==="INVALID"?new jo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new jo("Error: cannot restore image")}else if("text"in Blob?t=await e.text():t=await new Promise(r=>{let o=new FileReader;o.readAsText(e,"utf8"),o.onloadend=()=>{o.readyState===FileReader.DONE&&r(o.result)}}),e.type===se.svg)try{return await(await Promise.resolve().then(()=>(tl(),Bc))).decodeSvgMetadata({svg:t})}catch(r){throw r.message==="INVALID"?new jo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new jo("Error: cannot restore image")}return t},vf=e=>e&&e.name.match(/\.(json|excalidraw|png|svg)$/)?.[1]||null,o2=e=>e==="png"||e==="svg",Js=e=>{let t=vf(e);return t==="png"||t==="svg"},$i=e=>{let{type:t}=e||{};return!!t&&Object.values(xc).includes(t)},yp=async(e,t,r,o)=>{let n=await r2(e),i;try{try{i=JSON.parse(n)}catch(a){throw $i(e)?new jo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):a}if(Vw(i))return{type:se.excalidraw,data:Xi({elements:fp(i.elements||[]),appState:{theme:t?.theme,fileHandle:o||e.handle||null,...Gm(i.appState||{}),...t?_n(i.elements||[],t):{}},files:i.files},t,r,{repairBindings:!0,refreshDimensions:!1})};if(bf(i))return{type:se.excalidrawlib,data:i};throw new Error("Error: invalid file")}catch(a){throw a instanceof jo?a:new Error("Error: invalid file")}},Qs=async(e,t,r,o)=>{let n=await yp(e,t,r,o);if(n.type!==se.excalidraw)throw new Error("Error: invalid file");return n.data},Tf=(e,t="unpublished")=>{let r=JSON.parse(e);if(!bf(r))throw new Error("Invalid library");let o=r.libraryItems||r.library;return Ga(o,t)},Sf=async(e,t="unpublished")=>Tf(await r2(e),t),gi=async e=>new Promise(async(t,r)=>{try{Cn(e)&&(e=await e),e.toBlob(o=>{if(!o)return r(new Hm("Error: Canvas too big","CANVAS_POSSIBLY_TOO_BIG"));t(o)})}catch(o){r(o)}}),n2=async e=>{try{let t=await window.crypto.subtle.digest("SHA-1",await ui(e));return P0(new Uint8Array(t))}catch(t){return console.error(t),K6(40)}},wp=async e=>new Promise((t,r)=>{let o=new FileReader;o.onload=()=>{let n=o.result;t(n)},o.onerror=n=>r(n),o.readAsDataURL(e)}),i2=(e,t="")=>{let r=e.indexOf(","),o=atob(e.slice(r+1)),n=e.slice(0,r).split(":")[1].split(";")[0],i=new ArrayBuffer(o.length),a=new Uint8Array(i);for(let s=0;s<o.length;s++)a[s]=o.charCodeAt(s);return new File([i],t,{type:n})},zc=async(e,t)=>{if(e.type===se.svg)return e;let[r,o]=await Promise.all([import("pica").then(i=>i.default),import("image-blob-reduce").then(i=>i.default)]),n=o({pica:r({features:["js","wasm"]})});if(t.outputType){let{outputType:i}=t;n._create_blob=function(a){return this.pica.toBlob(a.out_canvas,i,.8).then(s=>(a.out_blob=s,a))}}if(!$i(e))throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"});return new File([await n.toBlob(e,{max:t.maxWidthOrHeight})],e.name,{type:t.outputType||e.type})},If=(e,t="")=>new File([new TextEncoder().encode(e)],t,{type:se.svg}),a2=async(e,t="")=>{let r;try{r=await fetch(e)}catch{throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"})}if(!r.ok)throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"});let o=await r.blob();if(o.type&&$i(o)){let n=t||o.name||"";return new File([o],n,{type:o.type})}throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"})},s2=async e=>{let t=e.dataTransfer.files.item(0),r=await $6(e);return{file:t?await Rc(t):null,fileHandle:r}},$6=async e=>{if(Wi)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(t){return console.warn(t.name,t.message),null}return null},t2=e=>{let t=null,r=`${[...new Uint8Array(e).slice(0,8)].join(" ")} `,o={png:"137 80 78 71 13 10 26 10 ",jpg:"255 216 255 ",gif:"71 73 70 56 57 97 "};return r===o.png?t=se.png:r.startsWith(o.jpg)?t=se.jpg:r.startsWith(o.gif)&&(t=se.gif),t},xp=(e,t,r)=>new File([e],r||"",{type:t}),Rc=async e=>{if(e.type){if($i(e)){let t=await ui(e),r=t2(t);r&&r!==e.type&&(e=xp(t,r,e.name))}}else if(e?.name?.endsWith(".excalidrawlib"))e=xp(await ui(e),se.excalidrawlib,e.name);else if(e?.name?.endsWith(".excalidraw"))e=xp(await ui(e),se.excalidraw,e.name);else{let t=await ui(e),r=t2(t);r&&(e=xp(t,r,e.name))}return e},ui=e=>"arrayBuffer"in e?e.arrayBuffer():new Promise((t,r)=>{let o=new FileReader;o.onload=n=>{if(!n.target?.result)return r(new Error("Couldn't convert blob to ArrayBuffer"));t(n.target.result)},o.readAsArrayBuffer(e)})});var l2=X(()=>{"use strict";f();Y();qr()});import{deflate as Z6,inflate as j6}from"pako";var Hc,c2,d2,Ep,e2,xf,yf,wf=X(()=>{"use strict";f();l2();Hc=e=>new Promise((t,r)=>{let o=typeof e=="string"?new Blob([new TextEncoder().encode(e)]):new Blob([e instanceof Uint8Array?e:new Uint8Array(e)]),n=new FileReader;n.onload=i=>{if(!i.target||typeof i.target.result!="string")return r(new Error("couldn't convert to byte string"));t(i.target.result)},n.readAsBinaryString(o)}),c2=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let o=0,n=e.length;o<n;o++)r[o]=e.charCodeAt(o);return t},d2=e=>new TextDecoder("utf-8").decode(c2(e)),Ep=async(e,t=!1)=>t?window.btoa(e):window.btoa(await Hc(e)),e2=async(e,t=!1)=>t?window.atob(e):d2(window.atob(e)),xf=async({text:e,compress:t})=>{let r;if(t!==!1)try{r=await Hc(Z6(e))}catch(o){console.error("encode: cannot deflate",o)}return{version:"1",encoding:"bstring",compressed:!!r,encoded:r||await Hc(e)}},yf=async e=>{let t;switch(e.encoding){case"bstring":t=e.compressed?e.encoded:await d2(e.encoded);break;default:throw new Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?j6(new Uint8Array(c2(t)),{to:"string"}):t}});var q6,vp,m2=X(()=>{"use strict";f();wf();hf();q6=`https://unpkg.com/${T.VITE_PKG_NAME?`${T.VITE_PKG_NAME}@${T.PKG_VERSION}`:"@excalidraw/excalidraw"}/dist/prod/`,vp=class e{urls;fontFace;constructor(t,r,o){this.urls=e.createUrls(r);let n=this.urls.map(i=>`url(${i}) ${e.getFormat(i)}`).join(", ");this.fontFace=new FontFace(t,n,{display:"swap",style:"normal",weight:"400",...o})}async getContent(){let t=0,r=[];for(;t<this.urls.length;){let o=this.urls[t];if(o.protocol==="data:")return o.toString();try{let n=await fetch(o,{headers:{Accept:"font/woff2"}});if(n.ok){let i=await n.headers.get("Content-Type"),a=await n.arrayBuffer();return`data:${i};base64,${await Ep(await Hc(a),!0)}`}r.push(`"${o.toString()}" returned status "${n.status}"`)}catch(n){r.push(`"${o.toString()}" returned error "${n}"`)}t++}return console.error(`Failed to fetch font "${this.fontFace.family}" from urls "${this.urls.toString()}`,JSON.stringify(r,void 0,2)),this.urls.length?this.urls[this.urls.length-1].toString():""}static createUrls(t){if(t.startsWith(up))return[];if(t.startsWith("http")||t.startsWith("data"))return[new URL(t)];let r=t.replace(/^\/+/,""),o=[];if(typeof window.EXCALIDRAW_ASSET_PATH=="string"){let n=this.normalizeBaseUrl(window.EXCALIDRAW_ASSET_PATH);o.push(new URL(r,n))}else Array.isArray(window.EXCALIDRAW_ASSET_PATH)&&window.EXCALIDRAW_ASSET_PATH.forEach(n=>{let i=this.normalizeBaseUrl(n);o.push(new URL(r,i))});return o.push(new URL(r,q6)),o}static getFormat(t){try{let o=new URL(t).pathname.split(".");return o.length===1?"":`format('${o.pop()}')`}catch{return""}}static normalizeBaseUrl(t){let r=t;return/^\.?\//.test(r)&&(r=new URL(r.replace(/^\.?\/+/,""),window?.location?.origin).toString()),r=`${r.replace(/\/+$/,"")}/`,r}}});var u2,p2=X(()=>{u2="./Virgil-Regular-YHAB2VGJ.woff2"});var h2,g2=X(()=>{h2="./Excalifont-Regular-CPKEUDVM.woff2"});var b2,f2=X(()=>{b2="./CascadiaCode-Regular-TMZI7IJ5.woff2"});var x2,E2=X(()=>{x2="./ComicShanns-Regular-6TOETDFT.woff2"});var w2,y2=X(()=>{w2="./LiberationSans-Regular-ZQD73GJM.woff2"});var T2,v2=X(()=>{T2="https://fonts.gstatic.com/s/lilitaone/v15/i7dPIFZ9Zz-WBtRtedDbYEF8RXi4EwQ.woff2"});var I2,S2=X(()=>{I2="https://fonts.gstatic.com/s/lilitaone/v15/i7dPIFZ9Zz-WBtRtedDbYE98RXi4EwSsbg.woff2"});var A2,C2=X(()=>{A2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTQ3j6zbXWjgeg.woff2"});var k2,M2=X(()=>{k2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTo3j6zbXWjgevT5.woff2"});var L2,P2=X(()=>{L2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTA3j6zbXWjgevT5.woff2"});var _2,D2=X(()=>{_2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTk3j6zbXWjgevT5.woff2"});var N2,R2=X(()=>{N2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTs3j6zbXWjgevT5.woff2"});function d4(e,t,...r){let o=Le[e];return this.registered.get(o)||this.registered.set(o,{metadata:t,fonts:r.map(({uri:i,descriptors:a})=>new vp(e,i,a))}),this.registered}var Lr,Tp,uo,on=X(()=>{"use strict";f();Qo();we();V();Y();hf();m2();He();p2();g2();f2();E2();y2();v2();S2();C2();M2();P2();D2();R2();Lr=class e{static loadedFontsCache=new Set;static _registered;static _initialized=!1;static get registered(){return e._registered?e._initialized||(e._registered=new Map([...e.init().entries(),...e._registered.entries()])):e._registered=e.init(),e._registered}get registered(){return e.registered}scene;constructor({scene:t}){this.scene=t}onLoaded=t=>{if(t.every(n=>{let i=`${n.family}-${n.style}-${n.weight}-${n.unicodeRange}`;return e.loadedFontsCache.has(i)?!0:(e.loadedFontsCache.add(i),!1)}))return!1;let r=!1,o=this.scene.getNonDeletedElementsMap();for(let n of this.scene.getNonDeletedElements())if(H(n)){r=!0,_e.delete(n);let i=Et(n,o);i&&_e.delete(i)}r&&this.scene.triggerUpdate()};loadSceneFonts=async()=>{let t=this.getSceneFontFamilies(),r=await e.loadFontFaces(t);return this.onLoaded(r),r};getSceneFontFamilies=()=>e.getFontFamilies(this.scene.getNonDeletedElements());static loadFontsForElements=async t=>{let r=e.getFontFamilies(t);return await e.loadFontFaces(r)};static async loadFontFaces(t){for(let{fonts:o,metadata:n}of e.registered.values())if(!n.local)for(let{fontFace:i}of o)window.document.fonts.has(i)||window.document.fonts.add(i);return(await Promise.all(t.map(async o=>{let n=Me({fontFamily:o,fontSize:16});if(!window.document.fonts.check(n))try{return await window.document.fonts.load(n)}catch(i){console.error(`Failed to load font "${n}" from urls "${e.registered.get(o)?.fonts.map(a=>a.urls)}"`,i)}return Promise.resolve()}))).flat().filter(Boolean)}static init(){let t={registered:new Map},r=d4.bind(t);return r("Virgil",rn[Le.Virgil],{uri:u2}),r("Excalifont",rn[Le.Excalifont],{uri:h2}),r("Helvetica",rn[Le.Helvetica],{uri:up}),r("Liberation Sans",rn[Le["Liberation Sans"]],{uri:w2}),r("Cascadia",rn[Le.Cascadia],{uri:b2}),r("Comic Shanns",rn[Le["Comic Shanns"]],{uri:x2}),r("Lilita One",rn[Le["Lilita One"]],{uri:I2,descriptors:{unicodeRange:Gi.LATIN_EXT}},{uri:T2,descriptors:{unicodeRange:Gi.LATIN}}),r("Nunito",rn[Le.Nunito],{uri:_2,descriptors:{unicodeRange:Gi.CYRILIC_EXT,weight:"500"}},{uri:L2,descriptors:{unicodeRange:Gi.CYRILIC,weight:"500"}},{uri:N2,descriptors:{unicodeRange:Gi.VIETNAMESE,weight:"500"}},{uri:k2,descriptors:{unicodeRange:Gi.LATIN_EXT,weight:"500"}},{uri:A2,descriptors:{unicodeRange:Gi.LATIN,weight:"500"}}),e._initialized=!0,t.registered}static getFontFamilies(t){return Array.from(t.reduce((r,o)=>(H(o)&&r.add(o.fontFamily),r),new Set))}};Tp=(e,t,r)=>{let{unitsPerEm:o,ascender:n,descender:i}=Lr.registered.get(e)?.metadata.metrics||rn[Le.Virgil].metrics,a=t/o,s=(r-a*n+a*i)/2;return a*n+s},uo=e=>{let{lineHeight:t}=Lr.registered.get(e)?.metadata.metrics||rn[Le.Excalifont].metrics;return t}});var Rn,go,Cf,O2,Cp,Uc,F2,jt,m4,Oc,B2,nn,Gc,Wc,Sp,an,Ip,Vc,Ap,Nn=X(()=>{"use strict";f();V();Zo();De();Gt();we();mt();dt();He();Y();on();Rn=(e,{x:t,y:r,strokeColor:o=pt.strokeColor,backgroundColor:n=pt.backgroundColor,fillStyle:i=pt.fillStyle,strokeWidth:a=pt.strokeWidth,strokeStyle:s=pt.strokeStyle,roughness:l=pt.roughness,opacity:c=pt.opacity,width:d=0,height:m=0,angle:p=0,groupIds:u=[],frameId:g=null,index:h=null,roundness:x=null,boundElements:v=null,link:y=null,locked:w=pt.locked,...C})=>({id:C.id||Ut(),type:e,x:t,y:r,width:d,height:m,angle:p,strokeColor:o,backgroundColor:n,fillStyle:i,strokeWidth:a,strokeStyle:s,roughness:l,opacity:c,groupIds:u,frameId:g,index:h,roundness:x,seed:C.seed??Co(),version:C.version||1,versionNonce:C.versionNonce??0,isDeleted:!1,boundElements:v,updated:si(),link:y,locked:w,customData:C.customData}),go=e=>Rn(e.type,e),Cf=e=>Rn("embeddable",e),O2=e=>({...Rn("iframe",e)}),Cp=e=>pe({...Rn("frame",e),type:"frame",name:e?.name||null},{}),Uc=e=>pe({...Rn("magicframe",e),type:"magicframe",name:e?.name||null},{}),F2=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),jt=e=>{let t=e.fontFamily||gr,r=e.fontSize||ur,o=e.lineHeight||uo(t),n=Zi(e.text),i=Vt(n,Me({fontFamily:t,fontSize:r}),o),a=e.textAlign||vn,s=e.verticalAlign||Pa,l=F2({textAlign:a,verticalAlign:s},i),c={...Rn("text",e),text:n,fontSize:r,fontFamily:t,textAlign:a,verticalAlign:s,x:e.x-l.x,y:e.y-l.y,width:i.width,height:i.height,containerId:e.containerId||null,originalText:e.originalText??n,autoResize:e.autoResize??!0,lineHeight:o};return pe(c,{})},m4=(e,t,r)=>{let{width:o,height:n}=Vt(r,Me(e),e.lineHeight);e.autoResize||(o=e.width);let{textAlign:i,verticalAlign:a}=e,s,l;if(i==="center"&&a===kt.MIDDLE&&!e.containerId&&e.autoResize){let c=Vt(e.text,Me(e),e.lineHeight),d=F2(e,{width:o-c.width,height:n-c.height});s=e.x-d.x,l=e.y-d.y}else{let[c,d,m,p]=ae(e,t),[u,g,h,x]=hi(e,o,n,!1),v=(c-u)/2,y=(d-g)/2,w=(m-h)/2,C=(p-x)/2;[s,l]=z2({s:!0,e:i==="center"||i==="left",w:i==="center"||i==="right"},e.x,e.y,e.angle,v,y,w,C)}return{width:o,height:n,x:Number.isFinite(s)?s:e.x,y:Number.isFinite(l)?l:e.y}},Oc=(e,t,r,o=e.text)=>{if(e.isDeleted)return;(t||!e.autoResize)&&(o=Lo(o,Me(e),t?br(t,e):e.width));let n=m4(e,r,o);return{text:o,...n}},B2=e=>({...Rn(e.type,e),points:e.points||[],pressures:[],simulatePressure:e.simulatePressure,lastCommittedPoint:null}),nn=e=>({...Rn(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:null,endArrowhead:null}),Gc=e=>({...Rn(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null,elbowed:e.elbowed||!1}),Wc=e=>({...Rn("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1]}),Sp=(e,t=0)=>{if(e==null||typeof e!="object")return e;let r=Object.prototype.toString.call(e);if(r==="[object Object]"){let o=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(t===0&&(n==="shape"||n==="canvas"))continue;o[n]=Sp(e[n],t+1)}return o}if(Array.isArray(e)){let o=e.length,n=new Array(o);for(;o--;)n[o]=Sp(e[o],t+1);return n}return T.DEV&&r!=="[object Object]"&&r!=="[object Array]"&&r.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${r}. This value will not be cloned!`),e},an=e=>Sp(e),Ip=e=>{if(Yr()&&e){let t=`${e}_copy`;return window.h?.app?.getSceneElementsIncludingDeleted().find(r=>r.id===t)&&(t+="_copy"),t}return Ut()},Vc=(e,t,r,o)=>{let n=an(r);return n.id=Ip(n.id),n.boundElements=null,n.updated=si(),n.seed=Co(),n.groupIds=K0(n.groupIds,e,i=>(t.has(i)||t.set(i,Ip(i)),t.get(i))),o&&(n=Object.assign(n,o)),n},Ap=(e,t)=>{let r=[],o=Z(e),n=new Map,i=s=>{if(n.has(s))return n.get(s);if(o.has(s)){let l=Ip(s);return n.set(s,l),l}return null},a=new Map;for(let s of e){let l=Sp(s);if(l.id=i(s.id),t?.randomizeSeed&&(l.seed=Co(),Ki(l)),l.groupIds&&(l.groupIds=l.groupIds.map(c=>(a.has(c)||a.set(c,Ip(c)),a.get(c)))),"containerId"in l&&l.containerId){let c=i(l.containerId);l.containerId=c}if("boundElements"in l&&l.boundElements&&(l.boundElements=l.boundElements.reduce((c,d)=>{let m=i(d.id);return m&&c.push({...d,id:m}),c},[])),"endBinding"in l&&l.endBinding){let c=i(l.endBinding.elementId);l.endBinding=c?{...l.endBinding,elementId:c}:null}if("startBinding"in l&&l.startBinding){let c=i(l.startBinding.elementId);l.startBinding=c?{...l.startBinding,elementId:c}:null}l.frameId&&(l.frameId=i(l.frameId)),r.push(l)}return r}});var Er,H2,Wa,rl,U2,Af,ji,p4,Mf,Mp,kf,G2,Pf,W2,Va,V2,Lf,oH,nH,iH,aH,sH,lH,cH,Ya=X(()=>{"use strict";f();Er=(e,t)=>[0,0,0,0,t,e,1,0],H2=(e,t)=>[0,0,0,0,t,e,0,0],Wa=(e=0,t=0)=>{let r=[0,0,0,0,0,0,0,0];if(t<0||t>7)throw new Error(`Expected \`index\` between 0 and 7, got \`${t}\``);return e!==0&&(r[t]=e),r},rl=e=>[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7]],U2=(e,t)=>Lf(t)?[e[0]+t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]+t[0],e[1]+t[1],e[2]+t[2],e[3]+t[3],e[4]+t[4],e[5]+t[5],e[6]+t[6],e[7]+t[7]],Af=(e,t)=>Lf(t)?[e[0]-t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3],e[4]-t[4],e[5]-t[5],e[6]-t[6],e[7]-t[7]],ji=(e,t)=>Lf(t)?[e[0]*t,e[1]*t,e[2]*t,e[3]*t,e[4]*t,e[5]*t,e[6]*t,e[7]*t]:[p4(e,t),t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[7]*e[3]+t[0]*e[4]+t[6]*e[5]-t[5]*e[6]+t[3]*e[7],t[5]*e[0]-t[3]*e[1]+t[7]*e[2]+t[1]*e[3]-t[6]*e[4]+t[0]*e[5]+t[4]*e[6]+t[2]*e[7],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]+t[0]*e[7]],p4=(e,t)=>t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],Mf=(e,t)=>[t[0]*e[0],t[1]*e[0]+t[0]*e[1],t[2]*e[0]+t[0]*e[2],t[3]*e[0]+t[0]*e[3],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[0]*e[4],t[5]*e[0]-t[3]*e[1]+t[1]*e[3]+t[0]*e[5],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]],Mp=(e,t)=>[kf(e,t),e[1]*t[7]+e[4]*t[5]-e[5]*t[4]+e[7]*t[1],e[2]*t[7]-e[4]*t[6]+e[6]*t[4]+e[7]*t[2],e[3]*t[7]+e[5]*t[6]-e[6]*t[5]+e[7]*t[3],e[4]*t[7]+e[7]*t[4],e[5]*t[7]+e[7]*t[5],e[6]*t[7]+e[7]*t[6],e[7]*t[7]],kf=(e,t)=>e[0]*t[7]+e[1]*t[6]+e[2]*t[5]+e[3]*t[4]+e[4]*t[3]+e[5]*t[2]+e[6]*t[1]+e[7]*t[0],G2=(e,t)=>[t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[7]*e[3]+t[0]*e[4]+t[3]*e[7],t[5]*e[0]+t[7]*e[2]+t[0]*e[5]+t[2]*e[7],t[6]*e[0]+t[0]*e[6],t[7]*e[0]+t[0]*e[7]],Pf=e=>Math.sqrt(Math.abs(e[0]*e[0]-e[2]*e[2]-e[3]*e[3]+e[6]*e[6])),W2=e=>Math.sqrt(Math.abs(e[7]*e[7]-e[5]*e[5]-e[4]*e[4]+e[1]*e[1])),Va=e=>{let t=Pf(e);if(t===0||t===1)return e;let r=e[6]<0?-1:1;return ji(e,r/t)},V2=e=>{let t=W2(e);return t===0||t===1?e:ji(e,1/t)},Lf=e=>typeof e=="number",oH=Wa(1,1),nH=Wa(1,2),iH=Wa(1,3),aH=Wa(1,4),sH=Wa(1,5),lH=Wa(1,6),cH=Wa(1,7)});var kp,ol,Y2,X2,K2,Df=X(()=>{"use strict";f();Ya();kp=(e,t,r)=>Va([0,r,e,t,0,0,0,0]),ol=(e,t)=>Va(Mp(t,e)),Y2=(e,t)=>G2(e,t),X2=(e,t)=>Y2(ol(e,t),t),K2=e=>Math.sign(e[1])});var Xa,Ka,Z2,j2,_f,qi,q2=X(()=>{"use strict";f();Ya();Df();Ya();Xa=([e,t])=>[0,0,0,0,t,e,1,0],Ka=e=>[e[5],e[4]],Z2=e=>[0,0,0,0,Math.abs(e[4]),Math.abs(e[5]),1,0],j2=(e,t)=>Va(Mf(e,t)),_f=(e,t)=>Pf(Mp(e,t)),qi=(e,t)=>kf(e,t)});var Rf,J2,Nf=X(()=>{"use strict";f();Ya();Rf=e=>[0,0,0,0,e[4],e[5],0,0],J2=(e,t)=>V2([0,0,0,0,t[4]-e[4],t[5]-e[5],0,0])});var Of,ev,tv,rv,sn,ov=X(()=>{"use strict";f();Ya();Nf();Of=(e,t)=>U2(ji(e,Math.sin(t/2)),Math.cos(t/2)),ev=e=>[1,0,0,0,-(.5*e[5]),.5*e[4],0,0],tv=(e,t)=>{let r=.5*t;return[1,0,0,0,r*e[4],r*e[5],0,0]},rv=(e,t)=>ji(t,e),sn=(e,t)=>Va(ji(ji(e,t),rl(e)))});var nl,Xc,h4,il,ln,f4,nv,b4,At,E4,Ff,x4,iv,av,y4,$a,Bf,w4,v4,zf,sv,Hf,lv,T4,cv,dv,al=X(()=>{"use strict";f();mt();nl=1e-4,Xc=(e,t,r)=>(e[0]-r[0])*(t[1]-r[1])-(e[1]-r[1])*(t[0]-r[0]),h4=e=>{let t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},il=e=>h4(e)?e:[...e,e[0]],ln=e=>{let t=e*180/Math.PI;return t<0?360+t:t},f4=e=>e/180*Math.PI,nv=(e,t)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)],b4=e=>e[0]===0&&e[1]===0,At=(e,t,r)=>{let o=f4(t);return!r||b4(r)?nv(e,o):nv(e.map((n,i)=>n-r[i]),o).map((n,i)=>n+r[i])},E4=e=>[-e[0],-e[1]],Ff=(e,t)=>[e[0]+t[0],e[1]+t[1]],x4=(e,t)=>Pt(...e,...t),iv=e=>ln(Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0])),av=(e,t,r)=>{let o=Ff(e,E4(t));return At(o,-ln(r))},y4=(e,t)=>{let[r,o]=e,[[n,i],[a,s]]=t,l=r-n,c=o-i,d=a-n,m=s-i,p=l*d+c*m,u=d*d+m*m,g=-1;u!==0&&(g=p/u);let h,x;g<0?(h=n,x=i):g>1?(h=a,x=s):(h=n+g*d,x=i+g*m);let v=r-h,y=o-x;return Math.sqrt(v*v+y*y)},$a=(e,t,r=nl)=>{let o=y4(e,t);return o===0?!0:o<r},Bf=(e,t,r=nl)=>t.some(o=>$a(e,o,r)),w4=e=>{let[t,r,o,n]=e;return(i,a)=>Math.pow(1-i,3)*n[a]+3*i*Math.pow(1-i,2)*o[a]+3*Math.pow(i,2)*(1-i)*r[a]+t[a]*Math.pow(i,3)},v4=(e,t=10)=>{let r=w4(e),o=[r(0,0),r(0,1)],n=[],i=0,a=1/t;for(let s=0;s<t;s++)if(i+=a,i<=1){let l=[r(i,0),r(i,1)];n.push([o,l]),o=l}return n},zf=(e,t,r=nl)=>Bf(e,v4(t),r),sv=(e,t,r=nl)=>t.some(o=>zf(e,o,r)),Hf=(e,t)=>{let r=e[0],o=e[1],n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){let s=t[i][0],l=t[i][1],c=t[a][0],d=t[a][1];(l>o&&d<=o||l<=o&&d>o)&&r<(c-s)*(o-l)/(d-l)+s&&(n=!n)}return n},lv=(e,t,r=nl)=>{let o=!1,n=il(t);for(let i=0,a=n.length-1;i<a;i++)if($a(e,[n[i],n[i+1]],r)){o=!0;break}return o},T4=(e,t)=>{let{angle:r,halfWidth:o,halfHeight:n,center:i}=t,a=o,s=n,[l,c]=av(e,i,r),d=Math.abs(l),m=Math.abs(c),p=.707,u=.707;for(let x=0;x<3;x++){let v=a*p,y=s*u,w=(a*a-s*s)*p**3/a,C=(s*s-a*a)*u**3/s,M=v-w,I=y-C,P=d-w,A=m-C,N=Math.hypot(I,M),k=Math.hypot(A,P);p=Math.min(1,Math.max(0,(P*N/k+w)/a)),u=Math.min(1,Math.max(0,(A*N/k+C)/s));let D=Math.hypot(u,p);p/=D,u/=D}let[g,h]=[a*p*Math.sign(l),s*u*Math.sign(c)];return x4([l,c],[g,h])},cv=(e,t,r=nl)=>T4(e,t)<=r,dv=(e,t)=>{let{center:r,angle:o,halfWidth:n,halfHeight:i}=t,[a,s]=av(e,r,o);return a/n*(a/n)+s/i*(s/i)<=1}});var Kc,sl,Pp=X(()=>{"use strict";f();al();Kc=(e,t,r=0)=>{switch(t.type){case"polygon":return lv(e,t.data,r);case"ellipse":return cv(e,t.data,r);case"line":return $a(e,t.data,r);case"polyline":return Bf(e,t.data,r);case"curve":return zf(e,t.data,r);case"polycurve":return sv(e,t.data,r);default:throw Error(`shape ${t} is not implemented`)}},sl=(e,t)=>{switch(t.type){case"polygon":return Hf(e,t.data);case"line":return!1;case"curve":return!1;case"ellipse":return dv(e,t.data);case"polyline":{let r=il(t.data.flat());return Hf(e,r)}case"polycurve":return!1;default:throw Error(`shape ${t} is not implemented`)}}});var Se,S,ll,Lp,cl,Za,ye=X(()=>{"use strict";f();Y();Se={EQUAL:"Equal",MINUS:"Minus",NUM_ADD:"NumpadAdd",NUM_SUBTRACT:"NumpadSubtract",NUM_ZERO:"Numpad0",BRACKET_RIGHT:"BracketRight",BRACKET_LEFT:"BracketLeft",ONE:"Digit1",TWO:"Digit2",THREE:"Digit3",NINE:"Digit9",QUOTE:"Quote",ZERO:"Digit0",SLASH:"Slash",C:"KeyC",D:"KeyD",H:"KeyH",V:"KeyV",Z:"KeyZ",R:"KeyR",S:"KeyS"},S={ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",BACKSPACE:"Backspace",ALT:"Alt",CTRL_OR_CMD:Cr?"metaKey":"ctrlKey",DELETE:"Delete",ENTER:"Enter",ESCAPE:"Escape",QUESTION_MARK:"?",SPACE:" ",TAB:"Tab",CHEVRON_LEFT:"<",CHEVRON_RIGHT:">",PERIOD:".",COMMA:",",SUBTRACT:"-",SLASH:"/",A:"a",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",L:"l",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",V:"v",X:"x",Y:"y",Z:"z",K:"k",W:"w",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9"},ll=e=>e===S.ARROW_LEFT||e===S.ARROW_RIGHT||e===S.ARROW_DOWN||e===S.ARROW_UP,Lp=e=>e.altKey,cl=e=>e.shiftKey,Za=e=>e.shiftKey});import{pointsOnBezierCurves as S4}from"points-on-curve";var Dp,mv,pv,uv,gv,I4,hv,fv,_p=X(()=>{"use strict";f();we();al();Dp=e=>{let{angle:t,width:r,height:o,x:n,y:i}=e,a=ln(t),s=n+r/2,l=i+o/2,c=[s,l],d=[];return e.type==="diamond"?d=[At([s,i],a,c),At([n+r,l],a,c),At([s,i+o],a,c),At([n,l],a,c)]:d=[At([n,i],a,c),At([n+r,i],a,c),At([n+r,i+o],a,c),At([n,i+o],a,c)],{type:"polygon",data:d}},mv=(e,t,r=10)=>{let[o,n,i,a,s,l]=ae(e,t,!0);o-=r,i+=r,n-=r,a+=r;let c=ln(e.angle),d=[s,l],m=At([o,n],c,d),p=At([i,n],c,d),u=At([o,a],c,d),g=At([i,a],c,d);return{type:"polygon",data:[m,p,g,u]}},pv=e=>{let{width:t,height:r,angle:o,x:n,y:i}=e;return{type:"ellipse",data:{center:[n+t/2,i+r/2],angle:o,halfWidth:t/2,halfHeight:r/2}}},uv=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},gv=(e,t=[0,0],r,o)=>{let n=l=>At([l[0]+t[0],l[1]+t[1]],ln(r),o),i=uv(e),a=[],s=[0,0];for(let l of i)if(l.op==="move"&&(s=n(l.data)),l.op==="bcurveTo"){let c=n([l.data[0],l.data[1]]),d=n([l.data[2],l.data[3]]),m=n([l.data[4],l.data[5]]);a.push([s,c,d,m]),s=m}return{type:"polycurve",data:a}},I4=e=>{let t=e[0],r=[];for(let o=1;o<e.length;o++){let n=e[o];r.push([t,n]),t=n}return r},hv=(e,t,r=!1)=>{let o=ln(e.angle),n=a=>At(Ff(a,[e.x,e.y]),o,t),i=I4(e.points.map(a=>n(a)));return r?{type:"polygon",data:il(i.flat())}:{type:"polyline",data:i}},fv=(e,t,r=[0,0],o,n)=>{let i=d=>At([d[0]+r[0],d[1]+r[1]],ln(o),n);if(e.roundness===null)return{type:"polygon",data:il(e.points.map(d=>i(d)))};let a=uv(t),s=[],l=!1;for(let d of a)d.op==="move"?(l=!l,l&&s.push([d.data[0],d.data[1]])):d.op==="bcurveTo"?l&&(s.push([d.data[0],d.data[1]]),s.push([d.data[2],d.data[3]]),s.push([d.data[4],d.data[5]])):d.op==="lineTo"&&l&&s.push([d.data[0],d.data[1]]);return{type:"polygon",data:S4(s,10,5).map(d=>i(d))}}});var Rp,ja,$c,bv,Uf,Zc=X(()=>{"use strict";f();mt();dt();_p();Pp();V();me();dl();Rp=e=>{if(e.type==="arrow")return!1;let t=!Ar(e.backgroundColor)||Ct(e)||sr(e)||H(e);return e.type==="line"?t&&Dr(e.points):e.type==="freedraw"?t&&Dr(e.points):t||So(e)},ja=({x:e,y:t,element:r,shape:o,threshold:n=10,frameNameBound:i=null})=>{let a=Rp(r)?sl([e,t],o)||Kc([e,t],o,n):Kc([e,t],o,n);return!a&&i&&(a=sl([e,t],{type:"polygon",data:Dp(i).data})),a},$c=(e,t,r,o,n=0)=>{let[i,a,s,l]=ho(r,o);return i-=n,a-=n,s+=n,l+=n,Op([i,a],[e,t],[s,l])},bv=(e,t)=>!ja(e)&&!Uf(e.x,e.y,Np(e.element,t))&&$c(e.x,e.y,e.element,t),Uf=(e,t,r)=>!!r&&sl([e,t],r)});var jc,Ev,cn,Np,dl=X(()=>{"use strict";f();_p();ee();we();Zc();Wt();He();ye();Qo();jc=[{icon:cy,value:"selection",key:S.V,numericKey:S[1],fillable:!0},{icon:dy,value:"rectangle",key:S.R,numericKey:S[2],fillable:!0},{icon:my,value:"diamond",key:S.D,numericKey:S[3],fillable:!0},{icon:py,value:"ellipse",key:S.O,numericKey:S[4],fillable:!0},{icon:uy,value:"arrow",key:S.A,numericKey:S[5],fillable:!0},{icon:gy,value:"line",key:S.L,numericKey:S[6],fillable:!0},{icon:ci,value:"freedraw",key:[S.P,S.X],numericKey:S[7],fillable:!1},{icon:Jm,value:"text",key:S.T,numericKey:S[8],fillable:!1},{icon:fy,value:"image",key:null,numericKey:S[9],fillable:!1},{icon:by,value:"eraser",key:S.E,numericKey:S[0],fillable:!1}],Ev=e=>jc.find((r,o)=>r.numericKey!=null&&e===r.numericKey.toString()||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null,cn=(e,t)=>{switch(e.type){case"rectangle":case"diamond":case"frame":case"magicframe":case"embeddable":case"image":case"iframe":case"text":case"selection":return Dp(e);case"arrow":case"line":{let r=_e.get(e)?.[0]??_e.generateElementShape(e,null)[0],[,,,,o,n]=ae(e,t);return Rp(e)?fv(e,r,[e.x,e.y],e.angle,[o,n]):gv(r,[e.x,e.y],e.angle,[o,n])}case"ellipse":return pv(e);case"freedraw":{let[,,,,r,o]=ae(e,t);return hv(e,[r,o],Rp(e))}}},Np=(e,t)=>{let r=J(e,t);return r?e.type==="arrow"?cn({...r,...K.getBoundTextElementPosition(e,r,t)},t):cn(r,t):null}});var Nt,_r,Rr,Nr,Fp,Ji,ml,Gf,Wf=X(()=>{"use strict";f();al();mt();Nt=[1,0],_r=[0,1],Rr=[-1,0],Nr=[0,-1],Fp=(e,t)=>{let r=iv([e,t]);return r>=315||r<45?Nr:r>=45&&r<135?Nt:r>=135&&r<225?_r:Rr},Ji=e=>{let[t,r]=e,o=Math.abs(t),n=Math.abs(r);return t>n?Nt:t<=-n?Rr:r>o?_r:Nr},ml=(e,t)=>e[0]===t[0]&&e[1]===t[1],Gf=(e,t,r)=>{let n=Bp(t);if(e.type==="diamond"){if(r[0]<e.x)return Rr;if(r[1]<e.y)return Nr;if(r[0]>e.x+e.width)return Nt;if(r[1]>e.y+e.height)return _r;let c=ce(dn([e.x+e.width/2,e.y],n,2),n,e.angle),d=ce(dn([e.x+e.width,e.y+e.height/2],n,2),n,e.angle),m=ce(dn([e.x+e.width/2,e.y+e.height],n,2),n,e.angle),p=ce(dn([e.x,e.y+e.height/2],n,2),n,e.angle);return qa(r,c,d,n)?Fp(c,d):qa(r,d,m,n)?Fp(d,m):qa(r,m,p,n)?Fp(m,p):Fp(p,c)}let i=dn([t[0],t[1]],n,2),a=dn([t[2],t[1]],n,2),s=dn([t[0],t[3]],n,2),l=dn([t[2],t[3]],n,2);return qa(r,i,a,n)?Nr:qa(r,a,l,n)?Nt:qa(r,l,s,n)?_r:Rr}});var vv,Fn,at,C4,Qa,xv,A4,Tv,M4,k4,es,Gp,Jc,On,Sv,Xf,Iv,P4,xr,L4,qt,D4,_4,Cv,R4,gl,N4,Av,Mv,O4,Qc,yv,pl,kv,Wp,wv,Vp,qc,Pv,ed,Ja,F4,B4,z4,H4,Kf,$f,Zf,U4,G4,Vf,W4,Lv,V4,Y4,X4,K4,$4,Z4,Dv,zp,Hp,Qi,ea,Up,j4,_v,yr=X(()=>{"use strict";f();Ya();q2();Nf();Df();ov();dt();Pp();et();me();De();Wt();V();ye();He();dl();mt();Wf();vv=e=>!e[S.CTRL_OR_CMD],Fn=e=>e.isBindingEnabled,at=5,C4=(e,t)=>{let r=[];return t.forEach(o=>{let n=e.getNonDeletedElement(o);n!=null&&r.push(n)}),r},Qa=(e,t,r,o,n)=>{let i=new Set,a=new Set;xv(e,t,r,"start",i,a,o,n),xv(e,r,t,"end",i,a,o,n);let s=Array.from(a).filter(l=>!i.has(l));C4(n,s).forEach(l=>{F(l,{boundElements:l.boundElements?.filter(c=>c.type!=="arrow"||c.id!==e.id)})})},xv=(e,t,r,o,n,i,a,s)=>{if(t!=="keep"){if(t===null){let l=P4(e,o);l!=null&&i.add(l);return}Iv(e)?(r==null||(r==="keep"?!Sv(e,t,o):o==="start"||r.id!==t.id))&&(On(e,t,o,a),n.add(t.id)):(On(e,t,o,a),n.add(t.id))}},A4=(e,t,r)=>{let o=kv(e,t,r),n=t==="start"?e.startBinding?.elementId:e.endBinding?.elementId;if(n){let i=r.get(n);if(An(i)&&Pv(i,o,r))return i}return null},Tv=(e,t)=>["start","end"].map(r=>A4(e,r,t)),M4=(e,t,r,o,n)=>{let a=e.points.length-1,s=r.findIndex(m=>m===0)>-1,l=r.findIndex(m=>m===a)>-1,c=s?t?pl(e,"start",o,n):null:pl(e,"start",o,n),d=l?t?pl(e,"end",o,n):null:pl(e,"end",o,n);return[c,d]},k4=(e,t,r,o)=>{let[n,i]=Tv(e,t),a=n&&o?pl(e,"start",t,r):null,s=i&&o?pl(e,"end",t,r):null;return[a,s]},es=(e,t,r,o,n,i)=>{e.forEach(a=>{let[s,l]=i?.length?M4(a,n,i??[],t,r):k4(a,t,r,n);Qa(a,s,l,t,o)})},Gp=(e,t)=>e.length>50?[]:e.filter(ie).flatMap(r=>Tv(r,t)).filter(r=>r!==null).filter(r=>e.filter(o=>o.id===r?.id).length===0),Jc=(e,t,r,o,n)=>{t.startBoundElement!=null&&On(e,t.startBoundElement,"start",o);let i=xr(r,n,o,de(e)&&de(e));i!==null&&(Sv(e,i,"end")||On(e,i,"end",o))},On=(e,t,r,o)=>{if(!ne(e))return;let n={elementId:t.id,...L4(e,t,r,o),...de(e)?Qc(e,t,r,o):{fixedPoint:null}};F(e,{[r==="start"?"startBinding":"endBinding"]:n}),Z(t.boundElements||[]).has(e.id)||F(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},Sv=(e,t,r)=>{let o=e[r==="start"?"endBinding":"startBinding"];return Xf(e,o?.elementId,t)},Xf=(e,t,r)=>t===r.id&&Iv(e),Iv=e=>e.points.length<3,P4=(e,t)=>{let r=t==="start"?"startBinding":"endBinding",o=e[r];return o==null?null:(F(e,{[r]:null}),o.elementId)},xr=(e,t,r,o)=>jf(t,i=>An(i,!1)&&Pv(i,e,r,o&&!Q(i))),L4=(e,t,r,o)=>{let n=r==="start"?-1:1,i=n===-1?0:e.points.length-1,a=i-n,s=K.getPointAtIndexGlobalCoordinates(e,i,o),l=K.getPointAtIndexGlobalCoordinates(e,a,o);return{focus:U4(t,l,s,o),gap:Math.max(1,Ja(t,s,o))}},qt=(e,t,r,o)=>{let{oldSize:n,simultaneouslyUpdated:i,changedElements:a}=o??{},s=_4(i);An(e)&&zp(t,e,l=>{if(!ie(l)||l.isDeleted||!D4(l,e))return;let c={startBinding:yv(e,l.startBinding,n),endBinding:yv(e,l.endBinding,n)};if(s.has(l.id)){F(l,c);return}let d=Hp(t,l,(p,u)=>{if(p&&An(p)&&(u==="startBinding"||u==="endBinding")&&e.id===l[u]?.elementId){let g=O4(l,u,c[u],p,t);if(g)return{index:u==="startBinding"?0:l.points.length-1,point:g}}return null}).filter(p=>p!==null);K.movePoints(l,d,r,{...e.id===l.startBinding?.elementId?{startBinding:c.startBinding}:{},...e.id===l.endBinding?.elementId?{endBinding:c.endBinding}:{}},{changedElements:a});let m=J(l,t);m&&!m.isDeleted&&mn(l,t,!1)})},D4=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,_4=e=>new Set((e||[]).map(t=>t.id)),Cv=(e,t,r,o,n,i)=>{let a=Ji(fi(t,e));return!r||!o?a:R4(i,r,n)?Gf(r,o,e):Ji(fi(e,Yp(r)))},R4=(e,t,r)=>{let o=Ja(t,e,r),n=ed(t,t.width,t.height);return o>n?null:o},gl=(e,t,r,o)=>{let n=r&&bi(r);if(r&&n){let i=[...Vf(r,[e[0],e[1]-2*r.height],[e[0],e[1]+2*r.height],at,o),...Vf(r,[e[0]-2*r.width,e[1]],[e[0]+2*r.width,e[1]],at,o)].map(d=>Ja(r,d,o)>Math.min(r.width,r.height)/2?[-1*d[0],-1*d[1]]:d),a=Gf(r,n,e),s=ml(a,Rr)||ml(a,Nt),l=Ja(r,e,o),c=s?l<r.width*-.1:l<r.height*-.1;return i.sort((d,m)=>ul(d,e)-ul(m,e)),c?N4(t,r,n):i.filter(d=>s?Math.abs(e[1]-d[1])<.1:Math.abs(e[0]-d[0])<.1)[0]??e}return e},N4=(e,t,r)=>{let o=Bp(r),n=Ji(fi(e,o));switch(!0){case ml(n,Nr):return ce([(r[0]+r[2])/2+.1,r[1]],o,t.angle);case ml(n,Nt):return ce([r[2],(r[1]+r[3])/2+.1],o,t.angle);case ml(n,_r):return ce([(r[0]+r[2])/2-.1,r[3]],o,t.angle);default:return ce([r[0],(r[1]+r[3])/2-.1],o,t.angle)}},Av=(e,t)=>{let r=Yp(e),o=ce(t,r,-e.angle);return o[0]<e.x&&o[1]<e.y?o[1]-e.y>-at?ce([e.x-at,e.y],r,e.angle):ce([e.x,e.y-at],r,e.angle):o[0]<e.x&&o[1]>e.y+e.height?o[0]-e.x>-at?ce([e.x,e.y+e.height+at],r,e.angle):ce([e.x-at,e.y+e.height],r,e.angle):o[0]>e.x+e.width&&o[1]>e.y+e.height?o[0]-e.x<e.width+at?ce([e.x+e.width,e.y+e.height+at],r,e.angle):ce([e.x+e.width+at,e.y+e.height],r,e.angle):o[0]>e.x+e.width&&o[1]<e.y?o[0]-e.x<e.width+at?ce([e.x+e.width,e.y-at],r,e.angle):ce([e.x+e.width+at,e.y],r,e.angle):t},Mv=(e,t,r=.05)=>{let{x:o,y:n,width:i,height:a,angle:s}=e,l=[o+i/2-.1,n+a/2-.1],c=ce(t,l,-s),d=Yf(r*a,5,80),m=Yf(r*i,5,80);return c[0]<=o+i/2&&c[1]>l[1]-d&&c[1]<l[1]+d?ce([o-at,l[1]],l,s):c[1]<=n+a/2&&c[0]>l[0]-m&&c[0]<l[0]+m?ce([l[0],n-at],l,s):c[0]>=o+i/2&&c[1]>l[1]-d&&c[1]<l[1]+d?ce([o+i+at,l[1]],l,s):c[1]>=n+a/2&&c[0]>l[0]-m&&c[0]<l[0]+m?ce([l[0],n+a+at],l,s):t},O4=(e,t,r,o,n)=>{if(r==null||r.elementId!==o.id&&e.points.length>2)return null;let i=t==="startBinding"?-1:1,a=i===-1?0:e.points.length-1;if(de(e)){let m=r.fixedPoint??Qc(e,o,t==="startBinding"?"start":"end",n).fixedPoint,p=[o.x+o.width/2,o.y+o.height/2],u=[o.x+m[0]*o.width,o.y+m[1]*o.height],g=ce(u,p,o.angle);return K.pointFromAbsoluteCoords(e,g,n)}let s=a-i,l=K.getPointAtIndexGlobalCoordinates(e,s,n),c=G4(o,r.focus,l,n),d;if(r.gap===0)d=c;else{let m=Vf(o,l,c,r.gap,n);m.length===0?d=c:d=m[0]}return K.pointFromAbsoluteCoords(e,d,n)},Qc=(e,t,r,o)=>{let n=[t.x,t.y,t.x+t.width,t.y+t.height],i=r==="start"?0:e.points.length-1,a=K.getPointAtIndexGlobalCoordinates(e,i,o),s=K.getPointAtIndexGlobalCoordinates(e,i,o),l=gl(a,s,t,o),c=[n[0]+(n[2]-n[0])/2,n[1]+(n[3]-n[1])/2],d=ce(l,c,-t.angle);return{fixedPoint:[(d[0]-t.x)/t.width,(d[1]-t.y)/t.height]}},yv=(e,t,r)=>{if(t==null||r==null)return t;let{width:o,height:n}=r,{width:i,height:a}=e,s=Math.max(1,Math.min(ed(e,o,n),t.gap*(o<n?o/i:n/a)));return{...t,gap:s}},pl=(e,t,r,o)=>xr(kv(e,t,r),o,r),kv=(e,t,r)=>{let o=t==="start"?0:-1;return ar(K.getPointAtIndexGlobalCoordinates(e,o,r))},Wp=(e,t,r,o)=>{let n=new Set,i=new Set,a=o==="duplicatesServeAsOld",s=new Map([...r].map(([l,c])=>[c,l]));t.forEach(l=>{let{boundElements:c}=l;if(c!=null&&c.length>0&&(c.forEach(d=>{a&&!r.has(d.id)&&n.add(d.id)}),i.add(r.get(l.id))),Kr(l)){if(l.startBinding!=null){let{elementId:d}=l.startBinding;a&&!r.has(d)&&i.add(d)}if(l.endBinding!=null){let{elementId:d}=l.endBinding;a&&!r.has(d)&&i.add(d)}(l.startBinding!=null||l.endBinding!=null)&&n.add(r.get(l.id))}}),e.filter(({id:l})=>n.has(l)).forEach(l=>{let{startBinding:c,endBinding:d}=l;F(l,{startBinding:wv(c,r),endBinding:wv(d,r)})}),e.filter(({id:l})=>i.has(l)).forEach(l=>{let c=s.get(l.id),{boundElements:d}=e.find(({id:m})=>m===c);d!=null&&d.length>0&&F(l,{boundElements:d.map(m=>r.has(m.id)?{id:r.get(m.id),type:m.type}:m)})})},wv=(e,t)=>e==null?null:{...e,elementId:t.get(e.elementId)??e.elementId},Vp=(e,t)=>{let r=Z(e);for(let o of t)Qi.unbindAffected(r,o,F),ea.unbindAffected(r,o,F)},qc=(e,t,r=[])=>{if(!e)return null;let o=e.filter(n=>!t.has(n.id));return o.push(...r.map(n=>({id:n.id,type:n.type}))),o},Pv=(e,{x:t,y:r},o,n)=>{let i=ed(e,e.width,e.height),a=cn(e,o);return Kc([t,r],a,i)||n===!0&&ta([t,r],bi(e))},ed=(e,t,r)=>{let n=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,r);return Math.max(16,Math.min(.25*n,32))},Ja=(e,t,r)=>{switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return F4(e,t,r);case"diamond":return B4(e,t,r);case"ellipse":return z4(e,t,r)}},F4=(e,t,r)=>{let[,o,n,i]=Kf(e,t,r);return Math.max(qi(o,kp(0,1,-i)),qi(o,kp(1,0,-n)))},B4=(e,t,r)=>{let[,o,n,i]=Kf(e,t,r),a=kp(i,n,-i*n);return qi(o,a)},z4=(e,t,r)=>{let[o,n]=H4(e,t,r);return-K2(n)*qi(o,n)},H4=(e,t,r)=>{let[,o,n,i]=Kf(e,t,r),[a,s]=Ka(o),l=.707,c=.707,d=n,m=i;[0,1,2,3].forEach(g=>{let h=d*l,x=m*c,v=(d*d-m*m)*l**3/d,y=(m*m-d*d)*c**3/m,w=h-v,C=x-y,M=a-v,I=s-y,P=Math.hypot(C,w),A=Math.hypot(I,M);l=Math.min(1,Math.max(0,(M*P/A+v)/d)),c=Math.min(1,Math.max(0,(I*P/A+y)/m));let N=Math.hypot(c,l);l/=N,c/=N});let p=Er(d*l,m*c),u=X2(o,p);return[o,u]},Kf=(e,t,r)=>{let o=Xa(t),[n,i,a,s]=ae(e,r),l=Zf(n,i,a,s),c=Of(l,e.angle),d=sn(c,o),m=Af(d,Rf(l)),p=Z2(m),u=H2(e.x,e.y),g=Af(d,u),h=(a-n)/2,x=(s-i)/2;return[g,p,h,x]},$f=(e,t)=>{let[r,o,n,i]=ae(e,t),a=Zf(r,o,n,i),s=Of(a,e.angle),l=rl(ev(Rf(a)));return rv(s,l)},Zf=(e,t,r,o)=>Er((e+r)/2,(t+o)/2),U4=(e,t,r,o)=>{let n=$f(e,o),i=sn(n,Xa(t)),a=sn(n,Xa(r)),s=ol(i,a),l=e.height/e.width,c=e.width/2,d=e.height/2,m=s[2],p=s[3],u=s[1],g=Math.abs(p),h=Math.abs(m),x;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":x=u/(c*(h+l*g));break;case"diamond":x=g<h?u/(h*c):u/(g*d);break;case"ellipse":x=u/(c*Math.sqrt(m**2+l**2*p**2));break}return x||0},G4=(e,t,r,o)=>{if(t===0){let[l,c,d,m]=ae(e,o),p=Zf(l,c,d,m);return Ka(p)}let n=$f(e,o),i=sn(n,Xa(r)),a=rl(n),s;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":s=Z4(e,t,i);break;case"ellipse":s=$4(e,t,i);break}return Ka(sn(a,s))},Vf=(e,t,r,o=0,n)=>{let i=$f(e,n),a=sn(i,Xa(t)),s=sn(i,Xa(r)),l=ol(a,s),c=rl(i);return W4(e,l,a,o).map(m=>Ka(sn(c,m)))},W4=(e,t,r,o=0)=>{let n;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":let a=Lv(e);n=a.flatMap((s,l)=>{let c=[s,a[(l+1)%4]];return V4(t,Y4(c,o))}).concat(a.flatMap(s=>K4(s,o,t)));break;case"ellipse":n=X4(e,o,t);break}if(n.length<2)return[];let i=n.sort((a,s)=>_f(a,r)-_f(s,r));return[i[0],i[i.length-1]]},Lv=(e,t=1)=>{let r=t*e.width/2,o=t*e.height/2;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return[Er(r,o),Er(r,-o),Er(-r,-o),Er(-r,o)];case"diamond":return[Er(0,o),Er(r,0),Er(0,-o),Er(-r,0)]}},V4=(e,t)=>{let[r,o]=t,n=qi(r,e),i=qi(o,e);return n*i>=0?[]:[j2(e,ol(r,o))]},Y4=(e,t)=>{let[r,o]=e,n=tv(J2(r,o),t);return[sn(n,r),sn(n,o)]},X4=(e,t,r)=>{let o=e.width/2+t,n=e.height/2+t,i=r[2],a=r[3],s=r[1],l=o*o*i*i+n*n*a*a,c=l-s*s;if(l===0||c<=0)return[];let d=Math.sqrt(c),m=-o*o*i*s,p=-n*n*a*s;return[Er((m+o*n*a*d)/l,(p-o*n*i*d)/l),Er((m-o*n*a*d)/l,(p+o*n*i*d)/l)]},K4=(e,t,r)=>{if(t===0)return qi(r,e)===0?[e]:[];let o=r[2],n=r[3],i=r[1],[a,s]=Ka(e),l=t,c=o*o+n*n,d=l*l*c-(o*a+n*s+i)**2;if(c===0||d<=0)return[];let m=Math.sqrt(d),p=a*n*n-s*o*n-o*i,u=s*o*o-a*o*n-n*i;return[Er((p+n*m)/c,(u-o*m)/c),Er((p-n*m)/c,(u+o*m)/c)]},$4=(e,t,r)=>{let o=Math.abs(t),n=e.width*o/2,i=e.height*o/2,a=Math.sign(t),[s,l]=Ka(r),c=l===0?1e-4:l,d=s**2*i**2+c**2*n**2,m=(-s*i**2+a*c*Math.sqrt(Math.max(0,d-n**2*i**2)))/d,p=(-m*s-1)/c;p===0&&(p=(Object.is(p,-0)?-1:1)*.01);let u=-(n**2*m)/(p**2*i**2+m**2*n**2);return Er(u,(-m*u-1)/p)},Z4=(e,t,r)=>{let o=Math.abs(t),n=Math.sign(t),i=Lv(e,o),a=0,s=null;return i.forEach(l=>{let c=n*ol(r,l)[1];c>a&&(a=c,s=l)}),s},Dv=new Set(["boundElements","frameId","containerId","startBinding","endBinding"]),zp=(e,t,r)=>{An(t)&&(t.boundElements?.slice()??[]).forEach(({id:n})=>{r(e.get(n),"boundElements",n)})},Hp=(e,t,r)=>{let o=[];if(t.frameId){let n=t.frameId;o.push(r(e.get(n),"frameId",n))}if(ze(t)){let n=t.containerId;o.push(r(e.get(n),"containerId",n))}if(ne(t)){if(t.startBinding){let n=t.startBinding.elementId;o.push(r(e.get(n),"startBinding",n))}if(t.endBinding){let n=t.endBinding.elementId;o.push(r(e.get(n),"endBinding",n))}}return o},Qi=class{static unbindAffected(t,r,o){r&&Hp(t,r,n=>{!n||n.isDeleted||zp(t,n,(i,a,s)=>{s===r.id&&o(n,{boundElements:qc(n.boundElements,new Set([s]))})})})}static rebindAffected=(t,r,o)=>{!r||r.isDeleted||Hp(t,r,(n,i)=>{if(!n||n.isDeleted){o(r,{[i]:null});return}i!=="frameId"&&(n.boundElements?.find(a=>a.id===r.id)||(ne(r)&&o(n,{boundElements:qc(n.boundElements,new Set,new Array(r))}),H(r)&&(n.boundElements?.find(a=>a.type==="text")?o(r,{[i]:null}):o(n,{boundElements:qc(n.boundElements,new Set,new Array(r))}))))})}},ea=class{static unbindAffected(t,r,o){r&&zp(t,r,n=>{!n||n.isDeleted||Hp(t,n,(i,a,s)=>{s===r.id&&o(n,{[a]:null})})})}static rebindAffected=(t,r,o)=>{!r||r.isDeleted||zp(t,r,(n,i,a)=>{if(!n||n.isDeleted){o(r,{boundElements:qc(r.boundElements,new Set([a]))});return}H(n)&&((r.boundElements?.slice()??[]).reverse().find(l=>l.type==="text")?.id===n.id?n.containerId!==r.id&&o(n,{containerId:r.id}):(n.containerId!==null&&o(n,{containerId:null}),o(r,{boundElements:qc(r.boundElements,new Set([n.id]))})))})}},Up=(e,t)=>{let[r,o]=e;return ce([t.x+t.width*r,t.y+t.height*o],Yp(t),t.angle)},j4=(e,t)=>{let r=e.startBinding&&t.get(e.startBinding.elementId),o=e.endBinding&&t.get(e.endBinding.elementId),n=r&&e.startBinding?Up(e.startBinding.fixedPoint,r):[e.x+e.points[0][0],e.y+e.points[0][1]],i=o&&e.endBinding?Up(e.endBinding.fixedPoint,o):[e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]];return[n,i]},_v=(e,t)=>{let[r,o]=j4(e,t);return[K.pointFromAbsoluteCoords(e,r,t),K.pointFromAbsoluteCoords(e,o,t)]}});var Tt,td,rd,Rv=X(()=>{"use strict";f();Y();yr();Wt();De();He();me();ko();Gt();Re();V();Tt=class e{constructor(t,r){this.deleted=t;this.inserted=r}static create(t,r,o,n){let i=o&&n!=="inserted"?o(t):t,a=o&&n!=="deleted"?o(r):r;return new e(i,a)}static calculate(t,r,o,n){if(t===r)return e.empty();let i={},a={};for(let c of this.distinctKeysIterator("full",t,r))i[c]=t[c],a[c]=r[c];let[s,l]=n?n(i,a):[i,a];return e.create(s,l,o)}static empty(){return new e({},{})}static isEmpty(t){return!Object.keys(t.deleted).length&&!Object.keys(t.inserted).length}static mergeObjects(t,r,o){let n={...t};for(let i of Object.keys(o))delete n[i];return{...n,...r}}static mergeArrays(t,r,o,n){return Object.values(e.mergeObjects(In(t??[],n),In(r??[],n),In(o??[],n)))}static diffObjects(t,r,o,n){if(!(!t[o]&&!r[o])&&(typeof t[o]=="object"||typeof r[o]=="object")){let i=t[o]??{},a=r[o]??{},s=e.getLeftDifferences(i,a).reduce((c,d)=>(c[d]=n(i[d]),c),{}),l=e.getRightDifferences(i,a).reduce((c,d)=>(c[d]=n(a[d]),c),{});Object.keys(s).length||Object.keys(l).length?(Reflect.set(t,o,s),Reflect.set(r,o,l)):(Reflect.deleteProperty(t,o),Reflect.deleteProperty(r,o))}}static diffArrays(t,r,o,n){if(!(!t[o]&&!r[o])&&(Array.isArray(t[o])||Array.isArray(r[o]))){let i=Array.isArray(t[o])?t[o]:[],a=Array.isArray(r[o])?r[o]:[],s=In(e.getLeftDifferences(In(i,n),In(a,n))),l=In(e.getRightDifferences(In(i,n),In(a,n)));if(Object.keys(s).length||Object.keys(l).length){let c=i.filter(m=>s[n?n(m):String(m)]),d=a.filter(m=>l[n?n(m):String(m)]);Reflect.set(t,o,c),Reflect.set(r,o,d)}else Reflect.deleteProperty(t,o),Reflect.deleteProperty(r,o)}}static isLeftDifferent(t,r,o=!1){return!!this.distinctKeysIterator("left",t,r,o).next().value}static isRightDifferent(t,r,o=!1){return!!this.distinctKeysIterator("right",t,r,o).next().value}static getLeftDifferences(t,r,o=!1){return Array.from(this.distinctKeysIterator("left",t,r,o))}static getRightDifferences(t,r,o=!1){return Array.from(this.distinctKeysIterator("right",t,r,o))}static*distinctKeysIterator(t,r,o,n=!1){if(r===o)return;let i=[];t==="left"?i=Object.keys(r):t==="right"?i=Object.keys(o):t==="full"?i=Array.from(new Set([...Object.keys(r),...Object.keys(o)])):$o(t,`Unknown distinctKeysIterator's join param "${t}"`,!0);for(let a of i){let s=r[a],l=o[a];if(s!==l){if(!n&&typeof s=="object"&&typeof l=="object"&&s!==null&&l!==null&&it(s,l))continue;yield a}}}},td=class e{constructor(t){this.delta=t}static calculate(t,r){let o=Tt.calculate(t,r,void 0,e.postProcess);return new e(o)}static empty(){return new e(Tt.create({},{}))}inverse(){let t=Tt.create(this.delta.inserted,this.delta.deleted);return new e(t)}applyTo(t,r){try{let{selectedElementIds:o={},selectedGroupIds:n={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:s,editingLinearElementId:l,...c}=this.delta.inserted,d=Tt.mergeObjects(t.selectedElementIds,i,o),m=Tt.mergeObjects(t.selectedGroupIds,a,n),p=s&&r.has(s)?new K(r.get(s)):null,u=l&&r.has(l)?new K(r.get(l)):null,g={...t,...c,selectedElementIds:d,selectedGroupIds:m,selectedLinearElement:typeof s<"u"?p:t.selectedLinearElement,editingLinearElement:typeof l<"u"?u:t.editingLinearElement},h=this.filterInvisibleChanges(t,g,r);return[g,h]}catch(o){if(console.error("Couldn't apply appstate change",o),T.DEV||T.MODE===Kt.TEST)throw o;return[t,!1]}}isEmpty(){return Tt.isEmpty(this.delta)}static postProcess(t,r){try{Tt.diffObjects(t,r,"selectedElementIds",o=>!0),Tt.diffObjects(t,r,"selectedGroupIds",o=>o??!1)}catch(o){if(console.error("Couldn't postprocess appstate change deltas."),T.DEV||T.MODE===Kt.TEST)throw o}finally{return[t,r]}}filterInvisibleChanges(t,r,o){let n=od(t),i=od(r),a=Tt.isRightDifferent(e.stripElementsProps(n),e.stripElementsProps(i)),s=Tt.isRightDifferent(e.stripStandaloneProps(n),e.stripStandaloneProps(i));if(!a&&!s)return!1;let l={value:a};if(s){let c=Tt.getRightDifferences(e.stripStandaloneProps(n),e.stripStandaloneProps(i)),d=new Set;(c.includes("editingGroupId")||c.includes("selectedGroupIds"))&&(d=j0(o));for(let m of c)switch(m){case"selectedElementIds":r[m]=e.filterSelectedElements(r[m],o,l);break;case"selectedGroupIds":r[m]=e.filterSelectedGroups(r[m],d,l);break;case"editingGroupId":let p=r[m];p?d.has(p)?l.value=!0:r[m]=null:l.value=!0;break;case"selectedLinearElementId":case"editingLinearElementId":let u=e.convertToAppStateKey(m),g=r[u];if(!g)l.value=!0;else{let h=o.get(g.elementId);h&&!h.isDeleted?l.value=!0:r[u]=null}break;default:$o(m,`Unknown ObservedElementsAppState's key "${m}"`,!0)}}return l.value}static convertToAppStateKey(t){switch(t){case"selectedLinearElementId":return"selectedLinearElement";case"editingLinearElementId":return"editingLinearElement"}}static filterSelectedElements(t,r,o){let n=Object.keys(t);if(!n.length)return o.value=!0,t;let i={...t};for(let a of n){let s=r.get(a);s&&!s.isDeleted?o.value=!0:delete i[a]}return i}static filterSelectedGroups(t,r,o){if(!Object.keys(t).length)return o.value=!0,t;let i={...t};for(let a of Object.keys(i))r.has(a)?o.value=!0:delete i[a];return i}static stripElementsProps(t){let{editingGroupId:r,selectedGroupIds:o,selectedElementIds:n,editingLinearElementId:i,selectedLinearElementId:a,...s}=t;return s}static stripStandaloneProps(t){let{name:r,viewBackgroundColor:o,...n}=t;return n}},rd=class e{constructor(t,r,o){this.added=t;this.removed=r;this.updated=o}static create(t,r,o,n={shouldRedistribute:!1}){let i;if(n.shouldRedistribute){let a=new Map,s=new Map,l=new Map,c=[...t,...r,...o];for(let[d,m]of c)this.satisfiesAddition(m)?a.set(d,m):this.satisfiesRemoval(m)?s.set(d,m):l.set(d,m);i=new e(a,s,l)}else i=new e(t,r,o);return(T.DEV||T.MODE===Kt.TEST)&&(e.validate(i,"added",this.satisfiesAddition),e.validate(i,"removed",this.satisfiesRemoval),e.validate(i,"updated",this.satisfiesUpdate)),i}static satisfiesAddition=({deleted:t,inserted:r})=>t.isDeleted===!0&&!r.isDeleted;static satisfiesRemoval=({deleted:t,inserted:r})=>!t.isDeleted&&r.isDeleted===!0;static satisfiesUpdate=({deleted:t,inserted:r})=>!!t.isDeleted==!!r.isDeleted;static validate(t,r,o){for(let[n,i]of t[r].entries())if(!o(i))throw console.error(`Broken invariant for "${r}" delta, element "${n}", delta:`,i),new Error(`ElementsChange invariant broken for element "${n}".`)}static calculate(t,r){if(t===r)return e.empty();let o=new Map,n=new Map,i=new Map;for(let a of t.values())if(!r.get(a.id)){let l={...a,isDeleted:!1},c={isDeleted:!0},d=Tt.create(l,c,e.stripIrrelevantProps);n.set(a.id,d)}for(let a of r.values()){let s=t.get(a.id);if(!s){let l={isDeleted:!0},c={...a,isDeleted:!1},d=Tt.create(l,c,e.stripIrrelevantProps);o.set(a.id,d);continue}if(s.versionNonce!==a.versionNonce){let l=Tt.calculate(s,a,e.stripIrrelevantProps,e.postProcess);if(typeof s.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&s.isDeleted!==a.isDeleted){s.isDeleted&&!a.isDeleted?o.set(a.id,l):n.set(a.id,l);continue}Tt.isEmpty(l)||i.set(a.id,l)}}return e.create(o,n,i)}static empty(){return e.create(new Map,new Map,new Map)}inverse(){let t=i=>{let a=new Map;for(let[s,l]of i.entries())a.set(s,Tt.create(l.inserted,l.deleted));return a},r=t(this.added),o=t(this.removed),n=t(this.updated);return e.create(o,r,n)}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}applyLatestChanges(t){let r=s=>l=>{let c={};for(let d of Object.keys(l))switch(d){case"boundElements":c[d]=l[d];break;default:c[d]=s[d]}return c},o=s=>{let l=new Map;for(let[c,d]of s.entries()){let m=t.get(c);if(m){let p=Tt.create(d.deleted,d.inserted,r(m),"inserted");l.set(c,p)}else l.set(c,d)}return l},n=o(this.added),i=o(this.removed),a=o(this.updated);return e.create(n,i,a,{shouldRedistribute:!0})}applyTo(t,r,o){let n=Mr(new Map(t)),i,a={containsVisibleDifference:!1,containsZindexDifference:!1};try{let s=e.createApplier(n,r,a),l=s(this.added),c=s(this.removed),d=s(this.updated),m=this.resolveConflicts(t,n);i=new Map([...l,...c,...d,...m])}catch(s){if(console.error("Couldn't apply elements change",s),T.DEV||T.MODE===Kt.TEST)throw s;return[t,!0]}try{e.redrawTextBoundingBoxes(n,i),e.redrawBoundArrows(n,i,o),n=e.reorderElements(n,i,a)}catch(s){if(console.error("Couldn't mutate elements after applying elements change",s),T.DEV||T.MODE===Kt.TEST)throw s}finally{return[n,a.containsVisibleDifference]}}static createApplier=(t,r,o)=>{let n=e.createGetter(t,r,o);return i=>Array.from(i.entries()).reduce((a,[s,l])=>{let c=n(s,l.inserted);if(c){let d=e.applyDelta(c,l,o);t.set(d.id,d),a.set(d.id,d)}return a},new Map)};static createGetter=(t,r,o)=>(n,i)=>{let a=t.get(n);return a||(a=r.get(n),a&&(o.containsZindexDifference=!0,(i.isDeleted===!1||i.isDeleted!==!0&&a.isDeleted===!1)&&(o.containsVisibleDifference=!0))),a};static applyDelta(t,r,o={containsVisibleDifference:!0,containsZindexDifference:!0}){let{boundElements:n,...i}=r.inserted;if(r.deleted.boundElements?.length||r.inserted.boundElements?.length){let a=Tt.mergeArrays(t.boundElements,r.inserted.boundElements,r.deleted.boundElements,s=>s.id);Object.assign(i,{boundElements:a})}if(!o.containsVisibleDifference){let{index:a,...s}=i,l=e.checkForVisibleDifference(t,s);o.containsVisibleDifference=l}return o.containsZindexDifference||(o.containsZindexDifference=r.deleted.index!==r.inserted.index),pe(t,i)}static checkForVisibleDifference(t,r){return t.isDeleted&&r.isDeleted!==!1?!1:t.isDeleted&&r.isDeleted===!1||t.isDeleted===!1&&r.isDeleted?!0:Tt.isRightDifferent(t,r)}resolveConflicts(t,r){let o=new Map,n=(c,d)=>{let m=r.get(c.id);if(!m)return;let p;t.get(c.id)===m?p=pe(m,d):p=F(m,d),o.set(p.id,p),r.set(p.id,p)};for(let[c]of this.removed)e.unbindAffected(t,r,c,n);for(let[c]of this.added)e.rebindAffected(t,r,c,n);for(let[c]of Array.from(this.updated).filter(([d,m])=>Object.keys({...m.deleted,...m.inserted}).find(p=>Dv.has(p)))){let d=r.get(c);!d||d.isDeleted||e.rebindAffected(t,r,c,n)}let i=new Map(Array.from(t).filter(([c])=>o.has(c))),{added:a,removed:s,updated:l}=e.calculate(i,o);for(let[c,d]of a)this.added.set(c,d);for(let[c,d]of s)this.removed.set(c,d);for(let[c,d]of l)this.updated.set(c,d);return o}static unbindAffected(t,r,o,n){let i=()=>t.get(o),a=()=>r.get(o);Qi.unbindAffected(r,i(),n),Qi.unbindAffected(r,a(),n),ea.unbindAffected(r,i(),n),ea.unbindAffected(r,a(),n)}static rebindAffected(t,r,o,n){let i=()=>t.get(o),a=()=>r.get(o);Qi.unbindAffected(r,i(),n),Qi.rebindAffected(r,a(),n),ea.unbindAffected(r,i(),(s,l)=>{H(s)&&n(s,l)}),ea.rebindAffected(r,a(),n)}static redrawTextBoundingBoxes(t,r){let o=new Map;for(let n of r.values()){if(ze(n)){let{containerId:i}=n,a=i?t.get(i):void 0;a&&o.set(a.id,{container:a,boundText:n})}if(Ct(n)){let i=pn(n),a=i?t.get(i):void 0;a&&o.set(n.id,{container:n,boundText:a})}}for(let{container:n,boundText:i}of o.values())n.isDeleted||i.isDeleted||ft(i,n,t,!1)}static redrawBoundArrows(t,r,o){for(let n of r.values())!n.isDeleted&&An(n)&&qt(n,t,o,{changedElements:r})}static reorderElements(t,r,o){if(!o.containsZindexDifference)return t;let n=Array.from(t.values()),i=Xp([...n]),a=Tt.getRightDifferences(n,i,!0).reduce((s,l)=>{let c=n[Number(l)];return c&&r.has(c.id)&&s.set(c.id,c),s},new Map);return!o.containsVisibleDifference&&a.size&&(o.containsVisibleDifference=!0),Z(Jt(i,a))}static postProcess(t,r){try{Tt.diffArrays(t,r,"boundElements",o=>o.id)}catch(o){if(console.error("Couldn't postprocess elements change deltas."),T.DEV||T.MODE===Kt.TEST)throw o}finally{return[t,r]}}static stripIrrelevantProps(t){let{id:r,updated:o,version:n,versionNonce:i,seed:a,...s}=t;return s}}});var wr,nd=X(()=>{"use strict";f();wr=class{subscribers=[];on(...t){let r=t.flat().filter(o=>typeof o=="function");return this.subscribers.push(...r),()=>this.off(r)}once(...t){let r=t.flat().filter(n=>typeof n=="function");r.push(()=>o());let o=this.on(...r);return o}off(...t){let r=t.flat();this.subscribers=this.subscribers.filter(o=>!r.includes(o))}trigger(...t){for(let r of this.subscribers)r(...t);return this}clear(){this.subscribers=[]}}});var Nv,od,q4,_,qf,Kp,$p,Re=X(()=>{"use strict";f();Zr();Rv();Y();De();Nn();nd();V();Nv="__observedAppState",od=e=>{let t={name:e.name,editingGroupId:e.editingGroupId,viewBackgroundColor:e.viewBackgroundColor,selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,editingLinearElementId:e.editingLinearElement?.elementId||null,selectedLinearElementId:e.selectedLinearElement?.elementId||null};return Reflect.defineProperty(t,Nv,{value:!0,enumerable:!1}),t},q4=e=>!!Reflect.get(e,Nv),_={CAPTURE:"capture",UPDATE:"update",NONE:"none"},qf=class{constructor(t,r){this.elementsChange=t;this.appStateChange=r}},Kp=class{onStoreIncrementEmitter=new wr;scheduledActions=new Set;_snapshot=$p.empty();get snapshot(){return this._snapshot}set snapshot(t){this._snapshot=t}shouldCaptureIncrement=()=>{this.scheduleAction(_.CAPTURE)};shouldUpdateSnapshot=()=>{this.scheduleAction(_.UPDATE)};scheduleAction=t=>{this.scheduledActions.add(t),this.satisfiesScheduledActionsInvariant()};commit=(t,r)=>{try{this.scheduledActions.has(_.CAPTURE)?this.captureIncrement(t,r):this.scheduledActions.has(_.UPDATE)&&this.updateSnapshot(t,r)}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledActions=new Set}};captureIncrement=(t,r)=>{let o=this.snapshot,n=this.snapshot.maybeClone(t,r);if(o!==n){let i=n.meta.didElementsChange?rd.calculate(o.elements,n.elements):rd.empty(),a=n.meta.didAppStateChange?td.calculate(o.appState,n.appState):td.empty();(!i.isEmpty()||!a.isEmpty())&&this.onStoreIncrementEmitter.trigger(new qf(i,a)),this.snapshot=n}};updateSnapshot=(t,r)=>{let o=this.snapshot.maybeClone(t,r);this.snapshot!==o&&(this.snapshot=o)};filterUncomittedElements=(t,r)=>{for(let[o,n]of t.entries()){if(!r.get(o))continue;let a=this.snapshot.elements.get(o);a?a.version<n.version&&r.set(o,a):r.delete(o)}return r};clear=()=>{this.snapshot=$p.empty(),this.scheduledActions=new Set};satisfiesScheduledActionsInvariant=()=>{if(!(this.scheduledActions.size>=0&&this.scheduledActions.size<=3)){let t=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledActions.size}".`;if(console.error(t,this.scheduledActions.values()),T.DEV||T.MODE===Kt.TEST)throw new Error(t)}}},$p=class e{constructor(t,r,o={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=t;this.appState=r;this.meta=o}static empty(){return new e(new Map,od(lr()),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return this.meta.isEmpty}maybeClone(t,r){let o=this.maybeCreateElementsSnapshot(t),n=this.maybeCreateAppStateSnapshot(r),i=!1,a=!1;return this.elements!==o&&(i=!0),this.appState!==n&&(a=!0),!i&&!a?this:new e(o,n,{didElementsChange:i,didAppStateChange:a})}maybeCreateAppStateSnapshot(t){if(!t)return this.appState;let r=q4(t)?t:od(t);return this.detectChangedAppState(r)?r:this.appState}detectChangedAppState(t){return!it(this.appState,t,{selectedElementIds:it,selectedGroupIds:it})}maybeCreateElementsSnapshot(t){return t?this.detectChangedElements(t)?this.createElementsSnapshot(t):this.elements:this.elements}detectChangedElements(t){if(this.elements===t)return!1;if(this.elements.size!==t.size)return!0;let r=Array.from(t.keys());for(let o=r.length-1;o>=0;o--){let n=this.elements.get(r[o]),i=t.get(r[o]);if(!n||!i||n.id!==i.id||n.versionNonce!==i.versionNonce)return!0}return!1}createElementsSnapshot(t){let r=new Map;for(let[o,n]of this.elements.entries())t.get(o)?r.set(o,n):r.set(o,pe(n,{isDeleted:!0}));for(let[o,n]of t.entries()){let i=r.get(o);(!i||i&&i.versionNonce!==n.versionNonce)&&r.set(o,an(n))}return r}}});var Ei,J4,Q4,eM,Ov,tM,Fv,rM,oM,nM,Bv,Jf,zv,id,xi,Zp,KU,Qf,Hv,hl,ad=X(()=>{"use strict";f();$e();Y();V();Gs();Nn();He();me();Oa();Re();Ei=new Map,J4=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)(?:\?t=|&t=|\?start=|&start=)?([a-zA-Z0-9_-]+)?[^\s]*$/,Q4=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}\.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,eM=/^https:\/\/(?:www\.)?figma\.com/,Ov=/^https:\/\/gist\.github\.com\/([\w_-]+)\/([\w_-]+)/,tM=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist\.github\.com\/.*?)\.js["']/i,Fv=/(?:https?:\/\/)?(?:(?:w){3}\.)?(?:twitter|x)\.com\/[^/]+\/status\/(\d+)/,rM=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:twitter|x)\.com\/[^"']*)/i,oM=/^https:\/\/(?:www\.)?val\.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,nM=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,Bv=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,Jf=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","link.excalidraw.com","gist.github.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","val.town","giphy.com"]),zv=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com"]),id=e=>`<html><body>${e}</body></html>`,xi=e=>{if(!e)return null;if(Ei.has(e))return Ei.get(e);let t=e,r=zv.has(Qf(e,zv)||""),o="generic",n={w:560,h:840},i=e.match(J4);if(i?.[2]){let c=i[3]?`&start=${i[3]}`:"",d=e.includes("shorts");switch(o="video",i[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${c}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${i[2]}&enablejsapi=1${c}`;break;default:e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${c}`;break}return n=d?{w:315,h:560}:{w:560,h:315},Ei.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}}let a=e.match(Q4);if(a?.[1]){let c=a?.[1],d=/^\d+$/.test(c)?void 0:new URIError("Invalid embed link format");return o="video",e=`https://player.vimeo.com/video/${c}?api=1`,n={w:560,h:315},Ei.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,error:d,sandbox:{allowSameOrigin:r}}}if(e.match(eM))return o="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,n={w:550,h:550},Ei.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}};let l=e.match(oM);if(l)return e=l[1]==="embed"?l[0]:l[0].replace("/v","/embed"),Ei.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}};if(Fv.test(e)){let c=e.match(Fv)[1],d=Ym(`https://twitter.com/x/status/${c}`),m={type:"document",srcdoc:p=>id(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${p}"><a href="${d}"></a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`),intrinsicSize:{w:480,h:480},sandbox:{allowSameOrigin:r}};return Ei.set(t,m),m}if(Ov.test(e)){let[,c,d]=e.match(Ov),m=Ym(`https://gist.github.com/${c}/${d}`),p={type:"document",srcdoc:()=>id(`
|
|
16
3
|
<script src="${m}.js"><\/script>
|
|
17
4
|
<style type="text/css">
|
|
18
5
|
* { margin: 0px; }
|
|
19
6
|
table, .gist { height: 100%; }
|
|
20
7
|
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
21
8
|
</style>
|
|
22
|
-
`),intrinsicSize:{w:550,h:720},sandbox:{allowSameOrigin:r}};return
|
|
9
|
+
`),intrinsicSize:{w:550,h:720},sandbox:{allowSameOrigin:r}};return Ei.set(e,p),p}return Ei.set(e,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}},Zp=e=>{let t;Io(e)?t="IFrame element":t=!e.link||e?.link===""?"Empty Web-Embed":e.link;let r=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),o=Le.Helvetica,n=Me({fontSize:r,fontFamily:o});return jt({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:o,fontSize:r,text:Lo(t,n,e.width-20),textAlign:"center",verticalAlign:kt.MIDDLE,angle:e.angle??0})},KU=G({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,t,r,o)=>{let n=nt(t,{type:"embeddable"});return po(o.canvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:nt(t,{type:"embeddable"})},storeAction:_.NONE}}}),Qf=(e,t)=>{try{let{hostname:r}=new URL(e),o=r.replace(/^www\./,"");if(t instanceof Set){if(Jf.has(o))return o;let i=o.replace(/^([^.]+)/,"*");return Jf.has(i)?i:null}let n=t.replace(/^www\./,"");if(o===n)return n}catch{}return null},Hv=e=>{let t=e.match(rM);if(t&&t.length===2)return t[1];let r=e.match(tM);if(r&&r.length===2)return r[1];if(Bv.test(e))return`https://giphy.com/embed/${Bv.exec(e)[1]}`;let o=e.match(nM);return o&&o.length===2?o[1]:e},hl=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){let r=t(e);if(typeof r=="boolean")return r}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(let r of t)if(r instanceof RegExp){if(e.match(r))return!0}else if(Qf(e,r))return!0;return!1}}return!!Qf(e,Jf)}});var sd,ld,jp,Uv,Gv=X(()=>{"use strict";f();Y();Oa();we();ad();Wt();He();me();vr();mt();Qo();V();li();on();sd=(e,t,r)=>{if(typeof r>"u")return e.draw(t);let o={sets:t.sets,shape:t.shape,options:{...t.options,fixedDecimalPlaceDigits:r}};return e.draw(o)},ld=(e,t,r,o,n)=>{if(!o.enabled||!o.clip)return null;let i=Qt(e,n);if(i){let a=t.ownerDocument.createElementNS(Ke,"g");return a.setAttributeNS(Ke,"clip-path",`url(#${i.id})`),r.forEach(s=>a.appendChild(s)),a}return null},jp=(e,t,r,o,n,i,a,s)=>{let l={x:i,y:a},[c,d,m,p]=ae(e,t),u=(m-c)/2-(e.x-c),g=(p-d)/2-(e.y-d);if(H(e)){let w=Et(e,t);if(ne(w)){let[C,M,I,P]=ae(w,t),A=K.getBoundTextElementPosition(w,e,t);u=(I-C)/2-(A.x-C),g=(P-M)/2-(A.y-M),i=i+A.x-e.x,a=a+A.y-e.y}}let h=180*e.angle/Math.PI,x=o;if(e.link){let w=o.ownerDocument.createElementNS(Ke,"a");w.setAttribute("href",Pr(e.link)),x.appendChild(w),x=w}let v=(w,C)=>{Yr()&&w.setAttribute("data-id",C.id),x.appendChild(w)},y=(Qt(e,t)?.opacity??100)*e.opacity/1e4;switch(e.type){case"selection":throw new Error("Selection rendering is not supported for SVG");case"rectangle":case"diamond":case"ellipse":{let w=_e.generateElementShape(e,null),C=sd(r,w,Bs);y!==1&&(C.setAttribute("stroke-opacity",`${y}`),C.setAttribute("fill-opacity",`${y}`)),C.setAttribute("stroke-linecap","round"),C.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`);let M=ld(e,x,[C],s.frameRendering,t);v(M||C,e);break}case"iframe":case"embeddable":{let w=_e.generateElementShape(e,s),C=sd(r,w,Bs),M=e.opacity/100;M!==1&&(C.setAttribute("stroke-opacity",`${M}`),C.setAttribute("fill-opacity",`${M}`)),C.setAttribute("stroke-linecap","round"),C.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),v(C,e);let I=Zp(e);jp(I,t,r,x,n,I.x+l.x-e.x,I.y+l.y-e.y,s);let P=sd(r,w,Bs);for(P.setAttribute("stroke-linecap","round"),P.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`);P.firstChild;)P.removeChild(P.firstChild);let A=fo(Math.min(e.width,e.height),e),N=xi(Km(e.link||""));if(s.renderEmbeddables===!1||N?.type==="document"){let k=o.ownerDocument.createElementNS(Ke,"a");k.setAttribute("href",Pr(e.link||"")),k.setAttribute("target","_blank"),k.setAttribute("rel","noopener noreferrer"),k.style.borderRadius=`${A}px`,P.appendChild(k)}else{let k=o.ownerDocument.createElementNS(Ke,"foreignObject");k.style.width=`${e.width}px`,k.style.height=`${e.height}px`,k.style.border="none";let D=k.ownerDocument.createElementNS(Ke,"div");D.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),D.style.width="100%",D.style.height="100%";let z=D.ownerDocument.createElement("iframe");z.src=N?.link??"",z.style.width="100%",z.style.height="100%",z.style.border="none",z.style.borderRadius=`${A}px`,z.style.top="0",z.style.left="0",z.allowFullscreen=!0,D.appendChild(z),k.appendChild(D),P.appendChild(k)}v(P,e);break}case"line":case"arrow":{let w=J(e,t),C=o.ownerDocument.createElementNS(Ke,"mask");if(w){C.setAttribute("id",`mask-${e.id}`);let A=o.ownerDocument.createElementNS(Ke,"rect");i=i||0,a=a||0,A.setAttribute("x","0"),A.setAttribute("y","0"),A.setAttribute("fill","#fff"),A.setAttribute("width",`${e.width+100+i}`),A.setAttribute("height",`${e.height+100+a}`),C.appendChild(A);let N=o.ownerDocument.createElementNS(Ke,"rect"),k=K.getBoundTextElementPosition(e,w,t),D=i+k.x-e.x,z=a+k.y-e.y;N.setAttribute("x",D.toString()),N.setAttribute("y",z.toString()),N.setAttribute("fill","#000"),N.setAttribute("width",`${w.width}`),N.setAttribute("height",`${w.height}`),N.setAttribute("opacity","1"),C.appendChild(N)}let M=o.ownerDocument.createElementNS(Ke,"g");w&&M.setAttribute("mask",`url(#mask-${e.id})`),M.setAttribute("stroke-linecap","round"),_e.generateElementShape(e,s).forEach(A=>{let N=sd(r,A,Bs);y!==1&&(N.setAttribute("stroke-opacity",`${y}`),N.setAttribute("fill-opacity",`${y}`)),N.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),e.type==="line"&&Dr(e.points)&&e.backgroundColor!=="transparent"&&N.setAttribute("fill-rule","evenodd"),M.appendChild(N)});let P=ld(e,x,[M,C],s.frameRendering,t);P?(v(P,e),x.appendChild(P)):(v(M,e),x.append(C));break}case"freedraw":{let w=_e.generateElementShape(e,s),C=w?sd(r,w,Bs):o.ownerDocument.createElementNS(Ke,"g");y!==1&&(C.setAttribute("stroke-opacity",`${y}`),C.setAttribute("fill-opacity",`${y}`)),C.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),C.setAttribute("stroke","none");let M=o.ownerDocument.createElementNS(Ke,"path");M.setAttribute("fill",e.strokeColor),M.setAttribute("d",qp(e)),C.appendChild(M);let I=ld(e,x,[C],s.frameRendering,t);v(I||C,e);break}case"image":{let w=Math.round(e.width),C=Math.round(e.height),M=kr(e)&&n[e.fileId];if(M){let I=`image-${M.id}`,P=o.querySelector(`#${I}`);if(!P){P=o.ownerDocument.createElementNS(Ke,"symbol"),P.id=I;let D=o.ownerDocument.createElementNS(Ke,"image");D.setAttribute("width","100%"),D.setAttribute("height","100%"),D.setAttribute("href",M.dataURL),P.appendChild(D),x.prepend(P)}let A=o.ownerDocument.createElementNS(Ke,"use");if(A.setAttribute("href",`#${I}`),s.exportWithDarkMode&&M.mimeType!==se.svg&&A.setAttribute("filter",eb),A.setAttribute("width",`${w}`),A.setAttribute("height",`${C}`),A.setAttribute("opacity",`${y}`),e.scale[0]!==1||e.scale[1]!==1){let D=e.scale[0]!==1?-w:0,z=e.scale[1]!==1?-C:0;A.setAttribute("transform",`scale(${e.scale[0]}, ${e.scale[1]}) translate(${D} ${z})`)}let N=o.ownerDocument.createElementNS(Ke,"g");if(N.appendChild(A),N.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),e.roundness){let D=o.ownerDocument.createElementNS(Ke,"clipPath");D.id=`image-clipPath-${e.id}`;let z=o.ownerDocument.createElementNS(Ke,"rect"),R=fo(Math.min(e.width,e.height),e);z.setAttribute("width",`${e.width}`),z.setAttribute("height",`${e.height}`),z.setAttribute("rx",`${R}`),z.setAttribute("ry",`${R}`),D.appendChild(z),v(D,e),N.setAttributeNS(Ke,"clip-path",`url(#${D.id})`)}let k=ld(e,x,[N],s.frameRendering,t);v(k||N,e)}break}case"frame":case"magicframe":{if(s.frameRendering.enabled&&s.frameRendering.outline){let w=document.createElementNS(Ke,"rect");w.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),w.setAttribute("width",`${e.width}px`),w.setAttribute("height",`${e.height}px`),w.setAttribute("rx",rt.radius.toString()),w.setAttribute("ry",rt.radius.toString()),w.setAttribute("fill","none"),w.setAttribute("stroke",rt.strokeColor),w.setAttribute("stroke-width",rt.strokeWidth.toString()),v(w,e)}break}default:if(H(e)){let w=o.ownerDocument.createElementNS(Ke,"g");y!==1&&(w.setAttribute("stroke-opacity",`${y}`),w.setAttribute("fill-opacity",`${y}`)),w.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`);let C=e.text.replace(/\r\n?/g,`
|
|
23
10
|
`).split(`
|
|
24
|
-
`),A=Ci(e.fontSize,e.lineHeight),C=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,L=gm(e.fontFamily,e.fontSize,A),M=Vd(e.text)?"rtl":"ltr",z=e.textAlign==="center"?"middle":e.textAlign==="right"||M==="rtl"?"end":"start";for(let N=0;N<I.length;N++){let B=o.ownerDocument.createElementNS(We,"text");B.textContent=I[N],B.setAttribute("x",`${C}`),B.setAttribute("y",`${N*A+L}`),B.setAttribute("font-family",ls(e)),B.setAttribute("font-size",`${e.fontSize}px`),B.setAttribute("fill",e.strokeColor),B.setAttribute("text-anchor",z),B.setAttribute("style","white-space: pre;"),B.setAttribute("direction",M),B.setAttribute("dominant-baseline","alphabetic"),w.appendChild(B)}let k=Ec(e,x,[w],s.frameRendering,t);v(k||w,e)}else throw new Error(`Unimplemented type ${e.type}`)}},Y0=(e,t,r,o,n,i)=>{o&&(e.filter(a=>!jt(a)).forEach(a=>{if(!a.isDeleted){if(U(a)&&a.containerId&&t.has(a.containerId))return;try{_m(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i);let s=ae(a,t);s&&_m(s,t,r,o,n,s.x+i.offsetX,s.y+i.offsetY,i)}catch(s){console.error(s)}}}),e.filter(a=>jt(a)).forEach(a=>{if(!a.isDeleted)try{_m(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i)}catch(s){console.error(s)}}))}});import{fileOpen as AA,fileSave as kA,supported as ki}from"browser-fs-access";var $0,Ds,_s,$n=Q(()=>{"use strict";f();Y();fi();G();$0=500,Ds=e=>{let t=e.extensions?.reduce((o,n)=>(o.push(oe[n]),o),[]),r=e.extensions?.reduce((o,n)=>n==="jpg"?o.concat(".jpg",".jpeg"):o.concat(`.${n}`),[]);return AA({description:e.description,extensions:r,mimeTypes:t,multiple:e.multiple??!1,legacySetup:(o,n,i)=>{let a=aa(n,$0),s=()=>{l(),document.addEventListener("keyup",a),document.addEventListener("pointerup",a),a()},l=()=>{if(i.files?.length){let d=e.multiple?[...i.files]:i.files[0];o(d)}};requestAnimationFrame(()=>{window.addEventListener("focus",s)});let c=window.setInterval(()=>{l()},$0);return d=>{clearInterval(c),a.cancel(),window.removeEventListener("focus",s),document.removeEventListener("keyup",a),document.removeEventListener("pointerup",a),d&&(console.warn("Opening the file was canceled (legacy-fs)."),d(new mn))}}})},_s=(e,t)=>kA(e,{fileName:`${t.name}.${t.extension}`,description:t.description,extensions:[`.${t.extension}`]},t.fileHandle)});var MA,LA,X0,Rs,PA,DA,_A,RA,xc,NA,Z0,q0,Mi,j0,Ia,Ns=Q(()=>{"use strict";f();be();le();zo();Y();Or();Jt();Ae();G();G();Je();Sa();ho();ps();MA={selection:!0,text:!0,rectangle:!0,diamond:!0,ellipse:!0,line:!0,image:!0,arrow:!0,freedraw:!0,eraser:!1,custom:!0,frame:!0,embeddable:!0,hand:!0,laser:!1,magicframe:!1},LA=e=>Object.keys(mt).includes(e)?mt[e]:Zt,X0=e=>e?{...e,focus:e.focus||0}:null,Rs=(e,t)=>{let r={type:t.type||e.type,version:e.version||1,versionNonce:e.versionNonce??0,index:e.index??null,isDeleted:e.isDeleted??!1,id:e.id||Nt(),fillStyle:e.fillStyle||nt.fillStyle,strokeWidth:e.strokeWidth||nt.strokeWidth,strokeStyle:e.strokeStyle??nt.strokeStyle,roughness:e.roughness??nt.roughness,opacity:e.opacity==null?nt.opacity:e.opacity,angle:e.angle||0,x:t.x??e.x??0,y:t.y??e.y??0,strokeColor:e.strokeColor||nt.strokeColor,backgroundColor:e.backgroundColor||nt.backgroundColor,width:e.width||0,height:e.height||0,seed:e.seed??1,groupIds:e.groupIds??[],frameId:e.frameId??null,roundness:e.roundness?e.roundness:e.strokeSharpness==="round"?{type:dn(e.type)?lt.LEGACY:lt.PROPORTIONAL_RADIUS}:null,boundElements:e.boundElementIds?e.boundElementIds.map(o=>({type:"arrow",id:o})):e.boundElements??[],updated:e.updated??Fn(),link:e.link?vr(e.link):null,locked:e.locked??!1};return("customData"in e||"customData"in t)&&(r.customData="customData"in t?t.customData:e.customData),{...r,...yc(r),...t}},PA=e=>{switch(e.type){case"text":let t=e.fontSize,r=e.fontFamily;if("font"in e){let[i,a]=e.font.split(" ");t=parseFloat(i),r=LA(a)}let o=typeof e.text=="string"&&e.text||"",n=e.lineHeight||(e.height?u0(e):qr(e.fontFamily));return e=Rs(e,{fontSize:t,fontFamily:r,text:o,textAlign:e.textAlign||nn,verticalAlign:e.verticalAlign||oa,containerId:e.containerId??null,originalText:e.originalText||o,autoResize:e.autoResize??!0,lineHeight:n}),!o&&!e.isDeleted&&(e={...e,originalText:o,isDeleted:!0},e=Ai(e)),e;case"freedraw":return Rs(e,{points:e.points,lastCommittedPoint:null,simulatePressure:e.simulatePressure,pressures:e.pressures});case"image":return Rs(e,{status:e.status||"pending",fileId:e.fileId,scale:e.scale||[1,1]});case"line":case"draw":case"arrow":{let{startArrowhead:i=null,endArrowhead:a=e.type==="arrow"?"arrow":null}=e,s=e.x,l=e.y,c=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(c[0][0]!==0||c[0][1]!==0)&&({points:c,x:s,y:l}=j.getNormalizedPoints(e)),Rs(e,{type:e.type==="draw"?"line":e.type,startBinding:X0(e.startBinding),endBinding:X0(e.endBinding),lastCommittedPoint:null,startArrowhead:i,endArrowhead:a,points:c,x:s,y:l,...ms(c)})}case"ellipse":case"rectangle":case"diamond":case"iframe":case"embeddable":return Rs(e,{});case"magicframe":case"frame":return Rs(e,{name:e.name??null})}return null},DA=(e,t)=>{if(e.boundElements){let r=e.boundElements.slice(),o=new Set;e.boundElements=r.reduce((n,i)=>{let a=t.get(i.id);if(a&&!o.has(i.id)){if(o.add(i.id),a.isDeleted)return n;n.push(i),U(a)&&!a.containerId&&(a.containerId=e.id)}return n},[])}},_A=(e,t)=>{let r=e.containerId?t.get(e.containerId):null;if(!r){e.containerId=null;return}if(!e.isDeleted&&r.boundElements&&!r.boundElements.find(o=>o.id===e.id)){let o=(r.boundElements||(r.boundElements=[])).slice();o.push({type:"text",id:e.id}),r.boundElements=o}},RA=(e,t)=>{e.frameId&&(t.get(e.frameId)||(e.frameId=null))},xc=(e,t,r)=>{let o=new Set,n=t?X(t):null,i=yr((e||[]).reduce((s,l)=>{if(l.type!=="selection"&&!Eo(l)){let c=PA(l);if(c){let d=n?.get(l.id);d&&d.version>c.version&&(c=Ai(c,d.version)),o.has(c.id)&&(c={...c,id:Nt()}),o.add(c.id),s.push(c)}}return s},[]));if(!r?.repairBindings)return i;let a=X(i);for(let s of i)s.frameId&&RA(s,a),U(s)&&s.containerId?_A(s,a):s.boundElements&&DA(s,a),r.refreshDimensions&&U(s)&&Object.assign(s,Xo(s,wt(s,a),a));return i},NA=(e,t,r)=>{let o=t[e];return o!==void 0?o:r[e]},Z0={isSidebarDocked:(e,t)=>["defaultSidebarDockedPreference",e.isSidebarDocked??NA("defaultSidebarDockedPreference",e,t)]},q0=(e,t)=>{e=e||{};let r=Qt(),o={};for(let n of Object.keys(Z0))if(n in e){let[i,a]=Z0[n](e,r);o[i]=a}for(let[n,i]of Object.entries(r)){let a=e[n],s=t?t[n]:void 0;o[n]=a!==void 0?a:s!==void 0?s:i}return{...o,cursorButton:t?.cursorButton||"up",penDetected:t?.penDetected??(e.penMode?e.penDetected??!1:!1),activeTool:{...et(r,o.activeTool.type&&MA[o.activeTool.type]?o.activeTool:{type:"selection"}),lastActiveTool:null,locked:o.activeTool.locked??!1},zoom:typeof e.zoom=="number"?{value:e.zoom}:e.zoom?.value?e.zoom:r.zoom,openSidebar:typeof e.openSidebar=="string"?{name:Xr.name}:o.openSidebar}},Mi=(e,t,r,o)=>({elements:xc(e?.elements,r,o),appState:q0(e?.appState,t||null),files:e?.files||{}}),j0=e=>{let t=xc(Te(e.elements),null);return t.length?{...e,elements:t}:null},Ia=(e=[],t)=>{let r=[];for(let o of e)if(Array.isArray(o)){let n=j0({status:t,elements:o,id:Nt(),created:Date.now()});n&&r.push(n)}else{let n=o,i=j0({...n,id:n.id||Nt(),status:n.status||t,created:n.created||Date.now()});i&&r.push(i)}return r}});var J0=Q(()=>{"use strict";f();Y();Br()});import{deflate as OA,inflate as BA}from"pako";var Ig,Q0,ey,ty,ry,Cg,Ag,oy=Q(()=>{"use strict";f();J0();Ig=e=>new Promise((t,r)=>{let o=typeof e=="string"?new Blob([new TextEncoder().encode(e)]):new Blob([e instanceof Uint8Array?e:new Uint8Array(e)]),n=new FileReader;n.onload=i=>{if(!i.target||typeof i.target.result!="string")return r(new Error("couldn't convert to byte string"));t(i.target.result)},n.readAsBinaryString(o)}),Q0=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let o=0,n=e.length;o<n;o++)r[o]=e.charCodeAt(o);return t},ey=e=>new TextDecoder("utf-8").decode(Q0(e)),ty=async(e,t=!1)=>t?window.btoa(e):window.btoa(await Ig(e)),ry=async(e,t=!1)=>t?window.atob(e):ey(window.atob(e)),Cg=async({text:e,compress:t})=>{let r;if(t!==!1)try{r=await Ig(OA(e))}catch(o){console.error("encode: cannot deflate",o)}return{version:"1",encoding:"bstring",compressed:!!r,encoded:r||await Ig(e)}},Ag=async e=>{let t;switch(e.encoding){case"bstring":t=e.compressed?e.encoded:await ey(e.encoded);break;default:throw new Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?BA(new Uint8Array(Q0(t)),{to:"string"}):t}});var wc={};gh(wc,{decodePngMetadata:()=>zA,decodeSvgMetadata:()=>UA,encodePngMetadata:()=>kg,encodeSvgMetadata:()=>HA,getTEXtChunk:()=>ay});import ny from"png-chunks-extract";import iy from"png-chunk-text";import FA from"png-chunks-encode";var ay,kg,zA,HA,UA,Os=Q(()=>{"use strict";f();oy();Y();Br();ay=async e=>{let r=ny(new Uint8Array(await Xn(e))).find(o=>o.name==="tEXt");return r?iy.decode(r.data):null},kg=async({blob:e,metadata:t})=>{let r=ny(new Uint8Array(await Xn(e))),o=iy.encode(oe.excalidraw,JSON.stringify(await Cg({text:t,compress:!0})));return r.splice(-1,0,o),new Blob([FA(r)],{type:oe.png})},zA=async e=>{let t=await ay(e);if(t?.keyword===oe.excalidraw)try{let r=JSON.parse(t.text);if(!("encoded"in r)){if("type"in r&&r.type===ar.excalidraw)return t.text;throw new Error("FAILED")}return await Ag(r)}catch(r){throw console.error(r),new Error("FAILED")}throw new Error("INVALID")},HA=async({text:e})=>{let t=await ty(JSON.stringify(await Cg({text:e})),!0),r="";return r+=`<!-- payload-type:${oe.excalidraw} -->`,r+="<!-- payload-version:2 -->",r+="<!-- payload-start -->",r+=t,r+="<!-- payload-end -->",r},UA=async({svg:e})=>{if(e.includes(`payload-type:${oe.excalidraw}`)){let t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw new Error("INVALID");let n=(e.match(/<!-- payload-version:(\d+) -->/)?.[1]||"1")!=="1";try{let i=await ry(t[1],n),a=JSON.parse(i);if(!("encoded"in a)){if("type"in a&&a.type===ar.excalidraw)return i;throw new Error("FAILED")}return await Ag(a)}catch(i){throw console.error(i),new Error("FAILED")}}throw new Error("INVALID")}});import{nanoid as GA}from"nanoid";var ly,Mg,cy,Bs,Li,Om,Fs,Lg,Pg,Zn,dy,Bm,my,vc,Dg,py,uy,WA,sy,Nm,Tc,Xn,Br=Q(()=>{"use strict";f();Or();Y();be();fi();Xe();G();$n();jn();Ns();ly=async e=>{let t;if(e.type===oe.png)try{return await(await Promise.resolve().then(()=>(Os(),wc))).decodePngMetadata(e)}catch(r){throw r.message==="INVALID"?new Ho("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new Ho("Error: cannot restore image")}else if("text"in Blob?t=await e.text():t=await new Promise(r=>{let o=new FileReader;o.readAsText(e,"utf8"),o.onloadend=()=>{o.readyState===FileReader.DONE&&r(o.result)}}),e.type===oe.svg)try{return await(await Promise.resolve().then(()=>(Os(),wc))).decodeSvgMetadata({svg:t})}catch(r){throw r.message==="INVALID"?new Ho("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new Ho("Error: cannot restore image")}return t},Mg=e=>e&&e.name.match(/\.(json|excalidraw|png|svg)$/)?.[1]||null,cy=e=>e==="png"||e==="svg",Bs=e=>{let t=Mg(e);return t==="png"||t==="svg"},Li=e=>{let{type:t}=e||{};return!!t&&Object.values(Fl).includes(t)},Om=async(e,t,r,o)=>{let n=await ly(e),i;try{try{i=JSON.parse(n)}catch(a){throw Li(e)?new Ho("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):a}if(hy(i))return{type:oe.excalidraw,data:Mi({elements:Fm(i.elements||[]),appState:{theme:t?.theme,fileHandle:o||e.handle||null,...Em(i.appState||{}),...t?bn(i.elements||[],t):{}},files:i.files},t,r,{repairBindings:!0,refreshDimensions:!1})};if(_g(i))return{type:oe.excalidrawlib,data:i};throw new Error("Error: invalid file")}catch(a){throw a instanceof Ho?a:new Error("Error: invalid file")}},Fs=async(e,t,r,o)=>{let n=await Om(e,t,r,o);if(n.type!==oe.excalidraw)throw new Error("Error: invalid file");return n.data},Lg=(e,t="unpublished")=>{let r=JSON.parse(e);if(!_g(r))throw new Error("Invalid library");let o=r.libraryItems||r.library;return Ia(o,t)},Pg=async(e,t="unpublished")=>Lg(await ly(e),t),Zn=async e=>new Promise(async(t,r)=>{try{sn(e)&&(e=await e),e.toBlob(o=>{if(!o)return r(new jd("Error: Canvas too big","CANVAS_POSSIBLY_TOO_BIG"));t(o)})}catch(o){r(o)}}),dy=async e=>{try{let t=await window.crypto.subtle.digest("SHA-1",await Xn(e));return s1(new Uint8Array(t))}catch(t){return console.error(t),GA(40)}},Bm=async e=>new Promise((t,r)=>{let o=new FileReader;o.onload=()=>{let n=o.result;t(n)},o.onerror=n=>r(n),o.readAsDataURL(e)}),my=(e,t="")=>{let r=e.indexOf(","),o=atob(e.slice(r+1)),n=e.slice(0,r).split(":")[1].split(";")[0],i=new ArrayBuffer(o.length),a=new Uint8Array(i);for(let s=0;s<o.length;s++)a[s]=o.charCodeAt(s);return new File([i],t,{type:n})},vc=async(e,t)=>{if(e.type===oe.svg)return e;let[r,o]=await Promise.all([import("pica").then(i=>i.default),import("image-blob-reduce").then(i=>i.default)]),n=o({pica:r({features:["js","wasm"]})});if(t.outputType){let{outputType:i}=t;n._create_blob=function(a){return this.pica.toBlob(a.out_canvas,i,.8).then(s=>(a.out_blob=s,a))}}if(!Li(e))throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"});return new File([await n.toBlob(e,{max:t.maxWidthOrHeight})],e.name,{type:t.outputType||e.type})},Dg=(e,t="")=>new File([new TextEncoder().encode(e)],t,{type:oe.svg}),py=async(e,t="")=>{let r;try{r=await fetch(e)}catch{throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"})}if(!r.ok)throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"});let o=await r.blob();if(o.type&&Li(o)){let n=t||o.name||"";return new File([o],n,{type:o.type})}throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"})},uy=async e=>{let t=e.dataTransfer.files.item(0),r=await WA(e);return{file:t?await Tc(t):null,fileHandle:r}},WA=async e=>{if(ki)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(t){return console.warn(t.name,t.message),null}return null},sy=e=>{let t=null,r=`${[...new Uint8Array(e).slice(0,8)].join(" ")} `,o={png:"137 80 78 71 13 10 26 10 ",jpg:"255 216 255 ",gif:"71 73 70 56 57 97 "};return r===o.png?t=oe.png:r.startsWith(o.jpg)?t=oe.jpg:r.startsWith(o.gif)&&(t=oe.gif),t},Nm=(e,t,r)=>new File([e],r||"",{type:t}),Tc=async e=>{if(e.type){if(Li(e)){let t=await Xn(e),r=sy(t);r&&r!==e.type&&(e=Nm(t,r,e.name))}}else if(e?.name?.endsWith(".excalidrawlib"))e=Nm(await Xn(e),oe.excalidrawlib,e.name);else if(e?.name?.endsWith(".excalidraw"))e=Nm(await Xn(e),oe.excalidraw,e.name);else{let t=await Xn(e),r=sy(t);r&&(e=Nm(t,r,e.name))}return e},Xn=e=>"arrayBuffer"in e?e.arrayBuffer():new Promise((t,r)=>{let o=new FileReader;o.onload=n=>{if(!n.target?.result)return r(new Error("Couldn't convert blob to ArrayBuffer"));t(n.target.result)},o.readAsArrayBuffer(e)})});var VA,Pi,zm,Rg,hy,_g,Hm,gy,jn=Q(()=>{"use strict";f();$n();Or();Y();be();Br();VA=(e,t)=>{let r={};for(let o of e)!o.isDeleted&&"fileId"in o&&o.fileId&&t[o.fileId]&&(r[o.fileId]=t[o.fileId]);return r},Pi=(e,t,r,o)=>{let n={type:ar.excalidraw,version:ia.excalidraw,source:zl,elements:o==="local"?Fm(e):fy(e),appState:o==="local"?Em(t):S0(t),files:o==="local"?VA(e,r):void 0};return JSON.stringify(n,null,2)},zm=async(e,t,r,o=t.name||Ud)=>{let n=Pi(e,t,r,"local"),i=new Blob([n],{type:oe.excalidraw});return{fileHandle:await _s(i,{name:o,extension:"excalidraw",description:"Excalidraw file",fileHandle:Bs(t.fileHandle)?null:t.fileHandle})}},Rg=async(e,t)=>{let r=await Ds({description:"Excalidraw files"});return Fs(await Tc(r),e,t,r.handle)},hy=e=>e?.type===ar.excalidraw&&(!e.elements||Array.isArray(e.elements)&&(!e.appState||typeof e.appState=="object")),_g=e=>typeof e=="object"&&e&&e.type===ar.excalidrawLibrary&&(e.version===1||e.version===2),Hm=e=>{let t={type:ar.excalidrawLibrary,version:ia.excalidrawLibrary,source:zl,libraryItems:e};return JSON.stringify(t,null,2)},gy=async e=>{let t=Hm(e);await _s(new Blob([t],{type:oe.excalidrawlib}),{name:"library",extension:"excalidrawlib",description:"Excalidraw library file"})}});var Ng,Um,Gm,YA,by,Og=Q(()=>{"use strict";f();Y();le();Ng=e=>new Promise((t,r)=>{let o=new Image;o.onload=()=>{t(o)},o.onerror=n=>{r(n)},o.src=e}),Um=async({fileIds:e,files:t,imageCache:r})=>{let o=new Map,n=new Map;return await Promise.all(e.reduce((i,a)=>{let s=t[a];return s&&!o.has(a)?(o.set(a,!0),i.concat((async()=>{try{if(s.mimeType===oe.binary)throw new Error("Only images can be added to ImageCache");let l=Ng(s.dataURL),c={image:l,mimeType:s.mimeType};r.set(a,c);let d=await l;r.set(a,{...c,image:d})}catch{n.set(a,!0)}})())):i},[])),{imageCache:r,updatedFiles:o,erroredFiles:n}},Gm=e=>e.filter(t=>xr(t)),YA=e=>e?.nodeName.toLowerCase()==="svg",by=async e=>{let t=new DOMParser().parseFromString(e,oe.svg),r=t.querySelector("svg");if(t.querySelector("parsererror")||!YA(r))throw new Error("Invalid SVG");if(r.hasAttribute("xmlns")||r.setAttribute("xmlns",We),!r.hasAttribute("width")||!r.hasAttribute("height")){let n=r.getAttribute("viewBox"),i=r.getAttribute("width")||"50",a=r.getAttribute("height")||"50";if(n){let s=n.match(/\d+ +\d+ +(\d+) +(\d+)/);s&&([,i,a]=s)}r.setAttribute("width",i),r.setAttribute("height",a)}return r.outerHTML}});import{pointsOnBezierCurves as KA}from"points-on-curve";var Wm,Ey,xy,yy,wy,$A,vy,Ty,Bg=Q(()=>{"use strict";f();be();nm();Wm=e=>{let{angle:t,width:r,height:o,x:n,y:i}=e,a=un(t),s=n+r/2,l=i+o/2,c=[s,l],d=[];return e.type==="diamond"?d=[yt([s,i],a,c),yt([n+r,l],a,c),yt([s,i+o],a,c),yt([n,l],a,c)]:d=[yt([n,i],a,c),yt([n+r,i],a,c),yt([n+r,i+o],a,c),yt([n,i+o],a,c)],{type:"polygon",data:d}},Ey=(e,t,r=10)=>{let[o,n,i,a,s,l]=ne(e,t,!0);o-=r,i+=r,n-=r,a+=r;let c=un(e.angle),d=[s,l],m=yt([o,n],c,d),p=yt([i,n],c,d),u=yt([o,a],c,d),h=yt([i,a],c,d);return{type:"polygon",data:[m,p,h,u]}},xy=e=>{let{width:t,height:r,angle:o,x:n,y:i}=e;return{type:"ellipse",data:{center:[n+t/2,i+r/2],angle:o,halfWidth:t/2,halfHeight:r/2}}},yy=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},wy=(e,t=[0,0],r,o)=>{let n=l=>yt([l[0]+t[0],l[1]+t[1]],un(r),o),i=yy(e),a=[],s=[0,0];for(let l of i)if(l.op==="move"&&(s=n(l.data)),l.op==="bcurveTo"){let c=n([l.data[0],l.data[1]]),d=n([l.data[2],l.data[3]]),m=n([l.data[4],l.data[5]]);a.push([s,c,d,m]),s=m}return{type:"polycurve",data:a}},$A=e=>{let t=e[0],r=[];for(let o=1;o<e.length;o++){let n=e[o];r.push([t,n]),t=n}return r},vy=(e,t,r=!1)=>{let o=un(e.angle),n=a=>yt(Jh(a,[e.x,e.y]),o,t),i=$A(e.points.map(a=>n(a)));return r?{type:"polygon",data:ys(i.flat())}:{type:"polyline",data:i}},Ty=(e,t,r=[0,0],o,n)=>{let i=d=>yt([d[0]+r[0],d[1]+r[1]],un(o),n);if(e.roundness===null)return{type:"polygon",data:ys(e.points.map(d=>i(d)))};let a=yy(t),s=[],l=!1;for(let d of a)d.op==="move"?(l=!l,l&&s.push([d.data[0],d.data[1]])):d.op==="bcurveTo"?l&&(s.push([d.data[0],d.data[1]]),s.push([d.data[2],d.data[3]]),s.push([d.data[4],d.data[5]])):d.op==="lineTo"&&l&&s.push([d.data[0],d.data[1]]);return{type:"polygon",data:KA(s,10,5).map(d=>i(d))}}});var Vm,Ca,Sc,Sy,Iy,Ym=Q(()=>{"use strict";f();ft();it();Bg();im();G();le();Vm=e=>{if(e.type==="arrow")return!1;let t=!Er(e.backgroundColor)||sr(e)||jt(e)||U(e);return e.type==="line"?t&&wr(e.points):e.type==="freedraw"?t&&wr(e.points):t||mo(e)},Ca=({x:e,y:t,element:r,shape:o,threshold:n=10,frameNameBound:i=null})=>{let a=Vm(r)?ws([e,t],o)||ec([e,t],o,n):ec([e,t],o,n);return!a&&i&&(a=ws([e,t],{type:"polygon",data:Wm(i).data})),a},Sc=(e,t,r,o,n=0)=>{let[i,a,s,l]=Jr(r,o);return i-=n,a-=n,s+=n,l+=n,Qd([i,a],[e,t],[s,l])},Sy=(e,t)=>!Ca(e)&&Sc(e.x,e.y,e.element,t),Iy=(e,t,r)=>r&&ws([e,t],r)});var Fg,Ic,zg,Km,$m=Q(()=>{"use strict";f();Y();it();Ym();ft();Hn();Fg=document.createElement("img");Fg.src=`data:${oe.svg}, ${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1971c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>')}`;Ic=([e,t,r,o],n,i)=>{let a=Cy,s=a/i.zoom.value,l=a/i.zoom.value,c=a/i.zoom.value,d=(e+r)/2,m=(t+o)/2,p=(a-8)/(2*i.zoom.value),u=4/i.zoom.value,h=r+u-p,g=t-u-c+p,[x,v]=he(h+s/2,g+l/2,d,m,n);return[x-s/2,v-l/2,s,l]},zg=(e,t,r,[o,n])=>{let i=4/r.zoom.value,[a,s,l,c]=ne(e,t),[d,m,p,u]=Ic([a,s,l,c],e.angle,r);return o>d-i&&o<d+i+p&&n>m-i&&n<m+u+i},Km=(e,t,r,[o,n],i)=>!e.link||r.selectedElementIds[e.id]?!1:!i&&r.viewModeEnabled&&Sc(o,n,e,t)?!0:zg(e,t,r,[o,n])});var Cc,Xm,Zm,Hg=Q(()=>{"use strict";f();Y();Cc=(e,t,r,o,n=!0)=>{e.beginPath(),e.arc(t,r,o,0,Math.PI*2),e.fill(),n&&e.stroke()},Xm=(e,t)=>[e.width/t,e.height/t],Zm=({canvas:e,scale:t,normalizedWidth:r,normalizedHeight:o,theme:n,isExporting:i,viewBackgroundColor:a})=>{let s=e.getContext("2d");return s.setTransform(1,0,0,1,0,0),s.scale(t,t),i&&n===ce.DARK&&(s.filter=is),typeof a=="string"?((a==="transparent"||a.length===5||a.length===9||/(hsla|rgba)\(/.test(a))&&s.clearRect(0,0,r,o),s.save(),s.fillStyle=a,s.fillRect(0,0,r,o),s.restore()):s.clearRect(0,0,r,o),s}});var XA,Ay,qn,ky,My,Ug,qm,Jm=Q(()=>{"use strict";f();Y();be();mr();le();Hn();fc();$m();Hg();G();Je();XA=(e,t,r,o,n,i,a)=>{let l;(x=>(x.Bold="#cccccc",x.Regular="#e5e5e5"))(l||={});let c=-Math.round(n.value/t)*t+r%t,d=-Math.round(n.value/t)*t+o%t,m=Math.min(1/n.value,1),p=1/n.value,u=[m*3,p+(m+p)];e.save(),e.lineWidth=m;for(let h=c;h<c+i+t*2;h+=t){let g=Math.round(h-r)%(5*t)===0;e.beginPath(),e.setLineDash(g?[]:u),e.strokeStyle=g?"#cccccc":"#e5e5e5",e.moveTo(h,d-t),e.lineTo(h,d+a+t*2),e.stroke()}for(let h=d;h<d+a+t*2;h+=t){let g=Math.round(h-o)%(5*t)===0;e.beginPath(),e.setLineDash(g?[]:u),e.strokeStyle=g?"#cccccc":"#e5e5e5",e.moveTo(c-t,h),e.lineTo(c+i+t*2,h),e.stroke()}e.restore()},Ay=(e,t,r,o)=>{t.translate(e.x+o.scrollX,e.y+o.scrollY),t.beginPath(),t.roundRect?t.roundRect(0,0,e.width,e.height,qe.radius/o.zoom.value):t.rect(0,0,e.width,e.height),t.clip(),t.translate(-(e.x+o.scrollX),-(e.y+o.scrollY))},ky=(e,t,r,o)=>{if(e.link&&!r.selectedElementIds[e.id]){let[n,i,a,s]=ne(e,o),[l,c,d,m]=Ic([n,i,a,s],e.angle,r),p=l+d/2,u=c+m/2;if(t.save(),t.translate(r.scrollX+p,r.scrollY+u),t.rotate(e.angle),!qn||qn.zoom!==r.zoom.value){qn=document.createElement("canvas"),qn.zoom=r.zoom.value,qn.width=d*window.devicePixelRatio*r.zoom.value,qn.height=m*window.devicePixelRatio*r.zoom.value;let h=qn.getContext("2d");h.scale(window.devicePixelRatio*r.zoom.value,window.devicePixelRatio*r.zoom.value),h.fillStyle="#fff",h.fillRect(0,0,d,m),h.drawImage(Fg,0,0,d,m),h.restore(),t.drawImage(qn,l-p,c-u,d,m)}else t.drawImage(qn,l-p,c-u,d,m);t.restore()}},My=({canvas:e,rc:t,elementsMap:r,allElementsMap:o,visibleElements:n,scale:i,appState:a,renderConfig:s})=>{if(e===null)return;let{renderGrid:l=!0,isExporting:c}=s,[d,m]=Xm(e,i),p=Zm({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m,theme:a.theme,isExporting:c,viewBackgroundColor:a.viewBackgroundColor});p.scale(a.zoom.value,a.zoom.value),l&&a.gridSize&&XA(p,a.gridSize,a.scrollX,a.scrollY,a.zoom,d/a.zoom.value,m/a.zoom.value);let u=new Set;n.forEach(h=>{h.groupIds.length>0&&a.frameToHighlight&&a.selectedElementIds[h.id]&&(En(h,a.frameToHighlight,r)||h.groupIds.find(g=>u.has(g)))&&h.groupIds.forEach(g=>u.add(g))}),n.filter(h=>!jt(h)).forEach(h=>{try{let g=h.frameId||a.frameToHighlight?.id;if(U(h)&&h.containerId&&r.has(h.containerId))return;if(p.save(),g&&a.frameRendering.enabled&&a.frameRendering.clip){let v=jm(h,r,a);v&&Aa(h,r,a)&&Ay(v,p,s,a),zs(h,r,o,t,p,s,a)}else zs(h,r,o,t,p,s,a);let x=ae(h,r);x&&zs(x,r,o,t,p,s,a),p.restore(),c||ky(h,p,a,r)}catch(g){console.error(g)}}),n.filter(h=>jt(h)).forEach(h=>{try{let g=()=>{if(zs(h,r,o,t,p,s,a),jt(h)&&(c||kt(h)&&s.embedsValidationStatus.get(h.id)!==!0)&&h.width&&h.height){let v=Dm(h);zs(v,r,o,t,p,s,a)}c||ky(h,p,a,r)};if((h.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){p.save();let v=jm(h,r,a);v&&Aa(h,r,a)&&Ay(v,p,s,a),g(),p.restore()}else g()}catch(g){console.error(g)}})},Ug=cs(e=>{My(e)},{trailing:!0}),qm=(e,t)=>{if(t){Ug(e);return}My(e)}});import Ly from"roughjs/bin/rough";var ZA,jA,qA,Py,Dy,Qm,Hs,Gg,_y,Ac=Q(()=>{"use strict";f();it();K0();G();Y();Or();jn();Og();mr();be();Ae();le();ho();Jm();ZA="<!-- svg-source:excalidraw -->",jA=(e,t)=>{if(e.width<=t)return e;let o=document.createElement("canvas").getContext("2d");o.font=Ie({fontFamily:e.fontFamily,fontSize:e.fontSize});let n=e.text;if(o.measureText(n).width>t)for(let a=n.length;a>0;a--){let s=`${n.slice(0,a)}...`;if(o.measureText(s).width<=t){n=s;break}}return se(e,{text:n,width:t})},qA=(e,t)=>{let r=[],o=0,n=0;for(let i of e){if(re(i)){gi(i)?o++:n++;let a=Wt({x:i.x,y:i.y-qe.nameOffsetY,fontFamily:mt.Assistant,fontSize:qe.nameFontSize,lineHeight:qe.nameLineHeight,strokeColor:t.exportWithDarkMode?qe.nameColorDarkTheme:qe.nameColorLightTheme,text:ep(i,gi(i)?o:n)});a.y-=a.height,a=jA(a,i.width),r.push(a)}r.push(i)}return r},Py=(e,t)=>(t=t||Qt().frameRendering,{enabled:e?!0:t.enabled,outline:e?!1:t.outline,name:e?!1:t.name,clip:e?!0:t.clip}),Dy=({elements:e,exportingFrame:t,frameRendering:r,exportWithDarkMode:o})=>{let n;return t?n=Us(e,t):r.enabled&&r.name?n=qA(e,{exportWithDarkMode:o}):n=e,n},Qm=async(e,t,r,{exportBackground:o,exportPadding:n=Oo,viewBackgroundColor:i,exportingFrame:a},s=(l,c)=>{let d=document.createElement("canvas");return d.width=l*t.exportScale,d.height=c*t.exportScale,{canvas:d,scale:t.exportScale}})=>{let l=Py(a??null,t.frameRendering??null),c=Dy({elements:e,exportingFrame:a,exportWithDarkMode:t.exportWithDarkMode,frameRendering:l});a&&(n=0);let[d,m,p,u]=Gg(a?[a]:Wg(c),n),{canvas:h,scale:g=1}=s(p,u),x=Qt(),{imageCache:v}=await Um({imageCache:new Map,fileIds:Gm(c).map(y=>y.fileId),files:r});return qm({canvas:h,rc:Ly.canvas(h),elementsMap:Zr(X(c)),allElementsMap:Zr(X(yr(e))),visibleElements:c,scale:g,appState:{...t,frameRendering:l,viewBackgroundColor:o?i:null,scrollX:-d+n,scrollY:-m+n,zoom:x.zoom,shouldCacheIgnoreZoom:!1,theme:t.exportWithDarkMode?ce.DARK:ce.LIGHT},renderConfig:{canvasBackgroundColor:i,imageCache:v,renderGrid:!1,isExporting:!0,embedsValidationStatus:new Map,elementsPendingErasure:new Set}}),h},Hs=async(e,t,r,o)=>{let n=Py(o?.exportingFrame??null,t.frameRendering??null),{exportPadding:i=Oo,exportWithDarkMode:a=!1,viewBackgroundColor:s,exportScale:l=1,exportEmbedScene:c}=t,{exportingFrame:d=null}=o||{},m=Dy({elements:e,exportingFrame:d,exportWithDarkMode:a,frameRendering:n});d&&(i=0);let p="";if(c)try{p=await(await Promise.resolve().then(()=>(Os(),wc))).encodeSvgMetadata({text:Pi(e,t,r||{},"local")})}catch(k){console.error(k)}let[u,h,g,x]=Gg(d?[d]:Wg(m),i),v=document.createElementNS(We,"svg");v.setAttribute("version","1.1"),v.setAttribute("xmlns",We),v.setAttribute("viewBox",`0 0 ${g} ${x}`),v.setAttribute("width",`${g*l}`),v.setAttribute("height",`${x*l}`),a&&v.setAttribute("filter",is);let y="https://excalidraw.com/";T.VITE_IS_EXCALIDRAW_NPM_PACKAGE&&(y=window.EXCALIDRAW_ASSET_PATH||`https://unpkg.com/${T.VITE_PKG_NAME}@${T.VITE_PKG_VERSION}`,y?.startsWith("/")&&(y=y.replace("/",`${window.location.origin}/`)),y=`${y}/dist/excalidraw-assets/`);let w=-u+i,I=-h+i,A=kc(e),C="",L=X(e);for(let k of A){let[N,B,_,V]=ne(k,L),Z=(_-N)/2-(k.x-N),J=(V-B)/2-(k.y-B);C+=`<clipPath id=${k.id}>
|
|
25
|
-
<rect transform="translate(${
|
|
26
|
-
width="${
|
|
27
|
-
height="${
|
|
11
|
+
`),M=ra(e.fontSize,e.lineHeight),I=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,P=Tp(e.fontFamily,e.fontSize,M),A=Rm(e.text)?"rtl":"ltr",N=e.textAlign==="center"?"middle":e.textAlign==="right"||A==="rtl"?"end":"start";for(let D=0;D<C.length;D++){let z=o.ownerDocument.createElementNS(Ke,"text");z.textContent=C[D],z.setAttribute("x",`${I}`),z.setAttribute("y",`${D*M+P}`),z.setAttribute("font-family",Sn(e)),z.setAttribute("font-size",`${e.fontSize}px`),z.setAttribute("fill",e.strokeColor),z.setAttribute("text-anchor",N),z.setAttribute("style","white-space: pre;"),z.setAttribute("direction",A),z.setAttribute("dominant-baseline","alphabetic"),w.appendChild(z)}let k=ld(e,x,[w],s.frameRendering,t);v(k||w,e)}else throw new Error(`Unimplemented type ${e.type}`)}},Uv=(e,t,r,o,n,i)=>{o&&(e.filter(a=>!sr(a)).forEach(a=>{if(!a.isDeleted){if(H(a)&&a.containerId&&t.has(a.containerId))return;try{jp(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i);let s=J(a,t);s&&jp(s,t,r,o,n,s.x+i.offsetX,s.y+i.offsetY,i)}catch(s){console.error(s)}}}),e.filter(a=>sr(a)).forEach(a=>{if(!a.isDeleted)try{jp(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i)}catch(s){console.error(s)}}))}});var tb,Jp,Qp,iM,Wv,rb=X(()=>{"use strict";f();Y();me();tb=e=>new Promise((t,r)=>{let o=new Image;o.onload=()=>{t(o)},o.onerror=n=>{r(n)},o.src=e}),Jp=async({fileIds:e,files:t,imageCache:r})=>{let o=new Map,n=new Map;return await Promise.all(e.reduce((i,a)=>{let s=t[a];return s&&!o.has(a)?(o.set(a,!0),i.concat((async()=>{try{if(s.mimeType===se.binary)throw new Error("Only images can be added to ImageCache");let l=tb(s.dataURL),c={image:l,mimeType:s.mimeType};r.set(a,c);let d=await l;r.set(a,{...c,image:d})}catch{n.set(a,!0)}})())):i},[])),{imageCache:r,updatedFiles:o,erroredFiles:n}},Qp=e=>e.filter(t=>kr(t)),iM=e=>e?.nodeName.toLowerCase()==="svg",Wv=async e=>{let t=new DOMParser().parseFromString(e,se.svg),r=t.querySelector("svg");if(t.querySelector("parsererror")||!iM(r))throw new Error("Invalid SVG");if(r.hasAttribute("xmlns")||r.setAttribute("xmlns",Ke),!r.hasAttribute("width")||!r.hasAttribute("height")){let n=r.getAttribute("viewBox"),i=r.getAttribute("width")||"50",a=r.getAttribute("height")||"50";if(n){let s=n.match(/\d+ +\d+ +(\d+) +(\d+)/);s&&([,i,a]=s)}r.setAttribute("width",i),r.setAttribute("height",a)}return r.outerHTML}});var ob,cd,nb,eu,tu=X(()=>{"use strict";f();Y();dt();Zc();mt();li();ob=document.createElement("img");ob.src=`data:${se.svg}, ${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1971c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>')}`;cd=([e,t,r,o],n,i)=>{let a=Vv,s=a/i.zoom.value,l=a/i.zoom.value,c=a/i.zoom.value,d=(e+r)/2,m=(t+o)/2,p=(a-8)/(2*i.zoom.value),u=4/i.zoom.value,g=r+u-p,h=t-u-c+p,[x,v]=xe(g+s/2,h+l/2,d,m,n);return[x-s/2,v-l/2,s,l]},nb=(e,t,r,[o,n])=>{let i=4/r.zoom.value,[a,s,l,c]=ae(e,t),[d,m,p,u]=cd([a,s,l,c],e.angle,r);return o>d-i&&o<d+i+p&&n>m-i&&n<m+u+i},eu=(e,t,r,[o,n],i)=>!e.link||r.selectedElementIds[e.id]?!1:!i&&r.viewModeEnabled&&$c(o,n,e,t)?!0:nb(e,t,r,[o,n])});var dd,ru,ou,ib=X(()=>{"use strict";f();Y();dd=(e,t,r,o,n=!0)=>{e.beginPath(),e.arc(t,r,o,0,Math.PI*2),e.fill(),n&&e.stroke()},ru=(e,t)=>[e.width/t,e.height/t],ou=({canvas:e,scale:t,normalizedWidth:r,normalizedHeight:o,theme:n,isExporting:i,viewBackgroundColor:a})=>{let s=e.getContext("2d");return s.setTransform(1,0,0,1,0,0),s.scale(t,t),i&&n===ue.DARK&&(s.filter=Fs),typeof a=="string"?((a==="transparent"||a.length===5||a.length===9||/(hsla|rgba)\(/.test(a))&&s.clearRect(0,0,r,o),s.save(),s.fillStyle=a,s.fillRect(0,0,r,o),s.restore()):s.clearRect(0,0,r,o),s}});var aM,Yv,yi,Xv,Kv,ab,iu,au=X(()=>{"use strict";f();Y();we();vr();me();li();ad();tu();ib();V();He();aM=(e,t,r,o,n,i,a)=>{let l;(x=>(x.Bold="#cccccc",x.Regular="#e5e5e5"))(l||={});let c=-Math.round(n.value/t)*t+r%t,d=-Math.round(n.value/t)*t+o%t,m=Math.min(1/n.value,1),p=1/n.value,u=[m*3,p+(m+p)];e.save(),e.lineWidth=m;for(let g=c;g<c+i+t*2;g+=t){let h=Math.round(g-r)%(5*t)===0;e.beginPath(),e.setLineDash(h?[]:u),e.strokeStyle=h?"#cccccc":"#e5e5e5",e.moveTo(g,d-t),e.lineTo(g,d+a+t*2),e.stroke()}for(let g=d;g<d+a+t*2;g+=t){let h=Math.round(g-o)%(5*t)===0;e.beginPath(),e.setLineDash(h?[]:u),e.strokeStyle=h?"#cccccc":"#e5e5e5",e.moveTo(c-t,g),e.lineTo(c+i+t*2,g),e.stroke()}e.restore()},Yv=(e,t,r,o)=>{t.translate(e.x+o.scrollX,e.y+o.scrollY),t.beginPath(),t.roundRect?t.roundRect(0,0,e.width,e.height,rt.radius/o.zoom.value):t.rect(0,0,e.width,e.height),t.clip(),t.translate(-(e.x+o.scrollX),-(e.y+o.scrollY))},Xv=(e,t,r,o)=>{if(e.link&&!r.selectedElementIds[e.id]){let[n,i,a,s]=ae(e,o),[l,c,d,m]=cd([n,i,a,s],e.angle,r),p=l+d/2,u=c+m/2;if(t.save(),t.translate(r.scrollX+p,r.scrollY+u),t.rotate(e.angle),!yi||yi.zoom!==r.zoom.value){yi=document.createElement("canvas"),yi.zoom=r.zoom.value,yi.width=d*window.devicePixelRatio*r.zoom.value,yi.height=m*window.devicePixelRatio*r.zoom.value;let g=yi.getContext("2d");g.scale(window.devicePixelRatio*r.zoom.value,window.devicePixelRatio*r.zoom.value),g.fillStyle="#fff",g.fillRect(0,0,d,m),g.drawImage(ob,0,0,d,m),g.restore(),t.drawImage(yi,l-p,c-u,d,m)}else t.drawImage(yi,l-p,c-u,d,m);t.restore()}},Kv=({canvas:e,rc:t,elementsMap:r,allElementsMap:o,visibleElements:n,scale:i,appState:a,renderConfig:s})=>{if(e===null)return;let{renderGrid:l=!0,isExporting:c}=s,[d,m]=ru(e,i),p=ou({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m,theme:a.theme,isExporting:c,viewBackgroundColor:a.viewBackgroundColor});p.scale(a.zoom.value,a.zoom.value),l&&a.gridSize&&aM(p,a.gridSize,a.scrollX,a.scrollY,a.zoom,d/a.zoom.value,m/a.zoom.value);let u=new Set;n.forEach(g=>{g.groupIds.length>0&&a.frameToHighlight&&a.selectedElementIds[g.id]&&(Bn(g,a.frameToHighlight,r)||g.groupIds.find(h=>u.has(h)))&&g.groupIds.forEach(h=>u.add(h))}),n.filter(g=>!sr(g)).forEach(g=>{try{let h=g.frameId||a.frameToHighlight?.id;if(H(g)&&g.containerId&&r.has(g.containerId))return;if(p.save(),h&&a.frameRendering.enabled&&a.frameRendering.clip){let v=nu(g,r,a);v&&ts(g,r,a)&&Yv(v,p,s,a),fl(g,r,o,t,p,s,a)}else fl(g,r,o,t,p,s,a);let x=J(g,r);x&&fl(x,r,o,t,p,s,a),p.restore(),c||Xv(g,p,a,r)}catch(h){console.error(h)}}),n.filter(g=>sr(g)).forEach(g=>{try{let h=()=>{if(fl(g,r,o,t,p,s,a),sr(g)&&(c||Rt(g)&&s.embedsValidationStatus.get(g.id)!==!0)&&g.width&&g.height){let v=Zp(g);fl(v,r,o,t,p,s,a)}c||Xv(g,p,a,r)};if((g.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){p.save();let v=nu(g,r,a);v&&ts(g,r,a)&&Yv(v,p,s,a),h(),p.restore()}else h()}catch(h){console.error(h)}})},ab=Hs(e=>{Kv(e)},{trailing:!0}),iu=(e,t)=>{if(t){ab(e);return}Kv(e)}});import $v from"roughjs/bin/rough";var sM,lM,cM,Zv,jv,su,bl,sb,qv,md=X(()=>{"use strict";f();dt();Gv();V();Y();Zr();mi();rb();vr();we();De();me();ko();au();on();sM="<!-- svg-source:excalidraw -->",lM=(e,t)=>{if(e.width<=t)return e;let o=document.createElement("canvas").getContext("2d");o.font=Me({fontFamily:e.fontFamily,fontSize:e.fontSize});let n=e.text;if(o.measureText(n).width>t)for(let a=n.length;a>0;a--){let s=`${n.slice(0,a)}...`;if(o.measureText(s).width<=t){n=s;break}}return pe(e,{text:n,width:t})},cM=(e,t)=>{let r=[];for(let o of e){if(Q(o)){let n=jt({x:o.x,y:o.y-rt.nameOffsetY,fontFamily:Le.Helvetica,fontSize:rt.nameFontSize,lineHeight:rt.nameLineHeight,strokeColor:t.exportWithDarkMode?rt.nameColorDarkTheme:rt.nameColorLightTheme,text:lu(o)});n.y-=n.height,n=lM(n,o.width),r.push(n)}r.push(o)}return r},Zv=(e,t)=>(t=t||lr().frameRendering,{enabled:e?!0:t.enabled,outline:e?!1:t.outline,name:e?!1:t.name,clip:e?!0:t.clip}),jv=({elements:e,exportingFrame:t,frameRendering:r,exportWithDarkMode:o})=>{let n;return t?n=El(e,t):r.enabled&&r.name?n=cM(e,{exportWithDarkMode:o}):n=e,n},su=async(e,t,r,{exportBackground:o,exportPadding:n=Ko,viewBackgroundColor:i,exportingFrame:a},s=(c,d)=>{let m=document.createElement("canvas");return m.width=c*t.exportScale,m.height=d*t.exportScale,{canvas:m,scale:t.exportScale}},l=async()=>{await Lr.loadFontsForElements(e)})=>{await l();let c=Zv(a??null,t.frameRendering??null),d=jv({elements:e,exportingFrame:a,exportWithDarkMode:t.exportWithDarkMode,frameRendering:c});a&&(n=0);let[m,p,u,g]=sb(a?[a]:lb(d),n),{canvas:h,scale:x=1}=s(u,g),v=lr(),{imageCache:y}=await Jp({imageCache:new Map,fileIds:Qp(d).map(w=>w.fileId),files:r});return iu({canvas:h,rc:$v.canvas(h),elementsMap:Mr(Z(d)),allElementsMap:Mr(Z(fr(e))),visibleElements:d,scale:x,appState:{...t,frameRendering:c,viewBackgroundColor:o?i:null,scrollX:-m+n,scrollY:-p+n,zoom:v.zoom,shouldCacheIgnoreZoom:!1,theme:t.exportWithDarkMode?ue.DARK:ue.LIGHT},renderConfig:{canvasBackgroundColor:i,imageCache:y,renderGrid:!1,isExporting:!0,embedsValidationStatus:new Map,elementsPendingErasure:new Set}}),h},bl=async(e,t,r,o)=>{let n=Zv(o?.exportingFrame??null,t.frameRendering??null),{exportPadding:i=Ko,exportWithDarkMode:a=!1,viewBackgroundColor:s,exportScale:l=1,exportEmbedScene:c}=t,{exportingFrame:d=null}=o||{},m=jv({elements:e,exportingFrame:d,exportWithDarkMode:a,frameRendering:n});d&&(i=0);let p="";if(c)try{p=await(await Promise.resolve().then(()=>(tl(),Bc))).encodeSvgMetadata({text:Vi(e,t,r||{},"local")})}catch(D){console.error(D)}let[u,g,h,x]=sb(d?[d]:lb(m),i),v=document.createElementNS(Ke,"svg");v.setAttribute("version","1.1"),v.setAttribute("xmlns",Ke),v.setAttribute("viewBox",`0 0 ${h} ${x}`),v.setAttribute("width",`${h*l}`),v.setAttribute("height",`${x*l}`),a&&v.setAttribute("filter",Fs);let y=-u+i,w=-g+i,C=pd(e),M="",I=Z(e);for(let D of C){let[z,R,W,q]=ae(D,I),re=(W-z)/2-(D.x-z),ge=(q-R)/2-(D.y-R);M+=`<clipPath id=${D.id}>
|
|
12
|
+
<rect transform="translate(${D.x+y} ${D.y+w}) rotate(${D.angle} ${re} ${ge})"
|
|
13
|
+
width="${D.width}"
|
|
14
|
+
height="${D.height}"
|
|
28
15
|
>
|
|
29
16
|
</rect>
|
|
30
|
-
</clipPath>`}if(
|
|
31
|
-
|
|
17
|
+
</clipPath>`}let P=e.reduce((D,z)=>(H(z)&&D.add(z.fontFamily),D),new Set),A=o?.skipInliningFonts?[]:await Promise.all(Array.from(P).map(async D=>{let{fonts:z,metadata:R}=Lr.registered.get(D)??{};if(!Array.isArray(z)){console.error(`Couldn't find registered fonts for font-family "${D}"`,Lr.registered);return}if(!R?.local)return Promise.all(z.map(async W=>`@font-face {
|
|
18
|
+
font-family: ${W.fontFace.family};
|
|
19
|
+
src: url(${await W.getContent()});
|
|
20
|
+
}`))}));if(v.innerHTML=`
|
|
21
|
+
${sM}
|
|
32
22
|
${p}
|
|
33
23
|
<defs>
|
|
34
24
|
<style class="style-fonts">
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
src: url("${y}Virgil.woff2");
|
|
38
|
-
}
|
|
39
|
-
@font-face {
|
|
40
|
-
font-family: "Cascadia";
|
|
41
|
-
src: url("${y}Cascadia.woff2");
|
|
42
|
-
}
|
|
43
|
-
@font-face {
|
|
44
|
-
font-family: "Assistant";
|
|
45
|
-
src: url("${y}Assistant-Regular.woff2");
|
|
46
|
-
}
|
|
25
|
+
${A.flat().filter(Boolean).join(`
|
|
26
|
+
`)}
|
|
47
27
|
</style>
|
|
48
|
-
${
|
|
28
|
+
${M}
|
|
49
29
|
</defs>
|
|
50
|
-
`,t.exportBackground&&s){let
|
|
30
|
+
`,t.exportBackground&&s){let D=v.ownerDocument.createElementNS(Ke,"rect");D.setAttribute("x","0"),D.setAttribute("y","0"),D.setAttribute("width",`${h}`),D.setAttribute("height",`${x}`),D.setAttribute("fill",s),v.appendChild(D)}let N=$v.svg(v),k=o?.renderEmbeddables??!1;return Uv(m,Mr(Z(m)),N,v,r||{},{offsetX:y,offsetY:w,isExporting:!0,exportWithDarkMode:a,renderEmbeddables:k,frameRendering:n,canvasBackgroundColor:s,embedsValidationStatus:k?new Map(m.filter(D=>Q(D)).map(D=>[D.id,!0])):new Map}),v},sb=(e,t)=>{let[r,o,n,i]=Te(e),a=Ht(r,n)+t*2,s=Ht(o,i)+t*2;return[r,o,a,s]},qv=(e,t,r)=>{let[,,o,n]=sb(e,t).map(i=>Math.trunc(i*r));return[o,n]}});var un,st,oa,Qv,rs,xl,ud,cb,Jv,dM,eT,cu,Do,tT,mM,pM,uM,rT,gM,hM,oT,db=X(()=>{"use strict";f();pr();Y();we();Zo();un=32,st=12,oa=256,Qv=50,rs="NOT_SPREADSHEET",xl="VALID_SPREADSHEET",ud=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},cb=(e,t)=>e.slice(1).every(r=>ud(r[t])!==null),Jv=e=>{let t=e[0].length;if(t>2)return{type:rs,reason:"More than 2 columns"};if(t===1){if(!cb(e,0))return{type:rs,reason:"Value is not numeric"};let l=ud(e[0][0])===null,c=(l?e.slice(1):e).map(d=>ud(d[0]));return c.length<2?{type:rs,reason:"Less than two rows"}:{type:xl,spreadsheet:{title:l?e[0][0]:null,labels:null,values:c}}}let r=cb(e,0),o=cb(e,1);if(!r&&!o)return{type:rs,reason:"Value is not numeric"};let[n,i]=o?[0,1]:[1,0],a=ud(e[0][i])===null,s=a?e.slice(1):e;return s.length<2?{type:rs,reason:"Less than 2 rows"}:{type:xl,spreadsheet:{title:a?e[0][i]:null,labels:s.map(l=>l[n]),values:s.map(l=>ud(l[i]))}}},dM=e=>{let t=[];for(let r=0;r<e[0].length;r++){let o=[];for(let n=0;n<e.length;n++)o.push(e[n][r]);t.push(o)}return t},eT=e=>{let t=e.trim().split(`
|
|
51
31
|
`).map(i=>i.trim().split(" "));if(t.length&&t[0].length!==2&&(t=e.trim().split(`
|
|
52
|
-
`).map(i=>i.trim().split(","))),t.length===0)return{type:
|
|
53
|
-
`).trim()}:r:{type:"text",value:(e.clipboardData?.getData("text/plain")||"").trim()}}catch{return{type:"text",value:""}}},np=async(e,t=!1)=>{let r=await l6(e,t);if(r.type==="mixedContent")return{mixedContent:r.value};try{let o=!t&&a6(r.value);if(o)return o}catch(o){console.error(o)}try{let o=JSON.parse(r.value),n=o.type===ar.excalidrawClipboardWithAPI;if(n6(o))return{elements:o.elements,files:o.files,text:t?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:r.value}},ip=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[oe.png]:e})])}catch(t){if(sn(e))await navigator.clipboard.write([new window.ClipboardItem({[oe.png]:await e})]);else throw t}},Jn=async(e,t)=>{if(rp)try{await navigator.clipboard.writeText(e||"");return}catch(r){console.error(r)}try{if(t){if(t.clipboardData?.setData("text/plain",e||""),t.clipboardData?.getData("text/plain")!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}if(!c6(e))throw new Error("Error copying to clipboard.")},c6=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",r=document.createElement("textarea");r.style.border="0",r.style.padding="0",r.style.margin="0",r.style.position="absolute",r.style[t?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;r.style.top=`${o}px`,r.style.fontSize="12pt",r.setAttribute("readonly",""),r.value=e,document.body.appendChild(r);let n=!1;try{r.select(),r.setSelectionRange(0,r.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return r.remove(),n}});var Ri,ap,Vs,d6,Ma=Q(()=>{"use strict";f();Ac();Or();Ns();Y();Os();jn();_i();Ri=({elements:e,appState:t,files:r,maxWidthOrHeight:o,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:s,appState:l}=Mi({elements:e,appState:t},null,null),{exportBackground:c,viewBackgroundColor:d}=l;return Qm(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},r||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(m,p),x=o<g?o/g:t?.exportScale??1;return u.width=m*x,u.height=p*x,{canvas:u,scale:x}}let h=n?.(m,p)||{width:m,height:p};return u.width=h.width,u.height=h.height,{canvas:u,scale:h.scale??1}})},ap=async e=>{let{mimeType:t=oe.png,quality:r}=e;t===oe.png&&typeof r=="number"&&console.warn(`"quality" will be ignored for "${oe.png}" mimeType`),t==="image/jpg"&&(t=oe.jpg),t===oe.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${oe.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Ri(e);return r=r||(/image\/jpe?g/.test(t)?.92:.8),new Promise((n,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&t===oe.png&&e.appState?.exportEmbedScene&&(a=await kg({blob:a,metadata:Pi(e.elements,e.appState,e.files||{},"local")})),n(a)},t,r)})},Vs=async({elements:e,appState:t=Qt(),files:r={},exportPadding:o,renderEmbeddables:n,exportingFrame:i})=>{let{elements:a,appState:s}=Mi({elements:e,appState:t},null,null),l={...s,exportPadding:o};return Hs(a,l,r,{exportingFrame:i,renderEmbeddables:n})},d6=async e=>{if(e.type==="svg"){let t=await Vs(e);await Jn(t.outerHTML)}else if(e.type==="png")await ip(ap(e));else if(e.type==="json")await op(e.elements,e.files);else throw new Error("Invalid export type")}});var m6,p6,Wy,Vy,Kg,Yy,$g,Xg=Q(()=>{"use strict";f();le();ft();it();G();m6=e=>e.type==="diamond"?[[e.width/2,0],[e.width,e.height/2],[e.width/2,e.height],[0,e.height/2]]:[[0,0],[0+e.width,0],[0+e.width,e.height],[0,e.height]],p6=e=>ie(e)||Rt(e)?e.points:m6(e),Wy=e=>{let t=e.reduce((r,[o,n])=>(r.minY=Math.min(r.minY,n),r.minX=Math.min(r.minX,o),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,n),r),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},Vy=e=>{let t=p6(e),{cx:r,cy:o}=Wy(t),n=[r,o],i=t.map(d=>Pe([d[0],d[1]],n,e.angle)),{minX:a,minY:s,maxX:l,maxY:c}=Wy(i);return[a+e.x,s+e.y,l+e.x,c+e.y]},Kg=(e,t,r=!1)=>{let o=Vy(e),n=t[0]<=o[0]&&t[2]>=o[2]&&t[1]<=o[1]&&t[3]>=o[3];return r?n?!0:o[0]<=t[0]&&o[2]>=t[2]&&o[1]<=t[1]&&o[3]>=t[3]:n},Yy=(e,t)=>{let r=Vy(e);return(jl(r[0],t[0],t[2])||jl(t[0],r[0],r[2]))&&(jl(r[1],t[1],t[3])||jl(t[1],r[1],r[3]))},$g=({elements:e,bounds:t,type:r,errorMargin:o=0})=>{Kl(t)&&(t=Jr(t,X(e)));let n=[t[0]-o,t[1]-o,t[2]+o,t[3]+o],i=new Set;for(let a of e){if(i.has(a.id))continue;if(r==="overlap"?Yy(a,n):r==="inside"?Kg(a,n):Kg(a,n,!0)){if(i.add(a.id),a.boundElements)for(let l of a.boundElements)i.add(l.id);U(a)&&a.containerId&&i.add(a.containerId),xe(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))}});function Ky(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function Zy(e,t){return e[0]*t[1]-t[0]*e[1]}function u6(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function sp(e,t){return[e[0]-t[0],e[1]-t[1]]}function $y(e,t){let r=sp(e[1],e[0]),o=sp(t,e[0]),n=Zy(r,o);return Math.abs(n)<h6}function Zg(e,t){let r=sp(e[1],e[0]),o=sp(t,e[0]);return Zy(r,o)<0}function Xy(e,t){return $y(e,t[0])||$y(e,t[1])||(Zg(e,t[0])?!Zg(e,t[1]):Zg(e,t[1]))}function jy(e,t){return u6(Ky(e),Ky(t))&&Xy(e,t)&&Xy(t,e)}var h6,qy=Q(()=>{"use strict";f();h6=1e-6});var Jy=Q(()=>{"use strict";f();Ma();Xg();qy()});function Qy(e,t,r){let o=ug(t,r),n=ug(e,r);return o.some(a=>n.some(s=>jy(a,s)))}var lp,ew,tw,rw,En,jg,ow,ro,kc,Wg,Ys,nw,Vt,iw,Lc,Ks,qg,cp,xn,dp,jm,Aa,ep,Us,mr=Q(()=>{"use strict";f();be();ft();Je();G();Ae();Xe();Gt();it();Jy();le();lp=(e,t,r)=>{let o=X(e);for(let n of t)if(n.frameId){let i=r.get(n.id),a=r.get(n.frameId);if(i){let s=o.get(i);s&&O(s,{frameId:a??n.frameId},!1)}}};ew=(e,t,r)=>dp($s(e,t,r,!1)).filter(o=>!re(o)&&!o.frameId||o.frameId===t.id),tw=(e,t,r,o)=>$s(e,t,o).some(n=>n.id===r.id),rw=(e,t,r)=>{let[o,n,i,a]=ne(t,r),[s,l,c,d]=we(e);return o<=s&&n<=l&&i>=c&&a>=d},En=(e,t,r)=>rw([e],t,r)||Qy(e,t,r)||tw([t],e,t,r),jg=(e,t,r)=>{let[o,n,i,a]=ne(t,r);return Qd([o,n],[e.x,e.y],[i,a])},ow=e=>{let t=new Map;for(let r of e){let o=re(r)?r.id:r.frameId;o&&!t.has(o)&&t.set(o,ro(e,o))}return t},ro=(e,t)=>{let r=[];for(let o of e.values())o.frameId===t&&r.push(o);return r},kc=e=>e.filter(t=>re(t)),Wg=e=>{let t=X(kc(e));return e.filter(r=>t.has(r.id)||!r.frameId||!t.has(r.frameId))},Ys=(e,t,r,o)=>{let n=ro(e,t.id),i=new Set(n),a=new Set([...ew(e,t,o),...n.filter(p=>tw(e,p,t,o))]),s=n.filter(p=>!a.has(p)),l=new Set(Array.from(a).flatMap(p=>p.groupIds));for(let p of s)if(!Qy(p,t,o))p.groupIds.length===0&&i.delete(p);else if(p.groupIds.length>0)for(let u of p.groupIds)l.add(u);for(let p of s)if(p.groupIds.length>0){let u=!0;for(let h of p.groupIds)l.has(h)&&(u=!1);u&&i.delete(p)}let c=Array.from(a).filter(p=>p.groupIds.length===0);for(let p of c)i.add(p);let d=Array.from(a).filter(p=>p.groupIds.length>0),m=ym(d,r);for(let[p,u]of Object.entries(m))if(u){let h=Qe(e,p);if(rw(h,t,o))for(let g of h)i.add(g)}return[...i].filter(p=>!(U(p)&&p.containerId))},nw=(e,t,r)=>dp(e,ew(e,t,r)),Vt=(e,t)=>e.frameId&&t.get(e.frameId)||null,iw=(e,t)=>{let r=new Set,o=X(e);e=dp(e);for(let a of e)re(a)&&a.id!==t.id&&r.add(a.id);let n=new Set,i=[];for(let a of e)if(!(re(a)||a.frameId&&r.has(a.frameId)))if(a.groupIds.length){let s=a.groupIds.at(-1);if(!n.has(s)){n.add(s);let l=Qe(e,s);if(l.some(c=>En(c,t,o)))for(let c of l)i.push(c)}}else En(a,t,o)&&i.push(a);return i},Lc=(e,t,r)=>{let o=X(e),n=new Map;for(let l of e.values())l.frameId===r.id&&n.set(l.id,!0);let i=new Set(t.map(l=>l.id)),a=[],s=new Set;for(let l of t)re(l)&&l.id!==r.id&&s.add(l.id);for(let l of dp(e,t)){if(re(l)||l.frameId&&s.has(l.frameId))continue;n.has(l.id)||a.push(l);let c=ae(l,o);c&&!i.has(c.id)&&!n.has(c.id)&&a.push(c)}for(let l of a)O(l,{frameId:r.id},!1);return e},Ks=(e,t)=>{let r=new Map,o=new Map;for(let n of e)if(n.frameId){r.set(n.id,n);let i=o.get(n.frameId)||[];i.push(n);let a=ae(n,t);a&&(r.set(a.id,a),i.push(a)),o.set(n.frameId,i)}for(let[,n]of r)O(n,{frameId:null},!1)},qg=(e,t)=>{let r=ro(e,t.id);return Ks(r,X(e)),e},cp=(e,t,r,o)=>Lc(qg(e,r),t,r).slice(),xn=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),n=new Set(o);if(t.editingGroupId)for(let s of o)s.groupIds.length===0?n.add(s):s.groupIds.flatMap(l=>Qe(e,l)).forEach(l=>n.add(l));let i=new Set,a=X(e);return n.forEach(s=>{s.frameId&&!re(s)&&!Aa(s,a,t)&&i.add(s)}),i.size>0&&Ks(i,a),e},dp=(e,t)=>{let r=new Set,o=t||e;for(let a of o.values()){let s=a.groupIds[a.groupIds.length-1];s&&r.add(s)}let n=new Set;for(let a of r)Qe(e,a).some(s=>re(s))&&n.add(a);let i=[];for(let a of o.values())n.has(a.groupIds[a.groupIds.length-1])||i.push(a);return i},jm=(e,t,r)=>{let o=U(e)&&wt(e,t)||e;return r.selectedElementIds[o.id]&&r.selectedElementsAreBeingDragged?r.frameToHighlight:Vt(o,t)},Aa=(e,t,r)=>{let o=jm(e,t,r),n=U(e)&&wt(e,t)||e;if(o){if(!r.selectedElementIds[e.id]||!r.selectedElementsAreBeingDragged)return!0;if(n.groupIds.length===0)return En(n,o,t);let i=new Set(n.groupIds.flatMap(a=>Qe(t,a)));if(r.editingGroupId&&r.selectedElementsAreBeingDragged){let a=new Set(pe(t,r));if(r.frameToHighlight!==null)return!0;a.forEach(l=>{i.delete(l)})}for(let a of i)if(re(a))return!1;for(let a of i)if(En(a,o,t))return!0}return!1},ep=(e,t)=>e.name===null?gi(e)?`Frame ${t}`:`AI Frame $${t}`:e.name,Us=(e,t)=>$g({elements:e,bounds:t,type:"overlap"}).filter(r=>!r.frameId||r.frameId===t.id)});import cw from"roughjs/bin/rough";import{getStroke as g6}from"perfect-freehand";function M1(e){let t=Rm(e),r=new Path2D(t);return gw.set(e,r),r}function y6(e){return gw.get(e)}function Rm(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([o,n],i)=>[o,n,e.pressures[i]]):[[0,0,.5]],r={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:o=>Math.sin(o*Math.PI/2),last:!!e.lastCommittedPoint};return v6(g6(t,r))}function lw(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function v6(e){if(!e.length)return"";let t=e.length-1;return e.reduce((r,o,n,i)=>(n===t?r.push(o,lw(o,i[0]),"L",i[0],"Z"):r.push(o,lw(o,i[n+1])),r),["M",e[0],"Q"]).join(" ").replace(w6,"$1")}var Sg,f6,dw,mw,up,Jg,b6,E6,Cy,pw,uw,x6,mp,pp,aw,sw,hw,zs,gw,w6,Hn=Q(()=>{"use strict";f();le();it();G();ft();Or();Y();Je();Jt();mr();pn();Sg="invert(100%) hue-rotate(180deg) saturate(1.25)",f6=Qt(),dw=(e,t)=>xr(e)&&!t.imageCache.has(e.fileId),mw=(e,t,r)=>r.theme===ce.DARK&&xr(e)&&!dw(e,t)&&t.imageCache.get(e.fileId)?.mimeType!==oe.svg,up=e=>e.type==="freedraw"?e.strokeWidth*12:20,Jg=(e,t,r)=>{let o=(t?.opacity??100)*e.opacity/1e4;return(r.has(e.id)||t&&r.has(t.id))&&(o*=Xx/100),o},b6=(e,t,r)=>{let i=up(e),[a,s,l,c]=ne(e,t),d=ie(e)||Rt(e)?_t(a,l):e.width,m=ie(e)||Rt(e)?_t(s,c):e.height,p=d*window.devicePixelRatio+i*2,u=m*window.devicePixelRatio+i*2,h=r.value;return(p*h>32767||u*h>32767)&&(h=Math.min(32767/p,32767/u)),p*u*h*h>16777216&&(h=Math.sqrt(16777216/(p*u))),p=Math.floor(p*h),u=Math.floor(u*h),{width:p,height:u,scale:h}},E6=(e,t,r,o,n)=>{let i=document.createElement("canvas"),a=i.getContext("2d"),s=up(e),{width:l,height:c,scale:d}=b6(e,t,r);i.width=l,i.height=c;let m=0,p=0;if(ie(e)||Rt(e)){let[h,g]=ne(e,t);m=e.x>h?_t(e.x,h)*window.devicePixelRatio*d:0,p=e.y>g?_t(e.y,g)*window.devicePixelRatio*d:0,a.translate(m,p)}a.save(),a.translate(s*d,s*d),a.scale(window.devicePixelRatio*d,window.devicePixelRatio*d);let u=cw.canvas(i);return mw(e,o,n)&&(a.filter=Sg),mp(e,u,a,o,n),a.restore(),{element:e,canvas:i,theme:n.theme,scale:d,zoomValue:r.value,canvasOffsetX:m,canvasOffsetY:p,boundTextElementVersion:ae(e,t)?.version||null,containingFrameOpacity:Vt(e,t)?.opacity||100}},Cy=14,pw=document.createElement("img");pw.src=`data:${oe.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>')}`;uw=document.createElement("img");uw.src=`data:${oe.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;x6=(e,t)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);let r=Math.min(e.width,e.height),o=Math.min(r,Math.min(r*.4,100));t.drawImage(e.status==="error"?uw:pw,e.width/2-o/2,e.height/2-o/2,o,o)},mp=(e,t,r,o,n)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{r.lineJoin="round",r.lineCap="round",t.draw(Oe.get(e));break}case"arrow":case"line":{r.lineJoin="round",r.lineCap="round",Oe.get(e).forEach(i=>{t.draw(i)});break}case"freedraw":{r.save(),r.fillStyle=e.strokeColor;let i=y6(e),a=Oe.get(e);a&&t.draw(a),r.fillStyle=e.strokeColor,r.fill(i),r.restore();break}case"image":{let i=xr(e)?o.imageCache.get(e.fileId)?.image:void 0;i!=null&&!(i instanceof Promise)?(e.roundness&&r.roundRect&&(r.beginPath(),r.roundRect(0,0,e.width,e.height,Uo(Math.min(e.width,e.height),e)),r.clip()),r.drawImage(i,0,0,e.width,e.height)):x6(e,r);break}default:if(U(e)){let i=Vd(e.text),a=i&&!r.canvas.isConnected;a&&document.body.appendChild(r.canvas),r.canvas.setAttribute("dir",i?"rtl":"ltr"),r.save(),r.font=Ie(e),r.fillStyle=e.strokeColor,r.textAlign=e.textAlign;let s=e.text.replace(/\r\n?/g,`
|
|
32
|
+
`).map(i=>i.trim().split(","))),t.length===0)return{type:rs,reason:"No values"};let r=t[0].length;if(!t.every(i=>i.length===r))return{type:rs,reason:"All rows don't have same number of columns"};let n=Jv(t);if(n.type!==xl){let i=Jv(dM(t));if(i.type===xl)return i}return n},cu=Xx(Gx),Do={fillStyle:"hachure",fontFamily:gr,fontSize:ur,opacity:100,roughness:1,strokeColor:Ee.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:kt.MIDDLE,locked:!1},tT=e=>{let t=(un+st)*e.values.length+st,r=oa+st*2;return{chartWidth:t,chartHeight:r}},mM=(e,t,r,o,n)=>e.labels?.map((i,a)=>jt({groupIds:[o],backgroundColor:n,...Do,text:i.length>8?`${i.slice(0,5)}...`:i,x:t+a*(un+st)+st*2,y:r+st/2,width:un,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],pM=(e,t,r,o,n)=>{let i=jt({groupIds:[o],backgroundColor:n,...Do,x:t-st,y:r-st,text:"0",textAlign:"right"}),a=jt({groupIds:[o],backgroundColor:n,...Do,x:t-st,y:r-oa-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},uM=(e,t,r,o,n)=>{let{chartWidth:i,chartHeight:a}=tT(e),s=nn({backgroundColor:n,groupIds:[o],...Do,type:"line",x:t,y:r,width:i,points:[[0,0],[i,0]]}),l=nn({backgroundColor:n,groupIds:[o],...Do,type:"line",x:t,y:r,height:a,points:[[0,0],[0,-a]]}),c=nn({backgroundColor:n,groupIds:[o],...Do,type:"line",x:t,y:r-oa-st,strokeStyle:"dotted",width:i,opacity:Qv,points:[[0,0],[i,0]]});return[s,l,c]},rT=(e,t,r,o,n,i)=>{let{chartWidth:a,chartHeight:s}=tT(e),l=e.title?jt({backgroundColor:n,groupIds:[o],...Do,text:e.title,x:t+a/2,y:r-oa-st*2-ur,roundness:null,textAlign:"center"}):null,c=i?go({backgroundColor:n,groupIds:[o],...Do,type:"rectangle",x:t,y:r-s,width:a,height:s,strokeColor:Ee.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...l?[l]:[],...mM(e,t,r,o,n),...pM(e,t,r,o,n),...uM(e,t,r,o,n)]},gM=(e,t,r)=>{let o=Math.max(...e.values),n=Ut(),i=cu[Math.floor(Math.random()*cu.length)];return[...e.values.map((s,l)=>{let c=s/o*oa;return go({backgroundColor:i,groupIds:[n],...Do,type:"rectangle",x:t+l*(un+st)+st,y:r-c-st,width:un,height:c})}),...rT(e,t,r,n,i,T.DEV)]},hM=(e,t,r)=>{let o=Math.max(...e.values),n=Ut(),i=cu[Math.floor(Math.random()*cu.length)],a=0,s=[];for(let h of e.values){let x=a*(un+st),v=-(h/o)*oa;s.push([x,v]),a++}let l=Math.max(...s.map(h=>h[0])),c=Math.max(...s.map(h=>h[1])),d=Math.min(...s.map(h=>h[0])),m=Math.min(...s.map(h=>h[1])),p=nn({backgroundColor:i,groupIds:[n],...Do,type:"line",x:t+st+un/2,y:r-st,height:c-m,width:l-d,strokeWidth:2,points:s}),u=e.values.map((h,x)=>{let v=x*(un+st)+st/2,y=-(h/o)*oa+st/2;return go({backgroundColor:i,groupIds:[n],...Do,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:t+v+un/2,y:r+y-st*2,width:st,height:st})}),g=e.values.map((h,x)=>{let v=x*(un+st)+st/2,y=h/o*oa+st/2+st;return nn({backgroundColor:i,groupIds:[n],...Do,type:"line",x:t+v+un/2+st/2,y:r-y,height:y,strokeStyle:"dotted",opacity:Qv,points:[[0,0],[0,y]]})});return[...rT(e,t,r,n,i,T.DEV),p,...g,...u]},oT=(e,t,r,o)=>e==="line"?hM(t,r,o):gM(t,r,o)});function iT(e){let t=[];for(let r of e.childNodes)if(r.nodeType===3){let o=r.textContent?.trim();o&&t.push({type:"text",value:o})}else if(r instanceof HTMLImageElement){let o=r.getAttribute("src");o&&o.startsWith("http")&&t.push({type:"imageUrl",value:o})}else t=t.concat(iT(r));return t}var uW,du,yl,fM,nT,bM,mu,EM,xM,aT,yM,pu,uu,wi,wM,na=X(()=>{"use strict";f();db();Y();me();Nn();De();vr();V();uW="clipboard"in navigator&&"readText"in navigator.clipboard,du="clipboard"in navigator&&"writeText"in navigator.clipboard,yl="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,fM=e=>!!([hr.excalidraw,hr.excalidrawClipboard,hr.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),nT=({types:e,files:t})=>{!e&&!t&&console.warn("createPasteEvent: no types or files provided");let r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[o,n]of Object.entries(e))try{if(r.clipboardData?.setData(o,n),r.clipboardData?.getData(o)!==n)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}if(t){let o=-1;for(let n of t){o++;try{if(r.clipboardData?.items.add(n),r.clipboardData?.files[o]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return r},bM=({elements:e,files:t})=>{let r=Z(e),o=new Set(e.filter(s=>Q(s))),n=!1,i=e.reduce((s,l)=>(kr(l)&&(n=!0,t&&t[l.fileId]&&(s[l.fileId]=t[l.fileId])),s),{});n&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:hr.excalidrawClipboard,elements:e.map(s=>{if(Qt(s,r)&&!o.has(Qt(s,r))){let l=an(s);return F(l,{frameId:null}),l}return s}),files:t?i:void 0};return JSON.stringify(a)},mu=async(e,t,r)=>{await wi(bM({elements:e,files:t}),r)},EM=e=>{let t=eT(e);return t.type===xl?{spreadsheet:t.spreadsheet}:null};xM=e=>{let t=e.clipboardData?.getData("text/html");if(!t)return null;try{let r=new DOMParser().parseFromString(t,"text/html"),o=iT(r.body);if(o.length)return{type:"mixedContent",value:o}}catch(r){console.error(`error in parseHTMLFromPaste: ${r.message}`)}return null},aT=async()=>{let e={};try{if(navigator.clipboard?.readText)return{"text/plain":await navigator.clipboard?.readText()}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else throw r}let t;try{t=await navigator.clipboard?.read()}catch(r){if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}for(let r of t)for(let o of r.types)if(Sc(o0,o))try{e[o]=await(await r.getType(o)).text()}catch(n){console.warn(`Cannot retrieve ${o} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},yM=async(e,t=!1)=>{try{let r=!t&&e&&xM(e);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData("text/plain")||r.value.map(n=>n.value).join(`
|
|
33
|
+
`).trim()}:r:{type:"text",value:(e.clipboardData?.getData("text/plain")||"").trim()}}catch{return{type:"text",value:""}}},pu=async(e,t=!1)=>{let r=await yM(e,t);if(r.type==="mixedContent")return{mixedContent:r.value};try{let o=!t&&EM(r.value);if(o)return o}catch(o){console.error(o)}try{let o=JSON.parse(r.value),n=o.type===hr.excalidrawClipboardWithAPI;if(fM(o))return{elements:o.elements,files:o.files,text:t?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:r.value}},uu=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[se.png]:e})])}catch(t){if(Cn(e))await navigator.clipboard.write([new window.ClipboardItem({[se.png]:await e})]);else throw t}},wi=async(e,t)=>{if(du)try{await navigator.clipboard.writeText(e||"");return}catch(r){console.error(r)}try{if(t){if(t.clipboardData?.setData("text/plain",e||""),t.clipboardData?.getData("text/plain")!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}if(!wM(e))throw new Error("Error copying to clipboard.")},wM=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",r=document.createElement("textarea");r.style.border="0",r.style.padding="0",r.style.margin="0",r.style.position="absolute",r.style[t?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;r.style.top=`${o}px`,r.style.fontSize="12pt",r.setAttribute("readonly",""),r.value=e,document.body.appendChild(r);let n=!1;try{r.select(),r.setSelectionRange(0,r.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return r.remove(),n}});var ia,gu,wl,vM,os=X(()=>{"use strict";f();md();Zr();el();Y();tl();mi();na();ia=({elements:e,appState:t,files:r,maxWidthOrHeight:o,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:s,appState:l}=Xi({elements:e,appState:t},null,null),{exportBackground:c,viewBackgroundColor:d}=l;return su(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},r||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let h=Math.max(m,p),x=o<h?o/h:t?.exportScale??1;return u.width=m*x,u.height=p*x,{canvas:u,scale:x}}let g=n?.(m,p)||{width:m,height:p};return u.width=g.width,u.height=g.height,{canvas:u,scale:g.scale??1}})},gu=async e=>{let{mimeType:t=se.png,quality:r}=e;t===se.png&&typeof r=="number"&&console.warn(`"quality" will be ignored for "${se.png}" mimeType`),t==="image/jpg"&&(t=se.jpg),t===se.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${se.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await ia(e);return r=r||(/image\/jpe?g/.test(t)?.92:.8),new Promise((n,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&t===se.png&&e.appState?.exportEmbedScene&&(a=await Ef({blob:a,metadata:Vi(e.elements,e.appState,e.files||{},"local")})),n(a)},t,r)})},wl=async({elements:e,appState:t=lr(),files:r={},exportPadding:o,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a})=>{let{elements:s,appState:l}=Xi({elements:e,appState:t},null,null),c={...l,exportPadding:o};return bl(s,c,r,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a})},vM=async e=>{if(e.type==="svg"){let t=await wl(e);await wi(t.outerHTML)}else if(e.type==="png")await uu(gu(e));else if(e.type==="json")await mu(e.elements,e.files);else throw new Error("Invalid export type")}});var TM,SM,sT,lT,mb,cT,pb,ub=X(()=>{"use strict";f();me();mt();dt();V();TM=e=>e.type==="diamond"?[[e.width/2,0],[e.width,e.height/2],[e.width/2,e.height],[0,e.height/2]]:[[0,0],[0+e.width,0],[0+e.width,e.height],[0,e.height]],SM=e=>ie(e)||Zt(e)?e.points:TM(e),sT=e=>{let t=e.reduce((r,[o,n])=>(r.minY=Math.min(r.minY,n),r.minX=Math.min(r.minX,o),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,n),r),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},lT=e=>{let t=SM(e),{cx:r,cy:o}=sT(t),n=[r,o],i=t.map(d=>ce([d[0],d[1]],n,e.angle)),{minX:a,minY:s,maxX:l,maxY:c}=sT(i);return[a+e.x,s+e.y,l+e.x,c+e.y]},mb=(e,t,r=!1)=>{let o=lT(e),n=t[0]<=o[0]&&t[2]>=o[2]&&t[1]<=o[1]&&t[3]>=o[3];return r?n?!0:o[0]<=t[0]&&o[2]>=t[2]&&o[1]<=t[1]&&o[3]>=t[3]:n},cT=(e,t)=>{let r=lT(e);return(gd(r[0],t[0],t[2])||gd(t[0],r[0],r[2]))&&(gd(r[1],t[1],t[3])||gd(t[1],r[1],r[3]))},pb=({elements:e,bounds:t,type:r,errorMargin:o=0})=>{Ac(t)&&(t=ho(t,Z(e)));let n=[t[0]-o,t[1]-o,t[2]+o,t[3]+o],i=new Set;for(let a of e){if(i.has(a.id))continue;if(r==="overlap"?cT(a,n):r==="inside"?mb(a,n):mb(a,n,!0)){if(i.add(a.id),a.boundElements)for(let l of a.boundElements)i.add(l.id);H(a)&&a.containerId&&i.add(a.containerId),ne(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))}});function dT(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function uT(e,t){return e[0]*t[1]-t[0]*e[1]}function IM(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function hu(e,t){return[e[0]-t[0],e[1]-t[1]]}function mT(e,t){let r=hu(e[1],e[0]),o=hu(t,e[0]),n=uT(r,o);return Math.abs(n)<CM}function gb(e,t){let r=hu(e[1],e[0]),o=hu(t,e[0]);return uT(r,o)<0}function pT(e,t){return mT(e,t[0])||mT(e,t[1])||(gb(e,t[0])?!gb(e,t[1]):gb(e,t[1]))}function gT(e,t){return IM(dT(e),dT(t))&&pT(e,t)&&pT(t,e)}var CM,hT=X(()=>{"use strict";f();CM=1e-6});var fT=X(()=>{"use strict";f();os();ub();hT();dt()});function bT(e,t,r){let o=hb(t,r),n=hb(e,r);return o.some(a=>n.some(s=>gT(a,s)))}var fu,ET,xT,yT,Bn,fb,wT,bo,pd,lb,vl,vT,Qt,TT,hd,Tl,bb,bu,zn,Eu,nu,ts,lu,El,vr=X(()=>{"use strict";f();we();mt();He();V();De();et();Gt();dt();fT();me();fu=(e,t,r)=>{let o=Z(e);for(let n of t)if(n.frameId){let i=r.get(n.id),a=r.get(n.frameId);if(i){let s=o.get(i);s&&F(s,{frameId:a??n.frameId},!1)}}};ET=(e,t,r)=>Eu(Sl(e,t,r,!1)).filter(o=>!Q(o)&&!o.frameId||o.frameId===t.id),xT=(e,t,r,o)=>Sl(e,t,o).some(n=>n.id===r.id),yT=(e,t,r)=>{let[o,n,i,a]=ae(t,r),[s,l,c,d]=Te(e);return o<=s&&n<=l&&i>=c&&a>=d},Bn=(e,t,r)=>yT([e],t,r)||bT(e,t,r)||xT([t],e,t,r),fb=(e,t,r)=>{let[o,n,i,a]=ae(t,r);return Op([o,n],[e.x,e.y],[i,a])},wT=e=>{let t=new Map;for(let r of e){let o=Q(r)?r.id:r.frameId;o&&!t.has(o)&&t.set(o,bo(e,o))}return t},bo=(e,t)=>{let r=[];for(let o of e.values())o.frameId===t&&r.push(o);return r},pd=e=>e.filter(t=>Q(t)),lb=e=>{let t=Z(pd(e));return e.filter(r=>t.has(r.id)||!r.frameId||!t.has(r.frameId))},vl=(e,t,r,o)=>{let n=bo(e,t.id),i=new Set(n),a=new Set([...ET(e,t,o),...n.filter(p=>xT(e,p,t,o))]),s=n.filter(p=>!a.has(p)),l=new Set(Array.from(a).flatMap(p=>p.groupIds));for(let p of s)if(!bT(p,t,o))p.groupIds.length===0&&i.delete(p);else if(p.groupIds.length>0)for(let u of p.groupIds)l.add(u);for(let p of s)if(p.groupIds.length>0){let u=!0;for(let g of p.groupIds)l.has(g)&&(u=!1);u&&i.delete(p)}let c=Array.from(a).filter(p=>p.groupIds.length===0);for(let p of c)i.add(p);let d=Array.from(a).filter(p=>p.groupIds.length>0),m=Vm(d,r);for(let[p,u]of Object.entries(m))if(u){let g=ot(e,p);if(yT(g,t,o))for(let h of g)i.add(h)}return[...i].filter(p=>!(H(p)&&p.containerId))},vT=(e,t,r)=>Eu(e,ET(e,t,r)),Qt=(e,t)=>e.frameId&&t.get(e.frameId)||null,TT=(e,t)=>{let r=new Set,o=Z(e);e=Eu(e);for(let a of e)Q(a)&&a.id!==t.id&&r.add(a.id);let n=new Set,i=[];for(let a of e)if(!(Q(a)||a.frameId&&r.has(a.frameId)))if(a.groupIds.length){let s=a.groupIds.at(-1);if(!n.has(s)){n.add(s);let l=ot(e,s);if(l.some(c=>Bn(c,t,o)))for(let c of l)i.push(c)}}else Bn(a,t,o)&&i.push(a);return i},hd=(e,t,r)=>{let o=Z(e),n=new Map;for(let l of e.values())l.frameId===r.id&&n.set(l.id,!0);let i=new Set(t.map(l=>l.id)),a=[],s=new Set;for(let l of t)Q(l)&&l.id!==r.id&&s.add(l.id);for(let l of Eu(e,t)){if(Q(l)||l.frameId&&s.has(l.frameId))continue;n.has(l.id)||a.push(l);let c=J(l,o);c&&!i.has(c.id)&&!n.has(c.id)&&a.push(c)}for(let l of a)F(l,{frameId:r.id},!1);return e},Tl=(e,t)=>{let r=new Map,o=new Map;for(let n of e)if(n.frameId){r.set(n.id,n);let i=o.get(n.frameId)||[];i.push(n);let a=J(n,t);a&&(r.set(a.id,a),i.push(a)),o.set(n.frameId,i)}for(let[,n]of r)F(n,{frameId:null},!1)},bb=(e,t)=>{let r=bo(e,t.id);return Tl(r,Z(e)),e},bu=(e,t,r,o)=>hd(bb(e,r),t,r).slice(),zn=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),n=new Set(o);if(t.editingGroupId)for(let s of o)s.groupIds.length===0?n.add(s):s.groupIds.flatMap(l=>ot(e,l)).forEach(l=>n.add(l));let i=new Set,a=Z(e);return n.forEach(s=>{s.frameId&&!Q(s)&&!ts(s,a,t)&&i.add(s)}),i.size>0&&Tl(i,a),e},Eu=(e,t)=>{let r=new Set,o=t||e;for(let a of o.values()){let s=a.groupIds[a.groupIds.length-1];s&&r.add(s)}let n=new Set;for(let a of r)ot(e,a).some(s=>Q(s))&&n.add(a);let i=[];for(let a of o.values())n.has(a.groupIds[a.groupIds.length-1])||i.push(a);return i},nu=(e,t,r)=>{let o=H(e)&&Et(e,t)||e;return r.selectedElementIds[o.id]&&r.selectedElementsAreBeingDragged?r.frameToHighlight:Qt(o,t)},ts=(e,t,r)=>{let o=nu(e,t,r),n=H(e)&&Et(e,t)||e;if(o){if(!r.selectedElementIds[e.id]||!r.selectedElementsAreBeingDragged)return!0;if(n.groupIds.length===0)return Bn(n,o,t);let i=new Set(n.groupIds.flatMap(a=>ot(t,a)));if(r.editingGroupId&&r.selectedElementsAreBeingDragged){let a=new Set(he(t,r));if(r.frameToHighlight!==null)return!0;a.forEach(l=>{i.delete(l)})}for(let a of i)if(Q(a))return!1;for(let a of i)if(Bn(a,o,t))return!0}return!1},lu=e=>e.name===null?B0(e)?"Frame":"AI Frame":e.name,El=(e,t)=>pb({elements:e,bounds:t,type:"overlap"}).filter(r=>!r.frameId||r.frameId===t.id)});import AT from"roughjs/bin/rough";import{getStroke as AM}from"perfect-freehand";function RT(e){let t=qp(e),r=new Path2D(t);return _T.set(e,r),r}function DM(e){return _T.get(e)}function qp(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([o,n],i)=>[o,n,e.pressures[i]]):[[0,0,.5]],r={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:o=>Math.sin(o*Math.PI/2),last:!!e.lastCommittedPoint};return RM(AM(t,r))}function CT(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function RM(e){if(!e.length)return"";let t=e.length-1;return e.reduce((r,o,n,i)=>(n===t?r.push(o,CT(o,i[0]),"L",i[0],"Z"):r.push(o,CT(o,i[n+1])),r),["M",e[0],"Q"]).join(" ").replace(_M,"$1")}var eb,MM,MT,kT,yu,Eb,kM,PM,Vv,PT,LT,LM,xu,jm,ST,IT,DT,fl,_T,_M,li=X(()=>{"use strict";f();me();dt();V();mt();Zr();Y();He();Wt();vr();Qo();on();eb="invert(100%) hue-rotate(180deg) saturate(1.25)",MM=lr(),MT=(e,t)=>kr(e)&&!t.imageCache.has(e.fileId),kT=(e,t,r)=>r.theme===ue.DARK&&kr(e)&&!MT(e,t)&&t.imageCache.get(e.fileId)?.mimeType!==se.svg,yu=e=>{switch(e.type){case"freedraw":return e.strokeWidth*12;case"text":return e.fontSize/2;default:return 20}},Eb=(e,t,r)=>{let o=(t?.opacity??100)*e.opacity/1e4;return(r.has(e.id)||t&&r.has(t.id))&&(o*=b0/100),o},kM=(e,t,r)=>{let i=yu(e),[a,s,l,c]=ae(e,t),d=ie(e)||Zt(e)?Ht(a,l):e.width,m=ie(e)||Zt(e)?Ht(s,c):e.height,p=d*window.devicePixelRatio+i*2,u=m*window.devicePixelRatio+i*2,g=r.value;return(p*g>32767||u*g>32767)&&(g=Math.min(32767/p,32767/u)),p*u*g*g>16777216&&(g=Math.sqrt(16777216/(p*u))),p=Math.floor(p*g),u=Math.floor(u*g),{width:p,height:u,scale:g}},PM=(e,t,r,o,n)=>{let i=document.createElement("canvas"),a=i.getContext("2d"),s=yu(e),{width:l,height:c,scale:d}=kM(e,t,r);i.width=l,i.height=c;let m=-100,p=0;if(ie(e)||Zt(e)){let[v,y]=ae(e,t);m=e.x>v?Ht(e.x,v)*window.devicePixelRatio*d:0,p=e.y>y?Ht(e.y,y)*window.devicePixelRatio*d:0,a.translate(m,p)}a.save(),a.translate(s*d,s*d),a.scale(window.devicePixelRatio*d,window.devicePixelRatio*d);let u=AT.canvas(i);kT(e,o,n)&&(a.filter=eb),xu(e,u,a,o,n),a.restore();let g=J(e,t),h=document.createElement("canvas"),x=h.getContext("2d");if(ne(e)&&g){let[v,y,w,C]=ae(e,t),M=Math.max(Ht(v,w),Ht(y,C));h.width=M*window.devicePixelRatio*d+s*d*10,h.height=M*window.devicePixelRatio*d+s*d*10,x.translate(h.width/2,h.height/2),x.rotate(e.angle),x.drawImage(i,-i.width/2,-i.height/2,i.width,i.height);let[,,,,I,P]=ae(g,t);x.rotate(-e.angle);let A=(h.width-i.width)/2,N=(h.height-i.height)/2,k=h.width/2-(I-v)*window.devicePixelRatio*d-A-s*d,D=h.height/2-(P-y)*window.devicePixelRatio*d-N-s*d;x.translate(-k,-D),x.clearRect(-(g.width/2+wt)*window.devicePixelRatio*d,-(g.height/2+wt)*window.devicePixelRatio*d,(g.width+wt*2)*window.devicePixelRatio*d,(g.height+wt*2)*window.devicePixelRatio*d)}return{element:e,canvas:i,theme:n.theme,scale:d,zoomValue:r.value,canvasOffsetX:m,canvasOffsetY:p,boundTextElementVersion:J(e,t)?.version||null,containingFrameOpacity:Qt(e,t)?.opacity||100,boundTextCanvas:h,angle:e.angle}},Vv=14,PT=document.createElement("img");PT.src=`data:${se.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>')}`;LT=document.createElement("img");LT.src=`data:${se.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>')}`;LM=(e,t)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);let r=Math.min(e.width,e.height),o=Math.min(r,Math.min(r*.4,100));t.drawImage(e.status==="error"?LT:PT,e.width/2-o/2,e.height/2-o/2,o,o)},xu=(e,t,r,o,n)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{r.lineJoin="round",r.lineCap="round",t.draw(_e.get(e));break}case"arrow":case"line":{r.lineJoin="round",r.lineCap="round",_e.get(e).forEach(i=>{t.draw(i)});break}case"freedraw":{r.save(),r.fillStyle=e.strokeColor;let i=DM(e),a=_e.get(e);a&&t.draw(a),r.fillStyle=e.strokeColor,r.fill(i),r.restore();break}case"image":{let i=kr(e)?o.imageCache.get(e.fileId)?.image:void 0;i!=null&&!(i instanceof Promise)?(e.roundness&&r.roundRect&&(r.beginPath(),r.roundRect(0,0,e.width,e.height,fo(Math.min(e.width,e.height),e)),r.clip()),r.drawImage(i,0,0,e.width,e.height)):LM(e,r);break}default:if(H(e)){let i=Rm(e.text),a=i&&!r.canvas.isConnected;a&&document.body.appendChild(r.canvas),r.canvas.setAttribute("dir",i?"rtl":"ltr"),r.save(),r.font=Me(e),r.fillStyle=e.strokeColor,r.textAlign=e.textAlign;let s=e.text.replace(/\r\n?/g,`
|
|
54
34
|
`).split(`
|
|
55
|
-
`),l=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,c=Ci(e.fontSize,e.lineHeight),d=gm(e.fontFamily,e.fontSize,c);for(let m=0;m<s.length;m++)r.fillText(s[m],l,m*c+d);r.restore(),a&&r.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},pp=new WeakMap,aw=(e,t,r,o)=>{let n=r?o.zoom:f6.zoom,i=pp.get(e),a=i&&i.zoomValue!==n.value&&!o?.shouldCacheIgnoreZoom,s=ae(e,t)?.version||null,l=Vt(e,t)?.opacity||100;if(!i||a||i.theme!==o.theme||i.boundTextElementVersion!==s||i.containingFrameOpacity!==l){let c=E6(e,t,n,r,o);return pp.set(e,c),c}return i},sw=(e,t,r,o,n)=>{let i=e.element,a=up(i),s=e.scale,[l,c,d,m]=ne(i,n);Rt(i)&&(l=Math.floor(l),d=Math.ceil(d),c=Math.floor(c),m=Math.ceil(m));let p=((l+d)/2+o.scrollX)*window.devicePixelRatio,u=((c+m)/2+o.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let h=ae(i,n);if(xe(i)&&h){let g=document.createElement("canvas"),x=g.getContext("2d"),v=Math.max(_t(l,d),_t(c,m));g.width=v*window.devicePixelRatio*s+a*e.scale*10,g.height=v*window.devicePixelRatio*s+a*e.scale*10;let y=(g.width-e.canvas.width)/2,w=(g.height-e.canvas.height)/2;x.translate(g.width/2,g.height/2),x.rotate(i.angle),x.drawImage(e.canvas,-e.canvas.width/2,-e.canvas.height/2,e.canvas.width,e.canvas.height);let[,,,,I,A]=ne(h,n);x.rotate(-i.angle);let C=g.width/2-(I-l)*window.devicePixelRatio*s-y-a*s,L=g.height/2-(A-c)*window.devicePixelRatio*s-w-a*s;x.translate(-C,-L),x.clearRect(-(h.width/2+ht)*window.devicePixelRatio*s,-(h.height/2+ht)*window.devicePixelRatio*s,(h.width+ht*2)*window.devicePixelRatio*s,(h.height+ht*2)*window.devicePixelRatio*s),t.translate(p,u),t.drawImage(g,-(d-l)/2*window.devicePixelRatio-y/s-a,-(m-c)/2*window.devicePixelRatio-w/s-a,g.width/s,g.height/s)}else if(t.translate(p,u),t.rotate(i.angle),"scale"in e.element&&!dw(i,r)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-p,-u),t.drawImage(e.canvas,(l+o.scrollX)*window.devicePixelRatio-a*e.scale/e.scale,(c+o.scrollY)*window.devicePixelRatio-a*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),T.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&sr(i)){let g=ae(i,n),x=dg(i);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((x.x+o.scrollX)*window.devicePixelRatio,(x.y+o.scrollY)*window.devicePixelRatio,cr(i,g)*window.devicePixelRatio,wa(i,g)*window.devicePixelRatio)}t.restore()},hw=(e,t,r,o)=>{t.save(),t.translate(e.x+r.scrollX,e.y+r.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let n=.5/r.zoom.value;t.fillRect(n,n,e.width,e.height),t.lineWidth=1/r.zoom.value,t.strokeStyle=o,t.strokeRect(n,n,e.width,e.height),t.restore()},zs=(e,t,r,o,n,i,a)=>{switch(n.globalAlpha=Jg(e,Vt(e,t),i.elementsPendingErasure),e.type){case"magicframe":case"frame":{a.frameRendering.enabled&&a.frameRendering.outline&&(n.save(),n.translate(e.x+a.scrollX,e.y+a.scrollY),n.fillStyle="rgba(0, 0, 200, 0.04)",n.lineWidth=qe.strokeWidth/a.zoom.value,n.strokeStyle=qe.strokeColor,sa(e)&&(n.strokeStyle=a.theme===ce.LIGHT?"#7affd7":"#1d8264"),qe.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,e.width,e.height,qe.radius/a.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,e.width,e.height),n.restore());break}case"freedraw":{if(Oe.generateElementShape(e,null),i.isExporting){let[s,l,c,d]=ne(e,t),m=(s+c)/2+a.scrollX,p=(l+d)/2+a.scrollY,u=(c-s)/2-(e.x-s),h=(d-l)/2-(e.y-l);n.save(),n.translate(m,p),n.rotate(e.angle),n.translate(-u,-h),mp(e,o,n,i,a),n.restore()}else{let s=aw(e,t,i,a);sw(s,n,i,a,r)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(Oe.generateElementShape(e,i),i.isExporting){let[s,l,c,d]=ne(e,t),m=(s+c)/2+a.scrollX,p=(l+d)/2+a.scrollY,u=(c-s)/2-(e.x-s),h=(d-l)/2-(e.y-l);if(U(e)){let x=wt(e,t);if(xe(x)){let v=j.getBoundTextElementPosition(x,e,t);u=(c-s)/2-(v.x-s),h=(d-l)/2-(v.y-l)}}n.save(),n.translate(m,p),mw(e,i,a)&&(n.filter="none");let g=ae(e,t);if(xe(e)&&g){let x=document.createElement("canvas"),v=x.getContext("2d"),y=Math.max(_t(s,c),_t(l,d)),w=up(e);x.width=y*a.exportScale+w*10*a.exportScale,x.height=y*a.exportScale+w*10*a.exportScale,v.translate(x.width/2,x.height/2),v.scale(a.exportScale,a.exportScale),u=e.width/2-(e.x-s),h=e.height/2-(e.y-l),v.rotate(e.angle);let I=cw.canvas(x);v.translate(-u,-h),mp(e,I,v,i,a),v.translate(u,h),v.rotate(-e.angle);let[,,,,A,C]=ne(g,t),L=(s+c)/2-A,M=(l+d)/2-C;v.translate(-L,-M),v.clearRect(-g.width/2,-g.height/2,g.width,g.height),n.scale(1/a.exportScale,1/a.exportScale),n.drawImage(x,-x.width/2,-x.height/2,x.width,x.height)}else n.rotate(e.angle),e.type==="image"&&n.scale(e.scale[0],e.scale[1]),n.translate(-u,-h),mp(e,o,n,i,a);n.restore()}else{let s=aw(e,t,i,a),l=n.imageSmoothingEnabled;!a?.shouldCacheIgnoreZoom&&(!e.angle||S1(e.angle))&&(n.imageSmoothingEnabled=!1),sw(s,n,i,a,r),n.imageSmoothingEnabled=l}break}default:throw new Error(`Unimplemented type ${e.type}`)}n.globalAlpha=1},gw=new WeakMap([]);w6=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g});import{RoughGenerator as T6}from"roughjs/bin/generator";var Oe,pn=Q(()=>{"use strict";f();Hn();zh();ir();Oe=class e{static rg=new T6;static cache=new WeakMap;static get=t=>e.cache.get(t);static set=(t,r)=>e.cache.set(t,r);static delete=t=>e.cache.delete(t);static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,r)=>{let o=r?.isExporting?void 0:e.get(t);if(o!==void 0)return o;pp.delete(t);let n=k1(t,e.rg,r||{isExporting:!1,canvasBackgroundColor:ue.white,embedsValidationStatus:null});return e.cache.set(t,n),n}}});var O,se,Ai,Ae=Q(()=>{"use strict";f();bi();ps();zo();G();pn();O=(e,t,r=!0)=>{let o=!1,{points:n,fileId:i}=t;typeof n<"u"&&(t={...ms(n),...t});for(let a in t){let s=t[a];if(typeof s<"u"){if(e[a]===s&&(typeof s!="object"||s===null||a==="groupIds"||a==="scale"))continue;if(a==="scale"){let l=e[a],c=s;if(l[0]===c[0]&&l[1]===c[1])continue}else if(a==="points"){let l=e[a],c=s;if(l.length===c.length){let d=!1,m=l.length;for(;--m;){let p=l[m],u=c[m];if(p[0]!==u[0]||p[1]!==u[1]){d=!0;break}}if(!d)continue}}e[a]=s,o=!0}}return o&&((typeof t.height<"u"||typeof t.width<"u"||typeof i<"u"||typeof n<"u")&&Oe.delete(e),e.version++,e.versionNonce=uo(),e.updated=Fn(),r&&Mt.getScene(e)?.triggerUpdate()),e},se=(e,t,r=!1)=>{let o=!1;for(let n in t){let i=t[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!r?e:{...e,...t,updated:Fn(),version:e.version+1,versionNonce:uo()}},Ai=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=uo(),e.updated=Fn(),e)});var Eo,La,hp,Is,yc,Pa=Q(()=>{"use strict";f();Ae();le();Y();it();G();Eo=e=>ie(e)||Rt(e)?e.points.length<2:e.width===0&&e.height===0,La=(e,t,r,o,n)=>{let[i,a,s,l]=Jr(e,n),c=$e({clientX:o.offsetLeft,clientY:o.offsetTop},o),d=$e({clientX:o.offsetLeft+t,clientY:o.offsetTop+r},o);return c.x<=s&&c.y<=l&&d.x>=i&&d.y>=a},hp=(e,t,r)=>{let o=Math.abs(t),n=Math.abs(r);if(e==="line"||e==="arrow"||e==="freedraw"){let i=Math.round(Math.atan(n/o)/on)*on;i===0?r=0:i===Math.PI/2?t=0:r=o*Math.tan(i)*Math.sign(r)||r}else e!=="selection"&&(r=o*Math.sign(r));return{width:t,height:r}},Is=(e,t,r,o)=>{let n=r-e,i=o-t,a=Math.round(Math.atan(i/n)/on)*on;if(a===0)i=0;else if(a===Math.PI/2)n=0;else{let s=Math.tan(a),l=-1,c=t-s*e,d=-1/s,m=-1,p=o-d*r,u=(l*p-m*c)/(s*m-d*l),h=(c*d-p*s)/(s*m-d*l);n=u-e,i=h-t}return{width:n,height:i}},yc=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let r=Math.abs(e.width);t.width=r,t.x=e.x-r}if(e.height<0){let r=Math.abs(e.height);t.height=r,t.y=e.y-r}return t}});var fw,S6,Ew,bw,Qg,Qn,gp,Da,Xs,Pc,fp,Dc=Q(()=>{"use strict";f();it();ft();le();Y();fw={mouse:8,pen:16,touch:28},S6=16,Ew={e:!0,s:!0,n:!0,w:!0},bw={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},Qg={e:!0,s:!0,n:!0,w:!0},Qn=(e,t,r,o,n,i,a)=>{let[s,l]=he(e+r/2,t+o/2,n,i,a);return[s-r/2,l-o/2,r,o]},gp=e=>!(e.viewport.isMobile||e.isTouchScreen&&(Cx||Pd)),Da=e=>gp(e)?Ew:{},Xs=([e,t,r,o,n,i],a,s,l,c={},d=4)=>{let m=fw[l],p=m/s.value,u=m/s.value,h=m/s.value,g=m/s.value,x=r-e,v=o-t,y=d/s.value,w=(m-Nn*2)/(2*s.value),I={nw:c.nw?void 0:Qn(e-y-h+w,t-y-g+w,p,u,n,i,a),ne:c.ne?void 0:Qn(r+y-w,t-y-g+w,p,u,n,i,a),sw:c.sw?void 0:Qn(e-y-h+w,o+y-w,p,u,n,i,a),se:c.se?void 0:Qn(r+y-w,o+y-w,p,u,n,i,a),rotation:c.rotation?void 0:Qn(e+x/2-p/2,t-y-g+w-S6/s.value,p,u,n,i,a)},A=5*fw.mouse/s.value;return Math.abs(x)>A&&(c.n||(I.n=Qn(e+x/2-p/2,t-y-g+w,p,u,n,i,a)),c.s||(I.s=Qn(e+x/2-p/2,o+y-w,p,u,n,i,a))),Math.abs(v)>A&&(c.w||(I.w=Qn(e-y-h+w,t+v/2-u/2,p,u,n,i,a)),c.e||(I.e=Qn(r+y-w,t+v/2-u/2,p,u,n,i,a))),I},Pc=(e,t,r,o="mouse",n=Ew)=>{if(e.locked)return{};if(e.type==="freedraw"||ie(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=Qg:a[0]>0&&a[1]<0?n=bw:a[0]>0&&a[1]>0?n=Qg:a[0]<0&&a[1]>0?n=bw:a[0]<0&&a[1]<0&&(n=Qg)}}else re(e)&&(n={...n,rotation:!0});let i=ie(e)?Nn+8:Nn;return Xs(ne(e,r,!0),e.angle,t,o,n,i)},fp=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let r=e[0];return ie(r)?r.points.length>2:!0}});var tf,xw,bp,Ep,ef,I6,xp,yw,ww=Q(()=>{"use strict";f();Dc();it();Y();nm();le();tf=(e,t,r)=>t>=e[0]&&t<=e[0]+e[2]&&r>=e[1]&&r<=e[1]+e[3],xw=(e,t,r,o,n,i,a,s)=>{if(!r.selectedElementIds[e.id])return!1;let{rotation:l,...c}=Pc(e,i,t,a,Da(s));if(l&&tf(l,o,n))return"rotation";let d=Object.keys(c).filter(m=>{let p=c[m];return p?tf(p,o,n):!1});if(d.length>0)return d[0];if(gp(s)){let[m,p,u,h,g,x]=ne(e,t);if(!(ie(e)&&e.points.length<=2)){let v=Rd/i.value,y=yw([m-v,p-v],[u+v,h+v],[g,x],un(e.angle));for(let[w,I]of Object.entries(y))if(ga([o,n],I,v))return w}}return!1},bp=(e,t,r,o,n,i,a,s)=>e.reduce((l,c)=>{if(l)return l;let d=xw(c,a,t,r,o,n,i,s);return d?{element:c,transformHandleType:d}:null},null),Ep=([e,t,r,o],n,i,a,s,l)=>{let c=Xs([e,t,r,o,(e+r)/2,(t+o)/2],0,a,s,Da(l)),d=Object.keys(c).find(m=>{let p=c[m];return p&&tf(p,n,i)});if(d)return d;if(gp(l)){let m=(e+r)/2,p=(t+o)/2,u=Rd/a.value,h=yw([e-u,t-u],[r+u,o+u],[m,p],un(0));for(let[g,x]of Object.entries(h))if(ga([n,i],x,u))return g}return!1},ef=["ns","nesw","ew","nwse"],I6=(e,t)=>{let r=ef.indexOf(e);if(r>=0){let o=Math.round(t/(Math.PI/4));e=ef[(r+o)%ef.length]}return e},xp=e=>{let{element:t,transformHandleType:r}=e,o=t&&Math.sign(t.height)*Math.sign(t.width)===-1,n=null;switch(r){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":o?n="nesw":n="nwse";break;case"ne":case"sw":o?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&t&&(n=I6(n,t.angle)),n?`${n}-resize`:""},yw=([e,t],[r,o],n,i)=>{let a=yt([e,t],i,n),s=yt([r,t],i,n),l=yt([e,o],i,n),c=yt([r,o],i,n);return{n:[a,s],e:[s,c],s:[c,l],w:[l,a]}}});var yp,rf,C6,_c,Rc,A6,k6,of,M6,nf,af,Nc=Q(()=>{"use strict";f();Y();ps();ft();it();le();Ae();G();_r();bi();Je();Jt();Gt();yp=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e,rf=(e,t,r,o,n,i,a,s,l,c,d)=>{if(r.length===1){let[m]=r;return t==="rotation"?(C6(m,o,s,l,n),qt(m,o)):U(m)&&t?(A6(e,m,o,t,i,s,l),qt(m,o)):t&&k6(e,a,m,o,t,i,s,l),!0}else if(r.length>1){if(t==="rotation")return M6(e,r,o,s,l,n,c,d),!0;if(t)return of(e,r,o,t,i,a,s,l),!0}return!1},C6=(e,t,r,o,n)=>{let[i,a,s,l]=ne(e,t),c=(i+s)/2,d=(a+l)/2,m;re(e)?m=0:(m=5*Math.PI/2+Math.atan2(o-d,r-c),n&&(m+=on/2,m-=m%on),m=yp(m));let p=Vo(e);if(O(e,{angle:m}),p){let u=Mt.getScene(e)?.getElement(p);u&&!xe(e)&&O(u,{angle:m})}},_c=(e,t,r,o)=>ie(e)||Rt(e)?{points:xi(0,t,xi(1,r,e.points,o),o)}:{},Rc=(e,t,r)=>{let o=e.width;if(Me(e)){let a=wt(e,t);a&&(o=cr(a,e))}let i=e.fontSize*(r/o);return i<_d?null:{size:i}},A6=(e,t,r,o,n,i,a)=>{let[s,l,c,d,m,p]=ne(t,r),[u,h]=he(i,a,m,p,-t.angle),g=0,x=0;o!=="e"&&o!=="w"&&(o.includes("e")&&(g=(u-s)/(c-s)),o.includes("w")&&(g=(c-u)/(c-s)),o.includes("n")&&(x=(d-h)/(d-l)),o.includes("s")&&(x=(h-l)/(d-l)));let v=Math.max(g,x);if(v>0){let y=t.width*v,w=t.height*v,I=Rc(t,r,y);if(I===null)return;let A=[s,l],C=[c,d],L=[m,p],M=[s,l];if(["n","w","nw"].includes(o)&&(M=[C[0]-Math.abs(y),C[1]-Math.abs(w)]),o==="ne"){let Z=[A[0],C[1]];M=[Z[0],Z[1]-Math.abs(w)]}if(o==="sw"){let Z=[C[0],A[1]];M=[Z[0]-Math.abs(y),Z[1]]}["s","n"].includes(o)&&(M[0]=L[0]-y/2),["e","w"].includes(o)&&(M[1]=L[1]-w/2),n&&(M[0]=L[0]-Math.abs(y)/2,M[1]=L[1]-Math.abs(w)/2);let z=t.angle,k=Pe(M,[m,p],z),N=[M[0]+Math.abs(y)/2,M[1]+Math.abs(w)/2],B=Pe(N,[m,p],z);M=Pe(k,B,-z);let[_,V]=M;O(t,{fontSize:I.size,width:y,height:w,x:_,y:V})}if(o==="e"||o==="w"){let y=e.get(t.id),[w,I,A,C]=Wn(y,y.width,y.height,!0),L=[w,I],M=[A,C],z=us(L,M),k=Pe([i,a],z,-y.angle),[N,,B]=Wn(t,t.width,t.height,!0),_=B-N,V=M[0]-L[0],Z=Ms(Ie({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),J=V/_;o.includes("e")&&(J=(k[0]-L[0])/_),o.includes("w")&&(J=(M[0]-k[0])/_);let Se=t.width*J<Z?Z:t.width*J,W=go(t.originalText,Ie(t),Math.abs(Se)),$=Bt(W,Ie(t),t.lineHeight),ee=$.height,[fe,ot,Le,zt]=Wn(y,Se,ee,!0),Do=Le-fe,Yr=zt-ot,fr=[...L];["n","w","nw"].includes(o)&&(fr=[M[0]-Math.abs(Do),L[1]]);let Kr=y.angle,li=Pe(fr,z,Kr),_o=[fr[0]+Math.abs(Do)/2,fr[1]+Math.abs(Yr)/2],Ar=Pe(_o,z,Kr);fr=Pe(li,Ar,-Kr);let $r={width:Math.abs(Se),height:Math.abs($.height),x:fr[0],y:fr[1],text:W,autoResize:!1};O(t,$r)}},k6=(e,t,r,o,n,i,a,s)=>{let l=e.get(r.id),[c,d,m,p]=Wn(l,l.width,l.height,!0),u=[c,d],h=[m,p],g=us(u,h),x=Pe([a,s],g,-l.angle),[v,y,w,I]=Wn(r,r.width,r.height,!0),A=w-v,C=I-y,L=h[0]-u[0],M=h[1]-u[1],z=L/A,k=M/C,N={},B=ae(r,o);n.includes("e")&&(z=(x[0]-u[0])/A),n.includes("s")&&(k=(x[1]-u[1])/C),n.includes("w")&&(z=(h[0]-x[0])/A),n.includes("n")&&(k=(h[1]-x[1])/C);let _=l.width,V=l.height,Z=r.width*z,J=r.height*k;if(i&&(Z=2*Z-_,J=2*J-V),t){let kr=Math.abs(Z)/_,Ja=Math.abs(J)/V;if(n.length===1&&(J*=kr,Z*=Ja),n.length===2){let ea=Math.max(kr,Ja);Z=_*ea*Math.sign(Z),J=V*ea*Math.sign(J)}}if(B){let kr=e.get(B.id);if(kr&&(N={fontSize:kr.fontSize}),t){let Ja={...r,width:Z,height:J},ea=Rc(B,o,cr(Ja,B));if(ea===null)return;N={fontSize:ea.size}}else{let Ja=ks(Ie(B),B.lineHeight),ea=As(B.fontSize,B.lineHeight);Z=Math.max(Z,Ja),J=Math.max(J,ea)}}let[Se,W,$,ee]=Wn(l,Z,J,!0),fe=$-Se,ot=ee-W,Le=[...u];if(["n","w","nw"].includes(n)&&(Le=[h[0]-Math.abs(fe),h[1]-Math.abs(ot)]),n==="ne"){let kr=[u[0],h[1]];Le=[kr[0],kr[1]-Math.abs(ot)]}if(n==="sw"){let kr=[h[0],u[1]];Le=[kr[0]-Math.abs(fe),kr[1]]}t&&(["s","n"].includes(n)&&(Le[0]=g[0]-fe/2),["e","w"].includes(n)&&(Le[1]=g[1]-ot/2));let zt=Z<0,Do=J<0;zt&&(n.includes("e")&&(Le[0]-=Math.abs(fe)),n.includes("w")&&(Le[0]+=Math.abs(fe))),Do&&(n.includes("s")&&(Le[1]-=Math.abs(ot)),n.includes("n")&&(Le[1]+=Math.abs(ot))),i&&(Le[0]=g[0]-Math.abs(fe)/2,Le[1]=g[1]-Math.abs(ot)/2);let Yr=l.angle,fr=Pe(Le,g,Yr),Kr=[Le[0]+Math.abs(fe)/2,Le[1]+Math.abs(ot)/2],li=Pe(Kr,g,Yr);Le=Pe(fr,li,-Yr);let _o=[...Le],Ar=l.x-Se,$r=l.y-W;_o[0]+=Ar,_o[1]+=$r;let or=_o[0],RC=_o[1],px,ux;(ie(r)||Rt(r))&&(px=xi(1,J,l.points,!0),ux=xi(0,Z,px,!0));let ci={width:Math.abs(Z),height:Math.abs(J),x:or,y:RC,points:ux};if("scale"in r&&"scale"in l&&O(r,{scale:[(Math.sign($-l.x)||l.scale[0])*l.scale[0],(Math.sign(ee-l.y)||l.scale[1])*l.scale[1]]}),xe(r)&&B&&t){let kr=ci.width/r.width*B.fontSize;if(kr<_d)return;N.fontSize=kr}ci.width!==0&&ci.height!==0&&Number.isFinite(ci.x)&&Number.isFinite(ci.y)&&(O(r,ci),qt(r,o,{newSize:{width:ci.width,height:ci.height}}),B&&N!=null&&O(B,{fontSize:N.fontSize}),Wo(r,o,n,t))},of=(e,t,r,o,n,i,a,s)=>{let l=t.reduce((W,$)=>{let ee=e.get($.id);return ee&&W.push({orig:ee,latest:$}),W},[]),c=l.reduce((W,{orig:$})=>{if(!ie($))return W;let ee=Vo($);if(!ee)return W;let fe=e.get(ee)??null;if(!Me(fe))return W;let ot=j.getBoundTextElementPosition($,fe,r);return[...W,{...fe,...ot}]},[]),{minX:d,minY:m,maxX:p,maxY:u,midX:h,midY:g}=Rr(l.map(({orig:W})=>W).concat(c)),x=p-d,v=u-m,y=o,w={ne:[d,u],se:[d,m],sw:[p,m],nw:[p,u],e:[d,m+v/2],w:[p,m+v/2],n:[d+x/2,u],s:[d+x/2,m]},[I,A]=n?[h,g]:w[y],C=n?2:1,L=Math.max(Math.abs(a-I)/x||0,Math.abs(s-A)/v||0)*C;if(L===0)return;let M=y.includes("e")||y.includes("w")?Math.abs(a-I)/x*C:1,z=y.includes("n")||y.includes("s")?Math.abs(s-A)/v*C:1,k=i||l.some(W=>W.latest.angle!==0||U(W.latest)||$o(W.latest));k&&(M=L,z=L);let N={ne:[a<I,s>A],se:[a<I,s<A],sw:[a>I,s<A],nw:[a>I,s>A],e:[a<I,!1],w:[a>I,!1],n:[!1,s>A],s:[!1,s<A]},[B,_]=N[y].map(W=>W?-1:1),V=B<0,Z=_<0,J=[];for(let{orig:W,latest:$}of l){if(U(W)&&Me(W))continue;let ee=W.width*M,fe=W.height*z,ot=yp(W.angle*B*_),Le=ie(W)||Rt(W),zt=W.x-I,Do=W.y-A,Yr=V&&!Le?ee:0,fr=Z&&!Le?fe:0,Kr=I+B*(zt*M+Yr),li=A+_*(Do*z+fr),_o=_c(W,ee*B,fe*_,!1),Ar={x:Kr,y:li,width:ee,height:fe,angle:ot,..._o};if(mo(W)&&(Ar.scale=[W.scale[0]*B,W.scale[1]*_]),U(W)){let or=Rc(W,r,ee);if(!or)return;Ar.fontSize=or.size}let $r=e.get(Vo(W)??"");if($r)if(k){let or=$r.fontSize*L;if(or<_d)return;Ar.boundTextFontSize=or}else Ar.boundTextFontSize=$r.fontSize;J.push({element:$,update:Ar})}let Se=J.map(({element:W})=>W);for(let{element:W,update:{boundTextFontSize:$,...ee}}of J){let{width:fe,height:ot,angle:Le}=ee;O(W,ee,!1),qt(W,r,{simultaneouslyUpdated:Se,newSize:{width:fe,height:ot}});let zt=ae(W,r);zt&&$&&(O(zt,{fontSize:$,angle:ie(W)?void 0:Le},!1),Wo(W,r,o,!0))}Mt.getScene(J[0].element)?.triggerUpdate()},M6=(e,t,r,o,n,i,a,s)=>{let l=5*Math.PI/2+Math.atan2(n-s,o-a);i&&(l+=on/2,l-=l%on),t.filter(c=>!re(c)).forEach(c=>{let[d,m,p,u]=ne(c,r),h=(d+p)/2,g=(m+u)/2,x=e.get(c.id)?.angle??c.angle,[v,y]=he(h,g,a,s,l+x-c.angle);O(c,{x:c.x+(v-h),y:c.y+(y-g),angle:yp(l+x)},!1),qt(c,r,{simultaneouslyUpdated:t});let w=ae(c,r);w&&!xe(c)&&O(w,{x:w.x+(v-h),y:w.y+(y-g),angle:yp(l+x)},!1)}),Mt.getScene(t[0])?.triggerUpdate()},nf=(e,t,r,o,n)=>{let[i,a,s,l]=t.length===1?ne(t[0],r):we(t),c=(i+s)/2,d=(a+l)/2,m=t.length===1?t[0].angle:0;switch([o,n]=he(o,n,c,d,-m),e){case"n":return he(o-(i+s)/2,n-a,0,0,m);case"s":return he(o-(i+s)/2,n-l,0,0,m);case"w":return he(o-i,n-(a+l)/2,0,0,m);case"e":return he(o-s,n-(a+l)/2,0,0,m);case"nw":return he(o-i,n-a,0,0,m);case"ne":return he(o-s,n-a,0,0,m);case"sw":return he(o-i,n-l,0,0,m);case"se":return he(o-s,n-l,0,0,m);default:return[0,0]}},af=(e,t)=>{let[,[r,o]]=t.points;return e==="nw"&&(r<0||o<0)||e==="ne"&&r>=0||e==="sw"&&r<=0||e==="se"&&(r>0||o>0)?"end":"origin"}});var sf,L6,vw,lf,wp,Tw=Q(()=>{"use strict";f();_r();it();Ae();Pa();Je();ft();le();G();Y();sf=(e,t,r,o,n,i,a)=>{let s=new Set(t),l=t.filter(m=>re(m)).map(m=>m.id);if(l.length>0)for(let m of n.getNonDeletedElements())m.frameId!==null&&l.includes(m.frameId)&&s.add(m);let c=we(Array.from(s).map(m=>e.originalElements.get(m.id)??m)),d=L6(c,r,i,a);s.forEach(m=>{if(vw(e,m,d),!xe(m)){let p=ae(m,n.getNonDeletedElementsMap());p&&vw(e,p,d)}qt(m,n.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(s)})})},L6=(e,t,r,o)=>{let[n,i]=e,a=n+t.x+r.x,s=i+t.y+r.y;if(r.x===0||r.y===0){let[l,c]=Lt(n+t.x,i+t.y,o);r.x===0&&(a=l),r.y===0&&(s=c)}return{x:a-n,y:s-i}},vw=(e,t,r)=>{let o=e.originalElements.get(t.id)??t,n=o.x+r.x,i=o.y+r.y;O(t,{x:n,y:i})},lf=(e,t,r)=>{let[o,n]=we(e);return[t-o,r-n]},wp=(e,t,r,o,n,i,a,s,l,c,d,m,p=null)=>{l&&e.type!=="selection"&&(m?s=a/m:(Math.abs(i-o)>Math.abs(n-r)?{width:a,height:s}=hp(t,s,n<r?-a:a):{width:a,height:s}=hp(t,a,i<o?-s:s),s<0&&(s=-s)));let u=n<r?r-a:r,h=i<o?o-s:o;c&&(a+=a,s+=s,u=r-a/2,h=o-s/2);let g=null;if(U(e)){s=e.height;let x=Ms(Ie({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);a=Math.max(a,x),Math.abs(n-r)>kx/d&&(g={autoResize:!1}),h=o,c&&(u=r-a/2)}a!==0&&s!==0&&O(e,{x:u+(p?.x??0),y:h+(p?.y??0),width:a,height:s,...g})}});var _a,Sw=Q(()=>{"use strict";f();Xe();_a=(e,t)=>!!(!e.viewModeEnabled&&(e.activeTool.type!=="custom"&&(e.editingElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||pe(t,e).length))});var P6,cf,df,Iw,Te,$l,Cw,fy,Fm,be=Q(()=>{"use strict";f();Pa();le();jo();it();Dc();ww();Nc();Tw();le();Je();Pa();Sw();P6=e=>e.reduce((t,r)=>t+r.version,0),cf=e=>{let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e[r].versionNonce;return t>>>0},df=e=>{let t=5381;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)+t+o}return t>>>0},Iw=e=>e.filter(t=>!t.isDeleted&&!Eo(t)),Te=e=>e.filter(t=>!t.isDeleted),$l=e=>!e.isDeleted,Cw=e=>Te(e).map(t=>Yl(t.type)?{...t,lastCommittedPoint:null}:t),fy=e=>Cw(e),Fm=e=>Cw(e)});var Ra,$s,mf,Ke,pf,pe,Oc,Fe,Ei=Q(()=>{"use strict";f();be();le();mr();G();Pa();Ra=e=>{let t=new Set;return e.forEach(r=>{re(r)&&t.add(r.id)}),e.filter(r=>!(r.frameId&&t.has(r.frameId)))},$s=(e,t,r,o=!0)=>{let[n,i,a,s]=ne(t,r),l=e.filter(c=>{let[d,m,p,u]=Jr(c,r),h=Vt(c,r);if(h){let[g,x,v,y]=Jr(h,r);d=Math.max(g,d),m=Math.max(x,m),p=Math.min(v,p),u=Math.min(y,u)}return c.locked===!1&&c.type!=="selection"&&!Me(c)&&n<=d&&i<=m&&a>=p&&s>=u});return l=o?Ra(l):l,l=l.filter(c=>{let d=Vt(c,r);return d?En(c,d,r):!0}),l},mf=(e,t,r,o)=>{let n=new Set(t.map(i=>i.id));return e.filter(i=>{let a=La(i,r.width,r.height,r,o);return!n.has(i.id)&&a})},Ke=function(){let e=null,t=null,r=null,o=(n,i)=>(r!=null&&n===e&&i.selectedElementIds===t||(r=n.some(a=>i.selectedElementIds[a.id]),e=n,t=i.selectedElementIds),r);return o.clearCache=()=>{e=null,t=null,r=null},o}(),pf=(e,t,r)=>{let o=Array.from(new Set(pe(e,t).map(n=>r(n))));return o.length===1?o[0]:null},pe=(e,t,r)=>{let o=[];for(let n of e.values()){if(t.selectedElementIds[n.id]){o.push(n);continue}if(r?.includeBoundTextElement&&Me(n)&&t.selectedElementIds[n?.containerId]){o.push(n);continue}}if(r?.includeElementsInFrames){let n=[];return o.forEach(i=>{re(i)&&ro(e,i.id).forEach(a=>n.push(a)),n.push(i)}),n}return o},Oc=(e,t)=>t.editingElement?[t.editingElement]:pe(e,t,{includeBoundTextElement:!0}),Fe=(e,t)=>tt(t.selectedElementIds,e)?t.selectedElementIds:e});var D6,uf,bn,hf=Q(()=>{"use strict";f();be();G();D6=(e,t)=>{let[r,o,n,i]=t,{x:a,y:s}=Ht({sceneX:r,sceneY:o},e),{x:l,y:c}=Ht({sceneX:n,sceneY:i},e);return l-a>e.width||c-s>e.height},uf=({scenePoint:e,viewportDimensions:t,zoom:r})=>({scrollX:t.width/2/r.value-e.x,scrollY:t.height/2/r.value-e.y}),bn=(e,t)=>{if(e=Iw(e),!e.length)return{scrollX:0,scrollY:0};let[r,o,n,i]=we(e);D6(t,[r,o,n,i])&&([r,o,n,i]=gg(e,$e({clientX:t.scrollX,clientY:t.scrollY},t)));let a=(r+n)/2,s=(o+i)/2;return uf({scenePoint:{x:a,y:s},viewportDimensions:{width:t.width,height:t.height},zoom:t.zoom})}});var yn,ei,vp=Q(()=>{"use strict";f();Y();yn=e=>Math.max(ns,Math.min(e,30)),ei=({viewportX:e,viewportY:t,nextZoom:r},o)=>{let n=e-o.offsetLeft,i=t-o.offsetTop,a=o.zoom.value,s=o.scrollX+(n-n/a),l=o.scrollY+(i-i/a),c=-(n-n/r),d=-(i-i/r);return{scrollX:s+c,scrollY:l+d,zoom:{value:r}}}});var Xe=Q(()=>{"use strict";f();Ei();hf();Jl();vp()});f();import p7,{useEffect as u7}from"react";f();import{useEffect as e5,useState as t5}from"react";f();f();import fx from"./en-EB2MBPAV.json";import zC from"./percentages-UCQDHIQF.json";f();import{unstable_createStore as BC,useAtom as w7}from"jotai";import{useLayoutEffect as T7}from"react";var Ge=Symbol(),nr=BC();import{atom as HC,useAtomValue as UC}from"jotai";var FC=hx({"./locales/ar-SA.json":()=>import("./ar-SA-JA6F2FMJ.json"),"./locales/az-AZ.json":()=>import("./az-AZ-GVIENQVH.json"),"./locales/bg-BG.json":()=>import("./bg-BG-YFNNHCEP.json"),"./locales/bn-BD.json":()=>import("./bn-BD-LMEIWSRD.json"),"./locales/ca-ES.json":()=>import("./ca-ES-C2WGCLOT.json"),"./locales/cs-CZ.json":()=>import("./cs-CZ-F2NDIQMB.json"),"./locales/da-DK.json":()=>import("./da-DK-WBEQB3CJ.json"),"./locales/de-DE.json":()=>import("./de-DE-VEIMCP7R.json"),"./locales/el-GR.json":()=>import("./el-GR-TKRKG5GQ.json"),"./locales/en.json":()=>import("./en-EB2MBPAV.json"),"./locales/es-ES.json":()=>import("./es-ES-TOLWEZNW.json"),"./locales/eu-ES.json":()=>import("./eu-ES-7CDRJQWJ.json"),"./locales/fa-IR.json":()=>import("./fa-IR-527E2XGU.json"),"./locales/fi-FI.json":()=>import("./fi-FI-NLQ7RQGZ.json"),"./locales/fr-FR.json":()=>import("./fr-FR-KUHO4FLU.json"),"./locales/gl-ES.json":()=>import("./gl-ES-NEXX3VBB.json"),"./locales/he-IL.json":()=>import("./he-IL-MED2VGBZ.json"),"./locales/hi-IN.json":()=>import("./hi-IN-5V633W7V.json"),"./locales/hu-HU.json":()=>import("./hu-HU-2FOZGVGR.json"),"./locales/id-ID.json":()=>import("./id-ID-I6BOLXTF.json"),"./locales/it-IT.json":()=>import("./it-IT-WKPQOK4P.json"),"./locales/ja-JP.json":()=>import("./ja-JP-VKA4ISRU.json"),"./locales/kaa.json":()=>import("./kaa-IKPRSBNY.json"),"./locales/kab-KAB.json":()=>import("./kab-KAB-IE4PHQTZ.json"),"./locales/kk-KZ.json":()=>import("./kk-KZ-MNJT6XSV.json"),"./locales/km-KH.json":()=>import("./km-KH-LADGDFXV.json"),"./locales/ko-KR.json":()=>import("./ko-KR-XD7AVF2F.json"),"./locales/ku-TR.json":()=>import("./ku-TR-4XBHKDQA.json"),"./locales/lt-LT.json":()=>import("./lt-LT-QC35R4YH.json"),"./locales/lv-LV.json":()=>import("./lv-LV-GSD5D3BA.json"),"./locales/mr-IN.json":()=>import("./mr-IN-KOLSWM7Y.json"),"./locales/my-MM.json":()=>import("./my-MM-M53KMUET.json"),"./locales/nb-NO.json":()=>import("./nb-NO-XXC6U37A.json"),"./locales/nl-NL.json":()=>import("./nl-NL-HCCJQEUO.json"),"./locales/nn-NO.json":()=>import("./nn-NO-6P7Z2PI2.json"),"./locales/oc-FR.json":()=>import("./oc-FR-JRJKPLNT.json"),"./locales/pa-IN.json":()=>import("./pa-IN-LZWLEPIB.json"),"./locales/percentages.json":()=>import("./percentages-UCQDHIQF.json"),"./locales/pl-PL.json":()=>import("./pl-PL-3WBLCXI2.json"),"./locales/pt-BR.json":()=>import("./pt-BR-O3ZPTUNW.json"),"./locales/pt-PT.json":()=>import("./pt-PT-7AQTSAFO.json"),"./locales/ro-RO.json":()=>import("./ro-RO-HJ65JYWV.json"),"./locales/ru-RU.json":()=>import("./ru-RU-P7ROIYNC.json"),"./locales/si-LK.json":()=>import("./si-LK-7ZSWVION.json"),"./locales/sk-SK.json":()=>import("./sk-SK-NXVBGLYY.json"),"./locales/sl-SI.json":()=>import("./sl-SI-VFTWOYNP.json"),"./locales/sv-SE.json":()=>import("./sv-SE-YONBLQNW.json"),"./locales/ta-IN.json":()=>import("./ta-IN-BSETPMLX.json"),"./locales/th-TH.json":()=>import("./th-TH-URTRDITB.json"),"./locales/tr-TR.json":()=>import("./tr-TR-N5SCAVTB.json"),"./locales/uk-UA.json":()=>import("./uk-UA-LBCYVSQZ.json"),"./locales/vi-VN.json":()=>import("./vi-VN-POZWLIUU.json"),"./locales/zh-CN.json":()=>import("./zh-CN-FUF5V3SC.json"),"./locales/zh-HK.json":()=>import("./zh-HK-OB4VW42C.json"),"./locales/zh-TW.json":()=>import("./zh-TW-5JPVKOM7.json")});var GC=85,rn={code:"en",label:"English"},es=[rn,...[{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=>zC[e.code]>=GC).sort((e,t)=>e.label>t.label?1:-1)],Id="__test__";T.DEV&&es.unshift({code:Id,label:"test language"},{code:`${Id}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Qa=rn,Sd={},Cd=async e=>{if(Qa=e,document.documentElement.dir=Qa.rtl?"rtl":"ltr",document.documentElement.lang=Qa.code,e.code.startsWith(Id))Sd={};else try{Sd=await FC(`./locales/${Qa.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),Sd=fx}nr.set(bx,e.code)},Dn=()=>Qa,gx=(e,t)=>{for(let r=0;r<t.length;++r){let o=t[r];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},E=(e,t,r)=>{if(Qa.code.startsWith(Id))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),n=gx(Sd,o)||gx(fx,o)||r;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)n=n.replace(`{{${i}}}`,String(t[i]));return n},bx=HC(rn.code),At=()=>{let e=UC(bx,Ge);return{t:E,langCode:e}};import{useState as jC,useEffect as qC}from"react";f();import WC from"react";import{jsx as fh}from"react/jsx-runtime";var VC=({size:e="1em",circleWidth:t=8,synchronized:r=!1})=>{let n=-(WC.useRef(Date.now()).current%1600);return fh("div",{className:"Spinner",children:fh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":r?`${n}ms`:0},children:fh("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},Xt=VC;Y();import JC from"clsx";import{jsx as Ih,jsxs as QC}from"react/jsx-runtime";var Gd=({delay:e,theme:t})=>{let[r,o]=jC(!!e);return qC(()=>{if(!e)return;let n=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(n)},[e]),r?null:QC("div",{className:JC("LoadingMessage",{"LoadingMessage--dark":t===ce.DARK}),children:[Ih("div",{children:Ih(Xt,{})}),Ih("div",{className:"LoadingMessage-text",children:E("labels.loadingScene")})]})};import{jsx as r5}from"react/jsx-runtime";var jx=e=>{let[t,r]=t5(!0);return e5(()=>{let o=async()=>{await Cd(n),r(!1)},n=es.find(i=>i.code===e.langCode)||rn;o()},[e.langCode]),t?r5(Gd,{theme:e.theme}):e.children};f();import Pn,{useContext as Ji}from"react";import{flushSync as YE}from"react-dom";import $_ from"roughjs/bin/rough";import gC from"clsx";import{nanoid as X_}from"nanoid";f();f();Xe();ge();f();import gf,{useEffect as _6,useRef as Aw,useState as R6}from"react";import kw from"clsx";fi();G();import{jsx as Bc,jsxs as Fc}from"react/jsx-runtime";var de=gf.forwardRef((e,t)=>{let{id:r}=Yt(),o=gf.useRef(null);gf.useImperativeHandle(t,()=>o.current);let n=`ToolIcon_size_${e.size}`,[i,a]=R6(!1),s=Aw(!0),l=async d=>{let m="onClick"in e&&e.onClick?.(d);if(sn(m))try{a(!0),await m}catch(p){if(p instanceof mn)console.warn(p);else throw p}finally{s.current&&a(!1)}};_6(()=>(s.current=!0,()=>{s.current=!1}),[]);let c=Aw(null);if(e.type==="button"||e.type==="icon"||e.type==="submit"){let d=e.type==="icon"?"button":e.type;return Fc("button",{className:kw("ToolIcon_type_button",n,e.className,e.visible&&!e.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!e.hidden,"ToolIcon--selected":e.selected,"ToolIcon--plain":e.type==="icon"}),style:e.style,"data-testid":e["data-testid"],hidden:e.hidden,title:e.title,"aria-label":e["aria-label"],type:d,onClick:l,ref:o,disabled:i||e.isLoading||!!e.disabled,children:[(e.icon||e.label)&&Fc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!e.disabled,children:[e.icon||e.label,e.keyBindingLabel&&Bc("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel}),e.isLoading&&Bc(Xt,{})]}),e.showAriaLabel&&Fc("div",{className:"ToolIcon__label",children:[e["aria-label"]," ",i&&Bc(Xt,{})]}),e.children]})}return Fc("label",{className:kw("ToolIcon",e.className),title:e.title,onPointerDown:d=>{c.current=d.pointerType||null,e.onPointerDown?.({pointerType:d.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{c.current=null})},children:[Bc("input",{className:`ToolIcon_type_radio ${n}`,type:"radio",name:e.name,"aria-label":e["aria-label"],"aria-keyshortcuts":e["aria-keyshortcuts"],"data-testid":e["data-testid"],id:`${r}-${e.id}`,onChange:()=>{e.onChange?.({pointerType:c.current})},checked:e.checked,ref:o}),Fc("div",{className:"ToolIcon__icon",children:[e.icon,e.keyBindingLabel&&Bc("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel})]})]})});de.defaultProps={visible:!0,className:"",size:"medium"};de.displayName="ToolButton";Ve();be();Ae();Gt();Jt();_r();le();G();f();Y();import Fr from"react";import N6 from"open-color";import O6 from"clsx";import{Fragment as Ze,jsx as b,jsxs as F}from"react/jsx-runtime";var Jo=e=>"var(--icon-fill-color)",Mw=e=>e===ce.LIGHT?N6.white:"#1e1e1e",P=(e,t=512)=>{let{width:r=512,height:o=r,mirror:n,style:i,...a}=typeof t=="number"?{width:t}:t;return b("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${r} ${o}`,className:O6({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?b("path",{fill:"currentColor",d:e}):e})},q={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Ee={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},EG=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:3,y:8,width:18,height:4,rx:1}),b("line",{x1:12,y1:8,x2:12,y2:21}),b("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),b("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),q),Tp=P(F("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),b("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),b("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),q),Lw=P(F("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),q),Pw=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"1"}),b("circle",{cx:"12",cy:"19",r:"1"}),b("circle",{cx:"12",cy:"5",r:"1"})]}),q),Dw=P(F("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),b("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),b("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),q),Na=P(F("g",{children:[b("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"}),b("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"}),b("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:b("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"})}),b("g",{mask:"url(#UnlockedIcon)",children:b("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"})})]}),Ee),Zs=P(F("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),b("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"})]}),Ee),_w=P(F(Ze,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),b("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"}),Rw=P(F(Ze,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),b("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"}),Nw=P(F(Ze,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),b("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"}),xG=P(b("g",{fill:"currentColor",children:b("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"}),Ow=P(F("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Bw=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),q),Fw=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),q),zw=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"})]}),q),Hw=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),q),Uw=P(b("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),Ee),Gw=P(F("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),b("path",{d:"M16 7h4"}),b("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),q),js=P(F("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"m11.25 5.417 3.333 3.333"})]}),Ee),Ww=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),b("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),b("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),b("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),b("polyline",{points:"5 20 11 4 13 4 20 20"})]}),q),Vw=P(F("g",{strokeWidth:"1.25",children:[b("path",{d:"M12.5 6.667h.01"}),b("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"}),b("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),b("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),Ee),Yw=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M18 13.3l-6.3 -6.3"})]}),q),ff=P(b("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),Ee),bf=P(b("path",{d:"M5 10h10",strokeWidth:"1.25"}),Ee),Kw=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 21l-6 -6"}),b("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"}),b("path",{d:"M3 4v4h4"})]}),q),Qo=P(b("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"}),Ee),$w=P(F("g",{strokeWidth:"1.25",children:[b("polyline",{points:"12 16 18 10 12 4"}),b("polyline",{points:"8 4 2 10 8 16"})]}),Ee),zc=P(F("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),Ee),Hc=P(b("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"}),Ee),Uc=P(b("g",{stroke:"currentColor",strokeLinejoin:"round",children:b("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"})}),{...Ee,strokeWidth:1.5}),Sp=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),b("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),q),Oa=P(b("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"}),Ee),qs=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),q),Xw=P(F("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),q),Ef=P(b("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"}),Ee),Ip=P(b("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"}),Ee),Zw=P(F("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),Ee),jw=P(F("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),b("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),q),qw=P(b("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Gc=P(F("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),Ee),Jw=P("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),Qw=P("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Js=P(b("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"}),Ee),yG=P("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),e2=P("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Cp=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),b("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),b("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),q),Ap=P(F("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 8h.01"}),b("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),b("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),b("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),b("path",{d:"M19 16v6"}),b("path",{d:"M22 19l-3 3l-3 -3"})]}),q),t2=P("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),wG=P("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),vG=P("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),r2=P("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),TG=P("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),xf=P(b("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"}),Ee),yf=P(b("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"}),Ee),o2=P("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),n2=P(b("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"}),Ee),SG=P("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),IG=P("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),CG=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 14v-11"}),b("path",{d:"M9 6l3 -3l3 3"})]}),q),AG=P(F(Ze,{children:[b("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"}),b("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}),kG=P(b("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}),i2=F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 10l0 10"}),b("path",{d:"M12 10l4 4"}),b("path",{d:"M12 10l-4 4"}),b("path",{d:"M4 4l16 0"})]}),a2=F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 5l0 14"}),b("path",{d:"M16 9l-4 -4"}),b("path",{d:"M8 9l4 -4"})]}),wf=P(a2,q),vf=P(a2,{...q,style:{transform:"rotate(180deg)"}}),Tf=P(i2,q),Sf=P(i2,{...q,style:{transform:"rotate(180deg)"}}),If=P(F(Ze,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),Cf=P(F(Ze,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),Af=P(F(Ze,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),kf=P(F(Ze,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),s2=P(F(Ze,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),l2=P(F(Ze,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),Mf=P(F("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),b("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),Ee),Lf=P(F("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),b("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),Ee),kp=P(F("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"9",cy:"7",r:"4"}),b("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),b("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),b("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),q),MG=P("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),LG=P("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),yo=P(F(Ze,{children:[b("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"M15 5 5 15M5 5l10 10"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),PG=P("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),DG=P("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),_G=P("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Pf=Fr.memo(({theme:e})=>P(F(Ze,{children:[b("path",{d:"M25 26H111V111H25",fill:Jo(e)}),b("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:Jo(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:Jo(e)}),b("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:Jo(e),strokeWidth:"2"}),F("g",{fill:Mw(e),stroke:Jo(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Df=Fr.memo(({theme:e})=>P(F(Ze,{children:[b("path",{d:"M25 26H111V111H25",fill:Jo(e)}),b("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:Jo(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:Jo(e)}),b("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:Jo(e),strokeWidth:"2"}),F("g",{fill:Mw(e),stroke:Jo(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),b("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),c2=P(b("g",{strokeWidth:1.25,children:b("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"})}),Ee),d2=P(F(Ze,{children:[b("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"}),b("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:b("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"})}),b("g",{mask:"url(#FillHachureIcon)",children:b("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"})})]}),Ee),m2=P(F(Ze,{children:[F("g",{clipPath:"url(#a)",children:[b("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"}),b("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:b("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"})}),b("g",{mask:"url(#FillCrossHatchIcon)",children:b("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"})})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),p2=P(F(Ze,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...Ee,fill:"currentColor"}),_f=P(b(Ze,{children:b("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),Ee),u2=P(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),Ee),h2=P(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),Ee),RG=Fr.memo(({theme:e})=>P(b("path",{d:"M6 10H34",stroke:Jo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),g2=P(F("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12h2"}),b("path",{d:"M17 12h2"}),b("path",{d:"M11 12h2"})]}),q),f2=P(F("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M8 12v.01"}),b("path",{d:"M12 12v.01"}),b("path",{d:"M16 12v.01"}),b("path",{d:"M20 12v.01"})]}),q),b2=P(b("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"}),Ee),E2=P(b("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"}),Ee),x2=P(b("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"}),Ee),y2=P(F("svg",{strokeWidth:"1.5",children:[b("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"}),b("path",{d:"M13.3333 3.33331V3.34331"}),b("path",{d:"M16.6667 3.33331V3.34331"}),b("path",{d:"M16.6667 6.66669V6.67669"}),b("path",{d:"M16.6667 10V10.01"}),b("path",{d:"M3.33334 13.3333V13.3433"}),b("path",{d:"M16.6667 13.3333V13.3433"}),b("path",{d:"M3.33334 16.6667V16.6767"}),b("path",{d:"M6.66666 16.6667V16.6767"}),b("path",{d:"M10 16.6667V16.6767"}),b("path",{d:"M13.3333 16.6667V16.6767"}),b("path",{d:"M16.6667 16.6667V16.6767"})]}),Ee),w2=P(F("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),b("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),b("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),b("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),b("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),b("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),b("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),b("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),b("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),b("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),b("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),b("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),q),v2=P(b("path",{d:"M6 10H34",stroke:"currentColor",strokeWidth:2,fill:"none"}),{width:40,height:20}),T2=Fr.memo(({flip:e=!1})=>P(F("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[b("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),b("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),Rf=Fr.memo(({flip:e=!1})=>P(F("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[b("path",{d:"M32 10L6 10",strokeWidth:2}),b("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),S2=Fr.memo(({flip:e=!1})=>P(F("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[b("path",{d:"M26 10L6 10"}),b("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),I2=Fr.memo(({flip:e=!1})=>P(b("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:b("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),C2=Fr.memo(({flip:e=!1})=>P(F("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[b("path",{d:"M32 10L6 10",strokeWidth:2}),b("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),A2=Fr.memo(({flip:e=!1})=>P(F("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[b("path",{d:"M6,9.5H27"}),b("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),k2=Fr.memo(({flip:e=!1})=>P(F("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M6,9.5H20"}),b("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),M2=Fr.memo(({flip:e=!1})=>P(F("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M6,9.5H20"}),b("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),L2=P(F(Ze,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),P2=P(F(Ze,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),D2=P(F(Ze,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),_2=P(b(Ze,{children:b("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"})}),Ee),Ba=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 7v-2h13v2"}),b("path",{d:"M10 5v14"}),b("path",{d:"M12 19h-4"}),b("path",{d:"M15 13v-1h6v1"}),b("path",{d:"M18 12v7"}),b("path",{d:"M17 19h2"})]}),q),R2=P(b(Ze,{children:b("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("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"})})}),Ee),N2=P(F(Ze,{children:[b("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),Ee),O2=P(F("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),b("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),q),B2=P(F("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),b("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),q),F2=P(F("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),q),z2=Fr.memo(({theme:e})=>P(F("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),b("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),q)),H2=Fr.memo(({theme:e})=>P(F("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),b("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),q)),U2=Fr.memo(({theme:e})=>P(F("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),b("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),b("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),q)),Mp=P(F("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 19h-18l9 -15"}),b("path",{d:"M20.615 15.171h.015"}),b("path",{d:"M19.515 11.771h.015"}),b("path",{d:"M17.715 8.671h.015"}),b("path",{d:"M15.415 5.971h.015"})]}),q),G2=P(b("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}),NG=P(b("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"})),Lp=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),b("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),b("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),b("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),q),Nf=P(F(Ze,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),b("path",{d:"M7 11l5 5l5 -5"}),b("path",{d:"M12 4l0 12"})]}),q),Pp=P(F(Ze,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),q),W2=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M9.15 14.85l8.85 -10.85"}),b("path",{d:"M6 4l8.85 10.85"})]}),q),V2=P(F(Ze,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),b("path",{d:"M12 17l0 .01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),q),OG=P(F(Ze,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 4v16l13 -8z"})]}),q),BG=P(F(Ze,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),q),FG=P(F(Ze,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12l5 5l10 -10"})]}),q),Y2=P(F(Ze,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 9v4"}),b("path",{d:"M12 17h.01"})]}),q),K2=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11 7l6 6"}),b("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),q),$2=P(F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l-4 7h8z"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),q),Dp=P(F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 7l16 0"}),b("path",{d:"M4 17l16 0"}),b("path",{d:"M7 4l0 16"}),b("path",{d:"M17 4l0 16"})]}),q),_p=P(b("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),Qs=P(F("g",{strokeWidth:"1.25",children:[b("path",{d:"M4.16602 10H15.8327"}),b("path",{d:"M12.5 13.3333L15.8333 10"}),b("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),Ee),Rp=P(F("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[b("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"}),b("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),el=P(F("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),q),zG=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),q),Wc=P(F("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),b("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),b("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"}),b("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),b("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),b("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),q),X2=P(F("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),b("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),b("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),b("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),q),tl=P(F("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),b("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),q),Z2=P(F("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),b("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"}),b("path",{d:"M3 3l18 18"})]}),q),j2=P(F("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),q),q2=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),q),Np=P(F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),b("path",{d:"M21 21l-6 -6"})]}),q),J2=P(F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),b("path",{d:"M12 7v5l3 3"}),b("path",{d:"M19 16l-2 3h4l-2 3"})]}),q),Q2=P(F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 14 0"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),q),ev=P(F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 3l18 18"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),q),Op=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),q),tv=P(F("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 20v.01"}),b("path",{d:"M16 20v.01"}),b("path",{d:"M8 20v.01"}),b("path",{d:"M4 20v.01"}),b("path",{d:"M4 16v.01"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M4 8v.01"}),b("path",{d:"M4 4v.01"}),b("path",{d:"M8 4v.01"}),b("path",{d:"M12 4v.01"}),b("path",{d:"M16 4v.01"}),b("path",{d:"M20 4v.01"}),b("path",{d:"M20 8v.01"}),b("path",{d:"M20 12v.01"}),b("path",{d:"M20 16v.01"}),b("path",{d:"M20 20v.01"})]}),q),rv=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 3v18"}),b("path",{d:"M19 21v-18"}),b("path",{d:"M5 7h14"}),b("path",{d:"M5 15h14"}),b("path",{d:"M8 13v4"}),b("path",{d:"M11 13v4"}),b("path",{d:"M16 13v4"}),b("path",{d:"M14 5v4"}),b("path",{d:"M11 5v4"}),b("path",{d:"M8 5v4"}),b("path",{d:"M3 21h18"})]}),q),ov=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 12l18 0"}),b("path",{d:"M7 16l10 0l-10 5l0 -5"}),b("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),q),nv=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l0 18"}),b("path",{d:"M16 7l0 10l5 0l-5 -10"}),b("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),q),Of=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),b("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),q),Bp=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),b("path",{d:"M22 22l-3 -3"}),b("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),b("path",{d:"M3 11v-1"}),b("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),b("path",{d:"M10 3h1"}),b("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),q),iv=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("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"}),b("path",{d:"M10 15l2 6l2 -6"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),q),av=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),b("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),b("path",{d:"M11 21v-6l3 6v-6"})]}),q),sv=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M4 8l5 0"}),b("path",{d:"M15 8l4 0"})]}),q),lv=P(F("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),b("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),q),cv=P(F("g",{stroke:"currentColor",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...q,strokeWidth:1.5}),HG=P(F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M21 12h-13l3 -3"}),b("path",{d:"M11 15l-3 -3"})]}),q),dv=P(F("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M10 9l5 3l-5 3z"})]}),q),mv=P(F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 6h18"}),b("path",{d:"M3 12h18"}),b("path",{d:"M3 18h18"}),b("path",{d:"M6 3v18"}),b("path",{d:"M12 3v18"}),b("path",{d:"M18 3v18"})]}),q),pv=P(F("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),q),uv=P(F("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 9l6 6l6 -6"})]}),q),hv=P(F("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 15l6 -6l6 6"})]}),q);De();import{jsx as F6}from"react/jsx-runtime";var B6=(e,t)=>{let r=new Set(pe(e.filter(o=>re(o)),t).map(o=>o.id));return{elements:e.map(o=>t.selectedElementIds[o.id]?se(o,{isDeleted:!0}):o.frameId&&r.has(o.frameId)?se(o,{isDeleted:!0}):Me(o)&&t.selectedElementIds[o.containerId]?se(o,{isDeleted:!0}):o),appState:{...t,selectedElementIds:{},selectedGroupIds:{}}}},gv=(e,t)=>{if(e.editingGroupId){let r=Qe(Te(t),e.editingGroupId);if(r.length)return{...e,selectedElementIds:{[r[0].id]:!0}}}return e},Vc=H({name:"deleteSelectedElements",label:"labels.delete",icon:Qo,trackEvent:{category:"element",action:"delete"},perform:(e,t,r,o)=>{if(t.editingLinearElement){let{elementId:a,selectedPointsIndices:s,startBindingElement:l,endBindingElement:c}=t.editingLinearElement,d=o.scene.getNonDeletedElementsMap(),m=j.getElement(a,d);if(!m||s==null)return!1;if(m.points.length<2){let u=e.map(g=>g.id===m.id?se(g,{isDeleted:!0}):g),h=gv(t,u);return{elements:u,appState:{...h,editingLinearElement:null},storeAction:D.CAPTURE}}let p={startBindingElement:s?.includes(0)?null:l,endBindingElement:s?.includes(m.points.length-1)?null:c};return j.deletePoints(m,s),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...p,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},storeAction:D.CAPTURE}}let{elements:n,appState:i}=B6(e,t);return mm(n,e.filter(({id:a})=>t.selectedElementIds[a])),i=gv(i,n),{elements:n,appState:{...i,activeTool:et(t,{type:"selection"}),multiElement:null,activeEmbeddable:null},storeAction:Ke(Te(e),t)?D.CAPTURE:D.NONE}},keyTest:(e,t,r)=>(e.key===S.BACKSPACE||e.key===S.DELETE)&&!e[S.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:r})=>F6(de,{type:"button",icon:Qo,title:E("labels.delete"),"aria-label":E("labels.delete"),onClick:()=>r(null),visible:Ke(Te(e),t)})});f();f();le();ho();Gt();Xe();bi();G();var Bf=(e,t)=>e.frameId===t||e.id===t,bv=(e,t,r)=>{let o=[],n=[],i=null,a=-1,s=X(r||pe(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let l=e[a];s.get(l.id)?(n.length&&(o=o.concat(n),n=[]),o.push(a),i=a+1):l.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return o},z6=e=>{let t=0;return e.reduce((r,o,n)=>(n>0&&e[n-1]!==o-1&&(t=++t),(r[t]||(r[t]=[])).push(o),r),[])},fv=(e,t,r)=>{if("containerId"in e&&e.containerId)if(r==="left"){let o=Mt.getScene(e).getElement(e.containerId);if(o)return t.indexOf(o)}else return t.indexOf(e);else{let o=e.boundElements?.find(n=>n.type!=="arrow")?.id;if(o){if(r==="left")return t.indexOf(e);let n=Mt.getScene(e).getElement(o);if(n)return t.indexOf(n)}}},H6=(e,t)=>{let r=-1,o=-1;return e.forEach((n,i)=>{Bf(n,t)&&(r===-1&&(r=i),o=i)}),r===-1?[]:e.slice(r,o+1)},U6=(e,t,r,o,n)=>{let i=t[r],a=m=>m.isDeleted?!1:n?m.frameId===n:e.editingGroupId?m.groupIds.includes(e.editingGroupId):!0,s=o==="left"?Mh(t,m=>a(m),Math.max(0,r-1)):kh(t,m=>a(m),r+1),l=t[s];if(!l)return-1;if(e.editingGroupId){if(i?.groupIds.join("")===l?.groupIds.join(""))return fv(l,t,o)??s;if(!l?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(l.frameId||re(l))){let m=H6(t,l.frameId||l.id);return o==="left"?t.indexOf(m[0]):t.indexOf(m[m.length-1])}if(!l.groupIds.length)return fv(l,t,o)??s;let c=e.editingGroupId?l.groupIds[l.groupIds.indexOf(e.editingGroupId)-1]:l.groupIds[l.groupIds.length-1],d=Qe(t,c);return d.length?o==="left"?t.indexOf(d[0]):t.indexOf(d[d.length-1]):s},Ev=(e,t)=>t.reduce((r,o)=>{let n=e[o];return r.set(n.id,n),r},new Map),xv=(e,t,r)=>{let o=bv(e,t),n=Ev(e,o),i=z6(o);r==="right"&&(i=i.reverse());let a=new Set(o.filter(s=>re(e[s])).map(s=>e[s].id));return i.forEach((s,l)=>{let c=s[0],d=s[s.length-1],m=r==="left"?c:d,p=s.some(y=>{let w=e[y];return w.frameId&&a.has(w.frameId)})?null:e[m]?.frameId,u=U6(t,e,m,r,p);if(u===-1||m===u)return;let h=r==="left"?e.slice(0,u):e.slice(0,c),g=e.slice(c,d+1),x=r==="left"?e.slice(u,c):e.slice(d+1,u+1),v=r==="left"?e.slice(d+1):e.slice(u+1);e=r==="left"?[...h,...g,...x,...v]:[...h,...x,...g,...v]}),Ut(e,n),e},yv=(e,t,r,o,n)=>{let i=bv(e,t,n),a=Ev(e,i),s=[],l,c;if(r==="left"){if(o)l=kh(e,h=>Bf(h,o));else if(t.editingGroupId){let h=Qe(e,t.editingGroupId);if(!h.length)return e;l=e.indexOf(h[0])}else l=0;c=i[i.length-1]}else{if(o)c=Mh(e,h=>Bf(h,o));else if(t.editingGroupId){let h=Qe(e,t.editingGroupId);if(!h.length)return e;c=e.indexOf(h[h.length-1])}else c=e.length-1;l=i[0]}l===-1&&(l=0);for(let h=l;h<c+1;h++)i.includes(h)||s.push(e[h]);let d=Array.from(a.values()),m=e.slice(0,l),p=e.slice(c+1),u=r==="left"?[...m,...d,...s,...p]:[...m,...s,...d,...p];return Ut(u,a),u};function wv(e,t,r,o){let n=X(pe(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&re(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(re(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let d=i.frameChildren.get(c.frameId)||[];d.push(c),i.frameChildren.set(c.frameId,d)}let s=e,l=Array.from(i.frameChildren.entries());for(let[c,d]of l)s=o(e,t,r,c,d);return o(s,t,r,null,i.regularElements)}var vv=(e,t)=>xv(e,t,"left"),Tv=(e,t)=>xv(e,t,"right"),Sv=(e,t)=>wv(e,t,"left",yv),Iv=(e,t)=>wv(e,t,"right",yv);ge();G();Ve();Y();De();import{jsx as Fp}from"react/jsx-runtime";var Ff=H({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:vf,trackEvent:{category:"element"},perform:(e,t)=>({elements:vv(e,t),appState:t,storeAction:D.CAPTURE}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ye.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Fp("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${E("labels.sendBackward")} \u2014 ${R("CtrlOrCmd+[")}`,children:vf})}),zf=H({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:wf,trackEvent:{category:"element"},perform:(e,t)=>({elements:Tv(e,t),appState:t,storeAction:D.CAPTURE}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ye.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Fp("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${E("labels.bringForward")} \u2014 ${R("CtrlOrCmd+]")}`,children:wf})}),Hf=H({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Sf,trackEvent:{category:"element"},perform:(e,t)=>({elements:Sv(e,t),appState:t,storeAction:D.CAPTURE}),keyTest:e=>br?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.BRACKET_LEFT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===ye.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Fp("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${E("labels.sendToBack")} \u2014 ${br?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")}`,children:Sf})}),Uf=H({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Tf,trackEvent:{category:"element"},perform:(e,t)=>({elements:Iv(e,t),appState:t,storeAction:D.CAPTURE}),keyTest:e=>br?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.BRACKET_RIGHT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===ye.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Fp("button",{type:"button",className:"zIndexButton",onClick:r=>e(null),title:`${E("labels.bringToFront")} \u2014 ${br?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")}`,children:Tf})});f();ge();Ve();Gt();be();le();Jt();Ei();De();var Gf=H({name:"selectAll",label:"labels.selectAll",icon:tv,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,r,o)=>{if(t.editingLinearElement)return!1;let n=Ra(e.filter(i=>!i.isDeleted&&!(U(i)&&i.containerId)&&!i.locked)).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...t,...er({editingGroupId:null,selectedElementIds:n},Te(e),t,o),selectedLinearElement:Object.keys(n).length===1&&ie(e[0])?new j(e[0]):null},storeAction:D.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.A});f();ge();Ve();be();Xe();G();Jt();Gt();_r();Y();Je();le();f();G();var G6=e=>{let t=e.slice(),r=new Set,o=i=>{let a=i[0]?.groupIds?.join(""),s=[i[0]],l=[];for(let c of i.slice(1))c.groupIds?.join("")===a?s.push(c):l.push(c);return l.length?[...s,...o(l)]:s},n=new Map;return t.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let s=i.groupIds[i.groupIds.length-1],l=t.slice(a).filter(c=>{let d=c?.groupIds?.some(m=>m===s);return d&&n.set(c.id,!0),d});for(let c of o(l))r.add(c)}else r.add(i)}),r.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...r]},W6=e=>{let t=l1(e),r=e.slice(),o=new Set;return r.forEach((n,i)=>{n&&(n.boundElements?.length?(o.add(n),r[i]=null,n.boundElements.forEach(a=>{let s=t.get(a.id);s&&a.type==="text"&&(o.add(s[0]),r[s[1]]=null)})):n.type==="text"&&n.containerId&&t.get(n.containerId)?.[0].boundElements?.find(s=>s.id===n.id)||(o.add(n),r[i]=null))}),o.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...o]},Cv=e=>W6(G6(e));mr();Ei();ho();De();import{jsx as Y6}from"react/jsx-runtime";var Wf=H({name:"duplicateSelection",label:"labels.duplicateSelection",icon:zc,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getNonDeletedElementsMap();if(t.editingLinearElement){let i=j.duplicateSelectedPoints(t,n);return i?{elements:e,appState:i.appState,storeAction:D.CAPTURE}:!1}return{...V6(e,t),storeAction:D.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.D,PanelComponent:({elements:e,appState:t,updateData:r})=>Y6(de,{type:"button",icon:zc,title:`${E("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":E("labels.duplicateSelection"),onClick:()=>r(null),visible:Ke(Te(e),t)})}),V6=(e,t)=>{let r=Cv(e),o=new Map,n=[],i=[],a=new Map,s=new Map,l=y=>{let w=dc(t.editingGroupId,o,y,{x:y.x+On/2,y:y.y+On/2});return s.set(w.id,w),a.set(y.id,w.id),i.push(y),n.push(w),w},c=X(pe(r,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),d=new Map,m=y=>{for(let w of y)d.set(w.id,!0);return y},p=[],u=-1;for(;++u<r.length;){let y=r[u];if(d.get(y.id))continue;let w=ae(y,X(e)),I=re(y);if(c.get(y.id)){if(y.groupIds.length||w||I){let A=Eg(t,y);if(A){let C=Qe(r,A).flatMap(L=>re(L)?[...ro(e,L.id),L]:[L]);p.push(...m([...C,...C.map(L=>l(L))]));continue}if(w){p.push(...m([y,w,l(y),l(w)]));continue}if(I){let C=ro(r,y.id);p.push(...m([...C,y,...C.map(L=>l(L)),l(y)]));continue}}(!y.frameId||!c.has(y.frameId))&&p.push(...m([y,l(y)]))}else p.push(...m([y]))}let h=[],g=new Map;for(u=p.length;--u>=0;){let y=p[u];g.get(y.id)||(g.set(y.id,!0),h.push(y))}let x=Ut(h.reverse(),X(n));hm(p,i,a),dm(p,i,a),lp(x,i,a);let v=Ra(n);return{elements:x,appState:{...t,...er({editingGroupId:t.editingGroupId,selectedElementIds:v.reduce((y,w)=>(Me(w)||(y[w.id]=!0),y),{})},Te(x),t,null)}}};f();ir();f();var K6=["ai","command_palette"],ve=(e,t,r,o)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.PROD||!K6.includes(e))return;T.PROD||console.info("trackEvent",{category:e,action:t,label:r,value:o}),window.sa_event&&window.sa_event(t,{category:e,label:r,value:o})}catch(n){console.error("error during analytics",n)}};f();import Av from"clsx";import{jsx as Vf,jsxs as $6}from"react/jsx-runtime";var wn=e=>Vf("div",{className:"buttonList buttonListIcon",children:e.options.map(t=>e.type==="button"?Vf("button",{type:"button",onClick:r=>e.onClick(t.value,r),className:Av({active:t.active??e.value===t.value}),"data-testid":t.testId,title:t.text,children:t.icon},t.text):$6("label",{className:Av({active:e.value===t.value}),title:t.text,children:[Vf("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});f();G();f();ir();import X6 from"clsx";import{jsx as Yf}from"react/jsx-runtime";var kv=({onChange:e,type:t,activeColor:r,topPicks:o})=>{let n;return t==="elementStroke"&&(n=Ad),t==="elementBackground"&&(n=kd),t==="canvasBackground"&&(n=Md),o&&(n=o),n?Yf("div",{className:"color-picker__top-picks",children:n.map(i=>Yf("button",{className:X6("color-picker__button",{active:i===r,"is-transparent":i==="transparent"||!i}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Yf("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};f();import Bv,{useEffect as Fv,useState as f4}from"react";f();import J6 from"clsx";import{useAtom as Q6}from"jotai";import{useEffect as e4,useRef as t4}from"react";f();ir();import{atom as Z6}from"jotai";var Ni=({palette:e,color:t})=>{for(let[r,o]of Object.entries(e))if(Array.isArray(o)){let n=o.indexOf(t);if(n>-1)return{colorName:r,shade:n}}else if(o===t)return{colorName:r,shade:null};return null},Yc=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Kf=({color:e,palette:t})=>!Object.values(t).flat().includes(e),Lv=(e,t,r)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[t]];return Kf({color:s,palette:r})}),i=new Map;return n.forEach(a=>{let s=a[o[t]];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,xx)},wo=Z6(null),Mv=(e,t,r)=>(e*299+t*587+r*114)/1e3>=160?"black":"white",Pv=(e,t)=>{if(t){let i=new Option().style;if(i.color=e,i.color){let a=i.color.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(a[0]),l=parseInt(a[1]),c=parseInt(a[2]);return Mv(s,l,c)}}if(e==="transparent")return"black";let r=parseInt(e.substring(1,3),16),o=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return Mv(r,o,n)};f();import{jsxs as q6}from"react/jsx-runtime";var j6=({color:e,keyLabel:t,isCustomColor:r=!1,isShade:o=!1})=>q6("div",{className:"color-picker__button__hotkey-label",style:{color:Pv(e,r)},children:[o&&"\u21E7",t]}),rl=j6;import{jsx as Kc,jsxs as Dv}from"react/jsx-runtime";var _v=({hex:e,onChange:t,palette:r})=>{let o=Ni({color:e||"transparent",palette:r}),[n,i]=Q6(wo),a=t4(null);if(e4(()=>{a.current&&n==="shades"&&a.current.focus()},[o,n]),o){let{colorName:s,shade:l}=o,c=r[s];if(Array.isArray(c))return Kc("div",{className:"color-picker-content--default shades",children:c.map((d,m)=>Dv("button",{ref:m===l&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:J6("color-picker__button color-picker__button--large",{active:m===l}),"aria-label":"Shade",title:`${s} - ${m+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{t(d),i("shades")},children:[Kc("div",{className:"color-picker__button-outline"}),Kc(rl,{color:d,keyLabel:m+1,isShade:!0})]},m))})}return Dv("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Kc("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Kc("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:E("colorPicker.noShades")})]})};f();import r4 from"clsx";import{useAtom as o4}from"jotai";import{useEffect as n4,useRef as i4}from"react";import{jsx as $f,jsxs as s4}from"react/jsx-runtime";var a4=({palette:e,color:t,onChange:r,label:o,activeShade:n})=>{let i=Ni({color:t||"transparent",palette:e}),[a,s]=o4(wo),l=i4(null);return n4(()=>{l.current&&a==="baseColors"&&l.current.focus()},[i?.colorName,a]),$f("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,d],m)=>{let p=(Array.isArray(d)?d[n]:d)||"transparent",u=Yc[m],h=E(`colors.${c.replace(/\d+/,"")}`,null,"");return s4("button",{ref:i?.colorName===c?l:void 0,tabIndex:-1,type:"button",className:r4("color-picker__button color-picker__button--large",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{r(p),s("baseColors")},title:`${h}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${h} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[$f("div",{className:"color-picker__button-outline"}),$f(rl,{color:p,keyLabel:u})]},c)})})},Rv=a4;import{useAtom as b4}from"jotai";f();import l4 from"clsx";import{useAtom as c4}from"jotai";import{useEffect as d4,useRef as m4}from"react";import{jsx as Xf,jsxs as p4}from"react/jsx-runtime";var Nv=({colors:e,color:t,onChange:r,label:o})=>{let[n,i]=c4(wo),a=m4(null);return d4(()=>{a.current&&a.current.focus()},[t,n]),Xf("div",{className:"color-picker-content--default",children:e.map((s,l)=>p4("button",{ref:t===s?a:void 0,tabIndex:-1,type:"button",className:l4("color-picker__button color-picker__button--large",{active:t===s,"is-transparent":s==="transparent"||!s}),onClick:()=>{r(s),i("custom")},title:s,"aria-label":o,style:{"--swatch-color":s},children:[Xf("div",{className:"color-picker__button-outline"}),Xf(rl,{color:s,keyLabel:l+1,isCustomColor:!0})]},l))})};f();ge();ir();var Zf=(e,t,r)=>{let o=Math.ceil(r/ta);switch(t=t??-1,e){case"ArrowLeft":{let n=t-1;return n<0?r-1:n}case"ArrowRight":return(t+1)%r;case"ArrowDown":{let n=t+ta;return n>=r?t%ta:n}case"ArrowUp":{let n=t-ta,i=n<0?ta*o+n:n;return i>=r?void 0:i}}},u4=({e,colorObj:t,onChange:r,palette:o,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let s=Number(e.code.slice(-1))-1;return r(o[t.colorName][s]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return r(n[Number(e.key)-1]),i("custom"),!0;if(Yc.includes(e.key)){let s=Yc.indexOf(e.key),l=Object.keys(o)[s],c=o[l],d=Array.isArray(c)?c[a]:c;return r(d),i("baseColors"),!0}return!1},Ov=({event:e,activeColorPickerSection:t,palette:r,color:o,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d})=>{if(e[S.CTRL_OR_CMD])return!1;if(e.key===S.ESCAPE)return d(e),!0;if(e.key===S.ALT)return c(!0),!0;if(e.key===S.I)return c(),!0;let m=Ni({color:o,palette:r});if(e.key===S.TAB){let p={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},u=Object.entries(p).reduce((y,[w,I])=>(I&&y.push(w),y),[]),h=u.indexOf(t),g=e.shiftKey?-1:1,x=h+g>u.length-1?0:h+g<0?u.length-1:h+g,v=u[x];return v&&a(v),v==="custom"?n(i[0]):v==="baseColors"&&(Object.entries(r).find(([w,I])=>Array.isArray(I)?I.includes(o):I===o?w:null)||n(ue.black)),e.preventDefault(),e.stopPropagation(),!0}if(u4({e,colorObj:m,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:l}))return!0;if(t==="shades"&&m){let{shade:p}=m,u=Zf(e.key,p,ta);if(u!==void 0)return n(r[m.colorName][u]),!0}if(t==="baseColors"&&m){let{colorName:p}=m,u=Object.keys(r),h=u.indexOf(p),g=Zf(e.key,h,u.length);if(g!==void 0){let x=u[g],v=r[x];return n(Array.isArray(v)?v[l]:v),!0}}if(t==="custom"){let p=i.indexOf(o),u=Zf(e.key,p,i.length);if(u!==void 0){let h=i[u];return n(h),!0}}return!1};f();import{jsx as g4}from"react/jsx-runtime";var h4=({children:e})=>g4("div",{className:"color-picker__heading",children:e}),ol=h4;ir();ge();Y();import{jsx as Fa,jsxs as zp}from"react/jsx-runtime";var zv=({color:e,onChange:t,label:r,type:o,elements:n,palette:i,updateData:a,children:s,onEyeDropperToggle:l,onEscape:c})=>{let[d]=Bv.useState(()=>o==="canvasBackground"?[]:Lv(n,o,i)),[m,p]=b4(wo),u=Ni({color:e,palette:i});Fv(()=>{if(!m){let v=Kf({color:e,palette:i}),y=v&&!d.includes(e);p(y?"hex":v?"custom":u?.shade!=null?"shades":"baseColors")}},[m,e,i,p,u,d]);let[h,g]=f4(u?.shade??(o==="elementBackground"?rs:ts));Fv(()=>{u?.shade!=null&&g(u.shade);let v=y=>{y.key===S.ALT&&l(!1)};return document.addEventListener("keyup",v,{capture:!0}),()=>{document.removeEventListener("keyup",v,{capture:!0})}},[u,l]);let x=Bv.useRef(null);return Fa("div",{role:"dialog","aria-modal":"true","aria-label":E("labels.colorPicker"),children:zp("div",{ref:x,onKeyDown:v=>{Ov({event:v,activeColorPickerSection:m,palette:i,color:e,onChange:t,onEyeDropperToggle:l,customColors:d,setActiveColorPickerSection:p,updateData:a,activeShade:h,onEscape:c})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content",tabIndex:-1,children:[!!d.length&&zp("div",{children:[Fa(ol,{children:E("colorPicker.mostUsedCustomColors")}),Fa(Nv,{colors:d,color:e,label:E("colorPicker.mostUsedCustomColors"),onChange:t})]}),zp("div",{children:[Fa(ol,{children:E("colorPicker.colors")}),Fa(Rv,{color:e,label:r,palette:i,onChange:t,activeShade:h})]}),zp("div",{children:[Fa(ol,{children:E("colorPicker.shades")}),Fa(_v,{hex:e,onChange:t,palette:i})]}),s]})})};import*as vn from"@radix-ui/react-popover";import{useAtom as Xv}from"jotai";ir();import L4 from"clsx";f();import{useCallback as C4,useEffect as qf,useRef as Wv,useState as A4}from"react";import{useAtom as Vv}from"jotai";ge();f();ir();Y();import{atom as w4}from"jotai";import{useEffect as v4,useRef as T4}from"react";import{createPortal as S4}from"react-dom";f();import Hv from"react";var jf=Hv.createContext(null),Be=()=>Hv.useContext(jf);f();import{useState as E4,useLayoutEffect as Uv}from"react";Y();var Hp=e=>{let[t,r]=E4(null),o=_e(),{theme:n}=Be(),{container:i}=Yt();return Uv(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",o.editor.isMobile),t.classList.toggle("theme--dark",n===ce.DARK))},[t,n,o.editor.isMobile,e?.className]),Uv(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),r(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),t};f();Y();import{useEffect as x4}from"react";function nl(e,t,r){x4(()=>{function o(n){let i=n;if(!e.current)return;let a=r?.(i,e.current);if(a===!0)return;if(a===!1)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||t(i)}return document.addEventListener("pointerdown",o),document.addEventListener("touchstart",o),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("touchstart",o)}},[e,t,r])}ge();Xe();f();import{useRef as y4}from"react";var il=e=>{let t=y4(e);return Object.assign(t.current,e),t.current};import{jsx as I4}from"react/jsx-runtime";var Oi=w4(null),Gv=({onCancel:e,onChange:t,onSelect:r,colorPickerType:o})=>{let n=Hp({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Be(),a=Bi(),s=pr(),l=pe(a,i),c=il({app:s,onCancel:e,onChange:t,onSelect:r,selectedElements:l}),{container:d}=Yt();v4(()=>{let p=m.current;if(!p||!s.canvas||!n)return;let u=!1,h=s.canvas.getContext("2d"),g=({clientX:C,clientY:L})=>{let M=h.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(L-i.offsetTop)*window.devicePixelRatio,1,1).data;return Ix(M[0],M[1],M[2])},x=({clientX:C,clientY:L,altKey:M})=>{p.style.top=`${L+20}px`,p.style.left=`${C+20}px`;let z=g({clientX:C,clientY:L});u&&c.onChange(o,z,c.selectedElements,{altKey:M}),p.style.background=z},v=()=>{c.onCancel()},y=(C,L)=>{c.onSelect(C,L)},w=C=>{u=!0,C.stopImmediatePropagation()},I=C=>{u=!1,d?.focus(),C.stopImmediatePropagation(),C.preventDefault(),y(g(C),C)},A=C=>{C.key===S.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),v())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",A),n.addEventListener("pointerdown",w),n.addEventListener("pointerup",I),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",v),()=>{u=!1,n.removeEventListener("keydown",A),n.removeEventListener("pointerdown",w),n.removeEventListener("pointerup",I),window.removeEventListener("pointermove",x),window.removeEventListener("blur",v)}},[c,s.canvas,n,o,d,i.offsetLeft,i.offsetTop]);let m=T4(null);return nl(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?S4(I4("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),n):null};import k4 from"clsx";G();import{Fragment as M4,jsx as Up,jsxs as Yv}from"react/jsx-runtime";var Kv=({color:e,onChange:t,label:r,colorPickerType:o})=>{let n=_e(),[i,a]=A4(e),[s,l]=Vv(wo);qf(()=>{a(e)},[e]);let c=C4(h=>{let g=h.toLowerCase(),x=$v(g);x&&t(x),a(g)},[t]),d=Wv(null),m=Wv(null);qf(()=>{d.current&&d.current.focus()},[s]);let[p,u]=Vv(Oi,Ge);return qf(()=>()=>{u(null)},[u]),Yv("div",{className:"color-picker__input-label",children:[Up("div",{className:"color-picker__input-hash",children:"#"}),Up("input",{ref:s==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":r,onChange:h=>{c(h.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>l("hex"),onKeyDown:h=>{h.key!==S.TAB&&(h.key===S.ESCAPE&&m.current?.focus(),h.stopPropagation())}}),!n.editor.isMobile&&Yv(M4,{children:[Up("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Up("div",{ref:m,className:k4("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(h=>h?null:{keepOpenOnAlt:!1,onSelect:g=>t(g),colorPickerType:o}),title:`${E("labels.eyeDropper")} \u2014 ${S.I.toLocaleUpperCase()} or ${R("Alt")} `,children:K2})]})]})};import{useRef as P4}from"react";import{jsx as vo,jsxs as Gp}from"react/jsx-runtime";var Zv=e=>{let t=new Option().style;return t.color=e,!!t.color},$v=e=>Er(e)?e:Zv(`#${e}`)?`#${e}`:Zv(e)?e:null,D4=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=ue,updateData:a})=>{let[,s]=Xv(wo),[l,c]=Xv(Oi,Ge),{container:d}=Yt(),m=_e(),p=Gp("div",{children:[vo(ol,{children:E("colorPicker.hexCode")}),vo(Kv,{color:t,label:o,onChange:g=>{r(g)},colorPickerType:e})]}),u=P4(null),h=()=>{u.current?.querySelector(".color-picker-content")?.focus()};return vo(vn.Portal,{container:d,children:Gp(vn.Content,{ref:u,className:"focus-visible-none","data-prevent-outside-click":!0,onFocusOutside:g=>{h(),g.preventDefault()},onPointerDownOutside:g=>{l&&g.preventDefault()},onCloseAutoFocus:g=>{g.stopPropagation(),g.preventDefault(),d&&!t1(document.activeElement)&&d.focus(),a({openPopup:null}),s(null)},side:m.editor.isMobile&&!m.viewport.isLandscape?"bottom":"right",align:m.editor.isMobile&&!m.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-layerUI)",backgroundColor:"var(--popup-bg-color)",maxWidth:"208px",maxHeight:window.innerHeight,padding:"12px",borderRadius:"8px",boxSizing:"border-box",overflowY:"auto",boxShadow:"0px 7px 14px rgba(0, 0, 0, 0.05), 0px 0px 3.12708px rgba(0, 0, 0, 0.0798), 0px 0px 0.931014px rgba(0, 0, 0, 0.1702)"},children:[i?vo(zv,{palette:i,color:t,onChange:g=>{r(g)},onEyeDropperToggle:g=>{c(x=>g?(x=x||{keepOpenOnAlt:!0,onSelect:r,colorPickerType:e},x.keepOpenOnAlt=!0,x):g===!1||x?null:{keepOpenOnAlt:!1,onSelect:r,colorPickerType:e})},onEscape:g=>{l?c(null):co(g.target)?h():a({openPopup:null})},label:o,type:e,elements:n,updateData:a,children:p}):p,vo(vn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})},_4=({label:e,color:t,type:r})=>vo(vn.Trigger,{type:"button",className:L4("color-picker__button active-color",{"is-transparent":t==="transparent"||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:r==="elementStroke"?E("labels.showStroke"):E("labels.showBackground"),children:vo("div",{className:"color-picker__button-outline"})}),$c=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=ue,topPicks:a,updateData:s,appState:l})=>vo("div",{children:Gp("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[vo(kv,{activeColor:t,onChange:r,type:e,topPicks:a}),vo("div",{style:{width:1,height:"100%",backgroundColor:"var(--default-border-color)",margin:"0 auto"}}),Gp(vn.Root,{open:l.openPopup===e,onOpenChange:c=>{s({openPopup:c?e:null})},children:[vo(_4,{color:t,label:o,type:e}),l.openPopup===e&&vo(D4,{type:e,color:t,onChange:r,label:o,elements:n,palette:i,updateData:s})]})]})});f();import za from"react";f();import{useLayoutEffect as R4,useRef as jv,useEffect as qv}from"react";G();ge();import{unstable_batchedUpdates as N4}from"react-dom";import{jsx as O4}from"react/jsx-runtime";var Wp=({children:e,left:t,top:r,onCloseRequest:o,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:s=window.innerWidth,viewportHeight:l=window.innerHeight})=>{let c=jv(null);qv(()=>{let m=c.current;if(!m)return;m.contains(document.activeElement)||m.focus();let p=u=>{if(u.key===S.TAB){let h=Gl(m),{activeElement:g}=document,x=h.findIndex(v=>v===g);g===m?(u.shiftKey?h[h.length-1]?.focus():h[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(h[h.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===h.length-1&&!u.shiftKey&&(h[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return m.addEventListener("keydown",p),()=>m.removeEventListener("keydown",p)},[]);let d=jv(null);return R4(()=>{if(n&&c.current&&r!=null&&t!=null){let m=c.current,{width:p,height:u}=m.getBoundingClientRect();if(d.current?.top===r&&d.current?.left===t)return;d.current={top:r,left:t},p>=s?(m.style.width=`${s}px`,m.style.left="0px",m.style.overflowX="scroll"):t+p-i>s?m.style.left=`${s-p-10}px`:m.style.left=`${t}px`,u>=l?(m.style.height=`${l-20}px`,m.style.top="10px",m.style.overflowY="scroll"):r+u-a>l?m.style.top=`${l-u}px`:m.style.top=`${r}px`}},[r,t,n,s,l,i,a]),qv(()=>{if(o){let m=p=>{c.current?.contains(p.target)||N4(()=>o(p))};return document.addEventListener("pointerdown",m,!1),()=>document.removeEventListener("pointerdown",m,!1)}},[o]),O4("div",{className:"popover",ref:c,tabIndex:-1,children:e})};ge();import B4 from"clsx";import{Fragment as z4,jsx as Fi,jsxs as Jf}from"react/jsx-runtime";function F4({options:e,value:t,label:r,onChange:o,onClose:n}){let i=za.useRef(),a=za.useRef(),s=za.useRef(null);return za.useEffect(()=>{a.current?a.current.focus():s.current&&s.current.focus()},[]),Fi("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":r,onKeyDown:c=>{let d=e.find(m=>m.keyBinding===c.key.toLowerCase());if(!(c.metaKey||c.altKey||c.ctrlKey)&&d){let m=e.indexOf(d);s.current.children[m].focus(),c.preventDefault()}else if(c.key===S.TAB)setTimeout(()=>{let m=a.current,p=document.activeElement;m!==p&&n()},0);else if(vs(c.key)){let{activeElement:m}=document,p=Dn().rtl,u=Array.prototype.indexOf.call(s.current.children,m);if(u!==-1){let h=e.length,g=u;switch(c.key){case(p?S.ARROW_LEFT:S.ARROW_RIGHT):case S.ARROW_DOWN:{g=(u+1)%h;break}case(p?S.ARROW_RIGHT:S.ARROW_LEFT):case S.ARROW_UP:{g=(h+u-1)%h;break}}s.current.children[g].focus()}c.preventDefault()}else(c.key===S.ESCAPE||c.key===S.ENTER)&&(c.preventDefault(),n());c.nativeEvent.stopImmediatePropagation(),c.stopPropagation()},children:Fi("div",{className:"picker-content",ref:s,children:e.map((c,d)=>Jf("button",{type:"button",className:B4("picker-option",{active:t===c.value}),onClick:m=>{m.currentTarget.focus(),o(c.value)},title:`${c.text} ${c.keyBinding&&`\u2014 ${c.keyBinding.toUpperCase()}`}`,"aria-label":c.text||"none","aria-keyshortcuts":c.keyBinding||void 0,ref:m=>{m&&d===0&&(i.current=m),m&&c.value===t&&(a.current=m)},onFocus:()=>{o(c.value)},children:[c.icon,c.keyBinding&&Fi("span",{className:"picker-keybinding",children:c.keyBinding})]},c.text))})})}function Qf({value:e,label:t,options:r,onChange:o,group:n=""}){let[i,a]=za.useState(!1),s=za.useRef(null),l=Dn().rtl;return Jf("div",{children:[Fi("button",{name:n,type:"button",className:i?"active":"","aria-label":t,onClick:()=>a(!i),ref:s,children:r.find(c=>c.value===e)?.icon}),Fi(za.Suspense,{fallback:"",children:i?Jf(z4,{children:[Fi(Wp,{onCloseRequest:c=>c.target!==s.current&&a(!1),...l?{right:5.5}:{left:-5.5},children:Fi(F4,{options:r.filter(c=>c.showInPicker!==!1),value:e,label:t,onChange:o,onClose:()=>{a(!1),s.current?.focus()}})}),Fi("div",{className:"picker-triangle"})]}):null})]})}Y();be();Ae();Je();le();ge();zo();Xe();Jl();G();Ve();De();import{Fragment as eT,jsx as ke,jsxs as oo}from"react/jsx-runtime";var Qv=.1,no=(e,t,r,o=!1)=>{let n=X(pe(e,t,{includeBoundTextElement:o}));return e.map(i=>n.get(i.id)||i.id===t.editingElement?.id?r(i):i)},zr=function(e,t,r,o,n){let i=t.editingElement,a=Te(e),s=null;return i&&(s=r(i)),s||(Ke(a,t)?s=pf(o===!0?a:a.filter(c=>o(c)),t,r)??(typeof n=="function"?n(!0):n):s=typeof n=="function"?n(!1):n),s},H4=(e,t)=>Me(t)||!t.autoResize?t:O(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2},!1),eb=(e,t,r,o,n)=>{let i=new Set;return{elements:no(e,t,a=>{if(U(a)){let s=o(a);i.add(s);let l=se(a,{fontSize:s});return Ot(l,r.scene.getContainerElement(a),r.scene.getNonDeletedElementsMap()),l=H4(a,l),l}return a},!0),appState:{...t,currentItemFontSize:i.size===1?[...i][0]:n??t.currentItemFontSize},storeAction:D.CAPTURE}},U4=H({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemStrokeColor&&{elements:no(e,t,o=>ql(o.type)?se(o,{strokeColor:r.currentItemStrokeColor}):o,!0)},appState:{...t,...r},storeAction:r.currentItemStrokeColor?D.CAPTURE:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>oo(eT,{children:[ke("h3",{"aria-hidden":"true",children:E("labels.stroke")}),ke($c,{topPicks:Ad,palette:vx,type:"elementStroke",label:E("labels.stroke"),color:zr(e,t,n=>n.strokeColor,!0,t.currentItemStrokeColor),onChange:n=>r({currentItemStrokeColor:n}),elements:e,appState:t,updateData:r})]})}),G4=H({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemBackgroundColor&&{elements:no(e,t,o=>se(o,{backgroundColor:r.currentItemBackgroundColor}))},appState:{...t,...r},storeAction:r.currentItemBackgroundColor?D.CAPTURE:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>oo(eT,{children:[ke("h3",{"aria-hidden":"true",children:E("labels.background")}),ke($c,{topPicks:kd,palette:Tx,type:"elementBackground",label:E("labels.background"),color:zr(e,t,n=>n.backgroundColor,!0,t.currentItemBackgroundColor),onChange:n=>r({currentItemBackgroundColor:n}),elements:e,appState:t,updateData:r})]})}),W4=H({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,r,o)=>(ve("element","changeFillStyle",`${r} (${o.device.editor.isMobile?"mobile":"desktop"})`),{elements:no(e,t,n=>se(n,{fillStyle:r})),appState:{...t,currentItemFillStyle:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=pe(e,t),n=o.length>0&&o.every(i=>i.fillStyle==="zigzag");return oo("fieldset",{children:[ke("legend",{children:E("labels.fill")}),ke(wn,{type:"button",options:[{value:"hachure",text:`${n?E("labels.zigzag"):E("labels.hachure")} (${R("Alt-Click")})`,icon:n?c2:d2,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:E("labels.crossHatch"),icon:m2,testId:"fill-cross-hatch"},{value:"solid",text:E("labels.solid"),icon:p2,testId:"fill-solid"}],value:zr(e,t,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:t.currentItemFillStyle),onClick:(i,a)=>{let s=a.altKey&&i==="hachure"&&o.every(l=>l.fillStyle==="hachure")?"zigzag":i;r(s)}})]})}}),V4=H({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,r)=>({elements:no(e,t,o=>se(o,{strokeWidth:r})),appState:{...t,currentItemStrokeWidth:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>oo("fieldset",{children:[ke("legend",{children:E("labels.strokeWidth")}),ke(wn,{group:"stroke-width",options:[{value:zd.thin,text:E("labels.thin"),icon:_f,testId:"strokeWidth-thin"},{value:zd.bold,text:E("labels.bold"),icon:u2,testId:"strokeWidth-bold"},{value:zd.extraBold,text:E("labels.extraBold"),icon:h2,testId:"strokeWidth-extraBold"}],value:zr(e,t,o=>o.strokeWidth,o=>o.hasOwnProperty("strokeWidth"),o=>o?null:t.currentItemStrokeWidth),onChange:o=>r(o)})]})}),Y4=H({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,r)=>({elements:no(e,t,o=>se(o,{seed:uo(),roughness:r})),appState:{...t,currentItemRoughness:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>oo("fieldset",{children:[ke("legend",{children:E("labels.sloppiness")}),ke(wn,{group:"sloppiness",options:[{value:0,text:E("labels.architect"),icon:b2},{value:1,text:E("labels.artist"),icon:E2},{value:2,text:E("labels.cartoonist"),icon:x2}],value:zr(e,t,o=>o.roughness,o=>o.hasOwnProperty("roughness"),o=>o?null:t.currentItemRoughness),onChange:o=>r(o)})]})}),S$=H({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,r)=>({elements:no(e,t,o=>se(o,{strokeStyle:r})),appState:{...t,currentItemStrokeStyle:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>oo("fieldset",{children:[ke("legend",{children:E("labels.strokeStyle")}),ke(wn,{group:"strokeStyle",options:[{value:"solid",text:E("labels.strokeStyle_solid"),icon:_f},{value:"dashed",text:E("labels.strokeStyle_dashed"),icon:g2},{value:"dotted",text:E("labels.strokeStyle_dotted"),icon:f2}],value:zr(e,t,o=>o.strokeStyle,o=>o.hasOwnProperty("strokeStyle"),o=>o?null:t.currentItemStrokeStyle),onChange:o=>r(o)})]})}),K4=H({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,r)=>({elements:no(e,t,o=>se(o,{opacity:r}),!0),appState:{...t,currentItemOpacity:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>oo("label",{className:"control-label",children:[E("labels.opacity"),ke("input",{type:"range",min:"0",max:"100",step:"10",onChange:o=>r(+o.target.value),value:zr(e,t,o=>o.opacity,!0,t.currentItemOpacity)??void 0})]})}),$4=H({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,r,o)=>eb(e,t,o,()=>r,r),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>oo("fieldset",{children:[ke("legend",{children:E("labels.fontSize")}),ke(wn,{group:"font-size",options:[{value:16,text:E("labels.small"),icon:L2,testId:"fontSize-small"},{value:20,text:E("labels.medium"),icon:P2,testId:"fontSize-medium"},{value:28,text:E("labels.large"),icon:D2,testId:"fontSize-large"},{value:36,text:E("labels.veryLarge"),icon:_2,testId:"fontSize-veryLarge"}],value:zr(e,t,n=>{if(U(n))return n.fontSize;let i=ae(n,o.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>U(n)||ae(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:t.currentItemFontSize||Tt),onChange:n=>r(n)})]})}),tb=H({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Ba,trackEvent:!1,perform:(e,t,r,o)=>eb(e,t,o,n=>Math.round(1/(1+Qv)*n.fontSize)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_LEFT||e.key===S.COMMA)}),rb=H({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Ba,trackEvent:!1,perform:(e,t,r,o)=>eb(e,t,o,n=>Math.round(n.fontSize*(1+Qv))),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_RIGHT||e.key===S.PERIOD)}),X4=H({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,r,o)=>({elements:no(e,t,n=>{if(U(n)){let i=se(n,{fontFamily:r,lineHeight:qr(r)});return Ot(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemFontFamily:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=[{value:mt.Virgil,text:E("labels.handDrawn"),icon:js,testId:"font-family-virgil"},{value:mt.Helvetica,text:E("labels.normal"),icon:R2,testId:"font-family-normal"},{value:mt.Cascadia,text:E("labels.code"),icon:N2,testId:"font-family-code"}];return oo("fieldset",{children:[ke("legend",{children:E("labels.fontFamily")}),ke(wn,{group:"font-family",options:n,value:zr(e,t,i=>{if(U(i))return i.fontFamily;let a=ae(i,o.scene.getNonDeletedElementsMap());return a?a.fontFamily:null},i=>U(i)||ae(i,o.scene.getNonDeletedElementsMap())!==null,i=>i?null:t.currentItemFontFamily||Zt),onChange:i=>r(i)})]})}}),Z4=H({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,r,o)=>({elements:no(e,t,n=>{if(U(n)){let i=se(n,{textAlign:r});return Ot(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemTextAlign:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=o.scene.getNonDeletedElementsMap();return oo("fieldset",{children:[ke("legend",{children:E("labels.textAlign")}),ke(wn,{group:"text-align",options:[{value:"left",text:E("labels.left"),icon:O2,testId:"align-left"},{value:"center",text:E("labels.center"),icon:B2,testId:"align-horizontal-center"},{value:"right",text:E("labels.right"),icon:F2,testId:"align-right"}],value:zr(e,t,i=>{if(U(i))return i.textAlign;let a=ae(i,n);return a?a.textAlign:null},i=>U(i)||ae(i,n)!==null,i=>i?null:t.currentItemTextAlign),onChange:i=>r(i)})]})}}),j4=H({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:no(e,t,n=>{if(U(n)){let i=se(n,{verticalAlign:r});return Ot(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>ke("fieldset",{children:ke(wn,{group:"text-align",options:[{value:St.TOP,text:E("labels.alignTop"),icon:ke(z2,{theme:t.theme}),testId:"align-top"},{value:St.MIDDLE,text:E("labels.centerVertically"),icon:ke(U2,{theme:t.theme}),testId:"align-middle"},{value:St.BOTTOM,text:E("labels.alignBottom"),icon:ke(H2,{theme:t.theme}),testId:"align-bottom"}],value:zr(e,t,n=>{if(U(n)&&n.containerId)return n.verticalAlign;let i=ae(n,o.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>U(n)||ae(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:St.MIDDLE),onChange:n=>r(n)})})}),I$=H({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,r)=>({elements:no(e,t,o=>se(o,{roundness:r==="round"?{type:dn(o.type)?lt.ADAPTIVE_RADIUS:lt.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let n=Oc(Te(e),t).some(i=>i.roundness?.type===lt.LEGACY);return oo("fieldset",{children:[ke("legend",{children:E("labels.edges")}),ke(wn,{group:"edges",options:[{value:"sharp",text:E("labels.sharp"),icon:y2},{value:"round",text:E("labels.round"),icon:w2}],value:zr(e,t,i=>n?null:i.roundness?"round":"sharp",i=>i.hasOwnProperty("roundness"),i=>i?null:t.currentItemRoundness),onChange:i=>r(i)})]})}}),Jv=e=>[{value:null,text:E("labels.arrowhead_none"),keyBinding:"q",icon:v2},{value:"arrow",text:E("labels.arrowhead_arrow"),keyBinding:"w",icon:ke(T2,{flip:e})},{value:"bar",text:E("labels.arrowhead_bar"),keyBinding:"e",icon:ke(I2,{flip:e})},{value:"dot",text:E("labels.arrowhead_circle"),keyBinding:null,icon:ke(Rf,{flip:e}),showInPicker:!1},{value:"circle",text:E("labels.arrowhead_circle"),keyBinding:"r",icon:ke(Rf,{flip:e}),showInPicker:!1},{value:"circle_outline",text:E("labels.arrowhead_circle_outline"),keyBinding:null,icon:ke(S2,{flip:e}),showInPicker:!1},{value:"triangle",text:E("labels.arrowhead_triangle"),icon:ke(C2,{flip:e}),keyBinding:"t"},{value:"triangle_outline",text:E("labels.arrowhead_triangle_outline"),icon:ke(A2,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond",text:E("labels.arrowhead_diamond"),icon:ke(k2,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond_outline",text:E("labels.arrowhead_diamond_outline"),icon:ke(M2,{flip:e}),keyBinding:null,showInPicker:!1}],C$=H({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,r)=>({elements:no(e,t,o=>{if(ie(o)){let{position:n,type:i}=r;if(n==="start")return se(o,{startArrowhead:i});if(n==="end")return se(o,{endArrowhead:i})}return o}),appState:{...t,[r.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:r.type},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=Dn().rtl;return oo("fieldset",{children:[ke("legend",{children:E("labels.arrowheads")}),oo("div",{className:"iconSelectList buttonList",children:[ke(Qf,{label:"arrowhead_start",options:Jv(!o),value:zr(e,t,n=>ie(n)&&ca(n.type)?n.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:n=>r({position:"start",type:n})}),ke(Qf,{label:"arrowhead_end",group:"arrowheads",options:Jv(!!o),value:zr(e,t,n=>ie(n)&&ca(n.type)?n.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:n=>r({position:"end",type:n})})]})]})}});f();Y();be();ge();Xe();hf();vp();G();Ve();f();import{useEffect as q4}from"react";import{jsx as Q4}from"react/jsx-runtime";var al=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},ob=(e,t,r="bottom")=>{let o=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,s=t.left+t.width/2-o.width/2;s<0?s=a:s+o.width>=n&&(s=n-o.width-a);let l;r==="bottom"?(l=t.top+t.height+a,l+o.height>=i&&(l=t.top-o.height-a)):(l=t.top-o.height-a,l<0&&(l=t.top+t.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},J4=(e,t,r,o)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=o?"50ch":"10ch",t.style.maxWidth=o?"50ch":"15ch",t.textContent=r;let n=e.getBoundingClientRect();ob(t,n)},io=({children:e,label:t,long:r=!1,style:o,disabled:n})=>(q4(()=>()=>al().classList.remove("excalidraw-tooltip--visible"),[]),n?null:Q4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>J4(i.currentTarget,al(),t,r),onPointerLeave:()=>al().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));Ae();Or();ir();Ls();De();import{jsx as Kp,jsxs as nk}from"react/jsx-runtime";var ek=H({name:"changeViewBackgroundColor",label:"labels.canvasBackground",paletteName:"Change canvas background color",trackEvent:!1,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,r)=>({appState:{...t,...r},storeAction:r.viewBackgroundColor?D.CAPTURE:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>Kp($c,{palette:null,topPicks:Md,label:E("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:n=>r({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:r})}),ti=H({name:"clearCanvas",label:"labels.clearCanvas",paletteName:"Clear canvas",icon:Qo,trackEvent:{category:"canvas"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled,perform:(e,t,r,o)=>(o.imageCache.clear(),{elements:e.map(n=>se(n,{isDeleted:!0})),appState:{...Qt(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,stats:t.stats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:"selection"}:t.activeTool},storeAction:D.CAPTURE})}),Vp=H({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:ff,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...ei({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:yn(t.zoom.value+na)},t),userToFollow:null},storeAction:D.NONE}),PanelComponent:({updateData:e,appState:t})=>Kp(de,{type:"button",className:"zoom-in-button zoom-button",icon:ff,title:`${E("buttons.zoomIn")} \u2014 ${R("CtrlOrCmd++")}`,"aria-label":E("buttons.zoomIn"),disabled:t.zoom.value>=wh,onClick:()=>{e(null)}}),keyTest:e=>(e.code===ye.EQUAL||e.code===ye.NUM_ADD)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),Yp=H({name:"zoomOut",label:"buttons.zoomOut",icon:bf,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...ei({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:yn(t.zoom.value-na)},t),userToFollow:null},storeAction:D.NONE}),PanelComponent:({updateData:e,appState:t})=>Kp(de,{type:"button",className:"zoom-out-button zoom-button",icon:bf,title:`${E("buttons.zoomOut")} \u2014 ${R("CtrlOrCmd+-")}`,"aria-label":E("buttons.zoomOut"),disabled:t.zoom.value<=ns,onClick:()=>{e(null)}}),keyTest:e=>(e.code===ye.MINUS||e.code===ye.NUM_SUBTRACT)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),tk=H({name:"resetZoom",label:"buttons.resetZoom",icon:Kw,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...ei({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:yn(1)},t),userToFollow:null},storeAction:D.NONE}),PanelComponent:({updateData:e,appState:t})=>Kp(io,{label:E("buttons.resetZoom"),style:{height:"100%"},children:nk(de,{type:"button",className:"reset-zoom-button zoom-button",title:E("buttons.resetZoom"),"aria-label":E("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===ye.ZERO||e.code===ye.NUM_ZERO)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),rk=(e,t)=>{let[r,o,n,i]=e,a=n-r,s=t.width/a,l=i-o,c=t.height/l,d=Math.min(s,c),m=Math.floor(d/na)*na;return Math.min(Math.max(m,ns),1)},tT=({bounds:e,appState:t,fitToViewport:r=!1,viewportZoomFactor:o=.7})=>{let[n,i,a,s]=e,l=(n+a)/2,c=(i+s)/2,d,m,p;if(r){let u=a-n,h=s-i;d=Math.min(t.width/u,t.height/h)*Math.min(1,Math.max(o,.1)),d=Math.min(Math.max(d,ns),wh);let g=t.width;if(t.openSidebar){let v=document.querySelector(".sidebar")?.offsetWidth??0;g=document.documentElement.getAttribute("dir")==="rtl"?t.width+v:t.width-v}m=g/2*(1/d)-l,p=t.height/2*(1/d)-c}else{d=rk(e,{width:t.width,height:t.height});let u=uf({scenePoint:{x:l,y:c},viewportDimensions:{width:t.width,height:t.height},zoom:{value:d}});m=u.scrollX,p=u.scrollY}return{appState:{...t,scrollX:m,scrollY:p,zoom:{value:d}},storeAction:D.NONE}},Xc=({targetElements:e,appState:t,fitToViewport:r,viewportZoomFactor:o})=>{let n=we(Te(e));return tT({bounds:n,appState:t,fitToViewport:r,viewportZoomFactor:o})},rX=H({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Bp,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return Xc({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!1})},keyTest:e=>e.code===ye.TWO&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),oX=H({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Bp,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return Xc({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!0})},keyTest:e=>e.code===ye.THREE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),ok=H({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Bp,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>Xc({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1}),keyTest:e=>e.code===ye.ONE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),Ha=H({name:"toggleTheme",label:(e,t)=>t.theme===ce.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ce.LIGHT?Hc:Uc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r)=>({appState:{...t,theme:r||(t.theme===ce.LIGHT?ce.DARK:ce.LIGHT)},storeAction:D.NONE}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===ye.D,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.toggleTheme}),nX=H({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t)=>{let r;return Nr(t)?r=et(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):r=et(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},storeAction:D.CAPTURE}},keyTest:e=>e.key===S.E}),rT=H({name:"toggleHandTool",label:"toolBar.hand",paletteName:"Toggle hand tool",trackEvent:{category:"toolbar"},icon:Lp,viewMode:!1,perform:(e,t,r,o)=>{let n;return Yo(t)?n=et(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=et(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),Ye(o.interactiveCanvas,Ne.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},storeAction:D.CAPTURE}},keyTest:e=>!e.altKey&&!e[S.CTRL_OR_CMD]&&e.key===S.H});f();ge();be();G();Ve();Ae();ft();Jt();_r();le();Ls();De();import{jsx as ik}from"react/jsx-runtime";var To=H({name:"finalize",label:"",trackEvent:!1,perform:(e,t,r,o)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=o,s=a.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:h}=t.editingLinearElement,g=j.getElement(p,s);if(g)return Dr(g)&&Ea(g,u,h,s),{elements:g.points.length<2||Eo(g)?e.filter(x=>x.id!==g.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null,selectedLinearElement:null},storeAction:D.CAPTURE}}let l=e,c=t.pendingImageElementId&&a.getElement(t.pendingImageElementId);c&&O(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let d=t.multiElement?t.multiElement:t.editingElement?.type==="freedraw"?t.editingElement:null;if(d){if(d.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:h}=d;(!h||u[u.length-1]!==h)&&O(d,{points:d.points.slice(0,-1)})}Eo(d)&&(l=l.filter(u=>u.id!==d.id));let p=wr(d.points,t.zoom.value);if((d.type==="line"||d.type==="freedraw")&&p){let u=d.points,h=u[0];O(d,{points:u.map((g,x)=>x===u.length-1?[h[0],h[1]]:g)})}if(Dr(d)&&!p&&d.points.length>1){let[u,h]=j.getPointAtIndexGlobalCoordinates(d,-1,X(e));oc(d,t,{x:u,y:h},o)}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!d)&&Qr(n);let m;return t.activeTool.type==="eraser"?m=et(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):m=et(t,{type:"selection"}),{elements:l,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&d?t.activeTool:m,activeEmbeddable:null,draggingElement:null,multiElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[d.id]:!0}:t.selectedElementIds,selectedLinearElement:d&&ie(d)?new j(d):t.selectedLinearElement,pendingImageElementId:null},storeAction:D.CAPTURE}},keyTest:(e,t)=>e.key===S.ESCAPE&&(t.editingLinearElement!==null||!t.draggingElement&&t.multiElement===null)||(e.key===S.ESCAPE||e.key===S.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:r})=>ik(de,{type:"button",icon:r2,title:E("buttons.done"),"aria-label":E("buttons.done"),onClick:t,visible:e.multiElement!=null,size:r?.size||"medium"})});f();f();G();import{useState as ak}from"react";ge();import{jsx as oT,jsxs as sk}from"react/jsx-runtime";var nT=e=>{let{id:t}=Yt(),[r,o]=ak(e.value),n=a=>{e.ignoreFocus||i1(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===S.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return sk("div",{className:"ProjectName",children:[oT("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),oT("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${t}-filename`,value:r,onChange:a=>o(a.target.value)})]})};f();Y();import{jsx as Zc}from"react/jsx-runtime";var aT=e=>{let t=e.title||(e.value===ce.DARK?E("buttons.lightMode"):E("buttons.darkMode"));return Zc(de,{type:"icon",icon:e.value===ce.LIGHT?iT.MOON:iT.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===ce.DARK?ce.LIGHT:ce.DARK),"data-testid":"toggle-dark-mode"})},iT={SUN:Zc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Zc("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:Zc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Zc("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};f();_i();Y();be();le();Xe();Ac();G();Br();$n();jn();mr();Br();jn();var Ua=(e,{selectedElementIds:t},r)=>{e=Te(e);let o=r&&Ke(e,{selectedElementIds:t}),n=null,i=o?pe(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return o&&(i.length===1&&re(i[0])?(n=i[0],i=Us(e,n)):i.length>1&&(i=pe(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:ln(i)}},Ga=async(e,t,r,o,{exportBackground:n,exportPadding:i=Oo,viewBackgroundColor:a,name:s=r.name||Ud,fileHandle:l=null,exportingFrame:c=null})=>{if(t.length===0)throw new Error(E("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Hs(t,{exportBackground:n,exportWithDarkMode:r.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:r.exportScale,exportEmbedScene:r.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return _s(m.then(p=>new Blob([p.outerHTML],{type:oe.svg})),{description:"Export to SVG",name:s,extension:r.exportEmbedScene?"excalidraw.svg":"svg",fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await Jn(p)}catch{throw new Error(E("errors.copyToSystemClipboardFailed"))}return}}let d=Qm(t,r,o,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Zn(d);return r.exportEmbedScene&&(m=m.then(p=>Promise.resolve().then(()=>(Os(),wc)).then(({encodePngMetadata:u})=>u({blob:p,metadata:Pi(t,r,o,"local")})))),_s(m,{description:"Export to PNG",name:s,extension:"png",fileHandle:l})}else if(e==="clipboard")try{let m=Zn(d);await ip(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(E("canvasError.canvasTooBig")):_n&&m.name==="TypeError"?new Error(`${E("alerts.couldNotCopyToClipboard")}
|
|
35
|
+
`),l=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,c=ra(e.fontSize,e.lineHeight),d=Tp(e.fontFamily,e.fontSize,c);for(let m=0;m<s.length;m++)r.fillText(s[m],l,m*c+d);r.restore(),a&&r.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},jm=new WeakMap,ST=(e,t,r,o)=>{let n=r?o.zoom:MM.zoom,i=jm.get(e),a=i&&i.zoomValue!==n.value&&!o?.shouldCacheIgnoreZoom,s=J(e,t),l=s?.version||null,c=Qt(e,t)?.opacity||100;if(!i||a||i.theme!==o.theme||i.boundTextElementVersion!==l||i.containingFrameOpacity!==c||ne(e)&&s&&e.angle!==i.angle){let d=PM(e,t,n,r,o);return jm.set(e,d),d}return i},IT=(e,t,r,o,n)=>{let i=e.element,a=yu(i),s=e.scale,[l,c,d,m]=ae(i,n),p=((l+d)/2+o.scrollX)*window.devicePixelRatio,u=((c+m)/2+o.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let g=J(i,n);if(ne(i)&&g){let h=(e.boundTextCanvas.width-e.canvas.width)/2,x=(e.boundTextCanvas.height-e.canvas.height)/2;t.translate(p,u),t.drawImage(e.boundTextCanvas,-(d-l)/2*window.devicePixelRatio-h/s-a,-(m-c)/2*window.devicePixelRatio-x/s-a,e.boundTextCanvas.width/s,e.boundTextCanvas.height/s)}else if(t.translate(p,u),t.rotate(i.angle),"scale"in e.element&&!MT(i,r)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-p,-u),t.drawImage(e.canvas,(l+o.scrollX)*window.devicePixelRatio-a*e.scale/e.scale,(c+o.scrollY)*window.devicePixelRatio-a*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),T.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&Ct(i)){let h=J(i,n),x=xb(i);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((x.x+o.scrollX)*window.devicePixelRatio,(x.y+o.scrollY)*window.devicePixelRatio,br(i,h)*window.devicePixelRatio,ns(i,h)*window.devicePixelRatio)}t.restore()},DT=(e,t,r,o)=>{t.save(),t.translate(e.x+r.scrollX,e.y+r.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let n=.5/r.zoom.value;t.fillRect(n,n,e.width,e.height),t.lineWidth=1/r.zoom.value,t.strokeStyle=o,t.strokeRect(n,n,e.width,e.height),t.restore()},fl=(e,t,r,o,n,i,a)=>{switch(n.globalAlpha=Eb(e,Qt(e,t),i.elementsPendingErasure),e.type){case"magicframe":case"frame":{a.frameRendering.enabled&&a.frameRendering.outline&&(n.save(),n.translate(e.x+a.scrollX,e.y+a.scrollY),n.fillStyle="rgba(0, 0, 200, 0.04)",n.lineWidth=rt.strokeWidth/a.zoom.value,n.strokeStyle=rt.strokeColor,_a(e)&&(n.strokeStyle=a.theme===ue.LIGHT?"#7affd7":"#1d8264"),rt.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,e.width,e.height,rt.radius/a.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,e.width,e.height),n.restore());break}case"freedraw":{if(_e.generateElementShape(e,null),i.isExporting){let[s,l,c,d]=ae(e,t),m=(s+c)/2+a.scrollX,p=(l+d)/2+a.scrollY,u=(c-s)/2-(e.x-s),g=(d-l)/2-(e.y-l);n.save(),n.translate(m,p),n.rotate(e.angle),n.translate(-u,-g),xu(e,o,n,i,a),n.restore()}else{let s=ST(e,r,i,a);IT(s,n,i,a,r)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(_e.generateElementShape(e,i),i.isExporting){let[s,l,c,d]=ae(e,t),m=(s+c)/2+a.scrollX,p=(l+d)/2+a.scrollY,u=(c-s)/2-(e.x-s),g=(d-l)/2-(e.y-l);if(H(e)){let x=Et(e,t);if(ne(x)){let v=K.getBoundTextElementPosition(x,e,t);u=(c-s)/2-(v.x-s),g=(d-l)/2-(v.y-l)}}n.save(),n.translate(m,p),kT(e,i,a)&&(n.filter="none");let h=J(e,t);if(ne(e)&&h){let x=document.createElement("canvas"),v=x.getContext("2d"),y=Math.max(Ht(s,c),Ht(l,d)),w=yu(e);x.width=y*a.exportScale+w*10*a.exportScale,x.height=y*a.exportScale+w*10*a.exportScale,v.translate(x.width/2,x.height/2),v.scale(a.exportScale,a.exportScale),u=e.width/2-(e.x-s),g=e.height/2-(e.y-l),v.rotate(e.angle);let C=AT.canvas(x);v.translate(-u,-g),xu(e,C,v,i,a),v.translate(u,g),v.rotate(-e.angle);let[,,,,M,I]=ae(h,t),P=(s+c)/2-M,A=(l+d)/2-I;v.translate(-P,-A),v.clearRect(-h.width/2,-h.height/2,h.width,h.height),n.scale(1/a.exportScale,1/a.exportScale),n.drawImage(x,-x.width/2,-x.height/2,x.width,x.height)}else n.rotate(e.angle),e.type==="image"&&n.scale(e.scale[0],e.scale[1]),n.translate(-u,-g),xu(e,o,n,i,a);n.restore()}else{let s=ST(e,r,i,a),l=n.imageSmoothingEnabled;!a?.shouldCacheIgnoreZoom&&(!e.angle||NT(e.angle))&&(n.imageSmoothingEnabled=!1),IT(s,n,i,a,r),n.imageSmoothingEnabled=l}break}default:throw new Error(`Unimplemented type ${e.type}`)}n.globalAlpha=1},_T=new WeakMap([]);_M=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g});var vi,fd,wu,vu,Il,yb,is,jf,bd=X(()=>{"use strict";f();me();vi=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",fd=e=>e!=="image"&&e!=="frame"&&e!=="magicframe",wu=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",vu=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",Il=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image",yb=e=>e==="arrow",is=e=>e==="arrow",jf=(e,t)=>{let r=null;for(let o=e.length-1;o>=0;--o){let n=e[o];if(!n.isDeleted&&t(n)){r=n;break}}return r}});import{simplify as NM}from"points-on-curve";function FM(e){let t=e.roughness,r=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&r>=50||o>=15&&e.roundness&&Il(e.type)||ie(e)&&r>=50?t:Math.min(t/(r<10?3:2),2.5)}var OM,BT,Jr,OT,FT,ty,BM,Xh=X(()=>{"use strict";f();we();mt();li();V();Y();me();bd();OM=e=>[8,8+e],BT=e=>[1.5,6+e];Jr=(e,t=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?OM(e.strokeWidth):e.strokeStyle==="dotted"?BT(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:FM(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<Rh.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return r.fillStyle=e.fillStyle,r.fill=Ar(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(r.curveFitting=1),r;case"line":case"freedraw":return Dr(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),r;case"arrow":return r;default:throw new Error(`Unimplemented type ${e.type}`)}},OT=(e,t,r)=>sr(e)&&(t||Rt(e)&&r?.get(e.id)!==!0)&&Ar(e.backgroundColor)&&Ar(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Io(e)?{...e,strokeColor:Ar(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Ar(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,FT=(e,t,r,o,n,i,a)=>{let s=vb(e,t,r,o);if(s===null)return[];switch(o){case"dot":case"circle":case"circle_outline":{let[l,c,d]=s;return delete i.strokeLineDash,[n.circle(l,c,d,{...i,fill:o==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[l,c,d,m,p,u]=s;return delete i.strokeLineDash,[n.polygon([[l,c],[d,m],[p,u],[l,c]],{...i,fill:o==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[l,c,d,m,p,u,g,h]=s;return delete i.strokeLineDash,[n.polygon([[l,c],[d,m],[p,u],[g,h],[l,c]],{...i,fill:o==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"bar":case"arrow":default:{let[l,c,d,m,p,u]=s;if(e.strokeStyle==="dotted"){let g=BT(e.strokeWidth-1);i.strokeLineDash=[g[0],g[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(d,m,l,c,i),n.line(p,u,l,c,i)]}}},ty=(e,t,{isExporting:r,canvasBackgroundColor:o,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,s=e.height,l=fo(Math.min(a,s),e);i=t.path(`M ${l} 0 L ${a-l} 0 Q ${a} 0, ${a} ${l} L ${a} ${s-l} Q ${a} ${s}, ${a-l} ${s} L ${l} ${s} Q 0 ${s}, 0 ${s-l} L 0 ${l} Q 0 0, ${l} 0`,Jr(OT(e,r,n),!0))}else i=t.rectangle(0,0,e.width,e.height,Jr(OT(e,r,n),!1));return i}case"diamond":{let i,[a,s,l,c,d,m,p,u]=wb(e);if(e.roundness){let g=fo(Math.abs(a-p),e),h=fo(Math.abs(c-s),e);i=t.path(`M ${a+g} ${s+h} L ${l-g} ${c-h}
|
|
36
|
+
C ${l} ${c}, ${l} ${c}, ${l-g} ${c+h}
|
|
37
|
+
L ${d+g} ${m-h}
|
|
38
|
+
C ${d} ${m}, ${d} ${m}, ${d-g} ${m-h}
|
|
39
|
+
L ${p+g} ${u+h}
|
|
40
|
+
C ${p} ${u}, ${p} ${u}, ${p+g} ${u-h}
|
|
41
|
+
L ${a-g} ${s+h}
|
|
42
|
+
C ${a} ${s}, ${a} ${s}, ${a+g} ${s+h}`,Jr(e,!0))}else i=t.polygon([[a,s],[l,c],[d,m],[p,u]],Jr(e));return i}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,Jr(e));case"line":case"arrow":{let i,a=Jr(e),s=e.points.length?e.points:[[0,0]];if(de(e)?i=[t.path(BM(s,16),Jr(e,!0))]:e.roundness?i=[t.curve(s,a)]:a.fill?i=[t.polygon(s,a)]:i=[t.linearPath(s,a)],e.type==="arrow"){let{startArrowhead:l=null,endArrowhead:c="arrow"}=e;if(l!==null){let d=FT(e,i,"start",l,t,a,o);i.push(...d)}if(c!==null){let d=FT(e,i,"end",c,t,a,o);i.push(...d)}}return i}case"freedraw":{let i;if(RT(e),Dr(e.points)){let a=NM(e.points,.75);i=t.curve(a,{...Jr(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return $o(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},BM=(e,t)=>{let r=[];for(let n=1;n<e.length-1;n+=1){let i=e[n-1],a=e[n+1],s=Math.min(t,Math.sqrt(ul(e[n],a))/2,Math.sqrt(ul(e[n],i))/2);i[0]<e[n][0]&&i[1]===e[n][1]?r.push([e[n][0]-s,e[n][1]]):i[0]===e[n][0]&&i[1]<e[n][1]?r.push([e[n][0],e[n][1]-s]):i[0]>e[n][0]&&i[1]===e[n][1]?r.push([e[n][0]+s,e[n][1]]):r.push([e[n][0],e[n][1]+s]),r.push(e[n]),a[0]<e[n][0]&&a[1]===e[n][1]?r.push([e[n][0]-s,e[n][1]]):a[0]===e[n][0]&&a[1]<e[n][1]?r.push([e[n][0],e[n][1]-s]):a[0]>e[n][0]&&a[1]===e[n][1]?r.push([e[n][0]+s,e[n][1]]):r.push([e[n][0],e[n][1]+s])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let n=0;n<r.length;n+=3)o.push(`L ${r[n][0]} ${r[n][1]}`),o.push(`Q ${r[n+1][0]} ${r[n+1][1]}, ${r[n+2][0]} ${r[n+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")}});import Sb from"roughjs/bin/rough";var Tb,ae,hb,wb,aa,zT,HT,zM,Ed,Ib,HM,UM,GM,vb,WM,VM,ho,Te,Tu,hi,Cb,Ab,Qr,Mb,dt=X(()=>{"use strict";f();mt();Xh();me();Ha();He();Wt();Qo();V();Tb=class e{static boundsCache=new WeakMap;static getBounds(t,r){let o=e.boundsCache.get(t);if(o?.version&&o.version===t.version&&!ze(t))return o.bounds;let n=e.calculateBounds(t,r);return e.boundsCache.set(t,{version:t.version,bounds:n}),n}static calculateBounds(t,r){let o,[n,i,a,s,l,c]=ae(t,r);if(Zt(t)){let[d,m,p,u]=Ib(t.points.map(([g,h])=>xe(g,h,l-t.x,c-t.y,t.angle)));return[d+t.x,m+t.y,p+t.x,u+t.y]}else if(ie(t))o=VM(t,l,c,r);else if(t.type==="diamond"){let[d,m]=xe(l,i,l,c,t.angle),[p,u]=xe(l,s,l,c,t.angle),[g,h]=xe(n,c,l,c,t.angle),[x,v]=xe(a,c,l,c,t.angle),y=Math.min(d,p,g,x),w=Math.min(m,u,h,v),C=Math.max(d,p,g,x),M=Math.max(m,u,h,v);o=[y,w,C,M]}else if(t.type==="ellipse"){let d=(a-n)/2,m=(s-i)/2,p=Math.cos(t.angle),u=Math.sin(t.angle),g=Math.hypot(d*p,m*u),h=Math.hypot(m*p,d*u);o=[l-g,c-h,l+g,c+h]}else{let[d,m]=xe(n,i,l,c,t.angle),[p,u]=xe(n,s,l,c,t.angle),[g,h]=xe(a,s,l,c,t.angle),[x,v]=xe(a,i,l,c,t.angle),y=Math.min(d,p,g,x),w=Math.min(m,u,h,v),C=Math.max(d,p,g,x),M=Math.max(m,u,h,v);o=[y,w,C,M]}return o}},ae=(e,t,r=!1)=>{if(Zt(e))return HM(e);if(ie(e))return K.getElementAbsoluteCoords(e,t,r);if(H(e)){let o=t?Et(e,t):null;if(ne(o)){let n=K.getBoundTextElementPosition(o,e,t);return[n.x,n.y,n.x+e.width,n.y+e.height,n.x+e.width/2,n.y+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]},hb=(e,t)=>{let[r,o,n,i,a,s]=ae(e,t),l=[a,s];if(ie(e)||Zt(e)){let v=[],y=0;for(;y<e.points.length-1;)v.push([ce([e.points[y][0]+e.x,e.points[y][1]+e.y],l,e.angle),ce([e.points[y+1][0]+e.x,e.points[y+1][1]+e.y],l,e.angle)]),y++;return v}let[c,d,m,p,u,g,h,x]=[[r,o],[n,o],[r,i],[n,i],[a,o],[a,i],[r,s],[n,s]].map(v=>ce(v,l,e.angle));return e.type==="diamond"?[[u,h],[u,x],[g,h],[g,x]]:e.type==="ellipse"?[[u,h],[u,x],[g,h],[g,x],[u,h],[u,x],[g,h],[g,x]]:[[c,d],[m,p],[c,m],[d,p],[c,x],[m,x],[d,h],[p,h]]},wb=e=>{let t=Math.floor(e.width/2)+1,r=0,o=e.width,n=Math.floor(e.height/2)+1,i=t,a=e.height;return[t,r,o,n,i,a,0,n]},aa=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},zT=(e,t,r,o,n)=>{let i=1-e;return Math.pow(i,3)*t+3*Math.pow(i,2)*e*r+3*i*Math.pow(e,2)*o+Math.pow(e,3)*n},HT=(e,t,r,o)=>{let n=t-e,i=r-t,a=o-r,s=3*n-6*i+3*a,l=6*i-6*n,c=3*n,d=l*l-4*s*c;if(!(d>=0))return!1;let p=null,u=null,g=1/0,h=1/0;return s===0?g=h=-c/l:(g=(-l+Math.sqrt(d))/(2*s),h=(-l-Math.sqrt(d))/(2*s)),g>=0&&g<=1&&(p=zT(g,e,t,r,o)),h>=0&&h<=1&&(u=zT(h,e,t,r,o)),[p,u]},zM=(e,t,r,o)=>{let n=HT(e[0],t[0],r[0],o[0]),i=HT(e[1],t[1],r[1],o[1]),a=Math.min(e[0],o[0]),s=Math.max(e[0],o[0]);if(n){let d=n.filter(m=>m!==null);a=Math.min(a,...d),s=Math.max(s,...d)}let l=Math.min(e[1],o[1]),c=Math.max(e[1],o[1]);if(i){let d=i.filter(m=>m!==null);l=Math.min(l,...d),c=Math.max(c,...d)}return[a,l,s,c]},Ed=(e,t)=>{let r=[0,0],{minX:o,minY:n,maxX:i,maxY:a}=e.reduce((s,{op:l,data:c})=>{if(l==="move")r=c;else if(l==="bcurveTo"){let d=[c[0],c[1]],m=[c[2],c[3]],p=[c[4],c[5]],u=t?t(...d):d,g=t?t(...m):m,h=t?t(...p):p,x=t?t(...r):r;r=p;let[v,y,w,C]=zM(x,u,g,h);s.minX=Math.min(s.minX,v),s.minY=Math.min(s.minY,y),s.maxX=Math.max(s.maxX,w),s.maxY=Math.max(s.maxY,C)}return s},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[o,n,i,a]},Ib=e=>{let t=1/0,r=1/0,o=-1/0,n=-1/0;for(let[i,a]of e)t=Math.min(t,i),r=Math.min(r,a),o=Math.max(o,i),n=Math.max(n,a);return[t,r,o,n]},HM=e=>{let[t,r,o,n]=Ib(e.points),i=t+e.x,a=r+e.y,s=o+e.x,l=n+e.y;return[i,a,s,l,(i+s)/2,(a+l)/2]},UM=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;default:return 15}},GM=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},vb=(e,t,r,o)=>{let n=aa(t[0]);if(n.length<1)return null;let i=r==="start"?1:n.length-1,a=n[i].data,s=[a[4],a[5]],l=[a[2],a[3]],c=[a[0],a[1]],d=n[i-1],m=[0,0];d.op==="move"?m=d.data:d.op==="bcurveTo"&&(m=[d.data[4],d.data[5]]);let p=(q,re)=>Math.pow(1-q,3)*s[re]+3*q*Math.pow(1-q,2)*l[re]+3*Math.pow(q,2)*(1-q)*c[re]+m[re]*Math.pow(q,3),[u,g]=r==="start"?m:s,[h,x]=[p(.3,0),p(.3,1)],v=Math.hypot(u-h,g-x),y=(u-h)/v,w=(g-x)/v,C=UM(o),M=0;{let[q,re]=r==="end"?e.points[e.points.length-1]:e.points[0],[ge,le]=e.points.length>1?r==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];M=Math.hypot(q-ge,re-le)}let P=Math.min(C,M*(o==="diamond"||o==="diamond_outline"?.25:.5)),A=u-y*P,N=g-w*P;if(o==="dot"||o==="circle"||o==="circle_outline"){let q=Math.hypot(N-g,A-u)+e.strokeWidth-2;return[u,g,q]}let k=GM(o),[D,z]=xe(A,N,u,g,-k*Math.PI/180),[R,W]=xe(A,N,u,g,k*Math.PI/180);if(o==="diamond"||o==="diamond_outline"){let q,re;if(r==="start"){let[ge,le]=e.points.length>1?e.points[1]:[0,0];[q,re]=xe(u+P*2,g,u,g,Math.atan2(le-g,ge-u))}else{let[ge,le]=e.points.length>1?e.points[e.points.length-2]:[0,0];[q,re]=xe(u-P*2,g,u,g,Math.atan2(g-le,u-ge))}return[u,g,D,z,q,re,R,W]}return[u,g,D,z,R,W]},WM=e=>{let t=Sb.generator(),r=Jr(e),o=e.roundness?"curve":r.fill?"polygon":"linearPath";return t[o](e.points,r)},VM=(e,t,r,o)=>{let n=J(e,o);if(e.points.length<2){let[m,p]=e.points[0],[u,g]=xe(e.x+m,e.y+p,t,r,e.angle),h=[u,g,u,g];if(n){let x=K.getMinMaxXYWithBoundText(e,o,[u,g,u,g],n);h=[x[0],x[1],x[2],x[3]]}return h}let a=_e.get(e)?.[0]??WM(e),s=aa(a),c=Ed(s,(m,p)=>xe(e.x+m,e.y+p,t,r,e.angle)),d=[c[0],c[1],c[2],c[3]];if(n){let m=K.getMinMaxXYWithBoundText(e,o,d,n);d=[m[0],m[1],m[2],m[3]]}return d},ho=(e,t)=>Tb.getBounds(e,t),Te=e=>{if(!e.length)return[0,0,0,0];let t=1/0,r=-1/0,o=1/0,n=-1/0,i=Z(e);return e.forEach(a=>{let[s,l,c,d]=ho(a,i);t=Math.min(t,s),o=Math.min(o,l),r=Math.max(r,c),n=Math.max(n,d)}),[t,o,r,n]},Tu=(e,t)=>{let[r,o,n,i]=Te(e);return[r+t.x,o+t.y,n+t.x,i+t.y]},hi=(e,t,r,o)=>{if(!(ie(e)||Zt(e)))return[e.x,e.y,e.x+t,e.y+r];let n=Yi(0,t,Yi(1,r,e.points,o),o),i;if(Zt(e))i=Ib(n);else{let d=Sb.generator(),m=e.roundness?d.curve(n,Jr(e)):d.linearPath(n,Jr(e)),p=aa(m);i=Ed(p)}let[a,s,l,c]=i;return[a+e.x,s+e.y,l+e.x,c+e.y]},Cb=(e,t)=>{let r=Sb.generator(),o=e.roundness==null?r.linearPath(t,Jr(e)):r.curve(t,Jr(e)),n=aa(o),[i,a,s,l]=Ed(n);return[i+e.x,a+e.y,s+e.x,l+e.y]},Ab=(e,t)=>{if(!e.length)return[0,0,0,0];let r=1/0,o=e[0],n=Z(e);return e.forEach(i=>{let[a,s,l,c]=ho(i,n),d=Pt((a+l)/2,(s+c)/2,t.x,t.y);d<r&&(r=d,o=i)}),ho(o,n)},Qr=e=>{let[t,r,o,n]=Te(e);return{minX:t,minY:r,maxX:o,maxY:n,width:o-t,height:n-r,midX:(t+o)/2,midY:(r+n)/2}},Mb=({scrollX:e,scrollY:t,width:r,height:o,zoom:n})=>[-e,-t,-e+r/n.value,-t+o/n.value]});var xe,ce,z2,Pt,ul,Cl,Dr,Op,Ot,fo,Pb,Lb,YM,UT,GT,WT,gn,NT,Al,Ml,xd,yd,gd,Su,Db,fi,dn,kb,qa,ta,bi,Bp,Yp,Yf,mt=X(()=>{"use strict";f();Y();dt();Qo();xe=(e,t,r,o,n)=>[(e-r)*Math.cos(n)-(t-o)*Math.sin(n)+r,(e-r)*Math.sin(n)+(t-o)*Math.cos(n)+o],ce=(e,t,r)=>xe(e[0],e[1],t[0],t[1],r),z2=(e,t,r,o,n,i,a,s)=>{let l=Math.cos(o),c=Math.sin(o);return e.e&&e.w?t+=n+a:e.e?(t+=n*(1+l),r+=n*c,t+=a*(1-l),r+=a*-c):e.w&&(t+=n*(1-l),r+=n*-c,t+=a*(1+l),r+=a*c),e.n&&e.s?r+=i+s:e.n?(t+=i*c,r+=i*(1-l),t+=s*-c,r+=s*(1+l)):e.s&&(t+=i*-c,r+=i*(1+l),t+=s*c,r+=s*(1-l)),[t,r]},Pt=(e,t,r,o)=>{let n=r-e,i=o-t;return Math.hypot(n,i)},ul=(e,t)=>{let r=t[0]-e[0],o=t[1]-e[1];return r*r+o*o},Cl=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],Dr=(e,t=1)=>{if(e.length>=3){let[r,o]=[e[0],e[e.length-1]];return Pt(r[0],r[1],o[0],o[1])<=Ns/t}return!1},Op=(e,t,r)=>t[0]<=Math.max(e[0],r[0])&&t[0]>=Math.min(e[0],r[0])&&t[1]<=Math.max(e[1],r[1])&&t[1]>=Math.min(e[1],r[1]),Ot=(e,t,r)=>r?[Math.round(e/r)*r,Math.round(t/r)*r]:[e,t],fo=(e,t)=>{if(t.roundness?.type===ct.PROPORTIONAL_RADIUS||t.roundness?.type===ct.LEGACY)return e*Mm;if(t.roundness?.type===ct.ADAPTIVE_RADIUS){let r=t.roundness?.value??E0,o=r/Mm;return e<=o?e*Mm:r}return 0},Pb=(e,t)=>{let r=_e.generateElementShape(e,null);if(!r)return null;let o=aa(r[0]),n=[0,0],i=0,a=1/0,s=null;for(;i<o.length;){let{op:l,data:c}=o[i];if(l==="move"&&(n=c),l==="bcurveTo"){let d=n,m=[c[0],c[1]],p=[c[2],c[3]],u=[c[4],c[5]],g=Pt(u[0],u[1],t[0],t[1]);g<a&&(a=g,s=[d,m,p,u]),n=u}i++}return s},Lb=(e,t,r,o,n)=>{let i=(l,c)=>Math.pow(1-l,3)*o[c]+3*l*Math.pow(1-l,2)*r[c]+3*Math.pow(l,2)*(1-l)*t[c]+e[c]*Math.pow(l,3),a=i(n,0),s=i(n,1);return[a,s]},YM=(e,t)=>{let r=Pb(e,t);if(!r)return[];let o=[],n=1;for(;n>0;){let i=Lb(r[0],r[1],r[2],r[3],n);o.push([i[0],i[1]]),n-=.05}return o.length&&gn(o.at(-1),t)&&o.push([t[0],t[1]]),o},UT=(e,t)=>{let r=[];r[0]=0;let o=YM(e,t),n=0,i=0;for(;n<o.length-1;){let a=Pt(o[n][0],o[n][1],o[n+1][0],o[n+1][1]);i+=a,r.push(i),n++}return r},GT=(e,t)=>UT(e,t).at(-1),WT=(e,t,r)=>{let o=UT(e,t),n=o.length-1,i=o.at(-1),a=r*i,s=0,l=n,c=0;for(;s<l;)c=Math.floor(s+(l-s)/2),o[c]<a?s=c+1:l=c;return o[c]>a&&c--,o[c]===a?c/n:1-(c+(a-o[c])/(o[c+1]-o[c]))/n},gn=(e,t)=>e[0]===t[0]&&e[1]===t[1],NT=e=>Math.round(e/Math.PI*1e4)%5e3===0,Al=e=>e*180/Math.PI,Ml=e=>e/180*Math.PI,xd=([e,t],[r,o])=>e<=r?t>=r:e>=r?o>=e:!1,yd=(e,t)=>{let r=Math.max(e[0],t[0]),o=Math.min(e[1],t[1]);return r<=o?[r,o]:null},gd=(e,t,r)=>e>=t&&e<=r,Su=(e,t)=>[e[0]+t[0],e[1]+t[1]],Db=(e,t)=>[e[0]*t,e[1]*t],fi=(e,t=[0,0])=>[e[0]-t[0],e[1]-t[1]],dn=(e,t,r)=>Su(t,Db(fi(e,t),r)),kb=(e,t,r)=>(e[0]-r[0])*(t[1]-r[1])-(t[0]-r[0])*(e[1]-r[1]),qa=(e,t,r,o)=>{let n=kb(e,t,r),i=kb(e,r,o),a=kb(e,o,t),s=n<0||i<0||a<0,l=n>0||i>0||a>0;return!(s&&l)},ta=(e,t)=>e[0]>t[0]&&e[0]<t[2]&&e[1]>t[1]&&e[1]<t[3],bi=(e,t)=>{let r={minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height,midX:e.x+e.width/2,midY:e.y+e.height/2},o=[r.midX,r.midY],[n,i]=ce([r.minX,r.minY],o,e.angle),[a,s]=ce([r.maxX,r.minY],o,e.angle),[l,c]=ce([r.maxX,r.maxY],o,e.angle),[d,m]=ce([r.minX,r.maxY],o,e.angle),p=[Math.min(n,a,l,d),Math.min(i,s,c,m),Math.max(n,a,l,d),Math.max(i,s,c,m)];if(t){let[u,g,h,x]=t;return[p[0]-x,p[1]-u,p[2]+g,p[3]+h]}return p},Bp=e=>[e[0]+(e[2]-e[0])/2,e[1]+(e[3]-e[1])/2],Yp=e=>[e.x+e.width/2,e.y+e.height/2],Yf=(e,t,r)=>Math.min(Math.max(e,t),r)});var wd,VT=X(()=>{"use strict";f();wd=class{constructor(t){this.scoreFunction=t}content=[];sinkDown(t){let r=this.content[t];for(;t>0;){let o=(t+1>>1)-1,n=this.content[o];if(this.scoreFunction(r)<this.scoreFunction(n))this.content[o]=r,this.content[t]=n,t=o;else break}}bubbleUp(t){let r=this.content.length,o=this.content[t],n=this.scoreFunction(o);for(;;){let i=t+1<<1,a=i-1,s=null,l=0;if(a<r){let c=this.content[a];l=this.scoreFunction(c),l<n&&(s=a)}if(i<r){let c=this.content[i];this.scoreFunction(c)<(s===null?n:l)&&(s=i)}if(s!==null)this.content[t]=this.content[s],this.content[s]=o,t=s;else break}}push(t){this.content.push(t),this.sinkDown(this.content.length-1)}pop(){if(this.content.length===0)return null;let t=this.content[0],r=this.content.pop();return this.content.length>0&&(this.content[0]=r,this.bubbleUp(0)),t}remove(t){if(this.content.length===0)return;let r=this.content.indexOf(t),o=this.content.pop();r<this.content.length&&(this.content[r]=o,this.scoreFunction(o)<this.scoreFunction(t)?this.sinkDown(r):this.bubbleUp(r))}size(){return this.content.length}rescoreElement(t){this.sinkDown(this.content.indexOf(t))}}});var Hn,_o,sa,XM,KM,_b,$M,ZM,YT,jM,qM,vd,Iu,jT,XT,JM,QM,ek,tk,rk,KT,$T,ZT,kl=X(()=>{"use strict";f();al();VT();mt();Ha();V();yr();Wf();De();me();Hn=40,_o=(e,t,r,o,n,i)=>{let a=rk(t,i?.changedElements),s=tk(t,i?.changedElements),l=Su(r[0],[e.x+(o?o[0]:0),e.y+(o?o[1]:0)]),c=Su(r[r.length-1],[e.x+(o?o[0]:0),e.y+(o?o[1]:0)]),d=e.startBinding&&XT(e.startBinding.elementId,s),m=e.endBinding&&XT(e.endBinding.elementId,s),p=i?.isDragging?xr(ar(l),a,s,!0):d,u=i?.isDragging?xr(ar(c),a,s,!0):m,g=KT(e.startBinding?.fixedPoint,l,c,s,d,p,i?.isDragging),h=KT(e.endBinding?.fixedPoint,c,l,s,m,u,i?.isDragging),x=ZT(g,h,s,p,l),v=ZT(h,g,s,u,c),y=[g[0]-2,g[1]-2,g[0]+2,g[1]+2],w=[h[0]-2,h[1]-2,h[0]+2,h[1]+2],C=p?bi(p,sa(x,e.startArrowhead?at*6:at*2,1)):y,M=u?bi(u,sa(v,e.endArrowhead?at*6:at*2,1)):w,I=ta(g,u?bi(u,sa(v,Hn,Hn)):w)||ta(h,p?bi(p,sa(x,Hn,Hn)):y),P=jT(I?[y,w]:[C,M]),A=$M(I?y:C,I?w:M,P,I?sa(x,!p&&!u?0:Hn,0):sa(x,!p&&!u?0:Hn-(e.startArrowhead?at*6:at*2),Hn),I?sa(v,!p&&!u?0:Hn,0):sa(v,!p&&!u?0:Hn-(e.endArrowhead?at*6:at*2),Hn),I),N=YT(A[0],x,g),k=YT(A[1],v,h),D=ZM(A,N||g,x,k||h,v,P),z=N&&Iu(N,D),R=k&&Iu(k,D),W=Iu(h,D);W&&u&&(W.closed=!0);let q=Iu(g,D);q&&e.startBinding&&(q.closed=!0);let re=z&&R&&(ta(z.pos,A[1])||ta(R.pos,A[0])),ge=XM(z||q,R||W,D,x||Nt,v||Nt,re?[]:A);if(ge){let le=ge.map(U=>[U.pos[0],U.pos[1]]);z&&le.unshift(g),R&&le.push(h),F(e,{...n,...JM(QM(le),0,0),angle:0},i?.informMutation)}else console.error("Elbow arrow cannot find a route")},sa=(e,t,r)=>{switch(e){case Nr:return[t,r,r,r];case Nt:return[r,t,r,r];case _r:return[r,r,t,r]}return[r,r,r,t]},XM=(e,t,r,o,n,i)=>{let a=_b(e.pos,t.pos),s=new wd(l=>l.f);for(s.push(e);s.size()>0;){let l=s.pop();if(!l||l.closed)continue;if(l===t)return KM(e,l);l.closed=!0;let c=qM(l.addr,r);for(let d=0;d<4;d++){let m=c[d];if(!m||m.closed)continue;let p=dn(m.pos,l.pos,.5);if(F0(...i.map(C=>ta(p,C))))continue;let u=ek(d),g=l.parent?Ji(fi(l.pos,l.parent.pos)):o,h=Db(g,-1);if(gn(h,u)||gn(e.addr,m.addr)&&gn(u,o)||gn(t.addr,m.addr)&&gn(u,n))continue;let v=g!==u,y=l.g+_b(m.pos,l.pos)+(v?Math.pow(a,3):0),w=m.visited;if(!w||y<m.g){let C=jM(m,t,u,n);m.visited=!0,m.parent=l,m.h=_b(t.pos,m.pos)+C*Math.pow(a,2),m.g=y,m.f=m.g+m.h,w?s.rescoreElement(m):s.push(m)}}}return null},KM=(e,t)=>{let r=t,o=[];for(;r.parent;)o.unshift(r),r=r.parent;return o.unshift(e),o},_b=(e,t)=>Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1]),$M=(e,t,r,o,n,i)=>{let[a,s,l,c]=o??[0,0,0,0],[d,m,p,u]=n??[0,0,0,0],g=[e[0]>t[2]?e[1]>t[3]||e[3]<t[1]?Math.min((e[0]+t[2])/2,e[0]-c):(e[0]+t[2])/2:e[0]>t[0]?e[0]-c:r[0]-c,e[1]>t[3]?e[0]>t[2]||e[2]<t[0]?Math.min((e[1]+t[3])/2,e[1]-a):(e[1]+t[3])/2:e[1]>t[1]?e[1]-a:r[1]-a,e[2]<t[0]?e[1]>t[3]||e[3]<t[1]?Math.max((e[2]+t[0])/2,e[2]+s):(e[2]+t[0])/2:e[2]<t[2]?e[2]+s:r[2]+s,e[3]<t[1]?e[0]>t[2]||e[2]<t[0]?Math.max((e[3]+t[1])/2,e[3]+l):(e[3]+t[1])/2:e[3]<t[3]?e[3]+l:r[3]+l],h=[t[0]>e[2]?t[1]>e[3]||t[3]<e[1]?Math.min((t[0]+e[2])/2,t[0]-u):(t[0]+e[2])/2:t[0]>e[0]?t[0]-u:r[0]-u,t[1]>e[3]?t[0]>e[2]||t[2]<e[0]?Math.min((t[1]+e[3])/2,t[1]-d):(t[1]+e[3])/2:t[1]>e[1]?t[1]-d:r[1]-d,t[2]<e[0]?t[1]>e[3]||t[3]<e[1]?Math.max((t[2]+e[0])/2,t[2]+m):(t[2]+e[0])/2:t[2]<e[2]?t[2]+m:r[2]+m,t[3]<e[1]?t[0]>e[2]||t[2]<e[0]?Math.max((t[3]+e[1])/2,t[3]+p):(t[3]+e[1])/2:t[3]<e[3]?t[3]+p:r[3]+p],x=jT([g,h]);if(!i&&g[2]-g[0]+h[2]-h[0]>x[2]-x[0]+1e-11&&g[3]-g[1]+h[3]-h[1]>x[3]-x[1]+1e-11){let[v,y]=[(h[0]+h[2])/2,(h[1]+h[3])/2];if(t[0]>e[2]&&e[1]>t[3]){let w=g[2]+(h[0]-g[2])/2,C=h[3]+(g[1]-h[3])/2;return Xc([e[2],e[1]],[e[0],e[3]],[v,y])>0?[[g[0],g[1],w,g[3]],[w,h[1],h[2],h[3]]]:[[g[0],C,g[2],g[3]],[h[0],h[1],h[2],C]]}else if(e[2]<t[0]&&e[3]<t[1]){let w=g[2]+(h[0]-g[2])/2,C=g[3]+(h[1]-g[3])/2;return Xc([e[0],e[1]],[e[2],e[3]],[v,y])>0?[[g[0],g[1],g[2],C],[h[0],C,h[2],h[3]]]:[[g[0],g[1],w,g[3]],[w,h[1],h[2],h[3]]]}else if(e[0]>t[2]&&e[3]<t[1]){let w=h[2]+(g[0]-h[2])/2,C=g[3]+(h[1]-g[3])/2;return Xc([e[2],e[1]],[e[0],e[3]],[v,y])>0?[[w,g[1],g[2],g[3]],[h[0],h[1],w,h[3]]]:[[g[0],g[1],g[2],C],[h[0],C,h[2],h[3]]]}else if(e[0]>t[2]&&e[1]>t[3]){let w=h[2]+(g[0]-h[2])/2,C=h[3]+(g[1]-h[3])/2;return Xc([e[0],e[1]],[e[2],e[3]],[v,y])>0?[[w,g[1],g[2],g[3]],[h[0],h[1],w,h[3]]]:[[g[0],C,g[2],g[3]],[h[0],h[1],h[2],C]]}}return[g,h]},ZM=(e,t,r,o,n,i)=>{let a=new Set,s=new Set;r===Rr||r===Nt?s.add(t[1]):a.add(t[0]),n===Rr||n===Nt?s.add(o[1]):a.add(o[0]),e.forEach(d=>{a.add(d[0]),a.add(d[2]),s.add(d[1]),s.add(d[3])}),a.add(i[0]),a.add(i[2]),s.add(i[1]),s.add(i[3]);let l=Array.from(s).sort((d,m)=>d-m),c=Array.from(a).sort((d,m)=>d-m);return{row:l.length,col:c.length,data:l.flatMap((d,m)=>c.map((p,u)=>({f:0,g:0,h:0,closed:!1,visited:!1,parent:null,addr:[u,m],pos:[p,d]})))}},YT=(e,t,r)=>{switch(t){case Nr:return[r[0],e[1]];case Nt:return[e[2],r[1]];case _r:return[r[0],e[3]]}return[e[0],r[1]]},jM=(e,t,r,o)=>{if(o===Nt)switch(r){case Nt:return e.pos[0]>=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2;case Nr:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case _r:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Rr:return e.pos[1]===t.pos[1]?4:2}else if(o===Rr)switch(r){case Nt:return e.pos[1]===t.pos[1]?4:2;case Nr:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case _r:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case Rr:return e.pos[0]<=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2}else if(o===Nr)switch(r){case Nt:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Nr:return e.pos[1]>=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case _r:return e.pos[0]===t.pos[0]?4:2;case Rr:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3}else if(o===_r)switch(r){case Nt:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Nr:return e.pos[0]===t.pos[0]?4:2;case _r:return e.pos[1]<=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case Rr:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3}return 0},qM=([e,t],r)=>[vd([e,t-1],r),vd([e+1,t],r),vd([e,t+1],r),vd([e-1,t],r)],vd=([e,t],r)=>e<0||e>=r.col||t<0||t>=r.row?null:r.data[t*r.col+e]??null,Iu=(e,t)=>{for(let r=0;r<t.col;r++)for(let o=0;o<t.row;o++){let n=vd([r,o],t);if(n&&e[0]===n.pos[0]&&e[1]===n.pos[1])return n}return null},jT=e=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1])),Math.max(...e.map(t=>t[2])),Math.max(...e.map(t=>t[3]))],XT=(e,t)=>{let r=t.get(e);return r&&An(r)?r:null},JM=(e,t,r)=>{let o=e[0][0],n=e[0][1],i=e.map((a,s)=>[a[0]-o,a[1]-n]);return{points:i,x:o+(t??0),y:n+(r??0),...pi(i)}},QM=e=>e.slice(2).reduce((t,r)=>gn(Ji(fi(t[t.length-1],t[t.length-2])),Ji(fi(r,t[t.length-1])))?[...t.slice(0,-1),r]:[...t,r],[e[0]??[0,0],e[1]??[1,0]]),ek=e=>{switch(e){case 0:return Nr;case 1:return Nt;case 2:return _r}return Rr},tk=(e,t)=>t?Mr(new Map([...e.getNonDeletedElementsMap(),...t])):e.getNonDeletedElementsMap(),rk=(e,t)=>t?[...e.getNonDeletedElements(),...[...t].map(([r,o])=>o)]:e.getNonDeletedElements(),KT=(e,t,r,o,n,i,a)=>{if(a){if(i){let s=$T(t,r,i,o);return Mv(i,s)}return t}if(n){let s=Up(e||[0,0],n);return Math.abs(Ja(n,s,o)-at)>.01?$T(t,r,n,o):s}return t},$T=(e,t,r,o)=>gl(z0(r)?Av(r,e):e,t,r,o),ZT=(e,t,r,o,n)=>Cv(e,t,o,o&&bi(o,Array(4).fill(Ja(o,e,r))),r,n)});var Ti,K,ok,Wt=X(()=>{"use strict";f();mt();we();dt();De();yr();V();me();ye();He();Y();Qo();kl();Ti={version:null,points:[],zoom:null},K=class e{elementId;selectedPointsIndices;pointerDownState;isDragging;lastUncommittedPoint;pointerOffset;startBindingElement;endBindingElement;hoverPointIndex;segmentMidPointHoveredCoords;constructor(t){this.elementId=t.id,gn(t.points[0],[0,0])||console.error("Linear element is not normalized",Error().stack),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,lastClickedIsEndPoint:!1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null}static POINT_HANDLE_SIZE=10;static getElement(t,r){let o=r.get(t);return o||null}static handleBoxSelection(t,r,o,n){if(!r.editingLinearElement||r.draggingElement?.type!=="selection")return!1;let{editingLinearElement:i}=r,{selectedPointsIndices:a,elementId:s}=i,l=e.getElement(s,n);if(!l)return!1;let[c,d,m,p]=ae(r.draggingElement,n),g=e.getPointsGlobalCoordinates(l,n).reduce((h,x,v)=>((x[0]>=c&&x[0]<=m&&x[1]>=d&&x[1]<=p||t.shiftKey&&a?.includes(v))&&h.push(v),h),[]).filter(h=>!(de(l)&&h!==0&&h!==l.points.length-1));o({editingLinearElement:{...i,selectedPointsIndices:g.length?g:null}})}static handlePointDragging(t,r,o,n,i,a,s){if(!a)return!1;let{elementId:l}=a,c=s.getNonDeletedElementsMap(),d=e.getElement(l,c);if(!d||de(d)&&!a.pointerDownState.lastClickedIsEndPoint&&a.pointerDownState.lastClickedPoint!==0)return!1;let m=de(d)?a.selectedPointsIndices?.reduce((g,h)=>h===0?[0,g[1]]:[g[0],d.points.length-1],[!1,!1]).filter(g=>typeof g=="number"):a.selectedPointsIndices,p=de(d)?a.pointerDownState.lastClickedPoint>0?d.points.length-1:0:a.pointerDownState.lastClickedPoint,u=d.points[p];if(m&&u){if(Za(t)&&m.length===1&&d.points.length>1){let h=m[0],x=d.points[h===0?1:h-1],[v,y]=e._getShiftLockedDelta(d,c,x,[o,n],t[S.CTRL_OR_CMD]?null:r.gridSize);e.movePoints(d,[{index:h,point:[v+x[0],y+x[1]],isDragging:h===p}],s)}else{let h=e.createPointAt(d,c,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize),x=h[0]-u[0],v=h[1]-u[1];e.movePoints(d,m.map(y=>{let w=y===p?e.createPointAt(d,c,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize):[d.points[y][0]+x,d.points[y][1]+v];return{index:y,point:w,isDragging:y===p}}),s)}if(J(d,c)&&mn(d,c,!1),Kr(d,!1)){let h=[];m[0]===0&&h.push(ar(e.getPointGlobalCoordinates(d,d.points[0],c)));let v=m[m.length-1];v===d.points.length-1&&h.push(ar(e.getPointGlobalCoordinates(d,d.points[v],c))),h.length&&i(d,h)}return!0}return!1}static handlePointerUp(t,r,o,n){let i=n.getNonDeletedElementsMap(),a=n.getNonDeletedElements(),{elementId:s,selectedPointsIndices:l,isDragging:c,pointerDownState:d}=r,m=e.getElement(s,i);if(!m)return r;let p={};if(c&&l){for(let u of l)if(u===0||u===m.points.length-1){Dr(m.points,o.zoom.value)&&e.movePoints(m,[{index:u,point:u===0?m.points[m.points.length-1]:m.points[0]}],n);let g=Fn(o)?xr(ar(e.getPointAtIndexGlobalCoordinates(m,u,i)),a,i):null;p[u===0?"startBindingElement":"endBindingElement"]=g}}return{...r,...p,selectedPointsIndices:c||t.shiftKey?!c&&t.shiftKey&&d.prevSelectedPointsIndices?.includes(d.lastClickedPoint)?l&&l.filter(u=>u!==d.lastClickedPoint):l:l?.includes(d.lastClickedPoint)?[d.lastClickedPoint]:l,isDragging:!1,pointerOffset:{x:0,y:0}}}static getEditorMidPoints=(t,r,o)=>{let n=J(t,r);return!o.editingLinearElement&&t.points.length>2&&!n?[]:(Ti.version===t.version&&Ti.zoom===o.zoom.value||e.updateEditorMidPointsCache(t,r,o),Ti.points)};static updateEditorMidPointsCache=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,r),i=0,a=[];for(;i<n.length-1;){if(e.isSegmentTooShort(t,t.points[i],t.points[i+1],o.zoom)){a.push(null),i++;continue}let s=e.getSegmentMidPoint(t,n[i],n[i+1],i+1,r);a.push(s),i++}Ti.points=a,Ti.version=t.version,Ti.zoom=o.zoom.value};static getSegmentMidpointHitCoords=(t,r,o,n)=>{let{elementId:i}=t,a=e.getElement(i,n);if(!a||e.getPointIndexUnderCursor(a,n,o.zoom,r.x,r.y)>=0||e.getPointsGlobalCoordinates(a,n).length>=3&&!o.editingLinearElement)return null;let c=e.POINT_HANDLE_SIZE/o.zoom.value,d=t.segmentMidPointHoveredCoords;if(d&&Pt(d[0],d[1],r.x,r.y)<=c)return d;let m=0,p=e.getEditorMidPoints(a,n,o);for(;m<p.length;){if(p[m]!==null&&Pt(p[m][0],p[m][1],r.x,r.y)<=c)return p[m];m++}return null};static isSegmentTooShort(t,r,o,n){let i=Pt(r[0],r[1],o[0],o[1]);return t.points.length>2&&t.roundness&&(i=GT(t,o)),i*n.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,r,o,n,i){let a=Cl(r,o);if(t.points.length>2&&t.roundness){let s=Pb(t,t.points[n]);if(s){let l=WT(t,t.points[n],.5),[c,d]=Lb(s[0],s[1],s[2],s[3],l);a=e.getPointGlobalCoordinates(t,[c,d],i)}}return a}static getSegmentMidPointIndex(t,r,o,n){let i=e.getElement(t.elementId,n);if(!i)return-1;let a=e.getEditorMidPoints(i,n,r),s=0;for(;s<a.length;){if(e.arePointsEqual(o,a[s]))return s+1;s++}return-1}static handlePointerDown(t,r,o,n,i,a){let s=a.getNonDeletedElementsMap(),l=a.getNonDeletedElements(),c={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!i)return c;let{elementId:d}=i,m=e.getElement(d,s);if(!m)return c;let p=e.getSegmentMidpointHitCoords(i,n,r,s),u=null;if(p&&(u=e.getSegmentMidPointIndex(i,r,p,s)),t.altKey&&r.editingLinearElement)return(i.lastUncommittedPoint==null||!de(m))&&(F(m,{points:[...m.points,e.createPointAt(m,s,n.x,n.y,t[S.CTRL_OR_CMD]?null:r.gridSize)]}),c.didAddPoint=!0),o.shouldCaptureIncrement(),c.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:-1,lastClickedIsEndPoint:!1,origin:{x:n.x,y:n.y},segmentMidpoint:{value:p,index:u,added:!1}},selectedPointsIndices:[m.points.length-1],lastUncommittedPoint:null,endBindingElement:xr(n,l,s)},c.didAddPoint=!0,c;let g=e.getPointIndexUnderCursor(m,s,r.zoom,n.x,n.y);if(g>=0||p)c.hitElement=m;else{let{startBindingElement:P,endBindingElement:A}=i;Fn(r)&&Kr(m)&&Qa(m,P,A,s,a)}let[h,x,v,y]=ae(m,s),w=(h+v)/2,C=(x+y)/2,M=g>-1&&xe(m.x+m.points[g][0],m.y+m.points[g][1],w,C,m.angle),I=g>-1||t.shiftKey?t.shiftKey||i.selectedPointsIndices?.includes(g)?ok([...i.selectedPointsIndices||[],g]):[g]:null;return c.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:g,lastClickedIsEndPoint:g===m.points.length-1,origin:{x:n.x,y:n.y},segmentMidpoint:{value:p,index:u,added:!1}},selectedPointsIndices:I,pointerOffset:M?{x:n.x-M[0],y:n.y-M[1]}:{x:0,y:0}},c}static arePointsEqual(t,r){return!t&&!r?!0:!t||!r?!1:gn(t,r)}static handlePointerMove(t,r,o,n,i){if(!n.editingLinearElement)return null;let{elementId:a,lastUncommittedPoint:s}=n.editingLinearElement,l=i.getNonDeletedElementsMap(),c=e.getElement(a,l);if(!c)return n.editingLinearElement;let{points:d}=c,m=d[d.length-1];if(!t.altKey)return m===s&&e.deletePoints(c,[d.length-1],i),{...n.editingLinearElement,lastUncommittedPoint:null};let p;if(Za(t)&&d.length>=2){let u=d[d.length-2],[g,h]=e._getShiftLockedDelta(c,l,u,[r,o],t[S.CTRL_OR_CMD]?null:n.gridSize);p=[g+u[0],h+u[1]]}else p=e.createPointAt(c,l,r-n.editingLinearElement.pointerOffset.x,o-n.editingLinearElement.pointerOffset.y,t[S.CTRL_OR_CMD]||de(c)?null:n.gridSize);return m===s?e.movePoints(c,[{index:c.points.length-1,point:p}],i):e.addPoints(c,n,[{point:p}],i),{...n.editingLinearElement,lastUncommittedPoint:c.points[c.points.length-1]}}static getPointGlobalCoordinates(t,r,o){let[n,i,a,s]=ae(t,o),l=(n+a)/2,c=(i+s)/2,{x:d,y:m}=t;return[d,m]=xe(d+r[0],m+r[1],l,c,t.angle),[d,m]}static getPointsGlobalCoordinates(t,r){let[o,n,i,a]=ae(t,r),s=(o+i)/2,l=(n+a)/2;return t.points.map(c=>{let{x:d,y:m}=t;return[d,m]=xe(d+c[0],m+c[1],s,l,t.angle),[d,m]})}static getPointAtIndexGlobalCoordinates(t,r,o){let n=r<0?t.points.length+r:r,[i,a,s,l]=ae(t,o),c=(i+s)/2,d=(a+l)/2,m=t.points[n],{x:p,y:u}=t;return m?xe(p+m[0],u+m[1],c,d,t.angle):xe(p,u,c,d,t.angle)}static pointFromAbsoluteCoords(t,r,o){if(de(t))return[r[0]-t.x,r[1]-t.y];let[n,i,a,s]=ae(t,o),l=(n+a)/2,c=(i+s)/2,[d,m]=xe(r[0],r[1],l,c,-t.angle);return[d-t.x,m-t.y]}static getPointIndexUnderCursor(t,r,o,n,i){let a=e.getPointsGlobalCoordinates(t,r),s=a.length;for(;--s>-1;){let l=a[s];if(Pt(n,i,l[0],l[1])*o.value<e.POINT_HANDLE_SIZE+1)return s}return-1}static createPointAt(t,r,o,n,i){let a=Ot(o,n,i),[s,l,c,d]=ae(t,r),m=(s+c)/2,p=(l+d)/2,[u,g]=xe(a[0],a[1],m,p,-t.angle);return[u-t.x,g-t.y]}static getNormalizedPoints(t){let{points:r}=t,o=r[0][0],n=r[0][1];return{points:r.map((i,a)=>[i[0]-o,i[1]-n]),x:t.x+o,y:t.y+n}}static normalizePoints(t){F(t,e.getNormalizedPoints(t))}static duplicateSelectedPoints(t,r){if(!t.editingLinearElement)return!1;let{selectedPointsIndices:o,elementId:n}=t.editingLinearElement,i=r.getNonDeletedElementsMap(),a=e.getElement(n,i);if(!a||o===null)return!1;let{points:s}=a,l=[],c=!1,d=-1,m=s.reduce((p,u,g)=>{if(++d,p.push(u),o.includes(g)){let x=s[g+1];x||(c=!0),p.push(x?[(u[0]+x[0])/2,(u[1]+x[1])/2]:[u[0],u[1]]),l.push(d+1),++d}return p},[]);if(F(a,{points:m}),c){let p=a.points[a.points.length-1];e.movePoints(a,[{index:a.points.length-1,point:[p[0]+30,p[1]+30]}],r)}return{appState:{...t,editingLinearElement:{...t.editingLinearElement,selectedPointsIndices:l}}}}static deletePoints(t,r,o){let n=0,i=0;if(r.includes(0)){let l=t.points.find((c,d)=>!r.includes(d));l&&(n=l[0],i=l[1])}let s=t.points.reduce((l,c,d)=>(r.includes(d)||l.push(l.length?[c[0]-n,c[1]-i]:[0,0]),l),[]);e._updatePoints(t,s,n,i,o)}static addPoints(t,r,o,n){let s=[...t.points,...o.map(l=>l.point)];e._updatePoints(t,s,0,0,n)}static movePoints(t,r,o,n,i){let{points:a}=t,s=0,l=0,c=r.find(({index:m})=>m===0);c&&(s=c.point[0]+a[c.index][0],l=c.point[1]+a[c.index][1]);let d=a.map((m,p)=>{let u=r.find(g=>g.index===p);if(u){if(u.index===0)return m;let g=u.point[0]-a[u.index][0],h=u.point[1]-a[u.index][1];return[m[0]+g-s,m[1]+h-l]}return s||l?[m[0]-s,m[1]-l]:m});e._updatePoints(t,d,s,l,o,n,{isDragging:r.reduce((m,p)=>m||p.isDragging===!0,!1),changedElements:i?.changedElements})}static shouldAddMidpoint(t,r,o,n){let i=e.getElement(t.elementId,n);if(i&&de(i)||!i)return!1;let{segmentMidpoint:a}=t.pointerDownState;if(a.added||a.value===null||a.index===null||t.pointerDownState.origin===null)return!1;let s=t.pointerDownState.origin,l=Pt(s.x,s.y,r.x,r.y);return!(!o.editingLinearElement&&l<ri/o.zoom.value)}static addMidpoint(t,r,o,n,i){let a=e.getElement(t.elementId,i);if(!a)return;let{segmentMidpoint:s}=t.pointerDownState,l={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,i,r.x,r.y,n&&!de(a)?o.gridSize:null),d=[...a.points.slice(0,s.index),c,...a.points.slice(s.index)];return F(a,{points:d}),l.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:s.index},l.selectedPointsIndices=[s.index],l}static _updatePoints(t,r,o,n,i,a,s){if(de(t)){let l={};a?.startBinding!==void 0&&(l.startBinding=a.startBinding!==null&&Gh(a.startBinding)?a.startBinding:null),a?.endBinding!==void 0&&(l.endBinding=a.endBinding!==null&&Gh(a.endBinding)?a.endBinding:null),_o(t,i,r,[o,n],l,s)}else{let l=Cb(t,r),c=Cb(t,t.points),d=(l[0]+l[2])/2,m=(l[1]+l[3])/2,p=(c[0]+c[2])/2,u=(c[1]+c[3])/2,g=p-d,h=u-m,x=xe(o,n,g,h,t.angle);F(t,{...a,points:r,x:t.x+x[0],y:t.y+x[1]})}}static _getShiftLockedDelta(t,r,o,n,i){let a=e.getPointGlobalCoordinates(t,o,r);if(de(t))return[n[0]-a[0],n[1]-a[1]];let[s,l]=Ot(n[0],n[1],i),{width:c,height:d}=Pl(a[0],a[1],s,l);return ce([c,d],[0,0],-t.angle)}static getBoundTextElementPosition=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,o);n.length<2&&F(r,{isDeleted:!0});let i=0,a=0;if(t.points.length%2===1){let s=Math.floor(t.points.length/2),l=e.getPointGlobalCoordinates(t,t.points[s],o);i=l[0]-r.width/2,a=l[1]-r.height/2}else{let s=t.points.length/2-1,l=Ti.points[s];t.points.length===2&&(l=Cl(n[0],n[1])),(!l||Ti.version!==t.version)&&(l=e.getSegmentMidPoint(t,n[s],n[s+1],s+1,o)),i=l[0]-r.width/2,a=l[1]-r.height/2}return{x:i,y:a}};static getMinMaxXYWithBoundText=(t,r,o,n)=>{let[i,a,s,l]=o,c=(i+s)/2,d=(a+l)/2,{x:m,y:p}=e.getBoundTextElementPosition(t,n,r),u=m+n.width,g=p+n.height,h=ce([i,a],[c,d],t.angle),x=ce([s,a],[c,d],t.angle),v=ce([m,p],[c,d],-t.angle),y=ce([u,p],[c,d],-t.angle),w=ce([m,g],[c,d],-t.angle),C=ce([u,g],[c,d],-t.angle);return h[0]<x[0]&&h[1]>=x[1]?(i=Math.min(i,w[0]),s=Math.max(s,Math.max(y[0],C[0])),a=Math.min(a,v[1]),l=Math.max(l,C[1])):h[0]>=x[0]&&h[1]>x[1]?(i=Math.min(i,C[0]),s=Math.max(s,Math.max(v[0],y[0])),a=Math.min(a,w[1]),l=Math.max(l,y[1])):h[0]>=x[0]?(i=Math.min(i,y[0]),s=Math.max(s,w[0]),a=Math.min(a,C[1]),l=Math.max(l,v[1])):h[1]<=x[1]&&(i=Math.min(i,Math.min(y[0],v[0])),s=Math.max(s,C[0]),a=Math.min(a,y[1]),l=Math.max(l,w[1])),[i,a,s,l,c,d]};static getElementAbsoluteCoords=(t,r,o=!1)=>{let n,i,a,s,l;if(t.points.length<2||!_e.get(t)){let{minX:p,minY:u,maxX:g,maxY:h}=t.points.reduce((x,[v,y])=>(x.minY=Math.min(x.minY,y),x.minX=Math.min(x.minX,v),x.maxX=Math.max(x.maxX,v),x.maxY=Math.max(x.maxY,y),x),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});i=p+t.x,a=u+t.y,s=g+t.x,l=h+t.y}else{let p=_e.generateElementShape(t,null),u=aa(p[0]),[g,h,x,v]=Ed(u);i=g+t.x,a=h+t.y,s=x+t.x,l=v+t.y}let c=(i+s)/2,d=(a+l)/2;if(n=[i,a,s,l,c,d],!o)return n;let m=J(t,r);return m&&(n=e.getMinMaxXYWithBoundText(t,r,[i,a,s,l],m)),n}},ok=e=>{let t=[...new Set(e.filter(r=>r!==null&&r!==-1))];return t=t.sort((r,o)=>r-o),t.length?t:null}});var as,ss,Cu,qT,Au=X(()=>{"use strict";f();as={},ss=(e,t)=>{let r=as[e]||(as[e]={height:t});return r.height=t,r},Cu=e=>{as[e]&&delete as[e]},qT=e=>as[e]?.height??null});var Zi,Nb,ft,Mu,mn,Ll,Vt,jw,ra,Dl,Rb,ls,ku,nk,ik,Lo,JT,QT,_l,ak,pn,J,Et,Pu,xb,e3,t3,r3,sk,o3,Si,br,ns,n3,Rl,He=X(()=>{"use strict";f();V();De();Y();we();me();Wt();Au();Zi=e=>zm(e).replace(/\t/g," "),Nb=e=>Zi(e).split(`
|
|
43
|
+
`),ft=(e,t,r,o=!0)=>{let n,i={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height,angle:t?.angle??e.angle};i.text=e.text,(t||!e.autoResize)&&(n=t?br(t,e):e.width,i.text=Lo(e.originalText,Me(e),n));let a=Vt(i.text,Me(e),e.lineHeight);if(e.autoResize&&(i.width=a.width),i.height=a.height,t){let s=ns(t,e),l=br(t,e);if(!ne(t)&&a.height>s){let p=Si(a.height,t.type);F(t,{height:p},o),ss(t.id,p)}if(a.width>l){let p=Si(a.width,t.type);F(t,{width:p},o)}let c={...e,...i},{x:d,y:m}=Ll(t,c,r);i.x=d,i.y=m}F(e,i,o)},Mu=(e,t,r)=>{let o=Z(e);t.forEach(n=>{let i=r.get(n.id),a=pn(n);if(a){let s=r.get(a);if(s){let l=o.get(i);l&&F(l,{boundElements:(n.boundElements||[]).filter(d=>d.id!==s&&d.id!==a).concat({type:"text",id:s})});let c=o.get(s);c&&H(c)&&F(c,{containerId:l?i:null})}}})},mn=(e,t,r,o=!1)=>{if(!pn(e))return;Cu(e.id);let i=J(e,t);if(i&&i.text){if(!e)return;let a=i.text,s=i.height,l=i.width,c=br(e,i),d=ns(e,i),m=e.height;if(o||r!=="n"&&r!=="s"){a&&(a=Lo(i.originalText,Me(i),c));let p=Vt(a,Me(i),i.lineHeight);s=p.height,l=p.width}if(s>d){m=Si(s,e.type);let p=m-e.height,u=!ne(e)&&(r==="ne"||r==="nw"||r==="n")?e.y-p:e.y;F(e,{height:m,y:u})}F(i,{text:a,width:l,height:s}),ne(e)||F(i,Ll(e,i,t))}},Ll=(e,t,r)=>{if(ne(e))return K.getBoundTextElementPosition(e,t,r);let o=xb(e),n=ns(e,t),i=br(e,t),a,s;return t.verticalAlign===kt.TOP?s=o.y:t.verticalAlign===kt.BOTTOM?s=o.y+(n-t.height):s=o.y+(n/2-t.height/2),t.textAlign===Oi.LEFT?a=o.x:t.textAlign===Oi.RIGHT?a=o.x+(i-t.width):a=o.x+(i/2-t.width/2),{x:a,y:s}},Vt=(e,t,r)=>{e=e.split(`
|
|
44
|
+
`).map(a=>a||" ").join(`
|
|
45
|
+
`);let o=parseFloat(t),n=nk(e,o,r);return{width:ku(e,t),height:n}},jw=e=>{let t=Nb(e.text).length;return e.height/t/e.fontSize},ra=(e,t)=>e*t,Dl=(e,t)=>ra(e,t)+wt*2,ls=(e,t,r)=>{Rb||(Rb=document.createElement("canvas"));let o=Rb.getContext("2d");o.font=t;let n=o.measureText(e),i=n.width;if(!r&&window.TextMetrics&&"actualBoundingBoxLeft"in window.TextMetrics.prototype&&"actualBoundingBoxRight"in window.TextMetrics.prototype){let a=Math.abs(n.actualBoundingBoxLeft)+Math.abs(n.actualBoundingBoxRight);return Math.max(a,i)}return Yr()?i*10:i},ku=(e,t,r)=>{let o=Nb(e),n=0;return o.forEach(i=>{n=Math.max(n,ls(i,t,r))}),n},nk=(e,t,r)=>{let o=Nb(e).length;return ra(t,r)*o},ik=e=>{let t=e.split("-");return t.length>1&&t.forEach((r,o)=>{o!==t.length-1&&(t[o]=r+="-")}),t.join(" ").split(" ")},Lo=(e,t,r)=>{if(!Number.isFinite(r)||r<0)return e;let o=[],n=e.split(`
|
|
46
|
+
`),i=ls(" ",t,!0),a="",s=0,l=d=>{d.trim()&&o.push(d)},c=()=>{a="",s=0};for(let d of n){if(ls(d,t,!0)<=r){o.push(d);continue}let p=ik(d);c();let u=0;for(;u<p.length;){let g=ls(p[u],t,!0);if(g===r)l(p[u]),u++;else if(g>r){for(l(a),c();p[u].length>0;){let h=String.fromCodePoint(p[u].codePointAt(0)),x=a+h,v=ls(x,t,!0),y=JT.calculate(h,t);s=v,p[u]=p[u].slice(h.length),s>=r?(l(a),a=h,s=y):a=x}s+i>=r?(l(a),c()):a.endsWith("-")||(a+=" ",s+=i),u++}else for(;s<r&&u<p.length;){let h=p[u];if(s=ls(a+h,t,!0),s>r){l(a),c();break}u++;let x=!h.endsWith("-");if(a+=h,x&&(a+=" "),s+i>=r){x?o.push(a.slice(0,-1)):o.push(a),c();break}}}a.slice(-1)===" "&&(a=a.slice(0,-1),l(a))}return o.join(`
|
|
47
|
+
`)},JT=(()=>{let e={};return{calculate:(o,n)=>{let i=o.charCodeAt(0);if(e[n]||(e[n]=[]),!e[n][i]){let a=ls(o,n,!0);e[n][i]=a}return e[n][i]},getCache:o=>e[o]}})(),QT="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),_l=(e,t)=>{let r=ak(e);return r===0?Vt(QT.split("").join(`
|
|
48
|
+
`),e,t).width+wt*2:r+wt*2},ak=e=>{let t=JT.getCache(e);if(!t)return 0;let r=t.filter(o=>o!==void 0);return Math.max(...r)},pn=e=>e?.boundElements?.length&&e?.boundElements?.find(t=>t.type==="text")?.id||null,J=(e,t)=>{if(!e)return null;let r=pn(e);return r&&t.get(r)||null},Et=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,Pu=(e,t,r)=>{if(!ne(e))return{x:e.x+e.width/2,y:e.y+e.height/2};let o=K.getPointsGlobalCoordinates(e,r);if(o.length%2===1){let a=Math.floor(e.points.length/2),s=K.getPointGlobalCoordinates(e,e.points[a],r);return{x:s[0],y:s[1]}}let n=e.points.length/2-1,i=K.getEditorMidPoints(e,r,t)[n];return i||(i=K.getSegmentMidPoint(e,o[n],o[n+1],n+1,r)),{x:i[0],y:i[1]}},xb=e=>{let t=wt,r=wt;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),r+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,r+=e.height/4),{x:e.x+t,y:e.y+r}},e3=(e,t)=>!t||ne(t)?e.angle:t.angle,t3=(e,t)=>e.some(r=>{if(ze(r)){let o=Et(r,t);return!ne(o)}return!1}),r3=(e,t)=>e.some(r=>{if(ze(r)){let o=Et(r,t);return!ne(o)}return H(r)}),sk=new Set(["rectangle","ellipse","diamond","arrow"]),o3=e=>sk.has(e.type),Si=(e,t)=>{e=Math.ceil(e);let r=wt*2;return t==="ellipse"?Math.round((e+r)/Math.sqrt(2)*2):t==="arrow"?e+r*8:t==="diamond"?2*(e+r):e+r},br=(e,t)=>{let{width:r}=e;if(ne(e)){let o=(t?.fontSize??ur)*f0;return Math.max(h0*r,o)}return e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-wt*2:e.type==="diamond"?Math.round(r/2)-wt*2:r-wt*2},ns=(e,t)=>{let{height:r}=e;return ne(e)?r-wt*8*2<=0?t.height:r:e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-wt*2:e.type==="diamond"?Math.round(r/2)-wt*2:r-wt*2},n3=()=>ku(QT,Me({fontSize:ur,fontFamily:gr}))>0,Rl=(e,t)=>Vt("",e,t).width+wt*2});import{generateNKeysBetween as lk}from"fractional-indexing";var Td,Xp,Jt,fr,ck,dk,Ob,a3,i3,ko=X(()=>{"use strict";f();De();Hi();me();He();V();Td=(e,{shouldThrow:t=!1,includeBoundTextValidation:r=!1,reconciliationContext:o})=>{let n=[],i=s=>`${s?.index}:${s?.id}:${s?.type}:${s?.isDeleted}:${s?.version}:${s?.versionNonce}`,a=e.map(s=>s.index);for(let[s,l]of a.entries()){let c=a[s-1],d=a[s+1];if(Ob(l,c,d)||n.push(`Fractional indices invariant has been compromised: "${i(e[s-1])}", "${i(e[s])}", "${i(e[s+1])}"`),r&&Ct(e[s])){let m=e[s],p=J(m,Z(e));p&&p.index<=m.index&&n.push(`Fractional indices invariant for bound elements has been compromised: "${i(p)}", "${i(m)}"`)}}if(n.length){let s=new Um,l=[];if(o&&(l.push("Additional reconciliation context:"),l.push(o.localElements.map(c=>i(c))),l.push(o.remoteElements.map(c=>i(c)))),console.error(n.join(`
|
|
49
|
+
|
|
50
|
+
`),s.stack,e.map(c=>i(c)),...l),t)throw s}},Xp=e=>e.sort((t,r)=>i3(t)&&i3(r)?t.index<r.index?-1:t.index>r.index?1:t.id<r.id?-1:1:1),Jt=(e,t)=>{try{let r=ck(e,t),o=a3(e,r),n=e.map(i=>o.has(i)?{...i,...o.get(i)}:i);Td(n,{includeBoundTextValidation:!1,shouldThrow:!0});for(let[i,a]of o)F(i,a,!1)}catch{fr(e)}return e},fr=e=>{let t=dk(e),r=a3(e,t);for(let[o,n]of r)F(o,n,!1);return e},ck=(e,t)=>{let r=[],o=0;for(;o<e.length;)if(t.has(e[o].id)){let n=[o-1,o];for(;++o<e.length&&t.has(e[o].id);)n.push(o);n.push(o),r.push(n)}else o++;return r},dk=e=>{let t=[],r,o,n=-1,i=0,a=c=>{let d=e[n]?e[n].index:void 0,m=e[c-1]?.index;return!d&&m||d&&m&&m>d?[m,c-1]:[d,n]},s=c=>{let d=e[i]?e[i].index:void 0;if(d&&c<i)return[d,i];let m=i;for(;++m<e.length;){let p=e[m]?.index;if(!d&&p||d&&p&&p>d)return[p,m]}return[void 0,m]},l=0;for(;l<e.length;){let c=e[l].index;if([r,n]=a(l),[o,i]=s(l),Ob(c,r,o))l++;else{let d=[n,l];for(;++l<e.length;){let m=e[l].index,[p,u]=a(l),[g,h]=s(l);if(Ob(m,p,g))break;[r,n]=[p,u],[o,i]=[g,h],d.push(l)}d.push(i),t.push(d)}}return t},Ob=(e,t,r)=>e?t&&r?t<e&&e<r:!t&&r?e<r:t&&!r?t<e:!!e:!1,a3=(e,t)=>{let r=new Map;for(let o of t){let n=o.shift(),i=o.pop(),a=lk(e[n]?.index,e[i]?.index,o.length);for(let s=0;s<o.length;s++){let l=e[o[s]];r.set(l,{index:a[s]})}}return r},i3=e=>!!e.index});var s3,mk,l3,Fb,er,cs=X(()=>{"use strict";f();we();me();Ui();Zo();ko();V();V();Y();s3=e=>{let t=new Map,r=[];for(let o of e)o.isDeleted||(r.push(o),t.set(o.id,o));return{elementsMap:t,elements:r}},mk=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],r="";for(let o of t)r+=`${o}:${e[o]?"1":"0"}`;return r},l3=e=>typeof e=="string",Fb=class e{static sceneMapByElement=new WeakMap;static sceneMapById=new Map;static mapElementToScene(t,r){l3(t)?this.sceneMapById.set(t,r):(this.sceneMapByElement.set(t,r),this.sceneMapById.set(t.id,r))}static getScene(t){return l3(t)?this.sceneMapById.get(t)||null:this.sceneMapByElement.get(t)||null}callbacks=new Set;nonDeletedElements=[];nonDeletedElementsMap=Mr(new Map);elements=[];nonDeletedFramesLikes=[];frames=[];elementsMap=Mr(new Map);selectedElementsCache={selectedElementIds:null,elements:null,cache:new Map};sceneNonce;getSceneNonce(){return this.sceneNonce}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(t){let r=mk(t),o=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===o&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let i=this.selectedElementsCache.cache.get(r);if(i)return i}else t?.elements==null&&this.selectedElementsCache.cache.clear();let n=he(o,{selectedElementIds:t.selectedElementIds},t);return t?.elements==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(r,n)),n}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getNonDeletedElement(t){let r=this.getElement(t);return r&&Sd(r)?r:null}mapElements(t){let r=!1,o=this.elements.map(n=>{let i=t(n);return i!==n&&(r=!0),i});return r&&this.replaceAllElements(o),r}replaceAllElements(t){let r=t instanceof Array?t:Array.from(t.values()),o=[];(T.DEV||T.MODE===Kt.TEST||window?.DEBUG_FRACTIONAL_INDICES)&&Td(r,{includeBoundTextValidation:!0,shouldThrow:T.DEV||T.MODE===Kt.TEST}),this.elements=fr(r),this.elementsMap.clear(),this.elements.forEach(i=>{Q(i)&&o.push(i),this.elementsMap.set(i.id,i),e.mapElementToScene(i,this)});let n=s3(this.elements);this.nonDeletedElements=n.elements,this.nonDeletedElementsMap=n.elementsMap,this.frames=o,this.nonDeletedFramesLikes=s3(this.frames).elements,this.triggerUpdate()}triggerUpdate(){this.sceneNonce=Co();for(let t of Array.from(this.callbacks))t()}onUpdate(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),e.sceneMapById.forEach((t,r)=>{t===this&&e.sceneMapById.delete(r)}),this.callbacks.clear()}insertElementAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),t,...this.elements.slice(r)];Jt(o,Z([t])),this.replaceAllElements(o)}insertElementsAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),...t,...this.elements.slice(r)];Jt(o,Z(t)),this.replaceAllElements(o)}insertElement=t=>{let r=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,r)};insertElements=t=>{let r=t[0].frameId?this.getElementIndex(t[0].frameId):this.elements.length;this.insertElementsAtIndex(t,r)};getElementIndex(t){return this.elements.findIndex(r=>r.id===t)}getContainerElement=t=>t&&t.containerId&&this.getElement(t.containerId)||null},er=Fb});var F,pe,Ki,De=X(()=>{"use strict";f();cs();Ha();Zo();V();Qo();F=(e,t,r=!0)=>{let o=!1,{points:n,fileId:i}=t;typeof n<"u"&&(t={...pi(n),...t});for(let a in t){let s=t[a];if(typeof s<"u"){if(e[a]===s&&(typeof s!="object"||s===null||a==="groupIds"||a==="scale"))continue;if(a==="scale"){let l=e[a],c=s;if(l[0]===c[0]&&l[1]===c[1])continue}else if(a==="points"){let l=e[a],c=s;if(l.length===c.length){let d=!1,m=l.length;for(;--m;){let p=l[m],u=c[m];if(p[0]!==u[0]||p[1]!==u[1]){d=!0;break}}if(!d)continue}}e[a]=s,o=!0}}return o&&((typeof t.height<"u"||typeof t.width<"u"||typeof i<"u"||typeof n<"u")&&_e.delete(e),e.version++,e.versionNonce=Co(),e.updated=si(),r&&er.getScene(e)?.triggerUpdate()),e},pe=(e,t,r=!1)=>{let o=!1;for(let n in t){let i=t[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!r?e:{...e,...t,updated:si(),version:e.version+1,versionNonce:Co()}},Ki=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=Co(),e.updated=si(),e)});var Po,ds,Lu,Pl,Fc,ms=X(()=>{"use strict";f();De();me();Y();dt();V();Po=e=>ie(e)||Zt(e)?e.points.length<2:e.width===0&&e.height===0,ds=(e,t,r,o,n)=>{let[i,a,s,l]=ho(e,n),c=Qe({clientX:o.offsetLeft,clientY:o.offsetTop},o),d=Qe({clientX:o.offsetLeft+t,clientY:o.offsetTop+r},o);return c.x<=s&&c.y<=l&&d.x>=i&&d.y>=a},Lu=(e,t,r)=>{let o=Math.abs(t),n=Math.abs(r);if(e==="line"||e==="arrow"||e==="freedraw"){let i=Math.round(Math.atan(n/o)/wn)*wn;i===0?r=0:i===Math.PI/2?t=0:r=o*Math.tan(i)*Math.sign(r)||r}else e!=="selection"&&(r=o*Math.sign(r));return{width:t,height:r}},Pl=(e,t,r,o)=>{let n=r-e,i=o-t,a=Math.round(Math.atan(i/n)/wn)*wn;if(a===0)i=0;else if(a===Math.PI/2)n=0;else{let s=Math.tan(a),l=-1,c=t-s*e,d=-1/s,m=-1,p=o-d*r,u=(l*p-m*c)/(s*m-d*l),g=(c*d-p*s)/(s*m-d*l);n=u-e,i=g-t}return{width:n,height:i}},Fc=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let r=Math.abs(e.width);t.width=r,t.x=e.x-r}if(e.height<0){let r=Math.abs(e.height);t.height=r,t.y=e.y-r}return t}});var c3,pk,m3,d3,Bb,Ii,Du,ps,Nl,Id,_u,Cd=X(()=>{"use strict";f();dt();mt();me();Y();c3={mouse:8,pen:16,touch:28},pk=16,m3={e:!0,s:!0,n:!0,w:!0},d3={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},Bb={e:!0,s:!0,n:!0,w:!0},Ii=(e,t,r,o,n,i,a)=>{let[s,l]=xe(e+r/2,t+o/2,n,i,a);return[s-r/2,l-o/2,r,o]},Du=e=>!(e.viewport.isMobile||e.isTouchScreen&&($x||ym)),ps=e=>Du(e)?m3:{},Nl=([e,t,r,o,n,i],a,s,l,c={},d=4)=>{let m=c3[l],p=m/s.value,u=m/s.value,g=m/s.value,h=m/s.value,x=r-e,v=o-t,y=d/s.value,w=(m-oi*2)/(2*s.value),C={nw:c.nw?void 0:Ii(e-y-g+w,t-y-h+w,p,u,n,i,a),ne:c.ne?void 0:Ii(r+y-w,t-y-h+w,p,u,n,i,a),sw:c.sw?void 0:Ii(e-y-g+w,o+y-w,p,u,n,i,a),se:c.se?void 0:Ii(r+y-w,o+y-w,p,u,n,i,a),rotation:c.rotation?void 0:Ii(e+x/2-p/2,t-y-h+w-pk/s.value,p,u,n,i,a)},M=5*c3.mouse/s.value;return Math.abs(x)>M&&(c.n||(C.n=Ii(e+x/2-p/2,t-y-h+w,p,u,n,i,a)),c.s||(C.s=Ii(e+x/2-p/2,o+y-w,p,u,n,i,a))),Math.abs(v)>M&&(c.w||(C.w=Ii(e-y-g+w,t+v/2-u/2,p,u,n,i,a)),c.e||(C.e=Ii(r+y-w,t+v/2-u/2,p,u,n,i,a))),C},Id=(e,t,r,o="mouse",n=m3)=>{if(e.locked||de(e))return{};if(e.type==="freedraw"||ie(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=Bb:a[0]>0&&a[1]<0?n=d3:a[0]>0&&a[1]>0?n=Bb:a[0]<0&&a[1]>0?n=d3:a[0]<0&&a[1]<0&&(n=Bb)}}else Q(e)&&(n={...n,rotation:!0});let i=ie(e)?oi+8:oi;return Nl(ae(e,r,!0),e.angle,t,o,n,i)},_u=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let r=e[0];return de(r)?!1:ie(r)?r.points.length>2:!0}});var Hb,p3,Ru,Nu,zb,uk,Ou,u3,g3=X(()=>{"use strict";f();Cd();dt();Y();al();me();Hb=(e,t,r)=>t>=e[0]&&t<=e[0]+e[2]&&r>=e[1]&&r<=e[1]+e[3],p3=(e,t,r,o,n,i,a,s)=>{if(!r.selectedElementIds[e.id])return!1;let{rotation:l,...c}=Id(e,i,t,a,ps(s));if(l&&Hb(l,o,n))return"rotation";let d=Object.keys(c).filter(m=>{let p=c[m];return p?Hb(p,o,n):!1});if(d.length>0)return d[0];if(Du(s)){let[m,p,u,g,h,x]=ae(e,t);if(!(ie(e)&&e.points.length<=2)){let v=Sm/i.value,y=u3([m-v,p-v],[u+v,g+v],[h,x],ln(e.angle));for(let[w,C]of Object.entries(y))if($a([o,n],C,v))return w}}return!1},Ru=(e,t,r,o,n,i,a,s)=>e.reduce((l,c)=>{if(l)return l;let d=p3(c,a,t,r,o,n,i,s);return d?{element:c,transformHandleType:d}:null},null),Nu=([e,t,r,o],n,i,a,s,l)=>{let c=Nl([e,t,r,o,(e+r)/2,(t+o)/2],0,a,s,ps(l)),d=Object.keys(c).find(m=>{let p=c[m];return p&&Hb(p,n,i)});if(d)return d;if(Du(l)){let m=(e+r)/2,p=(t+o)/2,u=Sm/a.value,g=u3([e-u,t-u],[r+u,o+u],[m,p],ln(0));for(let[h,x]of Object.entries(g))if($a([n,i],x,u))return h}return!1},zb=["ns","nesw","ew","nwse"],uk=(e,t)=>{let r=zb.indexOf(e);if(r>=0){let o=Math.round(t/(Math.PI/4));e=zb[(r+o)%zb.length]}return e},Ou=e=>{let{element:t,transformHandleType:r}=e,o=t&&Math.sign(t.height)*Math.sign(t.width)===-1,n=null;switch(r){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":o?n="nesw":n="nwse";break;case"ne":case"sw":o?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&t&&(n=uk(n,t.angle)),n?`${n}-resize`:""},u3=([e,t],[r,o],n,i)=>{let a=At([e,t],i,n),s=At([r,t],i,n),l=At([e,o],i,n),c=At([r,o],i,n);return{n:[a,s],e:[s,c],s:[c,l],w:[l,a]}}});var Fu,Ub,gk,Ad,Md,hk,fk,Gb,bk,Wb,Vb,kd=X(()=>{"use strict";f();Y();Ha();mt();dt();me();De();V();yr();cs();He();Wt();Gt();kl();Fu=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e,Ub=(e,t,r,o,n,i,a,s,l,c,d,m)=>{if(r.length===1){let[p]=r;return t==="rotation"?de(p)||(gk(p,o,s,l,n),qt(p,o,m)):H(p)&&t?(hk(e,p,o,t,i,s,l),qt(p,o,m)):t&&fk(e,a,p,o,t,i,s,l,m),!0}else if(r.length>1){if(t==="rotation")return bk(e,r,o,s,l,n,c,d,m),!0;if(t)return Gb(e,r,o,t,i,a,s,l,m),!0}return!1},gk=(e,t,r,o,n)=>{let[i,a,s,l]=ae(e,t),c=(i+s)/2,d=(a+l)/2,m;Q(e)?m=0:(m=5*Math.PI/2+Math.atan2(o-d,r-c),n&&(m+=wn/2,m-=m%wn),m=Fu(m));let p=pn(e);if(F(e,{angle:m}),p){let u=er.getScene(e)?.getElement(p);u&&!ne(e)&&F(u,{angle:m})}},Ad=(e,t,r,o)=>ie(e)||Zt(e)?{points:Yi(0,t,Yi(1,r,e.points,o),o)}:{},Md=(e,t,r)=>{let o=e.width;if(ze(e)){let a=Et(e,t);a&&(o=br(a,e))}let i=e.fontSize*(r/o);return i<Tm?null:{size:i}},hk=(e,t,r,o,n,i,a)=>{let[s,l,c,d,m,p]=ae(t,r),[u,g]=xe(i,a,m,p,-t.angle),h=0,x=0;o!=="e"&&o!=="w"&&(o.includes("e")&&(h=(u-s)/(c-s)),o.includes("w")&&(h=(c-u)/(c-s)),o.includes("n")&&(x=(d-g)/(d-l)),o.includes("s")&&(x=(g-l)/(d-l)));let v=Math.max(h,x);if(v>0){let y=t.width*v,w=t.height*v,C=Md(t,r,y);if(C===null)return;let M=[s,l],I=[c,d],P=[m,p],A=[s,l];if(["n","w","nw"].includes(o)&&(A=[I[0]-Math.abs(y),I[1]-Math.abs(w)]),o==="ne"){let q=[M[0],I[1]];A=[q[0],q[1]-Math.abs(w)]}if(o==="sw"){let q=[I[0],M[1]];A=[q[0]-Math.abs(y),q[1]]}["s","n"].includes(o)&&(A[0]=P[0]-y/2),["e","w"].includes(o)&&(A[1]=P[1]-w/2),n&&(A[0]=P[0]-Math.abs(y)/2,A[1]=P[1]-Math.abs(w)/2);let N=t.angle,k=ce(A,[m,p],N),D=[A[0]+Math.abs(y)/2,A[1]+Math.abs(w)/2],z=ce(D,[m,p],N);A=ce(k,z,-N);let[R,W]=A;F(t,{fontSize:C.size,width:y,height:w,x:R,y:W})}if(o==="e"||o==="w"){let y=e.get(t.id),[w,C,M,I]=hi(y,y.width,y.height,!0),P=[w,C],A=[M,I],N=Cl(P,A),k=ce([i,a],N,-y.angle),[D,,z]=hi(t,t.width,t.height,!0),R=z-D,W=A[0]-P[0],q=Rl(Me({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),re=W/R;o.includes("e")&&(re=(k[0]-P[0])/R),o.includes("w")&&(re=(A[0]-k[0])/R);let ge=t.width*re<q?q:t.width*re,le=Lo(t.originalText,Me(t),Math.abs(ge)),U=Vt(le,Me(t),t.lineHeight),oe=U.height,[Ie,Fe,lt,Je]=hi(y,ge,oe,!0),Gr=lt-Ie,Wo=Je-Fe,nr=[...P];["n","w","nw"].includes(o)&&(nr=[A[0]-Math.abs(Gr),P[1]]);let so=y.angle,Ri=ce(nr,N,so),Ca=[nr[0]+Math.abs(Gr)/2,nr[1]+Math.abs(Wo)/2],Vo=ce(Ca,N,so);nr=ce(Ri,Vo,-so);let vo={width:Math.abs(ge),height:Math.abs(U.height),x:nr[0],y:nr[1],text:le,autoResize:!1};F(t,vo)}},fk=(e,t,r,o,n,i,a,s,l)=>{if(ne(r)&&de(r)&&(r.startBinding||r.endBinding))return;let c=e.get(r.id),[d,m,p,u]=hi(c,c.width,c.height,!0),g=[d,m],h=[p,u],x=Cl(g,h),v=ce([a,s],x,-c.angle),[y,w,C,M]=hi(r,r.width,r.height,!0),I=C-y,P=M-w,A=h[0]-g[0],N=h[1]-g[1],k=A/I,D=N/P,z={},R=J(r,o);n.includes("e")&&(k=(v[0]-g[0])/I),n.includes("s")&&(D=(v[1]-g[1])/P),n.includes("w")&&(k=(h[0]-v[0])/I),n.includes("n")&&(D=(h[1]-v[1])/P);let W=c.width,q=c.height,re=r.width*k,ge=r.height*D;if(i&&(re=2*re-W,ge=2*ge-q),t){let Wr=Math.abs(re)/W,Ps=Math.abs(ge)/q;if(n.length===1&&(ge*=Wr,re*=Ps),n.length===2){let Aa=Math.max(Wr,Ps);re=W*Aa*Math.sign(re),ge=q*Aa*Math.sign(ge)}}if(R){let Wr=e.get(R.id);if(Wr&&(z={fontSize:Wr.fontSize}),t){let Ps={...r,width:re,height:ge},Aa=Md(R,o,br(Ps,R));if(Aa===null)return;z={fontSize:Aa.size}}else{let Ps=_l(Me(R),R.lineHeight),Aa=Dl(R.fontSize,R.lineHeight);re=Math.max(re,Ps),ge=Math.max(ge,Aa)}}let[le,U,oe,Ie]=hi(c,re,ge,!0),Fe=oe-le,lt=Ie-U,Je=[...g];if(["n","w","nw"].includes(n)&&(Je=[h[0]-Math.abs(Fe),h[1]-Math.abs(lt)]),n==="ne"){let Wr=[g[0],h[1]];Je=[Wr[0],Wr[1]-Math.abs(lt)]}if(n==="sw"){let Wr=[h[0],g[1]];Je=[Wr[0]-Math.abs(Fe),Wr[1]]}t&&(["s","n"].includes(n)&&(Je[0]=x[0]-Fe/2),["e","w"].includes(n)&&(Je[1]=x[1]-lt/2));let Gr=re<0,Wo=ge<0;Gr&&(n.includes("e")&&(Je[0]-=Math.abs(Fe)),n.includes("w")&&(Je[0]+=Math.abs(Fe))),Wo&&(n.includes("s")&&(Je[1]-=Math.abs(lt)),n.includes("n")&&(Je[1]+=Math.abs(lt))),i&&(Je[0]=x[0]-Math.abs(Fe)/2,Je[1]=x[1]-Math.abs(lt)/2);let nr=c.angle,so=ce(Je,x,nr),Ri=[Je[0]+Math.abs(Fe)/2,Je[1]+Math.abs(lt)/2],Ca=ce(Ri,x,nr);Je=ce(so,Ca,-nr);let Vo=[...Je],vo=c.x-le,En=c.y-U;Vo[0]+=vo,Vo[1]+=En;let lo=Vo[0],xn=Vo[1],Rx,Nx;(ie(r)||Zt(r))&&(Rx=Yi(1,ge,c.points,!0),Nx=Yi(0,re,Rx,!0));let ks={width:Math.abs(re),height:Math.abs(ge),x:lo,y:xn,points:Nx};if("scale"in r&&"scale"in c&&F(r,{scale:[(Math.sign(oe-c.x)||c.scale[0])*c.scale[0],(Math.sign(Ie-c.y)||c.scale[1])*c.scale[1]]}),ne(r)&&R&&t){let Wr=ks.width/r.width*R.fontSize;if(Wr<Tm)return;z.fontSize=Wr}ks.width!==0&&ks.height!==0&&Number.isFinite(ks.x)&&Number.isFinite(ks.y)&&(F(r,ks),qt(r,o,l,{oldSize:{width:c.width,height:c.height}}),R&&z!=null&&F(R,{fontSize:z.fontSize}),mn(r,o,n,t))},Gb=(e,t,r,o,n,i,a,s,l)=>{let c=t.reduce((U,oe)=>{let Ie=e.get(oe.id);return Ie&&U.push({orig:Ie,latest:oe}),U},[]),d=c.reduce((U,{orig:oe})=>{if(!ie(oe))return U;let Ie=pn(oe);if(!Ie)return U;let Fe=e.get(Ie)??null;if(!ze(Fe))return U;let lt=K.getBoundTextElementPosition(oe,Fe,r);return[...U,{...Fe,...lt}]},[]),{minX:m,minY:p,maxX:u,maxY:g,midX:h,midY:x}=Qr(c.map(({orig:U})=>U).concat(d)),v=u-m,y=g-p,w=o,C={ne:[m,g],se:[m,p],sw:[u,p],nw:[u,g],e:[m,p+y/2],w:[u,p+y/2],n:[m+v/2,g],s:[m+v/2,p]},[M,I]=n?[h,x]:C[w],P=n?2:1,A=Math.max(Math.abs(a-M)/v||0,Math.abs(s-I)/y||0)*P;if(A===0)return;let N=w.includes("e")||w.includes("w")?Math.abs(a-M)/v*P:1,k=w.includes("n")||w.includes("s")?Math.abs(s-I)/y*P:1,D=i||c.some(U=>U.latest.angle!==0||H(U.latest)||Ln(U.latest));D&&(N=A,k=A);let z={ne:[a<M,s>I],se:[a<M,s<I],sw:[a>M,s<I],nw:[a>M,s>I],e:[a<M,!1],w:[a>M,!1],n:[!1,s>I],s:[!1,s<I]},[R,W]=z[w].map(U=>U?-1:1),q=R<0,re=W<0,ge=[];for(let{orig:U,latest:oe}of c){if(H(U)&&ze(U))continue;let Ie=U.width*N,Fe=U.height*k,lt=Fu(U.angle*R*W),Je=ie(U)||Zt(U),Gr=U.x-M,Wo=U.y-I,nr=q&&!Je?Ie:0,so=re&&!Je?Fe:0,Ri=M+R*(Gr*N+nr),Ca=I+W*(Wo*k+so),Vo=Ad(U,Ie*R,Fe*W,!1),vo={x:Ri,y:Ca,width:Ie,height:Fe,angle:lt,...Vo};if(So(U)&&(vo.scale=[U.scale[0]*R,U.scale[1]*W]),H(U)){let lo=Md(U,r,Ie);if(!lo)return;vo.fontSize=lo.size}let En=e.get(pn(U)??"");if(En)if(D){let lo=En.fontSize*A;if(lo<Tm)return;vo.boundTextFontSize=lo}else vo.boundTextFontSize=En.fontSize;ge.push({element:oe,update:vo})}let le=ge.map(({element:U})=>U);for(let{element:U,update:{boundTextFontSize:oe,...Ie}}of ge){let{angle:Fe}=Ie,{width:lt,height:Je}=U;F(U,Ie,!1),ne(U)&&de(U)&&_o(U,l,U.points,void 0,void 0,{informMutation:!1}),qt(U,r,l,{simultaneouslyUpdated:le,oldSize:{width:lt,height:Je}});let Gr=J(U,r);Gr&&oe&&(F(Gr,{fontSize:oe,angle:ie(U)?void 0:Fe},!1),mn(U,r,o,!0))}er.getScene(ge[0].element)?.triggerUpdate()},bk=(e,t,r,o,n,i,a,s,l)=>{let c=5*Math.PI/2+Math.atan2(n-s,o-a);i&&(c+=wn/2,c-=c%wn),t.filter(d=>!Q(d)).forEach(d=>{let[m,p,u,g]=ae(d,r),h=(m+u)/2,x=(p+g)/2,v=e.get(d.id)?.angle??d.angle,[y,w]=xe(h,x,a,s,c+v-d.angle);if(ne(d)&&de(d)){let M=_v(d,r);_o(d,l,M)}else F(d,{x:d.x+(y-h),y:d.y+(w-x),angle:Fu(c+v)},!1);qt(d,r,l,{simultaneouslyUpdated:t});let C=J(d,r);C&&!ne(d)&&F(C,{x:C.x+(y-h),y:C.y+(w-x),angle:Fu(c+v)},!1)}),er.getScene(t[0])?.triggerUpdate()},Wb=(e,t,r,o,n)=>{let[i,a,s,l]=t.length===1?ae(t[0],r):Te(t),c=(i+s)/2,d=(a+l)/2,m=t.length===1?t[0].angle:0;switch([o,n]=xe(o,n,c,d,-m),e){case"n":return xe(o-(i+s)/2,n-a,0,0,m);case"s":return xe(o-(i+s)/2,n-l,0,0,m);case"w":return xe(o-i,n-(a+l)/2,0,0,m);case"e":return xe(o-s,n-(a+l)/2,0,0,m);case"nw":return xe(o-i,n-a,0,0,m);case"ne":return xe(o-s,n-a,0,0,m);case"sw":return xe(o-i,n-l,0,0,m);case"se":return xe(o-s,n-l,0,0,m);default:return[0,0]}},Vb=(e,t)=>{let[,[r,o]]=t.points;return e==="nw"&&(r<0||o<0)||e==="ne"&&r>=0||e==="sw"&&r<=0||e==="se"&&(r>0||o>0)?"end":"origin"}});var Yb,Ek,h3,Xb,Bu,f3=X(()=>{"use strict";f();yr();dt();De();ms();He();mt();me();V();Y();Yb=(e,t,r,o,n,i)=>{if(t.length===1&&ne(t[0])&&de(t[0])&&(t[0].startBinding||t[0].endBinding))return;let a=t.filter(m=>!(ne(m)&&de(m)&&m.startBinding&&m.endBinding)),s=new Set(a),l=a.filter(m=>Q(m)).map(m=>m.id);if(l.length>0)for(let m of o.getNonDeletedElements())m.frameId!==null&&l.includes(m.frameId)&&s.add(m);let c=Te(Array.from(s).map(m=>e.originalElements.get(m.id)??m)),d=Ek(c,r,n,i);s.forEach(m=>{if(h3(e,m,d),!ne(m)){let p=J(m,o.getNonDeletedElementsMap());p&&h3(e,p,d)}qt(m,o.getElementsMapIncludingDeleted(),o,{simultaneouslyUpdated:Array.from(s)})})},Ek=(e,t,r,o)=>{let[n,i]=e,a=n+t.x+r.x,s=i+t.y+r.y;if(r.x===0||r.y===0){let[l,c]=Ot(n+t.x,i+t.y,o);r.x===0&&(a=l),r.y===0&&(s=c)}return{x:a-n,y:s-i}},h3=(e,t,r)=>{let o=e.originalElements.get(t.id)??t,n=o.x+r.x,i=o.y+r.y;F(t,{x:n,y:i})},Xb=(e,t,r)=>{let[o,n]=Te(e);return[t-o,r-n]},Bu=(e,t,r,o,n,i,a,s,l,c,d,m,p=null)=>{l&&e.type!=="selection"&&(m?s=a/m:(Math.abs(i-o)>Math.abs(n-r)?{width:a,height:s}=Lu(t,s,n<r?-a:a):{width:a,height:s}=Lu(t,a,i<o?-s:s),s<0&&(s=-s)));let u=n<r?r-a:r,g=i<o?o-s:o;c&&(a+=a,s+=s,u=r-a/2,g=o-s/2);let h=null;if(H(e)){s=e.height;let x=Rl(Me({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);a=Math.max(a,x),Math.abs(n-r)>qx/d&&(h={autoResize:!1}),g=o,c&&(u=r-a/2)}a!==0&&s!==0&&F(e,{x:u+(p?.x??0),y:g+(p?.y??0),width:a,height:s,...h})}});var us,b3=X(()=>{"use strict";f();et();us=(e,t)=>!!(!e.viewModeEnabled&&(e.activeTool.type!=="custom"&&(e.editingElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||he(t,e).length))});var xk,Kb,$b,E3,Ae,Sd,x3,Xw,fp,we=X(()=>{"use strict";f();ms();me();Nn();dt();Cd();g3();kd();f3();me();He();ms();b3();xk=e=>e.reduce((t,r)=>t+r.version,0),Kb=e=>{let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e[r].versionNonce;return t>>>0},$b=e=>{let t=5381;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)+t+o}return t>>>0},E3=e=>e.filter(t=>!t.isDeleted&&!Po(t)),Ae=e=>e.filter(t=>!t.isDeleted),Sd=e=>!e.isDeleted,x3=e=>Ae(e).map(t=>Cc(t.type)?{...t,lastCommittedPoint:null}:t),Xw=e=>x3(e),fp=e=>x3(e)});var gs,Sl,Zb,qe,jb,he,Pd,Ge,Ui=X(()=>{"use strict";f();we();me();vr();V();ms();gs=e=>{let t=new Set;return e.forEach(r=>{Q(r)&&t.add(r.id)}),e.filter(r=>!(r.frameId&&t.has(r.frameId)))},Sl=(e,t,r,o=!0)=>{let[n,i,a,s]=ae(t,r),l=e.filter(c=>{let[d,m,p,u]=ho(c,r),g=Qt(c,r);if(g){let[h,x,v,y]=ho(g,r);d=Math.max(h,d),m=Math.max(x,m),p=Math.min(v,p),u=Math.min(y,u)}return c.locked===!1&&c.type!=="selection"&&!ze(c)&&n<=d&&i<=m&&a>=p&&s>=u});return l=o?gs(l):l,l=l.filter(c=>{let d=Qt(c,r);return d?Bn(c,d,r):!0}),l},Zb=(e,t,r,o)=>{let n=new Set(t.map(i=>i.id));return e.filter(i=>{let a=ds(i,r.width,r.height,r,o);return!n.has(i.id)&&a})},qe=function(){let e=null,t=null,r=null,o=(n,i)=>(r!=null&&n===e&&i.selectedElementIds===t||(r=n.some(a=>i.selectedElementIds[a.id]),e=n,t=i.selectedElementIds),r);return o.clearCache=()=>{e=null,t=null,r=null},o}(),jb=(e,t,r)=>{let o=Array.from(new Set(he(e,t).map(n=>r(n))));return o.length===1?o[0]:null},he=(e,t,r)=>{let o=[];for(let n of e.values()){if(t.selectedElementIds[n.id]){o.push(n);continue}if(r?.includeBoundTextElement&&ze(n)&&t.selectedElementIds[n?.containerId]){o.push(n);continue}}if(r?.includeElementsInFrames){let n=[];return o.forEach(i=>{Q(i)&&bo(e,i.id).forEach(a=>n.push(a)),n.push(i)}),n}return o},Pd=(e,t)=>t.editingElement?[t.editingElement]:he(e,t,{includeBoundTextElement:!0}),Ge=(e,t)=>it(t.selectedElementIds,e)?t.selectedElementIds:e});var yk,qb,_n,Jb=X(()=>{"use strict";f();we();V();yk=(e,t)=>{let[r,o,n,i]=t,{x:a,y:s}=$t({sceneX:r,sceneY:o},e),{x:l,y:c}=$t({sceneX:n,sceneY:i},e);return l-a>e.width||c-s>e.height},qb=({scenePoint:e,viewportDimensions:t,zoom:r})=>({scrollX:t.width/2/r.value-e.x,scrollY:t.height/2/r.value-e.y}),_n=(e,t)=>{if(e=E3(e),!e.length)return{scrollX:0,scrollY:0};let[r,o,n,i]=Te(e);yk(t,[r,o,n,i])&&([r,o,n,i]=Ab(e,Qe({clientX:t.scrollX,clientY:t.scrollY},t)));let a=(r+n)/2,s=(o+i)/2;return qb({scenePoint:{x:a,y:s},viewportDimensions:{width:t.width,height:t.height},zoom:t.zoom})}});var Un,Ci,zu=X(()=>{"use strict";f();Y();Un=e=>Math.max(Os,Math.min(e,30)),Ci=({viewportX:e,viewportY:t,nextZoom:r},o)=>{let n=e-o.offsetLeft,i=t-o.offsetTop,a=o.zoom.value,s=o.scrollX+(n-n/a),l=o.scrollY+(i-i/a),c=-(n-n/r),d=-(i-i/r);return{scrollX:s+c,scrollY:l+d,zoom:{value:r}}}});var et=X(()=>{"use strict";f();Ui();Jb();bd();zu()});f();import N9,{useEffect as O9}from"react";f();import{useEffect as u6,useState as g6}from"react";f();f();import Bx from"./en-YNVBSAIL.json";import JA from"./percentages-UCQDHIQF.json";f();import{unstable_createStore as jA,useAtom as V9}from"jotai";import{useLayoutEffect as X9}from"react";var Xe=Symbol(),mr=jA();import{atom as QA,useAtomValue as e6}from"jotai";var qA=Ox({"./locales/ar-SA.json":()=>import("./ar-SA-JA6F2FMJ.json"),"./locales/az-AZ.json":()=>import("./az-AZ-GVIENQVH.json"),"./locales/bg-BG.json":()=>import("./bg-BG-YFNNHCEP.json"),"./locales/bn-BD.json":()=>import("./bn-BD-LMEIWSRD.json"),"./locales/ca-ES.json":()=>import("./ca-ES-C2WGCLOT.json"),"./locales/cs-CZ.json":()=>import("./cs-CZ-F2NDIQMB.json"),"./locales/da-DK.json":()=>import("./da-DK-WBEQB3CJ.json"),"./locales/de-DE.json":()=>import("./de-DE-VEIMCP7R.json"),"./locales/el-GR.json":()=>import("./el-GR-TKRKG5GQ.json"),"./locales/en.json":()=>import("./en-YNVBSAIL.json"),"./locales/es-ES.json":()=>import("./es-ES-TOLWEZNW.json"),"./locales/eu-ES.json":()=>import("./eu-ES-7CDRJQWJ.json"),"./locales/fa-IR.json":()=>import("./fa-IR-527E2XGU.json"),"./locales/fi-FI.json":()=>import("./fi-FI-NLQ7RQGZ.json"),"./locales/fr-FR.json":()=>import("./fr-FR-KUHO4FLU.json"),"./locales/gl-ES.json":()=>import("./gl-ES-NEXX3VBB.json"),"./locales/he-IL.json":()=>import("./he-IL-MED2VGBZ.json"),"./locales/hi-IN.json":()=>import("./hi-IN-5V633W7V.json"),"./locales/hu-HU.json":()=>import("./hu-HU-2FOZGVGR.json"),"./locales/id-ID.json":()=>import("./id-ID-I6BOLXTF.json"),"./locales/it-IT.json":()=>import("./it-IT-WKPQOK4P.json"),"./locales/ja-JP.json":()=>import("./ja-JP-VKA4ISRU.json"),"./locales/kaa.json":()=>import("./kaa-IKPRSBNY.json"),"./locales/kab-KAB.json":()=>import("./kab-KAB-IE4PHQTZ.json"),"./locales/kk-KZ.json":()=>import("./kk-KZ-MNJT6XSV.json"),"./locales/km-KH.json":()=>import("./km-KH-LADGDFXV.json"),"./locales/ko-KR.json":()=>import("./ko-KR-XD7AVF2F.json"),"./locales/ku-TR.json":()=>import("./ku-TR-4XBHKDQA.json"),"./locales/lt-LT.json":()=>import("./lt-LT-QC35R4YH.json"),"./locales/lv-LV.json":()=>import("./lv-LV-GSD5D3BA.json"),"./locales/mr-IN.json":()=>import("./mr-IN-KOLSWM7Y.json"),"./locales/my-MM.json":()=>import("./my-MM-M53KMUET.json"),"./locales/nb-NO.json":()=>import("./nb-NO-XXC6U37A.json"),"./locales/nl-NL.json":()=>import("./nl-NL-HCCJQEUO.json"),"./locales/nn-NO.json":()=>import("./nn-NO-6P7Z2PI2.json"),"./locales/oc-FR.json":()=>import("./oc-FR-JRJKPLNT.json"),"./locales/pa-IN.json":()=>import("./pa-IN-LZWLEPIB.json"),"./locales/percentages.json":()=>import("./percentages-UCQDHIQF.json"),"./locales/pl-PL.json":()=>import("./pl-PL-3WBLCXI2.json"),"./locales/pt-BR.json":()=>import("./pt-BR-O3ZPTUNW.json"),"./locales/pt-PT.json":()=>import("./pt-PT-7AQTSAFO.json"),"./locales/ro-RO.json":()=>import("./ro-RO-HJ65JYWV.json"),"./locales/ru-RU.json":()=>import("./ru-RU-P7ROIYNC.json"),"./locales/si-LK.json":()=>import("./si-LK-7ZSWVION.json"),"./locales/sk-SK.json":()=>import("./sk-SK-NXVBGLYY.json"),"./locales/sl-SI.json":()=>import("./sl-SI-VFTWOYNP.json"),"./locales/sv-SE.json":()=>import("./sv-SE-YONBLQNW.json"),"./locales/ta-IN.json":()=>import("./ta-IN-BSETPMLX.json"),"./locales/th-TH.json":()=>import("./th-TH-URTRDITB.json"),"./locales/tr-TR.json":()=>import("./tr-TR-N5SCAVTB.json"),"./locales/uk-UA.json":()=>import("./uk-UA-LBCYVSQZ.json"),"./locales/vi-VN.json":()=>import("./vi-VN-POZWLIUU.json"),"./locales/zh-CN.json":()=>import("./zh-CN-FUF5V3SC.json"),"./locales/zh-HK.json":()=>import("./zh-HK-OB4VW42C.json"),"./locales/zh-TW.json":()=>import("./zh-TW-5JPVKOM7.json")});var t6=85,yn={code:"en",label:"English"},Ds=[yn,...[{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=>JA[e.code]>=t6).sort((e,t)=>e.label>t.label?1:-1)],gm="__test__";T.DEV&&Ds.unshift({code:gm,label:"test language"},{code:`${gm}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ls=yn,um={},hm=async e=>{if(Ls=e,document.documentElement.dir=Ls.rtl?"rtl":"ltr",document.documentElement.lang=Ls.code,e.code.startsWith(gm))um={};else try{um=await qA(`./locales/${Ls.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),um=Bx}mr.set(zx,e.code)},ei=()=>Ls,Fx=(e,t)=>{for(let r=0;r<t.length;++r){let o=t[r];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},E=(e,t,r)=>{if(Ls.code.startsWith(gm))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),n=Fx(um,o)||Fx(Bx,o)||r;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)n=n.replace(`{{${i}}}`,String(t[i]));return n},zx=QA(yn.code),Dt=()=>{let e=e6(zx,Xe);return{t:E,langCode:e}};import{useState as c6,useEffect as d6}from"react";f();import r6 from"react";import{jsx as Ah}from"react/jsx-runtime";var o6=({size:e="1em",circleWidth:t=8,synchronized:r=!1})=>{let n=-(r6.useRef(Date.now()).current%1600);return Ah("div",{className:"Spinner",children:Ah("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":r?`${n}ms`:0},children:Ah("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},ir=o6;Y();import m6 from"clsx";import{jsx as Nh,jsxs as p6}from"react/jsx-runtime";var Dm=({delay:e,theme:t})=>{let[r,o]=c6(!!e);return d6(()=>{if(!e)return;let n=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(n)},[e]),r?null:p6("div",{className:m6("LoadingMessage",{"LoadingMessage--dark":t===ue.DARK}),children:[Nh("div",{children:Nh(ir,{})}),Nh("div",{className:"LoadingMessage-text",children:E("labels.loadingScene")})]})};import{jsx as h6}from"react/jsx-runtime";var x0=e=>{let[t,r]=g6(!0);return u6(()=>{let o=async()=>{await hm(n),r(!1)},n=Ds.find(i=>i.code===e.langCode)||yn;o()},[e.langCode]),t?h6(Dm,{theme:e.theme}):e.children};f();import Qn,{useContext as Sa}from"react";import{flushSync as ux}from"react-dom";import f9 from"roughjs/bin/rough";import kA from"clsx";import{nanoid as b9}from"nanoid";f();f();et();ye();f();import Qb,{useEffect as wk,useRef as y3,useState as vk}from"react";import w3 from"clsx";Hi();V();import{jsx as Ld,jsxs as Dd}from"react/jsx-runtime";var fe=Qb.forwardRef((e,t)=>{let{id:r}=Ft(),o=Qb.useRef(null);Qb.useImperativeHandle(t,()=>o.current);let n=`ToolIcon_size_${e.size}`,[i,a]=vk(!1),s=y3(!0),l=async d=>{let m="onClick"in e&&e.onClick?.(d);if(Cn(m))try{a(!0),await m}catch(p){if(p instanceof Pn)console.warn(p);else throw p}finally{s.current&&a(!1)}};wk(()=>(s.current=!0,()=>{s.current=!1}),[]);let c=y3(null);if(e.type==="button"||e.type==="icon"||e.type==="submit"){let d=e.type==="icon"?"button":e.type;return Dd("button",{className:w3("ToolIcon_type_button",n,e.className,e.visible&&!e.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!e.hidden,"ToolIcon--selected":e.selected,"ToolIcon--plain":e.type==="icon"}),style:e.style,"data-testid":e["data-testid"],hidden:e.hidden,title:e.title,"aria-label":e["aria-label"],type:d,onClick:l,ref:o,disabled:i||e.isLoading||!!e.disabled,children:[(e.icon||e.label)&&Dd("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!e.disabled,children:[e.icon||e.label,e.keyBindingLabel&&Ld("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel}),e.isLoading&&Ld(ir,{})]}),e.showAriaLabel&&Dd("div",{className:"ToolIcon__label",children:[e["aria-label"]," ",i&&Ld(ir,{})]}),e.children]})}return Dd("label",{className:w3("ToolIcon",e.className),title:e.title,onPointerDown:d=>{c.current=d.pointerType||null,e.onPointerDown?.({pointerType:d.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{c.current=null})},children:[Ld("input",{className:`ToolIcon_type_radio ${n}`,type:"radio",name:e.name,"aria-label":e["aria-label"],"aria-keyshortcuts":e["aria-keyshortcuts"],"data-testid":e["data-testid"],id:`${r}-${e.id}`,onChange:()=>{e.onChange?.({pointerType:c.current})},checked:e.checked,ref:o}),Dd("div",{className:"ToolIcon__icon",children:[e.icon,e.keyBindingLabel&&Ld("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel})]})]})});fe.defaultProps={visible:!0,className:"",size:"medium"};fe.displayName="ToolButton";$e();we();De();Gt();Wt();yr();me();V();ee();Re();kl();import{jsx as Sk}from"react/jsx-runtime";var Tk=(e,t,r)=>{let o=new Set(he(e.filter(n=>Q(n)),t).map(n=>n.id));return{elements:e.map(n=>t.selectedElementIds[n.id]?(n.boundElements&&n.boundElements.forEach(i=>{let a=r.scene.getNonDeletedElementsMap().get(i.id);a&&de(a)&&(F(a,{startBinding:n.id===a.startBinding?.elementId?null:a.startBinding,endBinding:n.id===a.endBinding?.elementId?null:a.endBinding}),_o(a,r.scene,a.points))}),pe(n,{isDeleted:!0})):n.frameId&&o.has(n.frameId)?pe(n,{isDeleted:!0}):ze(n)&&t.selectedElementIds[n.containerId]?pe(n,{isDeleted:!0}):n),appState:{...t,selectedElementIds:{},selectedGroupIds:{}}}},v3=(e,t)=>{if(e.editingGroupId){let r=ot(Ae(t),e.editingGroupId);if(r.length)return{...e,selectedElementIds:{[r[0].id]:!0}}}return e},_d=G({name:"deleteSelectedElements",label:"labels.delete",icon:tn,trackEvent:{category:"element",action:"delete"},perform:(e,t,r,o)=>{if(t.editingLinearElement){let{elementId:a,selectedPointsIndices:s,startBindingElement:l,endBindingElement:c}=t.editingLinearElement,d=o.scene.getNonDeletedElementsMap(),m=K.getElement(a,d);if(!m||s==null)return!1;if(m.points.length<2){let u=e.map(h=>h.id===m.id?pe(h,{isDeleted:!0}):h),g=v3(t,u);return{elements:u,appState:{...g,editingLinearElement:null},storeAction:_.CAPTURE}}let p={startBindingElement:s?.includes(0)?null:l,endBindingElement:s?.includes(m.points.length-1)?null:c};return K.deletePoints(m,s,o.scene),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...p,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},storeAction:_.CAPTURE}}let{elements:n,appState:i}=Tk(e,t,o);return Vp(n,e.filter(({id:a})=>t.selectedElementIds[a])),i=v3(i,n),{elements:n,appState:{...i,activeTool:nt(t,{type:"selection"}),multiElement:null,activeEmbeddable:null},storeAction:qe(Ae(e),t)?_.CAPTURE:_.NONE}},keyTest:(e,t,r)=>(e.key===S.BACKSPACE||e.key===S.DELETE)&&!e[S.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:r})=>Sk(fe,{type:"button",icon:tn,title:E("labels.delete"),"aria-label":E("labels.delete"),onClick:()=>r(null),visible:qe(Ae(e),t)})});f();f();me();ko();Gt();et();cs();V();var eE=(e,t)=>e.frameId===t||e.id===t,S3=(e,t,r)=>{let o=[],n=[],i=null,a=-1,s=Z(r||he(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let l=e[a];s.get(l.id)?(n.length&&(o=o.concat(n),n=[]),o.push(a),i=a+1):l.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return o},Ik=e=>{let t=0;return e.reduce((r,o,n)=>(n>0&&e[n-1]!==o-1&&(t=++t),(r[t]||(r[t]=[])).push(o),r),[])},T3=(e,t,r)=>{if("containerId"in e&&e.containerId)if(r==="left"){let o=er.getScene(e).getElement(e.containerId);if(o)return t.indexOf(o)}else return t.indexOf(e);else{let o=e.boundElements?.find(n=>n.type!=="arrow")?.id;if(o){if(r==="left")return t.indexOf(e);let n=er.getScene(e).getElement(o);if(n)return t.indexOf(n)}}},Ck=(e,t)=>{let r=-1,o=-1;return e.forEach((n,i)=>{eE(n,t)&&(r===-1&&(r=i),o=i)}),r===-1?[]:e.slice(r,o+1)},Ak=(e,t,r,o,n)=>{let i=t[r],a=m=>m.isDeleted?!1:n?m.frameId===n:e.editingGroupId?m.groupIds.includes(e.editingGroupId):!0,s=o==="left"?zh(t,m=>a(m),Math.max(0,r-1)):Bh(t,m=>a(m),r+1),l=t[s];if(!l)return-1;if(e.editingGroupId){if(i?.groupIds.join("")===l?.groupIds.join(""))return T3(l,t,o)??s;if(!l?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(l.frameId||Q(l))){let m=Ck(t,l.frameId||l.id);return o==="left"?t.indexOf(m[0]):t.indexOf(m[m.length-1])}if(!l.groupIds.length)return T3(l,t,o)??s;let c=e.editingGroupId?l.groupIds[l.groupIds.indexOf(e.editingGroupId)-1]:l.groupIds[l.groupIds.length-1],d=ot(t,c);return d.length?o==="left"?t.indexOf(d[0]):t.indexOf(d[d.length-1]):s},I3=(e,t)=>t.reduce((r,o)=>{let n=e[o];return r.set(n.id,n),r},new Map),C3=(e,t,r)=>{let o=S3(e,t),n=I3(e,o),i=Ik(o);r==="right"&&(i=i.reverse());let a=new Set(o.filter(s=>Q(e[s])).map(s=>e[s].id));return i.forEach((s,l)=>{let c=s[0],d=s[s.length-1],m=r==="left"?c:d,p=s.some(y=>{let w=e[y];return w.frameId&&a.has(w.frameId)})?null:e[m]?.frameId,u=Ak(t,e,m,r,p);if(u===-1||m===u)return;let g=r==="left"?e.slice(0,u):e.slice(0,c),h=e.slice(c,d+1),x=r==="left"?e.slice(u,c):e.slice(d+1,u+1),v=r==="left"?e.slice(d+1):e.slice(u+1);e=r==="left"?[...g,...h,...x,...v]:[...g,...x,...h,...v]}),Jt(e,n),e},A3=(e,t,r,o,n)=>{let i=S3(e,t,n),a=I3(e,i),s=[],l,c;if(r==="left"){if(o)l=Bh(e,g=>eE(g,o));else if(t.editingGroupId){let g=ot(e,t.editingGroupId);if(!g.length)return e;l=e.indexOf(g[0])}else l=0;c=i[i.length-1]}else{if(o)c=zh(e,g=>eE(g,o));else if(t.editingGroupId){let g=ot(e,t.editingGroupId);if(!g.length)return e;c=e.indexOf(g[g.length-1])}else c=e.length-1;l=i[0]}l===-1&&(l=0);for(let g=l;g<c+1;g++)i.includes(g)||s.push(e[g]);let d=Array.from(a.values()),m=e.slice(0,l),p=e.slice(c+1),u=r==="left"?[...m,...d,...s,...p]:[...m,...s,...d,...p];return Jt(u,a),u};function M3(e,t,r,o){let n=Z(he(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&Q(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(Q(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let d=i.frameChildren.get(c.frameId)||[];d.push(c),i.frameChildren.set(c.frameId,d)}let s=e,l=Array.from(i.frameChildren.entries());for(let[c,d]of l)s=o(e,t,r,c,d);return o(s,t,r,null,i.regularElements)}var k3=(e,t)=>C3(e,t,"left"),P3=(e,t)=>C3(e,t,"right"),L3=(e,t)=>M3(e,t,"left",A3),D3=(e,t)=>M3(e,t,"right",A3);ye();V();$e();ee();Y();Re();import{jsx as Hu}from"react/jsx-runtime";var tE=G({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Qh,trackEvent:{category:"element"},perform:(e,t)=>({elements:k3(e,t),appState:t,storeAction:_.CAPTURE}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Se.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Hu("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${E("labels.sendBackward")} \u2014 ${O("CtrlOrCmd+[")}`,children:Qh})}),rE=G({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Jh,trackEvent:{category:"element"},perform:(e,t)=>({elements:P3(e,t),appState:t,storeAction:_.CAPTURE}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Se.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Hu("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${E("labels.bringForward")} \u2014 ${O("CtrlOrCmd+]")}`,children:Jh})}),oE=G({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:tf,trackEvent:{category:"element"},perform:(e,t)=>({elements:L3(e,t),appState:t,storeAction:_.CAPTURE}),keyTest:e=>Cr?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.BRACKET_LEFT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===Se.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Hu("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${E("labels.sendToBack")} \u2014 ${Cr?O("CtrlOrCmd+Alt+["):O("CtrlOrCmd+Shift+[")}`,children:tf})}),nE=G({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:ef,trackEvent:{category:"element"},perform:(e,t)=>({elements:D3(e,t),appState:t,storeAction:_.CAPTURE}),keyTest:e=>Cr?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.BRACKET_RIGHT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===Se.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Hu("button",{type:"button",className:"zIndexButton",onClick:r=>e(null),title:`${E("labels.bringToFront")} \u2014 ${Cr?O("CtrlOrCmd+Alt+]"):O("CtrlOrCmd+Shift+]")}`,children:ef})});f();ye();$e();Gt();we();me();Wt();Ui();ee();Re();var iE=G({name:"selectAll",label:"labels.selectAll",icon:Cw,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,r,o)=>{if(t.editingLinearElement)return!1;let n=gs(e.filter(i=>!i.isDeleted&&!(H(i)&&i.containerId)&&!i.locked)).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...t,...cr({editingGroupId:null,selectedElementIds:n},Ae(e),t,o),selectedLinearElement:Object.keys(n).length===1&&ie(e[0])?new K(e[0]):null},storeAction:_.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.A});f();ye();$e();we();et();V();Wt();Gt();yr();Y();He();me();f();V();var Mk=e=>{let t=e.slice(),r=new Set,o=i=>{let a=i[0]?.groupIds?.join(""),s=[i[0]],l=[];for(let c of i.slice(1))c.groupIds?.join("")===a?s.push(c):l.push(c);return l.length?[...s,...o(l)]:s},n=new Map;return t.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let s=i.groupIds[i.groupIds.length-1],l=t.slice(a).filter(c=>{let d=c?.groupIds?.some(m=>m===s);return d&&n.set(c.id,!0),d});for(let c of o(l))r.add(c)}else r.add(i)}),r.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...r]},kk=e=>{let t=L0(e),r=e.slice(),o=new Set;return r.forEach((n,i)=>{n&&(n.boundElements?.length?(o.add(n),r[i]=null,n.boundElements.forEach(a=>{let s=t.get(a.id);s&&a.type==="text"&&(o.add(s[0]),r[s[1]]=null)})):n.type==="text"&&n.containerId&&t.get(n.containerId)?.[0].boundElements?.find(s=>s.id===n.id)||(o.add(n),r[i]=null))}),o.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...o]},_3=e=>kk(Mk(e));ee();vr();Ui();ko();Re();import{jsx as Lk}from"react/jsx-runtime";var aE=G({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Mc,trackEvent:{category:"element"},perform:(e,t,r,o)=>{if(t.editingLinearElement){let n=K.duplicateSelectedPoints(t,o.scene);return n?{elements:e,appState:n.appState,storeAction:_.CAPTURE}:!1}return{...Pk(e,t),storeAction:_.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.D,PanelComponent:({elements:e,appState:t,updateData:r})=>Lk(fe,{type:"button",icon:Mc,title:`${E("labels.duplicateSelection")} \u2014 ${O("CtrlOrCmd+D")}`,"aria-label":E("labels.duplicateSelection"),onClick:()=>r(null),visible:qe(Ae(e),t)})}),Pk=(e,t)=>{let r=_3(e),o=new Map,n=[],i=[],a=new Map,s=new Map,l=y=>{let w=Vc(t.editingGroupId,o,y,{x:y.x+ni/2,y:y.y+ni/2});return s.set(w.id,w),a.set(y.id,w.id),i.push(y),n.push(w),w},c=Z(he(r,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),d=new Map,m=y=>{for(let w of y)d.set(w.id,!0);return y},p=[],u=-1;for(;++u<r.length;){let y=r[u];if(d.get(y.id))continue;let w=J(y,Z(e)),C=Q(y);if(c.get(y.id)){if(y.groupIds.length||w||C){let M=Vh(t,y);if(M){let I=ot(r,M).flatMap(P=>Q(P)?[...bo(e,P.id),P]:[P]);p.push(...m([...I,...I.map(P=>l(P))]));continue}if(w){p.push(...m([y,w,l(y),l(w)]));continue}if(C){let I=bo(r,y.id);p.push(...m([...I,y,...I.map(P=>l(P)),l(y)]));continue}}(!y.frameId||!c.has(y.frameId))&&p.push(...m([y,l(y)]))}else p.push(...m([y]))}let g=[],h=new Map;for(u=p.length;--u>=0;){let y=p[u];h.get(y.id)||(h.set(y.id,!0),g.push(y))}let x=Jt(g.reverse(),Z(n));Mu(p,i,a),Wp(p,i,a),fu(x,i,a);let v=gs(n);return{elements:x,appState:{...t,...cr({editingGroupId:t.editingGroupId,selectedElementIds:v.reduce((y,w)=>(ze(w)||(y[w.id]=!0),y),{})},Ae(x),t,null)}}};f();pr();import{useEffect as SE,useMemo as lL,useRef as IE,useState as cL}from"react";f();var Dk=new Set(["command_palette"]),Ce=(e,t,r,o)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!Dk.has(e)||T.DEV)return;T.PROD||console.info("trackEvent",{category:e,action:t,label:r,value:o}),window.sa_event&&window.sa_event(t,{category:e,label:r,value:o})}catch(n){console.error("error during analytics",n)}};f();import Ok from"clsx";f();import{forwardRef as _k}from"react";import Rk from"clsx";import{jsx as Nk}from"react/jsx-runtime";var Uu=_k((e,t)=>{let{title:r,className:o,testId:n,active:i,standalone:a,icon:s,onClick:l}=e;return Nk("button",{type:"button",ref:t,title:r,"data-testid":n,className:Rk(o,{standalone:a,active:i}),onClick:l,children:s},r)});import{jsx as sE,jsxs as Fk}from"react/jsx-runtime";var Ro=e=>sE("div",{className:"buttonList",children:e.options.map(t=>e.type==="button"?sE(Uu,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:r=>e.onClick(t.value,r)},t.text):Fk("label",{className:Ok({active:e.value===t.value}),title:t.text,children:[sE("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});f();V();f();pr();import Bk from"clsx";import{jsx as lE}from"react/jsx-runtime";var R3=({onChange:e,type:t,activeColor:r,topPicks:o})=>{let n;return t==="elementStroke"&&(n=fm),t==="elementBackground"&&(n=bm),t==="canvasBackground"&&(n=Em),o&&(n=o),n?lE("div",{className:"color-picker__top-picks",children:n.map(i=>lE("button",{className:Bk("color-picker__button",{active:i===r,"is-transparent":i==="transparent"||!i}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:lE("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};f();import{jsx as zk}from"react/jsx-runtime";var Gu=()=>zk("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});f();import W3,{useEffect as V3,useState as sP}from"react";f();import Wk from"clsx";import{useAtom as Vk}from"jotai";import{useEffect as Yk,useRef as Xk}from"react";f();pr();import{atom as Hk}from"jotai";var la=({palette:e,color:t})=>{for(let[r,o]of Object.entries(e))if(Array.isArray(o)){let n=o.indexOf(t);if(n>-1)return{colorName:r,shade:n}}else if(o===t)return{colorName:r,shade:null};return null},Rd=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),cE=({color:e,palette:t})=>!Object.values(t).flat().includes(e),O3=(e,t,r)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[t]];return cE({color:s,palette:r})}),i=new Map;return n.forEach(a=>{let s=a[o[t]];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,Ux)},No=Hk(null),N3=(e,t,r)=>(e*299+t*587+r*114)/1e3>=160?"black":"white",F3=(e,t)=>{if(t){let i=new Option().style;if(i.color=e,i.color){let a=i.color.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(a[0]),l=parseInt(a[1]),c=parseInt(a[2]);return N3(s,l,c)}}if(e==="transparent")return"black";let r=parseInt(e.substring(1,3),16),o=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return N3(r,o,n)};f();import{jsxs as Gk}from"react/jsx-runtime";var Uk=({color:e,keyLabel:t,isCustomColor:r=!1,isShade:o=!1})=>Gk("div",{className:"color-picker__button__hotkey-label",style:{color:F3(e,r)},children:[o&&"\u21E7",t]}),Ol=Uk;import{jsx as Nd,jsxs as B3}from"react/jsx-runtime";var z3=({hex:e,onChange:t,palette:r})=>{let o=la({color:e||"transparent",palette:r}),[n,i]=Vk(No),a=Xk(null);if(Yk(()=>{a.current&&n==="shades"&&a.current.focus()},[o,n]),o){let{colorName:s,shade:l}=o,c=r[s];if(Array.isArray(c))return Nd("div",{className:"color-picker-content--default shades",children:c.map((d,m)=>B3("button",{ref:m===l&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:Wk("color-picker__button color-picker__button--large",{active:m===l}),"aria-label":"Shade",title:`${s} - ${m+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{t(d),i("shades")},children:[Nd("div",{className:"color-picker__button-outline"}),Nd(Ol,{color:d,keyLabel:m+1,isShade:!0})]},m))})}return B3("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Nd("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Nd("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:E("colorPicker.noShades")})]})};f();import Kk from"clsx";import{useAtom as $k}from"jotai";import{useEffect as Zk,useRef as jk}from"react";import{jsx as dE,jsxs as Jk}from"react/jsx-runtime";var qk=({palette:e,color:t,onChange:r,label:o,activeShade:n})=>{let i=la({color:t||"transparent",palette:e}),[a,s]=$k(No),l=jk(null);return Zk(()=>{l.current&&a==="baseColors"&&l.current.focus()},[i?.colorName,a]),dE("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,d],m)=>{let p=(Array.isArray(d)?d[n]:d)||"transparent",u=Rd[m],g=E(`colors.${c.replace(/\d+/,"")}`,null,"");return Jk("button",{ref:i?.colorName===c?l:void 0,tabIndex:-1,type:"button",className:Kk("color-picker__button color-picker__button--large",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{r(p),s("baseColors")},title:`${g}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${g} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[dE("div",{className:"color-picker__button-outline"}),dE(Ol,{color:p,keyLabel:u})]},c)})})},H3=qk;import{useAtom as lP}from"jotai";f();import Qk from"clsx";import{useAtom as eP}from"jotai";import{useEffect as tP,useRef as rP}from"react";import{jsx as mE,jsxs as oP}from"react/jsx-runtime";var U3=({colors:e,color:t,onChange:r,label:o})=>{let[n,i]=eP(No),a=rP(null);return tP(()=>{a.current&&a.current.focus()},[t,n]),mE("div",{className:"color-picker-content--default",children:e.map((s,l)=>oP("button",{ref:t===s?a:void 0,tabIndex:-1,type:"button",className:Qk("color-picker__button color-picker__button--large",{active:t===s,"is-transparent":s==="transparent"||!s}),onClick:()=>{r(s),i("custom")},title:s,"aria-label":o,style:{"--swatch-color":s},children:[mE("div",{className:"color-picker__button-outline"}),mE(Ol,{color:s,keyLabel:l+1,isCustomColor:!0})]},l))})};f();ye();pr();var pE=(e,t,r)=>{let o=Math.ceil(r/Ma);switch(t=t??-1,e){case"ArrowLeft":{let n=t-1;return n<0?r-1:n}case"ArrowRight":return(t+1)%r;case"ArrowDown":{let n=t+Ma;return n>=r?t%Ma:n}case"ArrowUp":{let n=t-Ma,i=n<0?Ma*o+n:n;return i>=r?void 0:i}}},nP=({e,colorObj:t,onChange:r,palette:o,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let s=Number(e.code.slice(-1))-1;return r(o[t.colorName][s]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return r(n[Number(e.key)-1]),i("custom"),!0;if(Rd.includes(e.key)){let s=Rd.indexOf(e.key),l=Object.keys(o)[s],c=o[l],d=Array.isArray(c)?c[a]:c;return r(d),i("baseColors"),!0}return!1},G3=({event:e,activeColorPickerSection:t,palette:r,color:o,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d})=>{if(e[S.CTRL_OR_CMD])return!1;if(e.key===S.ESCAPE)return d(e),!0;if(e.key===S.ALT)return c(!0),!0;if(e.key===S.I)return c(),!0;let m=la({color:o,palette:r});if(e.key===S.TAB){let p={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},u=Object.entries(p).reduce((y,[w,C])=>(C&&y.push(w),y),[]),g=u.indexOf(t),h=e.shiftKey?-1:1,x=g+h>u.length-1?0:g+h<0?u.length-1:g+h,v=u[x];return v&&a(v),v==="custom"?n(i[0]):v==="baseColors"&&(Object.entries(r).find(([w,C])=>Array.isArray(C)?C.includes(o):C===o?w:null)||n(Ee.black)),e.preventDefault(),e.stopPropagation(),!0}if(nP({e,colorObj:m,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:l}))return!0;if(t==="shades"&&m){let{shade:p}=m,u=pE(e.key,p,Ma);if(u!==void 0)return n(r[m.colorName][u]),!0}if(t==="baseColors"&&m){let{colorName:p}=m,u=Object.keys(r),g=u.indexOf(p),h=pE(e.key,g,u.length);if(h!==void 0){let x=u[h],v=r[x];return n(Array.isArray(v)?v[l]:v),!0}}if(t==="custom"){let p=i.indexOf(o),u=pE(e.key,p,i.length);if(u!==void 0){let g=i[u];return n(g),!0}}return!1};f();import{jsx as aP}from"react/jsx-runtime";var iP=({children:e})=>aP("div",{className:"color-picker__heading",children:e}),Fl=iP;pr();ye();Y();import{jsx as hs,jsxs as Wu}from"react/jsx-runtime";var Y3=({color:e,onChange:t,label:r,type:o,elements:n,palette:i,updateData:a,children:s,onEyeDropperToggle:l,onEscape:c})=>{let[d]=W3.useState(()=>o==="canvasBackground"?[]:O3(n,o,i)),[m,p]=lP(No),u=la({color:e,palette:i});V3(()=>{if(!m){let v=cE({color:e,palette:i}),y=v&&!d.includes(e);p(y?"hex":v?"custom":u?.shade!=null?"shades":"baseColors")}},[m,e,i,p,u,d]);let[g,h]=sP(u?.shade??(o==="elementBackground"?Rs:_s));V3(()=>{u?.shade!=null&&h(u.shade);let v=y=>{y.key===S.ALT&&l(!1)};return document.addEventListener("keyup",v,{capture:!0}),()=>{document.removeEventListener("keyup",v,{capture:!0})}},[u,l]);let x=W3.useRef(null);return hs("div",{role:"dialog","aria-modal":"true","aria-label":E("labels.colorPicker"),children:Wu("div",{ref:x,onKeyDown:v=>{G3({event:v,activeColorPickerSection:m,palette:i,color:e,onChange:t,onEyeDropperToggle:l,customColors:d,setActiveColorPickerSection:p,updateData:a,activeShade:g,onEscape:c})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!d.length&&Wu("div",{children:[hs(Fl,{children:E("colorPicker.mostUsedCustomColors")}),hs(U3,{colors:d,color:e,label:E("colorPicker.mostUsedCustomColors"),onChange:t})]}),Wu("div",{children:[hs(Fl,{children:E("colorPicker.colors")}),hs(H3,{color:e,label:r,palette:i,onChange:t,activeShade:g})]}),Wu("div",{children:[hs(Fl,{children:E("colorPicker.shades")}),hs(z3,{hex:e,onChange:t,palette:i})]}),s]})})};import*as Ku from"@radix-ui/react-popover";import{useAtom as eS}from"jotai";pr();import AP from"clsx";import{useRef as MP}from"react";f();import{useCallback as bP,useEffect as gE,useRef as Z3,useState as EP}from"react";import{useAtom as j3}from"jotai";ee();ye();f();pr();Y();import{atom as pP}from"jotai";import{useEffect as uP,useRef as gP}from"react";import{createPortal as hP}from"react-dom";f();import X3 from"react";var uE=X3.createContext(null),Ue=()=>X3.useContext(uE);f();import{useState as cP,useLayoutEffect as K3}from"react";Y();var Vu=e=>{let[t,r]=cP(null),o=Ne(),{theme:n}=Ue(),{container:i}=Ft();return K3(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",o.editor.isMobile),t.classList.toggle("theme--dark",n===ue.DARK))},[t,n,o.editor.isMobile,e?.className]),K3(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),r(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),t};f();Y();import{useEffect as dP}from"react";function Bl(e,t,r){dP(()=>{function o(n){let i=n;if(!e.current)return;let a=r?.(i,e.current);if(a===!0)return;if(a===!1)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||t(i)}return document.addEventListener("pointerdown",o),document.addEventListener("touchstart",o),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("touchstart",o)}},[e,t,r])}ye();et();f();import{useRef as mP}from"react";var zl=e=>{let t=mP(e);return Object.assign(t.current,e),t.current};import{jsx as fP}from"react/jsx-runtime";var ca=pP(null),$3=({onCancel:e,onChange:t,onSelect:r,colorPickerType:o})=>{let n=Vu({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Ue(),a=da(),s=tr(),l=he(a,i),c=zl({app:s,onCancel:e,onChange:t,onSelect:r,selectedElements:l}),{container:d}=Ft();uP(()=>{let p=m.current;if(!p||!s.canvas||!n)return;let u=!1,g=s.canvas.getContext("2d"),h=({clientX:I,clientY:P})=>{let A=g.getImageData((I-i.offsetLeft)*window.devicePixelRatio,(P-i.offsetTop)*window.devicePixelRatio,1,1).data;return Kx(A[0],A[1],A[2])},x=({clientX:I,clientY:P,altKey:A})=>{p.style.top=`${P+20}px`,p.style.left=`${I+20}px`;let N=h({clientX:I,clientY:P});u&&c.onChange(o,N,c.selectedElements,{altKey:A}),p.style.background=N},v=()=>{c.onCancel()},y=(I,P)=>{c.onSelect(I,P)},w=I=>{u=!0,I.stopImmediatePropagation()},C=I=>{u=!1,d?.focus(),I.stopImmediatePropagation(),I.preventDefault(),y(h(I),I)},M=I=>{I.key===S.ESCAPE&&(I.preventDefault(),I.stopImmediatePropagation(),v())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",M),n.addEventListener("pointerdown",w),n.addEventListener("pointerup",C),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",v),()=>{u=!1,n.removeEventListener("keydown",M),n.removeEventListener("pointerdown",w),n.removeEventListener("pointerup",C),window.removeEventListener("pointermove",x),window.removeEventListener("blur",v)}},[c,s.canvas,n,o,d,i.offsetLeft,i.offsetTop]);let m=gP(null);return Bl(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?hP(fP("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),n):null};import xP from"clsx";V();import{Fragment as yP,jsx as Yu,jsxs as q3}from"react/jsx-runtime";var J3=({color:e,onChange:t,label:r,colorPickerType:o})=>{let n=Ne(),[i,a]=EP(e),[s,l]=j3(No);gE(()=>{a(e)},[e]);let c=bP(g=>{let h=g.toLowerCase(),x=Q3(h);x&&t(x),a(h)},[t]),d=Z3(null),m=Z3(null);gE(()=>{d.current&&d.current.focus()},[s]);let[p,u]=j3(ca,Xe);return gE(()=>()=>{u(null)},[u]),q3("div",{className:"color-picker__input-label",children:[Yu("div",{className:"color-picker__input-hash",children:"#"}),Yu("input",{ref:s==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":r,onChange:g=>{c(g.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>l("hex"),onKeyDown:g=>{g.key!==S.TAB&&(g.key===S.ESCAPE&&m.current?.focus(),g.stopPropagation())}}),!n.editor.isMobile&&q3(yP,{children:[Yu("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Yu("div",{ref:m,className:xP("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(g=>g?null:{keepOpenOnAlt:!1,onSelect:h=>t(h),colorPickerType:o}),title:`${E("labels.eyeDropper")} \u2014 ${S.I.toLocaleUpperCase()} or ${O("Alt")} `,children:bw})]})]})};f();import SP from"react";import IP from"clsx";import*as Hl from"@radix-ui/react-popover";f();import wP from"react";import vP from"clsx";import{jsx as TP}from"react/jsx-runtime";var Yt=wP.forwardRef(({children:e,padding:t,className:r,style:o},n)=>TP("div",{className:vP("Island",r),style:{"--padding":t,...o},ref:n,children:e}));V();import{jsx as hE,jsxs as CP}from"react/jsx-runtime";var Xu=SP.forwardRef(({className:e,container:t,children:r,style:o,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l},c)=>{let d=Ne();return hE(Hl.Portal,{container:t,children:CP(Hl.Content,{ref:c,className:IP("focus-visible-none",e),"data-prevent-outside-click":!0,side:d.editor.isMobile&&!d.viewport.isLandscape?"bottom":"right",align:d.editor.isMobile&&!d.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onCloseAutoFocus:m=>{m.stopPropagation(),m.preventDefault(),t&&!S0(document.activeElement)&&t.focus(),n()},children:[hE(Yt,{padding:3,style:o,children:r}),hE(Hl.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{jsx as hn,jsxs as fE}from"react/jsx-runtime";var tS=e=>{let t=new Option().style;return t.color=e,!!t.color},Q3=e=>Ar(e)?e:tS(`#${e}`)?`#${e}`:tS(e)?e:null,kP=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=Ee,updateData:a})=>{let{container:s}=Ft(),[,l]=eS(No),[c,d]=eS(ca,Xe),m=fE("div",{children:[hn(Fl,{children:E("colorPicker.hexCode")}),hn(J3,{color:t,label:o,onChange:g=>{r(g)},colorPickerType:e})]}),p=MP(null),u=()=>{p.current?.querySelector(".color-picker-content")?.focus()};return hn(Xu,{container:s,style:{maxWidth:"208px"},onFocusOutside:g=>{u(),g.preventDefault()},onPointerDownOutside:g=>{c&&g.preventDefault()},onClose:()=>{a({openPopup:null}),l(null)},children:i?hn(Y3,{palette:i,color:t,onChange:g=>{r(g)},onEyeDropperToggle:g=>{d(h=>g?(h=h||{keepOpenOnAlt:!0,onSelect:r,colorPickerType:e},h.keepOpenOnAlt=!0,h):g===!1||h?null:{keepOpenOnAlt:!1,onSelect:r,colorPickerType:e})},onEscape:g=>{c?d(null):a({openPopup:null})},label:o,type:e,elements:n,updateData:a,children:m}):m})},PP=({label:e,color:t,type:r})=>hn(Ku.Trigger,{type:"button",className:AP("color-picker__button active-color properties-trigger",{"is-transparent":t==="transparent"||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:r==="elementStroke"?E("labels.showStroke"):E("labels.showBackground"),children:hn("div",{className:"color-picker__button-outline"})}),Od=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=Ee,topPicks:a,updateData:s,appState:l})=>hn("div",{children:fE("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[hn(R3,{activeColor:t,onChange:r,type:e,topPicks:a}),hn(Gu,{}),fE(Ku.Root,{open:l.openPopup===e,onOpenChange:c=>{s({openPopup:c?e:null})},children:[hn(PP,{color:t,label:o,type:e}),l.openPopup===e&&hn(kP,{type:e,color:t,onChange:r,label:o,elements:n,palette:i,updateData:s})]})]})});f();import fs from"react";f();import{useLayoutEffect as LP,useRef as rS,useEffect as oS}from"react";V();ye();import{unstable_batchedUpdates as DP}from"react-dom";import{jsx as _P}from"react/jsx-runtime";var $u=({children:e,left:t,top:r,onCloseRequest:o,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:s=window.innerWidth,viewportHeight:l=window.innerHeight})=>{let c=rS(null);oS(()=>{let m=c.current;if(!m)return;m.contains(document.activeElement)||m.focus();let p=u=>{if(u.key===S.TAB){let g=Tc(m),{activeElement:h}=document,x=g.findIndex(v=>v===h);h===m?(u.shiftKey?g[g.length-1]?.focus():g[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(g[g.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===g.length-1&&!u.shiftKey&&(g[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return m.addEventListener("keydown",p),()=>m.removeEventListener("keydown",p)},[]);let d=rS(null);return LP(()=>{if(n&&c.current&&r!=null&&t!=null){let m=c.current,{width:p,height:u}=m.getBoundingClientRect();if(d.current?.top===r&&d.current?.left===t)return;d.current={top:r,left:t},p>=s?(m.style.width=`${s}px`,m.style.left="0px",m.style.overflowX="scroll"):t+p-i>s?m.style.left=`${s-p-10}px`:m.style.left=`${t}px`,u>=l?(m.style.height=`${l-20}px`,m.style.top="10px",m.style.overflowY="scroll"):r+u-a>l?m.style.top=`${l-u}px`:m.style.top=`${r}px`}},[r,t,n,s,l,i,a]),oS(()=>{if(o){let m=p=>{c.current?.contains(p.target)||DP(()=>o(p))};return document.addEventListener("pointerdown",m,!1),()=>document.removeEventListener("pointerdown",m,!1)}},[o]),_P("div",{className:"popover",ref:c,tabIndex:-1,children:e})};ye();import RP from"clsx";import{Fragment as OP,jsx as ma,jsxs as bE}from"react/jsx-runtime";function NP({options:e,value:t,label:r,onChange:o,onClose:n}){let i=fs.useRef(),a=fs.useRef(),s=fs.useRef(null);return fs.useEffect(()=>{a.current?a.current.focus():s.current&&s.current.focus()},[]),ma("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":r,onKeyDown:c=>{let d=e.find(m=>m.keyBinding===c.key.toLowerCase());if(!(c.metaKey||c.altKey||c.ctrlKey)&&d){let m=e.indexOf(d);s.current.children[m].focus(),c.preventDefault()}else if(c.key===S.TAB)setTimeout(()=>{let m=a.current,p=document.activeElement;m!==p&&n()},0);else if(ll(c.key)){let{activeElement:m}=document,p=ei().rtl,u=Array.prototype.indexOf.call(s.current.children,m);if(u!==-1){let g=e.length,h=u;switch(c.key){case(p?S.ARROW_LEFT:S.ARROW_RIGHT):case S.ARROW_DOWN:{h=(u+1)%g;break}case(p?S.ARROW_RIGHT:S.ARROW_LEFT):case S.ARROW_UP:{h=(g+u-1)%g;break}}s.current.children[h].focus()}c.preventDefault()}else(c.key===S.ESCAPE||c.key===S.ENTER)&&(c.preventDefault(),n());c.nativeEvent.stopImmediatePropagation(),c.stopPropagation()},children:ma("div",{className:"picker-content",ref:s,children:e.map((c,d)=>bE("button",{type:"button",className:RP("picker-option",{active:t===c.value}),onClick:m=>{m.currentTarget.focus(),o(c.value)},title:`${c.text} ${c.keyBinding&&`\u2014 ${c.keyBinding.toUpperCase()}`}`,"aria-label":c.text||"none","aria-keyshortcuts":c.keyBinding||void 0,ref:m=>{m&&d===0&&(i.current=m),m&&c.value===t&&(a.current=m)},onFocus:()=>{o(c.value)},children:[c.icon,c.keyBinding&&ma("span",{className:"picker-keybinding",children:c.keyBinding})]},c.text))})})}function EE({value:e,label:t,options:r,onChange:o,group:n=""}){let[i,a]=fs.useState(!1),s=fs.useRef(null),l=ei().rtl;return bE("div",{children:[ma("button",{name:n,type:"button",className:i?"active":"","aria-label":t,onClick:()=>a(!i),ref:s,children:r.find(c=>c.value===e)?.icon}),ma(fs.Suspense,{fallback:"",children:i?bE(OP,{children:[ma($u,{onCloseRequest:c=>c.target!==s.current&&a(!1),...l?{right:5.5}:{left:-5.5},children:ma(NP,{options:r.filter(c=>c.showInPicker!==!1),value:e,label:t,onChange:o,onClose:()=>{a(!1),s.current?.focus()}})}),ma("div",{className:"picker-triangle"})]}):null})]})}f();import nL,{useCallback as iL,useMemo as aL}from"react";import*as uS from"@radix-ui/react-popover";f();import JP,{useMemo as pa,useState as QP,useRef as eL,useEffect as tL,useCallback as rL}from"react";f();ee();import FP from"clsx";import BP from"react";import{jsx as zP,jsxs as HP}from"react/jsx-runtime";var Zu=BP.forwardRef(({className:e,placeholder:t,onChange:r},o)=>HP("div",{className:FP("QuickSearch__wrapper",e),children:[dp,zP("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:t,onChange:n=>r(n.target.value.trim().toLowerCase())})]}));f();import UP from"clsx";import{Children as GP}from"react";import{jsx as nS}from"react/jsx-runtime";var ju=({className:e,placeholder:t,children:r})=>{let o=!GP.count(r);return nS("div",{className:UP("ScrollableList__wrapper",e),role:"menu",children:o?nS("div",{className:"empty",children:t}):r})};f();import{jsx as WP,jsxs as VP}from"react/jsx-runtime";var iS=({children:e,className:t="",style:r,title:o})=>VP("div",{className:`dropdown-menu-group ${t}`,style:r,children:[o&&WP("p",{className:"dropdown-menu-group-title",children:o}),e]}),Fd=iS;iS.displayName="DropdownMenuGroup";f();import{useEffect as jP,useRef as qP}from"react";f();Y();V();import YP,{useContext as XP}from"react";var xE=YP.createContext({}),qu=(e="",t=!1,r=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
51
|
+
${t?"dropdown-menu-item--selected":""} ${r?"dropdown-menu-item--hovered":""}`.trim(),Ju=(e,t)=>{let r=XP(xE);return zi(e,o=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});t?.(n),n.defaultPrevented||r.onSelect?.(n)})};f();import{Fragment as $P,jsx as yE,jsxs as ZP}from"react/jsx-runtime";var KP=({textStyle:e,icon:t,shortcut:r,children:o})=>{let n=Ne();return ZP($P,{children:[t&&yE("div",{className:"dropdown-menu-item__icon",children:t}),yE("div",{style:e,className:"dropdown-menu-item__text",children:o}),r&&!n.editor.isMobile&&yE("div",{className:"dropdown-menu-item__shortcut",children:r})]})},Qu=KP;Y();import{jsx as wE}from"react/jsx-runtime";var vE=({icon:e,value:t,order:r,children:o,shortcut:n,className:i,hovered:a,selected:s,textStyle:l,onSelect:c,onClick:d,...m})=>{let p=Ju(d,c),u=qP(null);return jP(()=>{a&&(r===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,r]),wE("button",{...m,ref:u,value:t,onClick:p,className:qu(i,s,a),title:m.title??m["aria-label"],children:wE(Qu,{textStyle:l,icon:e,shortcut:n,children:o})})};vE.displayName="DropdownMenuItem";var Ul={GREEN:"green",RED:"red",BLUE:"blue"},eg=({type:e=Ul.BLUE,children:t})=>{let{theme:r}=Gn(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:r===ue.LIGHT?"1.5px solid white":"none"};switch(e){case Ul.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Ul.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Ul.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return wE("div",{className:"DropDownMenuItemBadge",style:o,children:t})};eg.displayName="DropdownMenuItemBadge";vE.Badge=eg;var eo=vE;V();f();ye();var aS=({event:e,inputRef:t,hoveredFont:r,filteredFonts:o,onClose:n,onSelect:i,onHover:a})=>{if(!e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===S.F)return t.current?.focus(),!0;if(e.key===S.ESCAPE)return n(),!0;if(e.key===S.ENTER)return r?.value&&i(r.value),!0;if(e.key===S.ARROW_DOWN)return r?.next?a(r.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===S.ARROW_UP)return r?.prev?a(r.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};on();import{jsx as Bd,jsxs as sS}from"react/jsx-runtime";var lS=JP.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:r,onHover:o,onLeave:n,onOpen:i,onClose:a})=>{let{container:s}=Ft(),{fonts:l}=tr(),{showDeprecatedFonts:c}=Wn(),[d,m]=QP(""),p=eL(null),u=pa(()=>Array.from(Lr.registered.entries()).filter(([A,{metadata:N}])=>!N.serverSide).map(([A,{metadata:N,fonts:k}])=>{let D={value:A,icon:N.icon,text:k[0].fontFace.family};return N.deprecated&&Object.assign(D,{deprecated:N.deprecated,badge:{type:Ul.RED,placeholder:E("fontList.badge.old")}}),D}).sort((A,N)=>A.text.toLowerCase()>N.text.toLowerCase()?1:-1),[]),g=pa(()=>new Set(l.getSceneFontFamilies()),[e]),h=pa(()=>u.filter(A=>g.has(A.value)),[u,g]),x=pa(()=>u.filter(A=>!g.has(A.value)&&(c||!A.deprecated)),[u,g,c]),v=pa(()=>D0([...h,...x].filter(A=>A.text?.toLowerCase().includes(d))),[h,x,d]),y=pa(()=>{let A;return t?A=v.find(N=>N.value===t):e&&(A=v.find(N=>N.value===e)),!A&&d&&(v[0]?.value?o(v[0].value):n()),A},[t,e,d,v,o,n]),w=rL(A=>{aS({event:A,inputRef:p,hoveredFont:y,filteredFonts:v,onSelect:r,onHover:o,onClose:a})&&(A.preventDefault(),A.stopPropagation())},[y,v,r,o,a]);tL(()=>(i(),()=>{a()}),[]);let C=pa(()=>v.filter(A=>g.has(A.value)),[v,g]),M=pa(()=>v.filter(A=>!g.has(A.value)),[v,g]),I=(A,N)=>sS(eo,{icon:A.icon,value:A.value,order:N,textStyle:{fontFamily:Sn({fontFamily:A.value})},hovered:A.value===y?.value,selected:A.value===e,tabIndex:A.value===e?0:-1,onClick:k=>{r(Number(k.currentTarget.value))},onMouseMove:()=>{y?.value!==A.value&&o(A.value)},children:[A.text,A.badge&&Bd(eg,{type:A.badge.type,children:A.badge.placeholder})]},A.value),P=[];return C.length&&P.push(Bd(Fd,{title:E("fontList.sceneFonts"),children:C.map(I)},"group_1")),M.length&&P.push(Bd(Fd,{title:E("fontList.availableFonts"),children:M.map((A,N)=>I(A,N+C.length))},"group_2")),sS(Xu,{className:"properties-content",container:s,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:w,children:[Bd(Zu,{ref:p,placeholder:E("quickSearch.placeholder"),onChange:ii(m,20)}),Bd(ju,{className:"dropdown-menu fonts manual-hover",placeholder:E("fontList.empty"),children:P.length?P:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);f();import*as cS from"@radix-ui/react-popover";import{useMemo as oL}from"react";ee();import{jsx as TE}from"react/jsx-runtime";var dS=({selectedFontFamily:e})=>{let t=oL(()=>!!(e&&!mS(e)),[e]);return TE(cS.Trigger,{asChild:!0,children:TE("div",{children:TE(Uu,{standalone:!0,icon:Jm,title:E("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:t,onClick:()=>{}})})})};ee();Y();import{jsx as tg,jsxs as pS}from"react/jsx-runtime";var gS=[{value:Le.Excalifont,icon:ci,text:E("labels.handDrawn"),testId:"font-family-handrawn"},{value:Le.Nunito,icon:Xs,text:E("labels.normal"),testId:"font-family-normal"},{value:Le["Comic Shanns"],icon:Dc,text:E("labels.code"),testId:"font-family-code"}],sL=new Set(gS.map(e=>e.value)),mS=e=>e?sL.has(e):!1,hS=nL.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:r,onSelect:o,onHover:n,onLeave:i,onPopupChange:a})=>{let s=aL(()=>gS,[]),l=iL(c=>{c&&o(c)},[o]);return pS("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[tg(Ro,{type:"button",options:s,value:t,onClick:l}),tg(Gu,{}),pS(uS.Root,{open:e,onOpenChange:a,children:[tg(dS,{selectedFontFamily:t}),e&&tg(lS,{selectedFontFamily:t,hoveredFontFamily:r,onSelect:l,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);ee();Y();we();De();He();me();ye();Zo();et();bd();V();$e();Re();on();yr();kl();Wt();import{Fragment as ES,jsx as ke,jsxs as to}from"react/jsx-runtime";var bS=.1,Or=(e,t,r,o=!1)=>{let n=Z(he(e,t,{includeBoundTextElement:o}));return e.map(i=>n.get(i.id)||i.id===t.editingElement?.id?r(i):i)},Fr=function(e,t,r,o,n){let i=t.editingElement,a=Ae(e),s=null;return i&&(s=r(i)),s||(qe(a,t)?s=jb(o===!0?a:a.filter(c=>o(c)),t,r)??(typeof n=="function"?n(!0):n):s=typeof n=="function"?n(!1):n),s},dL=(e,t)=>ze(t)||!t.autoResize?t:F(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2},!1),CE=(e,t,r,o,n)=>{let i=new Set;return{elements:Or(e,t,a=>{if(H(a)){let s=o(a);i.add(s);let l=pe(a,{fontSize:s});return ft(l,r.scene.getContainerElement(a),r.scene.getNonDeletedElementsMap()),l=dL(a,l),l}return a},!0),appState:{...t,currentItemFontSize:i.size===1?[...i][0]:n??t.currentItemFontSize},storeAction:_.CAPTURE}},mL=G({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemStrokeColor&&{elements:Or(e,t,o=>fd(o.type)?pe(o,{strokeColor:r.currentItemStrokeColor}):o,!0)},appState:{...t,...r},storeAction:r.currentItemStrokeColor?_.CAPTURE:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>to(ES,{children:[ke("h3",{"aria-hidden":"true",children:E("labels.stroke")}),ke(Od,{topPicks:fm,palette:Vx,type:"elementStroke",label:E("labels.stroke"),color:Fr(e,t,n=>n.strokeColor,!0,t.currentItemStrokeColor),onChange:n=>r({currentItemStrokeColor:n}),elements:e,appState:t,updateData:r})]})}),pL=G({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemBackgroundColor&&{elements:Or(e,t,o=>pe(o,{backgroundColor:r.currentItemBackgroundColor}))},appState:{...t,...r},storeAction:r.currentItemBackgroundColor?_.CAPTURE:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>to(ES,{children:[ke("h3",{"aria-hidden":"true",children:E("labels.background")}),ke(Od,{topPicks:bm,palette:Yx,type:"elementBackground",label:E("labels.background"),color:Fr(e,t,n=>n.backgroundColor,!0,t.currentItemBackgroundColor),onChange:n=>r({currentItemBackgroundColor:n}),elements:e,appState:t,updateData:r})]})}),uL=G({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,r,o)=>(Ce("element","changeFillStyle",`${r} (${o.device.editor.isMobile?"mobile":"desktop"})`),{elements:Or(e,t,n=>pe(n,{fillStyle:r})),appState:{...t,currentItemFillStyle:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=he(e,t),n=o.length>0&&o.every(i=>i.fillStyle==="zigzag");return to("fieldset",{children:[ke("legend",{children:E("labels.fill")}),ke(Ro,{type:"button",options:[{value:"hachure",text:`${n?E("labels.zigzag"):E("labels.hachure")} (${O("Alt-Click")})`,icon:n?Ny:Oy,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:E("labels.crossHatch"),icon:Fy,testId:"fill-cross-hatch"},{value:"solid",text:E("labels.solid"),icon:By,testId:"fill-solid"}],value:Fr(e,t,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:t.currentItemFillStyle),onClick:(i,a)=>{let s=a.altKey&&i==="hachure"&&o.every(l=>l.fillStyle==="hachure")?"zigzag":i;r(s)}})]})}}),gL=G({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>pe(o,{strokeWidth:r})),appState:{...t,currentItemStrokeWidth:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("fieldset",{children:[ke("legend",{children:E("labels.strokeWidth")}),ke(Ro,{group:"stroke-width",options:[{value:km.thin,text:E("labels.thin"),icon:mf,testId:"strokeWidth-thin"},{value:km.bold,text:E("labels.bold"),icon:zy,testId:"strokeWidth-bold"},{value:km.extraBold,text:E("labels.extraBold"),icon:Hy,testId:"strokeWidth-extraBold"}],value:Fr(e,t,o=>o.strokeWidth,o=>o.hasOwnProperty("strokeWidth"),o=>o?null:t.currentItemStrokeWidth),onChange:o=>r(o)})]})}),hL=G({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>pe(o,{seed:Co(),roughness:r})),appState:{...t,currentItemRoughness:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("fieldset",{children:[ke("legend",{children:E("labels.sloppiness")}),ke(Ro,{group:"sloppiness",options:[{value:0,text:E("labels.architect"),icon:Wy},{value:1,text:E("labels.artist"),icon:Vy},{value:2,text:E("labels.cartoonist"),icon:Yy}],value:Fr(e,t,o=>o.roughness,o=>o.hasOwnProperty("roughness"),o=>o?null:t.currentItemRoughness),onChange:o=>r(o)})]})}),Cee=G({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>pe(o,{strokeStyle:r})),appState:{...t,currentItemStrokeStyle:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("fieldset",{children:[ke("legend",{children:E("labels.strokeStyle")}),ke(Ro,{group:"strokeStyle",options:[{value:"solid",text:E("labels.strokeStyle_solid"),icon:mf},{value:"dashed",text:E("labels.strokeStyle_dashed"),icon:Uy},{value:"dotted",text:E("labels.strokeStyle_dotted"),icon:Gy}],value:Fr(e,t,o=>o.strokeStyle,o=>o.hasOwnProperty("strokeStyle"),o=>o?null:t.currentItemStrokeStyle),onChange:o=>r(o)})]})}),fL=G({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>pe(o,{opacity:r}),!0),appState:{...t,currentItemOpacity:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("label",{className:"control-label",children:[E("labels.opacity"),ke("input",{type:"range",min:"0",max:"100",step:"10",onChange:o=>r(+o.target.value),value:Fr(e,t,o=>o.opacity,!0,t.currentItemOpacity)??void 0})]})}),bL=G({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,r,o)=>CE(e,t,o,()=>r,r),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>to("fieldset",{children:[ke("legend",{children:E("labels.fontSize")}),ke(Ro,{group:"font-size",options:[{value:16,text:E("labels.small"),icon:rw,testId:"fontSize-small"},{value:20,text:E("labels.medium"),icon:ow,testId:"fontSize-medium"},{value:28,text:E("labels.large"),icon:nw,testId:"fontSize-large"},{value:36,text:E("labels.veryLarge"),icon:iw,testId:"fontSize-veryLarge"}],value:Fr(e,t,n=>{if(H(n))return n.fontSize;let i=J(n,o.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>H(n)||J(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:t.currentItemFontSize||ur),onChange:n=>r(n)})]})}),AE=G({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:za,trackEvent:!1,perform:(e,t,r,o)=>CE(e,t,o,n=>Math.round(1/(1+bS)*n.fontSize)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_LEFT||e.key===S.COMMA)}),ME=G({name:"increaseFontSize",label:"labels.increaseFontSize",icon:za,trackEvent:!1,perform:(e,t,r,o)=>CE(e,t,o,n=>Math.round(n.fontSize*(1+bS))),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_RIGHT||e.key===S.PERIOD)}),EL=G({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,r,o)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...s}=r;if(i)return{elements:Or(e,t,h=>{let x=n?.get(h.id);return x?pe(h,{...x}):h},!0),appState:{...t,...s},storeAction:_.UPDATE};let{currentItemFontFamily:l,currentHoveredFontFamily:c}=r,d=_.NONE,m,p=!1;if(l)m=l,d=_.CAPTURE;else if(c){m=c,d=_.NONE;let g=he(e,t,{includeBoundTextElement:!0}).filter(h=>H(h));if(g.length>200)p=!0;else{let h=0,x=0;for(;h<g.length&&x<5e3;){let v=g[h];x+=v?.originalText.length||0,h++}x>5e3&&(p=!0)}}let u={appState:{...t,...s},storeAction:d};if(m&&!p){let g=new Map,h=new Set,x=!1,v=Array.from(Lr.loadedFontsCache.values()),y=Object.entries(Le).find(([M,I])=>I===m)?.[0];c&&y&&v.some(M=>M.startsWith(y))&&(x=!0),Object.assign(u,{elements:Or(e,t,M=>{if(H(M)&&(M.fontFamily!==m||l)){let I=pe(M,{fontFamily:m,lineHeight:uo(m)}),P=n?.get(M.containerId||"")||{},A=o.scene.getContainerElement(M);return a&&A&&P&&F(A,{...P},!1),x||(h=new Set([...h,...Array.from(I.originalText)])),g.set(I,A),I}return M},!0)});let w=`10px ${Sn({fontFamily:m})}`,C=Array.from(h.values()).join();if(x||window.document.fonts.check(w,C))for(let[M,I]of g)ft(M,I,o.scene.getNonDeletedElementsMap(),!1);else window.document.fonts.load(w,C).then(M=>{for(let[I,P]of g){let A=o.scene.getElement(I.id),N=P?o.scene.getElement(P.id):null;A&&ft(A,N,o.scene.getNonDeletedElementsMap(),!1)}o.fonts.onLoaded(M)})}return u},PanelComponent:({elements:e,appState:t,app:r,updateData:o})=>{let n=IE(new Map),i=IE(null),[a,s]=cL({}),l=IE(!0),c=lL(()=>{let d=(m,p)=>Fr(m,t,u=>{if(H(u))return u.fontFamily;let g=J(u,p);return g?g.fontFamily:null},u=>H(u)||J(u,p)!==null,u=>u?null:t.currentItemFontFamily||gr);return a.openPopup==="fontFamily"&&t.openPopup==="fontFamily"?d(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&t.openPopup!=="fontFamily"?d(e,r.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,t,e,r.scene]);return SE(()=>{i.current=c},[c]),SE(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),SE(()=>(l.current=!1,()=>{l.current=!0}),[]),to("fieldset",{children:[ke("legend",{children:E("labels.fontFamily")}),ke(hS,{isOpened:t.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:t.currentHoveredFontFamily,onSelect:d=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),n.current.clear()},onHover:d=>{s({currentHoveredFontFamily:d,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:d=>{if(d){n.current.clear();let{editingElement:m}=t;if(m?.type==="text"){let p=r.scene.getElement(m.id);n.current.set(m.id,pe(p||m,{},!0))}else{let p=he(e,t,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,pe(u,{},!0))}s({openPopup:"fontFamily"})}else{let m={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};l.current?o({...a,...m}):s(m),n.current.clear()}}})]})}}),xL=G({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,r,o)=>({elements:Or(e,t,n=>{if(H(n)){let i=pe(n,{textAlign:r});return ft(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemTextAlign:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=o.scene.getNonDeletedElementsMap();return to("fieldset",{children:[ke("legend",{children:E("labels.textAlign")}),ke(Ro,{group:"text-align",options:[{value:"left",text:E("labels.left"),icon:sw,testId:"align-left"},{value:"center",text:E("labels.center"),icon:lw,testId:"align-horizontal-center"},{value:"right",text:E("labels.right"),icon:cw,testId:"align-right"}],value:Fr(e,t,i=>{if(H(i))return i.textAlign;let a=J(i,n);return a?a.textAlign:null},i=>H(i)||J(i,n)!==null,i=>i?null:t.currentItemTextAlign),onChange:i=>r(i)})]})}}),yL=G({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:Or(e,t,n=>{if(H(n)){let i=pe(n,{verticalAlign:r});return ft(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>ke("fieldset",{children:ke(Ro,{group:"text-align",options:[{value:kt.TOP,text:E("labels.alignTop"),icon:ke(dw,{theme:t.theme}),testId:"align-top"},{value:kt.MIDDLE,text:E("labels.centerVertically"),icon:ke(pw,{theme:t.theme}),testId:"align-middle"},{value:kt.BOTTOM,text:E("labels.alignBottom"),icon:ke(mw,{theme:t.theme}),testId:"align-bottom"}],value:Fr(e,t,n=>{if(H(n)&&n.containerId)return n.verticalAlign;let i=J(n,o.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>H(n)||J(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:kt.MIDDLE),onChange:n=>r(n)})})}),Aee=G({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>de(o)?o:pe(o,{roundness:r==="round"?{type:kn(o.type)?ct.ADAPTIVE_RADIUS:ct.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let n=Pd(Ae(e),t).some(i=>i.roundness?.type===ct.LEGACY);return to("fieldset",{children:[ke("legend",{children:E("labels.edges")}),ke(Ro,{group:"edges",options:[{value:"sharp",text:E("labels.sharp"),icon:Xy},{value:"round",text:E("labels.round"),icon:Ky}],value:Fr(e,t,i=>n?null:i.roundness?"round":"sharp",i=>!ne(i)&&i.hasOwnProperty("roundness"),i=>i?null:t.currentItemRoundness),onChange:i=>r(i)})]})}}),fS=e=>[{value:null,text:E("labels.arrowhead_none"),keyBinding:"q",icon:$y},{value:"arrow",text:E("labels.arrowhead_arrow"),keyBinding:"w",icon:ke(Zy,{flip:e})},{value:"bar",text:E("labels.arrowhead_bar"),keyBinding:"e",icon:ke(qy,{flip:e})},{value:"dot",text:E("labels.arrowhead_circle"),keyBinding:null,icon:ke(pf,{flip:e}),showInPicker:!1},{value:"circle",text:E("labels.arrowhead_circle"),keyBinding:"r",icon:ke(pf,{flip:e}),showInPicker:!1},{value:"circle_outline",text:E("labels.arrowhead_circle_outline"),keyBinding:null,icon:ke(jy,{flip:e}),showInPicker:!1},{value:"triangle",text:E("labels.arrowhead_triangle"),icon:ke(Jy,{flip:e}),keyBinding:"t"},{value:"triangle_outline",text:E("labels.arrowhead_triangle_outline"),icon:ke(Qy,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond",text:E("labels.arrowhead_diamond"),icon:ke(ew,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond_outline",text:E("labels.arrowhead_diamond_outline"),icon:ke(tw,{flip:e}),keyBinding:null,showInPicker:!1}],Mee=G({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>{if(ie(o)){let{position:n,type:i}=r;if(n==="start")return pe(o,{startArrowhead:i});if(n==="end")return pe(o,{endArrowhead:i})}return o}),appState:{...t,[r.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:r.type},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=ei().rtl;return to("fieldset",{children:[ke("legend",{children:E("labels.arrowheads")}),to("div",{className:"iconSelectList buttonList",children:[ke(EE,{label:"arrowhead_start",options:fS(!o),value:Fr(e,t,n=>ie(n)&&is(n.type)?n.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:n=>r({position:"start",type:n})}),ke(EE,{label:"arrowhead_end",group:"arrowheads",options:fS(!!o),value:Fr(e,t,n=>ie(n)&&is(n.type)?n.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:n=>r({position:"end",type:n})})]})]})}}),kee=G({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,t,r,o)=>({elements:Or(e,t,n=>{if(!ne(n))return n;let i=pe(n,{roundness:r===_t.round?{type:ct.PROPORTIONAL_RADIUS}:null,elbowed:r===_t.elbow,points:r===_t.elbow||n.elbowed?[n.points[0],n.points[n.points.length-1]]:n.points});if(de(i)){let a=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let s=K.getPointAtIndexGlobalCoordinates(i,0,a),l=K.getPointAtIndexGlobalCoordinates(i,-1,a),c=!i.startBinding&&xr(ar(s),e,a,!0),d=!i.endBinding&&xr(ar(l),e,a,!0),m=c||i.startBinding&&a.get(i.startBinding.elementId),p=d||i.endBinding&&a.get(i.endBinding.elementId),u=c?gl(s,l,c,a):s,g=d?gl(l,s,d,a):l;c&&On(i,c,"start",a),d&&On(i,d,"end",a),_o(i,o.scene,[u,g].map(h=>[h[0]-i.x,h[1]-i.y]),[0,0],{...m&&i.startBinding?{startBinding:{...i.startBinding,...Qc(i,m,"start",a)}}:{},...p&&i.endBinding?{endBinding:{...i.endBinding,...Qc(i,p,"end",a)}}:{}})}else F(i,{startBinding:i.startBinding?{...i.startBinding,fixedPoint:null}:null,endBinding:i.endBinding?{...i.endBinding,fixedPoint:null}:null},!1);return i}),appState:{...t,currentItemArrowType:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("fieldset",{children:[ke("legend",{children:E("labels.arrowtypes")}),ke(Ro,{group:"arrowtypes",options:[{value:_t.sharp,text:E("labels.arrowtype_sharp"),icon:Bw,testId:"sharp-arrow"},{value:_t.round,text:E("labels.arrowtype_round"),icon:Hw,testId:"round-arrow"},{value:_t.elbow,text:E("labels.arrowtype_elbowed"),icon:zw,testId:"elbow-arrow"}],value:Fr(e,t,o=>ne(o)?o.elbowed?_t.elbow:o.roundness?_t.round:_t.sharp:null,o=>ne(o),o=>o?null:t.currentItemArrowType),onChange:o=>r(o)})]})});f();ee();Y();we();ye();et();Jb();zu();V();$e();f();import{useEffect as wL}from"react";import{jsx as TL}from"react/jsx-runtime";var Gl=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},kE=(e,t,r="bottom")=>{let o=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,s=t.left+t.width/2-o.width/2;s<0?s=a:s+o.width>=n&&(s=n-o.width-a);let l;r==="bottom"?(l=t.top+t.height+a,l+o.height>=i&&(l=t.top-o.height-a)):(l=t.top-o.height-a,l<0&&(l=t.top+t.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},vL=(e,t,r,o)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=o?"50ch":"10ch",t.style.maxWidth=o?"50ch":"15ch",t.textContent=r;let n=e.getBoundingClientRect();kE(t,n)},Eo=({children:e,label:t,long:r=!1,style:o,disabled:n})=>(wL(()=>()=>Gl().classList.remove("excalidraw-tooltip--visible"),[]),n?null:TL("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>vL(i.currentTarget,Gl(),t,r),onPointerLeave:()=>Gl().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));De();Zr();pr();Gs();Re();import{jsx as ng,jsxs as ML}from"react/jsx-runtime";var SL=G({name:"changeViewBackgroundColor",label:"labels.canvasBackground",paletteName:"Change canvas background color",trackEvent:!1,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,r)=>({appState:{...t,...r},storeAction:r.viewBackgroundColor?_.CAPTURE:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>ng(Od,{palette:null,topPicks:Em,label:E("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:n=>r({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:r})}),Ai=G({name:"clearCanvas",label:"labels.clearCanvas",paletteName:"Clear canvas",icon:tn,trackEvent:{category:"canvas"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled,perform:(e,t,r,o)=>(o.imageCache.clear(),{elements:e.map(n=>pe(n,{isDeleted:!0})),appState:{...lr(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,stats:t.stats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:"selection"}:t.activeTool},storeAction:_.CAPTURE})}),rg=G({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Kh,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Ci({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Un(t.zoom.value+La)},t),userToFollow:null},storeAction:_.NONE}),PanelComponent:({updateData:e,appState:t})=>ng(fe,{type:"button",className:"zoom-in-button zoom-button",icon:Kh,title:`${E("buttons.zoomIn")} \u2014 ${O("CtrlOrCmd++")}`,"aria-label":E("buttons.zoomIn"),disabled:t.zoom.value>=Lh,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Se.EQUAL||e.code===Se.NUM_ADD)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),og=G({name:"zoomOut",label:"buttons.zoomOut",icon:$h,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Ci({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Un(t.zoom.value-La)},t),userToFollow:null},storeAction:_.NONE}),PanelComponent:({updateData:e,appState:t})=>ng(fe,{type:"button",className:"zoom-out-button zoom-button",icon:$h,title:`${E("buttons.zoomOut")} \u2014 ${O("CtrlOrCmd+-")}`,"aria-label":E("buttons.zoomOut"),disabled:t.zoom.value<=Os,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Se.MINUS||e.code===Se.NUM_SUBTRACT)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),IL=G({name:"resetZoom",label:"buttons.resetZoom",icon:Ey,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Ci({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Un(1)},t),userToFollow:null},storeAction:_.NONE}),PanelComponent:({updateData:e,appState:t})=>ng(Eo,{label:E("buttons.resetZoom"),style:{height:"100%"},children:ML(fe,{type:"button",className:"reset-zoom-button zoom-button",title:E("buttons.resetZoom"),"aria-label":E("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===Se.ZERO||e.code===Se.NUM_ZERO)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),CL=(e,t)=>{let[r,o,n,i]=e,a=n-r,s=t.width/a,l=i-o,c=t.height/l,d=Math.min(s,c),m=Math.floor(d/La)*La;return Math.min(Math.max(m,Os),1)},xS=({bounds:e,appState:t,fitToViewport:r=!1,viewportZoomFactor:o=.7})=>{let[n,i,a,s]=e,l=(n+a)/2,c=(i+s)/2,d,m,p;if(r){let u=a-n,g=s-i;d=Math.min(t.width/u,t.height/g)*Math.min(1,Math.max(o,.1)),d=Math.min(Math.max(d,Os),Lh);let h=t.width;if(t.openSidebar){let v=document.querySelector(".sidebar")?.offsetWidth??0;h=document.documentElement.getAttribute("dir")==="rtl"?t.width+v:t.width-v}m=h/2*(1/d)-l,p=t.height/2*(1/d)-c}else{d=CL(e,{width:t.width,height:t.height});let u=qb({scenePoint:{x:l,y:c},viewportDimensions:{width:t.width,height:t.height},zoom:{value:d}});m=u.scrollX,p=u.scrollY}return{appState:{...t,scrollX:m,scrollY:p,zoom:{value:d}},storeAction:_.NONE}},zd=({targetElements:e,appState:t,fitToViewport:r,viewportZoomFactor:o})=>{let n=Te(Ae(e));return xS({bounds:n,appState:t,fitToViewport:r,viewportZoomFactor:o})},ite=G({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:pp,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return zd({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!1})},keyTest:e=>e.code===Se.TWO&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),ate=G({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:pp,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return zd({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!0})},keyTest:e=>e.code===Se.THREE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),AL=G({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:pp,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>zd({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1}),keyTest:e=>e.code===Se.ONE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),bs=G({name:"toggleTheme",label:(e,t)=>t.theme===ue.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ue.LIGHT?kc:Pc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r)=>({appState:{...t,theme:r||(t.theme===ue.LIGHT?ue.DARK:ue.LIGHT)},storeAction:_.NONE}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===Se.D,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.toggleTheme}),ste=G({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t)=>{let r;return $r(t)?r=nt(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):r=nt(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},storeAction:_.CAPTURE}},keyTest:e=>e.key===S.E}),yS=G({name:"toggleHandTool",label:"toolBar.hand",paletteName:"Toggle hand tool",trackEvent:{category:"toolbar"},icon:ip,viewMode:!1,perform:(e,t,r,o)=>{let n;return qo(t)?n=nt(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=nt(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),Ze(o.interactiveCanvas,Be.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},storeAction:_.CAPTURE}},keyTest:e=>!e.altKey&&!e[S.CTRL_OR_CMD]&&e.key===S.H});f();ye();we();V();ee();$e();De();mt();Wt();yr();me();Gs();Re();import{jsx as kL}from"react/jsx-runtime";var xo=G({name:"finalize",label:"",trackEvent:!1,perform:(e,t,r,o)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=o,s=a.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:g}=t.editingLinearElement,h=K.getElement(p,s);if(h)return Kr(h)&&Qa(h,u,g,s,a),{elements:h.points.length<2||Po(h)?e.filter(x=>x.id!==h.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null,selectedLinearElement:null},storeAction:_.CAPTURE}}let l=e,c=t.pendingImageElementId&&a.getElement(t.pendingImageElementId);c&&F(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let d=t.multiElement?t.multiElement:t.editingElement?.type==="freedraw"?t.editingElement:null;if(d){if(d.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:g}=d;(!g||u[u.length-1]!==g)&&F(d,{points:d.points.slice(0,-1)})}Po(d)&&(l=l.filter(u=>u.id!==d.id));let p=Dr(d.points,t.zoom.value);if((d.type==="line"||d.type==="freedraw")&&p){let u=d.points,g=u[0];F(d,{points:u.map((h,x)=>x===u.length-1?[g[0],g[1]]:h)})}if(Kr(d)&&!p&&d.points.length>1){let[u,g]=K.getPointAtIndexGlobalCoordinates(d,-1,Z(e));Jc(d,t,{x:u,y:g},s,e)}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!d)&&mo(n);let m;return t.activeTool.type==="eraser"?m=nt(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):m=nt(t,{type:"selection"}),{elements:l,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&d?t.activeTool:m,activeEmbeddable:null,draggingElement:null,multiElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[d.id]:!0}:t.selectedElementIds,selectedLinearElement:d&&ie(d)?new K(d):t.selectedLinearElement,pendingImageElementId:null},storeAction:_.CAPTURE}},keyTest:(e,t)=>e.key===S.ESCAPE&&(t.editingLinearElement!==null||!t.draggingElement&&t.multiElement===null)||(e.key===S.ESCAPE||e.key===S.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:r})=>kL(fe,{type:"button",icon:My,title:E("buttons.done"),"aria-label":E("buttons.done"),onClick:t,visible:e.multiElement!=null,size:r?.size||"medium"})});f();ee();f();V();import{useState as PL}from"react";ye();import{jsx as wS,jsxs as LL}from"react/jsx-runtime";var vS=e=>{let{id:t}=Ft(),[r,o]=PL(e.value),n=a=>{e.ignoreFocus||M0(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===S.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return LL("div",{className:"ProjectName",children:[wS("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),wS("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${t}-filename`,value:r,onChange:a=>o(a.target.value)})]})};f();Y();import{jsx as Hd}from"react/jsx-runtime";var SS=e=>{let t=e.title||(e.value===ue.DARK?E("buttons.lightMode"):E("buttons.darkMode"));return Hd(fe,{type:"icon",icon:e.value===ue.LIGHT?TS.MOON:TS.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===ue.DARK?ue.LIGHT:ue.DARK),"data-testid":"toggle-dark-mode"})},TS={SUN:Hd("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hd("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:Hd("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hd("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};f();na();Y();we();me();et();md();V();qr();di();mi();vr();qr();mi();var Es=(e,{selectedElementIds:t},r)=>{e=Ae(e);let o=r&&qe(e,{selectedElementIds:t}),n=null,i=o?he(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return o&&(i.length===1&&Q(i[0])?(n=i[0],i=El(e,n)):i.length>1&&(i=he(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:Xr(i)}},xs=async(e,t,r,o,{exportBackground:n,exportPadding:i=Ko,viewBackgroundColor:a,name:s=r.name||Lm,fileHandle:l=null,exportingFrame:c=null})=>{if(t.length===0)throw new Error(E("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=bl(t,{exportBackground:n,exportWithDarkMode:r.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:r.exportScale,exportEmbedScene:r.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return qs(m.then(p=>new Blob([p.outerHTML],{type:se.svg})),{description:"Export to SVG",name:s,extension:r.exportEmbedScene?"excalidraw.svg":"svg",fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await wi(p)}catch{throw new Error(E("errors.copyToSystemClipboardFailed"))}return}}let d=su(t,r,o,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=gi(d);return r.exportEmbedScene&&(m=m.then(p=>Promise.resolve().then(()=>(tl(),Bc)).then(({encodePngMetadata:u})=>u({blob:p,metadata:Vi(t,r,o,"local")})))),qs(m,{description:"Export to PNG",name:s,extension:"png",fileHandle:l})}else if(e==="clipboard")try{let m=gi(d);await uu(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(E("canvasError.canvasTooBig")):ti&&m.name==="TypeError"?new Error(`${E("alerts.couldNotCopyToClipboard")}
|
|
56
52
|
|
|
57
|
-
${E("hints.firefox_clipboard_write")}`):new Error(E("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};f();Br();var sT=async(e,t,r,o)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=t,s=Mg(a);if(!a||!cy(s))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};let{exportedElements:l,exportingFrame:c}=Ua(e,t,!1);return await Ga(s,l,t,r,{exportBackground:n,viewBackgroundColor:i,name:o,fileHandle:a,exportingFrame:c}),{fileHandle:a}};ge();Ve();f();import lk from"clsx";import{jsx as lT,jsxs as ck}from"react/jsx-runtime";var Wa=({children:e,checked:t,onChange:r,className:o})=>ck("div",{className:lk("Checkbox",o,{"is-checked":t}),onClick:n=>{r(!t,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[lT("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":t,children:qw}),lT("div",{className:"Checkbox-label",children:e})]});Ac();Y();Xe();be();Br();$n();De();import{Fragment as dk,jsx as ri,jsxs as mk}from"react/jsx-runtime";var nb=H({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,r)=>({appState:{...t,name:r},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t,appProps:r,data:o,app:n})=>ri(nT,{label:E("labels.fileTitle"),value:n.getName(),onChange:i=>t(i),ignoreFocus:o?.ignoreFocus??!1})}),cT=H({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,r)=>({appState:{...t,exportScale:r},storeAction:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=Te(e),i=Ke(o,t)?pe(o,t):o;return ri(dk,{children:ss.map(a=>{let[s,l]=_y(i,Oo,a),c=`${E("imageExportDialog.label.scale")} ${a}x (${s}x${l})`;return ri(de,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===t.exportScale,onChange:()=>r(a)},a)})})}}),ib=H({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,r)=>({appState:{...t,exportBackground:r},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t})=>ri(Wa,{checked:e.exportBackground,onChange:r=>t(r),children:E("imageExportDialog.label.withBackground")})}),$p=H({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,r)=>({appState:{...t,exportEmbedScene:r},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t})=>mk(Wa,{checked:e.exportEmbedScene,onChange:r=>t(r),children:[E("imageExportDialog.label.embedScene"),ri(io,{label:E("imageExportDialog.tooltip.embedScene"),long:!0,children:ri("div",{className:"excalidraw-tooltip-icon",children:o2})})]})}),Xp=H({name:"saveToActiveFile",label:"buttons.save",icon:Oa,trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{let n=!!t.fileHandle;try{let{fileHandle:i}=Bs(t.fileHandle)?await sT(e,t,o.files,o.getName()):await zm(e,t,o.files,o.getName());return{storeAction:D.NONE,appState:{...t,fileHandle:i,toast:n?{message:i?.name?E("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):E("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{storeAction:D.NONE}}},keyTest:e=>e.key===S.S&&e[S.CTRL_OR_CMD]&&!e.shiftKey}),jc=H({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Oa,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,r,o)=>{try{let{fileHandle:n}=await zm(e,{...t,fileHandle:null},o.files,o.getName());return{storeAction:D.NONE,appState:{...t,openDialog:null,fileHandle:n,toast:{message:E("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{storeAction:D.NONE}}},keyTest:e=>e.key===S.S&&e.shiftKey&&e[S.CTRL_OR_CMD],PanelComponent:({updateData:e})=>ri(de,{type:"button",icon:Qw,title:E("buttons.saveAs"),"aria-label":E("buttons.saveAs"),showAriaLabel:_e().editor.isMobile,hidden:!ki,onClick:()=>e(null),"data-testid":"save-as-button"})}),sl=H({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{try{let{elements:n,appState:i,files:a}=await Rg(t,e);return{elements:n,appState:i,files:a,storeAction:D.CAPTURE}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:o.files,storeAction:D.NONE}}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.O}),dT=H({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,r)=>({appState:{...t,exportWithDarkMode:r},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t})=>ri("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:ri(aT,{value:e.exportWithDarkMode?ce.DARK:ce.LIGHT,onChange:r=>{t(r===ce.DARK)},title:E("imageExportDialog.label.darkMode")})})});f();be();ge();Ve();Ae();Y();Je();le();Xe();De();var mT="{}",ab=H({name:"copyStyles",label:"labels.copyStyles",icon:Of,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=[],i=e.find(a=>t.selectedElementIds[a.id]);if(n.push(i),i&&sr(i)){let a=ae(i,o.scene.getNonDeletedElementsMap());n.push(a)}return i&&(mT=JSON.stringify(n)),{appState:{...t,toast:{message:E("toast.copyStyles")}},storeAction:D.NONE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.C}),sb=H({name:"pasteStyles",label:"labels.pasteStyles",icon:Of,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=JSON.parse(mT),i=n[0],a=n[1];if(!Kl(i))return{elements:e,storeAction:D.NONE};let s=pe(e,t,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(U(c)&&c.containerId&&(d=a),!d)return c;let m=se(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?h1(d.roundness.type,c)?d.roundness:g1(c):null});if(U(m)){let p=d.fontSize||Tt,u=d.fontFamily||Zt;m=se(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||nn,lineHeight:d.lineHeight||qr(u)});let h=null;m.containerId&&(h=s.find(g=>U(m)&&g.id===m.containerId)||null),Ot(m,h,o.scene.getNonDeletedElementsMap())}return m.type==="arrow"&&xe(d)&&(m=se(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),re(c)&&(m=se(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),storeAction:D.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.V});f();be();Ve();ge();De();import{jsx as pT}from"react/jsx-runtime";var pk=H({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t})=>pT(de,{type:"button",icon:Sp,"aria-label":E("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})}),uk=H({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},storeAction:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r})=>pT(de,{visible:_a(t,Te(e)),type:"button",icon:e2,"aria-label":E("buttons.edit"),onClick:r,selected:t.openMenu==="shape"})}),Va=H({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Xw,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,r,{focusContainer:o})=>(t.openDialog?.name==="help"&&o(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},storeAction:D.NONE}),keyTest:e=>e.key===S.QUESTION_MARK});f();ge();G();Ve();Ae();Xe();Gt();be();zo();le();mr();ho();De();import{jsx as ll}from"react/jsx-runtime";var hk=e=>{if(e.length>=2){let t=e[0].groupIds;for(let r of t)if(e.reduce((o,n)=>o&&va(n,r),!0))return!0}return!1},uT=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return o.length>=2&&!hk(o)},lb=H({name:"group",label:"labels.group",icon:e=>ll(Pf,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});if(n.length<2)return{appState:t,elements:e,storeAction:D.NONE};let i=Ko(t);if(i.length===1){let x=i[0],v=new Set(Qe(e,x).map(I=>I.id)),y=new Set(n.map(I=>I.id));if(new Set([...Array.from(v),...Array.from(y)]).size===v.size)return{appState:t,elements:e,storeAction:D.NONE}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&ow(n).forEach((v,y)=>{Ks(v,o.scene.getNonDeletedElementsMap())});let l=Nt(),c=X(n);a=a.map(x=>c.get(x.id)?se(x,{groupIds:k0(x.groupIds,l,t.editingGroupId)}):x);let d=Qe(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),h=a.slice(0,p).filter(x=>!va(x,l)),g=Ut([...h,...d,...u],X(d));return{appState:{...t,...bg(l,{...t,selectedGroupIds:{}},Te(a))},elements:g,storeAction:D.CAPTURE}},predicate:(e,t,r,o)=>uT(e,t,o),keyTest:e=>!e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>ll(de,{hidden:!uT(e,t,o),type:"button",icon:ll(Pf,{theme:t.theme}),onClick:()=>r(null),title:`${E("labels.group")} \u2014 ${R("CtrlOrCmd+G")}`,"aria-label":E("labels.group"),visible:Ke(Te(e),t)})}),cb=H({name:"ungroup",label:"labels.ungroup",icon:e=>ll(Df,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=Ko(t),i=X(e);if(n.length===0)return{appState:t,elements:e,storeAction:D.NONE};let a=[...e],s=[];a=a.map(p=>{Me(p)&&s.push(p.id);let u=M0(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:se(p,{groupIds:u})});let l=er(t,Te(a),t,null),c=o.scene.getSelectedElements(t),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return kc(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=cp(a,Ys(a,p,t,i),p,o))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,h])=>(h&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...l},elements:a,storeAction:D.CAPTURE}},keyTest:e=>e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G.toUpperCase(),predicate:(e,t)=>Ko(t).length>0,PanelComponent:({elements:e,appState:t,updateData:r})=>ll(de,{type:"button",hidden:Ko(t).length===0,icon:ll(Df,{theme:t.theme}),onClick:()=>r(null),title:`${E("labels.ungroup")} \u2014 ${R("CtrlOrCmd+Shift+G")}`,"aria-label":E("labels.ungroup"),visible:Ke(Te(e),t)})});f();f();Y();f();var Zp=(e,t,r,o,n,i,a)=>{e.beginPath(),e.moveTo(t+i,r),e.lineTo(t+o-i,r),e.quadraticCurveTo(t+o,r,t+o,r+i),e.lineTo(t+o,r+n-i),e.quadraticCurveTo(t+o,r+n,t+o-i,r+n),e.lineTo(t+i,r+n),e.quadraticCurveTo(t,r+n,t,r+n-i),e.lineTo(t,r+i),e.quadraticCurveTo(t,r,t+i,r),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};f();function gk(e){let t=0;if(e.length===0)return t;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)-t+o}return t}var Ya=(e,t)=>`hsl(${Math.abs(gk(t?.id||e))%37*10}, 100%, 83%)`,hT=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},gT=({context:e,renderConfig:t,appState:r,normalizedWidth:o,normalizedHeight:n})=>{for(let[i,a]of t.remotePointerViewportCoords){let{x:s,y:l}=a,c=r.collaborators.get(i);s-=r.offsetLeft,l-=r.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>n-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,n-m);let u=Ya(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let h=t.remotePointerUserStates.get(i),g=p||h==="idle"||h==="away";g&&(e.globalAlpha=.3),t.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 x=r.theme===ce.DARK?"#2f6330":_x,v=c?.isSpeaking;v&&(e.fillStyle=x,e.strokeStyle=x,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=Bl,e.strokeStyle=Bl,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 y=t.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let w=(v?s+0:s)+d/2,I=(v?l+0:l)+m+2,A=5,C=3,L=e.measureText(y),M=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,z=Math.max(M,12),k=w-1,N=I-1,B=L.width+2+A*2+2,_=z+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(k,N,B,_,8),e.fillStyle=u,e.fill(),e.strokeStyle=Bl,e.stroke(),v&&(e.beginPath(),e.roundRect(k-2,N-2,B+4,_+4,8),e.strokeStyle=x,e.stroke())):Zp(e,k,N,B,_,8,Bl),e.fillStyle=Dx,e.fillText(y,w+A+1,I+C+L.actualBoundingBoxAscent+Math.floor((z-M)/2)+2),v){e.fillStyle=x;let V=8,Z=8,J=5;e.fillRect(k+B+Z,N+(_/2-V/2),2,V),e.fillRect(k+B+Z+J,N+(_/2-V*2/2),2,V*2),e.fillRect(k+B+Z+J*2,N+(_/2-V/2),2,V)}}e.restore(),e.closePath()}};f();import{useState as fk}from"react";import bk from"clsx";import{jsx as fT}from"react/jsx-runtime";var db=({color:e,onClick:t,name:r,src:o,className:n})=>{let i=hT(r),[a,s]=fk(!1),l=!a&&o,c=l?void 0:{background:e};return fT("div",{className:bk("Avatar",n),style:c,onClick:t,children:l?fT("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};De();Ve();import Ek from"clsx";import{jsx as Tn,jsxs as jp}from"react/jsx-runtime";var xk=H({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,r)=>!r.socketId||t.userToFollow?.socketId===r.socketId||r.isCurrentUser?{appState:{...t,userToFollow:null},storeAction:D.NONE}:{appState:{...t,userToFollow:{socketId:r.socketId,username:r.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},storeAction:D.NONE},PanelComponent:({updateData:e,data:t,appState:r})=>{let{socketId:o,collaborator:n,withName:i,isBeingFollowed:a}=t,s=Ya(o,n),l=Ek({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?jp("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:E("userList.hint.isSpeaking"),children:[Tn("div",{}),Tn("div",{}),Tn("div",{})]}):n.isMuted?Tn("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:E("userList.hint.micMuted"),children:ev}):Tn("div",{title:E("userList.hint.inCall"),children:Q2}):null;return i?jp("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[Tn(db,{color:s,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:l}),Tn("div",{className:"UserList__collaborator-name",children:n.username}),jp("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Tn("div",{className:"UserList__collaborator-status-icon-is-followed",title:E("userList.hint.followStatus"),children:tl}),c]})]}):jp("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[Tn(db,{color:s,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:l}),c&&Tn("div",{className:"UserList__collaborator-status-icon",children:c})]})}});f();Ve();jo();zo();Y();De();var mb=H({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of Hd)if(n.some(a=>a.type===i))return{storeAction:D.NONE,appState:{...t,errorMessage:E(`errors.libraryElementTypeError.${i}`)}};return o.library.getLatestLibrary().then(i=>o.library.setLibrary([{id:Nt(),status:"unpublished",elements:n.map(Zo),created:Date.now()},...i])).then(()=>({storeAction:D.NONE,appState:{...t,toast:{message:E("toast.addedToLibrary")}}})).catch(i=>({storeAction:D.NONE,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});f();f();Ae();it();Gt();var bT=(e,t,r)=>{let o=Ta(e,t),n=Rr(e);return o.flatMap(i=>{let a=yk(i,n,r);return i.map(s=>se(s,{x:s.x+a.x,y:s.y+a.y}))})},yk=(e,t,{axis:r,position:o})=>{let n=Rr(e),[i,a]=r==="x"?["minX","maxX"]:["minY","maxY"],s={x:0,y:0};return o==="start"?{...s,[r]:t[i]-n[i]}:o==="end"?{...s,[r]:t[a]-n[a]}:{...s,[r]:(t[i]+t[a])/2-(n[i]+n[a])/2}};be();le();mr();ge();Xe();De();G();Ve();import{jsx as dl}from"react/jsx-runtime";var So=(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>1&&!n.some(i=>re(i))},cl=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=X(e),a=bT(n,i,o),s=X(a);return xn(e.map(l=>s.get(l.id)||l),t,r)},wk=H({name:"alignTop",label:"labels.alignTop",icon:If,trackEvent:{category:"element"},predicate:So,perform:(e,t,r,o)=>({appState:t,elements:cl(e,t,o,{position:"start",axis:"y"}),storeAction:D.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>dl(de,{hidden:!So(e,t,null,o),type:"button",icon:If,onClick:()=>r(null),title:`${E("labels.alignTop")} \u2014 ${R("CtrlOrCmd+Shift+Up")}`,"aria-label":E("labels.alignTop"),visible:Ke(Te(e),t)})}),vk=H({name:"alignBottom",label:"labels.alignBottom",icon:Cf,trackEvent:{category:"element"},predicate:So,perform:(e,t,r,o)=>({appState:t,elements:cl(e,t,o,{position:"end",axis:"y"}),storeAction:D.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>dl(de,{hidden:!So(e,t,null,o),type:"button",icon:Cf,onClick:()=>r(null),title:`${E("labels.alignBottom")} \u2014 ${R("CtrlOrCmd+Shift+Down")}`,"aria-label":E("labels.alignBottom"),visible:Ke(Te(e),t)})}),Tk=H({name:"alignLeft",label:"labels.alignLeft",icon:Af,trackEvent:{category:"element"},predicate:So,perform:(e,t,r,o)=>({appState:t,elements:cl(e,t,o,{position:"start",axis:"x"}),storeAction:D.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>dl(de,{hidden:!So(e,t,null,o),type:"button",icon:Af,onClick:()=>r(null),title:`${E("labels.alignLeft")} \u2014 ${R("CtrlOrCmd+Shift+Left")}`,"aria-label":E("labels.alignLeft"),visible:Ke(Te(e),t)})}),Sk=H({name:"alignRight",label:"labels.alignRight",icon:kf,trackEvent:{category:"element"},predicate:So,perform:(e,t,r,o)=>({appState:t,elements:cl(e,t,o,{position:"end",axis:"x"}),storeAction:D.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>dl(de,{hidden:!So(e,t,null,o),type:"button",icon:kf,onClick:()=>r(null),title:`${E("labels.alignRight")} \u2014 ${R("CtrlOrCmd+Shift+Right")}`,"aria-label":E("labels.alignRight"),visible:Ke(Te(e),t)})}),Ik=H({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Mf,trackEvent:{category:"element"},predicate:So,perform:(e,t,r,o)=>({appState:t,elements:cl(e,t,o,{position:"center",axis:"y"}),storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>dl(de,{hidden:!So(e,t,null,o),type:"button",icon:Mf,onClick:()=>r(null),title:E("labels.centerVertically"),"aria-label":E("labels.centerVertically"),visible:Ke(Te(e),t)})}),Ck=H({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Lf,trackEvent:{category:"element"},predicate:So,perform:(e,t,r,o)=>({appState:t,elements:cl(e,t,o,{position:"center",axis:"x"}),storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>dl(de,{hidden:!So(e,t,null,o),type:"button",icon:Lf,onClick:()=>r(null),title:E("labels.centerHorizontally"),"aria-label":E("labels.centerHorizontally"),visible:Ke(Te(e),t)})});f();f();Ae();Gt();it();var ET=(e,t,r)=>{let[o,n,i,a]=r.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],s=Rr(e),l=Ta(e,t).map(p=>[p,Rr(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of l)c+=p[1][a];let d=(s[a]-c)/(l.length-1);if(d<0){let p=l.findIndex(x=>x[1][o]===s[o]),u=l.findIndex(x=>x[1][i]===s[i]),h=(l[u][1][n]-l[p][1][n])/(l.length-1),g=l[p][1][n];return l.flatMap(([x,v],y)=>{let w={x:0,y:0};return y!==p&&y!==u&&(g+=h,w[r.axis]=g-v[n]),x.map(I=>se(I,{x:I.x+w.x,y:I.y+w.y}))})}let m=s[o];return l.flatMap(([p,u])=>{let h={x:0,y:0};return h[r.axis]=m-u[o],m+=d,m+=u[a],p.map(g=>se(g,{x:g.x+h.x,y:g.y+h.y}))})};be();le();mr();ge();Xe();De();G();Ve();import{jsx as wT}from"react/jsx-runtime";var xT=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length>1&&!r.some(o=>re(o))},yT=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=ET(n,r.scene.getNonDeletedElementsMap(),o),a=X(i);return xn(e.map(s=>a.get(s.id)||s),t,r)},Ak=H({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:yT(e,t,o,{space:"between",axis:"x"}),storeAction:D.CAPTURE}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.H,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>wT(de,{hidden:!xT(t,o),type:"button",icon:s2,onClick:()=>r(null),title:`${E("labels.distributeHorizontally")} \u2014 ${R("Alt+H")}`,"aria-label":E("labels.distributeHorizontally"),visible:Ke(Te(e),t)})}),kk=H({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:yT(e,t,o,{space:"between",axis:"y"}),storeAction:D.CAPTURE}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.V,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>wT(de,{hidden:!xT(t,o),type:"button",icon:l2,onClick:()=>r(null),title:`${E("labels.distributeVertically")} \u2014 ${R("Alt+V")}`,"aria-label":E("labels.distributeVertically"),visible:Ke(Te(e),t)})});f();Ve();Xe();be();Nc();G();ge();it();_r();mr();De();le();var pb=H({name:"flipHorizontal",label:"labels.flipHorizontal",icon:nv,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:xn(vT(e,o.scene.getNonDeletedElementsMap(),t,"horizontal",o),t,o),appState:t,storeAction:D.CAPTURE}),keyTest:e=>e.shiftKey&&e.code===ye.H}),ub=H({name:"flipVertical",label:"labels.flipVertical",icon:ov,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:xn(vT(e,o.scene.getNonDeletedElementsMap(),t,"vertical",o),t,o),appState:t,storeAction:D.CAPTURE}),keyTest:e=>e.shiftKey&&e.code===ye.V&&!e[S.CTRL_OR_CMD]}),vT=(e,t,r,o,n)=>{let i=pe(Te(e),r,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=Mk(i,t,r,o,n),s=X(a);return e.map(l=>s.get(l.id)||l)},Mk=(e,t,r,o,n)=>{let{minX:i,minY:a,maxX:s,maxY:l}=Rr(e);return of(t,e,t,"nw",!0,!0,o==="horizontal"?s:i,o==="horizontal"?a:l),rc(e.filter(ie),n,hn(r),[]),e};f();ge();Ve();_i();be();Y();De();var ml=H({name:"copy",label:"labels.copy",icon:zc,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await op(n,o.files,r)}catch(i){return{storeAction:D.NONE,appState:{...t,errorMessage:i.message}}}return{storeAction:D.NONE}},keyTest:void 0}),hb=H({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n;try{n=await Gy()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),_n?{storeAction:D.NONE,appState:{...t,errorMessage:E("hints.firefox_clipboard_write")}}:{storeAction:D.NONE,appState:{...t,errorMessage:E("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(Hy({types:n}))}catch(i){return console.error(i),{storeAction:D.NONE,appState:{...t,errorMessage:E("errors.asyncPasteFailedOnParse")}}}return{storeAction:D.NONE}},keyTest:void 0}),qp=H({name:"cut",label:"labels.cut",icon:W2,trackEvent:{category:"element"},perform:(e,t,r,o)=>(ml.perform(e,t,r,o),Vc.perform(e,t,null,o)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.X}),Jp=H({name:"copyAsSvg",label:"labels.copyAsSvg",icon:iv,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{storeAction:D.NONE};let{exportedElements:n,exportingFrame:i}=Ua(e,t,!0);try{return await Ga("clipboard-svg",n,t,o.files,{...t,exportingFrame:i,name:o.getName()}),{storeAction:D.NONE}}catch(a){return console.error(a),{appState:{...t,errorMessage:a.message},storeAction:D.NONE}}},predicate:e=>rp&&e.length>0,keywords:["svg","clipboard","copy"]}),Qp=H({name:"copyAsPng",label:"labels.copyAsPng",icon:av,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{storeAction:D.NONE};let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Ua(e,t,!0);try{return await Ga("clipboard",i,t,o.files,{...t,exportingFrame:a,name:o.getName()}),{appState:{...t,toast:{message:E("toast.copyToClipboardAsPng",{exportSelection:n.length?E("toast.selection"):E("toast.canvas"),exportColorScheme:t.exportWithDarkMode?E("buttons.darkMode"):E("buttons.lightMode")})}},storeAction:D.NONE}}catch(s){return console.error(s),{appState:{...t,errorMessage:s.message},storeAction:D.NONE}}},predicate:e=>Ws&&e.length>0,keyTest:e=>e.code===ye.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),eu=H({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let i=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).reduce((a,s)=>(U(s)&&a.push(s.text),a),[]).join(`
|
|
53
|
+
${E("hints.firefox_clipboard_write")}`):new Error(E("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};f();qr();var IS=async(e,t,r,o)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=t,s=vf(a);if(!a||!o2(s))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};let{exportedElements:l,exportingFrame:c}=Es(e,t,!1);return await xs(s,l,t,r,{exportBackground:n,viewBackgroundColor:i,name:o,fileHandle:a,exportingFrame:c}),{fileHandle:a}};ye();$e();f();ee();import DL from"clsx";import{jsx as CS,jsxs as _L}from"react/jsx-runtime";var ys=({children:e,checked:t,onChange:r,className:o})=>_L("div",{className:DL("Checkbox",o,{"is-checked":t}),onClick:n=>{r(!t,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[CS("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":t,children:Ty}),CS("div",{className:"Checkbox-label",children:e})]});md();Y();et();we();qr();di();Re();import{Fragment as RL,jsx as Mi,jsxs as NL}from"react/jsx-runtime";var PE=G({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,r)=>({appState:{...t,name:r},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t,appProps:r,data:o,app:n})=>Mi(vS,{label:E("labels.fileTitle"),value:n.getName(),onChange:i=>t(i),ignoreFocus:o?.ignoreFocus??!1})}),AS=G({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,r)=>({appState:{...t,exportScale:r},storeAction:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=Ae(e),i=qe(o,t)?he(o,t):o;return Mi(RL,{children:zs.map(a=>{let[s,l]=qv(i,Ko,a),c=`${E("imageExportDialog.label.scale")} ${a}x (${s}x${l})`;return Mi(fe,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===t.exportScale,onChange:()=>r(a)},a)})})}}),LE=G({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,r)=>({appState:{...t,exportBackground:r},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t})=>Mi(ys,{checked:e.exportBackground,onChange:r=>t(r),children:E("imageExportDialog.label.withBackground")})}),ig=G({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,r)=>({appState:{...t,exportEmbedScene:r},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t})=>NL(ys,{checked:e.exportEmbedScene,onChange:r=>t(r),children:[E("imageExportDialog.label.embedScene"),Mi(Eo,{label:E("imageExportDialog.tooltip.embedScene"),long:!0,children:Mi("div",{className:"excalidraw-tooltip-icon",children:ky})})]})}),ag=G({name:"saveToActiveFile",label:"buttons.save",icon:Ba,trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{let n=!!t.fileHandle;try{let{fileHandle:i}=Js(t.fileHandle)?await IS(e,t,o.files,o.getName()):await gp(e,t,o.files,o.getName());return{storeAction:_.NONE,appState:{...t,fileHandle:i,toast:n?{message:i?.name?E("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):E("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{storeAction:_.NONE}}},keyTest:e=>e.key===S.S&&e[S.CTRL_OR_CMD]&&!e.shiftKey}),Ud=G({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Ba,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,r,o)=>{try{let{fileHandle:n}=await gp(e,{...t,fileHandle:null},o.files,o.getName());return{storeAction:_.NONE,appState:{...t,openDialog:null,fileHandle:n,toast:{message:E("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{storeAction:_.NONE}}},keyTest:e=>e.key===S.S&&e.shiftKey&&e[S.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Mi(fe,{type:"button",icon:Iy,title:E("buttons.saveAs"),"aria-label":E("buttons.saveAs"),showAriaLabel:Ne().editor.isMobile,hidden:!Wi,onClick:()=>e(null),"data-testid":"save-as-button"})}),Wl=G({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{try{let{elements:n,appState:i,files:a}=await ff(t,e);return{elements:n,appState:i,files:a,storeAction:_.CAPTURE}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:o.files,storeAction:_.NONE}}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.O}),MS=G({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,r)=>({appState:{...t,exportWithDarkMode:r},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t})=>Mi("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Mi(SS,{value:e.exportWithDarkMode?ue.DARK:ue.LIGHT,onChange:r=>{t(r===ue.DARK)},title:E("imageExportDialog.label.darkMode")})})});f();we();ye();$e();De();Y();He();me();et();ee();Re();on();var kS="{}",DE=G({name:"copyStyles",label:"labels.copyStyles",icon:gf,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=[],i=e.find(a=>t.selectedElementIds[a.id]);if(n.push(i),i&&Ct(i)){let a=J(i,o.scene.getNonDeletedElementsMap());n.push(a)}return i&&(kS=JSON.stringify(n)),{appState:{...t,toast:{message:E("toast.copyStyles")}},storeAction:_.NONE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.C}),_E=G({name:"pasteStyles",label:"labels.pasteStyles",icon:gf,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=JSON.parse(kS),i=n[0],a=n[1];if(!Ac(i))return{elements:e,storeAction:_.NONE};let s=he(e,t,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(H(c)&&c.containerId&&(d=a),!d)return c;let m=pe(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?U0(d.roundness.type,c)?d.roundness:G0(c):null});if(H(m)){let p=d.fontSize||ur,u=d.fontFamily||gr;m=pe(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||vn,lineHeight:d.lineHeight||uo(u)});let g=null;m.containerId&&(g=s.find(h=>H(m)&&h.id===m.containerId)||null),ft(m,g,o.scene.getNonDeletedElementsMap())}return m.type==="arrow"&&ne(d)&&(m=pe(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),Q(c)&&(m=pe(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),storeAction:_.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.V});f();ee();we();$e();ye();Re();import{jsx as PS}from"react/jsx-runtime";var OL=G({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t})=>PS(fe,{type:"button",icon:Qm,"aria-label":E("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})}),FL=G({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},storeAction:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r})=>PS(fe,{visible:us(t,Ae(e)),type:"button",icon:Cy,"aria-label":E("buttons.edit"),onClick:r,selected:t.openMenu==="shape"})}),ws=G({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:yy,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,r,{focusContainer:o})=>(t.openDialog?.name==="help"&&o(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},storeAction:_.NONE}),keyTest:e=>e.key===S.QUESTION_MARK});f();ye();V();$e();ee();De();et();Gt();we();Zo();me();vr();ko();Re();import{jsx as Vl}from"react/jsx-runtime";var BL=e=>{if(e.length>=2){let t=e[0].groupIds;for(let r of t)if(e.reduce((o,n)=>o&&Ra(n,r),!0))return!0}return!1},LS=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return o.length>=2&&!BL(o)},RE=G({name:"group",label:"labels.group",icon:e=>Vl(cf,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});if(n.length<2)return{appState:t,elements:e,storeAction:_.NONE};let i=Jo(t);if(i.length===1){let x=i[0],v=new Set(ot(e,x).map(C=>C.id)),y=new Set(n.map(C=>C.id));if(new Set([...Array.from(v),...Array.from(y)]).size===v.size)return{appState:t,elements:e,storeAction:_.NONE}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&wT(n).forEach((v,y)=>{Tl(v,o.scene.getNonDeletedElementsMap())});let l=Ut(),c=Z(n);a=a.map(x=>c.get(x.id)?pe(x,{groupIds:$0(x.groupIds,l,t.editingGroupId)}):x);let d=ot(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),g=a.slice(0,p).filter(x=>!Ra(x,l)),h=Jt([...g,...d,...u],Z(d));return{appState:{...t,...Wh(l,{...t,selectedGroupIds:{}},Ae(a))},elements:h,storeAction:_.CAPTURE}},predicate:(e,t,r,o)=>LS(e,t,o),keyTest:e=>!e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Vl(fe,{hidden:!LS(e,t,o),type:"button",icon:Vl(cf,{theme:t.theme}),onClick:()=>r(null),title:`${E("labels.group")} \u2014 ${O("CtrlOrCmd+G")}`,"aria-label":E("labels.group"),visible:qe(Ae(e),t)})}),NE=G({name:"ungroup",label:"labels.ungroup",icon:e=>Vl(df,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=Jo(t),i=Z(e);if(n.length===0)return{appState:t,elements:e,storeAction:_.NONE};let a=[...e],s=[];a=a.map(p=>{ze(p)&&s.push(p.id);let u=Z0(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:pe(p,{groupIds:u})});let l=cr(t,Ae(a),t,null),c=o.scene.getSelectedElements(t),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return pd(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=bu(a,vl(a,p,t,i),p,o))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,g])=>(g&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...l},elements:a,storeAction:_.CAPTURE}},keyTest:e=>e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G.toUpperCase(),predicate:(e,t)=>Jo(t).length>0,PanelComponent:({elements:e,appState:t,updateData:r})=>Vl(fe,{type:"button",hidden:Jo(t).length===0,icon:Vl(df,{theme:t.theme}),onClick:()=>r(null),title:`${E("labels.ungroup")} \u2014 ${O("CtrlOrCmd+Shift+G")}`,"aria-label":E("labels.ungroup"),visible:qe(Ae(e),t)})});f();f();Y();f();var sg=(e,t,r,o,n,i,a)=>{e.beginPath(),e.moveTo(t+i,r),e.lineTo(t+o-i,r),e.quadraticCurveTo(t+o,r,t+o,r+i),e.lineTo(t+o,r+n-i),e.quadraticCurveTo(t+o,r+n,t+o-i,r+n),e.lineTo(t+i,r+n),e.quadraticCurveTo(t,r+n,t,r+n-i),e.lineTo(t,r+i),e.quadraticCurveTo(t,r,t+i,r),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};f();function zL(e){let t=0;if(e.length===0)return t;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)-t+o}return t}var vs=(e,t)=>`hsl(${Math.abs(zL(t?.id||e))%37*10}, 100%, 83%)`,DS=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},_S=({context:e,renderConfig:t,appState:r,normalizedWidth:o,normalizedHeight:n})=>{for(let[i,a]of t.remotePointerViewportCoords){let{x:s,y:l}=a,c=r.collaborators.get(i);s-=r.offsetLeft,l-=r.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>n-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,n-m);let u=vs(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let g=t.remotePointerUserStates.get(i),h=p||g==="idle"||g==="away";h&&(e.globalAlpha=.3),t.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 x=r.theme===ue.DARK?"#2f6330":r0,v=c?.isSpeaking;v&&(e.fillStyle=x,e.strokeStyle=x,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=Ec,e.strokeStyle=Ec,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(),h?(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 y=t.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let w=(v?s+0:s)+d/2,C=(v?l+0:l)+m+2,M=5,I=3,P=e.measureText(y),A=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,N=Math.max(A,12),k=w-1,D=C-1,z=P.width+2+M*2+2,R=N+2+I*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(k,D,z,R,8),e.fillStyle=u,e.fill(),e.strokeStyle=Ec,e.stroke(),v&&(e.beginPath(),e.roundRect(k-2,D-2,z+4,R+4,8),e.strokeStyle=x,e.stroke())):sg(e,k,D,z,R,8,Ec),e.fillStyle=t0,e.fillText(y,w+M+1,C+I+P.actualBoundingBoxAscent+Math.floor((N-A)/2)+2),v){e.fillStyle=x;let W=8,q=8,re=5;e.fillRect(k+z+q,D+(R/2-W/2),2,W),e.fillRect(k+z+q+re,D+(R/2-W*2/2),2,W*2),e.fillRect(k+z+q+re*2,D+(R/2-W/2),2,W)}}e.restore(),e.closePath()}};f();import{useState as HL}from"react";import UL from"clsx";import{jsx as RS}from"react/jsx-runtime";var OE=({color:e,onClick:t,name:r,src:o,className:n})=>{let i=DS(r),[a,s]=HL(!1),l=!a&&o,c=l?void 0:{background:e};return RS("div",{className:UL("Avatar",n),style:c,onClick:t,children:l?RS("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};ee();Re();$e();import GL from"clsx";import{jsx as Vn,jsxs as lg}from"react/jsx-runtime";var WL=G({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,r)=>!r.socketId||t.userToFollow?.socketId===r.socketId||r.isCurrentUser?{appState:{...t,userToFollow:null},storeAction:_.NONE}:{appState:{...t,userToFollow:{socketId:r.socketId,username:r.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},storeAction:_.NONE},PanelComponent:({updateData:e,data:t,appState:r})=>{let{socketId:o,collaborator:n,withName:i,isBeingFollowed:a}=t,s=vs(o,n),l=GL({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?lg("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:E("userList.hint.isSpeaking"),children:[Vn("div",{}),Vn("div",{}),Vn("div",{})]}):n.isMuted?Vn("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:E("userList.hint.micMuted"),children:Iw}):Vn("div",{title:E("userList.hint.inCall"),children:Sw}):null;return i?lg("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[Vn(OE,{color:s,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:l}),Vn("div",{className:"UserList__collaborator-name",children:n.username}),lg("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Vn("div",{className:"UserList__collaborator-status-icon-is-followed",title:E("userList.hint.followStatus"),children:Zs}),c]})]}):lg("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[Vn(OE,{color:s,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:l}),c&&Vn("div",{className:"UserList__collaborator-status-icon",children:c})]})}});f();$e();Nn();Zo();Y();Re();var FE=G({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of Pm)if(n.some(a=>a.type===i))return{storeAction:_.NONE,appState:{...t,errorMessage:E(`errors.libraryElementTypeError.${i}`)}};return o.library.getLatestLibrary().then(i=>o.library.setLibrary([{id:Ut(),status:"unpublished",elements:n.map(an),created:Date.now()},...i])).then(()=>({storeAction:_.NONE,appState:{...t,toast:{message:E("toast.addedToLibrary")}}})).catch(i=>({storeAction:_.NONE,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});f();f();De();dt();Gt();var NS=(e,t,r)=>{let o=Na(e,t),n=Qr(e);return o.flatMap(i=>{let a=VL(i,n,r);return i.map(s=>pe(s,{x:s.x+a.x,y:s.y+a.y}))})},VL=(e,t,{axis:r,position:o})=>{let n=Qr(e),[i,a]=r==="x"?["minX","maxX"]:["minY","maxY"],s={x:0,y:0};return o==="start"?{...s,[r]:t[i]-n[i]}:o==="end"?{...s,[r]:t[a]-n[a]}:{...s,[r]:(t[i]+t[a])/2-(n[i]+n[a])/2}};ee();we();me();vr();ye();et();Re();V();$e();import{jsx as Xl}from"react/jsx-runtime";var Oo=(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>1&&!n.some(i=>Q(i))},Yl=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=Z(e),a=NS(n,i,o),s=Z(a);return zn(e.map(l=>s.get(l.id)||l),t,r)},YL=G({name:"alignTop",label:"labels.alignTop",icon:rf,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"start",axis:"y"}),storeAction:_.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:rf,onClick:()=>r(null),title:`${E("labels.alignTop")} \u2014 ${O("CtrlOrCmd+Shift+Up")}`,"aria-label":E("labels.alignTop"),visible:qe(Ae(e),t)})}),XL=G({name:"alignBottom",label:"labels.alignBottom",icon:of,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"end",axis:"y"}),storeAction:_.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:of,onClick:()=>r(null),title:`${E("labels.alignBottom")} \u2014 ${O("CtrlOrCmd+Shift+Down")}`,"aria-label":E("labels.alignBottom"),visible:qe(Ae(e),t)})}),KL=G({name:"alignLeft",label:"labels.alignLeft",icon:nf,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"start",axis:"x"}),storeAction:_.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:nf,onClick:()=>r(null),title:`${E("labels.alignLeft")} \u2014 ${O("CtrlOrCmd+Shift+Left")}`,"aria-label":E("labels.alignLeft"),visible:qe(Ae(e),t)})}),$L=G({name:"alignRight",label:"labels.alignRight",icon:af,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"end",axis:"x"}),storeAction:_.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:af,onClick:()=>r(null),title:`${E("labels.alignRight")} \u2014 ${O("CtrlOrCmd+Shift+Right")}`,"aria-label":E("labels.alignRight"),visible:qe(Ae(e),t)})}),ZL=G({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:sf,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"center",axis:"y"}),storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:sf,onClick:()=>r(null),title:E("labels.centerVertically"),"aria-label":E("labels.centerVertically"),visible:qe(Ae(e),t)})}),jL=G({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:lf,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"center",axis:"x"}),storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:lf,onClick:()=>r(null),title:E("labels.centerHorizontally"),"aria-label":E("labels.centerHorizontally"),visible:qe(Ae(e),t)})});f();ee();f();De();Gt();dt();var OS=(e,t,r)=>{let[o,n,i,a]=r.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],s=Qr(e),l=Na(e,t).map(p=>[p,Qr(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of l)c+=p[1][a];let d=(s[a]-c)/(l.length-1);if(d<0){let p=l.findIndex(x=>x[1][o]===s[o]),u=l.findIndex(x=>x[1][i]===s[i]),g=(l[u][1][n]-l[p][1][n])/(l.length-1),h=l[p][1][n];return l.flatMap(([x,v],y)=>{let w={x:0,y:0};return y!==p&&y!==u&&(h+=g,w[r.axis]=h-v[n]),x.map(C=>pe(C,{x:C.x+w.x,y:C.y+w.y}))})}let m=s[o];return l.flatMap(([p,u])=>{let g={x:0,y:0};return g[r.axis]=m-u[o],m+=d,m+=u[a],p.map(h=>pe(h,{x:h.x+g.x,y:h.y+g.y}))})};we();me();vr();ye();et();Re();V();$e();import{jsx as zS}from"react/jsx-runtime";var FS=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length>1&&!r.some(o=>Q(o))},BS=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=OS(n,r.scene.getNonDeletedElementsMap(),o),a=Z(i);return zn(e.map(s=>a.get(s.id)||s),t,r)},qL=G({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:BS(e,t,o,{space:"between",axis:"x"}),storeAction:_.CAPTURE}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.H,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>zS(fe,{hidden:!FS(t,o),type:"button",icon:_y,onClick:()=>r(null),title:`${E("labels.distributeHorizontally")} \u2014 ${O("Alt+H")}`,"aria-label":E("labels.distributeHorizontally"),visible:qe(Ae(e),t)})}),JL=G({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:BS(e,t,o,{space:"between",axis:"y"}),storeAction:_.CAPTURE}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.V,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>zS(fe,{hidden:!FS(t,o),type:"button",icon:Ry,onClick:()=>r(null),title:`${E("labels.distributeVertically")} \u2014 ${O("Alt+V")}`,"aria-label":E("labels.distributeVertically"),visible:qe(Ae(e),t)})});f();$e();et();we();kd();V();ye();dt();yr();vr();ee();Re();me();var BE=G({name:"flipHorizontal",label:"labels.flipHorizontal",icon:kw,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:zn(HS(e,o.scene.getNonDeletedElementsMap(),t,"horizontal",o),t,o),appState:t,storeAction:_.CAPTURE}),keyTest:e=>e.shiftKey&&e.code===Se.H}),zE=G({name:"flipVertical",label:"labels.flipVertical",icon:Mw,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:zn(HS(e,o.scene.getNonDeletedElementsMap(),t,"vertical",o),t,o),appState:t,storeAction:_.CAPTURE}),keyTest:e=>e.shiftKey&&e.code===Se.V&&!e[S.CTRL_OR_CMD]}),HS=(e,t,r,o,n)=>{let i=he(Ae(e),r,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=QL(i,t,r,o,n),s=Z(a);return e.map(l=>s.get(l.id)||l)},QL=(e,t,r,o,n)=>{let{minX:i,minY:a,maxX:s,maxY:l}=Qr(e);return Gb(t,e,t,"nw",!0,!0,o==="horizontal"?s:i,o==="horizontal"?a:l,n.scene),es(e.filter(ie),t,n.scene.getNonDeletedElements(),n.scene,Fn(r),[]),e};f();ye();$e();na();we();Y();ee();Re();var Kl=G({name:"copy",label:"labels.copy",icon:Mc,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await mu(n,o.files,r)}catch(i){return{storeAction:_.NONE,appState:{...t,errorMessage:i.message}}}return{storeAction:_.NONE}},keyTest:void 0}),HE=G({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n;try{n=await aT()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),ti?{storeAction:_.NONE,appState:{...t,errorMessage:E("hints.firefox_clipboard_write")}}:{storeAction:_.NONE,appState:{...t,errorMessage:E("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(nT({types:n}))}catch(i){return console.error(i),{storeAction:_.NONE,appState:{...t,errorMessage:E("errors.asyncPasteFailedOnParse")}}}return{storeAction:_.NONE}},keyTest:void 0}),cg=G({name:"cut",label:"labels.cut",icon:gw,trackEvent:{category:"element"},perform:(e,t,r,o)=>(Kl.perform(e,t,r,o),_d.perform(e,t,null,o)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.X}),dg=G({name:"copyAsSvg",label:"labels.copyAsSvg",icon:Pw,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{storeAction:_.NONE};let{exportedElements:n,exportingFrame:i}=Es(e,t,!0);try{return await xs("clipboard-svg",n,t,o.files,{...t,exportingFrame:i,name:o.getName()}),{storeAction:_.NONE}}catch(a){return console.error(a),{appState:{...t,errorMessage:a.message},storeAction:_.NONE}}},predicate:e=>du&&e.length>0,keywords:["svg","clipboard","copy"]}),mg=G({name:"copyAsPng",label:"labels.copyAsPng",icon:Lw,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{storeAction:_.NONE};let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Es(e,t,!0);try{return await xs("clipboard",i,t,o.files,{...t,exportingFrame:a,name:o.getName()}),{appState:{...t,toast:{message:E("toast.copyToClipboardAsPng",{exportSelection:n.length?E("toast.selection"):E("toast.canvas"),exportColorScheme:t.exportWithDarkMode?E("buttons.darkMode"):E("buttons.lightMode")})}},storeAction:_.NONE}}catch(s){return console.error(s),{appState:{...t,errorMessage:s.message},storeAction:_.NONE}}},predicate:e=>yl&&e.length>0,keyTest:e=>e.code===Se.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),pg=G({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let i=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).reduce((a,s)=>(H(s)&&a.push(s.text),a),[]).join(`
|
|
58
54
|
|
|
59
|
-
`);try{Jn(i)}catch{throw new Error(E("errors.copyToSystemClipboardFailed"))}return{storeAction:D.NONE}},predicate:(e,t,r,o)=>rp&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(U),keywords:["text","clipboard","copy"]});f();ge();Ve();Y();De();var tu=H({name:"gridMode",icon:mv,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.gridSize},perform(e,t){return{appState:{...t,gridSize:this.checked(t)?null:On,objectsSnapModeEnabled:!1},storeAction:D.NONE}},checked:e=>e.gridSize!==null,predicate:(e,t,r)=>typeof r.gridModeEnabled>"u",keyTest:e=>e[S.CTRL_OR_CMD]&&e.code===ye.QUOTE});f();ge();De();Ve();var pl=H({name:"zenMode",label:"buttons.zenMode",icon:lv,paletteName:"Toggle zen mode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},storeAction:D.NONE}},checked:e=>e.zenModeEnabled,predicate:(e,t,r)=>typeof r.zenModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.Z});f();ge();De();Ve();var gb=H({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:sv,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridSize:null},storeAction:D.NONE}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,r)=>typeof r.objectsSnapModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.S});f();Ve();ge();De();var ul=H({name:"stats",label:"stats.fullTitle",icon:rv,paletteName:"Toggle stats",viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},storeAction:D.NONE}},checked:e=>e.stats.open,keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.SLASH});f();Y();be();Ae();Je();um();le();G();Ve();ho();De();var fb=H({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>o.scene.getSelectedElements(t).some(i=>sr(i)),perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=o.scene.getNonDeletedElementsMap();return n.forEach(a=>{let s=ae(a,i);if(s){let{width:l,height:c}=Bt(s.originalText,Ie(s),s.lineHeight),d=m0(a.id);pm(a.id);let{x:m,y:p}=Cs(a,s,i);O(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),O(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:t,storeAction:D.CAPTURE}}}),bb=H({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);if(n.length===2){let i=U(n[0])||U(n[1]),a;if(cn(n[0])?a=n[0]:cn(n[1])&&(a=n[1]),i&&a&&ae(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i,a;U(n[0])&&cn(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),O(i,{containerId:a.id,verticalAlign:St.MIDDLE,textAlign:mi.CENTER,autoResize:!0}),O(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return Ot(i,a,o.scene.getNonDeletedElementsMap()),ya(a.id,s),{elements:Lk(e,a,i),appState:{...t,selectedElementIds:{[a.id]:!0}},storeAction:D.CAPTURE}}}),Lk=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===r.id);o.splice(n,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i+1,0,r),Ut(o,X([t,r])),o},Pk=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===t.id);o.splice(n,1);let i=o.findIndex(a=>a.id===r.id);return o.splice(i,0,t),Ut(o,X([t,r])),o},TT=H({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=n.every(a=>U(a));return n.length>0&&i},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=e.slice(),a={};for(let s of n)if(U(s)){let l=to({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:dn("rectangle")?lt.ADAPTIVE_RADIUS:lt.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-ht,y:s.y-ht,width:Gn(s.width,"rectangle"),height:Gn(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(m,{startBinding:p,endBinding:u},!1)})}O(s,{containerId:l.id,verticalAlign:St.MIDDLE,boundElements:null,textAlign:mi.CENTER,autoResize:!0},!1),Ot(s,l,o.scene.getNonDeletedElementsMap()),i=Pk([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...t,selectedElementIds:a},storeAction:D.CAPTURE}}});f();f();G();fc();Ae();ge();Y();it();import{useCallback as ST,useEffect as Dk,useLayoutEffect as _k,useRef as Rk,useState as Nk}from"react";import Ok from"clsx";Xe();Ym();Sa();le();$m();import{jsx as qc,jsxs as IT}from"react/jsx-runtime";var yb=320,CT=85,Eb=5,Bk=42,Fk=500,xb=!1,ru=new Map,AT=({element:e,elementsMap:t,setAppState:r,onLinkOpen:o,setToast:n,updateEmbedValidationStatus:i})=>{let a=Hi(),s=zi(),l=e.link||"",[c,d]=Nk(l),m=Rk(null),p=a.showHyperlinkPopup==="editor",u=ST(()=>{if(!m.current)return;let y=vr(m.current.value)||null;if(!e.link&&y&&ve("hyperlink","create"),kt(e)){if(a.activeEmbeddable?.element===e&&r({activeEmbeddable:null}),!y){O(e,{link:null}),i(e,!1);return}if(!Ps(y,s.validateEmbeddable))y&&n({message:E("toast.unableToEmbed"),closable:!0}),e.link&&ru.set(e.id,e.link),O(e,{link:y}),i(e,!1);else{let{width:w,height:I}=e,A=Kn(y);A?.error instanceof URIError&&n({message:E("toast.unrecognizedLinkFormat"),closable:!0});let C=A?A.intrinsicSize.w/A.intrinsicSize.h:1,L=ru.get(e.id)!==e.link;O(e,{...L?{width:A?.type==="video"?w>I?w:I*C:w,height:A?.type==="video"&&w>I?w/C:I}:{},link:y}),i(e,!0),ru.has(e.id)&&ru.delete(e.id)}}else O(e,{link:y})},[e,n,s.validateEmbeddable,a.activeEmbeddable,r,i]);_k(()=>()=>{u()},[u]),Dk(()=>{let y=null,w=I=>{if(p)return;y&&clearTimeout(y),Hk(e,t,a,[I.clientX,I.clientY])&&(y=window.setTimeout(()=>{r({showHyperlinkPopup:!1})},Fk))};return window.addEventListener("pointermove",w,!1),()=>{window.removeEventListener("pointermove",w,!1),y&&clearTimeout(y)}},[a,e,p,r,t]);let h=ST(()=>{ve("hyperlink","delete"),O(e,{link:null}),p&&(m.current.value=""),r({showHyperlinkPopup:!1})},[r,e,p]),g=()=>{ve("hyperlink","edit","popup-ui"),r({showHyperlinkPopup:"editor"})},{x,y:v}=kT(e,a,t);return a.contextMenu||a.draggingElement||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:IT("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${v}px`,left:`${x}px`,width:yb,padding:Eb},onClick:()=>{!e.link&&!p&&r({showHyperlinkPopup:"editor"})},children:[p?qc("input",{className:Ok("excalidraw-hyperlinkContainer-input"),placeholder:"Type or paste your link here",ref:m,value:c,onChange:y=>d(y.target.value),autoFocus:!0,onKeyDown:y=>{y.stopPropagation(),y[S.CTRL_OR_CMD]&&y.key===S.K&&y.preventDefault(),(y.key===S.ENTER||y.key===S.ESCAPE)&&(u(),r({showHyperlinkPopup:"info"}))}}):e.link?qc("a",{href:vr(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:vm(e.link)?"_self":"_blank",onClick:y=>{if(e.link&&o){let w=$d("excalidraw-link",y.nativeEvent);o({...e,link:vr(e.link)},w),w.defaultPrevented&&y.preventDefault()}},rel:"noopener noreferrer",children:e.link}):qc("div",{className:"excalidraw-hyperlinkContainer-link",children:E("labels.link.empty")}),IT("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!p&&qc(de,{type:"button",title:E("buttons.edit"),"aria-label":E("buttons.edit"),label:E("buttons.edit"),onClick:g,className:"excalidraw-hyperlinkContainer--edit",icon:js}),l&&!kt(e)&&qc(de,{type:"button",title:E("buttons.remove"),"aria-label":E("buttons.remove"),label:E("buttons.remove"),onClick:h,className:"excalidraw-hyperlinkContainer--remove",icon:Qo})]})]})},kT=(e,t,r)=>{let[o,n]=ne(e,r),{x:i,y:a}=Ht({sceneX:o+e.width/2,sceneY:n},t),s=i-t.offsetLeft-yb/2,l=a-t.offsetTop-CT;return{x:s,y:l}},wb=(e,t)=>{let r=pe(e,t);return r[0]?.link?kt(r[0])?"labels.link.editEmbed":"labels.link.edit":kt(r[0])?"labels.link.createEmbed":"labels.link.create"},Jc=null,MT=(e,t,r)=>{Jc&&clearTimeout(Jc),Jc=window.setTimeout(()=>zk(e,t,r),zx)},zk=(e,t,r)=>{if(!e.link)return;let o=al();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=e.link;let[n,i,a,s]=ne(e,r),[l,c,d,m]=Ic([n,i,a,s],e.angle,t),p=Ht({sceneX:l,sceneY:c},t);ob(o,{left:p.x,top:p.y,width:d,height:m},"top"),ve("hyperlink","tooltip","link-icon"),xb=!0},LT=()=>{Jc&&clearTimeout(Jc),xb&&(xb=!1,al().classList.remove("excalidraw-tooltip--visible"))},Hk=(e,t,r,[o,n])=>{let{x:i,y:a}=$e({clientX:o,clientY:n},r),s=15/r.zoom.value;if(Sc(i,a,e,t))return!1;let[l,c,d]=ne(e,t);if(i>=l&&i<=d&&a>=c-CT&&a<=c)return!1;let{x:m,y:p}=kT(e,r,t);return!(o>=m-s&&o<=m+yb+Eb*2+s&&n>=p-s&&n<=p+s+Eb*2+Bk)};le();ge();Xe();De();G();Ve();import{jsx as Uk}from"react/jsx-runtime";var Qc=H({name:"hyperlink",label:(e,t)=>wb(e,t),icon:Gc,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},storeAction:D.CAPTURE},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.K,predicate:(e,t)=>pe(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=pe(e,t);return Uk(de,{type:"button",icon:Gc,"aria-label":E(wb(e,t)),title:`${kt(e[0])?E("labels.link.labelEmbed"):E("labels.link.label")} - ${R("CtrlOrCmd+K")}`,onClick:()=>r(null),selected:o.length===1&&!!o[0].link})}});f();Ae();le();ge();Xe();De();G();Ve();var vb=e=>e.every(t=>!t.locked),Tb=H({name:"toggleElementLock",label:(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return o.length===1&&!re(o[0])?o[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":vb(o)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,t)=>{let r=pe(t,e);return vb(r)?Zs:Na},trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=vb(n),a=X(n);return{elements:e.map(s=>a.has(s.id)?se(s,{locked:i}):s),appState:{...t,selectedLinearElement:i?null:t.selectedLinearElement},storeAction:D.CAPTURE}},keyTest:(e,t,r,o)=>e.key.toLocaleLowerCase()===S.L&&e[S.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),PT=H({name:"unlockAllElements",paletteName:"Unlock all elements",trackEvent:{category:"canvas"},viewMode:!1,icon:Na,predicate:(e,t)=>pe(e,t).length===0&&e.some(o=>o.locked),perform:(e,t)=>{let r=e.filter(o=>o.locked);return{elements:e.map(o=>o.locked?se(o,{locked:!1}):o),appState:{...t,selectedElementIds:Object.fromEntries(r.map(o=>[o.id,!0]))},storeAction:D.CAPTURE}},label:"labels.elementLock.unlockAll"});f();f();import{useEffect as Cu,useRef as jL,useState as Iu}from"react";ge();f();import yL from"clsx";import{useEffect as wL,useState as vL}from"react";f();import{useCallback as Gk,useState as Wk}from"react";var DT=()=>{let[e,t]=Wk(null),r=Gk(o=>t(o),[]);return[e,r]};ge();f();import Vk from"react";import Yk from"clsx";import{jsx as Kk}from"react/jsx-runtime";var tr=Vk.forwardRef(({children:e,padding:t,className:r,style:o},n)=>Kk("div",{className:Yk("Island",r),style:{"--padding":t,...o},ref:n,children:e}));f();ge();import{createPortal as $k}from"react-dom";import Xk from"clsx";import{useRef as Zk}from"react";import{jsx as _T,jsxs as jk}from"react/jsx-runtime";var RT=e=>{let{closeOnClickOutside:t=!0}=e,r=Hp({className:"excalidraw-modal-container"}),o=Zk(document.body.classList.contains("excalidraw-animations-disabled"));if(!r)return null;let n=i=>{i.key===S.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return $k(jk("div",{className:Xk("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[_T("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),_T("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),r)};G();import{useSetAtom as TL}from"jotai";f();import{useState as gL,useCallback as zb,useMemo as w3,useRef as Fb}from"react";f();Br();Ns();import{atom as tM}from"jotai";it();fi();Y();import{useEffect as BT,useRef as FT}from"react";f();ir();import{atom as qk,useAtom as Jk}from"jotai";import{useEffect as Qk,useState as eM}from"react";Ma();var Sb=qk(new Map),NT=async e=>await Vs({elements:e,appState:{exportBackground:!1,viewBackgroundColor:ue.white},files:null,renderEmbeddables:!1}),OT=(e,t,r)=>{let[o,n]=eM();return Qk(()=>{if(t)if(e){let i=r.get(e);i?n(i):(async()=>{let a=await NT(t);a.querySelector(".style-fonts")?.remove(),a&&(r.set(e,a),n(a))})()}else(async()=>{let i=await NT(t);n(i)})()},[e,t,r,n]),o},ou=()=>{let[e]=Jk(Sb,Ge);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:o=>{o.forEach(n=>e.delete(n))},svgCache:e}};G();hc();f();G();var nu=class{jobs=[];running=!1;tick(){if(this.running)return;let t=this.jobs.shift();t?(this.running=!0,t.promise.resolve(Vl(t.jobFactory,...t.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(t,...r){let o=Kd();return this.jobs.push({jobFactory:t,promise:o,args:r}),this.tick(),o}};be();var HT=new dr,Ka=tM({status:"loaded",isInitialized:!1,libraryItems:[]}),ed=e=>ln(e),rM=(e,t)=>!e.find(r=>r.elements.length!==t.elements.length?!1:r.elements.every((o,n)=>o.id===t.elements[n].id&&o.versionNonce===t.elements[n].versionNonce)),UT=(e,t)=>{let r=[];for(let o of t)rM(e,o)&&r.push(o);return[...r,...e]},GT=(e,t)=>{let r=X(t),o={deletedItems:new Map,addedItems:new Map};for(let i of e)r.has(i.id)||o.deletedItems.set(i.id,i);let n=X(e);for(let i of t)n.has(i.id)||o.addedItems.set(i.id,i);return o},Ib=class{currLibraryItems=[];prevLibraryItems=ed(this.currLibraryItems);app;constructor(t){this.app=t}updateQueue=[];getLastUpdateTask=()=>this.updateQueue[this.updateQueue.length-1];notifyListeners=()=>{if(this.updateQueue.length>0)nr.set(Ka,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{nr.set(Ka,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=ed(this.currLibraryItems);let r=ed(this.currLibraryItems);this.app.props.onLibraryChange?.(r),HT.trigger(GT(t,r),r)}catch(t){console.error(t)}}};destroy=()=>{this.updateQueue=[],this.currLibraryItems=[],nr.set(Sb,new Map)};resetLibrary=()=>this.setLibrary([]);getLatestLibrary=()=>new Promise(async t=>{try{let r=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(ed(r))}catch{return t(this.currLibraryItems)}});updateLibrary=async({libraryItems:t,prompt:r=!1,merge:o=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:Xr.name,tab:Hl}}),this.setLibrary(()=>new Promise(async(a,s)=>{try{let l=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),c;l instanceof Blob?c=await Pg(l,i):c=Ia(l,i),!r||window.confirm(E("alerts.confirmAddLibrary",{numShapes:c.length}))?(r&&this.app.focusContainer(),a(o?UT(this.currLibraryItems,c):c)):s(new mn)}catch(l){s(l)}})));setLibrary=t=>{let r=new Promise(async(o,n)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=ed(await t),o(this.currLibraryItems)}catch(i){n(i)}}).catch(o=>{if(o.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw o}).finally(()=>{this.updateQueue=this.updateQueue.filter(o=>o!==r),this.notifyListeners()});return this.updateQueue.push(r),this.notifyListeners(),r}},WT=Ib,su=e=>{let r=Math.ceil(Math.sqrt(e.length)),o=[],n=u=>e.slice(u*r,u*r+r).reduce((g,x)=>{let{height:v}=Rr(x.elements);return Math.max(g,v)},0),i=u=>{let h=0,g=0,x=0;for(let v of e){if(h%r===0&&(g=0),g===u){let{width:y}=Rr(v.elements);x=Math.max(x,y)}h++,g++}return x},a=0,s=0,l=0,c=0,d=0,m=0,p=0;for(let u of e){d&&d%r===0&&(s+=l+50,a=0,m=0,p++),m===0&&(l=n(p)),c=i(m);let{minX:h,minY:g,width:x,height:v}=Rr(u.elements),y=(c-x)/2,w=(l-v)/2;o.push(...u.elements.map(I=>({...I,x:I.x+a+y-h,y:I.y+s+w-g}))),a+=c+50,d++,m++}return o},Cb=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Bd.addLibrary)||new URLSearchParams(window.location.search).get(Od.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},hl=class e{static queue=new nu;static async getLibraryItems(t,r,o=!0){let n=()=>new Promise(async(i,a)=>{try{let s=await t.load({source:r});i(Ia(s?.libraryItems||[],"published"))}catch(s){a(s)}});return o?e.queue.push(n):n()}static run=async(t,r)=>{let o=new e(t);return e.queue.push(()=>r(o))};adapter;constructor(t){this.adapter=t}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}},td=0,iu=0,au=e=>df(e.map(t=>`${t.id}:${cf(t.elements)}`).sort().join()),zT=async(e,t)=>{try{return iu++,await hl.run(e,async r=>{let o=X(await r.getLibraryItems("save"));for(let[s]of t.deletedItems)o.delete(s);let n=[];for(let[s,l]of t.addedItems)o.has(s)?o.set(s,l):n.push(l);let i=n.concat(Array.from(o.values())),a=au(i);return a!==td&&await e.save({libraryItems:i}),td=a,i})}finally{iu--}},oM=e=>{let{excalidrawAPI:t}=e,r=FT(e);r.current=e;let o=FT(!1);BT(()=>{if(!t)return;o.current=!1;let n=async({libraryUrl:s,idToken:l})=>{let c=new Promise(async(m,p)=>{try{let h=await(await fetch(decodeURIComponent(s))).blob();m(h)}catch(u){p(u)}}),d=l!==t.id;await(d&&document.hidden?new Promise(m=>{window.addEventListener("focus",()=>m(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(m){throw m}finally{if(window.location.hash.includes(Bd.addLibrary)){let m=new URLSearchParams(window.location.hash.slice(1));m.delete(Bd.addLibrary),window.history.replaceState({},Nl,`#${m.toString()}`)}else if(window.location.search.includes(Od.addLibrary)){let m=new URLSearchParams(window.location.search);m.delete(Od.addLibrary),window.history.replaceState({},Nl,`?${m.toString()}`)}}},i=s=>{s.preventDefault();let l=Cb();l&&(s.stopImmediatePropagation(),window.history.replaceState({},"",s.oldURL),n(l))},a=Cb();if(a&&n(a),"getInitialLibraryItems"in r.current&&r.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(r.current.getInitialLibraryItems()).then(s=>{t.updateLibrary({libraryItems:s,merge:!0})}).catch(s=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${s?.message}`)})),"adapter"in r.current&&r.current.adapter){let s=r.current.adapter,l=r.current.migrationAdapter,c=Kd();l?c.resolve(Vl(l.load).then(async d=>{let m=null;try{if(!d)return hl.getLibraryItems(s,"load");m=Ia(d.libraryItems||[],"published");let p=await zT(s,GT([],m));try{await l.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),m}}).catch(d=>(console.error(`error during library migration: ${d.message}`),hl.getLibraryItems(s,"load")))):c.resolve(Vl(hl.getLibraryItems,s,"load")),t.updateLibrary({libraryItems:c.then(d=>{let m=d||[];return td=au(m),m}),merge:!0}).finally(()=>{o.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[t]),BT(()=>{let n=HT.on(async(a,s)=>{let l=o.current,c="adapter"in r.current&&r.current.adapter||null;try{c&&td!==au(s)&&await zT(c,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),l&&r.current.excalidrawAPI&&r.current.excalidrawAPI.updateScene({appState:{errorMessage:E("errors.saveLibraryError")}})}}),i=a=>{iu&&a1(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),td=0,iu=0}},[])};zo();f();jn();import{useCallback as El,useEffect as dL,useMemo as b3,useRef as mL,useState as pL}from"react";G();f();import{forwardRef as VT}from"react";import YT from"clsx";import{jsx as KT}from"react/jsx-runtime";var nM=VT(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>KT("div",{className:YT("Stack Stack_horizontal",n),style:{"--gap":t,alignItems:r,justifyContent:o,...i},ref:a,children:e})),iM=VT(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>KT("div",{className:YT("Stack Stack_vertical",n),style:{"--gap":t,justifyItems:r,justifyContent:o,...i},ref:a,children:e})),Kt={Row:nM,Col:iM};Y();jo();f();f();Y();import{jsx as sM}from"react/jsx-runtime";var aM=({theme:e,id:t,libraryReturnUrl:r})=>{let o=r||window.location.origin+window.location.pathname;return sM("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${o}&useHash=true&token=${t}&theme=${e}&version=${ia.excalidrawLibrary}`,target:"_excalidraw_libraries",children:E("labels.libraries")})},$T=aM;import lM from"clsx";import{jsx as cM,jsxs as dM}from"react/jsx-runtime";var lu=({libraryReturnUrl:e,theme:t,id:r,style:o,children:n,className:i})=>dM("div",{className:lM("library-menu-control-buttons",i),style:o,children:[cM($T,{id:r,libraryReturnUrl:e,theme:t}),n]});f();import{useCallback as WM,useState as _b}from"react";f();import cu from"react";var mM=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,pM=/{{([\w-]+)}}/,uM=/<([\w-]+)>/,hM=/<\/([\w-]+)>/,gM=(e,t)=>{let r=[{name:"",children:[]}];return e.split(mM).filter(Boolean).forEach(o=>{let n=o.match(uM),i=o.match(hM),a=o.match(pM);if(n!==null){let s=n[1];t.hasOwnProperty(s)?r.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===r[r.length-1].name){let l=r.pop(),c=cu.createElement(cu.Fragment,{},...l.children),d=t[l.name];typeof d=="function"&&r[r.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];t.hasOwnProperty(s)?r[r.length-1].children.push(t[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else r[r.length-1].children.push(o)}),r.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),r[0].children},fM=({i18nKey:e,children:t,...r})=>{let{t:o}=At();return cu.createElement(cu.Fragment,{},...gM(o(e),r))},Tr=fM;jn();$n();G();import{useAtom as Rb}from"jotai";f();f();import bM from"clsx";import{jsx as du,jsxs as xM}from"react/jsx-runtime";var EM=({label:e,onClick:t,className:r,children:o,actionType:n,type:i="button",isLoading:a,...s})=>{let l=n?`Dialog__action-button--${n}`:"";return xM("button",{className:bM("Dialog__action-button",l,r),type:i,"aria-label":e,onClick:t,...s,children:[o&&du("div",{style:a?{visibility:"hidden"}:{},children:o}),du("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&du("div",{style:{position:"absolute",inset:0},children:du(Xt,{})})]})},gl=EM;import{useSetAtom as yM}from"jotai";import{jsx as XT,jsxs as ZT}from"react/jsx-runtime";var wM=e=>{let{onConfirm:t,onCancel:r,children:o,confirmText:n=E("buttons.confirm"),cancelText:i=E("buttons.cancel"),className:a="",...s}=e,l=Re(),c=yM(fl,Ge),{container:d}=Yt();return ZT(pt,{onCloseRequest:r,size:"small",...s,className:`confirm-dialog ${a}`,children:[o,ZT("div",{className:"confirm-dialog-buttons",children:[XT(gl,{label:i,onClick:()=>{l({openMenu:null}),c(!1),r(),d?.focus()}}),XT(gl,{label:n,onClick:()=>{l({openMenu:null}),c(!1),t(),d?.focus()},actionType:"danger"})]})]})},mu=wM;f();import{useCallback as vM,useEffect as kb,useRef as jT,useState as Ab}from"react";import pu from"open-color";Ma();Y();Br();G();f();var Hr=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),!1}}static get(t){try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):null}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),null}}static set=(t,r)=>{try{return window.localStorage.setItem(t,JSON.stringify(r)),!0}catch(o){return console.warn(`localStorage.setItem error: ${o.message}`),!1}};static delete=t=>{try{window.localStorage.removeItem(t)}catch(r){console.warn(`localStorage.removeItem error: ${r.message}`)}}};import{jsx as Ce,jsxs as ur}from"react/jsx-runtime";var TM=async e=>{let o=Math.round(8),n=Math.max(Math.round(128/64),2),i=o1(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(o*2)-o*2,a.height=i.length*128+(i.length+1)*(o*2)-o*2;let s=a.getContext("2d");s.fillStyle=pu.white,s.fillRect(0,0,a.width,a.height);for(let[l,c]of e.entries()){let d=await Ri({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:m,height:p}=d,u=Math.floor(l/6)*(128+o*2),h=l%6*(128+o*2);s.drawImage(d,h+(128-m)/2+o,u+(128-p)/2+o),s.lineWidth=n,s.strokeStyle=pu.gray[4],s.strokeRect(h+o/2,u+o/2,128+o,128+o)}return await vc(new File([await Zn(a)],"preview",{type:oe.png}),{outputType:oe.jpg,maxWidthOrHeight:5e3})},SM=({libItem:e,appState:t,index:r,onChange:o,onRemove:n})=>{let i=jT(null),a=jT(null);return kb(()=>{let s=i.current;s&&(async()=>{let l=await Vs({elements:e.elements,appState:{...t,viewBackgroundColor:pu.white,exportBackground:!0},files:null});s.innerHTML=l.outerHTML})()},[e.elements,t]),ur("div",{className:"single-library-item",children:[e.status==="published"&&Ce("span",{className:"single-library-item-status",children:E("labels.statusPublished")}),Ce("div",{ref:i,className:"single-library-item__svg"}),Ce(de,{"aria-label":E("buttons.remove"),type:"button",icon:yo,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:E("buttons.remove")}),ur("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[ur("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[ur("div",{style:{padding:"0.5em 0"},children:[Ce("span",{style:{fontWeight:500,color:pu.gray[6]},children:E("publishDialog.itemName")}),Ce("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ce("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:s=>{o(s.target.value,r)}})]}),Ce("span",{className:"error",children:e.error})]})]})},IM=({onClose:e,libraryItems:t,appState:r,onSuccess:o,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[s,l]=Ab({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=Ab(!1);kb(()=>{let w=Hr.get(lo.PUBLISH_LIBRARY);w&&l(w)},[]);let[m,p]=Ab(t.slice());kb(()=>{p(t.slice())},[t]);let u=w=>{l({...s,[w.target.name]:w.target.value})},h=async w=>{w.preventDefault(),d(!0);let I=[],A=!1;if(m.forEach(N=>{let B="";N.name||(B=E("publishDialog.errors.required"),A=!0),I.push({...N,error:B})}),A){p(I),d(!1);return}let C=await TM(m),L={type:ar.excalidrawLibrary,version:ia.excalidrawLibrary,source:zl,libraryItems:m},M=JSON.stringify(L,null,2),z=new Blob([M],{type:"application/json"}),k=new FormData;k.append("excalidrawLib",z),k.append("previewImage",C),k.append("previewImageType",C.type),k.append("title",s.name),k.append("authorName",s.authorName),k.append("githubHandle",s.githubHandle),k.append("name",s.name),k.append("description",s.description),k.append("twitterHandle",s.twitterHandle),k.append("website",s.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:k}).then(N=>N.ok?N.json().then(({url:B})=>{Hr.delete(lo.PUBLISH_LIBRARY),o({url:B,authorName:s.authorName,items:m})}):N.json().catch(()=>{throw new Error(N.statusText||"something went wrong")}).then(B=>{throw new Error(B.message||N.statusText||"something went wrong")}),N=>{console.error(N),n(N),d(!1)}).catch(N=>{console.error(N),n(N),d(!1)})},g=()=>{let w=[];return m.forEach((I,A)=>{w.push(Ce("div",{className:"single-library-item-wrapper",children:Ce(SM,{libItem:I,appState:r,index:A,onChange:(C,L)=>{let M=m.slice();M[L].name=C,p(M)},onRemove:a})},A))}),Ce("div",{className:"selected-library-items",children:w})},x=vM(()=>{i(m),Hr.set(lo.PUBLISH_LIBRARY,s),e()},[m,e,i,s]),v=!!t.length,y=t.some(w=>w.status==="published");return Ce(pt,{onCloseRequest:x,title:E("publishDialog.title"),className:"publish-library",children:v?ur("form",{onSubmit:h,children:[Ce("div",{className:"publish-library-note",children:Ce(Tr,{i18nKey:"publishDialog.noteDescription",link:w=>Ce("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:w})})}),Ce("span",{className:"publish-library-note",children:Ce(Tr,{i18nKey:"publishDialog.noteGuidelines",link:w=>Ce("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:w})})}),Ce("div",{className:"publish-library-note",children:E("publishDialog.noteItems")}),y&&Ce("span",{className:"publish-library-note publish-library-warning",children:E("publishDialog.republishWarning")}),g(),ur("div",{className:"publish-library__fields",children:[ur("label",{children:[ur("div",{children:[Ce("span",{children:E("publishDialog.libraryName")}),Ce("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ce("input",{type:"text",name:"name",required:!0,value:s.name,onChange:u,placeholder:E("publishDialog.placeholder.libraryName")})]}),ur("label",{style:{alignItems:"flex-start"},children:[ur("div",{children:[Ce("span",{children:E("publishDialog.libraryDesc")}),Ce("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ce("textarea",{name:"description",rows:4,required:!0,value:s.description,onChange:u,placeholder:E("publishDialog.placeholder.libraryDesc")})]}),ur("label",{children:[ur("div",{children:[Ce("span",{children:E("publishDialog.authorName")}),Ce("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ce("input",{type:"text",name:"authorName",required:!0,value:s.authorName,onChange:u,placeholder:E("publishDialog.placeholder.authorName")})]}),ur("label",{children:[Ce("span",{children:E("publishDialog.githubUsername")}),Ce("input",{type:"text",name:"githubHandle",value:s.githubHandle,onChange:u,placeholder:E("publishDialog.placeholder.githubHandle")})]}),ur("label",{children:[Ce("span",{children:E("publishDialog.twitterUsername")}),Ce("input",{type:"text",name:"twitterHandle",value:s.twitterHandle,onChange:u,placeholder:E("publishDialog.placeholder.twitterHandle")})]}),ur("label",{children:[Ce("span",{children:E("publishDialog.website")}),Ce("input",{type:"text",name:"website",pattern:"https?://.+",title:E("publishDialog.errors.website"),value:s.website,onChange:u,placeholder:E("publishDialog.placeholder.website")})]}),Ce("span",{className:"publish-library-note",children:Ce(Tr,{i18nKey:"publishDialog.noteLicense",link:w=>Ce("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:w})})})]}),ur("div",{className:"publish-library__buttons",children:[Ce(gl,{label:E("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),Ce(gl,{type:"submit",label:E("buttons.submit"),actionType:"primary",isLoading:c})]})]}):Ce("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:E("publishDialog.atleastOneLibItem")})})},qT=IM;f();f();import CM from"clsx";import{jsx as AM}from"react/jsx-runtime";var JT=({className:e="",children:t,onToggle:r,title:o,...n})=>{let i=_e(),a=CM(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return AM("button",{"data-prevent-outside-click":!0,className:a,onClick:r,type:"button","data-testid":"dropdown-menu-button",title:o,...n,children:t})},QT=JT;JT.displayName="DropdownMenuTrigger";f();f();Y();G();import kM,{useContext as MM}from"react";var Mb=kM.createContext({}),uu=(e="",t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?"dropdown-menu-item--selected":""}`.trim(),hu=(e,t)=>{let r=MM(Mb);return hi(e,o=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});t?.(n),n.defaultPrevented||r.onSelect?.(n)})};f();import{Fragment as PM,jsx as Lb,jsxs as DM}from"react/jsx-runtime";var LM=({icon:e,shortcut:t,children:r})=>{let o=_e();return DM(PM,{children:[Lb("div",{className:"dropdown-menu-item__icon",children:e}),Lb("div",{className:"dropdown-menu-item__text",children:r}),t&&!o.editor.isMobile&&Lb("div",{className:"dropdown-menu-item__shortcut",children:t})]})},gu=LM;import{jsx as Pb}from"react/jsx-runtime";var Db=({icon:e,onSelect:t,children:r,shortcut:o,className:n,selected:i,...a})=>{let s=hu(a.onClick,t);return Pb("button",{...a,onClick:s,type:"button",className:uu(n,i),title:a.title??a["aria-label"],children:Pb(gu,{icon:e,shortcut:o,children:r})})};Db.displayName="DropdownMenuItem";var e3=({children:e})=>Pb("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",background:"var(--color-promo)",color:"var(--color-surface-lowest)",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace"},children:e});e3.displayName="DropdownMenuItemBadge";Db.Badge=e3;var Io=Db;f();import{jsx as _M}from"react/jsx-runtime";var t3=()=>_M("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),r3=t3;t3.displayName="DropdownMenuSeparator";f();import{jsx as RM,jsxs as NM}from"react/jsx-runtime";var o3=({children:e,className:t="",style:r,title:o})=>NM("div",{className:`dropdown-menu-group ${t}`,style:r,children:[o&&RM("p",{className:"dropdown-menu-group-title",children:o}),e]}),n3=o3;o3.displayName="DropdownMenuGroup";f();import OM from"clsx";import{useEffect as BM,useRef as FM}from"react";ge();Y();import{jsx as fu}from"react/jsx-runtime";var i3=({children:e,onClickOutside:t,className:r="",onSelect:o,style:n})=>{let i=_e(),a=FM(null),s=il({onClickOutside:t});nl(a,()=>{s.onClickOutside?.()}),BM(()=>{let c=m=>{m.key===S.ESCAPE&&(m.stopImmediatePropagation(),s.onClickOutside?.())},d={capture:!0};return document.addEventListener("keydown",c,d),()=>{document.removeEventListener("keydown",c,d)}},[s]);let l=OM(`dropdown-menu ${r}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return fu(Mb.Provider,{value:{onSelect:o},children:fu("div",{ref:a,className:l,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?fu(Kt.Col,{className:"dropdown-menu-container",children:e}):fu(tr,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};i3.displayName="DropdownMenuContent";var a3=i3;f();import{jsx as s3}from"react/jsx-runtime";var l3=({icon:e,shortcut:t,href:r,children:o,onSelect:n,className:i="",selected:a,...s})=>{let l=hu(s.onClick,n);return s3("a",{...s,href:r,target:"_blank",rel:"noreferrer",className:uu(i,a),title:s.title??s["aria-label"],onClick:l,children:s3(gu,{icon:e,shortcut:t,children:o})})},bl=l3;l3.displayName="DropdownMenuItemLink";f();import{jsx as HM}from"react/jsx-runtime";var zM=({children:e,className:t="",selected:r,...o})=>HM("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${r?"dropdown-menu-item--selected":""}`.trim(),children:e}),c3=zM;f();import bu from"react";var d3=e=>{let t=bu.Children.toArray(e).find(r=>bu.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuTrigger");return t||null},m3=e=>{let t=bu.Children.toArray(e).find(r=>bu.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuContent");return t||null};import{Fragment as UM,jsxs as GM}from"react/jsx-runtime";var oi=({children:e,open:t})=>{let r=d3(e),o=m3(e);return GM(UM,{children:[r,t&&o]})};oi.Trigger=QT;oi.Content=a3;oi.Item=Io;oi.ItemLink=bl;oi.ItemCustom=c3;oi.Group=n3;oi.Separator=r3;var Ue=oi;oi.displayName="DropdownMenu";import VM from"clsx";import{jsx as Ur,jsxs as Eu}from"react/jsx-runtime";var YM=(e,t)=>e.filter(r=>t.includes(r.id)),KM=({setAppState:e,selectedItems:t,library:r,onRemoveFromLibrary:o,resetLibrary:n,onSelectItems:i,appState:a,className:s})=>{let[l]=Rb(Ka,Ge),[c,d]=Rb(fl,Ge),m=()=>{let k=t.length?E("alerts.removeItemsFromsLibrary",{count:t.length}):E("alerts.resetLibrary"),N=t.length?E("confirmDialog.removeItemsFromLib"):E("confirmDialog.resetLibrary");return Ur(mu,{onConfirm:()=>{t.length?o():n(),u(!1)},onCancel:()=>{u(!1)},title:N,children:Ur("p",{children:k})})},[p,u]=_b(!1),h=!!t.length,g=h?l.libraryItems.filter(k=>t.includes(k.id)):l.libraryItems,x=h?E("buttons.remove"):E("buttons.resetLibrary"),[v,y]=_b(!1),[w,I]=_b(null),A=WM(()=>Eu(pt,{onCloseRequest:()=>I(null),title:E("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Ur("p",{children:Ur(Tr,{i18nKey:"publishSuccessDialog.content",authorName:w.authorName,link:k=>Ur("a",{href:w?.url,target:"_blank",rel:"noopener noreferrer",children:k})})}),Ur(de,{type:"button",title:E("buttons.close"),"aria-label":E("buttons.close"),label:E("buttons.close"),onClick:()=>I(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[I,w]),C=(k,N)=>{y(!1),I({url:k.url,authorName:k.authorName});let B=N.slice();B.forEach(_=>{t.includes(_.id)&&(_.status="published")}),r.setLibrary(B)},L=async()=>{try{await r.updateLibrary({libraryItems:Ds({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(k){if(k?.name==="AbortError"){console.warn(k);return}e({errorMessage:E("errors.importLibraryError")})}},M=async()=>{let k=h?g:await r.getLatestLibrary();gy(k).catch(Yd).catch(N=>{e({errorMessage:N.message})})},z=()=>Eu(Ue,{open:c,children:[Ur(Ue.Trigger,{onToggle:()=>d(!c),children:Pw}),Eu(Ue.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!h&&Ur(Ue.Item,{onSelect:L,icon:Js,"data-testid":"lib-dropdown--load",children:E("buttons.load")}),!!g.length&&Ur(Ue.Item,{onSelect:M,icon:Oa,"data-testid":"lib-dropdown--export",children:E("buttons.export")}),!!g.length&&Ur(Ue.Item,{onSelect:()=>u(!0),icon:Qo,children:x}),h&&Ur(Ue.Item,{icon:G2,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:E("buttons.publishLibrary")})]})]});return Eu("div",{className:VM("library-menu-dropdown-container",s),children:[z(),t.length>0&&Ur("div",{className:"library-actions-counter",children:t.length}),p&&m(),v&&Ur(qT,{onClose:()=>y(!1),libraryItems:YM(l.libraryItems,t),appState:a,onSuccess:k=>C(k,l.libraryItems),onError:k=>window.alert(k),updateItemsInStorage:()=>r.setLibrary(l.libraryItems),onRemove:k=>i(t.filter(N=>N!==k))}),w&&A()]})},Nb=({selectedItems:e,onSelectItems:t,className:r})=>{let{library:o}=pr(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=ou(),a=Be(),s=Re(),[l]=Rb(Ka,Ge),c=async m=>{let p=m.filter(u=>!e.includes(u.id));o.setLibrary(p).catch(()=>{s({errorMessage:E("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return Ur(KM,{appState:a,setAppState:s,selectedItems:e,onSelectItems:t,library:o,onRemoveFromLibrary:()=>c(l.libraryItems),resetLibrary:()=>{o.resetLibrary(),n()},className:r})};f();import{memo as tL,useEffect as rL,useState as oL}from"react";f();import p3 from"clsx";import{memo as $M,useEffect as XM,useRef as ZM,useState as jM}from"react";import{jsx as xu,jsxs as qM}from"react/jsx-runtime";var u3=$M(({id:e,elements:t,isPending:r,onClick:o,selected:n,onToggle:i,onDrag:a,svgCache:s})=>{let l=ZM(null),c=OT(e,t,s);XM(()=>{let h=l.current;if(h)return c&&(h.innerHTML=c.outerHTML),()=>{h.innerHTML=""}},[c]);let[d,m]=jM(!1),p=_e().editor.isMobile,u=r&&xu("div",{className:"library-unit__adder",children:Lw});return qM("div",{className:p3("library-unit",{"library-unit__active":t,"library-unit--hover":t&&d,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[xu("div",{className:p3("library-unit__dragger",{"library-unit__pulse":!!r}),ref:l,draggable:!!t,onClick:t||r?h=>{e&&h.shiftKey?i(e,h):o(e)}:void 0,onDragStart:h=>{if(!e){h.preventDefault();return}m(!1),a(e,h)}}),u,e&&t&&(d||p||n)&&xu(Wa,{checked:n,onChange:(h,g)=>i(e,g),className:"library-unit__checkbox"})]})}),h3=()=>xu("div",{className:"library-unit library-unit--skeleton"});f();import JM,{useCallback as QM}from"react";function eL(){return[!1,QM(t=>t(),[])]}var g3=JM.useTransition||eL;import{Fragment as nL,jsx as yu}from"react/jsx-runtime";var Ob=({children:e})=>yu("div",{className:"library-menu-items-container__grid",children:e}),wu=tL(({items:e,onItemSelectToggle:t,onItemDrag:r,isItemSelected:o,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,s]=g3(),[l,c]=oL(0);return rL(()=>{l<e.length&&s(()=>{c(l+a)})},[l,e.length,s,a]),yu(nL,{children:e.map((d,m)=>m<l?yu(u3,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:n,svgCache:i,id:d?.id,selected:o(d.id),onToggle:t,onDrag:r},d?.id??m):yu(h3,{},m))})});f();import{useEffect as iL}from"react";import{atom as aL,useAtom as sL}from"jotai";import lL from"lodash.throttle";var cL=aL(0),f3=e=>{let[t,r]=sL(cL);return iL(()=>{let{current:o}=e;if(!o)return;let n=lL(()=>{let{scrollTop:i}=o;r(i)},200);return o.addEventListener("scroll",n),()=>{n.cancel(),o.removeEventListener("scroll",n)}},[e,r]),t};import{Fragment as E3,jsx as Gr,jsxs as xl}from"react/jsx-runtime";var uL=17,hL=64;function Bb({isLoading:e,libraryItems:t,onAddToLibrary:r,onInsertLibraryItems:o,pendingElements:n,theme:i,id:a,libraryReturnUrl:s,onSelectItems:l,selectedItems:c}){let d=mL(null),m=f3(d);dL(()=>{m>0&&d.current?.scrollTo(0,m)},[]);let{svgCache:p}=ou(),u=b3(()=>t.filter(k=>k.status!=="published"),[t]),h=b3(()=>t.filter(k=>k.status==="published"),[t]),g=!t.length&&!n.length,x=!n.length&&!u.length&&!h.length,[v,y]=pL(null),w=El((k,N)=>{let B=!c.includes(k),_=[...u,...h];if(B){if(N.shiftKey&&v){let V=_.findIndex(W=>W.id===v),Z=_.findIndex(W=>W.id===k);if(V===-1||Z===-1){l([...c,k]);return}let J=X(c),Se=_.reduce((W,$,ee)=>((ee>=V&&ee<=Z||J.has($.id))&&W.push($.id),W),[]);l(Se)}else l([...c,k]);y(k)}else y(null),l(c.filter(V=>V!==k))},[v,l,h,c,u]),I=El(k=>{let N;return c.includes(k)?N=t.filter(B=>c.includes(B.id)):N=t.filter(B=>B.id===k),N.map(B=>({...B,elements:Mm(B.elements,{randomizeSeed:!0})}))},[t,c]),A=El((k,N)=>{N.dataTransfer.setData(oe.excalidrawlib,Hm(I(k)))},[I]),C=El(k=>k?c.includes(k):!1,[c]),L=El(()=>{r(n)},[n,r]),M=El(k=>{k&&o(I(k))},[I,o]),z=p.size>=t.length?hL:uL;return xl("div",{className:"library-menu-items-container",style:n.length||u.length||h.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&Gr(Nb,{selectedItems:c,onSelectItems:l,className:"library-menu-dropdown-container--in-heading"}),xl(Kt.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:h.length>0?1:"0 1 auto",marginBottom:0},ref:d,children:[xl(E3,{children:[!x&&Gr("div",{className:"library-menu-items-container__header",children:E("labels.personalLib")}),e&&Gr("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Gr(Xt,{})}),!n.length&&!u.length?xl("div",{className:"library-menu-items__no-items",children:[Gr("div",{className:"library-menu-items__no-items__label",children:E("library.noItems")}),Gr("div",{className:"library-menu-items__no-items__hint",children:h.length>0?E("library.hint_emptyPrivateLibrary"):E("library.hint_emptyLibrary")})]}):xl(Ob,{children:[n.length>0&&Gr(wu,{itemsRenderedPerBatch:z,items:[{id:null,elements:n}],onItemSelectToggle:w,onItemDrag:A,onClick:L,isItemSelected:C,svgCache:p}),Gr(wu,{itemsRenderedPerBatch:z,items:u,onItemSelectToggle:w,onItemDrag:A,onClick:M,isItemSelected:C,svgCache:p})]})]}),xl(E3,{children:[(h.length>0||n.length>0||u.length>0)&&Gr("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:E("labels.excalidrawLib")}),h.length>0?Gr(Ob,{children:Gr(wu,{itemsRenderedPerBatch:z,items:h,onItemSelectToggle:w,onItemDrag:A,onClick:M,isItemSelected:C,svgCache:p})}):u.length>0?Gr("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:E("library.noItems")}):null]}),g&&Gr(lu,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:s,theme:i,children:Gr(Nb,{selectedItems:c,onSelectItems:l})})]})]})}import{atom as fL,useAtom as bL}from"jotai";Xe();G();Y();import{jsx as Ui,jsxs as y3}from"react/jsx-runtime";var fl=fL(!1),x3=({children:e})=>Ui("div",{className:"layer-ui__library",children:e}),EL=({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:r,setAppState:o,libraryReturnUrl:n,library:i,id:a,theme:s,selectedItems:l,onSelectItems:c})=>{let[d]=bL(Ka,Ge),m=zb(h=>{(async(x,v)=>{ve("element","addToLibrary","ui");for(let w of Hd)if(x.some(I=>I.type===w))return o({errorMessage:E(`errors.libraryElementTypeError.${w}`)});let y=[{status:"unpublished",elements:x,id:Nt(),created:Date.now()},...v];r(),i.setLibrary(y).catch(()=>{o({errorMessage:E("alerts.errorAddingToLibrary")})})})(h,d.libraryItems)},[r,i,o,d.libraryItems]),p=w3(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return Ui(x3,{children:Ui("div",{className:"layer-ui__library-message",children:y3("div",{children:[Ui(Xt,{size:"2em"}),Ui("span",{children:E("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||t.length>0;return y3(x3,{children:[Ui(Bb,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:m,onInsertLibraryItems:e,pendingElements:t,id:a,libraryReturnUrl:n,theme:s,onSelectItems:c,selectedItems:l}),u&&Ui(lu,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:s})]})},xL=(e,t)=>{let r=()=>pe(t,e,{includeBoundTextElement:!0,includeElementsInFrames:!0}),o=Fb(r()),n=Fb(e),i=Fb(t);return(!tt(e.selectedElementIds,n.current.selectedElementIds)||!tt(t,i.current))&&(o.current=r(),n.current=e,i.current=t),o.current},v3=()=>{let{library:e,id:t,onInsertElements:r}=pr(),o=zi(),n=Be(),i=Re(),a=Bi(),[s,l]=gL([]),c=w3(()=>e,[e]),d=xL(n,a),m=zb(u=>{r(su(u))},[r]),p=zb(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return Ui(EL,{pendingElements:d,onInsertLibraryItems:m,onAddToLibrary:p,setAppState:i,libraryReturnUrl:o.libraryReturnUrl,library:c,id:t,theme:n.theme,selectedItems:s,onSelectItems:l})};import{jsx as rd,jsxs as IL}from"react/jsx-runtime";function SL(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var pt=e=>{let[t,r]=DT(),[o]=vL(document.activeElement),{id:n}=Yt(),i=_e().viewport.isMobile;wL(()=>{if(!t)return;let c=Gl(t);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=m=>{if(m.key===S.TAB){let p=Gl(t),{activeElement:u}=document,h=p.findIndex(g=>g===u);h===0&&m.shiftKey?(p[p.length-1].focus(),m.preventDefault()):h===p.length-1&&!m.shiftKey&&(p[0].focus(),m.preventDefault())}};return t.addEventListener("keydown",d),()=>t.removeEventListener("keydown",d)},[t,e.autofocus]);let a=Re(),s=TL(fl,Ge),l=()=>{a({openMenu:null}),s(!1),o.focus(),e.onCloseRequest()};return rd(RT,{className:yL("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:SL(e.size),onCloseRequest:l,closeOnClickOutside:e.closeOnClickOutside,children:IL(tr,{ref:r,children:[e.title&&rd("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:rd("span",{className:"Dialog__titleContent",children:e.title})}),i&&rd("button",{className:"Dialog__close",onClick:l,title:E("buttons.close"),"aria-label":E("buttons.close"),type:"button",children:yo}),rd("div",{className:"Dialog__content",children:e.children})]})})};f();import{forwardRef as kL,useRef as ML,useImperativeHandle as LL,useLayoutEffect as PL,useState as DL}from"react";import Hb from"clsx";f();G();import CL from"clsx";import{jsx as AL}from"react/jsx-runtime";var Sn=({type:e="button",onSelect:t,selected:r,children:o,className:n="",...i})=>AL("button",{onClick:hi(i.onClick,a=>{t()}),type:e,className:CL("excalidraw-button",n,{selected:r}),...i,children:o});import{jsx as Ub,jsxs as T3}from"react/jsx-runtime";var vu=kL(({onChange:e,label:t,fullWidth:r,placeholder:o,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,...l},c)=>{let d=ML(null);LL(c,()=>d.current),PL(()=>{i&&d.current?.select()},[i]);let[m,p]=DL(!1);return T3("div",{className:Hb("ExcTextField",{"ExcTextField--fullWidth":r}),onClick:()=>{d.current?.focus()},children:[Ub("div",{className:"ExcTextField__label",children:t}),T3("div",{className:Hb("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[Ub("input",{className:Hb({"is-redacted":"value"in l&&l.value&&s&&!m}),readOnly:n,value:"value"in l?l.value:void 0,defaultValue:"defaultValue"in l?l.defaultValue:void 0,placeholder:o,ref:d,onChange:u=>e?.(u.target.value),onKeyDown:a}),s&&Ub(Sn,{onSelect:()=>p(!m),style:{border:0,userSelect:"none"},children:m?Z2:tl})]})]})});Xe();import D3 from"clsx";f();Y();G();var _L={toggleTheme:[R("Shift+Alt+D")],saveScene:[R("CtrlOrCmd+S")],loadScene:[R("CtrlOrCmd+O")],clearCanvas:[R("CtrlOrCmd+Delete")],imageExport:[R("CtrlOrCmd+Shift+E")],commandPalette:[R("CtrlOrCmd+/"),R("CtrlOrCmd+Shift+P")],cut:[R("CtrlOrCmd+X")],copy:[R("CtrlOrCmd+C")],paste:[R("CtrlOrCmd+V")],copyStyles:[R("CtrlOrCmd+Alt+C")],pasteStyles:[R("CtrlOrCmd+Alt+V")],selectAll:[R("CtrlOrCmd+A")],deleteSelectedElements:[R("Delete")],duplicateSelection:[R("CtrlOrCmd+D"),R(`Alt+${E("helpDialog.drag")}`)],sendBackward:[R("CtrlOrCmd+[")],bringForward:[R("CtrlOrCmd+]")],sendToBack:[br?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")],bringToFront:[br?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")],copyAsPng:[R("Shift+Alt+C")],copyAsSvg:[],group:[R("CtrlOrCmd+G")],ungroup:[R("CtrlOrCmd+Shift+G")],gridMode:[R("CtrlOrCmd+'")],zenMode:[R("Alt+Z")],objectsSnapMode:[R("Alt+S")],stats:[R("Alt+/")],addToLibrary:[],flipHorizontal:[R("Shift+H")],flipVertical:[R("Shift+V")],viewMode:[R("Alt+R")],hyperlink:[R("CtrlOrCmd+K")],toggleElementLock:[R("CtrlOrCmd+Shift+L")],resetZoom:[R("CtrlOrCmd+0")],zoomOut:[R("CtrlOrCmd+-")],zoomIn:[R("CtrlOrCmd++")],zoomToFitSelection:[R("Shift+3")],zoomToFit:[R("Shift+1")],zoomToFitSelectionInViewport:[R("Shift+2")],toggleEraserTool:[R("E")],toggleHandTool:[R("H")],setFrameAsActiveTool:[R("F")],saveFileToDisk:[R("CtrlOrCmd+S")],saveToActiveFile:[R("CtrlOrCmd+S")],toggleShortcuts:[R("?")]},Pt=(e,t=0)=>{let r=_L[e];return r&&r.length>0?r[t]||r[0]:""};Y();import qL from"fuzzy";G();import{atom as JL,useAtom as QL}from"jotai";f();var RL="\\u0300-\\u036f",NL="\\ufe20-\\ufe2f",OL="\\u20d0-\\u20ff",BL=RL+NL+OL,FL=`[${BL}]`,zL=RegExp(FL,"g"),HL=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,UL={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},Gb=e=>e.replace(HL,t=>UL[t]||t).replace(zL,"");f();import{jsx as GL}from"react/jsx-runtime";var Co=({icon:e})=>GL("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});f();ge();var od=[{icon:Ow,value:"selection",key:S.V,numericKey:S[1],fillable:!0},{icon:Bw,value:"rectangle",key:S.R,numericKey:S[2],fillable:!0},{icon:Fw,value:"diamond",key:S.D,numericKey:S[3],fillable:!0},{icon:zw,value:"ellipse",key:S.O,numericKey:S[4],fillable:!0},{icon:Hw,value:"arrow",key:S.A,numericKey:S[5],fillable:!0},{icon:Uw,value:"line",key:S.L,numericKey:S[6],fillable:!0},{icon:js,value:"freedraw",key:[S.P,S.X],numericKey:S[7],fillable:!1},{icon:Ww,value:"text",key:S.T,numericKey:S[8],fillable:!1},{icon:Vw,value:"image",key:null,numericKey:S[9],fillable:!1},{icon:Yw,value:"eraser",key:S.E,numericKey:S[0],fillable:!1}],S3=e=>od.find((r,o)=>r.numericKey!=null&&e===r.numericKey.toString()||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null;f();import{useState as WL}from"react";Xe();G();Jl();le();import Yb from"clsx";Je();ge();f();import Wb from"react";import In from"tunnel-rat";var Vb=Wb.createContext(null),at=()=>Wb.useContext(Vb),I3=()=>Wb.useMemo(()=>({MainMenuTunnel:In(),WelcomeScreenMenuHintTunnel:In(),WelcomeScreenToolbarHintTunnel:In(),WelcomeScreenHelpHintTunnel:In(),WelcomeScreenCenterTunnel:In(),FooterCenterTunnel:In(),DefaultSidebarTriggerTunnel:In(),DefaultSidebarTabTriggersTunnel:In(),OverwriteConfirmDialogTunnel:In(),TTDDialogTriggerTunnel:In(),jotaiScope:Symbol()}),[]);import{Fragment as Gi,jsx as ct,jsxs as Ct}from"react/jsx-runtime";var Kb=(e,t)=>{let r=t[0]?.type||null;for(let o of t)if(o.type!==r){r=null;break}return ql(e.activeTool.type)&&e.activeTool.type!=="image"&&r!=="image"&&r!=="frame"&&r!=="magicframe"||t.some(o=>ql(o.type))},$b=(e,t)=>zn(e.activeTool.type)||t.some(r=>zn(r.type)),Tu=({appState:e,elementsMap:t,renderAction:r})=>{let o=Oc(t,e),n=!1;o.length===2&&(sr(o[0])||sr(o[1]))&&(n=!0);let i=!!e.editingElement,a=_e(),s=document.documentElement.getAttribute("dir")==="rtl",l=zn(e.activeTool.type)&&!Er(e.currentItemBackgroundColor)||o.some(m=>zn(m.type)&&!Er(m.backgroundColor)),c=o.length===1||n,d=!e.editingLinearElement&&o.length===1&&ie(o[0]);return Ct("div",{className:"panelColumn",children:[ct("div",{children:Kb(e,o)&&r("changeStrokeColor")}),$b(e,o)&&ct("div",{children:r("changeBackgroundColor")}),l&&r("changeFillStyle"),(em(e.activeTool.type)||o.some(m=>em(m.type)))&&r("changeStrokeWidth"),(e.activeTool.type==="freedraw"||o.some(m=>m.type==="freedraw"))&&r("changeStrokeShape"),(tm(e.activeTool.type)||o.some(m=>tm(m.type)))&&Ct(Gi,{children:[r("changeStrokeStyle"),r("changeSloppiness")]}),(fs(e.activeTool.type)||o.some(m=>fs(m.type)))&&ct(Gi,{children:r("changeRoundness")}),(e.activeTool.type==="text"||o.some(U))&&Ct(Gi,{children:[r("changeFontSize"),r("changeFontFamily"),(e.activeTool.type==="text"||E0(o,t))&&r("changeTextAlign")]}),b0(o,t)&&r("changeVerticalAlign"),(ca(e.activeTool.type)||o.some(m=>ca(m.type)))&&ct(Gi,{children:r("changeArrowhead")}),r("changeOpacity"),Ct("fieldset",{children:[ct("legend",{children:E("labels.layers")}),Ct("div",{className:"buttonList",children:[r("sendToBack"),r("sendBackward"),r("bringForward"),r("bringToFront")]})]}),o.length>1&&!n&&Ct("fieldset",{children:[ct("legend",{children:E("labels.align")}),Ct("div",{className:"buttonList",children:[s?Ct(Gi,{children:[r("alignRight"),r("alignHorizontallyCentered"),r("alignLeft")]}):Ct(Gi,{children:[r("alignLeft"),r("alignHorizontallyCentered"),r("alignRight")]}),o.length>2&&r("distributeHorizontally"),ct("div",{style:{flexBasis:"100%",height:0}}),Ct("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[r("alignTop"),r("alignVerticallyCentered"),r("alignBottom"),o.length>2&&r("distributeVertically")]})]})]}),!i&&o.length>0&&Ct("fieldset",{children:[ct("legend",{children:E("labels.actions")}),Ct("div",{className:"buttonList",children:[!a.editor.isMobile&&r("duplicateSelection"),!a.editor.isMobile&&r("deleteSelectedElements"),r("group"),r("ungroup"),c&&r("hyperlink"),d&&r("toggleLinearEditor")]})]})]})},Su=({activeTool:e,appState:t,app:r,UIOptions:o})=>{let[n,i]=WL(!1),a=e.type==="frame",s=e.type==="laser",l=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=at();return Ct(Gi,{children:[od.map(({value:d,icon:m,key:p,numericKey:u,fillable:h},g)=>{if(o.tools?.[d]===!1)return null;let x=E(`toolBar.${d}`),v=p&&ui(typeof p=="string"?p:p[0]),y=v?`${v} ${E("helpDialog.or")} ${u}`:`${u}`;return ct(de,{className:Yb("Shape",{fillable:h}),type:"radio",icon:m,checked:e.type===d,name:"editor-current-shape",title:`${ui(x)} \u2014 ${y}`,keyBindingLabel:u||v,"aria-label":ui(x),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:w})=>{!t.penDetected&&w==="pen"&&r.togglePenMode(!0)},onChange:({pointerType:w})=>{t.activeTool.type!==d&&ve("toolbar",d,"ui"),d==="image"?r.setActiveTool({type:d,insertOnCanvasDirectly:w!=="mouse"}):r.setActiveTool({type:d})}},d)}),ct("div",{className:"App-toolbar__divider"}),Ct(Ue,{open:n,children:[Ct(Ue.Trigger,{className:Yb("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||l||s&&!r.props.isCollaborating}),onToggle:()=>i(!n),title:E("toolBar.extraTools"),children:[$2,r.props.aiEnabled!==!1&&ct("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:8,fontFamily:"Cascadia, monospace",position:"absolute",background:"var(--color-promo)",color:"var(--color-surface-lowest)",bottom:3,right:4},children:"AI"})]}),Ct(Ue.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[ct(Ue.Item,{onSelect:()=>r.setActiveTool({type:"frame"}),icon:Dp,shortcut:S.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:E("toolBar.frame")}),ct(Ue.Item,{onSelect:()=>r.setActiveTool({type:"embeddable"}),icon:$w,"data-testid":"toolbar-embeddable",selected:l,children:E("toolBar.embeddable")}),ct(Ue.Item,{onSelect:()=>r.setActiveTool({type:"laser"}),icon:Rp,"data-testid":"toolbar-laser",selected:s,shortcut:S.K.toLocaleUpperCase(),children:E("toolBar.laser")}),ct("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),r.props.aiEnabled!==!1&&ct(c.Out,{}),ct(Ue.Item,{onSelect:()=>r.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:_p,"data-testid":"toolbar-embeddable",children:E("toolBar.mermaidToExcalidraw")}),r.props.aiEnabled!==!1&&Ct(Gi,{children:[Ct(Ue.Item,{onSelect:()=>r.onMagicframeToolSelect(),icon:el,"data-testid":"toolbar-magicframe",children:[E("toolBar.magicframe"),ct(Ue.Item.Badge,{children:"AI"})]}),ct(Ue.Item,{onSelect:()=>{ve("ai","open-settings","d2c"),r.setOpenDialog({name:"settings",source:"settings",tab:"diagram-to-code"})},icon:Wc,"data-testid":"toolbar-magicSettings",children:E("toolBar.magicSettings")})]})]})]})]})},C3=({renderAction:e,zoom:t})=>ct(Kt.Col,{gap:1,className:"zoom-actions",children:Ct(Kt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),A3=({renderAction:e,className:t})=>Ct("div",{className:`undo-redo-buttons ${t}`,children:[ct("div",{className:"undo-button-container",children:ct(io,{label:E("buttons.undo"),children:e("undo")})}),ct("div",{className:"redo-button-container",children:Ct(io,{label:E("buttons.redo"),children:[" ",e("redo")]})})]}),k3=({actionManager:e,showExitZenModeBtn:t})=>ct("button",{type:"button",className:Yb("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(pl),children:E("buttons.exitZenMode")}),M3=({renderAction:e,className:t})=>ct("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})});f();import{useRef as VL}from"react";var Xb=e=>{let t=VL({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...r)=>t.current.userFn(...r)),t.current.stableFn};f();import{atom as YL,useAtom as KL}from"jotai";import{jsx as XL,jsxs as $L}from"react/jsx-runtime";var $a=YL(null),L3=()=>{let[e,t]=KL($a,Ge),r=Ft();return e&&e==="clearCanvas"?XL(mu,{onConfirm:()=>{r.executeAction(ti),t(null)},onCancel:()=>t(null),title:E("clearCanvasDialog.title"),children:$L("p",{className:"clear-canvas__content",children:[" ",E("alerts.clearReset")]})}):null};var Zb={};gh(Zb,{toggleTheme:()=>ZL});f();var ZL={...Ha,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Ha,"commandPalette")}};import{jsx as Sr,jsxs as Cn}from"react/jsx-runtime";var eP=JL(null),vt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},tP=e=>{switch(e){case vt.app:return 1;case vt.export:return 2;case vt.editor:return 3;case vt.tools:return 4;case vt.elements:return 5;case vt.links:return 6;default:return 10}},Au=({shortcut:e,className:t,children:r})=>{let o=e.replace("++","+$").split("+");return Cn("div",{className:D3("shortcut",t),children:[o.map((n,i)=>Sr("div",{className:"shortcut-wrapper",children:Sr("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Sr("div",{className:"shortcut-desc",children:r})]})},_3=e=>!e.altKey&&e[S.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===S.P||e.key===S.SLASH),bse=Object.assign(e=>{let t=Be(),r=Re();return Cu(()=>{let o=n=>{_3(n)&&(n.preventDefault(),n.stopPropagation(),r(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ve("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",o,{capture:!0}),()=>window.removeEventListener("keydown",o,{capture:!0})},[r]),t.openDialog?.name!=="commandPalette"?null:Sr(rP,{...e})},{defaultItems:Zb});function rP({customCommandPaletteItems:e}){let t=pr(),r=Be(),o=Re(),n=zi(),i=Ft(),[a,s]=QL(eP),[l,c]=Iu(null),d=jL(null),m=il({uiAppState:r,customCommandPaletteItems:e,appProps:n});Cu(()=>{let{uiAppState:C,customCommandPaletteItems:L,appProps:M}=m,z=_=>{let V="";return _.label&&(typeof _.label=="function"?V=E(_.label(t.scene.getNonDeletedElements(),C,t)):V=E(_.label)),V},k=_=>typeof _.icon=="function"?_.icon(C,t.scene.getNonDeletedElements()):_.icon,N=[],B=(_,V,Z)=>{let J={label:z(_),icon:k(_),category:V,shortcut:Pt(_.name),keywords:_.keywords,predicate:_.predicate,viewMode:_.viewMode,perform:()=>{i.executeAction(_,"commandPalette")}};return Z?Z(J,_):J};if(C&&t.scene&&i){let _=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,Qc].map($=>B($,vt.elements,(ee,fe)=>({...ee,predicate:fe.predicate?fe.predicate:(ot,Le,zt,Do)=>pe(ot,Le).length>0}))),V=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool].map($=>B($,vt.tools)),Z=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map($=>B($,vt.editor)),J=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map($=>B($,vt.export));N=[..._,...Z,{label:z(ti),icon:k(ti),shortcut:Pt(ti.name),category:vt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{nr.set($a,"clearCanvas")}},{label:E("buttons.exportImage"),category:vt.export,icon:Ap,shortcut:Pt("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{o({openDialog:{name:"imageExport"}})}},...J];let Se=[{label:E("toolBar.library"),category:vt.app,icon:Tp,viewMode:!1,perform:()=>{C.openSidebar?o({openSidebar:null}):o({openSidebar:{name:Xr.name,tab:Xr.defaultTab}})}},{label:E("labels.changeStroke"),keywords:["color","outline"],category:vt.elements,icon:Cp,viewMode:!1,predicate:($,ee)=>{let fe=pe($,ee);return fe.length>0&&Kb(ee,fe)},perform:()=>{o($=>({openMenu:$.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:E("labels.changeBackground"),keywords:["color","fill"],icon:Cp,category:vt.elements,viewMode:!1,predicate:($,ee)=>{let fe=pe($,ee);return fe.length>0&&$b(ee,fe)},perform:()=>{o($=>({openMenu:$.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:E("labels.canvasBackground"),keywords:["color"],icon:Cp,category:vt.editor,viewMode:!1,perform:()=>{o($=>({openMenu:$.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...od.reduce(($,ee)=>{let{value:fe,icon:ot,key:Le,numericKey:zt}=ee;if(M.UIOptions.tools?.[fe]===!1)return $;let Yr=Le&&ui(typeof Le=="string"?Le:Le[0])||zt,fr={label:E(`toolBar.${fe}`),category:vt.tools,shortcut:Yr,icon:ot,keywords:["toolbar"],viewMode:!1,perform:({event:Kr})=>{fe==="image"?t.setActiveTool({type:fe,insertOnCanvasDirectly:Kr.type==="keydown"}):t.setActiveTool({type:fe})}};return $.push(fr),$},[]),...V,{label:E("toolBar.lock"),category:vt.tools,icon:C.activeTool.locked?Zs:Na,shortcut:S.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${E("labels.textToDiagram")}...`,category:vt.tools,icon:q2,viewMode:!1,predicate:M.aiEnabled,perform:()=>{o($=>({...$,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${E("toolBar.mermaidToExcalidraw")}...`,category:vt.tools,icon:_p,viewMode:!1,predicate:M.aiEnabled,perform:()=>{o($=>({...$,openDialog:{name:"ttd",tab:"mermaid"}}))}}],W=[...N,...Se,...L||[]].map($=>({...$,icon:$.icon||Op,order:$.order??tP($.category),haystack:`${Gb($.label.toLocaleLowerCase())} ${$.keywords?.join(" ")||""}`}));c(W),s(W.find($=>$.label===a?.label)??null)}},[m,t,i,c,a?.label,s,o]);let[p,u]=Iu(""),[h,g]=Iu(null),[x,v]=Iu({}),y=C=>{o({openDialog:null},C),u("")},w=(C,L)=>{r.openDialog?.name==="commandPalette"&&(L.stopPropagation(),L.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),y(()=>{C.perform({actionManager:i,event:L}),s(C),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},I=Xb(C=>C.viewMode===!1&&r.viewModeEnabled?!1:typeof C.predicate=="function"?C.predicate(t.scene.getNonDeletedElements(),r,n,t):C.predicate===void 0||C.predicate),A=Xb(C=>{let L=co(C.target)||_3(C)||C.key===S.ESCAPE;if(L&&C.key!==S.ARROW_UP&&C.key!==S.ARROW_DOWN&&C.key!==S.ENTER)return;let M=Object.values(x).flat(),z=a&&!p&&I(a);if(C.key===S.ARROW_UP){C.preventDefault();let k=M.findIndex(_=>_.label===h?.label);if(z){if(k===0){g(a);return}if(h===a){let _=M[M.length-1];_&&g(_);return}}let N;k===-1?N=M.length-1:N=k===0?M.length-1:(k-1)%M.length;let B=M[N];B&&g(B);return}if(C.key===S.ARROW_DOWN){C.preventDefault();let k=M.findIndex(_=>_.label===h?.label);if(z){if(!h||k===M.length-1){g(a);return}if(h===a){let _=M[0];_&&g(_);return}}let N=(k+1)%M.length,B=M[N];B&&g(B);return}if(C.key===S.ENTER&&h&&setTimeout(()=>{w(h,C)}),!L){if(C.stopPropagation(),/^[a-zA-Z0-9]$/.test(C.key)){d?.current?.focus();return}C.preventDefault()}});return Cu(()=>(window.addEventListener("keydown",A,{capture:!0}),()=>window.removeEventListener("keydown",A,{capture:!0})),[A]),Cu(()=>{if(!l)return;let C=k=>{let N={};for(let B of k)N[B.category]?N[B.category].push(B):N[B.category]=[B];return N},L=l.filter(I).sort((k,N)=>k.order-N.order),M=!p&&a&&I(a);if(!p){v(C(M?L.filter(k=>k.label!==a?.label):L)),g(M?a:L[0]||null);return}let z=Gb(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=qL.filter(z,L,{extract:k=>k.haystack}).sort((k,N)=>N.score-k.score).map(k=>k.original),v(C(L)),g(L[0]??null)},[p,l,I,a]),Cn(pt,{onCloseRequest:()=>y(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Sr(vu,{value:p,placeholder:E("commandPalette.search.placeholder"),onChange:C=>{u(C)},selectOnRender:!0,ref:d}),!t.device.viewport.isMobile&&Cn("div",{className:"shortcuts-wrapper",children:[Sr(Au,{shortcut:"\u2191\u2193",children:E("commandPalette.shortcuts.select")}),Sr(Au,{shortcut:"\u21B5",children:E("commandPalette.shortcuts.confirm")}),Sr(Au,{shortcut:R("Esc"),children:E("commandPalette.shortcuts.close")})]}),Cn("div",{className:"commands",children:[a&&!p&&Cn("div",{className:"command-category",children:[Cn("div",{className:"command-category-title",children:[E("commandPalette.recents"),Sr("div",{className:"icon",style:{marginLeft:"6px"},children:J2})]}),Sr(P3,{command:a,isSelected:a.label===h?.label,onClick:C=>w(a,C),disabled:!I(a),onMouseMove:()=>g(a),showShortcut:!t.device.viewport.isMobile,appState:r})]}),Object.keys(x).length>0?Object.keys(x).map((C,L)=>Cn("div",{className:"command-category",children:[Sr("div",{className:"command-category-title",children:C}),x[C].map(M=>Sr(P3,{command:M,isSelected:M.label===h?.label,onClick:z=>w(M,z),onMouseMove:()=>g(M),showShortcut:!t.device.viewport.isMobile,appState:r},M.label))]},C)):l?Cn("div",{className:"no-match",children:[Sr("div",{className:"icon",children:Np})," ",E("commandPalette.search.noMatch")]}):null]})]})}var P3=({command:e,isSelected:t,disabled:r,onMouseMove:o,onClick:n,showShortcut:i,appState:a})=>{let s=()=>{};return Cn("div",{className:D3("command-item",{"item-selected":t,"item-disabled":r}),ref:l=>{t&&!r&&l?.scrollIntoView?.({block:"nearest"})},onClick:r?s:n,onMouseMove:r?s:o,title:r?E("commandPalette.itemNotAvailable"):"",children:[Cn("div",{className:"name",children:[e.icon&&Sr(Co,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&Sr(Au,{shortcut:e.shortcut})]})};Jt();le();De();Ve();import{jsx as oP}from"react/jsx-runtime";var jb=H({name:"toggleLinearEditor",category:vt.elements,label:(e,t,r)=>r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return!!(!t.editingLinearElement&&n.length===1&&ie(n[0]))},perform(e,t,r,o){let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],i=t.editingLinearElement?.elementId===n.id?null:new j(n);return{appState:{...t,editingLinearElement:i},storeAction:D.CAPTURE}},PanelComponent:({appState:e,updateData:t,app:r})=>{let o=r.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=E(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return oP(de,{type:"button",icon:pv,title:n,"aria-label":n,onClick:()=>t(null)})}});f();f();hc();var Xa=class{constructor(t=!0,r=!0){this.isUndoStackEmpty=t;this.isRedoStackEmpty=r}},nd=class e{onHistoryChangedEmitter=new dr;undoStack=[];redoStack=[];get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(t,r){let o=qb.create(r,t);o.isEmpty()||(this.undoStack.push(o.inverse()),o.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Xa(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(t,r,o){return this.perform(t,r,o,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n,t))}redo(t,r,o){return this.perform(t,r,o,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n,t))}perform(t,r,o,n,i){try{let a=n();if(a===null)return;let s=t,l=r,c=!1;for(;a;){try{[s,l,c]=a.applyTo(s,l,o)}finally{i(a)}if(c)break;a=n()}return[s,l]}finally{this.onHistoryChangedEmitter.trigger(new Xa(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(t){if(!t.length)return null;let r=t.pop();return r!==void 0?r:null}static push(t,r,o){let n=r.inverse().applyLatestChanges(o);return t.push(n)}},qb=class e{constructor(t,r){this.appStateChange=t;this.elementsChange=r}static create(t,r){return new e(t,r)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(t,r,o){let[n,i]=this.elementsChange.applyTo(t,o.elements),[a,s]=this.appStateChange.applyTo(r,n);return[n,a,i||s]}applyLatestChanges(t){let r=this.elementsChange.applyLatestChanges(t);return e.create(this.appStateChange,r)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}};ge();G();Y();De();f();import{useEffect as nP,useState as iP}from"react";var Jb=(e,t)=>{let[r,o]=iP(t);return nP(()=>{let n=e.on(i=>{o(i)});return()=>{n()}},[e]),r};import{jsx as B3}from"react/jsx-runtime";var R3=(e,t)=>{if(!e.multiElement&&!e.resizingElement&&!e.editingElement&&!e.draggingElement){let r=t();if(!r)return{storeAction:D.NONE};let[o,n]=r,i=Array.from(o.values());return{appState:n,elements:i,storeAction:D.UPDATE}}return{storeAction:D.NONE}},N3=(e,t)=>({name:"undo",label:"buttons.undo",icon:xf,trackEvent:{category:"history"},viewMode:!1,perform:(r,o)=>R3(o,()=>e.undo(X(r),o,t.snapshot)),keyTest:r=>r[S.CTRL_OR_CMD]&&r.key.toLowerCase()===S.Z&&!r.shiftKey,PanelComponent:({updateData:r,data:o})=>{let{isUndoStackEmpty:n}=Jb(e.onHistoryChangedEmitter,new Xa(e.isUndoStackEmpty,e.isRedoStackEmpty));return B3(de,{type:"button",icon:xf,"aria-label":E("buttons.undo"),onClick:r,size:o?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),O3=(e,t)=>({name:"redo",label:"buttons.redo",icon:yf,trackEvent:{category:"history"},viewMode:!1,perform:(r,o)=>R3(o,()=>e.redo(X(r),o,t.snapshot)),keyTest:r=>r[S.CTRL_OR_CMD]&&r.shiftKey&&r.key.toLowerCase()===S.Z||Ld&&r.ctrlKey&&!r.shiftKey&&r.key===S.Y,PanelComponent:({updateData:r,data:o})=>{let{isRedoStackEmpty:n}=Jb(e.onHistoryChangedEmitter,new Xa(e.isUndoStackEmpty,e.isRedoStackEmpty));return B3(de,{type:"button",icon:yf,"aria-label":E("buttons.redo"),onClick:r,size:o?.size||"medium",disabled:n,"data-testid":"button-redo"})}});f();G();import{jsx as aP}from"react/jsx-runtime";var Qb=(e,t,r,o,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(r,o,i))&&ve(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},ku=class{actions={};updater;getAppState;getElementsIncludingDeleted;app;constructor(t,r,o,n){this.updater=i=>{if(sn(i))i.then(a=>t(a));else return t(i)},this.getAppState=r,this.getElementsIncludingDeleted=o,this.app=n}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(r=>this.registerAction(r))}handleKeyDown(t){let r=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in r?r[l.name]:!0)&&l.keyTest&&l.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let n=o[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),s=null;return Qb(n,"keyboard",a,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(o[0].perform(i,a,s,this.app)),!0}executeAction(t,r="api",o=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();Qb(t,r,i,n,this.app,o),this.updater(t.perform(n,i,o,this.app))}renderAction=(t,r)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in o)||o[t])){let n=this.actions[t],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),s=this.getAppState(),l=c=>{Qb(n,"ui",s,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return aP(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:l,appProps:this.app.props,app:this.app,data:r})}return null};isActionEnabled=t=>{let r=this.getElementsIncludingDeleted(),o=this.getAppState();return!t.predicate||t.predicate(r,o,this.app.props,this.app)}};Ve();Or();_i();Y();Y();Ns();be();_r();Jt();Ae();jo();le();f();var eE=e=>{let t=Array.from(e.values());return{x:F3(t,r=>r.x)/t.length,y:F3(t,r=>r.y)/t.length}},tE=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),F3=(e,t)=>e.reduce((r,o)=>r+t(o),0);Gt();ge();Pa();ft();Xe();bi();vp();Bg();im();G();fc();f();import sP from"clsx";import lP from"react";import{jsx as yl,jsxs as cP}from"react/jsx-runtime";var hr="separator",z3=lP.memo(({actionManager:e,items:t,top:r,left:o,onClose:n})=>{let i=Hi(),a=Bi(),s=t.reduce((l,c)=>(c&&(c===hr||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l),[]);return yl(Wp,{onCloseRequest:()=>{n()},top:r,left:o,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:yl("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===hr)return!s[c-1]||s[c-1]===hr?null:yl("hr",{className:"context-menu-item-separator"},c);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=E(l.label(a,i,e.app)):m=E(l.label)),yl("li",{"data-testid":d,onClick:()=>{n(()=>{e.executeAction(l,"contextMenu")})},children:cP("button",{type:"button",className:sP("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[yl("div",{className:"context-menu-item__label",children:m}),yl("kbd",{className:"context-menu-item__shortcut",children:d?Pt(d):""})]})},c)})})})});f();Y();be();import ud from"clsx";import VD from"react";Xe();G();f();import dP,{useState as mP}from"react";import{Fragment as pP,jsx as rE}from"react/jsx-runtime";var H3=({children:e,onClose:t})=>{let[r,o]=mP(!!e),{container:n}=Yt(),i=dP.useCallback(()=>{o(!1),t&&t(),n?.focus()},[t,n]);return rE(pP,{children:r&&rE(pt,{size:"small",onCloseRequest:i,title:E("errorDialog.title"),children:rE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};f();import{useEffect as yP,useRef as wP,useState as Wi}from"react";_i();Y();Br();$n();Xe();Ma();f();import uP from"clsx";import{jsx as U3,jsxs as hP}from"react/jsx-runtime";var Mu=function({onChange:e,value:t,choices:r,name:o}){return U3("div",{className:"RadioGroup",children:r.map(n=>hP("div",{className:uP("RadioGroup__choice",{active:n.value===t}),title:n.ariaLabel,children:[U3("input",{name:o,type:"radio",checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};f();import gP from"clsx";import{jsx as G3}from"react/jsx-runtime";var id=({title:e,name:t,checked:r,onChange:o,disabled:n=!1})=>G3("div",{className:gP("Switch",{toggled:r,disabled:n}),children:G3("input",{name:t,id:t,title:e,type:"checkbox",checked:r,disabled:n,onChange:()=>o(!r),onKeyDown:i=>{i.key===" "&&o(!r)}})});f();import{forwardRef as fP,useState as bP}from"react";import EP from"clsx";fi();G();import{jsx as oE,jsxs as xP}from"react/jsx-runtime";var An=fP(({children:e,icon:t,onClick:r,label:o,variant:n="filled",color:i="primary",size:a="medium",fullWidth:s,className:l},c)=>{let[d,m]=bP(!1),p=async u=>{let h=r?.(u);if(sn(h))try{m(!0),await h}catch(g){if(g instanceof mn)console.warn(g);else throw g}finally{m(!1)}};return oE("button",{className:EP("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,{"ExcButton--fullWidth":s},l),onClick:p,type:"button","aria-label":o,ref:c,disabled:d,children:xP("div",{className:"ExcButton__contents",children:[d&&oE(Xt,{}),t&&oE("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),n!=="icon"&&(e??o)]})})});G();import{jsx as st,jsxs as Vi}from"react/jsx-runtime";var vP="filter"in document.createElement("canvas").getContext("2d"),TP=()=>Vi("div",{children:[st("h3",{children:E("canvasError.cannotShowPreview")}),st("p",{children:st("span",{children:E("canvasError.canvasTooBig")})}),Vi("em",{children:["(",E("canvasError.canvasTooBigTip"),")"]})]}),SP=({appStateSnapshot:e,elementsSnapshot:t,files:r,actionManager:o,onExportImage:n,name:i})=>{let a=Ke(t,e),[s,l]=Wi(i),[c,d]=Wi(a),[m,p]=Wi(e.exportBackground),[u,h]=Wi(e.exportWithDarkMode),[g,x]=Wi(e.exportEmbedScene),[v,y]=Wi(e.exportScale),w=wP(null),[I,A]=Wi(null),{exportedElements:C,exportingFrame:L}=Ua(t,e,c);return yP(()=>{let M=w.current;if(!M)return;let z=M.offsetWidth,k=M.offsetHeight;z&&Ri({elements:C,appState:{...e,name:s,exportBackground:m,exportWithDarkMode:u,exportScale:v,exportEmbedScene:g},files:r,exportPadding:Oo,maxWidthOrHeight:Math.max(z,k),exportingFrame:L}).then(N=>(A(null),Zn(N).then(()=>{M.replaceChildren(N)}).catch(B=>{throw B.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(E("canvasError.canvasTooBig")):B}))).catch(N=>{console.error(N),A(N)})},[e,r,C,L,s,m,u,v,g]),Vi("div",{className:"ImageExportModal",children:[st("h3",{children:E("imageExportDialog.header")}),Vi("div",{className:"ImageExportModal__preview",children:[st("div",{className:"ImageExportModal__preview__canvas",ref:w,children:I&&st(TP,{})}),st("div",{className:"ImageExportModal__preview__filename",children:!ki&&st("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:M=>{l(M.target.value),o.executeAction(nb,"ui",M.target.value)}})})]}),Vi("div",{className:"ImageExportModal__settings",children:[st("h3",{children:E("imageExportDialog.header")}),a&&st(ad,{label:E("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:st(id,{name:"exportOnlySelected",checked:c,onChange:M=>{d(M)}})}),st(ad,{label:E("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:st(id,{name:"exportBackgroundSwitch",checked:m,onChange:M=>{p(M),o.executeAction(ib,"ui",M)}})}),vP&&st(ad,{label:E("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:st(id,{name:"exportDarkModeSwitch",checked:u,onChange:M=>{h(M),o.executeAction(dT,"ui",M)}})}),st(ad,{label:E("imageExportDialog.label.embedScene"),tooltip:E("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:st(id,{name:"exportEmbedSwitch",checked:g,onChange:M=>{x(M),o.executeAction($p,"ui",M)}})}),st(ad,{label:E("imageExportDialog.label.scale"),name:"exportScale",children:st(Mu,{name:"exportScale",value:v,onChange:M=>{y(M),o.executeAction(cT,"ui",M)},choices:ss.map(M=>({value:M,label:`${M}\xD7`}))})}),Vi("div",{className:"ImageExportModal__settings__buttons",children:[st(An,{className:"ImageExportModal__settings__buttons__button",label:E("imageExportDialog.title.exportToPng"),onClick:()=>n(Nd.png,C,{exportingFrame:L}),icon:Nf,children:E("imageExportDialog.button.exportToPng")}),st(An,{className:"ImageExportModal__settings__buttons__button",label:E("imageExportDialog.title.exportToSvg"),onClick:()=>n(Nd.svg,C,{exportingFrame:L}),icon:Nf,children:E("imageExportDialog.button.exportToSvg")}),(Ws||_n)&&st(An,{className:"ImageExportModal__settings__buttons__button",label:E("imageExportDialog.title.copyPngToClipboard"),onClick:()=>n(Nd.clipboard,C,{exportingFrame:L}),icon:Pp,children:E("imageExportDialog.button.copyPngToClipboard")})]})]})]})},ad=({label:e,children:t,tooltip:r,name:o})=>Vi("div",{className:"ImageExportModal__settings__setting",title:e,children:[Vi("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,r&&st(io,{label:r,long:!0,children:V2})]}),st("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),W3=({elements:e,appState:t,files:r,actionManager:o,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=Wi(()=>({appStateSnapshot:ln(t),elementsSnapshot:ln(e)}));return st(pt,{onCloseRequest:i,size:"wide",title:!1,children:st(SP,{elementsSnapshot:l,appStateSnapshot:s,files:r,actionManager:o,onExportImage:n,name:a})})};f();import IP from"clsx";import{jsx as CP}from"react/jsx-runtime";var Lu=({children:e,side:t,className:r})=>CP("div",{className:IP("FixedSideContainer",`FixedSideContainer_side_${t}`,r),children:e});f();le();G();Or();import{jsx as V3}from"react/jsx-runtime";var AP=({appState:e,isMobile:t,device:r,app:o})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar&&!r.editor.canFitSidebar)return null;if(Nr(e))return E("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return l?E("hints.linearElementMulti"):E("hints.linearElement");if(n.type==="freedraw")return E("hints.freeDraw");if(n.type==="text")return E("hints.text");if(n.type==="embeddable")return E("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return E("hints.placeImage");let c=o.scene.getSelectedElements(e);if(i&&s==="mouse"&&c.length===1){let d=c[0];return ie(d)&&d.points.length===2?E("hints.lockAngle"):mo(d)?E("hints.resizeImage"):E("hints.resize")}if(a&&s==="mouse")return E("hints.rotate");if(c.length===1&&U(c[0]))return E("hints.text_selected");if(e.editingElement&&U(e.editingElement))return E("hints.text_editing");if(n.type==="selection"){if(e.draggingElement?.type==="selection"&&!c.length&&!e.editingElement&&!e.editingLinearElement)return E("hints.deepBoxSelect");if(e.gridSize&&e.draggingElement)return E("hints.disableSnapping");if(!c.length&&!t)return E("hints.canvasPanning");if(c.length===1){if(ie(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?E("hints.lineEditor_pointSelected"):E("hints.lineEditor_nothingSelected"):E("hints.lineEditor_info");if(!e.draggingElement&&cn(c[0]))return E("hints.bindTextToElement")}}return null},Pu=({appState:e,isMobile:t,device:r,app:o})=>{let n=AP({appState:e,isMobile:t,device:r,app:o});return n?(n=R(n),V3("div",{className:"HintViewer",children:V3("span",{children:n})})):null};f();import kP from"clsx";import{jsx as K3,jsxs as LP}from"react/jsx-runtime";var MP="medium",Y3={CHECKED:Zs,UNCHECKED:Na},Du=e=>LP("label",{className:kP("ToolIcon ToolIcon__lock",`ToolIcon_size_${MP}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[K3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),K3("div",{className:"ToolIcon__icon",children:e.checked?Y3.CHECKED:Y3.UNCHECKED})]});f();be();Xe();f();import{Fragment as PP,jsx as $3,jsxs as DP}from"react/jsx-runtime";var Yi=({heading:e,children:t,...r})=>{let{id:o}=Yt(),n=$3("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:E(`headings.${e}`)});return $3("section",{...r,"aria-labelledby":`${o}-${e}-title`,children:typeof t=="function"?t(n):DP(PP,{children:[n,t]})})};f();be();G();var en=4,kn=6,X3="rgba(0,0,0,0.3)",Z3=(e,t,r,o)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,s]=we(e),l=t/o.zoom.value,c=r/o.zoom.value,d=t-l,m=r-c,p={top:parseInt(Ul("sat"))||0,bottom:parseInt(Ul("sab"))||0,left:parseInt(Ul("sal"))||0,right:parseInt(Ul("sar"))||0},u=Dn().rtl,h=-o.scrollX+d/2+p.left,g=-o.scrollY+m/2+p.top,x=h+l-p.right,v=g+c-p.bottom,y=Math.min(n,h),w=Math.min(i,g),I=Math.max(a,x),A=Math.max(s,v);return{horizontal:h===y&&x===I?null:{x:Math.max(p.left,en)+(h-y)/(I-y)*t,y:r-kn-Math.max(en,p.bottom),width:(x-h)/(I-y)*t-Math.max(en*2,p.left+p.right),height:kn},vertical:g===w&&v===A?null:{x:u?Math.max(p.left,en):t-kn-Math.max(p.right,en),y:(g-w)/(A-w)*r+Math.max(p.top,en),width:kn,height:(v-g)/(A-w)*r-Math.max(en*2,p.top+p.bottom)}}},nE=(e,t,r)=>{let[o,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=t&&t<=a.x+a.width&&a.y<=r&&r<=a.y+a.height);return{isOverEither:o||n,isOverHorizontal:o,isOverVertical:n}};f();import _P from"clsx";import{jsx as j3,jsxs as NP}from"react/jsx-runtime";var RP="medium",_u=e=>e.penDetected?NP("label",{className:_P("ToolIcon ToolIcon__penMode",`ToolIcon_size_${RP}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[j3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),j3("div",{className:"ToolIcon__icon",children:Gw})]}):null;f();import OP from"clsx";ge();import{jsx as BP}from"react/jsx-runtime";var Ru=e=>BP(de,{className:OP("Shape",{fillable:!1}),type:"radio",icon:Lp,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:S.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":S.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});Or();import{Fragment as FP,jsx as rr,jsxs as Ki}from"react/jsx-runtime";var q3=({appState:e,elements:t,actionManager:r,setAppState:o,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:s,renderCustomStats:l,renderSidebars:c,device:d,renderWelcomeScreen:m,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:h,MainMenuTunnel:g,DefaultSidebarTriggerTunnel:x}=at(),v=()=>Ki(Lu,{side:"top",className:"App-top-bar",children:[m&&rr(h.Out,{}),rr(Yi,{heading:"shapes",children:w=>rr(Kt.Col,{gap:4,align:"center",children:Ki(Kt.Row,{gap:1,className:"App-toolbar-container",children:[Ki(tr,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[w,rr(Kt.Row,{gap:1,children:rr(Su,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),s&&s(!0,e),Ki("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&rr(x.Out,{}),rr(_u,{checked:e.penMode,onChange:()=>a(null),title:E("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),rr(Du,{checked:e.activeTool.locked,onChange:n,title:E("toolBar.lock"),isMobile:!0}),rr(Ru,{checked:Yo(e),onChange:()=>i(),title:E("toolBar.hand"),isMobile:!0})]})]})})}),rr(Pu,{appState:e,isMobile:!0,device:d,app:u})]}),y=()=>e.viewModeEnabled?rr("div",{className:"App-toolbar-content",children:rr(g.Out,{})}):Ki("div",{className:"App-toolbar-content",children:[rr(g.Out,{}),r.renderAction("toggleEditMenu"),r.renderAction("undo"),r.renderAction("redo"),r.renderAction(e.multiElement?"finalize":"duplicateSelection"),r.renderAction("deleteSelectedElements")]});return Ki(FP,{children:[c(),!e.viewModeEnabled&&v(),rr("div",{className:"App-bottom-bar",style:{marginBottom:kn+en*2,marginLeft:kn+en*2,marginRight:kn+en*2},children:Ki(tr,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&_a(e,t)?rr(Yi,{className:"App-mobile-menu",heading:"selectedShapeActions",children:rr(Tu,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:r.renderAction})}):null,Ki("footer",{className:"App-toolbar",children:[y(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&rr("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(w=>({...bn(t,w)}))},children:E("buttons.scrollBackToContent")})]})]})})]})};f();import zP from"open-color";import HP,{useLayoutEffect as UP,useRef as GP,useState as WP}from"react";Yg();Ac();import{jsx as sd,jsxs as VP}from"react/jsx-runtime";var J3=e=>{let t=GP(null),[r,o]=WP(null);return UP(()=>{if(!e.spreadsheet)return;let n=zy(e.chartType,e.spreadsheet,0,0);o(n);let i,a=t.current;return(async()=>(i=await Hs(n,{exportBackground:!1,viewBackgroundColor:zP.white},null),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),sd("button",{type:"button",className:"ChartPreview",onClick:()=>{r&&e.onClick(e.chartType,r)},children:sd("div",{ref:t})})},Q3=({setAppState:e,appState:t,onClose:r})=>{let{onInsertElements:o}=pr(),n=HP.useCallback(()=>{r&&r()},[r]),i=(a,s)=>{o(s),ve("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return sd(pt,{size:"small",onCloseRequest:n,title:E("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:VP("div",{className:"container",children:[sd(J3,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:i}),sd(J3,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:i})]})})};f();import YP from"react";ge();G();_i();Y();import{Fragment as tS,jsx as K,jsxs as ao}from"react/jsx-runtime";var KP=()=>ao("div",{className:"HelpDialog__header",children:[ao("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[K("div",{className:"HelpDialog__link-icon",children:Ef}),E("helpDialog.documentation")]}),ao("a",{className:"HelpDialog__btn",href:"https://blog.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[K("div",{className:"HelpDialog__link-icon",children:Ef}),E("helpDialog.blog")]}),ao("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[K("div",{className:"HelpDialog__link-icon",children:Ip}),E("helpDialog.github")]}),ao("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[K("div",{className:"HelpDialog__link-icon",children:dv}),"YouTube"]})]}),$P=e=>ao(tS,{children:[K("h3",{children:e.title}),K("div",{className:"HelpDialog__islands-container",children:e.children})]}),iE=e=>ao("div",{className:`HelpDialog__island ${e.className}`,children:[K("h4",{className:"HelpDialog__island-title",children:e.caption}),K("div",{className:"HelpDialog__island-content",children:e.children})]});function*XP(e,t){let r=!0;for(let o of e)r||(yield t),r=!1,yield o}var ZP=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),te=({label:e,shortcuts:t,isOr:r=!0})=>{let o=t.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>K(jP,{children:ZP(a)},a)));return ao("div",{className:"HelpDialog__shortcut",children:[K("div",{children:e}),K("div",{className:"HelpDialog__key-container",children:[...XP(o,r?E("helpDialog.or"):null)]})]})},jP=e=>K("kbd",{className:"HelpDialog__key",...e}),eS=({onClose:e})=>{let t=YP.useCallback(()=>{e&&e()},[e]);return K(tS,{children:ao(pt,{onCloseRequest:t,title:E("helpDialog.title"),className:"HelpDialog",children:[K(KP,{}),ao($P,{title:E("helpDialog.shortcuts"),children:[ao(iE,{className:"HelpDialog__island--tools",caption:E("helpDialog.tools"),children:[K(te,{label:E("toolBar.hand"),shortcuts:[S.H]}),K(te,{label:E("toolBar.selection"),shortcuts:[S.V,S[1]]}),K(te,{label:E("toolBar.rectangle"),shortcuts:[S.R,S[2]]}),K(te,{label:E("toolBar.diamond"),shortcuts:[S.D,S[3]]}),K(te,{label:E("toolBar.ellipse"),shortcuts:[S.O,S[4]]}),K(te,{label:E("toolBar.arrow"),shortcuts:[S.A,S[5]]}),K(te,{label:E("toolBar.line"),shortcuts:[S.L,S[6]]}),K(te,{label:E("toolBar.freedraw"),shortcuts:[S.P,S[7]]}),K(te,{label:E("toolBar.text"),shortcuts:[S.T,S[8]]}),K(te,{label:E("toolBar.image"),shortcuts:[S[9]]}),K(te,{label:E("toolBar.eraser"),shortcuts:[S.E,S[0]]}),K(te,{label:E("toolBar.frame"),shortcuts:[S.F]}),K(te,{label:E("toolBar.laser"),shortcuts:[S.K]}),K(te,{label:E("labels.eyeDropper"),shortcuts:[S.I,"Shift+S","Shift+G"]}),K(te,{label:E("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),K(te,{label:E("helpDialog.editText"),shortcuts:[R("Enter")]}),K(te,{label:E("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),K(te,{label:E("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),K(te,{label:E("helpDialog.curvedArrow"),shortcuts:["A",E("helpDialog.click"),E("helpDialog.click"),E("helpDialog.click")],isOr:!1}),K(te,{label:E("helpDialog.curvedLine"),shortcuts:["L",E("helpDialog.click"),E("helpDialog.click"),E("helpDialog.click")],isOr:!1}),K(te,{label:E("toolBar.lock"),shortcuts:[S.Q]}),K(te,{label:E("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),K(te,{label:E("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]})]}),ao(iE,{className:"HelpDialog__island--view",caption:E("helpDialog.view"),children:[K(te,{label:E("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),K(te,{label:E("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),K(te,{label:E("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),K(te,{label:E("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),K(te,{label:E("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),K(te,{label:E("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),K(te,{label:E("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),K(te,{label:E("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),K(te,{label:E("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),K(te,{label:E("labels.toggleGrid"),shortcuts:[R("CtrlOrCmd+'")]}),K(te,{label:E("labels.viewMode"),shortcuts:[R("Alt+R")]}),K(te,{label:E("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),K(te,{label:E("stats.fullTitle"),shortcuts:[R("Alt+/")]}),K(te,{label:E("commandPalette.title"),shortcuts:_n?[Pt("commandPalette")]:[Pt("commandPalette"),Pt("commandPalette",1)]})]}),ao(iE,{className:"HelpDialog__island--editor",caption:E("helpDialog.editor"),children:[K(te,{label:E("labels.moveCanvas"),shortcuts:[R(`Space+${E("helpDialog.drag")}`),R(`Wheel+${E("helpDialog.drag")}`)],isOr:!0}),K(te,{label:E("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),K(te,{label:E("labels.delete"),shortcuts:[R("Delete")]}),K(te,{label:E("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),K(te,{label:E("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),K(te,{label:E("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),K(te,{label:E("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),K(te,{label:E("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),K(te,{label:E("labels.multiSelect"),shortcuts:[R(`Shift+${E("helpDialog.click")}`)]}),K(te,{label:E("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${E("helpDialog.click")}`)]}),K(te,{label:E("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${E("helpDialog.drag")}`)]}),(Ws||_n)&&K(te,{label:E("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),K(te,{label:E("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),K(te,{label:E("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),K(te,{label:E("labels.sendToBack"),shortcuts:[br?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),K(te,{label:E("labels.bringToFront"),shortcuts:[br?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),K(te,{label:E("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),K(te,{label:E("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),K(te,{label:E("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),K(te,{label:E("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),K(te,{label:E("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),K(te,{label:E("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),K(te,{label:E("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${E("helpDialog.drag")}`)]}),K(te,{label:E("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),K(te,{label:E("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),K(te,{label:E("buttons.redo"),shortcuts:Ld?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),K(te,{label:E("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),K(te,{label:E("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),K(te,{label:E("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),K(te,{label:E("labels.flipVertical"),shortcuts:[R("Shift+V")]}),K(te,{label:E("labels.showStroke"),shortcuts:[R("S")]}),K(te,{label:E("labels.showBackground"),shortcuts:[R("G")]}),K(te,{label:E("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),K(te,{label:E("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};f();import ld,{useLayoutEffect as qP}from"react";import rS from"clsx";import*as vl from"@radix-ui/react-popover";G();Y();import{jsx as ni,jsxs as wl}from"react/jsx-runtime";var JP=4,QP=8,e8=({shouldWrap:e,children:t,username:r})=>e?ni(io,{label:r||"Unknown user",children:t}):ni(ld.Fragment,{children:t}),aE=({actionManager:e,collaborator:t,socketId:r,withName:o=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:r,collaborator:t,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return ni(e8,{username:t.username,shouldWrap:n,children:s},r)},t8=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Nu=ld.memo(({className:e,mobile:t,collaborators:r,userToFollow:o})=>{let n=Ft(),i=new Map;r.forEach((x,v)=>{let y=x.id||v;i.set(y,{...x,socketId:v})});let a=Array.from(i.values()).filter(x=>x.username?.trim()),[s,l]=ld.useState(""),c=ld.useRef(null);qP(()=>{if(c.current){let x=y=>{let w=Math.max(1,Math.min(8,Math.floor(y/38)));m(w)};if(x(c.current.clientWidth),!Rl)return;let v=new ResizeObserver(y=>{for(let w of y){let{width:I}=w.contentRect;x(I)}});return v.observe(c.current),()=>{v.disconnect()}}},[]);let[d,m]=ld.useState(JP),u=s.trim().toLowerCase()?a.filter(x=>x.username?.toLowerCase().includes(s)):a,g=a.slice(0,d-1).map(x=>aE({actionManager:n,collaborator:x,socketId:x.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:x.socketId===o}));return t?ni("div",{className:rS("UserList UserList_mobile",e),children:a.map(x=>aE({actionManager:n,collaborator:x,socketId:x.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:x.socketId===o}))}):ni("div",{className:"UserList-wrapper",ref:c,children:wl("div",{className:rS("UserList",e),style:{"--max-avatars":d},children:[g,a.length>d-1&&wl(vl.Root,{onOpenChange:x=>{x||l("")},children:[wl(vl.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),ni(vl.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:wl(tr,{style:{overflow:"hidden"},children:[a.length>=QP&&wl("div",{className:"UserList__search-wrapper",children:[Np,ni("input",{className:"UserList__search",type:"text",placeholder:E("userList.search.placeholder"),value:s,onChange:x=>{l(x.target.value)}})]}),wl("div",{className:"dropdown-menu UserList__collaborators",children:[u.length===0&&ni("div",{className:"UserList__collaborators__empty",children:E("userList.search.empty")}),ni("div",{className:"UserList__hint",children:E("userList.hint.text")}),u.map(x=>aE({actionManager:n,collaborator:x,socketId:x.socketId,withName:!0,isBeingFollowed:x.socketId===o}))]})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let r=t.collaborators.keys();for(let[o,n]of e.collaborators){let i=t.collaborators.get(o);if(!i||o!==r.next().value||!tt(n,i,t8))return!1}return!0});f();import o8 from"react";f();import sE from"open-color";import{jsx as r8}from"react/jsx-runtime";var lE=({children:e,color:t})=>r8("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":sE[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":sE[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":sE[t][9]},children:e});$n();G();import{Fragment as i8,jsx as tn,jsxs as Ou}from"react/jsx-runtime";var n8=({elements:e,appState:t,setAppState:r,files:o,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return tn("div",{className:"ExportDialog ExportDialog--json",children:Ou("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Ou(lE,{color:"lime",children:[tn("div",{className:"Card-icon",children:t2}),tn("h2",{children:E("exportDialog.disk_title")}),Ou("div",{className:"Card-details",children:[E("exportDialog.disk_details"),!ki&&n.renderAction("changeProjectName")]}),tn(de,{className:"Card-button",type:"button",title:E("exportDialog.disk_button"),"aria-label":E("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(jc,"ui")}})]}),l&&Ou(lE,{color:"pink",children:[tn("div",{className:"Card-icon",children:Gc}),tn("h2",{children:E("exportDialog.link_title")}),tn("div",{className:"Card-details",children:E("exportDialog.link_details")}),tn(de,{className:"Card-button",type:"button",title:E("exportDialog.link_button"),"aria-label":E("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ve("export","link",`ui (${d1()})`),await l(e,t,o),s()}catch(c){r({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,o,a)]})})},oS=({elements:e,appState:t,files:r,actionManager:o,exportOpts:n,canvas:i,setAppState:a})=>{let s=o8.useCallback(()=>{a({openDialog:null})},[a]);return tn(i8,{children:t.openDialog?.name==="jsonExport"&&tn(pt,{onCloseRequest:s,title:E("buttons.export"),children:tn(n8,{elements:e,appState:t,setAppState:a,files:r,actionManager:o,onCloseRequest:s,exportOpts:n,canvas:i})})})};f();import Bu from"clsx";f();import{jsx as a8}from"react/jsx-runtime";var nS=e=>a8("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${E("helpDialog.title")} \u2014 ?`,"aria-label":E("helpDialog.title"),children:qs});import{jsx as Mn,jsxs as cE}from"react/jsx-runtime";var iS=({appState:e,actionManager:t,showExitZenModeBtn:r,renderWelcomeScreen:o})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=at(),a=_e(),s=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return cE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Mn("div",{className:Bu("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Mn(Kt.Col,{gap:2,children:cE(Yi,{heading:"canvasActions",children:[Mn(C3,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Mn(A3,{renderAction:t.renderAction,className:Bu("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),s&&Mn(M3,{renderAction:t.renderAction,className:Bu("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),Mn(n.Out,{}),Mn("div",{className:Bu("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:cE("div",{style:{position:"relative"},children:[o&&Mn(i.Out,{}),Mn(nS,{onClick:()=>t.executeAction(Va)})]})}),Mn(k3,{actionManager:t,showExitZenModeBtn:r})]})},aS=iS;iS.displayName="Footer";f();import{useEffect as fS,useLayoutEffect as bS,useRef as EE,useState as h8,forwardRef as ES,useImperativeHandle as g8,useCallback as hS}from"react";import{atom as f8,useSetAtom as b8}from"jotai";f();import s8 from"react";var Fu=s8.createContext({});f();import l8 from"clsx";import{useContext as c8}from"react";import{jsx as dE,jsxs as sS}from"react/jsx-runtime";var mE=({children:e,className:t})=>{let r=_e(),o=c8(Fu),n=!!(r.editor.canFitSidebar&&o.shouldRenderDockButton);return sS("div",{className:l8("sidebar__header",t),"data-testid":"sidebar-header",children:[e,sS("div",{className:"sidebar__header__buttons",children:[n&&dE(io,{label:E("labels.sidebarLock"),children:dE(Sn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":E("labels.sidebarLock"),children:Dw})}),dE(Sn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":E("buttons.close"),children:yo})]})]})};mE.displayName="SidebarHeader";import E8 from"clsx";G();ge();Y();f();import d8 from"clsx";import{jsx as pE,jsxs as lS}from"react/jsx-runtime";var uE=({name:e,tab:t,icon:r,title:o,children:n,onToggle:i,className:a,style:s})=>{let l=Re(),c=Be();return lS("label",{title:o,className:"sidebar-trigger__label-element",children:[pE("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=d.target.checked;l({openSidebar:m?{name:e,tab:t}:null}),i?.(m)},checked:c.openSidebar?.name===e,"aria-label":o,"aria-keyshortcuts":"0"}),lS("div",{className:d8("sidebar-trigger",a),style:s,children:[r&&pE("div",{children:r}),n&&pE("div",{className:"sidebar-trigger__label",children:n})]})]})};uE.displayName="SidebarTrigger";f();import*as cS from"@radix-ui/react-tabs";import{jsx as m8}from"react/jsx-runtime";var hE=({children:e,...t})=>m8(cS.List,{className:"sidebar-triggers",...t,children:e});hE.displayName="SidebarTabTriggers";f();import*as mS from"@radix-ui/react-tabs";import{jsx as dS}from"react/jsx-runtime";var gE=({children:e,tab:t,onSelect:r,...o})=>dS(mS.Trigger,{value:t,asChild:!0,onSelect:r,children:dS("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});gE.displayName="SidebarTabTrigger";f();import*as pS from"@radix-ui/react-tabs";import{jsx as p8}from"react/jsx-runtime";var fE=({children:e,...t})=>{let r=Be(),o=Re();if(!r.openSidebar)return null;let{name:n}=r.openSidebar;return p8(pS.Root,{className:"sidebar-tabs-root",value:r.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...t,children:e})};fE.displayName="SidebarTabs";f();import*as uS from"@radix-ui/react-tabs";import{jsx as u8}from"react/jsx-runtime";var bE=({tab:e,children:t,...r})=>u8(uS.Content,{...r,value:e,"data-testid":e,children:t});bE.displayName="SidebarTab";import{jsx as gS}from"react/jsx-runtime";import{createElement as x8}from"react";var cd=f8(!1),xS=ES(({name:e,children:t,onDock:r,docked:o,className:n,...i},a)=>{T.DEV&&r&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Re(),l=b8(cd,Ge);bS(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=EE({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>r?.(u),c.current=ds(c.current,{docked:o,shouldRenderDockButton:!!r&&o!=null});let d=EE(null);g8(a,()=>d.current);let m=_e(),p=hS(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return nl(d,hS(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.editor.canFitSidebar)&&p()},[p,o,m.editor.canFitSidebar])),fS(()=>{let u=h=>{h.key===S.ESCAPE&&(!o||!m.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,o,m.editor.canFitSidebar]),gS(tr,{...i,className:E8("sidebar",{"sidebar--docked":o},n),ref:d,children:gS(Fu.Provider,{value:c.current,children:t})})});xS.displayName="SidebarInner";var ii=Object.assign(ES((e,t)=>{let r=Be(),{onStateChange:o}=e,n=EE(r.openSidebar);fS(()=>{(!r.openSidebar&&n?.current?.name===e.name||r.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&r.openSidebar!==n.current&&o?.(r.openSidebar?.name!==e.name?null:r.openSidebar),n.current=r.openSidebar},[r.openSidebar,o,e.name]);let[i,a]=h8(!1);return bS(()=>(a(!0),()=>a(!1)),[]),i&&r.openSidebar?.name===e.name?x8(xS,{...e,ref:t,key:e.name}):null}),{Header:mE,TabTriggers:hE,TabTrigger:gE,Tabs:fE,Tab:bE,Trigger:uE});ii.displayName="Sidebar";import{Provider as YD,useAtom as KD,useAtomValue as $D}from"jotai";f();var wE={};gh(wE,{ChangeCanvasBackground:()=>PS,ClearCanvas:()=>MS,CommandPalette:()=>AS,Export:()=>DS,Help:()=>kS,LiveCollaborationTrigger:()=>RS,LoadScene:()=>SS,SaveAsImage:()=>CS,SaveToActiveFile:()=>IS,Socials:()=>_S,ToggleTheme:()=>LS});f();import v8 from"clsx";import{useSetAtom as T8}from"jotai";f();import{atom as y8}from"jotai";var xE=y8({active:!1});async function yS({title:e,description:t,actionLabel:r,color:o}){return new Promise(n=>{nr.set(xE,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:t,actionLabel:r,color:o})})}f();import{Fragment as w8,jsx as yE,jsxs as wS}from"react/jsx-runtime";var vS=({value:e,shortcut:t,onChange:r,choices:o,children:n,name:i})=>{let a=_e();return wS(w8,{children:[wS("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[yE("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),yE(Mu,{name:i,value:e,onChange:r,choices:o})]}),t&&!a.editor.isMobile&&yE("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};vS.displayName="DropdownMenuItemContentRadio";var TS=vS;Y();import{Fragment as S8,jsx as $t,jsxs as NS}from"react/jsx-runtime";var SS=()=>{let{t:e}=At(),t=Ft(),r=Bi();return t.isActionEnabled(sl)?$t(Io,{icon:Js,onSelect:async()=>{(!r.length||await yS({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:$t(Tr,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>$t("strong",{children:n}),br:()=>$t("br",{})})}))&&t.executeAction(sl)},"data-testid":"load-button",shortcut:Pt("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};SS.displayName="LoadScene";var IS=()=>{let{t:e}=At(),t=Ft();return t.isActionEnabled(Xp)?$t(Io,{shortcut:Pt("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(Xp),icon:Jw,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};IS.displayName="SaveToActiveFile";var CS=()=>{let e=Re(),{t}=At();return $t(Io,{icon:Ap,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Pt("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};CS.displayName="SaveAsImage";var AS=e=>{let t=Re(),{t:r}=At();return $t(Io,{icon:Op,"data-testid":"command-palette-button",onSelect:()=>{ve("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:Pt("commandPalette"),"aria-label":r("commandPalette.title"),className:e?.className,children:r("commandPalette.title")})};AS.displayName="CommandPalette";var kS=()=>{let{t:e}=At(),t=Ft();return $t(Io,{"data-testid":"help-menu-item",icon:qs,onSelect:()=>t.executeAction(Va),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};kS.displayName="Help";var MS=()=>{let{t:e}=At(),t=T8($a,Ge);return Ft().isActionEnabled(ti)?$t(Io,{icon:Qo,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};MS.displayName="ClearCanvas";var LS=e=>{let{t}=At(),r=Be(),o=Ft(),n=Pt("toggleTheme");return o.isActionEnabled(Ha)?e?.allowSystemTheme?$t(TS,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:ce.LIGHT,label:Uc,ariaLabel:`${t("buttons.lightMode")} - ${n}`},{value:ce.DARK,label:Hc,ariaLabel:`${t("buttons.darkMode")} - ${n}`},{value:"system",label:cv,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):$t(Io,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(r.theme===ce.DARK?ce.LIGHT:ce.DARK);else return o.executeAction(Ha)},icon:r.theme===ce.DARK?Uc:Hc,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":r.theme===ce.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:r.theme===ce.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};LS.displayName="ToggleTheme";var PS=()=>{let{t:e}=At(),t=Be(),r=Ft(),o=zi();return t.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:NS("div",{style:{marginTop:"0.5rem"},children:[$t("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),$t("div",{style:{padding:"0 0.625rem"},children:r.renderAction("changeViewBackgroundColor")})]})};PS.displayName="ChangeCanvasBackground";var DS=()=>{let{t:e}=At(),t=Re();return $t(Io,{icon:Oa,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};DS.displayName="Export";var _S=()=>{let{t:e}=At();return NS(S8,{children:[$t(bl,{icon:Ip,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),$t(bl,{icon:jw,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),$t(bl,{icon:Zw,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};_S.displayName="Socials";var RS=({onSelect:e,isCollaborating:t})=>{let{t:r}=At();return $t(Io,{"data-testid":"collab-button",icon:kp,className:v8({"active-collab":t}),onSelect:e,children:r("labels.liveCollaboration")})};RS.displayName="LiveCollaborationTrigger";f();import{atom as I8,useAtom as C8}from"jotai";import{useLayoutEffect as A8,useRef as k8}from"react";import{jsx as M8}from"react/jsx-runtime";var ai=(e,t)=>{let r=I8(0),o=n=>{let{jotaiScope:i}=at(),[,a]=C8(r,i),s=k8({preferHost:!1,counter:0});return A8(()=>{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]),n.__fallback||(s.current.preferHost=!0),!s.current.counter&&n.__fallback&&s.current.preferHost||s.current.counter>1&&n.__fallback?null:M8(t,{...n})};return o.displayName=e,o};G();import{jsx as zu,jsxs as vE}from"react/jsx-runtime";var L8=Object.assign(ai("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:r}=at(),o=_e(),n=Be(),i=Re(),a=o.editor.isMobile?void 0:()=>i({openMenu:null});return zu(r.In,{children:vE(Ue,{open:n.openMenu==="canvas",children:[zu(Ue.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Sp}),vE(Ue.Content,{onClickOutside:a,onSelect:hi(t,()=>{i({openMenu:null})}),children:[e,o.editor.isMobile&&n.collaborators.size>0&&vE("fieldset",{className:"UserList-Wrapper",children:[zu("legend",{children:E("labels.collaborators")}),zu(Nu,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ue.Trigger,Item:Ue.Item,ItemLink:Ue.ItemLink,ItemCustom:Ue.ItemCustom,Group:Ue.Group,Separator:Ue.Separator,DefaultItems:wE}),Ir=L8;f();import{useAtom as R8}from"jotai";f();import{jsx as Tl,jsxs as _8}from"react/jsx-runtime";var Hu=({title:e,children:t,actionLabel:r,onClick:o})=>_8("div",{className:"OverwriteConfirm__Actions__Action",children:[Tl("h4",{children:e}),Tl("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),Tl(An,{variant:"outlined",color:"muted",label:r,size:"large",fullWidth:!0,onClick:o})]}),P8=()=>{let{t:e}=At(),t=Ft(),r=Re();return Tl(Hu,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction($p,"ui",!0),r({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},D8=()=>{let{t:e}=At(),t=Ft();return Tl(Hu,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(jc,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},TE=Object.assign(({children:e})=>Tl("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:P8,SaveToDisk:D8});import{jsx as $i,jsxs as OS}from"react/jsx-runtime";var Uu=Object.assign(ai("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=at(),[r,o]=R8(xE,Ge);if(!r.active)return null;let n=()=>{r.onClose(),o(a=>({...a,active:!1}))},i=()=>{r.onConfirm(),o(a=>({...a,active:!1}))};return $i(t.In,{children:$i(pt,{onCloseRequest:n,title:!1,size:916,children:OS("div",{className:"OverwriteConfirm",children:[$i("h3",{children:r.title}),OS("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${r.color}`,children:[$i("div",{className:"OverwriteConfirm__Description__icon",children:Y2}),$i("div",{children:r.description}),$i("div",{className:"OverwriteConfirm__Description__spacer"}),$i(An,{color:r.color,size:"large",label:r.actionLabel,onClick:i})]}),$i(TE,{children:e})]})})})}),{Actions:TE,Action:Hu});Or();f();Y();import N8 from"clsx";G();import{jsx as Xi,jsxs as BS}from"react/jsx-runtime";import{createElement as O8}from"react";var FS=ai("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=at();return Xi(t.In,{children:Xi(ii.Trigger,{...e,className:"default-sidebar-trigger",name:Xr.name})})});FS.displayName="DefaultSidebarTrigger";var zS=({children:e,...t})=>{let{DefaultSidebarTabTriggersTunnel:r}=at();return Xi(r.In,{children:Xi(ii.TabTriggers,{...t,children:e})})};zS.displayName="DefaultTabTriggers";var Gu=Object.assign(ai("DefaultSidebar",({children:e,className:t,onDock:r,docked:o,...n})=>{let i=Be(),a=Re(),{DefaultSidebarTabTriggersTunnel:s}=at();return O8(ii,{...n,name:"default",key:"default",className:N8("default-sidebar",t),docked:o??i.defaultSidebarDockedPreference,onDock:r===!1||!r&&o!=null?void 0:hi(r,l=>{a({defaultSidebarDockedPreference:l})})},BS(ii.Tabs,{children:[BS(ii.Header,{children:[n.__fallback&&Xi("div",{style:{color:"var(--color-primary)",fontSize:"1.2em",fontWeight:"bold",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",paddingRight:"1em"},children:E("toolBar.library")}),Xi(s.Out,{})]}),Xi(ii.Tab,{tab:Hl,children:Xi(v3,{})}),e]}))}),{Trigger:FS,TabTriggers:zS});Ae();pn();bi();f();import B8 from"clsx";import{jsx as HS,jsxs as z8}from"react/jsx-runtime";var F8="small",US=e=>z8("label",{className:B8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${F8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[HS("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),HS("div",{className:"ToolIcon__icon",children:Rp})]});f();import{useState as KS}from"react";ge();f();import{jsx as H8}from"react/jsx-runtime";var Sl=e=>H8("p",{className:"excalidraw__paragraph",style:e.style,children:e.children});f();import*as WS from"@radix-ui/react-tabs";import{useRef as GS}from"react";G();import{jsx as U8}from"react/jsx-runtime";var VS=e=>{let t=Re(),r=GS(null),o=GS(0);return U8(WS.Root,{ref:r,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=r.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>o.current&&(o.current=a,i.style.minHeight=`min(${o.current}px, 100%)`)}e.dialog==="settings"&&Wl(["text-to-diagram","diagram-to-code"],n)?t({openDialog:{name:e.dialog,tab:n,source:"settings"}}):e.dialog==="ttd"&&Wl(["text-to-diagram","mermaid"],n)&&t({openDialog:{name:e.dialog,tab:n}})},children:e.children})};VS.displayName="TTDDialogTabs";var Wu=VS;f();import*as YS from"@radix-ui/react-tabs";import{jsx as G8}from"react/jsx-runtime";var Il=({tab:e,children:t,...r})=>G8(YS.Content,{...r,value:e,children:t});Il.displayName="TTDDialogTab";import{jsx as Wr,jsxs as dd}from"react/jsx-runtime";var $S=e=>{let[t,r]=KS(e.openAIKey||""),[o,n]=KS(e.isPersisted),i=Be(),a=()=>{e.onConfirm(t.trim(),o)};return i.openDialog?.name!=="settings"?null:Wr(pt,{onCloseRequest:()=>{e.onClose(),e.onConfirm(t.trim(),o)},title:dd("div",{style:{display:"flex"},children:["Wireframe to Code (AI)"," ",Wr("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.1rem 0.5rem",marginLeft:"1rem",fontSize:14,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"Experimental"})]}),className:"MagicSettings",autofocus:!1,children:Wr(Wu,{dialog:"settings",tab:i.openDialog.tab,children:dd(Il,{tab:"diagram-to-code",children:[dd(Sl,{children:["For the diagram-to-code feature we use"," ",Wr(Co,{icon:Wc}),"OpenAI."]}),dd(Sl,{children:["While the OpenAI API is in beta, its use is strictly limited \u2014 as such we require you use your own API key. You can create an"," ",Wr("a",{href:"https://platform.openai.com/login?launch",rel:"noopener noreferrer",target:"_blank",children:"OpenAI account"}),", add a small credit (5 USD minimum), and"," ",Wr("a",{href:"https://platform.openai.com/api-keys",rel:"noopener noreferrer",target:"_blank",children:"generate your own API key"}),"."]}),Wr(Sl,{children:"Your OpenAI key does not leave the browser, and you can also set your own limit in your OpenAI account dashboard if needed."}),Wr(vu,{isRedacted:!0,value:t,placeholder:"Paste your API key here",label:"OpenAI API key",onChange:s=>{r(s),e.onChange(s.trim(),o)},selectOnRender:!0,onKeyDown:s=>s.key===S.ENTER&&a()}),Wr(Sl,{children:"By default, your API token is not persisted anywhere so you'll need to insert it again after reload. But, you can persist locally in your browser below."}),Wr(Wa,{checked:o,onChange:n,children:"Persist API key in browser storage"}),dd(Sl,{children:["Once API key is set, you can use the ",Wr(Co,{icon:el})," ","tool to wrap your elements in a frame that will then allow you to turn it into code. This dialog can be accessed using the"," ",Wr("b",{children:"AI Settings"})," ",Wr(Co,{icon:Wc}),"."]}),Wr(An,{className:"MagicSettings__confirm",size:"large",label:"Confirm",onClick:a})]})})})};f();f();import{useState as JS,useRef as QS,useEffect as eI,useDeferredValue as Z8}from"react";f();Y();Br();var W8=({canvasRef:e,setError:t})=>{let r=e.current;if(!r)return;let o=r.parentElement;o&&(o.style.background="",t(null),r.replaceChildren())},Vu=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:r,setError:o,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!r){W8({canvasRef:e,setError:o});return}try{let s=await t.api,l;try{l=await s.parseMermaidToExcalidraw(r,{fontSize:Tt})}catch{l=await s.parseMermaidToExcalidraw(r.replace(/"/g,"'"),{fontSize:Tt})}let{elements:c,files:d}=l;o(null),n.current={elements:Cl(c,{regenerateIds:!0}),files:d};let m=await Ri({elements:n.current.elements,files:n.current.files,exportPadding:Oo,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Zn(m)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(E("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(m)}catch(s){throw a.style.background="var(--default-bg-color)",r&&o(s),s}}},md=e=>{Hr.set(lo.MERMAID_TO_EXCALIDRAW,e)},Yu=({app:e,data:t,text:r,shouldSaveMermaidDataToStorage:o})=>{let{elements:n,files:i}=t.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),o&&r&&md(r))};f();import{jsx as V8}from"react/jsx-runtime";var Ku=({children:e})=>V8("div",{className:"ttd-dialog-panels",children:e});f();import XS from"clsx";import{jsx as SE,jsxs as pd}from"react/jsx-runtime";var Al=({label:e,children:t,panelAction:r,panelActionDisabled:o=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:s})=>pd("div",{className:"ttd-dialog-panel",children:[pd("div",{className:"ttd-dialog-panel__header",children:[SE("label",{children:e}),i?.()]}),t,pd("div",{className:XS("ttd-dialog-panel-button-container",{invisible:!r}),style:{display:"flex",alignItems:"center"},children:[pd(Sn,{className:"ttd-dialog-panel-button",onSelect:r?r.action:()=>{},disabled:o||n,children:[pd("div",{className:XS({invisible:n}),children:[r?.label,r?.icon&&SE("span",{children:r.icon})]}),n&&SE(Xt,{})]}),!o&&!n&&a?.(),s?.()]})]});f();Y();ge();import{useEffect as Y8,useRef as ZS}from"react";import{jsx as K8}from"react/jsx-runtime";var $u=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:o})=>{let n=ZS(null),i=ZS(o);return i.current=o,Y8(()=>{if(!i.current)return;let a=n.current;if(a){let s=l=>{l[S.CTRL_OR_CMD]&&l.key===S.ENTER&&(l.preventDefault(),i.current?.())};return a.addEventListener("keydown",s),()=>{a.removeEventListener("keydown",s)}}},[]),K8("textarea",{className:"ttd-dialog-input",onChange:r,value:e,placeholder:t,autoFocus:!0,ref:n})};f();import{jsx as Xu,jsxs as jS}from"react/jsx-runtime";var $8=({error:e})=>jS("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Xu("p",{children:e})]}),Zu=({error:e,canvasRef:t,loaded:r})=>jS("div",{className:"ttd-dialog-output-wrapper",children:[e&&Xu($8,{error:e.message}),r?Xu("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Xu(Xt,{size:"2rem"})]});Y();G();f();G();import{jsx as qS,jsxs as X8}from"react/jsx-runtime";var ju=()=>X8("div",{className:"ttd-dialog-submit-shortcut",children:[qS("div",{className:"ttd-dialog-submit-shortcut__key",children:R("CtrlOrCmd")}),qS("div",{className:"ttd-dialog-submit-shortcut__key",children:R("Enter")})]});import{Fragment as J8,jsx as Ln,jsxs as rI}from"react/jsx-runtime";var j8=`flowchart TD
|
|
55
|
+
`);try{wi(i)}catch{throw new Error(E("errors.copyToSystemClipboardFailed"))}return{storeAction:_.NONE}},predicate:(e,t,r,o)=>du&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(H),keywords:["text","clipboard","copy"]});f();ye();$e();Y();ee();Re();var ug=G({name:"gridMode",icon:Ow,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.gridSize},perform(e,t){return{appState:{...t,gridSize:this.checked(t)?null:ni,objectsSnapModeEnabled:!1},storeAction:_.NONE}},checked:e=>e.gridSize!==null,predicate:(e,t,r)=>typeof r.gridModeEnabled>"u",keyTest:e=>e[S.CTRL_OR_CMD]&&e.code===Se.QUOTE});f();ee();ye();Re();$e();var $l=G({name:"zenMode",label:"buttons.zenMode",icon:_w,paletteName:"Toggle zen mode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},storeAction:_.NONE}},checked:e=>e.zenModeEnabled,predicate:(e,t,r)=>typeof r.zenModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.Z});f();ee();ye();Re();$e();var UE=G({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Dw,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridSize:null},storeAction:_.NONE}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,r)=>typeof r.objectsSnapModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.S});f();$e();ye();ee();Re();var Zl=G({name:"stats",label:"stats.fullTitle",icon:Aw,paletteName:"Toggle stats",viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},storeAction:_.NONE}},checked:e=>e.stats.open,keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.SLASH});f();Y();we();De();He();Au();me();V();$e();ko();Re();var GE=G({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>o.scene.getSelectedElements(t).some(i=>Ct(i)),perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=o.scene.getNonDeletedElementsMap();return n.forEach(a=>{let s=J(a,i);if(s){let{width:l,height:c}=Vt(s.originalText,Me(s),s.lineHeight),d=qT(a.id);Cu(a.id);let{x:m,y:p}=Ll(a,s,i);F(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),F(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:t,storeAction:_.CAPTURE}}}),WE=G({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);if(n.length===2){let i=H(n[0])||H(n[1]),a;if(Mn(n[0])?a=n[0]:Mn(n[1])&&(a=n[1]),i&&a&&J(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i,a;H(n[0])&&Mn(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),F(i,{containerId:a.id,verticalAlign:kt.MIDDLE,textAlign:Oi.CENTER,autoResize:!0}),F(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return ft(i,a,o.scene.getNonDeletedElementsMap()),ss(a.id,s),{elements:eD(e,a,i),appState:{...t,selectedElementIds:{[a.id]:!0}},storeAction:_.CAPTURE}}}),eD=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===r.id);o.splice(n,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i+1,0,r),Jt(o,Z([t,r])),o},tD=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===t.id);o.splice(n,1);let i=o.findIndex(a=>a.id===r.id);return o.splice(i,0,t),Jt(o,Z([t,r])),o},US=G({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=n.every(a=>H(a));return n.length>0&&i},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=e.slice(),a={};for(let s of n)if(H(s)){let l=go({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:kn("rectangle")?ct.ADAPTIVE_RADIUS:ct.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-wt,y:s.y-wt,width:Si(s.width,"rectangle"),height:Si(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)&&F(m,{startBinding:p,endBinding:u},!1)})}F(s,{containerId:l.id,verticalAlign:kt.MIDDLE,boundElements:null,textAlign:Oi.CENTER,autoResize:!0},!1),ft(s,l,o.scene.getNonDeletedElementsMap()),i=tD([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...t,selectedElementIds:a},storeAction:_.CAPTURE}}});f();f();V();ad();De();ee();ye();Y();dt();import{useCallback as GS,useEffect as rD,useLayoutEffect as oD,useRef as nD,useState as iD}from"react";import aD from"clsx";et();Zc();Oa();me();tu();import{jsx as Gd,jsxs as WS}from"react/jsx-runtime";var XE=320,VS=85,VE=5,sD=42,lD=500,YE=!1,gg=new Map,YS=({element:e,elementsMap:t,setAppState:r,onLinkOpen:o,setToast:n,updateEmbedValidationStatus:i})=>{let a=Gn(),s=Wn(),l=e.link||"",[c,d]=iD(l),m=nD(null),p=a.showHyperlinkPopup==="editor",u=GS(()=>{if(!m.current)return;let y=Pr(m.current.value)||null;if(!e.link&&y&&Ce("hyperlink","create"),Rt(e)){if(a.activeEmbeddable?.element===e&&r({activeEmbeddable:null}),!y){F(e,{link:null}),i(e,!1);return}if(!hl(y,s.validateEmbeddable))y&&n({message:E("toast.unableToEmbed"),closable:!0}),e.link&&gg.set(e.id,e.link),F(e,{link:y}),i(e,!1);else{let{width:w,height:C}=e,M=xi(y);M?.error instanceof URIError&&n({message:E("toast.unrecognizedLinkFormat"),closable:!0});let I=M?M.intrinsicSize.w/M.intrinsicSize.h:1,P=gg.get(e.id)!==e.link;F(e,{...P?{width:M?.type==="video"?w>C?w:C*I:w,height:M?.type==="video"&&w>C?w/I:C}:{},link:y}),i(e,!0),gg.has(e.id)&&gg.delete(e.id)}}else F(e,{link:y})},[e,n,s.validateEmbeddable,a.activeEmbeddable,r,i]);oD(()=>()=>{u()},[u]),rD(()=>{let y=null,w=C=>{if(p)return;y&&clearTimeout(y),dD(e,t,a,[C.clientX,C.clientY])&&(y=window.setTimeout(()=>{r({showHyperlinkPopup:!1})},lD))};return window.addEventListener("pointermove",w,!1),()=>{window.removeEventListener("pointermove",w,!1),y&&clearTimeout(y)}},[a,e,p,r,t]);let g=GS(()=>{Ce("hyperlink","delete"),F(e,{link:null}),p&&(m.current.value=""),r({showHyperlinkPopup:!1})},[r,e,p]),h=()=>{Ce("hyperlink","edit","popup-ui"),r({showHyperlinkPopup:"editor"})},{x,y:v}=XS(e,a,t);return a.contextMenu||a.draggingElement||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:WS("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${v}px`,left:`${x}px`,width:XE,padding:VE},onClick:()=>{!e.link&&!p&&r({showHyperlinkPopup:"editor"})},children:[p?Gd("input",{className:aD("excalidraw-hyperlinkContainer-input"),placeholder:"Type or paste your link here",ref:m,value:c,onChange:y=>d(y.target.value),autoFocus:!0,onKeyDown:y=>{y.stopPropagation(),y[S.CTRL_OR_CMD]&&y.key===S.K&&y.preventDefault(),(y.key===S.ENTER||y.key===S.ESCAPE)&&(u(),r({showHyperlinkPopup:"info"}))}}):e.link?Gd("a",{href:Pr(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Xm(e.link)?"_self":"_blank",onClick:y=>{if(e.link&&o){let w=Fm("excalidraw-link",y.nativeEvent);o({...e,link:Pr(e.link)},w),w.defaultPrevented&&y.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Gd("div",{className:"excalidraw-hyperlinkContainer-link",children:E("labels.link.empty")}),WS("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!p&&Gd(fe,{type:"button",title:E("buttons.edit"),"aria-label":E("buttons.edit"),label:E("buttons.edit"),onClick:h,className:"excalidraw-hyperlinkContainer--edit",icon:ci}),l&&!Rt(e)&&Gd(fe,{type:"button",title:E("buttons.remove"),"aria-label":E("buttons.remove"),label:E("buttons.remove"),onClick:g,className:"excalidraw-hyperlinkContainer--remove",icon:tn})]})]})},XS=(e,t,r)=>{let[o,n]=ae(e,r),{x:i,y:a}=$t({sceneX:o+e.width/2,sceneY:n},t),s=i-t.offsetLeft-XE/2,l=a-t.offsetTop-VS;return{x:s,y:l}},KE=(e,t)=>{let r=he(e,t);return r[0]?.link?Rt(r[0])?"labels.link.editEmbed":"labels.link.edit":Rt(r[0])?"labels.link.createEmbed":"labels.link.create"},Wd=null,KS=(e,t,r)=>{Wd&&clearTimeout(Wd),Wd=window.setTimeout(()=>cD(e,t,r),l0)},cD=(e,t,r)=>{if(!e.link)return;let o=Gl();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=e.link;let[n,i,a,s]=ae(e,r),[l,c,d,m]=cd([n,i,a,s],e.angle,t),p=$t({sceneX:l,sceneY:c},t);kE(o,{left:p.x,top:p.y,width:d,height:m},"top"),Ce("hyperlink","tooltip","link-icon"),YE=!0},$S=()=>{Wd&&clearTimeout(Wd),YE&&(YE=!1,Gl().classList.remove("excalidraw-tooltip--visible"))},dD=(e,t,r,[o,n])=>{let{x:i,y:a}=Qe({clientX:o,clientY:n},r),s=15/r.zoom.value;if($c(i,a,e,t))return!1;let[l,c,d]=ae(e,t);if(i>=l&&i<=d&&a>=c-VS&&a<=c)return!1;let{x:m,y:p}=XS(e,r,t);return!(o>=m-s&&o<=m+XE+VE*2+s&&n>=p-s&&n<=p+s+VE*2+sD)};ee();me();ye();et();Re();V();$e();import{jsx as mD}from"react/jsx-runtime";var Vd=G({name:"hyperlink",label:(e,t)=>KE(e,t),icon:Lc,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},storeAction:_.CAPTURE},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.K,predicate:(e,t)=>he(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=he(e,t);return mD(fe,{type:"button",icon:Lc,"aria-label":E(KE(e,t)),title:`${Rt(e[0])?E("labels.link.labelEmbed"):E("labels.link.label")} - ${O("CtrlOrCmd+K")}`,onClick:()=>r(null),selected:o.length===1&&!!o[0].link})}});f();ee();De();me();ye();et();Re();V();$e();var $E=e=>e.every(t=>!t.locked),ZE=G({name:"toggleElementLock",label:(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return o.length===1&&!Q(o[0])?o[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":$E(o)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,t)=>{let r=he(t,e);return $E(r)?Ws:Fa},trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=$E(n),a=Z(n);return{elements:e.map(s=>a.has(s.id)?pe(s,{locked:i}):s),appState:{...t,selectedLinearElement:i?null:t.selectedLinearElement},storeAction:_.CAPTURE}},keyTest:(e,t,r,o)=>e.key.toLocaleLowerCase()===S.L&&e[S.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),ZS=G({name:"unlockAllElements",paletteName:"Unlock all elements",trackEvent:{category:"canvas"},viewMode:!1,icon:Fa,predicate:(e,t)=>he(e,t).length===0&&e.some(o=>o.locked),perform:(e,t)=>{let r=e.filter(o=>o.locked);return{elements:e.map(o=>o.locked?pe(o,{locked:!1}):o),appState:{...t,selectedElementIds:Object.fromEntries(r.map(o=>[o.id,!0]))},storeAction:_.CAPTURE}},label:"labels.elementLock.unlockAll"});f();f();import{useEffect as Ng,useRef as d7,useState as Rg}from"react";ye();f();import R8 from"clsx";import{useEffect as N8,useState as O8}from"react";f();import{useCallback as pD,useState as uD}from"react";var jS=()=>{let[e,t]=uD(null),r=pD(o=>t(o),[]);return[e,r]};ye();f();ye();import{createPortal as gD}from"react-dom";import hD from"clsx";import{useRef as fD}from"react";import{jsx as qS,jsxs as bD}from"react/jsx-runtime";var JS=e=>{let{closeOnClickOutside:t=!0}=e,r=Vu({className:"excalidraw-modal-container"}),o=fD(document.body.classList.contains("excalidraw-animations-disabled"));if(!r)return null;let n=i=>{i.key===S.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return gD(bD("div",{className:hD("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[qS("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),qS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),r)};V();import{useSetAtom as F8}from"jotai";f();import{useState as k8,useCallback as s1,useMemo as OI,useRef as a1}from"react";f();qr();el();import{atom as vD}from"jotai";dt();Hi();Y();import{useEffect as tI,useRef as rI}from"react";f();pr();import{atom as ED,useAtom as xD}from"jotai";import{useEffect as yD,useState as wD}from"react";os();var jE=ED(new Map),QS=async e=>await wl({elements:e,appState:{exportBackground:!1,viewBackgroundColor:Ee.white},files:null,renderEmbeddables:!1}),eI=(e,t,r)=>{let[o,n]=wD();return yD(()=>{if(t)if(e){let i=r.get(e);i?n(i):(async()=>{let a=await QS(t);a.querySelector(".style-fonts")?.remove(),a&&(r.set(e,a),n(a))})()}else(async()=>{let i=await QS(t);n(i)})()},[e,t,r,n]),o},hg=()=>{let[e]=xD(jE,Xe);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:o=>{o.forEach(n=>e.delete(n))},svgCache:e}};V();nd();f();V();var fg=class{jobs=[];running=!1;tick(){if(this.running)return;let t=this.jobs.shift();t?(this.running=!0,t.promise.resolve(Ic(t.jobFactory,...t.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(t,...r){let o=Om();return this.jobs.push({jobFactory:t,promise:o,args:r}),this.tick(),o}};we();var nI=new wr,Ts=vD({status:"loaded",isInitialized:!1,libraryItems:[]}),Yd=e=>Xr(e),TD=(e,t)=>!e.find(r=>r.elements.length!==t.elements.length?!1:r.elements.every((o,n)=>o.id===t.elements[n].id&&o.versionNonce===t.elements[n].versionNonce)),iI=(e,t)=>{let r=[];for(let o of t)TD(e,o)&&r.push(o);return[...r,...e]},aI=(e,t)=>{let r=Z(t),o={deletedItems:new Map,addedItems:new Map};for(let i of e)r.has(i.id)||o.deletedItems.set(i.id,i);let n=Z(e);for(let i of t)n.has(i.id)||o.addedItems.set(i.id,i);return o},qE=class{currLibraryItems=[];prevLibraryItems=Yd(this.currLibraryItems);app;constructor(t){this.app=t}updateQueue=[];getLastUpdateTask=()=>this.updateQueue[this.updateQueue.length-1];notifyListeners=()=>{if(this.updateQueue.length>0)mr.set(Ts,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{mr.set(Ts,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=Yd(this.currLibraryItems);let r=Yd(this.currLibraryItems);this.app.props.onLibraryChange?.(r),nI.trigger(aI(t,r),r)}catch(t){console.error(t)}}};destroy=()=>{this.updateQueue=[],this.currLibraryItems=[],mr.set(jE,new Map)};resetLibrary=()=>this.setLibrary([]);getLatestLibrary=()=>new Promise(async t=>{try{let r=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(Yd(r))}catch{return t(this.currLibraryItems)}});updateLibrary=async({libraryItems:t,prompt:r=!1,merge:o=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:co.name,tab:wc}}),this.setLibrary(()=>new Promise(async(a,s)=>{try{let l=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),c;l instanceof Blob?c=await Sf(l,i):c=Ga(l,i),!r||window.confirm(E("alerts.confirmAddLibrary",{numShapes:c.length}))?(r&&this.app.focusContainer(),a(o?iI(this.currLibraryItems,c):c)):s(new Pn)}catch(l){s(l)}})));setLibrary=t=>{let r=new Promise(async(o,n)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=Yd(await t),o(this.currLibraryItems)}catch(i){n(i)}}).catch(o=>{if(o.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw o}).finally(()=>{this.updateQueue=this.updateQueue.filter(o=>o!==r),this.notifyListeners()});return this.updateQueue.push(r),this.notifyListeners(),r}},sI=qE,xg=e=>{let r=Math.ceil(Math.sqrt(e.length)),o=[],n=u=>e.slice(u*r,u*r+r).reduce((h,x)=>{let{height:v}=Qr(x.elements);return Math.max(h,v)},0),i=u=>{let g=0,h=0,x=0;for(let v of e){if(g%r===0&&(h=0),h===u){let{width:y}=Qr(v.elements);x=Math.max(x,y)}g++,h++}return x},a=0,s=0,l=0,c=0,d=0,m=0,p=0;for(let u of e){d&&d%r===0&&(s+=l+50,a=0,m=0,p++),m===0&&(l=n(p)),c=i(m);let{minX:g,minY:h,width:x,height:v}=Qr(u.elements),y=(c-x)/2,w=(l-v)/2;o.push(...u.elements.map(C=>({...C,x:C.x+a+y-g,y:C.y+s+w-h}))),a+=c+50,d++,m++}return o},JE=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Am.addLibrary)||new URLSearchParams(window.location.search).get(Cm.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},jl=class e{static queue=new fg;static async getLibraryItems(t,r,o=!0){let n=()=>new Promise(async(i,a)=>{try{let s=await t.load({source:r});i(Ga(s?.libraryItems||[],"published"))}catch(s){a(s)}});return o?e.queue.push(n):n()}static run=async(t,r)=>{let o=new e(t);return e.queue.push(()=>r(o))};adapter;constructor(t){this.adapter=t}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}},Xd=0,bg=0,Eg=e=>$b(e.map(t=>`${t.id}:${Kb(t.elements)}`).sort().join()),oI=async(e,t)=>{try{return bg++,await jl.run(e,async r=>{let o=Z(await r.getLibraryItems("save"));for(let[s]of t.deletedItems)o.delete(s);let n=[];for(let[s,l]of t.addedItems)o.has(s)?o.set(s,l):n.push(l);let i=n.concat(Array.from(o.values())),a=Eg(i);return a!==Xd&&await e.save({libraryItems:i}),Xd=a,i})}finally{bg--}},SD=e=>{let{excalidrawAPI:t}=e,r=rI(e);r.current=e;let o=rI(!1);tI(()=>{if(!t)return;o.current=!1;let n=async({libraryUrl:s,idToken:l})=>{let c=new Promise(async(m,p)=>{try{let g=await(await fetch(decodeURIComponent(s))).blob();m(g)}catch(u){p(u)}}),d=l!==t.id;await(d&&document.hidden?new Promise(m=>{window.addEventListener("focus",()=>m(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(m){throw m}finally{if(window.location.hash.includes(Am.addLibrary)){let m=new URLSearchParams(window.location.hash.slice(1));m.delete(Am.addLibrary),window.history.replaceState({},fc,`#${m.toString()}`)}else if(window.location.search.includes(Cm.addLibrary)){let m=new URLSearchParams(window.location.search);m.delete(Cm.addLibrary),window.history.replaceState({},fc,`?${m.toString()}`)}}},i=s=>{s.preventDefault();let l=JE();l&&(s.stopImmediatePropagation(),window.history.replaceState({},"",s.oldURL),n(l))},a=JE();if(a&&n(a),"getInitialLibraryItems"in r.current&&r.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(r.current.getInitialLibraryItems()).then(s=>{t.updateLibrary({libraryItems:s,merge:!0})}).catch(s=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${s?.message}`)})),"adapter"in r.current&&r.current.adapter){let s=r.current.adapter,l=r.current.migrationAdapter,c=Om();l?c.resolve(Ic(l.load).then(async d=>{let m=null;try{if(!d)return jl.getLibraryItems(s,"load");m=Ga(d.libraryItems||[],"published");let p=await oI(s,aI([],m));try{await l.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),m}}).catch(d=>(console.error(`error during library migration: ${d.message}`),jl.getLibraryItems(s,"load")))):c.resolve(Ic(jl.getLibraryItems,s,"load")),t.updateLibrary({libraryItems:c.then(d=>{let m=d||[];return Xd=Eg(m),m}),merge:!0}).finally(()=>{o.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[t]),tI(()=>{let n=nI.on(async(a,s)=>{let l=o.current,c="adapter"in r.current&&r.current.adapter||null;try{c&&Xd!==Eg(s)&&await oI(c,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),l&&r.current.excalidrawAPI&&r.current.excalidrawAPI.updateScene({appState:{errorMessage:E("errors.saveLibraryError")}})}}),i=a=>{bg&&k0(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),Xd=0,bg=0}},[])};Zo();f();mi();import{useCallback as ec,useEffect as S8,useMemo as DI,useRef as I8,useState as C8}from"react";V();f();import{forwardRef as lI}from"react";import cI from"clsx";import{jsx as dI}from"react/jsx-runtime";var ID=lI(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>dI("div",{className:cI("Stack Stack_horizontal",n),style:{"--gap":t,alignItems:r,justifyContent:o,...i},ref:a,children:e})),CD=lI(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>dI("div",{className:cI("Stack Stack_vertical",n),style:{"--gap":t,justifyItems:r,justifyContent:o,...i},ref:a,children:e})),rr={Row:ID,Col:CD};Y();Nn();f();f();Y();import{jsx as MD}from"react/jsx-runtime";var AD=({theme:e,id:t,libraryReturnUrl:r})=>{let o=r||window.location.origin+window.location.pathname;return MD("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${o}&useHash=true&token=${t}&theme=${e}&version=${Da.excalidrawLibrary}`,target:"_excalidraw_libraries",children:E("labels.libraries")})},mI=AD;import kD from"clsx";import{jsx as PD,jsxs as LD}from"react/jsx-runtime";var yg=({libraryReturnUrl:e,theme:t,id:r,style:o,children:n,className:i})=>LD("div",{className:kD("library-menu-control-buttons",i),style:o,children:[PD(mI,{id:r,libraryReturnUrl:e,theme:t}),n]});f();import{useCallback as o8,useState as t1}from"react";f();import wg from"react";var DD=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,_D=/{{([\w-]+)}}/,RD=/<([\w-]+)>/,ND=/<\/([\w-]+)>/,OD=(e,t)=>{let r=[{name:"",children:[]}];return e.split(DD).filter(Boolean).forEach(o=>{let n=o.match(RD),i=o.match(ND),a=o.match(_D);if(n!==null){let s=n[1];t.hasOwnProperty(s)?r.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===r[r.length-1].name){let l=r.pop(),c=wg.createElement(wg.Fragment,{},...l.children),d=t[l.name];typeof d=="function"&&r[r.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];t.hasOwnProperty(s)?r[r.length-1].children.push(t[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else r[r.length-1].children.push(o)}),r.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),r[0].children},FD=({i18nKey:e,children:t,...r})=>{let{t:o}=Dt();return wg.createElement(wg.Fragment,{},...OD(o(e),r))},Br=FD;mi();ee();di();V();import{useAtom as r1}from"jotai";f();f();import BD from"clsx";import{jsx as vg,jsxs as HD}from"react/jsx-runtime";var zD=({label:e,onClick:t,className:r,children:o,actionType:n,type:i="button",isLoading:a,...s})=>{let l=n?`Dialog__action-button--${n}`:"";return HD("button",{className:BD("Dialog__action-button",l,r),type:i,"aria-label":e,onClick:t,...s,children:[o&&vg("div",{style:a?{visibility:"hidden"}:{},children:o}),vg("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&vg("div",{style:{position:"absolute",inset:0},children:vg(ir,{})})]})},ql=zD;import{useSetAtom as UD}from"jotai";import{jsx as pI,jsxs as uI}from"react/jsx-runtime";var GD=e=>{let{onConfirm:t,onCancel:r,children:o,confirmText:n=E("buttons.confirm"),cancelText:i=E("buttons.cancel"),className:a="",...s}=e,l=Oe(),c=UD(Jl,Xe),{container:d}=Ft();return uI(xt,{onCloseRequest:r,size:"small",...s,className:`confirm-dialog ${a}`,children:[o,uI("div",{className:"confirm-dialog-buttons",children:[pI(ql,{label:i,onClick:()=>{l({openMenu:null}),c(!1),r(),d?.focus()}}),pI(ql,{label:n,onClick:()=>{l({openMenu:null}),c(!1),t(),d?.focus()},actionType:"danger"})]})]})},Tg=GD;f();import{useCallback as WD,useEffect as e1,useRef as gI,useState as QE}from"react";import Sg from"open-color";os();Y();qr();V();ee();f();var ro=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),!1}}static get(t){try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):null}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),null}}static set=(t,r)=>{try{return window.localStorage.setItem(t,JSON.stringify(r)),!0}catch(o){return console.warn(`localStorage.setItem error: ${o.message}`),!1}};static delete=t=>{try{window.localStorage.removeItem(t)}catch(r){console.warn(`localStorage.removeItem error: ${r.message}`)}}};import{jsx as Pe,jsxs as Tr}from"react/jsx-runtime";var VD=async e=>{let o=Math.round(8),n=Math.max(Math.round(128/64),2),i=C0(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(o*2)-o*2,a.height=i.length*128+(i.length+1)*(o*2)-o*2;let s=a.getContext("2d");s.fillStyle=Sg.white,s.fillRect(0,0,a.width,a.height);for(let[l,c]of e.entries()){let d=await ia({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:m,height:p}=d,u=Math.floor(l/6)*(128+o*2),g=l%6*(128+o*2);s.drawImage(d,g+(128-m)/2+o,u+(128-p)/2+o),s.lineWidth=n,s.strokeStyle=Sg.gray[4],s.strokeRect(g+o/2,u+o/2,128+o,128+o)}return await zc(new File([await gi(a)],"preview",{type:se.png}),{outputType:se.jpg,maxWidthOrHeight:5e3})},YD=({libItem:e,appState:t,index:r,onChange:o,onRemove:n})=>{let i=gI(null),a=gI(null);return e1(()=>{let s=i.current;s&&(async()=>{let l=await wl({elements:e.elements,appState:{...t,viewBackgroundColor:Sg.white,exportBackground:!0},files:null});s.innerHTML=l.outerHTML})()},[e.elements,t]),Tr("div",{className:"single-library-item",children:[e.status==="published"&&Pe("span",{className:"single-library-item-status",children:E("labels.statusPublished")}),Pe("div",{ref:i,className:"single-library-item__svg"}),Pe(fe,{"aria-label":E("buttons.remove"),type:"button",icon:Ao,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:E("buttons.remove")}),Tr("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[Tr("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[Tr("div",{style:{padding:"0.5em 0"},children:[Pe("span",{style:{fontWeight:500,color:Sg.gray[6]},children:E("publishDialog.itemName")}),Pe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Pe("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:s=>{o(s.target.value,r)}})]}),Pe("span",{className:"error",children:e.error})]})]})},XD=({onClose:e,libraryItems:t,appState:r,onSuccess:o,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[s,l]=QE({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=QE(!1);e1(()=>{let w=ro.get(To.PUBLISH_LIBRARY);w&&l(w)},[]);let[m,p]=QE(t.slice());e1(()=>{p(t.slice())},[t]);let u=w=>{l({...s,[w.target.name]:w.target.value})},g=async w=>{w.preventDefault(),d(!0);let C=[],M=!1;if(m.forEach(D=>{let z="";D.name||(z=E("publishDialog.errors.required"),M=!0),C.push({...D,error:z})}),M){p(C),d(!1);return}let I=await VD(m),P={type:hr.excalidrawLibrary,version:Da.excalidrawLibrary,source:yc,libraryItems:m},A=JSON.stringify(P,null,2),N=new Blob([A],{type:"application/json"}),k=new FormData;k.append("excalidrawLib",N),k.append("previewImage",I),k.append("previewImageType",I.type),k.append("title",s.name),k.append("authorName",s.authorName),k.append("githubHandle",s.githubHandle),k.append("name",s.name),k.append("description",s.description),k.append("twitterHandle",s.twitterHandle),k.append("website",s.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:k}).then(D=>D.ok?D.json().then(({url:z})=>{ro.delete(To.PUBLISH_LIBRARY),o({url:z,authorName:s.authorName,items:m})}):D.json().catch(()=>{throw new Error(D.statusText||"something went wrong")}).then(z=>{throw new Error(z.message||D.statusText||"something went wrong")}),D=>{console.error(D),n(D),d(!1)}).catch(D=>{console.error(D),n(D),d(!1)})},h=()=>{let w=[];return m.forEach((C,M)=>{w.push(Pe("div",{className:"single-library-item-wrapper",children:Pe(YD,{libItem:C,appState:r,index:M,onChange:(I,P)=>{let A=m.slice();A[P].name=I,p(A)},onRemove:a})},M))}),Pe("div",{className:"selected-library-items",children:w})},x=WD(()=>{i(m),ro.set(To.PUBLISH_LIBRARY,s),e()},[m,e,i,s]),v=!!t.length,y=t.some(w=>w.status==="published");return Pe(xt,{onCloseRequest:x,title:E("publishDialog.title"),className:"publish-library",children:v?Tr("form",{onSubmit:g,children:[Pe("div",{className:"publish-library-note",children:Pe(Br,{i18nKey:"publishDialog.noteDescription",link:w=>Pe("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:w})})}),Pe("span",{className:"publish-library-note",children:Pe(Br,{i18nKey:"publishDialog.noteGuidelines",link:w=>Pe("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:w})})}),Pe("div",{className:"publish-library-note",children:E("publishDialog.noteItems")}),y&&Pe("span",{className:"publish-library-note publish-library-warning",children:E("publishDialog.republishWarning")}),h(),Tr("div",{className:"publish-library__fields",children:[Tr("label",{children:[Tr("div",{children:[Pe("span",{children:E("publishDialog.libraryName")}),Pe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Pe("input",{type:"text",name:"name",required:!0,value:s.name,onChange:u,placeholder:E("publishDialog.placeholder.libraryName")})]}),Tr("label",{style:{alignItems:"flex-start"},children:[Tr("div",{children:[Pe("span",{children:E("publishDialog.libraryDesc")}),Pe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Pe("textarea",{name:"description",rows:4,required:!0,value:s.description,onChange:u,placeholder:E("publishDialog.placeholder.libraryDesc")})]}),Tr("label",{children:[Tr("div",{children:[Pe("span",{children:E("publishDialog.authorName")}),Pe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Pe("input",{type:"text",name:"authorName",required:!0,value:s.authorName,onChange:u,placeholder:E("publishDialog.placeholder.authorName")})]}),Tr("label",{children:[Pe("span",{children:E("publishDialog.githubUsername")}),Pe("input",{type:"text",name:"githubHandle",value:s.githubHandle,onChange:u,placeholder:E("publishDialog.placeholder.githubHandle")})]}),Tr("label",{children:[Pe("span",{children:E("publishDialog.twitterUsername")}),Pe("input",{type:"text",name:"twitterHandle",value:s.twitterHandle,onChange:u,placeholder:E("publishDialog.placeholder.twitterHandle")})]}),Tr("label",{children:[Pe("span",{children:E("publishDialog.website")}),Pe("input",{type:"text",name:"website",pattern:"https?://.+",title:E("publishDialog.errors.website"),value:s.website,onChange:u,placeholder:E("publishDialog.placeholder.website")})]}),Pe("span",{className:"publish-library-note",children:Pe(Br,{i18nKey:"publishDialog.noteLicense",link:w=>Pe("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:w})})})]}),Tr("div",{className:"publish-library__buttons",children:[Pe(ql,{label:E("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),Pe(ql,{type:"submit",label:E("buttons.submit"),actionType:"primary",isLoading:c})]})]}):Pe("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:E("publishDialog.atleastOneLibItem")})})},hI=XD;f();f();import KD from"clsx";import{jsx as $D}from"react/jsx-runtime";var fI=({className:e="",children:t,onToggle:r,title:o,...n})=>{let i=Ne(),a=KD(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return $D("button",{"data-prevent-outside-click":!0,className:a,onClick:r,type:"button","data-testid":"dropdown-menu-button",title:o,...n,children:t})},bI=fI;fI.displayName="DropdownMenuTrigger";f();import{jsx as ZD}from"react/jsx-runtime";var EI=()=>ZD("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),xI=EI;EI.displayName="DropdownMenuSeparator";f();import jD from"clsx";import{useEffect as qD,useRef as JD}from"react";ye();Y();import{jsx as Ig}from"react/jsx-runtime";var yI=({children:e,onClickOutside:t,className:r="",onSelect:o,style:n})=>{let i=Ne(),a=JD(null),s=zl({onClickOutside:t});Bl(a,()=>{s.onClickOutside?.()}),qD(()=>{let c=m=>{m.key===S.ESCAPE&&(m.stopImmediatePropagation(),s.onClickOutside?.())},d={capture:!0};return document.addEventListener("keydown",c,d),()=>{document.removeEventListener("keydown",c,d)}},[s]);let l=jD(`dropdown-menu ${r}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Ig(xE.Provider,{value:{onSelect:o},children:Ig("div",{ref:a,className:l,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Ig(rr.Col,{className:"dropdown-menu-container",children:e}):Ig(Yt,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};yI.displayName="DropdownMenuContent";var wI=yI;f();import{jsx as vI}from"react/jsx-runtime";var TI=({icon:e,shortcut:t,href:r,children:o,onSelect:n,className:i="",selected:a,...s})=>{let l=Ju(s.onClick,n);return vI("a",{...s,href:r,target:"_blank",rel:"noreferrer",className:qu(i,a),title:s.title??s["aria-label"],onClick:l,children:vI(Qu,{icon:e,shortcut:t,children:o})})},Ql=TI;TI.displayName="DropdownMenuItemLink";f();import{jsx as e8}from"react/jsx-runtime";var QD=({children:e,className:t="",selected:r,...o})=>e8("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${r?"dropdown-menu-item--selected":""}`.trim(),children:e}),SI=QD;f();import Cg from"react";var II=e=>{let t=Cg.Children.toArray(e).find(r=>Cg.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuTrigger");return t||null},CI=e=>{let t=Cg.Children.toArray(e).find(r=>Cg.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuContent");return t||null};import{Fragment as t8,jsxs as r8}from"react/jsx-runtime";var ki=({children:e,open:t})=>{let r=II(e),o=CI(e);return r8(t8,{children:[r,t&&o]})};ki.Trigger=bI;ki.Content=wI;ki.Item=eo;ki.ItemLink=Ql;ki.ItemCustom=SI;ki.Group=Fd;ki.Separator=xI;var Ye=ki;ki.displayName="DropdownMenu";import n8 from"clsx";import{jsx as oo,jsxs as Ag}from"react/jsx-runtime";var i8=(e,t)=>e.filter(r=>t.includes(r.id)),a8=({setAppState:e,selectedItems:t,library:r,onRemoveFromLibrary:o,resetLibrary:n,onSelectItems:i,appState:a,className:s})=>{let[l]=r1(Ts,Xe),[c,d]=r1(Jl,Xe),m=()=>{let k=t.length?E("alerts.removeItemsFromsLibrary",{count:t.length}):E("alerts.resetLibrary"),D=t.length?E("confirmDialog.removeItemsFromLib"):E("confirmDialog.resetLibrary");return oo(Tg,{onConfirm:()=>{t.length?o():n(),u(!1)},onCancel:()=>{u(!1)},title:D,children:oo("p",{children:k})})},[p,u]=t1(!1),g=!!t.length,h=g?l.libraryItems.filter(k=>t.includes(k.id)):l.libraryItems,x=g?E("buttons.remove"):E("buttons.resetLibrary"),[v,y]=t1(!1),[w,C]=t1(null),M=o8(()=>Ag(xt,{onCloseRequest:()=>C(null),title:E("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[oo("p",{children:oo(Br,{i18nKey:"publishSuccessDialog.content",authorName:w.authorName,link:k=>oo("a",{href:w?.url,target:"_blank",rel:"noopener noreferrer",children:k})})}),oo(fe,{type:"button",title:E("buttons.close"),"aria-label":E("buttons.close"),label:E("buttons.close"),onClick:()=>C(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[C,w]),I=(k,D)=>{y(!1),C({url:k.url,authorName:k.authorName});let z=D.slice();z.forEach(R=>{t.includes(R.id)&&(R.status="published")}),r.setLibrary(z)},P=async()=>{try{await r.updateLibrary({libraryItems:js({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(k){if(k?.name==="AbortError"){console.warn(k);return}e({errorMessage:E("errors.importLibraryError")})}},A=async()=>{let k=g?h:await r.getLatestLibrary();Yw(k).catch(Nm).catch(D=>{e({errorMessage:D.message})})},N=()=>Ag(Ye,{open:c,children:[oo(Ye.Trigger,{onToggle:()=>d(!c),children:ny}),Ag(Ye.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!g&&oo(Ye.Item,{onSelect:P,icon:Ys,"data-testid":"lib-dropdown--load",children:E("buttons.load")}),!!h.length&&oo(Ye.Item,{onSelect:A,icon:Ba,"data-testid":"lib-dropdown--export",children:E("buttons.export")}),!!h.length&&oo(Ye.Item,{onSelect:()=>u(!0),icon:tn,children:x}),g&&oo(Ye.Item,{icon:uw,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:E("buttons.publishLibrary")})]})]});return Ag("div",{className:n8("library-menu-dropdown-container",s),children:[N(),t.length>0&&oo("div",{className:"library-actions-counter",children:t.length}),p&&m(),v&&oo(hI,{onClose:()=>y(!1),libraryItems:i8(l.libraryItems,t),appState:a,onSuccess:k=>I(k,l.libraryItems),onError:k=>window.alert(k),updateItemsInStorage:()=>r.setLibrary(l.libraryItems),onRemove:k=>i(t.filter(D=>D!==k))}),w&&M()]})},o1=({selectedItems:e,onSelectItems:t,className:r})=>{let{library:o}=tr(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=hg(),a=Ue(),s=Oe(),[l]=r1(Ts,Xe),c=async m=>{let p=m.filter(u=>!e.includes(u.id));o.setLibrary(p).catch(()=>{s({errorMessage:E("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return oo(a8,{appState:a,setAppState:s,selectedItems:e,onSelectItems:t,library:o,onRemoveFromLibrary:()=>c(l.libraryItems),resetLibrary:()=>{o.resetLibrary(),n()},className:r})};f();import{memo as h8,useEffect as f8,useState as b8}from"react";f();import AI from"clsx";import{memo as s8,useEffect as l8,useRef as c8,useState as d8}from"react";ee();import{jsx as Mg,jsxs as m8}from"react/jsx-runtime";var MI=s8(({id:e,elements:t,isPending:r,onClick:o,selected:n,onToggle:i,onDrag:a,svgCache:s})=>{let l=c8(null),c=eI(e,t,s);l8(()=>{let g=l.current;if(g)return c&&(g.innerHTML=c.outerHTML),()=>{g.innerHTML=""}},[c]);let[d,m]=d8(!1),p=Ne().editor.isMobile,u=r&&Mg("div",{className:"library-unit__adder",children:oy});return m8("div",{className:AI("library-unit",{"library-unit__active":t,"library-unit--hover":t&&d,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[Mg("div",{className:AI("library-unit__dragger",{"library-unit__pulse":!!r}),ref:l,draggable:!!t,onClick:t||r?g=>{e&&g.shiftKey?i(e,g):o(e)}:void 0,onDragStart:g=>{if(!e){g.preventDefault();return}m(!1),a(e,g)}}),u,e&&t&&(d||p||n)&&Mg(ys,{checked:n,onChange:(g,h)=>i(e,h),className:"library-unit__checkbox"})]})}),kI=()=>Mg("div",{className:"library-unit library-unit--skeleton"});f();import p8,{useCallback as u8}from"react";function g8(){return[!1,u8(t=>t(),[])]}var PI=p8.useTransition||g8;import{Fragment as E8,jsx as kg}from"react/jsx-runtime";var n1=({children:e})=>kg("div",{className:"library-menu-items-container__grid",children:e}),Pg=h8(({items:e,onItemSelectToggle:t,onItemDrag:r,isItemSelected:o,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,s]=PI(),[l,c]=b8(0);return f8(()=>{l<e.length&&s(()=>{c(l+a)})},[l,e.length,s,a]),kg(E8,{children:e.map((d,m)=>m<l?kg(MI,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:n,svgCache:i,id:d?.id,selected:o(d.id),onToggle:t,onDrag:r},d?.id??m):kg(kI,{},m))})});f();import{useEffect as x8}from"react";import{atom as y8,useAtom as w8}from"jotai";import v8 from"lodash.throttle";var T8=y8(0),LI=e=>{let[t,r]=w8(T8);return x8(()=>{let{current:o}=e;if(!o)return;let n=v8(()=>{let{scrollTop:i}=o;r(i)},200);return o.addEventListener("scroll",n),()=>{n.cancel(),o.removeEventListener("scroll",n)}},[e,r]),t};import{Fragment as _I,jsx as no,jsxs as tc}from"react/jsx-runtime";var A8=17,M8=64;function i1({isLoading:e,libraryItems:t,onAddToLibrary:r,onInsertLibraryItems:o,pendingElements:n,theme:i,id:a,libraryReturnUrl:s,onSelectItems:l,selectedItems:c}){let d=I8(null),m=LI(d);S8(()=>{m>0&&d.current?.scrollTo(0,m)},[]);let{svgCache:p}=hg(),u=DI(()=>t.filter(k=>k.status!=="published"),[t]),g=DI(()=>t.filter(k=>k.status==="published"),[t]),h=!t.length&&!n.length,x=!n.length&&!u.length&&!g.length,[v,y]=C8(null),w=ec((k,D)=>{let z=!c.includes(k),R=[...u,...g];if(z){if(D.shiftKey&&v){let W=R.findIndex(le=>le.id===v),q=R.findIndex(le=>le.id===k);if(W===-1||q===-1){l([...c,k]);return}let re=Z(c),ge=R.reduce((le,U,oe)=>((oe>=W&&oe<=q||re.has(U.id))&&le.push(U.id),le),[]);l(ge)}else l([...c,k]);y(k)}else y(null),l(c.filter(W=>W!==k))},[v,l,g,c,u]),C=ec(k=>{let D;return c.includes(k)?D=t.filter(z=>c.includes(z.id)):D=t.filter(z=>z.id===k),D.map(z=>({...z,elements:Ap(z.elements,{randomizeSeed:!0})}))},[t,c]),M=ec((k,D)=>{D.dataTransfer.setData(se.excalidrawlib,hp(C(k)))},[C]),I=ec(k=>k?c.includes(k):!1,[c]),P=ec(()=>{r(n)},[n,r]),A=ec(k=>{k&&o(C(k))},[C,o]),N=p.size>=t.length?M8:A8;return tc("div",{className:"library-menu-items-container",style:n.length||u.length||g.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&no(o1,{selectedItems:c,onSelectItems:l,className:"library-menu-dropdown-container--in-heading"}),tc(rr.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:g.length>0?1:"0 1 auto",marginBottom:0},ref:d,children:[tc(_I,{children:[!x&&no("div",{className:"library-menu-items-container__header",children:E("labels.personalLib")}),e&&no("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:no(ir,{})}),!n.length&&!u.length?tc("div",{className:"library-menu-items__no-items",children:[no("div",{className:"library-menu-items__no-items__label",children:E("library.noItems")}),no("div",{className:"library-menu-items__no-items__hint",children:g.length>0?E("library.hint_emptyPrivateLibrary"):E("library.hint_emptyLibrary")})]}):tc(n1,{children:[n.length>0&&no(Pg,{itemsRenderedPerBatch:N,items:[{id:null,elements:n}],onItemSelectToggle:w,onItemDrag:M,onClick:P,isItemSelected:I,svgCache:p}),no(Pg,{itemsRenderedPerBatch:N,items:u,onItemSelectToggle:w,onItemDrag:M,onClick:A,isItemSelected:I,svgCache:p})]})]}),tc(_I,{children:[(g.length>0||n.length>0||u.length>0)&&no("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:E("labels.excalidrawLib")}),g.length>0?no(n1,{children:no(Pg,{itemsRenderedPerBatch:N,items:g,onItemSelectToggle:w,onItemDrag:M,onClick:A,isItemSelected:I,svgCache:p})}):u.length>0?no("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:E("library.noItems")}):null]}),h&&no(yg,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:s,theme:i,children:no(o1,{selectedItems:c,onSelectItems:l})})]})]})}import{atom as P8,useAtom as L8}from"jotai";et();V();Y();import{jsx as ua,jsxs as NI}from"react/jsx-runtime";var Jl=P8(!1),RI=({children:e})=>ua("div",{className:"layer-ui__library",children:e}),D8=({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:r,setAppState:o,libraryReturnUrl:n,library:i,id:a,theme:s,selectedItems:l,onSelectItems:c})=>{let[d]=L8(Ts,Xe),m=s1(g=>{(async(x,v)=>{Ce("element","addToLibrary","ui");for(let w of Pm)if(x.some(C=>C.type===w))return o({errorMessage:E(`errors.libraryElementTypeError.${w}`)});let y=[{status:"unpublished",elements:x,id:Ut(),created:Date.now()},...v];r(),i.setLibrary(y).catch(()=>{o({errorMessage:E("alerts.errorAddingToLibrary")})})})(g,d.libraryItems)},[r,i,o,d.libraryItems]),p=OI(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return ua(RI,{children:ua("div",{className:"layer-ui__library-message",children:NI("div",{children:[ua(ir,{size:"2em"}),ua("span",{children:E("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||t.length>0;return NI(RI,{children:[ua(i1,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:m,onInsertLibraryItems:e,pendingElements:t,id:a,libraryReturnUrl:n,theme:s,onSelectItems:c,selectedItems:l}),u&&ua(yg,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:s})]})},_8=(e,t)=>{let r=()=>he(t,e,{includeBoundTextElement:!0,includeElementsInFrames:!0}),o=a1(r()),n=a1(e),i=a1(t);return(!it(e.selectedElementIds,n.current.selectedElementIds)||!it(t,i.current))&&(o.current=r(),n.current=e,i.current=t),o.current},FI=()=>{let{library:e,id:t,onInsertElements:r}=tr(),o=Wn(),n=Ue(),i=Oe(),a=da(),[s,l]=k8([]),c=OI(()=>e,[e]),d=_8(n,a),m=s1(u=>{r(xg(u))},[r]),p=s1(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return ua(D8,{pendingElements:d,onInsertLibraryItems:m,onAddToLibrary:p,setAppState:i,libraryReturnUrl:o.libraryReturnUrl,library:c,id:t,theme:n.theme,selectedItems:s,onSelectItems:l})};ee();import{jsx as Kd,jsxs as z8}from"react/jsx-runtime";function B8(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var xt=e=>{let[t,r]=jS(),[o]=O8(document.activeElement),{id:n}=Ft(),i=Ne().viewport.isMobile;N8(()=>{if(!t)return;let c=Tc(t);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=m=>{if(m.key===S.TAB){let p=Tc(t),{activeElement:u}=document,g=p.findIndex(h=>h===u);g===0&&m.shiftKey?(p[p.length-1].focus(),m.preventDefault()):g===p.length-1&&!m.shiftKey&&(p[0].focus(),m.preventDefault())}};return t.addEventListener("keydown",d),()=>t.removeEventListener("keydown",d)},[t,e.autofocus]);let a=Oe(),s=F8(Jl,Xe),l=()=>{a({openMenu:null}),s(!1),o.focus(),e.onCloseRequest()};return Kd(JS,{className:R8("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:B8(e.size),onCloseRequest:l,closeOnClickOutside:e.closeOnClickOutside,children:z8(Yt,{ref:r,children:[e.title&&Kd("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Kd("span",{className:"Dialog__titleContent",children:e.title})}),i&&Kd("button",{className:"Dialog__close",onClick:l,title:E("buttons.close"),"aria-label":E("buttons.close"),type:"button",children:Ao}),Kd("div",{className:"Dialog__content",children:e.children})]})})};f();import{forwardRef as G8,useRef as W8,useImperativeHandle as V8,useLayoutEffect as Y8,useState as X8}from"react";import l1 from"clsx";f();V();import H8 from"clsx";import{jsx as U8}from"react/jsx-runtime";var Yn=({type:e="button",onSelect:t,selected:r,children:o,className:n="",...i})=>U8("button",{onClick:zi(i.onClick,a=>{t()}),type:e,className:H8("excalidraw-button",n,{selected:r}),...i,children:o});ee();import{jsx as c1,jsxs as BI}from"react/jsx-runtime";var Lg=G8(({onChange:e,label:t,fullWidth:r,placeholder:o,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,...l},c)=>{let d=W8(null);V8(c,()=>d.current),Y8(()=>{i&&d.current?.select()},[i]);let[m,p]=X8(!1);return BI("div",{className:l1("ExcTextField",{"ExcTextField--fullWidth":r}),onClick:()=>{d.current?.focus()},children:[c1("div",{className:"ExcTextField__label",children:t}),BI("div",{className:l1("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[c1("input",{className:l1({"is-redacted":"value"in l&&l.value&&s&&!m}),readOnly:n,value:"value"in l?l.value:void 0,defaultValue:"defaultValue"in l?l.defaultValue:void 0,placeholder:o,ref:d,onChange:u=>e?.(u.target.value),onKeyDown:a}),s&&c1(Yn,{onSelect:()=>p(!m),style:{border:0,userSelect:"none"},children:m?yw:Zs})]})]})});et();import XI from"clsx";f();Y();V();var K8={toggleTheme:[O("Shift+Alt+D")],saveScene:[O("CtrlOrCmd+S")],loadScene:[O("CtrlOrCmd+O")],clearCanvas:[O("CtrlOrCmd+Delete")],imageExport:[O("CtrlOrCmd+Shift+E")],commandPalette:[O("CtrlOrCmd+/"),O("CtrlOrCmd+Shift+P")],cut:[O("CtrlOrCmd+X")],copy:[O("CtrlOrCmd+C")],paste:[O("CtrlOrCmd+V")],copyStyles:[O("CtrlOrCmd+Alt+C")],pasteStyles:[O("CtrlOrCmd+Alt+V")],selectAll:[O("CtrlOrCmd+A")],deleteSelectedElements:[O("Delete")],duplicateSelection:[O("CtrlOrCmd+D"),O(`Alt+${E("helpDialog.drag")}`)],sendBackward:[O("CtrlOrCmd+[")],bringForward:[O("CtrlOrCmd+]")],sendToBack:[Cr?O("CtrlOrCmd+Alt+["):O("CtrlOrCmd+Shift+[")],bringToFront:[Cr?O("CtrlOrCmd+Alt+]"):O("CtrlOrCmd+Shift+]")],copyAsPng:[O("Shift+Alt+C")],copyAsSvg:[],group:[O("CtrlOrCmd+G")],ungroup:[O("CtrlOrCmd+Shift+G")],gridMode:[O("CtrlOrCmd+'")],zenMode:[O("Alt+Z")],objectsSnapMode:[O("Alt+S")],stats:[O("Alt+/")],addToLibrary:[],flipHorizontal:[O("Shift+H")],flipVertical:[O("Shift+V")],viewMode:[O("Alt+R")],hyperlink:[O("CtrlOrCmd+K")],toggleElementLock:[O("CtrlOrCmd+Shift+L")],resetZoom:[O("CtrlOrCmd+0")],zoomOut:[O("CtrlOrCmd+-")],zoomIn:[O("CtrlOrCmd++")],zoomToFitSelection:[O("Shift+3")],zoomToFit:[O("Shift+1")],zoomToFitSelectionInViewport:[O("Shift+2")],toggleEraserTool:[O("E")],toggleHandTool:[O("H")],setFrameAsActiveTool:[O("F")],saveFileToDisk:[O("CtrlOrCmd+S")],saveToActiveFile:[O("CtrlOrCmd+S")],toggleShortcuts:[O("?")]},Bt=(e,t=0)=>{let r=K8[e];return r&&r.length>0?r[t]||r[0]:""};Y();ee();import m7 from"fuzzy";V();import{atom as p7,useAtom as u7}from"jotai";f();var $8="\\u0300-\\u036f",Z8="\\ufe20-\\ufe2f",j8="\\u20d0-\\u20ff",q8=$8+Z8+j8,J8=`[${q8}]`,Q8=RegExp(J8,"g"),e7=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,t7={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},d1=e=>e.replace(e7,t=>t7[t]||t).replace(Q8,"");f();import{jsx as r7}from"react/jsx-runtime";var Fo=({icon:e})=>r7("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});dl();f();import{useState as o7}from"react";et();dl();V();bd();me();import u1 from"clsx";He();ee();ye();f();import m1 from"react";import Xn from"tunnel-rat";var p1=m1.createContext(null),ut=()=>m1.useContext(p1),zI=()=>m1.useMemo(()=>({MainMenuTunnel:Xn(),WelcomeScreenMenuHintTunnel:Xn(),WelcomeScreenToolbarHintTunnel:Xn(),WelcomeScreenHelpHintTunnel:Xn(),WelcomeScreenCenterTunnel:Xn(),FooterCenterTunnel:Xn(),DefaultSidebarTriggerTunnel:Xn(),DefaultSidebarTabTriggersTunnel:Xn(),OverwriteConfirmDialogTunnel:Xn(),TTDDialogTriggerTunnel:Xn(),jotaiScope:Symbol()}),[]);import{Fragment as Pi,jsx as gt,jsxs as Lt}from"react/jsx-runtime";var g1=(e,t)=>{let r=t[0]?.type||null;for(let o of t)if(o.type!==r){r=null;break}return fd(e.activeTool.type)&&e.activeTool.type!=="image"&&r!=="image"&&r!=="frame"&&r!=="magicframe"||t.some(o=>fd(o.type))},h1=(e,t)=>vi(e.activeTool.type)||t.some(r=>vi(r.type)),Dg=({appState:e,elementsMap:t,renderAction:r})=>{let o=Pd(t,e),n=!1;o.length===2&&(Ct(o[0])||Ct(o[1]))&&(n=!0);let i=!!e.editingElement,a=Ne(),s=document.documentElement.getAttribute("dir")==="rtl",l=vi(e.activeTool.type)&&!Ar(e.currentItemBackgroundColor)||o.some(m=>vi(m.type)&&!Ar(m.backgroundColor)),c=o.length===1||n,d=!e.editingLinearElement&&o.length===1&&ie(o[0])&&!de(o[0]);return Lt("div",{className:"panelColumn",children:[gt("div",{children:g1(e,o)&&r("changeStrokeColor")}),h1(e,o)&>("div",{children:r("changeBackgroundColor")}),l&&r("changeFillStyle"),(wu(e.activeTool.type)||o.some(m=>wu(m.type)))&&r("changeStrokeWidth"),(e.activeTool.type==="freedraw"||o.some(m=>m.type==="freedraw"))&&r("changeStrokeShape"),(vu(e.activeTool.type)||o.some(m=>vu(m.type)))&&Lt(Pi,{children:[r("changeStrokeStyle"),r("changeSloppiness")]}),(Il(e.activeTool.type)||o.some(m=>Il(m.type)))&>(Pi,{children:r("changeRoundness")}),(yb(e.activeTool.type)||o.some(m=>yb(m.type)))&>(Pi,{children:r("changeArrowType")}),(e.activeTool.type==="text"||o.some(H))&&Lt(Pi,{children:[r("changeFontFamily"),r("changeFontSize"),(e.activeTool.type==="text"||r3(o,t))&&r("changeTextAlign")]}),t3(o,t)&&r("changeVerticalAlign"),(is(e.activeTool.type)||o.some(m=>is(m.type)))&>(Pi,{children:r("changeArrowhead")}),r("changeOpacity"),Lt("fieldset",{children:[gt("legend",{children:E("labels.layers")}),Lt("div",{className:"buttonList",children:[r("sendToBack"),r("sendBackward"),r("bringForward"),r("bringToFront")]})]}),o.length>1&&!n&&Lt("fieldset",{children:[gt("legend",{children:E("labels.align")}),Lt("div",{className:"buttonList",children:[s?Lt(Pi,{children:[r("alignRight"),r("alignHorizontallyCentered"),r("alignLeft")]}):Lt(Pi,{children:[r("alignLeft"),r("alignHorizontallyCentered"),r("alignRight")]}),o.length>2&&r("distributeHorizontally"),gt("div",{style:{flexBasis:"100%",height:0}}),Lt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[r("alignTop"),r("alignVerticallyCentered"),r("alignBottom"),o.length>2&&r("distributeVertically")]})]})]}),!i&&o.length>0&&Lt("fieldset",{children:[gt("legend",{children:E("labels.actions")}),Lt("div",{className:"buttonList",children:[!a.editor.isMobile&&r("duplicateSelection"),!a.editor.isMobile&&r("deleteSelectedElements"),r("group"),r("ungroup"),c&&r("hyperlink"),d&&r("toggleLinearEditor")]})]})]})},_g=({activeTool:e,appState:t,app:r,UIOptions:o})=>{let[n,i]=o7(!1),a=e.type==="frame",s=e.type==="laser",l=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=ut();return Lt(Pi,{children:[jc.map(({value:d,icon:m,key:p,numericKey:u,fillable:g},h)=>{if(o.tools?.[d]===!1)return null;let x=E(`toolBar.${d}`),v=p&&Bi(typeof p=="string"?p:p[0]),y=v?`${v} ${E("helpDialog.or")} ${u}`:`${u}`;return gt(fe,{className:u1("Shape",{fillable:g}),type:"radio",icon:m,checked:e.type===d,name:"editor-current-shape",title:`${Bi(x)} \u2014 ${y}`,keyBindingLabel:u||v,"aria-label":Bi(x),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:w})=>{!t.penDetected&&w==="pen"&&r.togglePenMode(!0)},onChange:({pointerType:w})=>{t.activeTool.type!==d&&Ce("toolbar",d,"ui"),d==="image"?r.setActiveTool({type:d,insertOnCanvasDirectly:w!=="mouse"}):r.setActiveTool({type:d})}},d)}),gt("div",{className:"App-toolbar__divider"}),Lt(Ye,{open:n,children:[Lt(Ye.Trigger,{className:u1("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||l||s&&!r.props.isCollaborating}),onToggle:()=>i(!n),title:E("toolBar.extraTools"),children:[Ew,r.props.aiEnabled!==!1&>("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:8,fontFamily:"Cascadia, monospace",position:"absolute",background:"var(--color-promo)",color:"var(--color-surface-lowest)",bottom:3,right:4},children:"AI"})]}),Lt(Ye.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[gt(Ye.Item,{onSelect:()=>r.setActiveTool({type:"frame"}),icon:sp,shortcut:S.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:E("toolBar.frame")}),gt(Ye.Item,{onSelect:()=>r.setActiveTool({type:"embeddable"}),icon:xy,"data-testid":"toolbar-embeddable",selected:l,children:E("toolBar.embeddable")}),gt(Ye.Item,{onSelect:()=>r.setActiveTool({type:"laser"}),icon:cp,"data-testid":"toolbar-laser",selected:s,shortcut:S.K.toLocaleUpperCase(),children:E("toolBar.laser")}),gt("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),r.props.aiEnabled!==!1&>(c.Out,{}),gt(Ye.Item,{onSelect:()=>r.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:lp,"data-testid":"toolbar-embeddable",children:E("toolBar.mermaidToExcalidraw")}),r.props.aiEnabled!==!1&&Lt(Pi,{children:[Lt(Ye.Item,{onSelect:()=>r.onMagicframeToolSelect(),icon:$s,"data-testid":"toolbar-magicframe",children:[E("toolBar.magicframe"),gt(Ye.Item.Badge,{children:"AI"})]}),gt(Ye.Item,{onSelect:()=>{Ce("ai","open-settings","d2c"),r.setOpenDialog({name:"settings",source:"settings",tab:"diagram-to-code"})},icon:_c,"data-testid":"toolbar-magicSettings",children:E("toolBar.magicSettings")})]})]})]})]})},HI=({renderAction:e,zoom:t})=>gt(rr.Col,{gap:1,className:"zoom-actions",children:Lt(rr.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),UI=({renderAction:e,className:t})=>Lt("div",{className:`undo-redo-buttons ${t}`,children:[gt("div",{className:"undo-button-container",children:gt(Eo,{label:E("buttons.undo"),children:e("undo")})}),gt("div",{className:"redo-button-container",children:Lt(Eo,{label:E("buttons.redo"),children:[" ",e("redo")]})})]}),GI=({actionManager:e,showExitZenModeBtn:t})=>gt("button",{type:"button",className:u1("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction($l),children:E("buttons.exitZenMode")}),WI=({renderAction:e,className:t})=>gt("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})});f();import{useRef as n7}from"react";var f1=e=>{let t=n7({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...r)=>t.current.userFn(...r)),t.current.stableFn};f();import{atom as i7,useAtom as a7}from"jotai";import{jsx as l7,jsxs as s7}from"react/jsx-runtime";var Ss=i7(null),VI=()=>{let[e,t]=a7(Ss,Xe),r=Xt();return e&&e==="clearCanvas"?l7(Tg,{onConfirm:()=>{r.executeAction(Ai),t(null)},onCancel:()=>t(null),title:E("clearCanvasDialog.title"),children:s7("p",{className:"clear-canvas__content",children:[" ",E("alerts.clearReset")]})}):null};var b1={};Ch(b1,{toggleTheme:()=>c7});f();var c7={...bs,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(bs,"commandPalette")}};import{jsx as zr,jsxs as Kn}from"react/jsx-runtime";var g7=p7(null),Mt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},h7=e=>{switch(e){case Mt.app:return 1;case Mt.export:return 2;case Mt.editor:return 3;case Mt.tools:return 4;case Mt.elements:return 5;case Mt.links:return 6;default:return 10}},Og=({shortcut:e,className:t,children:r})=>{let o=e.replace("++","+$").split("+");return Kn("div",{className:XI("shortcut",t),children:[o.map((n,i)=>zr("div",{className:"shortcut-wrapper",children:zr("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),zr("div",{className:"shortcut-desc",children:r})]})},KI=e=>!e.altKey&&e[S.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===S.P||e.key===S.SLASH),Xue=Object.assign(e=>{let t=Ue(),r=Oe();return Ng(()=>{let o=n=>{KI(n)&&(n.preventDefault(),n.stopPropagation(),r(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&Ce("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",o,{capture:!0}),()=>window.removeEventListener("keydown",o,{capture:!0})},[r]),t.openDialog?.name!=="commandPalette"?null:zr(f7,{...e})},{defaultItems:b1});function f7({customCommandPaletteItems:e}){let t=tr(),r=Ue(),o=Oe(),n=Wn(),i=Xt(),[a,s]=u7(g7),[l,c]=Rg(null),d=d7(null),m=zl({uiAppState:r,customCommandPaletteItems:e,appProps:n});Ng(()=>{let{uiAppState:I,customCommandPaletteItems:P,appProps:A}=m,N=R=>{let W="";return R.label&&(typeof R.label=="function"?W=E(R.label(t.scene.getNonDeletedElements(),I,t)):W=E(R.label)),W},k=R=>typeof R.icon=="function"?R.icon(I,t.scene.getNonDeletedElements()):R.icon,D=[],z=(R,W,q)=>{let re={label:N(R),icon:k(R),category:W,shortcut:Bt(R.name),keywords:R.keywords,predicate:R.predicate,viewMode:R.viewMode,perform:()=>{i.executeAction(R,"commandPalette")}};return q?q(re,R):re};if(I&&t.scene&&i){let R=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,Vd].map(U=>z(U,Mt.elements,(oe,Ie)=>({...oe,predicate:Ie.predicate?Ie.predicate:(Fe,lt,Je,Gr)=>he(Fe,lt).length>0}))),W=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool].map(U=>z(U,Mt.tools)),q=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(U=>z(U,Mt.editor)),re=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(U=>z(U,Mt.export));D=[...R,...q,{label:N(Ai),icon:k(Ai),shortcut:Bt(Ai.name),category:Mt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{mr.set(Ss,"clearCanvas")}},{label:E("buttons.exportImage"),category:Mt.export,icon:rp,shortcut:Bt("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{o({openDialog:{name:"imageExport"}})}},...re];let ge=[{label:E("toolBar.library"),category:Mt.app,icon:qm,viewMode:!1,perform:()=>{I.openSidebar?o({openSidebar:null}):o({openSidebar:{name:co.name,tab:co.defaultTab}})}},{label:E("labels.changeStroke"),keywords:["color","outline"],category:Mt.elements,icon:tp,viewMode:!1,predicate:(U,oe)=>{let Ie=he(U,oe);return Ie.length>0&&g1(oe,Ie)},perform:()=>{o(U=>({openMenu:U.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:E("labels.changeBackground"),keywords:["color","fill"],icon:tp,category:Mt.elements,viewMode:!1,predicate:(U,oe)=>{let Ie=he(U,oe);return Ie.length>0&&h1(oe,Ie)},perform:()=>{o(U=>({openMenu:U.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:E("labels.canvasBackground"),keywords:["color"],icon:tp,category:Mt.editor,viewMode:!1,perform:()=>{o(U=>({openMenu:U.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...jc.reduce((U,oe)=>{let{value:Ie,icon:Fe,key:lt,numericKey:Je}=oe;if(A.UIOptions.tools?.[Ie]===!1)return U;let Wo=lt&&Bi(typeof lt=="string"?lt:lt[0])||Je,nr={label:E(`toolBar.${Ie}`),category:Mt.tools,shortcut:Wo,icon:Fe,keywords:["toolbar"],viewMode:!1,perform:({event:so})=>{Ie==="image"?t.setActiveTool({type:Ie,insertOnCanvasDirectly:so.type==="keydown"}):t.setActiveTool({type:Ie})}};return U.push(nr),U},[]),...W,{label:E("toolBar.lock"),category:Mt.tools,icon:I.activeTool.locked?Ws:Fa,shortcut:S.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${E("labels.textToDiagram")}...`,category:Mt.tools,icon:vw,viewMode:!1,predicate:A.aiEnabled,perform:()=>{o(U=>({...U,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${E("toolBar.mermaidToExcalidraw")}...`,category:Mt.tools,icon:lp,viewMode:!1,predicate:A.aiEnabled,perform:()=>{o(U=>({...U,openDialog:{name:"ttd",tab:"mermaid"}}))}}],le=[...D,...ge,...P||[]].map(U=>({...U,icon:U.icon||mp,order:U.order??h7(U.category),haystack:`${d1(U.label.toLocaleLowerCase())} ${U.keywords?.join(" ")||""}`}));c(le),s(le.find(U=>U.label===a?.label)??null)}},[m,t,i,c,a?.label,s,o]);let[p,u]=Rg(""),[g,h]=Rg(null),[x,v]=Rg({}),y=I=>{o({openDialog:null},I),u("")},w=(I,P)=>{r.openDialog?.name==="commandPalette"&&(P.stopPropagation(),P.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),y(()=>{I.perform({actionManager:i,event:P}),s(I),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},C=f1(I=>I.viewMode===!1&&r.viewModeEnabled?!1:typeof I.predicate=="function"?I.predicate(t.scene.getNonDeletedElements(),r,n,t):I.predicate===void 0||I.predicate),M=f1(I=>{let P=Tn(I.target)||KI(I)||I.key===S.ESCAPE;if(P&&I.key!==S.ARROW_UP&&I.key!==S.ARROW_DOWN&&I.key!==S.ENTER)return;let A=Object.values(x).flat(),N=a&&!p&&C(a);if(I.key===S.ARROW_UP){I.preventDefault();let k=A.findIndex(R=>R.label===g?.label);if(N){if(k===0){h(a);return}if(g===a){let R=A[A.length-1];R&&h(R);return}}let D;k===-1?D=A.length-1:D=k===0?A.length-1:(k-1)%A.length;let z=A[D];z&&h(z);return}if(I.key===S.ARROW_DOWN){I.preventDefault();let k=A.findIndex(R=>R.label===g?.label);if(N){if(!g||k===A.length-1){h(a);return}if(g===a){let R=A[0];R&&h(R);return}}let D=(k+1)%A.length,z=A[D];z&&h(z);return}if(I.key===S.ENTER&&g&&setTimeout(()=>{w(g,I)}),!P){if(I.stopPropagation(),/^[a-zA-Z0-9]$/.test(I.key)){d?.current?.focus();return}I.preventDefault()}});return Ng(()=>(window.addEventListener("keydown",M,{capture:!0}),()=>window.removeEventListener("keydown",M,{capture:!0})),[M]),Ng(()=>{if(!l)return;let I=k=>{let D={};for(let z of k)D[z.category]?D[z.category].push(z):D[z.category]=[z];return D},P=l.filter(C).sort((k,D)=>k.order-D.order),A=!p&&a&&C(a);if(!p){v(I(A?P.filter(k=>k.label!==a?.label):P)),h(A?a:P[0]||null);return}let N=d1(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));P=m7.filter(N,P,{extract:k=>k.haystack}).sort((k,D)=>D.score-k.score).map(k=>k.original),v(I(P)),h(P[0]??null)},[p,l,C,a]),Kn(xt,{onCloseRequest:()=>y(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[zr(Lg,{value:p,placeholder:E("commandPalette.search.placeholder"),onChange:I=>{u(I)},selectOnRender:!0,ref:d}),!t.device.viewport.isMobile&&Kn("div",{className:"shortcuts-wrapper",children:[zr(Og,{shortcut:"\u2191\u2193",children:E("commandPalette.shortcuts.select")}),zr(Og,{shortcut:"\u21B5",children:E("commandPalette.shortcuts.confirm")}),zr(Og,{shortcut:O("Esc"),children:E("commandPalette.shortcuts.close")})]}),Kn("div",{className:"commands",children:[a&&!p&&Kn("div",{className:"command-category",children:[Kn("div",{className:"command-category-title",children:[E("commandPalette.recents"),zr("div",{className:"icon",style:{marginLeft:"6px"},children:Tw})]}),zr(YI,{command:a,isSelected:a.label===g?.label,onClick:I=>w(a,I),disabled:!C(a),onMouseMove:()=>h(a),showShortcut:!t.device.viewport.isMobile,appState:r})]}),Object.keys(x).length>0?Object.keys(x).map((I,P)=>Kn("div",{className:"command-category",children:[zr("div",{className:"command-category-title",children:I}),x[I].map(A=>zr(YI,{command:A,isSelected:A.label===g?.label,onClick:N=>w(A,N),onMouseMove:()=>h(A),showShortcut:!t.device.viewport.isMobile,appState:r},A.label))]},I)):l?Kn("div",{className:"no-match",children:[zr("div",{className:"icon",children:dp})," ",E("commandPalette.search.noMatch")]}):null]})]})}var YI=({command:e,isSelected:t,disabled:r,onMouseMove:o,onClick:n,showShortcut:i,appState:a})=>{let s=()=>{};return Kn("div",{className:XI("command-item",{"item-selected":t,"item-disabled":r}),ref:l=>{t&&!r&&l?.scrollIntoView?.({block:"nearest"})},onClick:r?s:n,onMouseMove:r?s:o,title:r?E("commandPalette.itemNotAvailable"):"",children:[Kn("div",{className:"name",children:[e.icon&&zr(Fo,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&zr(Og,{shortcut:e.shortcut})]})};Wt();me();Re();$e();ee();import{jsx as b7}from"react/jsx-runtime";var E1=G({name:"toggleLinearEditor",category:Mt.elements,label:(e,t,r)=>r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return!!(!t.editingLinearElement&&n.length===1&&ie(n[0])&&!de(n[0]))},perform(e,t,r,o){let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],i=t.editingLinearElement?.elementId===n.id?null:new K(n);return{appState:{...t,editingLinearElement:i},storeAction:_.CAPTURE}},PanelComponent:({appState:e,updateData:t,app:r})=>{let o=r.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=E(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return b7(fe,{type:"button",icon:Fw,title:n,"aria-label":n,onClick:()=>t(null)})}});f();ee();f();nd();var Is=class{constructor(t=!0,r=!0){this.isUndoStackEmpty=t;this.isRedoStackEmpty=r}},$d=class e{onHistoryChangedEmitter=new wr;undoStack=[];redoStack=[];get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(t,r){let o=x1.create(r,t);o.isEmpty()||(this.undoStack.push(o.inverse()),o.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Is(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(t,r,o,n){return this.perform(t,r,o,()=>e.pop(this.undoStack),i=>e.push(this.redoStack,i,t),n)}redo(t,r,o,n){return this.perform(t,r,o,()=>e.pop(this.redoStack),i=>e.push(this.undoStack,i,t),n)}perform(t,r,o,n,i,a){try{let s=n();if(s===null)return;let l=t,c=r,d=!1;for(;s;){try{[l,c,d]=s.applyTo(l,c,o,a)}finally{i(s)}if(d)break;s=n()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new Is(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(t){if(!t.length)return null;let r=t.pop();return r!==void 0?r:null}static push(t,r,o){let n=r.inverse().applyLatestChanges(o);return t.push(n)}},x1=class e{constructor(t,r){this.appStateChange=t;this.elementsChange=r}static create(t,r){return new e(t,r)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(t,r,o,n){let[i,a]=this.elementsChange.applyTo(t,o.elements,n),[s,l]=this.appStateChange.applyTo(r,i);return[i,s,a||l]}applyLatestChanges(t){let r=this.elementsChange.applyLatestChanges(t);return e.create(this.appStateChange,r)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}};ye();V();Y();Re();f();import{useEffect as E7,useState as x7}from"react";var y1=(e,t)=>{let[r,o]=x7(t);return E7(()=>{let n=e.on(i=>{o(i)});return()=>{n()}},[e]),r};import{jsx as qI}from"react/jsx-runtime";var $I=(e,t)=>{if(!e.multiElement&&!e.resizingElement&&!e.editingElement&&!e.draggingElement){let r=t();if(!r)return{storeAction:_.NONE};let[o,n]=r,i=Array.from(o.values());return{appState:n,elements:i,storeAction:_.UPDATE}}return{storeAction:_.NONE}},ZI=(e,t)=>({name:"undo",label:"buttons.undo",icon:jh,trackEvent:{category:"history"},viewMode:!1,perform:(r,o,n,i)=>$I(o,()=>e.undo(Z(r),o,t.snapshot,i.scene)),keyTest:r=>r[S.CTRL_OR_CMD]&&r.key.toLowerCase()===S.Z&&!r.shiftKey,PanelComponent:({updateData:r,data:o})=>{let{isUndoStackEmpty:n}=y1(e.onHistoryChangedEmitter,new Is(e.isUndoStackEmpty,e.isRedoStackEmpty));return qI(fe,{type:"button",icon:jh,"aria-label":E("buttons.undo"),onClick:r,size:o?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),jI=(e,t)=>({name:"redo",label:"buttons.redo",icon:qh,trackEvent:{category:"history"},viewMode:!1,perform:(r,o,n,i)=>$I(o,()=>e.redo(Z(r),o,t.snapshot,i.scene)),keyTest:r=>r[S.CTRL_OR_CMD]&&r.shiftKey&&r.key.toLowerCase()===S.Z||xm&&r.ctrlKey&&!r.shiftKey&&r.key===S.Y,PanelComponent:({updateData:r,data:o})=>{let{isRedoStackEmpty:n}=y1(e.onHistoryChangedEmitter,new Is(e.isUndoStackEmpty,e.isRedoStackEmpty));return qI(fe,{type:"button",icon:qh,"aria-label":E("buttons.redo"),onClick:r,size:o?.size||"medium",disabled:n,"data-testid":"button-redo"})}});f();V();import{jsx as y7}from"react/jsx-runtime";var w1=(e,t,r,o,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(r,o,i))&&Ce(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Fg=class{actions={};updater;getAppState;getElementsIncludingDeleted;app;constructor(t,r,o,n){this.updater=i=>{if(Cn(i))i.then(a=>t(a));else return t(i)},this.getAppState=r,this.getElementsIncludingDeleted=o,this.app=n}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(r=>this.registerAction(r))}handleKeyDown(t){let r=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in r?r[l.name]:!0)&&l.keyTest&&l.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let n=o[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),s=null;return w1(n,"keyboard",a,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(o[0].perform(i,a,s,this.app)),!0}executeAction(t,r="api",o=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();w1(t,r,i,n,this.app,o),this.updater(t.perform(n,i,o,this.app))}renderAction=(t,r)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in o)||o[t])){let n=this.actions[t],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),s=this.getAppState(),l=c=>{w1(n,"ui",s,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return y7(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:l,appProps:this.app.props,app:this.app,data:r})}return null};isActionEnabled=t=>{let r=this.getElementsIncludingDeleted(),o=this.getAppState();return!t.predicate||t.predicate(r,o,this.app.props,this.app)}};$e();Zr();na();Y();Y();el();we();yr();Wt();De();Nn();me();f();var v1=e=>{let t=Array.from(e.values());return{x:JI(t,r=>r.x)/t.length,y:JI(t,r=>r.y)/t.length}},T1=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),JI=(e,t)=>e.reduce((r,o)=>r+t(o),0);Gt();ye();ms();mt();et();cs();zu();dl();_p();Pp();V();ad();f();import w7 from"clsx";import v7 from"react";import{jsx as rc,jsxs as T7}from"react/jsx-runtime";var Sr="separator",QI=v7.memo(({actionManager:e,items:t,top:r,left:o,onClose:n})=>{let i=Gn(),a=da(),s=t.reduce((l,c)=>(c&&(c===Sr||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l),[]);return rc($u,{onCloseRequest:()=>{n()},top:r,left:o,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:rc("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===Sr)return!s[c-1]||s[c-1]===Sr?null:rc("hr",{className:"context-menu-item-separator"},c);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=E(l.label(a,i,e.app)):m=E(l.label)),rc("li",{"data-testid":d,onClick:()=>{n(()=>{e.executeAction(l,"contextMenu")})},children:T7("button",{type:"button",className:w7("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[rc("div",{className:"context-menu-item__label",children:m}),rc("kbd",{className:"context-menu-item__shortcut",children:d?Bt(d):""})]})},c)})})})});f();Y();we();import om from"clsx";import uN from"react";et();V();f();import S7,{useState as I7}from"react";import{Fragment as C7,jsx as S1}from"react/jsx-runtime";var eC=({children:e,onClose:t})=>{let[r,o]=I7(!!e),{container:n}=Ft(),i=S7.useCallback(()=>{o(!1),t&&t(),n?.focus()},[t,n]);return S1(C7,{children:r&&S1(xt,{size:"small",onCloseRequest:i,title:E("errorDialog.title"),children:S1("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};f();import{useEffect as R7,useRef as N7,useState as ga}from"react";na();Y();qr();di();et();os();ee();f();import A7 from"clsx";import{jsx as tC,jsxs as M7}from"react/jsx-runtime";var Bg=function({onChange:e,value:t,choices:r,name:o}){return tC("div",{className:"RadioGroup",children:r.map(n=>M7("div",{className:A7("RadioGroup__choice",{active:n.value===t}),title:n.ariaLabel,children:[tC("input",{name:o,type:"radio",checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};f();import k7 from"clsx";import{jsx as rC}from"react/jsx-runtime";var Zd=({title:e,name:t,checked:r,onChange:o,disabled:n=!1})=>rC("div",{className:k7("Switch",{toggled:r,disabled:n}),children:rC("input",{name:t,id:t,title:e,type:"checkbox",checked:r,disabled:n,onChange:()=>o(!r),onKeyDown:i=>{i.key===" "&&o(!r)}})});f();import{forwardRef as P7,useState as L7}from"react";import D7 from"clsx";Hi();V();import{jsx as I1,jsxs as _7}from"react/jsx-runtime";var $n=P7(({children:e,icon:t,onClick:r,label:o,variant:n="filled",color:i="primary",size:a="medium",fullWidth:s,className:l},c)=>{let[d,m]=L7(!1),p=async u=>{let g=r?.(u);if(Cn(g))try{m(!0),await g}catch(h){if(h instanceof Pn)console.warn(h);else throw h}finally{m(!1)}};return I1("button",{className:D7("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,{"ExcButton--fullWidth":s},l),onClick:p,type:"button","aria-label":o,ref:c,disabled:d,children:_7("div",{className:"ExcButton__contents",children:[d&&I1(ir,{}),t&&I1("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),n!=="icon"&&(e??o)]})})});V();import{jsx as ht,jsxs as ha}from"react/jsx-runtime";var O7="filter"in document.createElement("canvas").getContext("2d"),F7=()=>ha("div",{children:[ht("h3",{children:E("canvasError.cannotShowPreview")}),ht("p",{children:ht("span",{children:E("canvasError.canvasTooBig")})}),ha("em",{children:["(",E("canvasError.canvasTooBigTip"),")"]})]}),B7=({appStateSnapshot:e,elementsSnapshot:t,files:r,actionManager:o,onExportImage:n,name:i})=>{let a=qe(t,e),[s,l]=ga(i),[c,d]=ga(a),[m,p]=ga(e.exportBackground),[u,g]=ga(e.exportWithDarkMode),[h,x]=ga(e.exportEmbedScene),[v,y]=ga(e.exportScale),w=N7(null),[C,M]=ga(null),{exportedElements:I,exportingFrame:P}=Es(t,e,c);return R7(()=>{let A=w.current;if(!A)return;let N=A.offsetWidth,k=A.offsetHeight;N&&ia({elements:I,appState:{...e,name:s,exportBackground:m,exportWithDarkMode:u,exportScale:v,exportEmbedScene:h},files:r,exportPadding:Ko,maxWidthOrHeight:Math.max(N,k),exportingFrame:P}).then(D=>(M(null),gi(D).then(()=>{A.replaceChildren(D)}).catch(z=>{throw z.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(E("canvasError.canvasTooBig")):z}))).catch(D=>{console.error(D),M(D)})},[e,r,I,P,s,m,u,v,h]),ha("div",{className:"ImageExportModal",children:[ht("h3",{children:E("imageExportDialog.header")}),ha("div",{className:"ImageExportModal__preview",children:[ht("div",{className:"ImageExportModal__preview__canvas",ref:w,children:C&&ht(F7,{})}),ht("div",{className:"ImageExportModal__preview__filename",children:!Wi&&ht("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:A=>{l(A.target.value),o.executeAction(PE,"ui",A.target.value)}})})]}),ha("div",{className:"ImageExportModal__settings",children:[ht("h3",{children:E("imageExportDialog.header")}),a&&ht(jd,{label:E("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:ht(Zd,{name:"exportOnlySelected",checked:c,onChange:A=>{d(A)}})}),ht(jd,{label:E("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:ht(Zd,{name:"exportBackgroundSwitch",checked:m,onChange:A=>{p(A),o.executeAction(LE,"ui",A)}})}),O7&&ht(jd,{label:E("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:ht(Zd,{name:"exportDarkModeSwitch",checked:u,onChange:A=>{g(A),o.executeAction(MS,"ui",A)}})}),ht(jd,{label:E("imageExportDialog.label.embedScene"),tooltip:E("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:ht(Zd,{name:"exportEmbedSwitch",checked:h,onChange:A=>{x(A),o.executeAction(ig,"ui",A)}})}),ht(jd,{label:E("imageExportDialog.label.scale"),name:"exportScale",children:ht(Bg,{name:"exportScale",value:v,onChange:A=>{y(A),o.executeAction(AS,"ui",A)},choices:zs.map(A=>({value:A,label:`${A}\xD7`}))})}),ha("div",{className:"ImageExportModal__settings__buttons",children:[ht($n,{className:"ImageExportModal__settings__buttons__button",label:E("imageExportDialog.title.exportToPng"),onClick:()=>n(Im.png,I,{exportingFrame:P}),icon:uf,children:E("imageExportDialog.button.exportToPng")}),ht($n,{className:"ImageExportModal__settings__buttons__button",label:E("imageExportDialog.title.exportToSvg"),onClick:()=>n(Im.svg,I,{exportingFrame:P}),icon:uf,children:E("imageExportDialog.button.exportToSvg")}),(yl||ti)&&ht($n,{className:"ImageExportModal__settings__buttons__button",label:E("imageExportDialog.title.copyPngToClipboard"),onClick:()=>n(Im.clipboard,I,{exportingFrame:P}),icon:ap,children:E("imageExportDialog.button.copyPngToClipboard")})]})]})]})},jd=({label:e,children:t,tooltip:r,name:o})=>ha("div",{className:"ImageExportModal__settings__setting",title:e,children:[ha("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,r&&ht(Eo,{label:r,long:!0,children:hw})]}),ht("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),oC=({elements:e,appState:t,files:r,actionManager:o,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=ga(()=>({appStateSnapshot:Xr(t),elementsSnapshot:Xr(e)}));return ht(xt,{onCloseRequest:i,size:"wide",title:!1,children:ht(B7,{elementsSnapshot:l,appStateSnapshot:s,files:r,actionManager:o,onExportImage:n,name:a})})};f();import z7 from"clsx";import{jsx as H7}from"react/jsx-runtime";var zg=({children:e,side:t,className:r})=>H7("div",{className:z7("FixedSideContainer",`FixedSideContainer_side_${t}`,r),children:e});f();me();V();Zr();import{jsx as nC}from"react/jsx-runtime";var U7=({appState:e,isMobile:t,device:r,app:o})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar&&!r.editor.canFitSidebar)return null;if($r(e))return E("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return l?E("hints.linearElementMulti"):n.type==="arrow"?E("hints.arrowTool",{arrowShortcut:O("A")}):E("hints.linearElement");if(n.type==="freedraw")return E("hints.freeDraw");if(n.type==="text")return E("hints.text");if(n.type==="embeddable")return E("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return E("hints.placeImage");let c=o.scene.getSelectedElements(e);if(i&&s==="mouse"&&c.length===1){let d=c[0];return ie(d)&&d.points.length===2?E("hints.lockAngle"):So(d)?E("hints.resizeImage"):E("hints.resize")}if(a&&s==="mouse")return E("hints.rotate");if(c.length===1&&H(c[0]))return E("hints.text_selected");if(e.editingElement&&H(e.editingElement))return E("hints.text_editing");if(n.type==="selection"){if(e.draggingElement?.type==="selection"&&!c.length&&!e.editingElement&&!e.editingLinearElement)return E("hints.deepBoxSelect");if(e.gridSize&&e.draggingElement)return E("hints.disableSnapping");if(!c.length&&!t)return E("hints.canvasPanning");if(c.length===1){if(ie(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?E("hints.lineEditor_pointSelected"):E("hints.lineEditor_nothingSelected"):E("hints.lineEditor_info");if(!e.draggingElement&&Mn(c[0]))return E("hints.bindTextToElement")}}return null},Hg=({appState:e,isMobile:t,device:r,app:o})=>{let n=U7({appState:e,isMobile:t,device:r,app:o});return n?(n=O(n),nC("div",{className:"HintViewer",children:nC("span",{children:n})})):null};f();ee();import G7 from"clsx";import{jsx as aC,jsxs as V7}from"react/jsx-runtime";var W7="medium",iC={CHECKED:Ws,UNCHECKED:Fa},Ug=e=>V7("label",{className:G7("ToolIcon ToolIcon__lock",`ToolIcon_size_${W7}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[aC("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),aC("div",{className:"ToolIcon__icon",children:e.checked?iC.CHECKED:iC.UNCHECKED})]});f();we();et();f();import{Fragment as Y7,jsx as sC,jsxs as X7}from"react/jsx-runtime";var fa=({heading:e,children:t,...r})=>{let{id:o}=Ft(),n=sC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:E(`headings.${e}`)});return sC("section",{...r,"aria-labelledby":`${o}-${e}-title`,children:typeof t=="function"?t(n):X7(Y7,{children:[n,t]})})};f();we();V();var fn=4,Zn=6,lC="rgba(0,0,0,0.3)",cC=(e,t,r,o)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,s]=Te(e),l=t/o.zoom.value,c=r/o.zoom.value,d=t-l,m=r-c,p={top:parseInt(vc("sat"))||0,bottom:parseInt(vc("sab"))||0,left:parseInt(vc("sal"))||0,right:parseInt(vc("sar"))||0},u=ei().rtl,g=-o.scrollX+d/2+p.left,h=-o.scrollY+m/2+p.top,x=g+l-p.right,v=h+c-p.bottom,y=Math.min(n,g),w=Math.min(i,h),C=Math.max(a,x),M=Math.max(s,v);return{horizontal:g===y&&x===C?null:{x:Math.max(p.left,fn)+(g-y)/(C-y)*t,y:r-Zn-Math.max(fn,p.bottom),width:(x-g)/(C-y)*t-Math.max(fn*2,p.left+p.right),height:Zn},vertical:h===w&&v===M?null:{x:u?Math.max(p.left,fn):t-Zn-Math.max(p.right,fn),y:(h-w)/(M-w)*r+Math.max(p.top,fn),width:Zn,height:(v-h)/(M-w)*r-Math.max(fn*2,p.top+p.bottom)}}},C1=(e,t,r)=>{let[o,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=t&&t<=a.x+a.width&&a.y<=r&&r<=a.y+a.height);return{isOverEither:o||n,isOverHorizontal:o,isOverVertical:n}};f();ee();import K7 from"clsx";import{jsx as dC,jsxs as Z7}from"react/jsx-runtime";var $7="medium",Gg=e=>e.penDetected?Z7("label",{className:K7("ToolIcon ToolIcon__penMode",`ToolIcon_size_${$7}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[dC("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),dC("div",{className:"ToolIcon__icon",children:hy})]}):null;f();import j7 from"clsx";ee();ye();import{jsx as q7}from"react/jsx-runtime";var Wg=e=>q7(fe,{className:j7("Shape",{fillable:!1}),type:"radio",icon:ip,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:S.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":S.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});Zr();import{Fragment as J7,jsx as dr,jsxs as ba}from"react/jsx-runtime";var mC=({appState:e,elements:t,actionManager:r,setAppState:o,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:s,renderCustomStats:l,renderSidebars:c,device:d,renderWelcomeScreen:m,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:g,MainMenuTunnel:h,DefaultSidebarTriggerTunnel:x}=ut(),v=()=>ba(zg,{side:"top",className:"App-top-bar",children:[m&&dr(g.Out,{}),dr(fa,{heading:"shapes",children:w=>dr(rr.Col,{gap:4,align:"center",children:ba(rr.Row,{gap:1,className:"App-toolbar-container",children:[ba(Yt,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[w,dr(rr.Row,{gap:1,children:dr(_g,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),s&&s(!0,e),ba("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&dr(x.Out,{}),dr(Gg,{checked:e.penMode,onChange:()=>a(null),title:E("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),dr(Ug,{checked:e.activeTool.locked,onChange:n,title:E("toolBar.lock"),isMobile:!0}),dr(Wg,{checked:qo(e),onChange:()=>i(),title:E("toolBar.hand"),isMobile:!0})]})]})})}),dr(Hg,{appState:e,isMobile:!0,device:d,app:u})]}),y=()=>e.viewModeEnabled?dr("div",{className:"App-toolbar-content",children:dr(h.Out,{})}):ba("div",{className:"App-toolbar-content",children:[dr(h.Out,{}),r.renderAction("toggleEditMenu"),r.renderAction("undo"),r.renderAction("redo"),r.renderAction(e.multiElement?"finalize":"duplicateSelection"),r.renderAction("deleteSelectedElements")]});return ba(J7,{children:[c(),!e.viewModeEnabled&&v(),dr("div",{className:"App-bottom-bar",style:{marginBottom:Zn+fn*2,marginLeft:Zn+fn*2,marginRight:Zn+fn*2},children:ba(Yt,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&us(e,t)?dr(fa,{className:"App-mobile-menu",heading:"selectedShapeActions",children:dr(Dg,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:r.renderAction})}):null,ba("footer",{className:"App-toolbar",children:[y(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&dr("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(w=>({..._n(t,w)}))},children:E("buttons.scrollBackToContent")})]})]})})]})};f();import Q7 from"open-color";import e_,{useLayoutEffect as t_,useRef as r_,useState as o_}from"react";db();md();import{jsx as qd,jsxs as n_}from"react/jsx-runtime";var pC=e=>{let t=r_(null),[r,o]=o_(null);return t_(()=>{if(!e.spreadsheet)return;let n=oT(e.chartType,e.spreadsheet,0,0);o(n);let i,a=t.current;return(async()=>(i=await bl(n,{exportBackground:!1,viewBackgroundColor:Q7.white},null),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),qd("button",{type:"button",className:"ChartPreview",onClick:()=>{r&&e.onClick(e.chartType,r)},children:qd("div",{ref:t})})},uC=({setAppState:e,appState:t,onClose:r})=>{let{onInsertElements:o}=tr(),n=e_.useCallback(()=>{r&&r()},[r]),i=(a,s)=>{o(s),Ce("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return qd(xt,{size:"small",onCloseRequest:n,title:E("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:n_("div",{className:"container",children:[qd(pC,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:i}),qd(pC,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:i})]})})};f();import i_ from"react";ye();V();ee();na();Y();import{Fragment as hC,jsx as $,jsxs as yo}from"react/jsx-runtime";var a_=()=>yo("div",{className:"HelpDialog__header",children:[yo("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[$("div",{className:"HelpDialog__link-icon",children:Zh}),E("helpDialog.documentation")]}),yo("a",{className:"HelpDialog__btn",href:"https://blog.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[$("div",{className:"HelpDialog__link-icon",children:Zh}),E("helpDialog.blog")]}),yo("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[$("div",{className:"HelpDialog__link-icon",children:ep}),E("helpDialog.github")]}),yo("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[$("div",{className:"HelpDialog__link-icon",children:Nw}),"YouTube"]})]}),s_=e=>yo(hC,{children:[$("h3",{children:e.title}),$("div",{className:"HelpDialog__islands-container",children:e.children})]}),A1=e=>yo("div",{className:`HelpDialog__island ${e.className}`,children:[$("h4",{className:"HelpDialog__island-title",children:e.caption}),$("div",{className:"HelpDialog__island-content",children:e.children})]});function*l_(e,t){let r=!0;for(let o of e)r||(yield t),r=!1,yield o}var c_=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),te=({label:e,shortcuts:t,isOr:r=!0})=>{let o=t.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>$(d_,{children:c_(a)},a)));return yo("div",{className:"HelpDialog__shortcut",children:[$("div",{children:e}),$("div",{className:"HelpDialog__key-container",children:[...l_(o,r?E("helpDialog.or"):null)]})]})},d_=e=>$("kbd",{className:"HelpDialog__key",...e}),gC=({onClose:e})=>{let t=i_.useCallback(()=>{e&&e()},[e]);return $(hC,{children:yo(xt,{onCloseRequest:t,title:E("helpDialog.title"),className:"HelpDialog",children:[$(a_,{}),yo(s_,{title:E("helpDialog.shortcuts"),children:[yo(A1,{className:"HelpDialog__island--tools",caption:E("helpDialog.tools"),children:[$(te,{label:E("toolBar.hand"),shortcuts:[S.H]}),$(te,{label:E("toolBar.selection"),shortcuts:[S.V,S[1]]}),$(te,{label:E("toolBar.rectangle"),shortcuts:[S.R,S[2]]}),$(te,{label:E("toolBar.diamond"),shortcuts:[S.D,S[3]]}),$(te,{label:E("toolBar.ellipse"),shortcuts:[S.O,S[4]]}),$(te,{label:E("toolBar.arrow"),shortcuts:[S.A,S[5]]}),$(te,{label:E("toolBar.line"),shortcuts:[S.L,S[6]]}),$(te,{label:E("toolBar.freedraw"),shortcuts:[S.P,S[7]]}),$(te,{label:E("toolBar.text"),shortcuts:[S.T,S[8]]}),$(te,{label:E("toolBar.image"),shortcuts:[S[9]]}),$(te,{label:E("toolBar.eraser"),shortcuts:[S.E,S[0]]}),$(te,{label:E("toolBar.frame"),shortcuts:[S.F]}),$(te,{label:E("toolBar.laser"),shortcuts:[S.K]}),$(te,{label:E("labels.eyeDropper"),shortcuts:[S.I,"Shift+S","Shift+G"]}),$(te,{label:E("helpDialog.editLineArrowPoints"),shortcuts:[O("CtrlOrCmd+Enter")]}),$(te,{label:E("helpDialog.editText"),shortcuts:[O("Enter")]}),$(te,{label:E("helpDialog.textNewLine"),shortcuts:[O("Enter"),O("Shift+Enter")]}),$(te,{label:E("helpDialog.textFinish"),shortcuts:[O("Esc"),O("CtrlOrCmd+Enter")]}),$(te,{label:E("helpDialog.curvedArrow"),shortcuts:["A",E("helpDialog.click"),E("helpDialog.click"),E("helpDialog.click")],isOr:!1}),$(te,{label:E("helpDialog.curvedLine"),shortcuts:["L",E("helpDialog.click"),E("helpDialog.click"),E("helpDialog.click")],isOr:!1}),$(te,{label:E("toolBar.lock"),shortcuts:[S.Q]}),$(te,{label:E("helpDialog.preventBinding"),shortcuts:[O("CtrlOrCmd")]}),$(te,{label:E("toolBar.link"),shortcuts:[O("CtrlOrCmd+K")]})]}),yo(A1,{className:"HelpDialog__island--view",caption:E("helpDialog.view"),children:[$(te,{label:E("buttons.zoomIn"),shortcuts:[O("CtrlOrCmd++")]}),$(te,{label:E("buttons.zoomOut"),shortcuts:[O("CtrlOrCmd+-")]}),$(te,{label:E("buttons.resetZoom"),shortcuts:[O("CtrlOrCmd+0")]}),$(te,{label:E("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),$(te,{label:E("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),$(te,{label:E("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),$(te,{label:E("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),$(te,{label:E("buttons.zenMode"),shortcuts:[O("Alt+Z")]}),$(te,{label:E("buttons.objectsSnapMode"),shortcuts:[O("Alt+S")]}),$(te,{label:E("labels.toggleGrid"),shortcuts:[O("CtrlOrCmd+'")]}),$(te,{label:E("labels.viewMode"),shortcuts:[O("Alt+R")]}),$(te,{label:E("labels.toggleTheme"),shortcuts:[O("Alt+Shift+D")]}),$(te,{label:E("stats.fullTitle"),shortcuts:[O("Alt+/")]}),$(te,{label:E("commandPalette.title"),shortcuts:ti?[Bt("commandPalette")]:[Bt("commandPalette"),Bt("commandPalette",1)]})]}),yo(A1,{className:"HelpDialog__island--editor",caption:E("helpDialog.editor"),children:[$(te,{label:E("labels.moveCanvas"),shortcuts:[O(`Space+${E("helpDialog.drag")}`),O(`Wheel+${E("helpDialog.drag")}`)],isOr:!0}),$(te,{label:E("buttons.clearReset"),shortcuts:[O("CtrlOrCmd+Delete")]}),$(te,{label:E("labels.delete"),shortcuts:[O("Delete")]}),$(te,{label:E("labels.cut"),shortcuts:[O("CtrlOrCmd+X")]}),$(te,{label:E("labels.copy"),shortcuts:[O("CtrlOrCmd+C")]}),$(te,{label:E("labels.paste"),shortcuts:[O("CtrlOrCmd+V")]}),$(te,{label:E("labels.pasteAsPlaintext"),shortcuts:[O("CtrlOrCmd+Shift+V")]}),$(te,{label:E("labels.selectAll"),shortcuts:[O("CtrlOrCmd+A")]}),$(te,{label:E("labels.multiSelect"),shortcuts:[O(`Shift+${E("helpDialog.click")}`)]}),$(te,{label:E("helpDialog.deepSelect"),shortcuts:[O(`CtrlOrCmd+${E("helpDialog.click")}`)]}),$(te,{label:E("helpDialog.deepBoxSelect"),shortcuts:[O(`CtrlOrCmd+${E("helpDialog.drag")}`)]}),(yl||ti)&&$(te,{label:E("labels.copyAsPng"),shortcuts:[O("Shift+Alt+C")]}),$(te,{label:E("labels.copyStyles"),shortcuts:[O("CtrlOrCmd+Alt+C")]}),$(te,{label:E("labels.pasteStyles"),shortcuts:[O("CtrlOrCmd+Alt+V")]}),$(te,{label:E("labels.sendToBack"),shortcuts:[Cr?O("CtrlOrCmd+Alt+["):O("CtrlOrCmd+Shift+[")]}),$(te,{label:E("labels.bringToFront"),shortcuts:[Cr?O("CtrlOrCmd+Alt+]"):O("CtrlOrCmd+Shift+]")]}),$(te,{label:E("labels.sendBackward"),shortcuts:[O("CtrlOrCmd+[")]}),$(te,{label:E("labels.bringForward"),shortcuts:[O("CtrlOrCmd+]")]}),$(te,{label:E("labels.alignTop"),shortcuts:[O("CtrlOrCmd+Shift+Up")]}),$(te,{label:E("labels.alignBottom"),shortcuts:[O("CtrlOrCmd+Shift+Down")]}),$(te,{label:E("labels.alignLeft"),shortcuts:[O("CtrlOrCmd+Shift+Left")]}),$(te,{label:E("labels.alignRight"),shortcuts:[O("CtrlOrCmd+Shift+Right")]}),$(te,{label:E("labels.duplicateSelection"),shortcuts:[O("CtrlOrCmd+D"),O(`Alt+${E("helpDialog.drag")}`)]}),$(te,{label:E("helpDialog.toggleElementLock"),shortcuts:[O("CtrlOrCmd+Shift+L")]}),$(te,{label:E("buttons.undo"),shortcuts:[O("CtrlOrCmd+Z")]}),$(te,{label:E("buttons.redo"),shortcuts:xm?[O("CtrlOrCmd+Y"),O("CtrlOrCmd+Shift+Z")]:[O("CtrlOrCmd+Shift+Z")]}),$(te,{label:E("labels.group"),shortcuts:[O("CtrlOrCmd+G")]}),$(te,{label:E("labels.ungroup"),shortcuts:[O("CtrlOrCmd+Shift+G")]}),$(te,{label:E("labels.flipHorizontal"),shortcuts:[O("Shift+H")]}),$(te,{label:E("labels.flipVertical"),shortcuts:[O("Shift+V")]}),$(te,{label:E("labels.showStroke"),shortcuts:[O("S")]}),$(te,{label:E("labels.showBackground"),shortcuts:[O("G")]}),$(te,{label:E("labels.showFonts"),shortcuts:[O("Shift+F")]}),$(te,{label:E("labels.decreaseFontSize"),shortcuts:[O("CtrlOrCmd+Shift+<")]}),$(te,{label:E("labels.increaseFontSize"),shortcuts:[O("CtrlOrCmd+Shift+>")]})]})]})]})})};f();import Vg,{useLayoutEffect as m_}from"react";import fC from"clsx";import*as Ea from"@radix-ui/react-popover";V();Y();import{Fragment as f_,jsx as jn,jsxs as Yg}from"react/jsx-runtime";var p_=4,u_=8,g_=({shouldWrap:e,children:t,username:r})=>e?jn(Eo,{label:r||"Unknown user",children:t}):jn(f_,{children:t}),M1=({actionManager:e,collaborator:t,socketId:r,withName:o=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:r,collaborator:t,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return jn(g_,{username:t.username,shouldWrap:n,children:s},r)},h_=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Xg=Vg.memo(({className:e,mobile:t,collaborators:r,userToFollow:o})=>{let n=Xt(),i=new Map;r.forEach((h,x)=>{let v=h.id||x;i.set(v,{...h,socketId:x})});let a=Array.from(i.values()).filter(h=>h.username?.trim()),[s,l]=Vg.useState(""),c=a.filter(h=>h.username?.toLowerCase().includes(s)),d=Vg.useRef(null);m_(()=>{if(d.current){let h=v=>{let y=Math.max(1,Math.min(8,Math.floor(v/38)));p(y)};if(h(d.current.clientWidth),!hc)return;let x=new ResizeObserver(v=>{for(let y of v){let{width:w}=y.contentRect;h(w)}});return x.observe(d.current),()=>{x.disconnect()}}},[]);let[m,p]=Vg.useState(p_),g=a.slice(0,m-1).map(h=>M1({actionManager:n,collaborator:h,socketId:h.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:h.socketId===o}));return t?jn("div",{className:fC("UserList UserList_mobile",e),children:a.map(h=>M1({actionManager:n,collaborator:h,socketId:h.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:h.socketId===o}))}):jn("div",{className:"UserList__wrapper",ref:d,children:Yg("div",{className:fC("UserList",e),style:{"--max-avatars":m},children:[g,a.length>m-1&&Yg(Ea.Root,{children:[Yg(Ea.Trigger,{className:"UserList__more",children:["+",a.length-m+1]}),jn(Ea.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Yg(Yt,{padding:2,children:[a.length>=u_&&jn(Zu,{placeholder:E("quickSearch.placeholder"),onChange:l}),jn(ju,{className:"dropdown-menu UserList__collaborators",placeholder:E("userList.empty"),children:c.length>0?[jn("div",{className:"hint",children:E("userList.hint.text")}),c.map(h=>M1({actionManager:n,collaborator:h,socketId:h.socketId,withName:!0,isBeingFollowed:h.socketId===o}))]:[]}),jn(Ea.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let r=t.collaborators.keys();for(let[o,n]of e.collaborators){let i=t.collaborators.get(o);if(!i||o!==r.next().value||!it(n,i,h_))return!1}return!0});f();import E_ from"react";ee();f();import k1 from"open-color";import{jsx as b_}from"react/jsx-runtime";var P1=({children:e,color:t})=>b_("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":k1[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":k1[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":k1[t][9]},children:e});di();V();import{Fragment as y_,jsx as bn,jsxs as Kg}from"react/jsx-runtime";var x_=({elements:e,appState:t,setAppState:r,files:o,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return bn("div",{className:"ExportDialog ExportDialog--json",children:Kg("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Kg(P1,{color:"lime",children:[bn("div",{className:"Card-icon",children:Ay}),bn("h2",{children:E("exportDialog.disk_title")}),Kg("div",{className:"Card-details",children:[E("exportDialog.disk_details"),!Wi&&n.renderAction("changeProjectName")]}),bn(fe,{className:"Card-button",type:"button",title:E("exportDialog.disk_button"),"aria-label":E("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Ud,"ui")}})]}),l&&Kg(P1,{color:"pink",children:[bn("div",{className:"Card-icon",children:Lc}),bn("h2",{children:E("exportDialog.link_title")}),bn("div",{className:"Card-details",children:E("exportDialog.link_details")}),bn(fe,{className:"Card-button",type:"button",title:E("exportDialog.link_button"),"aria-label":E("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ce("export","link",`ui (${R0()})`),await l(e,t,o),s()}catch(c){r({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,o,a)]})})},bC=({elements:e,appState:t,files:r,actionManager:o,exportOpts:n,canvas:i,setAppState:a})=>{let s=E_.useCallback(()=>{a({openDialog:null})},[a]);return bn(y_,{children:t.openDialog?.name==="jsonExport"&&bn(xt,{onCloseRequest:s,title:E("buttons.export"),children:bn(x_,{elements:e,appState:t,setAppState:a,files:r,actionManager:o,onCloseRequest:s,exportOpts:n,canvas:i})})})};f();import $g from"clsx";f();ee();import{jsx as w_}from"react/jsx-runtime";var EC=e=>w_("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${E("helpDialog.title")} \u2014 ?`,"aria-label":E("helpDialog.title"),children:Vs});import{jsx as qn,jsxs as L1}from"react/jsx-runtime";var xC=({appState:e,actionManager:t,showExitZenModeBtn:r,renderWelcomeScreen:o})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=ut(),a=Ne(),s=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return L1("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[qn("div",{className:$g("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:qn(rr.Col,{gap:2,children:L1(fa,{heading:"canvasActions",children:[qn(HI,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&qn(UI,{renderAction:t.renderAction,className:$g("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),s&&qn(WI,{renderAction:t.renderAction,className:$g("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),qn(n.Out,{}),qn("div",{className:$g("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:L1("div",{style:{position:"relative"},children:[o&&qn(i.Out,{}),qn(EC,{onClick:()=>t.executeAction(ws)})]})}),qn(GI,{actionManager:t,showExitZenModeBtn:r})]})},yC=xC;xC.displayName="Footer";f();import{useEffect as PC,useLayoutEffect as LC,useRef as H1,useState as k_,forwardRef as DC,useImperativeHandle as P_,useCallback as MC}from"react";import{atom as L_,useSetAtom as D_}from"jotai";f();import v_ from"react";var Zg=v_.createContext({});f();import T_ from"clsx";import{useContext as S_}from"react";ee();import{jsx as D1,jsxs as wC}from"react/jsx-runtime";var _1=({children:e,className:t})=>{let r=Ne(),o=S_(Zg),n=!!(r.editor.canFitSidebar&&o.shouldRenderDockButton);return wC("div",{className:T_("sidebar__header",t),"data-testid":"sidebar-header",children:[e,wC("div",{className:"sidebar__header__buttons",children:[n&&D1(Eo,{label:E("labels.sidebarLock"),children:D1(Yn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":E("labels.sidebarLock"),children:iy})}),D1(Yn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":E("buttons.close"),children:Ao})]})]})};_1.displayName="SidebarHeader";import __ from"clsx";V();ye();Y();f();import I_ from"clsx";import{jsx as R1,jsxs as vC}from"react/jsx-runtime";var N1=({name:e,tab:t,icon:r,title:o,children:n,onToggle:i,className:a,style:s})=>{let l=Oe(),c=Ue();return vC("label",{title:o,className:"sidebar-trigger__label-element",children:[R1("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=d.target.checked;l({openSidebar:m?{name:e,tab:t}:null}),i?.(m)},checked:c.openSidebar?.name===e,"aria-label":o,"aria-keyshortcuts":"0"}),vC("div",{className:I_("sidebar-trigger",a),style:s,children:[r&&R1("div",{children:r}),n&&R1("div",{className:"sidebar-trigger__label",children:n})]})]})};N1.displayName="SidebarTrigger";f();import*as TC from"@radix-ui/react-tabs";import{jsx as C_}from"react/jsx-runtime";var O1=({children:e,...t})=>C_(TC.List,{className:"sidebar-triggers",...t,children:e});O1.displayName="SidebarTabTriggers";f();import*as IC from"@radix-ui/react-tabs";import{jsx as SC}from"react/jsx-runtime";var F1=({children:e,tab:t,onSelect:r,...o})=>SC(IC.Trigger,{value:t,asChild:!0,onSelect:r,children:SC("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});F1.displayName="SidebarTabTrigger";f();import*as CC from"@radix-ui/react-tabs";import{jsx as A_}from"react/jsx-runtime";var B1=({children:e,...t})=>{let r=Ue(),o=Oe();if(!r.openSidebar)return null;let{name:n}=r.openSidebar;return A_(CC.Root,{className:"sidebar-tabs-root",value:r.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...t,children:e})};B1.displayName="SidebarTabs";f();import*as AC from"@radix-ui/react-tabs";import{jsx as M_}from"react/jsx-runtime";var z1=({tab:e,children:t,...r})=>M_(AC.Content,{...r,value:e,"data-testid":e,children:t});z1.displayName="SidebarTab";import{jsx as kC}from"react/jsx-runtime";import{createElement as R_}from"react";var Jd=L_(!1),_C=DC(({name:e,children:t,onDock:r,docked:o,className:n,...i},a)=>{T.DEV&&r&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Oe(),l=D_(Jd,Xe);LC(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=H1({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>r?.(u),c.current=Us(c.current,{docked:o,shouldRenderDockButton:!!r&&o!=null});let d=H1(null);P_(a,()=>d.current);let m=Ne(),p=MC(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Bl(d,MC(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.editor.canFitSidebar)&&p()},[p,o,m.editor.canFitSidebar])),PC(()=>{let u=g=>{g.key===S.ESCAPE&&(!o||!m.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,o,m.editor.canFitSidebar]),kC(Yt,{...i,className:__("sidebar",{"sidebar--docked":o},n),ref:d,children:kC(Zg.Provider,{value:c.current,children:t})})});_C.displayName="SidebarInner";var Li=Object.assign(DC((e,t)=>{let r=Ue(),{onStateChange:o}=e,n=H1(r.openSidebar);PC(()=>{(!r.openSidebar&&n?.current?.name===e.name||r.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&r.openSidebar!==n.current&&o?.(r.openSidebar?.name!==e.name?null:r.openSidebar),n.current=r.openSidebar},[r.openSidebar,o,e.name]);let[i,a]=k_(!1);return LC(()=>(a(!0),()=>a(!1)),[]),i&&r.openSidebar?.name===e.name?R_(_C,{...e,ref:t,key:e.name}):null}),{Header:_1,TabTriggers:O1,TabTrigger:F1,Tabs:B1,Tab:z1,Trigger:N1});Li.displayName="Sidebar";import{Provider as gN,useAtom as hN,useAtomValue as fN}from"jotai";f();var W1={};Ch(W1,{ChangeCanvasBackground:()=>YC,ClearCanvas:()=>WC,CommandPalette:()=>UC,Export:()=>XC,Help:()=>GC,LiveCollaborationTrigger:()=>$C,LoadScene:()=>BC,SaveAsImage:()=>HC,SaveToActiveFile:()=>zC,Socials:()=>KC,ToggleTheme:()=>VC});f();ee();ee();import F_ from"clsx";import{useSetAtom as B_}from"jotai";f();import{atom as N_}from"jotai";var U1=N_({active:!1});async function RC({title:e,description:t,actionLabel:r,color:o}){return new Promise(n=>{mr.set(U1,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:t,actionLabel:r,color:o})})}f();import{Fragment as O_,jsx as G1,jsxs as NC}from"react/jsx-runtime";var OC=({value:e,shortcut:t,onChange:r,choices:o,children:n,name:i})=>{let a=Ne();return NC(O_,{children:[NC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[G1("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),G1(Bg,{name:i,value:e,onChange:r,choices:o})]}),t&&!a.editor.isMobile&&G1("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};OC.displayName="DropdownMenuItemContentRadio";var FC=OC;Y();import{Fragment as z_,jsx as or,jsxs as ZC}from"react/jsx-runtime";var BC=()=>{let{t:e}=Dt(),t=Xt(),r=da();return t.isActionEnabled(Wl)?or(eo,{icon:Ys,onSelect:async()=>{(!r.length||await RC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:or(Br,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>or("strong",{children:n}),br:()=>or("br",{})})}))&&t.executeAction(Wl)},"data-testid":"load-button",shortcut:Bt("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};BC.displayName="LoadScene";var zC=()=>{let{t:e}=Dt(),t=Xt();return t.isActionEnabled(ag)?or(eo,{shortcut:Bt("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(ag),icon:Sy,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};zC.displayName="SaveToActiveFile";var HC=()=>{let e=Oe(),{t}=Dt();return or(eo,{icon:rp,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Bt("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};HC.displayName="SaveAsImage";var UC=e=>{let t=Oe(),{t:r}=Dt();return or(eo,{icon:mp,"data-testid":"command-palette-button",onSelect:()=>{Ce("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:Bt("commandPalette"),"aria-label":r("commandPalette.title"),className:e?.className,children:r("commandPalette.title")})};UC.displayName="CommandPalette";var GC=()=>{let{t:e}=Dt(),t=Xt();return or(eo,{"data-testid":"help-menu-item",icon:Vs,onSelect:()=>t.executeAction(ws),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};GC.displayName="Help";var WC=()=>{let{t:e}=Dt(),t=B_(Ss,Xe);return Xt().isActionEnabled(Ai)?or(eo,{icon:tn,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};WC.displayName="ClearCanvas";var VC=e=>{let{t}=Dt(),r=Ue(),o=Xt(),n=Bt("toggleTheme");return o.isActionEnabled(bs)?e?.allowSystemTheme?or(FC,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:ue.LIGHT,label:Pc,ariaLabel:`${t("buttons.lightMode")} - ${n}`},{value:ue.DARK,label:kc,ariaLabel:`${t("buttons.darkMode")} - ${n}`},{value:"system",label:Rw,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):or(eo,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(r.theme===ue.DARK?ue.LIGHT:ue.DARK);else return o.executeAction(bs)},icon:r.theme===ue.DARK?Pc:kc,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":r.theme===ue.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:r.theme===ue.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};VC.displayName="ToggleTheme";var YC=()=>{let{t:e}=Dt(),t=Ue(),r=Xt(),o=Wn();return t.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:ZC("div",{style:{marginTop:"0.5rem"},children:[or("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),or("div",{style:{padding:"0 0.625rem"},children:r.renderAction("changeViewBackgroundColor")})]})};YC.displayName="ChangeCanvasBackground";var XC=()=>{let{t:e}=Dt(),t=Oe();return or(eo,{icon:Ba,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};XC.displayName="Export";var KC=()=>{let{t:e}=Dt();return ZC(z_,{children:[or(Ql,{icon:ep,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),or(Ql,{icon:vy,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),or(Ql,{icon:wy,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};KC.displayName="Socials";var $C=({onSelect:e,isCollaborating:t})=>{let{t:r}=Dt();return or(eo,{"data-testid":"collab-button",icon:op,className:F_({"active-collab":t}),onSelect:e,children:r("labels.liveCollaboration")})};$C.displayName="LiveCollaborationTrigger";ee();f();import{atom as H_,useAtom as U_}from"jotai";import{useLayoutEffect as G_,useRef as W_}from"react";import{jsx as V_}from"react/jsx-runtime";var Di=(e,t)=>{let r=H_(0),o=n=>{let{jotaiScope:i}=ut(),[,a]=U_(r,i),s=W_({preferHost:!1,counter:0});return G_(()=>{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]),n.__fallback||(s.current.preferHost=!0),!s.current.counter&&n.__fallback&&s.current.preferHost||s.current.counter>1&&n.__fallback?null:V_(t,{...n})};return o.displayName=e,o};V();import{jsx as jg,jsxs as V1}from"react/jsx-runtime";var Y_=Object.assign(Di("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:r}=ut(),o=Ne(),n=Ue(),i=Oe(),a=o.editor.isMobile?void 0:()=>i({openMenu:null});return jg(r.In,{children:V1(Ye,{open:n.openMenu==="canvas",children:[jg(Ye.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Qm}),V1(Ye.Content,{onClickOutside:a,onSelect:zi(t,()=>{i({openMenu:null})}),children:[e,o.editor.isMobile&&n.collaborators.size>0&&V1("fieldset",{className:"UserList-Wrapper",children:[jg("legend",{children:E("labels.collaborators")}),jg(Xg,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ye.Trigger,Item:Ye.Item,ItemLink:Ye.ItemLink,ItemCustom:Ye.ItemCustom,Group:Ye.Group,Separator:Ye.Separator,DefaultItems:W1}),Hr=Y_;f();import{useAtom as Z_}from"jotai";ee();f();import{jsx as oc,jsxs as $_}from"react/jsx-runtime";var qg=({title:e,children:t,actionLabel:r,onClick:o})=>$_("div",{className:"OverwriteConfirm__Actions__Action",children:[oc("h4",{children:e}),oc("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),oc($n,{variant:"outlined",color:"muted",label:r,size:"large",fullWidth:!0,onClick:o})]}),X_=()=>{let{t:e}=Dt(),t=Xt(),r=Oe();return oc(qg,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(ig,"ui",!0),r({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},K_=()=>{let{t:e}=Dt(),t=Xt();return oc(qg,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(Ud,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Y1=Object.assign(({children:e})=>oc("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:X_,SaveToDisk:K_});import{jsx as xa,jsxs as jC}from"react/jsx-runtime";var Jg=Object.assign(Di("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=ut(),[r,o]=Z_(U1,Xe);if(!r.active)return null;let n=()=>{r.onClose(),o(a=>({...a,active:!1}))},i=()=>{r.onConfirm(),o(a=>({...a,active:!1}))};return xa(t.In,{children:xa(xt,{onCloseRequest:n,title:!1,size:916,children:jC("div",{className:"OverwriteConfirm",children:[xa("h3",{children:r.title}),jC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${r.color}`,children:[xa("div",{className:"OverwriteConfirm__Description__icon",children:fw}),xa("div",{children:r.description}),xa("div",{className:"OverwriteConfirm__Description__spacer"}),xa($n,{color:r.color,size:"large",label:r.actionLabel,onClick:i})]}),xa(Y1,{children:e})]})})})}),{Actions:Y1,Action:qg});Zr();ee();f();Y();import j_ from"clsx";V();import{jsx as ya,jsxs as qC}from"react/jsx-runtime";import{createElement as q_}from"react";var JC=Di("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=ut();return ya(t.In,{children:ya(Li.Trigger,{...e,className:"default-sidebar-trigger",name:co.name})})});JC.displayName="DefaultSidebarTrigger";var QC=({children:e,...t})=>{let{DefaultSidebarTabTriggersTunnel:r}=ut();return ya(r.In,{children:ya(Li.TabTriggers,{...t,children:e})})};QC.displayName="DefaultTabTriggers";var Qg=Object.assign(Di("DefaultSidebar",({children:e,className:t,onDock:r,docked:o,...n})=>{let i=Ue(),a=Oe(),{DefaultSidebarTabTriggersTunnel:s}=ut();return q_(Li,{...n,name:"default",key:"default",className:j_("default-sidebar",t),docked:o??i.defaultSidebarDockedPreference,onDock:r===!1||!r&&o!=null?void 0:zi(r,l=>{a({defaultSidebarDockedPreference:l})})},qC(Li.Tabs,{children:[qC(Li.Header,{children:[n.__fallback&&ya("div",{style:{color:"var(--color-primary)",fontSize:"1.2em",fontWeight:"bold",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",paddingRight:"1em"},children:E("toolBar.library")}),ya(s.Out,{})]}),ya(Li.Tab,{tab:wc,children:ya(FI,{})}),e]}))}),{Trigger:JC,TabTriggers:QC});De();Qo();cs();f();ee();import J_ from"clsx";import{jsx as e5,jsxs as eR}from"react/jsx-runtime";var Q_="small",t5=e=>eR("label",{className:J_("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${Q_}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[e5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),e5("div",{className:"ToolIcon__icon",children:cp})]});f();import{useState as a5}from"react";ee();ye();f();import{jsx as tR}from"react/jsx-runtime";var nc=e=>tR("p",{className:"excalidraw__paragraph",style:e.style,children:e.children});f();import*as o5 from"@radix-ui/react-tabs";import{useRef as r5}from"react";V();import{jsx as rR}from"react/jsx-runtime";var n5=e=>{let t=Oe(),r=r5(null),o=r5(0);return rR(o5.Root,{ref:r,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=r.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>o.current&&(o.current=a,i.style.minHeight=`min(${o.current}px, 100%)`)}e.dialog==="settings"&&Sc(["text-to-diagram","diagram-to-code"],n)?t({openDialog:{name:e.dialog,tab:n,source:"settings"}}):e.dialog==="ttd"&&Sc(["text-to-diagram","mermaid"],n)&&t({openDialog:{name:e.dialog,tab:n}})},children:e.children})};n5.displayName="TTDDialogTabs";var eh=n5;f();import*as i5 from"@radix-ui/react-tabs";import{jsx as oR}from"react/jsx-runtime";var ic=({tab:e,children:t,...r})=>oR(i5.Content,{...r,value:e,children:t});ic.displayName="TTDDialogTab";import{jsx as io,jsxs as Qd}from"react/jsx-runtime";var s5=e=>{let[t,r]=a5(e.openAIKey||""),[o,n]=a5(e.isPersisted),i=Ue(),a=()=>{e.onConfirm(t.trim(),o)};return i.openDialog?.name!=="settings"?null:io(xt,{onCloseRequest:()=>{e.onClose(),e.onConfirm(t.trim(),o)},title:Qd("div",{style:{display:"flex"},children:["Wireframe to Code (AI)"," ",io("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.1rem 0.5rem",marginLeft:"1rem",fontSize:14,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"Experimental"})]}),className:"MagicSettings",autofocus:!1,children:io(eh,{dialog:"settings",tab:i.openDialog.tab,children:Qd(ic,{tab:"diagram-to-code",children:[Qd(nc,{children:["For the diagram-to-code feature we use"," ",io(Fo,{icon:_c}),"OpenAI."]}),Qd(nc,{children:["While the OpenAI API is in beta, its use is strictly limited \u2014 as such we require you use your own API key. You can create an"," ",io("a",{href:"https://platform.openai.com/login?launch",rel:"noopener noreferrer",target:"_blank",children:"OpenAI account"}),", add a small credit (5 USD minimum), and"," ",io("a",{href:"https://platform.openai.com/api-keys",rel:"noopener noreferrer",target:"_blank",children:"generate your own API key"}),"."]}),io(nc,{children:"Your OpenAI key does not leave the browser, and you can also set your own limit in your OpenAI account dashboard if needed."}),io(Lg,{isRedacted:!0,value:t,placeholder:"Paste your API key here",label:"OpenAI API key",onChange:s=>{r(s),e.onChange(s.trim(),o)},selectOnRender:!0,onKeyDown:s=>s.key===S.ENTER&&a()}),io(nc,{children:"By default, your API token is not persisted anywhere so you'll need to insert it again after reload. But, you can persist locally in your browser below."}),io(ys,{checked:o,onChange:n,children:"Persist API key in browser storage"}),Qd(nc,{children:["Once API key is set, you can use the ",io(Fo,{icon:$s})," ","tool to wrap your elements in a frame that will then allow you to turn it into code. This dialog can be accessed using the"," ",io("b",{children:"AI Settings"})," ",io(Fo,{icon:_c}),"."]}),io($n,{className:"MagicSettings__confirm",size:"large",label:"Confirm",onClick:a})]})})})};f();f();import{useState as p5,useRef as u5,useEffect as g5,useDeferredValue as dR}from"react";ee();f();Y();qr();var nR=({canvasRef:e,setError:t})=>{let r=e.current;if(!r)return;let o=r.parentElement;o&&(o.style.background="",t(null),r.replaceChildren())},th=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:r,setError:o,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!r){nR({canvasRef:e,setError:o});return}try{let s=await t.api,l;try{l=await s.parseMermaidToExcalidraw(r)}catch{l=await s.parseMermaidToExcalidraw(r.replace(/"/g,"'"))}let{elements:c,files:d}=l;o(null),n.current={elements:ac(c,{regenerateIds:!0}),files:d};let m=await ia({elements:n.current.elements,files:n.current.files,exportPadding:Ko,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await gi(m)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(E("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(m)}catch(s){throw a.style.background="var(--default-bg-color)",r&&o(s),s}}},em=e=>{ro.set(To.MERMAID_TO_EXCALIDRAW,e)},rh=({app:e,data:t,text:r,shouldSaveMermaidDataToStorage:o})=>{let{elements:n,files:i}=t.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),o&&r&&em(r))};f();import{jsx as iR}from"react/jsx-runtime";var oh=({children:e})=>iR("div",{className:"ttd-dialog-panels",children:e});f();import l5 from"clsx";import{jsx as X1,jsxs as tm}from"react/jsx-runtime";var sc=({label:e,children:t,panelAction:r,panelActionDisabled:o=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:s})=>tm("div",{className:"ttd-dialog-panel",children:[tm("div",{className:"ttd-dialog-panel__header",children:[X1("label",{children:e}),i?.()]}),t,tm("div",{className:l5("ttd-dialog-panel-button-container",{invisible:!r}),style:{display:"flex",alignItems:"center"},children:[tm(Yn,{className:"ttd-dialog-panel-button",onSelect:r?r.action:()=>{},disabled:o||n,children:[tm("div",{className:l5({invisible:n}),children:[r?.label,r?.icon&&X1("span",{children:r.icon})]}),n&&X1(ir,{})]}),!o&&!n&&a?.(),s?.()]})]});f();Y();ye();import{useEffect as aR,useRef as c5}from"react";import{jsx as sR}from"react/jsx-runtime";var nh=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:o})=>{let n=c5(null),i=c5(o);return i.current=o,aR(()=>{if(!i.current)return;let a=n.current;if(a){let s=l=>{l[S.CTRL_OR_CMD]&&l.key===S.ENTER&&(l.preventDefault(),i.current?.())};return a.addEventListener("keydown",s),()=>{a.removeEventListener("keydown",s)}}},[]),sR("textarea",{className:"ttd-dialog-input",onChange:r,value:e,placeholder:t,autoFocus:!0,ref:n})};f();import{jsx as ih,jsxs as d5}from"react/jsx-runtime";var lR=({error:e})=>d5("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",ih("p",{children:e})]}),ah=({error:e,canvasRef:t,loaded:r})=>d5("div",{className:"ttd-dialog-output-wrapper",children:[e&&ih(lR,{error:e.message}),r?ih("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):ih(ir,{size:"2rem"})]});Y();V();f();V();import{jsx as m5,jsxs as cR}from"react/jsx-runtime";var sh=()=>cR("div",{className:"ttd-dialog-submit-shortcut",children:[m5("div",{className:"ttd-dialog-submit-shortcut__key",children:O("CtrlOrCmd")}),m5("div",{className:"ttd-dialog-submit-shortcut__key",children:O("Enter")})]});import{Fragment as uR,jsx as Jn,jsxs as f5}from"react/jsx-runtime";var mR=`flowchart TD
|
|
60
56
|
A[Christmas] -->|Get money| B(Go shopping)
|
|
61
57
|
B --> C{Let me think}
|
|
62
58
|
C -->|One| D[Laptop]
|
|
63
59
|
C -->|Two| E[iPhone]
|
|
64
|
-
C -->|Three| F[Car]`,
|
|
65
|
-
TTD mermaid definition render errror: ${k.message}`,"color: yellow"),ve("ai","mermaid parse failed","ttd"),A(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(C){let L=C.message;(!L||L==="Failed to fetch")&&(L="Request failed"),A(new Error(L))}finally{p(!1)}},x=CE(g);x.current=g;let[v,y]=Ju({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});eD(()=>{(async()=>{await v.api,y(L=>({...L,loaded:!0}))})()},[v.api]);let w=CE({elements:[],files:null}),[I,A]=Ju(null);return Cr(pt,{className:"ttd-dialog",onCloseRequest:()=>{r.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:Zi(Wu,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?Cr("p",{className:"dialog-mermaid-title",children:E("mermaid.title")}):Zi(IE,{children:[Cr(qu,{tab:"text-to-diagram",children:Zi("div",{style:{display:"flex",alignItems:"center"},children:[E("labels.textToDiagram"),Cr("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"AI Beta"})]})}),Cr(qu,{tab:"mermaid",children:"Mermaid"})]}),Cr(Il,{className:"ttd-dialog-content",tab:"mermaid",children:Cr(oI,{mermaidToExcalidrawLib:v})}),!("__fallback"in t)&&Zi(Il,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[Cr("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),Zi(Ku,{children:[Cr(Al,{label:E("labels.prompt"),panelAction:{action:g,label:"Generate",icon:Qs},onTextSubmitInProgess:m,panelActionDisabled:c.length>kl||u?.rateLimitRemaining===0,renderTopRight:()=>u?Zi("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>Cr(ju,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Zi("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(md(i.generatedResponse),o({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",Cr(Co,{icon:Qs})]});let C=c.length/kl;return C>.8?Zi("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:C>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",kl]}):null},children:Cr($u,{onChange:d,input:s,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),Cr(Al,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Yu({app:r,data:w})},label:"Insert",icon:Qs},children:Cr(Zu,{canvasRef:n,error:I,loaded:v.loaded})})]})]})]})})});f();it();import{useEffect as TI,useMemo as SI,useState as zD,memo as HD}from"react";import{throttle as UD}from"lodash";f();f();Y();ge();jo();import{useEffect as dI,useRef as ME,useState as iD}from"react";import aD from"clsx";f();_r();Ae();Nc();Je();le();ft();G();var cI=.01,Vr=(e,t)=>!(t==="height"&&U(e)||t==="width"&&U(e)||t==="angle"&&re(e)),Et=(e,t)=>{let r=e+t/2;return r-r%t},Ml=(e,t,r)=>Object.keys(e).map(o=>({original:(r??t).get(o),latest:t.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0),nD=(e,t,r,o,n,i,a)=>({x:e+(r-n)/2+(n-r)/2*Math.cos(a)+(o-i)/2*Math.sin(a),y:t+(o-i)/2+(n-r)/2*Math.sin(a)+(i-o)/2*Math.cos(a)}),Ll=(e,t,r,o,n,i,a,s=!0)=>{let l={},c=ae(o,i);if(c){let d=ks(Ie(c),c.lineHeight),m=As(c.fontSize,c.lineHeight);e=Math.max(e,d),t=Math.max(t,m)}if(O(o,{...nD(o.x,o.y,o.width,o.height,e,t,o.angle),width:e,height:t,..._c(n,e,t,!0)},s),c&&(l={fontSize:c.fontSize},r)){let d={...o,width:e,height:t};l={fontSize:Rc(c,i,cr(d,c))?.size??c.fontSize}}qt(o,i,{newSize:{width:e,height:t}}),c&&l&&O(c,{fontSize:l.fontSize}),Wo(o,i,"e",r)},Za=(e,t,r,o,n,i,a=!0)=>{let[s,l]=[o.x+o.width/2,o.y+o.height/2],[c,d]=he(o.x,o.y,s,l,o.angle),m=e-c,p=t-d,[u,h]=he(e,t,s+m,l+p,-o.angle);O(r,{x:u,y:h},a);let g=ae(o,i);if(g){let x=n.get(g.id);x&&O(x,{x:g.x+m,y:g.y+p},a)}};De();import{Fragment as cD,jsx as Qu,jsxs as lD}from"react/jsx-runtime";var sD=({label:e,icon:t,dragInputCallback:r,value:o,elements:n,editable:i=!0,shouldKeepAspectRatio:a})=>{let s=pr(),l=ME(null),c=ME(null),[d,m]=iD(o.toString());dI(()=>{m(o.toString())},[o,n]);let p=h=>{let g=Number(h);if(isNaN(g)){m(o.toString());return}let x=Number(g.toFixed(2)),v=Number(o);(isNaN(v)||Math.abs(x-v)>=cI)&&(r({accumulatedChange:0,instantChange:0,originalElements:n,originalElementsMap:s.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,nextValue:x}),s.syncActionResult({storeAction:D.CAPTURE}))},u=ME(p);return u.current=p,dI(()=>{let h=l.current;return()=>{let g=h?.value;g&&u.current(g)}},[]),i?lD("div",{className:aD("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Qu("div",{className:"drag-input-label",ref:c,onPointerDown:h=>{if(l.current&&i){let g=Number(l.current.value);isNaN(g)&&(g=0);let x=null,v=null,y=null,w=null;document.body.classList.add("excalidraw-cursor-resize");let I=A=>{if(y||(y=s.scene.getNonDeletedElements().reduce((C,L)=>(C.set(L.id,Zo(L)),C),new Map)),v||(v=n.map(C=>y.get(C.id))),w||(w=0),x&&y!==null&&w!==null){let C=A.clientX-x.x;w+=C,r({accumulatedChange:w,instantChange:C,originalElements:v,originalElementsMap:y,shouldKeepAspectRatio:a,shouldChangeByStepSize:A.shiftKey})}x={x:A.clientX,y:A.clientY}};window.addEventListener("pointermove",I,!1),window.addEventListener("pointerup",()=>{window.removeEventListener("pointermove",I,!1),s.syncActionResult({storeAction:D.CAPTURE}),x=null,w=null,v=null,y=null,document.body.classList.remove("excalidraw-cursor-resize")},!1)}},onPointerEnter:()=>{c.current&&(c.current.style.cursor="ew-resize")},children:t?Qu(Co,{icon:t}):e}),Qu("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:h=>{if(i){let g=h.target;g instanceof HTMLInputElement&&h.key===S.ENTER&&(p(g.value),s.focusContainer())}},ref:l,value:d,onChange:h=>{m(h.target.value)},onFocus:h=>{h.target.select()},onBlur:h=>{d?i&&p(h.target.value):m(o.toString())},disabled:!i})]}):Qu(cD,{})},gr=sD;Y();import{jsx as pD}from"react/jsx-runtime";var mI=10,dD=e=>e.type==="image",mD=({property:e,element:t,elementsMap:r})=>{let o=({accumulatedChange:i,originalElements:a,originalElementsMap:s,shouldKeepAspectRatio:l,shouldChangeByStepSize:c,nextValue:d})=>{let m=a[0];if(m){let p=l||dD(t),u=m.width/m.height;if(d!==void 0){let y=Math.max(e==="width"?d:p?d*u:m.width,Lr),w=Math.max(e==="height"?d:p?d/u:m.height,Lr);Ll(y,w,p,t,m,r,s);return}let h=e==="width"?i:0,g=e==="height"?i:0,x=Math.max(0,m.width+h);e==="width"&&(c?x=Et(x,mI):x=Math.round(x));let v=Math.max(0,m.height+g);e==="height"&&(c?v=Et(v,mI):v=Math.round(v)),p&&(e==="width"?v=Math.round(x/u*100)/100:x=Math.round(v*u*100)/100),v=Math.max(Lr,v),x=Math.max(Lr,x),Ll(x,v,p,t,m,r,s)}},n=Math.round((e==="width"?t.width:t.height)*100)/100;return pD(gr,{label:e==="width"?"W":"H",elements:[t],dragInputCallback:o,value:n,editable:Vr(t,e)})},LE=mD;f();Ae();Je();le();ft();import{jsx as gD}from"react/jsx-runtime";var uD=15,hD=({element:e,elementsMap:t})=>{let r=({accumulatedChange:o,originalElements:n,shouldChangeByStepSize:i,nextValue:a})=>{let s=n[0];if(s){if(a!==void 0){let u=gs(a);O(e,{angle:u});let h=ae(e,t);h&&!xe(e)&&O(h,{angle:u});return}let l=Math.round(hs(s.angle)*100)/100,c=Math.round(o),d=(l+c)%360;i&&(d=Et(d,uD)),d=d<0?d+360:d;let m=gs(d);O(e,{angle:m});let p=ae(e,t);p&&!xe(e)&&O(p,{angle:m})}};return gD(gr,{label:"A",icon:Mp,value:Math.round(hs(e.angle)%360*100)/100,elements:[e],dragInputCallback:r,editable:Vr(e,"angle")})},pI=hD;f();jo();Ae();import{jsx as ED}from"react/jsx-runtime";var uI=4,fD=4,bD=({element:e,elementsMap:t})=>{let r=({accumulatedChange:o,originalElements:n,shouldChangeByStepSize:i,nextValue:a})=>{let s=n[0];if(s){if(a!==void 0){let l=Math.max(Math.round(a),uI),c={...e,fontSize:l},d=Xo(c,null,t);O(e,{...d,fontSize:l});return}if(s.type==="text"){let l=Math.round(s.fontSize),c=Math.round(o),d=Math.max(l+c,uI);i&&(d=Et(d,fD));let m={...e,fontSize:d},p=Xo(m,null,t);O(e,{...p,fontSize:d})}}};return ED(gr,{label:"F",value:Math.round(e.fontSize*10)/10,elements:[e],dragInputCallback:r,icon:Ba})},hI=bD;f();be();_r();Ae();Nc();Je();import{useMemo as xD}from"react";Y();import{jsx as TD}from"react/jsx-runtime";var Pl=10,yD=(e,t,r,o)=>{let n=o.x-e,i=o.y-t,a=o.width*r,s=o.height*r,l=e+n*r,c=t+i*r;return{width:a,height:s,x:l,y:c,..._c(o,a,s,!1),...U(o)?{fontSize:o.fontSize*r}:{}}},wD=(e,t,r,o,n,i,a,s)=>{let l=yD(e,t,o,i);O(n,l,!1);let c=ae(i,s);if(c){let d=c.fontSize*o;qt(n,a,{newSize:{width:l.width,height:l.height}});let m=a.get(c.id);m&&U(m)&&(O(m,{fontSize:d},!1),Wo(n,a,r==="width"?"e":"s",!0))}},gI=(e,t,r,o,n,i,a,s,l,c)=>{i==="width"?t=Math.round(e/o*100)/100:e=Math.round(t*o*100)/100;let d=t/r;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];wD(n[0],n[1],i,d,u,p,l,c)}},vD=({property:e,elements:t,elementsMap:r,atomicUnits:o,scene:n})=>{let i=xD(()=>o.map(c=>{let d=Ml(c,r);if(d.length>1){let[p,u,h,g]=we(d.map(x=>x.latest));return Math.round((e==="width"?h-p:g-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[r,o,e]),a=new Set(i).size===1?Math.round(i[0]*100)/100:"Mixed",s=i.length>0;return TD(gr,{label:e==="width"?"W":"H",elements:t,dragInputCallback:({accumulatedChange:c,originalElementsMap:d,shouldChangeByStepSize:m,nextValue:p})=>{if(p!==void 0){for(let g of o){let x=Ml(g,r,d);if(x.length>1){let v=x.map(B=>B.latest),y=x.map(B=>B.original),[w,I,A,C]=we(y),L=A-w,M=C-I,z=L/M,k=Math.max(Lr,e==="width"?Math.max(0,p):L),N=Math.max(Lr,e==="height"?Math.max(0,p):M);gI(k,N,M,z,[w,I],e,v,y,r,d)}else{let[v]=x,y=v?.latest,w=v?.original;if(y&&w&&Vr(y,e)){let I=e==="width"?Math.max(0,p):y.width;e==="width"&&(m?I=Et(I,Pl):I=Math.round(I));let A=e==="height"?Math.max(0,p):y.height;e==="height"&&(m?A=Et(A,Pl):A=Math.round(A)),I=Math.max(Lr,I),A=Math.max(Lr,A),Ll(I,A,!1,y,w,r,d,!1)}}}n.triggerUpdate();return}let u=e==="width"?c:0,h=e==="height"?c:0;for(let g of o){let x=Ml(g,r,d);if(x.length>1){let v=x.map(B=>B.latest),y=x.map(B=>B.original),[w,I,A,C]=we(y),L=A-w,M=C-I,z=L/M,k=Math.max(0,L+u);e==="width"&&(m?k=Et(k,Pl):k=Math.round(k));let N=Math.max(0,M+h);e==="height"&&(m?N=Et(N,Pl):N=Math.round(N)),k=Math.max(Lr,k),N=Math.max(Lr,N),gI(k,N,M,z,[w,I],e,v,y,r,d)}else{let[v]=x,y=v?.latest,w=v?.original;if(y&&w&&Vr(y,e)){let I=Math.max(0,w.width+u);e==="width"&&(m?I=Et(I,Pl):I=Math.round(I));let A=Math.max(0,w.height+h);e==="height"&&(m?A=Et(A,Pl):A=Math.round(A)),I=Math.max(Lr,I),A=Math.max(Lr,A),Ll(I,A,!1,y,w,r,d)}}}n.triggerUpdate()},value:a,editable:s})},PE=vD;Gt();f();Ae();Je();le();Gt();ft();import{jsx as CD}from"react/jsx-runtime";var SD=15,ID=({elements:e,elementsMap:t,scene:r})=>{let o=({accumulatedChange:l,originalElements:c,shouldChangeByStepSize:d,nextValue:m})=>{let p=e.filter(h=>!$o(h)&&Vr(h,"angle")),u=c.filter(h=>!$o(h)&&Vr(h,"angle"));if(m!==void 0){let h=gs(m);for(let g of p){O(g,{angle:h},!1);let x=ae(g,t);x&&!xe(g)&&O(x,{angle:h},!1)}r.triggerUpdate();return}for(let h=0;h<p.length;h++){let g=p[h],x=u[h],v=Math.round(hs(x.angle)*100)/100,y=Math.round(l),w=(v+y)%360;d&&(w=Et(w,SD)),w=w<0?w+360:w;let I=gs(w);O(g,{angle:I},!1);let A=ae(g,t);A&&!xe(g)&&O(A,{angle:I},!1)}r.triggerUpdate()},n=e.filter(l=>!$o(l)&&Vr(l,"angle")),i=n.map(l=>Math.round(hs(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=n.some(l=>Vr(l,"angle"));return CD(gr,{label:"A",icon:Mp,value:a,elements:e,dragInputCallback:o,editable:s})},fI=ID;f();be();Ae();le();Gt();import{jsx as MD}from"react/jsx-runtime";var bI=4,AD=4,kD=({elements:e,elementsMap:t,scene:r})=>{let o=e.filter(l=>!$o(l)&&U(l)&&!Me(l)),n=o.map(l=>Math.round(l.fontSize*10)/10),i=new Set(n).size===1?n[0]:"Mixed",a=n.length>0;return MD(gr,{label:"F",icon:Ba,elements:e,dragInputCallback:({accumulatedChange:l,originalElements:c,shouldChangeByStepSize:d,nextValue:m})=>{if(m){let u=Math.max(Math.round(m),bI);for(let h of o){let g={...h,fontSize:u},x=Xo(g,null,t);O(h,{...x,fontSize:u},!1)}r.triggerUpdate();return}let p=c.filter(u=>!$o(u)&&U(u)&&!Me(u));for(let u=0;u<o.length;u++){let h=o[u],g=p[u],x=Math.round(g.fontSize),v=Math.round(l),y=Math.max(x+v,bI);d&&(y=Et(y,AD));let w={...h,fontSize:y},I=Xo(w,null,t);O(h,{...I,fontSize:y},!1)}r.triggerUpdate()},value:i,editable:a})},EI=kD;f();ft();import{jsx as PD}from"react/jsx-runtime";var xI=10,LD=({property:e,element:t,elementsMap:r})=>{let[o,n]=he(t.x,t.y,t.x+t.width/2,t.y+t.height/2,t.angle),i=Math.round((e==="x"?o:n)*100)/100;return PD(gr,{label:e==="x"?"X":"Y",elements:[t],dragInputCallback:({accumulatedChange:s,originalElements:l,originalElementsMap:c,shouldChangeByStepSize:d,nextValue:m})=>{let p=l[0],[u,h]=[p.x+p.width/2,p.y+p.height/2],[g,x]=he(p.x,p.y,u,h,p.angle);if(m!==void 0){Za(e==="x"?m:g,e==="y"?m:x,t,p,r,c);return}let v=e==="x"?s:0,y=e==="y"?s:0,w=e==="x"?Math.round(d?Et(p.x+v,xI):g+v):g,I=e==="y"?Math.round(d?Et(p.y+y,xI):x+y):x;Za(w,I,t,p,r,c)},value:i})},DE=LD;f();ft();be();import{useMemo as DD}from"react";import{jsx as BD}from"react/jsx-runtime";var _D=10,RD=(e,t,r,o,n,i,a)=>{for(let s=0;s<o.length;s++){let l=n[s],c=o[s],[d,m]=[l.x+l.width/2,l.y+l.height/2],[p,u]=he(l.x,l.y,d,m,l.angle),h=e==="x"?Math.round(p+t):p,g=e==="y"?Math.round(u+r):u;Za(h,g,c,l,i,a,!1)}},ND=(e,t,r,o,n,i)=>{let[a,s,,]=we(o),l=e-a,c=t-s;for(let d=0;d<r.length;d++){let m=o[d],p=r[d];if(!U(p)||!p.containerId){let[u,h]=[p.x+p.width/2,p.y+p.height/2],[g,x]=he(p.x,p.y,u,h,p.angle);Za(g+l,x+c,p,m,n,i,!1)}}},OD=({property:e,elements:t,elementsMap:r,atomicUnits:o,scene:n})=>{let i=DD(()=>o.map(l=>{let c=Object.keys(l).map(g=>r.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,x]=we(c);return Math.round((e==="x"?g:x)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,h]=he(d.x,d.y,m,p,d.angle);return Math.round((e==="x"?u:h)*100)/100}),[o,r,e]),a=new Set(i).size===1?i[0]:"Mixed";return BD(gr,{label:e==="x"?"X":"Y",elements:t,dragInputCallback:({accumulatedChange:l,originalElements:c,originalElementsMap:d,shouldChangeByStepSize:m,nextValue:p})=>{if(p!==void 0){for(let x of o){let v=Ml(x,r,d);if(v.length>1){let[y,w,,]=we(v.map(C=>C.latest));ND(e==="x"?p:y,e==="y"?p:w,v.map(C=>C.latest),v.map(C=>C.original),r,d)}else{let y=v[0]?.original,w=v[0]?.latest;if(y&&w&&Vr(w,e)){let[I,A]=[y.x+y.width/2,y.y+y.height/2],[C,L]=he(y.x,y.y,I,A,y.angle);Za(e==="x"?p:C,e==="y"?p:L,w,y,r,d,!1)}}}n.triggerUpdate();return}let u=m?Et(l,_D):l;RD(e,e==="x"?u:0,e==="y"?u:0,t,c,r,d),n.triggerUpdate()},value:a})},_E=OD;f();import{Fragment as vI,jsx as yI,jsxs as wI}from"react/jsx-runtime";var FD=({label:e,open:t,openTrigger:r,children:o})=>wI(vI,{children:[wI("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},onClick:r,children:[e,yI(Co,{icon:t?hv:uv})]}),t&&yI(vI,{children:o})]}),RE=FD;Y();import{jsx as ze,jsxs as Ao}from"react/jsx-runtime";var GD=50,II=e=>{let t=Hi(),r=e.scene.getSceneNonce()||1,o=e.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return ze(WD,{...e,appState:t,sceneNonce:r,selectedElements:o})},WD=HD(({scene:e,onClose:t,renderCustomStats:r,selectedElements:o,appState:n,sceneNonce:i})=>{let a=e.getNonDeletedElements(),s=e.getNonDeletedElementsMap(),l=Re(),c=o.length===1?o[0]:null,d=o.length>1?o:null,[m,p]=zD({width:0,height:0}),u=SI(()=>UD(g=>{let x=we(g);p({width:Math.round(x[2])-Math.round(x[0]),height:Math.round(x[3])-Math.round(x[1])})},GD),[]);TI(()=>{u(a)},[i,a,u]),TI(()=>()=>u.cancel(),[u]);let h=SI(()=>{let x=Ko(n).map(v=>Qe(o,v).reduce((y,w)=>(y[w.id]=!0,y),{}));return o.filter(v=>!$o(v)).forEach(v=>{x.push({[v.id]:!0})}),x},[o,n]);return ze("div",{className:"Stats",children:Ao(tr,{padding:3,children:[Ao("div",{className:"title",children:[ze("h2",{children:E("stats.title")}),ze("div",{className:"close",onClick:t,children:yo})]}),ze(RE,{label:ze("h3",{children:E("stats.generalStats")}),open:!!(n.stats.panels&pi.generalStats),openTrigger:()=>l(g=>({...g,stats:{open:!0,panels:g.stats.panels^pi.generalStats}})),children:ze("table",{children:Ao("tbody",{children:[ze("tr",{children:ze("th",{colSpan:2,children:E("stats.scene")})}),Ao("tr",{children:[ze("td",{children:E("stats.elements")}),ze("td",{children:a.length})]}),Ao("tr",{children:[ze("td",{children:E("stats.width")}),ze("td",{children:m.width})]}),Ao("tr",{children:[ze("td",{children:E("stats.height")}),ze("td",{children:m.height})]}),r?.(a,n)]})})}),o.length>0&&ze("div",{id:"elementStats",style:{marginTop:12},children:Ao(RE,{label:ze("h3",{children:E("stats.elementProperties")}),open:!!(n.stats.panels&pi.elementProperties),openTrigger:()=>l(g=>({...g,stats:{open:!0,panels:g.stats.panels^pi.elementProperties}})),children:[c&&Ao("div",{className:"sectionContent",children:[ze("div",{className:"elementType",children:E(`element.${c.type}`)}),Ao("div",{className:"statsItem",children:[ze(DE,{element:c,property:"x",elementsMap:s}),ze(DE,{element:c,property:"y",elementsMap:s}),ze(LE,{property:"width",element:c,elementsMap:s}),ze(LE,{property:"height",element:c,elementsMap:s}),ze(pI,{element:c,elementsMap:s}),c.type==="text"&&ze(hI,{element:c,elementsMap:s})]})]}),d&&Ao("div",{className:"sectionContent",children:[P0(d)&&ze("div",{className:"elementType",children:E("element.group")}),Ao("div",{className:"elementsCount",children:[ze("div",{children:E("stats.elements")}),ze("div",{children:o.length})]}),Ao("div",{className:"statsItem",children:[ze(_E,{property:"x",elements:d,elementsMap:s,atomicUnits:h,scene:e}),ze(_E,{property:"y",elements:d,elementsMap:s,atomicUnits:h,scene:e}),ze(PE,{property:"width",elements:d,elementsMap:s,atomicUnits:h,scene:e}),ze(PE,{property:"height",elements:d,elementsMap:s,atomicUnits:h,scene:e}),ze(fI,{elements:d,elementsMap:s,scene:e}),ze(EI,{elements:d,elementsMap:s,scene:e})]})]})]})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels);import{Fragment as AI,jsx as me,jsxs as so}from"react/jsx-runtime";var XD=({UIOptions:e})=>so(Ir,{__fallback:!0,children:[me(Ir.DefaultItems.LoadScene,{}),me(Ir.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&me(Ir.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&me(Ir.DefaultItems.SaveAsImage,{}),me(Ir.DefaultItems.Help,{}),me(Ir.DefaultItems.ClearCanvas,{}),me(Ir.Separator,{}),me(Ir.Group,{title:"Excalidraw links",children:me(Ir.DefaultItems.Socials,{})}),me(Ir.Separator,{}),me(Ir.DefaultItems.ToggleTheme,{}),me(Ir.DefaultItems.ChangeCanvasBackground,{})]}),ZD=()=>so(Uu,{__fallback:!0,children:[me(Uu.Actions.SaveToDisk,{}),me(Uu.Actions.ExportToImage,{})]}),jD=({actionManager:e,appState:t,files:r,setAppState:o,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:s,onPenModeToggle:l,showExitZenModeBtn:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:h,children:g,app:x,isCollaborating:v,openAIKey:y,isOpenAIKeyPersisted:w,onOpenAIAPIKeyChange:I,onMagicSettingsConfirm:A})=>{let C=_e(),L=I3(),[M,z]=KD(Oi,Ge),k=()=>p.canvasActions.export?me(oS,{elements:n,appState:t,files:r,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,N=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:me(W3,{elements:n,appState:t,files:r,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:x.getName()}),B=()=>so("div",{style:{position:"relative"},children:[me(L.MainMenuTunnel.Out,{}),h&&me(L.WelcomeScreenMenuHintTunnel.Out,{})]}),_=()=>me(Yi,{heading:"selectedShapeActions",className:ud("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:me(tr,{className:Dd.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:me(Tu,{appState:t,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction})})}),V=()=>{let W=_a(t,n),$=t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled;return me(Lu,{side:"top",children:so("div",{className:"App-menu App-menu_top",children:[so(Kt.Col,{gap:6,className:ud("App-menu_top__left"),children:[B(),W&&_()]}),!t.viewModeEnabled&&me(Yi,{heading:"shapes",className:"shapes-section",children:ee=>so("div",{style:{position:"relative"},children:[h&&me(L.WelcomeScreenToolbarHintTunnel.Out,{}),me(Kt.Col,{gap:4,align:"start",children:so(Kt.Row,{gap:1,className:ud("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[so(tr,{padding:1,className:ud("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[me(Pu,{appState:t,isMobile:C.editor.isMobile,device:C,app:x}),ee,so(Kt.Row,{gap:1,children:[me(_u,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>l(null),title:E("toolBar.penMode"),penDetected:t.penDetected}),me(Du,{checked:t.activeTool.locked,onChange:a,title:E("toolBar.lock")}),me("div",{className:"App-toolbar__divider"}),me(Ru,{checked:Yo(t),onChange:()=>s(),title:E("toolBar.hand"),isMobile:!0}),me(Su,{appState:t,activeTool:t.activeTool,UIOptions:p,app:x})]})]}),v&&me(tr,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:me(US,{title:E("toolBar.laser"),checked:t.activeTool.type===xt.laser,onChange:()=>x.setActiveTool({type:xt.laser}),isMobile:!0})})]})})]})}),so("div",{className:ud("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&me(Nu,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),d?.(C.editor.isMobile,t),!t.viewModeEnabled&&(!J||t.openSidebar?.name!==Xr.name)&&me(L.DefaultSidebarTriggerTunnel.Out,{}),$&&me(II,{scene:x.scene,onClose:()=>{e.executeAction(ul)},renderCustomStats:m})]})]})})},Z=()=>me(Gu,{__fallback:!0,onDock:W=>{ve("sidebar",`toggleDock (${W?"dock":"undock"})`,`(${C.editor.isMobile?"mobile":"desktop"})`)}}),J=$D(cd,Ge),Se=so(AI,{children:[g,me(XD,{UIOptions:p}),me(Gu.Trigger,{__fallback:!0,icon:Tp,title:ui(E("toolBar.library")),onToggle:W=>{W&&ve("sidebar",`${Xr.name} (open)`,`button (${C.editor.isMobile?"mobile":"desktop"})`)},tab:Xr.defaultTab,children:E("toolBar.library")}),me(ZD,{}),t.openDialog?.name==="ttd"&&me(kE,{__fallback:!0}),t.isLoading&&me(Gd,{delay:250}),t.errorMessage&&me(H3,{onClose:()=>o({errorMessage:null}),children:t.errorMessage}),M&&!C.editor.isMobile&&me(Gv,{colorPickerType:M.colorPickerType,onCancel:()=>{z(null)},onChange:(W,$,ee,{altKey:fe})=>{if(!(W!=="elementBackground"&&W!=="elementStroke"))if(ee.length){for(let ot of ee)O(ot,{[fe&&M.swapPreviewOnAlt?W==="elementBackground"?"strokeColor":"backgroundColor":W==="elementBackground"?"backgroundColor":"strokeColor"]:$},!1),Oe.delete(ot);Mt.getScene(ee[0])?.triggerUpdate()}else o(W==="elementBackground"?{currentItemBackgroundColor:$}:{currentItemStrokeColor:$})},onSelect:(W,$)=>{z(ee=>ee?.keepOpenOnAlt&&$.altKey?ee:null),M?.onSelect?.(W,$)}}),t.openDialog?.name==="help"&&me(eS,{onClose:()=>{o({openDialog:null})}}),t.openDialog?.name==="settings"&&me($S,{openAIKey:y,isPersisted:w,onChange:I,onConfirm:(W,$)=>{let ee=t.openDialog?.name==="settings"?t.openDialog?.source:"settings";o({openDialog:null},()=>{A(W,$,ee)})},onClose:()=>{o({openDialog:null})}}),me(L3,{}),me(L.OverwriteConfirmDialogTunnel.Out,{}),N(),k(),t.pasteDialog.shown&&me(Q3,{setAppState:o,appState:t,onClose:()=>o({pasteDialog:{shown:!1,data:null}})}),C.editor.isMobile&&me(q3,{app:x,appState:t,elements:n,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:N,setAppState:o,onLockToggle:a,onHandToolToggle:s,onPenModeToggle:l,renderTopRightUI:d,renderCustomStats:m,renderSidebars:Z,device:C,renderWelcomeScreen:h,UIOptions:p}),!C.editor.isMobile&&so(AI,{children:[so("div",{className:"layer-ui__wrapper",style:t.openSidebar&&J&&C.editor.canFitSidebar?{width:`calc(100% - ${Vx}px)`}:{},children:[h&&me(L.WelcomeScreenCenterTunnel.Out,{}),V(),me(aS,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:h}),t.scrolledOutside&&me("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(W=>({...bn(n,W)}))},children:E("buttons.scrollBackToContent")})]}),Z()]})]});return me(jf.Provider,{value:t,children:me(YD,{scope:L.jotaiScope,children:me(Vb.Provider,{value:L,children:Se})})})},CI=e=>{let{suggestedBindings:t,startBoundElement:r,cursorButton:o,scrollX:n,scrollY:i,...a}=e;return a},qD=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:r,appState:o,...n}=e,{canvas:i,appState:a,...s}=t;return tt(CI(o),CI(a),{selectedElementIds:tt,selectedGroupIds:tt})&&tt(n,s)},kI=VD.memo(jD,qD);f();import{useCallback as JD,useEffect as QD,useRef as e_}from"react";import{jsx as MI,jsxs as r_}from"react/jsx-runtime";var t_=5e3,LI=({message:e,onClose:t,closable:r=!1,duration:o=t_,style:n})=>{let i=e_(0),a=o!==1/0,s=JD(()=>{a&&(i.current=window.setTimeout(()=>t(),o))},[t,o,a]);return QD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),r_("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:n,children:[MI("p",{className:"Toast__message",children:e}),r&&MI(de,{icon:yo,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})};f();ge();De();Ve();var NE=H({name:"viewMode",label:"labels.viewMode",paletteName:"Toggle view mode",icon:tl,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},storeAction:D.NONE}},checked:e=>e.viewModeEnabled,predicate:(e,t,r)=>typeof r.viewModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===ye.R});Br();Og();$n();Je();import Z_ from"lodash.throttle";Sa();Dc();f();be();Ae();G();pn();var hd=class e{scene;constructor({scene:t}){this.scene=t}static loadedFontFaces=new Set;onFontsLoaded=t=>{if(t.every(o=>{let n=`${o.family}-${o.style}-${o.weight}`;return e.loadedFontFaces.has(n)?!0:(e.loadedFontFaces.add(n),!1)}))return!1;let r=!1;this.scene.mapElements(o=>U(o)?(r=!0,Oe.delete(o),se(o,{},!0)):o),r&&this.scene.triggerUpdate()};loadFontsForElements=async t=>{let r=await Promise.all([...new Set(t.filter(o=>U(o)).map(o=>o.fontFamily))].map(o=>{let n=Ie({fontFamily:o,fontSize:16});if(!document.fonts?.check?.(n))return document.fonts?.load?.(n)}));this.onFontsLoaded(r.flat().filter(Boolean))}};mr();Ei();f();be();mr();mr();ge();G();Ls();Ve();le();De();var PI=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length===1&&re(r[0])},DI=H({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;if(re(n)){let i=ro(Te(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},storeAction:D.CAPTURE}}return{elements:e,appState:t,storeAction:D.NONE}},predicate:(e,t,r,o)=>PI(t,o)}),_I=H({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;return re(n)?{elements:qg(e,n),appState:{...t,selectedElementIds:{[n.id]:!0}},storeAction:D.CAPTURE}:{elements:e,appState:t,storeAction:D.NONE}},predicate:(e,t,r,o)=>PI(t,o)}),C0e=H({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},storeAction:D.NONE}),checked:e=>e.frameRendering.enabled}),A0e=H({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Dp,viewMode:!1,perform:(e,t,r,o)=>{let n=et(t,{type:"frame"});return eo(o.interactiveCanvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:et(t,{type:"frame"})},storeAction:D.NONE}},keyTest:e=>!e[S.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===S.F});fi();f();Y();it();le();Gt();ge();ft();Ei();var o_=8,RI=99999,eh=e=>o_/e,ko=class e{static referenceSnapPoints=null;static visibleGaps=null;static setReferenceSnapPoints=t=>{e.referenceSnapPoints=t};static getReferenceSnapPoints=()=>e.referenceSnapPoints;static setVisibleGaps=t=>{e.visibleGaps=t};static getVisibleGaps=()=>e.visibleGaps;static destroy=()=>{e.referenceSnapPoints=null,e.visibleGaps=null}},si=({event:e,appState:t,selectedElements:r})=>e?t.objectsSnapModeEnabled&&!e[S.CTRL_OR_CMD]||!t.objectsSnapModeEnabled&&e[S.CTRL_OR_CMD]&&t.gridSize===null:r.length===1&&r[0].type==="arrow"?!1:t.objectsSnapModeEnabled,n_=(e,t,r=.01)=>Math.abs(e-t)<=r,gd=(e,t,{omitCenter:r,boundingBoxCorners:o,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=ne(a,t);n&&(s+=n.x,c+=n.x,m+=n.x,l+=n.y,d+=n.y,p+=n.y);let u=(c-s)/2,h=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=Pe([s,l+h],[m,p],a.angle),x=Pe([s+u,l],[m,p],a.angle),v=Pe([c,l+h],[m,p],a.angle),y=Pe([s+u,d],[m,p],a.angle);i=r?[g,x,v,y]:[g,x,v,y,[m,p]]}else{let g=Pe([s,l],[m,p],a.angle),x=Pe([c,l],[m,p],a.angle),v=Pe([s,d],[m,p],a.angle),y=Pe([c,d],[m,p],a.angle);i=r?[g,x,v,y]:[g,x,v,y,[m,p]]}}else if(e.length>1){let[a,s,l,c]=bm(e,n??{x:0,y:0}),d=l-a,m=c-s,p=[a,s],u=[l,s],h=[a,c],g=[l,c],x=[a+d/2,s+m/2];i=r?[p,u,h,g]:[p,u,h,g,x]}return i.map(a=>[ut(a[0]),ut(a[1])])},BI=(e,t,r,o)=>{let n=t.filter(i=>re(i)).map(i=>i.id);return mf(e,t,r,o).filter(i=>!(i.frameId&&n.includes(i.frameId)))},FI=(e,t,r,o)=>{let n=BI(e,t,r,o),i=Ta(n,o).filter(m=>!(m.length===1&&Me(m[0]))).map(m=>we(m).map(p=>ut(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>RI)break e;let h=a[u],[,g,x,v]=p,[y,w,,I]=h;x<y&&Xl([g,v],[w,I])&&s.push({startBounds:p,endBounds:h,startSide:[[x,g],[x,v]],endSide:[[y,w],[y,I]],length:y-x,overlap:Zl([g,v],[w,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>RI)break e;let h=c[u],[g,,x,v]=p,[y,w,I]=h;v<w&&Xl([g,x],[y,I])&&d.push({startBounds:p,endBounds:h,startSide:[[g,v],[x,v]],endSide:[[y,w],[I,w]],length:w-v,overlap:Zl([g,x],[y,I])})}}return{horizontalGaps:s,verticalGaps:d}},NI=(e,t,r,o,n,i,a)=>{if(!si({appState:r,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=ko.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=bm(e,t).map(x=>ut(x)),h=(d+p)/2,g=(m+u)/2;for(let x of l){if(!Xl([m,u],x.overlap))continue;let v=x.startSide[0][0]+x.length/2,y=ut(v-h);if(x.length>p-d&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(n.length=0),a.x=Math.abs(y);let k={type:"gap",direction:"center_horizontal",gap:x,offset:y};n.push(k);continue}let[,,I]=x.endBounds,A=d-I,C=ut(x.length-A);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(n.length=0),a.x=Math.abs(C);let k={type:"gap",direction:"side_right",gap:x,offset:C};n.push(k);continue}let[L,,,]=x.startBounds,M=L-p,z=ut(M-x.length);if(Math.abs(z)<=a.x){Math.abs(z)<a.x&&(n.length=0),a.x=Math.abs(z);let k={type:"gap",direction:"side_left",gap:x,offset:z};n.push(k);continue}}for(let x of c){if(!Xl([d,p],x.overlap))continue;let v=x.startSide[0][1]+x.length/2,y=ut(v-g);if(x.length>u-m&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let k={type:"gap",direction:"center_vertical",gap:x,offset:y};i.push(k);continue}let[,I,,]=x.startBounds,A=I-u,C=ut(A-x.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let k={type:"gap",direction:"side_top",gap:x,offset:C};i.push(k);continue}let[,,,L]=x.endBounds,M=ut(m-L),z=x.length-M;if(Math.abs(z)<=a.y){Math.abs(z)<a.y&&(i.length=0),a.y=Math.abs(z);let k={type:"gap",direction:"side_bottom",gap:x,offset:z};i.push(k);continue}}}},zI=(e,t,r,o)=>{let n=BI(e,t,r,o);return Ta(n,o).filter(i=>!(i.length===1&&Me(i[0]))).flatMap(i=>gd(i,o))},Dl=(e,t,r,o,n,i,a)=>{if(!si({appState:r,event:o,selectedElements:e})||e.length===0&&t.length===0)return[];let s=ko.getReferenceSnapPoints();if(s)for(let l of t)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&&(n.length=0),n.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))}},HI=(e,t,r,o,n)=>{let i=pe(e,r);if(!si({appState:r,event:o,selectedElements:i})||i.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=ut(t.x),t.y=ut(t.y);let a=[],s=[],l=eh(r.zoom.value),c={x:l,y:l},d=gd(i,n,{dragOffset:t});Dl(i,d,r,o,a,s,c),NI(i,t,r,o,a,s,c);let m={x:a[0]?.offset??0,y:s[0]?.offset??0};c.x=0,c.y=0,a.length=0,s.length=0;let p={x:ut(t.x+m.x),y:ut(t.y+m.y)};Dl(i,gd(i,n,{dragOffset:p}),r,o,a,s,c),NI(i,p,r,o,a,s,c);let u=OE(a,s),h=a_(i,p,[...a,...s].filter(g=>g.type==="gap"));return{snapOffset:m,snapLines:[...u,...h]}},ut=e=>Math.round(e*10**6)/10**6,OI=e=>{let t=new Map;for(let r of e){let o=r.join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},OE=(e,t)=>{let r={},o={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=ut(n.points[0][0]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>[ut(a[0]),ut(a[1])]))}}if(t.length>0){for(let n of t)if(n.type==="point"){let i=ut(n.points[0][1]);o[i]||(o[i]=[]),o[i].push(...n.points.map(a=>[ut(a[0]),ut(a[1])]))}}return Object.entries(r).map(([n,i])=>({type:"points",points:OI(i.map(a=>[Number(n),a[1]]).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([n,i])=>({type:"points",points:OI(i.map(a=>[a[0],Number(n)]).sort((a,s)=>a[0]-s[0]))})))},i_=e=>{let t=new Map;for(let r of e){let o=r.points.flat().map(n=>[ut(n)]).join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},a_=(e,t,r)=>{let[o,n,i,a]=bm(e,t),s=[];for(let l of r){let[c,d,m,p]=l.gap.startBounds,[u,h,g,x]=l.gap.endBounds,v=Zl([n,a],l.gap.overlap),y=Zl([o,i],l.gap.overlap);switch(l.direction){case"center_horizontal":{if(v){let w=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[[l.gap.startSide[0][0],w],[o,w]]},{type:"gap",direction:"horizontal",points:[[i,w],[l.gap.endSide[0][0],w]]})}break}case"center_vertical":{if(y){let w=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[[w,l.gap.startSide[0][1]],[w,n]]},{type:"gap",direction:"vertical",points:[[w,a],[w,l.gap.endSide[0][1]]]})}break}case"side_right":{if(v){let w=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[[m,w],[u,w]]},{type:"gap",direction:"horizontal",points:[[g,w],[o,w]]})}break}case"side_left":{if(v){let w=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[[i,w],[c,w]]},{type:"gap",direction:"horizontal",points:[[m,w],[u,w]]})}break}case"side_top":{if(y){let w=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[[w,a],[w,d]]},{type:"gap",direction:"vertical",points:[[w,p],[w,h]]})}break}case"side_bottom":{if(y){let w=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[[w,p],[w,h]]},{type:"gap",direction:"vertical",points:[[w,x],[w,n]]})}break}}}return i_(s.map(l=>({...l,points:l.points.map(c=>[ut(c[0]),ut(c[1])])})))},UI=(e,t,r,o,n,i)=>{if(!si({event:o,selectedElements:e,appState:r})||e.length===0||e.length===1&&!n_(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=we(t);i&&(i.includes("e")?l+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?s+=n.y:i.includes("s")&&(c+=n.y));let d=[];if(i)switch(i){case"e":{d.push([l,s],[l,c]);break}case"w":{d.push([a,s],[a,c]);break}case"n":{d.push([a,s],[l,s]);break}case"s":{d.push([a,c],[l,c]);break}case"ne":{d.push([l,s]);break}case"nw":{d.push([a,s]);break}case"se":{d.push([l,c]);break}case"sw":{d.push([a,c]);break}}let m=eh(r.zoom.value),p={x:m,y:m},u=[],h=[];Dl(t,d,r,o,u,h,p);let g={x:u[0]?.offset??0,y:h[0]?.offset??0};p.x=0,p.y=0,u.length=0,h.length=0;let[x,v,y,w]=we(e).map(C=>ut(C));Dl(e,[[x,v],[x,w],[y,v],[y,w]],r,o,u,h,p);let A=OE(u,h);return{snapOffset:g,snapLines:A}},GI=(e,t,r,o,n,i)=>{if(!si({event:r,selectedElements:[e],appState:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[[o.x+n.x,o.y+n.y]],s=eh(t.zoom.value),l={x:s,y:s},c=[],d=[];Dl([e],a,t,r,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=gd([e],i,{boundingBoxCorners:!0,omitCenter:!0});Dl([e],p,t,r,c,d,l);let u=OE(c,d);return{snapOffset:m,snapLines:u}},WI=(e,t,r,o,n)=>{if(!si({event:o,selectedElements:[],appState:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=mf(e,[],t,n),a=eh(t.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=gd([d],n);for(let p of m){let u=p[0]-r.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,[p[0],r.y]],direction:"vertical"}),s.x=u);let h=p[1]-r.y;Math.abs(h)<=Math.abs(s.y)&&(Math.abs(h)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,[r.x,p[1]]],direction:"horizontal"}),s.y=h)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-r.x:0,y:l.length>0?l[0].points[0][1]-r.y:0},snapLines:[...c,...l]}},VI=e=>e===xt.rectangle||e===xt.ellipse||e===xt.diamond||e===xt.frame||e===xt.magicframe||e===xt.image||e===xt.text;f();import{jsx as Mo,jsxs as YI}from"react/jsx-runtime";var s_=()=>YI("div",{"data-testid":"brave-measure-text-error",children:[Mo("p",{children:Mo(Tr,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Mo("span",{style:{fontWeight:600},children:e})})}),Mo("p",{children:Mo(Tr,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Mo("span",{style:{fontWeight:600},children:e})})}),Mo("p",{children:Mo(Tr,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Mo("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Mo("p",{children:Mo(Tr,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Mo("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>YI("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),KI=s_;f();Y();be();_r();jo();Je();G();ps();zo();ho();var th={width:100,height:0},ji=100,l_=(e,t,r)=>{let o=Wt({x:0,y:0,textAlign:mi.CENTER,verticalAlign:St.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:o.id})}),Ot(o,e,r),[e,o]},$I=(e,t,r,o,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let d=t?.width??ji,m=t?.height??ji,p;t.id&&(p=o.getElement(t.id),p||console.error(`No element for start binding with id ${t.id} found`));let u=t.x||e.x-d,h=t.y||e.y-m/2,g=p?p.type:t.type;if(g){if(g==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Wt({x:u,y:h,type:"text",...p,...t,text:x}),Object.assign(i,{x:t.x||e.x-i.width,y:t.y||e.y-i.height/2})}else switch(g){case"rectangle":case"ellipse":case"diamond":{i=to({x:u,y:h,width:d,height:m,...p,...t,type:g});break}default:Fo(e,`Unhandled element start type "${t.type}"`,!0)}ba(e,i,"start",n)}}if(r){let d=r?.height??ji,m=r?.width??ji,p;r.id&&(p=o.getElement(r.id),p||console.error(`No element for end binding with id ${r.id} found`));let u=r.x||e.x+e.width,h=r.y||e.y-d/2,g=p?p.type:r.type;if(g){if(g==="text"){let x="";p&&p.type==="text"?x=p.text:r.type==="text"&&(x=r.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Wt({x:u,y:h,type:"text",...p,...r,text:x}),Object.assign(a,{y:r.y||e.y-a.height/2})}else switch(g){case"rectangle":case"ellipse":case"diamond":{a=to({x:u,y:h,width:m,height:d,...p,...r,type:g});break}default:Fo(e,`Unhandled element end type "${g}"`,!0)}ba(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let s=e.points.length-1,l=.5,c=ln(e.points);return e.points[s][0]>e.points[s-1][0]&&(c[0][0]=l,c[s][0]-=l),e.points[s][0]<e.points[s-1][0]&&(c[0][0]=-l,c[s][0]+=l),e.points[s][1]>e.points[s-1][1]&&(c[0][1]=l,c[s][1]-=l),e.points[s][1]<e.points[s-1][1]&&(c[0][1]=-l,c[s][1]+=l),Object.assign(e,{points:c}),{linearElement:e,startBoundElement:i,endBoundElement:a}},BE=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>yr(Array.from(this.excalidrawElements.values()));getElementsMap=()=>Zr(X(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},Cl=(e,t)=>{if(!e)return[];let r=ln(e),o=new BE,n=new Map,i=new Map;for(let s of r){let l,c=s.id;switch(t?.regenerateIds!==!1&&Object.assign(s,{id:Nt()}),s.type){case"rectangle":case"ellipse":case"diamond":{let m=s?.label?.text&&s.width===void 0?0:s?.width||ji,p=s?.label?.text&&s.height===void 0?0:s?.height||ji;l=to({...s,width:m,height:p});break}case"line":{let m=s.width||th.width,p=s.height||th.height;l=fo({width:m,height:p,points:[[0,0],[m,p]],...s});break}case"arrow":{let m=s.width||th.width,p=s.height||th.height;l=fo({width:m,height:p,endArrowhead:"arrow",points:[[0,0],[m,p]],...s}),Object.assign(l,ms(l.points));break}case"text":{let m=s?.fontFamily||Zt,p=s?.fontSize||Tt,u=s?.lineHeight||qr(m),h=s.text??"",g=Ii(h),x=Bt(g,Ie({fontFamily:m,fontSize:p}),u);l=Wt({width:x.width,height:x.height,fontFamily:m,fontSize:p,...s});break}case"image":{l=cc({width:s?.width||ji,height:s?.height||ji,...s});break}case"frame":{l=km({x:0,y:0,...s});break}case"magicframe":{l=lc({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{l=s;break}default:l=s,Fo(s,`Unhandled element type "${s.type}"`,!0)}o.getElement(l.id)?console.error(`Duplicate id found for ${l.id}`):(o.add(l),n.set(l.id,s),c&&i.set(c,l.id))}let a=o.getElementsMap();for(let[s,l]of n){let c=o.getElement(s);switch(l.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(l.label?.text){let[d,m]=l_(c,l?.label,a);if(o.add(d),o.add(m),d.type==="arrow"){let p=l.type==="arrow"?l?.start:void 0,u=l.type==="arrow"?l?.end:void 0;if(p&&p.id){let v=i.get(p.id);v&&Object.assign(p,{id:v})}if(u&&u.id){let v=i.get(u.id);v&&Object.assign(u,{id:v})}let{linearElement:h,startBoundElement:g,endBoundElement:x}=$I(d,p,u,o,a);d=h,o.add(h),o.add(g),o.add(x)}}else switch(l.type){case"arrow":{let{start:d,end:m}=l;if(d&&d.id){let g=i.get(d.id);Object.assign(d,{id:g})}if(m&&m.id){let g=i.get(m.id);Object.assign(m,{id:g})}let{linearElement:p,startBoundElement:u,endBoundElement:h}=$I(c,d,m,o,a);o.add(p),o.add(u),o.add(h);break}}break}}}for(let[s,l]of n){if(l.type!=="frame"&&l.type!=="magicframe")continue;let c=o.getElement(s);if(!c)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let d=[];l.children.forEach(y=>{let w=i.get(y);if(!w)throw new Error(`Element with ${y} wasn't mapped correctly`);let I=o.getElement(w);if(!I)throw new Error(`Frame element with id ${w} doesn't exist`);Object.assign(I,{frameId:c.id}),I?.boundElements?.forEach(A=>{let C=o.getElement(A.id);if(!C)throw new Error(`Bound element with id ${A.id} doesn't exist`);Object.assign(C,{frameId:c.id}),d.push(C)}),d.push(I)});let[m,p,u,h]=we(d),g=10;m=m-g,p=p-g,u=u+g,h=h+g;let x=Math.max(c?.width,u-m),v=Math.max(c?.height,h-p);Object.assign(c,{x:m,y:p,width:x,height:v})}return o.getElements()};f();f();G();Y();import S_,{useEffect as I_,useRef as C_}from"react";f();G();import{unstable_batchedUpdates as XI}from"react-dom";import{version as c_}from"react";var dt=e=>t=>{XI(e,t)},rh=e=>cs(t=>{XI(e,t)}),oh=(()=>{let e;try{let r=c_.split(".");e=Number(r[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();f();be();Hn();Gt();Dc();G();Y();f();Y();var d_="#ff6b6b",m_="#ff0000",ZI=1,jI=2,qI=(e,t)=>{if(!t.snapLines.length)return;let r=t.theme===ce.LIGHT||t.zenModeEnabled?d_:m_,o=(t.zenModeEnabled?ZI*1.5:ZI)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let n of t.snapLines)n.type==="pointer"?(e.lineWidth=o,e.strokeStyle=r,u_(n,e,t)):n.type==="gap"?(e.lineWidth=o,e.strokeStyle=r,h_(n.points[0],n.points[1],n.direction,t,e)):n.type==="points"&&(e.lineWidth=o,e.strokeStyle=r,p_(n,e,t));e.restore()},p_=(e,t,r)=>{if(!r.zenModeEnabled){let o=e.points[0],n=e.points[e.points.length-1];Lo(o,n,t)}for(let o of e.points)JI(o,r,t)},u_=(e,t,r)=>{JI(e.points[0],r,t),r.zenModeEnabled||Lo(e.points[0],e.points[1],t)},JI=([e,t],r,o)=>{o.save();let n=(r.zenModeEnabled?jI*1.5:jI)/r.zoom.value;o.beginPath(),o.moveTo(e-n,t-n),o.lineTo(e+n,t+n),o.moveTo(e+n,t-n),o.lineTo(e-n,t+n),o.stroke(),o.restore()},Lo=(e,t,r)=>{r.beginPath(),r.lineTo(...e),r.lineTo(...t),r.stroke()},h_=(e,t,r,o,n)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(r==="horizontal"){let l=[(e[0]+t[0])/2,e[1]];o.zenModeEnabled||Lo([e[0],e[1]-i],[e[0],e[1]+i],n),Lo([l[0]-s,l[1]-a],[l[0]-s,l[1]+a],n),Lo([l[0]+s,l[1]-a],[l[0]+s,l[1]+a],n),o.zenModeEnabled||(Lo([t[0],t[1]-i],[t[0],t[1]+i],n),Lo(e,t,n))}else{let l=[e[0],(e[1]+t[1])/2];o.zenModeEnabled||Lo([e[0]-i,e[1]],[e[0]+i,e[1]],n),Lo([l[0]-a,l[1]-s],[l[0]+a,l[1]-s],n),Lo([l[0]-a,l[1]+s],[l[0]+a,l[1]+s],n),o.zenModeEnabled||(Lo([t[0]-i,t[1]],[t[0]+i,t[1]],n),Lo(e,t,n))}};_r();Jt();Hg();le();import nh from"open-color";var g_=(e,t,r)=>{let{elementId:o,hoverPointIndex:n}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=j.getElement(o,r);if(!i)return;let a=j.getPointAtIndexGlobalCoordinates(i,n,r);e.save(),e.translate(t.scrollX,t.scrollY),zE(a,e,t),e.restore()},zE=(e,t,r)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",Cc(t,e[0],e[1],j.POINT_HANDLE_SIZE/r.zoom.value,!1)},fd=(e,t,r,o,n,i,a,s,l=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(s),l&&e.fillRect(t-i,r-a,o,n),c&&e.roundRect?(e.beginPath(),e.roundRect(t-i,r-a,o,n,c),e.stroke(),e.closePath()):e.strokeRect(t-i,r-a,o,n),e.restore()},f_=(e,t,r,o,n,i)=>{e.save(),e.translate(o,n),e.rotate(i),e.beginPath(),e.moveTo(0,r/2),e.lineTo(t/2,0),e.lineTo(0,-r/2),e.lineTo(-t/2,0),e.closePath(),e.stroke(),e.restore()},ih=(e,t,r,o,n,i=!1)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Cc(e,r[0],r[1],o/t.zoom.value,!i)},b_=(e,t,r,o,n,i)=>{e.beginPath(),e.ellipse(o,n,t/2,r/2,i,0,Math.PI*2),e.stroke()},E_=(e,t,r)=>{let[o,n,i,a]=ne(t,r),s=i-o,l=a-n,c=nc(t,s,l),d=4;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=c-d;let m=d/2+c/2;switch(t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":fd(e,o-m,n-m,s+m*2,l+m*2,o+s/2,n+l/2,t.angle);break;case"diamond":let p=Math.hypot(s,l),u=m*p/l,h=m*p/s;f_(e,s+u*2,l+h*2,o+s/2,n+l/2,t.angle);break;case"ellipse":b_(e,s+m*2,l+m*2,o+s/2,n+l/2,t.angle);break}},x_=(e,t,r)=>{let[o,n,i]=t,a=nc(i,i.width,i.height);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(n==="both"?[0,-1]:n==="start"?[0]:[-1]).forEach(l=>{let[c,d]=j.getPointAtIndexGlobalCoordinates(o,l,r);Cc(e,c,d,a)})},eC=(e,t,r)=>{let{angle:o,elementX1:n,elementY1:i,elementX2:a,elementY2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=r,u=a-n,h=s-i,x=Nn*2/t.zoom.value,v=8/t.zoom.value,y=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(p?4:1)/t.zoom.value;let w=l.length;for(let I=0;I<w;++I)e.strokeStyle=l[I],m&&e.setLineDash([v,y+(v+y)*(w-1)]),e.lineDashOffset=(v+y)*I,fd(e,n-x,i-x,u+x*2,h+x*2,c,d,o);e.restore()},y_=(e,t,r,o)=>{let n=Array.isArray(r)?x_:E_;e.save(),e.translate(t.scrollX,t.scrollY),n(e,r,o),e.restore()},w_=(e,t,r,o)=>{let[n,i,a,s]=ne(r,o),l=a-n,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=qe.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),fd(e,n,i,l,c,n+l/2,i+c/2,r.angle,!1,qe.radius/t.zoom.value),e.restore()},v_=(e,t,r)=>{let o=r.filter(s=>s.groupIds.length===0),n=r.filter(s=>s.groupIds.length>0),i=s=>{let[l,c,d,m]=we(s);return{angle:0,elementX1:l,elementX2:d,elementY1:c,elementY2:m,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:l+(d-l)/2,cy:c+(m-c)/2,activeEmbeddable:!1}},a=s=>{let l=Qe(r,s);return i(l)};Object.entries(ym(n,t)).filter(([s,l])=>l).map(([s,l])=>s).map(s=>a(s)).concat(o.map(s=>i([s]))).forEach(s=>eC(e,t,s))},FE=(e,t,r,o)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let n=j.getPointsGlobalCoordinates(r,o),{POINT_HANDLE_SIZE:i}=j,a=t.editingLinearElement?i:i/2;n.forEach((l,c)=>{let d=!!t.editingLinearElement?.selectedPointsIndices?.includes(c);ih(e,t,l,a,d)}),j.getEditorMidPoints(r,o,t).filter(l=>l!==null).forEach(l=>{t?.selectedLinearElement?.segmentMidPointHoveredCoords&&j.arePointsEqual(l,t.selectedLinearElement.segmentMidPointHoveredCoords)?t.editingLinearElement?(ih(e,t,l,a,!1),zE(l,e,t)):(zE(l,e,t),ih(e,t,l,a,!1)):(t.editingLinearElement||n.length===2)&&ih(e,t,l,i/2,!1,!0)}),e.restore()},QI=(e,t,r,o,n)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/r.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?Cc(e,s+c/2,l+d/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/r.zoom.value),e.fill(),e.stroke()):fd(e,s,l,c,d,s+c/2,l+d/2,n,!0),e.restore()}})},T_=(e,t,r,o)=>{t.save();let n=Nn*2/r.zoom.value,i=e.width+n*2,a=e.height+n*2,s=e.x+i/2,l=e.y+a/2,c=-(i/2+n),d=-(a/2+n);t.translate(s+r.scrollX,l+r.scrollY),t.rotate(e.angle),t.lineWidth=1/r.zoom.value,t.strokeStyle=o,t.strokeRect(c,d,i,a),t.restore()},tC=({canvas:e,elementsMap:t,visibleElements:r,selectedElements:o,allElementsMap:n,scale:i,appState:a,renderConfig:s,device:l})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[c,d]=Xm(e,i),m=Zm({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:d});m.save(),m.scale(a.zoom.value,a.zoom.value);let p;if(r.forEach(g=>{a.editingLinearElement?.elementId===g.id&&g&&(p=g)}),p&&FE(m,a,p,t),a.selectionElement)try{hw(a.selectionElement,m,a,s.selectionColor)}catch(g){console.error(g)}if(a.editingElement&&U(a.editingElement)){let g=n.get(a.editingElement.id);g&&!g.autoResize&&T_(g,m,a,s.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(g=>g!=null).forEach(g=>{y_(m,a,g,t)}),a.frameToHighlight&&w_(m,a,a.frameToHighlight,t),a.elementsToHighlight&&v_(m,a,a.elementsToHighlight);let u=o.some(g=>re(g));if(o.length===1&&a.editingLinearElement?.elementId===o[0].id&&FE(m,a,o[0],t),a.selectedLinearElement&&a.selectedLinearElement.hoverPointIndex>=0&&g_(m,a,t),!a.multiElement&&!a.editingLinearElement){let g=fp(o,a);o.length===1&&ie(o[0])&&a.selectedLinearElement?.elementId===o[0].id&&!o[0].locked&&FE(m,a,o[0],t);let v=s.selectionColor||nh.black;if(g){let y=X(o),w=[];for(let A of t.values()){let C=[];y.has(A.id)&&!xm(a,A)&&C.push(v);let L=s.remoteSelectedElementIds.get(A.id);if(L&&C.push(...L.map(M=>Ya(M,a.collaborators.get(M)))),C.length){let[M,z,k,N,B,_]=ne(A,t,!0);w.push({angle:A.angle,elementX1:M,elementY1:z,elementX2:k,elementY2:N,selectionColors:C,dashed:!!L,cx:B,cy:_,activeEmbeddable:a.activeEmbeddable?.element===A&&a.activeEmbeddable.state==="active"})}}let I=A=>{let C=Qe(t,A),[L,M,z,k]=we(C);w.push({angle:0,elementX1:L,elementX2:z,elementY1:M,elementY2:k,selectionColors:[nh.black],dashed:!0,cx:L+(z-L)/2,cy:M+(k-M)/2,activeEmbeddable:!1})};for(let A of Ko(a))I(A);a.editingGroupId&&I(a.editingGroupId),w.forEach(A=>eC(m,a,A))}if(m.save(),m.translate(a.scrollX,a.scrollY),o.length===1){m.fillStyle=nh.white;let y=Pc(o[0],a.zoom,t,"mouse",Da(l));!a.viewModeEnabled&&g&&!U(a.editingElement)&&QI(m,s,a,y,o[0].angle)}else if(o.length>1&&!a.isRotating){let y=Nn*2/a.zoom.value;m.fillStyle=nh.white;let[w,I,A,C]=we(o),L=m.getLineDash();m.setLineDash([2/a.zoom.value]);let M=m.lineWidth;m.lineWidth=1/a.zoom.value,m.strokeStyle=v,fd(m,w-y,I-y,A-w+y*2,C-I+y*2,(w+A)/2,(I+C)/2,0),m.lineWidth=M,m.setLineDash(L);let z=Xs([w,I,A,C,(w+A)/2,(I+C)/2],0,a.zoom,"mouse",u?{...Da(l),rotation:!0}:Da(l));o.some(k=>!k.locked)&&QI(m,s,a,z,0)}m.restore()}qI(m,a),m.restore(),gT({context:m,renderConfig:s,appState:a,normalizedWidth:c,normalizedHeight:d});let h;return s.renderScrollbars&&(h=Z3(r,c,d,a),m.save(),m.fillStyle=X3,m.strokeStyle="rgba(255,255,255,0.8)",[h.horizontal,h.vertical].forEach(g=>{g&&Zp(m,g.x,g.y,g.width,g.height,kn/2)}),m.restore()),{scrollBars:h,atLeastOneVisibleElement:r.length>0,elementsMap:t}},HE=cs(e=>{let t=tC(e);e.callback?.(t)},{trailing:!0}),rC=(e,t)=>{if(t){HE(e);return}let r=tC(e);return e.callback(r),r};import{jsx as M_}from"react/jsx-runtime";var A_=e=>{let t=C_(!1);return I_(()=>{if(!t.current){t.current=!0;return}let r=new Map,o=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((l,c)=>{if(l.selectedElementIds)for(let d of Object.keys(l.selectedElementIds))n.has(d)||n.set(d,[]),n.get(d).push(c);!l.pointer||l.pointer.renderCursor===!1||(l.username&&i.set(c,l.username),l.userState&&a.set(c,l.userState),o.set(c,Ht({sceneX:l.pointer.x,sceneY:l.pointer.y},e.appState)),r.set(c,l.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";rC({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:o,remotePointerButton:r,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:s,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},oh())}),M_("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Ne.GRAB:Ne.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:E("labels.drawingCanvas")})},oC=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingElement:e.editingElement}),k_=(e,t)=>e.selectionNonce!==t.selectionNonce||e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements?!1:tt(oC(e.appState),oC(t.appState)),UE=S_.memo(A_,k_);f();Jm();G();import L_,{useEffect as P_,useRef as nC}from"react";import{jsx as R_}from"react/jsx-runtime";var D_=e=>{let t=nC(null),r=nC(!1);return P_(()=>{let o=t.current;if(!o)return;let n=e.canvas;r.current||(r.current=!0,o.replaceChildren(n),n.classList.add("excalidraw__canvas","static"));let i=`${e.appState.width}px`,a=`${e.appState.height}px`;n.style.width!==i&&(n.style.width=i),n.style.height!==a&&(n.style.height=a);let s=e.appState.width*e.scale,l=e.appState.height*e.scale;n.width!==s&&(n.width=s),n.height!==l&&(n.height=l),qm({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},oh())}),R_("div",{className:"excalidraw__canvas-wrapper",ref:t})},iC=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId}),__=(e,t)=>e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:tt(iC(e.appState),iC(t.appState))&&tt(e.renderConfig,t.renderConfig),GE=L_.memo(D_,__);f();Pa();le();Jm();G();var bd=class{scene;constructor(t){this.scene=t}getRenderableElements=(()=>{let t=({elementsMap:o,zoom:n,offsetLeft:i,offsetTop:a,scrollX:s,scrollY:l,height:c,width:d})=>{let m=[];for(let p of o.values())La(p,d,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:s,scrollY:l},o)&&m.push(p);return m},r=({elements:o,editingElement:n,pendingImageElementId:i})=>{let a=Zr(new Map);for(let s of o)mo(s)&&i===s.id||(!n||n.type!=="text"||s.id!==n.id)&&a.set(s.id,s);return a};return m1(({zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:s,height:l,width:c,editingElement:d,pendingImageElementId:m,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),h=r({elements:u,editingElement:d,pendingImageElementId:m}),g=t({elementsMap:h,zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:s,height:l,width:c});return{elementsMap:h,visibleElements:g}})})();destroy(){HE.cancel(),Ug.cancel(),this.getRenderableElements.clear()}};pn();f();import{useEffect as N_,useRef as O_}from"react";import{jsx as aC}from"react/jsx-runtime";var sC=({trails:e})=>{let t=O_(null);return N_(()=>{if(t.current)for(let r of e)r.start(t.current);return()=>{for(let r of e)r.stop()}},e),aC("div",{className:"SVGLayer",children:aC("svg",{ref:t})})};Ls();hc();f();G();be();import{jsx as z_}from"react/jsx-runtime";var B_=5,F_=(e,t,r)=>{let[o,n]=ne(e,r),{x:i,y:a}=Ht({sceneX:o+e.width,sceneY:n},t),s=i-t.offsetLeft+10,l=a-t.offsetTop;return{x:s,y:l}},WE=({children:e,element:t,elementsMap:r})=>{let o=Hi();if(o.contextMenu||o.draggingElement||o.resizingElement||o.isRotating||o.openMenu||o.viewModeEnabled)return null;let{x:n,y:i}=F_(t,o,r);return z_("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:B_},children:e})};f();Y();var H_=`You are a skilled front-end developer who builds interactive prototypes from wireframes, and is an expert at CSS Grid and Flex design.
|
|
60
|
+
C -->|Three| F[Car]`,h5=ii(em,300),pR=({mermaidToExcalidrawLib:e})=>{let[t,r]=p5(()=>ro.get(To.MERMAID_TO_EXCALIDRAW)||mR),o=dR(t.trim()),[n,i]=p5(null),a=u5(null),s=u5({elements:[],files:null}),l=tr();g5(()=>{th({canvasRef:a,data:s,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:o}).catch(d=>{_0()&&console.error("Failed to parse mermaid definition",d)}),h5(o)},[o,e]),g5(()=>()=>{h5.flush()},[]);let c=()=>{rh({app:l,data:s,text:t,shouldSaveMermaidDataToStorage:!0})};return f5(uR,{children:[Jn("div",{className:"ttd-dialog-desc",children:Jn(Br,{i18nKey:"mermaid.description",flowchartLink:d=>Jn("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>Jn("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>Jn("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),f5(oh,{children:[Jn(sc,{label:E("mermaid.syntax"),children:Jn(nh,{input:t,placeholder:"Write Mermaid diagram defintion here...",onChange:d=>r(d.target.value),onKeyboardSubmit:()=>{c()}})}),Jn(sc,{label:E("mermaid.preview"),panelAction:{action:()=>{c()},label:E("mermaid.button"),icon:Ks},renderSubmitShortcut:()=>Jn(sh,{}),children:Jn(ah,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},b5=pR;import{useEffect as hR,useRef as $1,useState as ch}from"react";f();import*as E5 from"@radix-ui/react-tabs";import{jsx as gR}from"react/jsx-runtime";var K1=({children:e,...t})=>gR(E5.List,{className:"ttd-dialog-triggers",...t,children:e});K1.displayName="TTDDialogTabTriggers";f();import*as y5 from"@radix-ui/react-tabs";import{jsx as x5}from"react/jsx-runtime";var lh=({children:e,tab:t,onSelect:r,...o})=>x5(y5.Trigger,{value:t,asChild:!0,onSelect:r,children:x5("button",{type:"button",className:"ttd-dialog-tab-trigger",...o,children:e})});lh.displayName="TTDDialogTabTrigger";ee();V();import{atom as v5,useAtom as w5}from"jotai";import{jsx as Ur,jsxs as wa}from"react/jsx-runtime";var Z1=3,lc=1e3,fR=v5(null),bR=v5(null),j1=e=>{let t=Ue();return t.openDialog?.name!=="ttd"?null:Ur(ER,{...e,tab:t.openDialog.tab})},ER=Di("TTDDialogBase",({tab:e,...t})=>{let r=tr(),o=Oe(),n=$1(null),[i,a]=w5(bR),[s,l]=ch(i?.prompt??""),c=s.trim(),d=I=>{l(I.target.value),a(P=>({generatedResponse:P?.generatedResponse??null,prompt:I.target.value}))},[m,p]=ch(!1),[u,g]=w5(fR),h=async()=>{if(c.length>lc||c.length<Z1||m||u?.rateLimitRemaining===0||"__fallback"in t){c.length<Z1&&M(new Error(`Prompt is too short (min ${Z1} characters)`)),c.length>lc&&M(new Error(`Prompt is too long (max ${lc} characters)`));return}try{p(!0),Ce("ai","generate","ttd");let{generatedResponse:I,error:P,rateLimit:A,rateLimitRemaining:N}=await t.onTextSubmit(c);if(typeof I=="string"&&a(k=>({generatedResponse:I,prompt:k?.prompt??null})),Hh(A)&&Hh(N)&&g({rateLimit:A,rateLimitRemaining:N}),P){M(P);return}if(!I){M(new Error("Generation failed"));return}try{await th({canvasRef:n,data:w,mermaidToExcalidrawLib:v,setError:M,mermaidDefinition:I}),Ce("ai","mermaid parse success","ttd")}catch(k){console.info(`%cTTD mermaid render errror: ${k.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
61
|
+
TTD mermaid definition render errror: ${k.message}`,"color: yellow"),Ce("ai","mermaid parse failed","ttd"),M(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(I){let P=I.message;(!P||P==="Failed to fetch")&&(P="Request failed"),M(new Error(P))}finally{p(!1)}},x=$1(h);x.current=h;let[v,y]=ch({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});hR(()=>{(async()=>{await v.api,y(P=>({...P,loaded:!0}))})()},[v.api]);let w=$1({elements:[],files:null}),[C,M]=ch(null);return Ur(xt,{className:"ttd-dialog",onCloseRequest:()=>{r.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:wa(eh,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?Ur("p",{className:"dialog-mermaid-title",children:E("mermaid.title")}):wa(K1,{children:[Ur(lh,{tab:"text-to-diagram",children:wa("div",{style:{display:"flex",alignItems:"center"},children:[E("labels.textToDiagram"),Ur("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"AI Beta"})]})}),Ur(lh,{tab:"mermaid",children:"Mermaid"})]}),Ur(ic,{className:"ttd-dialog-content",tab:"mermaid",children:Ur(b5,{mermaidToExcalidrawLib:v})}),!("__fallback"in t)&&wa(ic,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[Ur("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),wa(oh,{children:[Ur(sc,{label:E("labels.prompt"),panelAction:{action:h,label:"Generate",icon:Ks},onTextSubmitInProgess:m,panelActionDisabled:c.length>lc||u?.rateLimitRemaining===0,renderTopRight:()=>u?wa("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>Ur(sh,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return wa("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(em(i.generatedResponse),o({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",Ur(Fo,{icon:Ks})]});let I=c.length/lc;return I>.8?wa("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:I>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",lc]}):null},children:Ur(nh,{onChange:d,input:s,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),Ur(sc,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),rh({app:r,data:w})},label:"Insert",icon:Ks},children:Ur(ah,{canvasRef:n,error:C,loaded:v.loaded})})]})]})]})})});f();dt();import{useEffect as F5,useMemo as B5,useState as lN,memo as cN}from"react";ee();import{throttle as dN}from"lodash";f();f();Y();ye();Nn();import{useEffect as S5,useRef as dh,useState as yR}from"react";import wR from"clsx";f();yr();De();kd();He();me();Gt();mt();V();var T5=.01,ao=(e,t)=>!(t==="height"&&H(e)||t==="width"&&H(e)||t==="angle"&&Q(e)),St=(e,t)=>{let r=e+t/2;return r-r%t},cc=(e,t,r)=>Object.keys(e).map(o=>({original:(r??t).get(o),latest:t.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0),xR=(e,t,r,o,n,i,a)=>({x:e+(r-n)/2+(n-r)/2*Math.cos(a)+(o-i)/2*Math.sin(a),y:t+(o-i)/2+(n-r)/2*Math.sin(a)+(i-o)/2*Math.cos(a)}),dc=(e,t,r,o,n,i,a,s=!0)=>{let l=n.get(o.id);if(!l)return;let c={},d=J(l,n);if(d){let u=_l(Me(d),d.lineHeight),g=Dl(d.fontSize,d.lineHeight);e=Math.max(e,u),t=Math.max(t,g)}let{width:m,height:p}=l;if(F(l,{...xR(l.x,l.y,l.width,l.height,e,t,l.angle),width:e,height:t,...Ad(o,e,t,!0)},s),rm(l,n,i,a,{newSize:{width:e,height:t}}),d&&(c={fontSize:d.fontSize},r)){let u={...l,width:e,height:t};c={fontSize:Md(d,n,br(u,d))?.size??d.fontSize}}qt(l,n,a,{oldSize:{width:m,height:p}}),d&&c&&F(d,{fontSize:c.fontSize}),mn(l,n,"e",r)},Cs=(e,t,r,o,n,i,a,s=!0)=>{let l=o.get(r.id);if(!l)return;let[c,d]=[r.x+r.width/2,r.y+r.height/2],[m,p]=xe(r.x,r.y,c,d,r.angle),u=e-m,g=t-p,[h,x]=xe(e,t,c+u,d+g,-r.angle);F(l,{x:h,y:x},s),rm(l,o,n,i);let v=J(r,a);if(v){let y=o.get(v.id);y&&F(y,{x:v.x+u,y:v.y+g},s)}},mc=(e,t)=>{let o=Jo(t).map(n=>ot(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!Ln(n)).forEach(n=>{o.push({[n.id]:!0})}),o},rm=(e,t,r,o,n)=>{ie(e)?es([e],t,r,o,!0,[]):qt(e,t,o,n)};Re();V();import{jsx as q1,jsxs as TR}from"react/jsx-runtime";var vR=({label:e,icon:t,dragInputCallback:r,value:o,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c})=>{let d=tr(),m=dh(null),p=dh(null),[u,g]=yR(o.toString()),h=dh(null);h.current||(h.current={originalAppState:Xr(c),originalElements:n,lastUpdatedValue:u,updatePending:!1}),S5(()=>{let y=o.toString();g(y),h.current.lastUpdatedValue=y},[o]);let x=(y,w,C)=>{if(!h.current.updatePending)return!1;h.current.updatePending=!1;let M=Number(y);if(isNaN(M)){g(o.toString());return}let I=Number(M.toFixed(2)),P=Number(o);(isNaN(P)||Math.abs(I-P)>=T5)&&(h.current.lastUpdatedValue=y,r({accumulatedChange:0,instantChange:0,originalElements:w,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:I,property:s,originalAppState:C}),d.syncActionResult({storeAction:_.CAPTURE}))},v=dh(x);return v.current=x,S5(()=>{let y=m.current;return()=>{let w=y?.value;w&&v.current(w,h.current.originalElements,h.current.originalAppState)}},[i]),i?TR("div",{className:wR("drag-input-container",!i&&"disabled"),"data-testid":e,children:[q1("div",{className:"drag-input-label",ref:p,onPointerDown:y=>{if(m.current&&i){let w=Number(m.current.value);isNaN(w)&&(w=0);let C=null,M=d.scene.getNonDeletedElements().reduce((k,D)=>(k.set(D.id,an(D)),k),new Map),I=n.map(k=>M.get(k.id)),P=Xr(c),A=null;document.body.classList.add("excalidraw-cursor-resize");let N=k=>{if(A||(A=0),C&&M!==null&&I!==null&&A!==null){let D=k.clientX-C.x;A+=D,r({accumulatedChange:A,instantChange:D,originalElements:I,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:k.shiftKey,property:s,scene:l,originalAppState:P})}C={x:k.clientX,y:k.clientY}};window.addEventListener("pointermove",N,!1),window.addEventListener("pointerup",()=>{window.removeEventListener("pointermove",N,!1),d.syncActionResult({storeAction:_.CAPTURE}),C=null,A=null,I=null,M=null,document.body.classList.remove("excalidraw-cursor-resize")},!1)}},onPointerEnter:()=>{p.current&&(p.current.style.cursor="ew-resize")},children:t?q1(Fo,{icon:t}):e}),q1("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:y=>{if(i){let w=y.target;w instanceof HTMLInputElement&&y.key===S.ENTER&&(x(w.value,n,c),d.focusContainer())}},ref:m,value:u,onChange:y=>{h.current.updatePending=!0,g(y.target.value)},onFocus:y=>{y.target.select(),h.current.originalElements=n,h.current.originalAppState=Xr(c)},onBlur:y=>{u?i&&x(y.target.value,h.current.originalElements,h.current.originalAppState):g(o.toString())},disabled:!i})]}):null},Ir=vR;Y();import{jsx as AR}from"react/jsx-runtime";var I5=10,SR=e=>e.type==="image",IR=({accumulatedChange:e,originalElements:t,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:n,nextValue:i,property:a,scene:s})=>{let l=s.getNonDeletedElementsMap(),c=s.getNonDeletedElements(),d=t[0];if(d){let m=o||SR(d),p=d.width/d.height;if(i!==void 0){let v=Math.max(a==="width"?i:m?i*p:d.width,Vr),y=Math.max(a==="height"?i:m?i/p:d.height,Vr);dc(v,y,m,d,l,c,s);return}let u=a==="width"?e:0,g=a==="height"?e:0,h=Math.max(0,d.width+u);a==="width"&&(n?h=St(h,I5):h=Math.round(h));let x=Math.max(0,d.height+g);a==="height"&&(n?x=St(x,I5):x=Math.round(x)),m&&(a==="width"?x=Math.round(h/p*100)/100:h=Math.round(x*p*100)/100),x=Math.max(Vr,x),h=Math.max(Vr,h),dc(h,x,m,d,l,c,s)}},CR=({property:e,element:t,scene:r,appState:o})=>{let n=Math.round((e==="width"?t.width:t.height)*100)/100;return AR(Ir,{label:e==="width"?"W":"H",elements:[t],dragInputCallback:IR,value:n,editable:ao(t,e),scene:r,appState:o,property:e})},J1=CR;f();De();He();me();mt();ee();import{jsx as LR}from"react/jsx-runtime";var MR=15,kR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:r,nextValue:o,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=n.getNonDeletedElements(),s=t[0];if(s&&!de(s)){let l=i.get(s.id);if(!l)return;if(o!==void 0){let g=Ml(o);F(l,{angle:g}),rm(l,i,a,n);let h=J(l,i);h&&!ne(l)&&F(h,{angle:g});return}let c=Math.round(Al(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;r&&(m=St(m,MR)),m=m<0?m+360:m;let p=Ml(m);F(l,{angle:p}),rm(l,i,a,n);let u=J(l,i);u&&!ne(l)&&F(u,{angle:p})}},PR=({element:e,scene:t,appState:r,property:o})=>LR(Ir,{label:"A",icon:np,value:Math.round(Al(e.angle)%360*100)/100,elements:[e],dragInputCallback:kR,editable:ao(e,"angle"),scene:t,appState:r,property:o}),C5=PR;f();De();ee();we();me();He();import{jsx as NR}from"react/jsx-runtime";var A5=4,DR=4,_R=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:r,nextValue:o,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=t[0];if(a){let s=i.get(a.id);if(!s||!H(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),A5);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,A5),r&&(l=St(l,DR))}l&&(F(s,{fontSize:l}),ft(s,n.getContainerElement(s),n.getNonDeletedElementsMap()))}},RR=({element:e,scene:t,appState:r,property:o})=>{let n=H(e)?e:Ct(e)?J(e,t.getNonDeletedElementsMap()):null;return n?NR(Ir,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:_R,icon:za,appState:r,scene:t,property:o}):null},M5=RR;f();we();yr();De();kd();He();import{useMemo as OR}from"react";Y();import{jsx as UR}from"react/jsx-runtime";var pc=10,FR=(e,t,r,o)=>{let n=o.x-e,i=o.y-t,a=o.width*r,s=o.height*r,l=e+n*r,c=t+i*r;return{width:a,height:s,x:l,y:c,...Ad(o,a,s,!1),...H(o)?{fontSize:o.fontSize*r}:{}}},BR=(e,t,r,o,n,i,a,s,l)=>{let c=FR(e,t,o,i),{width:d,height:m}=n;F(n,c,!1);let p=J(i,s);if(p){let u=p.fontSize*o;qt(n,a,l,{oldSize:{width:d,height:m}});let g=a.get(p.id);g&&H(g)&&(F(g,{fontSize:u},!1),mn(n,a,r==="width"?"e":"s",!0))}},k5=(e,t,r,o,n,i,a,s,l,c,d)=>{i==="width"?t=Math.round(e/o*100)/100:e=Math.round(t*o*100)/100;let m=t/r;for(let p=0;p<s.length;p++){let u=s[p],g=a[p];BR(n[0],n[1],i,m,g,u,l,c,d)}},zR=({accumulatedChange:e,originalElements:t,originalElementsMap:r,originalAppState:o,shouldChangeByStepSize:n,nextValue:i,scene:a,property:s})=>{let l=a.getNonDeletedElementsMap(),c=a.getNonDeletedElements(),d=mc(t,o);if(i!==void 0){for(let u of d){let g=cc(u,l,r);if(g.length>1){let h=g.map(k=>k.latest),x=g.map(k=>k.original),[v,y,w,C]=Te(x),M=w-v,I=C-y,P=M/I,A=Math.max(Vr,s==="width"?Math.max(0,i):M),N=Math.max(Vr,s==="height"?Math.max(0,i):I);k5(A,N,I,P,[v,y],s,h,x,l,r,a)}else{let[h]=g,x=h?.latest,v=h?.original;if(x&&v&&ao(x,s)){let y=s==="width"?Math.max(0,i):x.width;s==="width"&&(n?y=St(y,pc):y=Math.round(y));let w=s==="height"?Math.max(0,i):x.height;s==="height"&&(n?w=St(w,pc):w=Math.round(w)),y=Math.max(Vr,y),w=Math.max(Vr,w),dc(y,w,!1,v,l,c,a,!1)}}}a.triggerUpdate();return}let m=s==="width"?e:0,p=s==="height"?e:0;for(let u of d){let g=cc(u,l,r);if(g.length>1){let h=g.map(k=>k.latest),x=g.map(k=>k.original),[v,y,w,C]=Te(x),M=w-v,I=C-y,P=M/I,A=Math.max(0,M+m);s==="width"&&(n?A=St(A,pc):A=Math.round(A));let N=Math.max(0,I+p);s==="height"&&(n?N=St(N,pc):N=Math.round(N)),A=Math.max(Vr,A),N=Math.max(Vr,N),k5(A,N,I,P,[v,y],s,h,x,l,r,a)}else{let[h]=g,x=h?.latest,v=h?.original;if(x&&v&&ao(x,s)){let y=Math.max(0,v.width+m);s==="width"&&(n?y=St(y,pc):y=Math.round(y));let w=Math.max(0,v.height+p);s==="height"&&(n?w=St(w,pc):w=Math.round(w)),y=Math.max(Vr,y),w=Math.max(Vr,w),dc(y,w,!1,v,l,c,a)}}}a.triggerUpdate()},HR=({property:e,elements:t,elementsMap:r,atomicUnits:o,scene:n,appState:i})=>{let a=OR(()=>o.map(c=>{let d=cc(c,r);if(d.length>1){let[p,u,g,h]=Te(d.map(x=>x.latest));return Math.round((e==="width"?g-p:h-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[r,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return UR(Ir,{label:e==="width"?"W":"H",elements:t,dragInputCallback:zR,value:s,editable:l,appState:i,property:e,scene:n})},Q1=HR;Gt();f();De();He();me();Gt();mt();ee();import{jsx as YR}from"react/jsx-runtime";var GR=15,WR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:r,nextValue:o,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=t.map(c=>a.get(c.id)).filter(c=>c&&!Ln(c)&&ao(c,n)),l=t.filter(c=>!Ln(c)&&ao(c,n));if(o!==void 0){let c=Ml(o);for(let d of s){if(!d)continue;F(d,{angle:c},!1);let m=J(d,a);m&&!ne(d)&&F(m,{angle:c},!1)}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(Al(m.angle)*100)/100,u=Math.round(e),g=(p+u)%360;r&&(g=St(g,GR)),g=g<0?g+360:g;let h=Ml(g);F(d,{angle:h},!1);let x=J(d,a);x&&!ne(d)&&F(x,{angle:h},!1)}i.triggerUpdate()},VR=({elements:e,scene:t,appState:r,property:o})=>{let n=e.filter(l=>!Ln(l)&&ao(l,"angle")),i=n.map(l=>Math.round(Al(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=n.some(l=>ao(l,"angle"));return YR(Ir,{label:"A",icon:np,value:a,elements:e,dragInputCallback:WR,editable:s,appState:r,scene:t,property:o})},P5=VR;f();we();De();me();Gt();ee();He();import{jsx as jR}from"react/jsx-runtime";var L5=4,XR=4,KR=(e,t)=>e.reduce((r,o)=>{if(!o||Ln(o))return r;if(H(o))return r.push(o),r;if(Ct(o)){let n=J(o,t);if(n)return r.push(n),r}return r},[]),$R=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:r,nextValue:o,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=t.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),L5);for(let l of a)F(l,{fontSize:s},!1),ft(l,n.getContainerElement(l),i,!1);n.triggerUpdate()}else{let l=t;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),g=Math.max(p+u,L5);r&&(g=St(g,XR)),F(d,{fontSize:g},!1),ft(d,n.getContainerElement(d),i,!1)}n.triggerUpdate()}},ZR=({elements:e,scene:t,appState:r,property:o,elementsMap:n})=>{let i=KR(e,n);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 jR(Ir,{label:"F",icon:za,elements:i,dragInputCallback:$R,value:s,editable:l,scene:t,property:o,appState:r})},D5=ZR;f();mt();import{jsx as QR}from"react/jsx-runtime";var _5=10,qR=({accumulatedChange:e,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:o,nextValue:n,property:i,scene:a})=>{let s=a.getNonDeletedElementsMap(),l=a.getNonDeletedElements(),c=t[0],[d,m]=[c.x+c.width/2,c.y+c.height/2],[p,u]=xe(c.x,c.y,d,m,c.angle);if(n!==void 0){Cs(i==="x"?n:p,i==="y"?n:u,c,s,l,a,r);return}let g=i==="x"?e:0,h=i==="y"?e:0,x=i==="x"?Math.round(o?St(c.x+g,_5):p+g):p,v=i==="y"?Math.round(o?St(c.y+h,_5):u+h):u;Cs(x,v,c,s,l,a,r)},JR=({property:e,element:t,elementsMap:r,scene:o,appState:n})=>{let[i,a]=xe(t.x,t.y,t.x+t.width/2,t.y+t.height/2,t.angle),s=Math.round((e==="x"?i:a)*100)/100;return QR(Ir,{label:e==="x"?"X":"Y",elements:[t],dragInputCallback:qR,scene:o,value:s,property:e,appState:n})},ex=JR;f();mt();we();import{useMemo as eN}from"react";import{jsx as aN}from"react/jsx-runtime";var tN=10,rN=(e,t,r,o,n,i,a,s)=>{for(let l=0;l<o.length;l++){let c=n[l],[d,m]=[c.x+c.width/2,c.y+c.height/2],[p,u]=xe(c.x,c.y,d,m,c.angle),g=e==="x"?Math.round(p+t):p,h=e==="y"?Math.round(u+r):u;Cs(g,h,c,i,o,s,a,!1)}},oN=(e,t,r,o,n,i,a)=>{let[s,l,,]=Te(r),c=e-s,d=t-l;for(let m=0;m<r.length;m++){let p=r[m],u=o.get(p.id);if(u&&(!H(u)||!u.containerId)){let[g,h]=[u.x+u.width/2,u.y+u.height/2],[x,v]=xe(u.x,u.y,g,h,u.angle);Cs(x+c,v+d,p,o,n,a,i,!1)}}},nN=({accumulatedChange:e,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:o,nextValue:n,property:i,scene:a,originalAppState:s})=>{let l=a.getNonDeletedElementsMap(),c=a.getNonDeletedElements();if(n!==void 0){for(let u of mc(t,s)){let g=cc(u,l,r);if(g.length>1){let[h,x,,]=Te(g.map(w=>w.latest));oN(i==="x"?n:h,i==="y"?n:x,g.map(w=>w.original),l,c,r,a)}else{let h=g[0]?.original,x=g[0]?.latest;if(h&&x&&ao(x,i)){let[v,y]=[h.x+h.width/2,h.y+h.height/2],[w,C]=xe(h.x,h.y,v,y,h.angle);Cs(i==="x"?n:w,i==="y"?n:C,h,l,c,a,r,!1)}}}a.triggerUpdate();return}let d=o?St(e,tN):e;rN(i,i==="x"?d:0,i==="y"?d:0,t,t,l,r,a),a.triggerUpdate()},iN=({property:e,elements:t,elementsMap:r,atomicUnits:o,scene:n,appState:i})=>{let a=eN(()=>o.map(l=>{let c=Object.keys(l).map(h=>r.get(h)).filter(h=>h!==void 0);if(c.length>1){let[h,x]=Te(c);return Math.round((e==="x"?h:x)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,g]=xe(d.x,d.y,m,p,d.angle);return Math.round((e==="x"?u:g)*100)/100}),[o,r,e]),s=new Set(a).size===1?a[0]:"Mixed";return aN(Ir,{label:e==="x"?"X":"Y",elements:t,dragInputCallback:nN,value:s,property:e,scene:n,appState:i})},tx=iN;f();ee();import{Fragment as O5,jsx as R5,jsxs as N5}from"react/jsx-runtime";var sN=({label:e,open:t,openTrigger:r,children:o})=>N5(O5,{children:[N5("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},onClick:r,children:[e,R5(Fo,{icon:t?Gw:Uw})]}),t&&R5(O5,{children:o})]}),rx=sN;Y();me();import{jsx as We,jsxs as Bo}from"react/jsx-runtime";var mN=50,z5=e=>{let t=Gn(),r=e.scene.getSceneNonce()||1,o=e.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return We(pN,{...e,appState:t,sceneNonce:r,selectedElements:o})},pN=cN(({scene:e,onClose:t,renderCustomStats:r,selectedElements:o,appState:n,sceneNonce:i})=>{let a=e.getNonDeletedElements(),s=e.getNonDeletedElementsMap(),l=Oe(),c=o.length===1?o[0]:null,d=o.length>1?o:null,[m,p]=lN({width:0,height:0}),u=B5(()=>dN(h=>{let x=Te(h);p({width:Math.round(x[2])-Math.round(x[0]),height:Math.round(x[3])-Math.round(x[1])})},mN),[]);F5(()=>{u(a)},[i,a,u]),F5(()=>()=>u.cancel(),[u]);let g=B5(()=>mc(o,n),[o,n]);return We("div",{className:"Stats",children:Bo(Yt,{padding:3,children:[Bo("div",{className:"title",children:[We("h2",{children:E("stats.title")}),We("div",{className:"close",onClick:t,children:Ao})]}),We(rx,{label:We("h3",{children:E("stats.generalStats")}),open:!!(n.stats.panels&Fi.generalStats),openTrigger:()=>l(h=>({...h,stats:{open:!0,panels:h.stats.panels^Fi.generalStats}})),children:We("table",{children:Bo("tbody",{children:[We("tr",{children:We("th",{colSpan:2,children:E("stats.scene")})}),Bo("tr",{children:[We("td",{children:E("stats.elements")}),We("td",{children:a.length})]}),Bo("tr",{children:[We("td",{children:E("stats.width")}),We("td",{children:m.width})]}),Bo("tr",{children:[We("td",{children:E("stats.height")}),We("td",{children:m.height})]}),r?.(a,n)]})})}),o.length>0&&We("div",{id:"elementStats",style:{marginTop:12},children:Bo(rx,{label:We("h3",{children:E("stats.elementProperties")}),open:!!(n.stats.panels&Fi.elementProperties),openTrigger:()=>l(h=>({...h,stats:{open:!0,panels:h.stats.panels^Fi.elementProperties}})),children:[c&&Bo("div",{className:"sectionContent",children:[We("div",{className:"elementType",children:E(`element.${c.type}`)}),Bo("div",{className:"statsItem",children:[We(ex,{element:c,property:"x",elementsMap:s,scene:e,appState:n}),We(ex,{element:c,property:"y",elementsMap:s,scene:e,appState:n}),We(J1,{property:"width",element:c,scene:e,appState:n}),We(J1,{property:"height",element:c,scene:e,appState:n}),!de(c)&&We(C5,{property:"angle",element:c,scene:e,appState:n}),We(M5,{property:"fontSize",element:c,scene:e,appState:n})]})]}),d&&Bo("div",{className:"sectionContent",children:[q0(d)&&We("div",{className:"elementType",children:E("element.group")}),Bo("div",{className:"elementsCount",children:[We("div",{children:E("stats.elements")}),We("div",{children:o.length})]}),Bo("div",{className:"statsItem",children:[We(tx,{property:"x",elements:d,elementsMap:s,atomicUnits:g,scene:e,appState:n}),We(tx,{property:"y",elements:d,elementsMap:s,atomicUnits:g,scene:e,appState:n}),We(Q1,{property:"width",elements:d,elementsMap:s,atomicUnits:g,scene:e,appState:n}),We(Q1,{property:"height",elements:d,elementsMap:s,atomicUnits:g,scene:e,appState:n}),We(P5,{property:"angle",elements:d,scene:e,appState:n}),We(D5,{property:"fontSize",elements:d,scene:e,appState:n,elementsMap:s})]})]})]})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels);import{Fragment as U5,jsx as be,jsxs as wo}from"react/jsx-runtime";var bN=({UIOptions:e})=>wo(Hr,{__fallback:!0,children:[be(Hr.DefaultItems.LoadScene,{}),be(Hr.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&be(Hr.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&be(Hr.DefaultItems.SaveAsImage,{}),be(Hr.DefaultItems.Help,{}),be(Hr.DefaultItems.ClearCanvas,{}),be(Hr.Separator,{}),be(Hr.Group,{title:"Excalidraw links",children:be(Hr.DefaultItems.Socials,{})}),be(Hr.Separator,{}),be(Hr.DefaultItems.ToggleTheme,{}),be(Hr.DefaultItems.ChangeCanvasBackground,{})]}),EN=()=>wo(Jg,{__fallback:!0,children:[be(Jg.Actions.SaveToDisk,{}),be(Jg.Actions.ExportToImage,{})]}),xN=({actionManager:e,appState:t,files:r,setAppState:o,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:s,onPenModeToggle:l,showExitZenModeBtn:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:g,children:h,app:x,isCollaborating:v,openAIKey:y,isOpenAIKeyPersisted:w,onOpenAIAPIKeyChange:C,onMagicSettingsConfirm:M})=>{let I=Ne(),P=zI(),[A,N]=hN(ca,Xe),k=()=>p.canvasActions.export?be(bC,{elements:n,appState:t,files:r,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,D=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:be(oC,{elements:n,appState:t,files:r,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:x.getName()}),z=()=>wo("div",{style:{position:"relative"},children:[be(P.MainMenuTunnel.Out,{}),g&&be(P.WelcomeScreenMenuHintTunnel.Out,{})]}),R=()=>be(fa,{heading:"selectedShapeActions",className:om("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:be(Yt,{className:vm.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:be(Dg,{appState:t,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction})})}),W=()=>{let le=us(t,n),U=t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled;return be(zg,{side:"top",children:wo("div",{className:"App-menu App-menu_top",children:[wo(rr.Col,{gap:6,className:om("App-menu_top__left"),children:[z(),le&&R()]}),!t.viewModeEnabled&&be(fa,{heading:"shapes",className:"shapes-section",children:oe=>wo("div",{style:{position:"relative"},children:[g&&be(P.WelcomeScreenToolbarHintTunnel.Out,{}),be(rr.Col,{gap:4,align:"start",children:wo(rr.Row,{gap:1,className:om("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[wo(Yt,{padding:1,className:om("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[be(Hg,{appState:t,isMobile:I.editor.isMobile,device:I,app:x}),oe,wo(rr.Row,{gap:1,children:[be(Gg,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>l(null),title:E("toolBar.penMode"),penDetected:t.penDetected}),be(Ug,{checked:t.activeTool.locked,onChange:a,title:E("toolBar.lock")}),be("div",{className:"App-toolbar__divider"}),be(Wg,{checked:qo(t),onChange:()=>s(),title:E("toolBar.hand"),isMobile:!0}),be(_g,{appState:t,activeTool:t.activeTool,UIOptions:p,app:x})]})]}),v&&be(Yt,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:be(t5,{title:E("toolBar.laser"),checked:t.activeTool.type===It.laser,onChange:()=>x.setActiveTool({type:It.laser}),isMobile:!0})})]})})]})}),wo("div",{className:om("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&be(Xg,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),d?.(I.editor.isMobile,t),!t.viewModeEnabled&&(!re||t.openSidebar?.name!==co.name)&&be(P.DefaultSidebarTriggerTunnel.Out,{}),U&&be(z5,{scene:x.scene,onClose:()=>{e.executeAction(Zl)},renderCustomStats:m})]})]})})},q=()=>be(Qg,{__fallback:!0,onDock:le=>{Ce("sidebar",`toggleDock (${le?"dock":"undock"})`,`(${I.editor.isMobile?"mobile":"desktop"})`)}}),re=fN(Jd,Xe),ge=wo(U5,{children:[h,be(bN,{UIOptions:p}),be(Qg.Trigger,{__fallback:!0,icon:qm,title:Bi(E("toolBar.library")),onToggle:le=>{le&&Ce("sidebar",`${co.name} (open)`,`button (${I.editor.isMobile?"mobile":"desktop"})`)},tab:co.defaultTab,children:E("toolBar.library")}),be(EN,{}),t.openDialog?.name==="ttd"&&be(j1,{__fallback:!0}),t.isLoading&&be(Dm,{delay:250}),t.errorMessage&&be(eC,{onClose:()=>o({errorMessage:null}),children:t.errorMessage}),A&&!I.editor.isMobile&&be($3,{colorPickerType:A.colorPickerType,onCancel:()=>{N(null)},onChange:(le,U,oe,{altKey:Ie})=>{if(!(le!=="elementBackground"&&le!=="elementStroke"))if(oe.length){for(let Fe of oe)F(Fe,{[Ie&&A.swapPreviewOnAlt?le==="elementBackground"?"strokeColor":"backgroundColor":le==="elementBackground"?"backgroundColor":"strokeColor"]:U},!1),_e.delete(Fe);er.getScene(oe[0])?.triggerUpdate()}else o(le==="elementBackground"?{currentItemBackgroundColor:U}:{currentItemStrokeColor:U})},onSelect:(le,U)=>{N(oe=>oe?.keepOpenOnAlt&&U.altKey?oe:null),A?.onSelect?.(le,U)}}),t.openDialog?.name==="help"&&be(gC,{onClose:()=>{o({openDialog:null})}}),t.openDialog?.name==="settings"&&be(s5,{openAIKey:y,isPersisted:w,onChange:C,onConfirm:(le,U)=>{let oe=t.openDialog?.name==="settings"?t.openDialog?.source:"settings";o({openDialog:null},()=>{M(le,U,oe)})},onClose:()=>{o({openDialog:null})}}),be(VI,{}),be(P.OverwriteConfirmDialogTunnel.Out,{}),D(),k(),t.pasteDialog.shown&&be(uC,{setAppState:o,appState:t,onClose:()=>o({pasteDialog:{shown:!1,data:null}})}),I.editor.isMobile&&be(mC,{app:x,appState:t,elements:n,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:D,setAppState:o,onLockToggle:a,onHandToolToggle:s,onPenModeToggle:l,renderTopRightUI:d,renderCustomStats:m,renderSidebars:q,device:I,renderWelcomeScreen:g,UIOptions:p}),!I.editor.isMobile&&wo(U5,{children:[wo("div",{className:"layer-ui__wrapper",style:t.openSidebar&&re&&I.editor.canFitSidebar?{width:`calc(100% - ${u0}px)`}:{},children:[g&&be(P.WelcomeScreenCenterTunnel.Out,{}),W(),be(yC,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),t.scrolledOutside&&be("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(le=>({..._n(n,le)}))},children:E("buttons.scrollBackToContent")})]}),q()]})]});return be(uE.Provider,{value:t,children:be(gN,{scope:P.jotaiScope,children:be(p1.Provider,{value:P,children:ge})})})},H5=e=>{let{suggestedBindings:t,startBoundElement:r,cursorButton:o,scrollX:n,scrollY:i,...a}=e;return a},yN=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:r,appState:o,...n}=e,{canvas:i,appState:a,...s}=t;return it(H5(o),H5(a),{selectedElementIds:it,selectedGroupIds:it})&&it(n,s)},G5=uN.memo(xN,yN);f();ee();import{useCallback as wN,useEffect as vN,useRef as TN}from"react";import{jsx as W5,jsxs as IN}from"react/jsx-runtime";var SN=5e3,V5=({message:e,onClose:t,closable:r=!1,duration:o=SN,style:n})=>{let i=TN(0),a=o!==1/0,s=wN(()=>{a&&(i.current=window.setTimeout(()=>t(),o))},[t,o,a]);return vN(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),IN("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:n,children:[W5("p",{className:"Toast__message",children:e}),r&&W5(fe,{icon:Ao,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})};f();ee();ye();Re();$e();var ox=G({name:"viewMode",label:"labels.viewMode",paletteName:"Toggle view mode",icon:Zs,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},storeAction:_.NONE}},checked:e=>e.viewModeEnabled,predicate:(e,t,r)=>typeof r.viewModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.R});qr();rb();di();He();import E9 from"lodash.throttle";Oa();Cd();on();vr();Ui();f();we();vr();vr();ye();V();Gs();$e();me();ee();Re();var Y5=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length===1&&Q(r[0])},X5=G({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;if(Q(n)){let i=bo(Ae(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},storeAction:_.CAPTURE}}return{elements:e,appState:t,storeAction:_.NONE}},predicate:(e,t,r,o)=>Y5(t,o)}),K5=G({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;return Q(n)?{elements:bb(e,n),appState:{...t,selectedElementIds:{[n.id]:!0}},storeAction:_.CAPTURE}:{elements:e,appState:t,storeAction:_.NONE}},predicate:(e,t,r,o)=>Y5(t,o)}),oSe=G({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},storeAction:_.NONE}),checked:e=>e.frameRendering.enabled}),nSe=G({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:sp,viewMode:!1,perform:(e,t,r,o)=>{let n=nt(t,{type:"frame"});return po(o.interactiveCanvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:nt(t,{type:"frame"})},storeAction:_.NONE}},keyTest:e=>!e[S.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===S.F});Hi();f();Y();dt();me();Gt();ye();mt();Ui();var CN=8,$5=99999,mh=e=>CN/e,zo=class e{static referenceSnapPoints=null;static visibleGaps=null;static setReferenceSnapPoints=t=>{e.referenceSnapPoints=t};static getReferenceSnapPoints=()=>e.referenceSnapPoints;static setVisibleGaps=t=>{e.visibleGaps=t};static getVisibleGaps=()=>e.visibleGaps;static destroy=()=>{e.referenceSnapPoints=null,e.visibleGaps=null}},_i=({event:e,appState:t,selectedElements:r})=>e?t.objectsSnapModeEnabled&&!e[S.CTRL_OR_CMD]||!t.objectsSnapModeEnabled&&e[S.CTRL_OR_CMD]&&t.gridSize===null:r.length===1&&r[0].type==="arrow"?!1:t.objectsSnapModeEnabled,AN=(e,t,r=.01)=>Math.abs(e-t)<=r,nm=(e,t,{omitCenter:r,boundingBoxCorners:o,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=ae(a,t);n&&(s+=n.x,c+=n.x,m+=n.x,l+=n.y,d+=n.y,p+=n.y);let u=(c-s)/2,g=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let h=ce([s,l+g],[m,p],a.angle),x=ce([s+u,l],[m,p],a.angle),v=ce([c,l+g],[m,p],a.angle),y=ce([s+u,d],[m,p],a.angle);i=r?[h,x,v,y]:[h,x,v,y,[m,p]]}else{let h=ce([s,l],[m,p],a.angle),x=ce([c,l],[m,p],a.angle),v=ce([s,d],[m,p],a.angle),y=ce([c,d],[m,p],a.angle);i=r?[h,x,v,y]:[h,x,v,y,[m,p]]}}else if(e.length>1){let[a,s,l,c]=Tu(e,n??{x:0,y:0}),d=l-a,m=c-s,p=[a,s],u=[l,s],g=[a,c],h=[l,c],x=[a+d/2,s+m/2];i=r?[p,u,g,h]:[p,u,g,h,x]}return i.map(a=>[yt(a[0]),yt(a[1])])},q5=(e,t,r,o)=>{let n=t.filter(i=>Q(i)).map(i=>i.id);return Zb(e,t,r,o).filter(i=>!(i.frameId&&n.includes(i.frameId)))},J5=(e,t,r,o)=>{let n=q5(e,t,r,o),i=Na(n,o).filter(m=>!(m.length===1&&ze(m[0]))).map(m=>Te(m).map(p=>yt(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>$5)break e;let g=a[u],[,h,x,v]=p,[y,w,,C]=g;x<y&&xd([h,v],[w,C])&&s.push({startBounds:p,endBounds:g,startSide:[[x,h],[x,v]],endSide:[[y,w],[y,C]],length:y-x,overlap:yd([h,v],[w,C])})}}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>$5)break e;let g=c[u],[h,,x,v]=p,[y,w,C]=g;v<w&&xd([h,x],[y,C])&&d.push({startBounds:p,endBounds:g,startSide:[[h,v],[x,v]],endSide:[[y,w],[C,w]],length:w-v,overlap:yd([h,x],[y,C])})}}return{horizontalGaps:s,verticalGaps:d}},Z5=(e,t,r,o,n,i,a)=>{if(!_i({appState:r,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=zo.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=Tu(e,t).map(x=>yt(x)),g=(d+p)/2,h=(m+u)/2;for(let x of l){if(!xd([m,u],x.overlap))continue;let v=x.startSide[0][0]+x.length/2,y=yt(v-g);if(x.length>p-d&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(n.length=0),a.x=Math.abs(y);let k={type:"gap",direction:"center_horizontal",gap:x,offset:y};n.push(k);continue}let[,,C]=x.endBounds,M=d-C,I=yt(x.length-M);if(Math.abs(I)<=a.x){Math.abs(I)<a.x&&(n.length=0),a.x=Math.abs(I);let k={type:"gap",direction:"side_right",gap:x,offset:I};n.push(k);continue}let[P,,,]=x.startBounds,A=P-p,N=yt(A-x.length);if(Math.abs(N)<=a.x){Math.abs(N)<a.x&&(n.length=0),a.x=Math.abs(N);let k={type:"gap",direction:"side_left",gap:x,offset:N};n.push(k);continue}}for(let x of c){if(!xd([d,p],x.overlap))continue;let v=x.startSide[0][1]+x.length/2,y=yt(v-h);if(x.length>u-m&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let k={type:"gap",direction:"center_vertical",gap:x,offset:y};i.push(k);continue}let[,C,,]=x.startBounds,M=C-u,I=yt(M-x.length);if(Math.abs(I)<=a.y){Math.abs(I)<a.y&&(i.length=0),a.y=Math.abs(I);let k={type:"gap",direction:"side_top",gap:x,offset:I};i.push(k);continue}let[,,,P]=x.endBounds,A=yt(m-P),N=x.length-A;if(Math.abs(N)<=a.y){Math.abs(N)<a.y&&(i.length=0),a.y=Math.abs(N);let k={type:"gap",direction:"side_bottom",gap:x,offset:N};i.push(k);continue}}}},Q5=(e,t,r,o)=>{let n=q5(e,t,r,o);return Na(n,o).filter(i=>!(i.length===1&&ze(i[0]))).flatMap(i=>nm(i,o))},uc=(e,t,r,o,n,i,a)=>{if(!_i({appState:r,event:o,selectedElements:e})||e.length===0&&t.length===0)return[];let s=zo.getReferenceSnapPoints();if(s)for(let l of t)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&&(n.length=0),n.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))}},eA=(e,t,r,o,n)=>{let i=he(e,r);if(!_i({appState:r,event:o,selectedElements:i})||i.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=yt(t.x),t.y=yt(t.y);let a=[],s=[],l=mh(r.zoom.value),c={x:l,y:l},d=nm(i,n,{dragOffset:t});uc(i,d,r,o,a,s,c),Z5(i,t,r,o,a,s,c);let m={x:a[0]?.offset??0,y:s[0]?.offset??0};c.x=0,c.y=0,a.length=0,s.length=0;let p={x:yt(t.x+m.x),y:yt(t.y+m.y)};uc(i,nm(i,n,{dragOffset:p}),r,o,a,s,c),Z5(i,p,r,o,a,s,c);let u=nx(a,s),g=kN(i,p,[...a,...s].filter(h=>h.type==="gap"));return{snapOffset:m,snapLines:[...u,...g]}},yt=e=>Math.round(e*10**6)/10**6,j5=e=>{let t=new Map;for(let r of e){let o=r.join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},nx=(e,t)=>{let r={},o={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=yt(n.points[0][0]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>[yt(a[0]),yt(a[1])]))}}if(t.length>0){for(let n of t)if(n.type==="point"){let i=yt(n.points[0][1]);o[i]||(o[i]=[]),o[i].push(...n.points.map(a=>[yt(a[0]),yt(a[1])]))}}return Object.entries(r).map(([n,i])=>({type:"points",points:j5(i.map(a=>[Number(n),a[1]]).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([n,i])=>({type:"points",points:j5(i.map(a=>[a[0],Number(n)]).sort((a,s)=>a[0]-s[0]))})))},MN=e=>{let t=new Map;for(let r of e){let o=r.points.flat().map(n=>[yt(n)]).join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},kN=(e,t,r)=>{let[o,n,i,a]=Tu(e,t),s=[];for(let l of r){let[c,d,m,p]=l.gap.startBounds,[u,g,h,x]=l.gap.endBounds,v=yd([n,a],l.gap.overlap),y=yd([o,i],l.gap.overlap);switch(l.direction){case"center_horizontal":{if(v){let w=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[[l.gap.startSide[0][0],w],[o,w]]},{type:"gap",direction:"horizontal",points:[[i,w],[l.gap.endSide[0][0],w]]})}break}case"center_vertical":{if(y){let w=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[[w,l.gap.startSide[0][1]],[w,n]]},{type:"gap",direction:"vertical",points:[[w,a],[w,l.gap.endSide[0][1]]]})}break}case"side_right":{if(v){let w=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[[m,w],[u,w]]},{type:"gap",direction:"horizontal",points:[[h,w],[o,w]]})}break}case"side_left":{if(v){let w=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[[i,w],[c,w]]},{type:"gap",direction:"horizontal",points:[[m,w],[u,w]]})}break}case"side_top":{if(y){let w=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[[w,a],[w,d]]},{type:"gap",direction:"vertical",points:[[w,p],[w,g]]})}break}case"side_bottom":{if(y){let w=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[[w,p],[w,g]]},{type:"gap",direction:"vertical",points:[[w,x],[w,n]]})}break}}}return MN(s.map(l=>({...l,points:l.points.map(c=>[yt(c[0]),yt(c[1])])})))},tA=(e,t,r,o,n,i)=>{if(!_i({event:o,selectedElements:e,appState:r})||e.length===0||e.length===1&&!AN(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=Te(t);i&&(i.includes("e")?l+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?s+=n.y:i.includes("s")&&(c+=n.y));let d=[];if(i)switch(i){case"e":{d.push([l,s],[l,c]);break}case"w":{d.push([a,s],[a,c]);break}case"n":{d.push([a,s],[l,s]);break}case"s":{d.push([a,c],[l,c]);break}case"ne":{d.push([l,s]);break}case"nw":{d.push([a,s]);break}case"se":{d.push([l,c]);break}case"sw":{d.push([a,c]);break}}let m=mh(r.zoom.value),p={x:m,y:m},u=[],g=[];uc(t,d,r,o,u,g,p);let h={x:u[0]?.offset??0,y:g[0]?.offset??0};p.x=0,p.y=0,u.length=0,g.length=0;let[x,v,y,w]=Te(e).map(I=>yt(I));uc(e,[[x,v],[x,w],[y,v],[y,w]],r,o,u,g,p);let M=nx(u,g);return{snapOffset:h,snapLines:M}},rA=(e,t,r,o,n,i)=>{if(!_i({event:r,selectedElements:[e],appState:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[[o.x+n.x,o.y+n.y]],s=mh(t.zoom.value),l={x:s,y:s},c=[],d=[];uc([e],a,t,r,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=nm([e],i,{boundingBoxCorners:!0,omitCenter:!0});uc([e],p,t,r,c,d,l);let u=nx(c,d);return{snapOffset:m,snapLines:u}},oA=(e,t,r,o,n)=>{if(!_i({event:o,selectedElements:[],appState:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Zb(e,[],t,n),a=mh(t.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=nm([d],n);for(let p of m){let u=p[0]-r.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,[p[0],r.y]],direction:"vertical"}),s.x=u);let g=p[1]-r.y;Math.abs(g)<=Math.abs(s.y)&&(Math.abs(g)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,[r.x,p[1]]],direction:"horizontal"}),s.y=g)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-r.x:0,y:l.length>0?l[0].points[0][1]-r.y:0},snapLines:[...c,...l]}},nA=e=>e===It.rectangle||e===It.ellipse||e===It.diamond||e===It.frame||e===It.magicframe||e===It.image||e===It.text;f();import{jsx as Ho,jsxs as iA}from"react/jsx-runtime";var PN=()=>iA("div",{"data-testid":"brave-measure-text-error",children:[Ho("p",{children:Ho(Br,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Ho("span",{style:{fontWeight:600},children:e})})}),Ho("p",{children:Ho(Br,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Ho("span",{style:{fontWeight:600},children:e})})}),Ho("p",{children:Ho(Br,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Ho("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Ho("p",{children:Ho(Br,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Ho("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>iA("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),aA=PN;f();Y();we();yr();Nn();He();V();Ha();Zo();ko();on();me();var ph={width:100,height:0},va=100,LN=(e,t,r)=>{let o=jt({x:0,y:0,textAlign:Oi.CENTER,verticalAlign:kt.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:o.id})}),ft(o,e,r),[e,o]},sA=(e,t,r,o,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let d=t?.width??va,m=t?.height??va,p;t.id&&(p=o.getElement(t.id),p||console.error(`No element for start binding with id ${t.id} found`));let u=t.x||e.x-d,g=t.y||e.y-m/2,h=p?p.type:t.type;if(h){if(h==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=jt({x:u,y:g,type:"text",...p,...t,text:x}),Object.assign(i,{x:t.x||e.x-i.width,y:t.y||e.y-i.height/2})}else switch(h){case"rectangle":case"ellipse":case"diamond":{i=go({x:u,y:g,width:d,height:m,...p,...t,type:h});break}default:$o(e,`Unhandled element start type "${t.type}"`,!0)}On(e,i,"start",n)}}if(r){let d=r?.height??va,m=r?.width??va,p;r.id&&(p=o.getElement(r.id),p||console.error(`No element for end binding with id ${r.id} found`));let u=r.x||e.x+e.width,g=r.y||e.y-d/2,h=p?p.type:r.type;if(h){if(h==="text"){let x="";p&&p.type==="text"?x=p.text:r.type==="text"&&(x=r.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=jt({x:u,y:g,type:"text",...p,...r,text:x}),Object.assign(a,{y:r.y||e.y-a.height/2})}else switch(h){case"rectangle":case"ellipse":case"diamond":{a=go({x:u,y:g,width:m,height:d,...p,...r,type:h});break}default:$o(e,`Unhandled element end type "${h}"`,!0)}On(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let s=e.points.length-1,l=.5,c=Xr(e.points);return e.points[s][0]>e.points[s-1][0]&&(c[0][0]=l,c[s][0]-=l),e.points[s][0]<e.points[s-1][0]&&(c[0][0]=-l,c[s][0]+=l),e.points[s][1]>e.points[s-1][1]&&(c[0][1]=l,c[s][1]-=l),e.points[s][1]<e.points[s-1][1]&&(c[0][1]=-l,c[s][1]+=l),Object.assign(e,{points:c}),{linearElement:e,startBoundElement:i,endBoundElement:a}},ix=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>fr(Array.from(this.excalidrawElements.values()));getElementsMap=()=>Mr(Z(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},ac=(e,t)=>{if(!e)return[];let r=Xr(e),o=new ix,n=new Map,i=new Map;for(let s of r){let l,c=s.id;switch(t?.regenerateIds!==!1&&Object.assign(s,{id:Ut()}),s.type){case"rectangle":case"ellipse":case"diamond":{let m=s?.label?.text&&s.width===void 0?0:s?.width||va,p=s?.label?.text&&s.height===void 0?0:s?.height||va;l=go({...s,width:m,height:p});break}case"line":{let m=s.width||ph.width,p=s.height||ph.height;l=nn({width:m,height:p,points:[[0,0],[m,p]],...s});break}case"arrow":{let m=s.width||ph.width,p=s.height||ph.height;l=Gc({width:m,height:p,endArrowhead:"arrow",points:[[0,0],[m,p]],...s,type:"arrow"}),Object.assign(l,pi(l.points));break}case"text":{let m=s?.fontFamily||gr,p=s?.fontSize||ur,u=s?.lineHeight||uo(m),g=s.text??"",h=Zi(g),x=Vt(h,Me({fontFamily:m,fontSize:p}),u);l=jt({width:x.width,height:x.height,fontFamily:m,fontSize:p,...s});break}case"image":{l=Wc({width:s?.width||va,height:s?.height||va,...s});break}case"frame":{l=Cp({x:0,y:0,...s});break}case"magicframe":{l=Uc({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{l=s;break}default:l=s,$o(s,`Unhandled element type "${s.type}"`,!0)}o.getElement(l.id)?console.error(`Duplicate id found for ${l.id}`):(o.add(l),n.set(l.id,s),c&&i.set(c,l.id))}let a=o.getElementsMap();for(let[s,l]of n){let c=o.getElement(s);switch(l.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(l.label?.text){let[d,m]=LN(c,l?.label,a);if(o.add(d),o.add(m),ne(d)){let p=l.type==="arrow"?l?.start:void 0,u=l.type==="arrow"?l?.end:void 0;if(p&&p.id){let v=i.get(p.id);v&&Object.assign(p,{id:v})}if(u&&u.id){let v=i.get(u.id);v&&Object.assign(u,{id:v})}let{linearElement:g,startBoundElement:h,endBoundElement:x}=sA(d,p,u,o,a);d=g,o.add(g),o.add(h),o.add(x)}}else switch(l.type){case"arrow":{let{start:d,end:m}=l;if(d&&d.id){let h=i.get(d.id);Object.assign(d,{id:h})}if(m&&m.id){let h=i.get(m.id);Object.assign(m,{id:h})}let{linearElement:p,startBoundElement:u,endBoundElement:g}=sA(c,d,m,o,a);o.add(p),o.add(u),o.add(g);break}}break}}}for(let[s,l]of n){if(l.type!=="frame"&&l.type!=="magicframe")continue;let c=o.getElement(s);if(!c)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let d=[];l.children.forEach(y=>{let w=i.get(y);if(!w)throw new Error(`Element with ${y} wasn't mapped correctly`);let C=o.getElement(w);if(!C)throw new Error(`Frame element with id ${w} doesn't exist`);Object.assign(C,{frameId:c.id}),C?.boundElements?.forEach(M=>{let I=o.getElement(M.id);if(!I)throw new Error(`Bound element with id ${M.id} doesn't exist`);Object.assign(I,{frameId:c.id}),d.push(I)}),d.push(C)});let[m,p,u,g]=Te(d),h=10;m=m-h,p=p-h,u=u+h,g=g+h;let x=Math.max(c?.width,u-m),v=Math.max(c?.height,g-p);Object.assign(c,{x:m,y:p,width:x,height:v})}return o.getElements()};f();f();V();Y();import KN,{useEffect as $N,useRef as ZN}from"react";f();V();import{unstable_batchedUpdates as lA}from"react-dom";import{version as DN}from"react";var bt=e=>t=>{lA(e,t)},uh=e=>Hs(t=>{lA(e,t)}),gh=(()=>{let e;try{let r=DN.split(".");e=Number(r[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();f();we();li();Gt();Cd();V();Y();f();Y();var _N="#ff6b6b",RN="#ff0000",cA=1,dA=2,mA=(e,t)=>{if(!t.snapLines.length)return;let r=t.theme===ue.LIGHT||t.zenModeEnabled?_N:RN,o=(t.zenModeEnabled?cA*1.5:cA)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let n of t.snapLines)n.type==="pointer"?(e.lineWidth=o,e.strokeStyle=r,ON(n,e,t)):n.type==="gap"?(e.lineWidth=o,e.strokeStyle=r,FN(n.points[0],n.points[1],n.direction,t,e)):n.type==="points"&&(e.lineWidth=o,e.strokeStyle=r,NN(n,e,t));e.restore()},NN=(e,t,r)=>{if(!r.zenModeEnabled){let o=e.points[0],n=e.points[e.points.length-1];Uo(o,n,t)}for(let o of e.points)pA(o,r,t)},ON=(e,t,r)=>{pA(e.points[0],r,t),r.zenModeEnabled||Uo(e.points[0],e.points[1],t)},pA=([e,t],r,o)=>{o.save();let n=(r.zenModeEnabled?dA*1.5:dA)/r.zoom.value;o.beginPath(),o.moveTo(e-n,t-n),o.lineTo(e+n,t+n),o.moveTo(e+n,t-n),o.lineTo(e-n,t+n),o.stroke(),o.restore()},Uo=(e,t,r)=>{r.beginPath(),r.lineTo(...e),r.lineTo(...t),r.stroke()},FN=(e,t,r,o,n)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(r==="horizontal"){let l=[(e[0]+t[0])/2,e[1]];o.zenModeEnabled||Uo([e[0],e[1]-i],[e[0],e[1]+i],n),Uo([l[0]-s,l[1]-a],[l[0]-s,l[1]+a],n),Uo([l[0]+s,l[1]-a],[l[0]+s,l[1]+a],n),o.zenModeEnabled||(Uo([t[0],t[1]-i],[t[0],t[1]+i],n),Uo(e,t,n))}else{let l=[e[0],(e[1]+t[1])/2];o.zenModeEnabled||Uo([e[0]-i,e[1]],[e[0]+i,e[1]],n),Uo([l[0]-a,l[1]-s],[l[0]+a,l[1]-s],n),Uo([l[0]-a,l[1]+s],[l[0]+a,l[1]+s],n),o.zenModeEnabled||(Uo([t[0]-i,t[1]],[t[0]+i,t[1]],n),Uo(e,t,n))}};yr();Wt();ib();me();mt();import hh from"open-color";var BN=(e,t,r)=>{let{elementId:o,hoverPointIndex:n}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=K.getElement(o,r);if(!i)return;let a=K.getPointAtIndexGlobalCoordinates(i,n,r);e.save(),e.translate(t.scrollX,t.scrollY),sx(a,e,t),e.restore()},sx=(e,t,r)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",dd(t,e[0],e[1],K.POINT_HANDLE_SIZE/r.zoom.value,!1)},im=(e,t,r,o,n,i,a,s,l=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(s),l&&e.fillRect(t-i,r-a,o,n),c&&e.roundRect?(e.beginPath(),e.roundRect(t-i,r-a,o,n,c),e.stroke(),e.closePath()):e.strokeRect(t-i,r-a,o,n),e.restore()},zN=(e,t,r,o,n,i)=>{e.save(),e.translate(o,n),e.rotate(i),e.beginPath(),e.moveTo(0,r/2),e.lineTo(t/2,0),e.lineTo(0,-r/2),e.lineTo(-t/2,0),e.closePath(),e.stroke(),e.restore()},fh=(e,t,r,o,n,i=!1)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),dd(e,r[0],r[1],o/t.zoom.value,!i)},HN=(e,t,r,o,n,i)=>{e.beginPath(),e.ellipse(o,n,t/2,r/2,i,0,Math.PI*2),e.stroke()},UN=(e,t,r)=>{let[o,n,i,a]=ae(t,r),s=i-o,l=a-n,c=10,d=4;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=c-d;let m=d/2+c/2,p=fo(Math.min(t.width,t.height),t);switch(t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":im(e,o-m,n-m,s+m*2,l+m*2,o+s/2,n+l/2,t.angle,void 0,p);break;case"diamond":let u=Math.hypot(s,l),g=m*u/l,h=m*u/s;zN(e,s+g*2,l+h*2,o+s/2,n+l/2,t.angle);break;case"ellipse":HN(e,s+m*2,l+m*2,o+s/2,n+l/2,t.angle);break}},GN=(e,t,r)=>{let[o,n,i]=t,a=ed(i,i.width,i.height);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(n==="both"?[0,-1]:n==="start"?[0]:[-1]).forEach(l=>{let[c,d]=K.getPointAtIndexGlobalCoordinates(o,l,r);dd(e,c,d,a)})},gA=(e,t,r)=>{let{angle:o,elementX1:n,elementY1:i,elementX2:a,elementY2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=r,u=a-n,g=s-i,x=oi*2/t.zoom.value,v=8/t.zoom.value,y=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(p?4:1)/t.zoom.value;let w=l.length;for(let C=0;C<w;++C)e.strokeStyle=l[C],m&&e.setLineDash([v,y+(v+y)*(w-1)]),e.lineDashOffset=(v+y)*C,im(e,n-x,i-x,u+x*2,g+x*2,c,d,o);e.restore()},WN=(e,t,r,o)=>{let n=Array.isArray(r)?GN:UN;e.save(),e.translate(t.scrollX,t.scrollY),n(e,r,o),e.restore()},VN=(e,t,r,o)=>{let[n,i,a,s]=ae(r,o),l=a-n,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=rt.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),im(e,n,i,l,c,n+l/2,i+c/2,r.angle,!1,rt.radius/t.zoom.value),e.restore()},YN=(e,t,r)=>{let o=r.filter(s=>s.groupIds.length===0),n=r.filter(s=>s.groupIds.length>0),i=s=>{let[l,c,d,m]=Te(s);return{angle:0,elementX1:l,elementX2:d,elementY1:c,elementY2:m,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:l+(d-l)/2,cy:c+(m-c)/2,activeEmbeddable:!1}},a=s=>{let l=ot(r,s);return i(l)};Object.entries(Vm(n,t)).filter(([s,l])=>l).map(([s,l])=>s).map(s=>a(s)).concat(o.map(s=>i([s]))).forEach(s=>gA(e,t,s))},ax=(e,t,r,o)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let n=K.getPointsGlobalCoordinates(r,o),{POINT_HANDLE_SIZE:i}=K,a=t.editingLinearElement?i:i/2;n.forEach((l,c)=>{if(de(r)&&c!==0&&c!==n.length-1)return;let d=!!t.editingLinearElement?.selectedPointsIndices?.includes(c);fh(e,t,l,a,d)}),K.getEditorMidPoints(r,o,t).filter(l=>l!==null).forEach(l=>{t?.selectedLinearElement?.segmentMidPointHoveredCoords&&K.arePointsEqual(l,t.selectedLinearElement.segmentMidPointHoveredCoords)?t.editingLinearElement?(fh(e,t,l,a,!1),sx(l,e,t)):(sx(l,e,t),fh(e,t,l,a,!1)):(t.editingLinearElement||n.length===2)&&fh(e,t,l,i/2,!1,!0)}),e.restore()},uA=(e,t,r,o,n)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/r.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?dd(e,s+c/2,l+d/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/r.zoom.value),e.fill(),e.stroke()):im(e,s,l,c,d,s+c/2,l+d/2,n,!0),e.restore()}})},XN=(e,t,r,o)=>{t.save();let n=oi*2/r.zoom.value,i=e.width+n*2,a=e.height+n*2,s=e.x+i/2,l=e.y+a/2,c=-(i/2+n),d=-(a/2+n);t.translate(s+r.scrollX,l+r.scrollY),t.rotate(e.angle),t.lineWidth=1/r.zoom.value,t.strokeStyle=o,t.strokeRect(c,d,i,a),t.restore()},hA=({canvas:e,elementsMap:t,visibleElements:r,selectedElements:o,allElementsMap:n,scale:i,appState:a,renderConfig:s,device:l})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[c,d]=ru(e,i),m=ou({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:d});m.save(),m.scale(a.zoom.value,a.zoom.value);let p;if(r.forEach(h=>{a.editingLinearElement?.elementId===h.id&&h&&(p=h)}),p&&ax(m,a,p,t),a.selectionElement)try{DT(a.selectionElement,m,a,s.selectionColor)}catch(h){console.error(h)}if(a.editingElement&&H(a.editingElement)){let h=n.get(a.editingElement.id);h&&!h.autoResize&&XN(h,m,a,s.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(h=>h!=null).forEach(h=>{WN(m,a,h,t)}),a.frameToHighlight&&VN(m,a,a.frameToHighlight,t),a.elementsToHighlight&&YN(m,a,a.elementsToHighlight);let u=o.some(h=>Q(h));if(o.length===1&&a.editingLinearElement?.elementId===o[0].id&&ax(m,a,o[0],t),a.selectedLinearElement&&a.selectedLinearElement.hoverPointIndex>=0&&!(de(o[0])&&a.selectedLinearElement.hoverPointIndex>0&&a.selectedLinearElement.hoverPointIndex<o[0].points.length-1)&&BN(m,a,t),!a.multiElement&&!a.editingLinearElement){let h=_u(o,a),x=o.length===1&&ie(o[0]);x&&a.selectedLinearElement?.elementId===o[0].id&&!o[0].locked&&ax(m,a,o[0],t);let v=s.selectionColor||hh.black;if(h){let y=Z(o),w=[];for(let M of t.values()){let I=[],P=s.remoteSelectedElementIds.get(M.id);if(x&&ne(M)&&de(M)&&(M.startBinding||M.endBinding)||(y.has(M.id)&&!Wm(a,M)&&I.push(v),P&&I.push(...P.map(A=>vs(A,a.collaborators.get(A))))),I.length){let[A,N,k,D,z,R]=ae(M,t,!0);w.push({angle:M.angle,elementX1:A,elementY1:N,elementX2:k,elementY2:D,selectionColors:I,dashed:!!P,cx:z,cy:R,activeEmbeddable:a.activeEmbeddable?.element===M&&a.activeEmbeddable.state==="active"})}}let C=M=>{let I=ot(t,M),[P,A,N,k]=Te(I);w.push({angle:0,elementX1:P,elementX2:N,elementY1:A,elementY2:k,selectionColors:[hh.black],dashed:!0,cx:P+(N-P)/2,cy:A+(k-A)/2,activeEmbeddable:!1})};for(let M of Jo(a))C(M);a.editingGroupId&&C(a.editingGroupId),w.forEach(M=>gA(m,a,M))}if(m.save(),m.translate(a.scrollX,a.scrollY),o.length===1){m.fillStyle=hh.white;let y=Id(o[0],a.zoom,t,"mouse",ps(l));!a.viewModeEnabled&&h&&!H(a.editingElement)&&uA(m,s,a,y,o[0].angle)}else if(o.length>1&&!a.isRotating){let y=oi*2/a.zoom.value;m.fillStyle=hh.white;let[w,C,M,I]=Te(o),P=m.getLineDash();m.setLineDash([2/a.zoom.value]);let A=m.lineWidth;m.lineWidth=1/a.zoom.value,m.strokeStyle=v,im(m,w-y,C-y,M-w+y*2,I-C+y*2,(w+M)/2,(C+I)/2,0),m.lineWidth=A,m.setLineDash(P);let N=Nl([w,C,M,I,(w+M)/2,(C+I)/2],0,a.zoom,"mouse",u?{...ps(l),rotation:!0}:ps(l));o.some(k=>!k.locked)&&uA(m,s,a,N,0)}m.restore()}mA(m,a),m.restore(),_S({context:m,renderConfig:s,appState:a,normalizedWidth:c,normalizedHeight:d});let g;return s.renderScrollbars&&(g=cC(r,c,d,a),m.save(),m.fillStyle=lC,m.strokeStyle="rgba(255,255,255,0.8)",[g.horizontal,g.vertical].forEach(h=>{h&&sg(m,h.x,h.y,h.width,h.height,Zn/2)}),m.restore()),{scrollBars:g,atLeastOneVisibleElement:r.length>0,elementsMap:t}},lx=Hs(e=>{let t=hA(e);e.callback?.(t)},{trailing:!0}),fA=(e,t)=>{if(t){lx(e);return}let r=hA(e);return e.callback(r),r};import{jsx as JN}from"react/jsx-runtime";var jN=e=>{let t=ZN(!1);return $N(()=>{if(!t.current){t.current=!0;return}let r=new Map,o=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((l,c)=>{if(l.selectedElementIds)for(let d of Object.keys(l.selectedElementIds))n.has(d)||n.set(d,[]),n.get(d).push(c);!l.pointer||l.pointer.renderCursor===!1||(l.username&&i.set(c,l.username),l.userState&&a.set(c,l.userState),o.set(c,$t({sceneX:l.pointer.x,sceneY:l.pointer.y},e.appState)),r.set(c,l.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";fA({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:o,remotePointerButton:r,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:s,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},gh())}),JN("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Be.GRAB:Be.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:E("labels.drawingCanvas")})},bA=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingElement:e.editingElement}),qN=(e,t)=>e.selectionNonce!==t.selectionNonce||e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements?!1:it(bA(e.appState),bA(t.appState)),cx=KN.memo(jN,qN);f();au();V();import QN,{useEffect as e9,useRef as EA}from"react";import{jsx as o9}from"react/jsx-runtime";var t9=e=>{let t=EA(null),r=EA(!1);return e9(()=>{let o=t.current;if(!o)return;let n=e.canvas;r.current||(r.current=!0,o.replaceChildren(n),n.classList.add("excalidraw__canvas","static"));let i=`${e.appState.width}px`,a=`${e.appState.height}px`;n.style.width!==i&&(n.style.width=i),n.style.height!==a&&(n.style.height=a);let s=e.appState.width*e.scale,l=e.appState.height*e.scale;n.width!==s&&(n.width=s),n.height!==l&&(n.height=l),iu({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},gh())}),o9("div",{className:"excalidraw__canvas-wrapper",ref:t})},xA=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily}),r9=(e,t)=>e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:it(xA(e.appState),xA(t.appState))&&it(e.renderConfig,t.renderConfig),dx=QN.memo(t9,r9);f();ms();me();au();V();var am=class{scene;constructor(t){this.scene=t}getRenderableElements=(()=>{let t=({elementsMap:o,zoom:n,offsetLeft:i,offsetTop:a,scrollX:s,scrollY:l,height:c,width:d})=>{let m=[];for(let p of o.values())ds(p,d,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:s,scrollY:l},o)&&m.push(p);return m},r=({elements:o,editingElement:n,pendingImageElementId:i})=>{let a=Mr(new Map);for(let s of o)So(s)&&i===s.id||(!n||n.type!=="text"||s.id!==n.id)&&a.set(s.id,s);return a};return N0(({zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:s,height:l,width:c,editingElement:d,pendingImageElementId:m,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),g=r({elements:u,editingElement:d,pendingImageElementId:m}),h=t({elementsMap:g,zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:s,height:l,width:c});return{elementsMap:g,visibleElements:h}})})();destroy(){lx.cancel(),ab.cancel(),this.getRenderableElements.clear()}};Qo();f();import{useEffect as n9,useRef as i9}from"react";import{jsx as yA}from"react/jsx-runtime";var wA=({trails:e})=>{let t=i9(null);return n9(()=>{if(t.current)for(let r of e)r.start(t.current);return()=>{for(let r of e)r.stop()}},e),yA("div",{className:"SVGLayer",children:yA("svg",{ref:t})})};Gs();nd();f();V();we();import{jsx as l9}from"react/jsx-runtime";var a9=5,s9=(e,t,r)=>{let[o,n]=ae(e,r),{x:i,y:a}=$t({sceneX:o+e.width,sceneY:n},t),s=i-t.offsetLeft+10,l=a-t.offsetTop;return{x:s,y:l}},mx=({children:e,element:t,elementsMap:r})=>{let o=Gn();if(o.contextMenu||o.draggingElement||o.resizingElement||o.isRotating||o.openMenu||o.viewModeEnabled)return null;let{x:n,y:i}=s9(t,o,r);return l9("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:a9},children:e})};f();Y();var c9=`You are a skilled front-end developer who builds interactive prototypes from wireframes, and is an expert at CSS Grid and Flex design.
|
|
66
62
|
Your role is to transform low-fidelity wireframes into working front-end HTML code.
|
|
67
63
|
|
|
68
64
|
YOU MUST FOLLOW FOLLOWING RULES:
|
|
@@ -82,13 +78,13 @@ If the wireframes, diagrams, or text is unclear or unreadable, refer to provided
|
|
|
82
78
|
|
|
83
79
|
Your goal is a production-ready prototype that brings the wireframes to life.
|
|
84
80
|
|
|
85
|
-
Please output JUST THE HTML file containing your best attempt at implementing the provided wireframes.`;async function lC({image:e,apiKey:t,text:r,theme:o=ce.LIGHT}){let n={model:"gpt-4-vision-preview",max_tokens:4096,temperature:.1,messages:[{role:"system",content:H_},{role:"user",content:[{type:"image_url",image_url:{url:e,detail:"high"}},{type:"text",text:`Above is the reference wireframe. Please make a new website based on these and return just the HTML file. Also, please make it for the ${o} theme. What follows are the wireframe's text annotations (if any)...`},{type:"text",text:r}]}]},i,a=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)});return a.ok?i={...await a.json(),ok:!0}:i={...await a.json(),ok:!1},i}Ma();ir();f();import U_ from"clsx";import{jsx as cC,jsxs as W_}from"react/jsx-runtime";var G_="small",ah=e=>W_("label",{className:U_("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${G_}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[cC("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),cC("div",{className:"ToolIcon__icon",children:e.icon})]});f();import{jsx as VE,jsxs as dC}from"react/jsx-runtime";var V_=({height:e,width:t,userToFollow:r,onDisconnect:o})=>VE("div",{className:"follow-mode",style:{width:t,height:e},children:dC("div",{className:"follow-mode__badge",children:[dC("div",{className:"follow-mode__badge__label",children:["Following"," ",VE("span",{className:"follow-mode__badge__username",title:r.username,children:r.username})]}),VE("button",{type:"button",onClick:o,className:"follow-mode__disconnect-btn",children:yo})]})}),mC=V_;De();f();var sh=class{targets=new WeakMap;rafIds=new WeakMap;register(t,r){this.targets.set(t,{callback:r,stopped:!0})}start(t){let r=this.targets.get(t);r&&(this.rafIds.has(t)||(this.targets.set(t,{...r,stopped:!1}),this.scheduleFrame(t)))}stop(t){let r=this.targets.get(t);r&&!r.stopped&&this.targets.set(t,{...r,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return r=>{let o=this.targets.get(t);if(!o)return;let n=this.onFrame(o,r);!o.stopped&&!n?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){let r=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,r)}cancelFrame(t){if(this.rafIds.has(t)){let r=this.rafIds.get(t);cancelAnimationFrame(r)}this.rafIds.delete(t)}onFrame(t,r){return t.callback(r)??!1}};f();G();Y();import{LaserPointer as Y_}from"@excalidraw/laser-pointer";var ja=class{constructor(t,r,o){this.animationFrameHandler=t;this.app=r;this.options=o;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(We,"path")}currentTrail;pastTrails=[];container;trailElement;get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(t,r){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===t&&this.currentTrail.originalPoints[o-1][1]===r}return!1}start(t){t&&(this.container=t),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(t,r){this.currentTrail=new Y_(this.options),this.currentTrail.addPoint([t,r,performance.now()]),this.update()}addPointToPath(t,r){this.currentTrail&&(this.currentTrail.addPoint([t,r,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}update(){this.start()}onFrame(){let t=[];for(let o of this.pastTrails)t.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);t.push(o)}this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline().length!==0),t.length===0&&this.stop();let r=t.join(" ").trim();this.trailElement.setAttribute("d",r),this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(t,r){let o=t.getStrokeOutline(t.options.size/r.zoom.value).map(([n,i])=>{let a=Ht({sceneX:n,sceneY:i},r);return[a.x,a.y]});return p1(o,!0)}};f();G();Y();var lh=class{constructor(t,r){this.animationFrameHandler=t;this.app=r;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new ja(t,r,{...this.getTrailOptions(),fill:()=>xh})}localTrail;collabTrails=new Map;container;getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(Bn(i),Bn(n))}}}startPath(t,r){this.localTrail.startPath(t,r)}addPointToPath(t,r){this.localTrail.addPointToPath(t,r)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[t,r]of this.app.state.collaborators.entries()){let o;this.collabTrails.has(t)?o=this.collabTrails.get(t):(o=new ja(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>r.pointer?.laserColor||Ya(t,r)}),o.start(this.container),this.collabTrails.set(t,o)),r.pointer&&r.pointer.tool==="laser"&&(r.button==="down"&&!o.hasCurrentTrail&&o.startPath(r.pointer.x,r.pointer.y),r.button==="down"&&o.hasCurrentTrail&&!o.hasLastPoint(r.pointer.x,r.pointer.y)&&o.addPointToPath(r.pointer.x,r.pointer.y),r.button==="up"&&o.hasCurrentTrail&&(o.addPointToPath(r.pointer.x,r.pointer.y),o.endPath()))}for(let t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}};Hn();Ym();f();ge();G();bi();le();Y();Ae();Je();Jt();_i();um();var K_=(e,t,r,o,n,i)=>{let{zoom:a}=o,s=180*r/Math.PI,l=e*(a.value-1)/2,c=t*(a.value-1)/2;return e>n&&a.value!==1&&(l=n*(a.value-1)/2),t>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value}) rotate(${s}deg)`},pC=({id:e,onChange:t,onSubmit:r,getViewportCoords:o,element:n,canvas:i,excalidrawContainer:a,app:s,autoSelect:l=!0})=>{let c=(_,V)=>{if(!V.style.fontFamily||!V.style.fontSize)return!1;let Z=V.style.fontFamily.replace(/"/g,"");return ls({fontFamily:_.fontFamily})!==Z||`${_.fontSize}px`!==V.style.fontSize},d=()=>{let _=s.state,V=Mt.getScene(n)?.getElement(e);if(!V)return;let{textAlign:Z,verticalAlign:J}=V,Se=s.scene.getNonDeletedElementsMap();if(V&&U(V)){let W=V.x,$=V.y,ee=wt(V,s.scene.getNonDeletedElementsMap()),fe=V.width,ot=V.height,Le=V.width,zt=V.height;if(ee&&V.containerId){if(xe(ee)){let or=j.getBoundTextElementPosition(ee,V,Se);W=or.x,$=or.y}let Ar=c(V,m),$r;if(Ar?$r=ya(ee.id,ee.height):($r=xa[ee.id],$r||($r=ya(ee.id,ee.height))),fe=cr(ee,V),ot=wa(ee,V),!xe(ee)&&zt>ot){let or=Gn(zt,ee.type);O(ee,{height:or});return}else if(!xe(ee)&&ee.height>$r.height&&zt<ot){let or=Gn(zt,ee.type);O(ee,{height:or})}else{let{y:or}=Cs(ee,V,Se);$=or}}let[Do,Yr]=o(W,$),fr=m.selectionStart,Kr=m.selectionEnd,li=m.value.length;if(fr===Kr&&Kr!==li){let Ar=li-Kr;m.selectionStart=m.value.length-Ar,m.selectionEnd=m.value.length-Ar}ee?Le+=.5:(fe=(_.width-8-Do)/_.zoom.value,Le=Math.min(Le,fe));let _o=(_.height-Yr)/_.zoom.value;Object.assign(m.style,{font:Ie(V),lineHeight:V.lineHeight,width:`${Le}px`,height:`${zt}px`,left:`${Do}px`,top:`${Yr}px`,transform:K_(Le,zt,f0(V,ee),_,fe,_o),textAlign:Z,verticalAlign:J,color:V.strokeColor,opacity:V.opacity/100,filter:"var(--theme-filter)",maxHeight:`${_o}px`}),m.scrollTop=0,Pr()&&(m.style.fontFamily=ls(V)),O(V,{x:W,y:$})}},m=document.createElement("textarea");m.dir="auto",m.tabIndex=0,m.dataset.type="wysiwyg",m.wrap="off",m.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(Me(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(m.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),m.value=n.originalText,d(),t&&(m.onpaste=async _=>{let V=await np(_,!0);if(!V.text)return;let Z=Ii(V.text);if(!Z)return;let J=wt(n,s.scene.getNonDeletedElementsMap()),Se=Ie({fontSize:s.state.currentItemFontSize,fontFamily:s.state.currentItemFontFamily});if(J){let W=ae(J,s.scene.getNonDeletedElementsMap()),$=go(`${m.value}${Z}`,Se,cr(J,W)),ee=sc($,Se);m.style.width=`${ee}px`}},m.oninput=()=>{t(Ii(m.value))}),m.onkeydown=_=>{if(!_.shiftKey&&Vp.keyTest(_))_.preventDefault(),s.actionManager.executeAction(Vp),d();else if(!_.shiftKey&&Yp.keyTest(_))_.preventDefault(),s.actionManager.executeAction(Yp),d();else if(tb.keyTest(_))s.actionManager.executeAction(tb);else if(rb.keyTest(_))s.actionManager.executeAction(rb);else if(_.key===S.ESCAPE)_.preventDefault(),A=!0,C();else if(_.key===S.ENTER&&_[S.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;A=!0,C()}else if(_.key===S.TAB||_[S.CTRL_OR_CMD]&&(_.code===ye.BRACKET_LEFT||_.code===ye.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===ye.BRACKET_LEFT?y():v(),m.dispatchEvent(new Event("input"))}};let h=4,g=" ".repeat(h),x=new RegExp(`^ {1,${h}}`),v=()=>{let{selectionStart:_,selectionEnd:V}=m,Z=w(),J=m.value;Z.forEach(Se=>{let W=J.slice(0,Se),$=J.slice(Se);J=`${W}${g}${$}`}),m.value=J,m.selectionStart=_+h,m.selectionEnd=V+h*Z.length},y=()=>{let{selectionStart:_,selectionEnd:V}=m,Z=w(),J=[],Se=m.value;Z.forEach(W=>{let $=Se.slice(W,W+h).match(x);if($){let ee=Se.slice(0,W),fe=Se.slice(W+$[0].length);Se=`${ee}${fe}`,J.push(W)}}),m.value=Se,J.length&&(_>J[J.length-1]?m.selectionStart=Math.max(_-h,J[J.length-1]):m.selectionStart=_,m.selectionEnd=Math.max(m.selectionStart,V-h*J.length))},w=()=>{let{selectionStart:_,selectionEnd:V,value:Z}=m,J=Z.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-J,Z.slice(_,V).split(`
|
|
86
|
-
`).reduce((W,$,ee,fe)=>W.concat(ee?W[ee-1]+fe[ee-1].length+1:_),[]).reverse()},I=_=>{_.preventDefault(),_.stopPropagation()},A=!1,C=()=>{if(N)return;N=!0,L();let _=Mt.getScene(n)?.getElement(n.id);if(!_)return;let V=wt(_,s.scene.getNonDeletedElementsMap());if(V){if(m.value.trim()){let Z=Vo(V);!Z||Z!==n.id?O(V,{boundElements:(V.boundElements||[]).concat({type:"text",id:n.id})}):xe(V)&&Ai(V)}else O(V,{boundElements:V.boundElements?.filter(Z=>!U(Z))});Ot(_,V,s.scene.getNonDeletedElementsMap())}r({viaKeyboard:A,nextOriginalText:m.value})},L=()=>{m.onblur=null,m.oninput=null,m.onkeydown=null,B&&B.disconnect(),window.removeEventListener("resize",d),window.removeEventListener("wheel",I,!0),window.removeEventListener("pointerdown",z),window.removeEventListener("pointerup",M),window.removeEventListener("blur",C),window.removeEventListener("beforeunload",C),k(),m.remove()},M=_=>{window.removeEventListener("pointerup",M);let V=_?.target,Z=V instanceof HTMLElement&&V.classList.contains("active-color");setTimeout(()=>{if(m.onblur=C,Z){let J=(W,$)=>{W.find(fe=>fe.removedNodes.length>0&&fe.removedNodes[0].dataset?.radixPopperContentWrapper!==void 0)&&(setTimeout(()=>{m.focus()}),$.disconnect())};new MutationObserver(J).observe(document.querySelector(".excalidraw-container"),{childList:!0})}Z||m.focus()})},z=_=>{let V=_.target instanceof HTMLElement&&_.target.classList.contains("active-color");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&_.target.closest(`.${Dd.SHAPE_ACTIONS_MENU}`)&&!co(_.target)||V?(m.onblur=null,window.addEventListener("pointerup",M),window.addEventListener("blur",C)):_.target instanceof HTMLElement&&!_.target.contains(m)&&!Pr()&&requestAnimationFrame(()=>{C()})},k=Mt.getScene(n).onUpdate(()=>{d(),!!document.activeElement?.closest(".color-picker-content")||m.focus()}),N=!1;l&&m.select(),M();let B=null;i&&"ResizeObserver"in window?(B=new window.ResizeObserver(()=>{d()}),B.observe(i)):window.addEventListener("resize",d),m.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",z,{capture:!0})}),window.addEventListener("wheel",I,{passive:!1,capture:!0}),window.addEventListener("beforeunload",C),a?.querySelector(".excalidraw-textEditorContainer").appendChild(m)};ho();$m();f();be();Ae();Je();Xe();De();G();Ve();var uC=H({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=pe(e,t);return n.length===1&&U(n[0])&&!n[0].autoResize},perform:(e,t,r,o)=>{let n=pe(e,t);return{appState:t,elements:e.map(i=>{if(i.id===n[0].id&&U(i)){let a=Bt(i.originalText,Ie(i),i.lineHeight);return se(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),storeAction:D.CAPTURE}}});it();f();var hC=e=>{let t=["flowchart","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b${t.map(o=>`${o}(-beta)?`).join("|")}\\b`).test(e.trim())};import{Fragment as q_,jsx as je,jsxs as dh}from"react/jsx-runtime";var EC=Pn.createContext(null),xC=Pn.createContext(null),yC={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},qE=Pn.createContext(yC);qE.displayName="DeviceContext";var JE=Pn.createContext({container:null,id:null});JE.displayName="ExcalidrawContainerContext";var QE=Pn.createContext([]);QE.displayName="ExcalidrawElementsContext";var ex=Pn.createContext({...Qt(),width:0,height:0,offsetLeft:0,offsetTop:0});ex.displayName="ExcalidrawAppStateContext";var tx=Pn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});tx.displayName="ExcalidrawSetAppStateContext";var rx=Pn.createContext(null);rx.displayName="ExcalidrawActionManagerContext";var pr=()=>Ji(EC),zi=()=>Ji(xC),_e=()=>Ji(qE),Yt=()=>Ji(JE),Bi=()=>Ji(QE),Hi=()=>Ji(ex),Re=()=>Ji(tx),Ft=()=>Ji(rx),Ed=!1,KE=0,qa=!1,xd=!1,$E=!1,XE={horizontal:null,vertical:null},qi=0,yd=!1,ZE=new Map,ch=!1,fC=0,bC=!1,wd=null,He={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},jE=class e extends Pn.Component{canvas;interactiveCanvas=null;rc;unmounted=!1;actionManager;device=yC;excalidrawContainerRef=Pn.createRef();scene;renderer;fonts;resizeObserver;nearestScrollableContainer;library;libraryItemsFromStorage;id;store;history;excalidrawContainerValue;files={};imageCache=new Map;iFrameRefs=new Map;embedsValidationStatus=new Map;initializedEmbeds=new Set;elementsPendingErasure=new Set;hitLinkElement;lastPointerDownEvent=null;lastPointerUpEvent=null;lastPointerMoveEvent=null;lastViewportPosition={x:0,y:0};animationFrameHandler=new sh;laserTrails=new lh(this.animationFrameHandler,this);eraserTrail=new ja(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/200),i=(10-Math.min(10,t.totalLength-t.currentIndex))/10;return Math.min(Bn(i),Bn(n))},fill:()=>this.state.theme===ce.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});onChangeEmitter=new dr;onPointerDownEmitter=new dr;onPointerUpEmitter=new dr;onUserFollowEmitter=new dr;onScrollChangeEmitter=new dr;missingPointerEventCleanupEmitter=new dr;onRemoveEventListenersEmitter=new dr;constructor(t){super(t);let r=Qt(),{excalidrawAPI:o,viewModeEnabled:n=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=r.theme,name:c=`${E("labels.untitled")}-${Ch()}`}=t;if(this.state={...r,theme:l,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:n,zenModeEnabled:i,objectsSnapModeEnabled:s,gridSize:a?On:null,name:c,width:window.innerWidth,height:window.innerHeight},this.id=X_(),this.library=new WT(this),this.actionManager=new ku(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new Mt,this.canvas=document.createElement("canvas"),this.rc=$_.canvas(this.canvas),this.renderer=new bd(this.scene),this.store=new Lm,this.history=new nd,o){let d={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:m=>{this.actionManager.registerAction(m)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:m=>this.onChangeEmitter.on(m),onPointerDown:m=>this.onPointerDownEmitter.on(m),onPointerUp:m=>this.onPointerUpEmitter.on(m),onScrollChange:m=>this.onScrollChangeEmitter.on(m),onUserFollow:m=>this.onUserFollowEmitter.on(m)};typeof o=="function"?o(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new hd({scene:this.scene}),this.history=new nd,this.actionManager.registerAll(Sm),this.actionManager.registerAction(N3(this.history,this.store)),this.actionManager.registerAction(O3(this.history,this.store))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let o=null,n=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!n)break;for(let i of n)i.contentWindow===t.source&&(o=i.contentWindow);o?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let o=r.id,n=r.info.playerState;Object.values(Ol).includes(n)&&ZE.set(o,n)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},draggingElement:null,selectionElement:null})},100),po(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let o=ZE.get(t.id);switch(o||(ZE.set(t.id,Ol.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),o){case Ol.PLAYING:case Ol.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,o,n){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&o>=t.x+t.width/3&&o<=t.x+2*t.width/3&&n>=t.y+t.height/3&&n<=t.y+2*t.height/3}updateEmbedValidationStatus=(t,r)=>{this.embedsValidationStatus.set(t.id,r),Oe.delete(t)};updateEmbeddables=()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(o=>{if(kt(o)){if(t.add(o.id),!this.embedsValidationStatus.has(o.id)){r=!0;let n=Ps(o.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(o,n)}}else po(o)&&t.add(o.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((o,n)=>{t.has(n)||this.iFrameRefs.delete(n)})};renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,o=this.state.height,n=this.scene.getNonDeletedElements().filter(i=>kt(i)&&this.embedsValidationStatus.get(i.id)===!0||po(i));return je(q_,{children:n.map(i=>{let{x:a,y:s}=Ht({sceneX:i.x,sceneY:i.y},this.state),l=La(i,r,o,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(i.id);if(l&&!c&&this.initializedEmbeds.add(i.id),!(l||c))return null;let m;if(po(i)){m=null;let h=(i.customData?.generationData??this.magicGenerations.get(i.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(h.status==="done"){let g=h.html;m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>g}}else if(h.status==="pending")m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>gc(`
|
|
81
|
+
Please output JUST THE HTML file containing your best attempt at implementing the provided wireframes.`;async function vA({image:e,apiKey:t,text:r,theme:o=ue.LIGHT}){let n={model:"gpt-4-vision-preview",max_tokens:4096,temperature:.1,messages:[{role:"system",content:c9},{role:"user",content:[{type:"image_url",image_url:{url:e,detail:"high"}},{type:"text",text:`Above is the reference wireframe. Please make a new website based on these and return just the HTML file. Also, please make it for the ${o} theme. What follows are the wireframe's text annotations (if any)...`},{type:"text",text:r}]}]},i,a=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)});return a.ok?i={...await a.json(),ok:!0}:i={...await a.json(),ok:!1},i}os();pr();f();import d9 from"clsx";import{jsx as TA,jsxs as p9}from"react/jsx-runtime";var m9="small",bh=e=>p9("label",{className:d9("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${m9}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[TA("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),TA("div",{className:"ToolIcon__icon",children:e.icon})]});ee();f();ee();import{jsx as px,jsxs as SA}from"react/jsx-runtime";var u9=({height:e,width:t,userToFollow:r,onDisconnect:o})=>px("div",{className:"follow-mode",style:{width:t,height:e},children:SA("div",{className:"follow-mode__badge",children:[SA("div",{className:"follow-mode__badge__label",children:["Following"," ",px("span",{className:"follow-mode__badge__username",title:r.username,children:r.username})]}),px("button",{type:"button",onClick:o,className:"follow-mode__disconnect-btn",children:Ao})]})}),IA=u9;Re();f();var Eh=class{targets=new WeakMap;rafIds=new WeakMap;register(t,r){this.targets.set(t,{callback:r,stopped:!0})}start(t){let r=this.targets.get(t);r&&(this.rafIds.has(t)||(this.targets.set(t,{...r,stopped:!1}),this.scheduleFrame(t)))}stop(t){let r=this.targets.get(t);r&&!r.stopped&&this.targets.set(t,{...r,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return r=>{let o=this.targets.get(t);if(!o)return;let n=this.onFrame(o,r);!o.stopped&&!n?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){let r=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,r)}cancelFrame(t){if(this.rafIds.has(t)){let r=this.rafIds.get(t);cancelAnimationFrame(r)}this.rafIds.delete(t)}onFrame(t,r){return t.callback(r)??!1}};f();V();Y();import{LaserPointer as g9}from"@excalidraw/laser-pointer";var As=class{constructor(t,r,o){this.animationFrameHandler=t;this.app=r;this.options=o;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Ke,"path")}currentTrail;pastTrails=[];container;trailElement;get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(t,r){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===t&&this.currentTrail.originalPoints[o-1][1]===r}return!1}start(t){t&&(this.container=t),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(t,r){this.currentTrail=new g9(this.options),this.currentTrail.addPoint([t,r,performance.now()]),this.update()}addPointToPath(t,r){this.currentTrail&&(this.currentTrail.addPoint([t,r,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}update(){this.start()}onFrame(){let t=[];for(let o of this.pastTrails)t.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);t.push(o)}this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline().length!==0),t.length===0&&this.stop();let r=t.join(" ").trim();this.trailElement.setAttribute("d",r),this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(t,r){let o=t.getStrokeOutline(t.options.size/r.zoom.value).map(([n,i])=>{let a=$t({sceneX:n,sceneY:i},r);return[a.x,a.y]});return O0(o,!0)}};f();V();Y();var xh=class{constructor(t,r){this.animationFrameHandler=t;this.app=r;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new As(t,r,{...this.getTrailOptions(),fill:()=>kh})}localTrail;collabTrails=new Map;container;getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(ai(i),ai(n))}}}startPath(t,r){this.localTrail.startPath(t,r)}addPointToPath(t,r){this.localTrail.addPointToPath(t,r)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[t,r]of this.app.state.collaborators.entries()){let o;this.collabTrails.has(t)?o=this.collabTrails.get(t):(o=new As(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>r.pointer?.laserColor||vs(t,r)}),o.start(this.container),this.collabTrails.set(t,o)),r.pointer&&r.pointer.tool==="laser"&&(r.button==="down"&&!o.hasCurrentTrail&&o.startPath(r.pointer.x,r.pointer.y),r.button==="down"&&o.hasCurrentTrail&&!o.hasLastPoint(r.pointer.x,r.pointer.y)&&o.addPointToPath(r.pointer.x,r.pointer.y),r.button==="up"&&o.hasCurrentTrail&&(o.addPointToPath(r.pointer.x,r.pointer.y),o.endPath()))}for(let t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}};li();Zc();f();ye();V();cs();me();Y();De();He();Wt();na();Au();var h9=(e,t,r,o,n,i)=>{let{zoom:a}=o,s=180*r/Math.PI,l=e*(a.value-1)/2,c=t*(a.value-1)/2;return e>n&&a.value!==1&&(l=n*(a.value-1)/2),t>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value}) rotate(${s}deg)`},CA=({id:e,onChange:t,onSubmit:r,getViewportCoords:o,element:n,canvas:i,excalidrawContainer:a,app:s,autoSelect:l=!0})=>{let c=(R,W)=>{if(!W.style.fontFamily||!W.style.fontSize)return!1;let q=W.style.fontFamily.replace(/"/g,"");return Sn({fontFamily:R.fontFamily})!==q||`${R.fontSize}px`!==W.style.fontSize},d=()=>{let R=s.state,W=er.getScene(n)?.getElement(e);if(!W)return;let{textAlign:q,verticalAlign:re}=W,ge=s.scene.getNonDeletedElementsMap();if(W&&H(W)){let le=W.x,U=W.y,oe=Et(W,s.scene.getNonDeletedElementsMap()),Ie=W.width,Fe=W.height,lt=W.width,Je=W.height;if(oe&&W.containerId){if(ne(oe)){let xn=K.getBoundTextElementPosition(oe,W,ge);le=xn.x,U=xn.y}let En=c(W,m),lo;if(En?lo=ss(oe.id,oe.height):(lo=as[oe.id],lo||(lo=ss(oe.id,oe.height))),lt=br(oe,W),Je=ns(oe,W),!ne(oe)&&Fe>Je){let xn=Si(Fe,oe.type);F(oe,{height:xn});return}else if(!ne(oe)&&oe.height>lo.height&&Fe<Je){let xn=Si(Fe,oe.type);F(oe,{height:xn})}else{let{y:xn}=Ll(oe,W,ge);U=xn}}let[Gr,Wo]=o(le,U),nr=m.selectionStart,so=m.selectionEnd,Ri=m.value.length;if(nr===so&&so!==Ri){let En=Ri-so;m.selectionStart=m.value.length-En,m.selectionEnd=m.value.length-En}oe?Ie+=.5:(lt=(R.width-8-Gr)/R.zoom.value,Ie=Math.min(Ie,lt)),Fe*=1.05;let Ca=Me(W),Vo=Zx?0:Math.ceil(W.fontSize/2),vo=(R.height-Wo)/R.zoom.value;Object.assign(m.style,{font:Ca,lineHeight:W.lineHeight,width:`${Ie}px`,height:`${Fe}px`,left:`${Gr-Vo}px`,top:`${Wo}px`,transform:h9(Ie,Fe,e3(W,oe),R,lt,vo),padding:`0 ${Vo}px`,textAlign:q,verticalAlign:re,color:W.strokeColor,opacity:W.opacity/100,filter:"var(--theme-filter)",maxHeight:`${vo}px`}),m.scrollTop=0,Yr()&&(m.style.fontFamily=Sn(W)),F(W,{x:le,y:U})}},m=document.createElement("textarea");m.dir="auto",m.tabIndex=0,m.dataset.type="wysiwyg",m.wrap="off",m.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(ze(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(m.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),m.value=n.originalText,d(),t&&(m.onpaste=async R=>{let W=await pu(R,!0);if(!W.text)return;let q=Zi(W.text);if(!q)return;let re=Et(n,s.scene.getNonDeletedElementsMap()),ge=Me({fontSize:s.state.currentItemFontSize,fontFamily:s.state.currentItemFontFamily});if(re){let le=J(re,s.scene.getNonDeletedElementsMap()),U=Lo(`${m.value}${q}`,ge,br(re,le)),oe=ku(U,ge,!0);m.style.width=`${oe}px`}},m.oninput=()=>{t(Zi(m.value))}),m.onkeydown=R=>{if(!R.shiftKey&&rg.keyTest(R))R.preventDefault(),s.actionManager.executeAction(rg),d();else if(!R.shiftKey&&og.keyTest(R))R.preventDefault(),s.actionManager.executeAction(og),d();else if(AE.keyTest(R))s.actionManager.executeAction(AE);else if(ME.keyTest(R))s.actionManager.executeAction(ME);else if(R.key===S.ESCAPE)R.preventDefault(),M=!0,I();else if(R.key===S.ENTER&&R[S.CTRL_OR_CMD]){if(R.preventDefault(),R.isComposing||R.keyCode===229)return;M=!0,I()}else if(R.key===S.TAB||R[S.CTRL_OR_CMD]&&(R.code===Se.BRACKET_LEFT||R.code===Se.BRACKET_RIGHT)){if(R.preventDefault(),R.isComposing)return;R.shiftKey||R.code===Se.BRACKET_LEFT?y():v(),m.dispatchEvent(new Event("input"))}};let g=4,h=" ".repeat(g),x=new RegExp(`^ {1,${g}}`),v=()=>{let{selectionStart:R,selectionEnd:W}=m,q=w(),re=m.value;q.forEach(ge=>{let le=re.slice(0,ge),U=re.slice(ge);re=`${le}${h}${U}`}),m.value=re,m.selectionStart=R+g,m.selectionEnd=W+g*q.length},y=()=>{let{selectionStart:R,selectionEnd:W}=m,q=w(),re=[],ge=m.value;q.forEach(le=>{let U=ge.slice(le,le+g).match(x);if(U){let oe=ge.slice(0,le),Ie=ge.slice(le+U[0].length);ge=`${oe}${Ie}`,re.push(le)}}),m.value=ge,re.length&&(R>re[re.length-1]?m.selectionStart=Math.max(R-g,re[re.length-1]):m.selectionStart=R,m.selectionEnd=Math.max(m.selectionStart,W-g*re.length))},w=()=>{let{selectionStart:R,selectionEnd:W,value:q}=m,re=q.slice(0,R).match(/[^\n]*$/)[0].length;return R=R-re,q.slice(R,W).split(`
|
|
82
|
+
`).reduce((le,U,oe,Ie)=>le.concat(oe?le[oe-1]+Ie[oe-1].length+1:R),[]).reverse()},C=R=>{R.target instanceof HTMLCanvasElement&&(R.preventDefault(),R.stopPropagation())},M=!1,I=()=>{if(D)return;D=!0,P();let R=er.getScene(n)?.getElement(n.id);if(!R)return;let W=Et(R,s.scene.getNonDeletedElementsMap());if(W){if(m.value.trim()){let q=pn(W);!q||q!==n.id?F(W,{boundElements:(W.boundElements||[]).concat({type:"text",id:n.id})}):ne(W)&&Ki(W)}else F(W,{boundElements:W.boundElements?.filter(q=>!H(q))});ft(R,W,s.scene.getNonDeletedElementsMap())}r({viaKeyboard:M,nextOriginalText:m.value})},P=()=>{m.onblur=null,m.oninput=null,m.onkeydown=null,z&&z.disconnect(),window.removeEventListener("resize",d),window.removeEventListener("wheel",C,!0),window.removeEventListener("pointerdown",N),window.removeEventListener("pointerup",A),window.removeEventListener("blur",I),window.removeEventListener("beforeunload",I),k(),m.remove()},A=R=>{window.removeEventListener("pointerup",A);let W=R?.target,q=W instanceof HTMLElement&&W.classList.contains("properties-trigger");setTimeout(()=>{m.onblur=I,q||m.focus()})},N=R=>{let W=R?.target,q=W instanceof HTMLElement&&W.classList.contains("properties-trigger");(R.target instanceof HTMLElement||R.target instanceof SVGElement)&&R.target.closest(`.${vm.SHAPE_ACTIONS_MENU}`)&&!Tn(R.target)||q?(m.onblur=null,window.addEventListener("pointerup",A),window.addEventListener("blur",I)):R.target instanceof HTMLElement&&R.target instanceof HTMLCanvasElement&&!Yr()&&requestAnimationFrame(()=>{I()})},k=er.getScene(n).onUpdate(()=>{d(),!!document.activeElement?.closest(".properties-content")||m.focus()}),D=!1;l&&m.select(),A();let z=null;i&&"ResizeObserver"in window?(z=new window.ResizeObserver(()=>{d()}),z.observe(i)):window.addEventListener("resize",d),m.onpointerdown=R=>R.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",N,{capture:!0})}),window.addEventListener("wheel",C,{passive:!1,capture:!0}),window.addEventListener("beforeunload",I),a?.querySelector(".excalidraw-textEditorContainer").appendChild(m)};ko();tu();f();we();De();He();et();Re();V();$e();var AA=G({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=he(e,t);return n.length===1&&H(n[0])&&!n[0].autoResize},perform:(e,t,r,o)=>{let n=he(e,t);return{appState:t,elements:e.map(i=>{if(i.id===n[0].id&&H(i)){let a=Vt(i.originalText,Me(i),i.lineHeight);return pe(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),storeAction:_.CAPTURE}}});dt();f();var MA=e=>{let t=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${t.map(o=>`\\s*${o}(-beta)?`).join("|")})\\b`).test(e.trim())};kl();import{Fragment as y9,jsx as tt,jsxs as wh}from"react/jsx-runtime";var DA=Qn.createContext(null),_A=Qn.createContext(null),RA={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},xx=Qn.createContext(RA);xx.displayName="DeviceContext";var yx=Qn.createContext({container:null,id:null});yx.displayName="ExcalidrawContainerContext";var wx=Qn.createContext([]);wx.displayName="ExcalidrawElementsContext";var vx=Qn.createContext({...lr(),width:0,height:0,offsetLeft:0,offsetTop:0});vx.displayName="ExcalidrawAppStateContext";var Tx=Qn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Tx.displayName="ExcalidrawSetAppStateContext";var Sx=Qn.createContext(null);Sx.displayName="ExcalidrawActionManagerContext";var tr=()=>Sa(DA),Wn=()=>Sa(_A),Ne=()=>Sa(xx),Ft=()=>Sa(yx),da=()=>Sa(wx),Gn=()=>Sa(vx),Oe=()=>Sa(Tx),Xt=()=>Sa(Sx),sm=!1,gx=0,Ms=!1,lm=!1,hx=!1,fx={horizontal:null,vertical:null},Ta=0,cm=!1,bx=new Map,yh=!1,PA=0,LA=!1,dm=null,Ve={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Ex=class e extends Qn.Component{canvas;interactiveCanvas=null;rc;unmounted=!1;actionManager;device=RA;excalidrawContainerRef=Qn.createRef();scene;fonts;renderer;resizeObserver;nearestScrollableContainer;library;libraryItemsFromStorage;id;store;history;excalidrawContainerValue;files={};imageCache=new Map;iFrameRefs=new Map;embedsValidationStatus=new Map;initializedEmbeds=new Set;elementsPendingErasure=new Set;hitLinkElement;lastPointerDownEvent=null;lastPointerUpEvent=null;lastPointerMoveEvent=null;lastViewportPosition={x:0,y:0};animationFrameHandler=new Eh;laserTrails=new xh(this.animationFrameHandler,this);eraserTrail=new As(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/200),i=(10-Math.min(10,t.totalLength-t.currentIndex))/10;return Math.min(ai(i),ai(n))},fill:()=>this.state.theme===ue.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});onChangeEmitter=new wr;onPointerDownEmitter=new wr;onPointerUpEmitter=new wr;onUserFollowEmitter=new wr;onScrollChangeEmitter=new wr;missingPointerEventCleanupEmitter=new wr;onRemoveEventListenersEmitter=new wr;constructor(t){super(t);let r=lr(),{excalidrawAPI:o,viewModeEnabled:n=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=r.theme,name:c=`${E("labels.untitled")}-${Oh()}`}=t;if(this.state={...r,theme:l,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:n,zenModeEnabled:i,objectsSnapModeEnabled:s,gridSize:a?ni:null,name:c,width:window.innerWidth,height:window.innerHeight},this.id=b9(),this.library=new sI(this),this.actionManager=new Fg(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new er,this.canvas=document.createElement("canvas"),this.rc=f9.canvas(this.canvas),this.renderer=new am(this.scene),this.store=new Kp,this.history=new $d,o){let d={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:m=>{this.actionManager.registerAction(m)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:m=>this.onChangeEmitter.on(m),onPointerDown:m=>this.onPointerDownEmitter.on(m),onPointerUp:m=>this.onPointerUpEmitter.on(m),onScrollChange:m=>this.onScrollChangeEmitter.on(m),onUserFollow:m=>this.onUserFollowEmitter.on(m)};typeof o=="function"?o(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Lr({scene:this.scene}),this.history=new $d,this.actionManager.registerAll($m),this.actionManager.registerAction(ZI(this.history,this.store)),this.actionManager.registerAction(jI(this.history,this.store))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let o=null,n=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!n)break;for(let i of n)i.contentWindow===t.source&&(o=i.contentWindow);o?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let o=r.id,n=r.info.playerState;Object.values(bc).includes(n)&&bx.set(o,n)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},draggingElement:null,selectionElement:null})},100),Io(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let o=bx.get(t.id);switch(o||(bx.set(t.id,bc.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),o){case bc.PLAYING:case bc.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,o,n){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&o>=t.x+t.width/3&&o<=t.x+2*t.width/3&&n>=t.y+t.height/3&&n<=t.y+2*t.height/3}updateEmbedValidationStatus=(t,r)=>{this.embedsValidationStatus.set(t.id,r),_e.delete(t)};updateEmbeddables=()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(o=>{if(Rt(o)){if(t.add(o.id),!this.embedsValidationStatus.has(o.id)){r=!0;let n=hl(o.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(o,n)}}else Io(o)&&t.add(o.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((o,n)=>{t.has(n)||this.iFrameRefs.delete(n)})};renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,o=this.state.height,n=this.scene.getNonDeletedElements().filter(i=>Rt(i)&&this.embedsValidationStatus.get(i.id)===!0||Io(i));return tt(y9,{children:n.map(i=>{let{x:a,y:s}=$t({sceneX:i.x,sceneY:i.y},this.state),l=ds(i,r,o,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(i.id);if(l&&!c&&this.initializedEmbeds.add(i.id),!(l||c))return null;let m;if(Io(i)){m=null;let g=(i.customData?.generationData??this.magicGenerations.get(i.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(g.status==="done"){let h=g.html;m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>h}}else if(g.status==="pending")m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>id(`
|
|
87
83
|
<style>
|
|
88
84
|
html, body {
|
|
89
85
|
width: 100%;
|
|
90
86
|
height: 100%;
|
|
91
|
-
color: ${this.state.theme===
|
|
87
|
+
color: ${this.state.theme===ue.DARK?"white":"black"};
|
|
92
88
|
}
|
|
93
89
|
body {
|
|
94
90
|
display: flex;
|
|
@@ -155,7 +151,7 @@ Please output JUST THE HTML file containing your best attempt at implementing th
|
|
|
155
151
|
</svg>
|
|
156
152
|
</div>
|
|
157
153
|
<div>Generating...</div>
|
|
158
|
-
`)};else{let g
|
|
154
|
+
`)};else{let h;g.code==="ERR_GENERATION_INTERRUPTED"?h="Generation was interrupted...":h=g.message||"Generation failed",m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>id(`
|
|
159
155
|
<style>
|
|
160
156
|
html, body {
|
|
161
157
|
height: 100%;
|
|
@@ -165,7 +161,7 @@ Please output JUST THE HTML file containing your best attempt at implementing th
|
|
|
165
161
|
flex-direction: column;
|
|
166
162
|
align-items: center;
|
|
167
163
|
justify-content: center;
|
|
168
|
-
color: ${
|
|
164
|
+
color: ${Ee.red[3]};
|
|
169
165
|
}
|
|
170
166
|
h1, h3 {
|
|
171
167
|
margin-top: 0;
|
|
@@ -173,10 +169,10 @@ Please output JUST THE HTML file containing your best attempt at implementing th
|
|
|
173
169
|
}
|
|
174
170
|
</style>
|
|
175
171
|
<h1>Error!</h1>
|
|
176
|
-
<h3>${
|
|
177
|
-
`)}}}else m=Kn(Tm(i.link||""));let p=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="active",u=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="hover";return je("div",{className:gC("excalidraw__embeddable-container",{"is-hovered":u}),style:{transform:l?`translate(${a-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:l?"block":"none",opacity:Jg(i,Vt(i,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure),"--embeddable-radius":`${Uo(Math.min(i.width,i.height),i)}px`},children:dh("div",{className:"excalidraw__embeddable-container__inner",style:{width:l?`${i.width}px`:0,height:l?`${i.height}px`:0,transform:l?`rotate(${i.angle}rad)`:"none",pointerEvents:p?ra.enabled:ra.disabled},children:[u&&je("div",{className:"excalidraw__embeddable-hint",children:E("buttons.embeddableInteractionButton")}),je("div",{className:"excalidraw__embeddable__outer",style:{padding:`${i.strokeWidth}px`},children:(kt(i)?this.props.renderEmbeddable?.(i,this.state):null)??je("iframe",{ref:h=>this.cacheEmbeddableRef(i,h),className:"excalidraw__embeddable",srcDoc:m?.type==="document"?m.srcdoc(this.state.theme):void 0,src:m?.type!=="document"?m?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${m?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},i.id)})})}getFrameNameDOMId=t=>`${this.id}-frame-name-${t.id}`;frameNameBoundsCache={get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let o=document.getElementById(this.getFrameNameDOMId(t));if(o){let n=o.getBoundingClientRect(),i=$e({clientX:n.x,clientY:n.y},this.state),a=$e({clientX:n.right,clientY:n.bottom},this.state);return r={x:i.x,y:i.y,width:a.x-i.x,height:a.y-i.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map};renderFrameNames=()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return null;let t=this.state.theme===ce.DARK,r=0,o=0;return this.scene.getNonDeletedFramesLikes().map(n=>{if(gi(n)?r++:o++,!La(n,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return null;let{x:i,y:a}=Ht({sceneX:n.x,sceneY:n.y},this.state),s=6,l=()=>{O(n,{name:n.name?.trim()||null}),this.setState({editingFrame:null})},c,d=ep(n,gi(n)?r:o);if(n.id===this.state.editingFrame){let m=d;c=je("input",{autoFocus:!0,value:m,onChange:p=>{O(n,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>l(),onKeyDown:p=>{(p.key===S.ESCAPE||p.key===S.ENTER)&&l()},style:{background:this.state.viewBackgroundColor,filter:t?is:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-i-s}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return je("div",{id:this.getFrameNameDOMId(n),style:{position:"absolute",bottom:`${this.state.height+qe.nameOffsetY-a+this.state.offsetTop}px`,left:`${i-this.state.offsetLeft}px`,zIndex:2,fontSize:qe.nameFontSize,color:t?qe.nameColorDarkTheme:qe.nameColorLightTheme,lineHeight:qe.nameLineHeight,width:"max-content",maxWidth:`${n.width}px`,overflow:n.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Ne.MOVE,pointerEvents:this.state.viewModeEnabled?ra.disabled:ra.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:n.id})},children:c},n.id)})};toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:o}=this.props,n=this.scene.getSceneNonce(),{elementsMap:i,visibleElements:a}=this.renderer.getRenderableElements({sceneNonce:n,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingElement:this.state.editingElement,pendingImageElementId:this.state.pendingImageElementId}),s=this.scene.getNonDeletedElementsMap(),l=!(this.state.editingElement&&ie(this.state.editingElement))&&(this.state.selectionElement||this.state.draggingElement||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down"||this.state.editingElement&&!U(this.state.editingElement)),c=t[0];return je("div",{className:gC("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":l?ra.disabled:ra.enabled},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:je(EC.Provider,{value:this,children:je(xC.Provider,{value:this.props,children:je(JE.Provider,{value:this.excalidrawContainerValue,children:je(qE.Provider,{value:this.device,children:je(tx.Provider,{value:this.setAppState,children:je(ex.Provider,{value:this.state,children:dh(QE.Provider,{value:this.scene.getNonDeletedElements(),children:[dh(rx.Provider,{value:this.actionManager,children:[je(kI,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Dn().code,renderTopRightUI:r,renderCustomStats:o,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,openAIKey:this.OPENAI_KEY,isOpenAIKeyPersisted:this.OPENAI_KEY_IS_PERSISTED,onOpenAIAPIKeyChange:this.onOpenAIKeyChange,onMagicSettingsConfirm:this.onMagicSettingsConfirm,children:this.props.children}),je("div",{className:"excalidraw-textEditorContainer"}),je("div",{className:"excalidraw-contextMenuContainer"}),je("div",{className:"excalidraw-eye-dropper-container"}),je(sC,{trails:[this.laserTrails,this.eraserTrail]}),t.length===1&&this.state.showHyperlinkPopup&&je(AT,{element:c,elementsMap:s,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&sa(c)&&je(WE,{element:c,elementsMap:i,children:je(ah,{title:E("labels.convertToCode"),icon:el,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&po(c)&&c.customData?.generationData?.status==="done"&&dh(WE,{element:c,elementsMap:i,children:[je(ah,{title:E("labels.copySource"),icon:Pp,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),je(ah,{title:"Enter fullscreen",icon:X2,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(c);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},draggingElement:null,selectionElement:null})}catch(m){console.warn(m),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&je(LI,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&je(z3,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:d=>{this.setState({contextMenu:null},()=>{this.focusContainer(),d?.()})}}),je(GE,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:s,visibleElements:a,sceneNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!0,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure}}),je(UE,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,allElementsMap:s,selectedElements:t,sceneNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&je(mC,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}focusContainer=()=>{this.excalidrawContainerRef.current?.focus()};getSceneElementsIncludingDeleted=()=>this.scene.getElementsIncludingDeleted();getSceneElements=()=>this.scene.getNonDeletedElements();onInsertElements=t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})};onExportImage=async(t,r,o)=>{ve("export",t,"ui");let n=await Ga(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:o.exportingFrame}).catch(Yd).catch(i=>{console.error(i),this.setState({errorMessage:i.message})});this.state.exportEmbedScene&&n&&Bs(n)&&this.setState({fileHandle:n})};magicGenerations=new Map;updateMagicGeneration=({frameElement:t,data:r})=>{r.status==="pending"?O(t,{customData:{generationData:void 0}},!1):O(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.triggerRender()};getTextFromElements(t){return t.reduce((o,n)=>(U(n)&&o.push(n.text),o),[]).join(`
|
|
172
|
+
<h3>${h}</h3>
|
|
173
|
+
`)}}}else m=xi(Km(i.link||""));let p=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="active",u=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="hover";return tt("div",{className:kA("excalidraw__embeddable-container",{"is-hovered":u}),style:{transform:l?`translate(${a-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:l?"block":"none",opacity:Eb(i,Qt(i,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure),"--embeddable-radius":`${fo(Math.min(i.width,i.height),i)}px`},children:wh("div",{className:"excalidraw__embeddable-container__inner",style:{width:l?`${i.width}px`:0,height:l?`${i.height}px`:0,transform:l?`rotate(${i.angle}rad)`:"none",pointerEvents:p?ka.enabled:ka.disabled},children:[u&&tt("div",{className:"excalidraw__embeddable-hint",children:E("buttons.embeddableInteractionButton")}),tt("div",{className:"excalidraw__embeddable__outer",style:{padding:`${i.strokeWidth}px`},children:(Rt(i)?this.props.renderEmbeddable?.(i,this.state):null)??tt("iframe",{ref:g=>this.cacheEmbeddableRef(i,g),className:"excalidraw__embeddable",srcDoc:m?.type==="document"?m.srcdoc(this.state.theme):void 0,src:m?.type!=="document"?m?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${m?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},i.id)})})}getFrameNameDOMId=t=>`${this.id}-frame-name-${t.id}`;frameNameBoundsCache={get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let o=document.getElementById(this.getFrameNameDOMId(t));if(o){let n=o.getBoundingClientRect(),i=Qe({clientX:n.x,clientY:n.y},this.state),a=Qe({clientX:n.right,clientY:n.bottom},this.state);return r={x:i.x,y:i.y,width:a.x-i.x,height:a.y-i.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map};renderFrameNames=()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return null;let t=this.state.theme===ue.DARK;return this.scene.getNonDeletedFramesLikes().map(r=>{if(!ds(r,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return null;let{x:o,y:n}=$t({sceneX:r.x,sceneY:r.y},this.state),i=6,a=()=>{F(r,{name:r.name?.trim()||null}),this.setState({editingFrame:null})},s,l=lu(r);if(r.id===this.state.editingFrame){let c=l;s=tt("input",{autoFocus:!0,value:c,onChange:d=>{F(r,{name:d.target.value})},onFocus:d=>d.target.select(),onBlur:()=>a(),onKeyDown:d=>{(d.key===S.ESCAPE||d.key===S.ENTER)&&a()},style:{background:this.state.viewBackgroundColor,filter:t?Fs:"none",zIndex:2,border:"none",display:"block",padding:`${i}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${i}px, ${i}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-o-i}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else s=l;return tt("div",{id:this.getFrameNameDOMId(r),style:{position:"absolute",bottom:`${this.state.height+rt.nameOffsetY-n+this.state.offsetTop}px`,left:`${o-this.state.offsetLeft}px`,zIndex:2,fontSize:rt.nameFontSize,color:t?rt.nameColorDarkTheme:rt.nameColorLightTheme,lineHeight:rt.nameLineHeight,width:"max-content",maxWidth:`${r.width}px`,overflow:r.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Be.MOVE,pointerEvents:this.state.viewModeEnabled?ka.disabled:ka.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:r.id})},children:s},r.id)})};toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:o}=this.props,n=this.scene.getSceneNonce(),{elementsMap:i,visibleElements:a}=this.renderer.getRenderableElements({sceneNonce:n,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingElement:this.state.editingElement,pendingImageElementId:this.state.pendingImageElementId}),s=this.scene.getNonDeletedElementsMap(),l=!(this.state.editingElement&&ie(this.state.editingElement))&&(this.state.selectionElement||this.state.draggingElement||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down"||this.state.editingElement&&!H(this.state.editingElement)),c=t[0];return tt("div",{className:kA("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":l?ka.disabled:ka.enabled},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:tt(DA.Provider,{value:this,children:tt(_A.Provider,{value:this.props,children:tt(yx.Provider,{value:this.excalidrawContainerValue,children:tt(xx.Provider,{value:this.device,children:tt(Tx.Provider,{value:this.setAppState,children:tt(vx.Provider,{value:this.state,children:wh(wx.Provider,{value:this.scene.getNonDeletedElements(),children:[wh(Sx.Provider,{value:this.actionManager,children:[tt(G5,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:ei().code,renderTopRightUI:r,renderCustomStats:o,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,openAIKey:this.OPENAI_KEY,isOpenAIKeyPersisted:this.OPENAI_KEY_IS_PERSISTED,onOpenAIAPIKeyChange:this.onOpenAIKeyChange,onMagicSettingsConfirm:this.onMagicSettingsConfirm,children:this.props.children}),tt("div",{className:"excalidraw-textEditorContainer"}),tt("div",{className:"excalidraw-contextMenuContainer"}),tt("div",{className:"excalidraw-eye-dropper-container"}),tt(wA,{trails:[this.laserTrails,this.eraserTrail]}),t.length===1&&this.state.showHyperlinkPopup&&tt(YS,{element:c,elementsMap:s,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&_a(c)&&tt(mx,{element:c,elementsMap:i,children:tt(bh,{title:E("labels.convertToCode"),icon:$s,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&Io(c)&&c.customData?.generationData?.status==="done"&&wh(mx,{element:c,elementsMap:i,children:[tt(bh,{title:E("labels.copySource"),icon:ap,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),tt(bh,{title:"Enter fullscreen",icon:xw,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(c);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},draggingElement:null,selectionElement:null})}catch(m){console.warn(m),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&tt(V5,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&tt(QI,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:d=>{this.setState({contextMenu:null},()=>{this.focusContainer(),d?.()})}}),tt(dx,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:s,visibleElements:a,sceneNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!0,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure}}),tt(cx,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,allElementsMap:s,selectedElements:t,sceneNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&tt(IA,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}focusContainer=()=>{this.excalidrawContainerRef.current?.focus()};getSceneElementsIncludingDeleted=()=>this.scene.getElementsIncludingDeleted();getSceneElements=()=>this.scene.getNonDeletedElements();onInsertElements=t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})};onExportImage=async(t,r,o)=>{Ce("export",t,"ui");let n=await xs(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:o.exportingFrame}).catch(Nm).catch(i=>{console.error(i),this.setState({errorMessage:i.message})});this.state.exportEmbedScene&&n&&Js(n)&&this.setState({fileHandle:n})};magicGenerations=new Map;updateMagicGeneration=({frameElement:t,data:r})=>{r.status==="pending"?F(t,{customData:{generationData:void 0}},!1):F(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.triggerRender()};getTextFromElements(t){return t.reduce((o,n)=>(H(n)&&o.push(n.text),o),[]).join(`
|
|
178
174
|
|
|
179
|
-
`)}async onMagicFrameGenerate(t,r){if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"generation"}}),ve("ai","generate (missing key)","d2c");return}let o=Us(this.scene.getNonDeletedElements(),t).filter(m=>!sa(m));if(!o.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ve("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let n=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(!n)return;this.updateMagicGeneration({frameElement:n,data:{status:"pending"}}),this.setState({selectedElementIds:{[n.id]:!0}});let i=await ap({elements:this.scene.getNonDeletedElements(),appState:{...this.state,exportBackground:!0,viewBackgroundColor:this.state.viewBackgroundColor},exportingFrame:t,files:this.files}),a=await Bm(i),s=this.getTextFromElements(o);ve("ai","generate (start)","d2c");let l=await lC({image:a,apiKey:this.OPENAI_KEY,text:s,theme:this.state.theme});if(!l.ok){ve("ai","generate (failed)","d2c"),console.error(l.error),this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:l.error?.message||"Unknown error during generation"}});return}if(ve("ai","generate (success)","d2c"),l.choices[0].message.content==null){this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let c=l.choices[0].message.content,d=c.slice(c.indexOf("<!DOCTYPE html>"),c.indexOf("</html>")+7);this.updateMagicGeneration({frameElement:n,data:{status:"done",html:d}})}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(Jn(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}OPENAI_KEY=Hr.get(lo.OAI_API_KEY);OPENAI_KEY_IS_PERSISTED=Hr.has(lo.OAI_API_KEY)||!1;onOpenAIKeyChange=(t,r)=>{if(this.OPENAI_KEY=t||null,r){let o=Hr.set(lo.OAI_API_KEY,t);this.OPENAI_KEY_IS_PERSISTED=o}else this.OPENAI_KEY_IS_PERSISTED=!1};onMagicSettingsConfirm=(t,r,o)=>{if(this.OPENAI_KEY=t||null,this.onOpenAIKeyChange(this.OPENAI_KEY,r),o==="settings")return;let n=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});t?n.length?this.onMagicframeToolSelect():this.setActiveTool({type:"magicframe"}):sa(n[0])||this.setActiveTool({type:"magicframe"})};onMagicframeToolSelect=()=>{if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"tool"}}),ve("ai","tool-select (missing key)","d2c");return}let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:xt.magicframe}),ve("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&sa(t[0])&&t[0];if(!r&&t.some(n=>re(n)||n.frameId)){this.setActiveTool({type:xt.magicframe});return}ve("ai","tool-select (existing selection)","d2c");let o;if(r)o=r;else{let[n,i,a,s]=we(t),l=50;o=lc({...qe,x:n-l,y:i-l,width:a-n+l*2,height:s-i+l*2,opacity:100,locked:!1}),this.scene.insertElement(o);for(let c of t)O(c,{frameId:o.id});this.setState({selectedElementIds:{[o.id]:!0}})}this.onMagicFrameGenerate(o,"upstream")}};openEyeDropper=({type:t})=>{nr.set(Oi,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,o)=>{let n=t==="background"&&o.altKey||t==="stroke"&&!o.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?n?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},storeAction:D.CAPTURE}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},storeAction:D.CAPTURE}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?se(a,{[n?"strokeColor":"backgroundColor"]:r}):a),storeAction:D.CAPTURE})},keepOpenOnAlt:!1})};syncActionResult=dt(t=>{if(this.unmounted||t===!1)return;t.storeAction===D.UPDATE?this.store.shouldUpdateSnapshot():t.storeAction===D.CAPTURE&&this.store.shouldCaptureIncrement();let r=!1,o=null;if(t.elements&&(t.elements.forEach(n=>{this.state.editingElement?.id===n.id&&this.state.editingElement!==n&&$l(n)&&(o=n)}),this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.files=t.replaceFiles?t.files:{...this.files,...t.files},this.addNewImagesToImageCache()),t.appState||o||this.state.contextMenu){let n=t?.appState?.viewModeEnabled||!1,i=t?.appState?.zenModeEnabled||!1,a=t?.appState?.gridSize||null,s=t?.appState?.theme||this.props.theme||ce.LIGHT,l=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(n=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(i=this.props.zenModeEnabled),typeof this.props.gridModeEnabled<"u"&&(a=this.props.gridModeEnabled?On:null),o=o||t.appState?.editingElement||null,o?.isDeleted&&(o=null),this.setState(d=>Object.assign(t.appState||{},{contextMenu:null,editingElement:o,viewModeEnabled:n,zenModeEnabled:i,gridSize:a,theme:s,name:l,errorMessage:c})),r=!0}!r&&t.storeAction!==D.NONE&&this.scene.triggerUpdate()});onBlur=dt(()=>{qa=!1,this.setState({isBindingEnabled:!0})});onUnload=()=>{this.onBlur()};disableEvent=t=>{t.preventDefault()};resetHistory=()=>{this.history.clear()};resetStore=()=>{this.store.clear()};resetScene=dt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...Qt(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()});initializeScene=async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async o=>{if(!o.files.length)return;let n=o.files[0],i=await n.getFile();this.loadFileToCanvas(new File([i],i.name||"",{type:i.type}),n)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(o=>{console.error(o)})}catch(o){console.error(o),t={appState:{errorMessage:o.message||"Encountered an error during importing or restoring scene data"}}}let r=Mi(t,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...bn(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.fonts.loadFontsForElements(r.elements),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,storeAction:D.UPDATE})};isMobileBreakpoint=(t,r)=>t<Hx||r<Gx&&t<Ux;refreshViewportBreakpoints=()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:o}=document.body,n=this.device.viewport,i=ds(n,{isLandscape:r>o,isMobile:this.isMobileBreakpoint(r,o)});return n!==i?(this.device={...this.device,viewport:i},!0):!1};refreshEditorBreakpoints=()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:o}=t.getBoundingClientRect(),n=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:Wx,i=this.device.editor,a=ds(i,{isMobile:this.isMobileBreakpoint(r,o),canFitSidebar:r>n});return i!==a?(this.device={...this.device,editor:a},!0):!1};async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,T.MODE===Mr.TEST||T.DEV){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...o)=>this.setState(...o)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store}})}this.store.onStoreIncrementEmitter.on(r=>{this.history.record(r.elementsChange,r.appStateChange)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Pr()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),Rl&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),Ax()&&!y0()&&this.setState({errorMessage:je(KI,{})})}componentWillUnmount(){this.renderer.destroy(),this.scene=new Mt,this.fonts=new hd({scene:this.scene}),this.renderer=new bd(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.scene.destroy(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),Oe.destroy(),ko.destroy(),clearTimeout(qi),Ke.clearCache(),er.clearCache(),qi=0,document.documentElement.style.overscrollBehaviorX=""}onResize=dt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Oe.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),Rl||this.refreshEditorBreakpoints(),this.setState({})});onFullscreenChange=()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})};removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(gt(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(gt(this.excalidrawContainerRef.current,"wheel",this.onWheel,{passive:!1}),gt(window,"message",this.onWindowMessage,!1),gt(document,"pointerup",this.removePointer),gt(document,"copy",this.onCopy),gt(document,"keyup",this.onKeyUp,{passive:!0}),gt(document,"pointermove",this.updateCurrentCursorPosition),gt(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onFontsLoaded(r)}),gt(document,"gesturestart",this.onGestureStart,!1),gt(document,"gesturechange",this.onGestureChange,!1),gt(document,"gestureend",this.onGestureEnd,!1),gt(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(gt(document,"fullscreenchange",this.onFullscreenChange),gt(document,"paste",this.pasteFromClipboard),gt(document,"cut",this.onCut),gt(window,"resize",this.onResize,!1),gt(window,"unload",this.onUnload,!1),gt(window,"blur",this.onBlur,!1),gt(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),gt(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(gt(n1(this.excalidrawContainerRef.current),"scroll",this.onScroll)))}componentDidUpdate(t,r){this.updateEmbeddables();let o=this.scene.getElementsIncludingDeleted(),n=this.scene.getElementsMapIncludingDeleted(),i=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!o.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&Nr(this.state)&&this.setState({activeTool:et(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&xg(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),Nr(r)&&!Nr(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),t.gridModeEnabled!==this.props.gridModeEnabled&&this.setState({gridSize:this.props.gridModeEnabled?On:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ce.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(To)}),this.state.editingElement?.isDeleted&&this.setState({editingElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:s}=r;r.activeTool!==this.state.activeTool&&s!=null&&hn(this.state)&&Dr(s,!1)&&oc(s,this.state,Bo(j.getPointAtIndexGlobalCoordinates(s,-1,i)),this),this.store.commit(n,this.state),this.state.isLoading||(this.props.onChange?.(o,this.state,this.files),this.onChangeEmitter.trigger(o,this.state,this.files))}renderInteractiveSceneCallback=({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:o})=>{r&&(XE=r);let n=U(this.state.editingElement)?!1:!t&&o.size>0;this.state.scrolledOutside!==n&&this.setState({scrolledOutside:n}),this.scheduleImageRefresh()};onScroll=aa(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(o=>o.offsetLeft===r&&o.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},Fx);onCut=dt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||co(t.target)||(this.actionManager.executeAction(qp,"keyboard",t),t.preventDefault(),t.stopPropagation())});onCopy=dt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||co(t.target)||(this.actionManager.executeAction(ml,"keyboard",t),t.preventDefault(),t.stopPropagation())});static resetTapTwice(){Ed=!1}onTouchStart=t=>{if(Pd&&t.preventDefault(),!Ed){Ed=!0,clearTimeout(KE),KE=window.setTimeout(e.resetTapTwice,Ox);return}if(Ed&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),Ed=!1,clearTimeout(KE)}t.touches.length===2&&this.setState({selectedElementIds:Fe({},this.state),activeEmbeddable:null})};onTouchEnd=t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Fe(this.state.previousSelectedElementIds,this.state)}):He.pointers.clear()};pasteFromClipboard=dt(async t=>{let r=!!ch,o=document.activeElement,n=this.excalidrawContainerRef.current?.contains(o);if(t&&!n)return;let i=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(i instanceof HTMLCanvasElement)||co(o)))return;let{x:a,y:s}=$e({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),l=t?.clipboardData?.files[0],c=await np(t,r);if(!l&&!r){if(c.mixedContent)return this.addElementsFromMixedContentPaste(c.mixedContent,{isPlainPaste:r,sceneX:a,sceneY:s});if(c.text){let d=c.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(l=Dg(d))}}if(Li(l)&&!c.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:E("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:a,sceneY:s});this.insertImageElement(d,l),this.initializeImageDimensions(d),this.setState({selectedElementIds:Fe({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}if(c.errorMessage)this.setState({errorMessage:c.errorMessage});else if(c.spreadsheet&&!r)this.setState({pasteDialog:{data:c.spreadsheet,shown:!0}});else if(c.elements){let d=c.programmaticAPI?Cl(c.elements):c.elements;this.addElementsFromPasteOrLibrary({elements:d,files:c.files||null,position:"cursor",retainSeed:r})}else if(c.text){if(c.text&&hC(c.text)){let p=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:u,files:h}=await p.parseMermaidToExcalidraw(c.text,{fontSize:Tt}),g=Cl(u,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:g,files:h,position:"cursor"});return}catch(u){console.warn(`parsing pasted text as mermaid definition failed: ${u.message}`)}}let d=Zd(c.text).split(/\n+/).map(p=>p.trim()).filter(Boolean),m=d.map(p=>V0(p)).filter(p=>Ps(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||Kn(p)?.type==="video"));if(!ch&&m.length>0&&m.length===d.length){let p=[];for(let u of m){let h=p[p.length-1],g=this.insertEmbeddableElement({sceneX:h?h.x+h.width+20:a,sceneY:s,link:vr(u)});g&&p.push(g)}p.length&&this.setState({selectedElementIds:Object.fromEntries(p.map(u=>[u.id,!0]))});return}this.addTextFromPaste(c.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()});addElementsFromPasteOrLibrary=t=>{let r=xc(t.elements,null,void 0),[o,n,i,a]=we(r),s=_t(o,i)/2,l=_t(n,a)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:m,y:p}=$e({clientX:c,clientY:d},this.state),u=m-s,h=p-l,[g,x]=Lt(u,h,this.state.gridSize),v=Mm(r.map(C=>se(C,{x:C.x+g-o,y:C.y+x-n})),{randomizeSeed:!t.retainSeed}),w=[...this.scene.getElementsIncludingDeleted(),...v];Ut(w,X(v));let I=this.getTopLayerFrameAtSceneCoords({x:m,y:p});if(I){let C=iw(v,I);Lc(w,C,I)}this.scene.replaceAllElements(w),v.forEach(C=>{if(U(C)&&Me(C)){let L=wt(C,this.scene.getElementsMapIncludingDeleted());Ot(C,L,this.scene.getElementsMapIncludingDeleted())}}),t.files&&(this.files={...this.files,...t.files}),this.store.shouldCaptureIncrement();let A=Ra(v);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&nr.get(cd)?this.state.openSidebar:null,...er({editingGroupId:null,selectedElementIds:A.reduce((C,L)=>(Me(L)||(C[L.id]=!0),C),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(v,{fitToContent:!0})};async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:o,sceneY:n}){if(!r&&t.some(i=>i.type==="imageUrl")&&this.isToolSupported("image")){let i=t.filter(m=>m.type==="imageUrl").map(m=>m.value),a=await Promise.all(i.map(async m=>{try{return{file:await py(m)}}catch(p){let u=p.message;return p.cause==="FETCH_ERROR"?u=E("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(u=E("errors.unsupportedFileType")),{errorMessage:u}}})),s=n,l=!1,c={};for(let m of a)if(m.file){let p=this.createImageElement({sceneX:o,sceneY:s}),u=await this.insertImageElement(p,m.file);u&&(l||(l=!0,s-=u.height/2),O(u,{y:s},!1),s=p.y+p.height+25,c[p.id]=!0)}this.setState({selectedElementIds:Fe(c,this.state)});let d=a.find(m=>!!m.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let i=t.filter(a=>a.type==="text");i.length&&this.addTextFromPaste(i.map(a=>a.value).join(`
|
|
175
|
+
`)}async onMagicFrameGenerate(t,r){if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"generation"}}),Ce("ai","generate (missing key)","d2c");return}let o=El(this.scene.getNonDeletedElements(),t).filter(m=>!_a(m));if(!o.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),Ce("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let n=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(!n)return;this.updateMagicGeneration({frameElement:n,data:{status:"pending"}}),this.setState({selectedElementIds:{[n.id]:!0}});let i=await gu({elements:this.scene.getNonDeletedElements(),appState:{...this.state,exportBackground:!0,viewBackgroundColor:this.state.viewBackgroundColor},exportingFrame:t,files:this.files}),a=await wp(i),s=this.getTextFromElements(o);Ce("ai","generate (start)","d2c");let l=await vA({image:a,apiKey:this.OPENAI_KEY,text:s,theme:this.state.theme});if(!l.ok){Ce("ai","generate (failed)","d2c"),console.error(l.error),this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:l.error?.message||"Unknown error during generation"}});return}if(Ce("ai","generate (success)","d2c"),l.choices[0].message.content==null){this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let c=l.choices[0].message.content,d=c.slice(c.indexOf("<!DOCTYPE html>"),c.indexOf("</html>")+7);this.updateMagicGeneration({frameElement:n,data:{status:"done",html:d}})}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(wi(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}OPENAI_KEY=ro.get(To.OAI_API_KEY);OPENAI_KEY_IS_PERSISTED=ro.has(To.OAI_API_KEY)||!1;onOpenAIKeyChange=(t,r)=>{if(this.OPENAI_KEY=t||null,r){let o=ro.set(To.OAI_API_KEY,t);this.OPENAI_KEY_IS_PERSISTED=o}else this.OPENAI_KEY_IS_PERSISTED=!1};onMagicSettingsConfirm=(t,r,o)=>{if(this.OPENAI_KEY=t||null,this.onOpenAIKeyChange(this.OPENAI_KEY,r),o==="settings")return;let n=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});t?n.length?this.onMagicframeToolSelect():this.setActiveTool({type:"magicframe"}):_a(n[0])||this.setActiveTool({type:"magicframe"})};onMagicframeToolSelect=()=>{if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"tool"}}),Ce("ai","tool-select (missing key)","d2c");return}let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:It.magicframe}),Ce("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&_a(t[0])&&t[0];if(!r&&t.some(n=>Q(n)||n.frameId)){this.setActiveTool({type:It.magicframe});return}Ce("ai","tool-select (existing selection)","d2c");let o;if(r)o=r;else{let[n,i,a,s]=Te(t),l=50;o=Uc({...rt,x:n-l,y:i-l,width:a-n+l*2,height:s-i+l*2,opacity:100,locked:!1}),this.scene.insertElement(o);for(let c of t)F(c,{frameId:o.id});this.setState({selectedElementIds:{[o.id]:!0}})}this.onMagicFrameGenerate(o,"upstream")}};openEyeDropper=({type:t})=>{mr.set(ca,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,o)=>{let n=t==="background"&&o.altKey||t==="stroke"&&!o.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?n?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},storeAction:_.CAPTURE}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},storeAction:_.CAPTURE}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?pe(a,{[n?"strokeColor":"backgroundColor"]:r}):a),storeAction:_.CAPTURE})},keepOpenOnAlt:!1})};dismissLinearEditor=()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})};syncActionResult=bt(t=>{if(this.unmounted||t===!1)return;t.storeAction===_.UPDATE?this.store.shouldUpdateSnapshot():t.storeAction===_.CAPTURE&&this.store.shouldCaptureIncrement();let r=!1,o=null;if(t.elements&&(t.elements.forEach(n=>{this.state.editingElement?.id===n.id&&this.state.editingElement!==n&&Sd(n)&&(o=n)}),this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.files=t.replaceFiles?t.files:{...this.files,...t.files},this.addNewImagesToImageCache()),t.appState||o||this.state.contextMenu){let n=t?.appState?.viewModeEnabled||!1,i=t?.appState?.zenModeEnabled||!1,a=t?.appState?.gridSize||null,s=t?.appState?.theme||this.props.theme||ue.LIGHT,l=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(n=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(i=this.props.zenModeEnabled),typeof this.props.gridModeEnabled<"u"&&(a=this.props.gridModeEnabled?ni:null),o=o||t.appState?.editingElement||null,o?.isDeleted&&(o=null),this.setState(d=>Object.assign(t.appState||{},{contextMenu:null,editingElement:o,viewModeEnabled:n,zenModeEnabled:i,gridSize:a,theme:s,name:l,errorMessage:c})),r=!0}!r&&t.storeAction!==_.NONE&&this.scene.triggerUpdate()});onBlur=bt(()=>{Ms=!1,this.setState({isBindingEnabled:!0})});onUnload=()=>{this.onBlur()};disableEvent=t=>{t.preventDefault()};resetHistory=()=>{this.history.clear()};resetStore=()=>{this.store.clear()};resetScene=bt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...lr(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()});initializeScene=async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async o=>{if(!o.files.length)return;let n=o.files[0],i=await n.getFile();this.loadFileToCanvas(new File([i],i.name||"",{type:i.type}),n)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(o=>{console.error(o)})}catch(o){console.error(o),t={appState:{errorMessage:o.message||"Encountered an error during importing or restoring scene data"}}}let r=Xi(t,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,..._n(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,storeAction:_.UPDATE}),this.fonts.loadSceneFonts()};isMobileBreakpoint=(t,r)=>t<c0||r<m0&&t<d0;refreshViewportBreakpoints=()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:o}=document.body,n=this.device.viewport,i=Us(n,{isLandscape:r>o,isMobile:this.isMobileBreakpoint(r,o)});return n!==i?(this.device={...this.device,viewport:i},!0):!1};refreshEditorBreakpoints=()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:o}=t.getBoundingClientRect(),n=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:p0,i=this.device.editor,a=Us(i,{isMobile:this.isMobileBreakpoint(r,o),canFitSidebar:r>n});return i!==a?(this.device={...this.device,editor:a},!0):!1};async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,T.MODE===Kt.TEST||T.DEV){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...o)=>this.setState(...o)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onStoreIncrementEmitter.on(r=>{this.history.record(r.elementsChange,r.appStateChange)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Yr()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),hc&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),jx()&&!n3()&&this.setState({errorMessage:tt(aA,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new er,this.fonts=new Lr({scene:this.scene}),this.renderer=new am(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),_e.destroy(),zo.destroy(),clearTimeout(Ta),qe.clearCache(),cr.clearCache(),Ta=0,document.documentElement.style.overscrollBehaviorX=""}onResize=bt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>_e.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),hc||this.refreshEditorBreakpoints(),this.setState({})});onFullscreenChange=()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})};removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(vt(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(vt(this.excalidrawContainerRef.current,"wheel",this.onWheel,{passive:!1}),vt(window,"message",this.onWindowMessage,!1),vt(document,"pointerup",this.removePointer),vt(document,"copy",this.onCopy),vt(document,"keyup",this.onKeyUp,{passive:!0}),vt(document,"pointermove",this.updateCurrentCursorPosition),vt(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)}),vt(document,"gesturestart",this.onGestureStart,!1),vt(document,"gesturechange",this.onGestureChange,!1),vt(document,"gestureend",this.onGestureEnd,!1),vt(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(vt(document,"fullscreenchange",this.onFullscreenChange),vt(document,"paste",this.pasteFromClipboard),vt(document,"cut",this.onCut),vt(window,"resize",this.onResize,!1),vt(window,"unload",this.onUnload,!1),vt(window,"blur",this.onBlur,!1),vt(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),vt(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(vt(A0(this.excalidrawContainerRef.current),"scroll",this.onScroll)))}componentDidUpdate(t,r){this.updateEmbeddables();let o=this.scene.getElementsIncludingDeleted(),n=this.scene.getElementsMapIncludingDeleted(),i=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!o.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&$r(this.state)&&this.setState({activeTool:nt(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&Yh(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),$r(r)&&!$r(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),t.gridModeEnabled!==this.props.gridModeEnabled&&this.setState({gridSize:this.props.gridModeEnabled?ni:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ue.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(xo)}),this.state.editingElement?.isDeleted&&this.setState({editingElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:s}=r;r.activeTool!==this.state.activeTool&&s!=null&&Fn(this.state)&&Kr(s,!1)&&Jc(s,this.state,ar(K.getPointAtIndexGlobalCoordinates(s,-1,i)),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.store.commit(n,this.state),this.state.isLoading||(this.props.onChange?.(o,this.state,this.files),this.onChangeEmitter.trigger(o,this.state,this.files))}renderInteractiveSceneCallback=({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:o})=>{r&&(fx=r);let n=H(this.state.editingElement)?!1:!t&&o.size>0;this.state.scrolledOutside!==n&&this.setState({scrolledOutside:n}),this.scheduleImageRefresh()};onScroll=ii(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(o=>o.offsetLeft===r&&o.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},s0);onCut=bt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Tn(t.target)||(this.actionManager.executeAction(cg,"keyboard",t),t.preventDefault(),t.stopPropagation())});onCopy=bt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Tn(t.target)||(this.actionManager.executeAction(Kl,"keyboard",t),t.preventDefault(),t.stopPropagation())});static resetTapTwice(){sm=!1}onTouchStart=t=>{if(ym&&t.preventDefault(),!sm){sm=!0,clearTimeout(gx),gx=window.setTimeout(e.resetTapTwice,i0);return}if(sm&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),sm=!1,clearTimeout(gx)}t.touches.length===2&&this.setState({selectedElementIds:Ge({},this.state),activeEmbeddable:null})};onTouchEnd=t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ge(this.state.previousSelectedElementIds,this.state)}):Ve.pointers.clear()};pasteFromClipboard=bt(async t=>{let r=!!yh,o=document.activeElement,n=this.excalidrawContainerRef.current?.contains(o);if(t&&!n)return;let i=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(i instanceof HTMLCanvasElement)||Tn(o)))return;let{x:a,y:s}=Qe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),l=t?.clipboardData?.files[0],c=await pu(t,r);if(!l&&!r){if(c.mixedContent)return this.addElementsFromMixedContentPaste(c.mixedContent,{isPlainPaste:r,sceneX:a,sceneY:s});if(c.text){let d=c.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(l=If(d))}}if($i(l)&&!c.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:E("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:a,sceneY:s});this.insertImageElement(d,l),this.initializeImageDimensions(d),this.setState({selectedElementIds:Ge({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}if(c.errorMessage)this.setState({errorMessage:c.errorMessage});else if(c.spreadsheet&&!r)this.setState({pasteDialog:{data:c.spreadsheet,shown:!0}});else if(c.elements){let d=c.programmaticAPI?ac(c.elements):c.elements;this.addElementsFromPasteOrLibrary({elements:d,files:c.files||null,position:"cursor",retainSeed:r})}else if(c.text){if(c.text&&MA(c.text)){let p=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:u,files:g}=await p.parseMermaidToExcalidraw(c.text),h=ac(u,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:h,files:g,position:"cursor"});return}catch(u){console.warn(`parsing pasted text as mermaid definition failed: ${u.message}`)}}let d=zm(c.text).split(/\n+/).map(p=>p.trim()).filter(Boolean),m=d.map(p=>Hv(p)).filter(p=>hl(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||xi(p)?.type==="video"));if(!yh&&m.length>0&&m.length===d.length){let p=[];for(let u of m){let g=p[p.length-1],h=this.insertEmbeddableElement({sceneX:g?g.x+g.width+20:a,sceneY:s,link:Pr(u)});h&&p.push(h)}p.length&&this.setState({selectedElementIds:Object.fromEntries(p.map(u=>[u.id,!0]))});return}this.addTextFromPaste(c.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()});addElementsFromPasteOrLibrary=t=>{let r=Nc(t.elements,null,void 0),[o,n,i,a]=Te(r),s=Ht(o,i)/2,l=Ht(n,a)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:m,y:p}=Qe({clientX:c,clientY:d},this.state),u=m-s,g=p-l,[h,x]=Ot(u,g,this.state.gridSize),v=Ap(r.map(I=>pe(I,{x:I.x+h-o,y:I.y+x-n})),{randomizeSeed:!t.retainSeed}),w=[...this.scene.getElementsIncludingDeleted(),...v];Jt(w,Z(v));let C=this.getTopLayerFrameAtSceneCoords({x:m,y:p});if(C){let I=TT(v,C);hd(w,I,C)}this.scene.replaceAllElements(w),v.forEach(I=>{if(H(I)&&ze(I)){let P=Et(I,this.scene.getElementsMapIncludingDeleted());ft(I,P,this.scene.getElementsMapIncludingDeleted())}}),t.files&&(this.files={...this.files,...t.files}),this.store.shouldCaptureIncrement();let M=gs(v);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&mr.get(Jd)?this.state.openSidebar:null,...cr({editingGroupId:null,selectedElementIds:M.reduce((I,P)=>(ze(P)||(I[P.id]=!0),I),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(v,{fitToContent:!0})};async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:o,sceneY:n}){if(!r&&t.some(i=>i.type==="imageUrl")&&this.isToolSupported("image")){let i=t.filter(m=>m.type==="imageUrl").map(m=>m.value),a=await Promise.all(i.map(async m=>{try{return{file:await a2(m)}}catch(p){let u=p.message;return p.cause==="FETCH_ERROR"?u=E("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(u=E("errors.unsupportedFileType")),{errorMessage:u}}})),s=n,l=!1,c={};for(let m of a)if(m.file){let p=this.createImageElement({sceneX:o,sceneY:s}),u=await this.insertImageElement(p,m.file);u&&(l||(l=!0,s-=u.height/2),F(u,{y:s},!1),s=p.y+p.height+25,c[p.id]=!0)}this.setState({selectedElementIds:Ge(c,this.state)});let d=a.find(m=>!!m.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let i=t.filter(a=>a.type==="text");i.length&&this.addTextFromPaste(i.map(a=>a.value).join(`
|
|
180
176
|
|
|
181
|
-
`),r)}}addTextFromPaste(t,r=!1){let{x:o,y:n}
|
|
182
|
-
`),h=u.reduce((g,x,v)=>{let y=x.trim();if(y.length){let w=this.getTopLayerFrameAtSceneCoords({x:o,y:p}),I=Bt(y,a,s),A=I.width>d,C=A?go(y,a,d):y;I=A?Bt(C,a,s):I;let L=o-I.width/2,M=p-I.height/2,z=Wt({...i,x:L,y:M,text:C,originalText:y,lineHeight:s,autoResize:!A,frameId:w?w.id:null});g.push(z),p+=z.height+m}else u[v-1]?.trim()&&(p+=Ci(i.fontSize,s)+m);return g},[]);h.length!==0&&(this.scene.insertElements(h),this.setState({selectedElementIds:Fe(Object.fromEntries(h.map(g=>[g.id,!0])),this.state)}),!r&&h.length>1&&bC===!1&&!this.device.editor.isMobile&&(this.setToast({message:E("toast.pasteAsSingleElement",{shortcut:R("CtrlOrCmd+Shift+V")}),duration:5e3}),bC=!0),this.store.shouldCaptureIncrement())}setAppState=(t,r)=>{this.setState(t,r)};removePointer=t=>{qi&&this.resetContextMenuTimer(),He.pointers.delete(t.pointerId)};toggleLock=(t="ui")=>{this.state.activeTool.locked||ve("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...et(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))};updateFrameRendering=t=>{this.setState(r=>{let o=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:o?.enabled??r.frameRendering.enabled,clip:o?.clip??r.frameRendering.clip,name:o?.name??r.frameRendering.name,outline:o?.outline??r.frameRendering.outline}}})};togglePenMode=t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))};onHandToolToggle=()=>{this.actionManager.executeAction(rT)};zoomCanvas=t=>{this.setState({...ei({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:yn(t)},this.state)})};cancelInProgressAnimation=null;scrollToContent=(t=this.scene.getNonDeletedElements(),r)=>{this.cancelInProgressAnimation?.();let o=Array.isArray(t)?t:[t],n=this.state.zoom,i=this.state.scrollX,a=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=Xc({targetElements:o,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor});n=s.zoom,i=s.scrollX,a=s.scrollY}else{let s=bn(o,this.state);i=s.scrollX,a=s.scrollY}if(r?.animate){let s=this.state.scrollX,l=this.state.scrollY,c=this.state.zoom.value,d=r1({fromValues:{scrollX:s,scrollY:l,zoom:c},toValues:{scrollX:i,scrollY:a,zoom:n.value},interpolateValue:(m,p,u,h)=>{if(h==="zoom")return m*Math.pow(p/m,Bn(u))},onStep:({scrollX:m,scrollY:p,zoom:u})=>{this.setState({scrollX:m,scrollY:p,zoom:{value:u}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:i,scrollY:a,zoom:n})};maybeUnfollowRemoteUser=()=>{this.state.userToFollow&&this.setState({userToFollow:null})};translateCanvas=t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)};setToast=t=>{this.setState({toast:t})};restoreFileFromShare=async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let o=await r.blob(),n=new File([o],o.name||"",{type:o.type});this.loadFileToCanvas(n,null),await t.delete("shared-file"),window.history.replaceState(null,Nl,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}};addFiles=dt(t=>{let r=t.reduce((o,n)=>(o.set(n.id,n),o),new Map);this.files={...this.files,...Object.fromEntries(r)},this.scene.getNonDeletedElements().forEach(o=>{xr(o)&&r.has(o.fileId)&&(this.imageCache.delete(o.fileId),Oe.delete(o))}),this.scene.triggerUpdate(),this.addNewImagesToImageCache()});updateScene=dt(t=>{let r=yr(t.elements??[]);if(t.storeAction&&t.storeAction!==D.NONE){let o=this.store.snapshot.appState,n=this.store.snapshot.elements,i=t.appState?Object.assign({},o,t.appState):o,a=t.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),X(r)):n;t.storeAction===D.CAPTURE?this.store.captureIncrement(a,i):t.storeAction===D.UPDATE&&this.store.updateSnapshot(a,i)}t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(r),t.collaborators&&this.setState({collaborators:t.collaborators})});triggerRender=t=>{t===!0?this.scene.triggerUpdate():this.setState({})};toggleSidebar=({name:t,tab:r,force:o})=>{let n;o===void 0?n=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:n=o?t:null;let i=n?{name:n}:null;return i&&r&&(i.tab=r),this.setState({openSidebar:i}),!!n};updateCurrentCursorPosition=dt(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY});onKeyDown=dt(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(i,a){let s=i[a];return typeof s=="function"?s.bind(i):a==="key"?t.shiftKey?i.key.toUpperCase():i.key.toLowerCase():s}})),t[S.CTRL_OR_CMD]&&t.key===S.P&&!t.shiftKey&&!t.altKey){this.setToast({message:E("commandPalette.shortcutHint",{shortcut:Pt("commandPalette")})}),t.preventDefault();return}if(t[S.CTRL_OR_CMD]&&t.key.toLowerCase()===S.V&&(ch=t.shiftKey,clearTimeout(fC),fC=window.setTimeout(()=>{ch=!1},100)),t[S.CTRL_OR_CMD]&&co(t.target)&&(t.code===ye.MINUS||t.code===ye.EQUAL)){t.preventDefault();return}if(co(t.target)&&t.key!==S.ESCAPE||vs(t.key)&&Ah(t.target))return;if(t.key===S.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===S.E&&t.shiftKey&&t[S.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===S.PAGE_UP||t.key===S.PAGE_DOWN){let i=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===S.PAGE_DOWN&&(i=-i),t.shiftKey?this.translateCanvas(a=>({scrollX:a.scrollX+i})):this.translateCanvas(a=>({scrollY:a.scrollY+i}))}if(this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[S.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),vs(t.key)){let i=this.state.gridSize&&(t.shiftKey?Eh:this.state.gridSize)||(t.shiftKey?Mx:Eh),a=0,s=0;t.key===S.ARROW_LEFT?a=-i:t.key===S.ARROW_RIGHT?a=i:t.key===S.ARROW_UP?s=-i:t.key===S.ARROW_DOWN&&(s=i);let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});l.forEach(c=>{O(c,{x:c.x+a,y:c.y+s}),qt(c,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:l})}),this.setState({suggestedBindings:cm(l,this)}),t.preventDefault()}else if(t.key===S.ENTER){let i=this.scene.getSelectedElements(this.state);if(i.length===1){let a=i[0];if(t[S.CTRL_OR_CMD])ie(a)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==i[0].id)&&(this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new j(a)}));else if(U(a)||x0(a)){let s;U(a)||(s=a);let l=fm(a,this.state,this.scene.getNonDeletedElementsMap()),c=l.x,d=l.y;this.startTextEditing({sceneX:c,sceneY:d,container:s}),t.preventDefault();return}else re(a)&&this.setState({editingFrame:a.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&this.state.draggingElement===null){let i=S3(t.key);i?(this.state.activeTool.type!==i&&ve("toolbar",i,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setActiveTool({type:i}),t.stopPropagation()):t.key===S.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===S.SPACE&&He.pointers.size===0&&(qa=!0,Ye(this.interactiveCanvas,Ne.GRAB),t.preventDefault()),(t.key===S.G||t.key===S.S)&&!t.altKey&&!t[S.CTRL_OR_CMD]){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;t.key===S.G&&(zn(this.state.activeTool.type)||i.some(a=>zn(a.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===S.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(t.key===S.K&&!t.altKey&&!t[S.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[S.CTRL_OR_CMD]&&(t.key===S.BACKSPACE||t.key===S.DELETE)&&nr.set($a,"clearCanvas");let r=t.key.toLocaleLowerCase(),o=r===S.S&&t.shiftKey,n=t.key===S.I||r===S.G&&t.shiftKey;(o||n)&&this.openEyeDropper({type:o?"stroke":"background"})});onWheel=dt(t=>{!(t.target instanceof HTMLCanvasElement)&&t.ctrlKey&&t.preventDefault()});onKeyUp=dt(t=>{t.key===S.SPACE&&(this.state.viewModeEnabled?Ye(this.interactiveCanvas,Ne.GRAB):this.state.activeTool.type==="selection"?Qr(this.interactiveCanvas):(eo(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),qa=!1),!t[S.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),vs(t.key)&&(rc(this.scene.getSelectedElements(this.state).filter(ie),this,hn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[]),this.setState({suggestedBindings:[]}))});isToolSupported=t=>this.props.UIOptions.tools?.[t]!==!1;setActiveTool=t=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=et(this.state,t);r.type==="hand"?Ye(this.interactiveCanvas,Ne.GRAB):qa||eo(this.interactiveCanvas,this.state),e1(document.activeElement)&&this.focusContainer(),Yl(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(t.type==="image"&&t.insertOnCanvasDirectly)??!1}),this.setState(o=>{let n={snapLines:o.snapLines.length?[]:o.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type==="freedraw"&&this.store.shouldCaptureIncrement(),r.type!=="selection"?{...o,activeTool:r,selectedElementIds:Fe({},o),selectedGroupIds:Fe({},o),editingGroupId:null,multiElement:null,...n}:{...o,activeTool:r,...n}})};setOpenDialog=t=>{this.setState({openDialog:t})};setCursor=t=>{Ye(this.interactiveCanvas,t)};resetCursor=()=>{Qr(this.interactiveCanvas)};isTouchScreenMultiTouchGesture=()=>He.pointers.size>=2;getName=()=>this.state.name||this.props.name||`${E("labels.untitled")}-${Ch()}`;onGestureStart=dt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Fe({},this.state),activeEmbeddable:null}),He.initialScale=this.state.zoom.value});onGestureChange=dt(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=He.initialScale;r&&this.setState(o=>({...ei({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:yn(r*t.scale)},o)}))});onGestureEnd=dt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Fe(this.state.previousSelectedElementIds,this.state)}),He.initialScale=null});handleTextWysiwyg(t,{isExistingElement:r=!1}){let o=this.scene.getElementsMapIncludingDeleted(),n=(i,a)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&U(s)?se(s,{originalText:i,isDeleted:a??s.isDeleted,...Xo(s,wt(s,o),o,i)}):s)])};pC({id:t.id,canvas:this.canvas,getViewportCoords:(i,a)=>{let{x:s,y:l}=Ht({sceneX:i,sceneY:a},this.state);return[s-this.state.offsetLeft,l-this.state.offsetTop]},onChange:dt(i=>{n(i,!1),$l(t)&&qt(t,o)}),onSubmit:dt(({viaKeyboard:i,nextOriginalText:a})=>{let s=!a.trim();if(n(a,s),!s&&i){let l=t.containerId?t.containerId:t.id;this.setState(c=>({selectedElementIds:Fe({...c.selectedElementIds,[l]:!0},c)}))}s&&mm(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.shouldCaptureIncrement(),this.setState({draggingElement:null,editingElement:null}),this.state.activeTool.locked&&eo(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),n(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let o=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return o&&U(o)&&!o.isDeleted?o:null}getElementShape(t){switch(t.type){case"rectangle":case"diamond":case"frame":case"magicframe":case"embeddable":case"image":case"iframe":case"text":case"selection":return Wm(t);case"arrow":case"line":{let r=Oe.get(t)?.[0]??Oe.generateElementShape(t,null)[0],[,,,,o,n]=ne(t,this.scene.getNonDeletedElementsMap());return Vm(t)?Ty(t,r,[t.x,t.y],t.angle,[o,n]):wy(r,[t.x,t.y],t.angle,[o,n])}case"ellipse":return xy(t);case"freedraw":{let[,,,,r,o]=ne(t,this.scene.getNonDeletedElementsMap());return vy(t,[r,o],Vm(t))}}}getBoundTextShape(t){let r=ae(t,this.scene.getNonDeletedElementsMap());return r?t.type==="arrow"?this.getElementShape({...r,...j.getBoundTextElementPosition(t,r,this.scene.getNonDeletedElementsMap())}):this.getElementShape(r):null}getElementAtPosition(t,r,o){let n=this.getElementsAtPosition(t,r,o?.includeBoundTextElement,o?.includeLockedElements);if(n.length>1){if(o?.preferSelected){for(let a=n.length-1;a>-1;a--)if(this.state.selectedElementIds[n[a].id])return n[a]}let i=n[n.length-1];return Ca({x:t,y:r,element:i,shape:this.getElementShape(i),threshold:this.getElementHitThreshold()/2,frameNameBound:re(i)?this.frameNameBoundsCache.get(i):null})?i:n[n.length-2]}return n.length===1?n[0]:null}getElementsAtPosition(t,r,o=!1,n=!1){let i=[],a=this.scene.getNonDeletedElementsMap();return(o&&n?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(n||!l.locked)&&(o||!(U(l)&&l.containerId)))).filter(l=>this.hitElement(t,r,l)).filter(l=>{let c=Vt(l,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?jg({x:t,y:r},c,a):!0}).filter(l=>po(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(){return Px/this.state.zoom.value}hitElement(t,r,o,n=!0){if(n&&this.state.selectedElementIds[o.id]&&fp([o],this.state)){let a=Ey(o,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold());return ws([t,r],a)}return Iy(t,r,this.getBoundTextShape(o))?!0:Ca({x:t,y:r,element:o,shape:this.getElementShape(o),threshold:this.getElementHitThreshold(),frameNameBound:re(o)?this.frameNameBoundsCache.get(o):null})}getTextBindableContainerAtPosition(t,r){let o=this.scene.getNonDeletedElements(),n=this.scene.getSelectedElements(this.state);if(n.length===1)return cn(n[0],!1)?n[0]:null;let i=null;for(let a=o.length-1;a>=0;--a){if(o[a].isDeleted)continue;let[s,l,c,d]=ne(o[a],this.scene.getNonDeletedElementsMap());if(xe(o[a])&&Ca({x:t,y:r,element:o[a],shape:this.getElementShape(o[a]),threshold:this.getElementHitThreshold()})){i=o[a];break}else if(s<t&&t<c&&l<r&&r<d){i=o[a];break}}return cn(i,!1)?i:null}startTextEditing=({sceneX:t,sceneY:r,insertAtParentCenter:o=!0,container:n,autoEdit:i=!0})=>{let a=!1,s=o&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n);n&&s&&(ae(n,this.scene.getNonDeletedElementsMap())||(a=!0));let l=null,c=this.scene.getSelectedElements(this.state);c.length===1?U(c[0])?l=c[0]:n?l=ae(c[0],this.scene.getNonDeletedElementsMap()):l=this.getTextElementAtPosition(t,r):l=this.getTextElementAtPosition(t,r);let d=l?.fontFamily||this.state.currentItemFontFamily,m=l?.lineHeight||qr(d),p=this.state.currentItemFontSize;if(!l&&a&&n&&!xe(n)){let x=ks(Ie({fontSize:p,fontFamily:d}),m),v=As(p,m),y=Math.max(n.height,v),w=Math.max(n.width,x);O(n,{height:y,width:w}),t=n.x+w/2,r=n.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n))}let u=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),h=l||Wt({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:p,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?St.MIDDLE:oa,containerId:a?n?.id:void 0,groupIds:n?.groupIds??[],lineHeight:m,angle:n?.angle??0,frameId:u?u.id:null});if(!l&&a&&n&&O(n,{boundElements:(n.boundElements||[]).concat({type:"text",id:h.id})}),this.setState({editingElement:h}),!l)if(n&&a){let g=this.scene.getElementIndex(n.id);this.scene.insertElementAtIndex(h,g+1)}else this.scene.insertElement(h);i||l||n?this.handleTextWysiwyg(h,{isExistingElement:!!l}):this.setState({draggingElement:h,multiElement:null})};handleCanvasDoubleClick=t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state);if(r.length===1&&ie(r[0])&&t[S.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new j(r[0])});return}Qr(this.interactiveCanvas);let{x:o,y:n}=$e(t,this.state);if(Ko(this.state).length>0){let a=this.getElementAtPosition(o,n),s=a&&C0(a,this.state.selectedGroupIds);if(s){this.store.shouldCaptureIncrement(),this.setState(l=>({...l,...er({editingGroupId:s,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),l,this)}));return}}if(Qr(this.interactiveCanvas),!t[S.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let a=this.getElementAtPosition(o,n);if(jt(a)){this.setState({activeEmbeddable:{element:a,state:"active"}});return}let s=this.getTextBindableContainerAtPosition(o,n);if(s&&(sr(s)||!Er(s.backgroundColor)||Ca({x:o,y:n,element:s,shape:this.getElementShape(s),threshold:this.getElementHitThreshold()}))){let l=fm(s,this.state,this.scene.getNonDeletedElementsMap());o=l.x,n=l.y}this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:s})}};getElementLinkAtPosition=(t,r)=>{let o=this.scene.getNonDeletedElements().slice().reverse(),n=1/0;return o.find((i,a)=>(r&&i.id===r.id&&(n=a),i.link&&a<=n&&Km(i,this.scene.getNonDeletedElementsMap(),this.state,[t.x,t.y],this.device.editor.isMobile)))};redirectToLink=(t,r)=>{let o=It(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY,this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY);if(!this.hitLinkElement||r&&o>Rn||!r&&o!==0)return;let n=$e(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=Km(this.hitLinkElement,i,this.state,[n.x,n.y],this.device.editor.isMobile),s=$e(this.lastPointerUpEvent,this.state),l=Km(this.hitLinkElement,i,this.state,[s.x,s.y],this.device.editor.isMobile);if(a&&l){let c=this.hitLinkElement.link;if(c){c=vr(c);let d;if(this.props.onLinkOpen&&(d=$d("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let m=vm(c)?"_self":"_blank",p=window.open(void 0,m);p&&(p.opener=null,p.location=c)}}}};getTopLayerFrameAtSceneCoords=t=>{let r=this.scene.getNonDeletedElementsMap(),o=this.scene.getNonDeletedFramesLikes().filter(n=>jg(t,n,r));return o.length?o[o.length-1]:null};handleCanvasPointerMove=t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,He.pointers.has(t.pointerId)&&He.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=He.initialScale;if(He.pointers.size===2&&He.lastCenter&&r&&He.initialDistance){let p=eE(He.pointers),u=p.x-He.lastCenter.x,h=p.y-He.lastCenter.y;He.lastCenter=p;let g=tE(Array.from(He.pointers.values())),x=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:g/He.initialDistance,v=x?yn(r*x):this.state.zoom.value;this.setState(y=>{let w=ei({viewportX:p.x,viewportY:p.y,nextZoom:v},y);this.translateCanvas({zoom:w.zoom,scrollX:w.scrollX+2*(u/v),scrollY:w.scrollY+2*(h/v),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else He.lastCenter=He.initialDistance=He.initialScale=null;if(qa||xd||$E||Yo(this.state))return;let n=nE(XE,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.draggingElement&&!this.state.multiElement&&(n?Qr(this.interactiveCanvas):eo(this.interactiveCanvas,this.state));let i=$e(t,this.state),{x:a,y:s}=i;if(!this.state.draggingElement&&VI(this.state.activeTool.type)){let{originOffset:p,snapLines:u}=WI(this.scene.getNonDeletedElements(),this.state,{x:a,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(h=>{let g=Xd(h.snapLines,u),x=h.originSnapOffset?Xd(h.originSnapOffset,p):p;return h.snapLines===g&&h.originSnapOffset===x?null:{snapLines:g,originSnapOffset:x}})}else this.state.draggingElement||this.setState(p=>p.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let p=j.handlePointerMove(t,a,s,this.state,this.scene.getNonDeletedElementsMap());p&&p!==this.state.editingLinearElement&&YE(()=>{this.setState({editingLinearElement:p})}),p?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(i):YE(()=>{this.setState({suggestedBindings:[]})})}if(Ph(this.state.activeTool.type)){let{draggingElement:p}=this.state;Dr(p,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(p,[i],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(i)}if(this.state.multiElement){let{multiElement:p}=this.state,{x:u,y:h}=p,{points:g,lastCommittedPoint:x}=p,v=g[g.length-1];if(eo(this.interactiveCanvas,this.state),v===x)It(a-u,s-h,v[0],v[1])>=os?O(p,{points:[...g,[a-u,s-h]]}):Ye(this.interactiveCanvas,Ne.POINTER);else if(g.length>2&&x&&It(a-u,s-h,x[0],x[1])<os)Ye(this.interactiveCanvas,Ne.POINTER),O(p,{points:g.slice(0,-1)});else{let[y,w]=Lt(a,s,t[S.CTRL_OR_CMD]?null:this.state.gridSize),[I,A]=p?.lastCommittedPoint??[0,0],C=y-u-I,L=w-h-A;fa(t)&&({width:C,height:L}=Is(I+u,A+h,y,w)),wr(g,this.state.zoom.value)&&Ye(this.interactiveCanvas,Ne.POINTER),O(p,{points:[...g.slice(0,-1),[I+C,A+L]]})}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!n&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,s),!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1){let p=bp(c,this.state,a,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(p&&p.transformHandleType){Ye(this.interactiveCanvas,xp(p));return}}}else if(d.length>1&&!n){let p=Ep(we(d),a,s,this.state.zoom,t.pointerType,this.device);if(p){Ye(this.interactiveCanvas,xp({transformHandleType:p}));return}}let m=this.getElementAtPosition(i.x,i.y);this.hitLinkElement=this.getElementLinkAtPosition(i,m),!Nr(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(Ye(this.interactiveCanvas,Ne.POINTER),MT(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(LT(),m&&(m.link||kt(m))&&this.state.selectedElementIds[m.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Ye(this.interactiveCanvas,U(m)?Ne.TEXT:Ne.CROSSHAIR):this.state.viewModeEnabled?Ye(this.interactiveCanvas,Ne.GRAB):n?Ye(this.interactiveCanvas,Ne.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,s):t[S.CTRL_OR_CMD]?Ye(this.interactiveCanvas,Ne.AUTO):(m||this.isHittingCommonBoundingBoxOfSelectedElements(i,d))&&!m?.locked&&(m&&jt(m)&&this.isIframeLikeElementCenter(m,t,a,s)?(Ye(this.interactiveCanvas,Ne.POINTER),this.setState({activeEmbeddable:{element:m,state:"hover"}})):(Ye(this.interactiveCanvas,Ne.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))))};handleEraser=(t,r,o)=>{this.eraserTrail.addPointToPath(o.x,o.y);let n=!1,i=new Set,a=this.scene.getNonDeletedElements(),s=p=>{for(let u of p){if(u.locked)return;if(t.altKey?this.elementsPendingErasure.delete(u.id)&&(n=!0):this.elementsPendingErasure.has(u.id)||(n=!0,this.elementsPendingErasure.add(u.id)),n&&u.groupIds?.length){let h=u.groupIds.at(-1);if(!i.has(h)){i.add(h);let g=Qe(a,h);for(let x of g)t.altKey?this.elementsPendingErasure.delete(x.id):this.elementsPendingErasure.add(x.id)}}}},l=It(r.lastCoords.x,r.lastCoords.y,o.x,o.y),c=this.getElementHitThreshold(),d={...r.lastCoords},m=0;for(;m<=l;){let p=this.getElementsAtPosition(d.x,d.y);if(s(p),m===l)break;m=Math.min(m+c,l);let u=m/l,h=(1-u)*d.x+u*o.x,g=(1-u)*d.y+u*o.y;d.x=h,d.y=g}if(r.lastCoords.x=o.x,r.lastCoords.y=o.y,n){for(let p of this.scene.getNonDeletedElements())Me(p)&&(this.elementsPendingErasure.has(p.id)||this.elementsPendingErasure.has(p.containerId))&&(t.altKey?(this.elementsPendingErasure.delete(p.id),this.elementsPendingErasure.delete(p.containerId)):(this.elementsPendingErasure.add(p.id),this.elementsPendingErasure.add(p.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.triggerRender()}};handleTouchMove=t=>{yd=!0};handleHoverSelectedLinearElement(t,r,o){let n=this.scene.getNonDeletedElementsMap(),i=j.getElement(t.elementId,n);if(i)if(this.state.selectedLinearElement){let a=-1,s=null;Ca({x:r,y:o,element:i,shape:this.getElementShape(i)})?(a=j.getPointIndexUnderCursor(i,n,this.state.zoom,r,o),s=j.getSegmentMidpointHitCoords(t,{x:r,y:o},this.state,this.scene.getNonDeletedElementsMap()),a>=0||s?Ye(this.interactiveCanvas,Ne.POINTER):this.hitElement(r,o,i)&&Ye(this.interactiveCanvas,Ne.MOVE)):this.hitElement(r,o,i)&&Ye(this.interactiveCanvas,Ne.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),j.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else Ye(this.interactiveCanvas,Ne.AUTO)}handleCanvasPointerDown=t=>{if(this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.draggingElement&&this.state.draggingElement.type==="freedraw"){let c=this.state.draggingElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(d=>d.id!==c.id)}:{},appState:{draggingElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Fe(Object.keys(this.state.selectedElementIds).filter(d=>d!==c.id).reduce((d,m)=>(d[m]=this.state.selectedElementIds[m],d),{}),this.state)},storeAction:D.UPDATE});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=ds(this.device,{isTouchScreen:!0})),xd||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===di.ERASER&&this.state.activeTool.type!==xt.eraser){this.setState({activeTool:et(this.state,{type:xt.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{d(),m?.(),Nr(this.state)&&this.setState({activeTool:et(this.state,{...this.state.activeTool.lastActiveTool||{type:xt.selection},lastActiveToolBeforeEraser:null})})},d=gt(window,"pointerup",c,{once:!0}),m;requestAnimationFrame(()=>{m=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==di.MAIN&&t.button!==di.TOUCH&&t.button!==di.ERASER||He.pointers.size>1)return;let o=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,o)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,o))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="text")this.handleTextOnPointerDown(t,o);else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,o);else if(this.state.activeTool.type==="image"){Ye(this.interactiveCanvas,Ne.CROSSHAIR);let c=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!c)return;this.setState({draggingElement:c,editingElement:c,pendingImageElementId:null,multiElement:null});let{x:d,y:m}=$e(t,this.state),p=this.getTopLayerFrameAtSceneCoords({x:d,y:m});O(c,{x:d,y:m,frameId:p?p.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,o):this.state.activeTool.type==="custom"?eo(this.interactiveCanvas,this.state):this.state.activeTool.type===xt.frame||this.state.activeTool.type===xt.magicframe?this.createFrameElementOnPointerDown(o,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(o.lastCoords.x,o.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,o);this.props?.onPointerDown?.(this.state.activeTool,o),this.onPointerDownEmitter.trigger(this.state.activeTool,o,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(o.lastCoords.x,o.lastCoords.y);let i=this.onPointerMoveFromPointerDownHandler(o),a=this.onPointerUpFromPointerDownHandler(o),s=this.onKeyDownFromPointerDownHandler(o),l=this.onKeyUpFromPointerDownHandler(o);this.missingPointerEventCleanupEmitter.once(c=>a(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",i),window.addEventListener("pointerup",a),window.addEventListener("keydown",s),window.addEventListener("keyup",l),o.eventListeners.onMove=i,o.eventListeners.onUp=a,o.eventListeners.onKeyUp=l,o.eventListeners.onKeyDown=s)};handleCanvasPointerUp=t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=$e({clientX:t.clientX,clientY:t.clientY},this.state),o=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&o<300){let n=this.getElementAtPosition(r.x,r.y);if(jt(n)&&this.isIframeLikeElementCenter(n,t,r.x,r.y)){this.handleEmbeddableCenterClick(n);return}}if(this.device.isTouchScreen){let n=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,n)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?o<300&&jt(this.hitLinkElement)&&!zg(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,[r.x,r.y])?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})};maybeOpenContextMenuAfterPointerDownOnTouchDevices=t=>{t.pointerType==="touch"&&(yd=!1,qi?yd=!0:qi=window.setTimeout(()=>{qi=0,yd||this.handleCanvasContextMenu(t)},Bx))};resetContextMenuTimer=()=>{clearTimeout(qi),qi=0,yd=!1};maybeCleanupAfterMissingPointerUp=t=>{wd?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()};handleCanvasPanUsingWheelOrSpaceDrag=t=>{if(!(He.pointers.size<=1&&(t.button===di.WHEEL||t.button===di.MAIN&&qa||Yo(this.state)||this.state.viewModeEnabled))||U(this.state.editingElement))return!1;xd=!0,t.preventDefault();let r=!1,o=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Ye(this.interactiveCanvas,Ne.GRABBING);let{clientX:n,clientY:i}=t,a=rh(l=>{let c=n-l.clientX,d=i-l.clientY;if(n=l.clientX,i=l.clientY,o&&!r&&(Math.abs(c)>1||Math.abs(d)>1)){r=!0;let m=u=>{document.body.removeEventListener("paste",m),u.stopPropagation()},p=()=>{setTimeout(()=>{document.body.removeEventListener("paste",m),window.removeEventListener("pointerup",p)},100)};document.body.addEventListener("paste",m),window.addEventListener("pointerup",p)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=dt(wd=()=>{wd=null,xd=!1,qa||(this.state.viewModeEnabled?Ye(this.interactiveCanvas,Ne.GRAB):eo(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),a.flush()});return window.addEventListener("blur",s),window.addEventListener("pointermove",a,{passive:!0}),window.addEventListener("pointerup",s),!0};updateGestureOnPointerDown(t){He.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),He.pointers.size===2&&(He.lastCenter=eE(He.pointers),He.initialScale=this.state.zoom.value,He.initialDistance=tE(Array.from(He.pointers.values())))}initialPointerDownState(t){let r=$e(t,this.state),o=this.scene.getSelectedElements(this.state),[n,i,a,s]=we(o);return{origin:r,withCmdOrCtrl:t[S.CTRL_OR_CMD],originInGrid:Bo(Lt(r.x,r.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize)),scrollbars:nE(XE,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((l,c)=>(l.set(c.id,Zo(c)),l),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+n)/2,y:(s+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,o)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;$E=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let o=rh(i=>{i.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(i,r)}),n=dt(()=>{wd=null,$E=!1,eo(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",n),o.flush()});return wd=n,window.addEventListener("pointermove",o),window.addEventListener("pointerup",n),!0}clearSelectionIfNotUsingSelection=()=>{this.state.activeTool.type!=="selection"&&this.setState({selectedElementIds:Fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})};handleSelectionOnPointerDown=(t,r)=>{if(this.state.activeTool.type==="selection"){let o=this.scene.getNonDeletedElements(),n=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.editingLinearElement&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let a=bp(o,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);a!=null&&(this.setState({resizingElement:a.element}),r.resize.handleType=a.transformHandleType)}else i.length>1&&(r.resize.handleType=Ep(we(i),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=Bo(nf(r.resize.handleType,i,n,r.origin.x,r.origin.y)),i.length===1&&ie(i[0])&&i[0].points.length===2&&(r.resize.arrowDirection=af(r.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let l=this.state.editingLinearElement||this.state.selectedLinearElement,c=j.handlePointerDown(t,this.state,this.store,r.origin,l,this);if(c.hitElement&&(r.hit.element=c.hitElement),c.linearElementEditor&&(this.setState({selectedLinearElement:c.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:c.linearElementEditor})),c.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=this.getElementsAtPosition(r.origin.x,r.origin.y);let a=r.hit.element,s=r.hit.allHitElements.some(l=>this.isASelectedElement(l));if((a===null||!s)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(a),this.state.editingLinearElement)this.setState({selectedElementIds:Fe({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(a!=null){if(t[S.CTRL_OR_CMD])return this.state.selectedElementIds[a.id]||(r.hit.wasAddedToSelection=!0),this.setState(l=>({...I0(l,a),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!va(a,this.state.editingGroupId)&&this.setState({selectedElementIds:Fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!s&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(l=>{let c={...l.selectedElementIds,[a.id]:!0},d=[];if(Object.keys(l.selectedElementIds).forEach(m=>{let p=this.scene.getElement(m);p&&d.push(p)}),re(a))ro(d,a.id).forEach(m=>{delete c[m.id]});else if(a.frameId)c[a.frameId]&&delete c[a.id];else{let m=a.groupIds,p=new Set(m.flatMap(u=>Qe(this.scene.getNonDeletedElements(),u)).filter(u=>re(u)).map(u=>u.id));p.size>0&&d.forEach(u=>{u.frameId&&p.has(u.frameId)&&(delete c[u.id],u.groupIds.flatMap(h=>Qe(this.scene.getNonDeletedElements(),h)).forEach(h=>{delete c[h.id]}))})}return{...er({editingGroupId:l.editingGroupId,selectedElementIds:c},this.scene.getNonDeletedElements(),l,this),showHyperlinkPopup:a.link||kt(a)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1};isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let o=this.getElementHitThreshold(),[n,i,a,s]=we(r);return t.x>n-o&&t.x<a+o&&t.y>i-o&&t.y<s+o}handleTextOnPointerDown=(t,r)=>{if(U(this.state.editingElement))return;let o=r.origin.x,n=r.origin.y,i=this.getElementAtPosition(o,n,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(o,n);sr(i)&&(a=i,o=i.x+i.width/2,n=i.y+i.height/2),this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:a,autoEdit:!1}),Qr(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:et(this.state,{type:"selection"})})};handleFreeDrawElementOnPointerDown=(t,r,o)=>{let[n,i]=Lt(o.origin.x,o.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),s=B0({type:r,x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:t.pressure===.5,locked:!1,frameId:a?a.id:null});this.setState(d=>{let m={...d.selectedElementIds};return delete m[s.id],{selectedElementIds:Fe(m,d)}});let l=s.simulatePressure?s.pressures:[...s.pressures,t.pressure];O(s,{points:[[0,0]],pressures:l});let c=gn(o.origin,this);this.scene.insertElement(s),this.setState({draggingElement:s,editingElement:s,startBoundElement:c,suggestedBindings:[]})};insertIframeElement=({sceneX:t,sceneY:r,width:o,height:n})=>{let[i,a]=Lt(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),s=N0({type:"iframe",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:o,height:n});return this.scene.insertElement(s),s};insertEmbeddableElement=({sceneX:t,sceneY:r,link:o})=>{let[n,i]=Lt(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=Kn(o);if(!a)return;a.error instanceof URIError&&this.setToast({message:E("toast.unrecognizedLinkFormat"),closable:!0});let s=yg({type:"embeddable",x:n,y:i,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:o});return this.scene.insertElement(s),s};createImageElement=({sceneX:t,sceneY:r,addToFrameUnderCursor:o=!0})=>{let[n,i]=Lt(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=o?this.getTopLayerFrameAtSceneCoords({x:n,y:i}):null;return cc({type:"image",x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null})};handleLinearElementOnPointerDown=(t,r,o)=>{if(this.state.multiElement){let{multiElement:n}=this.state;if(n.type==="line"&&wr(n.points,this.state.zoom.value)){O(n,{lastCommittedPoint:n.points[n.points.length-1]}),this.actionManager.executeAction(To);return}let{x:i,y:a,lastCommittedPoint:s}=n;if(n.points.length>1&&s&&It(o.origin.x-i,o.origin.y-a,s[0],s[1])<os){this.actionManager.executeAction(To);return}this.setState(l=>({selectedElementIds:Fe({...l.selectedElementIds,[n.id]:!0},l)})),O(n,{lastCommittedPoint:n.points[n.points.length-1]}),Ye(this.interactiveCanvas,Ne.POINTER)}else{let[n,i]=Lt(o.origin.x,o.origin.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),{currentItemStartArrowhead:s,currentItemEndArrowhead:l}=this.state,[c,d]=r==="arrow"?[s,l]:[null,null],m=fo({type:r,x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:lt.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:a?a.id:null});this.setState(u=>{let h={...u.selectedElementIds};return delete h[m.id],{selectedElementIds:Fe(h,u)}}),O(m,{points:[...m.points,[0,0]]});let p=gn(o.origin,this);this.scene.insertElement(m),this.setState({draggingElement:m,editingElement:m,startBoundElement:p,suggestedBindings:[]})}};getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:dn(t)?lt.ADAPTIVE_RADIUS:lt.PROPORTIONAL_RADIUS}:null}createGenericElementOnPointerDown=(t,r)=>{let[o,n]=Lt(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i=this.getTopLayerFrameAtSceneCoords({x:o,y:n}),a={x:o,y:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:i?i.id:null},s;t==="embeddable"?s=yg({type:"embeddable",...a}):s=to({type:t,...a}),s.type==="selection"?this.setState({selectionElement:s,draggingElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,draggingElement:s,editingElement:s}))};createFrameElementOnPointerDown=(t,r)=>{let[o,n]=Lt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i={x:o,y:n,opacity:this.state.currentItemOpacity,locked:!1,...qe},a=r===xt.magicframe?lc(i):km(i);this.scene.insertElement(a),this.setState({multiElement:null,draggingElement:a,editingElement:a})};maybeCacheReferenceSnapPoints(t,r,o=!1){si({event:t,appState:this.state,selectedElements:r})&&(o||!ko.getReferenceSnapPoints())&&ko.setReferenceSnapPoints(zI(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,o=!1){si({event:t,appState:this.state,selectedElements:r})&&(o||!ko.getVisibleGaps())&&ko.setVisibleGaps(FI(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return dt(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return dt(r=>{r.key===S.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return rh(r=>{if(t.drag.offset===null&&(t.drag.offset=Bo(lf(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;let n=$e(r,this.state);if(Nr(this.state)){this.handleEraser(r,t,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[i,a]=Lt(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize);if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&It(n.x,n.y,t.origin.x,t.origin.y)<Rn)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleResize(t,r)))return!0;let s=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let m=this.state.editingLinearElement||this.state.selectedLinearElement;if(j.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,s)){let u=j.addMidpoint(this.state.selectedLinearElement,n,this.state,!r[S.CTRL_OR_CMD],s);if(!u)return;YE(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}})});return}else if(m.pointerDownState.segmentMidpoint.value!==null&&!m.pointerDownState.segmentMidpoint.added)return;if(j.handlePointDragging(r,this.state,n.x,n.y,(u,h)=>{this.maybeSuggestBindingsForLinearElementAtCoords(u,h)},m,this.scene.getNonDeletedElementsMap())){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging&&this.setState({editingLinearElement:{...this.state.editingLinearElement,isDragging:!0}}),this.state.selectedLinearElement.isDragging||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0}});return}}let l=t.hit.allHitElements.some(m=>this.isASelectedElement(m)),c=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((l||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c){let m=this.scene.getSelectedElements(this.state);if(m.every(h=>h.locked))return;let p=m.find(h=>re(h)),u=this.getTopLayerFrameAtSceneCoords(n);if(this.setState({frameToHighlight:u&&!p?u:null}),t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0}),m.length>0&&!t.withCmdOrCtrl&&!this.state.editingElement&&this.state.activeEmbeddable?.state!=="active"){let h={x:n.x-t.origin.x,y:n.y-t.origin.y},g=[...t.originalElements.values()],x=r.shiftKey;if(x){let w=Math.abs(h.x),I=Math.abs(h.y),A=x&&w<I,C=x&&w>I;A&&(h.x=0),C&&(h.y=0)}this.maybeCacheVisibleGaps(r,m),this.maybeCacheReferenceSnapPoints(r,m);let{snapOffset:v,snapLines:y}=HI(g,h,this.state,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:y}),!this.state.editingFrame&&sf(t,m,h,this.state,this.scene,v,r[S.CTRL_OR_CMD]?null:this.state.gridSize),this.setState({suggestedBindings:cm(m,this)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let w=[],I=[],A=new Map,C=new Map,L=t.hit.element,M=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(N=>N.id)),z=this.scene.getElementsIncludingDeleted();for(let N of z)if(M.has(N.id)||N.id===L?.id&&t.hit.wasAddedToSelection){let B=dc(this.state.editingGroupId,A,N),_=t.originalElements.get(N.id);O(B,{x:_.x,y:_.y}),t.originalElements.set(B.id,B),w.push(B),I.push(N),C.set(N.id,B.id)}else w.push(N);let k=[...w,...I];Ut(k,X(I)),hm(w,I,C),dm(k,I,C,"duplicatesServeAsOld"),lp(k,I,C),this.scene.replaceAllElements(k),this.maybeCacheVisibleGaps(r,m,!0),this.maybeCacheReferenceSnapPoints(r,m,!0)}return}}let d=this.state.draggingElement;if(d){if(d.type==="freedraw"){let m=d.points,p=n.x-d.x,u=n.y-d.y,h=m.length>0&&m[m.length-1];if(!(h&&h[0]===p&&h[1]===u)){let x=d.simulatePressure?d.pressures:[...d.pressures,r.pressure];O(d,{points:[...m,[p,u]],pressures:x})}}else if(ie(d)){t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0});let m=d.points,p=i-d.x,u=a-d.y;fa(r)&&m.length===2&&({width:p,height:u}=Is(d.x,d.y,n.x,n.y)),m.length===1?O(d,{points:[...m,[p,u]]}):m.length===2&&O(d,{points:[...m.slice(0,-1),[p,u]]}),Dr(d,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(d,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r);if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let m=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)j.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let p=!0;!r.shiftKey&&Ke(m,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(h=>er({...h,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),h,this)):p=!1);let u=$s(m,d,this.scene.getNonDeletedElementsMap());this.setState(h=>{let g={...p&&h.selectedElementIds,...u.reduce((x,v)=>(x[v.id]=!0,x),{})};return t.hit.element&&(u.length?delete g[t.hit.element.id]:g[t.hit.element.id]=!0),h=p?h:{...h,selectedGroupIds:{},editingGroupId:null},{...er({editingGroupId:h.editingGroupId,selectedElementIds:g},this.scene.getNonDeletedElements(),h,this),selectedLinearElement:u.length===1&&ie(u[0])?new j(u[0]):null,showHyperlinkPopup:u.length===1&&(u[0].link||kt(u[0]))?"info":!1}})}}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let o=t.clientX,n=o-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-n/this.state.zoom.value}),r.lastCoords.x=o,!0}if(r.scrollbars.isOverVertical){let o=t.clientY,n=o-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-n/this.state.zoom.value}),r.lastCoords.y=o,!0}return!1}onPointerUpFromPointerDownHandler(t){return dt(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{draggingElement:o,resizingElement:n,multiElement:i,activeTool:a,isResizing:s,isRotating:l}=this.state;this.setState(u=>({isResizing:!1,isRotating:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",editingElement:i||U(this.state.editingElement)?this.state.editingElement:null,snapLines:Xd(u.snapLines,[]),originSnapOffset:null})),ko.setReferenceSnapPoints(null),ko.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let c=this.scene.getNonDeletedElementsMap();if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(To);else{let u=j.handlePointerUp(r,this.state.editingLinearElement,this.state,this);u!==this.state.editingLinearElement&&this.setState({editingLinearElement:u,suggestedBindings:[]})}else if(this.state.selectedLinearElement)if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let u=j.handlePointerUp(r,this.state.selectedLinearElement,this.state,this),{startBindingElement:h,endBindingElement:g}=u,x=this.scene.getElement(u.elementId);Dr(x)&&Ea(x,h,g,c),u!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(a,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),o?.type==="freedraw"){let u=$e(r,this.state),h=o.points,g=u.x-o.x,x=u.y-o.y;g===h[0][0]&&x===h[0][1]&&(x+=1e-4,g+=1e-4);let v=o.simulatePressure?[]:[...o.pressures,r.pressure];O(o,{points:[...h,[g,x]],pressures:v,lastCommittedPoint:[g,x]}),this.actionManager.executeAction(To);return}if(mo(o)){let u=o;try{this.initializeImageDimensions(u),this.setState({selectedElementIds:Fe({[u.id]:!0},this.state)},()=>{this.actionManager.executeAction(To)})}catch(h){console.error(h),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(g=>g.id!==u.id)),this.actionManager.executeAction(To)}return}if(ie(o)){o.points.length>1&&this.store.shouldCaptureIncrement();let u=$e(r,this.state);!t.drag.hasOccurred&&o&&!i?(O(o,{points:[...o.points,[u.x-o.x,u.y-o.y]]}),this.setState({multiElement:o,editingElement:this.state.draggingElement})):t.drag.hasOccurred&&!i&&(hn(this.state)&&Dr(o,!1)&&oc(o,this.state,u,this),this.setState({suggestedBindings:[],startBoundElement:null}),a.locked?this.setState(h=>({draggingElement:null})):(Qr(this.interactiveCanvas),this.setState(h=>({draggingElement:null,activeTool:et(this.state,{type:"selection"}),selectedElementIds:Fe({...h.selectedElementIds,[o.id]:!0},h),selectedLinearElement:new j(o)}))));return}if(U(o)){let u=Ms(Ie({fontSize:o.fontSize,fontFamily:o.fontFamily}),o.lineHeight);o.width<u&&O(o,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(o,{isExistingElement:!0})}if(a.type!=="selection"&&o&&Eo(o)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(u=>u.id!==o.id),appState:{draggingElement:null},storeAction:D.UPDATE});return}if(o){if(t.drag.hasOccurred){let u=$e(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let h=this.scene.getElement(this.state.selectedLinearElement.elementId);if(h?.frameId){let g=Vt(h,c);g&&h&&(En(h,g,this.scene.getNonDeletedElementsMap())||(O(h,{groupIds:[]}),Ks([h],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let h=this.getTopLayerFrameAtSceneCoords(u),g=this.scene.getSelectedElements(this.state),x=this.scene.getElementsMapIncludingDeleted(),v=y=>{if(y.length>0){for(let w of y){let I=w.groupIds.indexOf(this.state.editingGroupId);O(w,{groupIds:w.groupIds.slice(0,I)},!1)}x.forEach(w=>{w.groupIds.length&&Qe(x,w.groupIds[w.groupIds.length-1]).length<2&&O(w,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(h&&!this.state.selectedElementIds[h.id]){let y=g.filter(w=>w.frameId!==h.id&&Aa(w,x,this.state));this.state.editingGroupId&&v(y),x=Lc(x,y,h)}else if(!h&&this.state.editingGroupId){let y=g.filter(w=>w.frameId&&!Aa(w,x,this.state));v(y)}x=xn(x,this.state,this),this.scene.replaceAllElements(x)}}if(re(o)){let u=nw(this.scene.getElementsIncludingDeleted(),o,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Lc(this.scene.getElementsMapIncludingDeleted(),u,o))}O(o,yc(o))}if(n&&this.store.shouldCaptureIncrement(),n&&Eo(n)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(u=>u.id!==n.id),storeAction:D.UPDATE}),t.resize.isResizing){let u=xn(this.scene.getElementsIncludingDeleted(),this.state,this),h=this.scene.getSelectedElements(this.state).filter(g=>re(g));for(let g of h)u=cp(u,Ys(this.scene.getElementsIncludingDeleted(),g,this.state,c),g,this);this.scene.replaceAllElements(u)}let d=t.hit.element;this.state.selectedLinearElement?.elementId!==d?.id&&ie(d)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new j(d)});let m=this.lastPointerDownEvent,p=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Nr(this.state)&&m&&p){if(this.eraserTrail.endPath(),It(m.clientX,m.clientY,p.clientX,p.clientY)===0){let h=$e({clientX:p.clientX,clientY:p.clientY},this.state);this.getElementsAtPosition(h.x,h.y).forEach(x=>this.elementsPendingErasure.add(x.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(d&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[d.id]?xm(this.state,d)?this.setState(u=>{let h={...u.selectedElementIds};for(let g of d.groupIds.flatMap(x=>Qe(this.scene.getNonDeletedElements(),x)))delete h[g.id];return{selectedGroupIds:{...u.selectedElementIds,...d.groupIds.map(g=>({[g]:!1})).reduce((g,x)=>({...g,...x}),{})},selectedElementIds:Fe(h,u)}}):this.state.selectedLinearElement?.isDragging||this.setState(u=>{let h={...u.selectedElementIds};delete h[d.id];let g=pe(this.scene.getNonDeletedElements(),{selectedElementIds:h});return{...er({editingGroupId:u.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:g.length===1&&ie(g[0])?new j(g[0]):u.selectedLinearElement}}):d.frameId&&this.state.selectedElementIds[d.frameId]?this.setState(u=>{let h={...u.selectedElementIds,[d.id]:!0};return delete h[d.frameId],(this.scene.getElement(d.frameId)?.groupIds??[]).flatMap(g=>Qe(this.scene.getNonDeletedElements(),g)).forEach(g=>{delete h[g.id]}),{...er({editingGroupId:u.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:d.link||kt(d)?"info":!1}}):this.setState(u=>({selectedElementIds:Fe({...u.selectedElementIds,[d.id]:!0},u)})):this.setState(u=>({...er({editingGroupId:u.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:ie(d)&&u.selectedLinearElement?.elementId!==d.id?new j(d):u.selectedLinearElement}))),!t.drag.hasOccurred&&!this.state.isResizing&&(d&&Sy({x:t.origin.x,y:t.origin.y,element:d,shape:this.getElementShape(d),threshold:this.getElementHitThreshold(),frameNameBound:re(d)?this.frameNameBoundsCache.get(d):null},c)||!d&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Ye(this.interactiveCanvas,Ne.AUTO);return}if(!a.locked&&a.type!=="freedraw"&&o&&o.type!=="selection"&&this.setState(u=>({selectedElementIds:Fe({...u.selectedElementIds,[o.id]:!0},u),showHyperlinkPopup:kt(o)&&!o.link?"editor":u.showHyperlinkPopup})),(a.type!=="selection"||Ke(this.scene.getNonDeletedElements(),this.state)||!tt(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),t.drag.hasOccurred||s||l){let u=this.scene.getSelectedElements(this.state).filter(ie);rc(u,this,hn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[])}if(a.type==="laser"){this.laserTrails.endPath();return}!a.locked&&a.type!=="freedraw"?(Qr(this.interactiveCanvas),this.setState({draggingElement:null,suggestedBindings:[],activeTool:et(this.state,{type:"selection"})})):this.setState({draggingElement:null,suggestedBindings:[]}),d&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&He.pointers.size<=1&&jt(d)&&this.isIframeLikeElementCenter(d,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(d)})}restoreReadyToEraseElements=()=>{this.elementsPendingErasure=new Set,this.triggerRender()};eraseElements=()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(o=>this.elementsPendingErasure.has(o.id)||o.frameId&&this.elementsPendingErasure.has(o.frameId)||Me(o)&&this.elementsPendingErasure.has(o.containerId)?(t=!0,se(o,{isDeleted:!0})):o);this.elementsPendingErasure=new Set,t&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(r))};initializeImage=async({imageFile:t,imageElement:r,showCursorImagePreview:o=!1})=>{if(!Li(t))throw new Error(E("errors.unsupportedFileType"));let n=t.type;if(Ye(this.interactiveCanvas,"wait"),n===oe.svg)try{t=Dg(await by(await t.text()),t.name)}catch(c){throw console.warn(c),new Error(E("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(t)||dy(t));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(E("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{t=await vc(t,{maxWidthOrHeight:Yx})}catch(c){console.error("Error trying to resizing image file on insertion",c)}if(t.size>Th)throw new Error(E("errors.fileTooBig",{maxSize:`${Math.trunc(Th/1024/1024)}MB`}))}if(o){let c=this.files[i]?.dataURL,d=c&&my(c);this.setImagePreviewCursor(d||t)}let s=this.files[i]?.dataURL||await Bm(t),l=O(r,{fileId:i},!1);return new Promise(async(c,d)=>{try{this.files={...this.files,[i]:{mimeType:n,id:i,dataURL:s,created:Date.now(),lastRetrieved:Date.now()}};let m=this.imageCache.get(i);m||(this.addNewImagesToImageCache(),await this.updateImageCache([l])),m?.image instanceof Promise&&await m.image,this.state.pendingImageElementId!==l.id&&this.state.draggingElement?.id!==l.id&&this.initializeImageDimensions(l,!0),c(l)}catch(m){console.error(m),d(new Error(E("errors.imageInsertError")))}finally{o||Qr(this.interactiveCanvas)}})};insertImageElement=async(t,r,o)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:E("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:o})}catch(n){return O(t,{isDeleted:!0}),this.actionManager.executeAction(To),this.setState({errorMessage:n.message||E("errors.imageInsertError")}),null}};setImagePreviewCursor=async t=>{let o;try{o=await vc(t,{maxWidthOrHeight:96})}catch(i){throw i.cause==="UNSUPPORTED"?new Error(E("errors.unsupportedFileType")):i}let n=await Bm(o);if(t.type===oe.svg){let i=await Ng(n),a=Math.min(i.height,96),s=a*(i.width/i.height);s>96&&(s=96,a=s*(i.height/i.width));let l=document.createElement("canvas");l.height=a,l.width=s,l.getContext("2d").drawImage(i,0,0,s,a),n=l.toDataURL(oe.svg)}this.state.pendingImageElementId&&Ye(this.interactiveCanvas,`url(${n}) 4 4, auto`)};onImageAction=async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:n,y:i}=$e({clientX:r,clientY:o},this.state),a=await Ds({description:"Image",extensions:Object.keys(Fl)}),s=this.createImageElement({sceneX:n,sceneY:i,addToFrameUnderCursor:!1});t?(this.insertImageElement(s,a),this.initializeImageDimensions(s),this.setState({selectedElementIds:Fe({[s.id]:!0},this.state)},()=>{this.actionManager.executeAction(To)})):this.setState({pendingImageElementId:s.id},()=>{this.insertImageElement(s,a,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,editingElement:null,activeTool:et(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(To)})}};initializeImageDimensions=(t,r=!1)=>{let o=xr(t)&&this.imageCache.get(t.fileId)?.image;if(!o||o instanceof Promise){if(t.width<Rn/this.state.zoom.value&&t.height<Rn/this.state.zoom.value){let n=100/this.state.zoom.value;O(t,{x:t.x-n/2,y:t.y-n/2,width:n,height:n})}return}if(r||t.width<Rn/this.state.zoom.value&&t.height<Rn/this.state.zoom.value){let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;O(t,{x:l,y:c,width:s,height:a})}};updateImageCache=async(t,r=this.files)=>{let{updatedFiles:o,erroredFiles:n}=await Um({imageCache:this.imageCache,fileIds:t.map(i=>i.fileId),files:r});if(o.size||n.size)for(let i of t)o.has(i.fileId)&&Oe.delete(i);return n.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(i=>xr(i)&&n.has(i.fileId)?se(i,{status:"error"}):i)),{updatedFiles:o,erroredFiles:n}};addNewImagesToImageCache=async(t=Gm(this.scene.getNonDeletedElements()),r=this.files)=>{let o=t.filter(n=>!n.isDeleted&&!this.imageCache.has(n.fileId));if(o.length){let{updatedFiles:n}=await this.updateImageCache(o,r);n.size&&this.scene.triggerUpdate()}};scheduleImageRefresh=Z_(()=>{this.addNewImagesToImageCache()},Nx);updateBindingEnabledOnPointerMove=t=>{let r=o0(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})};maybeSuggestBindingAtCursor=t=>{let r=gn(t,this);this.setState({suggestedBindings:r!=null?[r]:[]})};maybeSuggestBindingsForLinearElementAtCoords=(t,r,o)=>{if(!r.length)return;let n=r.reduce((i,a)=>{let s=gn(a,this);return s!=null&&!rg(t,o?.id,s)&&i.push(s),i},[]);this.setState({suggestedBindings:n})};clearSelection(t){this.setState(r=>({selectedElementIds:Fe({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&va(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Fe({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}handleInteractiveCanvasRef=t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("wheel",this.handleWheel),this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("wheel",this.handleWheel),this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))};handleAppOnDrop=async t=>{let{file:r,fileHandle:o}=await uy(t),{x:n,y:i}=$e(t,this.state);try{if(Li(r)&&this.isToolSupported("image")){if(r?.type===oe.png||r?.type===oe.svg)try{let l=await Fs(r,this.state,this.scene.getElementsIncludingDeleted(),o);this.syncActionResult({...l,appState:{...l.appState||this.state,isLoading:!1},replaceFiles:!0,storeAction:D.CAPTURE});return}catch(l){if(l.name!=="EncodingError")throw new Error(E("alerts.couldNotLoadInvalidFile"))}let s=this.createImageElement({sceneX:n,sceneY:i});this.insertImageElement(s,r),this.initializeImageDimensions(s),this.setState({selectedElementIds:Fe({[s.id]:!0},this.state)});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let a=t.dataTransfer.getData(oe.excalidrawlib);if(a&&typeof a=="string"){try{let s=Lg(a);this.addElementsFromPasteOrLibrary({elements:su(s),position:t,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(r&&await this.loadFileToCanvas(r,o),t.dataTransfer?.types?.includes("text/plain")){let s=t.dataTransfer?.getData("text");if(s&&Ps(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||Kn(s)?.type==="video")){let l=this.insertEmbeddableElement({sceneX:n,sceneY:i,link:vr(s)});l&&this.setState({selectedElementIds:{[l.id]:!0}})}}};loadFileToCanvas=async(t,r)=>{t=await Tc(t);try{let o=this.scene.getElementsIncludingDeleted(),n;try{n=await Om(t,this.state,o,r)}catch(i){let a=i instanceof Ho;if(a&&i.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:E("errors.imageToolNotSupported")});return}let s=a?E("alerts.cannotRestoreFromImage"):E("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!n)return;n.type===oe.excalidraw?(yr(o.concat(n.data.elements)),this.store.updateSnapshot(X(o),this.state),this.setState({isLoading:!0}),this.syncActionResult({...n.data,appState:{...n.data.appState||this.state,isLoading:!1},replaceFiles:!0,storeAction:D.CAPTURE})):n.type===oe.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(i=>{console.error(i),this.setState({errorMessage:E("errors.importLibraryError")})})}catch(o){this.setState({isLoading:!1,errorMessage:o.message})}};handleCanvasContextMenu=t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==di.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:o}=$e(t,this.state),n=this.getElementAtPosition(r,o,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:o},i),s=n||a?"element":"canvas",l=this.excalidrawContainerRef.current,{top:c,left:d}=l.getBoundingClientRect(),m=t.clientX-d,p=t.clientY-c;ve("contextMenu","openContextMenu",s),this.setState({...n&&!this.state.selectedElementIds[n.id]?{...this.state,...er({editingGroupId:this.state.editingGroupId,selectedElementIds:{[n.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ie(n)?new j(n):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:p,left:m,items:this.getContextMenuItems(s)}})})};maybeDragNewGenericElement=(t,r)=>{let o=this.state.draggingElement,n=t.lastCoords;if(o)if(o.type==="selection"&&this.state.activeTool.type!=="eraser")wp(o,this.state.activeTool.type,t.origin.x,t.origin.y,n.x,n.y,_t(t.origin.x,n.x),_t(t.origin.y,n.y),Ts(r),am(r),this.state.zoom.value);else{let[i,a]=Lt(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),s=xr(o)&&this.imageCache.get(o.fileId)?.image,l=s&&!(s instanceof Promise)?s.width/s.height:null;this.maybeCacheReferenceSnapPoints(r,[o]);let{snapOffset:c,snapLines:d}=GI(o,this.state,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:i-t.originInGrid.x,y:a-t.originInGrid.y},this.scene.getNonDeletedElementsMap());i+=c.x,a+=c.y,this.setState({snapLines:d}),wp(o,this.state.activeTool.type,t.originInGrid.x,t.originInGrid.y,i,a,_t(t.originInGrid.x,i),_t(t.originInGrid.y,a),mo(o)?!Ts(r):Ts(r),am(r),this.state.zoom.value,l,this.state.originSnapOffset),(this.state.activeTool.type===xt.frame||this.state.activeTool.type===xt.magicframe)&&this.setState({elementsToHighlight:Ys(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap())})}};maybeHandleResize=(t,r)=>{let o=this.scene.getSelectedElements(this.state),n=o.filter(d=>re(d)),i=t.resize.handleType;if(n.length>0&&i==="rotation")return!1;this.setState({isResizing:i&&i!=="rotation",isRotating:i==="rotation",activeEmbeddable:null});let a=t.lastCoords,[s,l]=Lt(a.x-t.resize.offset.x,a.y-t.resize.offset.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),c=new Map;if(n.forEach(d=>{ro(this.scene.getNonDeletedElements(),d.id).forEach(p=>{c.set(d.id+p.id,{x:p.x-d.x,y:p.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,m]=Lt(a.x,a.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),p={x:d-t.originInGrid.x,y:m-t.originInGrid.y},u=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,o);let{snapOffset:h,snapLines:g}=UI(o,pe(u,this.state),this.state,r,p,i);s+=h.x,l+=h.y,this.setState({snapLines:g})}if(rf(t.originalElements,i,o,this.scene.getElementsMapIncludingDeleted(),fa(r),am(r),o.some(d=>mo(d))?!Ts(r):Ts(r),s,l,t.resize.center.x,t.resize.center.y)){let d=cm(o,this),m=new Set;return n.forEach(p=>{Ys(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>m.add(u))}),this.setState({elementsToHighlight:[...m],suggestedBindings:d}),!0}return!1};getContextMenuItems=t=>{let r=[];return r.push(Qp,Jp),t==="canvas"?this.state.viewModeEnabled?[...r,tu,pl,NE,ul]:[hb,hr,Qp,Jp,eu,hr,Gf,PT,hr,tu,gb,pl,NE,ul]:(r.push(eu),this.state.viewModeEnabled?[ml,...r]:[hr,qp,ml,hb,DI,_I,hr,...r,hr,ab,sb,hr,lb,uC,fb,bb,TT,cb,hr,mb,hr,Ff,zf,Hf,Uf,hr,pb,ub,hr,jb,Qc,Wf,Tb,hr,Vc])};handleWheel=dt(t=>{if(t.preventDefault(),xd)return;let{deltaX:r,deltaY:o}=t;if(t.metaKey||t.ctrlKey){let n=Math.sign(o),i=na*100,a=Math.abs(o),s=o;a>i&&(s=i*n);let l=this.state.zoom.value-s/100;l+=Math.log10(Math.max(1,this.state.zoom.value))*-n*Math.min(1,a/20),this.translateCanvas(c=>({...ei({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:yn(l)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:n,scrollX:i})=>({scrollX:i-(o||r)/n.value}));return}this.translateCanvas(({zoom:n,scrollX:i,scrollY:a})=>({scrollX:i-r/n.value,scrollY:a-o/n.value}))});getTextWysiwygSnappedToCenterPosition(t,r,o,n){if(n){let i=n.x+n.width/2,a=n.y+n.height/2,s=fm(n,o,this.scene.getNonDeletedElementsMap());if(s&&(i=s.x,a=s.y),Math.hypot(t-i,r-a)<Lx){let{x:d,y:m}=Ht({sceneX:i,sceneY:a},o);return{viewportX:d,viewportY:m,elementCenterX:i,elementCenterY:a}}}}savePointer=(t,r,o)=>{if(!t||!r)return;let{x:n,y:i}=$e({clientX:t,clientY:r},this.state);isNaN(n)||isNaN(i);let a={x:n,y:i,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:a,button:o,pointersMap:He.pointers})};resetShouldCacheIgnoreZoomDebounced=aa(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300);updateDOMRect=t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:o,height:n,left:i,top:a}=r.getBoundingClientRect(),{width:s,height:l,offsetTop:c,offsetLeft:d}=this.state;if(o===s&&n===l&&i===d&&a===c){t&&t();return}this.setState({width:o,height:n,offsetLeft:i,offsetTop:a},()=>{t&&t()})}};refresh=()=>{this.setState({...this.getCanvasOffsets()})};getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:o}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:o}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=es.find(r=>r.code===this.props.langCode)||rn;await Cd(t),this.setAppState({})}},j_=()=>{(T.MODE===Mr.TEST||T.DEV)&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(yr(e))}}}))};j_();var wC=jE;G();f();var J_=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},vC=J_;Y();import{Provider as h7}from"jotai";f();import Q_ from"clsx";import{jsx as TC}from"react/jsx-runtime";var SC=({children:e})=>{let{FooterCenterTunnel:t}=at(),r=Be();return TC(t.In,{children:TC("div",{className:Q_("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":r.zenModeEnabled}),children:e})})},e7=SC;SC.displayName="FooterCenter";f();f();f();import{jsx as Qi,jsxs as CC}from"react/jsx-runtime";var t7=()=>Qi("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Qi("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"})}),r7=()=>CC("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Qi("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)"}),Qi("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)"}),Qi("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)"}),Qi("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)"})]}),IC=({style:e,size:t="small",withText:r})=>CC("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Qi(t7,{}),r&&Qi(r7,{})]});import{Fragment as MC,jsx as Dt,jsxs as ox}from"react/jsx-runtime";var nx=({icon:e,shortcut:t,children:r})=>{let o=_e();return ox(MC,{children:[Dt("div",{className:"welcome-screen-menu-item__icon",children:e}),Dt("div",{className:"welcome-screen-menu-item__text",children:r}),t&&!o.editor.isMobile&&Dt("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};nx.displayName="WelcomeScreenMenuItemContent";var vd=({onSelect:e,children:t,icon:r,shortcut:o,className:n="",...i})=>Dt("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Dt(nx,{icon:r,shortcut:o,children:t})});vd.displayName="WelcomeScreenMenuItem";var AC=({children:e,href:t,icon:r,shortcut:o,className:n="",...i})=>Dt("a",{...i,className:`welcome-screen-menu-item ${n}`,href:t,target:"_blank",rel:"noreferrer",children:Dt(nx,{icon:r,shortcut:o,children:e})});AC.displayName="WelcomeScreenMenuItemLink";var Po=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=at();return Dt(t.In,{children:Dt("div",{className:"welcome-screen-center",children:e||ox(MC,{children:[Dt(ix,{}),Dt(ax,{children:E("welcomeScreen.defaults.center_heading")}),ox(sx,{children:[Dt(cx,{}),Dt(lx,{})]})]})})})};Po.displayName="Center";var ix=({children:e})=>Dt("div",{className:"welcome-screen-center__logo virgil welcome-screen-decor",children:e||Dt(IC,{withText:!0})});ix.displayName="Logo";var ax=({children:e})=>Dt("div",{className:"welcome-screen-center__heading welcome-screen-decor virgil",children:e});ax.displayName="Heading";var sx=({children:e})=>Dt("div",{className:"welcome-screen-menu",children:e});sx.displayName="Menu";var lx=()=>{let e=Ft();return Dt(vd,{onSelect:()=>e.executeAction(Va),shortcut:"?",icon:qs,children:E("helpDialog.title")})};lx.displayName="MenuItemHelp";var cx=()=>{let e=Be(),t=Ft();return e.viewModeEnabled?null:Dt(vd,{onSelect:()=>t.executeAction(sl),shortcut:Pt("loadScene"),icon:Js,children:E("buttons.load")})};cx.displayName="MenuItemLoadScene";var kC=({onSelect:e})=>{let{t}=At();return Dt(vd,{shortcut:null,onSelect:e,icon:kp,children:t("labels.liveCollaboration")})};kC.displayName="MenuItemLiveCollaborationTrigger";Po.Logo=ix;Po.Heading=ax;Po.Menu=sx;Po.MenuItem=vd;Po.MenuItemLink=AC;Po.MenuItemHelp=lx;Po.MenuItemLoadScene=cx;Po.MenuItemLiveCollaborationTrigger=kC;f();import{jsx as _l,jsxs as dx}from"react/jsx-runtime";var mh=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=at();return _l(t.In,{children:dx("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[_w,_l("div",{className:"welcome-screen-decor-hint__label",children:e||E("welcomeScreen.defaults.menuHint")})]})})};mh.displayName="MenuHint";var ph=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=at();return _l(t.In,{children:dx("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[_l("div",{className:"welcome-screen-decor-hint__label",children:e||E("welcomeScreen.defaults.toolbarHint")}),Nw]})})};ph.displayName="ToolbarHint";var uh=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=at();return _l(t.In,{children:dx("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[_l("div",{children:e||E("welcomeScreen.defaults.helpHint")}),Rw]})})};uh.displayName="HelpHint";import{Fragment as LC,jsx as Td,jsxs as n7}from"react/jsx-runtime";var hh=e=>Td(LC,{children:e.children||n7(LC,{children:[Td(Po,{}),Td(mh,{}),Td(ph,{}),Td(uh,{})]})});hh.displayName="WelcomeScreen";hh.Center=Po;hh.Hints={MenuHint:mh,ToolbarHint:ph,HelpHint:uh};var o7=hh;f();import i7 from"clsx";import{jsx as s7,jsxs as l7}from"react/jsx-runtime";var PC=({isCollaborating:e,onSelect:t,...r})=>{let o=Be(),n=o.width<830;return l7(Sn,{...r,className:i7("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:n?void 0:"auto"},title:E("labels.liveCollaboration"),children:[n?n2:E("labels.share"),o.collaborators.size>0&&s7("div",{className:"CollabButton-collaborators",children:o.collaborators.size})]})},a7=PC;PC.displayName="LiveCollaborationTrigger";be();Ns();f();ho();G();var c7=(e,t,r)=>!!(t&&(t.id===e.editingElement?.id||t.id===e.resizingElement?.id||t.id===e.draggingElement?.id||t.version>r.version||t.version===r.version&&t.versionNonce<r.versionNonce)),d7=(e,t,r)=>{let o=X(e),n=[],i=new Set;for(let s of t)if(!i.has(s.id)){let l=o.get(s.id),c=c7(r,l,s);l&&c?(n.push(l),i.add(l.id)):(n.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(n.push(s),i.add(s.id));let a=Jd(n);return yr(a),a};Ma();jn();Br();Hn();le();Y();Ae();De();G();f();import{jsx as DC,jsxs as m7}from"react/jsx-runtime";var _C=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:r}=at(),o=Re();return DC(r.In,{children:m7(Ue.Item,{onSelect:()=>{ve("ai","dialog open","ttd"),o({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??j2,children:[e??E("labels.textToDiagram"),DC(Ue.Item.Badge,{children:"AI"})]})})};_C.displayName="TTDDialogTrigger";Sa();it();Xg();import{jsx as mx}from"react/jsx-runtime";vC();var g7=e=>{let{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n=!1,onPointerUpdate:i,renderTopRightUI:a,langCode:s=rn.code,viewModeEnabled:l,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:h,onPaste:g,detectScroll:x=!0,handleKeyboardGlobally:v=!1,onLibraryChange:y,autoFocus:w=!1,generateIdForFile:I,onLinkOpen:A,onPointerDown:C,onPointerUp:L,onScrollChange:M,children:z,validateEmbeddable:k,renderEmbeddable:N,aiEnabled:B}=e,_=e.UIOptions?.canvasActions,V={...e.UIOptions,canvasActions:{...vh.canvasActions,..._},tools:{image:e.UIOptions?.tools?.image??!0}};return _?.export&&(V.canvasActions.export.saveFileToDisk=_.export?.saveFileToDisk??vh.canvasActions.export.saveFileToDisk),V.canvasActions.toggleTheme===null&&typeof p>"u"&&(V.canvasActions.toggleTheme=!0),u7(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let J=Se=>{typeof Se.scale=="number"&&Se.scale!==1&&Se.preventDefault()};return document.addEventListener("touchmove",J,{passive:!1}),()=>{document.removeEventListener("touchmove",J)}},[]),mx(h7,{unstable_createStore:()=>nr,scope:Ge,children:mx(jx,{langCode:s,theme:p,children:mx(wC,{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n,onPointerUpdate:i,renderTopRightUI:a,langCode:s,viewModeEnabled:l,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:h,UIOptions:V,onPaste:g,detectScroll:x,handleKeyboardGlobally:v,onLibraryChange:y,autoFocus:w,generateIdForFile:I,onLinkOpen:A,onPointerDown:C,onPointerUp:L,onScrollChange:M,validateEmbeddable:k,renderEmbeddable:N,aiEnabled:B!==!1,children:z})})})},f7=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:r,UIOptions:o={},...n}=e,{initialData:i,UIOptions:a={},...s}=t,l=Object.keys(o),c=Object.keys(a);return l.length!==c.length?!1:l.every(m=>m==="canvasActions"?Object.keys(o.canvasActions).every(u=>u==="export"&&o?.canvasActions?.export&&a?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:o?.canvasActions?.[u]===a?.canvasActions?.[u]):o[m]===a[m])&&tt(n,s)},b7=p7.memo(g7,f7);b7.displayName="Excalidraw";export{Sn as Button,xh as DEFAULT_LASER_COLOR,Gu as DefaultSidebar,b7 as Excalidraw,mt as FONT_FAMILY,e7 as Footer,a7 as LiveCollaborationTrigger,oe as MIME_TYPES,Ir as MainMenu,lt as ROUNDNESS,ii as Sidebar,D as StoreAction,ce as THEME,kE as TTDDialog,_C as TTDDialogTrigger,o7 as WelcomeScreen,Ai as bumpVersion,Cl as convertToExcalidrawElements,rn as defaultLang,Yy as elementPartiallyOverlapsWithOrContainsBBox,$g as elementsOverlappingBBox,ap as exportToBlob,Ri as exportToCanvas,d6 as exportToClipboard,Vs as exportToSvg,we as getCommonBounds,Rm as getFreeDrawSvgPath,au as getLibraryItemsHash,Te as getNonDeletedElements,P6 as getSceneVersion,fg as getVisibleSceneBounds,cf as hashElementsVersion,df as hashString,Kg as isElementInsideBBox,Eo as isInvisiblySmallElement,ie as isLinearElement,es as languages,Fs as loadFromBlob,Pg as loadLibraryFromBlob,Om as loadSceneOrLibraryFromBlob,UT as mergeLibraryItems,O as mutateElement,se as newElementWith,vr as normalizeLink,Cb as parseLibraryTokensFromUrl,d7 as reconcileElements,Mi as restore,q0 as restoreAppState,xc as restoreElements,Ia as restoreLibraryItems,Ht as sceneCoordsToViewportCoords,Pi as serializeAsJSON,Hm as serializeLibraryAsJSON,_e as useDevice,oM as useHandleLibrary,At as useI18n,$e as viewportCoordsToSceneCoords,tT as zoomToFitBounds};
|
|
177
|
+
`),r)}}addTextFromPaste(t,r=!1){let{x:o,y:n}=Qe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),i={x:o,y:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:vn,verticalAlign:Pa,locked:!1},a=Me({fontSize:i.fontSize,fontFamily:i.fontFamily}),s=uo(i.fontFamily),[l,,c]=Mb(this.state),d=Math.max(Math.min((c-l)*.5,800),200),m=10,p=n,u=r?[t]:t.split(`
|
|
178
|
+
`),g=u.reduce((h,x,v)=>{let y=x.trim();if(y.length){let w=this.getTopLayerFrameAtSceneCoords({x:o,y:p}),C=Vt(y,a,s),M=C.width>d,I=M?Lo(y,a,d):y;C=M?Vt(I,a,s):C;let P=o-C.width/2,A=p-C.height/2,N=jt({...i,x:P,y:A,text:I,originalText:y,lineHeight:s,autoResize:!M,frameId:w?w.id:null});h.push(N),p+=N.height+m}else u[v-1]?.trim()&&(p+=ra(i.fontSize,s)+m);return h},[]);g.length!==0&&(this.scene.insertElements(g),this.setState({selectedElementIds:Ge(Object.fromEntries(g.map(h=>[h.id,!0])),this.state)}),!r&&g.length>1&&LA===!1&&!this.device.editor.isMobile&&(this.setToast({message:E("toast.pasteAsSingleElement",{shortcut:O("CtrlOrCmd+Shift+V")}),duration:5e3}),LA=!0),this.store.shouldCaptureIncrement())}setAppState=(t,r)=>{this.setState(t,r)};removePointer=t=>{Ta&&this.resetContextMenuTimer(),Ve.pointers.delete(t.pointerId)};toggleLock=(t="ui")=>{this.state.activeTool.locked||Ce("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...nt(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))};updateFrameRendering=t=>{this.setState(r=>{let o=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:o?.enabled??r.frameRendering.enabled,clip:o?.clip??r.frameRendering.clip,name:o?.name??r.frameRendering.name,outline:o?.outline??r.frameRendering.outline}}})};togglePenMode=t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))};onHandToolToggle=()=>{this.actionManager.executeAction(yS)};zoomCanvas=t=>{this.setState({...Ci({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Un(t)},this.state)})};cancelInProgressAnimation=null;scrollToContent=(t=this.scene.getNonDeletedElements(),r)=>{this.cancelInProgressAnimation?.();let o=Array.isArray(t)?t:[t],n=this.state.zoom,i=this.state.scrollX,a=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=zd({targetElements:o,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor});n=s.zoom,i=s.scrollX,a=s.scrollY}else{let s=_n(o,this.state);i=s.scrollX,a=s.scrollY}if(r?.animate){let s=this.state.scrollX,l=this.state.scrollY,c=this.state.zoom.value,d=I0({fromValues:{scrollX:s,scrollY:l,zoom:c},toValues:{scrollX:i,scrollY:a,zoom:n.value},interpolateValue:(m,p,u,g)=>{if(g==="zoom")return m*Math.pow(p/m,ai(u))},onStep:({scrollX:m,scrollY:p,zoom:u})=>{this.setState({scrollX:m,scrollY:p,zoom:{value:u}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:i,scrollY:a,zoom:n})};maybeUnfollowRemoteUser=()=>{this.state.userToFollow&&this.setState({userToFollow:null})};translateCanvas=t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)};setToast=t=>{this.setState({toast:t})};restoreFileFromShare=async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let o=await r.blob(),n=new File([o],o.name||"",{type:o.type});this.loadFileToCanvas(n,null),await t.delete("shared-file"),window.history.replaceState(null,fc,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}};addFiles=bt(t=>{let r=t.reduce((o,n)=>(o.set(n.id,n),o),new Map);this.files={...this.files,...Object.fromEntries(r)},this.scene.getNonDeletedElements().forEach(o=>{kr(o)&&r.has(o.fileId)&&(this.imageCache.delete(o.fileId),_e.delete(o))}),this.scene.triggerUpdate(),this.addNewImagesToImageCache()});updateScene=bt(t=>{let r=fr(t.elements??[]);if(t.storeAction&&t.storeAction!==_.NONE){let o=this.store.snapshot.appState,n=this.store.snapshot.elements,i=t.appState?Object.assign({},o,t.appState):o,a=t.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),Z(r)):n;t.storeAction===_.CAPTURE?this.store.captureIncrement(a,i):t.storeAction===_.UPDATE&&this.store.updateSnapshot(a,i)}t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(r),t.collaborators&&this.setState({collaborators:t.collaborators})});triggerRender=t=>{t===!0?this.scene.triggerUpdate():this.setState({})};toggleSidebar=({name:t,tab:r,force:o})=>{let n;o===void 0?n=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:n=o?t:null;let i=n?{name:n}:null;return i&&r&&(i.tab=r),this.setState({openSidebar:i}),!!n};updateCurrentCursorPosition=bt(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY});onKeyDown=bt(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(i,a){let s=i[a];return typeof s=="function"?s.bind(i):a==="key"?t.shiftKey?i.key.toUpperCase():i.key.toLowerCase():s}})),t[S.CTRL_OR_CMD]&&t.key===S.P&&!t.shiftKey&&!t.altKey){this.setToast({message:E("commandPalette.shortcutHint",{shortcut:Bt("commandPalette")})}),t.preventDefault();return}if(t[S.CTRL_OR_CMD]&&t.key.toLowerCase()===S.V&&(yh=t.shiftKey,clearTimeout(PA),PA=window.setTimeout(()=>{yh=!1},100)),t[S.CTRL_OR_CMD]&&Tn(t.target)&&(t.code===Se.MINUS||t.code===Se.EQUAL)){t.preventDefault();return}if(Tn(t.target)&&t.key!==S.ESCAPE||ll(t.key)&&Fh(t.target))return;if(t.key===S.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===S.E&&t.shiftKey&&t[S.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===S.PAGE_UP||t.key===S.PAGE_DOWN){let i=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===S.PAGE_DOWN&&(i=-i),t.shiftKey?this.translateCanvas(a=>({scrollX:a.scrollX+i})):this.translateCanvas(a=>({scrollY:a.scrollY+i}))}if(this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[S.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),ll(t.key)){let i=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),a=i.find(de),s=a?a.startBinding||a.endBinding?0:wm:this.state.gridSize&&(t.shiftKey?wm:this.state.gridSize)||(t.shiftKey?Jx:wm),l=0,c=0;t.key===S.ARROW_LEFT?l=-s:t.key===S.ARROW_RIGHT?l=s:t.key===S.ARROW_UP?c=-s:t.key===S.ARROW_DOWN&&(c=s),i.forEach(d=>{F(d,{x:d.x+l,y:d.y+c}),qt(d,this.scene.getNonDeletedElementsMap(),this.scene,{simultaneouslyUpdated:i})}),this.setState({suggestedBindings:Gp(i.filter(d=>d.id!==a?.id||s!==0),this.scene.getNonDeletedElementsMap())}),t.preventDefault()}else if(t.key===S.ENTER){let i=this.scene.getSelectedElements(this.state);if(i.length===1){let a=i[0];if(t[S.CTRL_OR_CMD])ie(a)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==i[0].id)&&(this.store.shouldCaptureIncrement(),de(a)||this.setState({editingLinearElement:new K(a)}));else if(H(a)||o3(a)){let s;H(a)||(s=a);let l=Pu(a,this.state,this.scene.getNonDeletedElementsMap()),c=l.x,d=l.y;this.startTextEditing({sceneX:c,sceneY:d,container:s}),t.preventDefault();return}else Q(a)&&this.setState({editingFrame:a.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&this.state.draggingElement===null){let i=Ev(t.key);i?(this.state.activeTool.type!==i&&Ce("toolbar",i,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),i==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(a=>({currentItemArrowType:a.currentItemArrowType===_t.sharp?_t.round:a.currentItemArrowType===_t.round?_t.elbow:_t.sharp})),this.setActiveTool({type:i}),t.stopPropagation()):t.key===S.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===S.SPACE&&Ve.pointers.size===0&&(Ms=!0,Ze(this.interactiveCanvas,Be.GRAB),t.preventDefault()),(t.key===S.G||t.key===S.S)&&!t.altKey&&!t[S.CTRL_OR_CMD]){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;t.key===S.G&&(vi(this.state.activeTool.type)||i.some(a=>vi(a.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===S.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[S.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===S.F){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;(this.state.activeTool.type==="text"||i.find(a=>H(a)||J(a,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===S.K&&!t.altKey&&!t[S.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[S.CTRL_OR_CMD]&&(t.key===S.BACKSPACE||t.key===S.DELETE)&&mr.set(Ss,"clearCanvas");let r=t.key.toLocaleLowerCase(),o=r===S.S&&t.shiftKey,n=t.key===S.I||r===S.G&&t.shiftKey;(o||n)&&this.openEyeDropper({type:o?"stroke":"background"})});onWheel=bt(t=>{!(t.target instanceof HTMLCanvasElement)&&t.ctrlKey&&t.preventDefault()});onKeyUp=bt(t=>{t.key===S.SPACE&&(this.state.viewModeEnabled?Ze(this.interactiveCanvas,Be.GRAB):this.state.activeTool.type==="selection"?mo(this.interactiveCanvas):(po(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Ms=!1),!t[S.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),ll(t.key)&&(es(this.scene.getSelectedElements(this.state).filter(ie),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Fn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[]),this.setState({suggestedBindings:[]}))});isToolSupported=t=>this.props.UIOptions.tools?.[t]!==!1;setActiveTool=t=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=nt(this.state,t);r.type==="hand"?Ze(this.interactiveCanvas,Be.GRAB):Ms||po(this.interactiveCanvas,this.state),T0(document.activeElement)&&this.focusContainer(),Cc(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(t.type==="image"&&t.insertOnCanvasDirectly)??!1}),this.setState(o=>{let n={snapLines:o.snapLines.length?[]:o.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type==="freedraw"&&this.store.shouldCaptureIncrement(),r.type!=="selection"?{...o,activeTool:r,selectedElementIds:Ge({},o),selectedGroupIds:Ge({},o),editingGroupId:null,multiElement:null,...n}:{...o,activeTool:r,...n}})};setOpenDialog=t=>{this.setState({openDialog:t})};setCursor=t=>{Ze(this.interactiveCanvas,t)};resetCursor=()=>{mo(this.interactiveCanvas)};isTouchScreenMultiTouchGesture=()=>Ve.pointers.size>=2;getName=()=>this.state.name||this.props.name||`${E("labels.untitled")}-${Oh()}`;onGestureStart=bt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ge({},this.state),activeEmbeddable:null}),Ve.initialScale=this.state.zoom.value});onGestureChange=bt(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=Ve.initialScale;r&&this.setState(o=>({...Ci({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Un(r*t.scale)},o)}))});onGestureEnd=bt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ge(this.state.previousSelectedElementIds,this.state)}),Ve.initialScale=null});handleTextWysiwyg(t,{isExistingElement:r=!1}){let o=this.scene.getElementsMapIncludingDeleted(),n=(i,a)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&H(s)?pe(s,{originalText:i,isDeleted:a??s.isDeleted,...Oc(s,Et(s,o),o,i)}):s)])};CA({id:t.id,canvas:this.canvas,getViewportCoords:(i,a)=>{let{x:s,y:l}=$t({sceneX:i,sceneY:a},this.state);return[s-this.state.offsetLeft,l-this.state.offsetTop]},onChange:bt(i=>{n(i,!1),Sd(t)&&qt(t,o,this.scene)}),onSubmit:bt(({viaKeyboard:i,nextOriginalText:a})=>{let s=!a.trim();if(n(a,s),!s&&i){let l=t.containerId?t.containerId:t.id;this.setState(c=>({selectedElementIds:Ge({...c.selectedElementIds,[l]:!0},c)}))}s&&Vp(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.shouldCaptureIncrement(),this.setState({draggingElement:null,editingElement:null}),this.state.activeTool.locked&&po(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),n(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let o=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return o&&H(o)&&!o.isDeleted?o:null}getElementAtPosition(t,r,o){let n=this.getElementsAtPosition(t,r,o?.includeBoundTextElement,o?.includeLockedElements);if(n.length>1){if(o?.preferSelected){for(let a=n.length-1;a>-1;a--)if(this.state.selectedElementIds[n[a].id])return n[a]}let i=n[n.length-1];return ja({x:t,y:r,element:i,shape:cn(i,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:Q(i)?this.frameNameBoundsCache.get(i):null})?i:n[n.length-2]}return n.length===1?n[0]:null}getElementsAtPosition(t,r,o=!1,n=!1){let i=[],a=this.scene.getNonDeletedElementsMap();return(o&&n?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(n||!l.locked)&&(o||!(H(l)&&l.containerId)))).filter(l=>this.hitElement(t,r,l)).filter(l=>{let c=Qt(l,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?fb({x:t,y:r},c,a):!0}).filter(l=>Io(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(){return e0/this.state.zoom.value}hitElement(t,r,o,n=!0){if(n&&this.state.selectedElementIds[o.id]&&_u([o],this.state)){let a=mv(o,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold());return sl([t,r],a)}return Uf(t,r,Np(o,this.scene.getNonDeletedElementsMap()))?!0:ja({x:t,y:r,element:o,shape:cn(o,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:Q(o)?this.frameNameBoundsCache.get(o):null})}getTextBindableContainerAtPosition(t,r){let o=this.scene.getNonDeletedElements(),n=this.scene.getSelectedElements(this.state);if(n.length===1)return Mn(n[0],!1)?n[0]:null;let i=null;for(let a=o.length-1;a>=0;--a){if(o[a].isDeleted)continue;let[s,l,c,d]=ae(o[a],this.scene.getNonDeletedElementsMap());if(ne(o[a])&&ja({x:t,y:r,element:o[a],shape:cn(o[a],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})){i=o[a];break}else if(s<t&&t<c&&l<r&&r<d){i=o[a];break}}return Mn(i,!1)?i:null}startTextEditing=({sceneX:t,sceneY:r,insertAtParentCenter:o=!0,container:n,autoEdit:i=!0})=>{let a=!1,s=o&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n);n&&s&&(J(n,this.scene.getNonDeletedElementsMap())||(a=!0));let l=null,c=this.scene.getSelectedElements(this.state);c.length===1?H(c[0])?l=c[0]:n?l=J(c[0],this.scene.getNonDeletedElementsMap()):l=this.getTextElementAtPosition(t,r):l=this.getTextElementAtPosition(t,r);let d=l?.fontFamily||this.state.currentItemFontFamily,m=l?.lineHeight||uo(d),p=this.state.currentItemFontSize;if(!l&&a&&n&&!ne(n)){let x=_l(Me({fontSize:p,fontFamily:d}),m),v=Dl(p,m),y=Math.max(n.height,v),w=Math.max(n.width,x);F(n,{height:y,width:w}),t=n.x+w/2,r=n.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n))}let u=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),g=l||jt({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:p,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?kt.MIDDLE:Pa,containerId:a?n?.id:void 0,groupIds:n?.groupIds??[],lineHeight:m,angle:n?.angle??0,frameId:u?u.id:null});if(!l&&a&&n&&F(n,{boundElements:(n.boundElements||[]).concat({type:"text",id:g.id})}),this.setState({editingElement:g}),!l)if(n&&a){let h=this.scene.getElementIndex(n.id);this.scene.insertElementAtIndex(g,h+1)}else this.scene.insertElement(g);i||l||n?this.handleTextWysiwyg(g,{isExistingElement:!!l}):this.setState({draggingElement:g,multiElement:null})};handleCanvasDoubleClick=t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state);if(r.length===1&&ie(r[0])&&t[S.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)&&!de(r[0])){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new K(r[0])});return}mo(this.interactiveCanvas);let{x:o,y:n}=Qe(t,this.state);if(Jo(this.state).length>0){let a=this.getElementAtPosition(o,n),s=a&&X0(a,this.state.selectedGroupIds);if(s){this.store.shouldCaptureIncrement(),this.setState(l=>({...l,...cr({editingGroupId:s,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),l,this)}));return}}if(mo(this.interactiveCanvas),!t[S.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let a=this.getElementAtPosition(o,n);if(sr(a)){this.setState({activeEmbeddable:{element:a,state:"active"}});return}let s=this.getTextBindableContainerAtPosition(o,n);if(s&&(Ct(s)||!Ar(s.backgroundColor)||ja({x:o,y:n,element:s,shape:cn(s,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let l=Pu(s,this.state,this.scene.getNonDeletedElementsMap());o=l.x,n=l.y}this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:s})}};getElementLinkAtPosition=(t,r)=>{let o=this.scene.getNonDeletedElements().slice().reverse(),n=1/0;return o.find((i,a)=>(r&&i.id===r.id&&(n=a),i.link&&a<=n&&eu(i,this.scene.getNonDeletedElementsMap(),this.state,[t.x,t.y],this.device.editor.isMobile)))};redirectToLink=(t,r)=>{let o=Pt(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY,this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY);if(!this.hitLinkElement||r&&o>ri||!r&&o!==0)return;let n=Qe(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=eu(this.hitLinkElement,i,this.state,[n.x,n.y],this.device.editor.isMobile),s=Qe(this.lastPointerUpEvent,this.state),l=eu(this.hitLinkElement,i,this.state,[s.x,s.y],this.device.editor.isMobile);if(a&&l){let c=this.hitLinkElement.link;if(c){c=Pr(c);let d;if(this.props.onLinkOpen&&(d=Fm("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let m=Xm(c)?"_self":"_blank",p=window.open(void 0,m);p&&(p.opener=null,p.location=c)}}}};getTopLayerFrameAtSceneCoords=t=>{let r=this.scene.getNonDeletedElementsMap(),o=this.scene.getNonDeletedFramesLikes().filter(n=>fb(t,n,r));return o.length?o[o.length-1]:null};handleCanvasPointerMove=t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,Ve.pointers.has(t.pointerId)&&Ve.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=Ve.initialScale;if(Ve.pointers.size===2&&Ve.lastCenter&&r&&Ve.initialDistance){let p=v1(Ve.pointers),u=p.x-Ve.lastCenter.x,g=p.y-Ve.lastCenter.y;Ve.lastCenter=p;let h=T1(Array.from(Ve.pointers.values())),x=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:h/Ve.initialDistance,v=x?Un(r*x):this.state.zoom.value;this.setState(y=>{let w=Ci({viewportX:p.x,viewportY:p.y,nextZoom:v},y);this.translateCanvas({zoom:w.zoom,scrollX:w.scrollX+2*(u/v),scrollY:w.scrollY+2*(g/v),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else Ve.lastCenter=Ve.initialDistance=Ve.initialScale=null;if(Ms||lm||hx||qo(this.state))return;let n=C1(fx,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.draggingElement&&!this.state.multiElement&&(n?mo(this.interactiveCanvas):po(this.interactiveCanvas,this.state));let i=Qe(t,this.state),{x:a,y:s}=i;if(!this.state.draggingElement&&nA(this.state.activeTool.type)){let{originOffset:p,snapLines:u}=oA(this.scene.getNonDeletedElements(),this.state,{x:a,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(g=>{let h=Bm(g.snapLines,u),x=g.originSnapOffset?Bm(g.originSnapOffset,p):p;return g.snapLines===h&&g.originSnapOffset===x?null:{snapLines:h,originSnapOffset:x}})}else this.state.draggingElement||this.setState(p=>p.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let p=K.handlePointerMove(t,a,s,this.state,this.scene);p&&p!==this.state.editingLinearElement&&ux(()=>{this.setState({editingLinearElement:p})}),p?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(i):ux(()=>{this.setState({suggestedBindings:[]})})}if(Uh(this.state.activeTool.type)){let{draggingElement:p}=this.state;Kr(p,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(p,[i],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(i)}if(this.state.multiElement){let{multiElement:p}=this.state,{x:u,y:g}=p,{points:h,lastCommittedPoint:x}=p,v=h[h.length-1];if(po(this.interactiveCanvas,this.state),v===x)Pt(a-u,s-g,v[0],v[1])>=Ns?F(p,{points:[...h,[a-u,s-g]]}):Ze(this.interactiveCanvas,Be.POINTER);else if(h.length>2&&x&&Pt(a-u,s-g,x[0],x[1])<Ns)Ze(this.interactiveCanvas,Be.POINTER),F(p,{points:h.slice(0,-1)});else{let[y,w]=Ot(a,s,t[S.CTRL_OR_CMD]||de(p)?null:this.state.gridSize),[C,M]=p?.lastCommittedPoint??[0,0],I=y-u-C,P=w-g-M;Za(t)&&({width:I,height:P}=Pl(C+u,M+g,y,w)),Dr(h,this.state.zoom.value)&&Ze(this.interactiveCanvas,Be.POINTER),de(p)?_o(p,this.scene,[...h.slice(0,-1),[C+I,M+P]],void 0,void 0,{isDragging:!0}):F(p,{points:[...h.slice(0,-1),[C+I,M+P]]})}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!n&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&!(d.length===1&&de(d[0]))){let p=Ru(c,this.state,a,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(p&&p.transformHandleType){Ze(this.interactiveCanvas,Ou(p));return}}}else if(d.length>1&&!n){let p=Nu(Te(d),a,s,this.state.zoom,t.pointerType,this.device);if(p){Ze(this.interactiveCanvas,Ou({transformHandleType:p}));return}}let m=this.getElementAtPosition(i.x,i.y);this.hitLinkElement=this.getElementLinkAtPosition(i,m),!$r(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(Ze(this.interactiveCanvas,Be.POINTER),KS(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):($S(),m&&(m.link||Rt(m))&&this.state.selectedElementIds[m.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Ze(this.interactiveCanvas,H(m)?Be.TEXT:Be.CROSSHAIR):this.state.viewModeEnabled?Ze(this.interactiveCanvas,Be.GRAB):n?Ze(this.interactiveCanvas,Be.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,s):t[S.CTRL_OR_CMD]?Ze(this.interactiveCanvas,Be.AUTO):(m||this.isHittingCommonBoundingBoxOfSelectedElements(i,d))&&!m?.locked&&(m&&sr(m)&&this.isIframeLikeElementCenter(m,t,a,s)?(Ze(this.interactiveCanvas,Be.POINTER),this.setState({activeEmbeddable:{element:m,state:"hover"}})):(Ze(this.interactiveCanvas,Be.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))))};handleEraser=(t,r,o)=>{this.eraserTrail.addPointToPath(o.x,o.y);let n=!1,i=new Set,a=this.scene.getNonDeletedElements(),s=p=>{for(let u of p){if(u.locked)return;if(t.altKey?this.elementsPendingErasure.delete(u.id)&&(n=!0):this.elementsPendingErasure.has(u.id)||(n=!0,this.elementsPendingErasure.add(u.id)),n&&u.groupIds?.length){let g=u.groupIds.at(-1);if(!i.has(g)){i.add(g);let h=ot(a,g);for(let x of h)t.altKey?this.elementsPendingErasure.delete(x.id):this.elementsPendingErasure.add(x.id)}}}},l=Pt(r.lastCoords.x,r.lastCoords.y,o.x,o.y),c=this.getElementHitThreshold(),d={...r.lastCoords},m=0;for(;m<=l;){let p=this.getElementsAtPosition(d.x,d.y);if(s(p),m===l)break;m=Math.min(m+c,l);let u=m/l,g=(1-u)*d.x+u*o.x,h=(1-u)*d.y+u*o.y;d.x=g,d.y=h}if(r.lastCoords.x=o.x,r.lastCoords.y=o.y,n){for(let p of this.scene.getNonDeletedElements())ze(p)&&(this.elementsPendingErasure.has(p.id)||this.elementsPendingErasure.has(p.containerId))&&(t.altKey?(this.elementsPendingErasure.delete(p.id),this.elementsPendingErasure.delete(p.containerId)):(this.elementsPendingErasure.add(p.id),this.elementsPendingErasure.add(p.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.triggerRender()}};handleTouchMove=t=>{cm=!0};handleHoverSelectedLinearElement(t,r,o){let n=this.scene.getNonDeletedElementsMap(),i=K.getElement(t.elementId,n);if(i)if(this.state.selectedLinearElement){let a=-1,s=null;ja({x:r,y:o,element:i,shape:cn(i,this.scene.getNonDeletedElementsMap())})?(a=K.getPointIndexUnderCursor(i,n,this.state.zoom,r,o),s=K.getSegmentMidpointHitCoords(t,{x:r,y:o},this.state,this.scene.getNonDeletedElementsMap()),a>=0||s?Ze(this.interactiveCanvas,Be.POINTER):this.hitElement(r,o,i)&&Ze(this.interactiveCanvas,Be.MOVE)):this.hitElement(r,o,i)&&(!de(i)||!(i.startBinding||i.endBinding))&&Ze(this.interactiveCanvas,Be.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),K.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else Ze(this.interactiveCanvas,Be.AUTO)}handleCanvasPointerDown=t=>{if(this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.draggingElement&&this.state.draggingElement.type==="freedraw"){let c=this.state.draggingElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(d=>d.id!==c.id)}:{},appState:{draggingElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Ge(Object.keys(this.state.selectedElementIds).filter(d=>d!==c.id).reduce((d,m)=>(d[m]=this.state.selectedElementIds[m],d),{}),this.state)},storeAction:_.UPDATE});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Us(this.device,{isTouchScreen:!0})),lm||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Ni.ERASER&&this.state.activeTool.type!==It.eraser){this.setState({activeTool:nt(this.state,{type:It.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{d(),m?.(),$r(this.state)&&this.setState({activeTool:nt(this.state,{...this.state.activeTool.lastActiveTool||{type:It.selection},lastActiveToolBeforeEraser:null})})},d=vt(window,"pointerup",c,{once:!0}),m;requestAnimationFrame(()=>{m=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==Ni.MAIN&&t.button!==Ni.TOUCH&&t.button!==Ni.ERASER||Ve.pointers.size>1)return;let o=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,o)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,o))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="text")this.handleTextOnPointerDown(t,o);else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,o);else if(this.state.activeTool.type==="image"){Ze(this.interactiveCanvas,Be.CROSSHAIR);let c=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!c)return;this.setState({draggingElement:c,editingElement:c,pendingImageElementId:null,multiElement:null});let{x:d,y:m}=Qe(t,this.state),p=this.getTopLayerFrameAtSceneCoords({x:d,y:m});F(c,{x:d,y:m,frameId:p?p.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,o):this.state.activeTool.type==="custom"?po(this.interactiveCanvas,this.state):this.state.activeTool.type===It.frame||this.state.activeTool.type===It.magicframe?this.createFrameElementOnPointerDown(o,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(o.lastCoords.x,o.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,o);this.props?.onPointerDown?.(this.state.activeTool,o),this.onPointerDownEmitter.trigger(this.state.activeTool,o,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(o.lastCoords.x,o.lastCoords.y);let i=this.onPointerMoveFromPointerDownHandler(o),a=this.onPointerUpFromPointerDownHandler(o),s=this.onKeyDownFromPointerDownHandler(o),l=this.onKeyUpFromPointerDownHandler(o);this.missingPointerEventCleanupEmitter.once(c=>a(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",i),window.addEventListener("pointerup",a),window.addEventListener("keydown",s),window.addEventListener("keyup",l),o.eventListeners.onMove=i,o.eventListeners.onUp=a,o.eventListeners.onKeyUp=l,o.eventListeners.onKeyDown=s)};handleCanvasPointerUp=t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Qe({clientX:t.clientX,clientY:t.clientY},this.state),o=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&o<300){let n=this.getElementAtPosition(r.x,r.y);if(sr(n)&&this.isIframeLikeElementCenter(n,t,r.x,r.y)){this.handleEmbeddableCenterClick(n);return}}if(this.device.isTouchScreen){let n=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,n)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?o<300&&sr(this.hitLinkElement)&&!nb(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,[r.x,r.y])?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})};maybeOpenContextMenuAfterPointerDownOnTouchDevices=t=>{t.pointerType==="touch"&&(cm=!1,Ta?cm=!0:Ta=window.setTimeout(()=>{Ta=0,cm||this.handleCanvasContextMenu(t)},a0))};resetContextMenuTimer=()=>{clearTimeout(Ta),Ta=0,cm=!1};maybeCleanupAfterMissingPointerUp=t=>{dm?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()};handleCanvasPanUsingWheelOrSpaceDrag=t=>{if(!(Ve.pointers.size<=1&&(t.button===Ni.WHEEL||t.button===Ni.MAIN&&Ms||qo(this.state)||this.state.viewModeEnabled))||H(this.state.editingElement))return!1;lm=!0,t.preventDefault();let r=!1,o=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Ze(this.interactiveCanvas,Be.GRABBING);let{clientX:n,clientY:i}=t,a=uh(l=>{let c=n-l.clientX,d=i-l.clientY;if(n=l.clientX,i=l.clientY,o&&!r&&(Math.abs(c)>1||Math.abs(d)>1)){r=!0;let m=u=>{document.body.removeEventListener("paste",m),u.stopPropagation()},p=()=>{setTimeout(()=>{document.body.removeEventListener("paste",m),window.removeEventListener("pointerup",p)},100)};document.body.addEventListener("paste",m),window.addEventListener("pointerup",p)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=bt(dm=()=>{dm=null,lm=!1,Ms||(this.state.viewModeEnabled?Ze(this.interactiveCanvas,Be.GRAB):po(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),a.flush()});return window.addEventListener("blur",s),window.addEventListener("pointermove",a,{passive:!0}),window.addEventListener("pointerup",s),!0};updateGestureOnPointerDown(t){Ve.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),Ve.pointers.size===2&&(Ve.lastCenter=v1(Ve.pointers),Ve.initialScale=this.state.zoom.value,Ve.initialDistance=T1(Array.from(Ve.pointers.values())))}initialPointerDownState(t){let r=Qe(t,this.state),o=this.scene.getSelectedElements(this.state),[n,i,a,s]=Te(o),l=o.findIndex(de)===0;return{origin:r,withCmdOrCtrl:t[S.CTRL_OR_CMD],originInGrid:ar(Ot(r.x,r.y,t[S.CTRL_OR_CMD]||l?null:this.state.gridSize)),scrollbars:C1(fx,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((c,d)=>(c.set(d.id,an(d)),c),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+n)/2,y:(s+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,o)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;hx=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let o=uh(i=>{i.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(i,r)}),n=bt(()=>{dm=null,hx=!1,po(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",n),o.flush()});return dm=n,window.addEventListener("pointermove",o),window.addEventListener("pointerup",n),!0}clearSelectionIfNotUsingSelection=()=>{this.state.activeTool.type!=="selection"&&this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})};handleSelectionOnPointerDown=(t,r)=>{if(this.state.activeTool.type==="selection"){let o=this.scene.getNonDeletedElements(),n=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.editingLinearElement&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let a=Ru(o,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);a!=null&&(this.setState({resizingElement:a.element}),r.resize.handleType=a.transformHandleType)}else i.length>1&&(r.resize.handleType=Nu(Te(i),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=ar(Wb(r.resize.handleType,i,n,r.origin.x,r.origin.y)),i.length===1&&ie(i[0])&&i[0].points.length===2&&(r.resize.arrowDirection=Vb(r.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let l=this.state.editingLinearElement||this.state.selectedLinearElement,c=K.handlePointerDown(t,this.state,this.store,r.origin,l,this.scene);if(c.hitElement&&(r.hit.element=c.hitElement),c.linearElementEditor&&(this.setState({selectedLinearElement:c.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:c.linearElementEditor})),c.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=this.getElementsAtPosition(r.origin.x,r.origin.y);let a=r.hit.element,s=r.hit.allHitElements.some(l=>this.isASelectedElement(l));if((a===null||!s)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(a),this.state.editingLinearElement)this.setState({selectedElementIds:Ge({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(a!=null){if(t[S.CTRL_OR_CMD])return this.state.selectedElementIds[a.id]||(r.hit.wasAddedToSelection=!0),this.setState(l=>({...Y0(l,a),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!Ra(a,this.state.editingGroupId)&&this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!s&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(l=>{let c={...l.selectedElementIds,[a.id]:!0},d=[];if(Object.keys(l.selectedElementIds).forEach(m=>{let p=this.scene.getElement(m);p&&d.push(p)}),Q(a))bo(d,a.id).forEach(m=>{delete c[m.id]});else if(a.frameId)c[a.frameId]&&delete c[a.id];else{let m=a.groupIds,p=new Set(m.flatMap(u=>ot(this.scene.getNonDeletedElements(),u)).filter(u=>Q(u)).map(u=>u.id));p.size>0&&d.forEach(u=>{u.frameId&&p.has(u.frameId)&&(delete c[u.id],u.groupIds.flatMap(g=>ot(this.scene.getNonDeletedElements(),g)).forEach(g=>{delete c[g.id]}))})}return{...cr({editingGroupId:l.editingGroupId,selectedElementIds:c},this.scene.getNonDeletedElements(),l,this),showHyperlinkPopup:a.link||Rt(a)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1};isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let o=this.getElementHitThreshold(),[n,i,a,s]=Te(r);return t.x>n-o&&t.x<a+o&&t.y>i-o&&t.y<s+o}handleTextOnPointerDown=(t,r)=>{if(H(this.state.editingElement))return;let o=r.origin.x,n=r.origin.y,i=this.getElementAtPosition(o,n,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(o,n);Ct(i)&&(a=i,o=i.x+i.width/2,n=i.y+i.height/2),this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:a,autoEdit:!1}),mo(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:nt(this.state,{type:"selection"})})};handleFreeDrawElementOnPointerDown=(t,r,o)=>{let[n,i]=Ot(o.origin.x,o.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),s=B2({type:r,x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:t.pressure===.5,locked:!1,frameId:a?a.id:null});this.setState(d=>{let m={...d.selectedElementIds};return delete m[s.id],{selectedElementIds:Ge(m,d)}});let l=s.simulatePressure?s.pressures:[...s.pressures,t.pressure];F(s,{points:[[0,0]],pressures:l});let c=xr(o.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.scene.insertElement(s),this.setState({draggingElement:s,editingElement:s,startBoundElement:c,suggestedBindings:[]})};insertIframeElement=({sceneX:t,sceneY:r,width:o,height:n})=>{let[i,a]=Ot(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),s=O2({type:"iframe",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:o,height:n});return this.scene.insertElement(s),s};insertEmbeddableElement=({sceneX:t,sceneY:r,link:o})=>{let[n,i]=Ot(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=xi(o);if(!a)return;a.error instanceof URIError&&this.setToast({message:E("toast.unrecognizedLinkFormat"),closable:!0});let s=Cf({type:"embeddable",x:n,y:i,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:o});return this.scene.insertElement(s),s};createImageElement=({sceneX:t,sceneY:r,addToFrameUnderCursor:o=!0})=>{let[n,i]=Ot(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=o?this.getTopLayerFrameAtSceneCoords({x:n,y:i}):null;return Wc({type:"image",x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null})};handleLinearElementOnPointerDown=(t,r,o)=>{if(this.state.multiElement){let{multiElement:n}=this.state;if(n.type==="line"&&Dr(n.points,this.state.zoom.value)){F(n,{lastCommittedPoint:n.points[n.points.length-1]}),this.actionManager.executeAction(xo);return}if(de(n)&&n.points.length>1){F(n,{lastCommittedPoint:n.points[n.points.length-1]}),this.actionManager.executeAction(xo);return}let{x:i,y:a,lastCommittedPoint:s}=n;if(n.points.length>1&&s&&Pt(o.origin.x-i,o.origin.y-a,s[0],s[1])<Ns){this.actionManager.executeAction(xo);return}this.setState(l=>({selectedElementIds:Ge({...l.selectedElementIds,[n.id]:!0},l)})),F(n,{lastCommittedPoint:n.points[n.points.length-1]}),Ze(this.interactiveCanvas,Be.POINTER)}else{let[n,i]=Ot(o.origin.x,o.origin.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),{currentItemStartArrowhead:s,currentItemEndArrowhead:l}=this.state,[c,d]=r==="arrow"?[s,l]:[null,null],m=r==="arrow"?Gc({type:r,x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===_t.round?{type:ct.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===_t.elbow}):nn({type:r,x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:ct.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null});this.setState(u=>{let g={...u.selectedElementIds};return delete g[m.id],{selectedElementIds:Ge(g,u)}}),F(m,{points:[...m.points,[0,0]]});let p=xr(o.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),de(m));this.scene.insertElement(m),this.setState({draggingElement:m,editingElement:m,startBoundElement:p,suggestedBindings:[]})}};getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:kn(t)?ct.ADAPTIVE_RADIUS:ct.PROPORTIONAL_RADIUS}:null}createGenericElementOnPointerDown=(t,r)=>{let[o,n]=Ot(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i=this.getTopLayerFrameAtSceneCoords({x:o,y:n}),a={x:o,y:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:i?i.id:null},s;t==="embeddable"?s=Cf({type:"embeddable",...a}):s=go({type:t,...a}),s.type==="selection"?this.setState({selectionElement:s,draggingElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,draggingElement:s,editingElement:s}))};createFrameElementOnPointerDown=(t,r)=>{let[o,n]=Ot(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i={x:o,y:n,opacity:this.state.currentItemOpacity,locked:!1,...rt},a=r===It.magicframe?Uc(i):Cp(i);this.scene.insertElement(a),this.setState({multiElement:null,draggingElement:a,editingElement:a})};maybeCacheReferenceSnapPoints(t,r,o=!1){_i({event:t,appState:this.state,selectedElements:r})&&(o||!zo.getReferenceSnapPoints())&&zo.setReferenceSnapPoints(Q5(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,o=!1){_i({event:t,appState:this.state,selectedElements:r})&&(o||!zo.getVisibleGaps())&&zo.setVisibleGaps(J5(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return bt(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return bt(r=>{r.key===S.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return uh(r=>{if(t.drag.offset===null&&(t.drag.offset=ar(Xb(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;let n=Qe(r,this.state);if($r(this.state)){this.handleEraser(r,t,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[i,a]=Ot(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize);if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Pt(n.x,n.y,t.origin.x,t.origin.y)<ri)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleResize(t,r)))return!0;let s=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let m=this.state.editingLinearElement||this.state.selectedLinearElement;if(K.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,s)){let u=K.addMidpoint(this.state.selectedLinearElement,n,this.state,!r[S.CTRL_OR_CMD],s);if(!u)return;ux(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}})});return}else if(m.pointerDownState.segmentMidpoint.value!==null&&!m.pointerDownState.segmentMidpoint.added)return;if(K.handlePointDragging(r,this.state,n.x,n.y,(u,g)=>{this.maybeSuggestBindingsForLinearElementAtCoords(u,g)},m,this.scene)){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging&&this.setState({editingLinearElement:{...this.state.editingLinearElement,isDragging:!0}}),this.state.selectedLinearElement.isDragging||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0}});return}}let l=t.hit.allHitElements.some(m=>this.isASelectedElement(m)),c=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((l||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c){let m=this.scene.getSelectedElements(this.state);if(m.every(g=>g.locked))return;let p=m.find(g=>Q(g)),u=this.getTopLayerFrameAtSceneCoords(n);if(this.setState({frameToHighlight:u&&!p?u:null}),t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0}),m.length>0&&!t.withCmdOrCtrl&&!this.state.editingElement&&this.state.activeEmbeddable?.state!=="active"){let g={x:n.x-t.origin.x,y:n.y-t.origin.y},h=[...t.originalElements.values()],x=r.shiftKey;if(x){let w=Math.abs(g.x),C=Math.abs(g.y),M=x&&w<C,I=x&&w>C;M&&(g.x=0),I&&(g.y=0)}this.maybeCacheVisibleGaps(r,m),this.maybeCacheReferenceSnapPoints(r,m);let{snapOffset:v,snapLines:y}=eA(h,g,this.state,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:y}),!this.state.editingFrame&&Yb(t,m,g,this.scene,v,r[S.CTRL_OR_CMD]?null:this.state.gridSize),(m.length!==1||!de(m[0]))&&this.setState({suggestedBindings:Gp(m,this.scene.getNonDeletedElementsMap())}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let w=[],C=[],M=new Map,I=new Map,P=t.hit.element,A=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(D=>D.id)),N=this.scene.getElementsIncludingDeleted();for(let D of N)if(A.has(D.id)||D.id===P?.id&&t.hit.wasAddedToSelection){let z=Vc(this.state.editingGroupId,M,D),R=t.originalElements.get(D.id);F(z,{x:R.x,y:R.y}),t.originalElements.set(z.id,z),w.push(z),C.push(D),I.set(D.id,z.id)}else w.push(D);let k=[...w,...C];Jt(k,Z(C)),Mu(w,C,I),Wp(k,C,I,"duplicatesServeAsOld"),fu(k,C,I),this.scene.replaceAllElements(k),this.maybeCacheVisibleGaps(r,m,!0),this.maybeCacheReferenceSnapPoints(r,m,!0)}return}}let d=this.state.draggingElement;if(d){if(d.type==="freedraw"){let m=d.points,p=n.x-d.x,u=n.y-d.y,g=m.length>0&&m[m.length-1];if(!(g&&g[0]===p&&g[1]===u)){let x=d.simulatePressure?d.pressures:[...d.pressures,r.pressure];F(d,{points:[...m,[p,u]],pressures:x})}}else if(ie(d)){t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0});let m=d.points,p=i-d.x,u=a-d.y;Za(r)&&m.length===2&&({width:p,height:u}=Pl(d.x,d.y,n.x,n.y)),m.length===1?F(d,{points:[...m,[p,u]]}):m.length>1&&de(d)?_o(d,this.scene,[...m.slice(0,-1),[p,u]],[0,0],void 0,{isDragging:!0}):m.length===2&&F(d,{points:[...m.slice(0,-1),[p,u]]}),Kr(d,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(d,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r);if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let m=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)K.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let p=!0;!r.shiftKey&&qe(m,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>cr({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):p=!1);let u=Sl(m,d,this.scene.getNonDeletedElementsMap());this.setState(g=>{let h={...p&&g.selectedElementIds,...u.reduce((x,v)=>(x[v.id]=!0,x),{})};return t.hit.element&&(u.length?delete h[t.hit.element.id]:h[t.hit.element.id]=!0),g=p?g:{...g,selectedGroupIds:{},editingGroupId:null},{...cr({editingGroupId:g.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:u.length===1&&ie(u[0])?new K(u[0]):null,showHyperlinkPopup:u.length===1&&(u[0].link||Rt(u[0]))?"info":!1}})}}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let o=t.clientX,n=o-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-n/this.state.zoom.value}),r.lastCoords.x=o,!0}if(r.scrollbars.isOverVertical){let o=t.clientY,n=o-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-n/this.state.zoom.value}),r.lastCoords.y=o,!0}return!1}onPointerUpFromPointerDownHandler(t){return bt(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{draggingElement:o,resizingElement:n,multiElement:i,activeTool:a,isResizing:s,isRotating:l}=this.state;this.setState(u=>({isResizing:!1,isRotating:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",editingElement:i||H(this.state.editingElement)?this.state.editingElement:null,snapLines:Bm(u.snapLines,[]),originSnapOffset:null})),zo.setReferenceSnapPoints(null),zo.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let c=this.scene.getNonDeletedElementsMap();if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(xo);else{let u=K.handlePointerUp(r,this.state.editingLinearElement,this.state,this.scene);u!==this.state.editingLinearElement&&this.setState({editingLinearElement:u,suggestedBindings:[]})}else if(this.state.selectedLinearElement)if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let u=K.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:g,endBindingElement:h}=u,x=this.scene.getElement(u.elementId);Kr(x)&&Qa(x,g,h,c,this.scene),u!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(a,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),o?.type==="freedraw"){let u=Qe(r,this.state),g=o.points,h=u.x-o.x,x=u.y-o.y;h===g[0][0]&&x===g[0][1]&&(x+=1e-4,h+=1e-4);let v=o.simulatePressure?[]:[...o.pressures,r.pressure];F(o,{points:[...g,[h,x]],pressures:v,lastCommittedPoint:[h,x]}),this.actionManager.executeAction(xo);return}if(So(o)){let u=o;try{this.initializeImageDimensions(u),this.setState({selectedElementIds:Ge({[u.id]:!0},this.state)},()=>{this.actionManager.executeAction(xo)})}catch(g){console.error(g),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(h=>h.id!==u.id)),this.actionManager.executeAction(xo)}return}if(ie(o)){o.points.length>1&&this.store.shouldCaptureIncrement();let u=Qe(r,this.state);!t.drag.hasOccurred&&o&&!i?(F(o,{points:[...o.points,[u.x-o.x,u.y-o.y]]}),this.setState({multiElement:o,editingElement:this.state.draggingElement})):t.drag.hasOccurred&&!i&&(Fn(this.state)&&Kr(o,!1)&&Jc(o,this.state,u,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.setState({suggestedBindings:[],startBoundElement:null}),a.locked?this.setState(g=>({draggingElement:null})):(mo(this.interactiveCanvas),this.setState(g=>({draggingElement:null,activeTool:nt(this.state,{type:"selection"}),selectedElementIds:Ge({...g.selectedElementIds,[o.id]:!0},g),selectedLinearElement:new K(o)}))));return}if(H(o)){let u=Rl(Me({fontSize:o.fontSize,fontFamily:o.fontFamily}),o.lineHeight);o.width<u&&F(o,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(o,{isExistingElement:!0})}if(a.type!=="selection"&&o&&Po(o)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(u=>u.id!==o.id),appState:{draggingElement:null},storeAction:_.UPDATE});return}if(o){if(t.drag.hasOccurred){let u=Qe(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let g=this.scene.getElement(this.state.selectedLinearElement.elementId);if(g?.frameId){let h=Qt(g,c);h&&g&&(Bn(g,h,this.scene.getNonDeletedElementsMap())||(F(g,{groupIds:[]}),Tl([g],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let g=this.getTopLayerFrameAtSceneCoords(u),h=this.scene.getSelectedElements(this.state),x=this.scene.getElementsMapIncludingDeleted(),v=y=>{if(y.length>0){for(let w of y){let C=w.groupIds.indexOf(this.state.editingGroupId);F(w,{groupIds:w.groupIds.slice(0,C)},!1)}x.forEach(w=>{w.groupIds.length&&ot(x,w.groupIds[w.groupIds.length-1]).length<2&&F(w,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(g&&!this.state.selectedElementIds[g.id]){let y=h.filter(w=>w.frameId!==g.id&&ts(w,x,this.state));this.state.editingGroupId&&v(y),x=hd(x,y,g)}else if(!g&&this.state.editingGroupId){let y=h.filter(w=>w.frameId&&!ts(w,x,this.state));v(y)}x=zn(x,this.state,this),this.scene.replaceAllElements(x)}}if(Q(o)){let u=vT(this.scene.getElementsIncludingDeleted(),o,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(hd(this.scene.getElementsMapIncludingDeleted(),u,o))}F(o,Fc(o))}if(n&&this.store.shouldCaptureIncrement(),n&&Po(n)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(u=>u.id!==n.id),storeAction:_.UPDATE}),t.resize.isResizing){let u=zn(this.scene.getElementsIncludingDeleted(),this.state,this),g=this.scene.getSelectedElements(this.state).filter(h=>Q(h));for(let h of g)u=bu(u,vl(this.scene.getElementsIncludingDeleted(),h,this.state,c),h,this);this.scene.replaceAllElements(u)}let d=t.hit.element;this.state.selectedLinearElement?.elementId!==d?.id&&ie(d)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new K(d)});let m=this.lastPointerDownEvent,p=this.lastPointerUpEvent||this.lastPointerMoveEvent;if($r(this.state)&&m&&p){if(this.eraserTrail.endPath(),Pt(m.clientX,m.clientY,p.clientX,p.clientY)===0){let g=Qe({clientX:p.clientX,clientY:p.clientY},this.state);this.getElementsAtPosition(g.x,g.y).forEach(x=>this.elementsPendingErasure.add(x.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(d&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[d.id]?Wm(this.state,d)?this.setState(u=>{let g={...u.selectedElementIds};for(let h of d.groupIds.flatMap(x=>ot(this.scene.getNonDeletedElements(),x)))delete g[h.id];return{selectedGroupIds:{...u.selectedElementIds,...d.groupIds.map(h=>({[h]:!1})).reduce((h,x)=>({...h,...x}),{})},selectedElementIds:Ge(g,u)}}):this.state.selectedLinearElement?.isDragging||this.setState(u=>{let g={...u.selectedElementIds};delete g[d.id];let h=he(this.scene.getNonDeletedElements(),{selectedElementIds:g});return{...cr({editingGroupId:u.editingGroupId,selectedElementIds:g},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:h.length===1&&ie(h[0])?new K(h[0]):u.selectedLinearElement}}):d.frameId&&this.state.selectedElementIds[d.frameId]?this.setState(u=>{let g={...u.selectedElementIds,[d.id]:!0};return delete g[d.frameId],(this.scene.getElement(d.frameId)?.groupIds??[]).flatMap(h=>ot(this.scene.getNonDeletedElements(),h)).forEach(h=>{delete g[h.id]}),{...cr({editingGroupId:u.editingGroupId,selectedElementIds:g},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:d.link||Rt(d)?"info":!1}}):this.setState(u=>({selectedElementIds:Ge({...u.selectedElementIds,[d.id]:!0},u)})):this.setState(u=>({...cr({editingGroupId:u.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:ie(d)&&u.selectedLinearElement?.elementId!==d.id?new K(d):u.selectedLinearElement}))),!t.drag.hasOccurred&&!this.state.isResizing&&(d&&bv({x:t.origin.x,y:t.origin.y,element:d,shape:cn(d,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:Q(d)?this.frameNameBoundsCache.get(d):null},c)||!d&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Ze(this.interactiveCanvas,Be.AUTO);return}if(!a.locked&&a.type!=="freedraw"&&o&&o.type!=="selection"&&this.setState(u=>({selectedElementIds:Ge({...u.selectedElementIds,[o.id]:!0},u),showHyperlinkPopup:Rt(o)&&!o.link?"editor":u.showHyperlinkPopup})),(a.type!=="selection"||qe(this.scene.getNonDeletedElements(),this.state)||!it(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),t.drag.hasOccurred||s||l){let u=this.scene.getSelectedElements(this.state).filter(ie);es(u,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Fn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[])}if(a.type==="laser"){this.laserTrails.endPath();return}!a.locked&&a.type!=="freedraw"?(mo(this.interactiveCanvas),this.setState({draggingElement:null,suggestedBindings:[],activeTool:nt(this.state,{type:"selection"})})):this.setState({draggingElement:null,suggestedBindings:[]}),d&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&Ve.pointers.size<=1&&sr(d)&&this.isIframeLikeElementCenter(d,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(d)})}restoreReadyToEraseElements=()=>{this.elementsPendingErasure=new Set,this.triggerRender()};eraseElements=()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(o=>this.elementsPendingErasure.has(o.id)||o.frameId&&this.elementsPendingErasure.has(o.frameId)||ze(o)&&this.elementsPendingErasure.has(o.containerId)?(t=!0,pe(o,{isDeleted:!0})):o);this.elementsPendingErasure=new Set,t&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(r))};initializeImage=async({imageFile:t,imageElement:r,showCursorImagePreview:o=!1})=>{if(!$i(t))throw new Error(E("errors.unsupportedFileType"));let n=t.type;if(Ze(this.interactiveCanvas,"wait"),n===se.svg)try{t=If(await Wv(await t.text()),t.name)}catch(c){throw console.warn(c),new Error(E("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(t)||n2(t));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(E("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{t=await zc(t,{maxWidthOrHeight:g0})}catch(c){console.error("Error trying to resizing image file on insertion",c)}if(t.size>_h)throw new Error(E("errors.fileTooBig",{maxSize:`${Math.trunc(_h/1024/1024)}MB`}))}if(o){let c=this.files[i]?.dataURL,d=c&&i2(c);this.setImagePreviewCursor(d||t)}let s=this.files[i]?.dataURL||await wp(t),l=F(r,{fileId:i},!1);return new Promise(async(c,d)=>{try{this.files={...this.files,[i]:{mimeType:n,id:i,dataURL:s,created:Date.now(),lastRetrieved:Date.now()}};let m=this.imageCache.get(i);m||(this.addNewImagesToImageCache(),await this.updateImageCache([l])),m?.image instanceof Promise&&await m.image,this.state.pendingImageElementId!==l.id&&this.state.draggingElement?.id!==l.id&&this.initializeImageDimensions(l,!0),c(l)}catch(m){console.error(m),d(new Error(E("errors.imageInsertError")))}finally{o||mo(this.interactiveCanvas)}})};insertImageElement=async(t,r,o)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:E("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:o})}catch(n){return F(t,{isDeleted:!0}),this.actionManager.executeAction(xo),this.setState({errorMessage:n.message||E("errors.imageInsertError")}),null}};setImagePreviewCursor=async t=>{let o;try{o=await zc(t,{maxWidthOrHeight:96})}catch(i){throw i.cause==="UNSUPPORTED"?new Error(E("errors.unsupportedFileType")):i}let n=await wp(o);if(t.type===se.svg){let i=await tb(n),a=Math.min(i.height,96),s=a*(i.width/i.height);s>96&&(s=96,a=s*(i.height/i.width));let l=document.createElement("canvas");l.height=a,l.width=s,l.getContext("2d").drawImage(i,0,0,s,a),n=l.toDataURL(se.svg)}this.state.pendingImageElementId&&Ze(this.interactiveCanvas,`url(${n}) 4 4, auto`)};onImageAction=async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Qe({clientX:r,clientY:o},this.state),a=await js({description:"Image",extensions:Object.keys(xc)}),s=this.createImageElement({sceneX:n,sceneY:i,addToFrameUnderCursor:!1});t?(this.insertImageElement(s,a),this.initializeImageDimensions(s),this.setState({selectedElementIds:Ge({[s.id]:!0},this.state)},()=>{this.actionManager.executeAction(xo)})):this.setState({pendingImageElementId:s.id},()=>{this.insertImageElement(s,a,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,editingElement:null,activeTool:nt(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(xo)})}};initializeImageDimensions=(t,r=!1)=>{let o=kr(t)&&this.imageCache.get(t.fileId)?.image;if(!o||o instanceof Promise){if(t.width<ri/this.state.zoom.value&&t.height<ri/this.state.zoom.value){let n=100/this.state.zoom.value;F(t,{x:t.x-n/2,y:t.y-n/2,width:n,height:n})}return}if(r||t.width<ri/this.state.zoom.value&&t.height<ri/this.state.zoom.value){let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;F(t,{x:l,y:c,width:s,height:a})}};updateImageCache=async(t,r=this.files)=>{let{updatedFiles:o,erroredFiles:n}=await Jp({imageCache:this.imageCache,fileIds:t.map(i=>i.fileId),files:r});if(o.size||n.size)for(let i of t)o.has(i.fileId)&&_e.delete(i);return n.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(i=>kr(i)&&n.has(i.fileId)?pe(i,{status:"error"}):i)),{updatedFiles:o,erroredFiles:n}};addNewImagesToImageCache=async(t=Qp(this.scene.getNonDeletedElements()),r=this.files)=>{let o=t.filter(n=>!n.isDeleted&&!this.imageCache.has(n.fileId));if(o.length){let{updatedFiles:n}=await this.updateImageCache(o,r);n.size&&this.scene.triggerUpdate()}};scheduleImageRefresh=E9(()=>{this.addNewImagesToImageCache()},n0);updateBindingEnabledOnPointerMove=t=>{let r=vv(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})};maybeSuggestBindingAtCursor=t=>{let r=xr(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({suggestedBindings:r!=null?[r]:[]})};maybeSuggestBindingsForLinearElementAtCoords=(t,r,o)=>{if(!r.length)return;let n=r.reduce((i,a)=>{let s=xr(a,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),ne(t)&&de(t));return s!=null&&!Xf(t,o?.id,s)&&i.push(s),i},[]);this.setState({suggestedBindings:n})};clearSelection(t){this.setState(r=>({selectedElementIds:Ge({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&Ra(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Ge({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}handleInteractiveCanvasRef=t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("wheel",this.handleWheel),this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("wheel",this.handleWheel),this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))};handleAppOnDrop=async t=>{let{file:r,fileHandle:o}=await s2(t),{x:n,y:i}=Qe(t,this.state);try{if($i(r)&&this.isToolSupported("image")){if(r?.type===se.png||r?.type===se.svg)try{let l=await Qs(r,this.state,this.scene.getElementsIncludingDeleted(),o);this.syncActionResult({...l,appState:{...l.appState||this.state,isLoading:!1},replaceFiles:!0,storeAction:_.CAPTURE});return}catch(l){if(l.name!=="EncodingError")throw new Error(E("alerts.couldNotLoadInvalidFile"))}let s=this.createImageElement({sceneX:n,sceneY:i});this.insertImageElement(s,r),this.initializeImageDimensions(s),this.setState({selectedElementIds:Ge({[s.id]:!0},this.state)});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let a=t.dataTransfer.getData(se.excalidrawlib);if(a&&typeof a=="string"){try{let s=Tf(a);this.addElementsFromPasteOrLibrary({elements:xg(s),position:t,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(r&&await this.loadFileToCanvas(r,o),t.dataTransfer?.types?.includes("text/plain")){let s=t.dataTransfer?.getData("text");if(s&&hl(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||xi(s)?.type==="video")){let l=this.insertEmbeddableElement({sceneX:n,sceneY:i,link:Pr(s)});l&&this.setState({selectedElementIds:{[l.id]:!0}})}}};loadFileToCanvas=async(t,r)=>{t=await Rc(t);try{let o=this.scene.getElementsIncludingDeleted(),n;try{n=await yp(t,this.state,o,r)}catch(i){let a=i instanceof jo;if(a&&i.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:E("errors.imageToolNotSupported")});return}let s=a?E("alerts.cannotRestoreFromImage"):E("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!n)return;n.type===se.excalidraw?(fr(o.concat(n.data.elements)),this.store.updateSnapshot(Z(o),this.state),this.setState({isLoading:!0}),this.syncActionResult({...n.data,appState:{...n.data.appState||this.state,isLoading:!1},replaceFiles:!0,storeAction:_.CAPTURE})):n.type===se.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(i=>{console.error(i),this.setState({errorMessage:E("errors.importLibraryError")})})}catch(o){this.setState({isLoading:!1,errorMessage:o.message})}};handleCanvasContextMenu=t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Ni.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:o}=Qe(t,this.state),n=this.getElementAtPosition(r,o,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:o},i),s=n||a?"element":"canvas",l=this.excalidrawContainerRef.current,{top:c,left:d}=l.getBoundingClientRect(),m=t.clientX-d,p=t.clientY-c;Ce("contextMenu","openContextMenu",s),this.setState({...n&&!this.state.selectedElementIds[n.id]?{...this.state,...cr({editingGroupId:this.state.editingGroupId,selectedElementIds:{[n.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ie(n)?new K(n):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:p,left:m,items:this.getContextMenuItems(s)}})})};maybeDragNewGenericElement=(t,r)=>{let o=this.state.draggingElement,n=t.lastCoords;if(o)if(o.type==="selection"&&this.state.activeTool.type!=="eraser")Bu(o,this.state.activeTool.type,t.origin.x,t.origin.y,n.x,n.y,Ht(t.origin.x,n.x),Ht(t.origin.y,n.y),cl(r),Lp(r),this.state.zoom.value);else{let[i,a]=Ot(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),s=kr(o)&&this.imageCache.get(o.fileId)?.image,l=s&&!(s instanceof Promise)?s.width/s.height:null;this.maybeCacheReferenceSnapPoints(r,[o]);let{snapOffset:c,snapLines:d}=rA(o,this.state,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:i-t.originInGrid.x,y:a-t.originInGrid.y},this.scene.getNonDeletedElementsMap());i+=c.x,a+=c.y,this.setState({snapLines:d}),Bu(o,this.state.activeTool.type,t.originInGrid.x,t.originInGrid.y,i,a,Ht(t.originInGrid.x,i),Ht(t.originInGrid.y,a),So(o)?!cl(r):cl(r),Lp(r),this.state.zoom.value,l,this.state.originSnapOffset),(this.state.activeTool.type===It.frame||this.state.activeTool.type===It.magicframe)&&this.setState({elementsToHighlight:vl(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap())})}};maybeHandleResize=(t,r)=>{let o=this.scene.getSelectedElements(this.state),n=o.filter(d=>Q(d)),i=t.resize.handleType;if(n.length>0&&i==="rotation")return!1;this.setState({isResizing:i&&i!=="rotation",isRotating:i==="rotation",activeEmbeddable:null});let a=t.lastCoords,[s,l]=Ot(a.x-t.resize.offset.x,a.y-t.resize.offset.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),c=new Map;if(n.forEach(d=>{bo(this.scene.getNonDeletedElements(),d.id).forEach(p=>{c.set(d.id+p.id,{x:p.x-d.x,y:p.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,m]=Ot(a.x,a.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),p={x:d-t.originInGrid.x,y:m-t.originInGrid.y},u=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,o);let{snapOffset:g,snapLines:h}=tA(o,he(u,this.state),this.state,r,p,i);s+=g.x,l+=g.y,this.setState({snapLines:h})}if(Ub(t.originalElements,i,o,this.scene.getElementsMapIncludingDeleted(),Za(r),Lp(r),o.some(d=>So(d))?!cl(r):cl(r),s,l,t.resize.center.x,t.resize.center.y,this.scene)){let d=Gp(o,this.scene.getNonDeletedElementsMap()),m=new Set;return n.forEach(p=>{vl(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>m.add(u))}),this.setState({elementsToHighlight:[...m],suggestedBindings:d}),!0}return!1};getContextMenuItems=t=>{let r=[];return r.push(mg,dg),t==="canvas"?this.state.viewModeEnabled?[...r,ug,$l,ox,Zl]:[HE,Sr,mg,dg,pg,Sr,iE,ZS,Sr,ug,UE,$l,ox,Zl]:(r.push(pg),this.state.viewModeEnabled?[Kl,...r]:[Sr,cg,Kl,HE,X5,K5,Sr,...r,Sr,DE,_E,Sr,RE,AA,GE,WE,US,NE,Sr,FE,Sr,tE,rE,oE,nE,Sr,BE,zE,Sr,E1,Vd,aE,ZE,Sr,_d])};handleWheel=bt(t=>{if(t.preventDefault(),lm)return;let{deltaX:r,deltaY:o}=t;if(t.metaKey||t.ctrlKey){let n=Math.sign(o),i=La*100,a=Math.abs(o),s=o;a>i&&(s=i*n);let l=this.state.zoom.value-s/100;l+=Math.log10(Math.max(1,this.state.zoom.value))*-n*Math.min(1,a/20),this.translateCanvas(c=>({...Ci({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Un(l)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:n,scrollX:i})=>({scrollX:i-(o||r)/n.value}));return}this.translateCanvas(({zoom:n,scrollX:i,scrollY:a})=>({scrollX:i-r/n.value,scrollY:a-o/n.value}))});getTextWysiwygSnappedToCenterPosition(t,r,o,n){if(n){let i=n.x+n.width/2,a=n.y+n.height/2,s=Pu(n,o,this.scene.getNonDeletedElementsMap());if(s&&(i=s.x,a=s.y),Math.hypot(t-i,r-a)<Qx){let{x:d,y:m}=$t({sceneX:i,sceneY:a},o);return{viewportX:d,viewportY:m,elementCenterX:i,elementCenterY:a}}}}savePointer=(t,r,o)=>{if(!t||!r)return;let{x:n,y:i}=Qe({clientX:t,clientY:r},this.state);isNaN(n)||isNaN(i);let a={x:n,y:i,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:a,button:o,pointersMap:Ve.pointers})};resetShouldCacheIgnoreZoomDebounced=ii(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300);updateDOMRect=t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:o,height:n,left:i,top:a}=r.getBoundingClientRect(),{width:s,height:l,offsetTop:c,offsetLeft:d}=this.state;if(o===s&&n===l&&i===d&&a===c){t&&t();return}this.setState({width:o,height:n,offsetLeft:i,offsetTop:a},()=>{t&&t()})}};refresh=()=>{this.setState({...this.getCanvasOffsets()})};getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:o}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:o}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Ds.find(r=>r.code===this.props.langCode)||yn;await hm(t),this.setAppState({})}},x9=()=>{(T.MODE===Kt.TEST||T.DEV)&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(fr(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};x9();var NA=Ex;V();f();var w9=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},OA=w9;Y();import{Provider as F9}from"jotai";f();import v9 from"clsx";import{jsx as FA}from"react/jsx-runtime";var BA=({children:e})=>{let{FooterCenterTunnel:t}=ut(),r=Ue();return FA(t.In,{children:FA("div",{className:v9("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":r.zenModeEnabled}),children:e})})},T9=BA;BA.displayName="FooterCenter";f();f();ee();f();import{jsx as Ia,jsxs as HA}from"react/jsx-runtime";var S9=()=>Ia("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Ia("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"})}),I9=()=>HA("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Ia("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)"}),Ia("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)"}),Ia("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)"}),Ia("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)"})]}),zA=({style:e,size:t="small",withText:r})=>HA("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Ia(S9,{}),r&&Ia(I9,{})]});import{Fragment as WA,jsx as zt,jsxs as Ix}from"react/jsx-runtime";var Cx=({icon:e,shortcut:t,children:r})=>{let o=Ne();return Ix(WA,{children:[zt("div",{className:"welcome-screen-menu-item__icon",children:e}),zt("div",{className:"welcome-screen-menu-item__text",children:r}),t&&!o.editor.isMobile&&zt("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};Cx.displayName="WelcomeScreenMenuItemContent";var mm=({onSelect:e,children:t,icon:r,shortcut:o,className:n="",...i})=>zt("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:zt(Cx,{icon:r,shortcut:o,children:t})});mm.displayName="WelcomeScreenMenuItem";var UA=({children:e,href:t,icon:r,shortcut:o,className:n="",...i})=>zt("a",{...i,className:`welcome-screen-menu-item ${n}`,href:t,target:"_blank",rel:"noreferrer",children:zt(Cx,{icon:r,shortcut:o,children:e})});UA.displayName="WelcomeScreenMenuItemLink";var Go=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=ut();return zt(t.In,{children:zt("div",{className:"welcome-screen-center",children:e||Ix(WA,{children:[zt(Ax,{}),zt(Mx,{children:E("welcomeScreen.defaults.center_heading")}),Ix(kx,{children:[zt(Lx,{}),zt(Px,{})]})]})})})};Go.displayName="Center";var Ax=({children:e})=>zt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||zt(zA,{withText:!0})});Ax.displayName="Logo";var Mx=({children:e})=>zt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Mx.displayName="Heading";var kx=({children:e})=>zt("div",{className:"welcome-screen-menu",children:e});kx.displayName="Menu";var Px=()=>{let e=Xt();return zt(mm,{onSelect:()=>e.executeAction(ws),shortcut:"?",icon:Vs,children:E("helpDialog.title")})};Px.displayName="MenuItemHelp";var Lx=()=>{let e=Ue(),t=Xt();return e.viewModeEnabled?null:zt(mm,{onSelect:()=>t.executeAction(Wl),shortcut:Bt("loadScene"),icon:Ys,children:E("buttons.load")})};Lx.displayName="MenuItemLoadScene";var GA=({onSelect:e})=>{let{t}=Dt();return zt(mm,{shortcut:null,onSelect:e,icon:op,children:t("labels.liveCollaboration")})};GA.displayName="MenuItemLiveCollaborationTrigger";Go.Logo=Ax;Go.Heading=Mx;Go.Menu=kx;Go.MenuItem=mm;Go.MenuItemLink=UA;Go.MenuItemHelp=Px;Go.MenuItemLoadScene=Lx;Go.MenuItemLiveCollaborationTrigger=GA;f();ee();import{jsx as gc,jsxs as Dx}from"react/jsx-runtime";var vh=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=ut();return gc(t.In,{children:Dx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[ay,gc("div",{className:"welcome-screen-decor-hint__label",children:e||E("welcomeScreen.defaults.menuHint")})]})})};vh.displayName="MenuHint";var Th=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=ut();return gc(t.In,{children:Dx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[gc("div",{className:"welcome-screen-decor-hint__label",children:e||E("welcomeScreen.defaults.toolbarHint")}),ly]})})};Th.displayName="ToolbarHint";var Sh=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=ut();return gc(t.In,{children:Dx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[gc("div",{children:e||E("welcomeScreen.defaults.helpHint")}),sy]})})};Sh.displayName="HelpHint";import{Fragment as VA,jsx as pm,jsxs as A9}from"react/jsx-runtime";var Ih=e=>pm(VA,{children:e.children||A9(VA,{children:[pm(Go,{}),pm(vh,{}),pm(Th,{}),pm(Sh,{})]})});Ih.displayName="WelcomeScreen";Ih.Center=Go;Ih.Hints={MenuHint:vh,ToolbarHint:Th,HelpHint:Sh};var C9=Ih;f();ee();import M9 from"clsx";import{jsx as P9,jsxs as L9}from"react/jsx-runtime";var YA=({isCollaborating:e,onSelect:t,...r})=>{let o=Ue(),n=o.width<830;return L9(Yn,{...r,className:M9("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:n?void 0:"auto"},title:E("labels.liveCollaboration"),children:[n?Py:E("labels.share"),o.collaborators.size>0&&P9("div",{className:"CollabButton-collaborators",children:o.collaborators.size})]})},k9=YA;YA.displayName="LiveCollaborationTrigger";we();el();f();Y();ko();V();var D9=(e,t,r)=>!!(t&&(t.id===e.editingElement?.id||t.id===e.resizingElement?.id||t.id===e.draggingElement?.id||t.version>r.version||t.version===r.version&&t.versionNonce<r.versionNonce)),_9=(e,t,r)=>{let o=Z(e),n=[],i=new Set;for(let s of t)if(!i.has(s.id)){let l=o.get(s.id),c=D9(r,l,s);l&&c?(n.push(l),i.add(l.id)):(n.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(n.push(s),i.add(s.id));let a=Xp(n);if(T.DEV||T.MODE===Kt.TEST||window?.DEBUG_FRACTIONAL_INDICES){let s=fr(a.map(l=>({...l})));Td(s,{shouldThrow:T.DEV||T.MODE===Kt.TEST,includeBoundTextValidation:!0,reconciliationContext:{localElements:e,remoteElements:t}})}return fr(a),a};os();mi();qr();li();me();Y();De();Re();V();f();ee();import{jsx as XA,jsxs as R9}from"react/jsx-runtime";var KA=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:r}=ut(),o=Oe();return XA(r.In,{children:R9(Ye.Item,{onSelect:()=>{Ce("ai","dialog open","ttd"),o({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??ww,children:[e??E("labels.textToDiagram"),XA(Ye.Item.Badge,{children:"AI"})]})})};KA.displayName="TTDDialogTrigger";Oa();dt();ub();import{jsx as _x}from"react/jsx-runtime";OA();var B9=e=>{let{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n=!1,onPointerUpdate:i,renderTopRightUI:a,langCode:s=yn.code,viewModeEnabled:l,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:g,onPaste:h,detectScroll:x=!0,handleKeyboardGlobally:v=!1,onLibraryChange:y,autoFocus:w=!1,generateIdForFile:C,onLinkOpen:M,onPointerDown:I,onPointerUp:P,onScrollChange:A,children:N,validateEmbeddable:k,renderEmbeddable:D,aiEnabled:z,showDeprecatedFonts:R}=e,W=e.UIOptions?.canvasActions,q={...e.UIOptions,canvasActions:{...Dh.canvasActions,...W},tools:{image:e.UIOptions?.tools?.image??!0}};return W?.export&&(q.canvasActions.export.saveFileToDisk=W.export?.saveFileToDisk??Dh.canvasActions.export.saveFileToDisk),q.canvasActions.toggleTheme===null&&typeof p>"u"&&(q.canvasActions.toggleTheme=!0),O9(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ge=le=>{typeof le.scale=="number"&&le.scale!==1&&le.preventDefault()};return document.addEventListener("touchmove",ge,{passive:!1}),()=>{document.removeEventListener("touchmove",ge)}},[]),_x(F9,{unstable_createStore:()=>mr,scope:Xe,children:_x(x0,{langCode:s,theme:p,children:_x(NA,{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n,onPointerUpdate:i,renderTopRightUI:a,langCode:s,viewModeEnabled:l,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:g,UIOptions:q,onPaste:h,detectScroll:x,handleKeyboardGlobally:v,onLibraryChange:y,autoFocus:w,generateIdForFile:C,onLinkOpen:M,onPointerDown:I,onPointerUp:P,onScrollChange:A,validateEmbeddable:k,renderEmbeddable:D,aiEnabled:z!==!1,showDeprecatedFonts:R,children:N})})})},z9=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:r,UIOptions:o={},...n}=e,{initialData:i,UIOptions:a={},...s}=t,l=Object.keys(o),c=Object.keys(a);return l.length!==c.length?!1:l.every(m=>m==="canvasActions"?Object.keys(o.canvasActions).every(u=>u==="export"&&o?.canvasActions?.export&&a?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:o?.canvasActions?.[u]===a?.canvasActions?.[u]):o[m]===a[m])&&it(n,s)},H9=N9.memo(B9,z9);H9.displayName="Excalidraw";export{Yn as Button,kh as DEFAULT_LASER_COLOR,Qg as DefaultSidebar,H9 as Excalidraw,Le as FONT_FAMILY,T9 as Footer,k9 as LiveCollaborationTrigger,se as MIME_TYPES,Hr as MainMenu,ct as ROUNDNESS,Li as Sidebar,_ as StoreAction,ue as THEME,j1 as TTDDialog,KA as TTDDialogTrigger,C9 as WelcomeScreen,Ki as bumpVersion,ac as convertToExcalidrawElements,yn as defaultLang,cT as elementPartiallyOverlapsWithOrContainsBBox,pb as elementsOverlappingBBox,gu as exportToBlob,ia as exportToCanvas,vM as exportToClipboard,wl as exportToSvg,Te as getCommonBounds,qp as getFreeDrawSvgPath,Eg as getLibraryItemsHash,Ae as getNonDeletedElements,xk as getSceneVersion,Mb as getVisibleSceneBounds,Kb as hashElementsVersion,$b as hashString,mb as isElementInsideBBox,Po as isInvisiblySmallElement,ie as isLinearElement,Ds as languages,Qs as loadFromBlob,Sf as loadLibraryFromBlob,yp as loadSceneOrLibraryFromBlob,iI as mergeLibraryItems,F as mutateElement,pe as newElementWith,Pr as normalizeLink,JE as parseLibraryTokensFromUrl,_9 as reconcileElements,Xi as restore,Zw as restoreAppState,Nc as restoreElements,Ga as restoreLibraryItems,$t as sceneCoordsToViewportCoords,Vi as serializeAsJSON,hp as serializeLibraryAsJSON,Ne as useDevice,SD as useHandleLibrary,Dt as useI18n,Qe as viewportCoordsToSceneCoords,xS as zoomToFitBounds};
|